diff --git a/.env b/.env new file mode 100644 index 0000000000000000000000000000000000000000..b3149bdd9e10de6b5b4055c2be0ef7ac34220812 --- /dev/null +++ b/.env @@ -0,0 +1,6 @@ +PUBLIC_SUPABASE_URL=https://jjmzipyewddbepnelawf.supabase.co +PUBLIC_SUPABASE_ANON_KEY=sb_publishable_p45xwwJNPMFAzp9K8YQlkA_2oc87I1u + +# TPhimX Cloudflare Worker HLS Proxy URL +# Triển khai worker trong thư mục `cloudflare-worker/` trước rồi dán link vào đây +PUBLIC_CLOUDFLARE_PROXY_URL=https://tphimx-r2-proxy.txagt145.workers.dev diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000000000000000000000000000000000..db80e86382d0d6440fba365a286726d007ec155a --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +*.png filter=lfs diff=lfs merge=lfs -text +*.jpg filter=lfs diff=lfs merge=lfs -text +*.ico filter=lfs diff=lfs merge=lfs -text +*.svg filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..c8ce957490590ae7436f7dff9e7ed5c4cf4cc22d --- /dev/null +++ b/.gitignore @@ -0,0 +1,19 @@ +# Dependencies +node_modules/ + +# Build outputs +dist/ +.astro/ +.vercel/ + +# Logs +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.pnpm-debug.log* + +# System Files +.DS_Store +Thumbs.db + +.vercel diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9eb292f70d57e463372550390d94e5d0d9f6fe52 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM node:18-alpine AS build +WORKDIR /app +COPY package*.json ./ +RUN npm install --legacy-peer-deps +COPY . . +RUN npm run build + +FROM node:18-alpine AS runtime +WORKDIR /app +COPY --from=build /app/dist ./dist +COPY --from=build /app/node_modules ./node_modules +COPY --from=build /app/package.json ./package.json +COPY --from=build /app/public ./public + +ENV HOST=0.0.0.0 +ENV PORT=7860 +EXPOSE 7860 + +CMD ["node", "./dist/server/entry.mjs"] diff --git a/astro.config.mjs b/astro.config.mjs new file mode 100644 index 0000000000000000000000000000000000000000..0dfe1e22fd8a4dc20628980f0c89c29ae467a24c --- /dev/null +++ b/astro.config.mjs @@ -0,0 +1,23 @@ +import { defineConfig } from 'astro/config'; +import react from '@astrojs/react'; +import tailwindcss from '@tailwindcss/vite'; +import sitemap from '@astrojs/sitemap'; +import node from '@astrojs/node'; + +export default defineConfig({ + site: 'https://dongmephim.online', + output: 'server', + adapter: node({ + mode: 'standalone' + }), + integrations: [react(), sitemap()], + vite: { + plugins: [tailwindcss()] + }, + prefetch: true, + image: { + service: { + entrypoint: 'astro/assets/services/sharp' + } + } +}); diff --git a/cloudflare-worker/README.md b/cloudflare-worker/README.md new file mode 100644 index 0000000000000000000000000000000000000000..f0e6ba232f7e1b8972480bf96b93777fad634b77 --- /dev/null +++ b/cloudflare-worker/README.md @@ -0,0 +1,49 @@ +# TPhimX - Cloudflare Worker R2 Auto-Cache CDN & Media Proxy + +Dự án này chứa mã nguồn **Cloudflare Worker** chịu trách nhiệm chạy **Reverse Proxy & Tự động lưu trữ (Cache) luồng phim HLS** vào bộ nhớ Cloudflare R2 bucket của bạn. + +--- + +## ⚡ Các Tính Năng Vượt Trội + +1. **Bỏ qua CORS (CORS Bypass):** Cho phép phát phim trực tiếp từ trình duyệt trên mọi tên miền (`localhost`, `vercel.app`, `Smart TV`, `Mobile App`). +2. **Hỗ trợ tua phim (Range Requests):** Trình phát phim có thể tua (seeking/scrubbing) mượt mà không bị xoay tròn tải lại nhờ hỗ trợ mã phản hồi HTTP `206 Partial Content`. +3. **Tự động Cache vào R2 (Cache Miss / Cache Hit):** + - Khi có người xem phim, Worker sẽ kiểm tra trong Cloudflare R2 bucket (`tphimx-movie`) trước. + - Nếu phim **đã có** (Cache HIT): Worker phát trực tiếp từ R2 cực nhanh và mượt mà, **không tốn băng thông và zero egress fee**. + - Nếu phim **chưa có** (Cache MISS): Worker tải phim từ link gốc (như KKPhim/NguonC), đồng thời lưu file đó vào R2 bucket của bạn ở chế độ nền (background task) và trả về cho người dùng cùng lúc. Lần sau người khác xem sẽ là Cache HIT! +4. **M3U8 Playlist Rewriter:** Tự động phân tích file danh sách phát `.m3u8` và viết lại toàn bộ đường dẫn các phân đoạn `.ts` để chúng tự động đi qua Worker và lưu vào R2 bucket của bạn. + +--- + +## 🚀 Hướng Dẫn Triển Khai (Chỉ 2 Phút) + +Hãy chắc chắn rằng máy tính của bạn đã cài đặt Node.js. Chạy các lệnh sau trong Terminal tại thư mục này: + +### Bước 1: Đăng nhập vào Cloudflare +Bật Terminal và chạy lệnh sau để đăng nhập tài khoản Cloudflare của bạn: +```bash +npx wrangler login +``` +*Trình duyệt sẽ tự động mở ra, bạn chỉ cần bấm **Allow/Xác nhận**.* + +### Bước 2: Triển khai Worker +Chạy lệnh sau để deploy trực tiếp lên hệ thống Cloudflare toàn cầu: +```bash +npx wrangler deploy +``` +*Sau khi hoàn tất, hệ thống sẽ trả về một đường dẫn Worker của bạn, ví dụ:* +`https://tphimx-r2-proxy.tên-tài-khoản.workers.dev` + +--- + +## ⚙️ Cấu Hình Tên Miền / Cập Nhật Ứng Dụng Web + +Sau khi đã deploy xong và có link Worker của bạn: + +1. Mở file `.env` của web và cấu hình thêm biến môi trường sau để ứng dụng web tự động nhận diện: + ```env + PUBLIC_CLOUDFLARE_PROXY_URL=https://tphimx-r2-proxy.tên-tài-khoản.workers.dev + ``` + +2. Các trang phát phim như [[slug].astro](file:///c:/Users/TXA3100/Desktop/SRC%20-%20ROPHIm/web/src/pages/xem/%5Bslug%5D.astro) sẽ tự động ưu tiên điều hướng qua Proxy R2 của bạn để phát phim nhanh chóng và tự động lưu trữ lại. diff --git a/cloudflare-worker/index.js b/cloudflare-worker/index.js new file mode 100644 index 0000000000000000000000000000000000000000..7abcd103f7b7b38062fefe9dcf547bfb83cc174a --- /dev/null +++ b/cloudflare-worker/index.js @@ -0,0 +1,274 @@ +/** + * TPhimX - Cloudflare Worker HLS Media Proxy & R2 Auto-Cache CDN + * + * Features: + * 1. CORS Bypass: Attaches Access-Control-Allow-Origin: * to all requests. + * 2. Range Requests: Supports seeking/scrubbing in HLS players (206 Partial Content). + * 3. Dynamic R2 Caching: Checks R2 first. On cache miss, fetches original video segment, + * caches it into R2, and pipes it back to the client. + * 4. Playlist Rewriter: Rewrites .m3u8 relative and absolute URLs to route all subsequent + * .ts media segment requests through this Worker and cache them in R2 automatically. + */ + +export default { + async fetch(request, env, ctx) { + const urlObj = new URL(request.url); + const targetUrlStr = urlObj.searchParams.get('url'); + + if (!targetUrlStr) { + // Direct R2 Path-based Request: e.g. /fbi-part-one/360p/index.m3u8 + const pathname = urlObj.pathname; + if (pathname && pathname !== '/') { + const r2Key = pathname.replace(/^\/+/, ''); // Convert leading slash to relative key + try { + const object = await env.tphimx_movie.get(r2Key); + if (object !== null) { + // Cache HIT - Serve directly from R2 + const headers = new Headers(); + object.writeHttpMetadata(headers); + headers.set('Access-Control-Allow-Origin', '*'); + headers.set('X-TPhimX-Cache', 'HIT (Direct R2 Path)'); + + // Handle Range Requests for seekability + const rangeHeader = request.headers.get('Range'); + if (rangeHeader && object.size > 0) { + const parts = rangeHeader.replace(/bytes=/, "").split("-"); + const start = parseInt(parts[0], 10); + const end = parts[1] ? parseInt(parts[1], 10) : object.size - 1; + + if (start >= 0 && end < object.size && start <= end) { + const slicedObject = await env.tphimx_movie.get(r2Key, { + range: { offset: start, length: end - start + 1 } + }); + + headers.set('Content-Range', `bytes ${start}-${end}/${object.size}`); + headers.set('Content-Length', String(end - start + 1)); + + return new Response(slicedObject.body, { + status: 206, + headers + }); + } + } + + return new Response(object.body, { + status: 200, + headers + }); + } else { + return new Response('File not found in R2 bucket', { + status: 404, + headers: { 'Access-Control-Allow-Origin': '*' } + }); + } + } catch (err) { + return new Response(`R2 Path Error: ${err.message}`, { + status: 500, + headers: { 'Access-Control-Allow-Origin': '*' } + }); + } + } + + return new Response(JSON.stringify({ + error: 'Missing "url" search parameter.', + usage: `${urlObj.origin}/?url=https://example.com/stream.m3u8` + }), { + status: 400, + headers: { + 'Content-Type': 'application/json', + 'Access-Control-Allow-Origin': '*' + } + }); + } + + // Handle OPTIONS Preflight request + if (request.method === 'OPTIONS') { + return new Response(null, { + status: 204, + headers: { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Methods': 'GET, HEAD, OPTIONS', + 'Access-Control-Allow-Headers': '*', + 'Access-Control-Max-Age': '86400' + } + }); + } + + let targetUrl; + try { + targetUrl = new URL(targetUrlStr); + } catch (e) { + return new Response('Invalid target URL format', { status: 400, headers: { 'Access-Control-Allow-Origin': '*' } }); + } + + // Generate unique storage key for Cloudflare R2 + // Scheme: cache// + const cleanPath = targetUrl.pathname.replace(/^\/+/, ''); + const r2Key = `cache/${targetUrl.hostname}/${cleanPath}`; + + // 1. Check if file already exists in Cloudflare R2 bucket + try { + const object = await env.tphimx_movie.get(r2Key); + if (object !== null) { + // Cache HIT - Serve directly from R2 + const headers = new Headers(); + object.writeHttpMetadata(headers); + headers.set('Access-Control-Allow-Origin', '*'); + headers.set('X-TPhimX-Cache', 'HIT (Cloudflare R2)'); + + // Handle Range Requests for seekability + const rangeHeader = request.headers.get('Range'); + if (rangeHeader && object.size > 0) { + const parts = rangeHeader.replace(/bytes=/, "").split("-"); + const start = parseInt(parts[0], 10); + const end = parts[1] ? parseInt(parts[1], 10) : object.size - 1; + + if (start >= 0 && end < object.size && start <= end) { + // Slice the R2 object + const slicedObject = await env.tphimx_movie.get(r2Key, { + range: { offset: start, length: end - start + 1 } + }); + + headers.set('Content-Range', `bytes ${start}-${end}/${object.size}`); + headers.set('Content-Length', String(end - start + 1)); + + return new Response(slicedObject.body, { + status: 206, + headers + }); + } + } + + return new Response(object.body, { + status: 200, + headers + }); + } + } catch (err) { + // Log error but fallback to fetching from source to prevent playback interruption + console.error('R2 read error:', err.message); + } + + // Cache MISS - Fetch from original media source server + try { + // Forward request headers like Range + const fetchHeaders = new Headers(); + + // Bypass anti-hotlinking/Referer checks of media providers (e.g. s2.phim1280.tv) + const targetOrigin = targetUrl.origin; + fetchHeaders.set('Referer', targetOrigin + '/'); + fetchHeaders.set('Origin', targetOrigin); + fetchHeaders.set('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'); + + const range = request.headers.get('Range'); + if (range) fetchHeaders.set('Range', range); + + const response = await fetch(targetUrlStr, { + headers: fetchHeaders + }); + + if (!response.ok && response.status !== 206) { + const responseText = await response.text().catch(() => ''); + return new Response(JSON.stringify({ + error: `Failed to fetch original media source (HTTP ${response.status})`, + targetUrl: targetUrlStr, + sentHeaders: Object.fromEntries(fetchHeaders.entries()), + responseHeaders: Object.fromEntries(response.headers.entries()), + responseBody: responseText.substring(0, 500) + }), { + status: response.status, + headers: { + 'Content-Type': 'application/json', + 'Access-Control-Allow-Origin': '*' + } + }); + } + + const contentType = response.headers.get('Content-Type') || ''; + const isM3U8 = targetUrl.pathname.endsWith('.m3u8') || + contentType.includes('mpegurl') || + contentType.includes('application/x-mpegURL'); + + if (isM3U8) { + // Rewrite HLS playlist URLs to route through this Worker Proxy + let playlistText = await response.text(); + const baseTargetUrl = targetUrl.origin + targetUrl.pathname.substring(0, targetUrl.pathname.lastIndexOf('/') + 1); + + const lines = playlistText.split('\n'); + const rewrittenLines = lines.map(line => { + const trimmed = line.trim(); + if (trimmed.length === 0 || trimmed.startsWith('#')) { + return line; + } + + // Resolve absolute URL + let absoluteUrl = trimmed; + if (!trimmed.startsWith('http://') && !trimmed.startsWith('https://')) { + if (trimmed.startsWith('/')) { + absoluteUrl = targetUrl.origin + trimmed; + } else { + absoluteUrl = baseTargetUrl + trimmed; + } + } + + // Rewritten relative segment URL to pipe through the worker + return `${urlObj.origin}/?url=${encodeURIComponent(absoluteUrl)}`; + }); + + const rewrittenPlaylist = rewrittenLines.join('\n'); + const playlistBuffer = new TextEncoder().encode(rewrittenPlaylist); + + // Save the rewritten playlist into Cloudflare R2 bucket + ctx.waitUntil( + env.tphimx_movie.put(r2Key, playlistBuffer, { + httpMetadata: { contentType: 'application/x-mpegURL' } + }).catch(e => console.error('R2 Put Error:', e.message)) + ); + + return new Response(rewrittenPlaylist, { + status: 200, + headers: { + 'Content-Type': 'application/x-mpegURL', + 'Access-Control-Allow-Origin': '*', + 'X-TPhimX-Cache': 'MISS (Rewritten & Cached)' + } + }); + } else { + // Fetch raw binary segment file (.ts) + const segmentData = await response.arrayBuffer(); + + // Save the segment file into Cloudflare R2 bucket asynchronously + ctx.waitUntil( + env.tphimx_movie.put(r2Key, segmentData, { + httpMetadata: { contentType: contentType } + }).catch(e => console.error('R2 Put Error:', e.message)) + ); + + // Build Response + const headers = new Headers(); + headers.set('Content-Type', contentType); + headers.set('Access-Control-Allow-Origin', '*'); + headers.set('X-TPhimX-Cache', 'MISS (Cached Segment)'); + + if (response.status === 206) { + const contentRange = response.headers.get('Content-Range'); + if (contentRange) headers.set('Content-Range', contentRange); + return new Response(segmentData, { + status: 206, + headers + }); + } + + return new Response(segmentData, { + status: 200, + headers + }); + } + } catch (fetchErr) { + return new Response(`Proxy error: ${fetchErr.message}`, { + status: 502, + headers: { 'Access-Control-Allow-Origin': '*' } + }); + } + } +}; diff --git a/cloudflare-worker/wrangler.toml b/cloudflare-worker/wrangler.toml new file mode 100644 index 0000000000000000000000000000000000000000..4ee45df3e74329788de5100489afd43064c4310f --- /dev/null +++ b/cloudflare-worker/wrangler.toml @@ -0,0 +1,9 @@ +name = "tphimx-r2-proxy" +main = "index.js" +compatibility_date = "2024-03-01" + +# Cloudflare R2 Bucket Binding +[[r2_buckets]] +binding = "tphimx_movie" +bucket_name = "tphimx-movie" +preview_bucket_name = "tphimx-movie" diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000000000000000000000000000000000000..e7fca99b65d533eadd5d6dacd901c08a4ba7599e --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6836 @@ +{ + "name": "tphimx", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "tphimx", + "version": "1.0.0", + "dependencies": { + "@astrojs/node": "^10.1.1", + "@astrojs/react": "^5.0.5", + "@astrojs/sitemap": "^3.7.2", + "@astrojs/vercel": "^10.0.7", + "@supabase/supabase-js": "^2.105.4", + "@tailwindcss/vite": "^4.0.0", + "astro": "^6.3.3", + "lucide-react": "^0.460.0", + "nodemailer": "^8.0.7", + "react": "^19.0.0", + "react-dom": "^19.0.0", + "swiper": "^11.2.0", + "tailwindcss": "^4.0.0" + }, + "devDependencies": { + "@types/react": "^19.0.0", + "@types/react-dom": "^19.0.0", + "typescript": "^5.7.0" + } + }, + "node_modules/@astrojs/compiler": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@astrojs/compiler/-/compiler-4.0.0.tgz", + "integrity": "sha512-eouss7G8ygdZqHuke033VMcVw5HTZUu+PXd/h06DGDUg/jt5btPYPqh66ENWw/mU78rBrf/oeC4oqoBwMtDMNA==", + "license": "MIT" + }, + "node_modules/@astrojs/internal-helpers": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/@astrojs/internal-helpers/-/internal-helpers-0.9.1.tgz", + "integrity": "sha512-1pWuARqYom/TzuU3+0ZugsTrKlUydWKuULmDqSMTuonY+9IRDUEGKX/8PXQ1nBxRq3w85uGtd9q9SXfqEldMIQ==", + "license": "MIT", + "dependencies": { + "picomatch": "^4.0.4" + } + }, + "node_modules/@astrojs/markdown-remark": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/@astrojs/markdown-remark/-/markdown-remark-7.1.2.tgz", + "integrity": "sha512-caXZ4Dc2St2dW8luEg22GlP0gupLdztCTQE4EzZOxW1pqWXz9mbeJEuHUkgDYcKWW8tjIHkydYDhWLVoxJ327Q==", + "license": "MIT", + "dependencies": { + "@astrojs/internal-helpers": "0.9.1", + "@astrojs/prism": "4.0.2", + "github-slugger": "^2.0.0", + "hast-util-from-html": "^2.0.3", + "hast-util-to-text": "^4.0.2", + "js-yaml": "^4.1.1", + "mdast-util-definitions": "^6.0.0", + "rehype-raw": "^7.0.0", + "rehype-stringify": "^10.0.1", + "remark-gfm": "^4.0.1", + "remark-parse": "^11.0.0", + "remark-rehype": "^11.1.2", + "remark-smartypants": "^3.0.2", + "retext-smartypants": "^6.2.0", + "shiki": "^4.0.0", + "smol-toml": "^1.6.0", + "unified": "^11.0.5", + "unist-util-remove-position": "^5.0.0", + "unist-util-visit": "^5.1.0", + "unist-util-visit-parents": "^6.0.2", + "vfile": "^6.0.3" + } + }, + "node_modules/@astrojs/node": { + "version": "10.1.1", + "resolved": "https://registry.npmjs.org/@astrojs/node/-/node-10.1.1.tgz", + "integrity": "sha512-kCRbxconkgPpY4vR0GS7exovWEiCbxXLarsp+JeKixyDNf+fKN6v7jXDL8KdQgrzjhy131Kvl+GGGX8jGd8adA==", + "license": "MIT", + "dependencies": { + "@astrojs/internal-helpers": "0.9.1", + "send": "^1.2.1", + "server-destroy": "^1.0.1" + }, + "peerDependencies": { + "astro": "^6.3.0" + } + }, + "node_modules/@astrojs/prism": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@astrojs/prism/-/prism-4.0.2.tgz", + "integrity": "sha512-KTivpmnz6lDsC6o9H4+DNm2SrE/GHzw8cNAvEJwAvUT+eoaEnn/4NtbDNfRRaxaJHdp15gf+tfHAWiXR4wB3BA==", + "license": "MIT", + "dependencies": { + "prismjs": "^1.30.0" + }, + "engines": { + "node": ">=22.12.0" + } + }, + "node_modules/@astrojs/react": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/@astrojs/react/-/react-5.0.5.tgz", + "integrity": "sha512-5jSFDqWqLdEyp7CEVD66A7AQEEuwLkCGR25NJ4FR5EjziZQqZTGc7hJOFZ97qb98BiU6vElrS70R8iI+HhufGQ==", + "license": "MIT", + "dependencies": { + "@astrojs/internal-helpers": "0.9.1", + "@vitejs/plugin-react": "^5.2.0", + "devalue": "^5.6.4", + "ultrahtml": "^1.6.0", + "vite": "^7.3.2" + }, + "engines": { + "node": ">=22.12.0" + }, + "peerDependencies": { + "@types/react": "^17.0.50 || ^18.0.21 || ^19.0.0", + "@types/react-dom": "^17.0.17 || ^18.0.6 || ^19.0.0", + "react": "^17.0.2 || ^18.0.0 || ^19.0.0", + "react-dom": "^17.0.2 || ^18.0.0 || ^19.0.0" + } + }, + "node_modules/@astrojs/sitemap": { + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/@astrojs/sitemap/-/sitemap-3.7.2.tgz", + "integrity": "sha512-PqkzkcZTb5ICiyIR8VoKbIAP/laNRXi5tw616N1Ckk+40oNB8Can1AzVV56lrbC5GKSZFCyJYUVYqVivMisvpA==", + "license": "MIT", + "dependencies": { + "sitemap": "^9.0.0", + "stream-replace-string": "^2.0.0", + "zod": "^4.3.6" + } + }, + "node_modules/@astrojs/telemetry": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/@astrojs/telemetry/-/telemetry-3.3.2.tgz", + "integrity": "sha512-j8DNruA8ors99Al39RYZPJK4DC1bKkoNm93mAMuBhY9TCNC4R8n1q7ovFnJ5qhGh5Lsh7pa1gpQVpYpsJPeTHQ==", + "license": "MIT", + "dependencies": { + "ci-info": "^4.4.0", + "dset": "^3.1.4", + "is-docker": "^4.0.0", + "is-wsl": "^3.1.1", + "which-pm-runs": "^1.1.0" + }, + "engines": { + "node": "18.20.8 || ^20.3.0 || >=22.0.0" + } + }, + "node_modules/@astrojs/vercel": { + "version": "10.0.7", + "resolved": "https://registry.npmjs.org/@astrojs/vercel/-/vercel-10.0.7.tgz", + "integrity": "sha512-g9ruRlog9VEkCU9ERjcY6+4dedAJr0ylBO+9OqJ+wTqx/31xO/5QOl9w2rRsa26EVapmopdG2eZMytF9e3zW1w==", + "license": "MIT", + "dependencies": { + "@astrojs/internal-helpers": "0.9.1", + "@vercel/analytics": "^1.6.1", + "@vercel/functions": "^3.4.3", + "@vercel/nft": "^1.3.2", + "@vercel/routing-utils": "^5.3.3", + "esbuild": "^0.27.3", + "tinyglobby": "^0.2.15" + }, + "peerDependencies": { + "astro": "^6.0.0" + } + }, + "node_modules/@astrojs/vercel/node_modules/@vercel/analytics": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@vercel/analytics/-/analytics-1.6.1.tgz", + "integrity": "sha512-oH9He/bEM+6oKlv3chWuOOcp8Y6fo6/PSro8hEkgCW3pu9/OiCXiUpRUogDh3Fs3LH2sosDrx8CxeOLBEE+afg==", + "license": "MPL-2.0", + "peerDependencies": { + "@remix-run/react": "^2", + "@sveltejs/kit": "^1 || ^2", + "next": ">= 13", + "react": "^18 || ^19 || ^19.0.0-rc", + "svelte": ">= 4", + "vue": "^3", + "vue-router": "^4" + }, + "peerDependenciesMeta": { + "@remix-run/react": { + "optional": true + }, + "@sveltejs/kit": { + "optional": true + }, + "next": { + "optional": true + }, + "react": { + "optional": true + }, + "svelte": { + "optional": true + }, + "vue": { + "optional": true + }, + "vue-router": { + "optional": true + } + } + }, + "node_modules/@babel/code-frame": { + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.0.tgz", + "integrity": "sha512-9NhCeYjq9+3uxgdtp20LSiJXJvN0FeCtNGpJxuMFZ1Kv3cWUNb6DOhJwUvcVCzKGR66cw4njwM6hrJLqgOwbcw==", + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.28.5", + "js-tokens": "^4.0.0", + "picocolors": "^1.1.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/compat-data": { + "version": "7.29.3", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.29.3.tgz", + "integrity": "sha512-LIVqM46zQWZhj17qA8wb4nW/ixr2y1Nw+r1etiAWgRM6U1IqP+LNhL1yg440jYZR72jCWcWbLWzIosH+uP1fqg==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/core": { + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.0.tgz", + "integrity": "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==", + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.0", + "@babel/generator": "^7.29.0", + "@babel/helper-compilation-targets": "^7.28.6", + "@babel/helper-module-transforms": "^7.28.6", + "@babel/helpers": "^7.28.6", + "@babel/parser": "^7.29.0", + "@babel/template": "^7.28.6", + "@babel/traverse": "^7.29.0", + "@babel/types": "^7.29.0", + "@jridgewell/remapping": "^2.3.5", + "convert-source-map": "^2.0.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/core/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/@babel/generator": { + "version": "7.29.1", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.1.tgz", + "integrity": "sha512-qsaF+9Qcm2Qv8SRIMMscAvG4O3lJ0F1GuMo5HR/Bp02LopNgnZBC/EkbevHFeGs4ls/oPz9v+Bsmzbkbe+0dUw==", + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.0", + "@babel/types": "^7.29.0", + "@jridgewell/gen-mapping": "^0.3.12", + "@jridgewell/trace-mapping": "^0.3.28", + "jsesc": "^3.0.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.28.6.tgz", + "integrity": "sha512-JYtls3hqi15fcx5GaSNL7SCTJ2MNmjrkHXg4FSpOA/grxK8KwyZ5bubHsCq8FXCkua6xhuaaBit+3b7+VZRfcA==", + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.28.6", + "@babel/helper-validator-option": "^7.27.1", + "browserslist": "^4.24.0", + "lru-cache": "^5.1.1", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/@babel/helper-globals": { + "version": "7.28.0", + "resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.28.0.tgz", + "integrity": "sha512-+W6cISkXFa1jXsDEdYA8HeevQT/FULhxzR99pxphltZcVaugps53THCeiWA8SguxxpSp3gKPiuYfSWopkLQ4hw==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.28.6.tgz", + "integrity": "sha512-l5XkZK7r7wa9LucGw9LwZyyCUscb4x37JWTPz7swwFE/0FMQAGpiWUZn8u9DzkSBWEcK25jmvubfpw2dnAMdbw==", + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.28.6", + "@babel/types": "^7.28.6" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-transforms": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.28.6.tgz", + "integrity": "sha512-67oXFAYr2cDLDVGLXTEABjdBJZ6drElUSI7WKp70NrpyISso3plG9SAGEF6y7zbha/wOzUByWWTJvEDVNIUGcA==", + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.28.6", + "@babel/helper-validator-identifier": "^7.28.5", + "@babel/traverse": "^7.28.6" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-plugin-utils": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.28.6.tgz", + "integrity": "sha512-S9gzZ/bz83GRysI7gAD4wPT/AI3uCnY+9xn+Mx/KPs2JwHJIz1W8PZkg2cqyt3RNOBM8ejcXhV6y8Og7ly/Dug==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", + "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.28.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz", + "integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-option": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.27.1.tgz", + "integrity": "sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helpers": { + "version": "7.29.2", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.29.2.tgz", + "integrity": "sha512-HoGuUs4sCZNezVEKdVcwqmZN8GoHirLUcLaYVNBK2J0DadGtdcqgr3BCbvH8+XUo4NGjNl3VOtSjEKNzqfFgKw==", + "license": "MIT", + "dependencies": { + "@babel/template": "^7.28.6", + "@babel/types": "^7.29.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.29.3", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.3.tgz", + "integrity": "sha512-b3ctpQwp+PROvU/cttc4OYl4MzfJUWy6FZg+PMXfzmt/+39iHVF0sDfqay8TQM3JA2EUOyKcFZt75jWriQijsA==", + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.0" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/plugin-transform-react-jsx-self": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-self/-/plugin-transform-react-jsx-self-7.27.1.tgz", + "integrity": "sha512-6UzkCs+ejGdZ5mFFC/OCUrv028ab2fp1znZmCZjAOBKiBK2jXD1O+BPSfX8X2qjJ75fZBMSnQn3Rq2mrBJK2mw==", + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-react-jsx-source": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-source/-/plugin-transform-react-jsx-source-7.27.1.tgz", + "integrity": "sha512-zbwoTsBruTeKB9hSq73ha66iFeJHuaFkUbwvqElnygoNbj/jHRsSeokowZFN3CZ64IvEqcmmkVe89OPXc7ldAw==", + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/template": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.28.6.tgz", + "integrity": "sha512-YA6Ma2KsCdGb+WC6UpBVFJGXL58MDA6oyONbjyF/+5sBgxY/dwkhLogbMT2GXXyU84/IhRw/2D1Os1B/giz+BQ==", + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.28.6", + "@babel/parser": "^7.28.6", + "@babel/types": "^7.28.6" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.0.tgz", + "integrity": "sha512-4HPiQr0X7+waHfyXPZpWPfWL/J7dcN1mx9gL6WdQVMbPnF3+ZhSMs8tCxN7oHddJE9fhNE7+lxdnlyemKfJRuA==", + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.0", + "@babel/generator": "^7.29.0", + "@babel/helper-globals": "^7.28.0", + "@babel/parser": "^7.29.0", + "@babel/template": "^7.28.6", + "@babel/types": "^7.29.0", + "debug": "^4.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.0.tgz", + "integrity": "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A==", + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.27.1", + "@babel/helper-validator-identifier": "^7.28.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@capsizecss/unpack": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@capsizecss/unpack/-/unpack-4.0.0.tgz", + "integrity": "sha512-VERIM64vtTP1C4mxQ5thVT9fK0apjPFobqybMtA1UdUujWka24ERHbRHFGmpbbhp73MhV+KSsHQH9C6uOTdEQA==", + "license": "MIT", + "dependencies": { + "fontkitten": "^1.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@clack/core": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@clack/core/-/core-1.3.1.tgz", + "integrity": "sha512-fT1qHVGAag4IEkrupZ6lRRbNCs1vS9P01KB/sG8zKgvUztbYtFBtQpjSITNwooDZ83tpsPzP0mRNs1/KVszCRA==", + "license": "MIT", + "dependencies": { + "fast-wrap-ansi": "^0.2.0", + "sisteransi": "^1.0.5" + }, + "engines": { + "node": ">= 20.12.0" + } + }, + "node_modules/@clack/prompts": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@clack/prompts/-/prompts-1.4.0.tgz", + "integrity": "sha512-S0My7XPGIgpRWMDG8uRqalbgT+a6FmCUdOW+HaIOVVpUPHOb7RrpvjTjiODadKp06fsrVDJZlIzc6yCTp4AnxA==", + "license": "MIT", + "dependencies": { + "@clack/core": "1.3.1", + "fast-string-width": "^3.0.2", + "fast-wrap-ansi": "^0.2.0", + "sisteransi": "^1.0.5" + }, + "engines": { + "node": ">= 20.12.0" + } + }, + "node_modules/@emnapi/runtime": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.10.0.tgz", + "integrity": "sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==", + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.7.tgz", + "integrity": "sha512-EKX3Qwmhz1eMdEJokhALr0YiD0lhQNwDqkPYyPhiSwKrh7/4KRjQc04sZ8db+5DVVnZ1LmbNDI1uAMPEUBnQPg==", + "cpu": [ + "ppc64" + ], + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.7.tgz", + "integrity": "sha512-jbPXvB4Yj2yBV7HUfE2KHe4GJX51QplCN1pGbYjvsyCZbQmies29EoJbkEc+vYuU5o45AfQn37vZlyXy4YJ8RQ==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.7.tgz", + "integrity": "sha512-62dPZHpIXzvChfvfLJow3q5dDtiNMkwiRzPylSCfriLvZeq0a1bWChrGx/BbUbPwOrsWKMn8idSllklzBy+dgQ==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.7.tgz", + "integrity": "sha512-x5VpMODneVDb70PYV2VQOmIUUiBtY3D3mPBG8NxVk5CogneYhkR7MmM3yR/uMdITLrC1ml/NV1rj4bMJuy9MCg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.7.tgz", + "integrity": "sha512-5lckdqeuBPlKUwvoCXIgI2D9/ABmPq3Rdp7IfL70393YgaASt7tbju3Ac+ePVi3KDH6N2RqePfHnXkaDtY9fkw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.7.tgz", + "integrity": "sha512-rYnXrKcXuT7Z+WL5K980jVFdvVKhCHhUwid+dDYQpH+qu+TefcomiMAJpIiC2EM3Rjtq0sO3StMV/+3w3MyyqQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.7.tgz", + "integrity": "sha512-B48PqeCsEgOtzME2GbNM2roU29AMTuOIN91dsMO30t+Ydis3z/3Ngoj5hhnsOSSwNzS+6JppqWsuhTp6E82l2w==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.7.tgz", + "integrity": "sha512-jOBDK5XEjA4m5IJK3bpAQF9/Lelu/Z9ZcdhTRLf4cajlB+8VEhFFRjWgfy3M1O4rO2GQ/b2dLwCUGpiF/eATNQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.7.tgz", + "integrity": "sha512-RkT/YXYBTSULo3+af8Ib0ykH8u2MBh57o7q/DAs3lTJlyVQkgQvlrPTnjIzzRPQyavxtPtfg0EopvDyIt0j1rA==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.7.tgz", + "integrity": "sha512-RZPHBoxXuNnPQO9rvjh5jdkRmVizktkT7TCDkDmQ0W2SwHInKCAV95GRuvdSvA7w4VMwfCjUiPwDi0ZO6Nfe9A==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.7.tgz", + "integrity": "sha512-GA48aKNkyQDbd3KtkplYWT102C5sn/EZTY4XROkxONgruHPU72l+gW+FfF8tf2cFjeHaRbWpOYa/uRBz/Xq1Pg==", + "cpu": [ + "ia32" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.7.tgz", + "integrity": "sha512-a4POruNM2oWsD4WKvBSEKGIiWQF8fZOAsycHOt6JBpZ+JN2n2JH9WAv56SOyu9X5IqAjqSIPTaJkqN8F7XOQ5Q==", + "cpu": [ + "loong64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.7.tgz", + "integrity": "sha512-KabT5I6StirGfIz0FMgl1I+R1H73Gp0ofL9A3nG3i/cYFJzKHhouBV5VWK1CSgKvVaG4q1RNpCTR2LuTVB3fIw==", + "cpu": [ + "mips64el" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.7.tgz", + "integrity": "sha512-gRsL4x6wsGHGRqhtI+ifpN/vpOFTQtnbsupUF5R5YTAg+y/lKelYR1hXbnBdzDjGbMYjVJLJTd2OFmMewAgwlQ==", + "cpu": [ + "ppc64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.7.tgz", + "integrity": "sha512-hL25LbxO1QOngGzu2U5xeXtxXcW+/GvMN3ejANqXkxZ/opySAZMrc+9LY/WyjAan41unrR3YrmtTsUpwT66InQ==", + "cpu": [ + "riscv64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.7.tgz", + "integrity": "sha512-2k8go8Ycu1Kb46vEelhu1vqEP+UeRVj2zY1pSuPdgvbd5ykAw82Lrro28vXUrRmzEsUV0NzCf54yARIK8r0fdw==", + "cpu": [ + "s390x" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.7.tgz", + "integrity": "sha512-hzznmADPt+OmsYzw1EE33ccA+HPdIqiCRq7cQeL1Jlq2gb1+OyWBkMCrYGBJ+sxVzve2ZJEVeePbLM2iEIZSxA==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.7.tgz", + "integrity": "sha512-b6pqtrQdigZBwZxAn1UpazEisvwaIDvdbMbmrly7cDTMFnw/+3lVxxCTGOrkPVnsYIosJJXAsILG9XcQS+Yu6w==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.7.tgz", + "integrity": "sha512-OfatkLojr6U+WN5EDYuoQhtM+1xco+/6FSzJJnuWiUw5eVcicbyK3dq5EeV/QHT1uy6GoDhGbFpprUiHUYggrw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.7.tgz", + "integrity": "sha512-AFuojMQTxAz75Fo8idVcqoQWEHIXFRbOc1TrVcFSgCZtQfSdc1RXgB3tjOn/krRHENUB4j00bfGjyl2mJrU37A==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.7.tgz", + "integrity": "sha512-+A1NJmfM8WNDv5CLVQYJ5PshuRm/4cI6WMZRg1by1GwPIQPCTs1GLEUHwiiQGT5zDdyLiRM/l1G0Pv54gvtKIg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.7.tgz", + "integrity": "sha512-+KrvYb/C8zA9CU/g0sR6w2RBw7IGc5J2BPnc3dYc5VJxHCSF1yNMxTV5LQ7GuKteQXZtspjFbiuW5/dOj7H4Yw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.7.tgz", + "integrity": "sha512-ikktIhFBzQNt/QDyOL580ti9+5mL/YZeUPKU2ivGtGjdTYoqz6jObj6nOMfhASpS4GU4Q/Clh1QtxWAvcYKamA==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.7.tgz", + "integrity": "sha512-7yRhbHvPqSpRUV7Q20VuDwbjW5kIMwTHpptuUzV+AA46kiPze5Z7qgt6CLCK3pWFrHeNfDd1VKgyP4O+ng17CA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.7.tgz", + "integrity": "sha512-SmwKXe6VHIyZYbBLJrhOoCJRB/Z1tckzmgTLfFYOfpMAx63BJEaL9ExI8x7v0oAO3Zh6D/Oi1gVxEYr5oUCFhw==", + "cpu": [ + "ia32" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.7.tgz", + "integrity": "sha512-56hiAJPhwQ1R4i+21FVF7V8kSD5zZTdHcVuRFMW0hn753vVfQN8xlx4uOPT4xoGH0Z/oVATuR82AiqSTDIpaHg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@img/colour": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.1.0.tgz", + "integrity": "sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ==", + "license": "MIT", + "optional": true, + "engines": { + "node": ">=18" + } + }, + "node_modules/@img/sharp-darwin-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.34.5.tgz", + "integrity": "sha512-imtQ3WMJXbMY4fxb/Ndp6HBTNVtWCUI0WdobyheGf5+ad6xX8VIDO8u2xE4qc/fr08CKG/7dDseFtn6M6g/r3w==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-arm64": "1.2.4" + } + }, + "node_modules/@img/sharp-darwin-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.34.5.tgz", + "integrity": "sha512-YNEFAF/4KQ/PeW0N+r+aVVsoIY0/qxxikF2SWdp+NRkmMB7y9LBZAVqQ4yhGCm/H3H270OSykqmQMKLBhBJDEw==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-x64": "1.2.4" + } + }, + "node_modules/@img/sharp-libvips-darwin-arm64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.2.4.tgz", + "integrity": "sha512-zqjjo7RatFfFoP0MkQ51jfuFZBnVE2pRiaydKJ1G/rHZvnsrHAOcQALIi9sA5co5xenQdTugCvtb1cuf78Vf4g==", + "cpu": [ + "arm64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-darwin-x64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.2.4.tgz", + "integrity": "sha512-1IOd5xfVhlGwX+zXv2N93k0yMONvUlANylbJw1eTah8K/Jtpi15KC+WSiaX/nBmbm2HxRM1gZ0nSdjSsrZbGKg==", + "cpu": [ + "x64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.2.4.tgz", + "integrity": "sha512-bFI7xcKFELdiNCVov8e44Ia4u2byA+l3XtsAj+Q8tfCwO6BQ8iDojYdvoPMqsKDkuoOo+X6HZA0s0q11ANMQ8A==", + "cpu": [ + "arm" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.2.4.tgz", + "integrity": "sha512-excjX8DfsIcJ10x1Kzr4RcWe1edC9PquDRRPx3YVCvQv+U5p7Yin2s32ftzikXojb1PIFc/9Mt28/y+iRklkrw==", + "cpu": [ + "arm64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-ppc64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.2.4.tgz", + "integrity": "sha512-FMuvGijLDYG6lW+b/UvyilUWu5Ayu+3r2d1S8notiGCIyYU/76eig1UfMmkZ7vwgOrzKzlQbFSuQfgm7GYUPpA==", + "cpu": [ + "ppc64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-riscv64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.2.4.tgz", + "integrity": "sha512-oVDbcR4zUC0ce82teubSm+x6ETixtKZBh/qbREIOcI3cULzDyb18Sr/Wcyx7NRQeQzOiHTNbZFF1UwPS2scyGA==", + "cpu": [ + "riscv64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-s390x": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.2.4.tgz", + "integrity": "sha512-qmp9VrzgPgMoGZyPvrQHqk02uyjA0/QrTO26Tqk6l4ZV0MPWIW6LTkqOIov+J1yEu7MbFQaDpwdwJKhbJvuRxQ==", + "cpu": [ + "s390x" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-x64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.2.4.tgz", + "integrity": "sha512-tJxiiLsmHc9Ax1bz3oaOYBURTXGIRDODBqhveVHonrHJ9/+k89qbLl0bcJns+e4t4rvaNBxaEZsFtSfAdquPrw==", + "cpu": [ + "x64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-arm64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.2.4.tgz", + "integrity": "sha512-FVQHuwx1IIuNow9QAbYUzJ+En8KcVm9Lk5+uGUQJHaZmMECZmOlix9HnH7n1TRkXMS0pGxIJokIVB9SuqZGGXw==", + "cpu": [ + "arm64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-x64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.2.4.tgz", + "integrity": "sha512-+LpyBk7L44ZIXwz/VYfglaX/okxezESc6UxDSoyo2Ks6Jxc4Y7sGjpgU9s4PMgqgjj1gZCylTieNamqA1MF7Dg==", + "cpu": [ + "x64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-linux-arm": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.34.5.tgz", + "integrity": "sha512-9dLqsvwtg1uuXBGZKsxem9595+ujv0sJ6Vi8wcTANSFpwV/GONat5eCkzQo/1O6zRIkh0m/8+5BjrRr7jDUSZw==", + "cpu": [ + "arm" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.34.5.tgz", + "integrity": "sha512-bKQzaJRY/bkPOXyKx5EVup7qkaojECG6NLYswgktOZjaXecSAeCWiZwwiFf3/Y+O1HrauiE3FVsGxFg8c24rZg==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm64": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-ppc64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.34.5.tgz", + "integrity": "sha512-7zznwNaqW6YtsfrGGDA6BRkISKAAE1Jo0QdpNYXNMHu2+0dTrPflTLNkpc8l7MUP5M16ZJcUvysVWWrMefZquA==", + "cpu": [ + "ppc64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-ppc64": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-riscv64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.34.5.tgz", + "integrity": "sha512-51gJuLPTKa7piYPaVs8GmByo7/U7/7TZOq+cnXJIHZKavIRHAP77e3N2HEl3dgiqdD/w0yUfiJnII77PuDDFdw==", + "cpu": [ + "riscv64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-riscv64": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-s390x": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.34.5.tgz", + "integrity": "sha512-nQtCk0PdKfho3eC5MrbQoigJ2gd1CgddUMkabUj+rBevs8tZ2cULOx46E7oyX+04WGfABgIwmMC0VqieTiR4jg==", + "cpu": [ + "s390x" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-s390x": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.34.5.tgz", + "integrity": "sha512-MEzd8HPKxVxVenwAa+JRPwEC7QFjoPWuS5NZnBt6B3pu7EG2Ge0id1oLHZpPJdn3OQK+BQDiw9zStiHBTJQQQQ==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-x64": "1.2.4" + } + }, + "node_modules/@img/sharp-linuxmusl-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.34.5.tgz", + "integrity": "sha512-fprJR6GtRsMt6Kyfq44IsChVZeGN97gTD331weR1ex1c1rypDEABN6Tm2xa1wE6lYb5DdEnk03NZPqA7Id21yg==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-arm64": "1.2.4" + } + }, + "node_modules/@img/sharp-linuxmusl-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.34.5.tgz", + "integrity": "sha512-Jg8wNT1MUzIvhBFxViqrEhWDGzqymo3sV7z7ZsaWbZNDLXRJZoRGrjulp60YYtV4wfY8VIKcWidjojlLcWrd8Q==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-x64": "1.2.4" + } + }, + "node_modules/@img/sharp-wasm32": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.34.5.tgz", + "integrity": "sha512-OdWTEiVkY2PHwqkbBI8frFxQQFekHaSSkUIJkwzclWZe64O1X4UlUjqqqLaPbUpMOQk6FBu/HtlGXNblIs0huw==", + "cpu": [ + "wasm32" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT", + "optional": true, + "dependencies": { + "@emnapi/runtime": "^1.7.0" + }, + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.34.5.tgz", + "integrity": "sha512-WQ3AgWCWYSb2yt+IG8mnC6Jdk9Whs7O0gxphblsLvdhSpSTtmu69ZG1Gkb6NuvxsNACwiPV6cNSZNzt0KPsw7g==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-ia32": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.34.5.tgz", + "integrity": "sha512-FV9m/7NmeCmSHDD5j4+4pNI8Cp3aW+JvLoXcTUo0IqyjSfAZJ8dIUmijx1qaJsIiU+Hosw6xM5KijAWRJCSgNg==", + "cpu": [ + "ia32" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.34.5.tgz", + "integrity": "sha512-+29YMsqY2/9eFEiW93eqWnuLcWcufowXewwSNIT6UwZdUUCrM3oFjMWH/Z6/TMmb4hlFenmfAVbpWeup2jryCw==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@isaacs/fs-minipass": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@isaacs/fs-minipass/-/fs-minipass-4.0.1.tgz", + "integrity": "sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==", + "license": "ISC", + "dependencies": { + "minipass": "^7.0.4" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/remapping": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", + "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", + "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@mapbox/node-pre-gyp": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-2.0.3.tgz", + "integrity": "sha512-uwPAhccfFJlsfCxMYTwOdVfOz3xqyj8xYL3zJj8f0pb30tLohnnFPhLuqp4/qoEz8sNxe4SESZedcBojRefIzg==", + "license": "BSD-3-Clause", + "dependencies": { + "consola": "^3.2.3", + "detect-libc": "^2.0.0", + "https-proxy-agent": "^7.0.5", + "node-fetch": "^2.6.7", + "nopt": "^8.0.0", + "semver": "^7.5.3", + "tar": "^7.4.0" + }, + "bin": { + "node-pre-gyp": "bin/node-pre-gyp" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@oslojs/encoding": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@oslojs/encoding/-/encoding-1.1.0.tgz", + "integrity": "sha512-70wQhgYmndg4GCPxPPxPGevRKqTIJ2Nh4OkiMWmDAVYsTQ+Ta7Sq+rPevXyXGdzr30/qZBnyOalCszoMxlyldQ==", + "license": "MIT" + }, + "node_modules/@rolldown/pluginutils": { + "version": "1.0.0-rc.3", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-rc.3.tgz", + "integrity": "sha512-eybk3TjzzzV97Dlj5c+XrBFW57eTNhzod66y9HrBlzJ6NsCrWCp/2kaPS3K9wJmurBC0Tdw4yPjXKZqlznim3Q==", + "license": "MIT" + }, + "node_modules/@rollup/pluginutils": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.3.0.tgz", + "integrity": "sha512-5EdhGZtnu3V88ces7s53hhfK5KSASnJZv8Lulpc04cWO3REESroJXg73DFsOmgbU2BhwV0E20bu2IDZb3VKW4Q==", + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^4.0.2" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.60.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.60.4.tgz", + "integrity": "sha512-F5QXMSiFebS9hKZj02XhWLLnRpJ3B3AROP0tWbFBSj+6kCbg5m9j5JoHKd4mmSVy5mS/IMQloYgYxCuJC0fxEQ==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.60.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.60.4.tgz", + "integrity": "sha512-GxxTKApUpzRhof7poWvCJHRF51C67u1R7D6DiluBE8wKU1u5GWE8t+v81JvJYtbawoBFX1hLv5Ei4eVjkWokaw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.60.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.60.4.tgz", + "integrity": "sha512-tua0TaJxMOB1R0V0RS1jFZ/RpURFDJIOR2A6jWwQeawuFyS4gBW+rntLRaQd0EQ4bd6Vp44Z2rXW+YYDBsj6IA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.60.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.60.4.tgz", + "integrity": "sha512-CSKq7MsP+5PFIcydhAiR1K0UhEI1A2jWXVKHPCBZ151yOutENwvnPocgVHkivu2kviURtCEB6zUQw0vs8RrhMg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.60.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.60.4.tgz", + "integrity": "sha512-+O8OkVdyvXMtJEciu2wS/pzm1IxntEEQx3z5TAVy4l32G0etZn+RsA48ARRrFm6Ri8fvqPQfgrvNxSjKAbnd3g==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.60.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.60.4.tgz", + "integrity": "sha512-Iw3oMskH3AfNuhU0MSN7vNbdi4me/NiYo2azqPz/Le16zHSa+3RRmliCMWWQmh4lcndccU40xcJuTYJZxNo/lw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.60.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.60.4.tgz", + "integrity": "sha512-EIPRXTVQpHyF8WOo219AD2yEltPehLTcTMz2fn6JsatLYSzQf00hj3rulF+yauOlF9/FtM2WpkT/hJh/KJFGhA==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.60.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.60.4.tgz", + "integrity": "sha512-J3Yh9PzzF1Ovah2At+lHiGQdsYgArxBbXv/zHfSyaiFQEqvNv7DcW98pCrmdjCZBrqBiKrKKe2V+aaSGWuBe/w==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.60.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.60.4.tgz", + "integrity": "sha512-BFDEZMYfUvLn37ONE1yMBojPxnMlTFsdyNoqncT0qFq1mAfllL+ATMMJd8TeuVMiX84s1KbcxcZbXInmcO2mRg==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.60.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.60.4.tgz", + "integrity": "sha512-pc9EYOSlOgdQ2uPl1o9PF6/kLSgaUosia7gOuS8mB69IxJvlclko1MECXysjs5ryez1/5zjYqx3+xYU0TU6R1A==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.60.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.60.4.tgz", + "integrity": "sha512-NxnomyxYerDh5n4iLrNa+sH+Z+U4BMEE46V2PgQ/hoB909i8gV1M5wPojWg9fk1jWpO3IQnOs20K4wyZuFLEFQ==", + "cpu": [ + "loong64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-musl": { + "version": "4.60.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.60.4.tgz", + "integrity": "sha512-nbJnQ8a3z1mtmrwImCYhc6BGpThAyYVRQxw9uKSKG4wR6aAYno9sVjJ0zaZcW9BPJX1GbrDPf+SvdWjgTuDmnw==", + "cpu": [ + "loong64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.60.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.60.4.tgz", + "integrity": "sha512-2EU6acNrQLd8tYvo/LXW535wupT3m6fo7HKo6lr7ktQoItxTyOL1ZCR/GfGCuXl2vR+zmfI6eRXkSemafv+iVg==", + "cpu": [ + "ppc64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-musl": { + "version": "4.60.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.60.4.tgz", + "integrity": "sha512-WeBtoMuaMxiiIrO2IYP3xs6GMWkJP2C0EoT8beTLkUPmzV1i/UcOSVw1d5r9KBODtHKilG5yFxsGRnBbK3wJ4A==", + "cpu": [ + "ppc64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.60.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.60.4.tgz", + "integrity": "sha512-FJHFfqpKUI3A10WrWKiFbBZ7yVbGT4q4B5o1qKFFojqpaYoh9LrQgqWCmmcxQzVSXYtyB5bzkXrYzlHTs21MYA==", + "cpu": [ + "riscv64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.60.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.60.4.tgz", + "integrity": "sha512-mcEl6CUT5IAUmQf1m9FYSmVqCJlpQ8r8eyftFUHG8i9OhY7BkBXSUdnLH5DOf0wCOjcP9v/QO93zpmF1SptCCw==", + "cpu": [ + "riscv64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.60.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.60.4.tgz", + "integrity": "sha512-ynt3JxVd2w2buzoKDWIyiV1pJW93xlQic1THVLXilz429oijRpSHivZAgp65KBu+cMcgf1eVVjdnTLvPxgCuoQ==", + "cpu": [ + "s390x" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.60.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.60.4.tgz", + "integrity": "sha512-Boiz5+MsaROEWDf+GGEwF8VMHGhlUoQMtIPjOgA5fv4osupqTVnJteQNKJwUcnUog2G55jYXH7KZFFiJe0TEzQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.60.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.60.4.tgz", + "integrity": "sha512-+qfSY27qIrFfI/Hom04KYFw3GKZSGU4lXus51wsb5EuySfFlWRwjkKWoE9emgRw/ukoT4Udsj4W/+xxG8VbPKg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-openbsd-x64": { + "version": "4.60.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.60.4.tgz", + "integrity": "sha512-VpTfOPHgVXEBeeR8hZ2O0F3aSso+JDWqTWmTmzcQKted54IAdUVbxE+j/MVxUsKa8L20HJhv3vUezVPoquqWjA==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.60.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.60.4.tgz", + "integrity": "sha512-IPOsh5aRYuLv/nkU51X10Bf75Bsf6+gZdx1X+QP5QM6lIJFHHqbHLG0uJn/hWthzo13UAc2umiUorqZy3axoZg==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.60.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.60.4.tgz", + "integrity": "sha512-4QzE9E81OohJ/HKzHhsqU+zcYYojVOXlFMs1DdyMT6qXl/niOH7AVElmmEdUNHHS/oRkc++d5k6Vy85zFs0DEw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.60.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.60.4.tgz", + "integrity": "sha512-zTPgT1YuHHcd+Tmx7h8aml0FWFVelV5N54oHow9SLj+GfoDy/huQ+UV396N/C7KpMDMiPspRktzM1/0r1usYEA==", + "cpu": [ + "ia32" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.60.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.60.4.tgz", + "integrity": "sha512-DRS4G7mi9lJxqEDezIkKCaUIKCrLUUDCUaCsTPCi/rtqaC6D/jjwslMQyiDU50Ka0JKpeXeRBFBAXwArY52vBw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.60.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.60.4.tgz", + "integrity": "sha512-QVTUovf40zgTqlFVrKA1uXMVvU2QWEFWfAH8Wdc48IxLvrJMQVMBRjuQyUpzZCDkakImib9eVazbWlC6ksWtJw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@shikijs/core": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-4.0.2.tgz", + "integrity": "sha512-hxT0YF4ExEqB8G/qFdtJvpmHXBYJ2lWW7qTHDarVkIudPFE6iCIrqdgWxGn5s+ppkGXI0aEGlibI0PAyzP3zlw==", + "license": "MIT", + "dependencies": { + "@shikijs/primitive": "4.0.2", + "@shikijs/types": "4.0.2", + "@shikijs/vscode-textmate": "^10.0.2", + "@types/hast": "^3.0.4", + "hast-util-to-html": "^9.0.5" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@shikijs/engine-javascript": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-4.0.2.tgz", + "integrity": "sha512-7PW0Nm49DcoUIQEXlJhNNBHyoGMjalRETTCcjMqEaMoJRLljy1Bi/EGV3/qLBgLKQejdspiiYuHGQW6dX94Nag==", + "license": "MIT", + "dependencies": { + "@shikijs/types": "4.0.2", + "@shikijs/vscode-textmate": "^10.0.2", + "oniguruma-to-es": "^4.3.4" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@shikijs/engine-oniguruma": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-4.0.2.tgz", + "integrity": "sha512-UpCB9Y2sUKlS9z8juFSKz7ZtysmeXCgnRF0dlhXBkmQnek7lAToPte8DkxmEYGNTMii72zU/lyXiCB6StuZeJg==", + "license": "MIT", + "dependencies": { + "@shikijs/types": "4.0.2", + "@shikijs/vscode-textmate": "^10.0.2" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@shikijs/langs": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@shikijs/langs/-/langs-4.0.2.tgz", + "integrity": "sha512-KaXby5dvoeuZzN0rYQiPMjFoUrz4hgwIE+D6Du9owcHcl6/g16/yT5BQxSW5cGt2MZBz6Hl0YuRqf12omRfUUg==", + "license": "MIT", + "dependencies": { + "@shikijs/types": "4.0.2" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@shikijs/primitive": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@shikijs/primitive/-/primitive-4.0.2.tgz", + "integrity": "sha512-M6UMPrSa3fN5ayeJwFVl9qWofl273wtK1VG8ySDZ1mQBfhCpdd8nEx7nPZ/tk7k+TYcpqBZzj/AnwxT9lO+HJw==", + "license": "MIT", + "dependencies": { + "@shikijs/types": "4.0.2", + "@shikijs/vscode-textmate": "^10.0.2", + "@types/hast": "^3.0.4" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@shikijs/themes": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@shikijs/themes/-/themes-4.0.2.tgz", + "integrity": "sha512-mjCafwt8lJJaVSsQvNVrJumbnnj1RI8jbUKrPKgE6E3OvQKxnuRoBaYC51H4IGHePsGN/QtALglWBU7DoKDFnA==", + "license": "MIT", + "dependencies": { + "@shikijs/types": "4.0.2" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@shikijs/types": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@shikijs/types/-/types-4.0.2.tgz", + "integrity": "sha512-qzbeRooUTPnLE+sHD/Z8DStmaDgnbbc/pMrU203950aRqjX/6AFHeDYT+j00y2lPdz0ywJKx7o/7qnqTivtlXg==", + "license": "MIT", + "dependencies": { + "@shikijs/vscode-textmate": "^10.0.2", + "@types/hast": "^3.0.4" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@shikijs/vscode-textmate": { + "version": "10.0.2", + "resolved": "https://registry.npmjs.org/@shikijs/vscode-textmate/-/vscode-textmate-10.0.2.tgz", + "integrity": "sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==", + "license": "MIT" + }, + "node_modules/@supabase/auth-js": { + "version": "2.105.4", + "resolved": "https://registry.npmjs.org/@supabase/auth-js/-/auth-js-2.105.4.tgz", + "integrity": "sha512-Ejfa37M5xoIwoxVebxRahnwubPo8g22qkXQ4p50+N9MIvU9UZoN+A8dwVPtczzGf8oV/YXN80ZPxK4aWXuSN/A==", + "license": "MIT", + "dependencies": { + "tslib": "2.8.1" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@supabase/functions-js": { + "version": "2.105.4", + "resolved": "https://registry.npmjs.org/@supabase/functions-js/-/functions-js-2.105.4.tgz", + "integrity": "sha512-JVNKbBft3Qkja+WlGaE026AJ2AH9K0UTsxsfvEIHgd4zFrBor4BYRCrYFrv9IDsvVqkF72wKDsODJl5GY/C4tA==", + "license": "MIT", + "dependencies": { + "tslib": "2.8.1" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@supabase/phoenix": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/@supabase/phoenix/-/phoenix-0.4.2.tgz", + "integrity": "sha512-YSAGnmDAfuleFCVt3CeurQZAhxRfXWeZIIkwp7NhYzQ1UwW6ePSnzsFAiUm/mbCkfoCf70QQHKW/K6RKh52a4A==", + "license": "MIT" + }, + "node_modules/@supabase/postgrest-js": { + "version": "2.105.4", + "resolved": "https://registry.npmjs.org/@supabase/postgrest-js/-/postgrest-js-2.105.4.tgz", + "integrity": "sha512-SppIyLo/kTwIlz1qpv2HN1EQqBg0GVktrDDFsXygYROha3MgVn4rT7p5EjFHFqXQm2rdRGb/BI7bc+jr10m91w==", + "license": "MIT", + "dependencies": { + "tslib": "2.8.1" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@supabase/realtime-js": { + "version": "2.105.4", + "resolved": "https://registry.npmjs.org/@supabase/realtime-js/-/realtime-js-2.105.4.tgz", + "integrity": "sha512-6ov6c59+8D9h7q4M4Gy/uDJlC0Akxl9/714Y+6vJ+Sijuc16TS/p5DwhfRCLNcIhNiej1gEt+CQUwsjiPt4PxQ==", + "license": "MIT", + "dependencies": { + "@supabase/phoenix": "^0.4.2", + "tslib": "2.8.1" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@supabase/storage-js": { + "version": "2.105.4", + "resolved": "https://registry.npmjs.org/@supabase/storage-js/-/storage-js-2.105.4.tgz", + "integrity": "sha512-Jx+pzMP1Whjof2PWHoVBUA75/p7PQE9CqKBzn1oXVyJDOggMLSH2OzVWwsXYaxEpdC1K/KltwmOX44nL3LHl9g==", + "license": "MIT", + "dependencies": { + "iceberg-js": "^0.8.1", + "tslib": "2.8.1" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@supabase/supabase-js": { + "version": "2.105.4", + "resolved": "https://registry.npmjs.org/@supabase/supabase-js/-/supabase-js-2.105.4.tgz", + "integrity": "sha512-cEnx+k49knU+qdIP7rXwR6fqEXPHZs+74xFK1R0S8MgQ7v9tbePVdGxvO03n3bPympMdJWVLadARBfU4TgNHCQ==", + "license": "MIT", + "dependencies": { + "@supabase/auth-js": "2.105.4", + "@supabase/functions-js": "2.105.4", + "@supabase/postgrest-js": "2.105.4", + "@supabase/realtime-js": "2.105.4", + "@supabase/storage-js": "2.105.4" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@tailwindcss/node": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/node/-/node-4.3.0.tgz", + "integrity": "sha512-aFb4gUhFOgdh9AXo4IzBEOzBkkAxm9VigwDJnMIYv3lcfXCJVesNfbEaBl4BNgVRyid92AmdviqwBUBRKSeY3g==", + "license": "MIT", + "dependencies": { + "@jridgewell/remapping": "^2.3.5", + "enhanced-resolve": "^5.21.0", + "jiti": "^2.6.1", + "lightningcss": "1.32.0", + "magic-string": "^0.30.21", + "source-map-js": "^1.2.1", + "tailwindcss": "4.3.0" + } + }, + "node_modules/@tailwindcss/oxide": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide/-/oxide-4.3.0.tgz", + "integrity": "sha512-F7HZGBeN9I0/AuuJS5PwcD8xayx5ri5GhjYUDBEVYUkexyA/giwbDNjRVrxSezE3T250OU2K/wp/ltWx3UOefg==", + "license": "MIT", + "engines": { + "node": ">= 20" + }, + "optionalDependencies": { + "@tailwindcss/oxide-android-arm64": "4.3.0", + "@tailwindcss/oxide-darwin-arm64": "4.3.0", + "@tailwindcss/oxide-darwin-x64": "4.3.0", + "@tailwindcss/oxide-freebsd-x64": "4.3.0", + "@tailwindcss/oxide-linux-arm-gnueabihf": "4.3.0", + "@tailwindcss/oxide-linux-arm64-gnu": "4.3.0", + "@tailwindcss/oxide-linux-arm64-musl": "4.3.0", + "@tailwindcss/oxide-linux-x64-gnu": "4.3.0", + "@tailwindcss/oxide-linux-x64-musl": "4.3.0", + "@tailwindcss/oxide-wasm32-wasi": "4.3.0", + "@tailwindcss/oxide-win32-arm64-msvc": "4.3.0", + "@tailwindcss/oxide-win32-x64-msvc": "4.3.0" + } + }, + "node_modules/@tailwindcss/oxide-android-arm64": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-android-arm64/-/oxide-android-arm64-4.3.0.tgz", + "integrity": "sha512-TJPiq67tKlLuObP6RkwvVGDoxCMBVtDgKkLfa/uyj7/FyxvQwHS+UOnVrXXgbEsfUaMgiVvC4KbJnRr26ho4Ng==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-darwin-arm64": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-arm64/-/oxide-darwin-arm64-4.3.0.tgz", + "integrity": "sha512-oMN/WZRb+SO37BmUElEgeEWuU8E/HXRkiODxJxLe1UTHVXLrdVSgfaJV7pSlhRGMSOiXLuxTIjfsF3wYvz8cgQ==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-darwin-x64": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-x64/-/oxide-darwin-x64-4.3.0.tgz", + "integrity": "sha512-N6CUmu4a6bKVADfw77p+iw6Yd9Q3OBhe0veaDX+QazfuVYlQsHfDgxBrsjQ/IW+zywL8mTrNd0SdJT/zgtvMdA==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-freebsd-x64": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-freebsd-x64/-/oxide-freebsd-x64-4.3.0.tgz", + "integrity": "sha512-zDL5hBkQdH5C6MpqbK3gQAgP80tsMwSI26vjOzjJtNCMUo0lFgOItzHKBIupOZNQxt3ouPH7RPhvNhiTfCe5CQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-linux-arm-gnueabihf": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm-gnueabihf/-/oxide-linux-arm-gnueabihf-4.3.0.tgz", + "integrity": "sha512-R06HdNi7A7OEoMsf6d4tjZ71RCWnZQPHj2mnotSFURjNLdBC+cIgXQ7l81CqeoiQftjf6OOblxXMInMgN2VzMA==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-linux-arm64-gnu": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-gnu/-/oxide-linux-arm64-gnu-4.3.0.tgz", + "integrity": "sha512-qTJHELX8jetjhRQHCLilkVLmybpzNQAtaI/gaoVoidn/ufbNDbAo8KlK2J+yPoc8wQxvDxCmh/5lr8nC1+lTbg==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-linux-arm64-musl": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-musl/-/oxide-linux-arm64-musl-4.3.0.tgz", + "integrity": "sha512-Z6sukiQsngnWO+l39X4pPbiWT81IC+PLKF+PHxIlyZbGNb9MODfYlXEVlFvej5BOZInWX01kVyzeLvHsXhfczQ==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-linux-x64-gnu": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-gnu/-/oxide-linux-x64-gnu-4.3.0.tgz", + "integrity": "sha512-DRNdQRpSGzRGfARVuVkxvM8Q12nh19l4BF/G7zGA1oe+9wcC6saFBHTISrpIcKzhiXtSrlSrluCfvMuledoCTQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-linux-x64-musl": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-musl/-/oxide-linux-x64-musl-4.3.0.tgz", + "integrity": "sha512-Z0IADbDo8bh6I7h2IQMx601AdXBLfFpEdUotft86evd/8ZPflZe9COPO8Q1vw+pfLWIUo9zN/JGZvwuAJqduqg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-wasm32-wasi": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-wasm32-wasi/-/oxide-wasm32-wasi-4.3.0.tgz", + "integrity": "sha512-HNZGOUxEmElksYR7S6sC5jTeNGpobAsy9u7Gu0AskJ8/20FR9GqebUyB+HBcU/ax6BHuiuJi+Oda4B+YX6H1yA==", + "bundleDependencies": [ + "@napi-rs/wasm-runtime", + "@emnapi/core", + "@emnapi/runtime", + "@tybys/wasm-util", + "@emnapi/wasi-threads", + "tslib" + ], + "cpu": [ + "wasm32" + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/core": "^1.10.0", + "@emnapi/runtime": "^1.10.0", + "@emnapi/wasi-threads": "^1.2.1", + "@napi-rs/wasm-runtime": "^1.1.4", + "@tybys/wasm-util": "^0.10.1", + "tslib": "^2.8.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@tailwindcss/oxide-win32-arm64-msvc": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-arm64-msvc/-/oxide-win32-arm64-msvc-4.3.0.tgz", + "integrity": "sha512-Pe+RPVTi1T+qymuuRpcdvwSVZjnll/f7n8gBxMMh3xLTctMDKqpdfGimbMyioqtLhUYZxdJ9wGNhV7MKHvgZsQ==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/oxide-win32-x64-msvc": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-x64-msvc/-/oxide-win32-x64-msvc-4.3.0.tgz", + "integrity": "sha512-Mvrf2kXW/yeW/OTezZlCGOirXRcUuLIBx/5Y12BaPM7wJoryG6dfS/NJL8aBPqtTEx/Vm4T4vKzFUcKDT+TKUA==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 20" + } + }, + "node_modules/@tailwindcss/vite": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@tailwindcss/vite/-/vite-4.3.0.tgz", + "integrity": "sha512-t6J3OrB5Fc0ExuhohouH0fWUGMYL6PTLhW+E7zIk/pdbnJARZDCwjBznFnkh5ynRnIRSI4YjtTH0t6USjJISrw==", + "license": "MIT", + "dependencies": { + "@tailwindcss/node": "4.3.0", + "@tailwindcss/oxide": "4.3.0", + "tailwindcss": "4.3.0" + }, + "peerDependencies": { + "vite": "^5.2.0 || ^6 || ^7 || ^8" + } + }, + "node_modules/@types/babel__core": { + "version": "7.20.5", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", + "integrity": "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==", + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.20.7", + "@babel/types": "^7.20.7", + "@types/babel__generator": "*", + "@types/babel__template": "*", + "@types/babel__traverse": "*" + } + }, + "node_modules/@types/babel__generator": { + "version": "7.27.0", + "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.27.0.tgz", + "integrity": "sha512-ufFd2Xi92OAVPYsy+P4n7/U7e68fex0+Ee8gSG9KX7eo084CWiQ4sdxktvdl0bOPupXtVJPY19zk6EwWqUQ8lg==", + "license": "MIT", + "dependencies": { + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__template": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.4.tgz", + "integrity": "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==", + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__traverse": { + "version": "7.28.0", + "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.28.0.tgz", + "integrity": "sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q==", + "license": "MIT", + "dependencies": { + "@babel/types": "^7.28.2" + } + }, + "node_modules/@types/debug": { + "version": "4.1.13", + "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.13.tgz", + "integrity": "sha512-KSVgmQmzMwPlmtljOomayoR89W4FynCAi3E8PPs7vmDVPe84hT+vGPKkJfThkmXs0x0jAaa9U8uW8bbfyS2fWw==", + "license": "MIT", + "dependencies": { + "@types/ms": "*" + } + }, + "node_modules/@types/estree": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz", + "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==", + "license": "MIT" + }, + "node_modules/@types/hast": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz", + "integrity": "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==", + "license": "MIT", + "dependencies": { + "@types/unist": "*" + } + }, + "node_modules/@types/mdast": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", + "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", + "license": "MIT", + "dependencies": { + "@types/unist": "*" + } + }, + "node_modules/@types/ms": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@types/ms/-/ms-2.1.0.tgz", + "integrity": "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==", + "license": "MIT" + }, + "node_modules/@types/nlcst": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@types/nlcst/-/nlcst-2.0.3.tgz", + "integrity": "sha512-vSYNSDe6Ix3q+6Z7ri9lyWqgGhJTmzRjZRqyq15N0Z/1/UnVsno9G/N40NBijoYx2seFDIl0+B2mgAb9mezUCA==", + "license": "MIT", + "dependencies": { + "@types/unist": "*" + } + }, + "node_modules/@types/node": { + "version": "24.12.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.12.4.tgz", + "integrity": "sha512-GUUEShf+PBCGW2KaXwcIt3Yk+e3pkKwWKb9GSyM9WQVE+ep2jzmHdGsHzu4wgcZy5fN9FBdVzjpBQsYlpfpgLA==", + "license": "MIT", + "dependencies": { + "undici-types": "~7.16.0" + } + }, + "node_modules/@types/react": { + "version": "19.2.14", + "resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.14.tgz", + "integrity": "sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w==", + "license": "MIT", + "dependencies": { + "csstype": "^3.2.2" + } + }, + "node_modules/@types/react-dom": { + "version": "19.2.3", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.2.3.tgz", + "integrity": "sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ==", + "license": "MIT", + "peerDependencies": { + "@types/react": "^19.2.0" + } + }, + "node_modules/@types/sax": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@types/sax/-/sax-1.2.7.tgz", + "integrity": "sha512-rO73L89PJxeYM3s3pPPjiPgVVcymqU490g0YO5n5By0k2Erzj6tay/4lr1CHAAU4JyOWd1rpQ8bCf6cZfHU96A==", + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/unist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", + "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", + "license": "MIT" + }, + "node_modules/@ungap/structured-clone": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.3.1.tgz", + "integrity": "sha512-mUFwbeTqrVgDQxFveS+df2yfap6iuP20NAKAsBt5jDEoOTDew+zwLAOilHCeQJOVSvmgCX4ogqIrA0mnyr08yQ==", + "license": "ISC" + }, + "node_modules/@vercel/functions": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/@vercel/functions/-/functions-3.6.0.tgz", + "integrity": "sha512-Xj68JYqqJwtqFWJN7EWmFN7MOiUjv5whjw48UEKqQbg8r7hRkhuJhncTU0ba3jJCh/wxEuLWckrtsKcrHQraxw==", + "license": "Apache-2.0", + "dependencies": { + "@vercel/oidc": "3.4.1" + }, + "engines": { + "node": ">= 20" + }, + "peerDependencies": { + "@aws-sdk/credential-provider-web-identity": "*" + }, + "peerDependenciesMeta": { + "@aws-sdk/credential-provider-web-identity": { + "optional": true + } + } + }, + "node_modules/@vercel/nft": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@vercel/nft/-/nft-1.5.0.tgz", + "integrity": "sha512-IWTDeIoWhQ7ZtRO/JRKH+jhmeQvZYhtGPmzw/QGDY+wDCQqfm25P9yIdoAFagu4fWsK4IwZXDFIjrmp5rRm/sA==", + "license": "MIT", + "dependencies": { + "@mapbox/node-pre-gyp": "^2.0.0", + "@rollup/pluginutils": "^5.1.3", + "acorn": "^8.6.0", + "acorn-import-attributes": "^1.9.5", + "async-sema": "^3.1.1", + "bindings": "^1.4.0", + "estree-walker": "2.0.2", + "glob": "^13.0.0", + "graceful-fs": "^4.2.9", + "node-gyp-build": "^4.2.2", + "picomatch": "^4.0.2", + "resolve-from": "^5.0.0" + }, + "bin": { + "nft": "out/cli.js" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@vercel/oidc": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/@vercel/oidc/-/oidc-3.4.1.tgz", + "integrity": "sha512-H6B+/ig/GoahccL3WZjiHayHw1H5KhvTJNceqYulwfK9kkz5iul2hTmYzcJ7tTCQzyd0dutuL9xYFZCyLUqsog==", + "license": "Apache-2.0", + "engines": { + "node": ">= 20" + } + }, + "node_modules/@vercel/routing-utils": { + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/@vercel/routing-utils/-/routing-utils-5.3.3.tgz", + "integrity": "sha512-KYm2sLNUD48gDScv8ob4ejc3Gww2jcJyW80hTdYlenAPz/5BQar1Gyh38xrUuZ532TUwSb5mV1uRbAuiykq0EQ==", + "license": "Apache-2.0", + "dependencies": { + "path-to-regexp": "6.1.0", + "path-to-regexp-updated": "npm:path-to-regexp@6.3.0" + }, + "optionalDependencies": { + "ajv": "^6.12.3" + } + }, + "node_modules/@vitejs/plugin-react": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-5.2.0.tgz", + "integrity": "sha512-YmKkfhOAi3wsB1PhJq5Scj3GXMn3WvtQ/JC0xoopuHoXSdmtdStOpFrYaT1kie2YgFBcIe64ROzMYRjCrYOdYw==", + "license": "MIT", + "dependencies": { + "@babel/core": "^7.29.0", + "@babel/plugin-transform-react-jsx-self": "^7.27.1", + "@babel/plugin-transform-react-jsx-source": "^7.27.1", + "@rolldown/pluginutils": "1.0.0-rc.3", + "@types/babel__core": "^7.20.5", + "react-refresh": "^0.18.0" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "peerDependencies": { + "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/abbrev": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-3.0.1.tgz", + "integrity": "sha512-AO2ac6pjRB3SJmGJo+v5/aK6Omggp6fsLrs6wN9bd35ulu4cCwaAU9+7ZhXjeqHVkaHThLuzH0nZr0YpCDhygg==", + "license": "ISC", + "engines": { + "node": "^18.17.0 || >=20.5.0" + } + }, + "node_modules/acorn": { + "version": "8.16.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.16.0.tgz", + "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==", + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-import-attributes": { + "version": "1.9.5", + "resolved": "https://registry.npmjs.org/acorn-import-attributes/-/acorn-import-attributes-1.9.5.tgz", + "integrity": "sha512-n02Vykv5uA3eHGM/Z2dQrcD56kL8TyDb2p1+0P83PClMnC/nc+anbQRhIOWnSq4Ke/KvDPrY3C9hDtC/A3eHnQ==", + "license": "MIT", + "peerDependencies": { + "acorn": "^8" + } + }, + "node_modules/agent-base": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", + "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==", + "license": "MIT", + "engines": { + "node": ">= 14" + } + }, + "node_modules/ajv": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.15.0.tgz", + "integrity": "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==", + "license": "MIT", + "optional": true, + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "license": "ISC", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/anymatch/node_modules/picomatch": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz", + "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==", + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/arg": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz", + "integrity": "sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==", + "license": "MIT" + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "license": "Python-2.0" + }, + "node_modules/aria-query": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.2.tgz", + "integrity": "sha512-COROpnaoap1E2F000S62r6A60uHZnmlvomhfyT2DlTcrY1OrBKn2UhH7qn5wTC9zMvD0AY7csdPSNwKP+7WiQw==", + "license": "Apache-2.0", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/array-iterate": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/array-iterate/-/array-iterate-2.0.1.tgz", + "integrity": "sha512-I1jXZMjAgCMmxT4qxXfPXa6SthSoE8h6gkSI9BGGNv8mP8G/v0blc+qFnZu6K42vTOiuME596QaLO0TP3Lk0xg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/astro": { + "version": "6.3.3", + "resolved": "https://registry.npmjs.org/astro/-/astro-6.3.3.tgz", + "integrity": "sha512-wvLIZQYbBZt6U8gyflBW4SLBypaqdwLZUH93rT3oT53cmQ0bTGubvMAGjqBRoheOYzYcTJZtW6czztzbu4kQ5g==", + "license": "MIT", + "dependencies": { + "@astrojs/compiler": "^4.0.0", + "@astrojs/internal-helpers": "0.9.1", + "@astrojs/markdown-remark": "7.1.2", + "@astrojs/telemetry": "3.3.2", + "@capsizecss/unpack": "^4.0.0", + "@clack/prompts": "^1.1.0", + "@oslojs/encoding": "^1.1.0", + "@rollup/pluginutils": "^5.3.0", + "aria-query": "^5.3.2", + "axobject-query": "^4.1.0", + "ci-info": "^4.4.0", + "clsx": "^2.1.1", + "common-ancestor-path": "^2.0.0", + "cookie": "^1.1.1", + "devalue": "^5.6.3", + "diff": "^8.0.3", + "dset": "^3.1.4", + "es-module-lexer": "^2.0.0", + "esbuild": "^0.27.3", + "flattie": "^1.1.1", + "fontace": "~0.4.1", + "get-tsconfig": "5.0.0-beta.4", + "github-slugger": "^2.0.0", + "html-escaper": "3.0.3", + "http-cache-semantics": "^4.2.0", + "js-yaml": "^4.1.1", + "jsonc-parser": "^3.3.1", + "magic-string": "^0.30.21", + "magicast": "^0.5.2", + "mrmime": "^2.0.1", + "neotraverse": "^0.6.18", + "obug": "^2.1.1", + "p-limit": "^7.3.0", + "p-queue": "^9.1.0", + "package-manager-detector": "^1.6.0", + "piccolore": "^0.1.3", + "picomatch": "^4.0.4", + "rehype": "^13.0.2", + "semver": "^7.7.4", + "shiki": "^4.0.2", + "smol-toml": "^1.6.0", + "svgo": "^4.0.1", + "tinyclip": "^0.1.12", + "tinyexec": "^1.0.4", + "tinyglobby": "^0.2.15", + "ultrahtml": "^1.6.0", + "unifont": "~0.7.4", + "unist-util-visit": "^5.1.0", + "unstorage": "^1.17.5", + "vfile": "^6.0.3", + "vite": "^7.3.2", + "vitefu": "^1.1.2", + "xxhash-wasm": "^1.1.0", + "yargs-parser": "^22.0.0", + "zod": "^4.3.6" + }, + "bin": { + "astro": "bin/astro.mjs" + }, + "engines": { + "node": ">=22.12.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/astrodotbuild" + }, + "optionalDependencies": { + "sharp": "^0.34.0" + } + }, + "node_modules/async-sema": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/async-sema/-/async-sema-3.1.1.tgz", + "integrity": "sha512-tLRNUXati5MFePdAk8dw7Qt7DpxPB60ofAgn8WRhW6a2rcimZnYBP9oxHiv0OHy+Wz7kPMG+t4LGdt31+4EmGg==", + "license": "MIT" + }, + "node_modules/axobject-query": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-4.1.0.tgz", + "integrity": "sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==", + "license": "Apache-2.0", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/bail": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/bail/-/bail-2.0.2.tgz", + "integrity": "sha512-0xO6mYd7JB2YesxDKplafRpsiOzPt9V02ddPCLbY1xYGPOX24NTyN50qnUxgCPcSoYMhKpAuBTjQoRZCAkUDRw==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/balanced-match": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", + "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", + "license": "MIT", + "engines": { + "node": "18 || 20 || >=22" + } + }, + "node_modules/baseline-browser-mapping": { + "version": "2.10.29", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.29.tgz", + "integrity": "sha512-Asa2krT+XTPZINCS+2QcyS8WTkObE77RwkydwF7h6DmnKqbvlalz93m/dnphUyCa6SWSP51VgtEUf2FN+gelFQ==", + "license": "Apache-2.0", + "bin": { + "baseline-browser-mapping": "dist/cli.cjs" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "license": "MIT", + "dependencies": { + "file-uri-to-path": "1.0.0" + } + }, + "node_modules/boolbase": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", + "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==", + "license": "ISC" + }, + "node_modules/brace-expansion": { + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.6.tgz", + "integrity": "sha512-kLpxurY4Z4r9sgMsyG0Z9uzsBlgiU/EFKhj/h91/8yHu0edo7XuixOIH3VcJ8kkxs6/jPzoI6U9Vj3WqbMQ94g==", + "license": "MIT", + "dependencies": { + "balanced-match": "^4.0.2" + }, + "engines": { + "node": "18 || 20 || >=22" + } + }, + "node_modules/browserslist": { + "version": "4.28.2", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.2.tgz", + "integrity": "sha512-48xSriZYYg+8qXna9kwqjIVzuQxi+KYWp2+5nCYnYKPTr0LvD89Jqk2Or5ogxz0NUMfIjhh2lIUX/LyX9B4oIg==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "baseline-browser-mapping": "^2.10.12", + "caniuse-lite": "^1.0.30001782", + "electron-to-chromium": "^1.5.328", + "node-releases": "^2.0.36", + "update-browserslist-db": "^1.2.3" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001792", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001792.tgz", + "integrity": "sha512-hVLMUZFgR4JJ6ACt1uEESvQN1/dBVqPAKY0hgrV70eN3391K6juAfTjKZLKvOMsx8PxA7gsY1/tLMMTcfFLLpw==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "CC-BY-4.0" + }, + "node_modules/ccount": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz", + "integrity": "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/character-entities": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/character-entities/-/character-entities-2.0.2.tgz", + "integrity": "sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/character-entities-html4": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/character-entities-html4/-/character-entities-html4-2.1.0.tgz", + "integrity": "sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/character-entities-legacy": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-3.0.0.tgz", + "integrity": "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/chokidar": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-5.0.0.tgz", + "integrity": "sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==", + "license": "MIT", + "dependencies": { + "readdirp": "^5.0.0" + }, + "engines": { + "node": ">= 20.19.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/chownr": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-3.0.0.tgz", + "integrity": "sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==", + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/ci-info": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.4.0.tgz", + "integrity": "sha512-77PSwercCZU2Fc4sX94eF8k8Pxte6JAwL4/ICZLFjJLqegs7kCuAsqqj/70NQF6TvDpgFjkubQB2FW2ZZddvQg==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/clsx": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", + "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/comma-separated-tokens": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-2.0.3.tgz", + "integrity": "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/commander": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz", + "integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==", + "license": "MIT", + "engines": { + "node": ">=16" + } + }, + "node_modules/common-ancestor-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/common-ancestor-path/-/common-ancestor-path-2.0.0.tgz", + "integrity": "sha512-dnN3ibLeoRf2HNC+OlCiNc5d2zxbLJXOtiZUudNFSXZrNSydxcCsSpRzXwfu7BBWCIfHPw+xTayeBvJCP/D8Ng==", + "license": "BlueOak-1.0.0", + "engines": { + "node": ">= 18" + } + }, + "node_modules/consola": { + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/consola/-/consola-3.4.2.tgz", + "integrity": "sha512-5IKcdX0nnYavi6G7TtOhwkYzyjfJlatbjMjuLSfE2kYT5pMDOilZ4OvMhi637CcDICTmz3wARPoyhqyX1Y+XvA==", + "license": "MIT", + "engines": { + "node": "^14.18.0 || >=16.10.0" + } + }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "license": "MIT" + }, + "node_modules/cookie": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-1.1.1.tgz", + "integrity": "sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/cookie-es": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/cookie-es/-/cookie-es-1.2.3.tgz", + "integrity": "sha512-lXVyvUvrNXblMqzIRrxHb57UUVmqsSWlxqt3XIjCkUP0wDAf6uicO6KMbEgYrMNtEvWgWHwe42CKxPu9MYAnWw==", + "license": "MIT" + }, + "node_modules/crossws": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/crossws/-/crossws-0.3.5.tgz", + "integrity": "sha512-ojKiDvcmByhwa8YYqbQI/hg7MEU0NC03+pSdEq4ZUnZR9xXpwk7E43SMNGkn+JxJGPFtNvQ48+vV2p+P1ml5PA==", + "license": "MIT", + "dependencies": { + "uncrypto": "^0.1.3" + } + }, + "node_modules/css-select": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-5.2.2.tgz", + "integrity": "sha512-TizTzUddG/xYLA3NXodFM0fSbNizXjOKhqiQQwvhlspadZokn1KDy0NZFS0wuEubIYAV5/c1/lAr0TaaFXEXzw==", + "license": "BSD-2-Clause", + "dependencies": { + "boolbase": "^1.0.0", + "css-what": "^6.1.0", + "domhandler": "^5.0.2", + "domutils": "^3.0.1", + "nth-check": "^2.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/css-tree": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-3.2.1.tgz", + "integrity": "sha512-X7sjQzceUhu1u7Y/ylrRZFU2FS6LRiFVp6rKLPg23y3x3c3DOKAwuXGDp+PAGjh6CSnCjYeAul8pcT8bAl+lSA==", + "license": "MIT", + "dependencies": { + "mdn-data": "2.27.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0" + } + }, + "node_modules/css-what": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-6.2.2.tgz", + "integrity": "sha512-u/O3vwbptzhMs3L1fQE82ZSLHQQfto5gyZzwteVIEyeaY5Fc7R4dapF/BvRoSYFeqfBk4m0V1Vafq5Pjv25wvA==", + "license": "BSD-2-Clause", + "engines": { + "node": ">= 6" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/csso": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/csso/-/csso-5.0.5.tgz", + "integrity": "sha512-0LrrStPOdJj+SPCCrGhzryycLjwcgUSHBtxNA8aIDxf0GLsRh1cKYhB00Gd1lDOS4yGH69+SNn13+TWbVHETFQ==", + "license": "MIT", + "dependencies": { + "css-tree": "~2.2.0" + }, + "engines": { + "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0", + "npm": ">=7.0.0" + } + }, + "node_modules/csso/node_modules/css-tree": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-2.2.1.tgz", + "integrity": "sha512-OA0mILzGc1kCOCSJerOeqDxDQ4HOh+G8NbOJFOTgOCzpw7fCBubk0fEyxp8AgOL/jvLgYA/uV0cMbe43ElF1JA==", + "license": "MIT", + "dependencies": { + "mdn-data": "2.0.28", + "source-map-js": "^1.0.1" + }, + "engines": { + "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0", + "npm": ">=7.0.0" + } + }, + "node_modules/csso/node_modules/mdn-data": { + "version": "2.0.28", + "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.28.tgz", + "integrity": "sha512-aylIc7Z9y4yzHYAJNuESG3hfhC+0Ibp/MAMiaOZgNv4pmEdFyfZhhhny4MNiAfWdBQ1RQ2mfDWmM1x8SvGyp8g==", + "license": "CC0-1.0" + }, + "node_modules/csstype": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", + "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", + "license": "MIT" + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decode-named-character-reference": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/decode-named-character-reference/-/decode-named-character-reference-1.3.0.tgz", + "integrity": "sha512-GtpQYB283KrPp6nRw50q3U9/VfOutZOe103qlN7BPP6Ad27xYnOIWv4lPzo8HCAL+mMZofJ9KEy30fq6MfaK6Q==", + "license": "MIT", + "dependencies": { + "character-entities": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/defu": { + "version": "6.1.7", + "resolved": "https://registry.npmjs.org/defu/-/defu-6.1.7.tgz", + "integrity": "sha512-7z22QmUWiQ/2d0KkdYmANbRUVABpZ9SNYyH5vx6PZ+nE5bcC0l7uFvEfHlyld/HcGBFTL536ClDt3DEcSlEJAQ==", + "license": "MIT" + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/dequal": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", + "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/destr": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/destr/-/destr-2.0.5.tgz", + "integrity": "sha512-ugFTXCtDZunbzasqBxrK93Ik/DRYsO6S/fedkWEMKqt04xZ4csmnmwGDBAb07QWNaGMAmnTIemsYZCksjATwsA==", + "license": "MIT" + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, + "node_modules/devalue": { + "version": "5.8.1", + "resolved": "https://registry.npmjs.org/devalue/-/devalue-5.8.1.tgz", + "integrity": "sha512-4CXDYRBGqN+57wVJkuXBYmpAVUSg3L6JAQa/DFqm238G73E1wuyc/JhGQJzN7vUf/CMphYau2zXbfWzDR5aTEw==", + "license": "MIT" + }, + "node_modules/devlop": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/devlop/-/devlop-1.1.0.tgz", + "integrity": "sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==", + "license": "MIT", + "dependencies": { + "dequal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/diff": { + "version": "8.0.4", + "resolved": "https://registry.npmjs.org/diff/-/diff-8.0.4.tgz", + "integrity": "sha512-DPi0FmjiSU5EvQV0++GFDOJ9ASQUVFh5kD+OzOnYdi7n3Wpm9hWWGfB/O2blfHcMVTL5WkQXSnRiK9makhrcnw==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/dom-serializer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", + "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", + "license": "MIT", + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "entities": "^4.2.0" + }, + "funding": { + "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" + } + }, + "node_modules/dom-serializer/node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/domelementtype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "license": "BSD-2-Clause" + }, + "node_modules/domhandler": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "license": "BSD-2-Clause", + "dependencies": { + "domelementtype": "^2.3.0" + }, + "engines": { + "node": ">= 4" + }, + "funding": { + "url": "https://github.com/fb55/domhandler?sponsor=1" + } + }, + "node_modules/domutils": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.2.2.tgz", + "integrity": "sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==", + "license": "BSD-2-Clause", + "dependencies": { + "dom-serializer": "^2.0.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3" + }, + "funding": { + "url": "https://github.com/fb55/domutils?sponsor=1" + } + }, + "node_modules/dset": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/dset/-/dset-3.1.4.tgz", + "integrity": "sha512-2QF/g9/zTaPDc3BjNcVTGoBbXBgYfMTTceLaYcFJ/W9kggFUkhxD/hMEeuLKbugyef9SqAx8cpgwlIP/jinUTA==", + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, + "node_modules/electron-to-chromium": { + "version": "1.5.357", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.357.tgz", + "integrity": "sha512-NHlTIQDK8fmVwHwuIzmXYEJ1Ewq3D9wDNc0cWXxDGysP6Pb21giwGNkxiTifyKy/4SoPuN5l6GLP1W9Sv7zB2g==", + "license": "ISC" + }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/enhanced-resolve": { + "version": "5.21.3", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.21.3.tgz", + "integrity": "sha512-QyL119InA+XXEkNLNTPCXPugSvOfhwv0JOlGNzvxs0hZaiHLNvXSpudUWsOlsXGWJh8G6ckCScEkVHfX3kw/2Q==", + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.4", + "tapable": "^2.3.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/entities": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-6.0.1.tgz", + "integrity": "sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/es-module-lexer": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.1.0.tgz", + "integrity": "sha512-n27zTYMjYu1aj4MjCWzSP7G9r75utsaoc8m61weK+W8JMBGGQybd43GstCXZ3WNmSFtGT9wi59qQTW6mhTR5LQ==", + "license": "MIT" + }, + "node_modules/esbuild": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.7.tgz", + "integrity": "sha512-IxpibTjyVnmrIQo5aqNpCgoACA/dTKLTlhMHihVHhdkxKyPO1uBBthumT0rdHmcsk9uMonIWS0m4FljWzILh3w==", + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.27.7", + "@esbuild/android-arm": "0.27.7", + "@esbuild/android-arm64": "0.27.7", + "@esbuild/android-x64": "0.27.7", + "@esbuild/darwin-arm64": "0.27.7", + "@esbuild/darwin-x64": "0.27.7", + "@esbuild/freebsd-arm64": "0.27.7", + "@esbuild/freebsd-x64": "0.27.7", + "@esbuild/linux-arm": "0.27.7", + "@esbuild/linux-arm64": "0.27.7", + "@esbuild/linux-ia32": "0.27.7", + "@esbuild/linux-loong64": "0.27.7", + "@esbuild/linux-mips64el": "0.27.7", + "@esbuild/linux-ppc64": "0.27.7", + "@esbuild/linux-riscv64": "0.27.7", + "@esbuild/linux-s390x": "0.27.7", + "@esbuild/linux-x64": "0.27.7", + "@esbuild/netbsd-arm64": "0.27.7", + "@esbuild/netbsd-x64": "0.27.7", + "@esbuild/openbsd-arm64": "0.27.7", + "@esbuild/openbsd-x64": "0.27.7", + "@esbuild/openharmony-arm64": "0.27.7", + "@esbuild/sunos-x64": "0.27.7", + "@esbuild/win32-arm64": "0.27.7", + "@esbuild/win32-ia32": "0.27.7", + "@esbuild/win32-x64": "0.27.7" + } + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, + "node_modules/escape-string-regexp": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz", + "integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "license": "MIT" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/eventemitter3": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.4.tgz", + "integrity": "sha512-mlsTRyGaPBjPedk6Bvw+aqbsXDtoAyAzm5MO7JgU+yVRyMQ5O8bD4Kcci7BS85f93veegeCPkL8R4GLClnjLFw==", + "license": "MIT" + }, + "node_modules/extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "license": "MIT" + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "license": "MIT", + "optional": true + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "license": "MIT", + "optional": true + }, + "node_modules/fast-string-truncated-width": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/fast-string-truncated-width/-/fast-string-truncated-width-3.0.3.tgz", + "integrity": "sha512-0jjjIEL6+0jag3l2XWWizO64/aZVtpiGE3t0Zgqxv0DPuxiMjvB3M24fCyhZUO4KomJQPj3LTSUnDP3GpdwC0g==", + "license": "MIT" + }, + "node_modules/fast-string-width": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/fast-string-width/-/fast-string-width-3.0.2.tgz", + "integrity": "sha512-gX8LrtNEI5hq8DVUfRQMbr5lpaS4nMIWV+7XEbXk2b8kiQIizgnlr12B4dA3ZEx3308ze0O4Q1R+cHts8kyUJg==", + "license": "MIT", + "dependencies": { + "fast-string-truncated-width": "^3.0.2" + } + }, + "node_modules/fast-wrap-ansi": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/fast-wrap-ansi/-/fast-wrap-ansi-0.2.0.tgz", + "integrity": "sha512-rLV8JHxTyhVmFYhBJuMujcrHqOT2cnO5Zxj37qROj23CP39GXubJRBUFF0z8KFK77Uc0SukZUf7JZhsVEQ6n8w==", + "license": "MIT", + "dependencies": { + "fast-string-width": "^3.0.2" + } + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", + "license": "MIT" + }, + "node_modules/flattie": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/flattie/-/flattie-1.1.1.tgz", + "integrity": "sha512-9UbaD6XdAL97+k/n+N7JwX46K/M6Zc6KcFYskrYL8wbBV/Uyk0CTAMY0VT+qiK5PM7AIc9aTWYtq65U7T+aCNQ==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/fontace": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/fontace/-/fontace-0.4.1.tgz", + "integrity": "sha512-lDMvbAzSnHmbYMTEld5qdtvNH2/pWpICOqpean9IgC7vUbUJc3k+k5Dokp85CegamqQpFbXf0rAVkbzpyTA8aw==", + "license": "MIT", + "dependencies": { + "fontkitten": "^1.0.2" + } + }, + "node_modules/fontkitten": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/fontkitten/-/fontkitten-1.0.3.tgz", + "integrity": "sha512-Wp1zXWPVUPBmfoa3Cqc9ctaKuzKAV6uLstRqlR56kSjplf5uAce+qeyYym7F+PHbGTk+tCEdkCW6RD7DX/gBZw==", + "license": "MIT", + "dependencies": { + "tiny-inflate": "^1.0.3" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/fresh": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", + "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/get-tsconfig": { + "version": "5.0.0-beta.4", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-5.0.0-beta.4.tgz", + "integrity": "sha512-7nF7C9fIPFEMHgEMEfgIlO9wDdZ8CyHw27rWciFZfHvHDReIiPhsYuzPRXsfvBCqFy1l8RRyyWV7QLM+ZhUJsQ==", + "license": "MIT", + "dependencies": { + "resolve-pkg-maps": "^1.0.0" + }, + "engines": { + "node": ">=20.20.0" + }, + "funding": { + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" + } + }, + "node_modules/github-slugger": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/github-slugger/-/github-slugger-2.0.0.tgz", + "integrity": "sha512-IaOQ9puYtjrkq7Y0Ygl9KDZnrf/aiUJYUpVf89y8kyaxbRG7Y1SrX/jaumrv81vc61+kiMempujsM3Yw7w5qcw==", + "license": "ISC" + }, + "node_modules/glob": { + "version": "13.0.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-13.0.6.tgz", + "integrity": "sha512-Wjlyrolmm8uDpm/ogGyXZXb1Z+Ca2B8NbJwqBVg0axK9GbBeoS7yGV6vjXnYdGm6X53iehEuxxbyiKp8QmN4Vw==", + "license": "BlueOak-1.0.0", + "dependencies": { + "minimatch": "^10.2.2", + "minipass": "^7.1.3", + "path-scurry": "^2.0.2" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "license": "ISC" + }, + "node_modules/h3": { + "version": "1.15.11", + "resolved": "https://registry.npmjs.org/h3/-/h3-1.15.11.tgz", + "integrity": "sha512-L3THSe2MPeBwgIZVSH5zLdBBU90TOxarvhK9d04IDY2AmVS8j2Jz2LIWtwsGOU3lu2I5jCN7FNvVfY2+XyF+mg==", + "license": "MIT", + "dependencies": { + "cookie-es": "^1.2.3", + "crossws": "^0.3.5", + "defu": "^6.1.6", + "destr": "^2.0.5", + "iron-webcrypto": "^1.2.1", + "node-mock-http": "^1.0.4", + "radix3": "^1.1.2", + "ufo": "^1.6.3", + "uncrypto": "^0.1.3" + } + }, + "node_modules/hast-util-from-html": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/hast-util-from-html/-/hast-util-from-html-2.0.3.tgz", + "integrity": "sha512-CUSRHXyKjzHov8yKsQjGOElXy/3EKpyX56ELnkHH34vDVw1N1XSQ1ZcAvTyAPtGqLTuKP/uxM+aLkSPqF/EtMw==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "devlop": "^1.1.0", + "hast-util-from-parse5": "^8.0.0", + "parse5": "^7.0.0", + "vfile": "^6.0.0", + "vfile-message": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-from-parse5": { + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/hast-util-from-parse5/-/hast-util-from-parse5-8.0.3.tgz", + "integrity": "sha512-3kxEVkEKt0zvcZ3hCRYI8rqrgwtlIOFMWkbclACvjlDw8Li9S2hk/d51OI0nr/gIpdMHNepwgOKqZ/sy0Clpyg==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/unist": "^3.0.0", + "devlop": "^1.0.0", + "hastscript": "^9.0.0", + "property-information": "^7.0.0", + "vfile": "^6.0.0", + "vfile-location": "^5.0.0", + "web-namespaces": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-is-element": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/hast-util-is-element/-/hast-util-is-element-3.0.0.tgz", + "integrity": "sha512-Val9mnv2IWpLbNPqc/pUem+a7Ipj2aHacCwgNfTiK0vJKl0LF+4Ba4+v1oPHFpf3bLYmreq0/l3Gud9S5OH42g==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-parse-selector": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/hast-util-parse-selector/-/hast-util-parse-selector-4.0.0.tgz", + "integrity": "sha512-wkQCkSYoOGCRKERFWcxMVMOcYE2K1AaNLU8DXS9arxnLOUEWbOXKXiJUNzEpqZ3JOKpnha3jkFrumEjVliDe7A==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-raw": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/hast-util-raw/-/hast-util-raw-9.1.0.tgz", + "integrity": "sha512-Y8/SBAHkZGoNkpzqqfCldijcuUKh7/su31kEBp67cFY09Wy0mTRgtsLYsiIxMJxlu0f6AA5SUTbDR8K0rxnbUw==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/unist": "^3.0.0", + "@ungap/structured-clone": "^1.0.0", + "hast-util-from-parse5": "^8.0.0", + "hast-util-to-parse5": "^8.0.0", + "html-void-elements": "^3.0.0", + "mdast-util-to-hast": "^13.0.0", + "parse5": "^7.0.0", + "unist-util-position": "^5.0.0", + "unist-util-visit": "^5.0.0", + "vfile": "^6.0.0", + "web-namespaces": "^2.0.0", + "zwitch": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-to-html": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-9.0.5.tgz", + "integrity": "sha512-OguPdidb+fbHQSU4Q4ZiLKnzWo8Wwsf5bZfbvu7//a9oTYoqD/fWpe96NuHkoS9h0ccGOTe0C4NGXdtS0iObOw==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/unist": "^3.0.0", + "ccount": "^2.0.0", + "comma-separated-tokens": "^2.0.0", + "hast-util-whitespace": "^3.0.0", + "html-void-elements": "^3.0.0", + "mdast-util-to-hast": "^13.0.0", + "property-information": "^7.0.0", + "space-separated-tokens": "^2.0.0", + "stringify-entities": "^4.0.0", + "zwitch": "^2.0.4" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-to-parse5": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/hast-util-to-parse5/-/hast-util-to-parse5-8.0.1.tgz", + "integrity": "sha512-MlWT6Pjt4CG9lFCjiz4BH7l9wmrMkfkJYCxFwKQic8+RTZgWPuWxwAfjJElsXkex7DJjfSJsQIt931ilUgmwdA==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "comma-separated-tokens": "^2.0.0", + "devlop": "^1.0.0", + "property-information": "^7.0.0", + "space-separated-tokens": "^2.0.0", + "web-namespaces": "^2.0.0", + "zwitch": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-to-text": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/hast-util-to-text/-/hast-util-to-text-4.0.2.tgz", + "integrity": "sha512-KK6y/BN8lbaq654j7JgBydev7wuNMcID54lkRav1P0CaE1e47P72AWWPiGKXTJU271ooYzcvTAn/Zt0REnvc7A==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/unist": "^3.0.0", + "hast-util-is-element": "^3.0.0", + "unist-util-find-after": "^5.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-whitespace": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-3.0.0.tgz", + "integrity": "sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hastscript": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/hastscript/-/hastscript-9.0.1.tgz", + "integrity": "sha512-g7df9rMFX/SPi34tyGCyUBREQoKkapwdY/T04Qn9TDWfHhAYt4/I0gMVirzK5wEzeUqIjEB+LXC/ypb7Aqno5w==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "comma-separated-tokens": "^2.0.0", + "hast-util-parse-selector": "^4.0.0", + "property-information": "^7.0.0", + "space-separated-tokens": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/html-escaper": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-3.0.3.tgz", + "integrity": "sha512-RuMffC89BOWQoY0WKGpIhn5gX3iI54O6nRA0yC124NYVtzjmFWBIiFd8M0x+ZdX0P9R4lADg1mgP8C7PxGOWuQ==", + "license": "MIT" + }, + "node_modules/html-void-elements": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/html-void-elements/-/html-void-elements-3.0.0.tgz", + "integrity": "sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/http-cache-semantics": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.2.0.tgz", + "integrity": "sha512-dTxcvPXqPvXBQpq5dUr6mEMJX4oIEFv6bwom3FDwKRDsuIjjJGANqhBuoAn9c1RQJIdAKav33ED65E2ys+87QQ==", + "license": "BSD-2-Clause" + }, + "node_modules/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/https-proxy-agent": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", + "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", + "license": "MIT", + "dependencies": { + "agent-base": "^7.1.2", + "debug": "4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/iceberg-js": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/iceberg-js/-/iceberg-js-0.8.1.tgz", + "integrity": "sha512-1dhVQZXhcHje7798IVM+xoo/1ZdVfzOMIc8/rgVSijRK38EDqOJoGula9N/8ZI5RD8QTxNQtK/Gozpr+qUqRRA==", + "license": "MIT", + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/iron-webcrypto": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/iron-webcrypto/-/iron-webcrypto-1.2.1.tgz", + "integrity": "sha512-feOM6FaSr6rEABp/eDfVseKyTMDt+KGpeB35SkVn9Tyn0CqvVsY3EwI0v5i8nMHyJnzCIQf7nsy3p41TPkJZhg==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/brc-dd" + } + }, + "node_modules/is-docker": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-4.0.0.tgz", + "integrity": "sha512-LHE+wROyG/Y/0ZnbktRCoTix2c1RhgWaZraMZ8o1Q7zCh0VSrICJQO5oqIIISrcSBtrXv0o233w1IYwsWCjTzA==", + "license": "MIT", + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-inside-container": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz", + "integrity": "sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==", + "license": "MIT", + "dependencies": { + "is-docker": "^3.0.0" + }, + "bin": { + "is-inside-container": "cli.js" + }, + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-inside-container/node_modules/is-docker": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz", + "integrity": "sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==", + "license": "MIT", + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-plain-obj": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-4.1.0.tgz", + "integrity": "sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-wsl": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-3.1.1.tgz", + "integrity": "sha512-e6rvdUCiQCAuumZslxRJWR/Doq4VpPR82kqclvcS0efgt430SlGIk05vdCN58+VrzgtIcfNODjozVielycD4Sw==", + "license": "MIT", + "dependencies": { + "is-inside-container": "^1.0.0" + }, + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/jiti": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.7.0.tgz", + "integrity": "sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==", + "license": "MIT", + "bin": { + "jiti": "lib/jiti-cli.mjs" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "license": "MIT" + }, + "node_modules/js-yaml": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz", + "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==", + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/jsesc": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", + "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "license": "MIT", + "optional": true + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "license": "MIT", + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/jsonc-parser": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.3.1.tgz", + "integrity": "sha512-HUgH65KyejrUFPvHFPbqOY0rsFip3Bo5wb4ngvdi1EpCYWUQDC5V+Y7mZws+DLkr4M//zQJoanu1SP+87Dv1oQ==", + "license": "MIT" + }, + "node_modules/lightningcss": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.32.0.tgz", + "integrity": "sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ==", + "license": "MPL-2.0", + "dependencies": { + "detect-libc": "^2.0.3" + }, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "lightningcss-android-arm64": "1.32.0", + "lightningcss-darwin-arm64": "1.32.0", + "lightningcss-darwin-x64": "1.32.0", + "lightningcss-freebsd-x64": "1.32.0", + "lightningcss-linux-arm-gnueabihf": "1.32.0", + "lightningcss-linux-arm64-gnu": "1.32.0", + "lightningcss-linux-arm64-musl": "1.32.0", + "lightningcss-linux-x64-gnu": "1.32.0", + "lightningcss-linux-x64-musl": "1.32.0", + "lightningcss-win32-arm64-msvc": "1.32.0", + "lightningcss-win32-x64-msvc": "1.32.0" + } + }, + "node_modules/lightningcss-android-arm64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.32.0.tgz", + "integrity": "sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg==", + "cpu": [ + "arm64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-arm64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.32.0.tgz", + "integrity": "sha512-RzeG9Ju5bag2Bv1/lwlVJvBE3q6TtXskdZLLCyfg5pt+HLz9BqlICO7LZM7VHNTTn/5PRhHFBSjk5lc4cmscPQ==", + "cpu": [ + "arm64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-x64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.32.0.tgz", + "integrity": "sha512-U+QsBp2m/s2wqpUYT/6wnlagdZbtZdndSmut/NJqlCcMLTWp5muCrID+K5UJ6jqD2BFshejCYXniPDbNh73V8w==", + "cpu": [ + "x64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-freebsd-x64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.32.0.tgz", + "integrity": "sha512-JCTigedEksZk3tHTTthnMdVfGf61Fky8Ji2E4YjUTEQX14xiy/lTzXnu1vwiZe3bYe0q+SpsSH/CTeDXK6WHig==", + "cpu": [ + "x64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm-gnueabihf": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.32.0.tgz", + "integrity": "sha512-x6rnnpRa2GL0zQOkt6rts3YDPzduLpWvwAF6EMhXFVZXD4tPrBkEFqzGowzCsIWsPjqSK+tyNEODUBXeeVHSkw==", + "cpu": [ + "arm" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-gnu": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.32.0.tgz", + "integrity": "sha512-0nnMyoyOLRJXfbMOilaSRcLH3Jw5z9HDNGfT/gwCPgaDjnx0i8w7vBzFLFR1f6CMLKF8gVbebmkUN3fa/kQJpQ==", + "cpu": [ + "arm64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-musl": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.32.0.tgz", + "integrity": "sha512-UpQkoenr4UJEzgVIYpI80lDFvRmPVg6oqboNHfoH4CQIfNA+HOrZ7Mo7KZP02dC6LjghPQJeBsvXhJod/wnIBg==", + "cpu": [ + "arm64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-gnu": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.32.0.tgz", + "integrity": "sha512-V7Qr52IhZmdKPVr+Vtw8o+WLsQJYCTd8loIfpDaMRWGUZfBOYEJeyJIkqGIDMZPwPx24pUMfwSxxI8phr/MbOA==", + "cpu": [ + "x64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-musl": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.32.0.tgz", + "integrity": "sha512-bYcLp+Vb0awsiXg/80uCRezCYHNg1/l3mt0gzHnWV9XP1W5sKa5/TCdGWaR/zBM2PeF/HbsQv/j2URNOiVuxWg==", + "cpu": [ + "x64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-arm64-msvc": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.32.0.tgz", + "integrity": "sha512-8SbC8BR40pS6baCM8sbtYDSwEVQd4JlFTOlaD3gWGHfThTcABnNDBda6eTZeqbofalIJhFx0qKzgHJmcPTnGdw==", + "cpu": [ + "arm64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-x64-msvc": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.32.0.tgz", + "integrity": "sha512-Amq9B/SoZYdDi1kFrojnoqPLxYhQ4Wo5XiL8EVJrVsB8ARoC1PWW6VGtT0WKCemjy8aC+louJnjS7U18x3b06Q==", + "cpu": [ + "x64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/longest-streak": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-3.1.0.tgz", + "integrity": "sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "license": "ISC", + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/lucide-react": { + "version": "0.460.0", + "resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-0.460.0.tgz", + "integrity": "sha512-BVtq/DykVeIvRTJvRAgCsOwaGL8Un3Bxh8MbDxMhEWlZay3T4IpEKDEpwt5KZ0KJMHzgm6jrltxlT5eXOWXDHg==", + "license": "ISC", + "peerDependencies": { + "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0-rc" + } + }, + "node_modules/magic-string": { + "version": "0.30.21", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", + "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } + }, + "node_modules/magicast": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/magicast/-/magicast-0.5.3.tgz", + "integrity": "sha512-pVKE4UdSQ7DvHzivsCIFx2BJn1mHG6KsyrFcaxFx6tONdneEuThrDx0Cj3AMg58KyN4pzYT+LHOotxDQDjNvkw==", + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.3", + "@babel/types": "^7.29.0", + "source-map-js": "^1.2.1" + } + }, + "node_modules/markdown-table": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-3.0.4.tgz", + "integrity": "sha512-wiYz4+JrLyb/DqW2hkFJxP7Vd7JuTDm77fvbM8VfEQdmSMqcImWeeRbHwZjBjIFki/VaMK2BhFi7oUUZeM5bqw==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/mdast-util-definitions": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-definitions/-/mdast-util-definitions-6.0.0.tgz", + "integrity": "sha512-scTllyX6pnYNZH/AIp/0ePz6s4cZtARxImwoPJ7kS42n+MnVsI4XbnG6d4ibehRIldYMWM2LD7ImQblVhUejVQ==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "@types/unist": "^3.0.0", + "unist-util-visit": "^5.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-find-and-replace": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mdast-util-find-and-replace/-/mdast-util-find-and-replace-3.0.2.tgz", + "integrity": "sha512-Tmd1Vg/m3Xz43afeNxDIhWRtFZgM2VLyaf4vSTYwudTyeuTneoL3qtWMA5jeLyz/O1vDJmmV4QuScFCA2tBPwg==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "escape-string-regexp": "^5.0.0", + "unist-util-is": "^6.0.0", + "unist-util-visit-parents": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-from-markdown": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.3.tgz", + "integrity": "sha512-W4mAWTvSlKvf8L6J+VN9yLSqQ9AOAAvHuoDAmPkz4dHf553m5gVj2ejadHJhoJmcmxEnOv6Pa8XJhpxE93kb8Q==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "@types/unist": "^3.0.0", + "decode-named-character-reference": "^1.0.0", + "devlop": "^1.0.0", + "mdast-util-to-string": "^4.0.0", + "micromark": "^4.0.0", + "micromark-util-decode-numeric-character-reference": "^2.0.0", + "micromark-util-decode-string": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0", + "unist-util-stringify-position": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-gfm": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-gfm/-/mdast-util-gfm-3.1.0.tgz", + "integrity": "sha512-0ulfdQOM3ysHhCJ1p06l0b0VKlhU0wuQs3thxZQagjcjPrlFRqY215uZGHHJan9GEAXd9MbfPjFJz+qMkVR6zQ==", + "license": "MIT", + "dependencies": { + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-gfm-autolink-literal": "^2.0.0", + "mdast-util-gfm-footnote": "^2.0.0", + "mdast-util-gfm-strikethrough": "^2.0.0", + "mdast-util-gfm-table": "^2.0.0", + "mdast-util-gfm-task-list-item": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-gfm-autolink-literal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-autolink-literal/-/mdast-util-gfm-autolink-literal-2.0.1.tgz", + "integrity": "sha512-5HVP2MKaP6L+G6YaxPNjuL0BPrq9orG3TsrZ9YXbA3vDw/ACI4MEsnoDpn6ZNm7GnZgtAcONJyPhOP8tNJQavQ==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "ccount": "^2.0.0", + "devlop": "^1.0.0", + "mdast-util-find-and-replace": "^3.0.0", + "micromark-util-character": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-gfm-footnote": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-footnote/-/mdast-util-gfm-footnote-2.1.0.tgz", + "integrity": "sha512-sqpDWlsHn7Ac9GNZQMeUzPQSMzR6Wv0WKRNvQRg0KqHh02fpTz69Qc1QSseNX29bhz1ROIyNyxExfawVKTm1GQ==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "devlop": "^1.1.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-gfm-strikethrough": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-strikethrough/-/mdast-util-gfm-strikethrough-2.0.0.tgz", + "integrity": "sha512-mKKb915TF+OC5ptj5bJ7WFRPdYtuHv0yTRxK2tJvi+BDqbkiG7h7u/9SI89nRAYcmap2xHQL9D+QG/6wSrTtXg==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-gfm-table": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-table/-/mdast-util-gfm-table-2.0.0.tgz", + "integrity": "sha512-78UEvebzz/rJIxLvE7ZtDd/vIQ0RHv+3Mh5DR96p7cS7HsBhYIICDBCu8csTNWNO6tBWfqXPWekRuj2FNOGOZg==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "devlop": "^1.0.0", + "markdown-table": "^3.0.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-gfm-task-list-item": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-task-list-item/-/mdast-util-gfm-task-list-item-2.0.0.tgz", + "integrity": "sha512-IrtvNvjxC1o06taBAVJznEnkiHxLFTzgonUdy8hzFVeDun0uTjxxrRGVaNFqkU1wJR3RBPEfsxmU6jDWPofrTQ==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "devlop": "^1.0.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-phrasing": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-4.1.0.tgz", + "integrity": "sha512-TqICwyvJJpBwvGAMZjj4J2n0X8QWp21b9l0o7eXyVJ25YNWYbJDVIyD1bZXE6WtV6RmKJVYmQAKWa0zWOABz2w==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "unist-util-is": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-to-hast": { + "version": "13.2.1", + "resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-13.2.1.tgz", + "integrity": "sha512-cctsq2wp5vTsLIcaymblUriiTcZd0CwWtCbLvrOzYCDZoWyMNV8sZ7krj09FSnsiJi3WVsHLM4k6Dq/yaPyCXA==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/mdast": "^4.0.0", + "@ungap/structured-clone": "^1.0.0", + "devlop": "^1.0.0", + "micromark-util-sanitize-uri": "^2.0.0", + "trim-lines": "^3.0.0", + "unist-util-position": "^5.0.0", + "unist-util-visit": "^5.0.0", + "vfile": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-to-markdown": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.1.2.tgz", + "integrity": "sha512-xj68wMTvGXVOKonmog6LwyJKrYXZPvlwabaryTjLh9LuvovB/KAH+kvi8Gjj+7rJjsFi23nkUxRQv1KqSroMqA==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "@types/unist": "^3.0.0", + "longest-streak": "^3.0.0", + "mdast-util-phrasing": "^4.0.0", + "mdast-util-to-string": "^4.0.0", + "micromark-util-classify-character": "^2.0.0", + "micromark-util-decode-string": "^2.0.0", + "unist-util-visit": "^5.0.0", + "zwitch": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-to-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-4.0.0.tgz", + "integrity": "sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdn-data": { + "version": "2.27.1", + "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.27.1.tgz", + "integrity": "sha512-9Yubnt3e8A0OKwxYSXyhLymGW4sCufcLG6VdiDdUGVkPhpqLxlvP5vl1983gQjJl3tqbrM731mjaZaP68AgosQ==", + "license": "CC0-1.0" + }, + "node_modules/micromark": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.2.tgz", + "integrity": "sha512-zpe98Q6kvavpCr1NPVSCMebCKfD7CA2NqZ+rykeNhONIJBpc1tFKt9hucLGwha3jNTNI8lHpctWJWoimVF4PfA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "@types/debug": "^4.0.0", + "debug": "^4.0.0", + "decode-named-character-reference": "^1.0.0", + "devlop": "^1.0.0", + "micromark-core-commonmark": "^2.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-chunked": "^2.0.0", + "micromark-util-combine-extensions": "^2.0.0", + "micromark-util-decode-numeric-character-reference": "^2.0.0", + "micromark-util-encode": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-resolve-all": "^2.0.0", + "micromark-util-sanitize-uri": "^2.0.0", + "micromark-util-subtokenize": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-core-commonmark": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-2.0.3.tgz", + "integrity": "sha512-RDBrHEMSxVFLg6xvnXmb1Ayr2WzLAWjeSATAoxwKYJV94TeNavgoIdA0a9ytzDSVzBy2YKFK+emCPOEibLeCrg==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "decode-named-character-reference": "^1.0.0", + "devlop": "^1.0.0", + "micromark-factory-destination": "^2.0.0", + "micromark-factory-label": "^2.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-factory-title": "^2.0.0", + "micromark-factory-whitespace": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-chunked": "^2.0.0", + "micromark-util-classify-character": "^2.0.0", + "micromark-util-html-tag-name": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-resolve-all": "^2.0.0", + "micromark-util-subtokenize": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-extension-gfm": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm/-/micromark-extension-gfm-3.0.0.tgz", + "integrity": "sha512-vsKArQsicm7t0z2GugkCKtZehqUm31oeGBV/KVSorWSy8ZlNAv7ytjFhvaryUiCUJYqs+NoE6AFhpQvBTM6Q4w==", + "license": "MIT", + "dependencies": { + "micromark-extension-gfm-autolink-literal": "^2.0.0", + "micromark-extension-gfm-footnote": "^2.0.0", + "micromark-extension-gfm-strikethrough": "^2.0.0", + "micromark-extension-gfm-table": "^2.0.0", + "micromark-extension-gfm-tagfilter": "^2.0.0", + "micromark-extension-gfm-task-list-item": "^2.0.0", + "micromark-util-combine-extensions": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-gfm-autolink-literal": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-autolink-literal/-/micromark-extension-gfm-autolink-literal-2.1.0.tgz", + "integrity": "sha512-oOg7knzhicgQ3t4QCjCWgTmfNhvQbDDnJeVu9v81r7NltNCVmhPy1fJRX27pISafdjL+SVc4d3l48Gb6pbRypw==", + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-sanitize-uri": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-gfm-footnote": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-footnote/-/micromark-extension-gfm-footnote-2.1.0.tgz", + "integrity": "sha512-/yPhxI1ntnDNsiHtzLKYnE3vf9JZ6cAisqVDauhp4CEHxlb4uoOTxOCJ+9s51bIB8U1N1FJ1RXOKTIlD5B/gqw==", + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-core-commonmark": "^2.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-sanitize-uri": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-gfm-strikethrough": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-strikethrough/-/micromark-extension-gfm-strikethrough-2.1.0.tgz", + "integrity": "sha512-ADVjpOOkjz1hhkZLlBiYA9cR2Anf8F4HqZUO6e5eDcPQd0Txw5fxLzzxnEkSkfnD0wziSGiv7sYhk/ktvbf1uw==", + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-util-chunked": "^2.0.0", + "micromark-util-classify-character": "^2.0.0", + "micromark-util-resolve-all": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-gfm-table": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-table/-/micromark-extension-gfm-table-2.1.1.tgz", + "integrity": "sha512-t2OU/dXXioARrC6yWfJ4hqB7rct14e8f7m0cbI5hUmDyyIlwv5vEtooptH8INkbLzOatzKuVbQmAYcbWoyz6Dg==", + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-gfm-tagfilter": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-tagfilter/-/micromark-extension-gfm-tagfilter-2.0.0.tgz", + "integrity": "sha512-xHlTOmuCSotIA8TW1mDIM6X2O1SiX5P9IuDtqGonFhEK0qgRI4yeC6vMxEV2dgyr2TiD+2PQ10o+cOhdVAcwfg==", + "license": "MIT", + "dependencies": { + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-gfm-task-list-item": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-task-list-item/-/micromark-extension-gfm-task-list-item-2.1.0.tgz", + "integrity": "sha512-qIBZhqxqI6fjLDYFTBIa4eivDMnP+OZqsNwmQ3xNLE4Cxwc+zfQEfbs6tzAo2Hjq+bh6q5F+Z8/cksrLFYWQQw==", + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-factory-destination": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.1.tgz", + "integrity": "sha512-Xe6rDdJlkmbFRExpTOmRj9N3MaWmbAgdpSrBQvCFqhezUn4AHqJHbaEnfbVYYiexVSs//tqOdY/DxhjdCiJnIA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-label": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-2.0.1.tgz", + "integrity": "sha512-VFMekyQExqIW7xIChcXn4ok29YE3rnuyveW3wZQWWqF4Nv9Wk5rgJ99KzPvHjkmPXF93FXIbBp6YdW3t71/7Vg==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-space": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", + "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-title": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-2.0.1.tgz", + "integrity": "sha512-5bZ+3CjhAd9eChYTHsjy6TGxpOFSKgKKJPJxr293jTbfry2KDoWkhBb6TcPVB4NmzaPhMs1Frm9AZH7OD4Cjzw==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-whitespace": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-2.0.1.tgz", + "integrity": "sha512-Ob0nuZ3PKt/n0hORHyvoD9uZhr+Za8sFoP+OnMcnWK5lngSzALgQYKMr9RJVOWLqQYuyn6ulqGWSXdwf6F80lQ==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-character": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", + "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-chunked": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-2.0.1.tgz", + "integrity": "sha512-QUNFEOPELfmvv+4xiNg2sRYeS/P84pTW0TCgP5zc9FpXetHY0ab7SxKyAQCNCc1eK0459uoLI1y5oO5Vc1dbhA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-classify-character": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-2.0.1.tgz", + "integrity": "sha512-K0kHzM6afW/MbeWYWLjoHQv1sgg2Q9EccHEDzSkxiP/EaagNzCm7T/WMKZ3rjMbvIpvBiZgwR3dKMygtA4mG1Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-combine-extensions": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-2.0.1.tgz", + "integrity": "sha512-OnAnH8Ujmy59JcyZw8JSbK9cGpdVY44NKgSM7E9Eh7DiLS2E9RNQf0dONaGDzEG9yjEl5hcqeIsj4hfRkLH/Bg==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-chunked": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-decode-numeric-character-reference": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-2.0.2.tgz", + "integrity": "sha512-ccUbYk6CwVdkmCQMyr64dXz42EfHGkPQlBj5p7YVGzq8I7CtjXZJrubAYezf7Rp+bjPseiROqe7G6foFd+lEuw==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-decode-string": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-decode-string/-/micromark-util-decode-string-2.0.1.tgz", + "integrity": "sha512-nDV/77Fj6eH1ynwscYTOsbK7rR//Uj0bZXBwJZRfaLEJ1iGBR6kIfNmlNqaqJf649EP0F3NWNdeJi03elllNUQ==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "decode-named-character-reference": "^1.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-decode-numeric-character-reference": "^2.0.0", + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-encode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.1.tgz", + "integrity": "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-html-tag-name": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-2.0.1.tgz", + "integrity": "sha512-2cNEiYDhCWKI+Gs9T0Tiysk136SnR13hhO8yW6BGNyhOC4qYFnwF1nKfD3HFAIXA5c45RrIG1ub11GiXeYd1xA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-normalize-identifier": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-2.0.1.tgz", + "integrity": "sha512-sxPqmo70LyARJs0w2UclACPUUEqltCkJ6PhKdMIDuJ3gSf/Q+/GIe3WKl0Ijb/GyH9lOpUkRAO2wp0GVkLvS9Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-resolve-all": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-2.0.1.tgz", + "integrity": "sha512-VdQyxFWFT2/FGJgwQnJYbe1jjQoNTS4RjglmSjTUlpUMa95Htx9NHeYW4rGDJzbjvCsl9eLjMQwGeElsqmzcHg==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-sanitize-uri": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.1.tgz", + "integrity": "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-encode": "^2.0.0", + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-subtokenize": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.1.0.tgz", + "integrity": "sha512-XQLu552iSctvnEcgXw6+Sx75GflAPNED1qx7eBJ+wydBb2KCbRZe+NwvIEEMM83uml1+2WSXpBAcp9IUCgCYWA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-util-chunked": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-symbol": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/mime-db": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz", + "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", + "license": "MIT", + "dependencies": { + "mime-db": "^1.54.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/minimatch": { + "version": "10.2.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.5.tgz", + "integrity": "sha512-MULkVLfKGYDFYejP07QOurDLLQpcjk7Fw+7jXS2R2czRQzR56yHRveU5NDJEOviH+hETZKSkIk5c+T23GjFUMg==", + "license": "BlueOak-1.0.0", + "dependencies": { + "brace-expansion": "^5.0.5" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/minipass": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz", + "integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==", + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/minizlib": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-3.1.0.tgz", + "integrity": "sha512-KZxYo1BUkWD2TVFLr0MQoM8vUUigWD3LlD83a/75BqC+4qE0Hb1Vo5v1FgcfaNXvfXzr+5EhQ6ing/CaBijTlw==", + "license": "MIT", + "dependencies": { + "minipass": "^7.1.2" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/mrmime": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.1.tgz", + "integrity": "sha512-Y3wQdFg2Va6etvQ5I82yUhGdsKrcYox6p7FfL1LbK2J4V01F9TGlepTIhnK24t7koZibmg82KGglhA1XK5IsLQ==", + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/nanoid": { + "version": "3.3.12", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.12.tgz", + "integrity": "sha512-ZB9RH/39qpq5Vu6Y+NmUaFhQR6pp+M2Xt76XBnEwDaGcVAqhlvxrl3B2bKS5D3NH3QR76v3aSrKaF/Kiy7lEtQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/neotraverse": { + "version": "0.6.18", + "resolved": "https://registry.npmjs.org/neotraverse/-/neotraverse-0.6.18.tgz", + "integrity": "sha512-Z4SmBUweYa09+o6pG+eASabEpP6QkQ70yHj351pQoEXIs8uHbaU2DWVmzBANKgflPa47A50PtB2+NgRpQvr7vA==", + "license": "MIT", + "engines": { + "node": ">= 10" + } + }, + "node_modules/nlcst-to-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/nlcst-to-string/-/nlcst-to-string-4.0.0.tgz", + "integrity": "sha512-YKLBCcUYKAg0FNlOBT6aI91qFmSiFKiluk655WzPF+DDMA02qIyy8uiRqI8QXtcFpEvll12LpL5MXqEmAZ+dcA==", + "license": "MIT", + "dependencies": { + "@types/nlcst": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/node-fetch-native": { + "version": "1.6.7", + "resolved": "https://registry.npmjs.org/node-fetch-native/-/node-fetch-native-1.6.7.tgz", + "integrity": "sha512-g9yhqoedzIUm0nTnTqAQvueMPVOuIY16bqgAJJC8XOOubYFNwz6IER9qs0Gq2Xd0+CecCKFjtdDTMA4u4xG06Q==", + "license": "MIT" + }, + "node_modules/node-gyp-build": { + "version": "4.8.4", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.4.tgz", + "integrity": "sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ==", + "license": "MIT", + "bin": { + "node-gyp-build": "bin.js", + "node-gyp-build-optional": "optional.js", + "node-gyp-build-test": "build-test.js" + } + }, + "node_modules/node-mock-http": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/node-mock-http/-/node-mock-http-1.0.4.tgz", + "integrity": "sha512-8DY+kFsDkNXy1sJglUfuODx1/opAGJGyrTuFqEoN90oRc2Vk0ZbD4K2qmKXBBEhZQzdKHIVfEJpDU8Ak2NJEvQ==", + "license": "MIT" + }, + "node_modules/node-releases": { + "version": "2.0.44", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.44.tgz", + "integrity": "sha512-5WUyunoPMsvvEhS8AxHtRzP+oA8UCkJ7YRxatWKjngndhDGLiqEVAQKWjFAiAiuL8zMRGzGSJxFnLetoa43qGQ==", + "license": "MIT" + }, + "node_modules/nodemailer": { + "version": "8.0.7", + "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-8.0.7.tgz", + "integrity": "sha512-pkjE4mkBzQjdJT4/UmlKl3pX0rC9fZmjh7c6C9o7lv66Ac6w9WCnzPzhbPNxwZAzlF4mdq4CSWB5+FbK6FWCow==", + "license": "MIT-0", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/nopt": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-8.1.0.tgz", + "integrity": "sha512-ieGu42u/Qsa4TFktmaKEwM6MQH0pOWnaB3htzh0JRtx84+Mebc0cbZYN5bC+6WTZ4+77xrL9Pn5m7CV6VIkV7A==", + "license": "ISC", + "dependencies": { + "abbrev": "^3.0.0" + }, + "bin": { + "nopt": "bin/nopt.js" + }, + "engines": { + "node": "^18.17.0 || >=20.5.0" + } + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/nth-check": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", + "integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==", + "license": "BSD-2-Clause", + "dependencies": { + "boolbase": "^1.0.0" + }, + "funding": { + "url": "https://github.com/fb55/nth-check?sponsor=1" + } + }, + "node_modules/obug": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/obug/-/obug-2.1.1.tgz", + "integrity": "sha512-uTqF9MuPraAQ+IsnPf366RG4cP9RtUi7MLO1N3KEc+wb0a6yKpeL0lmk2IB1jY5KHPAlTc6T/JRdC/YqxHNwkQ==", + "funding": [ + "https://github.com/sponsors/sxzz", + "https://opencollective.com/debug" + ], + "license": "MIT" + }, + "node_modules/ofetch": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/ofetch/-/ofetch-1.5.1.tgz", + "integrity": "sha512-2W4oUZlVaqAPAil6FUg/difl6YhqhUR7x2eZY4bQCko22UXg3hptq9KLQdqFClV+Wu85UX7hNtdGTngi/1BxcA==", + "license": "MIT", + "dependencies": { + "destr": "^2.0.5", + "node-fetch-native": "^1.6.7", + "ufo": "^1.6.1" + } + }, + "node_modules/ohash": { + "version": "2.0.11", + "resolved": "https://registry.npmjs.org/ohash/-/ohash-2.0.11.tgz", + "integrity": "sha512-RdR9FQrFwNBNXAr4GixM8YaRZRJ5PUWbKYbE5eOsrwAjJW0q2REGcf79oYPsLyskQCZG1PLN+S/K1V00joZAoQ==", + "license": "MIT" + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/oniguruma-parser": { + "version": "0.12.2", + "resolved": "https://registry.npmjs.org/oniguruma-parser/-/oniguruma-parser-0.12.2.tgz", + "integrity": "sha512-6HVa5oIrgMC6aA6WF6XyyqbhRPJrKR02L20+2+zpDtO5QAzGHAUGw5TKQvwi5vctNnRHkJYmjAhRVQF2EKdTQw==", + "license": "MIT" + }, + "node_modules/oniguruma-to-es": { + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/oniguruma-to-es/-/oniguruma-to-es-4.3.6.tgz", + "integrity": "sha512-csuQ9x3Yr0cEIs/Zgx/OEt9iBw9vqIunAPQkx19R/fiMq2oGVTgcMqO/V3Ybqefr1TBvosI6jU539ksaBULJyA==", + "license": "MIT", + "dependencies": { + "oniguruma-parser": "^0.12.2", + "regex": "^6.1.0", + "regex-recursion": "^6.0.2" + } + }, + "node_modules/p-limit": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-7.3.0.tgz", + "integrity": "sha512-7cIXg/Z0M5WZRblrsOla88S4wAK+zOQQWeBYfV3qJuJXMr+LnbYjaadrFaS0JILfEDPVqHyKnZ1Z/1d6J9VVUw==", + "license": "MIT", + "dependencies": { + "yocto-queue": "^1.2.1" + }, + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-queue": { + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/p-queue/-/p-queue-9.3.0.tgz", + "integrity": "sha512-7NED7xhQ74Ngp4JP/2e0VZHp7vSWfJfqeiR92jPgxsz6m0Se4P03YoTKa9dDXyZ3r6P616gUXttrB6nnHYKang==", + "license": "MIT", + "dependencies": { + "eventemitter3": "^5.0.4", + "p-timeout": "^7.0.0" + }, + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-timeout": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-7.0.1.tgz", + "integrity": "sha512-AxTM2wDGORHGEkPCt8yqxOTMgpfbEHqF51f/5fJCmwFC3C/zNcGT63SymH2ttOAaiIws2zVg4+izQCjrakcwHg==", + "license": "MIT", + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/package-manager-detector": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/package-manager-detector/-/package-manager-detector-1.6.0.tgz", + "integrity": "sha512-61A5ThoTiDG/C8s8UMZwSorAGwMJ0ERVGj2OjoW5pAalsNOg15+iQiPzrLJ4jhZ1HJzmC2PIHT2oEiH3R5fzNA==", + "license": "MIT" + }, + "node_modules/parse-latin": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/parse-latin/-/parse-latin-7.0.0.tgz", + "integrity": "sha512-mhHgobPPua5kZ98EF4HWiH167JWBfl4pvAIXXdbaVohtK7a6YBOy56kvhCqduqyo/f3yrHFWmqmiMg/BkBkYYQ==", + "license": "MIT", + "dependencies": { + "@types/nlcst": "^2.0.0", + "@types/unist": "^3.0.0", + "nlcst-to-string": "^4.0.0", + "unist-util-modify-children": "^4.0.0", + "unist-util-visit-children": "^3.0.0", + "vfile": "^6.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/parse5": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.3.0.tgz", + "integrity": "sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==", + "license": "MIT", + "dependencies": { + "entities": "^6.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/path-scurry": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.2.tgz", + "integrity": "sha512-3O/iVVsJAPsOnpwWIeD+d6z/7PmqApyQePUtCndjatj/9I5LylHvt5qluFaBT3I5h3r1ejfR056c+FCv+NnNXg==", + "license": "BlueOak-1.0.0", + "dependencies": { + "lru-cache": "^11.0.0", + "minipass": "^7.1.2" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/path-scurry/node_modules/lru-cache": { + "version": "11.3.6", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.3.6.tgz", + "integrity": "sha512-Gf/KoL3C/MlI7Bt0PGI9I+TeTC/I6r/csU58N4BSNc4lppLBeKsOdFYkK+dX0ABDUMJNfCHTyPpzwwO21Awd3A==", + "license": "BlueOak-1.0.0", + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/path-to-regexp": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.1.0.tgz", + "integrity": "sha512-h9DqehX3zZZDCEm+xbfU0ZmwCGFCAAraPJWMXJ4+v32NjZJilVg3k1TcKsRgIb8IQ/izZSaydDc1OhJCZvs2Dw==", + "license": "MIT" + }, + "node_modules/path-to-regexp-updated": { + "name": "path-to-regexp", + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.3.0.tgz", + "integrity": "sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==", + "license": "MIT" + }, + "node_modules/piccolore": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/piccolore/-/piccolore-0.1.3.tgz", + "integrity": "sha512-o8bTeDWjE086iwKrROaDf31K0qC/BENdm15/uH9usSC/uZjJOKb2YGiVHfLY4GhwsERiPI1jmwI2XrA7ACOxVw==", + "license": "ISC" + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", + "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/postcss": { + "version": "8.5.14", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.14.tgz", + "integrity": "sha512-SoSL4+OSEtR99LHFZQiJLkT59C5B1amGO1NzTwj7TT1qCUgUO6hxOvzkOYxD+vMrXBM3XJIKzokoERdqQq/Zmg==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.11", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/prismjs": { + "version": "1.30.0", + "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.30.0.tgz", + "integrity": "sha512-DEvV2ZF2r2/63V+tK8hQvrR2ZGn10srHbXviTlcv7Kpzw8jWiNTqbVgjO3IY8RxrrOUF8VPMQQFysYYYv0YZxw==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/property-information": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/property-information/-/property-information-7.1.0.tgz", + "integrity": "sha512-TwEZ+X+yCJmYfL7TPUOcvBZ4QfoT5YenQiJuX//0th53DE6w0xxLEtfK3iyryQFddXuvkIk51EEgrJQ0WJkOmQ==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "license": "MIT", + "optional": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/radix3": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/radix3/-/radix3-1.1.2.tgz", + "integrity": "sha512-b484I/7b8rDEdSDKckSSBA8knMpcdsXudlE/LNL639wFoHKwLbEkQFZHWEYwDC0wa0FKUcCY+GAF73Z7wxNVFA==", + "license": "MIT" + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/react": { + "version": "19.2.6", + "resolved": "https://registry.npmjs.org/react/-/react-19.2.6.tgz", + "integrity": "sha512-sfWGGfavi0xr8Pg0sVsyHMAOziVYKgPLNrS7ig+ivMNb3wbCBw3KxtflsGBAwD3gYQlE/AEZsTLgToRrSCjb0Q==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-dom": { + "version": "19.2.6", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.6.tgz", + "integrity": "sha512-0prMI+hvBbPjsWnxDLxlCGyM8PN6UuWjEUCYmZhO67xIV9Xasa/r/vDnq+Xyq4Lo27g8QSbO5YzARu0D1Sps3g==", + "license": "MIT", + "dependencies": { + "scheduler": "^0.27.0" + }, + "peerDependencies": { + "react": "^19.2.6" + } + }, + "node_modules/react-refresh": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.18.0.tgz", + "integrity": "sha512-QgT5//D3jfjJb6Gsjxv0Slpj23ip+HtOpnNgnb2S5zU3CB26G/IDPGoy4RJB42wzFE46DRsstbW6tKHoKbhAxw==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/readdirp": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-5.0.0.tgz", + "integrity": "sha512-9u/XQ1pvrQtYyMpZe7DXKv2p5CNvyVwzUB6uhLAnQwHMSgKMBR62lc7AHljaeteeHXn11XTAaLLUVZYVZyuRBQ==", + "license": "MIT", + "engines": { + "node": ">= 20.19.0" + }, + "funding": { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/regex": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/regex/-/regex-6.1.0.tgz", + "integrity": "sha512-6VwtthbV4o/7+OaAF9I5L5V3llLEsoPyq9P1JVXkedTP33c7MfCG0/5NOPcSJn0TzXcG9YUrR0gQSWioew3LDg==", + "license": "MIT", + "dependencies": { + "regex-utilities": "^2.3.0" + } + }, + "node_modules/regex-recursion": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/regex-recursion/-/regex-recursion-6.0.2.tgz", + "integrity": "sha512-0YCaSCq2VRIebiaUviZNs0cBz1kg5kVS2UKUfNIx8YVs1cN3AV7NTctO5FOKBA+UT2BPJIWZauYHPqJODG50cg==", + "license": "MIT", + "dependencies": { + "regex-utilities": "^2.3.0" + } + }, + "node_modules/regex-utilities": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/regex-utilities/-/regex-utilities-2.3.0.tgz", + "integrity": "sha512-8VhliFJAWRaUiVvREIiW2NXXTmHs4vMNnSzuJVhscgmGav3g9VDxLrQndI3dZZVVdp0ZO/5v0xmX516/7M9cng==", + "license": "MIT" + }, + "node_modules/rehype": { + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/rehype/-/rehype-13.0.2.tgz", + "integrity": "sha512-j31mdaRFrwFRUIlxGeuPXXKWQxet52RBQRvCmzl5eCefn/KGbomK5GMHNMsOJf55fgo3qw5tST5neDuarDYR2A==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "rehype-parse": "^9.0.0", + "rehype-stringify": "^10.0.0", + "unified": "^11.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/rehype-parse": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/rehype-parse/-/rehype-parse-9.0.1.tgz", + "integrity": "sha512-ksCzCD0Fgfh7trPDxr2rSylbwq9iYDkSn8TCDmEJ49ljEUBxDVCzCHv7QNzZOfODanX4+bWQ4WZqLCRWYLfhag==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "hast-util-from-html": "^2.0.0", + "unified": "^11.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/rehype-raw": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/rehype-raw/-/rehype-raw-7.0.0.tgz", + "integrity": "sha512-/aE8hCfKlQeA8LmyeyQvQF3eBiLRGNlfBJEvWH7ivp9sBqs7TNqBL5X3v157rM4IFETqDnIOO+z5M/biZbo9Ww==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "hast-util-raw": "^9.0.0", + "vfile": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/rehype-stringify": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/rehype-stringify/-/rehype-stringify-10.0.1.tgz", + "integrity": "sha512-k9ecfXHmIPuFVI61B9DeLPN0qFHfawM6RsuX48hoqlaKSF61RskNjSm1lI8PhBEM0MRdLxVVm4WmTqJQccH9mA==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "hast-util-to-html": "^9.0.0", + "unified": "^11.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/remark-gfm": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/remark-gfm/-/remark-gfm-4.0.1.tgz", + "integrity": "sha512-1quofZ2RQ9EWdeN34S79+KExV1764+wCUGop5CPL1WGdD0ocPpu91lzPGbwWMECpEpd42kJGQwzRfyov9j4yNg==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "mdast-util-gfm": "^3.0.0", + "micromark-extension-gfm": "^3.0.0", + "remark-parse": "^11.0.0", + "remark-stringify": "^11.0.0", + "unified": "^11.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/remark-parse": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-11.0.0.tgz", + "integrity": "sha512-FCxlKLNGknS5ba/1lmpYijMUzX2esxW5xQqjWxw2eHFfS2MSdaHVINFmhjo+qN1WhZhNimq0dZATN9pH0IDrpA==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "mdast-util-from-markdown": "^2.0.0", + "micromark-util-types": "^2.0.0", + "unified": "^11.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/remark-rehype": { + "version": "11.1.2", + "resolved": "https://registry.npmjs.org/remark-rehype/-/remark-rehype-11.1.2.tgz", + "integrity": "sha512-Dh7l57ianaEoIpzbp0PC9UKAdCSVklD8E5Rpw7ETfbTl3FqcOOgq5q2LVDhgGCkaBv7p24JXikPdvhhmHvKMsw==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/mdast": "^4.0.0", + "mdast-util-to-hast": "^13.0.0", + "unified": "^11.0.0", + "vfile": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/remark-smartypants": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/remark-smartypants/-/remark-smartypants-3.0.2.tgz", + "integrity": "sha512-ILTWeOriIluwEvPjv67v7Blgrcx+LZOkAUVtKI3putuhlZm84FnqDORNXPPm+HY3NdZOMhyDwZ1E+eZB/Df5dA==", + "license": "MIT", + "dependencies": { + "retext": "^9.0.0", + "retext-smartypants": "^6.0.0", + "unified": "^11.0.4", + "unist-util-visit": "^5.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/remark-stringify": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/remark-stringify/-/remark-stringify-11.0.0.tgz", + "integrity": "sha512-1OSmLd3awB/t8qdoEOMazZkNsfVTeY4fTsgzcQFdXNq8ToTN4ZGwrMnlda4K6smTFKD+GRV6O48i6Z4iKgPPpw==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "mdast-util-to-markdown": "^2.0.0", + "unified": "^11.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "license": "MIT", + "funding": { + "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" + } + }, + "node_modules/retext": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/retext/-/retext-9.0.0.tgz", + "integrity": "sha512-sbMDcpHCNjvlheSgMfEcVrZko3cDzdbe1x/e7G66dFp0Ff7Mldvi2uv6JkJQzdRcvLYE8CA8Oe8siQx8ZOgTcA==", + "license": "MIT", + "dependencies": { + "@types/nlcst": "^2.0.0", + "retext-latin": "^4.0.0", + "retext-stringify": "^4.0.0", + "unified": "^11.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/retext-latin": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/retext-latin/-/retext-latin-4.0.0.tgz", + "integrity": "sha512-hv9woG7Fy0M9IlRQloq/N6atV82NxLGveq+3H2WOi79dtIYWN8OaxogDm77f8YnVXJL2VD3bbqowu5E3EMhBYA==", + "license": "MIT", + "dependencies": { + "@types/nlcst": "^2.0.0", + "parse-latin": "^7.0.0", + "unified": "^11.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/retext-smartypants": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/retext-smartypants/-/retext-smartypants-6.2.0.tgz", + "integrity": "sha512-kk0jOU7+zGv//kfjXEBjdIryL1Acl4i9XNkHxtM7Tm5lFiCog576fjNC9hjoR7LTKQ0DsPWy09JummSsH1uqfQ==", + "license": "MIT", + "dependencies": { + "@types/nlcst": "^2.0.0", + "nlcst-to-string": "^4.0.0", + "unist-util-visit": "^5.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/retext-stringify": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/retext-stringify/-/retext-stringify-4.0.0.tgz", + "integrity": "sha512-rtfN/0o8kL1e+78+uxPTqu1Klt0yPzKuQ2BfWwwfgIUSayyzxpM1PJzkKt4V8803uB9qSy32MvI7Xep9khTpiA==", + "license": "MIT", + "dependencies": { + "@types/nlcst": "^2.0.0", + "nlcst-to-string": "^4.0.0", + "unified": "^11.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/rollup": { + "version": "4.60.4", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.60.4.tgz", + "integrity": "sha512-WHeFSbZYsPu3+bLoNRUuAO+wavNlocOPf3wSHTP7hcFKVnJeWsYlCDbr3mTS14FCizf9ccIxXA8sGL8zKeQN3g==", + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.8" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.60.4", + "@rollup/rollup-android-arm64": "4.60.4", + "@rollup/rollup-darwin-arm64": "4.60.4", + "@rollup/rollup-darwin-x64": "4.60.4", + "@rollup/rollup-freebsd-arm64": "4.60.4", + "@rollup/rollup-freebsd-x64": "4.60.4", + "@rollup/rollup-linux-arm-gnueabihf": "4.60.4", + "@rollup/rollup-linux-arm-musleabihf": "4.60.4", + "@rollup/rollup-linux-arm64-gnu": "4.60.4", + "@rollup/rollup-linux-arm64-musl": "4.60.4", + "@rollup/rollup-linux-loong64-gnu": "4.60.4", + "@rollup/rollup-linux-loong64-musl": "4.60.4", + "@rollup/rollup-linux-ppc64-gnu": "4.60.4", + "@rollup/rollup-linux-ppc64-musl": "4.60.4", + "@rollup/rollup-linux-riscv64-gnu": "4.60.4", + "@rollup/rollup-linux-riscv64-musl": "4.60.4", + "@rollup/rollup-linux-s390x-gnu": "4.60.4", + "@rollup/rollup-linux-x64-gnu": "4.60.4", + "@rollup/rollup-linux-x64-musl": "4.60.4", + "@rollup/rollup-openbsd-x64": "4.60.4", + "@rollup/rollup-openharmony-arm64": "4.60.4", + "@rollup/rollup-win32-arm64-msvc": "4.60.4", + "@rollup/rollup-win32-ia32-msvc": "4.60.4", + "@rollup/rollup-win32-x64-gnu": "4.60.4", + "@rollup/rollup-win32-x64-msvc": "4.60.4", + "fsevents": "~2.3.2" + } + }, + "node_modules/rollup/node_modules/@types/estree": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", + "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", + "license": "MIT" + }, + "node_modules/sax": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.6.0.tgz", + "integrity": "sha512-6R3J5M4AcbtLUdZmRv2SygeVaM7IhrLXu9BmnOGmmACak8fiUtOsYNWUS4uK7upbmHIBbLBeFeI//477BKLBzA==", + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=11.0.0" + } + }, + "node_modules/scheduler": { + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.27.0.tgz", + "integrity": "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==", + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.0.tgz", + "integrity": "sha512-AcM7dV/5ul4EekoQ29Agm5vri8JNqRyj39o0qpX6vDF2GZrtutZl5RwgD1XnZjiTAfncsJhMI48QQH3sN87YNA==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/send": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz", + "integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.3", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "fresh": "^2.0.0", + "http-errors": "^2.0.1", + "mime-types": "^3.0.2", + "ms": "^2.1.3", + "on-finished": "^2.4.1", + "range-parser": "^1.2.1", + "statuses": "^2.0.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/server-destroy": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/server-destroy/-/server-destroy-1.0.1.tgz", + "integrity": "sha512-rb+9B5YBIEzYcD6x2VKidaa+cqYBJQKnU4oe4E3ANwRRN56yk/ua1YCJT1n21NTS8w6CcOclAKNP3PhdCXKYtQ==", + "license": "ISC" + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, + "node_modules/sharp": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.34.5.tgz", + "integrity": "sha512-Ou9I5Ft9WNcCbXrU9cMgPBcCK8LiwLqcbywW3t4oDV37n1pzpuNLsYiAV8eODnjbtQlSDwZ2cUEeQz4E54Hltg==", + "hasInstallScript": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "@img/colour": "^1.0.0", + "detect-libc": "^2.1.2", + "semver": "^7.7.3" + }, + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-darwin-arm64": "0.34.5", + "@img/sharp-darwin-x64": "0.34.5", + "@img/sharp-libvips-darwin-arm64": "1.2.4", + "@img/sharp-libvips-darwin-x64": "1.2.4", + "@img/sharp-libvips-linux-arm": "1.2.4", + "@img/sharp-libvips-linux-arm64": "1.2.4", + "@img/sharp-libvips-linux-ppc64": "1.2.4", + "@img/sharp-libvips-linux-riscv64": "1.2.4", + "@img/sharp-libvips-linux-s390x": "1.2.4", + "@img/sharp-libvips-linux-x64": "1.2.4", + "@img/sharp-libvips-linuxmusl-arm64": "1.2.4", + "@img/sharp-libvips-linuxmusl-x64": "1.2.4", + "@img/sharp-linux-arm": "0.34.5", + "@img/sharp-linux-arm64": "0.34.5", + "@img/sharp-linux-ppc64": "0.34.5", + "@img/sharp-linux-riscv64": "0.34.5", + "@img/sharp-linux-s390x": "0.34.5", + "@img/sharp-linux-x64": "0.34.5", + "@img/sharp-linuxmusl-arm64": "0.34.5", + "@img/sharp-linuxmusl-x64": "0.34.5", + "@img/sharp-wasm32": "0.34.5", + "@img/sharp-win32-arm64": "0.34.5", + "@img/sharp-win32-ia32": "0.34.5", + "@img/sharp-win32-x64": "0.34.5" + } + }, + "node_modules/shiki": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-4.0.2.tgz", + "integrity": "sha512-eAVKTMedR5ckPo4xne/PjYQYrU3qx78gtJZ+sHlXEg5IHhhoQhMfZVzetTYuaJS0L2Ef3AcCRzCHV8T0WI6nIQ==", + "license": "MIT", + "dependencies": { + "@shikijs/core": "4.0.2", + "@shikijs/engine-javascript": "4.0.2", + "@shikijs/engine-oniguruma": "4.0.2", + "@shikijs/langs": "4.0.2", + "@shikijs/themes": "4.0.2", + "@shikijs/types": "4.0.2", + "@shikijs/vscode-textmate": "^10.0.2", + "@types/hast": "^3.0.4" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/sisteransi": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", + "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==", + "license": "MIT" + }, + "node_modules/sitemap": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/sitemap/-/sitemap-9.0.1.tgz", + "integrity": "sha512-S6hzjGJSG3d6if0YoF5kTyeRJvia6FSTBroE5fQ0bu1QNxyJqhhinfUsXi9fH3MgtXODWvwo2BDyQSnhPQ88uQ==", + "license": "MIT", + "dependencies": { + "@types/node": "^24.9.2", + "@types/sax": "^1.2.1", + "arg": "^5.0.0", + "sax": "^1.4.1" + }, + "bin": { + "sitemap": "dist/esm/cli.js" + }, + "engines": { + "node": ">=20.19.5", + "npm": ">=10.8.2" + } + }, + "node_modules/smol-toml": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.6.1.tgz", + "integrity": "sha512-dWUG8F5sIIARXih1DTaQAX4SsiTXhInKf1buxdY9DIg4ZYPZK5nGM1VRIYmEbDbsHt7USo99xSLFu5Q1IqTmsg==", + "license": "BSD-3-Clause", + "engines": { + "node": ">= 18" + }, + "funding": { + "url": "https://github.com/sponsors/cyyynthia" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/space-separated-tokens": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-2.0.2.tgz", + "integrity": "sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/stream-replace-string": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/stream-replace-string/-/stream-replace-string-2.0.0.tgz", + "integrity": "sha512-TlnjJ1C0QrmxRNrON00JvaFFlNh5TTG00APw23j74ET7gkQpTASi6/L2fuiav8pzK715HXtUeClpBTw2NPSn6w==", + "license": "MIT" + }, + "node_modules/stringify-entities": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-4.0.4.tgz", + "integrity": "sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg==", + "license": "MIT", + "dependencies": { + "character-entities-html4": "^2.0.0", + "character-entities-legacy": "^3.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/svgo": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/svgo/-/svgo-4.0.1.tgz", + "integrity": "sha512-XDpWUOPC6FEibaLzjfe0ucaV0YrOjYotGJO1WpF0Zd+n6ZGEQUsSugaoLq9QkEZtAfQIxT42UChcssDVPP3+/w==", + "license": "MIT", + "dependencies": { + "commander": "^11.1.0", + "css-select": "^5.1.0", + "css-tree": "^3.0.1", + "css-what": "^6.1.0", + "csso": "^5.0.5", + "picocolors": "^1.1.1", + "sax": "^1.5.0" + }, + "bin": { + "svgo": "bin/svgo.js" + }, + "engines": { + "node": ">=16" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/svgo" + } + }, + "node_modules/swiper": { + "version": "11.2.10", + "resolved": "https://registry.npmjs.org/swiper/-/swiper-11.2.10.tgz", + "integrity": "sha512-RMeVUUjTQH+6N3ckimK93oxz6Sn5la4aDlgPzB+rBrG/smPdCTicXyhxa+woIpopz+jewEloiEE3lKo1h9w2YQ==", + "funding": [ + { + "type": "patreon", + "url": "https://www.patreon.com/swiperjs" + }, + { + "type": "open_collective", + "url": "http://opencollective.com/swiper" + } + ], + "license": "MIT", + "engines": { + "node": ">= 4.7.0" + } + }, + "node_modules/tailwindcss": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.3.0.tgz", + "integrity": "sha512-y6nxMGB1nMW9R6k96e5gdIFzcfL/gTJRNaqGes1YvkLnPVXzWgbqFF2yLC0T8G774n24cx3Pe8XrKoniCOAH+Q==", + "license": "MIT" + }, + "node_modules/tapable": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.3.3.tgz", + "integrity": "sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A==", + "license": "MIT", + "engines": { + "node": ">=6" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + } + }, + "node_modules/tar": { + "version": "7.5.15", + "resolved": "https://registry.npmjs.org/tar/-/tar-7.5.15.tgz", + "integrity": "sha512-dzGK0boVlC4W5QFuQN1EFSl3bIDYsk7Tj40U6eIBnK2k/8ml7TZ5agbI5j5+qnoVcAA+rNtBml8SEiLxZpNqRQ==", + "license": "BlueOak-1.0.0", + "dependencies": { + "@isaacs/fs-minipass": "^4.0.0", + "chownr": "^3.0.0", + "minipass": "^7.1.2", + "minizlib": "^3.1.0", + "yallist": "^5.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/tar/node_modules/yallist": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-5.0.0.tgz", + "integrity": "sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==", + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/tiny-inflate": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/tiny-inflate/-/tiny-inflate-1.0.3.tgz", + "integrity": "sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw==", + "license": "MIT" + }, + "node_modules/tinyclip": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/tinyclip/-/tinyclip-0.1.12.tgz", + "integrity": "sha512-Ae3OVUqifDw0wBriIBS7yVaW44Dp6eSHQcyq4Igc7eN2TJH/2YsicswaW+J/OuMvhpDPOKEgpAZCjkb4hpoyeA==", + "license": "MIT", + "engines": { + "node": "^16.14.0 || >= 17.3.0" + } + }, + "node_modules/tinyexec": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.1.2.tgz", + "integrity": "sha512-dAqSqE/RabpBKI8+h26GfLq6Vb3JVXs30XYQjdMjaj/c2tS8IYYMbIzP599KtRj7c57/wYApb3QjgRgXmrCukA==", + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.16", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.16.tgz", + "integrity": "sha512-pn99VhoACYR8nFHhxqix+uvsbXineAasWm5ojXoN8xEwK5Kd3/TrhNn1wByuD52UxWRLy8pu+kRMniEi6Eq9Zg==", + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "license": "MIT" + }, + "node_modules/trim-lines": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-3.0.1.tgz", + "integrity": "sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/trough": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/trough/-/trough-2.2.0.tgz", + "integrity": "sha512-tmMpK00BjZiUyVyvrBK7knerNgmgvcV/KLVyuma/SC+TQN167GrMRciANTz09+k3zW8L8t60jWO1GpfkZdjTaw==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "license": "0BSD" + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/ufo": { + "version": "1.6.4", + "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.6.4.tgz", + "integrity": "sha512-JFNbkD1Svwe0KvGi8GOeLcP4kAWQ609twvCdcHxq1oSL8svv39ZuSvajcD8B+5D0eL4+s1Is2D/O6KN3qcTeRA==", + "license": "MIT" + }, + "node_modules/ultrahtml": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/ultrahtml/-/ultrahtml-1.6.0.tgz", + "integrity": "sha512-R9fBn90VTJrqqLDwyMph+HGne8eqY1iPfYhPzZrvKpIfwkWZbcYlfpsb8B9dTvBfpy1/hqAD7Wi8EKfP9e8zdw==", + "license": "MIT" + }, + "node_modules/uncrypto": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/uncrypto/-/uncrypto-0.1.3.tgz", + "integrity": "sha512-Ql87qFHB3s/De2ClA9e0gsnS6zXG27SkTiSJwjCc9MebbfapQfuPzumMIUMi38ezPZVNFcHI9sUIepeQfw8J8Q==", + "license": "MIT" + }, + "node_modules/undici-types": { + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", + "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", + "license": "MIT" + }, + "node_modules/unified": { + "version": "11.0.5", + "resolved": "https://registry.npmjs.org/unified/-/unified-11.0.5.tgz", + "integrity": "sha512-xKvGhPWw3k84Qjh8bI3ZeJjqnyadK+GEFtazSfZv/rKeTkTjOJho6mFqh2SM96iIcZokxiOpg78GazTSg8+KHA==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "bail": "^2.0.0", + "devlop": "^1.0.0", + "extend": "^3.0.0", + "is-plain-obj": "^4.0.0", + "trough": "^2.0.0", + "vfile": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unifont": { + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/unifont/-/unifont-0.7.4.tgz", + "integrity": "sha512-oHeis4/xl42HUIeHuNZRGEvxj5AaIKR+bHPNegRq5LV1gdc3jundpONbjglKpihmJf+dswygdMJn3eftGIMemg==", + "license": "MIT", + "dependencies": { + "css-tree": "^3.1.0", + "ofetch": "^1.5.1", + "ohash": "^2.0.11" + } + }, + "node_modules/unist-util-find-after": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/unist-util-find-after/-/unist-util-find-after-5.0.0.tgz", + "integrity": "sha512-amQa0Ep2m6hE2g72AugUItjbuM8X8cGQnFoHk0pGfrFeT9GZhzN5SW8nRsiGKK7Aif4CrACPENkA6P/Lw6fHGQ==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-is": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-is": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.1.tgz", + "integrity": "sha512-LsiILbtBETkDz8I9p1dQ0uyRUWuaQzd/cuEeS1hoRSyW5E5XGmTzlwY1OrNzzakGowI9Dr/I8HVaw4hTtnxy8g==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-modify-children": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/unist-util-modify-children/-/unist-util-modify-children-4.0.0.tgz", + "integrity": "sha512-+tdN5fGNddvsQdIzUF3Xx82CU9sMM+fA0dLgR9vOmT0oPT2jH+P1nd5lSqfCfXAw+93NhcXNY2qqvTUtE4cQkw==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "array-iterate": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-position": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-5.0.0.tgz", + "integrity": "sha512-fucsC7HjXvkB5R3kTCO7kUjRdrS0BJt3M/FPxmHMBOm8JQi2BsHAHFsy27E0EolP8rp0NzXsJ+jNPyDWvOJZPA==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-remove-position": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/unist-util-remove-position/-/unist-util-remove-position-5.0.0.tgz", + "integrity": "sha512-Hp5Kh3wLxv0PHj9m2yZhhLt58KzPtEYKQQ4yxfYFEO7EvHwzyDYnduhHnY1mDxoqr7VUwVuHXk9RXKIiYS1N8Q==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-visit": "^5.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-stringify-position": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz", + "integrity": "sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-visit": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.1.0.tgz", + "integrity": "sha512-m+vIdyeCOpdr/QeQCu2EzxX/ohgS8KbnPDgFni4dQsfSCtpz8UqDyY5GjRru8PDKuYn7Fq19j1CQ+nJSsGKOzg==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-is": "^6.0.0", + "unist-util-visit-parents": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-visit-children": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/unist-util-visit-children/-/unist-util-visit-children-3.0.0.tgz", + "integrity": "sha512-RgmdTfSBOg04sdPcpTSD1jzoNBjt9a80/ZCzp5cI9n1qPzLZWF9YdvWGN2zmTumP1HWhXKdUWexjy/Wy/lJ7tA==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-visit-parents": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.2.tgz", + "integrity": "sha512-goh1s1TBrqSqukSc8wrjwWhL0hiJxgA8m4kFxGlQ+8FYQ3C/m11FcTs4YYem7V664AhHVvgoQLk890Ssdsr2IQ==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-is": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unstorage": { + "version": "1.17.5", + "resolved": "https://registry.npmjs.org/unstorage/-/unstorage-1.17.5.tgz", + "integrity": "sha512-0i3iqvRfx29hkNntHyQvJTpf5W9dQ9ZadSoRU8+xVlhVtT7jAX57fazYO9EHvcRCfBCyi5YRya7XCDOsbTgkPg==", + "license": "MIT", + "dependencies": { + "anymatch": "^3.1.3", + "chokidar": "^5.0.0", + "destr": "^2.0.5", + "h3": "^1.15.10", + "lru-cache": "^11.2.7", + "node-fetch-native": "^1.6.7", + "ofetch": "^1.5.1", + "ufo": "^1.6.3" + }, + "peerDependencies": { + "@azure/app-configuration": "^1.8.0", + "@azure/cosmos": "^4.2.0", + "@azure/data-tables": "^13.3.0", + "@azure/identity": "^4.6.0", + "@azure/keyvault-secrets": "^4.9.0", + "@azure/storage-blob": "^12.26.0", + "@capacitor/preferences": "^6 || ^7 || ^8", + "@deno/kv": ">=0.9.0", + "@netlify/blobs": "^6.5.0 || ^7.0.0 || ^8.1.0 || ^9.0.0 || ^10.0.0", + "@planetscale/database": "^1.19.0", + "@upstash/redis": "^1.34.3", + "@vercel/blob": ">=0.27.1", + "@vercel/functions": "^2.2.12 || ^3.0.0", + "@vercel/kv": "^1 || ^2 || ^3", + "aws4fetch": "^1.0.20", + "db0": ">=0.2.1", + "idb-keyval": "^6.2.1", + "ioredis": "^5.4.2", + "uploadthing": "^7.4.4" + }, + "peerDependenciesMeta": { + "@azure/app-configuration": { + "optional": true + }, + "@azure/cosmos": { + "optional": true + }, + "@azure/data-tables": { + "optional": true + }, + "@azure/identity": { + "optional": true + }, + "@azure/keyvault-secrets": { + "optional": true + }, + "@azure/storage-blob": { + "optional": true + }, + "@capacitor/preferences": { + "optional": true + }, + "@deno/kv": { + "optional": true + }, + "@netlify/blobs": { + "optional": true + }, + "@planetscale/database": { + "optional": true + }, + "@upstash/redis": { + "optional": true + }, + "@vercel/blob": { + "optional": true + }, + "@vercel/functions": { + "optional": true + }, + "@vercel/kv": { + "optional": true + }, + "aws4fetch": { + "optional": true + }, + "db0": { + "optional": true + }, + "idb-keyval": { + "optional": true + }, + "ioredis": { + "optional": true + }, + "uploadthing": { + "optional": true + } + } + }, + "node_modules/unstorage/node_modules/lru-cache": { + "version": "11.3.6", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.3.6.tgz", + "integrity": "sha512-Gf/KoL3C/MlI7Bt0PGI9I+TeTC/I6r/csU58N4BSNc4lppLBeKsOdFYkK+dX0ABDUMJNfCHTyPpzwwO21Awd3A==", + "license": "BlueOak-1.0.0", + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/update-browserslist-db": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.2.3.tgz", + "integrity": "sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "escalade": "^3.2.0", + "picocolors": "^1.1.1" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "license": "BSD-2-Clause", + "optional": true, + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/vfile": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.3.tgz", + "integrity": "sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "vfile-message": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/vfile-location": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-5.0.3.tgz", + "integrity": "sha512-5yXvWDEgqeiYiBe1lbxYF7UMAIm/IcopxMHrMQDq3nvKcjPKIhZklUKL+AE7J7uApI4kwe2snsK+eI6UTj9EHg==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "vfile": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/vfile-message": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-4.0.3.tgz", + "integrity": "sha512-QTHzsGd1EhbZs4AsQ20JX1rC3cOlt/IWJruk893DfLRr57lcnOeMaWG4K0JrRta4mIJZKth2Au3mM3u03/JWKw==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-stringify-position": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/vite": { + "version": "7.3.3", + "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.3.tgz", + "integrity": "sha512-/4XH147Ui7OGTjg3HbdWe5arnZQSbfuRzdr9Ec7TQi5I7R+ir0Rlc9GIvD4v0XZurELqA035KVXJXpR61xhiTA==", + "license": "MIT", + "dependencies": { + "esbuild": "^0.27.0", + "fdir": "^6.5.0", + "picomatch": "^4.0.3", + "postcss": "^8.5.6", + "rollup": "^4.43.0", + "tinyglobby": "^0.2.15" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "lightningcss": "^1.21.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vitefu": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/vitefu/-/vitefu-1.1.3.tgz", + "integrity": "sha512-ub4okH7Z5KLjb6hDyjqrGXqWtWvoYdU3IGm/NorpgHncKoLTCfRIbvlhBm7r0YstIaQRYlp4yEbFqDcKSzXSSg==", + "license": "MIT", + "workspaces": [ + "tests/deps/*", + "tests/projects/*", + "tests/projects/workspace/packages/*" + ], + "peerDependencies": { + "vite": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "vite": { + "optional": true + } + } + }, + "node_modules/web-namespaces": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/web-namespaces/-/web-namespaces-2.0.1.tgz", + "integrity": "sha512-bKr1DkiNa2krS7qxNtdrtHAmzuYGFQLiQ13TsorsdT6ULTkPLKuu5+GsFpDlg6JFjUTwX2DyhMPG2be8uPrqsQ==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "license": "BSD-2-Clause" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "license": "MIT", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/which-pm-runs": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/which-pm-runs/-/which-pm-runs-1.1.0.tgz", + "integrity": "sha512-n1brCuqClxfFfq/Rb0ICg9giSZqCS+pLtccdag6C2HyufBrh3fBOiy9nb6ggRMvWOVH5GrdJskj5iGTZNxd7SA==", + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/xxhash-wasm": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/xxhash-wasm/-/xxhash-wasm-1.1.0.tgz", + "integrity": "sha512-147y/6YNh+tlp6nd/2pWq38i9h6mz/EuQ6njIrmW8D1BS5nCqs0P6DG+m6zTGnNz5I+uhZ0SHxBs9BsPrwcKDA==", + "license": "MIT" + }, + "node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "license": "ISC" + }, + "node_modules/yargs-parser": { + "version": "22.0.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-22.0.0.tgz", + "integrity": "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw==", + "license": "ISC", + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=23" + } + }, + "node_modules/yocto-queue": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.2.2.tgz", + "integrity": "sha512-4LCcse/U2MHZ63HAJVE+v71o7yOdIe4cZ70Wpf8D/IyjDKYQLV5GD46B+hSTjJsvV5PztjvHoU580EftxjDZFQ==", + "license": "MIT", + "engines": { + "node": ">=12.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/zod": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.4.3.tgz", + "integrity": "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + }, + "node_modules/zwitch": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz", + "integrity": "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000000000000000000000000000000000000..40e5ad482040b28f90358be0e9d4220436699f99 --- /dev/null +++ b/package.json @@ -0,0 +1,33 @@ +{ + "name": "tphimx", + "type": "module", + "version": "1.0.0", + "scripts": { + "dev": "astro dev", + "start": "astro dev", + "build": "astro build", + "postbuild": "node scripts/format-xml.js", + "preview": "astro preview", + "astro": "astro" + }, + "dependencies": { + "@astrojs/node": "^10.1.1", + "@astrojs/react": "^5.0.5", + "@astrojs/sitemap": "^3.7.2", + "@astrojs/vercel": "^10.0.7", + "@supabase/supabase-js": "^2.105.4", + "@tailwindcss/vite": "^4.0.0", + "astro": "^6.3.3", + "lucide-react": "^0.460.0", + "nodemailer": "^8.0.7", + "react": "^19.0.0", + "react-dom": "^19.0.0", + "swiper": "^11.2.0", + "tailwindcss": "^4.0.0" + }, + "devDependencies": { + "@types/react": "^19.0.0", + "@types/react-dom": "^19.0.0", + "typescript": "^5.7.0" + } +} diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..7577859eb26909563bcaa4a5d3df6bfe07ecbff3 --- /dev/null +++ b/public/favicon.ico @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:81fe0c4ea68851716a27444871287c000144421182fcb2b3287ca361d4a39756 +size 67646 diff --git a/public/favicon.png b/public/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..786363cb567d6ba68e3400a4d559e53b70d9452b --- /dev/null +++ b/public/favicon.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9be9a2f7d99ee048339b466a999deb7ce453478fd6c10b543c0fedb373d88986 +size 31484 diff --git a/public/favicon.svg b/public/favicon.svg new file mode 100644 index 0000000000000000000000000000000000000000..5d11b0aba3440de7f02c74dc9b4a7d563681dbbf --- /dev/null +++ b/public/favicon.svg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f96d6e9cb308794525e75b2936fb35b49ae2915c717054967c11fa7e83b62ede +size 258 diff --git a/public/images/auth/bg.png b/public/images/auth/bg.png new file mode 100644 index 0000000000000000000000000000000000000000..25738e898df1ee06c175011bb61b5223a75b4c96 --- /dev/null +++ b/public/images/auth/bg.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:238e980db35bf25a91885f8eb97e0f6af636aa9b60a13c0521277860bd703de5 +size 774259 diff --git a/public/lib/txa/txacomment.js b/public/lib/txa/txacomment.js new file mode 100644 index 0000000000000000000000000000000000000000..841cd34b4876d216aa0201205cb1c41fa687b02e --- /dev/null +++ b/public/lib/txa/txacomment.js @@ -0,0 +1,493 @@ +/** + * TXA Comment Widget - TPHIMX Cinematic Platform + * Tự động hóa khung bình luận cao cấp. + */ + +class TxaComment { + constructor(containerId) { + this.container = document.getElementById(containerId); + if (!this.container) return; + + this.movieSlug = this.container.getAttribute('data-movie-slug'); + this.movieType = this.container.getAttribute('data-movie-type') || null; + this.episodeName = this.container.getAttribute('data-episode-name') || null; + this.serverName = this.container.getAttribute('data-server-name') || null; + + const userAttr = this.container.getAttribute('data-user'); + this.user = userAttr ? JSON.parse(userAttr) : null; + this.comments = []; + this.bannedUsers = []; + + this.init(); + } + + async init() { + this.renderSkeleton(); + await this.fetchComments(); + this.renderCommentsList(); + this.setupListeners(); + } + + renderSkeleton() { + const isLogged = !!this.user; + + this.container.innerHTML = ` +
+ +
+ +

Bình luận (0)

+
+ + +
+ ${isLogged ? ` +
+ 0 / 1000 + +
+ +
+ +
+ + Tiết lộ? +
+ + + +
+ ` : ` +
+ Vui lòng đăng nhập để tham gia bình luận. +
+ `} +
+ + +
+
Đang tải bình luận...
+
+
+ `; + } + + async fetchComments() { + try { + const res = await fetch(`/api/movie/comments?slug=${this.movieSlug}`); + if (res.ok) { + const data = await res.json(); + this.comments = data.comments || []; + this.bannedUsers = data.bannedUsers || []; + this.userProfiles = data.userProfiles || {}; + } + } catch (e) { + console.error('[TxaComment] Error fetching comments:', e); + } + } + + renderCommentsList() { + const listContainer = document.getElementById('txac-list'); + const countSpan = document.getElementById('txac-count'); + + if (countSpan) { + const totalCount = this.comments.length; + countSpan.textContent = window.txaformat ? window.txaformat.twoDigits(totalCount) : (totalCount < 10 ? '0' + totalCount : totalCount); + } + + if (!listContainer) return; + + if (this.comments.length === 0) { + listContainer.innerHTML = ` +
+ Chưa có bình luận nào. Hãy là người đầu tiên chia sẻ cảm nghĩ! +
+ `; + return; + } + + listContainer.innerHTML = this.comments.map(c => { + const charCode = c.username ? c.username.charCodeAt(0) : 65; + const avatarColors = [ + 'bg-primary text-dark', 'bg-emerald-500 text-white', 'bg-blue-500 text-white', + 'bg-pink-500 text-white', 'bg-yellow-500 text-dark', 'bg-purple-500 text-white' + ]; + const avatarStyle = avatarColors[charCode % avatarColors.length]; + + // Spoiler Logic + const isSpoiler = c.is_spoiler; + const commentBody = isSpoiler + ? `
+ Bình luận có chứa tình tiết phim (Click để xem) + ${c.content} +
` + : `

${c.content}

`; + + // Episode Tag (If commented from watch page) + const episodeTag = (c.episode_name && c.server_name) + ? `${c.episode_name} - ${c.server_name}` + : ''; + + // Likes/Dislikes Arrays + const likes = c.likes || []; + const dislikes = c.dislikes || []; + const hasLiked = this.user && likes.includes(this.user.username); + const hasDisliked = this.user && dislikes.includes(this.user.username); + + // Actions Check (Delete comment) + const canDelete = this.user && (c.username === this.user.username || this.user.role === 'admin'); + const deleteButton = canDelete + ? `` + : ''; + + // Ban Button (For Admin ONLY) + const isBanned = this.bannedUsers.includes(c.username); + const showBanBtn = this.user && this.user.role === 'admin' && c.username !== this.user.username; + const banButton = showBanBtn + ? (isBanned + ? `` + : `` + ) + : ''; + + // Lấy thông tin profile phục vụ cho hover popup + const profile = (this.userProfiles && this.userProfiles[c.username]) || { + commentsCount: 0, + likesCount: 0, + ward: '', + province: '' + }; + + let locationStr = 'Chưa cập nhật'; + if (profile.ward || profile.province) { + const parts = []; + if (profile.ward) parts.push(`xã ${profile.ward}`); + if (profile.province) parts.push(`tỉnh ${profile.province}`); + locationStr = parts.join(', '); + locationStr = locationStr.charAt(0).toUpperCase() + locationStr.slice(1); + } + + const formattedComments = window.txaformat ? window.txaformat.twoDigits(profile.commentsCount) : (profile.commentsCount < 10 ? '0' + profile.commentsCount : profile.commentsCount); + const formattedLikes = window.txaformat ? window.txaformat.twoDigits(profile.likesCount) : (profile.likesCount < 10 ? '0' + profile.likesCount : profile.likesCount); + + // Check if user has custom avatar URL + const hasAvatar = profile && profile.avatar_url; + const avatarInner = hasAvatar + ? `` + : (c.username ? c.username[0] : 'U'); + + return ` +
+ +
+ ${avatarInner} +
+ + +
+
+ +
+ @${c.username} + + +
+
+
+
+
+ ${avatarInner} +
+
+
@${c.username}
+
Thành viên TPhimX
+
+
+
+
+
+ + Số bình luận: ${formattedComments} +
+
+ + Đã thích: ${formattedLikes} phim +
+
+ + Nơi ở: ${locationStr} +
+
+
+
+
+ ${episodeTag} + ${(window.txaformat && window.txaformat.relativeTime) ? window.txaformat.relativeTime(c.created_at) : this.formatRelativeTime(c.created_at)} + ${banButton} + ${deleteButton} +
+ ${commentBody} + + +
+ + + + +
+
+
+ `; + }).join(''); + + if (window.initTxaTooltips) { + setTimeout(() => window.initTxaTooltips(), 50); + } + } + + setupListeners() { + const textarea = document.getElementById('txac-textarea'); + const counter = document.getElementById('txac-char-counter'); + const submitBtn = document.getElementById('txac-submit-btn'); + const spoiler = document.getElementById('txac-spoiler'); + + // Char count update + if (textarea && counter) { + textarea.addEventListener('input', () => { + const len = textarea.value.length; + counter.textContent = `${len} / 1000`; + }); + } + + // Submit new comment + if (submitBtn && textarea) { + submitBtn.addEventListener('click', async (e) => { + e.preventDefault(); + const content = textarea.value.trim(); + if (!content) { + if (window.txatoast) window.txatoast.warning('Nội dung bình luận không được để trống!', 3000, 'bottom-right'); + return; + } + + submitBtn.disabled = true; + + try { + const res = await fetch('/api/movie/comments', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + movieSlug: this.movieSlug, + content: content, + isSpoiler: spoiler ? spoiler.checked : false, + episodeName: this.episodeName, + serverName: this.serverName, + movieType: this.movieType + }) + }); + + const data = await res.json(); + if (res.ok) { + if (window.txatoast) window.txatoast.success(data.message, 3000, 'bottom-right'); + textarea.value = ''; + if (counter) counter.textContent = '0 / 1000'; + if (spoiler) spoiler.checked = false; + + // Reload comments + await this.fetchComments(); + this.renderCommentsList(); + } else { + if (window.txatoast) window.txatoast.error(data.error, 3000, 'bottom-right'); + } + } catch (err) { + if (window.txatoast) window.txatoast.error('Lỗi gửi bình luận!', 3000, 'bottom-right'); + } finally { + submitBtn.disabled = false; + } + }); + } + + // Event delegation for Likes, Dislikes, Delete, Ban buttons + const listContainer = document.getElementById('txac-list'); + if (listContainer) { + listContainer.addEventListener('click', async (e) => { + // Find reaction button (Like / Dislike) + const reactBtn = e.target.closest('.txac-reaction-btn'); + if (reactBtn) { + e.preventDefault(); + const commentId = reactBtn.getAttribute('data-id'); + const action = reactBtn.getAttribute('data-action'); + await this.handleReaction(commentId, action); + return; + } + + // Find delete button + const deleteBtn = e.target.closest('.txac-delete-btn'); + if (deleteBtn) { + e.preventDefault(); + const commentId = deleteBtn.getAttribute('data-id'); + this.handleDelete(commentId); + return; + } + + // Find ban button + const banBtn = e.target.closest('.txac-ban-btn'); + if (banBtn) { + e.preventDefault(); + const targetUsername = banBtn.getAttribute('data-username'); + const action = banBtn.getAttribute('data-action'); + this.handleBan(targetUsername, action); + return; + } + }); + } + } + + async handleReaction(commentId, action) { + if (!this.user) { + if (window.txatoast) window.txatoast.warning('Vui lòng đăng nhập để bình chọn bình luận!', 3000, 'bottom-right'); + return; + } + + try { + const res = await fetch('/api/movie/comments', { + method: 'PUT', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ commentId, action }) + }); + const data = await res.json(); + if (res.ok) { + // Cập nhật mảng trực tiếp cho comment hiện tại và re-render để hiển thị thay đổi lập tức + const comment = this.comments.find(c => c.id === commentId); + if (comment) { + comment.likes = data.likes || []; + comment.dislikes = data.dislikes || []; + this.renderCommentsList(); + } + } else { + if (window.txatoast) window.txatoast.error(data.error, 3000, 'bottom-right'); + } + } catch (err) { + console.error('[TxaComment] Lỗi tương tác:', err); + } + } + + handleDelete(commentId) { + if (!window.txamodal) { + if (confirm('Bạn có chắc chắn muốn xóa bình luận này không?')) { + this.executeDelete(commentId); + } + return; + } + + window.txamodal.show({ + title: 'Xóa bình luận', + message: 'Bạn có chắc chắn muốn xóa vĩnh viễn bình luận này? Hành động này không thể hoàn tác.', + type: 'danger', + confirmText: 'Xóa ngay', + onConfirm: async () => { + await this.executeDelete(commentId); + return true; + } + }); + } + + async executeDelete(commentId) { + try { + const res = await fetch('/api/movie/comments', { + method: 'DELETE', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ commentId }) + }); + const data = await res.json(); + if (res.ok) { + if (window.txatoast) window.txatoast.success(data.message, 3000, 'bottom-right'); + this.comments = this.comments.filter(c => c.id !== commentId); + this.renderCommentsList(); + } else { + if (window.txatoast) window.txatoast.error(data.error, 3000, 'bottom-right'); + } + } catch (err) { + if (window.txatoast) window.txatoast.error('Lỗi khi xóa bình luận!', 3000, 'bottom-right'); + } + } + + handleBan(targetUsername, action) { + // Chặn 1-click siêu tốc không cần xác nhận + this.executeBan(targetUsername, action); + } + + async executeBan(targetUsername, action) { + try { + const res = await fetch('/api/movie/comments', { + method: 'PUT', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ action, targetUsername }) + }); + const data = await res.json(); + if (res.ok) { + if (window.txatoast) window.txatoast.success(data.message, 3000, 'bottom-right'); + this.bannedUsers = data.bannedUsers || []; + this.renderCommentsList(); + } else { + if (window.txatoast) window.txatoast.error(data.error, 3000, 'bottom-right'); + } + } catch (err) { + if (window.txatoast) window.txatoast.error('Lỗi khi thực thi yêu cầu chặn!', 3000, 'bottom-right'); + } + } + + formatRelativeTime(isoString) { + if (!isoString) return ''; + const date = new Date(isoString); + const now = new Date(); + const diffMs = now.getTime() - date.getTime(); + + if (isNaN(date.getTime()) || diffMs < 0) return 'Vừa xong'; + + const diffSec = Math.floor(diffMs / 1000); + if (diffSec < 60) return 'Vừa xong'; + + const diffMin = Math.floor(diffSec / 60); + if (diffMin < 60) return `${diffMin} phút trước`; + + const diffHour = Math.floor(diffMin / 60); + if (diffHour < 24) return `${diffHour} giờ trước`; + + // Vượt quá 1 ngày (24 giờ): Chuyển sang định dạng ngày cụ thể "ngày/tháng/năm" chuẩn Việt Nam + const day = date.getDate(); + const month = date.getMonth() + 1; + const year = date.getFullYear(); + return `${day}/${month}/${year}`; + } +} + +// Auto instantiate on load +function initTxaCommentWidget() { + if (document.getElementById('txa-comment-container')) { + window.txacomment = new TxaComment('txa-comment-container'); + } +} +document.addEventListener('DOMContentLoaded', initTxaCommentWidget); +document.addEventListener('astro:page-load', initTxaCommentWidget); diff --git a/public/lib/txa/txaformat.js b/public/lib/txa/txaformat.js new file mode 100644 index 0000000000000000000000000000000000000000..23a21819522871459ebba20d55c98e7b72fd61b6 --- /dev/null +++ b/public/lib/txa/txaformat.js @@ -0,0 +1,67 @@ +/** + * TXA Format Utility + * Version: 1.0 (Web Optimized) + */ + +const txaformat = { + twoDigits: (n) => (n < 10 ? '0' : '') + n, + + shortNumber: (n) => { + if (n >= 1000000) return (n / 1000000).toFixed(1) + 'M'; + if (n >= 1000) return (n / 1000).toFixed(1) + 'K'; + return n; + }, + + number: (n) => new Intl.NumberFormat('vi-VN').format(n), + + duration: function (s) { + const h = Math.floor(s / 3600); + const m = Math.floor((s % 3600) / 60); + const sec = Math.floor(s % 60); + let str = ''; + if (h > 0) str += this.twoDigits(h) + ':'; + return str + this.twoDigits(m) + ':' + this.twoDigits(sec); + }, + + fileSize: (bytes) => { + if (bytes === 0) return '0 B'; + const units = ['B', 'KB', 'MB', 'GB', 'TB']; + const i = Math.floor(Math.log(bytes) / Math.log(1024)); + return parseFloat((bytes / Math.pow(1024, i)).toFixed(2)) + ' ' + units[i]; + }, + + dateTime: (val) => { + if (!val) return ''; + const d = new Date(val); + if (isNaN(d.getTime())) return val; + return d.toLocaleString('vi-VN'); + }, + + relativeTime: (val) => { + if (!val) return ''; + const date = new Date(val); + const now = new Date(); + const diffMs = now.getTime() - date.getTime(); + + if (isNaN(date.getTime()) || diffMs < 0) return 'Vừa xong'; + + const diffSec = Math.floor(diffMs / 1000); + if (diffSec < 60) return 'Vừa xong'; + + const diffMin = Math.floor(diffSec / 60); + if (diffMin < 60) return `${diffMin} phút trước`; + + const diffHour = Math.floor(diffMin / 60); + if (diffHour < 24) return `${diffHour} giờ trước`; + + // Quá 1 ngày (24 giờ) sẽ hiện là ngày/tháng/năm + const day = date.getDate(); + const month = date.getMonth() + 1; + const year = date.getFullYear(); + return `${day}/${month}/${year}`; + } +}; + +if (typeof window !== 'undefined') { + window.txaformat = txaformat; +} diff --git a/public/lib/txa/txamodal.js b/public/lib/txa/txamodal.js new file mode 100644 index 0000000000000000000000000000000000000000..1fdaa467efc7fa249d76cf3006c6266dc425d7f3 --- /dev/null +++ b/public/lib/txa/txamodal.js @@ -0,0 +1,138 @@ +/** + * TxaModal - Premium Modal System + * Migration: TPHIMX V2 (Vite Compatible) + */ + +class TxaModal { + constructor() { + this.containerCreated = false; + this.container = null; + this.overlay = null; + this.modal = null; + } + + createContainer() { + if (this.containerCreated && document.getElementById('txamodal-container')) { + this.container = document.getElementById('txamodal-container'); + this.overlay = document.getElementById('txamodal-overlay'); + this.modal = document.getElementById('txamodal-content'); + return true; + } + + const container = document.createElement('div'); + container.id = 'txamodal-container'; + container.style.cssText = `position: fixed; top: 0; left: 0; width: 100%; height: 100%; display: none; align-items: center; justify-content: center; z-index: 2147483640; padding: 20px;`; + + const overlay = document.createElement('div'); + overlay.id = 'txamodal-overlay'; + overlay.style.cssText = `position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(10, 15, 25, 0.7); backdrop-filter: blur(12px); opacity: 0; transition: opacity 0.3s ease;`; + + const modal = document.createElement('div'); + modal.id = 'txamodal-content'; + modal.style.cssText = `position: relative; background: rgba(30, 41, 59, 0.7); backdrop-filter: blur(24px); width: 100%; max-width: 500px; border-radius: 28px; border: 1px solid rgba(255, 255, 255, 0.1); box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8); transform: scale(0.9) translateY(30px); opacity: 0; transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); overflow: hidden; display: flex; flex-direction: column;`; + + container.appendChild(overlay); + container.appendChild(modal); + document.body.appendChild(container); + + this.container = container; + this.overlay = overlay; + this.modal = modal; + this.containerCreated = true; + return true; + } + + show({ title, message, type = 'info', confirmText = 'Xác nhận', cancelText = 'Hủy', showCancel = true, showConfirm = true, onConfirm = null, onCancel = null, input = null, inputPlaceholder = '', inputType = 'text' }) { + if (!this.createContainer()) return; + + let icon = ''; + let btnConfirmStyle = 'background: linear-gradient(135deg, #6366f1, #a855f7); color: #fff;'; + + if (type === 'danger') { + icon = ''; + btnConfirmStyle = 'background: #ef4444; color: #fff;'; + } else if (type === 'warning') { + icon = ''; + btnConfirmStyle = 'background: linear-gradient(135deg, #f59e0b, #ea580c); color: #fff;'; + } else if (type === 'success') { + icon = ''; + btnConfirmStyle = 'background: #10b981; color: #fff;'; + } + + let inputHtml = ''; + if (input) { + inputHtml = ` +
+ +
+ `; + } + + let cancelBtnHtml = ''; + if (showCancel && cancelText) { + cancelBtnHtml = ``; + } + + let confirmBtnHtml = ''; + if (showConfirm) { + confirmBtnHtml = ``; + } + + this.modal.innerHTML = ` +
+
${icon}
+

${title || 'Thông báo'}

+
${message}
+ ${inputHtml} +
+ ${(showCancel || showConfirm) ? ` +
+ ${cancelBtnHtml} + ${confirmBtnHtml} +
` : ''} + `; + + this.container.style.display = 'flex'; + setTimeout(() => { + this.overlay.style.opacity = '1'; + this.modal.style.opacity = '1'; + this.modal.style.transform = 'scale(1) translateY(0)'; + if (input) document.getElementById('txamodal-input').focus(); + }, 10); + + const confirmBtn = document.getElementById('txamodal-confirm'); + if (confirmBtn) { + confirmBtn.onclick = async () => { + let result = true; + if (input) { + const val = document.getElementById('txamodal-input').value; + if (onConfirm) result = await onConfirm(val); + } else { + if (onConfirm) result = await onConfirm(); + } + if (result !== false) this.hide(); + }; + } + + const cancelBtn = document.getElementById('txamodal-cancel'); + if (cancelBtn) { + cancelBtn.onclick = () => { + if (typeof onCancel === 'function') { + try { onCancel(); } catch (_) { /* noop */ } + } + this.hide(); + }; + } + } + + hide() { + if (!this.container) return; + this.overlay.style.opacity = '0'; + this.modal.style.opacity = '0'; + this.modal.style.transform = 'scale(0.95) translateY(20px)'; + setTimeout(() => { this.container.style.display = 'none'; }, 400); + } +} + +window.txamodal = new TxaModal(); diff --git a/public/lib/txa/txaplayer.js b/public/lib/txa/txaplayer.js new file mode 100644 index 0000000000000000000000000000000000000000..6fd88d5f83bbf7b428e9e36b3924f53a3678a395 --- /dev/null +++ b/public/lib/txa/txaplayer.js @@ -0,0 +1,6895 @@ +/** + * TXAPlayer v1.0 - TPhimX Next Generation + * Base Logic: Markers, Subtitles (VTT/SRT), Replay, Skip Outro, Snapshot + * v1.0: Optimized for Astro/Vite environment, integrated with KKPhim API + */ + +// dashjs is loaded via CDN or global script +var dashjs = window.dashjs || {}; + +var TXA_VERSION = 'v1.0'; + +// 🤖 TXA NEON CORE 2030 - STORYBOARD CONFIG +var STORYBOARD_LEVELS = window.STORYBOARD_LEVELS || { + L1: { grid: [10, 10], size: [160, 90], interval: 10, prefix: 'L1_M' }, + L2: { grid: [5, 5], size: [240, 135], interval: 30, prefix: 'L2_M' }, + L3: { grid: [3, 3], size: [320, 180], interval: 60, prefix: 'L3_M' } +}; + +const txaStorage = { + dbName: 'TXA_BLOB_CACHE', + storeName: 'episodes', + version: 1, + _getDB() { + return new Promise((resolve, reject) => { + const request = indexedDB.open(this.dbName, this.version); + request.onupgradeneeded = (e) => { + const db = e.target.result; + if (!db.objectStoreNames.contains(this.storeName)) { + db.createObjectStore(this.storeName, { keyPath: 'id' }); + } + }; + request.onsuccess = (e) => resolve(e.target.result); + request.onerror = (e) => reject(e.target.error); + }); + }, + async get(id) { + try { + const db = await this._getDB(); + return new Promise((resolve, reject) => { + const tx = db.transaction(this.storeName, 'readonly'); + const store = tx.objectStore(this.storeName); + const req = store.get(id); + req.onsuccess = () => resolve(req.result); + req.onerror = () => reject(req.error); + }); + } catch (e) { return null; } + }, + async set(id, data, m3u8Url) { + try { + const db = await this._getDB(); + const tx = db.transaction(this.storeName, 'readwrite'); + const store = tx.objectStore(this.storeName); + store.put({ id, data, m3u8Url, timestamp: Date.now() }); + return true; + } catch (e) { return false; } + } +}; + +if (typeof window.TXAPlayer === 'undefined') { + window.TXAPlayer = class { + + constructor(options) { + const defaults = { + containerId: 'player-container', + videoUrl: '', + posterUrl: '', + title: 'TPhimX Media', + markers: { intro: [0, 65], outro: [0, 0] }, + subtitles: [], + autoPlay: false, + + movieId: null, + episodeId: null, + movieSlug: null, + episodeSlug: null, + movieThumb: null, + epCount: null, + saveUrl: null, + restoreUrl: null, + csrfToken: null, + + nextEpisodeUrl: null, + prevEpisodeUrl: null, + autoSkipIntro: false, + autoNextEpisode: false, + hasSubtitles: true, + isLoggedIn: false + }; + + this.options = { ...defaults, ...options }; + + // Proxy external images + if (this.options.posterUrl) this.options.posterUrl = this.getProxiedUrl(this.options.posterUrl); + if (this.options.movieThumb) this.options.movieThumb = this.getProxiedUrl(this.options.movieThumb); + if (this.options.previewUrl) this.options.previewUrl = this.getProxiedUrl(this.options.previewUrl); + + // Deep validate markers to support [0,0] fallback + if (this.options.markers) { + if (!this.options.markers.intro || (this.options.markers.intro[0] === 0 && this.options.markers.intro[1] === 0)) { + this.options.markers.intro = defaults.markers.intro; + } + if (!this.options.markers.outro || (this.options.markers.outro[0] === 0 && this.options.markers.outro[1] === 0)) { + this.options.markers.outro = defaults.markers.outro; + } + } + + this.settings = { + volume: this.options.volume !== undefined ? this.options.volume : 1, + muted: this.options.muted !== undefined ? this.options.muted : false, + playbackRate: 1, + autoSkipIntro: this.options.autoSkipIntro || false, + autoNextEpisode: this.options.autoNextEpisode || false, + showRealTime: true, + clockFormat: 'H:i:s', + ...this.loadSettings() + }; + + let target = this.options.container || this.options.containerId; + this.container = typeof target === 'string' + ? (document.querySelector(target) || document.getElementById(target.replace(/^#/, ''))) + : target; + + if (!this.container) { console.error('TXAPlayer: Container not found'); return; } + + // State + this._isAutoNextTriggered = false; + this._autoNextCountdownInterval = null; // Store countdown interval ID + this._isRetryingVideo = false; // Track video retry state + this.dashPlayer = null; + this.video = null; + this.wrapper = null; + this.seekAccumulator = 0; + this.seekDebounce = null; + this.isDragging = false; + this.currentSubCues = []; + this.feedbackTimer = null; + this.activeSubIdx = -1; + this.destroyed = false; + this._handlers = {}; + + // v5.8.0 New Features State + this.isTheaterMode = false; + this.isCinemaMode = false; + this.isSpeedPreview = false; + this.originalSpeed = 1; + this.resumeShown = false; + + // v6.5.0 Preview Thumbnail State + this._previewSpriteUrl = null; + this._previewSpriteLoaded = false; + this._previewLowUrl = null; + this._previewLowLoaded = false; + this._previewUpgradeTimer = null; + + // v6.5.2 - Turbo Storyboard (Neon Core 2030) + this._useStoryboard = false; + this._storyboardPath = null; + this._currentStoryboardLevel = 'L1'; + this._storyboardCache = new Set(); + + // v6.5.2 - Predictive MP4 Multi-Quality + this._mp4Levels = []; + this._lastMP4Url = null; + this._mediaSetupDone = false; + + // v6.1.0 Ticker State + this.tickerMax = Math.floor(Math.random() * 9) + 2; // Random 2-10 times + this.tickerCount = 0; + this.tickerNextTime = 5 + Math.random() * 20; // Faster first ticker for better visibility + this._isTickerRunning = false; + this._fixedTickerShown = false; + this._endingTickerShown = false; + this._loadProgress = 0; + this._loadInterval = null; + + this.init(); + } + + init() { + // v6.3.0 - Grouped Console Log + console.group('%c ✨ TPHIMX PLAYER %c ' + TXA_VERSION + ' %c ACTIVE ✨ ', + 'background:#8b5cf6; color:#fff; font-weight:bold; padding:4px 0 4px 8px; border-radius:4px 0 0 4px;', + 'background:#facc15; color:#000; font-weight:900; padding:4px 8px;', + 'background:#8b5cf6; color:#fff; font-weight:bold; padding:4px 8px 4px 0; border-radius:0 4px 4px 0;' + ); + console.log('%cVersion: %c' + TXA_VERSION, 'color:#94a3b8', 'color:#fff; font-weight:bold'); + console.log('%cMode: %cPlatinum Premium', 'color:#94a3b8', 'color:#fbbf24'); + console.groupEnd(); + + if (window.txaPlayer) { + console.log('[TXAPlayer] Destroying existing player instance...'); + try { + window.txaPlayer.destroy(); + } catch (e) { + console.error('[TXAPlayer] Error destroying old instance:', e); + } + } + + window.txaPlayer = this; + window.TXAPlayer = TXAPlayer; + + this.container.classList.add('txa-player-skin'); + this.tickerCount = 0; + this.tickerMax = 5; + this.tickerNextTime = 15; + this._uiTimer = null; + + // Bind Methods + this.showUI = this.showUI.bind(this); + this.hideUI = this.hideUI.bind(this); + + this.injectStyles(); + this.renderUI(); + + if (this.options.autoPlay) { + this.setupMedia(); + } else { + // v6.6.2 - Support Lazy Click-to-Play + const cp = this.container.querySelector('#txa-center-play'); + if (cp) cp.classList.add('show'); + + // Still show controls but in non-playing state + this.showUI(false); + } + + this.bindEvents(); + this.startClock(); // v6.4.0 Real-time Clock + this.handleMobileEvents(); // v6.1.0 Mobile Events + this.setupContextMenu(); + this.setupShortcuts(); + this.loadInitialSettings(); + this.setupNewFeatures(); // v5.8.0 - Initialize new features + this.updateTopTitle(); // Set initial title + this.detectDevTools(); + console.log( + `%cSTOP! %cThis is a browser feature intended for developers. If someone told you to copy-paste something here to enable a feature or "hack" someone's account, it is a scam and will give them access to your account.\n\n%c[TXAPlayer ${TXA_VERSION}] %cSecurity Active`, + 'color:red;font-family:system-ui;font-size:4rem;font-weight:bold;-webkit-text-stroke:1px black;', + 'font-family:system-ui;font-size:1.5rem;font-weight:bold;', + 'color:#8b5cf6;font-size:1.2rem;font-weight:bold;', + 'color:gray;font-size:1.2rem;' + ); + } + + detectMobile() { + // Use external TXA Detector if available + if (typeof window.detectMobile === 'function') return window.detectMobile(); + if (window.TXADetector) return window.TXADetector.isMobile(); + + // Standard minimal fallback for extreme cases where script fails to load + return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent || '') || window.innerWidth <= 1024; + } + + getProxiedUrl(url) { + if (!url) return ''; + if (url.includes('localhost') || url.startsWith('/') || url.startsWith('blob:')) return url; + + const blockedDomains = [ + 'kkphim', + 'phimimg', + 'phimapi', + 'tebi.io', + 'stream', + 'cloud', + 'player', + 'phim1280', + 'ophim' + ]; + + const shouldProxy = blockedDomains.some(domain => url.toLowerCase().includes(domain)); + if (shouldProxy) { + return `/api/proxy-media?url=${encodeURIComponent(url)}`; + } + return url; + } + + handleMobileEvents() { + if (!this.detectMobile()) return; + + this.container.classList.add('is-mobile'); + const wrapper = this.wrapper; + + // State for Gestures + let lastTap = 0; + let tapTimer = null; + let touchStartX = 0; + let touchStartY = 0; + let startVolume = 0; + let isLongPress = false; + let pressTimer = null; + let isScrubbing = false; + let isVolumeGesture = false; + + // --- 1. LONG PRESS (2x SPEED) & GESTURE START --- + wrapper.addEventListener('touchstart', (e) => { + // Ignore if touching controls or panels + if (e.target.closest('.txa-controls, .txa-panel, .txa-ctx, .txa-replay-overlay, .txa-skip-btn, .txa-resume-overlay, .txa-next-countdown, .txa-loader, .txa-stats-panel, button, i, .txa-btn')) return; + + const touch = e.touches[0]; + touchStartX = touch.clientX; + touchStartY = touch.clientY; + startVolume = this.video.volume; + isLongPress = false; + isVolumeGesture = false; + + // Start Long Press Timer (YouTube Style 2x Speed) + pressTimer = setTimeout(() => { + if (!this.video.paused && !isScrubbing && !isVolumeGesture) { + isLongPress = true; + this.startSpeedPreview(); + if (window.navigator.vibrate) window.navigator.vibrate(20); + } + }, 500); + + }, { passive: true }); + + wrapper.addEventListener('touchend', (e) => { + if (e.target.closest('.txa-controls, .txa-panel, .txa-ctx, .txa-replay-overlay, .txa-skip-btn, .txa-resume-overlay, .txa-next-countdown, .txa-loader, .txa-stats-panel, button, i, .txa-btn')) return; + + clearTimeout(pressTimer); + + if (isLongPress) { + isLongPress = false; + this.stopSpeedPreview(); + e.preventDefault(); + return; + } + + if (isVolumeGesture) { + isVolumeGesture = false; + return; + } + + const touchEnd = e.changedTouches[0]; + const dx = Math.abs(touchEnd.clientX - touchStartX); + const dy = Math.abs(touchEnd.clientY - touchStartY); + + if (dx > 20 || dy > 20) return; + + const currentTime = new Date().getTime(); + const tapLength = currentTime - lastTap; + + if (tapLength < 300 && tapLength > 0) { + // DOUBLE TAP detection + clearTimeout(tapTimer); + const rect = wrapper.getBoundingClientRect(); + const x = touchEnd.clientX - rect.left; + + // 25% Left (Rewind), 25% Right (Forward), 50% Center (Toggle Play) + if (x < rect.width * 0.25) { + this.seekAccumulated(-10); + } else if (x > rect.width * 0.75) { + this.seekAccumulated(10); + } else { + this.togglePlay(); + } + if (e.cancelable) e.preventDefault(); + } else { + // SINGLE TAP logic - Highly sensitive center zone (60% width) + tapTimer = setTimeout(() => { + const rect = wrapper.getBoundingClientRect(); + const x = touchEnd.clientX - rect.left; + + if (x > rect.width * 0.2 && x < rect.width * 0.8) { + this.togglePlay(); + } else { + if (wrapper.classList.contains('active-ui')) this.hideUI(); + else this.showUI(); + } + }, 200); // Shorter delay for better responsiveness + } + lastTap = currentTime; + if (e.cancelable) e.preventDefault(); + }, { passive: false }); + + wrapper.addEventListener('touchmove', (e) => { + if (isScrubbing) return; + const touch = e.touches[0]; + const dx = touch.clientX - touchStartX; + const dy = touch.clientY - touchStartY; + + // Fullscreen Gestures (Volume on Right Side) + const isFS = !!(document.fullscreenElement || document.webkitIsFullScreen || this.video?.webkitDisplayingFullscreen || this.wrapper.classList.contains('fullscreen-mode')); + + if (isFS && !isLongPress && Math.abs(dy) > 20) { + const rect = wrapper.getBoundingClientRect(); + // Right side check + if (touchStartX > rect.width * 0.5) { + if (!isVolumeGesture && Math.abs(dy) > Math.abs(dx)) { + isVolumeGesture = true; + clearTimeout(pressTimer); + } + if (isVolumeGesture) { + if (e.cancelable) e.preventDefault(); + const sensitivity = 1.5; // Swipe height = 1.5x range + const delta = (touchStartY - touch.clientY) / (rect.height / sensitivity); + const newVol = Math.max(0, Math.min(1, startVolume + delta)); + this.video.volume = newVol; + this.video.muted = false; + this.updateVolUI(); + this.showFeedback('volume'); + } + } + } else if (Math.abs(dx) > 20 || Math.abs(dy) > 20) { + clearTimeout(pressTimer); + } + }, { passive: false }); + + // --- 2. MOBILE PROGRESS SCRUBBING --- + const pWrap = this.container.querySelector('#txa-progress'); + if (pWrap) { + pWrap.addEventListener('touchstart', (e) => { + isScrubbing = true; + pWrap.classList.add('dragging'); + this.showUI(false); + this.updateMobileScrub(e, pWrap); + }, { passive: true }); + + pWrap.addEventListener('touchmove', (e) => { + if (isScrubbing) { + if (e.cancelable) e.preventDefault(); + this.updateMobileScrub(e, pWrap); + } + }, { passive: false }); + + pWrap.addEventListener('touchend', (e) => { + if (isScrubbing) { + isScrubbing = false; + pWrap.classList.remove('dragging'); + const rect = pWrap.getBoundingClientRect(); + const x = e.changedTouches[0].clientX - rect.left; + const pct = Math.max(0, Math.min(1, x / rect.width)); + this.safeSeek(pct * this.video.duration); + const timeOverlay = this.container.querySelector('.txa-mobile-seek-time'); + if (timeOverlay) timeOverlay.style.display = 'none'; + this.showUI(); + } + }, { passive: true }); + } + } + + updateMobileScrub(e, pWrap, timeOverlay) { + if (!this.video.duration) return; + const rect = pWrap.getBoundingClientRect(); + const clientX = e.touches ? e.touches[0].clientX : e.clientX; + const x = clientX - rect.left; + const pct = Math.max(0, Math.min(1, x / rect.width)); + const targetTime = pct * this.video.duration; + + // Update Visual Bar immediately + const playedBar = this.container.querySelector('#txa-played'); + if (playedBar) playedBar.style.width = (pct * 100) + '%'; + + // Update Time Preview + if (timeOverlay) { + timeOverlay.style.display = 'block'; + timeOverlay.innerText = this.formatTime(targetTime, this.video.duration >= 3600); + } + } + + /** + * YouTube-style buffer bar update + * Called every 1s and on FRAG_LOADED to reflect pre-loaded segments + */ + _updateBufferBar() { + if (!this.video) return; + const duration = this.video.duration; + if (!duration || !isFinite(duration)) return; + + const bufBar = this.container.querySelector('#txa-buffer'); + if (!bufBar) return; + + const buffered = this.video.buffered; + const current = this.video.currentTime; + let bufferEnd = 0; + + // Find the buffer range that contains or is closest ahead of current time + for (let i = 0; i < buffered.length; i++) { + if (current >= buffered.start(i) - 0.5 && current <= buffered.end(i)) { + bufferEnd = buffered.end(i); + break; + } + } + + // Fallback: use the largest buffered end + if (bufferEnd === 0 && buffered.length > 0) { + bufferEnd = buffered.end(buffered.length - 1); + } + + const bufPct = (bufferEnd / duration) * 100; + bufBar.style.width = Math.min(100, bufPct).toFixed(2) + '%'; + } + + updateProgress() { + if (!this.video || this.isDragging) return; + const current = this.video.currentTime; + const duration = this.video.duration; + if (!duration) return; + + const pct = (current / duration) * 100; + const playedBar = this.container.querySelector('#txa-played'); + if (playedBar) playedBar.style.width = pct + '%'; + + // Update Buffer Progress (YouTube-style) + this._updateBufferBar(); + + const currText = this.container.querySelector('#txa-curr') || this.container.querySelector('#txa-time'); + if (currText) { + if (currText.id === 'txa-time') { + currText.innerText = this.formatTimeDisplay(); + } else { + currText.innerText = this.formatTime(current, duration >= 3600); + } + } + + this.checkMarkers(current); + this.checkTicker(); + this.renderSubtitles(); + } + + injectStyles() { + if (document.getElementById('txa-css')) return; + const s = document.createElement('style'); + s.id = 'txa-css'; + s.textContent = ` + @import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800;900&display=swap'); + @import url('https://fonts.cdnfonts.com/css/digital-7-mono'); + + /* ==================== BASE PLAYER STYLES (MERGED) ==================== */ + .txa-player { position: relative; width: 100%; height: 100%; background: #000; border-radius: 12px; overflow: hidden; font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; user-select: none; -webkit-user-select: none; overscroll-behavior-x: none; } + .txa-video-container { position: relative; width: 100%; height: 100%; background: #000; display: flex; align-items: center; justify-content: center; } + .txa-video { width: 100%; height: 100%; object-fit: contain; } + .txa-ambient-light { position: absolute; top: 0; left: 0; width: 50px; height: 50px; pointer-events: none; opacity: 0; } + .txa-subtitle-overlay { position: absolute; bottom: 80px; left: 50%; transform: translateX(-50%); max-width: 80%; text-align: center; color: #fff; font-size: 24px; font-weight: 600; text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.9); pointer-events: none; z-index: 10; line-height: 1.4; transition: bottom 0.3s ease; } + .txa-controls.visible~.txa-subtitle-overlay { bottom: 100px; } + .txa-branding { position: absolute; top: 20px; right: 20px; width: 60px; height: 60px; opacity: 0.8; transition: opacity 0.3s ease; z-index: 5; pointer-events: none; } + .txa-branding.playing { opacity: 0.3; } + .txa-branding.visible { opacity: 0.8; } + .txa-logo { width: 100%; height: 100%; filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5)); } + .txa-loading-spinner { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: none; z-index: 20; pointer-events: none; } + .txa-loading-spinner.active { display: block; } + .spinner { width: 50px; height: 50px; border: 3px solid rgba(255, 255, 255, 0.1); border-top-color: #6366f1; border-radius: 50%; animation: spin 0.8s linear infinite; } + @keyframes spin { to { transform: rotate(360deg); } } + .txa-play-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.3); opacity: 0; transition: opacity 0.3s ease; z-index: 15; pointer-events: none; } + .txa-play-overlay.visible { opacity: 1; pointer-events: auto; } + .txa-big-play-btn { width: 80px; height: 80px; background: rgba(255, 255, 255, 0.9); border: none; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.3s ease; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3); } + .txa-big-play-btn svg { width: 32px; height: 32px; color: #6366f1; margin-left: 4px; } + .txa-big-play-btn:hover { transform: scale(1.1); background: #fff; } + .txa-controls { position: absolute; bottom: 0; left: 0; width: 100%; background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, transparent 100%); padding: 20px; opacity: 0; visibility: hidden; transition: all 0.3s ease; z-index: 25; } + .txa-controls.visible { opacity: 1; visibility: visible; } + .txa-progress-container { position: relative; width: 100%; height: 6px; margin-bottom: 20px; cursor: pointer; touch-action: none; } + .txa-progress-bar { position: relative; width: 100%; height: 100%; background: rgba(255, 255, 255, 0.2); border-radius: 3px; overflow: visible; transition: height 0.1s ease; } + .txa-progress-container:hover .txa-progress-bar { height: 8px; } + .txa-progress-buffer { position: absolute; top: 0; left: 0; height: 100%; background: rgba(255, 255, 255, 0.3); transition: width 0.1s linear; border-radius: 3px; } + .txa-progress-played { position: absolute; top: 0; left: 0; height: 100%; background: linear-gradient(90deg, #6366f1, #8b5cf6); transition: width 0.05s linear; border-radius: 3px; box-shadow: 0 0 10px rgba(99, 102, 241, 0.5); } + .txa-progress-handle { position: absolute; top: 50%; right: -7px; width: 14px; height: 14px; background: #fff; border-radius: 50%; transform: translateY(-50%) scale(0); transition: transform 0.2s ease; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); z-index: 2; } + .txa-progress-container:hover .txa-progress-handle, .txa-progress-container.dragging .txa-progress-handle { transform: translateY(-50%) scale(1); } + .txa-progress-tooltip { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); background: rgba(0, 0, 0, 0.9); color: #fff; padding: 6px 10px; border-radius: 6px; font-size: 13px; white-space: nowrap; opacity: 0; visibility: hidden; transition: all 0.2s ease; pointer-events: none; font-weight: 500; } + .txa-progress-container:hover .txa-progress-tooltip { opacity: 1; visibility: visible; bottom: 15px; } + .txa-controls-row { display: flex; align-items: center; justify-content: space-between; } + .txa-controls-left, .txa-controls-right { display: flex; align-items: center; gap: 15px; } + .txa-time { display: flex; align-items: center; gap: 5px; color: rgba(255, 255, 255, 0.9); font-size: 13px; font-weight: 600; letter-spacing: 0.3px; min-width: 110px; justify-content: center; font-family: 'JetBrains Mono', monospace; } + .txa-time-separator { opacity: 0.5; font-size: 12px; } + .txa-btn { width: 44px; height: 44px; background: transparent; border: none; border-radius: 8px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s ease; color: rgba(255, 255, 255, 0.9); position: relative; overflow: visible; } + .txa-btn:hover { background: rgba(255, 255, 255, 0.15); color: #fff; transform: translateY(-2px); } + .txa-btn:active { transform: translateY(0); } + .txa-btn svg { width: 24px; height: 24px; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3)); } + .txa-btn-play .icon-pause { display: none; } + .txa-btn-play.playing .icon-play { display: none; } + .txa-btn-play.playing .icon-pause { display: block; } + .txa-volume-container { position: relative; display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; } + .txa-volume-slider { position: absolute; bottom: 50px; left: 50%; transform: translateX(-50%); width: 32px; height: 0; background: rgba(15, 23, 42, 0.9); backdrop-filter: blur(10px); border-radius: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; opacity: 0; visibility: hidden; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); overflow: hidden; padding: 10px 0; border: 1px solid rgba(255, 255, 255, 0.1); box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5); z-index: 50; } + .txa-volume-container:hover .txa-volume-slider { height: 150px; opacity: 1; visibility: visible; bottom: 55px; } + .txa-volume-input { width: 110px; height: 6px; -webkit-appearance: none; appearance: none; background: rgba(255, 255, 255, 0.2); border-radius: 3px; cursor: pointer; outline: none; transform: rotate(-90deg); margin: 55px 0; } + .txa-volume-input::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; background: #fff; border-radius: 50%; cursor: pointer; transition: transform 0.1s; } + .txa-volume-input::-webkit-slider-thumb:hover { transform: scale(1.2); } + .txa-settings-panel { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.95); width: 380px; max-height: 85vh; background: rgba(15, 23, 42, 0.95); backdrop-filter: blur(30px) saturate(180%); border: 1px solid rgba(255, 255, 255, 0.15); box-shadow: 0 40px 100px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05); border-radius: 24px; padding: 30px; overflow-y: auto; opacity: 0; visibility: hidden; transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); z-index: 100; } + .txa-panel-close { position: absolute; top: 15px; right: 15px; width: 32px; height: 32px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 50%; color: #fff; font-size: 20px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s; z-index: 10; } + .txa-panel-close:hover { background: #ef4444; border-color: #ef4444; transform: rotate(90deg); } + .txa-settings-panel.active { opacity: 1; visibility: visible; transform: translate(-50%, -50%) scale(1); } + .txa-settings-content { display: flex; flex-direction: column; gap: 24px; } + .txa-setting-group { display: flex; flex-direction: column; gap: 12px; } + .txa-setting-label { color: #94a3b8; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; margin-left: 4px; } + .txa-setting-options { display: flex; flex-wrap: wrap; gap: 8px; } + .txa-option-btn { padding: 8px 16px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 8px; color: #e2e8f0; font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.2s ease; } + .txa-option-btn:hover { background: rgba(255, 255, 255, 0.15); border-color: rgba(255, 255, 255, 0.2); } + .txa-option-btn.active { background: linear-gradient(135deg, #6366f1, #8b5cf6); border-color: transparent; color: #fff; box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3); } + .txa-subtitle-style-group { display: none; border-top: 1px solid rgba(255, 255, 255, 0.1); padding-top: 20px; } + .txa-subtitle-style-group.active { display: flex; } + .txa-style-controls { display: grid; grid-template-columns: 1fr; gap: 16px; } + .txa-style-control { display: grid; grid-template-columns: 80px 1fr; align-items: center; gap: 12px; } + .txa-style-control label { color: #cbd5e1; font-size: 13px; } + .txa-style-control input[type="range"], .txa-style-control input[type="color"], .txa-style-control select { width: 100%; background: rgba(0, 0, 0, 0.3); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 6px; padding: 6px 10px; color: #fff; font-size: 13px; cursor: pointer; } + .txa-stats-panel { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.95); width: 400px; max-height: 80vh; background: rgba(15, 23, 42, 0.9); backdrop-filter: blur(20px); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 16px; padding: 24px; overflow-y: auto; opacity: 0; visibility: hidden; transition: all 0.2s ease; z-index: 100; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5); } + .txa-stats-panel.active { opacity: 1; visibility: visible; transform: translate(-50%, -50%) scale(1); } + .txa-stats-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.05); font-family: 'JetBrains Mono', monospace; } + .txa-stats-label { color: #94a3b8; font-size: 12px; } + .txa-stats-value { color: #a5b4fc; font-size: 12px; } + .txa-lockdown-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.98); display: flex; align-items: center; justify-content: center; z-index: 200; opacity: 0; visibility: hidden; transition: all 0.3s ease; } + .txa-lockdown-overlay.active { opacity: 1; visibility: visible; } + .txa-context-menu { position: fixed; z-index: 9999; min-width: 220px; background: rgba(30, 41, 59, 0.95); backdrop-filter: blur(16px); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 12px; padding: 6px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); opacity: 0; visibility: hidden; transform: scale(0.95); transform-origin: top left; transition: opacity 0.15s ease, transform 0.15s ease; } + .txa-context-menu.active { opacity: 1; visibility: visible; transform: scale(1); } + .txa-ctx-header { padding: 12px; margin-bottom: 6px; background: rgba(255, 255, 255, 0.05); border-radius: 8px; display: flex; align-items: center; gap: 10px; } + .txa-ctx-header span { color: #fff; font-weight: 600; font-size: 14px; } + .txa-ctx-item { padding: 10px 12px; color: #cbd5e1; font-size: 13px; border-radius: 6px; transition: all 0.1s; display: flex; align-items: center; gap: 10px; } + .txa-ctx-item:hover { background: rgba(99, 102, 241, 0.2); color: #fff; } + .txa-ctx-item-sub { margin-left: auto; font-size: 11px; opacity: 0.6; background: rgba(255, 255, 255, 0.1); padding: 2px 6px; border-radius: 4px; } + .txa-ctx-divider { height: 1px; background: rgba(255, 255, 255, 0.1); margin: 4px 0; } + [data-tooltip] { position: relative; } + [data-tooltip]:hover::after { content: attr(data-tooltip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: rgba(15, 23, 42, 0.95); color: #fff; padding: 6px 10px; border-radius: 6px; font-size: 12px; white-space: nowrap; margin-bottom: 10px; opacity: 0; visibility: hidden; transition: all 0.2s ease; pointer-events: none; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); border: 1px solid rgba(255, 255, 255, 0.1); z-index: 50; } + [data-tooltip]:hover::after { opacity: 1; visibility: visible; } + @media (max-width: 768px) { + .txa-controls { padding: 12px 14px; } + .txa-controls-left, .txa-controls-right { gap: 6px; } + .txa-btn { width: 44px; height: 44px; } + .txa-btn svg { width: 20px; height: 20px; } + .txa-time { font-size: 12px; gap: 3px; } + .txa-branding { width: 40px; height: 40px; top: 12px; right: 12px; } + .txa-big-play-btn { width: 64px; height: 64px; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } + .txa-big-play-btn svg { width: 26px; height: 26px; } + .txa-subtitle-overlay { font-size: 16px; max-width: 90%; bottom: 60px; } + .txa-controls.visible~.txa-subtitle-overlay { bottom: 80px; } + .txa-progress-container { margin-bottom: 14px; } + .txa-settings-panel { width: 90vw; max-width: 340px; padding: 20px; border-radius: 18px; } + .txa-option-btn { padding: 7px 12px; font-size: 12px; } + .txa-stats-panel { width: 90vw; max-width: 340px; padding: 18px; } + .txa-volume-slider { display: none !important; } + .is-mobile .txa-volume-slider-wrap { display: none !important; } + .txa-volume-container:hover .txa-volume-slider { display: none !important; } + .txa-context-menu { min-width: 180px; max-width: calc(100vw - 40px); } + .txa-progress-tooltip { font-size: 11px; padding: 4px 8px; } + .spinner { width: 40px; height: 40px; } + } + @media (max-width: 480px) { + .txa-controls { padding: 8px 10px; } + .txa-controls-left, .txa-controls-right { gap: 2px; } + .txa-btn { width: 34px; height: 34px; border-radius: 6px; } + .txa-btn svg { width: 18px; height: 18px; } + .txa-time { font-size: 11px; } + .txa-branding { width: 32px; height: 32px; top: 8px; right: 8px; } + .txa-btn-pro { display: none !important; } + .txa-time { min-width: 90px; font-size: 10px; } + .txa-big-play-btn { width: 56px; height: 56px; position: absolute; top: calc(50% - 28px); left: calc(50% - 28px); } + .txa-big-play-btn svg { width: 22px; height: 22px; } + .txa-subtitle-overlay { font-size: 13px; max-width: 94%; bottom: 50px; text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.9); } + .txa-controls.visible~.txa-subtitle-overlay { bottom: 65px; } + .txa-progress-container { margin-bottom: 12px; height: 4px; padding-top: 15px; padding-bottom: 15px; background-clip: content-box; } + .txa-progress-bar { height: 100%; border-radius: 2px; } + .txa-progress-bg { background: rgba(255, 255, 255, 0.2); } + .txa-progress-handle { width: 14px; height: 14px; right: -7px; transform: translateY(-50%) scale(0); transition: transform 0.1s; } + .txa-progress-container.dragging .txa-progress-handle, .active-ui .txa-progress-handle { transform: translateY(-50%) scale(1); } + .txa-speed-overlay { position: absolute; top: 25%; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--txa-glass); backdrop-filter: blur(20px); padding: 12px 24px; border-radius: 100px; color: #fff; font-size: 16px; font-weight: 800; display: flex; align-items: center; gap: 12px; opacity: 0; pointer-events: none; transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); z-index: 500; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8); border: 1px solid var(--txa-border); } + .txa-speed-overlay.show { opacity: 1; transform: translateX(-50%) translateY(0); } + .txa-speed-overlay i { font-size: 12px; } + .txa-mobile-seek-time { position: absolute; bottom: 40px; left: 50%; transform: translateX(-50%); background: rgba(0, 0, 0, 0.8); color: #fff; padding: 6px 12px; border-radius: 8px; font-size: 14px; font-weight: 700; display: none; z-index: 60; border: 1px solid rgba(255, 255, 255, 0.1); } + .txa-progress-container.dragging .txa-mobile-seek-time { display: block; } + .txa-settings-panel { width: 94vw; max-width: none; padding: 16px; border-radius: 14px; max-height: 75vh; } + .txa-setting-group { gap: 8px; } + .txa-setting-label { font-size: 10px; } + .txa-option-btn { padding: 6px 10px; font-size: 11px; } + .txa-stats-panel { width: 94vw; max-width: none; padding: 14px; border-radius: 14px; } + .txa-stats-row { padding: 8px 0; } + .txa-stats-label, .txa-stats-value { font-size: 11px; } + .spinner { width: 34px; height: 34px; border-width: 2px; } + .txa-panel-close { width: 28px; height: 28px; font-size: 16px; top: 10px; right: 10px; } + .txa-style-control { grid-template-columns: 60px 1fr; gap: 8px; } + .txa-style-control label { font-size: 11px; } + } + + + :root { + --txa-brand: #8b5cf6; + --txa-brand-glow: rgba(139,92,246,0.6); + --txa-glass: rgba(12,12,18,0.85); + --txa-glass-light: rgba(30,30,40,0.9); + --txa-border: rgba(255,255,255,0.12); + --txa-text: #f1f5f9; + --txa-intro: #fbbf24; + --txa-outro: #ef4444; + --txa-brand-light: #a78bfa; + } + + /* BRANDING elements - LUXURY STYLE */ + .txa-brand-logo { + position: absolute; top: 25px; left: 25px; z-index: 150; + pointer-events: none; opacity: 0.6; transform: translateY(0); + transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1); + filter: drop-shadow(0 4px 12px rgba(0,0,0,0.8)); + } + + /* REAL-TIME CLOCK - v6.5.1 Top-Down Dynamic */ + .txa-realtime-clock { + position: absolute; top: 25px; right: 25px; z-index: 2147483647; + background: rgba(15, 15, 20, 0.7); backdrop-filter: blur(25px); + border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 50px; + padding: 8px 16px; font-family: 'Digital-7 Mono', 'Outfit', sans-serif; + font-size: 16px; font-weight: 600; color: #fff; + display: none; align-items: center; gap: 8px; + box-shadow: 0 10px 40px rgba(0,0,0,0.6); + transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1); + pointer-events: none; + letter-spacing: 1px; + will-change: top, transform; + } + .txa-realtime-clock.active { display: flex; } + .active-ui .txa-realtime-clock { top: 85px; } /* Slide DOWN to avoid Top Info Bar */ + .txa-realtime-clock i { font-size: 12px; color: var(--txa-brand); opacity: 0.8; } + + @media (max-width: 768px) { + .txa-realtime-clock { font-size: 15px; padding: 6px 12px; top: 15px; right: 15px; } + } + + .txa-wrapper.video-playing.active-ui .txa-brand-logo { opacity: 1; } + .txa-wrapper.video-playing:not(.active-ui) .txa-brand-logo { opacity: 0.25; } + + .txa-logo-text { font-family: 'Outfit', sans-serif; font-weight: 900; font-size: 24px; letter-spacing: -1px; } + .txa-logo-t { color: var(--txa-brand); } + .txa-logo-phimx { color: #fff; } + + /* Smooth Center Play/Pause Animation */ + .txa-center-feedback { + position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.5); + width: 80px; height: 80px; background: rgba(0,0,0,0.4); border-radius: 50%; + display: flex; align-items: center; justify-content: center; + opacity: 0; pointer-events: none; transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); + z-index: 200; border: 1px solid rgba(255,255,255,0.1); backdrop-filter: blur(10px); + } + .txa-center-feedback.animate { opacity: 1; transform: translate(-50%, -50%) scale(1.2); } + .txa-center-feedback.animate-out { opacity: 0; transform: translate(-50%, -50%) scale(1.5); } + .txa-center-feedback i { font-size: 32px; color: #fff; text-shadow: 0 0 15px var(--txa-brand-glow); } + + /* Click-to-Play Center Button v6.6.2 */ + .txa-center-play { + position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.9); + width: 90px; height: 90px; background: rgba(139, 92, 246, 0.4); backdrop-filter: blur(25px); + border: 2px solid rgba(255, 255, 255, 0.2); border-radius: 50%; + display: flex; align-items: center; justify-content: center; + color: #fff; font-size: 36px; cursor: pointer; + opacity: 0; visibility: hidden; z-index: 150; + transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1); + box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 40px var(--txa-brand-glow); + } + .txa-center-play.show { opacity: 1; visibility: visible; transform: translate(-50%, -50%) scale(1); } + .txa-center-play:hover { transform: translate(-50%, -50%) scale(1.15); background: var(--txa-brand); border-color: #fff; } + .txa-center-play i { margin-left: 6px; filter: drop-shadow(0 0 15px #fff); } + + .txa-watermark { + position: absolute; bottom: 100px; right: 25px; z-index: 80; + pointer-events: none; opacity: 0.3; font-size: 11px; font-weight: 800; + color: rgba(255,255,255,0.4); text-transform: uppercase; letter-spacing: 2px; + font-family: 'Outfit', sans-serif; transition: opacity 0.3s; + } + .txa-watermark span { color: var(--txa-brand); } + .txa-wrapper.video-playing:not(.active-ui) .txa-watermark { opacity: 0.15; } + + .txa-player-skin { position:absolute; inset:0; background:#000; font-family:'Outfit',sans-serif; color:var(--txa-text); user-select:none; overflow:hidden; } + .txa-wrapper { position:relative; width:100%; height:100%; outline:none; container-type: inline-size; container-name: player; } + .txa-video { width:100%; height:100%; object-fit:contain; } + + /* LOADER - Enhanced */ + .txa-loader { position:absolute; inset:0; background:rgba(0,0,0,0.85); z-index:95; display:flex; align-items:center; justify-content:center; flex-direction:column; gap:0; backdrop-filter:blur(8px); pointer-events: none; } + .txa-loader.hidden { display:none; } + .txa-loader-content { display:flex; flex-direction:column; align-items:center; gap:12px; max-width:380px; width:90%; } + .txa-spinner { width:52px; height:52px; border:3px solid rgba(255,255,255,0.08); border-top-color:var(--txa-brand); border-radius:50%; animation:txaspin 0.7s linear infinite; } + .txa-load-pct-row { display:flex; align-items:baseline; gap:10px; justify-content:center; } + .txa-load-pct { font-size:28px; font-weight:900; color:#fff; text-shadow: 0 0 15px var(--txa-brand-glow); font-variant-numeric:tabular-nums; } + .txa-load-speed { font-size:12px; font-weight:700; color:var(--txa-brand); background:rgba(139,92,246,0.15); padding:3px 10px; border-radius:20px; font-variant-numeric:tabular-nums; letter-spacing:0.3px; white-space:nowrap; } + .txa-load-text { font-size:12px; font-weight:500; color:rgba(255,255,255,0.5); letter-spacing:0.3px; text-align:center; } + .txa-load-info { display:flex; flex-wrap:wrap; gap:8px; justify-content:center; margin-top:20px; width:100%; } + .txa-load-info-tag { + font-size:11px; font-weight:700; color:#fff; + background:rgba(255,255,255,0.06); backdrop-filter:blur(10px); + padding:6px 14px; border-radius:10px; + border:1px solid rgba(255,255,255,0.1); + text-transform:uppercase; letter-spacing:0.8px; + display:flex; align-items:center; gap:8px; + box-shadow: 0 10px 30px rgba(0,0,0,0.3); + transition: transform 0.3s ease; + } + .txa-load-info-tag i { font-size:12px; color: var(--txa-brand-light); } + .txa-load-info-tag .tag-val { color:#fff; font-weight: 800; } + .txa-load-info-tag.bg-warning { border-color: rgba(234, 179, 8, 0.4); color: #facc15; } + .txa-load-info-tag.bg-warning i { color: #facc15; } + + @container player (max-width: 500px) { + .txa-load-info { flex-direction: column; align-items: center; gap: 10px; } + .txa-load-info-tag { width: 85%; justify-content: center; font-size: 10px; padding: 10px; } + .txa-load-pct { font-size: 42px; } + } + + .txa-load-bar { width:100%; height:5px; background:rgba(255,255,255,0.1); border-radius:10px; overflow:hidden; margin-top:10px; } + .txa-load-bar-fill { height:100%; width:0%; background:linear-gradient(90deg, var(--txa-brand), #f472b6); border-radius:10px; transition:width 0.4s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: 0 0 15px var(--txa-brand-glow); } + @keyframes txaspin { to { transform:rotate(360deg); } } + + /* STATS PANEL - Premium Centered */ + .txa-stats-panel { + position:absolute; top:50%; left:50%; transform:translate(-50%, -50%) scale(0.9); + z-index:2147483647; + background:rgba(10, 10, 15, 0.9); backdrop-filter:blur(30px); + border:1px solid rgba(255,255,255,0.15); border-radius:24px; + padding:25px; min-width:320px; max-width:450px; + font-family:'Outfit', system-ui, sans-serif; + display:none; pointer-events:auto; + box-shadow: 0 30px 100px rgba(0,0,0,0.9), 0 0 40px rgba(139,92,246,0.2); + transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1); + } + .txa-stats-panel.active { display:block; animation:txaStatsIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards; } + @keyframes txaStatsIn { + from { opacity:0; transform:translate(-50%, -45%) scale(0.95); } + to { opacity:1; transform:translate(-50%, -50%) scale(1); } + } + @keyframes txaShortcutsIn { + from { opacity:0; transform:translateY(20px) scale(0.95); } + to { opacity:1; transform:translateY(0) scale(1); } + } + .txa-shortcuts-panel { + position: absolute; inset: 0; + display: flex; align-items: center; justify-content: center; + pointer-events: none; z-index: 2147483647; + } + .txa-shortcuts-panel.active { pointer-events: auto; } + .txa-shortcuts-panel .txa-shortcuts-content { + background:rgba(10, 10, 15, 0.9); backdrop-filter:blur(30px); + border:1px solid rgba(255,255,255,0.15); border-radius:24px; + padding:25px; min-width:320px; max-width:500px; + font-family:'Outfit', system-ui, sans-serif; + box-shadow: 0 30px 100px rgba(0,0,0,0.9), 0 0 40px rgba(139,92,246,0.2); + opacity: 0; /* Start hidden for animation */ + animation: txaShortcutsIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards; + } + .txa-shortcuts-table { width: 100%; border-collapse: separate; border-spacing: 0 8px; } + .txa-shortcuts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; } + @media (max-width: 600px) { .txa-shortcuts-grid { grid-template-columns: 1fr; } } + .txa-shortcuts-table th { text-align: left; font-size: 11px; text-transform: uppercase; color: var(--txa-brand); letter-spacing: 1px; padding: 0 10px 10px; opacity: 0.8; } + .txa-shortcuts-table td { padding: 8px 10px; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.05); } + .txa-shortcuts-table td:first-child { border-radius: 10px 0 0 10px; border-right: none; font-size: 13px; color: #cbd5e1; } + .txa-shortcuts-table td:last-child { border-radius: 0 10px 10px 0; border-left: none; text-align: right; } + .txa-shortcuts-table kbd { + background: #1e293b; color: #fff; padding: 3px 8px; border-radius: 6px; + border-bottom: 2px solid #000; font-size: 10px; font-weight: 800; + font-family: inherit; display: inline-block; min-width: 18px; text-align: center; + box-shadow: 0 2px 5px rgba(0,0,0,0.5); + } + .txa-shortcuts-table tr:hover td { background: rgba(139, 92, 246, 0.1); border-color: rgba(139, 92, 246, 0.3); } + .txa-stats-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:10px; padding-bottom:8px; border-bottom:1px solid rgba(255,255,255,0.08); } + .txa-stats-title { font-size:12px; font-weight:800; color:var(--txa-brand); text-transform:uppercase; letter-spacing:1px; display:flex; align-items:center; gap:6px; } + .txa-stats-title i { font-size:11px; } + .txa-stats-close { background:none; border:none; color:rgba(255,255,255,0.4); cursor:pointer; font-size:14px; padding:4px; border-radius:6px; transition:0.2s; } + .txa-stats-close:hover { color:#fff; background:rgba(255,255,255,0.1); } + .txa-stats-grid { display:grid; grid-template-columns:1fr 1fr; gap:6px; } + .txa-stat-item { display:flex; flex-direction:column; gap:2px; padding:6px 8px; background:rgba(255,255,255,0.03); border-radius:8px; } + .txa-stat-item.full { grid-column:1/-1; } + .txa-stat-label { font-size:9px; font-weight:700; color:rgba(255,255,255,0.35); text-transform:uppercase; letter-spacing:0.8px; } + .txa-stat-value { font-size:13px; font-weight:700; color:#fff; font-variant-numeric:tabular-nums; } + .txa-stat-value.brand { color:var(--txa-brand); } + .txa-stat-value.green { color:#34d399; } + .txa-stat-value.yellow { color:#fbbf24; } + .txa-stat-value.red { color:#f87171; } + @media (max-width:600px) { + .txa-stats-panel { + top:5px; left:5px; right:5px; width: auto; + min-width:unset; max-width:unset; padding:12px; + font-size:10px; border-radius: 12px; + } + .txa-stats-grid { grid-template-columns: 1fr; gap:4px; } + .txa-stat-item { padding: 4px 8px; flex-direction: row; justify-content: space-between; align-items: center; } + .txa-stat-item.full { flex-direction: column; align-items: flex-start; } + .txa-stat-value { font-size:11px; text-align: right; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } + .txa-stat-item.full .txa-stat-value { text-align: left; max-width: 100%; } + .txa-load-pct { font-size:22px; } + .txa-load-speed { font-size:11px; } + } + + /* REPLAY OVERLAY */ + .txa-replay-overlay { + position:absolute; inset:0; background:rgba(0,0,0,0.85); z-index:250; + display:none; align-items:center; justify-content:center; flex-direction:column; gap:20px; + backdrop-filter:blur(15px); + } + .txa-replay-overlay.show { display:flex; } + .txa-replay-btn { + width:100px; height:100px; background:var(--txa-brand); border:none; border-radius:50%; + display:flex; align-items:center; justify-content:center; cursor:pointer; + transition:all 0.3s; box-shadow:0 10px 40px var(--txa-brand-glow); + } + .txa-replay-btn:hover { transform:scale(1.1); box-shadow:0 15px 50px var(--txa-brand-glow); } + .txa-replay-btn i { font-size:40px; color:#fff; } + .txa-replay-text { font-size:18px; font-weight:600; color:#fff; } + + /* FEEDBACK POPUP */ + .txa-feedback { + position:absolute; top:50%; left:50%; transform:translate(-50%,-50%) scale(0.8); + background:var(--txa-glass); backdrop-filter:blur(20px); border:1px solid var(--txa-border); + padding:16px 28px; border-radius:16px; font-size:22px; font-weight:700; color:#fff; + opacity:0; pointer-events:none; transition:all 0.4s cubic-bezier(0.16,1,0.3,1); z-index:1100; + box-shadow:0 15px 40px rgba(0,0,0,0.5); display:flex; align-items:center; gap:12px; + } + .txa-feedback.show { opacity:1; transform:translate(-50%,-50%) scale(1); } + + /* Smart Avoidance: Shift feedback up when Countdown is showing */ + .has-countdown .txa-feedback.show { transform:translate(-50%, -120%) scale(1); } + @media (max-width: 768px) { + .has-countdown .txa-feedback.show { transform:translate(-50%, -150%) scale(0.9); } + } + .txa-feedback.high-priority { z-index: 1000; background: var(--txa-brand); border-color: rgba(255,255,255,0.3); box-shadow: 0 20px 50px var(--txa-brand-glow); } + .txa-feedback.high-priority span { font-size: 18px; font-weight: 800; } + .txa-feedback i { font-size:26px; color:var(--txa-brand); } + .txa-feedback.high-priority i { color: #fff; } + + /* SEEK BADGES */ + .txa-seek-badge { + position:absolute; top:50%; width:90px; height:90px; background:rgba(0,0,0,0.6); + border-radius:50%; display:flex; flex-direction:column; align-items:center; justify-content:center; + backdrop-filter:blur(10px); border:1px solid var(--txa-border); + opacity:0; pointer-events:none; transition:all 0.25s; z-index:100; + } + .txa-seek-badge.left { left:18%; transform:translate(-50%,-50%); } + .txa-seek-badge.right { right:18%; transform:translate(50%,-50%); } + .txa-seek-badge.show { opacity:1; } + .txa-seek-badge i { font-size:22px; margin-bottom:6px; } + .txa-seek-badge span { font-size:16px; font-weight:700; } + + /* CENTER PLAY */ + .txa-center-play { + position:absolute; top:50%; left:50%; transform:translate(-50%,-50%) scale(0.9); + width:80px; height:80px; background:rgba(255,255,255,0.15); border-radius:50%; + display:flex; align-items:center; justify-content:center; backdrop-filter:blur(10px); + border:1px solid rgba(255,255,255,0.2); opacity:0; transition:all 0.3s; pointer-events:none; + z-index: 150; cursor: pointer; + } + .txa-center-play.show { opacity:1; transform:translate(-50%,-50%) scale(1); pointer-events:auto; } + .txa-center-play i { font-size:30px; } + + .txa-video { width:100%; height:100%; object-fit:contain; cursor: pointer; } + + /* TICKER NOTIFICATION - PREMIUM MARQUEE */ + .txa-ticker-container { + position: absolute; bottom: 40px; left: 0; right: 0; pointer-events: none; z-index: 20000; display: none; + height: 50px; overflow: hidden; + mask-image: linear-gradient(to right, transparent, black 15%, black 85%, transparent); + -webkit-mask-image: linear-gradient(to right, transparent, black 15%, black 85%, transparent); + transition: bottom 0.5s cubic-bezier(0.16, 1, 0.3, 1); + } + .txa-ticker-container.active { display: block; } + .active-ui .txa-ticker-container { bottom: 130px; } /* Push up when controls are visible */ + .has-countdown .txa-ticker-container { bottom: 180px; } + + .txa-ticker-text { + position: absolute; top: 50%; transform: translateY(-50%); + white-space: nowrap; font-size: 15px; font-weight: 500; color: rgba(255,255,255,0.9); + text-shadow: 0 2px 10px rgba(0,0,0,0.8); + font-family: 'Inter', sans-serif; letter-spacing: 0.3px; + left: 100%; will-change: transform, left; + padding: 10px 24px; border-radius: 12px; + display: flex; align-items: center; gap: 10px; + box-shadow: 0 10px 30px rgba(0,0,0,0.3); + } + .txa-ticker-text img { height: 20px; vertical-align: middle; margin-right: 5px; } + + /* Ticker Variants - Random Backgrounds */ + .txa-ticker-text.style-1 { + background: rgba(15, 23, 42, 0.8); + backdrop-filter: blur(12px); + border: 1px solid rgba(255, 255, 255, 0.08); + } + .txa-ticker-text.style-2 { + background: linear-gradient(90deg, rgba(88, 28, 135, 0.85), rgba(124, 58, 237, 0.85)); + backdrop-filter: blur(12px); + border: 1px solid rgba(139, 92, 246, 0.3); + box-shadow: 0 10px 40px rgba(139, 92, 246, 0.4); + } + .txa-ticker-text.style-3 { + background: linear-gradient(90deg, rgba(6, 182, 212, 0.85), rgba(59, 130, 246, 0.85)); + backdrop-filter: blur(12px); + border: 1px solid rgba(6, 182, 212, 0.3); + box-shadow: 0 10px 40px rgba(6, 182, 212, 0.4); + } + .txa-ticker-text.style-4 { + background: rgba(255, 255, 255, 0.1); + backdrop-filter: blur(20px) saturate(180%); + border: 1px solid rgba(255, 255, 255, 0.2); + color: #fff; + } + + .txa-ticker-text span.highlight { color: #facc15; font-weight: 800; } + .txa-ticker-text span.brand { color: #a78bfa; font-weight: 900; text-transform:uppercase; letter-spacing:1px; } + .txa-ticker-text i { font-size: 18px; margin-right: 4px; } + + .txa-ticker-text.run { animation: txamarquee var(--ticker-dur) linear forwards; } + @keyframes txamarquee { + from { left: 100%; transform: translate(0, -50%); } + to { left: 0%; transform: translate(-100%, -50%); } + } + + /* TXA PRO TOGGLES */ + /* TXA PRO TOGGLES - BADGE STYLE */ + .txa-btn-pro { width: 42px; padding: 0; border-radius: 50%; gap: 0; border: 1px solid transparent; position: relative; } + .txa-btn-pro:hover { background: rgba(255,255,255,0.1); border-color: transparent; } + .txa-btn-status { + position: absolute; top: -2px; right: -2px; + font-size: 8px; font-weight: 900; + padding: 1px 3px; border-radius: 6px; + background: #475569; color: #cbd5e1; + transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); + min-width: 18px; text-align: center; + border: 2px solid rgba(0,0,0,0.9); /* Cutout effect for dark mode */ + transform: scale(0.9); z-index: 5; + } + .txa-btn-pro.active .txa-btn-status { + background: var(--txa-brand); color: #fff; + box-shadow: 0 0 8px var(--txa-brand-glow); + transform: scale(1); + border-color: #000; + } + .txa-btn-pro.active i { color: var(--txa-brand-light); filter: drop-shadow(0 0 5px var(--txa-brand-glow)); } + + /* CONTROLS */ + .txa-controls { + position:absolute; bottom:0; left:0; right:0; z-index:100; padding:20px; + background:linear-gradient(transparent, rgba(0,0,0,0.95) 80%); pointer-events:none; + opacity:0; transform:translateY(15px); transition:all 0.4s cubic-bezier(0.16, 1, 0.3, 1); + cursor: default; + } + .active-ui .txa-controls { opacity:1; transform:translateY(0); pointer-events:auto; } + + /* PROGRESS - THICKER */ + .txa-progress-wrap { position:relative; height:10px; width:100%; cursor:pointer; margin-bottom:20px; transition:all 0.15s; } + .txa-progress-wrap:hover { height:16px; } + .txa-progress-bg { position:absolute; inset:0; background:rgba(255,255,255,0.15); border-radius:6px; overflow:hidden; } + .txa-progress-buf { position:absolute; height:100%; background:rgba(255,255,255,0.4); border-radius:6px; width:0; transition: width 0.4s ease; overflow:hidden; z-index: 2; box-shadow: 0 0 10px rgba(255,255,255,0.1); } + .txa-progress-buf.loading { background:rgba(255,255,255,0.5); } + .txa-progress-buf.loading::after { content:''; position:absolute; inset:0; background:linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent); animation:txaBufShimmer 1.5s ease-in-out infinite; } + @keyframes txaBufShimmer { 0% { transform:translateX(-100%); } 100% { transform:translateX(100%); } } + .txa-progress-fill { position:absolute; height:100%; background:var(--txa-brand); border-radius:6px; width:0; box-shadow:0 0 15px var(--txa-brand-glow); z-index: 3; } + + /* SCRUBBER - REFINED */ + .txa-scrubber { + position:absolute; right:-11px; top:50%; transform:translateY(-50%) scale(1); + width:22px; height:22px; background:var(--txa-brand); border-radius:50%; + box-shadow:0 0 15px var(--txa-brand-glow); transition:transform 0.15s; + display:flex; align-items:center; justify-content:center; + z-index: 5; border: 2px solid white; cursor: grab; + } + .txa-scrubber:active { cursor: grabbing; } + .txa-scrubber::after { + content:'T'; font-size:12px; font-weight:900; color:#fff; + font-family:'Inter',sans-serif; + } + + /* MARKERS - HIGHLIGHTED */ + .txa-marker-zone { + position:absolute; top:0; height:100%; z-index:5; pointer-events:none; + } + .txa-marker-zone.intro { + background: #facc15; + opacity: 0.8; + box-shadow: 0 0 15px rgba(250, 204, 21, 0.6); + } + .txa-marker-zone.outro { + background: #f87171; + opacity: 0.8; + box-shadow: 0 0 15px rgba(248, 113, 113, 0.6); + } + .txa-marker-dot { + position:absolute; top:50%; width:8px; height:8px; border-radius:50%; + transform:translateY(-50%); z-index:5; box-shadow:0 0 10px currentColor; border: 1px solid #fff; + } + .txa-marker-dot.intro-start, .txa-marker-dot.intro-end { background:var(--txa-intro); color:var(--txa-intro); } + .txa-marker-dot.outro-start, .txa-marker-dot.outro-end { background:var(--txa-outro); color:var(--txa-outro); } + + /* HOVER TIME TOOLTIP */ + .txa-hover-time { + position:absolute; bottom:28px; transform:translateX(-50%); background:rgba(0,0,0,0.85); + backdrop-filter: blur(8px); + padding:4px 10px; border-radius:6px; font-size:13px; font-weight:800; pointer-events:none; + color: #fff; + opacity:0; transition:opacity 0.15s, bottom 0.2s ease; border:1px solid rgba(255,255,255,0.1); + z-index:20; + box-shadow: 0 4px 12px rgba(0,0,0,0.5); + white-space: nowrap; + } + .txa-progress-wrap:hover .txa-hover-time { opacity:1; } + .txa-progress-wrap.dragging .txa-hover-time { opacity:1; } + + /* Dynamic positioning when preview thumbnail is visible */ + .txa-preview-thumb.has-sprite ~ .txa-hover-time { + bottom: 142px; /* 40px (thumb bottom) + 90px (thumb height) + 12px (offset) */ + background: var(--txa-brand); + border-color: var(--txa-brand-glow); + box-shadow: 0 4px 15px var(--txa-brand-glow); + } + + /* PREVIEW THUMBNAIL on progress bar hover */ + .txa-preview-thumb { + position:absolute; bottom:40px; transform:translateX(-50%); + width:160px; height:90px; + background-color:#000; background-size:1600px 900px; background-repeat:no-repeat; + border-radius:8px; border:2px solid rgba(139,92,246,0.6); + box-shadow:0 8px 32px rgba(0,0,0,0.8), 0 0 16px rgba(139,92,246,0.3); + pointer-events:none; opacity:0; transition:opacity 0.15s ease; + z-index:11; overflow:hidden; + } + .txa-preview-thumb::after { + content:''; position:absolute; inset:0; + border-radius:6px; + box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1); + pointer-events:none; + } + .txa-preview-thumb.loading::before { + content:''; position:absolute; top:50%; left:50%; + width:20px; height:20px; margin:-10px 0 0 -10px; + border:2px solid rgba(255,255,255,0.15); border-top-color:var(--txa-brand); + border-radius:50%; animation:txaspin 0.6s linear infinite; + } + .txa-progress-wrap:hover .txa-preview-thumb.has-sprite { opacity:1; } + .txa-progress-wrap.dragging .txa-preview-thumb.has-sprite { opacity:1; } + + /* TOOLBAR */ + .txa-toolbar { display:flex; align-items:center; justify-content:space-between; position:relative; z-index: 10; } + .txa-group { display:flex; align-items:center; gap:6px; background:var(--txa-glass); backdrop-filter:blur(16px); padding:5px 10px; border-radius:100px; border:1px solid var(--txa-border); transition:all 0.3s; } + + .txa-btn { background:none; border:none; color:#fff; width:42px; height:42px; display:flex; align-items:center; justify-content:center; cursor:pointer; border-radius:50%; transition:all 0.2s; position:relative; } + .txa-btn:hover { background:rgba(255,255,255,0.12); } + .txa-btn i { font-size:17px; filter: drop-shadow(0 0 5px rgba(0,0,0,0.5)); } + + .txa-video { width:100%; height:100%; object-fit:contain; cursor: pointer; } + .txa-wrapper { position:relative; width:100%; height:100%; outline:none; cursor: none; } + .txa-wrapper.active-ui { cursor: auto; } + + /* v6.4.6 - Force Hide Controls (for Speed Preview) */ + .txa-wrapper.hide-controls .txa-controls, + .txa-wrapper.hide-controls .txa-top-info, + .txa-wrapper.hide-controls .txa-realtime-clock { opacity: 0 !important; transform: translateY(15px); pointer-events: none !important; } + .txa-wrapper.hide-controls .txa-top-info { transform: translateY(-20px); } + + /* CC/SUB INDICATOR */ + .txa-btn.cc-active { color: var(--txa-brand); } + .txa-btn.cc-active i { filter: drop-shadow(0 0 8px var(--txa-brand-glow)); } + + /* TOOLTIP PUSHED HIGHER - SMART POSITIONING */ + /* TOOLTIP PUSHED HIGHER - SMART POSITIONING */ + .txa-tooltip { position:absolute; bottom:70px; left:50%; transform:translateX(-50%); background:var(--txa-glass-light); padding:8px 16px; border-radius:10px; font-size:12px; font-weight:700; white-space:nowrap; opacity:0; transition:all 0.2s; pointer-events:none; border:1px solid var(--txa-border); z-index:1000; box-shadow: 0 10px 30px rgba(0,0,0,0.6); } + + /* Right align tooltips for right-side buttons */ + .txa-right-group .txa-btn .txa-tooltip { left:auto; right:0; transform:translateX(0); } + .txa-btn:hover .txa-tooltip { opacity:1; bottom:65px; } + + .txa-time { font-size:13px; font-weight:700; margin:0 14px; color:#cbd5e1; font-feature-settings:"tnum"; } + + /* VOLUME PREMIUM ENHANCED */ + .txa-vol-container { display:flex; align-items:center; position:relative; } + .txa-vol-slider-wrap { + position:relative; + width:0; overflow:hidden; transition:width 0.3s cubic-bezier(0.16, 1, 0.3, 1); + display:flex; align-items:center; height: 42px; + } + .txa-vol-container:hover .txa-vol-slider-wrap { width:130px; } + .txa-vol-slider { + width:115px; height:24px; margin-left:12px; appearance:none; -webkit-appearance:none; + background: linear-gradient(to right, var(--txa-brand) 0%, rgba(255,255,255,0.1) 0%); + background-size: 100% 6px; + background-position: center; + background-repeat: no-repeat; + border-radius:10px; cursor:pointer; outline:none; + transition: background 0.2s; + } + .txa-vol-tooltip-p { + position:absolute; bottom:75px; background:var(--txa-glass-light); + backdrop-filter:blur(10px); color:#fff; padding:4px 10px; border-radius:8px; + font-size:11px; font-weight:800; opacity:0; pointer-events:none; + transition: opacity 0.2s, transform 0.2s; transform:translateX(-50%) translateY(5px); + border:1px solid var(--txa-border); z-index:100; box-shadow:0 8px 20px rgba(0,0,0,0.4); + } + .txa-vol-tooltip-p.visible { opacity:1; transform:translateX(-50%) translateY(0); } + + .txa-vol-slider::-webkit-slider-thumb { + -webkit-appearance:none; appearance:none; width:18px; height:18px; + background:#fff; border-radius:50%; box-shadow:0 0 15px var(--txa-brand-glow); + border: 3px solid var(--txa-brand); cursor:pointer; + transition: transform 0.1s; + } + .txa-vol-slider::-webkit-slider-thumb:hover { transform: scale(1.2); } + .txa-vol-slider::-moz-range-thumb { + appearance:none; width:18px; height:18px; background:#fff; border-radius:50%; + box-shadow:0 0 15px var(--txa-brand-glow); border: 3px solid var(--txa-brand); + cursor:pointer; transition: transform 0.1s; + } + .txa-vol-slider::-moz-range-thumb:hover { transform: scale(1.2); } + + /* SETTINGS PANEL */ + .txa-panel { + position:absolute; bottom:95px; right:20px; width:300px; + max-height: 480px; height: auto; overflow-y:auto; /* Fixed height safe */ + background:var(--txa-glass); backdrop-filter:blur(30px); border:1px solid var(--txa-border); + border-radius:20px; display:none; z-index:200; + box-shadow:0 30px 60px rgba(0,0,0,0.7); animation:txafadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1); + } + /* Custom Scrollbar for Panel */ + .txa-panel::-webkit-scrollbar { width:4px; } + .txa-panel::-webkit-scrollbar-track { background:transparent; } + .txa-panel::-webkit-scrollbar-thumb { background:rgba(255,255,255,0.2); border-radius:4px; } + .txa-panel::-webkit-scrollbar-thumb:hover { background:var(--txa-brand); } + .txa-panel.active { display:block; } + @keyframes txafadeIn { from { opacity:0; transform:translateY(10px) scale(0.95); } to { opacity:1; transform:translateY(0) scale(1); } } + + .txa-panel-header { position: sticky; top: 0; background: #1a1a24; z-index: 20; padding:16px 20px; border-bottom:1px solid var(--txa-border); font-weight:700; font-size:15px; display:flex; align-items:center; gap:10px; } + .txa-panel-header i { color:var(--txa-brand); } + .txa-menu-item { padding:14px 20px; display:flex; align-items:center; justify-content:space-between; cursor:pointer; font-size:14px; color:#e2e8f0; transition:all 0.2s; } + .txa-menu-item:hover { background:rgba(255,255,255,0.08); } + .txa-menu-item.active { color:var(--txa-brand); font-weight:700; background: rgba(139,92,246,0.1); } + .txa-menu-item span:last-child { opacity:0.6; font-size:12px; font-weight:600; } + .txa-menu-item.active span { opacity:1; } + + .txa-menu-back { position: sticky; top: 0; background: #1a1a24; z-index: 20; padding:14px 20px; border-bottom:1px solid var(--txa-border); display:flex; align-items:center; gap:12px; cursor:pointer; font-weight:700; font-size:14px; } + .txa-menu-back:hover { background:rgba(255,255,255,0.08); } + + /* CONTEXT MENU */ + .txa-ctx { + position:absolute; min-width:240px; background:var(--txa-glass); backdrop-filter:blur(30px); + border:1px solid var(--txa-border); border-radius:16px; padding:8px 0; display:none; z-index:300; + box-shadow:0 20px 50px rgba(0,0,0,0.7); animation:txafadeIn 0.2s; + } + .txa-ctx.active { display:block; } + .txa-ctx-header { padding:12px 18px; font-size:11px; text-transform:uppercase; letter-spacing:1px; color:var(--txa-brand); font-weight:800; border-bottom:1px solid var(--txa-border); margin-bottom:4px; } + .txa-ctx-item { padding:12px 18px; font-size:13px; color:#e2e8f0; cursor:pointer; display:flex; justify-content:space-between; align-items:center; transition:0.15s; } + .txa-ctx-item:hover { background:rgba(139,92,246,0.15); color:#fff; } + .txa-ctx-divider { height:1px; background:var(--txa-border); margin:6px 0; } + .txa-ctx-footer { padding:10px 18px; font-size:11px; color:#64748b; text-align:center; font-weight:600; } + + /* SWITCH TOGGLE */ + .txa-switch { position:relative; display:inline-block; width:36px; height:20px; } + .txa-switch input { opacity:0; width:0; height:0; } + .txa-slider { position:absolute; cursor:pointer; inset:0; background:rgba(255,255,255,0.1); transition:.4s; border-radius:34px; border:1px solid var(--txa-border); } + .txa-slider:before { position:absolute; content:""; height:14px; width:14px; left:2px; bottom:2px; background:white; transition:.4s; border-radius:50%; } + .txa-switch input:checked + .txa-slider { background:var(--txa-brand); border-color:transparent; } + .txa-switch input:checked + .txa-slider:before { transform:translateX(16px); } + + /* SUBTITLES - DRAGGABLE */ + .txa-captions { + position:absolute; bottom:110px; left:50%; transform:translateX(-50%); + text-align:center; width:auto; max-width:80%; z-index:90; transition: bottom 0.3s; + cursor:grab; user-select:none; white-space: pre-wrap; word-break: break-word; + } + .txa-captions.dragging { cursor:grabbing; } + .txa-cue { + display:inline-block; padding:8px 16px; border-radius:12px; + background:rgba(0,0,0,0.75); font-size:24px; font-weight:600; + text-shadow:0 2px 4px rgba(0,0,0,0.5); line-height: 1.4; + pointer-events:none; + } + + /* Subtitle Style Presets */ + .txa-captions.size-mini .txa-cue { font-size:14px; padding:4px 8px; } + .txa-captions.size-small .txa-cue { font-size:18px; padding:6px 12px; } + .txa-captions.size-medium .txa-cue { font-size:24px; } + .txa-captions.size-large .txa-cue { font-size:32px; padding:10px 20px; } + .txa-captions.size-jumbo .txa-cue { font-size:48px; padding:14px 28px; } + + .txa-captions.bg-none .txa-cue { background:transparent; text-shadow:1px 1px 2px #000, -1px -1px 2px #000, 1px -1px 2px #000, -1px 1px 2px #000; } + .txa-captions.bg-dark .txa-cue { background:rgba(0,0,0,0.85); } + .txa-captions.bg-light .txa-cue { background:rgba(255,255,255,0.2); } + .txa-captions.bg-glass .txa-cue { background:rgba(15, 23, 42, 0.6); backdrop-filter:blur(8px); border:1px solid rgba(255,255,255,0.1); } + + .txa-captions.weight-bold .txa-cue { font-weight: 800; } + .txa-captions.weight-normal .txa-cue { font-weight: 500; } + + /* Subtitle Stroke (Border) */ + .txa-captions.stroke-on .txa-cue { -webkit-text-stroke: 2px #000; paint-order: stroke fill; } + .txa-captions.stroke-white .txa-cue { -webkit-text-stroke-color: #ffffff !important; } + .txa-captions.stroke-black .txa-cue { -webkit-text-stroke-color: #000000 !important; } + .txa-captions.stroke-yellow .txa-cue { -webkit-text-stroke-color: #facc15 !important; } + .txa-captions.stroke-red .txa-cue { -webkit-text-stroke-color: #f87171 !important; } + .txa-captions.stroke-blue .txa-cue { -webkit-text-stroke-color: #3b82f6 !important; } + + /* Subtitle Color Classes */ + .txa-captions.color-white .txa-cue { color: #ffffff !important; } + .txa-captions.color-yellow .txa-cue { color: #facc15 !important; } + .txa-captions.color-orange .txa-cue { color: #fb923c !important; } + .txa-captions.color-red .txa-cue { color: #f87171 !important; } + .txa-captions.color-green .txa-cue { color: #4ade80 !important; } + .txa-captions.color-cyan .txa-cue { color: #22d3ee !important; } + .txa-captions.color-pink .txa-cue { color: #f472b6 !important; } + .txa-captions.color-violet .txa-cue { color: #a78bfa !important; } + + .txa-stroke-ctrl { overflow:hidden; transition: max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s; max-height:0; opacity:0; } + .txa-stroke-ctrl.active { max-height: 100px; opacity:1; padding-top:10px; } + .txa-color-btn[data-substroke].active { transform:scale(1.2); border:2px solid #fff; } + + /* SKIP BUTTONS - PUSHED HIGHER */ + .txa-skip-btn { position:absolute; bottom:160px; right:30px; z-index:120; background:rgba(255,255,255,0.1); border:2px solid var(--txa-border); backdrop-filter:blur(15px); color:#fff; padding:12px 28px; border-radius:14px; font-size:13px; font-weight:800; cursor:pointer; display:none; transition:all 0.3s cubic-bezier(0.16, 1, 0.3, 1); box-shadow: 0 10px 30px rgba(0,0,0,0.5); } + .txa-skip-btn:hover { background:var(--txa-brand); border-color:transparent; transform:scale(1.05) translateX(-5px); } + .txa-skip-btn.intro { border-color:var(--txa-intro); color:#fff; } + .txa-skip-btn.intro:hover { background:var(--txa-intro); box-shadow: 0 10px 30px rgba(251,191,36,0.5); } + .txa-skip-btn.outro { border-color:var(--txa-outro); color:#fff; } + .txa-skip-btn.outro:hover { background:var(--txa-outro); box-shadow: 0 10px 30px rgba(239,68,68,0.5); } + + /* ZONES */ + .txa-zone { position:absolute; top:0; bottom:0; width:30%; z-index:30; cursor: pointer; } + .txa-zone.left { left:0; } + .txa-zone.right { right:0; } + + /* UTILS */ + .txa-hidden { display:none !important; } + /* Grid for Sub Style */ + .txa-grid-opts { display:grid; grid-template-columns:1fr 1fr; gap:8px; padding:0 20px 14px; } + .txa-grid-item { + background:rgba(255,255,255,0.05); border:1px solid transparent; border-radius:8px; + padding:8px; font-size:12px; text-align:center; cursor:pointer; transition:all 0.2s; color:#cbd5e1; + } + .txa-grid-item:hover { background:rgba(255,255,255,0.1); } + .txa-grid-item.active { background:rgba(139,92,246,0.15); border-color:var(--txa-brand); color:#fff; font-weight:700; } + + /* Color circles */ + .txa-color-opts { display:flex; gap:10px; padding:0 20px 20px; justify-content:center; } + .txa-color-btn { width:32px; height:32px; border-radius:50%; border:2px solid transparent; cursor:pointer; transition:all 0.2s; position:relative; } + .txa-color-btn.active { border-color:white; transform:scale(1.1); box-shadow:0 0 10px var(--txa-brand-glow); } + .txa-color-btn[data-subcolor="white"] { background:#fff; } + .txa-color-btn[data-subcolor="yellow"] { background:#facc15; } + .txa-color-btn[data-subcolor="orange"] { background:#fb923c; } + .txa-color-btn[data-subcolor="red"] { background:#f87171; } + .txa-color-btn[data-subcolor="green"] { background:#4ade80; } + .txa-color-btn[data-subcolor="cyan"] { background:#22d3ee; } + .txa-color-btn[data-subcolor="pink"] { background:#f472b6; } + .txa-color-btn[data-subcolor="violet"] { background:#a78bfa; } + + /* v5.8.0 - THEATER MODE */ + body.theater-mode-active { + overflow: hidden !important; + } + body.theater-mode-active::after { + content: ""; + position: fixed; + inset: 0; + background: rgba(0, 0, 0, 0.95); + z-index: 999998; + backdrop-filter: blur(15px); + animation: txaFadeIn 0.5s ease forwards; + } + @keyframes txaFadeIn { + from { opacity: 0; } + to { opacity: 1; } + } + .txa-wrapper.theater-mode { + z-index: 999999 !important; + position: fixed !important; + top: 50% !important; + left: 50% !important; + transform: translate(-50%, -50%) !important; + width: 95vw !important; + max-width: 1600px !important; + height: 53.43vw !important; /* Aspect ratio 16:9 */ + max-height: 90vh !important; + border-radius: 24px; + box-shadow: 0 0 100px rgba(0, 0, 0, 0.8), 0 0 40px rgba(229, 9, 20, 0.3); + transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1) !important; + } + /* body.theater-mode-active handled here */ + + /* v5.8.0 - CINEMA AMBIENT LIGHT */ + .txa-ambient-canvas { + position: absolute; + top: -50px; + left: -50px; + right: -50px; + bottom: -50px; + pointer-events: none; + z-index: -1; + filter: blur(80px) saturate(2); + opacity: 0; + transition: opacity 0.8s ease; + } + .txa-wrapper.cinema-mode .txa-ambient-canvas { + opacity: 0.6; + } + .txa-wrapper.cinema-mode { + overflow: visible; + --txa-intro: #fbbf24; + --txa-outro: #8b5cf6; + } + + .txa-switch { position: relative; display: inline-block; width: 34px; height: 18px; margin-left: auto; } + .txa-switch input { opacity: 0; width: 0; height: 0; } + .txa-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(255,255,255,0.1); transition: .4s; border-radius: 34px; border: 1px solid var(--txa-border); } + .txa-slider:before { position: absolute; content: ""; height: 12px; width: 12px; left: 2px; bottom: 2px; background-color: white; transition: .4s; border-radius: 50%; } + input:checked + .txa-slider { background-color: var(--txa-brand); } + input:checked + .txa-slider:before { transform: translateX(16px); } + + .txa-player-skin.cinema-active { + background: transparent !important; + } + + /* v5.8.0 - SPEED PREVIEW INDICATOR */ + .txa-speed-indicator { + position: absolute; + top: 30px; + left: 50%; + transform: translateX(-50%) translateY(-20px) scale(0.9); + background: rgba(139, 92, 246, 0.9); + backdrop-filter: blur(10px); + padding: 12px 24px; + border-radius: 100px; + font-size: 16px; + font-weight: 800; + color: #fff; + display: flex; + align-items: center; + gap: 10px; + z-index: 2147483647; + opacity: 0; + pointer-events: none; + transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1); + box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(139, 92, 246, 0.4); + border: 1px solid rgba(255, 255, 255, 0.2); + } + .txa-speed-indicator.show { + opacity: 1; + transform: translateY(0) scale(1); + } + .txa-speed-indicator i { + animation: txapulse 0.5s infinite alternate; + } + @keyframes txapulse { + from { transform: scale(1); } + to { transform: scale(1.2); } + } + + /* v5.8.0 - RESUME PLAYBACK OVERLAY */ + .txa-resume-overlay { + position: absolute; + bottom: 120px; + left: 50%; + transform: translateX(-50%) translateY(20px); + background: var(--txa-glass); + backdrop-filter: blur(20px); + border: 1px solid var(--txa-border); + border-radius: 20px; + padding: 16px 24px; + display: flex; + align-items: center; + gap: 16px; + z-index: 210; + opacity: 0; + visibility: hidden; + pointer-events: none; + transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1); + box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6); + } + .txa-resume-overlay.show { + opacity: 1; + visibility: visible; + pointer-events: auto; + transform: translateX(-50%) translateY(0); + } + .txa-resume-text { + display: flex; + flex-direction: column; + gap: 4px; + } + .txa-resume-text span:first-child { + font-size: 12px; + color: #94a3b8; + font-weight: 600; + } + .txa-resume-text span:last-child { + font-size: 16px; + font-weight: 800; + color: #fff; + } + .txa-resume-btns { + display: flex; + gap: 10px; + } + .txa-settings-panel { + width: 100vw; + max-width: none; + padding: 24px 20px 40px 20px; + border-radius: 24px 24px 0 0; + bottom: 0; + left: 0; + right: 0; + top: auto; + transform: translateY(105%); + max-height: 80vh; + background: rgba(15, 23, 42, 0.98); + box-shadow: 0 -10px 40px rgba(0,0,0,0.5); + border: none; + border-top: 1px solid rgba(255,255,255,0.1); + transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1); + } + + .txa-settings-panel.active { + transform: translateY(0); + } + + .txa-settings-panel::before { + content: ''; + position: absolute; + top: 10px; + left: 50%; + transform: translateX(-50%); + width: 40px; + height: 4px; + background: rgba(255,255,255,0.2); + border-radius: 10px; + } + .txa-resume-btn { + padding: 10px 20px; + border-radius: 12px; + border: none; + font-weight: 700; + font-size: 13px; + cursor: pointer; + transition: all 0.2s; + } + .txa-resume-btn.primary { + background: var(--txa-brand); + color: #fff; + box-shadow: 0 5px 20px var(--txa-brand-glow); + } + .txa-resume-btn.primary:hover { + transform: translateY(-2px); + box-shadow: 0 8px 25px var(--txa-brand-glow); + } + .txa-resume-btn.secondary { + background: rgba(255, 255, 255, 0.1); + color: #fff; + border: 1px solid var(--txa-border); + } + .txa-resume-btn.secondary:hover { + background: rgba(255, 255, 255, 0.15); + } + + .txa-ripple { + position: absolute; + width: 100px; + height: 100px; + background: radial-gradient(circle, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 70%); + border-radius: 50%; + transform: scale(0); + pointer-events: none; + z-index: 50; + animation: txaripple 0.6s ease-out forwards; + } + @keyframes txaripple { + 0% { transform: scale(0); opacity: 1; } + 100% { transform: scale(4); opacity: 0; } + } + + .txa-btn.mode-active { + color: var(--txa-brand); + } + .txa-btn.mode-active i { + filter: drop-shadow(0 0 8px var(--txa-brand-glow)); + } + + .txa-badge-quality { + position: absolute; + top: 4px; + right: 4px; + background: rgba(255,255,255,0.2); + color: #fff; + font-size: 8px; + font-weight: 800; + padding: 1px 3px; + border-radius: 3px; + line-height: 1; + pointer-events: none; + transition: all 0.3s; + display: none; + z-index: 2; + font-family: sans-serif; + box-shadow: 0 1px 3px rgba(0,0,0,0.3); + } + + /* --- 2X SPEED OVERLAY --- */ + .txa-speed-overlay { + position: absolute; + top: 15%; + left: 50%; + transform: translateX(-50%); + background: rgba(0, 0, 0, 0.6); + color: #fff; + padding: 8px 16px; + border-radius: 20px; + font-size: 13px; + font-weight: 700; + opacity: 0; + transition: opacity 0.2s; + pointer-events: none; + z-index: 10000; + display: flex; + align-items: center; + gap: 8px; + backdrop-filter: blur(4px); + border: 1px solid rgba(255,255,255,0.1); + } + .txa-speed-overlay.show { opacity: 1; } + + /* v6.2.0 - TOP INFO BAR */ + .txa-top-info { + position: absolute; + top: 0; + left: 0; + right: 0; + padding: 15px 25px; + background: linear-gradient(to bottom, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 50%, transparent 100%); + z-index: 10002; + display: flex; + justify-content: space-between; + align-items: center; + opacity: 0; + transform: translateY(-20px); + transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1); + pointer-events: none; + } + .active-ui .txa-top-info { opacity: 1; transform: translateY(0); } + .txa-top-title { + font-weight: 700; + font-size: 15px; + color: #fff; + text-shadow: 0 2px 10px rgba(0,0,0,0.5); + display: flex; + align-items: center; + gap: 8px; + max-width: 80%; + } + + /* Desktop Title Size Increase */ + @media (min-width: 1024px) { + .txa-top-title { font-size: 20px; } + .txa-top-title i { font-size: 18px; } + .txa-top-logo { font-size: 24px; } + } + + .txa-top-title i { color: #facc15; font-size: 14px; } + + .txa-top-logo { font-weight: 800; font-size: 18px; letter-spacing: 0.5px; } + .txa-logo-t { color: #a855f7; } + .txa-logo-phim { color: #fff; } + .txa-logo-x { color: #ef4444; } + + /* Aspect Ratio & Flip Support */ + .txa-video.ratio-4-3 { object-fit: fill; aspect-ratio: 4/3; width: auto; height: 100%; margin: 0 auto; display: block; } + .txa-video.ratio-16-9 { object-fit: contain; aspect-ratio: 16/9; } + .txa-video.ratio-stretch { object-fit: fill; } + .txa-video.flip-h { transform: scaleX(-1); } + .txa-video.flip-v { transform: scaleY(-1); } + .txa-video.flip-both { transform: scale(-1); } + + /* Hide simple logo in FS when controls are shown */ + .fullscreen-mode.active-ui .txa-brand-logo { opacity: 0 !important; visibility: hidden !important; } + + /* --- NEXT EPISODE COUNTDOWN OVERLAY --- */ + .txa-next-countdown { + position: absolute; bottom: 120px; right: 30px; + background: rgba(15, 23, 42, 0.7); backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px); + border: 1px solid rgba(255,255,255,0.15); border-radius: 20px; padding: 20px; + display: flex; align-items: center; gap: 20px; z-index: 220; + transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1); + opacity: 0; transform: translateY(20px) scale(0.9); pointer-events: none; + box-shadow: 0 15px 45px rgba(0,0,0,0.5), 0 0 20px rgba(139,92,246,0.2); + max-width: 400px; + padding: 25px; + } + .txa-next-countdown.show { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; } + .txa-nc-thumb-wrap { position: relative; width: 140px; height: 79px; flex-shrink: 0; } + .txa-nc-thumb { width: 100%; height: 100%; border-radius: 12px; object-fit: cover; background: #000; border: 1px solid rgba(255,255,255,0.1); } + .txa-nc-badge { + position: absolute; top: -10px; left: -10px; + background: var(--txa-brand); color: #fff; + padding: 4px 10px; border-radius: 8px; + font-family: 'Outfit', sans-serif; font-weight: 900; font-size: 16px; + box-shadow: 0 4px 15px var(--txa-brand-glow); + border: 2px solid rgba(255,255,255,0.2); + transform: rotate(-5deg); + z-index: 2; + text-shadow: 0 2px 4px rgba(0,0,0,0.3); + } + .txa-nc-badge span { font-size: 10px; text-transform: uppercase; margin-right: 3px; opacity: 0.8; font-weight: 600; } + .txa-nc-info { flex: 1; display: flex; flex-direction: column; gap: 6px; } + .txa-nc-label { font-size: 12px; font-weight: 800; color: #94a3b8; text-transform: uppercase; letter-spacing: 1.2px; } + .txa-nc-title { font-size: 16px; font-weight: 700; color: #fff; line-height: 1.4; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; } + .txa-nc-timer { font-size: 13px; font-weight: 600; color: var(--txa-brand-light); } + .txa-nc-actions { display: flex; flex-direction: column; gap: 10px; } + .txa-nc-next { + background: var(--txa-brand); border: none; color: #fff; font-size: 12px; font-weight: 800; + padding: 8px 16px; border-radius: 10px; cursor: pointer; transition: 0.3s; + text-align: center; box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3); + } + .txa-nc-next:hover { transform: translateY(-2px); filter: brightness(1.1); } + .txa-nc-cancel { + background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.1); color: #fff; font-size: 11px; font-weight: 700; + padding: 6px 12px; border-radius: 10px; cursor: pointer; transition: 0.3s; + opacity: 0.7; + } + .txa-nc-cancel:hover { background: rgba(255,255,255,0.15); opacity: 1; } + + .txa-desktop-only { display: none; } + @media (min-width: 1024px) { .txa-desktop-only { display: block; } } + + @media (max-width: 768px) { + .txa-next-countdown { left: 15px; right: 15px; bottom: 85px; max-width: none; padding: 15px; gap: 12px; } + .txa-nc-thumb-wrap { width: 100px; height: 56px; } + .txa-nc-badge { font-size: 13px; padding: 3px 8px; top: -8px; left: -8px; } + + /* Mobile Controls Minimalist */ + .txa-controls { padding: 8px 15px; } + .txa-toolbar { display: flex; align-items: center; justify-content: space-between; } + .txa-group { padding: 3px 6px; gap: 4px; background: rgba(0,0,0,0.4); } + .txa-btn { width: 34px; height: 34px; } + .txa-btn i { font-size: 14px; } + .txa-time { font-size: 10px; margin: 0 4px; } + + /* Hide secondary tools on mobile vertical */ + #txa-theater, #txa-cinema, #txa-pip, .txa-vol-container, .txa-watermark { display: none; } + + /* Keep PRO buttons small & showing status */ + .txa-btn-pro { width: 32px; height: 32px; } + .txa-btn-status { font-size: 7px; min-width: 14px; top: -1px; right: -1px; border-width: 1px; transform: scale(0.85); visibility: visible !important; opacity: 1 !important; } + + /* Mobile Controls Minimalist */ + .txa-progress-wrap { height: 14px; margin-bottom: 25px; } + .txa-progress-wrap::before { + content: ''; position: absolute; top: -20px; bottom: -20px; left: 0; right: 0; + } + + /* Fullscreen Landscape Adjustments */ + .fullscreen-mode .txa-controls { padding: 15px 40px 30px; } + .fullscreen-mode .txa-toolbar { gap: 15px; } + + /* AUTOMATIC MINIMALISM BASED ON WIDTH */ + @container player (max-width: 500px) { + .txa-time { display: none !important; } + #txa-cc, #txa-pip, #txa-auto-skip, #txa-auto-next { display: none !important; } + } + + /* Ticker - Only show in fullscreen on mobile as requested */ + .txa-ticker-container { display: none !important; } + .fullscreen-mode .txa-ticker-container.active { display: block !important; bottom: 60px; } + .fullscreen-mode.active-ui .txa-ticker-container { bottom: 120px; } + + /* EXTREME MINIMALISM (< 480px) */ + @media (max-width: 480px) { + #txa-auto-skip, #txa-auto-next, #txa-cc, .txa-time { display: none !important; } + .txa-group { background: transparent; padding: 0; } + .txa-controls { padding: 5px 10px; } + .txa-toolbar { height: 40px; } + .txa-btn { width: 42px; height: 42px; } + .txa-btn i { font-size: 18px; } + .txa-top-info { padding: 10px 15px; } + .txa-top-logo { display: none; } + } + + /* TABLET ADAPTATION (768px - 1024px) */ + @media (min-width: 769px) and (max-width: 1024px) { + .txa-toolbar { gap: 5px; } + #txa-theater, #txa-cinema { display: none; } + .txa-btn-status { font-size: 8px; padding: 1px 3px; } + } + } + .txa-ticker-text { font-size: 13px; padding: 8px 18px; } + + /* v6.4.0 - Intermediate Responsive (Tablet/Resized Desktop) */ + @media (max-width: 1024px) { + .txa-vol-container:hover .txa-vol-slider-wrap { width: 100px; } + .txa-vol-slider { width: 85px; } + .txa-top-title { font-size: 16px; } + } + + /* Hide some buttons on very narrow players even on desk */ + @media (max-width: 650px) { + #txa-theater, #txa-cinema, #txa-pip, .txa-vol-container { display: none !important; } + .txa-group { padding: 4px 8px; } + .txa-btn { width: 38px; height: 38px; } + } + + /* Ultra small devices */ + @media (max-width: 375px) { + .txa-time, #txa-prev, #txa-next { display: none !important; } + .txa-nc-title { font-size: 14px; } + .txa-top-info { padding: 8px 12px; } + .txa-top-logo { font-size: 16px; } + .txa-brand-logo { display: none !important; } + .txa-realtime-clock { display: none !important; } + } + + /* Mobile Landscape Enhancements */ + @media (max-width: 768px) and (orientation: landscape) { + .txa-controls { padding: 6px 12px; } + .txa-toolbar { height: 35px; } + .txa-btn { width: 32px; height: 32px; } + .txa-btn i { font-size: 12px; } + .txa-time { font-size: 9px; margin: 0 2px; } + .txa-progress-wrap { height: 12px; margin-bottom: 20px; } + } + + /* Touch Device Optimizations */ + @media (hover: none) and (pointer: coarse) { + .txa-btn:hover { background: none; } + .txa-btn:active { background: rgba(255,255,255,0.15); transform: scale(0.95); } + .txa-tooltip { display: none !important; } + + /* Larger touch targets for mobile */ + .txa-btn { min-width: 44px; min-height: 44px; } + .txa-vol-slider { height: 28px; } + .txa-vol-slider::-webkit-slider-thumb { width: 20px; height: 20px; } + .txa-vol-slider::-moz-range-thumb { width: 20px; height: 20px; } + } + + /* High DPI Mobile Displays */ + @media (max-width: 768px) and (-webkit-min-device-pixel-ratio: 2) { + .txa-btn i { filter: drop-shadow(0 0 3px rgba(0,0,0,0.3)); } + .txa-progress-wrap { height: 16px; } + .txa-scrubber { width: 16px; height: 16px; } + } + + .txa-menu-item.disabled { opacity: 0.5; pointer-events: auto; cursor: not-allowed; } + .txa-menu-item.disabled:hover { background: transparent; } + /* v6.6.2 - MOBILE OPTIMIZATIONS (NEON CORE) */ + .is-mobile #txa-wrapper { border-radius: 0 !important; margin: 0 !important; box-shadow: none !important; } + .is-mobile .txa-btn { width: 48px; height: 48px; font-size: 18px; background: rgba(255,255,255,0.03); border-radius: 12px; } + .is-mobile .txa-progress-container { padding: 15px 0; } + .is-mobile .txa-progress-wrapper { height: 4px; } + .is-mobile .txa-controls { padding: 0 15px 15px; height: 80px; } + .is-mobile .txa-time { font-size: 13px; font-weight: 700; color: rgba(255,255,255,0.8); } + .is-mobile .txa-skip-btn { bottom: 100px; right: 15px; padding: 10px 20px; font-size: 12px; font-weight: 800; border-radius: 14px; } + .is-mobile .txa-preview-thumb { width: 140px; height: 78px; bottom: 90px; } + .is-mobile .txa-volume-container { display: none !important; } + + .is-mobile .txa-top-info { padding: 15px; background: linear-gradient(to bottom, rgba(0,0,0,0.9), transparent); } + .is-mobile .txa-top-title { font-size: 14px; max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } + .is-mobile .txa-top-logo { display: none; } + + .is-mobile .txa-panel { width: 100% !important; border-radius: 24px 24px 0 0 !important; bottom: 0 !important; right: 0 !important; top: auto !important; transform: translateY(100%); max-height: 80vh; background: #0a0f1d !important; } + .is-mobile .txa-panel.active { transform: translateY(0); } + .is-mobile .txa-panel-header { padding: 24px; font-size: 16px; } + .is-mobile .txa-menu-item { padding: 18px 24px; font-size: 15px; } + + .is-mobile .txa-zone-hint { width: 70px; height: 70px; } + .is-mobile #txa-theater, .is-mobile #txa-cinema { display: none !important; } + + .is-mobile .txa-next-countdown { width: calc(100% - 30px); bottom: 100px; left: 15px; padding: 15px; border-radius: 20px; font-size: 14px; } + .is-mobile .txa-nc-btn { padding: 8px 16px; font-size: 12px; } + + @keyframes txa-mobile-fade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } } + `; + document.head.appendChild(s); + } + + renderUI() { + this.container.innerHTML = ` +
+ +
+
+ + TPhimX Media +
+ +
+ + + + + +
+ + 00:00:00 +
+
TPHIMX Player-${TXA_VERSION}
+ + + +
+
+
+
+
0%
+
-- KB/s
+
+
+
Vui lòng chờ trong giây lát...
+
+
+
+ + +
+
+
STREAM STATS
+ +
+
+
+ +
+ + Phát lại +
+ +
50%
+ +
-10s
+
+10s
+ +
+ +
+ + + + + + +
+ + 2x Tua nhanh +
+ +
+
+ Tiếp tục xem? + 00:00 +
+
+ + +
+
+ + +
+
+
Tập--
+ +
+
+ Tập Tiếp Theo + Đang chuẩn bị... + Bắt đầu sau 05s +
+
+ + +
+
+ + +
+
+
+ +
+
+
+
+
+
+
+
0:00
+
+ +
+
+
+ + + +
+ +
100%
+
+ +
+
+
+
0:00 / 0:00
+
+ +
+
+ + +
+ + + + + + +
+
+
+
+ +
+
+
Settings
+
Playback Speed1x
+
Aspect RatioDefault
+
Video FlipNormal
+
SubtitlesOff
+ +
+ Hiện đồng hồ + +
+ +
+
+
Kiểu hiển thị đồng hồ
+ +
Chỉ thời gian
+
Giờ : Phút : GiâyH:i:s
+
Giờ : PhútH:i
+ +
Thời gian & Ngày
+
Đầy đủH:i:s d/M/YYYY
+
GọnH:i d/M/YYYY
+
Giờ & Ngày/ThángH:i:s d/M
+ +
Chỉ ngày tháng
+
Ngày / Tháng / Nămd/M/Y
+
Chuẩn ISOYYYY/M/d
+
+ +
+
Aspect Ratio
+
Default
+
4:3
+
16:9
+
Stretch
+
+
+
Video Flip
+
Normal
+
Horizontal
+
Vertical
+
Both
+
+
+
Speed
+
0.25x
+
0.5x
+
0.75x
+
Normal
+
1.25x
+
1.5x
+
1.75x
+
2x
+
2.5x
+
3x
+
+
+
Subtitles
+
+
Thiết kế phụ đề
+
+
+
Thiết kế phụ đề
+ +
Cỡ chữ
+
+
Tí hon
+
Nhỏ
+
Vừa
+
Lớn
+
Khổng lồ
+
+ +
Độ đậm
+
+
Thường
+
Đậm
+
+ +
Nền phụ đề
+
+
Không
+
Chuẩn
+
Kính
+
Tối
+
Sáng
+
+ +
Màu chữ
+
+
+
+
+
+
+
+
+
+
+ +
+ Viền chữ + +
+ +
+
Màu viền
+
+
+
+
+
+
+
+
+
+
+
Quality
+
+
+
+
+ +
+
+
+ +
+

BẢO MẬT HỆ THỐNG

+

+ Phát hiện hành động can thiệp trái phép vào trình phát. +
+ TPHIMX Security đã tạm khóa phiên làm việc này để bảo vệ nội dung. +

+
+ +
+
PROTECTED BY TXA SHIELD v6.5
+
+
+ +
+
TXAPlayer Controls
+
Chụp màn hình (4K)
+
Copy Video URL
+
Lặp lại (Loop)Off
+
Thống kê (Stats)
+
+
Bảng phím tắt
+ +
+ +
+
+ `; + this.wrapper = this.container.querySelector('#txa-wrapper'); + this.video = this.container.querySelector('#txa-video'); + this.controls = this.container.querySelector('.txa-controls'); + } + + async switchEpisode(newOptions = {}) { + // console.log('[TXAPlayer] Switching episode...', newOptions); + + // Save fullscreen state before switching + const wasFullscreen = !!document.fullscreenElement; + // Store reference to wrapper, not fullscreenElement (which will be null after video destroy) + const wrapperToFS = this.wrapper; + + // 0. Save current progress + this.saveWatchProgress(true); + + // Feedback immediately + if (newOptions.isAutoNext) { + this.showToast('⏭️ Tự động chuyển tập...'); + } else { + this.showToast('🚀 Đang chuyển tập mới...'); + } + + // 1. Cleanup current media + if (this._bufferInterval) { clearInterval(this._bufferInterval); this._bufferInterval = null; } + if (this.dashPlayer) { + try { this.dashPlayer.destroy(); } catch (e) { } + this.dashPlayer = null; + } + if (this.hls) { + try { this.hls.destroy(); } catch (e) { } + this.hls = null; + } + if (this._previewHls) { + try { this._previewHls.destroy(); } catch (e) { } + this._previewHls = null; + } + + // Reset video state + if (this.video) { + this.video.pause(); + this.video.src = ""; + this.video.load(); + + // Clear text tracks (subtitles) + while (this.video.firstChild) { + this.video.removeChild(this.video.firstChild); + } + } + + // 2. Update Options + this.options = { ...this.options, ...newOptions }; + + // Proxy external images for new episode + if (this.options.posterUrl) this.options.posterUrl = this.getProxiedUrl(this.options.posterUrl); + if (this.options.movieThumb) this.options.movieThumb = this.getProxiedUrl(this.options.movieThumb); + if (this.options.previewUrl) this.options.previewUrl = this.getProxiedUrl(this.options.previewUrl); + + // Clear runtime state + this.currentSubCues = []; + this.activeSubIdx = -1; + this.seekAccumulator = 0; + this._isAutoNextTriggered = false; + this._fixedTickerShown = false; // Reset fixed ticker flag + this._endingTickerShown = false; // Reset ending ticker flag + if (this.wrapper) this.wrapper.classList.remove('has-countdown'); + this.tickerCount = 0; // Reset ticker count for new episode + this._isTickerRunning = false; + this.tickerNextTime = 40; // Wait 40s for new episode ticker + this.resumeShown = false; // Reset resume flag for new episode + + // Clear any pending auto-next countdown + if (this._autoNextCountdownInterval) { + clearInterval(this._autoNextCountdownInterval); + this._autoNextCountdownInterval = null; + } + + // Reset markers on UI immediately + this.renderMarkers(); + + // Reset preview thumbnail state for new episode + this._previewSpriteUrl = null; + this._previewSpriteLoaded = false; + this._previewLowUrl = null; + this._previewLowLoaded = false; + if (this._previewUpgradeTimer) { clearTimeout(this._previewUpgradeTimer); this._previewUpgradeTimer = null; } + const previewThumb = this.container.querySelector('#txa-preview-thumb'); + if (previewThumb) { previewThumb.classList.remove('has-sprite', 'loading'); previewThumb.style.backgroundImage = ''; } + + // Reset UI Components + const replay = this.container.querySelector('#txa-replay'); + if (replay) replay.classList.remove('show'); + + const loader = this.container.querySelector('#txa-loader'); + if (loader) loader.classList.remove('hidden'); + + // Update Top Title + this.updateTopTitle(); + + // 3. Re-initialize Media + try { + await this.setupMedia(); + } catch (error) { + console.error('[TXAPlayer] setupMedia failed:', error); + this.reportErrorToServer('setupMediaError', error.message, { stack: error.stack }); + + // Keep loader hidden, show error + if (loader) loader.classList.add('hidden'); + this.showToast('❌ Lỗi load video. Đang thử lại...'); + + // Retry after 2 seconds + setTimeout(() => { + if (!this.destroyed) { + console.log('[TXAPlayer] Retrying setupMedia...'); + this.setupMedia().catch(err => { + console.error('[TXAPlayer] Retry failed:', err); + this.reportErrorToServer('setupMediaError', 'Retry failed: ' + err.message, { stack: err.stack }); + this.showToast('❌ Không thể load video. Vui lòng reload trang.'); + }); + } + }, 2000); + return; // Exit early, don't show feedback + } + + // 4. Re-initialize Subtitles UI (not just tracks) + this.initSubtitles(); + + // 5. Update Navigation Buttons + const prevBtn = this.container.querySelector('#txa-prev'); + const nextBtn = this.container.querySelector('#txa-next'); + if (prevBtn) { + prevBtn.style.display = this.options.prevEpisodeUrl ? 'flex' : 'none'; + } + if (nextBtn) { + nextBtn.style.display = this.options.nextEpisodeUrl ? 'flex' : 'none'; + } + + // 6. Wait for video to be ready before hiding loader + await new Promise((resolve) => { + const checkReady = () => { + // Check if video has valid duration and readyState + if (this.video && this.video.readyState >= 2) { + // HAVE_CURRENT_DATA - enough data to play + resolve(); + } else if (this.destroyed) { + resolve(); // Don't wait if destroyed + } else { + // Wait a bit and check again + setTimeout(checkReady, 100); + } + }; + + // Timeout after 15 seconds + setTimeout(() => { + console.warn('[TXAPlayer] Video ready timeout, proceeding anyway'); + resolve(); + }, 15000); + + checkReady(); + }); + + // 7. Final UI Polish (especially for Full Screen) + this.showUI(); + + // Hide loader only after video is ready + if (loader) loader.classList.add('hidden'); + + // 8. Restore fullscreen if it was active before switching + if (wasFullscreen && wrapperToFS) { + // Wait a bit for video to be ready before requesting fullscreen + setTimeout(async () => { + try { + await wrapperToFS.requestFullscreen(); + console.log('[TXAPlayer] Fullscreen restored after episode switch'); + } catch (err) { + console.warn('[TXAPlayer] Could not restore fullscreen:', err); + } + }, 500); + } + + // 9. Trigger external event if needed + if (this.options.onEpisodeSwitched) { + this.options.onEpisodeSwitched(this.options); + } + + // 10. Final Feedback (High Priority) - Only show after video is ready + setTimeout(() => { + if (!this.destroyed) { + this.showFeedback('high', `⏭️ Đã chuyển: ${this.options.episodeName || 'Tập mới'}`); + } + }, 500); + } + + updateTopTitle() { + const titleEl = this.container.querySelector('#txa-top-title span'); + if (!titleEl) return; + + let movieTitle = this.options.title || 'Đang tải...'; + let episodeTitle = this.options.episodeName || ''; + + // Clean up movieTitle if it already contains the episode name to avoid duplication + if (episodeTitle && movieTitle.includes(episodeTitle)) { + // If movieTitle is "Phim A - Tập 1" and episodeTitle is "Tập 1" + // We want titleStr to be "Xem phim: Phim A - Tập 1" + // Instead of "Xem phim: Phim A - Tập 1 - Tập 1" + titleEl.textContent = 'Xem phim: ' + movieTitle + (this.options.serverName ? ' - ' + this.options.serverName : ''); + return; + } + + let titleStr = 'Xem phim: ' + movieTitle; + + // Handle episode name logic (skip if "Full" or if duplication detected) + if (episodeTitle && !episodeTitle.toLowerCase().includes('full')) { + titleStr += ' - ' + episodeTitle; + } + + // Add server name if exists + if (this.options.serverName) { + titleStr += ' - ' + this.options.serverName; + } + + titleEl.textContent = titleStr; + } + + async getM3u8TsListFast(url) { + // Ensure URL is absolute because proxy URLs might be relative paths (e.g., /api/proxy-media...) + const absoluteUrl = new URL(url, window.location.origin).href; + + let response = await fetch(absoluteUrl, { headers: { 'X-EXTENSION-MODE': '1' } }); + if (!response.ok) throw new Error("Fetch m3u8 lỗi."); + let text = await response.text(); + let lines = text.split("\n"); + + if (text.includes("METHOD=AES-128")) { + throw new Error("Luồng bị mã hóa AES-128 (Yêu cầu HLS.js để giải mã)."); + } + + if (text.includes("EXT-X-STREAM-INF")) { + let variants = []; + for (let i = 0; i < lines.length; i++) { + if (lines[i].includes("EXT-X-STREAM-INF")) { + let info = lines[i]; + let nextLine = lines[i + 1]; + if (nextLine && !nextLine.startsWith("#")) { + let bandwidth = 0; + const bwMatch = info.match(/BANDWIDTH=(\d+)/); + if (bwMatch) bandwidth = parseInt(bwMatch[1]); + + let resolution = "0x0"; + const resMatch = info.match(/RESOLUTION=(\d+x\d+)/); + if (resMatch) resolution = resMatch[1]; + + variants.push({ + url: new URL(nextLine.trim(), absoluteUrl).href, + bandwidth: bandwidth, + resolution: resolution + }); + } + } + } + + if (variants.length > 0) { + // Sort by bandwidth descending (best quality first) + variants.sort((a, b) => b.bandwidth - a.bandwidth); + if (this.options.isAdmin) console.log('[TXAPlayer] High Quality Variant Selected:', variants[0]); + return await this.getM3u8TsListFast(variants[0].url); + } + } + + let tsUrls = []; + let initUrl = null; + let totalDuration = 0; + for (let i = 0; i < lines.length; i++) { + let line = lines[i].trim(); + if (line.startsWith("#EXTINF:")) { + let dur = parseFloat(line.split(":")[1]); + if (!isNaN(dur)) totalDuration += dur; + } + if (line.startsWith("#EXT-X-MAP:URI=")) { + const mapMatch = line.match(/URI="([^"]+)"/); + if (mapMatch) initUrl = new URL(mapMatch[1], absoluteUrl).href; + } + if (line && !line.startsWith("#")) { + tsUrls.push(new URL(line, absoluteUrl).href); + } + } + + if (initUrl) { + tsUrls.unshift(initUrl); // Prepend init map for FMP4 + } + + // Estimate 1.5 Mbps bitrate for size calculation + const estimatedSize = totalDuration * (1.5 * 1024 * 1024 / 8); + return { urls: tsUrls, duration: totalDuration, estimatedSize: estimatedSize }; + } + + async loadM3u8AsMP4(m3u8Url, updateLoadingPct, completeLoading, showLoaderWithProgress) { + try { + const loadText = this.container.querySelector('#txa-load-text'); + const pctEl = this.container.querySelector('#txa-load-pct'); + const speedEl = this.container.querySelector('#txa-load-speed'); + const loadInfoEl = this.container.querySelector('#txa-load-info'); + + // --- CACHE CHECK --- + const cacheKey = this.options.episodeId ? `ep-${this.options.episodeId}` : null; + if (cacheKey) { + if (loadText) loadText.textContent = "🔍 Đang kiểm tra bộ nhớ tạm (Cache)..."; + const cached = await txaStorage.get(cacheKey); + if (cached && (cached.m3u8Url === m3u8Url || m3u8Url.includes('proxy-media'))) { + if (loadText) loadText.textContent = "⚡ Phát từ Cache (Siêu tốc)!"; + updateLoadingPct(100, true); + completeLoading(); + const objectUrl = URL.createObjectURL(cached.data); + this.video.src = objectUrl; + if (this.options.autoPlay) this.video.play().catch(() => { }); + return; + } + } + + if (loadText) loadText.textContent = "⚙️ Đang phân tích luồng HLS..."; + showLoaderWithProgress(5); + + const m3u8Result = await this.getM3u8TsListFast(m3u8Url); + let tsList = m3u8Result.urls; + if (!tsList || tsList.length === 0) throw new Error("Không có file TS trong playlist!"); + + let total = tsList.length; + let mergedBuffers = []; + let totalBytes = 0; + let startTime = performance.now(); + let lastUpdate = performance.now(); + + if (loadInfoEl) { + const sMB = window.txaformat ? window.txaformat.fileSize(m3u8Result.estimatedSize, 1) : (m3u8Result.estimatedSize / (1024 * 1024)).toFixed(1) + " MB"; + const durStr = window.txaformat ? window.txaformat.timeRemaining(m3u8Result.duration) : (m3u8Result.duration / 60).toFixed(0) + " phút"; + loadInfoEl.innerHTML = ` + ${durStr} + ~${sMB} + PREMIUM BLOB ACTIVE + `; + } + + // Batch size for parallel downloads (Turbo Mode: 17) + const batchSize = 17; + + for (let i = 0; i < total; i += batchSize) { + const batch = tsList.slice(i, i + batchSize); + const promises = batch.map(async (ts, idx) => { + const r = await fetch(ts, { + headers: { 'X-EXTENSION-MODE': '1' } + }); + if (!r.ok) throw new Error(`Fetch TS ${i + idx} fail: ${r.status}`); + const buf = await r.arrayBuffer(); + totalBytes += buf.byteLength; + + // Periodic stats update + const now = performance.now(); + if (now - lastUpdate > 500) { + const elapsed = (now - startTime) / 1000; + const speed = totalBytes / elapsed; + const remaining = total - (i + idx); + const avgTimePerTs = elapsed / (i + idx + 1); + const etaSec = Math.round(remaining * avgTimePerTs); + + if (speedEl) { + const speedStr = window.txaformat ? window.txaformat.fileSize(speed, 1) + "/s" : (speed / 1048576).toFixed(1) + " MB/s"; + const etaStr = window.txaformat ? window.txaformat.timeRemaining(etaSec) : (etaSec > 60 ? Math.floor(etaSec / 60) + "m " + (etaSec % 60) + "s" : etaSec + "s"); + speedEl.innerHTML = `${speedStr} ETA: ${etaStr}`; + } + if (loadText) loadText.textContent = `🚀 [TSHORT] Đang tải seg ${i + idx + 1}/${total}...`; + lastUpdate = now; + } + return buf; + }); + + const buffers = await Promise.all(promises); + mergedBuffers.push(...buffers); + + const progress = 10 + Math.floor((Math.min(i + batchSize, total) / total) * 85); + updateLoadingPct(progress, true); + } + + if (loadText) loadText.textContent = "🛠️ Đang lắp ráp Video MP4..."; + + const isFmp4 = tsList[0].includes('.m4s') || tsList[0].includes('.mp4'); + const blobType = isFmp4 ? 'video/mp4' : 'video/mp2t'; + const combinedBlob = new Blob(mergedBuffers, { type: blobType }); + + // --- SAVE TO CACHE --- + if (cacheKey) { + txaStorage.set(cacheKey, combinedBlob, m3u8Url); + } + + const objectUrl = URL.createObjectURL(combinedBlob); + + if (loadText) loadText.textContent = "✨ Sẵn sàng phát (Premium)!"; + updateLoadingPct(100, true); + completeLoading(); + + this.video.src = objectUrl; + if (this.options.autoPlay) this.video.play().catch(() => { }); + + } catch (e) { + console.error("[TXAPlayer Premium] Error: ", e); + if (window.txatoastfy) window.txatoastfy.error('Anti-403 Mode thất bại: ' + e.message, 5000); + + // Fallback to standard HLS + const loadText = this.container.querySelector('#txa-load-text'); + if (loadText) loadText.textContent = "⚠️ Lỗi Anti-403, đang rollback về HLS tiêu chuẩn..."; + setTimeout(() => { + this._initStandardHls(); + }, 2000); + } + } + + async setupMedia() { + if (!this.video || this._mediaSetupDone) return; + this._mediaSetupDone = true; + + // --- Google Drive Auto-Resolution --- + // Detects Google Drive sharing links and converts to proxy stream URL + // Supported formats: + // https://drive.google.com/file/d/FILE_ID/view?usp=... + // https://drive.google.com/file/d/FILE_ID/preview + // https://drive.google.com/open?id=FILE_ID + // https://drive.google.com/uc?id=FILE_ID&export=download + if (this.options.videoUrl && this.options.videoUrl.includes('drive.google.com')) { + let driveFileId = null; + + // Pattern 1: /file/d/FILE_ID/ + const fileMatch = this.options.videoUrl.match(/\/file\/d\/([a-zA-Z0-9_-]+)/); + if (fileMatch) { + driveFileId = fileMatch[1]; + } + + // Pattern 2: ?id=FILE_ID or &id=FILE_ID + if (!driveFileId) { + try { + const u = new URL(this.options.videoUrl); + driveFileId = u.searchParams.get('id'); + } catch (_) { } + } + + if (driveFileId) { + // Convert to local proxy stream URL (supports HTTP Range seeking) + const proxyUrl = '/api/drive-stream/' + driveFileId; + console.log( + '%c[TXAPlayer] 📁 Google Drive Detected ✅', + 'color:#4285f4; font-weight:bold;', + { fileId: driveFileId, proxyUrl } + ); + this.options.videoUrl = proxyUrl; + + // Show status on loader + const _loadText = this.container?.querySelector('#txa-load-text'); + if (_loadText) _loadText.textContent = 'Đang kết nối Google Drive...'; + } + } + + // --- StreamC Auto-Resolution (Dynamic Subdomain Support) --- + if (this.options.videoUrl && (this.options.videoUrl.includes('streamc.xyz') || this.options.videoUrl.includes('streamc.top') || /^[a-f0-9]{32}$/i.test(this.options.videoUrl))) { + let hash = null; + let embedHost = ''; + if (/^[a-f0-9]{32}$/i.test(this.options.videoUrl)) { + hash = this.options.videoUrl; + } else if (this.options.videoUrl.includes('hash=')) { + try { + const u = new URL(this.options.videoUrl); + hash = u.searchParams.get('hash'); + embedHost = u.hostname; // e.g., embed18.streamc.xyz + embedHost = u.hostname; + } catch (_) { } + } else { + const m = this.options.videoUrl.match(/\/([a-f0-9]{32})\//i); + if (m) hash = m[1]; + } + if (!embedHost && this.options.videoUrl.includes('streamc')) { + const hm = this.options.videoUrl.match(/(embed\d*\.streamc\.(?:xyz|top))/i); + if (hm) embedHost = hm[1]; + } + if (hash) { + // ── Hiển thị trạng thái đang resolve trên loader ── + const _loadText = this.container?.querySelector('#txa-load-text'); + if (_loadText) _loadText.textContent = 'Đang kết nối nguồn phim...'; + + /** Hiện error overlay thay vì để loader treo mãi */ + const _showStreamCError = (msg, canRetry = true) => { + // Report resolve error to server + this.reportErrorToServer('resolveError', msg, { hash, embedHost }); + + const loader = this.container?.querySelector('#txa-loader'); + if (!loader) return; + const pctEl = loader.querySelector('#txa-load-pct'); + const barFill = loader.querySelector('#txa-load-bar-fill'); + const spinner = loader.querySelector('.txa-spinner'); + const loadText = loader.querySelector('#txa-load-text'); + const speedEl = loader.querySelector('#txa-load-speed'); + + // Đổi giao diện loader → error state + if (spinner) { spinner.style.borderTopColor = '#ef4444'; spinner.style.animationPlayState = 'paused'; } + if (pctEl) { pctEl.textContent = '!'; pctEl.style.color = '#ef4444'; } + if (barFill) { barFill.style.background = '#ef4444'; barFill.style.width = '100%'; barFill.style.boxShadow = '0 0 10px #ef4444'; } + if (speedEl) speedEl.textContent = ''; + if (loadText) { + loadText.style.color = '#fca5a5'; + loadText.innerHTML = `${msg}`; + } + + // Thêm nút Retry nếu chưa có + if (canRetry && !loader.querySelector('#txa-retry-btn')) { + const retryBtn = document.createElement('button'); + retryBtn.id = 'txa-retry-btn'; + retryBtn.innerHTML = 'Thử lại'; + retryBtn.style.cssText = ` + margin-top:14px; padding:8px 22px; + background:#3b82f6; color:#fff; border:none; + border-radius:8px; cursor:pointer; font-size:13px; font-weight:600; + pointer-events:all; + `; + retryBtn.onmouseenter = () => retryBtn.style.background = '#2563eb'; + retryBtn.onmouseleave = () => retryBtn.style.background = '#3b82f6'; + retryBtn.onclick = () => window.location.reload(); + const content = loader.querySelector('.txa-loader-content'); + if (content) content.appendChild(retryBtn); + // Đảm bảo loader nhận pointer events để click được + loader.style.pointerEvents = 'all'; + } + }; + + try { + let resolveUrl = '/api/resolve-streamc?hash=' + encodeURIComponent(hash); + if (embedHost) resolveUrl += '&embed_host=' + encodeURIComponent(embedHost); + + // Timeout 20s — nếu server không trả lời thì abort + const controller = new AbortController(); + const resolveTimeout = setTimeout(() => controller.abort(), 20000); + + let res; + try { + res = await fetch(resolveUrl, { signal: controller.signal }); + } finally { + clearTimeout(resolveTimeout); + } + + // HTTP error (502, 403, 500...) + if (!res.ok) { + const errMsg = res.status === 502 + ? 'Nguồn phim đang bảo trì hoặc bị chặn. Hãy thử nguồn khác.' + : res.status === 403 + ? 'Truy cập bị từ chối. Hãy thử nguồn khác.' + : `Lỗi kết nối (HTTP ${res.status}). Thử lại sau.`; + + console.error(`[TXAPlayer] StreamC HTTP ${res.status} ❌`, { hash, embedHost }); + _showStreamCError(errMsg, true); + return; // Dừng setupMedia — không tiếp tục khởi tạo HLS với URL rỗng + } + + const data = await res.json(); + const checkBlob = this.options.anti403Mode === 'blob' || this.options.videoUrl.includes('anti403=1'); + + if (data.success) { + if (checkBlob && data.raw_url) { + this.options.videoUrl = data.raw_url; + } else if (data.video_url) { + this.options.videoUrl = data.video_url; + if (this.options.isAdmin) { + console.log('%c[TXAPlayer] StreamC Resolved ✅', 'color:#10b981;font-weight:bold;', { + hash, embedHost: data.embed_host, method: data.method, + proxyUrl: data.video_url.substring(0, 80) + '...' + }); + } + } + } else { + const reason = data.message || data.error || 'Không xác định'; + console.error('[TXAPlayer] StreamC Resolve Failed ❌', { hash, embedHost, error: reason }); + _showStreamCError('Không thể kết nối nguồn phim. ' + reason, true); + return; // Dừng — không khởi tạo HLS với URL không hợp lệ + } + + } catch (e) { + if (e.name === 'AbortError') { + console.error('[TXAPlayer] StreamC Resolve Timeout (20s) ❌', { hash, embedHost }); + _showStreamCError('Nguồn phim phản hồi quá chậm. Hãy thử lại.', true); + } else { + console.error('[TXAPlayer] StreamC Resolve Error ❌', e); + _showStreamCError('Lỗi mạng khi kết nối nguồn phim.', true); + } + return; // Dừng — không tiếp tục HLS setup + } + } + } + + // Auto-proxy logic for known SSL-untrusted domains + if (this.options.videoUrl && (this.options.videoUrl.includes('phimmoi.net') || this.options.videoUrl.includes('sing.phimmoi.net') || this.options.videoUrl.includes('streamvda.top'))) { + if (this.options.videoUrl.includes('?url=')) { + console.log( + '%c[TXAPlayer] 🛡️ SSL Guard Bypass: Already Proxied via Cloudflare/Vercel Proxy ✅', + 'color:#10b981; font-weight:bold;', + { videoUrl: this.options.videoUrl } + ); + } + if (!this.options.videoUrl.includes('/api/proxy-media') && !this.options.videoUrl.includes('/api/video/') && !this.options.videoUrl.includes('?url=')) { + try { + console.log('%c[TXAPlayer] 🛡️ SSL Guard Active: Resolving video URL...', 'color:#f59e0b; font-weight:bold;'); + const r = await fetch(`/api/video/resolve?url=${encodeURIComponent(btoa(this.options.videoUrl))}`); + const data = await r.json(); + if (data.success && data.url) { + this.options.videoUrl = data.url; + console.log('%c[TXAPlayer] 🛡️ SSL Guard Resolved URL ✅', 'color:#10b981; font-weight:bold;', { resolvedUrl: this.options.videoUrl }); + } + } catch (e) { console.error('[TXAPlayer] SSL Guard Fail', e); } + } + } + + const loader = this.container.querySelector('#txa-loader'); + const pctEl = this.container.querySelector('#txa-load-pct'); + const speedEl = this.container.querySelector('#txa-load-speed'); + const barFill = this.container.querySelector('#txa-load-bar-fill'); + const loadInfoEl = this.container.querySelector('#txa-load-info'); + let loadProgress = 0, loadInterval = null, lastBytes = 0, lastSpeedTime = performance.now(); + let speedHistory = [], isHLS = false; + + // Populate loading info tags + if (loadInfoEl) { + const tags = []; + if (this.options.title) tags.push({ icon: 'fa-film', label: this.options.title }); + if (this.options.episodeName) tags.push({ icon: 'fa-list', label: this.options.episodeName }); + if (this.options.serverName) tags.push({ icon: 'fa-server', label: this.options.serverName }); + const url = this.options.videoUrl || ''; + if (url.includes('.mpd')) tags.push({ icon: 'fa-video', label: 'DASH' }); + else if (url.includes('.m3u8')) tags.push({ icon: 'fa-video', label: 'HLS' }); + else if (url.includes('.mp4')) tags.push({ icon: 'fa-video', label: 'MP4' }); + else if (url.includes('/api/drive-stream/')) tags.push({ icon: 'fab fa-google-drive', label: 'Google Drive' }); + loadInfoEl.innerHTML = tags.map(t => ` ${t.label}`).join(''); + } + + const updateSpeed = (n) => { + const now = performance.now(), elapsed = (now - lastSpeedTime) / 1000; + if (elapsed > 0.2 && n > lastBytes) { + const bps = (n - lastBytes) / elapsed; + speedHistory.push(bps); + if (speedHistory.length > 5) speedHistory.shift(); + const currentSpeed = speedHistory.reduce((a, b) => a + b, 0) / speedHistory.length; + if (speedEl) speedEl.textContent = (window.txaformat && window.txaformat.fileSize) ? window.txaformat.fileSize(currentSpeed, 1) + '/s' : (currentSpeed / 1048576).toFixed(1) + ' MB/s'; + lastBytes = n; lastSpeedTime = now; + } + }; + + const updateLoadingPct = (targetPct, instant = false) => { + if (!pctEl) return; + const loadText = this.container.querySelector('#txa-load-text'); + if (instant) { + this._loadProgress = targetPct; + pctEl.textContent = Math.round(this._loadProgress) + '%'; + if (barFill) barFill.style.width = Math.round(this._loadProgress) + '%'; + return; + } + if (this._loadInterval) clearInterval(this._loadInterval); + this._loadInterval = setInterval(() => { + if (this._loadProgress < targetPct) { + const inc = targetPct >= 90 ? 0.5 : (targetPct >= 70 ? 1 : 2); + this._loadProgress = Math.min(targetPct, this._loadProgress + inc); + pctEl.textContent = Math.round(this._loadProgress) + '%'; + if (barFill) barFill.style.width = Math.round(this._loadProgress) + '%'; + if (loadText) { + if (this._loadProgress < 20) loadText.textContent = 'Đang khởi tạo trình phát...'; + else if (this._loadProgress < 40) loadText.textContent = 'Đang tải manifest...'; + else if (this._loadProgress < 70) loadText.textContent = 'Đang đệm dữ liệu...'; + else if (this._loadProgress < 95) loadText.textContent = 'Đang tối ưu hóa...'; + else loadText.textContent = 'Sẵn sàng!'; + } + } else { clearInterval(this._loadInterval); this._loadInterval = null; } + }, 50); + }; + + const completeLoading = () => { + if (this._loadInterval) clearInterval(this._loadInterval); + this._loadProgress = 100; + if (pctEl) pctEl.textContent = '100%'; + if (barFill) barFill.style.width = '100%'; + if (speedEl) speedEl.textContent = '✓ Ready'; + setTimeout(() => loader.classList.add('hidden'), 200); + }; + + const showLoaderWithProgress = (startPct = null) => { + // v6.6.1 - Reset loader styles to default (clearing error states) + if (loader) { + const _spin = loader.querySelector('.txa-spinner'); + const _pct = loader.querySelector('#txa-load-pct'); + const _bar = loader.querySelector('#txa-load-bar-fill'); + const _text = loader.querySelector('#txa-load-text'); + const _retry = loader.querySelector('#txa-retry-btn'); + + if (_spin) { _spin.style.borderTopColor = 'var(--txa-brand)'; _spin.style.animationPlayState = 'running'; } + if (_pct) { _pct.style.color = '#fff'; } + if (_bar) { + _bar.style.background = 'linear-gradient(90deg, var(--txa-brand), #f472b6)'; + _bar.style.boxShadow = '0 0 15px var(--txa-brand-glow)'; + } + if (_text) { _text.style.color = 'rgba(255,255,255,0.5)'; } + if (_retry) _retry.remove(); + loader.style.pointerEvents = 'none'; + } + + loader?.classList.remove('hidden'); + if (startPct !== null) updateLoadingPct(startPct, true); + }; + + // Expose to instance so setQuality can use it + this.updateLoadingPct = updateLoadingPct; + this.hideLoader = completeLoading; + this.showLoader = showLoaderWithProgress; + + if (this.options.videoUrl?.endsWith('.mpd')) { + this.dashPlayer = dashjs.MediaPlayer().create(); + this.dashPlayer.initialize(this.video, this.options.videoUrl, this.options.autoPlay); + updateLoadingPct(10); + this.dashPlayer.on('streamInitialized', () => { + updateLoadingPct(80); + this.container.querySelector('#txa-item-quality').style.display = 'flex'; + this.generateQualityList(); this.initSubtitles(); this.renderMarkers(); + }); + this.dashPlayer.on('canPlay', completeLoading); + this.dashPlayer.on('bufferStalled', () => showLoaderWithProgress(loadProgress > 50 ? loadProgress : 50)); + this.dashPlayer.on('bufferLoaded', completeLoading); + this.dashPlayer.on('fragmentLoadingCompleted', (e) => { if (e?.request?.bytesTotal) updateSpeed(lastBytes + e.request.bytesTotal); }); + } else if (this.options.videoUrl) { + // Updated isHLS detection to be more robust + isHLS = this.options.videoUrl.includes('.m3u8') || + this.options.videoUrl.includes('txaformat=.m3u8') || + this.options.videoUrl.includes('format=.m3u8') || + (this.options.videoUrl.includes('streamc') && this.options.videoUrl.includes('.m3u8')); + + if (isHLS && typeof Hls !== 'undefined' && Hls.isSupported()) { + const isStreamC = this.options.videoUrl.includes('streamc'); + const isBlobMode = this.options.anti403Mode === 'blob' || this.options.videoUrl.includes('anti403=1'); + + if (this.options.isAdmin) { + console.log('%c[TXAPlayer] HLS Detected', 'color: #3b82f6; font-weight: bold;', this.options.videoUrl); + console.log('%c[TXAPlayer] Anti-403 Mode Strategy:', 'color: #10b981;', this.options.anti403Mode); + } + + const initStandardHls = (useExtensionMode = false) => { + if (this.options.isAdmin) console.log('%c[TXAPlayer] Initializing Standard HLS (Proxy Mode)...', 'color: #3b82f6;'); + if (this.hls) this.hls.destroy(); + this.hls = new Hls({ + enableWorker: true, + lowLatencyMode: false, + backBufferLength: 120, + maxBufferLength: 180, + maxMaxBufferLength: 600, + maxBufferSize: 250 * 1000 * 1000, + fragLoadingRetryDelay: 500, + fragLoadingMaxRetry: 10, + manifestLoadingMaxRetry: 5, + manifestLoadingRetryDelay: 1000, + levelLoadingMaxRetry: 5, + fragLoadingTimeOut: 20000, + startLevel: -1, + abandonAudioCodec: true, + fastReadyState: true, + liveDurationInfinity: true, + capLevelToPlayerSize: true, + xhrSetup: (xhr, url) => { + if (useExtensionMode) { + xhr.setRequestHeader('X-EXTENSION-MODE', '1'); + } else { + xhr.setRequestHeader('X-TXA-PLAYER', 'Premium'); + } + } + }); + updateLoadingPct(10); + this.hls.attachMedia(this.video); + this.hls.on(Hls.Events.MEDIA_ATTACHED, () => this.hls.loadSource(this.options.videoUrl)); + this.hls.on(Hls.Events.MANIFEST_LOADING, () => updateLoadingPct(20)); + this.hls.on(Hls.Events.MANIFEST_LOADED, () => updateLoadingPct(40)); + this.hls.on(Hls.Events.LEVEL_LOADING, () => updateLoadingPct(55)); + this.hls.on(Hls.Events.LEVEL_LOADED, () => updateLoadingPct(70)); + this.hls.on(Hls.Events.FRAG_LOADING, () => { if (loadProgress < 80) updateLoadingPct(80); }); + this.hls.on(Hls.Events.FRAG_LOADED, (e, data) => { + updateLoadingPct(90); + if (data?.frag?.stats?.loaded) updateSpeed(lastBytes + data.frag.stats.loaded); + this._updateBufferBar(); + }); + this.hls.on(Hls.Events.MANIFEST_PARSED, () => { + this.renderMarkers(); this.generateQualityList(); + if (this.options.autoPlay) this.video.play().catch(() => { }); + }); + this.hls.on(Hls.Events.LEVEL_SWITCHED, () => { + this.updateQualityUI(this.hls.autoLevelEnabled ? -1 : this.hls.loadLevel); + if (this.hideLoader) this.hideLoader(); // Hide loader after quality switch + }); + this.hls.on(Hls.Events.ERROR, (e, data) => { + console.warn('[TXAPlayer] HLS Error', data.type, data.details, data.fatal); + if (data.fatal) { + if (data.type === Hls.ErrorTypes.NETWORK_ERROR) { + // Network error: thử recover, nếu vẫn fail thì hiện lỗi + this._hlsNetworkRetries = (this._hlsNetworkRetries || 0) + 1; + if (this._hlsNetworkRetries <= 3) { + console.warn(`[TXAPlayer] HLS Network Error - Retry ${this._hlsNetworkRetries}/3`); + setTimeout(() => this.hls?.startLoad(), 1500); + } else { + console.error('[TXAPlayer] HLS Fatal Network Error after retries'); + this._txaShowHlsError('Không tải được video. Kiểm tra kết nối mạng.', data); + } + } else if (data.type === Hls.ErrorTypes.MEDIA_ERROR) { + this._hlsMediaRetries = (this._hlsMediaRetries || 0) + 1; + if (this._hlsMediaRetries <= 2) { + this.hls.recoverMediaError(); + } else { + this._txaShowHlsError('Lỗi giải mã video. Thử tải lại trang.', data); + } + } else { + this._txaShowHlsError('Lỗi không xác định khi phát video.', data); + this.hls.destroy(); + } + } + }); + }; + this._initStandardHls = initStandardHls; + if (isBlobMode) { + if (this.options.isAdmin) console.log('%c[TXAPlayer] 🚀 EXTENSION MODE. Fetching and merging M3U8...', 'color: #10b981; font-weight: bold; font-size: 14px;'); + this.loadM3u8AsMP4(this.options.videoUrl, updateLoadingPct, completeLoading, showLoaderWithProgress); + return; + } + initStandardHls(false); + } else if (isHLS) { + this.showFeedback('high', '❌ Thiếu thư viện HLS.js - Không thể phát M3U8. Vui lòng kiểm tra import HLS.js hoặc dùng link MP4 trực tiếp.'); completeLoading(); + } else { // Regular MP4 or other direct video URL + updateLoadingPct(15); + this.video.src = this.options.videoUrl; + if (this.options.autoPlay) this.video.play().catch(() => { }); + } + this.initSubtitles(); + } + + // Loading state management + const hideLoader = () => completeLoading(); + const showLoader = () => showLoaderWithProgress(loadProgress > 30 ? loadProgress : 30); + + this.video.onloadstart = () => { + if (loadProgress < 20) updateLoadingPct(20); + }; + this.video.onloadeddata = () => { + updateLoadingPct(60); + }; + this.video.oncanplay = () => { + updateLoadingPct(85); + }; + this.video.oncanplaythrough = () => { + completeLoading(); + }; + this.video.onwaiting = showLoader; + this.video.onseeking = () => { + showLoaderWithProgress(50); + }; + this.video.onseeked = hideLoader; + this.video.onplaying = hideLoader; + this.video.onloadedmetadata = () => { + updateLoadingPct(45); + this.updateTopTitle(); + this.renderMarkers(); + this.checkWatchResume(); + this.initSubtitles(); // Ensure subs are synced after metadata + }; + + /** + * ACCURATE BUFFERED PERCENTAGE CALCULATION + */ + this.video.onprogress = () => { + if (!loader.classList.contains('hidden') && pctEl) { + const duration = this.video.duration; + if (!duration || !isFinite(duration)) return; + const buffered = this.video.buffered; + if (buffered.length === 0) return; + let totalBuffered = 0; + for (let i = 0; i < buffered.length; i++) { + totalBuffered += buffered.end(i) - buffered.start(i); + } + const bufferPct = (totalBuffered / duration) * 100; + const mappedPct = 60 + (bufferPct * 0.39); + if (mappedPct > loadProgress) { + updateLoadingPct(Math.min(99, mappedPct)); + } + } + }; + + // ===== CONTINUOUS BUFFER BAR UPDATE (YouTube-style) ===== + if (this._bufferInterval) clearInterval(this._bufferInterval); + const bufBar = this.container.querySelector('#txa-buffer'); + if (bufBar) { + bufBar.classList.add('loading'); + this._bufferInterval = setInterval(() => { + this._updateBufferBar(); + }, 1000); + + this.video.addEventListener('progress', () => { + const duration = this.video.duration; + if (!duration || !isFinite(duration)) return; + const buffered = this.video.buffered; + if (buffered.length > 0) { + const lastEnd = buffered.end(buffered.length - 1); + if (lastEnd >= duration - 1) { + bufBar.classList.remove('loading'); + } + } + }); + } + // ── Watchdog: nếu progress stuck ở ≤20% sau 18s thì hiển thị lỗi ── + // Bảo vệ người dùng khỏi loader treo vô hạn khi mạng chậm hoặc nguồn lỗi + if (this._stuckWatchdog) clearTimeout(this._stuckWatchdog); + this._stuckWatchdog = setTimeout(() => { + // Chỉ kích hoạt nếu loader vẫn còn hiện và progress ≤ 22% + const _loader = this.container?.querySelector('#txa-loader'); + if (!_loader || _loader.classList.contains('hidden')) return; + const _pct = this.container?.querySelector('#txa-load-pct'); + const currentPct = parseInt(_pct?.textContent || '0'); + if (currentPct <= 22 && !isNaN(currentPct)) { + console.warn('[TXAPlayer] Watchdog: loader stuck at', currentPct + '% after 18s'); + this._txaShowHlsError?.('Quá trình tải mất quá nhiều thời gian. Có thể nguồn phim đang bảo trì.', null); + } + }, 18000); + + // Clear watchdog khi video thực sự play được + this.video.addEventListener('playing', () => { + if (this._stuckWatchdog) { clearTimeout(this._stuckWatchdog); this._stuckWatchdog = null; } + }, { once: true }); + + // v6.5.0 - Auto-detect preview thumbnail sprite + if (!this._isPreviewDetecting) { + this._isPreviewDetecting = true; + this._detectPreviewSprite(); + } + } + + /** + * v6.5.2 - Auto-detect and preload preview sprite (preview.jpg) + * OR New Turbo Storyboard (L1_M0.jpg) + */ + _detectPreviewSprite() { + let previewUrl = this.options.previewUrl; + const videoUrl = this.options.videoUrl; + const thumbEl = this.container?.querySelector('#txa-preview-thumb'); + if (!thumbEl) return; + + // Reset state + this._useStoryboard = false; + this._currentStoryboardLevel = 'L1'; + + // Try auto-detection of base path + let basePath = ''; + let actualVideoUrl = videoUrl || ''; + + // v6.6.3 - Support proxied URLs by extracting the real target + if (actualVideoUrl.includes('/api/proxy-media?url=')) { + try { + const search = actualVideoUrl.split('?')[1]; + const params = new URLSearchParams(search); + actualVideoUrl = params.get('url') || actualVideoUrl; + } catch(e) {} + } + + if (actualVideoUrl) { + try { + const url = new URL(actualVideoUrl); + const m3u8Match = actualVideoUrl.match(/(https?:\/\/[^/]*(?:s3|tebi|storage|cdn)[^/]*\/[^?]*\/)/); + if (m3u8Match) { + basePath = m3u8Match[1]; + } else { + const pathParts = url.pathname.split('/'); + pathParts.pop(); + basePath = url.origin + pathParts.join('/') + '/'; + } + } catch (e) { + const lastSlash = actualVideoUrl.lastIndexOf('/'); + if (lastSlash > 0) basePath = actualVideoUrl.substring(0, lastSlash + 1); + } + } + + const handleFinalError = () => { + this._previewSpriteUrl = null; + this._previewSpriteLoaded = false; + thumbEl.classList.remove('loading', 'has-sprite'); + thumbEl.style.backgroundImage = 'none'; + }; + + // 🚀 STRATEGY 1: Check for Turbo Storyboard (VOD Pipeline v2) + if (basePath) { + const storyboardPath = basePath + 'storyboard/'; + const checkImg = new Image(); + checkImg.src = this.getProxiedUrl(storyboardPath + 'L1_M0.jpg'); + checkImg.onload = () => { + if (this.destroyed) return; + this._useStoryboard = true; + this._storyboardPath = storyboardPath; + this._previewSpriteLoaded = true; + thumbEl.classList.add('has-sprite'); + thumbEl.classList.remove('loading'); + console.log('%c[TXAPlayer] 🚀 Turbo Storyboard Engine Active (L1) ✅', 'color:#a855f7; font-weight:bold;'); + + // Level Upgrade Timer (Premium Strategy) + this._previewUpgradeTimer = setTimeout(() => { + if (this.destroyed) return; + if (window.innerWidth > 1200) this._currentStoryboardLevel = 'L3'; + else if (window.innerWidth > 768) this._currentStoryboardLevel = 'L2'; + console.log(`%c[TXAPlayer] 🖼️ Storyboard upgraded to ${this._currentStoryboardLevel} for crispness`, 'color:#a855f7;'); + }, 4000); + }; + checkImg.onerror = () => { + // FALLBACK to Strategy 2 (Legacy preview.jpg) + this._detectLegacyPreview(previewUrl, basePath, thumbEl, handleFinalError); + }; + + // 🚀 STRATEGY 3: Detect MP4 Multi-Quality (NEW v6.5.2) + if (videoUrl && videoUrl.toLowerCase().endsWith('.mp4')) { + const filename = videoUrl.split('/').pop(); + if (filename.match(/(\d+)p\.mp4/i)) { + this._detectMP4Qualities(basePath, filename); + } + } + return; + } + + this._detectLegacyPreview(previewUrl, basePath, thumbEl, handleFinalError); + } + + /** + * v6.5.2 - Predictive MP4 Multi-Quality Detection + * Probes tebi/s3 folder for 1080p.mp4, 720p.mp4, etc. + */ + async _detectMP4Qualities(basePath, currentFilename) { + const qualities = ['1080p', '720p', '480p', '360p', '144p']; + const results = []; + const currentLabel = currentFilename.replace('.mp4', '').toLowerCase(); + + for (const q of qualities) { + if (q === currentLabel) { + results.push({ height: parseInt(q), url: this.options.videoUrl, name: q.toUpperCase() }); + continue; + } + + const checkUrl = basePath + q + '.mp4'; + try { + // Fast check with HEAD request + const res = await fetch(checkUrl, { method: 'HEAD' }); + if (res.ok) { + results.push({ height: parseInt(q), url: checkUrl, name: q.toUpperCase() }); + } + } catch (e) { } + } + + if (results.length > 1) { + this._mp4Levels = results.sort((a, b) => b.height - a.height); + this.generateQualityList(); + console.log(`%c[TXAPlayer] 🎞️ Predictive MP4 Active: ${this._mp4Levels.length} qualities found`, 'color:#a855f7; font-weight:bold;'); + } + } + + /** + * v6.5.2 - Legacy Sprite Logic (Backward Compatibility) + */ + _detectLegacyPreview(previewUrl, basePath, thumbEl, handleFinalError) { + if (!previewUrl && basePath) { + previewUrl = this.getProxiedUrl(basePath + 'preview.jpg'); + } + if (!previewUrl) return; + + const loadPreview = (useCORS = true) => { + const img = new Image(); + if (useCORS) img.crossOrigin = 'anonymous'; + + img.onload = () => { + if (this.destroyed) return; + if (img.naturalWidth < 160 || img.naturalHeight < 90) { + handleFinalError(); + return; + } + + if (useCORS) { + if (this.options.previewLowUrl) { + this._previewLowUrl = this.options.previewLowUrl; + this._previewLowLoaded = true; + thumbEl.style.backgroundImage = `url('${this._previewLowUrl}')`; + thumbEl.classList.add('has-sprite'); + thumbEl.classList.remove('loading'); + + this._previewUpgradeTimer = setTimeout(() => { + if (this.destroyed) return; + this._previewSpriteUrl = previewUrl; + this._previewSpriteLoaded = true; + thumbEl.style.backgroundImage = `url('${previewUrl}')`; + thumbEl.style.backgroundSize = '1600px 900px'; + }, 500); + } else { + // Canvas downscale + try { + const canvas = document.createElement('canvas'); + const scale = 0.25; + canvas.width = Math.round(img.naturalWidth * scale); + canvas.height = Math.round(img.naturalHeight * scale); + const ctx = canvas.getContext('2d'); + ctx.imageSmoothingEnabled = true; + ctx.imageSmoothingQuality = 'low'; + ctx.drawImage(img, 0, 0, canvas.width, canvas.height); + this._previewLowUrl = canvas.toDataURL('image/jpeg', 0.5); + this._previewLowLoaded = true; + thumbEl.style.backgroundImage = `url('${this._previewLowUrl}')`; + thumbEl.style.backgroundSize = '400px 225px'; + thumbEl.classList.add('has-sprite'); + thumbEl.classList.remove('loading'); + } catch (e) { + useHQDirectly(); + return; + } + this._previewUpgradeTimer = setTimeout(() => { + if (this.destroyed) return; + this._previewSpriteUrl = previewUrl; + this._previewSpriteLoaded = true; + thumbEl.style.backgroundImage = `url('${previewUrl}')`; + thumbEl.style.backgroundSize = '1600px 900px'; + }, 600); + } + } else { + useHQDirectly(); + } + }; + + const useHQDirectly = () => { + this._previewSpriteUrl = previewUrl; + this._previewSpriteLoaded = true; + thumbEl.style.backgroundImage = `url('${previewUrl}')`; + thumbEl.style.backgroundSize = '1600px 900px'; + thumbEl.classList.add('has-sprite'); + thumbEl.classList.remove('loading'); + }; + + img.onerror = () => { + if (useCORS) loadPreview(false); + else handleFinalError(); + }; + img.src = previewUrl; + }; + + loadPreview(true); + } + + /** + * v6.5.2 - Update preview thumbnail position based on hover/scrub position + * Supports both Legacy Sprite and Neon Core Storyboard (L1/L2/L3) + */ + _updatePreviewThumb(pos) { + const thumbEl = this.container?.querySelector('#txa-preview-thumb'); + if (!thumbEl || !this._previewSpriteLoaded) return; + + const duration = this.video?.duration; + if (!duration || !isFinite(duration)) return; + + const targetTime = pos * duration; + let thumbW = 160, thumbH = 90; + + if (this._useStoryboard) { + const config = STORYBOARD_LEVELS[this._currentStoryboardLevel]; + const framesPerChunk = config.grid[0] * config.grid[1]; + const frameIndex = Math.floor(targetTime / config.interval); + const chunkIndex = Math.floor(frameIndex / framesPerChunk); + const frameInChunk = frameIndex % framesPerChunk; + + const rawChunkUrl = `${this._storyboardPath}${config.prefix}${chunkIndex}.jpg`; + const chunkUrl = this.getProxiedUrl(rawChunkUrl); + const col = frameInChunk % config.grid[0]; + const row = Math.floor(frameInChunk / config.grid[0]); + + thumbW = config.size[0]; + thumbH = config.size[1]; + + thumbEl.style.backgroundImage = `url('${chunkUrl}')`; + thumbEl.style.backgroundSize = `${config.grid[0] * thumbW}px ${config.grid[1] * thumbH}px`; + thumbEl.style.backgroundPosition = `${-(col * thumbW)}px ${-(row * thumbH)}px`; + thumbEl.style.width = thumbW + 'px'; + thumbEl.style.height = thumbH + 'px'; + } else { + // Legacy Logic + const frameIndex = Math.min(99, Math.floor(targetTime / 10)); + const col = frameIndex % 10; + const row = Math.floor(frameIndex / 10); + thumbEl.style.backgroundPosition = `${-(col * 160)}px ${-(row * 90)}px`; + thumbEl.style.width = '160px'; + thumbEl.style.height = '90px'; + } + + // Clamp to container bounds + const pWrap = this.container?.querySelector('#txa-progress'); + if (pWrap) { + const wrapW = pWrap.offsetWidth; + const half = thumbW / 2; + const leftPx = pos * wrapW; + + if (leftPx < half) { + thumbEl.style.left = half + 'px'; + thumbEl.style.transform = 'translateX(-50%)'; + } else if (leftPx > wrapW - half) { + thumbEl.style.left = (wrapW - half) + 'px'; + thumbEl.style.transform = 'translateX(-50%)'; + } else { + thumbEl.style.left = (pos * 100) + '%'; + thumbEl.style.transform = 'translateX(-50%)'; + } + } + } + + generateQualityList() { + const list = this.container.querySelector('#txa-list-quality'); + if (!list) return; + list.innerHTML = ''; + + let levels = []; + let currentLevel = -1; + + if (this.hls) { + levels = this.hls.levels; + currentLevel = this.hls.currentLevel; + } else if (this.dashPlayer) { + levels = this.dashPlayer.getBitrateInfoListFor('video'); + currentLevel = this.dashPlayer.getQualityFor('video'); + } else if (this._mp4Levels.length > 0) { + levels = this._mp4Levels.map((l, i) => ({ ...l, originalIndex: i })); + // Find current active level by URL + currentLevel = this._mp4Levels.findIndex(l => l.url === (this._lastMP4Url || this.options.videoUrl)); + if (currentLevel !== -1) currentLevel = levels[currentLevel].originalIndex; // Map to originalIndex + } + + // Parse whitelist / manual quality list + const maxQRaw = this.options.maxQuality || 'auto'; + const qList = maxQRaw.split(',').map(s => s.trim().toLowerCase()); + const isAutoAllowed = qList.includes('auto'); + + // Allow single manual quality (e.g. "1080p") to show menu if provided + const hasManualQualities = qList.length > 0 && !(qList.length === 1 && qList[0] === 'auto'); + const hasMultipleLevels = levels && levels.length > 1; + + if (!hasMultipleLevels && !hasManualQualities) { + this.container.querySelector('#txa-item-quality').style.display = 'none'; + return; + } + + this.container.querySelector('#txa-item-quality').style.display = 'flex'; + + // Filter levels for UI + const isWhitelisted = (lvl) => { + if (qList.length === 0 || (qList.length === 1 && qList[0] === 'auto')) return true; + const h = lvl.height || 0; + const label = h + 'p'; + return qList.some(q => { + if (q === label) return true; // Exact match: "360p" === "360p" + if (q === '4k' && h >= 2160) return true; + if (q === '2k' && h >= 1440) return true; + if (q === 'fullhd' && h >= 1080) return true; + if (q === 'fhd' && h >= 1080) return true; + if (q === 'hd' && h >= 720 && h < 1080) return true; // HD = 720p only + if (['cam', 'sd'].includes(q)) return true; + return false; + }); + }; + + const availableLevels = levels.map((l, i) => ({ ...l, originalIndex: i })); + const filteredLevels = availableLevels.filter(isWhitelisted); + + let uiLevels = filteredLevels.length > 0 ? filteredLevels : availableLevels; + + // Dummy Logic if no levels found but Manual Quality is Enforced (e.g. Single MP4 with label) + if (uiLevels.length === 0 && hasManualQualities && (!levels || levels.length === 0)) { + uiLevels = qList.filter(q => q !== 'auto').map((q, i) => ({ + height: parseInt(q.replace(/\D/g, '')) || 0, + name: q.toUpperCase(), + originalIndex: -100 - i // Dummy Index + })); + // Force first one active if no HLS + if (currentLevel === -1 && uiLevels.length > 0) currentLevel = uiLevels[0].originalIndex; + } + + // Special check: if we are using MP4 Predictive levels, levels are ALREADY uiLevels + if (this._mp4Levels.length > 0 && uiLevels.length === 0) { + uiLevels = levels; + } + + // Auto Option (Only if we have real HLS/DASH switching capability) + if (isAutoAllowed && (hasMultipleLevels || levels.length > 0)) { + const autoItem = document.createElement('div'); + autoItem.className = 'txa-menu-item' + (currentLevel === -1 ? ' active' : ''); + autoItem.dataset.quality = -1; + + let autoLabel = 'Auto'; + if (uiLevels.length < levels.length && levels.length > 0) { + const sorted = [...uiLevels].sort((a, b) => a.height - b.height); + const minH = sorted[0]?.height || '?'; + const maxH = sorted[sorted.length - 1]?.height || '?'; + autoLabel = `Auto (${minH}p — ${maxH}p)`; + } + + autoItem.innerHTML = `${autoLabel}`; + + if (this.options.isGuest) { + autoItem.classList.add('disabled'); + autoItem.onclick = (e) => { e.stopPropagation(); this.showToast('Vui lòng đăng nhập để chỉnh chất lượng', 'warning'); }; + } else { + autoItem.onclick = (e) => { + e.stopPropagation(); + this.setQuality(-1); + this.updateQualityUI(-1); + }; + } + list.appendChild(autoItem); + } + + // Sort levels high to low for UI + const sortedUiLevels = [...uiLevels].sort((a, b) => b.height - a.height); + + sortedUiLevels.forEach((level) => { + const item = document.createElement('div'); + item.className = 'txa-menu-item' + (currentLevel === level.originalIndex ? ' active' : ''); + item.dataset.quality = level.originalIndex; // Ensure dataset is set + + if (this.options.isGuest) item.classList.add('disabled'); + + let label = ''; + + // Priority 1: Resolution based + if (level.height && level.height > 0) { + label = level.height + 'p'; + if (level.height >= 2160) label = '2160p 4K'; + else if (level.height >= 1440) label = '1440p 2K'; + else if (level.height >= 1080) label = '1080p FHD'; + else if (level.height >= 720) label = '720p HD'; + } + + // Priority 2: Level Name from Manifest + if ((!label || label === '0p') && level.name) { + label = level.name; + } + + // Priority 3: Inference from Config (Single Custom Label) + if (!label || label === '0p') { + const specialLabels = qList.filter(q => + q !== 'auto' && !q.endsWith('p') && !['4k', '2k', 'fullhd', 'hd'].includes(q.toLowerCase()) + ); + + if (specialLabels.length === 1) { + label = specialLabels[0]; // Keep original case + } else if (specialLabels.length > 1) { + label = level.bitrate ? `SD (${(level.bitrate / 1000).toFixed(0)}k)` : `Quality ${level.originalIndex}`; + } else { + label = level.bitrate ? `SD (${(level.bitrate / 1000).toFixed(0)}k)` : 'Original'; + } + } + + const bitrate = level.bitrate ? ` ${(level.bitrate / 1000000).toFixed(1)} Mbps` : ''; + const isPremiumQuality = level.height >= 1080; + if (this.options.isGuest && isPremiumQuality) { + item.innerHTML = `${label}PRO`; + item.style.opacity = '0.7'; + item.onclick = (e) => { + e.stopPropagation(); + this.showToast('Vui lòng đăng nhập để xem chất lượng ' + label, 'warning'); + }; + } else { + item.innerHTML = `${label}${bitrate}`; + item.onclick = (e) => { + e.stopPropagation(); + this.setQuality(level.originalIndex); + this.updateQualityUI(level.originalIndex); + + // For dummy levels (MP4), give immediate feedback as setQuality HLS logic won't run + if (level.originalIndex <= -100) { + this.showFeedback('text', `Quality: ${label}`); + } + }; + } + list.appendChild(item); + }); + + // Ensure "Auto" is the default selection if currentLevel is -1 + this.updateQualityUI(currentLevel); + + // Apply Default Quality Logic (Moved inside function) + let targetLevel = null; + const savedQ = localStorage.getItem('txa-quality'); + + // Check against `uiLevels` (variable from above scope) + if (savedQ !== null && !this.options.isGuest) { + const parsed = parseInt(savedQ); + const isStillAllowed = parsed === -1 || uiLevels.some(l => l.originalIndex === parsed); + if (isStillAllowed) { + targetLevel = parsed; + } else { + targetLevel = -1; + localStorage.removeItem('txa-quality'); + } + } else if (this.options.maxQuality && !this.options.isGuest) { + targetLevel = -1; + } + + if (targetLevel !== null && targetLevel !== undefined) { + this.setQuality(targetLevel); + this.updateQualityUI(targetLevel); + } + + if (uiLevels.length < levels.length) { + this.enforceQualityRestriction(availableLevels, uiLevels); + } + } + + /** + * HARD QUALITY ENFORCEMENT + * Physically removes disallowed levels from HLS.js manifest + * and sets autoLevelCapping + LEVEL_SWITCHING interceptor as fallback. + * This ensures ABR can NEVER select a quality outside admin's config. + */ + enforceQualityRestriction(allLevels, allowedLevels) { + const allowedIndices = new Set(allowedLevels.map(l => l.originalIndex)); + + if (this.hls) { + // Strategy 1: Remove levels from HLS.js (v1.4+) + // We must remove from highest index to lowest to avoid index shifting + const toRemove = allLevels + .filter(l => !allowedIndices.has(l.originalIndex)) + .sort((a, b) => b.originalIndex - a.originalIndex); + + if (typeof this.hls.removeLevel === 'function') { + // Build index mapping: old index → new index after removals + this._qualityIndexMap = {}; + let newIdx = 0; + + for (const lvl of allLevels.sort((a, b) => a.originalIndex - b.originalIndex)) { + if (allowedIndices.has(lvl.originalIndex)) { + this._qualityIndexMap[lvl.originalIndex] = newIdx; + newIdx++; + } + } + + // Actually remove the levels (reverse order to keep indices stable) + toRemove.forEach(lvl => { + try { + this.hls.removeLevel(lvl.originalIndex); + } catch (e) { + // Silently fail if removeLevel not available on this version + } + }); + + // After removal: cap auto to available levels + const newMaxIdx = this.hls.levels.length - 1; + if (newMaxIdx >= 0) { + this.hls.autoLevelCapping = newMaxIdx; + } + + // Remap onclick handlers for quality items + const qualityItems = this.container.querySelectorAll('#txa-list-quality .txa-menu-item[data-quality]'); + // Items' data-quality may refer to old indices which no longer exist + } else { + // Strategy 2: Fallback for older HLS.js without removeLevel + // Use autoLevelCapping for max, and LEVEL_SWITCHING to block disallowed + const maxAllowed = Math.max(...allowedIndices); + this.hls.autoLevelCapping = maxAllowed; + + // Intercept level switching to block non-allowed levels + this.hls.on(Hls.Events.LEVEL_SWITCHING, (event, data) => { + if (!allowedIndices.has(data.level)) { + // Force back to nearest allowed level + const nearest = [...allowedIndices].sort((a, b) => + Math.abs(a - data.level) - Math.abs(b - data.level) + )[0]; + if (nearest !== undefined) { + this.hls.currentLevel = nearest; + } + } + }); + } + } else if (this.dashPlayer) { + // DashJS: Use maxBitrate and minBitrate constraints + const allowedBitrates = allowedLevels.map(l => l.bitrate).filter(Boolean); + if (allowedBitrates.length > 0) { + const maxBr = Math.max(...allowedBitrates); + const minBr = Math.min(...allowedBitrates); + this.dashPlayer.updateSettings({ + 'streaming': { + 'abr': { + 'maxBitrate': { 'video': maxBr }, + 'minBitrate': { 'video': minBr } + } + } + }); + } + } + } + + setQuality(levelIndex) { + if (this.options.isGuest) return; + + // Show immediate loading indicator when switching quality + if (this.showLoader) { + this.showLoader(50); + const loadText = this.container.querySelector('#txa-load-text'); + if (loadText) loadText.textContent = 'Đang chuyển đổi chất lượng...'; + } + + if (this.hls) { + // Check if we need to force a redraw or buffer clear + const wasPlaying = !this.video.paused; + this.hls.currentLevel = levelIndex; + + // Fix for "stuck/frozen" frames on some browsers: + // Briefly pause and play to force-refresh the decoder if it was playing + if (wasPlaying) { + setTimeout(() => { + if (this.video.paused) this.video.play().catch(() => { }); + }, 100); + } + } else if (this.dashPlayer) { + const wasPlaying = !this.video.paused; + if (levelIndex === -1) { + this.dashPlayer.updateSettings({ 'streaming': { 'abr': { 'autoSwitchBitrate': { 'video': true } } } }); + } else { + this.dashPlayer.updateSettings({ 'streaming': { 'abr': { 'autoSwitchBitrate': { 'video': false } } } }); + this.dashPlayer.setQualityFor('video', levelIndex); + } + if (wasPlaying) { + setTimeout(() => { + if (this.video.paused) this.video.play().catch(() => { }); + }, 100); + } + + // For DASH, hide loader after a short delay or logic (simplification) + setTimeout(() => this.hideLoader && this.hideLoader(), 1500); + } else if (this._mp4Levels.length > 0 && levelIndex >= 0) { + // v6.5.2 Switching between Direct MP4 files + // Handle originalIndex mapping back to our _mp4Levels + const newLevel = this._mp4Levels.find(l => l.originalIndex === levelIndex) || this._mp4Levels[levelIndex]; + + if (newLevel && newLevel.url !== (this._lastMP4Url || this.options.videoUrl)) { + const currentTime = this.video.currentTime; + const wasPlaying = !this.video.paused; + + if (this.showLoader) this.showLoader(50); + + this._lastMP4Url = newLevel.url; + this.video.src = newLevel.url; + + this.video.onloadedmetadata = () => { + this.video.currentTime = currentTime; + if (wasPlaying) this.video.play().catch(() => { }); + this.hideLoader && this.hideLoader(); + this.generateQualityList(); // Update UI active state + this.video.onloadedmetadata = null; + }; + } + } + + // Save preference + localStorage.setItem('txa-quality', levelIndex); + + // Close settings menu + this.navSettings('main'); + } + + updateQualityUI(levelIndex) { + const items = this.container.querySelectorAll('#txa-list-quality .txa-menu-item'); + let activeLabel = 'Auto'; + let shortLabel = 'Auto'; + let realResolution = ''; // New: Track actual playing resolution + + // 1. Detect Real Resolution used by Auto (-1) + if (levelIndex === -1 && this.hls) { + // HLS: Use currentLevel (playing) or loadLevel (loading) + const lvlIdx = this.hls.currentLevel !== -1 ? this.hls.currentLevel : this.hls.loadLevel; + if (lvlIdx !== -1 && this.hls.levels && this.hls.levels[lvlIdx]) { + const lvl = this.hls.levels[lvlIdx]; + if (lvl && lvl.height) realResolution = lvl.height; + } + } else if (levelIndex === -1 && this.dashPlayer) { + // DASH: Logic if needed + } + + items.forEach(item => { + item.classList.remove('active'); + const icon = item.querySelector('.fa-check'); + if (icon) icon.remove(); + + if (parseInt(item.dataset.quality) === levelIndex) { + item.classList.add('active'); + + const check = document.createElement('i'); + check.className = 'fas fa-check'; + check.style.marginLeft = 'auto'; + check.style.color = 'var(--txa-brand)'; + check.style.fontSize = '12px'; + item.appendChild(check); + + const textSpan = item.querySelector('span'); + if (textSpan) { + activeLabel = textSpan.textContent; + + // Generate Short Label for Badge + if (levelIndex === -1) { + shortLabel = 'Auto'; + // Keep pure Auto for badge text to avoid clutter, + // but we will use realResolution for color coding below + } else { + shortLabel = activeLabel + .replace(' UHD', '') + .replace(' QHD', '') + .replace(' FHD', '') + .replace(' HD', '') + .replace('p', ''); + } + } + } + }); + + // Update Parent Menu Text + const lbl = this.container.querySelector('#txa-lbl-quality'); + if (lbl) { + // If Auto, append real resolution dynamically + if (levelIndex === -1 && realResolution) { + lbl.textContent = `Auto (${realResolution}p)`; + } else { + lbl.textContent = activeLabel; + } + } + + // Update Settings Button Badge + const badge = this.container.querySelector('#txa-quality-badge'); + if (badge) { + // If Auto, show actual res if we have it? Or just 'Auto'? + // "SHOW CURENT QUALITY ON BAGE ICON SETTINGS" -> User wants to see resolution + if (levelIndex === -1 && realResolution) { + badge.textContent = `${realResolution}p`; // e.g. "720p" + } else { + badge.textContent = shortLabel; // "1080", "AUTO" + } + + // Color Coding + badge.style.background = 'rgba(255,255,255,0.2)'; + badge.style.color = '#fff'; + badge.style.fontWeight = 'normal'; + badge.style.boxShadow = 'none'; + + // Determine effective resolution for styling + let effectiveRes = realResolution ? parseInt(realResolution) : 0; + if (levelIndex !== -1) effectiveRes = parseInt(shortLabel) || 0; + if (shortLabel.includes('4K')) effectiveRes = 2160; + + if (effectiveRes >= 2160) { // 4K + badge.style.background = '#f43f5e'; // Rose + badge.style.boxShadow = '0 0 10px rgba(244, 63, 94, 0.4)'; + badge.style.fontWeight = 'bold'; + } else if (effectiveRes >= 1080) { // FHD + badge.style.background = '#eab308'; // Yellow + badge.style.color = '#000'; + badge.style.fontWeight = '800'; + } else if (effectiveRes >= 720) { // HD + badge.style.background = '#3b82f6'; // Blue + } else if (activeLabel === 'Auto' || levelIndex === -1) { + // Low res auto or unknown + badge.style.background = 'var(--txa-brand)'; + } + } + + // Toast Notification + if (this._lastQualityIndex !== levelIndex) { + if (this._lastQualityIndex !== undefined) { + let msg = `Đã chuyển sang: ${activeLabel}`; + if (levelIndex === -1 && realResolution) msg = `Tự động (${realResolution}p)`; + this.showToast(msg, 'info'); + } + this._lastQualityIndex = levelIndex; + } + } + + renderMarkers() { + if (!this.options.isLoggedIn) return; + const container = this.container.querySelector('#txa-markers'); + if (!container) return; + + // Always reset markers first, even if duration is not ready + container.innerHTML = ''; + + if (!this.video || !this.video.duration || !this.options.markers) return; + + const dur = this.video.duration; + const { intro, outro } = this.options.markers; + + if (intro && intro[1] > intro[0]) { + const zone = document.createElement('div'); + zone.className = 'txa-marker-zone intro'; + zone.style.left = (intro[0] / dur * 100) + '%'; + zone.style.width = ((intro[1] - intro[0]) / dur * 100) + '%'; + container.appendChild(zone); + + const dotStart = document.createElement('div'); + dotStart.className = 'txa-marker-dot intro-start'; + dotStart.style.left = (intro[0] / dur * 100) + '%'; + container.appendChild(dotStart); + + const dotEnd = document.createElement('div'); + dotEnd.className = 'txa-marker-dot intro-end'; + dotEnd.style.left = (intro[1] / dur * 100) + '%'; + container.appendChild(dotEnd); + } + + if (outro && (outro[1] > outro[0] || (outro[0] > 0 && (outro[1] === 0 || !outro[1])))) { + const effectiveOutroOut = (outro[1] > 0) ? outro[1] : dur; + const zone = document.createElement('div'); + zone.className = 'txa-marker-zone outro'; + zone.style.left = (outro[0] / dur * 100) + '%'; + zone.style.width = ((effectiveOutroOut - outro[0]) / dur * 100) + '%'; + container.appendChild(zone); + + const dotStart = document.createElement('div'); + dotStart.className = 'txa-marker-dot outro-start'; + dotStart.style.left = (outro[0] / dur * 100) + '%'; + container.appendChild(dotStart); + + const dotEnd = document.createElement('div'); + dotEnd.className = 'txa-marker-dot outro-end'; + dotEnd.style.left = (effectiveOutroOut / dur * 100) + '%'; + container.appendChild(dotEnd); + } + } + + initSubtitles() { + const subs = this.options.subtitles || []; + const hasSubs = subs.length > 0; + + // 1. Update Internal Toolbar Track support if needed + // (Clearing old tracks first) + // Remove existing track elements from video to prevent duplicates + Array.from(this.video.children).filter(child => child.tagName === 'TRACK').forEach(track => track.remove()); + + subs.forEach((sub, index) => { + const track = document.createElement('track'); + track.kind = 'subtitles'; + track.label = sub.label || sub.lang; + track.srclang = sub.lang; + // Handle both URL (src/file) and inline content + if (sub.src || sub.file) { + track.src = sub.src || sub.file; + } else if (sub.content) { + // Create blob URL for inline VTT content + const blob = new Blob([sub.content], { type: 'text/vtt' }); + track.src = URL.createObjectURL(blob); + } + this.video.appendChild(track); + }); + + // 2. Update Settings Menu UI + const list = this.container.querySelector('#txa-list-subs'); + const itemSubs = this.container.querySelector('#txa-item-subs'); + const btnSubs = this.container.querySelector('#txa-cc'); + + if (itemSubs) itemSubs.style.display = hasSubs ? 'flex' : 'none'; + if (btnSubs) { + btnSubs.style.display = hasSubs ? '' : 'none'; + const icon = btnSubs.querySelector('i'); + if (icon) { + icon.style.opacity = hasSubs ? '1' : '0.4'; + icon.style.filter = hasSubs ? 'none' : 'grayscale(1)'; + } + const tip = btnSubs.querySelector('.txa-tooltip'); + if (tip) tip.textContent = hasSubs ? 'Subtitles (c)' : 'No Subtitles'; + } + + if (list) { + list.innerHTML = `
Off
`; + subs.forEach((sub, index) => { + const item = document.createElement('div'); + item.className = 'txa-menu-item'; + item.dataset.sub = index; + item.innerHTML = `${sub.label || sub.lang}${sub.lang || ''}`; + item.onclick = (e) => { + e.stopPropagation(); + this.toggleSub(index); + }; + list.appendChild(item); + }); + + // Auto-load first subtitle if enabled or newly switched + // If activeSubIdx is -1 (Off) and there are subs, default to first + // If activeSubIdx is set, try to re-activate it + if (hasSubs) { + if (this.activeSubIdx === undefined || this.activeSubIdx === -1) { + this.toggleSub(0); + list.querySelector('[data-sub="0"]')?.classList.add('active'); + } else { + this.toggleSub(this.activeSubIdx); + list.querySelector(`[data-sub="${this.activeSubIdx}"]`)?.classList.add('active'); + } + } else { + this.toggleSub(-1); // Ensure subtitles are off if none are available + list.querySelector('[data-sub="-1"]')?.classList.add('active'); + } + } + } + + + bindEvents() { + const el = (s) => this.container.querySelector(s); + + // Play/Pause + const toggle = () => this.togglePlay(); + const playBtnMain = el('#txa-play'); + if (playBtnMain) playBtnMain.onclick = toggle; + + // Prev/Next Navigation + const prevBtn = el('#txa-prev'); + const nextBtn = el('#txa-next'); + if (prevBtn) prevBtn.onclick = (e) => { + if (e) e.preventDefault(); + if (this.options.prevEpisodeUrl && typeof window.switchEpisodeSeamless === 'function') { + window.switchEpisodeSeamless(this.options.prevEpisodeUrl); + } else if (this.options.prevEpisodeUrl) { + window.location.href = this.options.prevEpisodeUrl; + } + }; + if (nextBtn) nextBtn.onclick = (e) => { + if (e) e.preventDefault(); + if (this.options.nextEpisodeUrl && typeof window.switchEpisodeSeamless === 'function') { + window.switchEpisodeSeamless(this.options.nextEpisodeUrl); + } else if (this.options.nextEpisodeUrl) { + window.location.href = this.options.nextEpisodeUrl; + } + }; + if (this.video) this.video.onclick = toggle; + + const centerPlay = el('#txa-center-play'); + if (centerPlay) centerPlay.onclick = toggle; + + const zoneL = el('#txa-zone-l'); + if (zoneL) zoneL.onclick = (e) => { + if (e.detail === 1) { + this._clickTimer = setTimeout(() => toggle(), 250); + } else if (e.detail > 1) { + clearTimeout(this._clickTimer); + } + }; + + const zoneR = el('#txa-zone-r'); + if (zoneR) zoneR.onclick = (e) => { + if (e.detail === 1) { + this._clickTimer = setTimeout(() => toggle(), 250); + } else if (e.detail > 1) { + clearTimeout(this._clickTimer); + } + }; + + const replayBtnMain = el('#txa-replay-btn'); + if (replayBtnMain) replayBtnMain.onclick = () => { + if (this.video) { + this.video.currentTime = 0; + this.video.play(); + } + const replayDiv = el('#txa-replay'); + if (replayDiv) replayDiv.classList.remove('show'); + }; + + this.video.addEventListener('play', () => { + if (this.destroyed) return; + const playBtn = el('#txa-play'); + if (playBtn) playBtn.innerHTML = '
Pause (k)
'; + this.animateCenter('play'); + const replayBtn = el('#txa-replay'); + if (replayBtn) replayBtn.classList.remove('show'); + if (this.wrapper) this.wrapper.classList.add('video-playing'); + const cp = el('#txa-center-play'); + if (cp) cp.classList.remove('show'); + this.showUI(); // Auto hide after playing starts + }); + + this.video.addEventListener('pause', () => { + if (this.destroyed) return; + const playBtn = el('#txa-play'); + if (playBtn) playBtn.innerHTML = '
Play (k)
'; + this.animateCenter('pause'); + this.showUI(false); // Maintain UI while paused + if (this.wrapper) this.wrapper.classList.remove('video-playing'); + const cp = el('#txa-center-play'); + if (cp) cp.classList.add('show'); + }); + + // Video Error Handler + this.video.addEventListener('error', () => { + if (this.destroyed) return; + + const error = this.video.error; + if (!error) return; + + // Report native video error to database + this.reportErrorToServer('nativeVideoError', error.message || 'Lỗi phát video HTML5', { code: error.code }); + + let errorMsg = 'Lỗi không xác định'; + let shouldRetry = false; + + switch (error.code) { + case MediaError.MEDIA_ERR_ABORTED: + errorMsg = 'Phát video bị hủy'; + break; + case MediaError.MEDIA_ERR_NETWORK: + errorMsg = 'Lỗi mạng khi load video'; + shouldRetry = true; + break; + case MediaError.MEDIA_ERR_DECODE: + errorMsg = 'Lỗi giải mã video'; + break; + case MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED: + errorMsg = 'Nguồn video không hỗ trợ'; + break; + } + + console.error('[TXAPlayer] Video error:', error.code, errorMsg); + + // Hide loader + const loader = el('#txa-loader'); + if (loader) loader.classList.add('hidden'); + + // Show error toast + this.showToast(`❌ ${errorMsg}`); + + // Auto retry for network errors + if (shouldRetry && !this._isRetryingVideo) { + this._isRetryingVideo = true; + setTimeout(() => { + if (!this.destroyed && this.options.videoUrl) { + console.log('[TXAPlayer] Retrying video load...'); + this.showToast('🔄 Đang thử load lại video...'); + + // Reload video source + this.video.src = this.options.videoUrl; + this.video.load(); + + // Show loader again + if (loader) loader.classList.remove('hidden'); + + setTimeout(() => { + this._isRetryingVideo = false; + }, 2000); + } + }, 1500); + } + }); + + this.video.addEventListener('ended', () => { + if (this.destroyed) return; + if (this.wrapper) this.wrapper.classList.remove('video-playing'); + if (!this.video.loop) { + // Check if auto-next is enabled and we have next episode + if (this.settings.autoNextEpisode && this.options.nextEpisodeUrl && !this._isAutoNextTriggered) { + // Show countdown overlay + this._showAutoNextCountdown(); + } else { + // Show replay button only if auto-next is not active + const replayBtn = el('#txa-replay'); + if (replayBtn) replayBtn.classList.add('show'); + if (this.wrapper) this.wrapper.classList.add('active-ui'); + } + } + }); + + this.video.ondurationchange = () => { + if (this.destroyed) return; + this.renderMarkers(); + }; + + const pWrap = el('#txa-progress'); + let pendingSeekPct = -1; + + + + const updateScrubbingUI = (pos, isDragOrClick = false) => { + const duration = this.video?.duration || 0; + const targetTime = pos * duration; + + // Only update the actual progress bar and main time if we are DRAGGING or explicitly CLICKING + if (isDragOrClick || this.isDragging) { + const playedEl = el('#txa-played'); + if (playedEl) playedEl.style.width = (pos * 100) + '%'; + + const timeEl = el('#txa-time'); + if (timeEl) timeEl.textContent = this.formatTimeDisplay(targetTime); + + pendingSeekPct = pos; + } + + // Tooltip and Preview ALWAYS follow on hover + const tip = el('#txa-hover-time'); + if (tip) { + const needHours = duration >= 3600; + tip.textContent = this.formatTime(targetTime, needHours); + tip.style.left = (pos * 100) + '%'; + } + + this._updatePreviewThumb(pos); + }; + + const updateHoverTooltip = (e, isDragOrClick = false) => { + if (!pWrap) return; + const rect = pWrap.getBoundingClientRect(); + const pos = Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width)); + updateScrubbingUI(pos, isDragOrClick); + return pos; + }; + + pWrap.onmousemove = (e) => { + updateHoverTooltip(e, false); // Just hover tooltip + }; + pWrap.onmousedown = (e) => { + if (e.button !== 0) return; // Left click only + this.isDragging = true; + pWrap.classList.add('dragging'); + updateHoverTooltip(e, true); + }; + + // Desktop Long Press (2x Speed) + let deskPressTimer = null; + let isDeskLongPress = false; + + this.video.onmousedown = (e) => { + if (this.detectMobile()) return; + if (e.button !== 0) return; // Left click only + + deskPressTimer = setTimeout(() => { + if (!this.video.paused) { + isDeskLongPress = true; + if (!this.originalSpeed) this.originalSpeed = this.video.playbackRate; + this.video.playbackRate = 2.0; + + let speedOverlay = this.container.querySelector('.txa-speed-overlay'); + if (!speedOverlay) { + speedOverlay = document.createElement('div'); + speedOverlay.className = 'txa-speed-overlay'; + speedOverlay.innerHTML = ' 2x Tốc độ'; + this.container.appendChild(speedOverlay); + } + this.wrapper.classList.add('hide-controls'); + setTimeout(() => speedOverlay.classList.add('show'), 10); + } + }, 500); + }; + pWrap.onclick = (e) => { + if (!this.isDragging) { + const rect = pWrap.getBoundingClientRect(); + const pos = Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width)); + this.safeSeek(pos * this.video.duration); + } + }; + + // Improved Mobile Touch Interaction + const handleTouchProgress = (e) => { + if (e.touches && e.touches[0]) { + const rect = pWrap.getBoundingClientRect(); + const pos = Math.max(0, Math.min(1, (e.touches[0].clientX - rect.left) / rect.width)); + updateScrubbingUI(pos); + // Show UI to prevent controls hiding while dragging + this.wrapper.classList.add('active-ui'); + e.preventDefault(); // Stop browser back/scroll + e.stopPropagation(); + } + }; + + pWrap.addEventListener('touchstart', (e) => { + this.isDragging = true; + pWrap.classList.add('dragging'); + handleTouchProgress(e); + }, { passive: false }); + + pWrap.addEventListener('touchmove', (e) => { + if (this.isDragging) handleTouchProgress(e); + }, { passive: false }); + + const endTouchProgress = (e) => { + if (this.isDragging) { + this.isDragging = false; + pWrap.classList.remove('dragging'); + if (pendingSeekPct !== -1) { + this.safeSeek(pendingSeekPct * this.video.duration); + pendingSeekPct = -1; + } + } + }; + + pWrap.addEventListener('touchend', endTouchProgress); + pWrap.addEventListener('touchcancel', endTouchProgress); + + this._handlers.winMouseMove = (e) => { + if (this.isDragging) { + const rect = pWrap.getBoundingClientRect(); + const pos = Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width)); + updateScrubbingUI(pos); + } + }; + this._handlers.winMouseUp = () => { + if (this.isDragging) { + this.isDragging = false; + pWrap.classList.remove('dragging'); + if (pendingSeekPct !== -1) { + this.safeSeek(pendingSeekPct * this.video.duration); + pendingSeekPct = -1; + } + } + + if (deskPressTimer) clearTimeout(deskPressTimer); + if (isDeskLongPress) { + isDeskLongPress = false; + this.video.playbackRate = this.originalSpeed || 1.0; + const speedOverlay = this.container.querySelector('.txa-speed-overlay'); + if (speedOverlay) speedOverlay.classList.remove('show'); + this.wrapper.classList.remove('hide-controls'); + } + }; + + window.addEventListener('mousemove', this._handlers.winMouseMove); + window.addEventListener('mouseup', this._handlers.winMouseUp); + + this.video.addEventListener('timeupdate', () => { + if (this.destroyed) return; + this.updateProgress(); + }); + + this.video.addEventListener('play', () => this.showUI()); + this.video.addEventListener('pause', () => this.showUI(false)); + this.video.addEventListener('playing', () => this.showUI()); + + // v6.4.1 - Enhanced Mobile UI Handling + if (this.detectMobile()) { + // Remove redundant touchstart on video which might reset timer too often + // Instead rely on handleMobileEvents wrapper listener + + // Listen for orientation/resize to update clock visibility immediately + window.addEventListener('resize', () => this.updateClockVisibility()); + window.addEventListener('orientationchange', () => { + setTimeout(() => this.updateClockVisibility(), 200); + }); + } + + el('#txa-mute').onclick = () => { this.video.muted = !this.video.muted; this.updateVolUI(); this.saveSettings(); }; + const volSlider = el('#txa-vol'); + const volTooltip = el('#txa-vol-tooltip'); + + const showVolTooltip = () => volTooltip?.classList.add('visible'); + const hideVolTooltip = () => { if (!this._isVolDragging) volTooltip?.classList.remove('visible'); }; + + volSlider.oninput = (e) => { + this.video.volume = e.target.value; + this.video.muted = false; + this.updateVolUI(); + showVolTooltip(); + }; + + // v6.5.2 - Centralized volume/rate sync to always save state correctly + this.video.addEventListener('volumechange', () => { + this.updateVolUI(); + this.saveSettings(); + }); + + this.video.addEventListener('ratechange', () => { + this.saveSettings(); + }); + + volSlider.onmousedown = () => { this._isVolDragging = true; showVolTooltip(); }; + volSlider.onmouseenter = showVolTooltip; + volSlider.onmouseleave = hideVolTooltip; + + window.addEventListener('mouseup', () => { + if (this._isVolDragging) { + this._isVolDragging = false; + hideVolTooltip(); + } + }); + + el('#txa-settings').onclick = (e) => { e.stopPropagation(); el('#txa-panel').classList.toggle('active'); this.navSettings('main'); }; + el('#txa-fs').onclick = () => this.toggleFS(); + el('#txa-pip').onclick = () => this.toggleNativePiP(); + + // TXA PRO Toggles + const autoSkipBtn = el('#txa-auto-skip'); + if (autoSkipBtn) autoSkipBtn.onclick = (e) => { e.stopPropagation(); this.toggleAutoSkipIntro(); }; + + const autoNextBtn = el('#txa-auto-next'); + if (autoNextBtn) autoNextBtn.onclick = (e) => { e.stopPropagation(); this.toggleAutoNextEpisode(); }; + + // DETECTION PIP/FS TO UPDATE UI + this.video.onenterpictureinpicture = () => { + const pipBtn = el('#txa-pip'); // Added null check + if (pipBtn) pipBtn.innerHTML = '
Exit Mini Player (p)
'; + }; + this.video.onleavepictureinpicture = () => { + const pipBtn = el('#txa-pip'); // Added null check + if (pipBtn) pipBtn.innerHTML = '
Mini Player (p)
'; + }; + this._handlers.docFSChange = () => { + const fsBtn = el('#txa-fs'); + if (document.fullscreenElement) { + this.wrapper.classList.add('fullscreen-mode'); + if (fsBtn) fsBtn.innerHTML = '
Exit Fullscreen (f)
'; + } else { + this.wrapper.classList.remove('fullscreen-mode'); + if (fsBtn) fsBtn.innerHTML = '
Fullscreen (f)
'; + } + this.showUI(); // Trigger timer on FS change + this.updateClockVisibility(); + }; + document.addEventListener('fullscreenchange', this._handlers.docFSChange); + + el('#txa-nc-cancel').onclick = (e) => { + e.stopPropagation(); + + // Clear countdown interval if exists + if (this._autoNextCountdownInterval) { + clearInterval(this._autoNextCountdownInterval); + this._autoNextCountdownInterval = null; + } + + this._isAutoNextTriggered = true; // Block auto-trigger for this episode + el('#txa-next-countdown').classList.remove('show'); + if (this.wrapper) this.wrapper.classList.remove('has-countdown'); + this.showToast('Đã hủy tự động chuyển tập'); + + // Change "Skip Outro" button text if next episode exists + const skipOutro = this.container.querySelector('#txa-skip-outro'); + if (skipOutro && this.options.nextEpisodeUrl) { + skipOutro.innerHTML = ' Tập Tiếp'; + skipOutro.style.display = 'block'; // Ensure it's visible now + } + }; + + el('#txa-nc-next').onclick = (e) => { + e.preventDefault(); + e.stopPropagation(); + + // Clear countdown interval if exists + if (this._autoNextCountdownInterval) { + clearInterval(this._autoNextCountdownInterval); + this._autoNextCountdownInterval = null; + } + + this._isAutoNextTriggered = true; + el('#txa-next-countdown').classList.remove('show'); + if (this.wrapper) this.wrapper.classList.remove('has-countdown'); + + this._triggerAutoNext(); + }; + + el('#txa-skip-intro').onclick = () => this.skipIntro(); + el('#txa-skip-outro').onclick = () => this.skipOutro(); + + this.container.querySelectorAll('[data-goto]').forEach(i => i.onclick = (e) => { e.stopPropagation(); this.navSettings(i.dataset.goto); }); + this.container.querySelectorAll('[data-back]').forEach(i => i.onclick = (e) => { e.stopPropagation(); this.navSettings(i.dataset.back); }); + + // Speed Menu Clicks + this.container.querySelectorAll('[data-speed]').forEach(i => i.onclick = (e) => { + e.stopPropagation(); + this.setSpeed(parseFloat(i.dataset.speed)); + this.container.querySelectorAll('[data-speed]').forEach(o => o.classList.remove('active')); + i.classList.add('active'); + }); + + // Ratio Menu Clicks + this.container.querySelectorAll('[data-ratio]').forEach(i => i.onclick = (e) => { + e.stopPropagation(); + this.setAspectRatio(i.dataset.ratio); + this.container.querySelectorAll('[data-ratio]').forEach(o => o.classList.remove('active')); + i.classList.add('active'); + }); + + // Flip Menu Clicks + this.container.querySelectorAll('[data-flip]').forEach(i => i.onclick = (e) => { + e.stopPropagation(); + this.setVideoFlip(i.dataset.flip); + this.container.querySelectorAll('[data-flip]').forEach(o => o.classList.remove('active')); + i.classList.add('active'); + }); + + // Subtitle Size Menu + this.container.querySelectorAll('[data-subsize]').forEach(i => i.onclick = (e) => { + e.stopPropagation(); + const cap = el('#txa-captions'); + if (cap) { + cap.classList.remove('size-mini', 'size-small', 'size-medium', 'size-large', 'size-jumbo'); + cap.classList.add('size-' + i.dataset.subsize); + } + this.container.querySelectorAll('[data-subsize]').forEach(o => o.classList.remove('active')); + i.classList.add('active'); + this.saveSettings(); + }); + + // Subtitle Weight Menu + this.container.querySelectorAll('[data-subweight]').forEach(i => i.onclick = (e) => { + e.stopPropagation(); + const cap = el('#txa-captions'); + if (cap) { + cap.classList.remove('weight-normal', 'weight-bold'); + cap.classList.add('weight-' + i.dataset.subweight); + } + this.container.querySelectorAll('[data-subweight]').forEach(o => o.classList.remove('active')); + i.classList.add('active'); + this.saveSettings(); + }); + + // Subtitle Background Menu + this.container.querySelectorAll('[data-subbg]').forEach(i => i.onclick = (e) => { + e.stopPropagation(); + const cap = el('#txa-captions'); + if (cap) { + cap.classList.remove('bg-none', 'bg-dark', 'bg-light', 'bg-glass', 'bg-default'); + if (i.dataset.subbg !== 'default') cap.classList.add('bg-' + i.dataset.subbg); + } + this.container.querySelectorAll('[data-subbg]').forEach(o => o.classList.remove('active')); + i.classList.add('active'); + this.saveSettings(); + }); + + // Subtitle Color Menu + this.container.querySelectorAll('[data-subcolor]').forEach(i => i.onclick = (e) => { + e.stopPropagation(); + const cap = el('#txa-captions'); + if (cap) { + cap.classList.remove('color-white', 'color-yellow', 'color-orange', 'color-red', 'color-green', 'color-cyan', 'color-pink', 'color-violet'); + cap.classList.add('color-' + i.dataset.subcolor); + } + this.container.querySelectorAll('[data-subcolor]').forEach(o => o.classList.remove('active')); + i.classList.add('active'); + this.saveSettings(); + }); + + // Subtitle Stroke Toggle + const strokeToggle = el('#txa-substroke-toggle'); + const strokePanel = el('#txa-stroke-panel'); + if (strokeToggle) { + strokeToggle.onchange = (e) => { + const cap = el('#txa-captions'); + if (cap) { + if (e.target.checked) { + cap.classList.add('stroke-on'); + strokePanel.classList.add('active'); + } else { + cap.classList.remove('stroke-on'); + strokePanel.classList.remove('active'); + } + } + this.saveSettings(); + }; + } + + // Subtitle Stroke Color + this.container.querySelectorAll('[data-substroke]').forEach(i => i.onclick = (e) => { + e.stopPropagation(); + const cap = el('#txa-captions'); + if (cap) { + cap.classList.remove('stroke-white', 'stroke-black', 'stroke-yellow', 'stroke-red', 'stroke-blue'); + cap.classList.add('stroke-' + i.dataset.substroke); + } + this.container.querySelectorAll('[data-substroke]').forEach(o => o.classList.remove('active')); + i.classList.add('active'); + this.saveSettings(); + }); + + // Real-time Clock Toggle v6.4.0 + const clockToggle = el('#txa-clock-toggle'); + if (clockToggle) { + clockToggle.checked = this.settings.showRealTime; + clockToggle.onchange = (e) => { + this.settings.showRealTime = e.target.checked; + this.updateClockVisibility(); + this.saveSettings(); + }; + } + + // Clock Format Selection + this.container.querySelectorAll('[data-clock]').forEach(i => i.onclick = (e) => { + e.stopPropagation(); + this.settings.clockFormat = i.dataset.clock; + this.container.querySelectorAll('[data-clock]').forEach(o => o.classList.remove('active')); + i.classList.add('active'); + const lbl = el('#txa-lbl-clock'); + if (lbl) lbl.textContent = this.settings.clockFormat; + this.updateClock(); // Immediate update + this.saveSettings(); + }); + + // v6.4.5 - Robust Click/Touch Outside Logic for Panels + this._handlers.docClick = (e) => { + if (this.destroyed) return; + + const panel = el('#txa-panel'); + const settingsBtn = el('#txa-settings'); + const ctx = el('#txa-ctx'); + const stats = el('#txa-stats-panel'); + + // 1. Settings Panel Click Outside + if (panel && panel.classList.contains('active')) { + // Check if target is NOT inside panel AND NOT inside settings button + if (!panel.contains(e.target) && (!settingsBtn || !settingsBtn.contains(e.target))) { + panel.classList.remove('active'); + } + } + + // 2. Context Menu Click Outside + if (ctx && ctx.classList.contains('active')) { + if (!ctx.contains(e.target)) ctx.classList.remove('active'); + } + + // 3. Stats Panel Click Outside + if (stats && stats.classList.contains('active')) { + if (!stats.contains(e.target) && !e.target.closest('#txa-ctx-stats')) { + this.toggleStatsPanel(); // Use clear cleanup logic + } + } + }; + document.addEventListener('click', this._handlers.docClick); + document.addEventListener('touchstart', this._handlers.docClick, { passive: true }); + + + this.wrapper.onmousemove = (e) => { + if (this.detectMobile()) return; // Absolutely disable bottom hover for mobile + + const rect = this.wrapper.getBoundingClientRect(); + const y = e.clientY - rect.top; + // Only show UI if cursor is in the bottom 30% or if video is paused (Desktop) + if (y > rect.height * 0.7 || this.video.paused) { + this.showUI(); + } + }; + this.wrapper.onclick = (e) => { + // Desktop click logic (Mobile handled in handleMobileEvents) + if (!this.detectMobile()) { + if (!e.target.closest('.txa-controls,.txa-panel,.txa-ctx,.txa-replay-overlay,.txa-loader,.txa-stats-panel,.txa-resume-overlay,.txa-next-countdown,.txa-skip-btn')) this.showUI(); + } + }; + + el('#txa-zone-l').ondblclick = () => this.seekAccumulated(-10); + el('#txa-zone-r').ondblclick = () => this.seekAccumulated(10); + + // REMOVED: Scroll wheel volume control (user request) + // this.wrapper.onwheel = (e) => { ... }; + + el('#txa-cc').onclick = (e) => { e.stopPropagation(); this.toggleSubLoop(); }; + + // SUBTITLE DRAGGING + this.setupSubtitleDrag(); + + // Initialize UI timer (Auto hide) + this.showUI(); + } + + /** + * Centralized UI visibility logic + * @param {boolean} autoHide - Whether to start a timer to hide the UI + */ + showUI(autoHide = true) { + if (!this.wrapper || this.destroyed) return; + this.wrapper.classList.add('active-ui'); + if (this.controls) this.controls.classList.add('visible'); + if (this._uiTimer) clearTimeout(this._uiTimer); + + // Always start timer if autoHide is requested + if (autoHide && this.video) { + const delay = this.detectMobile() ? 5000 : 3000; + this._uiTimer = setTimeout(() => this.hideUI(), delay); + } + } + + hideUI() { + if (!this.wrapper || this.destroyed) return; + + // Prevent hiding if video is paused + if (!this.video || this.video.paused) return; + + // Prevent hiding if any interactable panel is open + const el = (s) => this.container.querySelector(s); + const panel = el('#txa-panel'); + const ctx = el('#txa-ctx'); + const stats = el('#txa-stats-panel'); + const shortcuts = document.querySelector('.txa-shortcuts-panel'); + + if ((panel && panel.classList.contains('active')) || + (ctx && ctx.classList.contains('active')) || + (stats && stats.classList.contains('active')) || + (shortcuts)) { + // Something is active, reset timer to try again later + this.showUI(); + return; + } + + this.wrapper.classList.remove('active-ui'); + if (this.controls) this.controls.classList.remove('visible'); + } + + setupSubtitleDrag() { + const captions = this.container.querySelector('#txa-captions'); + if (!captions) return; + + // Load saved position & styles + const saved = this.loadSettings(); + if (saved.captionBottom) captions.style.bottom = saved.captionBottom + 'px'; + + // Fix: Use pixel positioning if available + if (saved.captionLeft !== undefined && saved.captionLeft !== null) { + if (saved.captionLeft <= 100 && saved.captionIsPercent) { + captions.style.left = saved.captionLeft + '%'; + captions.style.transform = 'translateX(-50%)'; + } else { + captions.style.left = saved.captionLeft + 'px'; + captions.style.transform = 'none'; + } + } + + // Apply saved styles + if (saved.subSize) { + captions.classList.add('size-' + saved.subSize); + this.container.querySelectorAll('[data-subsize]').forEach(i => { + i.classList.toggle('active', i.dataset.subsize === saved.subSize); + }); + } + if (saved.subBg) { + if (saved.subBg !== 'default') captions.classList.add('bg-' + saved.subBg); + this.container.querySelectorAll('[data-subbg]').forEach(i => { + i.classList.toggle('active', i.dataset.subbg === saved.subBg); + }); + } + if (saved.subColor) { + if (saved.subColor !== 'white') captions.classList.add('color-' + saved.subColor); + this.container.querySelectorAll('[data-subcolor]').forEach(i => { + i.classList.toggle('active', i.dataset.subcolor === saved.subColor); + }); + } + + let isDragging = false; + let startX = 0, startY = 0; + let startLeft = 0, startBottom = 0; + + captions.addEventListener('mousedown', (e) => { + isDragging = true; + captions.classList.add('dragging'); + startX = e.clientX; + startY = e.clientY; + const style = getComputedStyle(captions); + startBottom = parseInt(style.bottom) || 110; + const rect = captions.getBoundingClientRect(); + const pRect = this.wrapper.getBoundingClientRect(); + + // Calculate current relative position (Pixels) + startLeft = rect.left - pRect.left; + startBottom = pRect.bottom - rect.bottom; + + // Prepare for pixel drag + captions.style.left = startLeft + 'px'; + captions.style.bottom = startBottom + 'px'; + captions.style.transform = 'none'; + e.preventDefault(); + }); + + this._handlers.dragMouseMove = (e) => { + if (!isDragging) return; + const rect = this.wrapper.getBoundingClientRect(); + + // Vertical movement + const deltaY = startY - e.clientY; + const newBottom = Math.max(20, Math.min(rect.height - 80, startBottom + deltaY)); + captions.style.bottom = newBottom + 'px'; + + // Horizontal movement + const deltaX = e.clientX - startX; + const newLeft = Math.max(0, Math.min(rect.width - captions.offsetWidth, startLeft + deltaX)); // Boundary check + captions.style.left = newLeft + 'px'; + captions.style.transform = 'none'; + }; + + this._handlers.dragMouseUp = () => { + if (isDragging) { + isDragging = false; + captions.classList.remove('dragging'); + // Save position (Pixels) + const cfg = this.loadSettings(); + cfg.captionBottom = parseInt(captions.style.bottom); + cfg.captionLeft = parseFloat(captions.style.left); + cfg.captionIsPercent = false; + localStorage.setItem('txa-txa-cfg', JSON.stringify(cfg)); + } + }; + + window.addEventListener('mousemove', this._handlers.dragMouseMove); + window.addEventListener('mouseup', this._handlers.dragMouseUp); + } + + togglePlay() { + this._isExplicitToggle = true; + + // v6.6.2 - Lazy setup on first interaction + if (!this._mediaSetupDone) { + const cp = this.container.querySelector('#txa-center-play'); + if (cp) cp.classList.remove('show'); + + this.setupMedia(); + // We don't need to call play() here because setupMedia with autoPlay=true will do it, + // or if it's the first click, we might want to force it. + // Actually, setupMedia might take time to resolve. + // Let's ensure it plays after setup. + this.options.autoPlay = true; + return; + } + + this.video.paused ? this.video.play().catch(() => { }) : this.video.pause(); + // Clear the flag after a short delay + setTimeout(() => { this._isExplicitToggle = false; }, 500); + } + + animateCenter(type) { + // Only run animation if it was an explicit user toggle + if (!this._isExplicitToggle) return; + + // Remove existing if any + let c = this.container.querySelector('.txa-center-feedback'); + if (!c) { + c = document.createElement('div'); + c.className = 'txa-center-feedback'; + this.container.appendChild(c); + } + + c.innerHTML = type === 'play' ? '' : ''; + + // Reset classes + c.classList.remove('animate', 'animate-out'); + void c.offsetWidth; // Trigger reflow + + c.classList.add('animate'); + + setTimeout(() => { + if (c) { + c.classList.add('animate-out'); + setTimeout(() => { + c.classList.remove('animate', 'animate-out'); + }, 400); + } + }, 400); + if (window.navigator.vibrate) window.navigator.vibrate(15); + } + + showFeedback(type, value = null) { + const fb = this.container.querySelector('#txa-feedback'); + if (!fb) return; + + fb.classList.remove('high-priority'); // Reset + + if (type === 'volume') { + fb.innerHTML = `${Math.round(this.video.volume * 100)}%`; + } else if (type === 'seek') { + fb.innerHTML = `${value}`; + } else if (type === 'text') { + fb.innerHTML = `${value}`; + } else if (type === 'high') { + fb.innerHTML = `${value}`; + fb.classList.add('high-priority'); + } + + fb.classList.add('show'); + clearTimeout(this.feedbackTimer); + + const duration = type === 'high' ? 3000 : 800; + this.feedbackTimer = setTimeout(() => fb.classList.remove('show'), duration); + } + + reportErrorToServer(errorType, errorMessage, errorDetails = {}) { + const payload = { + movie_slug: this.options.movieSlug || null, + movie_name: this.options.title || null, + episode_name: this.options.episodeName || null, + error_type: errorType, + error_message: errorMessage || '', + error_details: { + ...errorDetails, + video_url: this.options.videoUrl || '', + server_name: this.options.serverName || '', + settings: this.settings || {}, + txa_version: typeof TXA_VERSION !== 'undefined' ? TXA_VERSION : 'v1.0' + }, + browser_token: localStorage.getItem('zalo_browser_token') || null + }; + + fetch('/api/player/report-error', { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(payload) + }) + .then(res => res.json()) + .then(data => { + if (this.options.isAdmin) { + console.log('[TXAPlayer] Error reported to server successfully:', data); + } + }) + .catch(err => { + console.error('[TXAPlayer] Failed to report error to server:', err); + }); + } + + _txaShowHlsError(msg, hlsData = null) { + // Report HLS fatal error to database + this.reportErrorToServer('hlsError', msg, hlsData); + + const loader = this.container?.querySelector('#txa-loader'); + if (!loader) return; + + loader.classList.remove('hidden'); + loader.style.pointerEvents = 'all'; + + const spinner = loader.querySelector('.txa-spinner'); + const pctEl = loader.querySelector('#txa-load-pct'); + const barFill = loader.querySelector('#txa-load-bar-fill'); + const loadText = loader.querySelector('#txa-load-text'); + const speedEl = loader.querySelector('#txa-load-speed'); + + if (spinner) { spinner.style.borderTopColor = '#f59e0b'; spinner.style.animationPlayState = 'paused'; } + if (pctEl) { pctEl.textContent = '✕'; pctEl.style.color = '#f59e0b'; } + if (barFill) { barFill.style.background = '#f59e0b'; barFill.style.width = '100%'; } + if (speedEl) speedEl.textContent = ''; + if (loadText) { + loadText.style.color = '#fde68a'; + loadText.innerHTML = `${msg}`; + } + + if (hlsData && this.options.isAdmin) { + console.error('[TXAPlayer] HLS Fatal:', hlsData.type, hlsData.details, hlsData.response); + } + + if (!loader.querySelector('#txa-retry-btn')) { + const retryBtn = document.createElement('button'); + retryBtn.id = 'txa-retry-btn'; + retryBtn.innerHTML = 'Tải lại'; + retryBtn.style.cssText = ` + margin-top:14px; padding:8px 22px; + background:#f59e0b; color:#000; border:none; + border-radius:8px; cursor:pointer; font-size:13px; font-weight:700; + pointer-events:all; + `; + retryBtn.onclick = () => window.location.reload(); + const content = loader.querySelector('.txa-loader-content'); + if (content) content.appendChild(retryBtn); + } + } + + setAspectRatio(ratio) { + if (!this.video) return; + this.video.classList.remove('ratio-4-3', 'ratio-16-9', 'ratio-stretch'); + if (ratio !== 'default') this.video.classList.add('ratio-' + ratio); + + const lbl = this.container.querySelector('#txa-lbl-ratio'); + if (lbl) lbl.textContent = ratio === 'default' ? 'Default' : ratio.replace('-', ':').toUpperCase(); + + // Update menu status + this.container.querySelectorAll('[data-ratio]').forEach(i => i.classList.toggle('active', i.dataset.ratio === ratio)); + + this.showFeedback('text', 'Ratio: ' + (ratio === 'default' ? 'Default' : ratio)); + this.saveSettings(); + } + + setVideoFlip(flip) { + if (!this.video) return; + this.video.classList.remove('flip-h', 'flip-v', 'flip-both'); + if (flip !== 'normal') this.video.classList.add('flip-' + flip); + + const lbl = this.container.querySelector('#txa-lbl-flip'); + if (lbl) { + const names = { normal: 'Normal', h: 'Horizontal', v: 'Vertical', both: 'Both' }; + lbl.textContent = names[flip] || 'Normal'; + } + + // Update menu status + this.container.querySelectorAll('[data-flip]').forEach(i => i.classList.toggle('active', i.dataset.flip === flip)); + + this.showFeedback('text', 'Flip: ' + flip); + this.saveSettings(); + } + + seekAccumulated(sec) { + this.seekAccumulator += sec; + clearTimeout(this.seekDebounce); + const badge = this.container.querySelector(this.seekAccumulator > 0 ? '#txa-badge-r' : '#txa-badge-l'); + const other = this.container.querySelector(this.seekAccumulator > 0 ? '#txa-badge-l' : '#txa-badge-r'); + if (other) other.classList.remove('show'); // Added null check + if (badge) { // Added null check + badge.querySelector('span').textContent = `${this.seekAccumulator > 0 ? '+' : ''}${this.seekAccumulator}s`; + badge.classList.add('show'); + } + this.seekDebounce = setTimeout(() => { + this.safeSeek(this.video.currentTime + this.seekAccumulator); + this.seekAccumulator = 0; + if (badge) badge.classList.remove('show'); // Added null check + }, 700); + } + + updateVolUI() { + const v = this.video.muted ? 0 : this.video.volume; + const btn = this.container.querySelector('#txa-mute'); + const volInput = this.container.querySelector('#txa-vol'); + const volTooltip = this.container.querySelector('#txa-vol-tooltip'); + + if (volInput) { + volInput.value = v; + const pct = v * 100; + // Update the premium fill effect + volInput.style.backgroundImage = `linear-gradient(to right, var(--txa-brand) ${pct}%, rgba(255,255,255,0.15) ${pct}%)`; + + if (volTooltip) { + volTooltip.textContent = Math.round(pct) + '%'; + // Precise positioning follow thumb + const sliderWidth = 115; + const thumbWidth = 18; + const btnWidth = 42; + const usableWidth = sliderWidth - thumbWidth; + // Offset calculation relative to volume container + const leftOffset = btnWidth + 12 + (v * usableWidth) + (thumbWidth / 2); + volTooltip.style.left = leftOffset + 'px'; + } + } + if (btn) { + const icon = v === 0 ? 'mute' : v < 0.5 ? 'down' : 'up'; + btn.innerHTML = `
${v === 0 ? 'Unmute' : 'Mute'} (m)
`; + if (v === 0) btn.style.opacity = '0.6'; + else btn.style.opacity = '1'; + } + } + + formatTime(s, forceHours = false) { + if (!s || isNaN(s)) return '00:00'; + const h = Math.floor(s / 3600); + const m = Math.floor((s % 3600) / 60); + const sec = Math.floor(s % 60); + const pad = n => n < 10 ? '0' + n : n; + // If duration >= 1 hour OR forceHours, show HH:MM:SS + if (forceHours || h > 0) { + return `${pad(h)}:${pad(m)}:${pad(sec)}`; + } + return `${pad(m)}:${pad(sec)}`; + } + + /** + * Safe seek - prevents "non-finite" errors when duration/time is NaN or Infinity + */ + safeSeek(time) { + if (!this.video) return; + if (!isFinite(time) || isNaN(time)) return; + const dur = this.video.duration; + if (!isFinite(dur) || isNaN(dur) || dur <= 0) return; + this.video.currentTime = Math.max(0, Math.min(dur, time)); + } + + formatTimeDisplay() { + const current = this.video.currentTime || 0; + const duration = this.video.duration || 0; + return `${this.formatTime(current, duration >= 3600)} / ${this.formatTime(duration)}`; + } + + async toggleFS() { + try { + const isFS = document.fullscreenElement || document.webkitFullscreenElement; + if (isFS) { + if (document.exitFullscreen) await document.exitFullscreen(); + else if (document.webkitExitFullscreen) await document.webkitExitFullscreen(); + if (screen.orientation && screen.orientation.unlock) { + try { await screen.orientation.unlock(); } catch (e) { } + } + } else { + if (this.wrapper.requestFullscreen) await this.wrapper.requestFullscreen(); + else if (this.wrapper.webkitRequestFullscreen) await this.wrapper.webkitRequestFullscreen(); + else if (this.video.webkitEnterFullscreen) { + this.video.webkitEnterFullscreen(); + return; + } + if (this.detectMobile() && screen.orientation && screen.orientation.lock) { + try { await screen.orientation.lock('landscape'); } catch (e) { } + } + } + } catch (err) { + console.error('FS Error:', err); + if (this.video.webkitEnterFullscreen) this.video.webkitEnterFullscreen(); + } + } + + skipIntro() { + if (!this.options.isLoggedIn) return; + const intro = this.options.markers.intro; + if (intro) { + this.safeSeek(intro[1]); + this.showToast('🚀 Bỏ qua Intro'); + } + } + + skipOutro() { + if (!this.options.isLoggedIn) return; + const outro = this.options.markers.outro; + if (!outro) return; + + const effectiveOutroOut = (outro[1] > 0) ? outro[1] : this.video.duration; + + if (this.options.nextEpisodeUrl && Math.abs(effectiveOutroOut - this.video.duration) < 5) { + if (this.options.onAutoNext) { + this.options.onAutoNext(true); + } else if (typeof window.switchEpisodeSeamless === 'function' && this.options.nextEpisodeUrl) { + window.switchEpisodeSeamless(this.options.nextEpisodeUrl, true); + } else { + window.location.href = this.options.nextEpisodeUrl; + } + return; + } + + if (effectiveOutroOut >= this.video.duration - 5) { + this.video.pause(); + const replay = this.container.querySelector('#txa-replay'); + if (replay) replay.classList.add('show'); + } else { + this.safeSeek(outro[1]); + this.showToast('🚀 Bỏ qua Outro'); + } + } + + toggleAutoSkipIntro() { + this.settings.autoSkipIntro = !this.settings.autoSkipIntro; + this.saveSettings(); + const text = this.settings.autoSkipIntro ? 'Auto Skip Intro: Bật' : 'Auto Skip Intro: Tắt'; + this.showToast('🚀 ' + text); + this.updatePeSwitches(); + } + + toggleAutoNextEpisode() { + this.settings.autoNextEpisode = !this.settings.autoNextEpisode; + this.saveSettings(); + const text = this.settings.autoNextEpisode ? 'Auto Next: Bật' : 'Auto Next: Tắt'; + this.showToast('⏭️ ' + text); + this.updatePeSwitches(); + } + + updatePeSwitches() { + // Update Internal Toolbar Buttons + const skipBtn = this.container ? this.container.querySelector('#txa-auto-skip') : null; + if (skipBtn) { + const isOn = this.settings.autoSkipIntro; + skipBtn.classList.toggle('active', isOn); + const statusEl = skipBtn.querySelector('.txa-btn-status'); + if (statusEl) statusEl.textContent = isOn ? 'ON' : 'OFF'; + const tooltipEl = skipBtn.querySelector('.txa-tooltip'); + if (tooltipEl) tooltipEl.textContent = `Tự động bỏ qua giới thiệu (${isOn ? 'Bật' : 'Tắt'})`; + } + + const nextBtn = this.container ? this.container.querySelector('#txa-auto-next') : null; + if (nextBtn) { + const isOn = this.settings.autoNextEpisode; + nextBtn.classList.toggle('active', isOn); + const statusEl = nextBtn.querySelector('.txa-btn-status'); + if (statusEl) statusEl.textContent = isOn ? 'ON' : 'OFF'; + const tooltipEl = nextBtn.querySelector('.txa-tooltip'); + if (tooltipEl) tooltipEl.textContent = `Tự động chuyển tập (${isOn ? 'Bật' : 'Tắt'})`; + } + + // Sync external UI if needed + const extAutoSkip = document.querySelector('.pe-item.auto-skip-intro'); + if (extAutoSkip) { + extAutoSkip.classList.toggle('active-pro', this.settings.autoSkipIntro); + extAutoSkip.setAttribute('data-txa-tooltip', `Tự động bỏ qua Intro (${this.settings.autoSkipIntro ? 'BẬT' : 'TẮT'})`); + } + + const extAutoNext = document.querySelector('.pe-item.auto-next'); + if (extAutoNext) { + extAutoNext.classList.toggle('active-pro', this.settings.autoNextEpisode); + extAutoNext.setAttribute('data-txa-tooltip', `Tự động chuyển tập (${this.settings.autoNextEpisode ? 'BẬT' : 'TẮT'})`); + } + } + + /** + * Show auto-next countdown overlay when video ends (without outro markers) + */ + _showAutoNextCountdown() { + console.log('[TXAPlayer] _showAutoNextCountdown called', { + autoNextEpisode: this.settings.autoNextEpisode, + nextEpisodeUrl: this.options.nextEpisodeUrl, + isAutoNextTriggered: this._isAutoNextTriggered + }); + + const overlay = this.container.querySelector('#txa-next-countdown'); + const timeEl = this.container.querySelector('#txa-nc-timer'); + const titleEl = this.container.querySelector('#txa-nc-title'); + const badgeEl = this.container.querySelector('#txa-nc-badge'); + + if (!overlay) { + console.warn('[TXAPlayer] Countdown overlay not found in DOM'); + return; + } + + // Set title + if (titleEl) titleEl.textContent = this.options.title || 'Tập tiếp theo'; + + // Smart Badge: Try to detect next episode number + if (badgeEl) { + let nextNum = '--'; + try { + const url = this.options.nextEpisodeUrl || ''; + const curName = this.options.episodeName || ''; + const matchUrl = url.match(/(tap|ep|episode)[\-_](\d+)/i) || url.match(/-(\d+)\.html/) || url.match(/-(\d+)$/); + + if (matchUrl) { + nextNum = matchUrl[matchUrl.length - 1]; + } else { + const matchCurr = curName.match(/(\d+)/); + if (matchCurr) { + const num = parseInt(matchCurr[1]) + 1; + nextNum = (matchCurr[1].startsWith('0') && num < 10) ? '0' + num : num; + } + } + } catch (e) { } + badgeEl.innerHTML = `Tập${nextNum}`; + } + + // Show overlay + overlay.classList.add('show'); + if (this.wrapper) this.wrapper.classList.add('has-countdown'); + + // Start countdown + let countdown = 5; + if (timeEl) { + timeEl.textContent = `Bắt đầu sau 0${countdown}s`; + } + + const countdownInterval = setInterval(() => { + countdown--; + if (countdown <= 0) { + clearInterval(countdownInterval); + overlay.classList.remove('show'); + if (this.wrapper) this.wrapper.classList.remove('has-countdown'); + + // Trigger auto-next + this._isAutoNextTriggered = true; + this._triggerAutoNext(); + } else { + if (timeEl) { + timeEl.textContent = `Bắt đầu sau 0${countdown}s`; + } + } + }, 1000); + + // Store interval ID to clear if needed + this._autoNextCountdownInterval = countdownInterval; + } + + /** + * Trigger auto-next episode switch + */ + _triggerAutoNext() { + // Always prefer window.switchEpisodeSeamless if available (for seamless SPA experience) + if (typeof window.switchEpisodeSeamless === 'function' && this.options.nextEpisodeUrl) { + console.log('[TXAPlayer] Using switchEpisodeSeamless for auto-next'); + window.switchEpisodeSeamless(this.options.nextEpisodeUrl, true); + } else if (this.options.onAutoNext) { + this.options.onAutoNext(true); + } else if (window.loadEpisode && typeof window.loadEpisode === 'function') { + window.loadEpisode(this.options.nextEpisodeUrl); + } else if (this.options.nextEpisodeUrl) { + console.warn('[TXAPlayer] No seamless switch available, falling back to page reload'); + window.location.href = this.options.nextEpisodeUrl; + } + } + + checkMarkers() { + if (!this.options.isLoggedIn || !this.options.markers) return; + const ct = this.video.currentTime; + const dur = this.video.duration; + const { intro, outro } = this.options.markers; + + // Player Internal Buttons + const skipIntro = this.container.querySelector('#txa-skip-intro'); + const skipOutro = this.container.querySelector('#txa-skip-outro'); + + // External Buttons (for TPhimX Tools) + const extIntro = document.querySelector('.skip-intro-btn'); + const extOutro = document.querySelector('.skip-outro-btn'); + + // Initial UI sync for external switches + if (!this._peSwitchesInited) { + this.updatePeSwitches(); + this._peSwitchesInited = true; + } + + // Skip Intro logic + if (intro && ct >= intro[0] && ct <= intro[1]) { + if (skipIntro) skipIntro.style.display = 'block'; + if (extIntro) extIntro.classList.remove('d-none'); + + if (this.settings.autoSkipIntro && ct < intro[1]) { + this.safeSeek(intro[1]); + this.showToast('🚀 Đã tự động bỏ qua Intro'); + } + } else { + if (skipIntro) skipIntro.style.display = 'none'; + if (extIntro) extIntro.classList.add('d-none'); + } + + // Skip Outro / Next Episode logic + // STRICT CHECK: Only trigger if Outro is VALID (Start > 0) per user request + const isValidOutro = outro && (outro[1] > outro[0] || (outro[0] > 0 && (outro[1] === 0 || !outro[1]))) && outro[0] > 0; + const effectiveOutroOut = isValidOutro ? (outro[1] > 0 ? outro[1] : dur) : 0; + + if (isValidOutro && ct >= outro[0] && ct <= effectiveOutroOut) { + if (skipOutro) { + skipOutro.style.display = 'block'; + // If we are very close to end, change text + if (this.options.nextEpisodeUrl && Math.abs(dur - ct) < 15) { + skipOutro.innerHTML = ' Tập Tiếp'; + } + } + if (extOutro) extOutro.classList.remove('d-none'); + + // Auto Next Countdown & Logic + // Only runs if Auto Next is enabled AND we have a valid Outro + if (this.settings.autoNextEpisode && this.options.nextEpisodeUrl && !this._isAutoNextTriggered) { + const triggerWait = 5; // 5s countdown + const overlay = this.container.querySelector('#txa-next-countdown'); + const timeEl = this.container.querySelector('#txa-nc-timer'); + const titleEl = this.container.querySelector('#txa-nc-title'); + const badgeEl = this.container.querySelector('#txa-nc-badge'); + + // Show Overlay + if (overlay && !overlay.classList.contains('show')) { + if (titleEl) titleEl.textContent = this.options.title || 'Tập tiếp theo'; + + // Smart Badge: Try to detect next episode number + if (badgeEl) { + let nextNum = '--'; + try { + const url = this.options.nextEpisodeUrl || ''; + const curName = this.options.episodeName || ''; + const matchUrl = url.match(/(tap|ep|episode)[\-_](\d+)/i) || url.match(/-(\d+)\.html/) || url.match(/-(\d+)$/); + + if (matchUrl) { + nextNum = matchUrl[matchUrl.length - 1]; + } else { + const matchCurr = curName.match(/(\d+)/); + if (matchCurr) { + const num = parseInt(matchCurr[1]) + 1; + nextNum = (matchCurr[1].startsWith('0') && num < 10) ? '0' + num : num; + } + } + } catch (e) { } + badgeEl.innerHTML = `Tập${nextNum}`; + } + + overlay.classList.add('show'); + this.wrapper.classList.add('has-countdown'); + if (skipOutro) skipOutro.style.display = 'none'; + } + + // Calculate Countdown + const elapsedInOutro = ct - outro[0]; + const remain = Math.max(0, triggerWait - Math.floor(elapsedInOutro)); + + if (timeEl) { + const fmt = (remain < 10 ? '0' + remain : remain) + 's'; + timeEl.textContent = `Bắt đầu sau ${fmt}`; + } + + // Trigger Next + if (elapsedInOutro >= triggerWait) { + this._isAutoNextTriggered = true; + if (overlay) overlay.classList.remove('show'); + this.wrapper.classList.remove('has-countdown'); + + this._triggerAutoNext(); + } + } + } else { + // Not in Outro / Invalid Outro + if (skipOutro) skipOutro.style.display = 'none'; + if (extOutro) extOutro.classList.add('d-none'); + + // Clean up if we sought out of outro + const overlay = this.container.querySelector('#txa-next-countdown'); + if (overlay && overlay.classList.contains('show')) { + overlay.classList.remove('show'); + this.wrapper.classList.remove('has-countdown'); + } + } + } + + setupShortcuts() { + this._handlers.winKeyDown = (e) => { + if (this.destroyed) return; + if (['INPUT', 'TEXTAREA'].includes(e.target.tagName)) return; + const k = e.key.toLowerCase(); + + // Prevent scrolling for arrow keys if player is in focus or just generally + if ([' ', 'k', 'f', 'm', 'p', 'arrowup', 'arrowdown', 'arrowleft', 'arrowright'].includes(k)) { + // Only prevent default if it's a player key + } + + switch (k) { + case ' ': case 'k': e.preventDefault(); this.togglePlay(); break; + case 'f': this.toggleFS(); break; + case 'm': this.video.muted = !this.video.muted; this.updateVolUI(); this.showFeedback('volume'); this.saveSettings(); break; + case 'p': this.toggleNativePiP(); break; + case 'j': case 'arrowleft': this.seekAccumulated(-10); break; + case 'l': case 'arrowright': this.seekAccumulated(10); break; + case 'arrowup': e.preventDefault(); this.video.volume = Math.min(1, this.video.volume + 0.05); this.updateVolUI(); this.showFeedback('volume'); this.saveSettings(); break; + case 'arrowdown': e.preventDefault(); this.video.volume = Math.max(0, this.video.volume - 0.05); this.updateVolUI(); this.showFeedback('volume'); this.saveSettings(); break; + case 'c': this.toggleSubLoop(); break; + case 'i': this.skipIntro(); break; + case 'o': this.skipOutro(); break; + case 't': this.toggleTheaterMode(); break; // v5.8.0 - Theater Mode + case 'a': this.toggleCinemaMode(); break; // v5.8.0 - Ambient Light + case 'escape': { + const el = (s) => this.container.querySelector(s); + + // 1. Close dynamic shortcuts panel + const sc = document.querySelector('.txa-shortcuts-panel'); + if (sc) sc.remove(); + + // 2. Toggle off Stats Panel if active + const stats = el('#txa-stats-panel'); + if (stats && stats.classList.contains('active')) this.toggleStatsPanel(); + + // 3. Hide Settings Panel + const settings = el('#txa-panel'); + if (settings && settings.classList.contains('active')) settings.classList.remove('active'); + + // 4. Hide Context Menu + const ctx = el('#txa-ctx'); + if (ctx && ctx.classList.contains('active')) ctx.classList.remove('active'); + + // 5. Hide Resume Overlay + const resume = el('#txa-resume'); + if (resume && resume.classList.contains('show')) { + resume.classList.remove('show'); + this.resumeShown = true; + } + + // 6. Cancel Next Episode Countdown + const next = el('#txa-next-countdown'); + if (next && next.classList.contains('show')) { + next.classList.remove('show'); + this._isAutoNextTriggered = true; + } + + // 7. Exit Theater Mode + if (this.isTheaterMode) this.toggleTheaterMode(); + + break; + } + case '/': { + if (e.shiftKey) { + e.preventDefault(); + this.showShortcuts(); + } else { + // Search Shortcut Focus + e.preventDefault(); + setTimeout(() => { + const searchInput = document.querySelector('input[name="keyword"]') || + document.querySelector('#search-keyword') || + document.querySelector('.search-input'); + if (searchInput) { + searchInput.focus(); + searchInput.select(); + } + }, 50); + } + break; + } + default: + if (k >= '0' && k <= '9') { + const pct = parseInt(k) * 10; + const t = (pct / 100) * this.video.duration; + this.safeSeek(t); + this.showFeedback('seek', `${pct}% (${this.formatTime(t)})`); + } + } + }; + window.addEventListener('keydown', this._handlers.winKeyDown); + } + + // initSubtitles merged with version above to avoid duplication logic bugs + + + async toggleSub(idx) { + const lbl = this.container.querySelector('#txa-lbl-subs'); + const btn = this.container.querySelector('#txa-cc'); + const subs = this.options.subtitles; + + // Clear previous subtitles immediately to avoid "stuck" captions while loading + this.currentSubCues = []; + this.renderSubtitles(); + + if (idx === -1) { + if (lbl) lbl.textContent = 'Off'; // Added null check + this.activeSubIdx = -1; + if (btn) btn.classList.remove('cc-active'); // Added null check + this.showFeedback('text', 'Subtitles: Off'); + } else { + const sub = subs && subs[idx]; + if (!sub) { + if (lbl) lbl.textContent = 'Off'; + this.activeSubIdx = -1; + if (btn) btn.classList.remove('cc-active'); + return; + } + if (lbl) lbl.textContent = sub.label || sub.lang; // Added null check + this.activeSubIdx = idx; + if (btn) btn.classList.add('cc-active'); // Added null check + this.showFeedback('text', `Subtitles: ${sub.label || sub.lang}`); + + let txt = sub.content || ''; + if (sub.file) { + try { + txt = await (await fetch(sub.file)).text(); + } catch (e) { + console.error('Subtitle fetch failed:', e); + this.showToast('Lỗi tải phụ đề'); + } + } + + this.currentSubCues = this.parseVTT(txt); + // Re-render immediately so the correct subtitle shows up at current time + this.renderSubtitles(); + } + this.navSettings('main'); + + // Update active class in menu list + const list = this.container.querySelector('#txa-list-subs'); + if (list) { + list.querySelectorAll('.txa-menu-item').forEach(o => o.classList.remove('active')); + list.querySelector(`[data-sub="${idx}"]`)?.classList.add('active'); + } + } + + toggleSubLoop() { + if (this.currentSubCues.length > 0) this.toggleSub(-1); + else if (this.options.subtitles?.length > 0) this.toggleSub(0); + } + + renderSubtitles() { + const box = this.container.querySelector('#txa-captions'); + if (!box) return; // Added null check + if (!this.currentSubCues.length) { box.innerHTML = ''; return; } + const ct = this.video.currentTime; + const cue = this.currentSubCues.find(c => ct >= c.start && ct <= c.end); + box.innerHTML = cue ? `
${cue.text}
` : ''; + } + + parseVTT(content) { + if (!content) return []; + const cues = []; + // Clean up content: Remove WEBVTT header and metadata + let processed = content.replace(/^WEBVTT.*\r?\n/i, ''); + // Convert SRT commas to dots for universal parsing + processed = processed.replace(/(\d+:\d+:\d+),(\d+)/g, '$1.$2'); + + const lines = processed.split(/\r?\n/); + let start = null, end = null, text = []; + + const parseTime = (t) => { + t = t.trim().replace(/[\[\]]/g, ''); + const p = t.split(':'); + if (p.length === 3) { + // HH:MM:SS.mmm or MM:SS.mmm + const hours = parseInt(p[0]) || 0; + const minutes = parseInt(p[1]) || 0; + const seconds = parseFloat(p[2].replace(',', '.')) || 0; + return hours * 3600 + minutes * 60 + seconds; + } else if (p.length === 2) { + const minutes = parseInt(p[0]) || 0; + const seconds = parseFloat(p[1].replace(',', '.')) || 0; + return minutes * 60 + seconds; + } + return parseFloat(t) || 0; + }; + + lines.forEach(line => { + const l = line.trim(); + if (l.includes('-->')) { + // Time range line + if (start !== null && text.length > 0) { + cues.push({ start, end: end || start + 5, text: text.join('
') }); + text = []; + } + const p = l.split('-->'); + start = parseTime(p[0]); + end = parseTime(p[1]); + } else if (l === '') { + // Separator + if (start !== null && text.length > 0) { + cues.push({ start, end: end || start + 5, text: text.join('
') }); + start = null; end = null; text = []; + } + } else if (/^\d+$/.test(l)) { + // Index line (SRT) - ignore + } else if (l !== '') { + // Text line + if (start !== null) text.push(l); + } + }); + + // Push last cue + if (start !== null && text.length > 0) { + cues.push({ start, end: end || start + 5, text: text.join('
') }); + } + + return cues; + } + + navSettings(view) { + const p = this.container.querySelector('#txa-panel'); + if (!p) return; // Added null check + p.querySelectorAll('[id^="txa-view-"]').forEach(d => d.classList.add('txa-hidden')); + const target = p.querySelector(`#txa-view-${view}`); + if (target) target.classList.remove('txa-hidden'); + } + + setSpeed(rate) { + this.video.playbackRate = rate; + const speedLabel = this.container.querySelector('#txa-lbl-speed'); // Added null check + if (speedLabel) speedLabel.textContent = rate === 1 ? 'Normal' : rate + 'x'; // Added null check + this.navSettings('main'); + this.saveSettings(); + } + + setupContextMenu() { + const el = (s) => this.container.querySelector(s); + const ctx = el('#txa-ctx'); + if (!ctx) return; + + if (this.detectMobile()) { + this.wrapper.oncontextmenu = (e) => { + if (this.destroyed) return; + e.preventDefault(); + return false; + }; + return; + } + + this.wrapper.oncontextmenu = (e) => { + if (this.destroyed) return; + e.preventDefault(); + const r = this.wrapper.getBoundingClientRect(); + // Collision detection + let left = e.clientX - r.left; + let top = e.clientY - r.top; + + // If menu goes off right edge + if (left + 250 > r.width) left = r.width - 250; + // If menu goes off bottom edge + if (top + 280 > r.height) top = r.height - 280; + + ctx.style.left = Math.max(10, left) + 'px'; + ctx.style.top = Math.max(10, top) + 'px'; + ctx.classList.add('active'); + }; + // Redundant ctxClick removed - now handled by docClick in bindEvents() + /* + this._handlers.ctxClick = (e) => { + if (this.destroyed) return; + if (ctx && !ctx.contains(e.target)) ctx.classList.remove('active'); + }; + document.addEventListener('click', this._handlers.ctxClick); + */ + + // Ensure these el() calls find elements correctly + const bindCtx = (id, fn) => { + const item = el(id); + if (item) item.onclick = () => { + if (ctx) ctx.classList.remove('active'); + fn(); + }; + }; + + bindCtx('#txa-ctx-snap', () => this.takeSnapshot()); + bindCtx('#txa-ctx-url', () => { navigator.clipboard.writeText(location.href); this.showToast('URL Copied!'); }); + bindCtx('#txa-ctx-loop', () => { + this.video.loop = !this.video.loop; + const state = this.video.loop ? 'On' : 'Off'; + const loopStat = el('#txa-loop-stat'); // Added null check + if (loopStat) loopStat.textContent = state; // Added null check + this.showFeedback('text', `Loop Mode: ${state}`); + }); + bindCtx('#txa-ctx-stats', () => this.toggleStatsPanel()); + bindCtx('#txa-ctx-sc', () => this.showShortcuts()); + + // Auto Toggle Handlers + const introSw = el('#txa-sw-intro'); + if (introSw) { + introSw.onchange = (e) => { + this.settings.autoSkipIntro = e.target.checked; + this.saveSettings(); + this.showToast(`Auto Skip Intro: ${e.target.checked ? 'ON' : 'OFF'}`); + }; + } + const nextSw = el('#txa-sw-next'); + if (nextSw) { + nextSw.onchange = (e) => { + this.settings.autoNextEpisode = e.target.checked; + this.saveSettings(); + this.showToast(`Auto Next: ${e.target.checked ? 'ON' : 'OFF'}`); + }; + } + } + + showToast(msg) { + const t = document.createElement('div'); + t.className = 'txa-feedback show'; + t.innerHTML = `${msg}`; + if (this.container) this.container.appendChild(t); // Added null check + setTimeout(() => t.remove(), 2500); + } + showShortcuts() { + // Removed redundant pointer check that might fail on some Windows desktops + + + const o = document.createElement('div'); + o.className = 'txa-shortcuts-panel active'; + o.id = 'txa-sc-panel'; + + const css = ` + .txa-shortcuts-panel { + background: rgba(0, 0, 0, 0.75); backdrop-filter: blur(25px); + z-index: 10000; + display: flex; align-items: center; justify-content: center; + opacity: 0; animation: txafadeIn 0.3s forwards; + } + .txa-shortcuts-content { + width: 900px; max-width: 90%; + background: #0d0d0d; border: 1px solid rgba(255,255,255,0.1); + border-radius: 24px; padding: 40px; + position: relative; box-shadow: 0 30px 60px rgba(0,0,0,0.8); + } + .txa-shortcuts-header { + display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 40px; + } + .txa-sc-title h3 { margin: 0; font-size: 28px; font-weight: 900; color: #fff; letter-spacing: -1px; } + .txa-sc-title p { margin: 8px 0 0; font-size: 14px; color: #64748b; font-weight: 500; } + .txa-sc-close { + width: 44px; height: 44px; border-radius: 14px; border: none; + background: rgba(255,255,255,0.05); color: #fff; cursor: pointer; + transition: 0.3s; display: flex; align-items: center; justify-content: center; + } + .txa-sc-close:hover { background: #ef4444; transform: rotate(90deg); } + + .txa-sc-grid { + display: grid; grid-template-columns: repeat(3, 1fr); gap: 30px; + } + + .txa-sc-column { + display: flex; flex-direction: column; gap: 15px; + } + + .txa-sc-group-label { + font-size: 11px; text-transform: uppercase; letter-spacing: 2px; + color: var(--txa-brand, #8b5cf6); font-weight: 800; opacity: 0.8; + padding-bottom: 10px; border-bottom: 1px solid rgba(255,255,255,0.05); + } + + .txa-sc-item { + display: flex; justify-content: space-between; align-items: center; + padding: 12px 16px; background: rgba(255,255,255,0.02); + border-radius: 12px; border: 1px solid transparent; transition: 0.2s; + } + .txa-sc-item:hover { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.1); } + + .txa-sc-name { color: #cbd5e1; font-size: 14px; font-weight: 500; } + .txa-sc-keys { display: flex; gap: 6px; } + + kbd { + background: #1a1a1a; border: 1px solid #333; border-bottom-width: 3px; + color: #fff; border-radius: 6px; padding: 4px 8px; + font-family: inherit; font-size: 11px; font-weight: 700; + min-width: 20px; text-align: center; + } + .txa-sc-footer { + margin-top: 40px; padding: 20px; border-radius: 16px; + background: linear-gradient(to right, rgba(139,92,246,0.1), transparent); + border: 1px solid rgba(139,92,246,0.2); display: flex; align-items: center; gap: 15px; + } + .txa-sc-footer i { font-size: 20px; color: #8b5cf6; } + .txa-sc-footer p { margin: 0; font-size: 13px; color: #94a3b8; line-height: 1.5; } + `; + + o.innerHTML = ` + +
+
+
+

PHÍM TẮT

+

Trải nghiệm điều khiển điện ảnh với TPhimX Player

+
+ +
+ +
+
+ ĐiềU KHIỂN CHÍNH +
Phát / Dừng
Space
+
Tua lại 10s
J /
+
Tua tiếp 10s
L /
+
Nhảy nhanh
0-9
+
+ +
+ ÂM THANH & SUB +
Tăng âm lượng
+
Giảm âm lượng
+
Tắt tiếng
M
+
Đổi phụ đề
C
+
+ +
+ GIAO DIỆN +
Toàn màn hình
F
+
Thu nhỏ (PiP)
P
+
Rạp chiếu phim
T
+
Đóng Menu
Esc
+
+
+ + +
+ `; + + const closeBtn = o.querySelector('.txa-sc-close'); + if (closeBtn) { + closeBtn.onclick = (e) => { e.stopPropagation(); o.remove(); }; + } + + o.onclick = (e) => { o.remove(); }; + if (this.wrapper) this.wrapper.appendChild(o); + } + + loadInitialSettings() { + const el = (s) => this.container.querySelector(s); + if (this.settings.volume !== undefined) { + this.video.volume = this.settings.volume; + this.video.muted = this.settings.muted || false; + this.updateVolUI(); + } + if (this.settings.playbackRate) { + this.setSpeed(this.settings.playbackRate); + } + + // v6.5.2 - Load Aspect Ratio & Flip + if (this.settings.aspectRatio) { + this.setAspectRatio(this.settings.aspectRatio); + } + if (this.settings.videoFlip) { + this.setVideoFlip(this.settings.videoFlip); + } + + if (this.settings.loop !== undefined) { + this.video.loop = this.settings.loop; + const loopStat = this.container.querySelector('#txa-loop-stat'); + if (loopStat) loopStat.textContent = this.video.loop ? 'On' : 'Off'; + } + if (this.settings.activeSubIdx !== undefined && this.settings.activeSubIdx !== -1) { + setTimeout(() => this.toggleSub(this.settings.activeSubIdx), 500); + } + const cap = el('#txa-captions'); + const s = this.settings; + if (cap && s.subStyle) { + if (s.subStyle.size) { + cap.classList.add('size-' + s.subStyle.size); + this.container.querySelectorAll('[data-subsize]').forEach(o => { + o.classList.toggle('active', o.dataset.subsize === s.subStyle.size); + }); + } + if (s.subStyle.weight) { + cap.classList.add('weight-' + s.subStyle.weight); + this.container.querySelectorAll('[data-subweight]').forEach(o => { + o.classList.toggle('active', o.dataset.subweight === s.subStyle.weight); + }); + } + if (s.subStyle.bg) { + if (s.subStyle.bg !== 'default') cap.classList.add('bg-' + s.subStyle.bg); + this.container.querySelectorAll('[data-subbg]').forEach(o => { + o.classList.toggle('active', o.dataset.subbg === s.subStyle.bg); + }); + } + if (s.subStyle.color) { + cap.classList.add('color-' + s.subStyle.color); + this.container.querySelectorAll('[data-subcolor]').forEach(o => { + o.classList.toggle('active', o.dataset.subcolor === s.subStyle.color); + }); + } + if (s.subStyle.stroke) { + cap.classList.add('stroke-on'); + const strokeToggle = el('#txa-substroke-toggle'); + if (strokeToggle) strokeToggle.checked = true; + const strokePanel = el('#txa-stroke-panel'); + if (strokePanel) strokePanel.classList.add('active'); + } + if (s.subStyle.strokeColor) { + cap.classList.add('stroke-' + s.subStyle.strokeColor); + this.container.querySelectorAll('[data-substroke]').forEach(o => { + if (o.dataset.substroke === s.subStyle.strokeColor) o.classList.add('active'); + else o.classList.remove('active'); + }); + } + } + + // v6.4.0 - Real-time clock initial state + const clockToggle = el('#txa-clock-toggle'); + if (clockToggle) clockToggle.checked = this.settings.showRealTime; + + if (this.settings.clockFormat) { + const lbl = el('#txa-lbl-clock'); + if (lbl) lbl.textContent = this.settings.clockFormat; + this.container.querySelectorAll('[data-clock]').forEach(o => { + o.classList.toggle('active', o.dataset.clock === this.settings.clockFormat); + }); + } + this.updateClockVisibility(); + + // v6.1.0 - Sync external switches + this.updatePeSwitches(); + } + loadSettings() { + const key = 'txa-p-conf'; + let saved = localStorage.getItem(key); + if (!saved) { + // Migration for old keys + const oldKeys = ['txa-txa-cfg', 'txa_player_settings', 'txa-player-v4-settings']; + for (const ok of oldKeys) { + const oldData = localStorage.getItem(ok); + if (oldData) { + localStorage.setItem(key, oldData); + // Cleanup old keys + oldKeys.forEach(k => localStorage.removeItem(k)); + localStorage.removeItem('txa_player_state'); + return JSON.parse(oldData); + } + } + return {}; + } + try { return JSON.parse(saved) || {}; } catch { return {}; } + } + saveSettings() { + if (!this.video || this.destroyed) return; + const el = (s) => this.container.querySelector(s); + const cap = el('#txa-captions'); + const strokeToggle = el('#txa-substroke-toggle'); + + // Extract Aspect Ratio and Flip from classList + const aspectRatio = Array.from(this.video.classList).find(c => c.startsWith('ratio-'))?.replace('ratio-', '') || 'default'; + const videoFlip = Array.from(this.video.classList).find(c => c.startsWith('flip-'))?.replace('flip-', '') || 'normal'; + + const cfg = { + volume: this.video.volume, + muted: this.video.muted, + playbackRate: this.video.playbackRate, + loop: this.video.loop, + activeSubIdx: this.activeSubIdx, + aspectRatio: aspectRatio, + videoFlip: videoFlip, + subStyle: cap ? { + size: Array.from(cap.classList).find(c => c.startsWith('size-'))?.replace('size-', ''), + weight: Array.from(cap.classList).find(c => c.startsWith('weight-'))?.replace('weight-', ''), + bg: Array.from(cap.classList).find(c => c.startsWith('bg-'))?.replace('bg-', '') || 'default', + color: Array.from(cap.classList).find(c => c.startsWith('color-'))?.replace('color-', ''), + stroke: strokeToggle ? strokeToggle.checked : false, + strokeColor: Array.from(cap.classList).find(c => c.startsWith('stroke-'))?.replace('stroke-', '') + } : {}, + captionBottom: cap ? parseInt(cap.style.bottom) : 110, + captionLeft: (cap && cap.style.left) ? parseFloat(cap.style.left) : undefined, + autoSkipIntro: this.settings.autoSkipIntro, + autoNextEpisode: this.settings.autoNextEpisode, + brightness: this.options.brightness || 1, + showRealTime: this.settings.showRealTime, + clockFormat: this.settings.clockFormat + }; + localStorage.setItem('txa-p-conf', JSON.stringify(cfg)); + + // v6.0.0 - Sync to Cloud if saveSettingsUrl is provided + if (this.options.saveSettingsUrl && this.options.csrfToken) { + fetch(this.options.saveSettingsUrl, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'X-CSRF-TOKEN': this.options.csrfToken + }, + body: JSON.stringify({ settings: cfg }) + }).catch(e => console.warn('[TXAPlayer] Settings sync failed:', e)); + } + } + + takeSnapshot() { + try { + const c = document.createElement('canvas'); + c.width = this.video.videoWidth; + c.height = this.video.videoHeight; + const ctx = c.getContext('2d'); + + // Draw video frame + ctx.drawImage(this.video, 0, 0); + + const watermark = `TPHIMX Player - ${TXA_VERSION} `; + const fontSize = Math.max(18, c.height * 0.03); + ctx.font = `bold ${fontSize}px Inter, sans - serif`; + ctx.fillStyle = 'rgba(255, 255, 255, 0.6)'; + ctx.textAlign = 'right'; + ctx.textBaseline = 'bottom'; + ctx.shadowColor = 'rgba(0, 0, 0, 0.7)'; + ctx.shadowBlur = 6; + ctx.fillText(watermark, c.width - 25, c.height - 20); + + const a = document.createElement('a'); + a.download = `tphimx - snapshot - ${Date.now()}.png`; + a.href = c.toDataURL('image/png', 1.0); + a.click(); + this.showToast('Snapshot 4K Captured!'); + } catch (e) { + console.error('TXAPlayer Snapshot Error:', e); + if (e.name === 'SecurityError') { + this.showToast('Lỗi bảo mật: Không thể chụp ảnh từ máy chủ này (CORS)'); + } else { + this.showToast('Không thể chụp ảnh màn hình lúc này'); + } + } + } + + toggleView(v) { + if (v === 'shortcuts') this.showShortcuts(); + if (v === 'stats') this.toggleStatsPanel(); + } + + toggleStatsPanel() { + const panel = this.container.querySelector('#txa-stats-panel'); + if (!panel) return; + + if (panel.classList.contains('active')) { + panel.classList.remove('active'); + if (this._statsInterval) { clearInterval(this._statsInterval); this._statsInterval = null; } + return; + } + + panel.classList.add('active'); + this.updateStatsPanel(); + + // Update every 1s + this._statsInterval = setInterval(() => { + if (this.destroyed || !panel.classList.contains('active')) { + clearInterval(this._statsInterval); + this._statsInterval = null; + return; + } + this.updateStatsPanel(); + }, 1000); + + // Close button + const closeBtn = this.container.querySelector('#txa-stats-close'); + if (closeBtn) closeBtn.onclick = () => this.toggleStatsPanel(); + } + + updateStatsPanel() { + const grid = this.container.querySelector('#txa-stats-grid'); + if (!grid || !this.video) return; + const v = this.video; + const fmt = window.txaformat; + + // Gather stats + const resolution = `${v.videoWidth || '?'}×${v.videoHeight || '?'} `; + const currentTime = this.formatTime(v.currentTime); + const duration = this.formatTime(v.duration); + const ahead = (v.buffered && v.buffered.length > 0) ? (v.buffered.end(v.buffered.length - 1) - v.currentTime) : 0; + + // Fast DOM Update + const html = ` + < div class="txa-stat-item" >
Resolution
${resolution}
+
Speed
${v.playbackRate}x
+
Progress
${currentTime} / ${duration}
+
Buffer
${ahead.toFixed(1)}s ahead
+
Volume
${v.muted ? 'Muted' : Math.round(v.volume * 100) + '%'}
+
Player
TXAPlayer ${TXA_VERSION}
+ `; + + if (this._lastStatsHTML !== html) { + grid.innerHTML = html; + this._lastStatsHTML = html; + } + } + toggleNativePiP() { document.pictureInPictureElement ? document.exitPictureInPicture() : this.video.requestPictureInPicture(); } + + destroy() { + this.destroyed = true; + + if (this._devCheck) clearInterval(this._devCheck); + if (this._statsInterval) clearInterval(this._statsInterval); + if (this._autoNextCountdownInterval) clearInterval(this._autoNextCountdownInterval); + + // Stop playback & Cleanup Video + if (this.video) { + try { + this.video.ontimeupdate = null; // Unbind immediately + this.video.pause(); + this.video.src = ""; + this.video.load(); + this.video.remove(); + } catch (e) { } + } + + // Destroy dashjs + if (this.dashPlayer) { + try { this.dashPlayer.destroy(); } catch (e) { } + this.dashPlayer = null; + } + + // Destroy Hls + if (this.hls) { + try { this.hls.destroy(); } catch (e) { } + this.hls = null; + } + + // Remove global listeners + if (this._handlers) { + if (this._handlers.winMouseMove) window.removeEventListener('mousemove', this._handlers.winMouseMove); + if (this._handlers.winMouseUp) window.removeEventListener('mouseup', this._handlers.winMouseUp); + if (this._handlers.winKeyDown) window.removeEventListener('keydown', this._handlers.winKeyDown); + if (this._handlers.docClick) document.removeEventListener('click', this._handlers.docClick); + if (this._handlers.docFSChange) document.removeEventListener('fullscreenchange', this._handlers.docFSChange); + if (this._handlers.dragMouseMove) window.removeEventListener('mousemove', this._handlers.dragMouseMove); + if (this._handlers.dragMouseUp) window.removeEventListener('mouseup', this._handlers.dragMouseUp); + if (this._handlers.ctxClick) document.removeEventListener('click', this._handlers.ctxClick); + if (this._handlers.theaterEscape) window.removeEventListener('keydown', this._handlers.theaterEscape); // v5.8.0 + } + + if (this.feedbackTimer) clearTimeout(this.feedbackTimer); + if (this.seekDebounce) clearTimeout(this.seekDebounce); + if (this._clickTimer) clearTimeout(this._clickTimer); + if (this._progressSaveInterval) clearInterval(this._progressSaveInterval); // v5.8.0 - Clear progress save interval + + // v5.8.0 - Stop ambient light animation + this.stopAmbientLight(); + + // v5.8.0 - Save final progress + this.saveWatchProgress(); + + // Clear UI + if (this.container) this.container.innerHTML = ""; + + console.log("TXAPlayer: Destroyed instance"); + } + + detectDevTools() { + // Commented out as requested for development + /* + if (this.options.isAdmin) return; + if (this.detectMobile()) return; + + const threshold = 160; + this._devCheck = setInterval(() => { + if (this.destroyed) return; + + const start = performance.now(); + debugger; + const end = performance.now(); + + if (end - start > threshold) { + this.tamperAlert(true); + } else { + this.tamperAlert(false); + } + }, 2000); + */ + } + + tamperAlert(isBlocked) { + const overlay = this.container.querySelector('#txa-tamper'); + if (!overlay || this.isTamperPermanent) return; + + if (isBlocked) { + // Once detected, it becomes permanent + this.isTamperPermanent = true; + overlay.classList.remove('txa-hidden'); + + console.warn('[TXA] Tamper detected! Locking player.'); + + // Aggressively stop video + if (this.video) { + try { + this.video.pause(); + this.video.muted = true; + this.video.removeAttribute('src'); // Remove src attr + this.video.load(); + } catch (e) { } + } + + if (this.hls) { + try { + this.hls.stopLoad(); + this.hls.detachMedia(); + this.hls.destroy(); + } catch (e) { } + this.hls = null; + } + + if (this.dashPlayer) { + try { + this.dashPlayer.reset(); + this.dashPlayer.destroy(); + } catch (e) { } + this.dashPlayer = null; + } + + // Disable interaction + if (this.wrapper) { + this.wrapper.style.pointerEvents = 'none'; + // Remove the opacity 0.1 to keep it "sang lên" + this.wrapper.style.filter = 'grayscale(1) brightness(0.5)'; + } + overlay.style.pointerEvents = 'all'; // Allow clicking reload button + overlay.style.opacity = '1'; + overlay.classList.remove('txa-hidden'); + + } else { + // Safe state + overlay.classList.add('txa-hidden'); + if (this.wrapper) { + this.wrapper.style.pointerEvents = ''; + this.wrapper.style.filter = ''; + } + } + } + + // ============================================================ + // v5.8.0 NEW FEATURES + // ============================================================ + + /** + * Theater Mode - Expand player to full screen overlay (not browser fullscreen) + */ + toggleTheaterMode() { + this.isTheaterMode = !this.isTheaterMode; + const btn = this.container.querySelector('#txa-theater'); + + if (this.isTheaterMode) { + this.wrapper.classList.add('theater-mode'); + document.body.classList.add('theater-mode-active'); + if (btn) btn.classList.add('mode-active'); + this.showFeedback('text', 'Theater Mode: On'); + } else { + this.wrapper.classList.remove('theater-mode'); + document.body.classList.remove('theater-mode-active'); + if (btn) btn.classList.remove('mode-active'); + this.showFeedback('text', 'Theater Mode: Off'); + } + } + + /** + * Cinema Mode - Ambient light effect that extracts colors from video + */ + toggleCinemaMode() { + this.isCinemaMode = !this.isCinemaMode; + const btn = this.container.querySelector('#txa-cinema'); + + if (this.isCinemaMode) { + this.wrapper.classList.add('cinema-mode'); + this.container.classList.add('cinema-active'); + if (btn) btn.classList.add('mode-active'); + this.startAmbientLight(); + this.showFeedback('text', 'Ánh sáng: Bật'); + } else { + this.wrapper.classList.remove('cinema-mode'); + this.container.classList.remove('cinema-active'); + if (btn) btn.classList.remove('mode-active'); + this.stopAmbientLight(); + this.showFeedback('text', 'Ánh sáng: Tắt'); + } + } + + startAmbientLight() { + const canvas = this.container.querySelector('#txa-ambient'); + if (!canvas) return; + + const ctx = canvas.getContext('2d'); + canvas.width = 32; // Low resolution for blur effect + canvas.height = 18; + + this._ambientFrame = () => { + if (!this.isCinemaMode || this.destroyed) return; + if (this.video && !this.video.paused && this.video.readyState >= 2) { + try { + ctx.drawImage(this.video, 0, 0, canvas.width, canvas.height); + } catch (e) { + // Cross-origin video might fail, just ignore + } + } + requestAnimationFrame(this._ambientFrame); + }; + requestAnimationFrame(this._ambientFrame); + } + + stopAmbientLight() { + this._ambientFrame = null; + } + + /** + * Speed Preview - Long press to fast forward at 2x speed + */ + startSpeedPreview() { + if (this.isSpeedPreview) return; + this.isSpeedPreview = true; + this.originalSpeed = this.video.playbackRate; + this.video.playbackRate = 2; + + const indicator = this.container.querySelector('#txa-speed-indicator'); + if (indicator) indicator.classList.add('show'); + if (this.wrapper) this.wrapper.classList.add('hide-controls'); + + // Play if paused + if (this.video.paused) { + this._wasPausedBeforePreview = true; + this.video.play().catch(() => { }); + } + } + + stopSpeedPreview() { + if (!this.isSpeedPreview) return; + this.isSpeedPreview = false; + this.video.playbackRate = this.originalSpeed || 1; + + const indicator = this.container.querySelector('#txa-speed-indicator'); + if (indicator) indicator.classList.remove('show'); + if (this.wrapper) this.wrapper.classList.remove('hide-controls'); + + // Pause if was paused before + if (this._wasPausedBeforePreview) { + this.video.pause(); + this._wasPausedBeforePreview = false; + } + } + + /** + * Watch Progress Resume - Save and restore watch position + */ + getVideoId() { + // Generate unique ID based on movie ID and episode info for stability + const base = this.options.movieId || this.options.title || 'unknown'; + const ep = this.options.episodeSlug || this.options.episodeName || 'single'; + return 'txa-progress-' + this.hashCode(base + '-' + ep); + } + + hashCode(str) { + let hash = 0; + for (let i = 0; i < str.length; i++) { + const char = str.charCodeAt(i); + hash = ((hash << 5) - hash) + char; + hash = hash & hash; + } + return Math.abs(hash).toString(36); + } + + saveWatchProgress(useApi = false) { + if (!this.video || this.video.duration < 10) return; + + const ct = this.video.currentTime; + const dur = this.video.duration; + const opt = this.options; + + // 1. App LocalStorage Sync (ContinueWatching) + if (window.ContinueWatching && opt.movieSlug) { + window.ContinueWatching.save( + opt.movieSlug, + opt.title.split(' - ')[0], // Assume Title is "Movie - Episode" + opt.movieThumb, + opt.episodeSlug, + opt.title.split(' - ')[1]?.replace('Tập ', '') || '1', + ct, + dur, + opt.epCount || 1 + ); + } + + // 2. App API Sync (Database) + if (useApi && opt.saveUrl) { + fetch(opt.saveUrl, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + ...(opt.csrfToken ? { 'X-CSRF-TOKEN': opt.csrfToken } : {}) + }, + body: JSON.stringify({ + movieSlug: opt.movieSlug, + movieName: opt.title?.split(' - ')[0], + movieThumb: opt.movieThumb, + episodeName: opt.episodeName, + currentTime: ct, + duration: dur, + // Legacy support + movie_id: opt.movieId, + episode_id: opt.episodeId, + current_time: ct + }) + }).catch(e => console.warn('Player: Progress sync failed', e)); + } + + // 3. Player Internal Backup (Fallback) + if (ct > 10 && ct < dur - 30) { + localStorage.setItem(this.getVideoId(), JSON.stringify({ + time: ct, + duration: dur, + timestamp: Date.now() + })); + } + } + + async checkWatchResume() { + if (this.resumeShown) return; + const opt = this.options; + let resumeTime = 0; + let duration = 0; + + // Try API first (Best source of truth) + if (opt.restoreUrl && opt.movieId) { + try { + const res = await fetch(opt.restoreUrl); + const data = await res.json(); + + if (data && data.current_time > 10) { + // Check if same episode (ID or Name/Slug match for multi-server) + // Relaxed Match: If restoreUrl is specific, we trust the data + const epIdMatch = (data.episode_id == opt.episodeId); + + // Normalize "Tập 01" -> "1", "01" -> "1" + const norm = (s) => (s || '').toString().toLowerCase().replace('tập ', '').replace(/^0+/, '').trim(); + + const epNameMatch = norm(data.episode_name) === norm(opt.episodeName); + // Slug match is usually safer but relies on consistent slugs + const slugMatch = (data.episode_slug && opt.episodeSlug && data.episode_slug === opt.episodeSlug); + + if (epIdMatch || epNameMatch || slugMatch || opt.restoreUrl.includes(opt.episodeId)) { + resumeTime = data.current_time; + duration = data.duration || 0; + } + } + } catch (e) { console.warn('Player: Restore API failed', e); } + } + + // Fallback to Player's internal LocalStorage + if (!resumeTime) { + const saved = localStorage.getItem(this.getVideoId()); + if (saved) { + try { + const data = JSON.parse(saved); + // Check if valid timestamp (within 30 days) + if (Date.now() - data.timestamp < 30 * 24 * 60 * 60 * 1000) { + resumeTime = data.time; + duration = data.duration; + } + } catch (e) { } + } + } + + if (resumeTime > 15) { + this.resumeShown = true; + const timeStr = this.formatTime(resumeTime, duration >= 3600); + + // MOBILE: Use SweetAlert2 (Premium & Out-of-player) + // Ensure Swal is available, otherwise fallback to standard overlay + if (this.detectMobile() && typeof Swal !== 'undefined') { + Swal.fire({ + title: 'Tiếp tục xem?', + text: `Hệ thống ghi nhận bạn đã xem đến ${timeStr}. Bạn có muốn tiếp tục từ đây không ? `, + icon: 'question', + showCancelButton: true, + confirmButtonText: 'Có, tiếp tục', + cancelButtonText: 'Xem từ đầu', + background: '#141414', + color: '#fff', + confirmButtonColor: '#8b5cf6', + cancelButtonColor: '#334155', + heightAuto: false, + backdrop: `rgba(0, 0, 0, 0.6)`, + allowOutsideClick: false // Prevent accidental close + }).then((result) => { + if (result.isConfirmed) { + this.safeSeek(resumeTime); + this.video.play().catch(() => { }); + this.showFeedback('text', `Đã tiếp tục từ ${timeStr} `); + } else if (result.dismiss === Swal.DismissReason.cancel) { + localStorage.removeItem(this.getVideoId()); + // Don't auto play if cancelled, let user decide + } + }); + return; + } + + // DESKTOP or Mobile-Fallback: Classic Overlay + const overlay = this.container.querySelector('#txa-resume'); + const timeEl = this.container.querySelector('#txa-resume-time'); + + if (overlay && timeEl) { + timeEl.textContent = timeStr; + + // Ensure overlay is visible + overlay.style.display = 'flex'; + // Trigger animation + requestAnimationFrame(() => { + overlay.classList.add('show'); + }); + + // Auto-hide after 30s if no interaction (increased from 15s) + const autoHideTimer = setTimeout(() => { + if (overlay.classList.contains('show')) { + overlay.classList.remove('show'); + setTimeout(() => overlay.style.display = 'none', 500); + } + }, 30000); + + const handleYes = (e) => { + if (e) e.stopPropagation(); + clearTimeout(autoHideTimer); + this.safeSeek(resumeTime); + overlay.classList.remove('show'); + setTimeout(() => overlay.style.display = 'none', 500); + this.video.play().catch(() => { }); + this.showFeedback('text', `Đã tiếp tục từ ${timeStr} `); + }; + + const handleNo = (e) => { + if (e) e.stopPropagation(); + clearTimeout(autoHideTimer); + overlay.classList.remove('show'); + setTimeout(() => overlay.style.display = 'none', 500); + localStorage.removeItem(this.getVideoId()); + }; + + const yesBtn = overlay.querySelector('#txa-resume-yes'); + const noBtn = overlay.querySelector('#txa-resume-no'); + + if (yesBtn) { + yesBtn.onclick = handleYes; + yesBtn.ontouchstart = (e) => { e.preventDefault(); handleYes(e); }; + } + if (noBtn) { + noBtn.onclick = handleNo; + noBtn.ontouchstart = (e) => { e.preventDefault(); handleNo(e); }; + } + } + } + } + + /** + * Double-tap Ripple Effect - Visual feedback for double-tap seek + */ + createRipple(x, y) { + const ripple = document.createElement('div'); + ripple.className = 'txa-ripple'; + ripple.style.left = (x - 50) + 'px'; + ripple.style.top = (y - 50) + 'px'; + this.wrapper.appendChild(ripple); + + // Remove after animation + setTimeout(() => ripple.remove(), 600); + } + + /** + * Setup new feature event bindings + */ + setupNewFeatures() { + + const el = (s) => this.container.querySelector(s); + + // Theater Mode Button + const theaterBtn = el('#txa-theater'); + if (theaterBtn) { + theaterBtn.onclick = () => this.toggleTheaterMode(); + } + + // Cinema Mode Button + const cinemaBtn = el('#txa-cinema'); + if (cinemaBtn) { + cinemaBtn.onclick = () => this.toggleCinemaMode(); + } + + // Speed Preview - Long press on video + let speedTimeout = null; + const startSpeed = () => { + speedTimeout = setTimeout(() => { + this.startSpeedPreview(); + }, 500); + }; + const endSpeed = () => { + clearTimeout(speedTimeout); + this.stopSpeedPreview(); + }; + + if (this.detectMobile()) { + this.video.addEventListener('mousedown', startSpeed); + this.video.addEventListener('mouseup', endSpeed); + this.video.addEventListener('mouseleave', endSpeed); + } + + // Touch support for Speed Preview + this.video.addEventListener('touchstart', startSpeed, { passive: true }); + this.video.addEventListener('touchend', endSpeed); + this.video.addEventListener('touchcancel', endSpeed); + + // Watch Resume - Check on video ready + this.video.addEventListener('loadedmetadata', () => { + this.checkWatchResume(); + }); + + // Save progress periodically (LocalStorage: 10s, API: 30s) + let lastApiSave = Date.now(); + this._progressSaveInterval = setInterval(() => { + if (!this.destroyed && this.video && !this.video.paused) { + const now = Date.now(); + const useApi = (now - lastApiSave) >= 30000; + this.saveWatchProgress(useApi); + if (useApi) lastApiSave = now; + } + }, 10000); + + // Save on pause and before unload + this.video.addEventListener('pause', () => this.saveWatchProgress(true)); + window.addEventListener('beforeunload', () => this.saveWatchProgress(true)); + + // Ripple effect on double-tap zones + const addRippleToZone = (zone, seekFn) => { + if (!zone) return; + zone.addEventListener('dblclick', (e) => { + const rect = this.wrapper.getBoundingClientRect(); + this.createRipple(e.clientX - rect.left, e.clientY - rect.top); + }); + }; + + addRippleToZone(el('#txa-zone-l')); + addRippleToZone(el('#txa-zone-r')); + + // Escape key to exit Theater Mode + this._handlers.theaterEscape = (e) => { + if (e.key === 'Escape' && this.isTheaterMode) { + this.toggleTheaterMode(); + } + }; + window.addEventListener('keydown', this._handlers.theaterEscape); + + // v6.3.0 - Screen Width Warning (<100px) + const checkWidth = () => { + if (window.innerWidth < 100 && !window._txa_too_small) { + window._txa_too_small = true; + // Hide header/nav via CSS first just in case document.write is blocked or delayed + const header = document.querySelector('.header'); + if (header) header.style.display = 'none'; + + document.open(); + document.write(` + < html > + + TPhimX - Màn hình quá nhỏ + + + +
+ +

MÀN HÌNH QUÁ NHỎ

+

Vui lòng phóng to trình duyệt hoặc xoay ngang điện thoại để có trải nghiệm xem phim tốt nhất tại TPhimX.

+
+ + + diff --git a/src/components/Header.jsx b/src/components/Header.jsx new file mode 100644 index 0000000000000000000000000000000000000000..c2846816c0ecd017fe948434989f4d23cf0df2e8 --- /dev/null +++ b/src/components/Header.jsx @@ -0,0 +1,100 @@ +import { useState, useEffect } from 'react'; +import { Search, Menu, X } from 'lucide-react'; + +const navLinks = [ + { href: '/', label: 'Trang chủ' }, + { href: '/danh-sach/phim-le', label: 'Phim Lẻ' }, + { href: '/danh-sach/phim-bo', label: 'Phim Bộ' }, + { href: '/danh-sach/hoat-hinh', label: 'Hoạt hình' }, +]; + +export default function Header() { + const [scrolled, setScrolled] = useState(false); + const [menuOpen, setMenuOpen] = useState(false); + const [query, setQuery] = useState(''); + const [mounted, setMounted] = useState(false); + + useEffect(() => { + setMounted(true); + const onScroll = () => setScrolled(window.scrollY > 20); + window.addEventListener('scroll', onScroll); + return () => window.removeEventListener('scroll', onScroll); + }, []); + + const handleSearch = (e) => { + e.preventDefault(); + if (query.trim()) { + window.location.href = `/tim-kiem?q=${encodeURIComponent(query.trim())}`; + } + }; + + if (!mounted) { + return ( +
+
+
TPHIMX
+
+
+ ); + } + + return ( +
+ {/* Row 1: Logo + Search + Auth */} +
+ +
+ TPHIMX +
+
+ +
+ + setQuery(e.target.value)} + className="flex-1 bg-transparent text-xs font-medium text-white outline-none placeholder:text-gray-500" + /> + + +
+ +
+
+ + {/* Row 2: Nav Bar */} + + + {/* Mobile Menu */} + {menuOpen && ( +
+ {navLinks.map((link) => ( + setMenuOpen(false)}> + {link.label} + + + ))} + setMenuOpen(false)}>Diễn viên + setMenuOpen(false)}>Lịch chiếu +
+ )} +
+ ); +} diff --git a/src/components/HeroBanner.jsx b/src/components/HeroBanner.jsx new file mode 100644 index 0000000000000000000000000000000000000000..23faf1ccdc4666814a0d6b3eafbe5d831829c9fd --- /dev/null +++ b/src/components/HeroBanner.jsx @@ -0,0 +1,223 @@ +import { useState, useEffect, useCallback } from 'react'; +import { Play, Info, ChevronLeft, ChevronRight } from 'lucide-react'; +import { formatImageUrl } from '../lib/image'; + +export default function HeroBanner({ movies = [] }) { + const [active, setActive] = useState(0); + const [progress, setProgress] = useState(0); + const [favorites, setFavorites] = useState([]); + + useEffect(() => { + fetch('/api/user/favorite') + .then(res => res.json()) + .then(data => { + if (data && data.favorites) { + setFavorites(data.favorites.map(f => f.slug)); + } + }) + .catch(() => {}); + }, []); + + const handleFavoriteClick = async (m) => { + try { + const res = await fetch('/api/user/favorite', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + movieSlug: m.slug, + movieName: m.name, + movieThumb: m.thumb_url || m.poster_url + }) + }); + const data = await res.json(); + if (res.ok) { + if (window.txatoast) { + window.txatoast.success(data.message); + } + if (data.action === 'added') { + setFavorites(prev => [...prev, m.slug]); + } else { + setFavorites(prev => prev.filter(slug => slug !== m.slug)); + } + } else { + if (window.txatoast) { + window.txatoast.error(data.error || 'Vui lòng đăng nhập!'); + } + } + } catch (e) { + if (window.txatoast) { + window.txatoast.error('Không thể thực hiện lúc này!'); + } + } + }; + + const heroMovies = movies.slice(0, 5); + + const next = useCallback(() => { + setActive((prev) => (prev + 1) % heroMovies.length); + setProgress(0); + }, [heroMovies.length]); + + const prev = useCallback(() => { + setActive((prev) => (prev - 1 + heroMovies.length) % heroMovies.length); + setProgress(0); + }, [heroMovies.length]); + + useEffect(() => { + if (heroMovies.length <= 1) return; + const interval = 100; // 0.1s + const step = 100 / (6000 / interval); // 6s per slide + + const timer = setInterval(() => { + setProgress((p) => { + if (p >= 100) { + next(); + return 0; + } + return p + step; + }); + }, interval); + + return () => clearInterval(timer); + }, [heroMovies.length, next]); + + if (!heroMovies.length) return null; + const movie = heroMovies[active]; + const bg = formatImageUrl(movie.poster_url || movie.thumb_url); + const year = movie.year || (movie.modified?.time ? new Date(movie.modified.time).getFullYear() : ''); + + return ( +
+ {/* Background Slides with Stylized Text */} + {heroMovies.map((m, i) => ( +
+ {/* Main Background Image */} +
+ + {/* Stylized Background Text Layer (The "Thu Hút Mãnh Liệt" style in bg) */} +
+

+ {m.name} +

+
+
+ ))} + + {/* Gradients for cinematic feel */} +
+
+ +
+
+

+ + {movie.name} + +

+ + {movie.origin_name && ( +

{movie.origin_name}

+ )} + + {/* Badges Row */} +
+
+ {movie.tmdb?.vote_average || (8.5 + (movie.slug.length % 15) / 10).toFixed(1)} +
+ + {movie.quality || 'Full HD'} + + + {year} + + {movie.tmdb?.season && ( + + Phần {movie.tmdb.season} + + )} + + {movie.episode_current?.toLowerCase().includes('hoàn tất') ? 'Hoàn tất' : `Tập ${movie.episode_current?.match(/\d+/)?.[0] || '??'}`} + {movie.episode_total && movie.episode_total !== '1' && ` / ${movie.episode_total}`} + +
+ + {/* Categories Row */} +
+ {movie.category?.slice(0, 4).map(cat => ( + + {cat.name} + + ))} +
+ +

+ {movie.content?.replace(/<[^>]*>/g, '') || movie.description || ''} +

+ +
+ + + + + + + + + +
+
+ + {/* Thumbnails Navigation (Right side row) */} +
+ {heroMovies.map((m, i) => ( +
{ setActive(i); setProgress(0); }} + className={`group relative h-16 w-24 cursor-pointer overflow-hidden rounded-xl border-2 transition-all duration-500 ${ + i === active ? 'border-primary scale-110 shadow-[0_0_20px_rgba(229,9,20,0.5)]' : 'border-white/10 opacity-50 hover:opacity-100' + }`} + > + nav + {i === active && ( +
+ )} +
+ ))} +
+ + {/* Mobile Navigation */} +
+ {heroMovies.map((_, i) => ( +
{ setActive(i); setProgress(0); }} + className={`h-1.5 rounded-full transition-all duration-500 ${i === active ? 'w-8 bg-primary' : 'w-2 bg-white/20'}`} + /> + ))} +
+
+
+ ); +} diff --git a/src/components/HomeSectionsLoader.jsx b/src/components/HomeSectionsLoader.jsx new file mode 100644 index 0000000000000000000000000000000000000000..a7835b8480aae3f17258ec700aa8a3e94d3d0915 --- /dev/null +++ b/src/components/HomeSectionsLoader.jsx @@ -0,0 +1,147 @@ +import { useEffect, useState, useRef } from 'react'; +import MovieSection from './MovieSection.jsx'; +import CombinedRegionSection from './CombinedRegionSection.jsx'; + +const SECTION_CONFIGS = [ + { type: 'newest', title: 'Phim mới cập nhật', href: '/danh-sach/phim-moi-cap-nhat' }, + { type: 'series', title: 'Phim bộ đặc sắc', href: '/danh-sach/phim-bo' }, + { type: 'single', title: 'Phim Điện Ảnh Mới Coóng', href: '/danh-sach/phim-le' }, + { category: 'phim-chieu-rap', title: 'Mãn Nhãn với Phim Chiếu Rạp', href: '/the-loai/phim-chieu-rap' }, + { type: 'cartoon', title: 'Thế giới hoạt hình', href: '/danh-sach/hoat-hinh' }, + { country: 'trung-quoc', title: 'Phim Trung Quốc mới', href: '/quoc-gia/trung-quoc' }, + { country: 'han-quoc', title: 'Phim Hàn Quốc mới', href: '/quoc-gia/han-quoc' }, + { country: 'au-my', title: 'Phim Âu-Mỹ mới', href: '/quoc-gia/au-my' } +]; + +export default function HomeSectionsLoader() { + const [loadedSections, setLoadedSections] = useState([]); + const [loading, setLoading] = useState(false); + const [currentIndex, setCurrentIndex] = useState(0); + const loaderRef = useRef(null); + + const fetchSectionData = async (config) => { + try { + const params = new URLSearchParams(); + if (config.type) params.append('type', config.type); + if (config.category) params.append('category', config.category); + if (config.country) params.append('country', config.country); + + const res = await fetch(`/api/movies?${params.toString()}`); + if (!res.ok) throw new Error('Failed to fetch movies'); + const data = await res.json(); + return data.items || []; + } catch (e) { + console.error(`[HomeSectionsLoader] Error loading ${config.title}:`, e); + return []; + } + }; + + // Tải danh mục tiếp theo khi cuộn xuống + const loadNextSection = async () => { + if (loading || currentIndex >= SECTION_CONFIGS.length) return; + + setLoading(true); + const config = SECTION_CONFIGS[currentIndex]; + const movies = await fetchSectionData(config); + + if (movies.length > 0) { + setLoadedSections(prev => { + if (prev.some(s => s.title === config.title)) return prev; + return [...prev, { ...config, movies }]; + }); + } + + setCurrentIndex(prev => prev + 1); + setLoading(false); + }; + + // Lần đầu tải 2 Section đầu tiên để lấp đầy khung nhìn ngay lập tức + useEffect(() => { + let active = true; + + const initLoad = async () => { + setLoading(true); + + // Load Section 1 + const config1 = SECTION_CONFIGS[0]; + const movies1 = await fetchSectionData(config1); + if (active && movies1.length > 0) { + setLoadedSections([{ ...config1, movies: movies1 }]); + } + + // Load Section 2 + const config2 = SECTION_CONFIGS[1]; + const movies2 = await fetchSectionData(config2); + if (active && movies2.length > 0) { + setLoadedSections(prev => [...prev, { ...config2, movies: movies2 }]); + } + + if (active) { + setCurrentIndex(2); + setLoading(false); + } + }; + + initLoad(); + + return () => { + active = false; + }; + }, []); + + // Lắng nghe Intersection Observer để kích hoạt tải Section tiếp theo khi cuộn xuống gần cuối + useEffect(() => { + if (!loaderRef.current || currentIndex >= SECTION_CONFIGS.length || loading) return; + + const observer = new IntersectionObserver((entries) => { + const target = entries[0]; + if (target.isIntersecting && !loading) { + loadNextSection(); + } + }, { + rootMargin: '350px', // Bắt đầu tải ngầm trước khi cuộn tới 350px để tạo trải nghiệm bất tận mượt mà + threshold: 0.1 + }); + + observer.observe(loaderRef.current); + return () => observer.disconnect(); + }, [currentIndex, loading]); + + const normalSections = loadedSections.filter(sec => !['trung-quoc', 'han-quoc', 'au-my'].includes(sec.country)); + const regionSections = loadedSections.filter(sec => ['trung-quoc', 'han-quoc', 'au-my'].includes(sec.country)); + + return ( +
+ {normalSections.map((sec, i) => ( + + ))} + + {regionSections.length > 0 && ( + + )} + + {/* Điểm kích hoạt cuộn tải Section */} + {currentIndex < SECTION_CONFIGS.length && ( +
+ {loading && ( + <> +
+ {/* Vòng quay hiệu ứng Neon cao cấp */} +
+
+
+ + Đang tải thêm danh mục phim... + + + )} +
+ )} +
+ ); +} diff --git a/src/components/MovieCard.jsx b/src/components/MovieCard.jsx new file mode 100644 index 0000000000000000000000000000000000000000..e8c9bea994638db5b038e940316c390401174f4a --- /dev/null +++ b/src/components/MovieCard.jsx @@ -0,0 +1,127 @@ +import { Play, Star, Clock, Calendar } from 'lucide-react'; +const IMAGE_BASE_URL = 'https://phimimg.com'; + +const formatImageUrl = (url) => { + if (!url) return ''; + if (url.startsWith('http')) return url; + const cleanUrl = url.startsWith('/') ? url : `/${url}`; + return `${IMAGE_BASE_URL}${cleanUrl}`; +}; + +export default function MovieCard({ movie }) { + if (!movie) return null; + + const poster = formatImageUrl(movie.poster_url); + const thumb = formatImageUrl(movie.thumb_url || movie.poster_url); + const year = movie.year || (movie.modified?.time ? new Date(movie.modified.time).getFullYear() : ''); + const quality = movie.quality || 'HD'; + const lang = movie.lang?.toLowerCase() || 'vietsub'; + + const isVietsub = lang.includes('vietsub') || lang.includes('pđ') || lang.includes('phụ đề') || lang === 'vietsub'; + const isThuyetMinh = lang.includes('thuyết minh') || lang.includes('tm'); + + const isSingle = movie.type === 'single' || movie.type === 'movie'; + const epNum = movie.episode_current?.match(/\d+/)?.[0]; + const isFull = movie.episode_current?.toLowerCase().includes('hoàn tất') || + (movie.episode_current === movie.episode_total && movie.episode_total !== '1' && movie.episode_total !== undefined); + + const statusLabel = isFull ? 'Hoàn tất' : (epNum ? `Tập ${epNum}` : movie.episode_current); + + // Deterministic rating based on slug to avoid hydration mismatch + const getRating = (slug) => { + if (!slug) return "8.5"; + let hash = 0; + for (let i = 0; i < slug.length; i++) hash = slug.charCodeAt(i) + ((hash << 5) - hash); + return (8.5 + (Math.abs(hash) % 15) / 10).toFixed(1); + }; + const rating = movie.tmdb?.vote_average || getRating(movie.slug); + + return ( +
${movie.name}
${movie.content?.replace(/<[^>]*>/g, '')}
`} + > +
+ {/* Main Background Image */} + {movie.name} + + {/* Overlay Gradients */} +
+
+ + {/* Quality Badge (Top Left) */} +
+ + {quality} + +
+ + {/* Rating Badge (Top Right) */} +
+
+ + {rating} +
+ {year && ( + + {year} + + )} +
+ + {/* Small Poster Thumbnail Overlay (Bottom Left) */} +
+ mini +
+ + {/* Bottom Status Badges (Vietsub | Thuyết Minh | Status) */} +
+
+ {isVietsub && ( + + Vietsub + + )} + {isThuyetMinh && ( + + Thuyết Minh + + )} + {isSingle ? ( + + FULL + + ) : ( + statusLabel && ( + + {statusLabel} + + ) + )} +
+
+
+ +
+

+ {movie.name} +

+
+

{movie.origin_name}

+ {statusLabel && ( + + {statusLabel} + + )} +
+
+
+ ); +} diff --git a/src/components/MovieSection.jsx b/src/components/MovieSection.jsx new file mode 100644 index 0000000000000000000000000000000000000000..d021c4776b91881e53a813b5f7391e3a63433f7e --- /dev/null +++ b/src/components/MovieSection.jsx @@ -0,0 +1,92 @@ +import { useEffect, useRef, useState } from 'react'; +import { ChevronLeft, ChevronRight } from 'lucide-react'; +import MovieCard from './MovieCard'; + +export default function MovieSection({ title, movies = [], href = '#' }) { + const [visible, setVisible] = useState(true); + const sectionRef = useRef(null); + const scrollRef = useRef(null); + const [showLeft, setShowLeft] = useState(false); + const [showRight, setShowRight] = useState(true); + + useEffect(() => { + const observer = new IntersectionObserver( + ([entry]) => { + if (entry.isIntersecting) { + setVisible(true); + observer.unobserve(entry.target); + } + }, + { threshold: 0.1 } + ); + if (sectionRef.current) observer.observe(sectionRef.current); + return () => observer.disconnect(); + }, []); + + const handleScroll = () => { + if (!scrollRef.current) return; + const { scrollLeft, scrollWidth, clientWidth } = scrollRef.current; + setShowLeft(scrollLeft > 10); + setShowRight(scrollLeft < scrollWidth - clientWidth - 10); + }; + + const scroll = (dir) => { + if (!scrollRef.current) return; + const amount = scrollRef.current.clientWidth * 0.8; + scrollRef.current.scrollBy({ left: dir * amount, behavior: 'smooth' }); + }; + + if (!movies?.length) return null; + + return ( +
+
+

+ + {title} +

+ {href !== '#' && ( + + Xem tất cả + + + )} +
+ +
+ {showLeft && ( + + )} + + {showRight && ( + + )} + +
+ {movies.map((movie) => ( +
+ +
+ ))} +
+
+
+ ); +} diff --git a/src/components/MovieSlider.jsx b/src/components/MovieSlider.jsx new file mode 100644 index 0000000000000000000000000000000000000000..883e262fceb10c36994188f4bd527b58a7df7ec2 --- /dev/null +++ b/src/components/MovieSlider.jsx @@ -0,0 +1,118 @@ +import { useEffect, useRef, useState } from 'react'; +import { ChevronLeft, ChevronRight, Play, Star, Calendar, Clock } from 'lucide-react'; + +export default function MovieSlider({ movies = [] }) { + const containerRef = useRef(null); + const [canScrollLeft, setCanScrollLeft] = useState(false); + const [canScrollRight, setCanScrollRight] = useState(true); + + const checkScroll = () => { + const el = containerRef.current; + if (!el) return; + setCanScrollLeft(el.scrollLeft > 0); + setCanScrollRight(el.scrollLeft + el.clientWidth < el.scrollWidth - 10); + }; + + useEffect(() => { + checkScroll(); + const el = containerRef.current; + if (el) { + el.addEventListener('scroll', checkScroll); + window.addEventListener('resize', checkScroll); + return () => { + el.removeEventListener('scroll', checkScroll); + window.removeEventListener('resize', checkScroll); + }; + } + }, [movies]); + + const scroll = (dir) => { + const el = containerRef.current; + if (!el) return; + el.scrollBy({ left: dir * el.clientWidth * 0.8, behavior: 'smooth' }); + }; + + if (!movies?.length) return null; + + return ( +
+
+ + Đề xuất hot +
+
+
+ {movies.map((movie) => { + const thumb = movie.thumb_url || movie.poster_url || ''; + const year = movie.year || (movie.modified?.time ? new Date(movie.modified.time).getFullYear() : ''); + return ( + + + + {canScrollLeft && ( + + )} + {canScrollRight && ( + + )} +
+
+ ); +} diff --git a/src/components/PaginatedGrid.jsx b/src/components/PaginatedGrid.jsx new file mode 100644 index 0000000000000000000000000000000000000000..1f478ac7a315b4069b7dd3668fe670bb26e87f7a --- /dev/null +++ b/src/components/PaginatedGrid.jsx @@ -0,0 +1,104 @@ +import { useState, useRef } from 'react'; +import MovieCard from './MovieCard'; +import Pagination from './Pagination'; + +export default function PaginatedGrid({ initialData, category, title, query, topic, country, type }) { + const [data, setData] = useState(initialData); + const [loading, setLoading] = useState(false); + const containerRef = useRef(null); + + const moviesList = data?.items || []; + const currentPage = data?.pagination?.currentPage || 1; + const totalPages = data?.pagination?.totalPages || 1; + + // Xây dựng đường dẫn cơ sở basePath động chuẩn chỉnh cho chuyển trang + let basePath = ''; + if (typeof window !== 'undefined') { + const url = new URL(window.location.href); + url.searchParams.delete('page'); + // Giữ nguyên các tham số tìm kiếm khác (như q) nếu có + basePath = url.pathname + url.search; + } else { + // Giải pháp dự phòng khi Render trên máy chủ (SSR Fallback) + if (query) { + basePath = `/tim-kiem?q=${encodeURIComponent(query)}`; + } else if (topic) { + basePath = `/chu-de/${topic}`; + } else { + basePath = category ? `/the-loai/${category}` : ''; + } + } + + const handlePageChange = async (pageNum) => { + if (pageNum === currentPage || loading) return; + setLoading(true); + + // Cuộn mượt mà lên đầu danh sách/bảng phim với offset hợp lý + if (containerRef.current) { + containerRef.current.scrollIntoView({ behavior: 'smooth', block: 'start' }); + } + + try { + let apiUrl = `/api/movies?page=${pageNum}`; + if (category) apiUrl += `&category=${encodeURIComponent(category)}`; + if (topic) apiUrl += `&topic=${encodeURIComponent(topic)}`; + if (country) apiUrl += `&country=${encodeURIComponent(country)}`; + if (query) apiUrl += `&q=${encodeURIComponent(query)}`; + if (type) apiUrl += `&type=${encodeURIComponent(type)}`; + + const res = await fetch(apiUrl); + if (!res.ok) throw new Error(`HTTP error ${res.status}`); + const json = await res.json(); + + // Giãn cách một chút (300ms) để hiệu ứng chuyển trang trông premium, mượt mà và trực quan + await new Promise((resolve) => setTimeout(resolve, 300)); + setData(json); + + // Cập nhật địa chỉ URL trình duyệt mà không gây tải lại toàn bộ trang + const newUrl = new URL(window.location.href); + newUrl.searchParams.set('page', String(pageNum)); + window.history.pushState({}, '', newUrl.toString()); + } catch (err) { + console.error('Lỗi khi tải trang mới:', err); + } finally { + setLoading(false); + } + }; + + return ( +
+ {/* Hiệu ứng phủ kính Glassmorphism Loading Siêu Sang Trọng */} + {loading && ( +
+
+
+ Đang cập nhật... +
+
+ )} + + {moviesList.length === 0 ? ( +
+ Không tìm thấy phim nào +
+ ) : ( + <> + {/* Grid hiển thị danh sách phim hiện tại */} +
+ {moviesList.map((movie) => ( + + ))} +
+ + {/* Phân trang tiêu chuẩn cao cấp bằng AJAX */} + + + )} +
+ ); +} diff --git a/src/components/Pagination.jsx b/src/components/Pagination.jsx new file mode 100644 index 0000000000000000000000000000000000000000..c9434727d520ffbd840a9b69569948f7b855ba1c --- /dev/null +++ b/src/components/Pagination.jsx @@ -0,0 +1,66 @@ +import { ChevronLeft, ChevronRight } from 'lucide-react'; + +export default function Pagination({ currentPage, totalPages, basePath, onPageChange }) { + if (totalPages <= 1) return null; + + const getPages = () => { + const pages = []; + const maxVisible = 5; + let start = Math.max(1, currentPage - Math.floor(maxVisible / 2)); + let end = Math.min(totalPages, start + maxVisible - 1); + if (end - start < maxVisible - 1) start = Math.max(1, end - maxVisible + 1); + for (let i = start; i <= end; i++) pages.push(i); + return pages; + }; + + const buildUrl = (page) => { + const sep = basePath.includes('?') ? '&' : '?'; + return `${basePath}${sep}page=${page}`; + }; + + const handlePageClick = (e, page) => { + if (onPageChange) { + e.preventDefault(); + onPageChange(page); + } + }; + + return ( + + ); +} diff --git a/src/components/SplashScreen.jsx b/src/components/SplashScreen.jsx new file mode 100644 index 0000000000000000000000000000000000000000..737ad11df81cbcd128b257a206f85c88cf3b7816 --- /dev/null +++ b/src/components/SplashScreen.jsx @@ -0,0 +1,55 @@ +import { useEffect, useState } from 'react'; + +export default function SplashScreen() { + const [visible, setVisible] = useState(true); + const [fadeOut, setFadeOut] = useState(false); + + useEffect(() => { + const show = () => { + setVisible(true); + setFadeOut(false); + }; + const hide = () => { + setFadeOut(true); + setTimeout(() => setVisible(false), 600); + }; + + document.addEventListener('astro:before-preparation', show); + document.addEventListener('astro:after-preparation', hide); + + // Initial hide for first page load + const timer = setTimeout(hide, 1000); + + return () => { + document.removeEventListener('astro:before-preparation', show); + document.removeEventListener('astro:after-preparation', hide); + clearTimeout(timer); + }; + }, []); + + if (!visible) return null; + + return ( +
+
+
+ TPHIMX Full Logo +
+
Tuyệt mỹ từng khung hình
+
+
+
+ {[0, 1, 2].map((i) => ( +
+ ))} +
+

Đang tải...

+
+ ); +} diff --git a/src/components/TopTenCard.jsx b/src/components/TopTenCard.jsx new file mode 100644 index 0000000000000000000000000000000000000000..a0d04710a452423adf9202b99dde02753aa13c6e --- /dev/null +++ b/src/components/TopTenCard.jsx @@ -0,0 +1,120 @@ +import { Play, Info } from 'lucide-react'; +import { useState, useRef } from 'react'; +import { formatImageUrl } from '../lib/image'; + +export default function TopTenCard({ movie, index }) { + const [showPreview, setShowPreview] = useState(false); + const hoverTimer = useRef(null); + + const handleMouseEnter = () => { + hoverTimer.current = setTimeout(() => { + setShowPreview(true); + }, 400); // Mượt mà hơn với 400ms phản hồi + }; + + const handleMouseLeave = () => { + if (hoverTimer.current) clearTimeout(hoverTimer.current); + setShowPreview(false); + }; + + const year = movie.year || (movie.modified?.time ? new Date(movie.modified.time).getFullYear() : ''); + const epCount = movie.episode_current?.match(/\d+/)?.[0] || '??'; + + // horizontal backdrop for preview + const backdrop = formatImageUrl(movie.poster_url || movie.thumb_url); + const poster = formatImageUrl(movie.thumb_url || movie.poster_url); + + return ( +
+ {/* Giant Netflix Outlined Number */} +
+ {index + 1} +
+ + {/* Overlapping Poster Card */} +
+
+ {movie.name} +
+
+ + {/* Episode Badge */} +
+ + TẬP {epCount} + +
+ + +
+ + {/* Info below aligned with poster */} +
+

+ {movie.name} +

+

+ {movie.origin_name} +

+
+ + {/* Premium Hover Preview Popup */} + {showPreview && ( +
+
+
+ preview +
+
+
+ {movie.name} + {movie.origin_name} +
+ {movie.quality || 'FHD'} +
+
+ +
+ +

+ {movie.content?.replace(/<[^>]*>/g, '') || 'Đang cập nhật nội dung cốt truyện...'} +

+
+ {year} + + {movie.episode_current} +
+
+
+
+ )} +
+ ); +} \ No newline at end of file diff --git a/src/components/TopTenSection.jsx b/src/components/TopTenSection.jsx new file mode 100644 index 0000000000000000000000000000000000000000..953a87cc4961f1320a1af9864e71300c31b8ad8b --- /dev/null +++ b/src/components/TopTenSection.jsx @@ -0,0 +1,119 @@ +import { useRef, useState, useEffect } from 'react'; +import { ChevronLeft, ChevronRight } from 'lucide-react'; +import TopTenCard from './TopTenCard'; + +export default function TopTenSection({ series = [], rated = [], favorited = [] }) { + const [activeTab, setActiveTab] = useState('series'); + const scrollRef = useRef(null); + const [showLeft, setShowLeft] = useState(false); + const [showRight, setShowRight] = useState(true); + + const getMoviesForTab = () => { + switch (activeTab) { + case 'rated': return rated; + case 'favorited': return favorited; + case 'series': + default: return series; + } + }; + + const movies = getMoviesForTab(); + + const handleScroll = () => { + if (!scrollRef.current) return; + const { scrollLeft, scrollWidth, clientWidth } = scrollRef.current; + setShowLeft(scrollLeft > 10); + setShowRight(scrollLeft < scrollWidth - clientWidth - 10); + }; + + const scroll = (dir) => { + if (!scrollRef.current) return; + const amount = scrollRef.current.clientWidth * 0.8; + scrollRef.current.scrollBy({ left: dir * amount, behavior: 'smooth' }); + }; + + // Reset scroll position on tab change + useEffect(() => { + if (scrollRef.current) { + scrollRef.current.scrollLeft = 0; + handleScroll(); + } + }, [activeTab]); + + if (!movies?.length) return null; + + return ( +
+ {/* Header Tabs */} +
+
+ +

+ Bảng Xếp Hạng +

+
+ + {/* Premium Tab Buttons */} +
+ {[ + { id: 'series', name: 'Top Phim Bộ', icon: 'fa-fire' }, + { id: 'rated', name: 'Đánh Giá Cao', icon: 'fa-star' }, + { id: 'favorited', name: 'Yêu Thích Nhất', icon: 'fa-heart' } + ].map(tab => ( + + ))} +
+
+ + {/* Row có scroll ngang */} +
+ {/* Nút trái */} + {showLeft && ( + + )} + + {/* Nút phải */} + {showRight && ( + + )} + + {/* Track */} +
+ {movies.slice(0, 10).map((movie, idx) => ( +
+ +
+ ))} +
+
+
+ ); +} \ No newline at end of file diff --git a/src/env.d.ts b/src/env.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f964fe0cffd88ccb9fcc20bd3c22e848c879d78a --- /dev/null +++ b/src/env.d.ts @@ -0,0 +1 @@ +/// diff --git a/src/layouts/AdminLayout.astro b/src/layouts/AdminLayout.astro new file mode 100644 index 0000000000000000000000000000000000000000..82a109c30ee70de0e9dc4e75f503b65c8ac7c318 --- /dev/null +++ b/src/layouts/AdminLayout.astro @@ -0,0 +1,463 @@ +--- +import '../styles/global.css'; +import { ClientRouter } from 'astro:transitions'; + +interface Props { + title: string; +} + +const { title } = Astro.props; + +// Mock admin check - in real app, check role from cookie/session +const token = Astro.cookies.get('auth_token')?.value; +let user = null; +if (token) { + try { + user = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + } catch(e) {} +} + +let forceRedirect = false; +if (!user || user.role !== 'admin') { + forceRedirect = true; +} + +const sidebarLinks = [ + { href: '/admin', label: 'Tổng quan', icon: 'fas fa-chart-line' }, + { href: '/admin/duyet-zalo', label: 'Duyệt Zalo', icon: 'fas fa-user-check', badgeId: 'nav-badge-zalo' }, + { href: '/admin/bao-cao-loi', label: 'Báo cáo lỗi', icon: 'fas fa-exclamation-triangle', badgeId: 'nav-badge-loi' }, + { href: '/admin/phim', label: 'Quản lý phim', icon: 'fas fa-film' }, + { href: '/admin/crawl', label: 'Thu thập phim', icon: 'fas fa-spider' }, + { href: '/admin/crawl-nang-cao', label: 'Cào nâng cao', icon: 'fas fa-search-plus' }, + { href: '/admin/server', label: 'Quản lý Server', icon: 'fas fa-server' }, + { href: '/admin/the-loai', label: 'Thể loại', icon: 'fas fa-tags' }, + { href: '/admin/quoc-gia', label: 'Quốc gia', icon: 'fas fa-globe' }, + { href: '/admin/dien-vien', label: 'Diễn viên', icon: 'fas fa-user-friends' }, + { href: '/admin/nguoi-dung', label: 'Người dùng', icon: 'fas fa-users' }, + { href: '/admin/binh-luan', label: 'Bình luận', icon: 'fas fa-comments', badgeId: 'nav-badge-comment' }, + { href: '/admin/email', label: 'Lịch sử Email', icon: 'fas fa-envelope-open-text' }, + { href: '/admin/cai-dat', label: 'Cài đặt', icon: 'fas fa-cog' }, +]; +--- + + + + + + + {forceRedirect && } + {title} - TPHIMX Admin + + + + + + + + + + + + {forceRedirect ? ( +
+
+

Vui lòng đăng nhập...

+
+ ) : ( + <> + +
+ +
+ +
+ +
+
+ +
+ +
+
+ + +
+
+ TPHIMX +
+
+ Hệ thống Quản trị Cao cấp +
+
+ + +
+
+
+
+
+ +
+ + + + +
+
+
+ +
+ TPHIMX +
+ +
+ + + + + +
+ +
+
+ + )} + + + + + + diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro new file mode 100644 index 0000000000000000000000000000000000000000..e05cf123283cfd5b27e827cf19000442970c3fcf --- /dev/null +++ b/src/layouts/Layout.astro @@ -0,0 +1,636 @@ +--- +import '../styles/global.css'; +import crypto from 'node:crypto'; +import Header from '../components/Header.astro'; +import Footer from '../components/Footer.jsx'; +import SplashScreen from '../components/SplashScreen.jsx'; + +import { txasupabase } from '../lib/txasupabase.js'; + +interface Props { + title?: string; + description?: string; + image?: string; + type?: string; + slug?: string; +} + +import { ClientRouter } from 'astro:transitions'; + +const settings = await txasupabase.getSettings() || {}; +const siteName = settings.site_name || 'DPTXA'; +const siteDescription = settings.site_description || 'DPTXA - Động Phim TXA | Nền tảng xem phim trực tuyến miễn phí với kho phim khổng lồ, cập nhật liên tục mỗi ngày. Phim bộ, phim lẻ, hoạt hình Full HD Vietsub.'; +const siteKeywords = settings.site_keywords || 'xem phim online, phim vietsub, phim hd, phim moi, phim bo, phim le, hoat hinh, dptxa, dong phim txa'; +const siteUrl = await txasupabase.getSiteUrl(Astro.request); + +const { + title = 'Động Phim Đỉnh Cao', + description = siteDescription, + image = 'https://dongmephim.online/og-image.jpg', + type = 'website', + slug = '' +} = Astro.props; + +// Automatically replace TPHIMX / DPTXA with the dynamic siteName from Admin Dashboard +const dynamicTitle = title.replace(/TPHIMX|DPTXA/gi, siteName); +const dynamicDescription = description.replace(/TPHIMX|DPTXA/gi, siteName); +const dynamicKeywords = siteKeywords.replace(/TPHIMX|DPTXA/gi, siteName); + +// --- REFERRER DECOY GATEKEEPER & ZALO ACCESS GATEKEEPER --- +const currentPath = Astro.url.pathname; + +// Các trang được miễn trừ bộ lọc ngụy trang (để Admin làm việc và các API hoạt động) +const isExempted = currentPath.startsWith('/admin') || + currentPath.startsWith('/api/') || + currentPath === '/dang-nhap' || + currentPath === '/dang-ky'; + +const referer = Astro.request.headers.get('referer') || ''; +const url = new URL(Astro.request.url); +const refParam = url.searchParams.get('ref') || url.searchParams.get('from') || ''; +const bypassParam = url.searchParams.get('bypass') || ''; + +let isReferred = Astro.cookies.get('nrotxa_referred')?.value === 'true'; + +if (bypassParam === 'true') { + isReferred = true; + Astro.cookies.set('nrotxa_referred', 'true', { path: '/', maxAge: 365 * 24 * 60 * 60 }); + Astro.cookies.set('zalo_access_approved', 'true', { path: '/', maxAge: 365 * 24 * 60 * 60 }); +} + +// --- ADMIN ABSOLUTE BYPASS --- +let isAdmin = false; +const token = Astro.cookies.get('auth_token')?.value; +if (token) { + try { + const user = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + if (user && user.role === 'admin') { + isAdmin = true; + isReferred = true; // Admin luôn được bypass trang ngụy trang + } + } catch(e) {} +} + +// Nếu chưa được xác định nguồn giới thiệu và trang hiện tại không được miễn trừ, tiến hành xác thực bảo mật +if (!isReferred && !isExempted) { + // 1. Xác thực HMAC SHA256 Token bảo mật từ film.nrotxa.online + const SECURE_KEY = 'TPhimX_Gatekeeper_Secret_Signature_Key_2026'; + const tTimeParam = url.searchParams.get('t_time') || ''; + const tTokenParam = url.searchParams.get('t_token') || ''; + + let isTokenValid = false; + if (tTimeParam && tTokenParam) { + try { + const timestamp = parseInt(tTimeParam, 10); + const now = Math.floor(Date.now() / 1000); + const timeDiff = Math.abs(now - timestamp); + + // Token hợp lệ trong vòng 1 tiếng (3600 giây) kể từ lúc sinh ra + if (timeDiff <= 3600) { + const expectedSignature = crypto + .createHmac('sha256', SECURE_KEY) + .update(tTimeParam) + .digest('hex'); + + if (crypto.timingSafeEqual(Buffer.from(tTokenParam, 'hex'), Buffer.from(expectedSignature, 'hex'))) { + isTokenValid = true; + } + } + } catch (e) { + console.error("Lỗi xác thực token bảo mật:", e); + } + } + + // 2. Chấp nhận nếu token bảo mật hợp lệ HOẶC đi từ domain chính thức cũ qua Referer + const isRefererValid = referer.includes('film.nrotxa.online'); + + if (isTokenValid || isRefererValid) { + isReferred = true; + Astro.cookies.set('nrotxa_referred', 'true', { path: '/', maxAge: 365 * 24 * 60 * 60 }); + } +} + +// Nếu không đến từ film.nrotxa.online và không phải trang miễn trừ -> kích hoạt trạng thái ngụy trang (Decoy) +const showDecoy = !isReferred && !isExempted; + +// Nếu đã được xác định nguồn giới thiệu, nhưng truy cập trang xem phim/trang chủ mà CHƯA ĐƯỢC DUYỆT Zalo -> đá về Landing Page (/) +let forceRedirect = false; +if (!showDecoy && !isExempted && currentPath !== '/') { + const isApproved = Astro.cookies.get('zalo_access_approved')?.value === 'true'; + if (!isApproved && !isAdmin) { + forceRedirect = true; + } +} + +const finalTitle = dynamicTitle.includes(siteName) ? dynamicTitle : `${dynamicTitle} | ${siteName}`; +const canonical = `${siteUrl}${slug}`; + +// Override metadata for Decoy Tech Blog to ensure Google Search only indexes technology content! +let seoTitle = finalTitle; +let seoDesc = dynamicDescription; +let seoKeywords = dynamicKeywords; +let seoImage = image; + +if (showDecoy) { + seoTitle = `TxaTech Studio - Giải Pháp Công Nghệ Đột Phá Doanh Nghiệp 2026`; + seoDesc = `TxaTech Studio chuyên cung cấp giải pháp phần mềm, ứng dụng di động hiệu năng cao và các dịch vụ bảo mật mạng doanh nghiệp toàn diện.`; + seoKeywords = `txatech, lập trình di động, phát triển website, bảo mật hệ thống, phần mềm doanh nghiệp, công nghệ số 2026`; + seoImage = `https://images.unsplash.com/photo-1517694712202-14dd9538aa97?q=80&w=600`; +} +--- + + + + + + + {forceRedirect && } + + + {seoTitle} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {forceRedirect ? ( +
+
+

Đang kết nối rạp phim...

+
+ ) : showDecoy ? ( + +
+ + + Tư vấn ngay +
+ +
+ +
+
+
+ + + KỶ NGUYÊN SỐ HÓA 2026 + +

+ Giải Pháp Công Nghệ Đột Phá Cho Doanh Nghiệp +

+

+ Chúng tôi thiết kế và phát triển các sản phẩm phần mềm, ứng dụng di động hiệu năng cao và hệ thống dữ liệu chuyên nghiệp. Hiện đã phục vụ hơn 1500 khách hàng trên toàn cầu. +

+ +
+ + +
+
+
+

Dịch Vụ Lõi Của Chúng Tôi

+

Đồng hành cùng sự phát triển bền vững của doanh nghiệp

+
+
+
+
+

Phát triển Phần mềm

+

Xây dựng ứng dụng web, hệ thống CRM/ERP tối ưu hiệu suất, bảo mật cao và tương thích đa thiết bị.

+
+
+
+

Lập trình Mobile App

+

Phát triển các ứng dụng iOS/Android mượt mà, tối ưu trải nghiệm người dùng với công nghệ React Native, Flutter.

+
+
+
+

Bảo mật hệ thống

+

Kiểm tra lỗ hổng bảo mật, thiết lập tường lửa và hệ thống bảo vệ dữ liệu đám mây toàn diện cho doanh nghiệp.

+
+
+
+
+ + +
+
+
+

Tin Tức & Công Nghệ

+

Chia sẻ kiến thức chuyên môn, thủ thuật lập trình & bảo mật hệ thống

+
+ +
+ +
+
+
+
+
+ Thủ thuật Mobile +

Tối ưu hóa hiệu năng Android cho trải nghiệm chơi game mượt mà

+
+ 15 Tháng 5, 2026 +
+
+
+
+
+
+ Lập trình +

Tại sao Flutter lại trở thành tương lai của lập trình đa nền tảng?

+
+ 12 Tháng 5, 2026 +
+
+
+
+
+
+ Bảo mật +

Bảo mật dữ liệu cá nhân trên môi trường Internet năm 2026

+
+ 08 Tháng 5, 2026 +
+
+
+
+
+
+ Web App +

Hướng dẫn build hệ thống Web App hiệu năng cao với Astro JS

+
+ 05 Tháng 5, 2026 +
+
+
+
+ + +
+
+
+

Kết Nối Với Chúng Tôi

+

Bắt đầu hóa ý tưởng công nghệ của bạn ngay hôm nay

+
+
+
+ + +
+ + + +
+ +
+
+
+ +
+

© 2026 TxaTech Studio. Tất cả các quyền được bảo hộ.

+
+ ) : ( + + <> + +
+
+
+
+
+ DPTXA +
+
+
+
+
+
+
+
+
+ Loading Cinematic Experience +
+
+
+ +
+
+ +
+
+ + )} + + + + diff --git a/src/lib/api.js b/src/lib/api.js new file mode 100644 index 0000000000000000000000000000000000000000..18cc2d2f93d0a80ff40b12ea73dce2372da1531b --- /dev/null +++ b/src/lib/api.js @@ -0,0 +1,199 @@ +import { txasupabase } from './txasupabase.js'; + +const getLocalMovies = () => txasupabase.getLocalMovies(); +const getDeletedMovies = () => txasupabase.getDeletedMovies(); + +export { formatImageUrl } from './image.js'; + +// Hàm định dạng phim cục bộ thành định dạng danh sách rút gọn +function mapLocalToListItem(localMovie) { + return { + _id: localMovie.movie.id || localMovie.movie.slug, + name: localMovie.movie.name, + slug: localMovie.movie.slug, + origin_name: localMovie.movie.origin_name, + thumb_url: localMovie.movie.thumb_url, + poster_url: localMovie.movie.poster_url, + year: localMovie.movie.year, + quality: localMovie.movie.quality || 'FHD', + lang: localMovie.movie.lang || 'Vietsub', + episode_current: localMovie.movie.episode_current || 'Tập 1', + type: localMovie.movie.type || 'single', + isLocal: true + }; +} + +// Trích tên gốc phim (bỏ Phần/Part/Season/SS/EP suffix) +function getBaseMovieName(name) { + if (!name) return ''; + let clean = name; + // 1. Xóa các cụm chứa ngoặc đơn hoặc ngoặc vuông chứa Phần/Part/Season (ví dụ: "(Phần 2)", "[Season 3]") + clean = clean.replace(/\s*[([\])]*\s*(Phần|Part|Season|SS|EP|Ep|Tập)\s*(\d+|[IVXLCDM]+)\s*[([\])]*/gi, ''); + // 2. Xóa các cụm Phần/Part/Season đứng độc lập ở cuối + clean = clean.replace(/\s*[-–—|:]?\s*(Phần|Part|Season|SS|EP|Ep|Tập)\s*(\d+|[IVXLCDM]+)\b/gi, ''); + // 3. Xóa các số hoặc ký tự số La Mã cô độc ở cuối + clean = clean.replace(/\s*[-–—|:]?\s*(\d+|[IVXLCDM]+)$/gi, ''); + // 4. Dọn dẹp sạch các dấu ngoặc đơn/ngoặc vuông rỗng còn sót lại ở cuối chuỗi + clean = clean.replace(/\s*[([\])]+\s*$/gi, ''); + return clean.trim().toLowerCase(); +} + +// Nhóm phim theo tên gốc, giữ lại phần mới nhất cho listing +function groupMoviesBySeason(movies) { + const groups = new Map(); + + for (const m of movies) { + const base = getBaseMovieName(m.movie.name); + if (!base || base.length <= 2) { + // Tên quá ngắn, không nhóm + groups.set(m.movie.slug, m); + continue; + } + + const existing = groups.get(base); + if (!existing) { + groups.set(base, m); + } else { + // Giữ phần cập nhật mới nhất + const existingTime = new Date(existing.movie.modified?.time || 0).getTime(); + const currentTime = new Date(m.movie.modified?.time || 0).getTime(); + if (currentTime > existingTime) { + groups.set(base, m); + } + } + } + + return Array.from(groups.values()); +} + +// Hàm lọc và phân trang phim cục bộ +// grouped = true: gộp phim cùng tên khác phần (mặc định cho trang công khai) +// grouped = false: không gộp (dùng cho trang admin) +async function queryLocalMovies(filterFn, page = 1, limit = 12, { grouped = true } = {}) { + const localMovies = await getLocalMovies(); + const deletedSlugs = await getDeletedMovies(); + + let list = Object.values(localMovies) + .filter(m => !deletedSlugs.includes(m.movie.slug)); + + if (filterFn) { + list = list.filter(filterFn); + } + + // Sắp xếp theo ngày cập nhật mới nhất (modified time) + list.sort((a, b) => { + const timeA = new Date(a.movie.modified?.time || 0).getTime(); + const timeB = new Date(b.movie.modified?.time || 0).getTime(); + return timeB - timeA; + }); + + // Nhóm phim theo season/part — chỉ hiển thị phần mới nhất trong listing + if (grouped) { + list = groupMoviesBySeason(list); + } + + const totalItems = list.length; + const totalPages = Math.ceil(totalItems / limit) || 1; + const paginated = list.slice((page - 1) * limit, page * limit) + .map(mapLocalToListItem); + + return { + items: paginated, + pagination: { + totalItems, + totalItemsPerPage: limit, + currentPage: page, + totalPages + } + }; +} + +/** + * Lấy danh sách phim mới cập nhật + * @param {number} page + * @param {{ grouped?: boolean }} options - set grouped: false for admin pages + */ +export async function getNewestMovies(page = 1, options = {}) { + return await queryLocalMovies(null, page, 12, options); +} + +/** + * Lấy chi tiết phim theo slug + */ +export async function getMovieDetail(slug) { + const deletedSlugs = await getDeletedMovies(); + if (deletedSlugs.includes(slug)) { + return null; + } + + const localMovies = await getLocalMovies(); + if (localMovies[slug]) { + return { + status: true, + movie: localMovies[slug].movie, + episodes: localMovies[slug].episodes || [] + }; + } + return null; +} + +export async function getSeriesMovies(page = 1) { + return await queryLocalMovies(m => m.movie.type === 'series', page, 12); +} + +export async function getSingleMovies(page = 1) { + return await queryLocalMovies(m => m.movie.type === 'single', page, 12); +} + +export async function getCartoonMovies(page = 1) { + return await queryLocalMovies(m => m.movie.type === 'hoat-hinh', page, 12); +} + +export async function getTvShows(page = 1) { + return await queryLocalMovies(m => m.movie.type === 'tvshows' || m.movie.type === 'tv-shows', page, 12); +} + +export async function getMoviesByCategory(category, page = 1) { + const defaultTypes = { + 'phim-bo': 'series', + 'phim-le': 'single', + 'hoat-hinh': 'hoat-hinh', + 'tv-shows': 'tv-shows' + }; + + if (defaultTypes[category]) { + return await queryLocalMovies(m => m.movie.type === defaultTypes[category], page, 12); + } + + return await queryLocalMovies(m => + m.movie.category?.some(c => c.slug === category), page, 12 + ); +} + +export async function getMoviesByCountry(country, page = 1) { + return await queryLocalMovies(m => + m.movie.country?.some(c => c.slug === country), page, 12 + ); +} + +export async function searchMovies(keyword, page = 1, options = {}) { + if (!keyword) { + return { items: [], pagination: { totalItems: 0, totalItemsPerPage: 12, currentPage: page, totalPages: 1 } }; + } + const k = keyword.toLowerCase(); + return await queryLocalMovies(m => + m.movie.name?.toLowerCase().includes(k) || + m.movie.origin_name?.toLowerCase().includes(k) || + m.movie.slug?.includes(k), page, 12, options + ); +} + +export async function getMoviesByTopic(topicSlug, page = 1) { + const { TOPICS } = await import('./topics.js'); + const topic = TOPICS.find(t => t.slug === topicSlug); + if (!topic) { + return { items: [], pagination: { totalItems: 0, totalItemsPerPage: 12, currentPage: page, totalPages: 1 } }; + } + return await queryLocalMovies(topic.filter, page, 12); +} + diff --git a/src/lib/image.js b/src/lib/image.js new file mode 100644 index 0000000000000000000000000000000000000000..71ebba47bec770614a4969de788782931860378d --- /dev/null +++ b/src/lib/image.js @@ -0,0 +1,21 @@ +const IMAGE_BASE_URL = 'https://phimimg.com'; + +/** + * Hàm định dạng URL ảnh thành URL tuyệt đối (chạy được trên cả Client và Server) + */ +export const formatImageUrl = (url) => { + if (!url) return ''; + let finalUrl = url; + if (!url.startsWith('http')) { + const cleanUrl = url.startsWith('/') ? url : `/${url}`; + finalUrl = `${IMAGE_BASE_URL}${cleanUrl}`; + } + if (finalUrl.includes('phim1280') || finalUrl.includes('s2.phim1280.tv') || finalUrl.includes('img.ophim.tv')) { + const cloudflareProxy = import.meta.env.PUBLIC_CLOUDFLARE_PROXY_URL; + if (cloudflareProxy) { + return `${cloudflareProxy}/?url=${encodeURIComponent(finalUrl)}`; + } + return `/api/proxy-media?url=${encodeURIComponent(finalUrl)}`; + } + return finalUrl; +}; diff --git a/src/lib/localDb.js b/src/lib/localDb.js new file mode 100644 index 0000000000000000000000000000000000000000..0974592e79a28487eb3f12f06fa8872142838e00 --- /dev/null +++ b/src/lib/localDb.js @@ -0,0 +1,243 @@ +import fs from 'node:fs/promises'; +import path from 'node:path'; +import { txasupabase } from './txasupabase.js'; + +const DATA_DIR = path.join(process.cwd(), 'src/data'); +const MOVIES_FILE = path.join(DATA_DIR, 'movies.json'); +const DELETED_FILE = path.join(DATA_DIR, 'deleted_movies.json'); +const GENRES_FILE = path.join(DATA_DIR, 'genres.json'); +const COUNTRIES_FILE = path.join(DATA_DIR, 'countries.json'); +const ACTORS_FILE = path.join(DATA_DIR, 'actors.json'); +const SERVERS_FILE = path.join(DATA_DIR, 'servers.json'); +const USERS_FILE = path.join(DATA_DIR, 'users.json'); +const RATINGS_FILE = path.join(DATA_DIR, 'ratings.json'); + +// --- AUTO MIGRATION FROM LOCAL JSON TO SUPABASE --- +let isMigrated = false; + +async function checkAndMigrate() { + if (isMigrated) return; + try { + // 1. Kiểm tra xem trên Supabase đã có phim nào chưa + const movies = await txasupabase.getLocalMovies(); + if (Object.keys(movies).length === 0) { + console.log('=== [SUPABASE AUTO-MIGRATION START] ==='); + + // A. Di trú Server + try { + const localServers = JSON.parse(await fs.readFile(SERVERS_FILE, 'utf-8')); + if (Array.isArray(localServers) && localServers.length > 0) { + console.log(`Migrating ${localServers.length} servers to Supabase...`); + for (const s of localServers) { + await txasupabase.saveServer(s.name); + } + } + } catch (e) {} + + // B. Di trú Thể loại + try { + const localGenres = JSON.parse(await fs.readFile(GENRES_FILE, 'utf-8')); + if (Array.isArray(localGenres) && localGenres.length > 0) { + console.log(`Migrating ${localGenres.length} genres to Supabase...`); + for (const g of localGenres) { + await txasupabase.saveGenre(g.slug, g.name); + } + } + } catch (e) {} + + // C. Di trú Quốc gia + try { + const localCountries = JSON.parse(await fs.readFile(COUNTRIES_FILE, 'utf-8')); + if (Array.isArray(localCountries) && localCountries.length > 0) { + console.log(`Migrating ${localCountries.length} countries to Supabase...`); + for (const c of localCountries) { + await txasupabase.saveCountry(c.slug, c.name); + } + } + } catch (e) {} + + // D. Di trú Diễn viên + try { + const localActors = JSON.parse(await fs.readFile(ACTORS_FILE, 'utf-8')); + if (Array.isArray(localActors) && localActors.length > 0) { + console.log(`Migrating ${localActors.length} actors to Supabase...`); + for (const a of localActors) { + await txasupabase.saveActor(a.name); + } + } + } catch (e) {} + + // E. Di trú Deleted/Hidden Movies list + try { + const localDeleted = JSON.parse(await fs.readFile(DELETED_FILE, 'utf-8')); + if (Array.isArray(localDeleted) && localDeleted.length > 0) { + console.log(`Migrating ${localDeleted.length} hidden movie slugs to Supabase...`); + for (const slug of localDeleted) { + await txasupabase.deleteLocalMovie(slug); + } + } + } catch (e) {} + + // F. Di trú Phim cục bộ + try { + const localMovies = JSON.parse(await fs.readFile(MOVIES_FILE, 'utf-8')); + const entries = Object.entries(localMovies); + if (entries.length > 0) { + console.log(`Migrating ${entries.length} movies with episodes to Supabase...`); + for (const [slug, mData] of entries) { + await txasupabase.saveLocalMovie(slug, mData); + } + } + } catch (e) {} + + // G. Di trú Users + try { + const localUsers = JSON.parse(await fs.readFile(USERS_FILE, 'utf-8')); + if (Array.isArray(localUsers) && localUsers.length > 0) { + console.log(`Migrating ${localUsers.length} user accounts to Supabase...`); + for (const user of localUsers) { + await txasupabase.saveUser(user); + } + } + } catch (e) {} + // H. Di trú Ratings + try { + const localRatings = JSON.parse(await fs.readFile(RATINGS_FILE, 'utf-8')); + const entries = Object.entries(localRatings); + if (entries.length > 0) { + console.log(`Migrating ${entries.length} movie ratings to Supabase...`); + for (const [slug, rData] of entries) { + await txasupabase.saveRating(slug, rData.count, rData.totalScore, rData.userRatings || {}, rData.ipRatings || {}); + } + } + } catch (e) {} + + console.log('=== [SUPABASE AUTO-MIGRATION COMPLETED SUCCESS] ==='); + } + isMigrated = true; + } catch (err) { + console.error('Error during Supabase auto-migration:', err); + } +} + +// --- MOVIES --- +export async function getLocalMovies() { + await checkAndMigrate(); + return await txasupabase.getLocalMovies(); +} + +export async function saveLocalMovie(slug, movieData) { + await checkAndMigrate(); + return await txasupabase.saveLocalMovie(slug, movieData); +} + +export async function resetLocalMovie(slug) { + await checkAndMigrate(); + return await txasupabase.resetLocalMovie(slug); +} + +// --- DELETED MOVIES --- +export async function getDeletedMovies() { + await checkAndMigrate(); + return await txasupabase.getDeletedMovies(); +} + +export async function deleteLocalMovie(slug) { + await checkAndMigrate(); + return await txasupabase.deleteLocalMovie(slug); +} + +export async function restoreLocalMovie(slug) { + await checkAndMigrate(); + return await txasupabase.restoreLocalMovie(slug); +} + +// --- GENRES --- +export async function getGenres() { + await checkAndMigrate(); + return await txasupabase.getGenres(); +} + +export async function saveGenre(slug, name) { + await checkAndMigrate(); + return await txasupabase.saveGenre(slug, name); +} + +export async function deleteGenre(slug) { + await checkAndMigrate(); + return await txasupabase.deleteGenre(slug); +} + +export async function bulkDeleteGenres(slugs) { + await checkAndMigrate(); + return await txasupabase.bulkDeleteGenres(slugs); +} + +// --- COUNTRIES --- +export async function getCountries() { + await checkAndMigrate(); + return await txasupabase.getCountries(); +} + +export async function saveCountry(slug, name) { + await checkAndMigrate(); + return await txasupabase.saveCountry(slug, name); +} + +export async function deleteCountry(slug) { + await checkAndMigrate(); + return await txasupabase.deleteCountry(slug); +} + +export async function bulkDeleteCountries(slugs) { + await checkAndMigrate(); + return await txasupabase.bulkDeleteCountries(slugs); +} + +// --- ACTORS --- +export async function getActors() { + await checkAndMigrate(); + return await txasupabase.getActors(); +} + +export async function saveActor(name, originalName = null) { + await checkAndMigrate(); + return await txasupabase.saveActor(name, originalName); +} + +export async function deleteActor(name) { + await checkAndMigrate(); + return await txasupabase.deleteActor(name); +} + +export async function bulkDeleteActors(names) { + await checkAndMigrate(); + return await txasupabase.bulkDeleteActors(names); +} + +// --- SERVERS --- +export async function getServers() { + await checkAndMigrate(); + return await txasupabase.getServers(); +} + +export async function saveServer(name, originalName = null) { + await checkAndMigrate(); + return await txasupabase.saveServer(name, originalName); +} + +export async function deleteServer(name) { + await checkAndMigrate(); + return await txasupabase.deleteServer(name); +} + +export async function bulkDeleteServers(names) { + await checkAndMigrate(); + return await txasupabase.bulkDeleteServers(names); +} + +// --- AUTOMATIC SYNC FROM MOVIES DATA --- +export async function syncFromMovies(type) { + await checkAndMigrate(); + return await txasupabase.syncFromMovies(type); +} diff --git a/src/lib/topics.js b/src/lib/topics.js new file mode 100644 index 0000000000000000000000000000000000000000..a123728410574dde9f39a5bf3d7e07bba0157506 --- /dev/null +++ b/src/lib/topics.js @@ -0,0 +1,85 @@ +export const TOPICS = [ + { + name: "Vũ Trụ Marvel", + slug: "vu-tru-marvel", + description: "Những siêu anh hùng vĩ đại nhất Trái Đất đối đầu với các hiểm họa vũ trụ. Khám phá toàn bộ bom tấn của MCU tại đây.", + color: "from-red-600/90 to-amber-600/90 shadow-red-500/20", + icon: "fas fa-shield-alt", + badge: "Siêu Anh Hùng", + filter: (m) => { + const name = (m.movie.name || '').toLowerCase(); + const origin = (m.movie.origin_name || '').toLowerCase(); + const slug = (m.movie.slug || '').toLowerCase(); + return name.includes('marvel') || name.includes('avengers') || name.includes('spider-man') || name.includes('iron man') || name.includes('thor') || name.includes('captain america') || name.includes('black panther') || name.includes('hulk') || name.includes('ant-man') || name.includes('doctor strange') || name.includes('guardian of the galaxy') || name.includes('guardians of the galaxy') || + origin.includes('marvel') || origin.includes('avengers') || origin.includes('spider-man') || origin.includes('iron man') || origin.includes('thor') || origin.includes('captain america') || origin.includes('black panther') || origin.includes('doctor strange') || origin.includes('guardians of the galaxy') || + slug.includes('marvel') || slug.includes('avengers') || slug.includes('spider-man') || slug.includes('iron-man') || slug.includes('thor') || slug.includes('captain-america'); + } + }, + { + name: "Thế Giới Netflix", + slug: "the-gioi-netflix", + description: "Bộ sưu tập các loạt phim truyền hình và phim điện ảnh nguyên bản (Netflix Originals) đột phá và gây bão toàn cầu.", + color: "from-stone-950 via-red-950 to-red-900 shadow-red-600/10", + icon: "fab fa-netflix", + badge: "Netflix Hot", + filter: (m) => { + const name = (m.movie.name || '').toLowerCase(); + const origin = (m.movie.origin_name || '').toLowerCase(); + const desc = (m.movie.content || '').toLowerCase(); + return name.includes('netflix') || origin.includes('netflix') || desc.includes('netflix'); + } + }, + { + name: "Vũ Trụ DC Comics", + slug: "vu-tru-dc-comics", + description: "Những huyền thoại bóng tối của Gotham, chiến binh Metropolis và các vị thần Atlantis. Hành trình công lý của Liên Minh Công Lý.", + color: "from-blue-600/90 to-indigo-950/90 shadow-blue-500/20", + icon: "fas fa-bolt", + badge: "DC Universe", + filter: (m) => { + const name = (m.movie.name || '').toLowerCase(); + const origin = (m.movie.origin_name || '').toLowerCase(); + const slug = (m.movie.slug || '').toLowerCase(); + return name.includes('dc comics') || name.includes('justice league') || name.includes('batman') || name.includes('superman') || name.includes('wonder woman') || name.includes('aquaman') || name.includes('flash') || name.includes('shazam') || name.includes('joker') || name.includes('suicide squad') || + origin.includes('justice league') || origin.includes('batman') || origin.includes('superman') || origin.includes('wonder woman') || origin.includes('aquaman') || origin.includes('flash') || origin.includes('shazam') || origin.includes('joker') || origin.includes('suicide squad') || + slug.includes('batman') || slug.includes('superman') || slug.includes('wonder-woman') || slug.includes('joker'); + } + }, + { + name: "Phim Chiếu Rạp Hot", + slug: "phim-chieu-rap-hot", + description: "Tổng hợp các siêu phẩm vừa oanh tạc các phòng vé trên khắp thế giới. Chất lượng hình ảnh sắc nét, vietsub hoàn chỉnh.", + color: "from-purple-600/90 to-indigo-900/90 shadow-purple-500/20", + icon: "fas fa-ticket-alt", + badge: "Phòng Vé", + filter: (m) => { + const isChieuRap = m.movie.chieu_rap === true || m.movie.chieu_rap === 'true'; + const isCategory = m.movie.category?.some(c => c.slug === 'phim-chieu-rap' || c.slug === 'chieu-rap'); + const name = (m.movie.name || '').toLowerCase(); + const origin = (m.movie.origin_name || '').toLowerCase(); + return isChieuRap || isCategory || name.includes('chiếu rạp') || origin.includes('chiếu rạp') || name.includes('cinema') || origin.includes('cinema'); + } + }, + { + name: "K-Drama: Phim Hàn Sốt Dẻo", + slug: "phim-han-quoc-hot", + description: "Những câu chuyện lãng mạn đốn tim, những vụ án giật gân kịch tính từ xứ sở Kim Chi. Cập nhật các bộ phim truyền hình hot nhất.", + color: "from-pink-600/90 to-rose-900/90 shadow-pink-500/20", + icon: "fas fa-heart", + badge: "K-Drama", + filter: (m) => { + return m.movie.country?.some(c => c.slug === 'han-quoc'); + } + }, + { + name: "Anime & Hoạt Hình Hot", + slug: "anime-hoat-hinh-hot", + description: "Dành riêng cho các tín đồ mê hoạt hình Nhật Bản và thế giới. Những chuyến phiêu lưu kỳ thú và những trận chiến huyền thoại.", + color: "from-emerald-600/90 to-teal-900/90 shadow-emerald-500/20", + icon: "fas fa-dragon", + badge: "Anime", + filter: (m) => { + return m.movie.type === 'hoat-hinh' || m.movie.category?.some(c => c.slug === 'hoat-hinh' || c.slug === 'anime'); + } + } +]; diff --git a/src/lib/txa/txaformat.js b/src/lib/txa/txaformat.js new file mode 100644 index 0000000000000000000000000000000000000000..f03a1fabe388ead4e8470a62900282df2059382d --- /dev/null +++ b/src/lib/txa/txaformat.js @@ -0,0 +1,67 @@ +/** + * TXA Format Utility + * Version: 1.0 (Web Optimized) + */ + +export const txaformat = { + twoDigits: (n) => (n < 10 ? '0' : '') + n, + + shortNumber: (n) => { + if (n >= 1000000) return (n / 1000000).toFixed(1) + 'M'; + if (n >= 1000) return (n / 1000).toFixed(1) + 'K'; + return n; + }, + + number: (n) => new Intl.NumberFormat('vi-VN').format(n), + + duration: function (s) { + const h = Math.floor(s / 3600); + const m = Math.floor((s % 3600) / 60); + const sec = Math.floor(s % 60); + let str = ''; + if (h > 0) str += this.twoDigits(h) + ':'; + return str + this.twoDigits(m) + ':' + this.twoDigits(sec); + }, + + fileSize: (bytes) => { + if (bytes === 0) return '0 B'; + const units = ['B', 'KB', 'MB', 'GB', 'TB']; + const i = Math.floor(Math.log(bytes) / Math.log(1024)); + return parseFloat((bytes / Math.pow(1024, i)).toFixed(2)) + ' ' + units[i]; + }, + + dateTime: (val) => { + if (!val) return ''; + const d = new Date(val); + if (isNaN(d.getTime())) return val; + return d.toLocaleString('vi-VN'); + }, + + relativeTime: (val) => { + if (!val) return ''; + const date = new Date(val); + const now = new Date(); + const diffMs = now.getTime() - date.getTime(); + + if (isNaN(date.getTime()) || diffMs < 0) return 'Vừa xong'; + + const diffSec = Math.floor(diffMs / 1000); + if (diffSec < 60) return 'Vừa xong'; + + const diffMin = Math.floor(diffSec / 60); + if (diffMin < 60) return `${diffMin} phút trước`; + + const diffHour = Math.floor(diffMin / 60); + if (diffHour < 24) return `${diffHour} giờ trước`; + + // Quá 1 ngày (24 giờ) sẽ hiện là ngày/tháng/năm + const day = date.getDate(); + const month = date.getMonth() + 1; + const year = date.getFullYear(); + return `${day}/${month}/${year}`; + } +}; + +if (typeof window !== 'undefined') { + window.txaformat = txaformat; +} diff --git a/src/lib/txa/txamodal.js b/src/lib/txa/txamodal.js new file mode 100644 index 0000000000000000000000000000000000000000..de53626c8c4d60cc66d95bc0af43a9be0a8818ac --- /dev/null +++ b/src/lib/txa/txamodal.js @@ -0,0 +1,120 @@ +/** + * TxaModal - Premium Modal System + * Migration: TPHIMX V2 (Vite Compatible) + */ + +export class TxaModal { + constructor() { + this.containerCreated = false; + this.container = null; + this.overlay = null; + this.modal = null; + } + + createContainer() { + if (this.containerCreated && document.getElementById('txamodal-container')) { + this.container = document.getElementById('txamodal-container'); + this.overlay = document.getElementById('txamodal-overlay'); + this.modal = document.getElementById('txamodal-content'); + return true; + } + + const container = document.createElement('div'); + container.id = 'txamodal-container'; + container.style.cssText = `position: fixed; top: 0; left: 0; width: 100%; height: 100%; display: none; align-items: center; justify-content: center; z-index: 2147483640; padding: 20px;`; + + const overlay = document.createElement('div'); + overlay.id = 'txamodal-overlay'; + overlay.style.cssText = `position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(10, 15, 25, 0.7); backdrop-filter: blur(12px); opacity: 0; transition: opacity 0.3s ease;`; + + const modal = document.createElement('div'); + modal.id = 'txamodal-content'; + modal.style.cssText = `position: relative; background: rgba(30, 41, 59, 0.7); backdrop-filter: blur(24px); width: 100%; max-width: 500px; border-radius: 28px; border: 1px solid rgba(255, 255, 255, 0.1); box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8); transform: scale(0.9) translateY(30px); opacity: 0; transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); overflow: hidden; display: flex; flex-direction: column;`; + + container.appendChild(overlay); + container.appendChild(modal); + document.body.appendChild(container); + + this.container = container; + this.overlay = overlay; + this.modal = modal; + this.containerCreated = true; + return true; + } + + show({ title, message, type = 'info', confirmText = 'Xác nhận', cancelText = 'Hủy', onConfirm = null, onCancel = null, input = null, inputPlaceholder = '', inputType = 'text' }) { + if (!this.createContainer()) return; + + let icon = ''; + let btnConfirmStyle = 'background: linear-gradient(135deg, #6366f1, #a855f7); color: #fff;'; + + if (type === 'danger') { + icon = ''; + btnConfirmStyle = 'background: #ef4444; color: #fff;'; + } else if (type === 'warning') { + icon = ''; + btnConfirmStyle = 'background: linear-gradient(135deg, #f59e0b, #ea580c); color: #fff;'; + } else if (type === 'success') { + icon = ''; + btnConfirmStyle = 'background: #10b981; color: #fff;'; + } + + let inputHtml = ''; + if (input) { + inputHtml = ` +
+ +
+ `; + } + + this.modal.innerHTML = ` +
+
${icon}
+

${title}

+
${message}
+ ${inputHtml} +
+
+ + +
+ `; + + this.container.style.display = 'flex'; + setTimeout(() => { + this.overlay.style.opacity = '1'; + this.modal.style.opacity = '1'; + this.modal.style.transform = 'scale(1) translateY(0)'; + if (input) document.getElementById('txamodal-input').focus(); + }, 10); + + document.getElementById('txamodal-confirm').onclick = async () => { + let result = true; + if (input) { + const val = document.getElementById('txamodal-input').value; + if (onConfirm) result = await onConfirm(val); + } else { + if (onConfirm) result = await onConfirm(); + } + if (result !== false) this.hide(); + }; + document.getElementById('txamodal-cancel').onclick = () => { + if (typeof onCancel === 'function') { + try { onCancel(); } catch (_) { /* noop */ } + } + this.hide(); + }; + } + + hide() { + if (!this.container) return; + this.overlay.style.opacity = '0'; + this.modal.style.opacity = '0'; + this.modal.style.transform = 'scale(0.95) translateY(20px)'; + setTimeout(() => { this.container.style.display = 'none'; }, 400); + } +} + +window.txamodal = new TxaModal(); diff --git a/src/lib/txa/txaplayer.css b/src/lib/txa/txaplayer.css new file mode 100644 index 0000000000000000000000000000000000000000..0d9d9fcab9ad7c403e26539e44c867ff85faf1d2 --- /dev/null +++ b/src/lib/txa/txaplayer.css @@ -0,0 +1,1105 @@ +/** + * TXAPlayer Styles + * Glassmorphism design with modern UI + */ + +/* ==================== Base Player Styles ==================== */ +.txa-player { + position: relative; + width: 100%; + height: 100%; + background: #000; + border-radius: 12px; + overflow: hidden; + font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; + user-select: none; + -webkit-user-select: none; + overscroll-behavior-x: none; +} + +/* ==================== Video Container ==================== */ +.txa-video-container { + position: relative; + width: 100%; + height: 100%; + background: #000; + display: flex; + align-items: center; + justify-content: center; +} + +.txa-video { + width: 100%; + height: 100%; + object-fit: contain; +} + +/* ==================== Ambient Light ==================== */ +.txa-ambient-light { + position: absolute; + top: 0; + left: 0; + width: 50px; + height: 50px; + pointer-events: none; + opacity: 0; +} + +/* ==================== Subtitle Overlay ==================== */ +.txa-subtitle-overlay { + position: absolute; + bottom: 80px; + left: 50%; + transform: translateX(-50%); + max-width: 80%; + text-align: center; + color: #fff; + font-size: 24px; + font-weight: 600; + text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.9); + pointer-events: none; + z-index: 10; + line-height: 1.4; + transition: bottom 0.3s ease; +} + +.txa-controls.visible~.txa-subtitle-overlay { + bottom: 100px; +} + +/* ==================== Branding ==================== */ +.txa-branding { + position: absolute; + top: 20px; + right: 20px; + width: 60px; + height: 60px; + opacity: 0.8; + transition: opacity 0.3s ease; + z-index: 5; + pointer-events: none; +} + +.txa-branding.playing { + opacity: 0.3; +} + +.txa-branding.visible { + opacity: 0.8; +} + +.txa-logo { + width: 100%; + height: 100%; + filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5)); +} + +/* ==================== Loading Spinner ==================== */ +.txa-loading-spinner { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + display: none; + z-index: 20; + pointer-events: none; +} + +.txa-loading-spinner.active { + display: block; +} + +.spinner { + width: 50px; + height: 50px; + border: 3px solid rgba(255, 255, 255, 0.1); + border-top-color: #6366f1; + border-radius: 50%; + animation: spin 0.8s linear infinite; +} + +@keyframes spin { + to { + transform: rotate(360deg); + } +} + +/* ==================== Play Overlay ==================== */ +.txa-play-overlay { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + display: flex; + align-items: center; + justify-content: center; + background: rgba(0, 0, 0, 0.3); + opacity: 0; + transition: opacity 0.3s ease; + z-index: 15; + pointer-events: none; +} + +.txa-play-overlay.visible { + opacity: 1; + pointer-events: auto; +} + +.txa-big-play-btn { + width: 80px; + height: 80px; + background: rgba(255, 255, 255, 0.9); + border: none; + border-radius: 50%; + cursor: pointer; + display: flex; + align-items: center; + justify-content: center; + transition: all 0.3s ease; + box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3); +} + +.txa-big-play-btn svg { + width: 32px; + height: 32px; + color: #6366f1; + margin-left: 4px; +} + +.txa-big-play-btn:hover { + transform: scale(1.1); + background: #fff; +} + +/* ==================== Controls ==================== */ +.txa-controls { + position: absolute; + bottom: 0; + left: 0; + width: 100%; + background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, transparent 100%); + padding: 20px; + opacity: 0; + visibility: hidden; + transition: all 0.3s ease; + z-index: 25; +} + +.txa-controls.visible { + opacity: 1; + visibility: visible; +} + +/* Progress Bar */ +.txa-progress-container { + position: relative; + width: 100%; + height: 6px; + margin-bottom: 20px; + cursor: pointer; + touch-action: none; +} + +.txa-progress-bar { + position: relative; + width: 100%; + height: 100%; + background: rgba(255, 255, 255, 0.2); + border-radius: 3px; + overflow: visible; + /* To see handle */ + transition: height 0.1s ease; +} + +.txa-progress-container:hover .txa-progress-bar { + height: 8px; +} + +.txa-progress-buffer { + position: absolute; + top: 0; + left: 0; + height: 100%; + background: rgba(255, 255, 255, 0.3); + transition: width 0.1s linear; + border-radius: 3px; +} + +.txa-progress-played { + position: absolute; + top: 0; + left: 0; + height: 100%; + background: linear-gradient(90deg, #6366f1, #8b5cf6); + transition: width 0.05s linear; + border-radius: 3px; + box-shadow: 0 0 10px rgba(99, 102, 241, 0.5); +} + +.txa-progress-handle { + position: absolute; + top: 50%; + right: -7px; + /* Adjust based on width/2 */ + width: 14px; + height: 14px; + background: #fff; + border-radius: 50%; + transform: translateY(-50%) scale(0); + transition: transform 0.2s ease; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); + z-index: 2; +} + +.txa-progress-container:hover .txa-progress-handle, +.txa-progress-container.dragging .txa-progress-handle { + transform: translateY(-50%) scale(1); +} + +.txa-progress-tooltip { + position: absolute; + bottom: 20px; + left: 50%; + transform: translateX(-50%); + background: rgba(0, 0, 0, 0.9); + color: #fff; + padding: 6px 10px; + border-radius: 6px; + font-size: 13px; + white-space: nowrap; + opacity: 0; + visibility: hidden; + transition: all 0.2s ease; + pointer-events: none; + font-weight: 500; +} + +.txa-progress-container:hover .txa-progress-tooltip { + opacity: 1; + visibility: visible; + bottom: 15px; +} + +/* Controls Row */ +.txa-controls-row { + display: flex; + align-items: center; + justify-content: space-between; +} + +.txa-controls-left, +.txa-controls-right { + display: flex; + align-items: center; + gap: 15px; + /* Increased gap */ +} + +/* Time Display */ +.txa-time { + display: flex; + align-items: center; + gap: 5px; + color: rgba(255, 255, 255, 0.9); + font-size: 13px; + font-weight: 600; + letter-spacing: 0.3px; + min-width: 110px; + justify-content: center; + font-family: 'JetBrains Mono', monospace; +} + +.txa-time-separator { + opacity: 0.5; + font-size: 12px; +} + +/* Buttons */ +.txa-btn { + width: 44px; + height: 44px; + background: transparent; + border: none; + border-radius: 8px; + /* Square with rounded corners looks better */ + display: flex; + align-items: center; + justify-content: center; + cursor: pointer; + transition: all 0.2s ease; + color: rgba(255, 255, 255, 0.9); + position: relative; + overflow: hidden; +} + +.txa-btn:hover { + background: rgba(255, 255, 255, 0.15); + color: #fff; + transform: translateY(-2px); +} + +.txa-btn:active { + transform: translateY(0); +} + +.txa-btn svg { + width: 24px; + height: 24px; + filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3)); +} + +.txa-btn-play .icon-pause { + display: none; +} + +.txa-btn-play.playing .icon-play { + display: none; +} + +.txa-btn-play.playing .icon-pause { + display: block; +} + +/* Vertical Volume Control */ +.txa-volume-container { + position: relative; + display: flex; + align-items: center; + justify-content: center; + width: 44px; + height: 44px; +} + +.txa-volume-slider { + position: absolute; + bottom: 50px; + /* Hiển thị phía trên nút volume */ + left: 50%; + transform: translateX(-50%); + width: 32px; + height: 0; + background: rgba(15, 23, 42, 0.9); + backdrop-filter: blur(10px); + border-radius: 20px; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + opacity: 0; + visibility: hidden; + transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); + overflow: hidden; + padding: 10px 0; + border: 1px solid rgba(255, 255, 255, 0.1); + box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5); + z-index: 50; +} + +.txa-volume-container:hover .txa-volume-slider { + height: 150px; + opacity: 1; + visibility: visible; + bottom: 55px; +} + +.txa-volume-input { + width: 110px; + height: 6px; + -webkit-appearance: none; + appearance: none; + background: rgba(255, 255, 255, 0.2); + border-radius: 3px; + cursor: pointer; + outline: none; + transform: rotate(-90deg); + /* Xoay dọc slider */ + margin: 55px 0; +} + +.txa-volume-input::-webkit-slider-thumb { + -webkit-appearance: none; + appearance: none; + width: 18px; + height: 18px; + background: #fff; + border-radius: 50%; + cursor: pointer; + transition: transform 0.1s; +} + +.txa-volume-input::-webkit-slider-thumb:hover { + transform: scale(1.2); +} + +/* Settings Panel - CENTERED */ +.txa-settings-panel { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%) scale(0.95); + width: 380px; + max-height: 85vh; + background: rgba(15, 23, 42, 0.95); + backdrop-filter: blur(30px) saturate(180%); + border: 1px solid rgba(255, 255, 255, 0.15); + box-shadow: 0 40px 100px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05); + border-radius: 24px; + padding: 30px; + overflow-y: auto; + opacity: 0; + visibility: hidden; + transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); + z-index: 100; +} + +/* Nút Close cho Panels */ +.txa-panel-close { + position: absolute; + top: 15px; + right: 15px; + width: 32px; + height: 32px; + background: rgba(255, 255, 255, 0.05); + border: 1px solid rgba(255, 255, 255, 0.1); + border-radius: 50%; + color: #fff; + font-size: 20px; + display: flex; + align-items: center; + justify-content: center; + cursor: pointer; + transition: all 0.2s; + z-index: 10; +} + +.txa-panel-close:hover { + background: #ef4444; + border-color: #ef4444; + transform: rotate(90deg); +} + +.txa-settings-panel.active { + opacity: 1; + visibility: visible; + transform: translate(-50%, -50%) scale(1); +} + +.txa-settings-content { + display: flex; + flex-direction: column; + gap: 24px; +} + +.txa-setting-group { + display: flex; + flex-direction: column; + gap: 12px; +} + +.txa-setting-label { + color: #94a3b8; + font-size: 12px; + font-weight: 600; + text-transform: uppercase; + letter-spacing: 1px; + margin-left: 4px; +} + +.txa-setting-options { + display: flex; + flex-wrap: wrap; + gap: 8px; +} + +.txa-option-btn { + padding: 8px 16px; + background: rgba(255, 255, 255, 0.05); + border: 1px solid rgba(255, 255, 255, 0.1); + border-radius: 8px; + color: #e2e8f0; + font-size: 13px; + font-weight: 500; + cursor: pointer; + transition: all 0.2s ease; +} + +.txa-option-btn:hover { + background: rgba(255, 255, 255, 0.15); + border-color: rgba(255, 255, 255, 0.2); +} + +.txa-option-btn.active { + background: linear-gradient(135deg, #6366f1, #8b5cf6); + border-color: transparent; + color: #fff; + box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3); +} + +/* Subtitle Style Controls */ +.txa-subtitle-style-group { + display: none; + border-top: 1px solid rgba(255, 255, 255, 0.1); + padding-top: 20px; +} + +.txa-subtitle-style-group.active { + display: flex; +} + +.txa-style-controls { + display: grid; + grid-template-columns: 1fr; + gap: 16px; +} + +.txa-style-control { + display: grid; + grid-template-columns: 80px 1fr; + align-items: center; + gap: 12px; +} + +.txa-style-control label { + color: #cbd5e1; + font-size: 13px; +} + +.txa-style-control input[type="range"], +.txa-style-control input[type="color"], +.txa-style-control select { + width: 100%; + background: rgba(0, 0, 0, 0.3); + border: 1px solid rgba(255, 255, 255, 0.1); + border-radius: 6px; + padding: 6px 10px; + color: #fff; + font-size: 13px; + cursor: pointer; +} + +/* Stats Panel - CENTERED */ +.txa-stats-panel { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%) scale(0.95); + width: 400px; + max-height: 80vh; + background: rgba(15, 23, 42, 0.9); + backdrop-filter: blur(20px); + border: 1px solid rgba(255, 255, 255, 0.1); + border-radius: 16px; + padding: 24px; + overflow-y: auto; + opacity: 0; + visibility: hidden; + transition: all 0.2s ease; + z-index: 100; + box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5); +} + +.txa-stats-panel.active { + opacity: 1; + visibility: visible; + transform: translate(-50%, -50%) scale(1); +} + +.txa-stats-row { + display: flex; + justify-content: space-between; + align-items: center; + padding: 10px 0; + border-bottom: 1px solid rgba(255, 255, 255, 0.05); + font-family: 'JetBrains Mono', monospace; +} + +.txa-stats-label { + color: #94a3b8; + font-size: 12px; +} + +.txa-stats-value { + color: #a5b4fc; + font-size: 12px; +} + +/* Lockdown Overlay */ +.txa-lockdown-overlay { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: rgba(0, 0, 0, 0.98); + display: flex; + align-items: center; + justify-content: center; + z-index: 200; + opacity: 0; + visibility: hidden; + transition: all 0.3s ease; +} + +.txa-lockdown-overlay.active { + opacity: 1; + visibility: visible; +} + +/* Context Menu */ +.txa-context-menu { + position: fixed; + z-index: 9999; + min-width: 220px; + background: rgba(30, 41, 59, 0.95); + backdrop-filter: blur(16px); + border: 1px solid rgba(255, 255, 255, 0.1); + border-radius: 12px; + padding: 6px; + box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); + opacity: 0; + visibility: hidden; + transform: scale(0.95); + transform-origin: top left; + transition: opacity 0.15s ease, transform 0.15s ease; +} + +.txa-context-menu.active { + opacity: 1; + visibility: visible; + transform: scale(1); +} + +.txa-ctx-header { + padding: 12px; + margin-bottom: 6px; + background: rgba(255, 255, 255, 0.05); + border-radius: 8px; + display: flex; + align-items: center; + gap: 10px; +} + +.txa-ctx-header span { + color: #fff; + font-weight: 600; + font-size: 14px; +} + +.txa-ctx-item { + padding: 10px 12px; + color: #cbd5e1; + font-size: 13px; + border-radius: 6px; + transition: all 0.1s; + display: flex; + align-items: center; + gap: 10px; +} + +.txa-ctx-item:hover { + background: rgba(99, 102, 241, 0.2); + color: #fff; +} + +.txa-ctx-item-sub { + margin-left: auto; + font-size: 11px; + opacity: 0.6; + background: rgba(255, 255, 255, 0.1); + padding: 2px 6px; + border-radius: 4px; +} + +.txa-ctx-divider { + height: 1px; + background: rgba(255, 255, 255, 0.1); + margin: 4px 0; +} + +/* Tooltip */ +[data-tooltip] { + position: relative; +} + +[data-tooltip]:hover::after { + content: attr(data-tooltip); + position: absolute; + bottom: 100%; + left: 50%; + transform: translateX(-50%); + background: rgba(15, 23, 42, 0.95); + color: #fff; + padding: 6px 10px; + border-radius: 6px; + font-size: 12px; + white-space: nowrap; + margin-bottom: 10px; + opacity: 0; + visibility: hidden; + transition: all 0.2s ease; + pointer-events: none; + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); + border: 1px solid rgba(255, 255, 255, 0.1); + z-index: 50; +} + +[data-tooltip]:hover::after { + opacity: 1; + visibility: visible; +} + +/* Scrollbar */ +::-webkit-scrollbar { + width: 6px; +} + +::-webkit-scrollbar-track { + background: transparent; +} + +::-webkit-scrollbar-thumb { + background: rgba(255, 255, 255, 0.2); + border-radius: 3px; +} + +::-webkit-scrollbar-thumb:hover { + background: rgba(255, 255, 255, 0.3); +} + +/* ==================== MOBILE RESPONSIVE ==================== */ + +/* Tablet & Small Desktop */ +@media (max-width: 768px) { + .txa-controls { + padding: 12px 14px; + } + + .txa-controls-left, + .txa-controls-right { + gap: 6px; + } + + .txa-btn { + width: 44px; + height: 44px; + } + + .txa-btn svg { + width: 20px; + height: 20px; + } + + .txa-time { + font-size: 12px; + gap: 3px; + } + + .txa-branding { + width: 40px; + height: 40px; + top: 12px; + right: 12px; + } + + .txa-big-play-btn { + width: 64px; + height: 64px; + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + } + + .txa-big-play-btn svg { + width: 26px; + height: 26px; + } + + .txa-subtitle-overlay { + font-size: 16px; + max-width: 90%; + bottom: 60px; + } + + .txa-controls.visible~.txa-subtitle-overlay { + bottom: 80px; + } + + .txa-progress-container { + margin-bottom: 14px; + } + + /* Settings Panel - fullwidth on mobile */ + .txa-settings-panel { + width: 90vw; + max-width: 340px; + padding: 20px; + border-radius: 18px; + } + + .txa-option-btn { + padding: 7px 12px; + font-size: 12px; + } + + /* Stats Panel */ + .txa-stats-panel { + width: 90vw; + max-width: 340px; + padding: 18px; + } + + /* Volume - Design a better mobile interaction */ + .txa-volume-slider { + display: none !important; + } + + /* Make volume button toggle mute only on mobile */ + .is-mobile .txa-volume-slider-wrap { + display: none !important; + } + + .txa-volume-container:hover .txa-volume-slider { + display: none !important; + } + + /* Context Menu - fit mobile screens */ + .txa-context-menu { + min-width: 180px; + max-width: calc(100vw - 40px); + } + + /* Progress tooltip */ + .txa-progress-tooltip { + font-size: 11px; + padding: 4px 8px; + } + + /* Spinner */ + .spinner { + width: 40px; + height: 40px; + } +} + +/* Phone */ +@media (max-width: 480px) { + .txa-controls { + padding: 8px 10px; + } + + .txa-controls-left, + .txa-controls-right { + gap: 2px; + } + + .txa-btn { + width: 34px; + height: 34px; + border-radius: 6px; + } + + .txa-btn svg { + width: 18px; + height: 18px; + } + + .txa-time { + font-size: 11px; + } + + .txa-branding { + width: 32px; + height: 32px; + top: 8px; + right: 8px; + } + + /* Hide redundant icons on mobile */ + .txa-btn-pro { + display: none !important; + } + + .txa-time { + min-width: 90px; + font-size: 10px; + } + + .txa-big-play-btn { + width: 56px; + height: 56px; + position: absolute; + top: calc(50% - 28px); + left: calc(50% - 28px); + } + + .txa-big-play-btn svg { + width: 22px; + height: 22px; + } + + .txa-subtitle-overlay { + font-size: 13px; + max-width: 94%; + bottom: 50px; + text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.9); + } + + .txa-controls.visible~.txa-subtitle-overlay { + bottom: 65px; + } + + /* Progress Bar - Massive Touch Area */ + .txa-progress-container { + margin-bottom: 12px; + height: 4px; + /* Visual height */ + padding-top: 15px; + /* Touch area padding top */ + padding-bottom: 15px; + /* Touch area padding bottom */ + background-clip: content-box; + /* Only show background in content box */ + } + + .txa-progress-bar { + height: 100%; + border-radius: 2px; + } + + .txa-progress-bg { + background: rgba(255, 255, 255, 0.2); + } + + .txa-progress-handle { + width: 14px; + height: 14px; + right: -7px; + transform: translateY(-50%) scale(0); + /* Hide by default on mobile unless dragging */ + transition: transform 0.1s; + } + + .txa-progress-container.dragging .txa-progress-handle, + .active-ui .txa-progress-handle { + transform: translateY(-50%) scale(1); + /* Show when dragging or UI active */ + } + + /* 2x Speed Overlay - Artplayer Style */ + .txa-speed-overlay { + position: absolute; + top: 25%; + left: 50%; + transform: translateX(-50%) translateY(20px); + background: var(--txa-glass); + backdrop-filter: blur(20px); + padding: 12px 24px; + border-radius: 100px; + color: #fff; + font-size: 16px; + font-weight: 800; + display: flex; + align-items: center; + gap: 12px; + opacity: 0; + pointer-events: none; + transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); + z-index: 500; + box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8); + border: 1px solid var(--txa-border); + } + + .txa-speed-overlay.show { + opacity: 1; + transform: translateX(-50%) translateY(0); + } + + .txa-speed-overlay i { + font-size: 12px; + } + + /* Time Preview on Mobile Seek */ + .txa-mobile-seek-time { + position: absolute; + bottom: 40px; + /* Above progress bar */ + left: 50%; + transform: translateX(-50%); + background: rgba(0, 0, 0, 0.8); + color: #fff; + padding: 6px 12px; + border-radius: 8px; + font-size: 14px; + font-weight: 700; + display: none; + z-index: 60; + border: 1px solid rgba(255, 255, 255, 0.1); + } + + .txa-progress-container.dragging .txa-mobile-seek-time { + display: block; + } + + .txa-settings-panel { + width: 94vw; + max-width: none; + padding: 16px; + border-radius: 14px; + max-height: 75vh; + } + + .txa-setting-group { + gap: 8px; + } + + .txa-setting-label { + font-size: 10px; + } + + .txa-option-btn { + padding: 6px 10px; + font-size: 11px; + } + + .txa-stats-panel { + width: 94vw; + max-width: none; + padding: 14px; + border-radius: 14px; + } + + .txa-stats-row { + padding: 8px 0; + } + + .txa-stats-label, + .txa-stats-value { + font-size: 11px; + } + + .spinner { + width: 34px; + height: 34px; + border-width: 2px; + } + + .txa-panel-close { + width: 28px; + height: 28px; + font-size: 16px; + top: 10px; + right: 10px; + } + + /* Style controls compact */ + .txa-style-control { + grid-template-columns: 60px 1fr; + gap: 8px; + } + + .txa-style-control label { + font-size: 11px; + } +} \ No newline at end of file diff --git a/src/lib/txa/txaplayer.js b/src/lib/txa/txaplayer.js new file mode 100644 index 0000000000000000000000000000000000000000..74dc1ba3d8a91f624c3d9ba0566e0e752bbbd39b --- /dev/null +++ b/src/lib/txa/txaplayer.js @@ -0,0 +1,6730 @@ +/** + * TXAPlayer v1.0 - TPhimX Next Generation + * Base Logic: Markers, Subtitles (VTT/SRT), Replay, Skip Outro, Snapshot + * v1.0: Optimized for Astro/Vite environment, integrated with KKPhim API + */ + +// dashjs is loaded via CDN or global script +var dashjs = window.dashjs || {}; + +var TXA_VERSION = 'v1.0'; + +// 🤖 TXA NEON CORE 2030 - STORYBOARD CONFIG +var STORYBOARD_LEVELS = window.STORYBOARD_LEVELS || { + L1: { grid: [10, 10], size: [160, 90], interval: 10, prefix: 'L1_M' }, + L2: { grid: [5, 5], size: [240, 135], interval: 30, prefix: 'L2_M' }, + L3: { grid: [3, 3], size: [320, 180], interval: 60, prefix: 'L3_M' } +}; + +const txaStorage = { + dbName: 'TXA_BLOB_CACHE', + storeName: 'episodes', + version: 1, + _getDB() { + return new Promise((resolve, reject) => { + const request = indexedDB.open(this.dbName, this.version); + request.onupgradeneeded = (e) => { + const db = e.target.result; + if (!db.objectStoreNames.contains(this.storeName)) { + db.createObjectStore(this.storeName, { keyPath: 'id' }); + } + }; + request.onsuccess = (e) => resolve(e.target.result); + request.onerror = (e) => reject(e.target.error); + }); + }, + async get(id) { + try { + const db = await this._getDB(); + return new Promise((resolve, reject) => { + const tx = db.transaction(this.storeName, 'readonly'); + const store = tx.objectStore(this.storeName); + const req = store.get(id); + req.onsuccess = () => resolve(req.result); + req.onerror = () => reject(req.error); + }); + } catch (e) { return null; } + }, + async set(id, data, m3u8Url) { + try { + const db = await this._getDB(); + const tx = db.transaction(this.storeName, 'readwrite'); + const store = tx.objectStore(this.storeName); + store.put({ id, data, m3u8Url, timestamp: Date.now() }); + return true; + } catch (e) { return false; } + } +}; + +if (typeof window.TXAPlayer === 'undefined') { + window.TXAPlayer = class { + + constructor(options) { + const defaults = { + containerId: 'player-container', + videoUrl: '', + posterUrl: '', + title: 'TPhimX Media', + markers: { intro: [0, 65], outro: [0, 0] }, + subtitles: [], + autoPlay: false, + + movieId: null, + episodeId: null, + movieSlug: null, + episodeSlug: null, + movieThumb: null, + epCount: null, + saveUrl: null, + restoreUrl: null, + csrfToken: null, + + nextEpisodeUrl: null, + prevEpisodeUrl: null, + autoSkipIntro: false, + autoNextEpisode: false, + hasSubtitles: true + }; + + this.options = { ...defaults, ...options }; + + // Deep validate markers to support [0,0] fallback + if (this.options.markers) { + if (!this.options.markers.intro || (this.options.markers.intro[0] === 0 && this.options.markers.intro[1] === 0)) { + this.options.markers.intro = defaults.markers.intro; + } + if (!this.options.markers.outro || (this.options.markers.outro[0] === 0 && this.options.markers.outro[1] === 0)) { + this.options.markers.outro = defaults.markers.outro; + } + } + + this.settings = { + volume: this.options.volume !== undefined ? this.options.volume : 1, + muted: this.options.muted !== undefined ? this.options.muted : false, + playbackRate: 1, + autoSkipIntro: this.options.autoSkipIntro || false, + autoNextEpisode: this.options.autoNextEpisode || false, + showRealTime: true, + clockFormat: 'H:i:s', + ...this.loadSettings() + }; + + let target = this.options.container || this.options.containerId; + this.container = typeof target === 'string' + ? (document.querySelector(target) || document.getElementById(target.replace(/^#/, ''))) + : target; + + if (!this.container) { console.error('TXAPlayer: Container not found'); return; } + + // State + this._isAutoNextTriggered = false; + this._autoNextCountdownInterval = null; // Store countdown interval ID + this._isRetryingVideo = false; // Track video retry state + this.dashPlayer = null; + this.video = null; + this.wrapper = null; + this.seekAccumulator = 0; + this.seekDebounce = null; + this.isDragging = false; + this.currentSubCues = []; + this.feedbackTimer = null; + this.activeSubIdx = -1; + this.destroyed = false; + this._handlers = {}; + + // v5.8.0 New Features State + this.isTheaterMode = false; + this.isCinemaMode = false; + this.isSpeedPreview = false; + this.originalSpeed = 1; + this.resumeShown = false; + + // v6.5.0 Preview Thumbnail State + this._previewSpriteUrl = null; + this._previewSpriteLoaded = false; + this._previewLowUrl = null; + this._previewLowLoaded = false; + this._previewUpgradeTimer = null; + + // v6.6.2 - Dynamic Preview Engine Fallback + this._useDynamicPreview = false; + this._previewVideo = null; + this._previewHls = null; + this._isPreviewSeeking = false; + this._pendingPreviewSeekTime = null; + + // v6.5.2 - Turbo Storyboard (Neon Core 2030) + this._useStoryboard = false; + this._storyboardPath = null; + this._currentStoryboardLevel = 'L1'; + this._storyboardCache = new Set(); + + // v6.5.2 - Predictive MP4 Multi-Quality + this._mp4Levels = []; + this._lastMP4Url = null; + + // v6.1.0 Ticker State + this.tickerMax = Math.floor(Math.random() * 9) + 2; // Random 2-10 times + this.tickerCount = 0; + this.tickerNextTime = 5 + Math.random() * 20; // Faster first ticker for better visibility + this._isTickerRunning = false; + this._fixedTickerShown = false; + this._endingTickerShown = false; + this._loadProgress = 0; + this._loadInterval = null; + + this.init(); + } + + init() { + // v6.3.0 - Grouped Console Log + console.group('%c ✨ TPHIMX PLAYER %c ' + TXA_VERSION + ' %c ACTIVE ✨ ', + 'background:#8b5cf6; color:#fff; font-weight:bold; padding:4px 0 4px 8px; border-radius:4px 0 0 4px;', + 'background:#facc15; color:#000; font-weight:900; padding:4px 8px;', + 'background:#8b5cf6; color:#fff; font-weight:bold; padding:4px 8px 4px 0; border-radius:0 4px 4px 0;' + ); + console.log('%cVersion: %c' + TXA_VERSION, 'color:#94a3b8', 'color:#fff; font-weight:bold'); + console.log('%cMode: %cPlatinum Premium', 'color:#94a3b8', 'color:#fbbf24'); + console.groupEnd(); + + if (window.txaPlayer && window.txaPlayer.container === this.container) { + console.log('[TXAPlayer] Destroying existing instance for this container...'); + window.txaPlayer.destroy(); + } + + window.txaPlayer = this; + window.TXAPlayer = TXAPlayer; + + this.container.classList.add('txa-player-skin'); + this.tickerCount = 0; + this.tickerMax = 5; + this.tickerNextTime = 15; + this._uiTimer = null; + + // Bind Methods + this.showUI = this.showUI.bind(this); + this.hideUI = this.hideUI.bind(this); + + this.injectStyles(); + this.renderUI(); + this.setupMedia(); + this.bindEvents(); + this.startClock(); // v6.4.0 Real-time Clock + this.handleMobileEvents(); // v6.1.0 Mobile Events + this.setupContextMenu(); + this.setupShortcuts(); + this.loadInitialSettings(); + this.setupNewFeatures(); // v5.8.0 - Initialize new features + this.updateTopTitle(); // Set initial title + this.detectDevTools(); + console.log( + `%cSTOP! %cThis is a browser feature intended for developers. If someone told you to copy-paste something here to enable a feature or "hack" someone's account, it is a scam and will give them access to your account.\n\n%c[TXAPlayer ${TXA_VERSION}] %cSecurity Active`, + 'color:red;font-family:system-ui;font-size:4rem;font-weight:bold;-webkit-text-stroke:1px black;', + 'font-family:system-ui;font-size:1.5rem;font-weight:bold;', + 'color:#8b5cf6;font-size:1.2rem;font-weight:bold;', + 'color:gray;font-size:1.2rem;' + ); + } + + detectMobile() { + // Use external TXA Detector if available + if (typeof window.detectMobile === 'function') return window.detectMobile(); + if (window.TXADetector) return window.TXADetector.isMobile(); + + // Standard minimal fallback for extreme cases where script fails to load + return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent || '') || window.innerWidth <= 1024; + } + + handleMobileEvents() { + if (!this.detectMobile()) return; + + this.container.classList.add('is-mobile'); + const wrapper = this.wrapper; + + // State for Gestures + let lastTap = 0; + let tapTimer = null; + let touchStartX = 0; + let touchStartY = 0; + let startVolume = 0; + let isLongPress = false; + let pressTimer = null; + let isScrubbing = false; + let isVolumeGesture = false; + + // --- 1. LONG PRESS (2x SPEED) & GESTURE START --- + wrapper.addEventListener('touchstart', (e) => { + // Ignore if touching controls or panels + if (e.target.closest('.txa-controls, .txa-panel, .txa-ctx, .txa-replay-overlay, .txa-skip-btn, .txa-resume-overlay, .txa-next-countdown, .txa-loader, .txa-stats-panel, button, i, .txa-btn')) return; + + const touch = e.touches[0]; + touchStartX = touch.clientX; + touchStartY = touch.clientY; + startVolume = this.video.volume; + isLongPress = false; + isVolumeGesture = false; + + // Start Long Press Timer (YouTube Style 2x Speed) + pressTimer = setTimeout(() => { + if (!this.video.paused && !isScrubbing && !isVolumeGesture) { + isLongPress = true; + this.startSpeedPreview(); + if (window.navigator.vibrate) window.navigator.vibrate(20); + } + }, 500); + + }, { passive: true }); + + wrapper.addEventListener('touchend', (e) => { + if (e.target.closest('.txa-controls, .txa-panel, .txa-ctx, .txa-replay-overlay, .txa-skip-btn, .txa-resume-overlay, .txa-next-countdown, .txa-loader, .txa-stats-panel, button, i, .txa-btn')) return; + + clearTimeout(pressTimer); + + if (isLongPress) { + isLongPress = false; + this.stopSpeedPreview(); + e.preventDefault(); + return; + } + + if (isVolumeGesture) { + isVolumeGesture = false; + return; + } + + const touchEnd = e.changedTouches[0]; + const dx = Math.abs(touchEnd.clientX - touchStartX); + const dy = Math.abs(touchEnd.clientY - touchStartY); + + if (dx > 20 || dy > 20) return; + + const currentTime = new Date().getTime(); + const tapLength = currentTime - lastTap; + + if (tapLength < 300 && tapLength > 0) { + // DOUBLE TAP detection + clearTimeout(tapTimer); + const rect = wrapper.getBoundingClientRect(); + const x = touchEnd.clientX - rect.left; + + // 25% Left (Rewind), 25% Right (Forward), 50% Center (Toggle Play) + if (x < rect.width * 0.25) { + this.seekAccumulated(-10); + } else if (x > rect.width * 0.75) { + this.seekAccumulated(10); + } else { + this.togglePlay(); + } + if (e.cancelable) e.preventDefault(); + } else { + // SINGLE TAP logic - Highly sensitive center zone (60% width) + tapTimer = setTimeout(() => { + const rect = wrapper.getBoundingClientRect(); + const x = touchEnd.clientX - rect.left; + + if (x > rect.width * 0.2 && x < rect.width * 0.8) { + this.togglePlay(); + } else { + if (wrapper.classList.contains('active-ui')) this.hideUI(); + else this.showUI(); + } + }, 200); // Shorter delay for better responsiveness + } + lastTap = currentTime; + if (e.cancelable) e.preventDefault(); + }, { passive: false }); + + wrapper.addEventListener('touchmove', (e) => { + if (isScrubbing) return; + const touch = e.touches[0]; + const dx = touch.clientX - touchStartX; + const dy = touch.clientY - touchStartY; + + // Fullscreen Gestures (Volume on Right Side) + const isFS = !!(document.fullscreenElement || document.webkitIsFullScreen || this.video?.webkitDisplayingFullscreen || this.wrapper.classList.contains('fullscreen-mode')); + + if (isFS && !isLongPress && Math.abs(dy) > 20) { + const rect = wrapper.getBoundingClientRect(); + // Right side check + if (touchStartX > rect.width * 0.5) { + if (!isVolumeGesture && Math.abs(dy) > Math.abs(dx)) { + isVolumeGesture = true; + clearTimeout(pressTimer); + } + if (isVolumeGesture) { + if (e.cancelable) e.preventDefault(); + const sensitivity = 1.5; // Swipe height = 1.5x range + const delta = (touchStartY - touch.clientY) / (rect.height / sensitivity); + const newVol = Math.max(0, Math.min(1, startVolume + delta)); + this.video.volume = newVol; + this.video.muted = false; + this.updateVolUI(); + this.showFeedback('volume'); + } + } + } else if (Math.abs(dx) > 20 || Math.abs(dy) > 20) { + clearTimeout(pressTimer); + } + }, { passive: false }); + + // --- 2. MOBILE PROGRESS SCRUBBING --- + const pWrap = this.container.querySelector('#txa-progress'); + if (pWrap) { + pWrap.addEventListener('touchstart', (e) => { + isScrubbing = true; + pWrap.classList.add('dragging'); + this.showUI(false); + this.updateMobileScrub(e, pWrap); + }, { passive: true }); + + pWrap.addEventListener('touchmove', (e) => { + if (isScrubbing) { + if (e.cancelable) e.preventDefault(); + this.updateMobileScrub(e, pWrap); + } + }, { passive: false }); + + pWrap.addEventListener('touchend', (e) => { + if (isScrubbing) { + isScrubbing = false; + pWrap.classList.remove('dragging'); + const rect = pWrap.getBoundingClientRect(); + const x = e.changedTouches[0].clientX - rect.left; + const pct = Math.max(0, Math.min(1, x / rect.width)); + this.safeSeek(pct * this.video.duration); + const timeOverlay = this.container.querySelector('.txa-mobile-seek-time'); + if (timeOverlay) timeOverlay.style.display = 'none'; + this.showUI(); + } + }, { passive: true }); + } + } + + updateMobileScrub(e, pWrap, timeOverlay) { + if (!this.video.duration) return; + const rect = pWrap.getBoundingClientRect(); + const clientX = e.touches ? e.touches[0].clientX : e.clientX; + const x = clientX - rect.left; + const pct = Math.max(0, Math.min(1, x / rect.width)); + const targetTime = pct * this.video.duration; + + // Update Visual Bar immediately + const playedBar = this.container.querySelector('#txa-played'); + if (playedBar) playedBar.style.width = (pct * 100) + '%'; + + // Update Time Preview + if (timeOverlay) { + timeOverlay.style.display = 'block'; + timeOverlay.innerText = this.formatTime(targetTime, this.video.duration >= 3600); + } + } + + /** + * YouTube-style buffer bar update + * Called every 1s and on FRAG_LOADED to reflect pre-loaded segments + */ + _updateBufferBar() { + if (!this.video) return; + const duration = this.video.duration; + if (!duration || !isFinite(duration)) return; + + const bufBar = this.container.querySelector('#txa-buffer'); + if (!bufBar) return; + + const buffered = this.video.buffered; + const current = this.video.currentTime; + let bufferEnd = 0; + + // Find the buffer range that contains or is closest ahead of current time + for (let i = 0; i < buffered.length; i++) { + if (current >= buffered.start(i) - 0.5 && current <= buffered.end(i)) { + bufferEnd = buffered.end(i); + break; + } + } + + // Fallback: use the largest buffered end + if (bufferEnd === 0 && buffered.length > 0) { + bufferEnd = buffered.end(buffered.length - 1); + } + + const bufPct = (bufferEnd / duration) * 100; + bufBar.style.width = Math.min(100, bufPct).toFixed(2) + '%'; + } + + updateProgress() { + if (!this.video || this.isDragging) return; + const current = this.video.currentTime; + const duration = this.video.duration; + if (!duration) return; + + const pct = (current / duration) * 100; + const playedBar = this.container.querySelector('#txa-played'); + if (playedBar) playedBar.style.width = pct + '%'; + + // Update Buffer Progress (YouTube-style) + this._updateBufferBar(); + + const currText = this.container.querySelector('#txa-curr') || this.container.querySelector('#txa-time'); + if (currText) { + if (currText.id === 'txa-time') { + currText.innerText = this.formatTimeDisplay(); + } else { + currText.innerText = this.formatTime(current, duration >= 3600); + } + } + + this.checkMarkers(current); + this.checkTicker(); + this.renderSubtitles(); + } + + injectStyles() { + if (document.getElementById('txa-css')) return; + const s = document.createElement('style'); + s.id = 'txa-css'; + s.textContent = ` + @import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800;900&display=swap'); + @import url('https://fonts.cdnfonts.com/css/digital-7-mono'); + + + :root { + --txa-brand: #8b5cf6; + --txa-brand-glow: rgba(139,92,246,0.6); + --txa-glass: rgba(12,12,18,0.85); + --txa-glass-light: rgba(30,30,40,0.9); + --txa-border: rgba(255,255,255,0.12); + --txa-text: #f1f5f9; + --txa-intro: #fbbf24; + --txa-outro: #ef4444; + --txa-brand-light: #a78bfa; + } + + /* BRANDING elements - LUXURY STYLE */ + .txa-brand-logo { + position: absolute; top: 25px; left: 25px; z-index: 150; + pointer-events: none; opacity: 0.6; transform: translateY(0); + transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1); + filter: drop-shadow(0 4px 12px rgba(0,0,0,0.8)); + } + + /* REAL-TIME CLOCK - v6.5.1 Top-Down Dynamic */ + .txa-realtime-clock { + position: absolute; top: 25px; right: 25px; z-index: 2147483647; + background: rgba(15, 15, 20, 0.7); backdrop-filter: blur(25px); + border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 50px; + padding: 8px 16px; font-family: 'Digital-7 Mono', 'Outfit', sans-serif; + font-size: 16px; font-weight: 600; color: #fff; + display: none; align-items: center; gap: 8px; + box-shadow: 0 10px 40px rgba(0,0,0,0.6); + transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1); + pointer-events: none; + letter-spacing: 1px; + will-change: top, transform; + } + .txa-realtime-clock.active { display: flex; } + .active-ui .txa-realtime-clock { top: 85px; } /* Slide DOWN to avoid Top Info Bar */ + .txa-realtime-clock i { font-size: 12px; color: var(--txa-brand); opacity: 0.8; } + + @media (max-width: 768px) { + .txa-realtime-clock { font-size: 15px; padding: 6px 12px; top: 15px; right: 15px; } + } + + .txa-wrapper.video-playing.active-ui .txa-brand-logo { opacity: 1; } + .txa-wrapper.video-playing:not(.active-ui) .txa-brand-logo { opacity: 0.25; } + + .txa-logo-text { font-family: 'Outfit', sans-serif; font-weight: 900; font-size: 24px; letter-spacing: -1px; } + .txa-logo-t { color: var(--txa-brand); } + .txa-logo-phimx { color: #fff; } + + /* Smooth Center Play/Pause Animation */ + .txa-center-feedback { + position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.5); + width: 80px; height: 80px; background: rgba(0,0,0,0.4); border-radius: 50%; + display: flex; align-items: center; justify-content: center; + opacity: 0; pointer-events: none; transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); + z-index: 200; border: 1px solid rgba(255,255,255,0.1); backdrop-filter: blur(10px); + } + .txa-center-feedback.animate { opacity: 1; transform: translate(-50%, -50%) scale(1.2); } + .txa-center-feedback.animate-out { opacity: 0; transform: translate(-50%, -50%) scale(1.5); } + .txa-center-feedback i { font-size: 32px; color: #fff; text-shadow: 0 0 15px var(--txa-brand-glow); } + + .txa-watermark { + position: absolute; bottom: 100px; right: 25px; z-index: 80; + pointer-events: none; opacity: 0.3; font-size: 11px; font-weight: 800; + color: rgba(255,255,255,0.4); text-transform: uppercase; letter-spacing: 2px; + font-family: 'Outfit', sans-serif; transition: opacity 0.3s; + } + .txa-watermark span { color: var(--txa-brand); } + .txa-wrapper.video-playing:not(.active-ui) .txa-watermark { opacity: 0.15; } + + .txa-player-skin { position:absolute; inset:0; background:#000; font-family:'Outfit',sans-serif; color:var(--txa-text); user-select:none; overflow:hidden; } + .txa-wrapper { position:relative; width:100%; height:100%; outline:none; container-type: inline-size; container-name: player; } + .txa-video { width:100%; height:100%; object-fit:contain; } + + /* LOADER - Enhanced */ + .txa-loader { position:absolute; inset:0; background:rgba(0,0,0,0.85); z-index:95; display:flex; align-items:center; justify-content:center; flex-direction:column; gap:0; backdrop-filter:blur(8px); pointer-events: none; } + .txa-loader.hidden { display:none; } + .txa-loader-content { display:flex; flex-direction:column; align-items:center; gap:12px; max-width:380px; width:90%; } + .txa-spinner { width:52px; height:52px; border:3px solid rgba(255,255,255,0.08); border-top-color:var(--txa-brand); border-radius:50%; animation:txaspin 0.7s linear infinite; } + .txa-load-pct-row { display:flex; align-items:baseline; gap:10px; justify-content:center; } + .txa-load-pct { font-size:28px; font-weight:900; color:#fff; text-shadow: 0 0 15px var(--txa-brand-glow); font-variant-numeric:tabular-nums; } + .txa-load-speed { font-size:12px; font-weight:700; color:var(--txa-brand); background:rgba(139,92,246,0.15); padding:3px 10px; border-radius:20px; font-variant-numeric:tabular-nums; letter-spacing:0.3px; white-space:nowrap; } + .txa-load-text { font-size:12px; font-weight:500; color:rgba(255,255,255,0.5); letter-spacing:0.3px; text-align:center; } + .txa-load-info { display:flex; flex-wrap:wrap; gap:8px; justify-content:center; margin-top:20px; width:100%; } + .txa-load-info-tag { + font-size:11px; font-weight:700; color:#fff; + background:rgba(255,255,255,0.06); backdrop-filter:blur(10px); + padding:6px 14px; border-radius:10px; + border:1px solid rgba(255,255,255,0.1); + text-transform:uppercase; letter-spacing:0.8px; + display:flex; align-items:center; gap:8px; + box-shadow: 0 10px 30px rgba(0,0,0,0.3); + transition: transform 0.3s ease; + } + .txa-load-info-tag i { font-size:12px; color: var(--txa-brand-light); } + .txa-load-info-tag .tag-val { color:#fff; font-weight: 800; } + .txa-load-info-tag.bg-warning { border-color: rgba(234, 179, 8, 0.4); color: #facc15; } + .txa-load-info-tag.bg-warning i { color: #facc15; } + + @container player (max-width: 500px) { + .txa-load-info { flex-direction: column; align-items: center; gap: 10px; } + .txa-load-info-tag { width: 85%; justify-content: center; font-size: 10px; padding: 10px; } + .txa-load-pct { font-size: 42px; } + } + + .txa-load-bar { width:100%; height:5px; background:rgba(255,255,255,0.1); border-radius:10px; overflow:hidden; margin-top:10px; } + .txa-load-bar-fill { height:100%; width:0%; background:linear-gradient(90deg, var(--txa-brand), #f472b6); border-radius:10px; transition:width 0.4s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: 0 0 15px var(--txa-brand-glow); } + @keyframes txaspin { to { transform:rotate(360deg); } } + + /* STATS PANEL - Premium Centered */ + .txa-stats-panel { + position:absolute; top:50%; left:50%; transform:translate(-50%, -50%) scale(0.9); + z-index:2147483647; + background:rgba(10, 10, 15, 0.9); backdrop-filter:blur(30px); + border:1px solid rgba(255,255,255,0.15); border-radius:24px; + padding:25px; min-width:320px; max-width:450px; + font-family:'Outfit', system-ui, sans-serif; + display:none; pointer-events:auto; + box-shadow: 0 30px 100px rgba(0,0,0,0.9), 0 0 40px rgba(139,92,246,0.2); + transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1); + } + .txa-stats-panel.active { display:block; animation:txaStatsIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards; } + @keyframes txaStatsIn { + from { opacity:0; transform:translate(-50%, -45%) scale(0.95); } + to { opacity:1; transform:translate(-50%, -50%) scale(1); } + } + @keyframes txaShortcutsIn { + from { opacity:0; transform:translateY(20px) scale(0.95); } + to { opacity:1; transform:translateY(0) scale(1); } + } + .txa-shortcuts-panel { + position: absolute; inset: 0; + display: flex; align-items: center; justify-content: center; + pointer-events: none; z-index: 2147483647; + } + .txa-shortcuts-panel.active { pointer-events: auto; } + .txa-shortcuts-panel .txa-shortcuts-content { + background:rgba(10, 10, 15, 0.9); backdrop-filter:blur(30px); + border:1px solid rgba(255,255,255,0.15); border-radius:24px; + padding:25px; min-width:320px; max-width:500px; + font-family:'Outfit', system-ui, sans-serif; + box-shadow: 0 30px 100px rgba(0,0,0,0.9), 0 0 40px rgba(139,92,246,0.2); + opacity: 0; /* Start hidden for animation */ + animation: txaShortcutsIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards; + } + .txa-shortcuts-table { width: 100%; border-collapse: separate; border-spacing: 0 8px; } + .txa-shortcuts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; } + @media (max-width: 600px) { .txa-shortcuts-grid { grid-template-columns: 1fr; } } + .txa-shortcuts-table th { text-align: left; font-size: 11px; text-transform: uppercase; color: var(--txa-brand); letter-spacing: 1px; padding: 0 10px 10px; opacity: 0.8; } + .txa-shortcuts-table td { padding: 8px 10px; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.05); } + .txa-shortcuts-table td:first-child { border-radius: 10px 0 0 10px; border-right: none; font-size: 13px; color: #cbd5e1; } + .txa-shortcuts-table td:last-child { border-radius: 0 10px 10px 0; border-left: none; text-align: right; } + .txa-shortcuts-table kbd { + background: #1e293b; color: #fff; padding: 3px 8px; border-radius: 6px; + border-bottom: 2px solid #000; font-size: 10px; font-weight: 800; + font-family: inherit; display: inline-block; min-width: 18px; text-align: center; + box-shadow: 0 2px 5px rgba(0,0,0,0.5); + } + .txa-shortcuts-table tr:hover td { background: rgba(139, 92, 246, 0.1); border-color: rgba(139, 92, 246, 0.3); } + .txa-stats-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:10px; padding-bottom:8px; border-bottom:1px solid rgba(255,255,255,0.08); } + .txa-stats-title { font-size:12px; font-weight:800; color:var(--txa-brand); text-transform:uppercase; letter-spacing:1px; display:flex; align-items:center; gap:6px; } + .txa-stats-title i { font-size:11px; } + .txa-stats-close { background:none; border:none; color:rgba(255,255,255,0.4); cursor:pointer; font-size:14px; padding:4px; border-radius:6px; transition:0.2s; } + .txa-stats-close:hover { color:#fff; background:rgba(255,255,255,0.1); } + .txa-stats-grid { display:grid; grid-template-columns:1fr 1fr; gap:6px; } + .txa-stat-item { display:flex; flex-direction:column; gap:2px; padding:6px 8px; background:rgba(255,255,255,0.03); border-radius:8px; } + .txa-stat-item.full { grid-column:1/-1; } + .txa-stat-label { font-size:9px; font-weight:700; color:rgba(255,255,255,0.35); text-transform:uppercase; letter-spacing:0.8px; } + .txa-stat-value { font-size:13px; font-weight:700; color:#fff; font-variant-numeric:tabular-nums; } + .txa-stat-value.brand { color:var(--txa-brand); } + .txa-stat-value.green { color:#34d399; } + .txa-stat-value.yellow { color:#fbbf24; } + .txa-stat-value.red { color:#f87171; } + @media (max-width:600px) { + .txa-stats-panel { + top:5px; left:5px; right:5px; width: auto; + min-width:unset; max-width:unset; padding:12px; + font-size:10px; border-radius: 12px; + } + .txa-stats-grid { grid-template-columns: 1fr; gap:4px; } + .txa-stat-item { padding: 4px 8px; flex-direction: row; justify-content: space-between; align-items: center; } + .txa-stat-item.full { flex-direction: column; align-items: flex-start; } + .txa-stat-value { font-size:11px; text-align: right; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } + .txa-stat-item.full .txa-stat-value { text-align: left; max-width: 100%; } + .txa-load-pct { font-size:22px; } + .txa-load-speed { font-size:11px; } + } + + /* REPLAY OVERLAY */ + .txa-replay-overlay { + position:absolute; inset:0; background:rgba(0,0,0,0.85); z-index:250; + display:none; align-items:center; justify-content:center; flex-direction:column; gap:20px; + backdrop-filter:blur(15px); + } + .txa-replay-overlay.show { display:flex; } + .txa-replay-btn { + width:100px; height:100px; background:var(--txa-brand); border:none; border-radius:50%; + display:flex; align-items:center; justify-content:center; cursor:pointer; + transition:all 0.3s; box-shadow:0 10px 40px var(--txa-brand-glow); + } + .txa-replay-btn:hover { transform:scale(1.1); box-shadow:0 15px 50px var(--txa-brand-glow); } + .txa-replay-btn i { font-size:40px; color:#fff; } + .txa-replay-text { font-size:18px; font-weight:600; color:#fff; } + + /* FEEDBACK POPUP */ + .txa-feedback { + position:absolute; top:50%; left:50%; transform:translate(-50%,-50%) scale(0.8); + background:var(--txa-glass); backdrop-filter:blur(20px); border:1px solid var(--txa-border); + padding:16px 28px; border-radius:16px; font-size:22px; font-weight:700; color:#fff; + opacity:0; pointer-events:none; transition:all 0.4s cubic-bezier(0.16,1,0.3,1); z-index:1100; + box-shadow:0 15px 40px rgba(0,0,0,0.5); display:flex; align-items:center; gap:12px; + } + .txa-feedback.show { opacity:1; transform:translate(-50%,-50%) scale(1); } + + /* Smart Avoidance: Shift feedback up when Countdown is showing */ + .has-countdown .txa-feedback.show { transform:translate(-50%, -120%) scale(1); } + @media (max-width: 768px) { + .has-countdown .txa-feedback.show { transform:translate(-50%, -150%) scale(0.9); } + } + .txa-feedback.high-priority { z-index: 1000; background: var(--txa-brand); border-color: rgba(255,255,255,0.3); box-shadow: 0 20px 50px var(--txa-brand-glow); } + .txa-feedback.high-priority span { font-size: 18px; font-weight: 800; } + .txa-feedback i { font-size:26px; color:var(--txa-brand); } + .txa-feedback.high-priority i { color: #fff; } + + /* SEEK BADGES */ + .txa-seek-badge { + position:absolute; top:50%; width:90px; height:90px; background:rgba(0,0,0,0.6); + border-radius:50%; display:flex; flex-direction:column; align-items:center; justify-content:center; + backdrop-filter:blur(10px); border:1px solid var(--txa-border); + opacity:0; pointer-events:none; transition:all 0.25s; z-index:100; + } + .txa-seek-badge.left { left:18%; transform:translate(-50%,-50%); } + .txa-seek-badge.right { right:18%; transform:translate(50%,-50%); } + .txa-seek-badge.show { opacity:1; } + .txa-seek-badge i { font-size:22px; margin-bottom:6px; } + .txa-seek-badge span { font-size:16px; font-weight:700; } + + /* CENTER PLAY */ + .txa-center-play { + position:absolute; top:50%; left:50%; transform:translate(-50%,-50%) scale(0.9); + width:80px; height:80px; background:rgba(255,255,255,0.15); border-radius:50%; + display:flex; align-items:center; justify-content:center; backdrop-filter:blur(10px); + border:1px solid rgba(255,255,255,0.2); opacity:0; transition:all 0.3s; pointer-events:none; + z-index: 150; cursor: pointer; + } + .txa-center-play.show { opacity:1; transform:translate(-50%,-50%) scale(1); pointer-events:auto; } + .txa-center-play i { font-size:30px; } + + .txa-video { width:100%; height:100%; object-fit:contain; cursor: pointer; } + + /* TICKER NOTIFICATION - PREMIUM MARQUEE */ + .txa-ticker-container { + position: absolute; bottom: 40px; left: 0; right: 0; pointer-events: none; z-index: 20000; display: none; + height: 50px; overflow: hidden; + mask-image: linear-gradient(to right, transparent, black 15%, black 85%, transparent); + -webkit-mask-image: linear-gradient(to right, transparent, black 15%, black 85%, transparent); + transition: bottom 0.5s cubic-bezier(0.16, 1, 0.3, 1); + } + .txa-ticker-container.active { display: block; } + .active-ui .txa-ticker-container { bottom: 130px; } /* Push up when controls are visible */ + .has-countdown .txa-ticker-container { bottom: 180px; } + + .txa-ticker-text { + position: absolute; top: 50%; transform: translateY(-50%); + white-space: nowrap; font-size: 15px; font-weight: 500; color: rgba(255,255,255,0.9); + text-shadow: 0 2px 10px rgba(0,0,0,0.8); + font-family: 'Inter', sans-serif; letter-spacing: 0.3px; + left: 100%; will-change: transform, left; + padding: 10px 24px; border-radius: 12px; + display: flex; align-items: center; gap: 10px; + box-shadow: 0 10px 30px rgba(0,0,0,0.3); + } + .txa-ticker-text img { height: 20px; vertical-align: middle; margin-right: 5px; } + + /* Ticker Variants - Random Backgrounds */ + .txa-ticker-text.style-1 { + background: rgba(15, 23, 42, 0.8); + backdrop-filter: blur(12px); + border: 1px solid rgba(255, 255, 255, 0.08); + } + .txa-ticker-text.style-2 { + background: linear-gradient(90deg, rgba(88, 28, 135, 0.85), rgba(124, 58, 237, 0.85)); + backdrop-filter: blur(12px); + border: 1px solid rgba(139, 92, 246, 0.3); + box-shadow: 0 10px 40px rgba(139, 92, 246, 0.4); + } + .txa-ticker-text.style-3 { + background: linear-gradient(90deg, rgba(6, 182, 212, 0.85), rgba(59, 130, 246, 0.85)); + backdrop-filter: blur(12px); + border: 1px solid rgba(6, 182, 212, 0.3); + box-shadow: 0 10px 40px rgba(6, 182, 212, 0.4); + } + .txa-ticker-text.style-4 { + background: rgba(255, 255, 255, 0.1); + backdrop-filter: blur(20px) saturate(180%); + border: 1px solid rgba(255, 255, 255, 0.2); + color: #fff; + } + + .txa-ticker-text span.highlight { color: #facc15; font-weight: 800; } + .txa-ticker-text span.brand { color: #a78bfa; font-weight: 900; text-transform:uppercase; letter-spacing:1px; } + .txa-ticker-text i { font-size: 18px; margin-right: 4px; } + + .txa-ticker-text.run { animation: txamarquee var(--ticker-dur) linear forwards; } + @keyframes txamarquee { + from { left: 100%; transform: translate(0, -50%); } + to { left: 0%; transform: translate(-100%, -50%); } + } + + /* TXA PRO TOGGLES */ + /* TXA PRO TOGGLES - BADGE STYLE */ + .txa-btn-pro { width: 42px; padding: 0; border-radius: 50%; gap: 0; border: 1px solid transparent; position: relative; } + .txa-btn-pro:hover { background: rgba(255,255,255,0.1); border-color: transparent; } + .txa-btn-status { + position: absolute; top: -2px; right: -2px; + font-size: 8px; font-weight: 900; + padding: 1px 3px; border-radius: 6px; + background: #475569; color: #cbd5e1; + transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); + min-width: 18px; text-align: center; + border: 2px solid rgba(0,0,0,0.9); /* Cutout effect for dark mode */ + transform: scale(0.9); z-index: 5; + } + .txa-btn-pro.active .txa-btn-status { + background: var(--txa-brand); color: #fff; + box-shadow: 0 0 8px var(--txa-brand-glow); + transform: scale(1); + border-color: #000; + } + .txa-btn-pro.active i { color: var(--txa-brand-light); filter: drop-shadow(0 0 5px var(--txa-brand-glow)); } + + /* CONTROLS */ + .txa-controls { + position:absolute; bottom:0; left:0; right:0; z-index:100; padding:20px; + background:linear-gradient(transparent, rgba(0,0,0,0.95) 80%); pointer-events:none; + opacity:0; transform:translateY(15px); transition:all 0.4s cubic-bezier(0.16, 1, 0.3, 1); + cursor: default; + } + .active-ui .txa-controls { opacity:1; transform:translateY(0); pointer-events:auto; } + + /* PROGRESS - THICKER */ + .txa-progress-wrap { position:relative; height:10px; width:100%; cursor:pointer; margin-bottom:20px; transition:all 0.15s; } + .txa-progress-wrap:hover { height:16px; } + .txa-progress-bg { position:absolute; inset:0; background:rgba(255,255,255,0.15); border-radius:6px; overflow:hidden; } + .txa-progress-buf { position:absolute; height:100%; background:rgba(255,255,255,0.4); border-radius:6px; width:0; transition: width 0.4s ease; overflow:hidden; z-index: 2; box-shadow: 0 0 10px rgba(255,255,255,0.1); } + .txa-progress-buf.loading { background:rgba(255,255,255,0.5); } + .txa-progress-buf.loading::after { content:''; position:absolute; inset:0; background:linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent); animation:txaBufShimmer 1.5s ease-in-out infinite; } + @keyframes txaBufShimmer { 0% { transform:translateX(-100%); } 100% { transform:translateX(100%); } } + .txa-progress-fill { position:absolute; height:100%; background:var(--txa-brand); border-radius:6px; width:0; box-shadow:0 0 15px var(--txa-brand-glow); z-index: 3; } + + /* SCRUBBER - REFINED */ + .txa-scrubber { + position:absolute; right:-11px; top:50%; transform:translateY(-50%) scale(1); + width:22px; height:22px; background:var(--txa-brand); border-radius:50%; + box-shadow:0 0 15px var(--txa-brand-glow); transition:transform 0.15s; + display:flex; align-items:center; justify-content:center; + z-index: 5; border: 2px solid white; cursor: grab; + } + .txa-scrubber:active { cursor: grabbing; } + .txa-scrubber::after { + content:'T'; font-size:12px; font-weight:900; color:#fff; + font-family:'Inter',sans-serif; + } + + /* MARKERS - HIGHLIGHTED */ + .txa-marker-zone { + position:absolute; top:0; height:100%; z-index:5; pointer-events:none; + } + .txa-marker-zone.intro { + background: #facc15; + opacity: 0.8; + box-shadow: 0 0 15px rgba(250, 204, 21, 0.6); + } + .txa-marker-zone.outro { + background: #f87171; + opacity: 0.8; + box-shadow: 0 0 15px rgba(248, 113, 113, 0.6); + } + .txa-marker-dot { + position:absolute; top:50%; width:8px; height:8px; border-radius:50%; + transform:translateY(-50%); z-index:5; box-shadow:0 0 10px currentColor; border: 1px solid #fff; + } + .txa-marker-dot.intro-start, .txa-marker-dot.intro-end { background:var(--txa-intro); color:var(--txa-intro); } + .txa-marker-dot.outro-start, .txa-marker-dot.outro-end { background:var(--txa-outro); color:var(--txa-outro); } + + /* HOVER TIME TOOLTIP */ + .txa-hover-time { + position:absolute; bottom:28px; transform:translateX(-50%); background:rgba(0,0,0,0.85); + backdrop-filter: blur(8px); + padding:4px 10px; border-radius:6px; font-size:13px; font-weight:800; pointer-events:none; + color: #fff; + opacity:0; transition:opacity 0.15s, bottom 0.2s ease; border:1px solid rgba(255,255,255,0.1); + z-index:20; + box-shadow: 0 4px 12px rgba(0,0,0,0.5); + white-space: nowrap; + } + .txa-progress-wrap:hover .txa-hover-time { opacity:1; } + .txa-progress-wrap.dragging .txa-hover-time { opacity:1; } + + /* Dynamic positioning when preview thumbnail is visible */ + .txa-preview-thumb.has-sprite ~ .txa-hover-time { + bottom: 142px; /* 40px (thumb bottom) + 90px (thumb height) + 12px (offset) */ + background: var(--txa-brand); + border-color: var(--txa-brand-glow); + box-shadow: 0 4px 15px var(--txa-brand-glow); + } + + /* PREVIEW THUMBNAIL on progress bar hover */ + .txa-preview-thumb { + position:absolute; bottom:40px; transform:translateX(-50%); + width:160px; height:90px; + background-color:#000; background-size:1600px 900px; background-repeat:no-repeat; + border-radius:8px; border:2px solid rgba(139,92,246,0.6); + box-shadow:0 8px 32px rgba(0,0,0,0.8), 0 0 16px rgba(139,92,246,0.3); + pointer-events:none; opacity:0; transition:opacity 0.15s ease; + z-index:11; overflow:hidden; + } + .txa-preview-thumb::after { + content:''; position:absolute; inset:0; + border-radius:6px; + box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1); + pointer-events:none; + } + .txa-preview-thumb.loading::before { + content:''; position:absolute; top:50%; left:50%; + width:20px; height:20px; margin:-10px 0 0 -10px; + border:2px solid rgba(255,255,255,0.15); border-top-color:var(--txa-brand); + border-radius:50%; animation:txaspin 0.6s linear infinite; + } + .txa-progress-wrap:hover .txa-preview-thumb.has-sprite { opacity:1; } + .txa-progress-wrap.dragging .txa-preview-thumb.has-sprite { opacity:1; } + + /* TOOLBAR */ + .txa-toolbar { display:flex; align-items:center; justify-content:space-between; position:relative; z-index: 10; } + .txa-group { display:flex; align-items:center; gap:6px; background:var(--txa-glass); backdrop-filter:blur(16px); padding:5px 10px; border-radius:100px; border:1px solid var(--txa-border); transition:all 0.3s; } + + .txa-btn { background:none; border:none; color:#fff; width:42px; height:42px; display:flex; align-items:center; justify-content:center; cursor:pointer; border-radius:50%; transition:all 0.2s; position:relative; } + .txa-btn:hover { background:rgba(255,255,255,0.12); } + .txa-btn i { font-size:17px; filter: drop-shadow(0 0 5px rgba(0,0,0,0.5)); } + + .txa-video { width:100%; height:100%; object-fit:contain; cursor: pointer; } + .txa-wrapper { position:relative; width:100%; height:100%; outline:none; cursor: none; } + .txa-wrapper.active-ui { cursor: auto; } + + /* v6.4.6 - Force Hide Controls (for Speed Preview) */ + .txa-wrapper.hide-controls .txa-controls, + .txa-wrapper.hide-controls .txa-top-info, + .txa-wrapper.hide-controls .txa-realtime-clock { opacity: 0 !important; transform: translateY(15px); pointer-events: none !important; } + .txa-wrapper.hide-controls .txa-top-info { transform: translateY(-20px); } + + /* CC/SUB INDICATOR */ + .txa-btn.cc-active { color: var(--txa-brand); } + .txa-btn.cc-active i { filter: drop-shadow(0 0 8px var(--txa-brand-glow)); } + + /* TOOLTIP PUSHED HIGHER - SMART POSITIONING */ + /* TOOLTIP PUSHED HIGHER - SMART POSITIONING */ + .txa-tooltip { position:absolute; bottom:70px; left:50%; transform:translateX(-50%); background:var(--txa-glass-light); padding:8px 16px; border-radius:10px; font-size:12px; font-weight:700; white-space:nowrap; opacity:0; transition:all 0.2s; pointer-events:none; border:1px solid var(--txa-border); z-index:1000; box-shadow: 0 10px 30px rgba(0,0,0,0.6); } + + /* Right align tooltips for right-side buttons */ + .txa-right-group .txa-btn .txa-tooltip { left:auto; right:0; transform:translateX(0); } + .txa-btn:hover .txa-tooltip { opacity:1; bottom:65px; } + + .txa-time { font-size:13px; font-weight:700; margin:0 14px; color:#cbd5e1; font-feature-settings:"tnum"; } + + /* VOLUME PREMIUM ENHANCED */ + .txa-vol-container { display:flex; align-items:center; position:relative; } + .txa-vol-slider-wrap { + position:relative; + width:0; overflow:hidden; transition:width 0.3s cubic-bezier(0.16, 1, 0.3, 1); + display:flex; align-items:center; height: 42px; + } + .txa-vol-container:hover .txa-vol-slider-wrap { width:130px; } + .txa-vol-slider { + width:115px; height:24px; margin-left:12px; appearance:none; -webkit-appearance:none; + background: linear-gradient(to right, var(--txa-brand) 0%, rgba(255,255,255,0.1) 0%); + background-size: 100% 6px; + background-position: center; + background-repeat: no-repeat; + border-radius:10px; cursor:pointer; outline:none; + transition: background 0.2s; + } + .txa-vol-tooltip-p { + position:absolute; bottom:75px; background:var(--txa-glass-light); + backdrop-filter:blur(10px); color:#fff; padding:4px 10px; border-radius:8px; + font-size:11px; font-weight:800; opacity:0; pointer-events:none; + transition: opacity 0.2s, transform 0.2s; transform:translateX(-50%) translateY(5px); + border:1px solid var(--txa-border); z-index:100; box-shadow:0 8px 20px rgba(0,0,0,0.4); + } + .txa-vol-tooltip-p.visible { opacity:1; transform:translateX(-50%) translateY(0); } + + .txa-vol-slider::-webkit-slider-thumb { + -webkit-appearance:none; appearance:none; width:18px; height:18px; + background:#fff; border-radius:50%; box-shadow:0 0 15px var(--txa-brand-glow); + border: 3px solid var(--txa-brand); cursor:pointer; + transition: transform 0.1s; + } + .txa-vol-slider::-webkit-slider-thumb:hover { transform: scale(1.2); } + .txa-vol-slider::-moz-range-thumb { + appearance:none; width:18px; height:18px; background:#fff; border-radius:50%; + box-shadow:0 0 15px var(--txa-brand-glow); border: 3px solid var(--txa-brand); + cursor:pointer; transition: transform 0.1s; + } + .txa-vol-slider::-moz-range-thumb:hover { transform: scale(1.2); } + + /* SETTINGS PANEL */ + .txa-panel { + position:absolute; bottom:95px; right:20px; width:300px; + max-height: 480px; height: auto; overflow-y:auto; /* Fixed height safe */ + background:var(--txa-glass); backdrop-filter:blur(30px); border:1px solid var(--txa-border); + border-radius:20px; display:none; z-index:200; + box-shadow:0 30px 60px rgba(0,0,0,0.7); animation:txafadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1); + } + /* Custom Scrollbar for Panel */ + .txa-panel::-webkit-scrollbar { width:4px; } + .txa-panel::-webkit-scrollbar-track { background:transparent; } + .txa-panel::-webkit-scrollbar-thumb { background:rgba(255,255,255,0.2); border-radius:4px; } + .txa-panel::-webkit-scrollbar-thumb:hover { background:var(--txa-brand); } + .txa-panel.active { display:block; } + @keyframes txafadeIn { from { opacity:0; transform:translateY(10px) scale(0.95); } to { opacity:1; transform:translateY(0) scale(1); } } + + .txa-panel-header { position: sticky; top: 0; background: #1a1a24; z-index: 20; padding:16px 20px; border-bottom:1px solid var(--txa-border); font-weight:700; font-size:15px; display:flex; align-items:center; gap:10px; } + .txa-panel-header i { color:var(--txa-brand); } + .txa-menu-item { padding:14px 20px; display:flex; align-items:center; justify-content:space-between; cursor:pointer; font-size:14px; color:#e2e8f0; transition:all 0.2s; } + .txa-menu-item:hover { background:rgba(255,255,255,0.08); } + .txa-menu-item.active { color:var(--txa-brand); font-weight:700; background: rgba(139,92,246,0.1); } + .txa-menu-item span:last-child { opacity:0.6; font-size:12px; font-weight:600; } + .txa-menu-item.active span { opacity:1; } + + .txa-menu-back { position: sticky; top: 0; background: #1a1a24; z-index: 20; padding:14px 20px; border-bottom:1px solid var(--txa-border); display:flex; align-items:center; gap:12px; cursor:pointer; font-weight:700; font-size:14px; } + .txa-menu-back:hover { background:rgba(255,255,255,0.08); } + + /* CONTEXT MENU */ + .txa-ctx { + position:absolute; min-width:240px; background:var(--txa-glass); backdrop-filter:blur(30px); + border:1px solid var(--txa-border); border-radius:16px; padding:8px 0; display:none; z-index:300; + box-shadow:0 20px 50px rgba(0,0,0,0.7); animation:txafadeIn 0.2s; + } + .txa-ctx.active { display:block; } + .txa-ctx-header { padding:12px 18px; font-size:11px; text-transform:uppercase; letter-spacing:1px; color:var(--txa-brand); font-weight:800; border-bottom:1px solid var(--txa-border); margin-bottom:4px; } + .txa-ctx-item { padding:12px 18px; font-size:13px; color:#e2e8f0; cursor:pointer; display:flex; justify-content:space-between; align-items:center; transition:0.15s; } + .txa-ctx-item:hover { background:rgba(139,92,246,0.15); color:#fff; } + .txa-ctx-divider { height:1px; background:var(--txa-border); margin:6px 0; } + .txa-ctx-footer { padding:10px 18px; font-size:11px; color:#64748b; text-align:center; font-weight:600; } + + /* SWITCH TOGGLE */ + .txa-switch { position:relative; display:inline-block; width:36px; height:20px; } + .txa-switch input { opacity:0; width:0; height:0; } + .txa-slider { position:absolute; cursor:pointer; inset:0; background:rgba(255,255,255,0.1); transition:.4s; border-radius:34px; border:1px solid var(--txa-border); } + .txa-slider:before { position:absolute; content:""; height:14px; width:14px; left:2px; bottom:2px; background:white; transition:.4s; border-radius:50%; } + .txa-switch input:checked + .txa-slider { background:var(--txa-brand); border-color:transparent; } + .txa-switch input:checked + .txa-slider:before { transform:translateX(16px); } + + /* SUBTITLES - DRAGGABLE */ + .txa-captions { + position:absolute; bottom:110px; left:50%; transform:translateX(-50%); + text-align:center; width:auto; max-width:80%; z-index:90; transition: bottom 0.3s; + cursor:grab; user-select:none; white-space: pre-wrap; word-break: break-word; + } + .txa-captions.dragging { cursor:grabbing; } + .txa-cue { + display:inline-block; padding:8px 16px; border-radius:12px; + background:rgba(0,0,0,0.75); font-size:24px; font-weight:600; + text-shadow:0 2px 4px rgba(0,0,0,0.5); line-height: 1.4; + pointer-events:none; + } + + /* Subtitle Style Presets */ + .txa-captions.size-mini .txa-cue { font-size:14px; padding:4px 8px; } + .txa-captions.size-small .txa-cue { font-size:18px; padding:6px 12px; } + .txa-captions.size-medium .txa-cue { font-size:24px; } + .txa-captions.size-large .txa-cue { font-size:32px; padding:10px 20px; } + .txa-captions.size-jumbo .txa-cue { font-size:48px; padding:14px 28px; } + + .txa-captions.bg-none .txa-cue { background:transparent; text-shadow:1px 1px 2px #000, -1px -1px 2px #000, 1px -1px 2px #000, -1px 1px 2px #000; } + .txa-captions.bg-dark .txa-cue { background:rgba(0,0,0,0.85); } + .txa-captions.bg-light .txa-cue { background:rgba(255,255,255,0.2); } + .txa-captions.bg-glass .txa-cue { background:rgba(15, 23, 42, 0.6); backdrop-filter:blur(8px); border:1px solid rgba(255,255,255,0.1); } + + .txa-captions.weight-bold .txa-cue { font-weight: 800; } + .txa-captions.weight-normal .txa-cue { font-weight: 500; } + + /* Subtitle Stroke (Border) */ + .txa-captions.stroke-on .txa-cue { -webkit-text-stroke: 2px #000; paint-order: stroke fill; } + .txa-captions.stroke-white .txa-cue { -webkit-text-stroke-color: #ffffff !important; } + .txa-captions.stroke-black .txa-cue { -webkit-text-stroke-color: #000000 !important; } + .txa-captions.stroke-yellow .txa-cue { -webkit-text-stroke-color: #facc15 !important; } + .txa-captions.stroke-red .txa-cue { -webkit-text-stroke-color: #f87171 !important; } + .txa-captions.stroke-blue .txa-cue { -webkit-text-stroke-color: #3b82f6 !important; } + + /* Subtitle Color Classes */ + .txa-captions.color-white .txa-cue { color: #ffffff !important; } + .txa-captions.color-yellow .txa-cue { color: #facc15 !important; } + .txa-captions.color-orange .txa-cue { color: #fb923c !important; } + .txa-captions.color-red .txa-cue { color: #f87171 !important; } + .txa-captions.color-green .txa-cue { color: #4ade80 !important; } + .txa-captions.color-cyan .txa-cue { color: #22d3ee !important; } + .txa-captions.color-pink .txa-cue { color: #f472b6 !important; } + .txa-captions.color-violet .txa-cue { color: #a78bfa !important; } + + .txa-stroke-ctrl { overflow:hidden; transition: max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s; max-height:0; opacity:0; } + .txa-stroke-ctrl.active { max-height: 100px; opacity:1; padding-top:10px; } + .txa-color-btn[data-substroke].active { transform:scale(1.2); border:2px solid #fff; } + + /* SKIP BUTTONS - PUSHED HIGHER */ + .txa-skip-btn { position:absolute; bottom:160px; right:30px; z-index:120; background:rgba(255,255,255,0.1); border:2px solid var(--txa-border); backdrop-filter:blur(15px); color:#fff; padding:12px 28px; border-radius:14px; font-size:13px; font-weight:800; cursor:pointer; display:none; transition:all 0.3s cubic-bezier(0.16, 1, 0.3, 1); box-shadow: 0 10px 30px rgba(0,0,0,0.5); } + .txa-skip-btn:hover { background:var(--txa-brand); border-color:transparent; transform:scale(1.05) translateX(-5px); } + .txa-skip-btn.intro { border-color:var(--txa-intro); color:#fff; } + .txa-skip-btn.intro:hover { background:var(--txa-intro); box-shadow: 0 10px 30px rgba(251,191,36,0.5); } + .txa-skip-btn.outro { border-color:var(--txa-outro); color:#fff; } + .txa-skip-btn.outro:hover { background:var(--txa-outro); box-shadow: 0 10px 30px rgba(239,68,68,0.5); } + + /* ZONES */ + .txa-zone { position:absolute; top:0; bottom:0; width:30%; z-index:30; cursor: pointer; } + .txa-zone.left { left:0; } + .txa-zone.right { right:0; } + + /* UTILS */ + .txa-hidden { display:none !important; } + /* Grid for Sub Style */ + .txa-grid-opts { display:grid; grid-template-columns:1fr 1fr; gap:8px; padding:0 20px 14px; } + .txa-grid-item { + background:rgba(255,255,255,0.05); border:1px solid transparent; border-radius:8px; + padding:8px; font-size:12px; text-align:center; cursor:pointer; transition:all 0.2s; color:#cbd5e1; + } + .txa-grid-item:hover { background:rgba(255,255,255,0.1); } + .txa-grid-item.active { background:rgba(139,92,246,0.15); border-color:var(--txa-brand); color:#fff; font-weight:700; } + + /* Color circles */ + .txa-color-opts { display:flex; gap:10px; padding:0 20px 20px; justify-content:center; } + .txa-color-btn { width:32px; height:32px; border-radius:50%; border:2px solid transparent; cursor:pointer; transition:all 0.2s; position:relative; } + .txa-color-btn.active { border-color:white; transform:scale(1.1); box-shadow:0 0 10px var(--txa-brand-glow); } + .txa-color-btn[data-subcolor="white"] { background:#fff; } + .txa-color-btn[data-subcolor="yellow"] { background:#facc15; } + .txa-color-btn[data-subcolor="orange"] { background:#fb923c; } + .txa-color-btn[data-subcolor="red"] { background:#f87171; } + .txa-color-btn[data-subcolor="green"] { background:#4ade80; } + .txa-color-btn[data-subcolor="cyan"] { background:#22d3ee; } + .txa-color-btn[data-subcolor="pink"] { background:#f472b6; } + .txa-color-btn[data-subcolor="violet"] { background:#a78bfa; } + + /* v5.8.0 - THEATER MODE */ + .txa-wrapper.theater-mode { + z-index: 100; + /* Transition for smooth expansion */ + transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1); + } + /* body.theater-mode-active handled in watch.css */ + + /* v5.8.0 - CINEMA AMBIENT LIGHT */ + .txa-ambient-canvas { + position: absolute; + top: -50px; + left: -50px; + right: -50px; + bottom: -50px; + pointer-events: none; + z-index: -1; + filter: blur(80px) saturate(2); + opacity: 0; + transition: opacity 0.8s ease; + } + .txa-wrapper.cinema-mode .txa-ambient-canvas { + opacity: 0.6; + } + .txa-wrapper.cinema-mode { + overflow: visible; + --txa-intro: #fbbf24; + --txa-outro: #8b5cf6; + } + + .txa-switch { position: relative; display: inline-block; width: 34px; height: 18px; margin-left: auto; } + .txa-switch input { opacity: 0; width: 0; height: 0; } + .txa-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(255,255,255,0.1); transition: .4s; border-radius: 34px; border: 1px solid var(--txa-border); } + .txa-slider:before { position: absolute; content: ""; height: 12px; width: 12px; left: 2px; bottom: 2px; background-color: white; transition: .4s; border-radius: 50%; } + input:checked + .txa-slider { background-color: var(--txa-brand); } + input:checked + .txa-slider:before { transform: translateX(16px); } + + .txa-player-skin.cinema-active { + background: transparent !important; + } + + /* v5.8.0 - SPEED PREVIEW INDICATOR */ + .txa-speed-indicator { + position: absolute; + top: 30px; + left: 50%; + transform: translateX(-50%) translateY(-20px) scale(0.9); + background: rgba(139, 92, 246, 0.9); + backdrop-filter: blur(10px); + padding: 12px 24px; + border-radius: 100px; + font-size: 16px; + font-weight: 800; + color: #fff; + display: flex; + align-items: center; + gap: 10px; + z-index: 2147483647; + opacity: 0; + pointer-events: none; + transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1); + box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(139, 92, 246, 0.4); + border: 1px solid rgba(255, 255, 255, 0.2); + } + .txa-speed-indicator.show { + opacity: 1; + transform: translateY(0) scale(1); + } + .txa-speed-indicator i { + animation: txapulse 0.5s infinite alternate; + } + @keyframes txapulse { + from { transform: scale(1); } + to { transform: scale(1.2); } + } + + /* v5.8.0 - RESUME PLAYBACK OVERLAY */ + .txa-resume-overlay { + position: absolute; + bottom: 120px; + left: 50%; + transform: translateX(-50%) translateY(20px); + background: var(--txa-glass); + backdrop-filter: blur(20px); + border: 1px solid var(--txa-border); + border-radius: 20px; + padding: 16px 24px; + display: flex; + align-items: center; + gap: 16px; + z-index: 210; + opacity: 0; + visibility: hidden; + pointer-events: none; + transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1); + box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6); + } + .txa-resume-overlay.show { + opacity: 1; + visibility: visible; + pointer-events: auto; + transform: translateX(-50%) translateY(0); + } + .txa-resume-text { + display: flex; + flex-direction: column; + gap: 4px; + } + .txa-resume-text span:first-child { + font-size: 12px; + color: #94a3b8; + font-weight: 600; + } + .txa-resume-text span:last-child { + font-size: 16px; + font-weight: 800; + color: #fff; + } + .txa-resume-btns { + display: flex; + gap: 10px; + } + .txa-settings-panel { + width: 100vw; + max-width: none; + padding: 24px 20px 40px 20px; + border-radius: 24px 24px 0 0; + bottom: 0; + left: 0; + right: 0; + top: auto; + transform: translateY(105%); + max-height: 80vh; + background: rgba(15, 23, 42, 0.98); + box-shadow: 0 -10px 40px rgba(0,0,0,0.5); + border: none; + border-top: 1px solid rgba(255,255,255,0.1); + transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1); + } + + .txa-settings-panel.active { + transform: translateY(0); + } + + .txa-settings-panel::before { + content: ''; + position: absolute; + top: 10px; + left: 50%; + transform: translateX(-50%); + width: 40px; + height: 4px; + background: rgba(255,255,255,0.2); + border-radius: 10px; + } + .txa-resume-btn { + padding: 10px 20px; + border-radius: 12px; + border: none; + font-weight: 700; + font-size: 13px; + cursor: pointer; + transition: all 0.2s; + } + .txa-resume-btn.primary { + background: var(--txa-brand); + color: #fff; + box-shadow: 0 5px 20px var(--txa-brand-glow); + } + .txa-resume-btn.primary:hover { + transform: translateY(-2px); + box-shadow: 0 8px 25px var(--txa-brand-glow); + } + .txa-resume-btn.secondary { + background: rgba(255, 255, 255, 0.1); + color: #fff; + border: 1px solid var(--txa-border); + } + .txa-resume-btn.secondary:hover { + background: rgba(255, 255, 255, 0.15); + } + + .txa-ripple { + position: absolute; + width: 100px; + height: 100px; + background: radial-gradient(circle, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 70%); + border-radius: 50%; + transform: scale(0); + pointer-events: none; + z-index: 50; + animation: txaripple 0.6s ease-out forwards; + } + @keyframes txaripple { + 0% { transform: scale(0); opacity: 1; } + 100% { transform: scale(4); opacity: 0; } + } + + .txa-btn.mode-active { + color: var(--txa-brand); + } + .txa-btn.mode-active i { + filter: drop-shadow(0 0 8px var(--txa-brand-glow)); + } + + .txa-badge-quality { + position: absolute; + top: 4px; + right: 4px; + background: rgba(255,255,255,0.2); + color: #fff; + font-size: 8px; + font-weight: 800; + padding: 1px 3px; + border-radius: 3px; + line-height: 1; + pointer-events: none; + transition: all 0.3s; + display: none; + z-index: 2; + font-family: sans-serif; + box-shadow: 0 1px 3px rgba(0,0,0,0.3); + } + + /* --- 2X SPEED OVERLAY --- */ + .txa-speed-overlay { + position: absolute; + top: 15%; + left: 50%; + transform: translateX(-50%); + background: rgba(0, 0, 0, 0.6); + color: #fff; + padding: 8px 16px; + border-radius: 20px; + font-size: 13px; + font-weight: 700; + opacity: 0; + transition: opacity 0.2s; + pointer-events: none; + z-index: 10000; + display: flex; + align-items: center; + gap: 8px; + backdrop-filter: blur(4px); + border: 1px solid rgba(255,255,255,0.1); + } + .txa-speed-overlay.show { opacity: 1; } + + /* v6.2.0 - TOP INFO BAR */ + .txa-top-info { + position: absolute; + top: 0; + left: 0; + right: 0; + padding: 15px 25px; + background: linear-gradient(to bottom, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 50%, transparent 100%); + z-index: 10002; + display: flex; + justify-content: space-between; + align-items: center; + opacity: 0; + transform: translateY(-20px); + transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1); + pointer-events: none; + } + .active-ui .txa-top-info { opacity: 1; transform: translateY(0); } + .txa-top-title { + font-weight: 700; + font-size: 15px; + color: #fff; + text-shadow: 0 2px 10px rgba(0,0,0,0.5); + display: flex; + align-items: center; + gap: 8px; + max-width: 80%; + } + + /* Desktop Title Size Increase */ + @media (min-width: 1024px) { + .txa-top-title { font-size: 20px; } + .txa-top-title i { font-size: 18px; } + .txa-top-logo { font-size: 24px; } + } + + .txa-top-title i { color: #facc15; font-size: 14px; } + + .txa-top-logo { font-weight: 800; font-size: 18px; letter-spacing: 0.5px; } + .txa-logo-t { color: #a855f7; } + .txa-logo-phim { color: #fff; } + .txa-logo-x { color: #ef4444; } + + /* Aspect Ratio & Flip Support */ + .txa-video.ratio-4-3 { object-fit: fill; aspect-ratio: 4/3; width: auto; height: 100%; margin: 0 auto; display: block; } + .txa-video.ratio-16-9 { object-fit: contain; aspect-ratio: 16/9; } + .txa-video.ratio-stretch { object-fit: fill; } + .txa-video.flip-h { transform: scaleX(-1); } + .txa-video.flip-v { transform: scaleY(-1); } + .txa-video.flip-both { transform: scale(-1); } + + /* Hide simple logo in FS when controls are shown */ + .fullscreen-mode.active-ui .txa-brand-logo { opacity: 0 !important; visibility: hidden !important; } + + /* --- NEXT EPISODE COUNTDOWN OVERLAY --- */ + .txa-next-countdown { + position: absolute; bottom: 120px; right: 30px; + background: rgba(15, 23, 42, 0.7); backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px); + border: 1px solid rgba(255,255,255,0.15); border-radius: 20px; padding: 20px; + display: flex; align-items: center; gap: 20px; z-index: 220; + transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1); + opacity: 0; transform: translateY(20px) scale(0.9); pointer-events: none; + box-shadow: 0 15px 45px rgba(0,0,0,0.5), 0 0 20px rgba(139,92,246,0.2); + max-width: 400px; + padding: 25px; + } + .txa-next-countdown.show { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; } + .txa-nc-thumb-wrap { position: relative; width: 140px; height: 79px; flex-shrink: 0; } + .txa-nc-thumb { width: 100%; height: 100%; border-radius: 12px; object-fit: cover; background: #000; border: 1px solid rgba(255,255,255,0.1); } + .txa-nc-badge { + position: absolute; top: -10px; left: -10px; + background: var(--txa-brand); color: #fff; + padding: 4px 10px; border-radius: 8px; + font-family: 'Outfit', sans-serif; font-weight: 900; font-size: 16px; + box-shadow: 0 4px 15px var(--txa-brand-glow); + border: 2px solid rgba(255,255,255,0.2); + transform: rotate(-5deg); + z-index: 2; + text-shadow: 0 2px 4px rgba(0,0,0,0.3); + } + .txa-nc-badge span { font-size: 10px; text-transform: uppercase; margin-right: 3px; opacity: 0.8; font-weight: 600; } + .txa-nc-info { flex: 1; display: flex; flex-direction: column; gap: 6px; } + .txa-nc-label { font-size: 12px; font-weight: 800; color: #94a3b8; text-transform: uppercase; letter-spacing: 1.2px; } + .txa-nc-title { font-size: 16px; font-weight: 700; color: #fff; line-height: 1.4; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; } + .txa-nc-timer { font-size: 13px; font-weight: 600; color: var(--txa-brand-light); } + .txa-nc-actions { display: flex; flex-direction: column; gap: 10px; } + .txa-nc-next { + background: var(--txa-brand); border: none; color: #fff; font-size: 12px; font-weight: 800; + padding: 8px 16px; border-radius: 10px; cursor: pointer; transition: 0.3s; + text-align: center; box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3); + } + .txa-nc-next:hover { transform: translateY(-2px); filter: brightness(1.1); } + .txa-nc-cancel { + background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.1); color: #fff; font-size: 11px; font-weight: 700; + padding: 6px 12px; border-radius: 10px; cursor: pointer; transition: 0.3s; + opacity: 0.7; + } + .txa-nc-cancel:hover { background: rgba(255,255,255,0.15); opacity: 1; } + + .txa-desktop-only { display: none; } + @media (min-width: 1024px) { .txa-desktop-only { display: block; } } + + @media (max-width: 768px) { + .txa-next-countdown { left: 15px; right: 15px; bottom: 85px; max-width: none; padding: 15px; gap: 12px; } + .txa-nc-thumb-wrap { width: 100px; height: 56px; } + .txa-nc-badge { font-size: 13px; padding: 3px 8px; top: -8px; left: -8px; } + + /* Mobile Controls Minimalist */ + .txa-controls { padding: 8px 15px; } + .txa-toolbar { display: flex; align-items: center; justify-content: space-between; } + .txa-group { padding: 3px 6px; gap: 4px; background: rgba(0,0,0,0.4); } + .txa-btn { width: 34px; height: 34px; } + .txa-btn i { font-size: 14px; } + .txa-time { font-size: 10px; margin: 0 4px; } + + /* Hide secondary tools on mobile vertical */ + #txa-theater, #txa-cinema, #txa-pip, .txa-vol-container, .txa-watermark { display: none; } + + /* Keep PRO buttons small & showing status */ + .txa-btn-pro { width: 32px; height: 32px; } + .txa-btn-status { font-size: 7px; min-width: 14px; top: -1px; right: -1px; border-width: 1px; transform: scale(0.85); visibility: visible !important; opacity: 1 !important; } + + /* Mobile Controls Minimalist */ + .txa-progress-wrap { height: 14px; margin-bottom: 25px; } + .txa-progress-wrap::before { + content: ''; position: absolute; top: -20px; bottom: -20px; left: 0; right: 0; + } + + /* Fullscreen Landscape Adjustments */ + .fullscreen-mode .txa-controls { padding: 15px 40px 30px; } + .fullscreen-mode .txa-toolbar { gap: 15px; } + + /* AUTOMATIC MINIMALISM BASED ON WIDTH */ + @container player (max-width: 500px) { + .txa-time { display: none !important; } + #txa-cc, #txa-pip, #txa-auto-skip, #txa-auto-next { display: none !important; } + } + + /* Ticker - Only show in fullscreen on mobile as requested */ + .txa-ticker-container { display: none !important; } + .fullscreen-mode .txa-ticker-container.active { display: block !important; bottom: 60px; } + .fullscreen-mode.active-ui .txa-ticker-container { bottom: 120px; } + + /* EXTREME MINIMALISM (< 480px) */ + @media (max-width: 480px) { + #txa-auto-skip, #txa-auto-next, #txa-cc, .txa-time { display: none !important; } + .txa-group { background: transparent; padding: 0; } + .txa-controls { padding: 5px 10px; } + .txa-toolbar { height: 40px; } + .txa-btn { width: 42px; height: 42px; } + .txa-btn i { font-size: 18px; } + .txa-top-info { padding: 10px 15px; } + .txa-top-logo { display: none; } + } + + /* TABLET ADAPTATION (768px - 1024px) */ + @media (min-width: 769px) and (max-width: 1024px) { + .txa-toolbar { gap: 5px; } + #txa-theater, #txa-cinema { display: none; } + .txa-btn-status { font-size: 8px; padding: 1px 3px; } + } + } + .txa-ticker-text { font-size: 13px; padding: 8px 18px; } + + /* v6.4.0 - Intermediate Responsive (Tablet/Resized Desktop) */ + @media (max-width: 1024px) { + .txa-vol-container:hover .txa-vol-slider-wrap { width: 100px; } + .txa-vol-slider { width: 85px; } + .txa-top-title { font-size: 16px; } + } + + /* Hide some buttons on very narrow players even on desk */ + @media (max-width: 650px) { + #txa-theater, #txa-cinema, #txa-pip, .txa-vol-container { display: none !important; } + .txa-group { padding: 4px 8px; } + .txa-btn { width: 38px; height: 38px; } + } + + /* Ultra small devices */ + @media (max-width: 375px) { + .txa-time, #txa-prev, #txa-next { display: none !important; } + .txa-nc-title { font-size: 14px; } + .txa-top-info { padding: 8px 12px; } + .txa-top-logo { font-size: 16px; } + .txa-brand-logo { display: none !important; } + .txa-realtime-clock { display: none !important; } + } + + /* Mobile Landscape Enhancements */ + @media (max-width: 768px) and (orientation: landscape) { + .txa-controls { padding: 6px 12px; } + .txa-toolbar { height: 35px; } + .txa-btn { width: 32px; height: 32px; } + .txa-btn i { font-size: 12px; } + .txa-time { font-size: 9px; margin: 0 2px; } + .txa-progress-wrap { height: 12px; margin-bottom: 20px; } + } + + /* Touch Device Optimizations */ + @media (hover: none) and (pointer: coarse) { + .txa-btn:hover { background: none; } + .txa-btn:active { background: rgba(255,255,255,0.15); transform: scale(0.95); } + .txa-tooltip { display: none !important; } + + /* Larger touch targets for mobile */ + .txa-btn { min-width: 44px; min-height: 44px; } + .txa-vol-slider { height: 28px; } + .txa-vol-slider::-webkit-slider-thumb { width: 20px; height: 20px; } + .txa-vol-slider::-moz-range-thumb { width: 20px; height: 20px; } + } + + /* High DPI Mobile Displays */ + @media (max-width: 768px) and (-webkit-min-device-pixel-ratio: 2) { + .txa-btn i { filter: drop-shadow(0 0 3px rgba(0,0,0,0.3)); } + .txa-progress-wrap { height: 16px; } + .txa-scrubber { width: 16px; height: 16px; } + } + + .txa-menu-item.disabled { opacity: 0.5; pointer-events: auto; cursor: not-allowed; } + .txa-menu-item.disabled:hover { background: transparent; } + `; + document.head.appendChild(s); + } + + renderUI() { + this.container.innerHTML = ` +
+ +
+
+ + TPhimX Media +
+ +
+ + + + + +
+ + 00:00:00 +
+
TPHIMX Player-${TXA_VERSION}
+ + + +
+
+
+
+
0%
+
-- KB/s
+
+
+
Vui lòng chờ trong giây lát...
+
+
+
+ + +
+
+
STREAM STATS
+ +
+
+
+ +
+ + Phát lại +
+ +
50%
+ +
-10s
+
+10s
+ +
+ +
+ + + + + + +
+ + 2x Tua nhanh +
+ +
+
+ Tiếp tục xem? + 00:00 +
+
+ + +
+
+ + +
+
+
Tập--
+ +
+
+ Tập Tiếp Theo + Đang chuẩn bị... + Bắt đầu sau 05s +
+
+ + +
+
+ + +
+
+
+ +
+
+
+
+
+
+
+
0:00
+
+ +
+
+
+ + + +
+ +
100%
+
+ +
+
+
+
0:00 / 0:00
+
+ +
+
+ + +
+ + + + + + +
+
+
+ +
+
+
Settings
+
Playback Speed1x
+
Aspect RatioDefault
+
Video FlipNormal
+
SubtitlesOff
+ +
+ Hiện đồng hồ + +
+ +
+
+
Kiểu hiển thị đồng hồ
+ +
Chỉ thời gian
+
Giờ : Phút : GiâyH:i:s
+
Giờ : PhútH:i
+ +
Thời gian & Ngày
+
Đầy đủH:i:s d/M/YYYY
+
GọnH:i d/M/YYYY
+
Giờ & Ngày/ThángH:i:s d/M
+ +
Chỉ ngày tháng
+
Ngày / Tháng / Nămd/M/Y
+
Chuẩn ISOYYYY/M/d
+
+ +
+
Aspect Ratio
+
Default
+
4:3
+
16:9
+
Stretch
+
+
+
Video Flip
+
Normal
+
Horizontal
+
Vertical
+
Both
+
+
+
Speed
+
0.25x
+
0.5x
+
0.75x
+
Normal
+
1.25x
+
1.5x
+
1.75x
+
2x
+
2.5x
+
3x
+
+
+
Subtitles
+
+
Thiết kế phụ đề
+
+
+
Thiết kế phụ đề
+ +
Cỡ chữ
+
+
Tí hon
+
Nhỏ
+
Vừa
+
Lớn
+
Khổng lồ
+
+ +
Độ đậm
+
+
Thường
+
Đậm
+
+ +
Nền phụ đề
+
+
Không
+
Chuẩn
+
Kính
+
Tối
+
Sáng
+
+ +
Màu chữ
+
+
+
+
+
+
+
+
+
+
+ +
+ Viền chữ + +
+ +
+
Màu viền
+
+
+
+
+
+
+
+
+
+
+
Quality
+
+
+
+
+ +
+
+
+ +
+

QUYỀN TRUY CẬP BỊ CHẶN

+

Chúng tôi phát hiện bạn đang cố gắng can thiệp vào mã nguồn của trình phát. Để bảo vệ bản quyền và tài nguyên hệ thống, trình phát đã bị khóa.

+
+ +
+
TXA SECURITY PROTOCOL ACTIVE
+
+
+ +
+
TXAPlayer Controls
+
Chụp màn hình (4K)
+
Copy Video URL
+
Lặp lại (Loop)Off
+
Thống kê (Stats)
+
+
Bảng phím tắt
+ +
+ +
+
+
`; + this.wrapper = this.container.querySelector('#txa-wrapper'); + this.video = this.container.querySelector('#txa-video'); + } + + async switchEpisode(newOptions = {}) { + // console.log('[TXAPlayer] Switching episode...', newOptions); + + // Save fullscreen state before switching + const wasFullscreen = !!document.fullscreenElement; + // Store reference to wrapper, not fullscreenElement (which will be null after video destroy) + const wrapperToFS = this.wrapper; + + // 0. Save current progress + this.saveWatchProgress(true); + + // Feedback immediately + if (newOptions.isAutoNext) { + this.showToast('⏭️ Tự động chuyển tập...'); + } else { + this.showToast('🚀 Đang chuyển tập mới...'); + } + + // 1. Cleanup current media + if (this._bufferInterval) { clearInterval(this._bufferInterval); this._bufferInterval = null; } + if (this.dashPlayer) { + try { this.dashPlayer.destroy(); } catch (e) { } + this.dashPlayer = null; + } + if (this.hls) { + try { this.hls.destroy(); } catch (e) { } + this.hls = null; + } + if (this._previewHls) { + try { this._previewHls.destroy(); } catch (e) { } + this._previewHls = null; + } + + // Reset video state + if (this.video) { + this.video.pause(); + this.video.src = ""; + this.video.load(); + + // Clear text tracks (subtitles) + while (this.video.firstChild) { + this.video.removeChild(this.video.firstChild); + } + } + + // 2. Update Options + this.options = { ...this.options, ...newOptions }; + + // Clear runtime state + this.currentSubCues = []; + this.activeSubIdx = -1; + this.seekAccumulator = 0; + this._isAutoNextTriggered = false; + this._fixedTickerShown = false; // Reset fixed ticker flag + this._endingTickerShown = false; // Reset ending ticker flag + if (this.wrapper) this.wrapper.classList.remove('has-countdown'); + this.tickerCount = 0; // Reset ticker count for new episode + this._isTickerRunning = false; + this.tickerNextTime = 40; // Wait 40s for new episode ticker + this.resumeShown = false; // Reset resume flag for new episode + + // Clear any pending auto-next countdown + if (this._autoNextCountdownInterval) { + clearInterval(this._autoNextCountdownInterval); + this._autoNextCountdownInterval = null; + } + + // Reset markers on UI immediately + this.renderMarkers(); + + // Reset preview thumbnail state for new episode + this._previewSpriteUrl = null; + this._previewSpriteLoaded = false; + this._previewLowUrl = null; + this._previewLowLoaded = false; + if (this._previewUpgradeTimer) { clearTimeout(this._previewUpgradeTimer); this._previewUpgradeTimer = null; } + const previewThumb = this.container.querySelector('#txa-preview-thumb'); + if (previewThumb) { previewThumb.classList.remove('has-sprite', 'loading'); previewThumb.style.backgroundImage = ''; } + + // Cleanup dynamic preview engine on episode switch + if (this._previewVideo) { + try { + this._previewVideo.pause(); + this._previewVideo.src = ""; + this._previewVideo.load(); + this._previewVideo.remove(); + } catch (e) { } + this._previewVideo = null; + } + if (this._previewHls) { + try { this._previewHls.destroy(); } catch (e) { } + this._previewHls = null; + } + this._useDynamicPreview = false; + this._isPreviewSeeking = false; + this._pendingPreviewSeekTime = null; + + // Reset UI Components + const replay = this.container.querySelector('#txa-replay'); + if (replay) replay.classList.remove('show'); + + const loader = this.container.querySelector('#txa-loader'); + if (loader) loader.classList.remove('hidden'); + + // Update Top Title + this.updateTopTitle(); + + // 3. Re-initialize Media + try { + await this.setupMedia(); + } catch (error) { + console.error('[TXAPlayer] setupMedia failed:', error); + this.reportErrorToServer('setupMediaError', error.message, { stack: error.stack }); + + // Keep loader hidden, show error + if (loader) loader.classList.add('hidden'); + this.showToast('❌ Lỗi load video. Đang thử lại...'); + + // Retry after 2 seconds + setTimeout(() => { + if (!this.destroyed) { + console.log('[TXAPlayer] Retrying setupMedia...'); + this.setupMedia().catch(err => { + console.error('[TXAPlayer] Retry failed:', err); + this.reportErrorToServer('setupMediaError', 'Retry failed: ' + err.message, { stack: err.stack }); + this.showToast('❌ Không thể load video. Vui lòng reload trang.'); + }); + } + }, 2000); + return; // Exit early, don't show feedback + } + + // 4. Re-initialize Subtitles UI (not just tracks) + this.initSubtitles(); + + // 5. Update Navigation Buttons + const prevBtn = this.container.querySelector('#txa-prev'); + const nextBtn = this.container.querySelector('#txa-next'); + if (prevBtn) { + prevBtn.style.display = this.options.prevEpisodeUrl ? 'flex' : 'none'; + } + if (nextBtn) { + nextBtn.style.display = this.options.nextEpisodeUrl ? 'flex' : 'none'; + } + + // 6. Wait for video to be ready before hiding loader + await new Promise((resolve) => { + const checkReady = () => { + // Check if video has valid duration and readyState + if (this.video && this.video.readyState >= 2) { + // HAVE_CURRENT_DATA - enough data to play + resolve(); + } else if (this.destroyed) { + resolve(); // Don't wait if destroyed + } else { + // Wait a bit and check again + setTimeout(checkReady, 100); + } + }; + + // Timeout after 15 seconds + setTimeout(() => { + console.warn('[TXAPlayer] Video ready timeout, proceeding anyway'); + resolve(); + }, 15000); + + checkReady(); + }); + + // 7. Final UI Polish (especially for Full Screen) + this.showUI(); + + // Hide loader only after video is ready + if (loader) loader.classList.add('hidden'); + + // 8. Restore fullscreen if it was active before switching + if (wasFullscreen && wrapperToFS) { + // Wait a bit for video to be ready before requesting fullscreen + setTimeout(async () => { + try { + await wrapperToFS.requestFullscreen(); + console.log('[TXAPlayer] Fullscreen restored after episode switch'); + } catch (err) { + console.warn('[TXAPlayer] Could not restore fullscreen:', err); + } + }, 500); + } + + // 9. Trigger external event if needed + if (this.options.onEpisodeSwitched) { + this.options.onEpisodeSwitched(this.options); + } + + // 10. Final Feedback (High Priority) - Only show after video is ready + setTimeout(() => { + if (!this.destroyed) { + this.showFeedback('high', `⏭️ Đã chuyển: ${this.options.episodeName || 'Tập mới'}`); + } + }, 500); + } + + updateTopTitle() { + const titleEl = this.container.querySelector('#txa-top-title span'); + if (!titleEl) return; + + let movieTitle = this.options.title || 'Đang tải...'; + let episodeTitle = this.options.episodeName || ''; + + // Clean up movieTitle if it already contains the episode name to avoid duplication + if (episodeTitle && movieTitle.includes(episodeTitle)) { + // If movieTitle is "Phim A - Tập 1" and episodeTitle is "Tập 1" + // We want titleStr to be "Xem phim: Phim A - Tập 1" + // Instead of "Xem phim: Phim A - Tập 1 - Tập 1" + titleEl.textContent = 'Xem phim: ' + movieTitle + (this.options.serverName ? ' - ' + this.options.serverName : ''); + return; + } + + let titleStr = 'Xem phim: ' + movieTitle; + + // Handle episode name logic (skip if "Full" or if duplication detected) + if (episodeTitle && !episodeTitle.toLowerCase().includes('full')) { + titleStr += ' - ' + episodeTitle; + } + + // Add server name if exists + if (this.options.serverName) { + titleStr += ' - ' + this.options.serverName; + } + + titleEl.textContent = titleStr; + } + + async getM3u8TsListFast(url) { + // Ensure URL is absolute because proxy URLs might be relative paths (e.g., /api/proxy-media...) + const absoluteUrl = new URL(url, window.location.origin).href; + + let response = await fetch(absoluteUrl, { headers: { 'X-EXTENSION-MODE': '1' } }); + if (!response.ok) throw new Error("Fetch m3u8 lỗi."); + let text = await response.text(); + let lines = text.split("\n"); + + if (text.includes("METHOD=AES-128")) { + throw new Error("Luồng bị mã hóa AES-128 (Yêu cầu HLS.js để giải mã)."); + } + + if (text.includes("EXT-X-STREAM-INF")) { + let variants = []; + for (let i = 0; i < lines.length; i++) { + if (lines[i].includes("EXT-X-STREAM-INF")) { + let info = lines[i]; + let nextLine = lines[i + 1]; + if (nextLine && !nextLine.startsWith("#")) { + let bandwidth = 0; + const bwMatch = info.match(/BANDWIDTH=(\d+)/); + if (bwMatch) bandwidth = parseInt(bwMatch[1]); + + let resolution = "0x0"; + const resMatch = info.match(/RESOLUTION=(\d+x\d+)/); + if (resMatch) resolution = resMatch[1]; + + variants.push({ + url: new URL(nextLine.trim(), absoluteUrl).href, + bandwidth: bandwidth, + resolution: resolution + }); + } + } + } + + if (variants.length > 0) { + // Sort by bandwidth descending (best quality first) + variants.sort((a, b) => b.bandwidth - a.bandwidth); + if (this.options.isAdmin) console.log('[TXAPlayer] High Quality Variant Selected:', variants[0]); + return await this.getM3u8TsListFast(variants[0].url); + } + } + + let tsUrls = []; + let initUrl = null; + let totalDuration = 0; + for (let i = 0; i < lines.length; i++) { + let line = lines[i].trim(); + if (line.startsWith("#EXTINF:")) { + let dur = parseFloat(line.split(":")[1]); + if (!isNaN(dur)) totalDuration += dur; + } + if (line.startsWith("#EXT-X-MAP:URI=")) { + const mapMatch = line.match(/URI="([^"]+)"/); + if (mapMatch) initUrl = new URL(mapMatch[1], absoluteUrl).href; + } + if (line && !line.startsWith("#")) { + tsUrls.push(new URL(line, absoluteUrl).href); + } + } + + if (initUrl) { + tsUrls.unshift(initUrl); // Prepend init map for FMP4 + } + + // Estimate 1.5 Mbps bitrate for size calculation + const estimatedSize = totalDuration * (1.5 * 1024 * 1024 / 8); + return { urls: tsUrls, duration: totalDuration, estimatedSize: estimatedSize }; + } + + async loadM3u8AsMP4(m3u8Url, updateLoadingPct, completeLoading, showLoaderWithProgress) { + try { + const loadText = this.container.querySelector('#txa-load-text'); + const pctEl = this.container.querySelector('#txa-load-pct'); + const speedEl = this.container.querySelector('#txa-load-speed'); + const loadInfoEl = this.container.querySelector('#txa-load-info'); + + // --- CACHE CHECK --- + const cacheKey = this.options.episodeId ? `ep-${this.options.episodeId}` : null; + if (cacheKey) { + if (loadText) loadText.textContent = "🔍 Đang kiểm tra bộ nhớ tạm (Cache)..."; + const cached = await txaStorage.get(cacheKey); + if (cached && (cached.m3u8Url === m3u8Url || m3u8Url.includes('proxy-media'))) { + if (loadText) loadText.textContent = "⚡ Phát từ Cache (Siêu tốc)!"; + updateLoadingPct(100, true); + completeLoading(); + const objectUrl = URL.createObjectURL(cached.data); + this.video.src = objectUrl; + if (this.options.autoPlay) this.video.play().catch(() => { }); + return; + } + } + + if (loadText) loadText.textContent = "⚙️ Đang phân tích luồng HLS..."; + showLoaderWithProgress(5); + + const m3u8Result = await this.getM3u8TsListFast(m3u8Url); + let tsList = m3u8Result.urls; + if (!tsList || tsList.length === 0) throw new Error("Không có file TS trong playlist!"); + + let total = tsList.length; + let mergedBuffers = []; + let totalBytes = 0; + let startTime = performance.now(); + let lastUpdate = performance.now(); + + if (loadInfoEl) { + const sMB = window.txaformat ? window.txaformat.fileSize(m3u8Result.estimatedSize, 1) : (m3u8Result.estimatedSize / (1024 * 1024)).toFixed(1) + " MB"; + const durStr = window.txaformat ? window.txaformat.timeRemaining(m3u8Result.duration) : (m3u8Result.duration / 60).toFixed(0) + " phút"; + loadInfoEl.innerHTML = ` + ${durStr} + ~${sMB} + PREMIUM BLOB ACTIVE + `; + } + + // Batch size for parallel downloads (Turbo Mode: 17) + const batchSize = 17; + + for (let i = 0; i < total; i += batchSize) { + const batch = tsList.slice(i, i + batchSize); + const promises = batch.map(async (ts, idx) => { + const r = await fetch(ts, { + headers: { 'X-EXTENSION-MODE': '1' } + }); + if (!r.ok) throw new Error(`Fetch TS ${i + idx} fail: ${r.status}`); + const buf = await r.arrayBuffer(); + totalBytes += buf.byteLength; + + // Periodic stats update + const now = performance.now(); + if (now - lastUpdate > 500) { + const elapsed = (now - startTime) / 1000; + const speed = totalBytes / elapsed; + const remaining = total - (i + idx); + const avgTimePerTs = elapsed / (i + idx + 1); + const etaSec = Math.round(remaining * avgTimePerTs); + + if (speedEl) { + const speedStr = window.txaformat ? window.txaformat.fileSize(speed, 1) + "/s" : (speed / 1048576).toFixed(1) + " MB/s"; + const etaStr = window.txaformat ? window.txaformat.timeRemaining(etaSec) : (etaSec > 60 ? Math.floor(etaSec / 60) + "m " + (etaSec % 60) + "s" : etaSec + "s"); + speedEl.innerHTML = `${speedStr} ETA: ${etaStr}`; + } + if (loadText) loadText.textContent = `🚀 [TSHORT] Đang tải seg ${i + idx + 1}/${total}...`; + lastUpdate = now; + } + return buf; + }); + + const buffers = await Promise.all(promises); + mergedBuffers.push(...buffers); + + const progress = 10 + Math.floor((Math.min(i + batchSize, total) / total) * 85); + updateLoadingPct(progress, true); + } + + if (loadText) loadText.textContent = "🛠️ Đang lắp ráp Video MP4..."; + + const isFmp4 = tsList[0].includes('.m4s') || tsList[0].includes('.mp4'); + const blobType = isFmp4 ? 'video/mp4' : 'video/mp2t'; + const combinedBlob = new Blob(mergedBuffers, { type: blobType }); + + // --- SAVE TO CACHE --- + if (cacheKey) { + txaStorage.set(cacheKey, combinedBlob, m3u8Url); + } + + const objectUrl = URL.createObjectURL(combinedBlob); + + if (loadText) loadText.textContent = "✨ Sẵn sàng phát (Premium)!"; + updateLoadingPct(100, true); + completeLoading(); + + this.video.src = objectUrl; + if (this.options.autoPlay) this.video.play().catch(() => { }); + + } catch (e) { + console.error("[TXAPlayer Premium] Error: ", e); + if (window.txatoastfy) window.txatoastfy.error('Anti-403 Mode thất bại: ' + e.message, 5000); + + // Fallback to standard HLS + const loadText = this.container.querySelector('#txa-load-text'); + if (loadText) loadText.textContent = "⚠️ Lỗi Anti-403, đang rollback về HLS tiêu chuẩn..."; + setTimeout(() => { + this._initStandardHls(); + }, 2000); + } + } + + async setupMedia() { + if (!this.video) return; + + // --- Google Drive Auto-Resolution --- + // Detects Google Drive sharing links and converts to proxy stream URL + // Supported formats: + // https://drive.google.com/file/d/FILE_ID/view?usp=... + // https://drive.google.com/file/d/FILE_ID/preview + // https://drive.google.com/open?id=FILE_ID + // https://drive.google.com/uc?id=FILE_ID&export=download + if (this.options.videoUrl && this.options.videoUrl.includes('drive.google.com')) { + let driveFileId = null; + + // Pattern 1: /file/d/FILE_ID/ + const fileMatch = this.options.videoUrl.match(/\/file\/d\/([a-zA-Z0-9_-]+)/); + if (fileMatch) { + driveFileId = fileMatch[1]; + } + + // Pattern 2: ?id=FILE_ID or &id=FILE_ID + if (!driveFileId) { + try { + const u = new URL(this.options.videoUrl); + driveFileId = u.searchParams.get('id'); + } catch (_) { } + } + + if (driveFileId) { + // Convert to local proxy stream URL (supports HTTP Range seeking) + const proxyUrl = '/api/drive-stream/' + driveFileId; + console.log( + '%c[TXAPlayer] 📁 Google Drive Detected ✅', + 'color:#4285f4; font-weight:bold;', + { fileId: driveFileId, proxyUrl } + ); + this.options.videoUrl = proxyUrl; + + // Show status on loader + const _loadText = this.container?.querySelector('#txa-load-text'); + if (_loadText) _loadText.textContent = 'Đang kết nối Google Drive...'; + } + } + + // --- StreamC Auto-Resolution (Dynamic Subdomain Support) --- + if (this.options.videoUrl && (this.options.videoUrl.includes('streamc.xyz') || this.options.videoUrl.includes('streamc.top') || /^[a-f0-9]{32}$/i.test(this.options.videoUrl))) { + let hash = null; + let embedHost = ''; + if (/^[a-f0-9]{32}$/i.test(this.options.videoUrl)) { + hash = this.options.videoUrl; + } else if (this.options.videoUrl.includes('hash=')) { + try { + const u = new URL(this.options.videoUrl); + hash = u.searchParams.get('hash'); + embedHost = u.hostname; // e.g., embed18.streamc.xyz + embedHost = u.hostname; + } catch (_) { } + } else { + const m = this.options.videoUrl.match(/\/([a-f0-9]{32})\//i); + if (m) hash = m[1]; + } + if (!embedHost && this.options.videoUrl.includes('streamc')) { + const hm = this.options.videoUrl.match(/(embed\d*\.streamc\.(?:xyz|top))/i); + if (hm) embedHost = hm[1]; + } + if (hash) { + // ── Hiển thị trạng thái đang resolve trên loader ── + const _loadText = this.container?.querySelector('#txa-load-text'); + if (_loadText) _loadText.textContent = 'Đang kết nối nguồn phim...'; + + /** Hiện error overlay thay vì để loader treo mãi */ + const _showStreamCError = (msg, canRetry = true) => { + // Report resolve error to server + this.reportErrorToServer('resolveError', msg, { hash, embedHost }); + + const loader = this.container?.querySelector('#txa-loader'); + if (!loader) return; + const pctEl = loader.querySelector('#txa-load-pct'); + const barFill = loader.querySelector('#txa-load-bar-fill'); + const spinner = loader.querySelector('.txa-spinner'); + const loadText = loader.querySelector('#txa-load-text'); + const speedEl = loader.querySelector('#txa-load-speed'); + + // Đổi giao diện loader → error state + if (spinner) { spinner.style.borderTopColor = '#ef4444'; spinner.style.animationPlayState = 'paused'; } + if (pctEl) { pctEl.textContent = '!'; pctEl.style.color = '#ef4444'; } + if (barFill) { barFill.style.background = '#ef4444'; barFill.style.width = '100%'; barFill.style.boxShadow = '0 0 10px #ef4444'; } + if (speedEl) speedEl.textContent = ''; + if (loadText) { + loadText.style.color = '#fca5a5'; + loadText.innerHTML = `${msg}`; + } + + // Thêm nút Retry nếu chưa có + if (canRetry && !loader.querySelector('#txa-retry-btn')) { + const retryBtn = document.createElement('button'); + retryBtn.id = 'txa-retry-btn'; + retryBtn.innerHTML = 'Thử lại'; + retryBtn.style.cssText = ` + margin-top:14px; padding:8px 22px; + background:#3b82f6; color:#fff; border:none; + border-radius:8px; cursor:pointer; font-size:13px; font-weight:600; + pointer-events:all; + `; + retryBtn.onmouseenter = () => retryBtn.style.background = '#2563eb'; + retryBtn.onmouseleave = () => retryBtn.style.background = '#3b82f6'; + retryBtn.onclick = () => window.location.reload(); + const content = loader.querySelector('.txa-loader-content'); + if (content) content.appendChild(retryBtn); + // Đảm bảo loader nhận pointer events để click được + loader.style.pointerEvents = 'all'; + } + }; + + try { + let resolveUrl = '/api/resolve-streamc?hash=' + encodeURIComponent(hash); + if (embedHost) resolveUrl += '&embed_host=' + encodeURIComponent(embedHost); + + // Timeout 20s — nếu server không trả lời thì abort + const controller = new AbortController(); + const resolveTimeout = setTimeout(() => controller.abort(), 20000); + + let res; + try { + res = await fetch(resolveUrl, { signal: controller.signal }); + } finally { + clearTimeout(resolveTimeout); + } + + // HTTP error (502, 403, 500...) + if (!res.ok) { + const errMsg = res.status === 502 + ? 'Nguồn phim đang bảo trì hoặc bị chặn. Hãy thử nguồn khác.' + : res.status === 403 + ? 'Truy cập bị từ chối. Hãy thử nguồn khác.' + : `Lỗi kết nối (HTTP ${res.status}). Thử lại sau.`; + + console.error(`[TXAPlayer] StreamC HTTP ${res.status} ❌`, { hash, embedHost }); + _showStreamCError(errMsg, true); + return; // Dừng setupMedia — không tiếp tục khởi tạo HLS với URL rỗng + } + + const data = await res.json(); + const checkBlob = this.options.anti403Mode === 'blob' || this.options.videoUrl.includes('anti403=1'); + + if (data.success) { + if (checkBlob && data.raw_url) { + this.options.videoUrl = data.raw_url; + } else if (data.video_url) { + this.options.videoUrl = data.video_url; + if (this.options.isAdmin) { + console.log('%c[TXAPlayer] StreamC Resolved ✅', 'color:#10b981;font-weight:bold;', { + hash, embedHost: data.embed_host, method: data.method, + proxyUrl: data.video_url.substring(0, 80) + '...' + }); + } + } + } else { + const reason = data.message || data.error || 'Không xác định'; + console.error('[TXAPlayer] StreamC Resolve Failed ❌', { hash, embedHost, error: reason }); + _showStreamCError('Không thể kết nối nguồn phim. ' + reason, true); + return; // Dừng — không khởi tạo HLS với URL không hợp lệ + } + + } catch (e) { + if (e.name === 'AbortError') { + console.error('[TXAPlayer] StreamC Resolve Timeout (20s) ❌', { hash, embedHost }); + _showStreamCError('Nguồn phim phản hồi quá chậm. Hãy thử lại.', true); + } else { + console.error('[TXAPlayer] StreamC Resolve Error ❌', e); + _showStreamCError('Lỗi mạng khi kết nối nguồn phim.', true); + } + return; // Dừng — không tiếp tục HLS setup + } + } + } + + // Auto-proxy logic for known SSL-untrusted domains + if (this.options.videoUrl && (this.options.videoUrl.includes('phimmoi.net') || this.options.videoUrl.includes('sing.phimmoi.net') || this.options.videoUrl.includes('streamvda.top') || this.options.videoUrl.includes('phim1280.tv'))) { + if (this.options.videoUrl.includes('?url=')) { + console.log( + '%c[TXAPlayer] 🛡️ SSL Guard Bypass: Already Proxied via Cloudflare/Vercel Proxy ✅', + 'color:#10b981; font-weight:bold;', + { videoUrl: this.options.videoUrl } + ); + } + if (!this.options.videoUrl.includes('/api/proxy-media') && !this.options.videoUrl.includes('/api/video/') && !this.options.videoUrl.includes('?url=')) { + try { + console.log('%c[TXAPlayer] 🛡️ SSL Guard Active: Resolving video URL...', 'color:#f59e0b; font-weight:bold;'); + const r = await fetch(`/api/video/resolve?url=${encodeURIComponent(btoa(this.options.videoUrl))}`); + const data = await r.json(); + if (data.success && data.url) { + this.options.videoUrl = data.url; + console.log('%c[TXAPlayer] 🛡️ SSL Guard Resolved URL ✅', 'color:#10b981; font-weight:bold;', { resolvedUrl: this.options.videoUrl }); + } + } catch (e) { console.error('[TXAPlayer] SSL Guard Fail', e); } + } + } + + const loader = this.container.querySelector('#txa-loader'); + const pctEl = this.container.querySelector('#txa-load-pct'); + const speedEl = this.container.querySelector('#txa-load-speed'); + const barFill = this.container.querySelector('#txa-load-bar-fill'); + const loadInfoEl = this.container.querySelector('#txa-load-info'); + let loadProgress = 0, loadInterval = null, lastBytes = 0, lastSpeedTime = performance.now(); + let speedHistory = [], isHLS = false; + + // Populate loading info tags + if (loadInfoEl) { + const tags = []; + if (this.options.title) tags.push({ icon: 'fa-film', label: this.options.title }); + if (this.options.episodeName) tags.push({ icon: 'fa-list', label: this.options.episodeName }); + if (this.options.serverName) tags.push({ icon: 'fa-server', label: this.options.serverName }); + const url = this.options.videoUrl || ''; + if (url.includes('.mpd')) tags.push({ icon: 'fa-video', label: 'DASH' }); + else if (url.includes('.m3u8')) tags.push({ icon: 'fa-video', label: 'HLS' }); + else if (url.includes('.mp4')) tags.push({ icon: 'fa-video', label: 'MP4' }); + else if (url.includes('/api/drive-stream/')) tags.push({ icon: 'fab fa-google-drive', label: 'Google Drive' }); + loadInfoEl.innerHTML = tags.map(t => ` ${t.label}`).join(''); + } + + const updateSpeed = (n) => { + const now = performance.now(), elapsed = (now - lastSpeedTime) / 1000; + if (elapsed > 0.2 && n > lastBytes) { + const bps = (n - lastBytes) / elapsed; + speedHistory.push(bps); + if (speedHistory.length > 5) speedHistory.shift(); + const currentSpeed = speedHistory.reduce((a, b) => a + b, 0) / speedHistory.length; + if (speedEl) speedEl.textContent = (window.txaformat && window.txaformat.fileSize) ? window.txaformat.fileSize(currentSpeed, 1) + '/s' : (currentSpeed / 1048576).toFixed(1) + ' MB/s'; + lastBytes = n; lastSpeedTime = now; + } + }; + + const updateLoadingPct = (targetPct, instant = false) => { + if (!pctEl) return; + const loadText = this.container.querySelector('#txa-load-text'); + if (instant) { + this._loadProgress = targetPct; + pctEl.textContent = Math.round(this._loadProgress) + '%'; + if (barFill) barFill.style.width = Math.round(this._loadProgress) + '%'; + return; + } + if (this._loadInterval) clearInterval(this._loadInterval); + this._loadInterval = setInterval(() => { + if (this._loadProgress < targetPct) { + const inc = targetPct >= 90 ? 0.5 : (targetPct >= 70 ? 1 : 2); + this._loadProgress = Math.min(targetPct, this._loadProgress + inc); + pctEl.textContent = Math.round(this._loadProgress) + '%'; + if (barFill) barFill.style.width = Math.round(this._loadProgress) + '%'; + if (loadText) { + if (this._loadProgress < 20) loadText.textContent = 'Đang khởi tạo trình phát...'; + else if (this._loadProgress < 40) loadText.textContent = 'Đang tải manifest...'; + else if (this._loadProgress < 70) loadText.textContent = 'Đang đệm dữ liệu...'; + else if (this._loadProgress < 95) loadText.textContent = 'Đang tối ưu hóa...'; + else loadText.textContent = 'Sẵn sàng!'; + } + } else { clearInterval(this._loadInterval); this._loadInterval = null; } + }, 50); + }; + + const completeLoading = () => { + if (this._loadInterval) clearInterval(this._loadInterval); + this._loadProgress = 100; + if (pctEl) pctEl.textContent = '100%'; + if (barFill) barFill.style.width = '100%'; + if (speedEl) speedEl.textContent = '✓ Ready'; + setTimeout(() => loader.classList.add('hidden'), 200); + }; + + const showLoaderWithProgress = (startPct = null) => { + // v6.6.1 - Reset loader styles to default (clearing error states) + if (loader) { + const _spin = loader.querySelector('.txa-spinner'); + const _pct = loader.querySelector('#txa-load-pct'); + const _bar = loader.querySelector('#txa-load-bar-fill'); + const _text = loader.querySelector('#txa-load-text'); + const _retry = loader.querySelector('#txa-retry-btn'); + + if (_spin) { _spin.style.borderTopColor = 'var(--txa-brand)'; _spin.style.animationPlayState = 'running'; } + if (_pct) { _pct.style.color = '#fff'; } + if (_bar) { + _bar.style.background = 'linear-gradient(90deg, var(--txa-brand), #f472b6)'; + _bar.style.boxShadow = '0 0 15px var(--txa-brand-glow)'; + } + if (_text) { _text.style.color = 'rgba(255,255,255,0.5)'; } + if (_retry) _retry.remove(); + loader.style.pointerEvents = 'none'; + } + + loader?.classList.remove('hidden'); + if (startPct !== null) updateLoadingPct(startPct, true); + }; + + // Expose to instance so setQuality can use it + this.updateLoadingPct = updateLoadingPct; + this.hideLoader = completeLoading; + this.showLoader = showLoaderWithProgress; + + if (this.options.videoUrl?.endsWith('.mpd')) { + this.dashPlayer = dashjs.MediaPlayer().create(); + this.dashPlayer.initialize(this.video, this.options.videoUrl, this.options.autoPlay); + updateLoadingPct(10); + this.dashPlayer.on('streamInitialized', () => { + updateLoadingPct(80); + this.container.querySelector('#txa-item-quality').style.display = 'flex'; + this.generateQualityList(); this.initSubtitles(); this.renderMarkers(); + }); + this.dashPlayer.on('canPlay', completeLoading); + this.dashPlayer.on('bufferStalled', () => showLoaderWithProgress(loadProgress > 50 ? loadProgress : 50)); + this.dashPlayer.on('bufferLoaded', completeLoading); + this.dashPlayer.on('fragmentLoadingCompleted', (e) => { if (e?.request?.bytesTotal) updateSpeed(lastBytes + e.request.bytesTotal); }); + } else if (this.options.videoUrl) { + // Updated isHLS detection to be more robust + isHLS = this.options.videoUrl.includes('.m3u8') || + this.options.videoUrl.includes('txaformat=.m3u8') || + this.options.videoUrl.includes('format=.m3u8') || + (this.options.videoUrl.includes('streamc') && this.options.videoUrl.includes('.m3u8')); + + if (isHLS && typeof Hls !== 'undefined' && Hls.isSupported()) { + const isStreamC = this.options.videoUrl.includes('streamc'); + const isBlobMode = this.options.anti403Mode === 'blob' || this.options.videoUrl.includes('anti403=1'); + + if (this.options.isAdmin) { + console.log('%c[TXAPlayer] HLS Detected', 'color: #3b82f6; font-weight: bold;', this.options.videoUrl); + console.log('%c[TXAPlayer] Anti-403 Mode Strategy:', 'color: #10b981;', this.options.anti403Mode); + } + + const initStandardHls = (useExtensionMode = false) => { + if (this.options.isAdmin) console.log('%c[TXAPlayer] Initializing Standard HLS (Proxy Mode)...', 'color: #3b82f6;'); + if (this.hls) this.hls.destroy(); + this.hls = new Hls({ + enableWorker: true, + lowLatencyMode: false, + backBufferLength: 120, + maxBufferLength: 180, + maxMaxBufferLength: 600, + maxBufferSize: 250 * 1000 * 1000, + fragLoadingRetryDelay: 500, + fragLoadingMaxRetry: 10, + manifestLoadingMaxRetry: 5, + manifestLoadingRetryDelay: 1000, + levelLoadingMaxRetry: 5, + fragLoadingTimeOut: 20000, + startLevel: -1, + abandonAudioCodec: true, + fastReadyState: true, + liveDurationInfinity: true, + capLevelToPlayerSize: true, + xhrSetup: (xhr, url) => { + if (useExtensionMode) { + xhr.setRequestHeader('X-EXTENSION-MODE', '1'); + } else { + xhr.setRequestHeader('X-TXA-PLAYER', 'Premium'); + } + } + }); + updateLoadingPct(10); + this.hls.attachMedia(this.video); + this.hls.on(Hls.Events.MEDIA_ATTACHED, () => this.hls.loadSource(this.options.videoUrl)); + this.hls.on(Hls.Events.MANIFEST_LOADING, () => updateLoadingPct(20)); + this.hls.on(Hls.Events.MANIFEST_LOADED, () => updateLoadingPct(40)); + this.hls.on(Hls.Events.LEVEL_LOADING, () => updateLoadingPct(55)); + this.hls.on(Hls.Events.LEVEL_LOADED, () => updateLoadingPct(70)); + this.hls.on(Hls.Events.FRAG_LOADING, () => { if (loadProgress < 80) updateLoadingPct(80); }); + this.hls.on(Hls.Events.FRAG_LOADED, (e, data) => { + updateLoadingPct(90); + if (data?.frag?.stats?.loaded) updateSpeed(lastBytes + data.frag.stats.loaded); + this._updateBufferBar(); + }); + this.hls.on(Hls.Events.MANIFEST_PARSED, () => { + this.renderMarkers(); this.generateQualityList(); + if (this.options.autoPlay) this.video.play().catch(() => { }); + }); + this.hls.on(Hls.Events.LEVEL_SWITCHED, () => { + this.updateQualityUI(this.hls.autoLevelEnabled ? -1 : this.hls.loadLevel); + if (this.hideLoader) this.hideLoader(); // Hide loader after quality switch + }); + this.hls.on(Hls.Events.ERROR, (e, data) => { + console.warn('[TXAPlayer] HLS Error', data.type, data.details, data.fatal); + if (data.fatal) { + if (data.type === Hls.ErrorTypes.NETWORK_ERROR) { + // Network error: thử recover, nếu vẫn fail thì hiện lỗi + this._hlsNetworkRetries = (this._hlsNetworkRetries || 0) + 1; + if (this._hlsNetworkRetries <= 3) { + console.warn(`[TXAPlayer] HLS Network Error - Retry ${this._hlsNetworkRetries}/3`); + setTimeout(() => this.hls?.startLoad(), 1500); + } else { + console.error('[TXAPlayer] HLS Fatal Network Error after retries'); + this._txaShowHlsError('Không tải được video. Kiểm tra kết nối mạng.', data); + } + } else if (data.type === Hls.ErrorTypes.MEDIA_ERROR) { + this._hlsMediaRetries = (this._hlsMediaRetries || 0) + 1; + if (this._hlsMediaRetries <= 2) { + this.hls.recoverMediaError(); + } else { + this._txaShowHlsError('Lỗi giải mã video. Thử tải lại trang.', data); + } + } else { + this._txaShowHlsError('Lỗi không xác định khi phát video.', data); + this.hls.destroy(); + } + } + }); + }; + this._initStandardHls = initStandardHls; + if (isBlobMode) { + if (this.options.isAdmin) console.log('%c[TXAPlayer] 🚀 EXTENSION MODE. Fetching and merging M3U8...', 'color: #10b981; font-weight: bold; font-size: 14px;'); + this.loadM3u8AsMP4(this.options.videoUrl, updateLoadingPct, completeLoading, showLoaderWithProgress); + return; + } + initStandardHls(false); + } else if (isHLS) { + this.showFeedback('high', '❌ Thiếu thư viện HLS.js - Không thể phát M3U8. Vui lòng kiểm tra import HLS.js hoặc dùng link MP4 trực tiếp.'); completeLoading(); + } else { // Regular MP4 or other direct video URL + updateLoadingPct(15); + this.video.src = this.options.videoUrl; + if (this.options.autoPlay) this.video.play().catch(() => { }); + } + this.initSubtitles(); + } + + // Loading state management + const hideLoader = () => completeLoading(); + const showLoader = () => showLoaderWithProgress(loadProgress > 30 ? loadProgress : 30); + + this.video.onloadstart = () => { + if (loadProgress < 20) updateLoadingPct(20); + }; + this.video.onloadeddata = () => { + updateLoadingPct(60); + }; + this.video.oncanplay = () => { + updateLoadingPct(85); + }; + this.video.oncanplaythrough = () => { + completeLoading(); + }; + this.video.onwaiting = showLoader; + this.video.onseeking = () => { + showLoaderWithProgress(50); + }; + this.video.onseeked = hideLoader; + this.video.onplaying = hideLoader; + this.video.onloadedmetadata = () => { + updateLoadingPct(45); + this.updateTopTitle(); + this.renderMarkers(); + this.checkWatchResume(); + this.initSubtitles(); // Ensure subs are synced after metadata + }; + + /** + * ACCURATE BUFFERED PERCENTAGE CALCULATION + */ + this.video.onprogress = () => { + if (!loader.classList.contains('hidden') && pctEl) { + const duration = this.video.duration; + if (!duration || !isFinite(duration)) return; + const buffered = this.video.buffered; + if (buffered.length === 0) return; + let totalBuffered = 0; + for (let i = 0; i < buffered.length; i++) { + totalBuffered += buffered.end(i) - buffered.start(i); + } + const bufferPct = (totalBuffered / duration) * 100; + const mappedPct = 60 + (bufferPct * 0.39); + if (mappedPct > loadProgress) { + updateLoadingPct(Math.min(99, mappedPct)); + } + } + }; + + // ===== CONTINUOUS BUFFER BAR UPDATE (YouTube-style) ===== + if (this._bufferInterval) clearInterval(this._bufferInterval); + const bufBar = this.container.querySelector('#txa-buffer'); + if (bufBar) { + bufBar.classList.add('loading'); + this._bufferInterval = setInterval(() => { + this._updateBufferBar(); + }, 1000); + + this.video.addEventListener('progress', () => { + const duration = this.video.duration; + if (!duration || !isFinite(duration)) return; + const buffered = this.video.buffered; + if (buffered.length > 0) { + const lastEnd = buffered.end(buffered.length - 1); + if (lastEnd >= duration - 1) { + bufBar.classList.remove('loading'); + } + } + }); + } + // ── Watchdog: nếu progress stuck ở ≤20% sau 18s thì hiển thị lỗi ── + // Bảo vệ người dùng khỏi loader treo vô hạn khi mạng chậm hoặc nguồn lỗi + if (this._stuckWatchdog) clearTimeout(this._stuckWatchdog); + this._stuckWatchdog = setTimeout(() => { + // Chỉ kích hoạt nếu loader vẫn còn hiện và progress ≤ 22% + const _loader = this.container?.querySelector('#txa-loader'); + if (!_loader || _loader.classList.contains('hidden')) return; + const _pct = this.container?.querySelector('#txa-load-pct'); + const currentPct = parseInt(_pct?.textContent || '0'); + if (currentPct <= 22 && !isNaN(currentPct)) { + console.warn('[TXAPlayer] Watchdog: loader stuck at', currentPct + '% after 18s'); + this._txaShowHlsError?.('Quá trình tải mất quá nhiều thời gian. Có thể nguồn phim đang bảo trì.', null); + } + }, 18000); + + // Clear watchdog khi video thực sự play được + this.video.addEventListener('playing', () => { + if (this._stuckWatchdog) { clearTimeout(this._stuckWatchdog); this._stuckWatchdog = null; } + }, { once: true }); + + // v6.5.0 - Auto-detect preview thumbnail sprite + this._detectPreviewSprite(); + } + + /** + * v6.5.2 - Auto-detect and preload preview sprite (preview.jpg) + * OR New Turbo Storyboard (L1_M0.jpg) + */ + _detectPreviewSprite() { + let previewUrl = this.options.previewUrl; + const videoUrl = this.options.videoUrl; + const thumbEl = this.container?.querySelector('#txa-preview-thumb'); + if (!thumbEl) return; + + // Reset state + this._useStoryboard = false; + this._currentStoryboardLevel = 'L1'; + + // Try auto-detection of base path + let basePath = ''; + if (videoUrl) { + try { + const url = new URL(videoUrl); + const m3u8Match = videoUrl.match(/(https?:\/\/[^/]*(?:s3|tebi|storage|cdn)[^/]*\/[^?]*\/)/); + if (m3u8Match) { + basePath = m3u8Match[1]; + } else if (!url.pathname.includes('/api/proxy-media') && !url.pathname.includes('proxy-m3u8')) { + const pathParts = url.pathname.split('/'); + pathParts.pop(); + basePath = url.origin + pathParts.join('/') + '/'; + } + } catch (e) { + const lastSlash = videoUrl.lastIndexOf('/'); + if (lastSlash > 0) basePath = videoUrl.substring(0, lastSlash + 1); + } + } + + const handleFinalError = () => { + this._previewSpriteUrl = null; + this._previewSpriteLoaded = false; + thumbEl.classList.remove('loading', 'has-sprite'); + thumbEl.style.backgroundImage = 'none'; + console.log('[TXAPlayer] Storyboard/Legacy Preview failed/missing. Initializing Dynamic Preview Engine...'); + this._initDynamicPreviewEngine(videoUrl, thumbEl); + }; + + // 🚀 STRATEGY 1: Check for Turbo Storyboard (VOD Pipeline v2) + if (basePath) { + const storyboardPath = basePath + 'storyboard/'; + const checkImg = new Image(); + checkImg.src = storyboardPath + 'L1_M0.jpg'; + checkImg.onload = () => { + if (this.destroyed) return; + this._useStoryboard = true; + this._storyboardPath = storyboardPath; + this._previewSpriteLoaded = true; + thumbEl.classList.add('has-sprite'); + thumbEl.classList.remove('loading'); + console.log('%c[TXAPlayer] 🚀 Turbo Storyboard Engine Active (L1) ✅', 'color:#a855f7; font-weight:bold;'); + + // Level Upgrade Timer (Premium Strategy) + this._previewUpgradeTimer = setTimeout(() => { + if (this.destroyed) return; + if (window.innerWidth > 1200) this._currentStoryboardLevel = 'L3'; + else if (window.innerWidth > 768) this._currentStoryboardLevel = 'L2'; + console.log(`%c[TXAPlayer] 🖼️ Storyboard upgraded to ${this._currentStoryboardLevel} for crispness`, 'color:#a855f7;'); + }, 4000); + }; + checkImg.onerror = () => { + // FALLBACK to Strategy 2 (Legacy preview.jpg) + this._detectLegacyPreview(previewUrl, basePath, thumbEl, handleFinalError); + }; + + // 🚀 STRATEGY 3: Detect MP4 Multi-Quality (NEW v6.5.2) + if (videoUrl && videoUrl.toLowerCase().endsWith('.mp4')) { + const filename = videoUrl.split('/').pop(); + if (filename.match(/(\d+)p\.mp4/i)) { + this._detectMP4Qualities(basePath, filename); + } + } + return; + } + + this._detectLegacyPreview(previewUrl, basePath, thumbEl, handleFinalError); + } + + /** + * v6.5.2 - Predictive MP4 Multi-Quality Detection + * Probes tebi/s3 folder for 1080p.mp4, 720p.mp4, etc. + */ + async _detectMP4Qualities(basePath, currentFilename) { + const qualities = ['1080p', '720p', '480p', '360p', '144p']; + const results = []; + const currentLabel = currentFilename.replace('.mp4', '').toLowerCase(); + + for (const q of qualities) { + if (q === currentLabel) { + results.push({ height: parseInt(q), url: this.options.videoUrl, name: q.toUpperCase() }); + continue; + } + + const checkUrl = basePath + q + '.mp4'; + try { + // Fast check with HEAD request + const res = await fetch(checkUrl, { method: 'HEAD' }); + if (res.ok) { + results.push({ height: parseInt(q), url: checkUrl, name: q.toUpperCase() }); + } + } catch (e) { } + } + + if (results.length > 1) { + this._mp4Levels = results.sort((a, b) => b.height - a.height); + this.generateQualityList(); + console.log(`%c[TXAPlayer] 🎞️ Predictive MP4 Active: ${this._mp4Levels.length} qualities found`, 'color:#a855f7; font-weight:bold;'); + } + } + + /** + * v6.5.2 - Legacy Sprite Logic (Backward Compatibility) + */ + _detectLegacyPreview(previewUrl, basePath, thumbEl, handleFinalError) { + if (!previewUrl && basePath) { + previewUrl = basePath + 'preview.jpg'; + } + if (!previewUrl) { + handleFinalError(); + return; + } + + const loadPreview = (useCORS = true) => { + const img = new Image(); + if (useCORS) img.crossOrigin = 'anonymous'; + + img.onload = () => { + if (this.destroyed) return; + if (img.naturalWidth < 160 || img.naturalHeight < 90) { + handleFinalError(); + return; + } + + if (useCORS) { + if (this.options.previewLowUrl) { + this._previewLowUrl = this.options.previewLowUrl; + this._previewLowLoaded = true; + thumbEl.style.backgroundImage = `url('${this._previewLowUrl}')`; + thumbEl.classList.add('has-sprite'); + thumbEl.classList.remove('loading'); + + this._previewUpgradeTimer = setTimeout(() => { + if (this.destroyed) return; + this._previewSpriteUrl = previewUrl; + this._previewSpriteLoaded = true; + thumbEl.style.backgroundImage = `url('${previewUrl}')`; + thumbEl.style.backgroundSize = '1600px 900px'; + }, 500); + } else { + // Canvas downscale + try { + const canvas = document.createElement('canvas'); + const scale = 0.25; + canvas.width = Math.round(img.naturalWidth * scale); + canvas.height = Math.round(img.naturalHeight * scale); + const ctx = canvas.getContext('2d'); + ctx.imageSmoothingEnabled = true; + ctx.imageSmoothingQuality = 'low'; + ctx.drawImage(img, 0, 0, canvas.width, canvas.height); + this._previewLowUrl = canvas.toDataURL('image/jpeg', 0.5); + this._previewLowLoaded = true; + thumbEl.style.backgroundImage = `url('${this._previewLowUrl}')`; + thumbEl.style.backgroundSize = '400px 225px'; + thumbEl.classList.add('has-sprite'); + thumbEl.classList.remove('loading'); + } catch (e) { + useHQDirectly(); + return; + } + this._previewUpgradeTimer = setTimeout(() => { + if (this.destroyed) return; + this._previewSpriteUrl = previewUrl; + this._previewSpriteLoaded = true; + thumbEl.style.backgroundImage = `url('${previewUrl}')`; + thumbEl.style.backgroundSize = '1600px 900px'; + }, 600); + } + } else { + useHQDirectly(); + } + }; + + const useHQDirectly = () => { + this._previewSpriteUrl = previewUrl; + this._previewSpriteLoaded = true; + thumbEl.style.backgroundImage = `url('${previewUrl}')`; + thumbEl.style.backgroundSize = '1600px 900px'; + thumbEl.classList.add('has-sprite'); + thumbEl.classList.remove('loading'); + }; + + img.onerror = () => { + if (useCORS) loadPreview(false); + else handleFinalError(); + }; + img.src = previewUrl; + }; + + loadPreview(true); + } + + /** + * v6.6.2 - Dynamic Canvas Hover Preview Engine Fallback + */ + _initDynamicPreviewEngine(videoUrl, thumbEl) { + if (!videoUrl) return; + if (this._useDynamicPreview) return; + + console.log('[TXAPlayer] Dynamic Canvas Hover Preview Engine initializing...'); + + this._useDynamicPreview = true; + this._previewSpriteLoaded = true; // Set to true to bypass early return in hover + + // Create a hidden video element + this._previewVideo = document.createElement('video'); + this._previewVideo.crossOrigin = 'anonymous'; + this._previewVideo.muted = true; + this._previewVideo.playsInline = true; + this._previewVideo.style.display = 'none'; + this._previewVideo.style.position = 'absolute'; + this._previewVideo.style.width = '0'; + this._previewVideo.style.height = '0'; + this._previewVideo.style.pointerEvents = 'none'; + + // Append to container or body + if (this.container) { + this.container.appendChild(this._previewVideo); + } else { + document.body.appendChild(this._previewVideo); + } + + // Smart CORS proxy: Only proxy HLS streams (.m3u8) to save bandwidth and memory + let streamUrl = videoUrl; + if (videoUrl.includes('.m3u8') && !videoUrl.includes('/api/proxy-media')) { + streamUrl = `/api/proxy-media?url=${encodeURIComponent(videoUrl)}`; + } + + const isHLS = streamUrl.includes('.m3u8') || streamUrl.includes('proxy-media'); + + if (isHLS && typeof Hls !== 'undefined' && Hls.isSupported()) { + this._previewHls = new Hls({ + enableWorker: true, + lowLatencyMode: false, + maxBufferLength: 2, // 1-2 segments to keep network traffic minimal + maxMaxBufferLength: 5, + maxBufferSize: 2 * 1024 * 1024, // 2MB max + capLevelToPlayerSize: true, // Auto-cap to lowest quality level + autoStartLoad: true + }); + this._previewHls.attachMedia(this._previewVideo); + this._previewHls.on(Hls.Events.MEDIA_ATTACHED, () => { + this._previewHls.loadSource(streamUrl); + }); + this._previewHls.on(Hls.Events.MANIFEST_PARSED, () => { + // Pin to lowest quality level to make seeking instant and save bandwidth + let lowestLevel = 0; + let minHeight = 9999; + this._previewHls.levels.forEach((lvl, idx) => { + if (lvl.height && lvl.height < minHeight) { + minHeight = lvl.height; + lowestLevel = idx; + } + }); + this._previewHls.currentLevel = lowestLevel; + this._previewHls.loadLevel = lowestLevel; + }); + } else { + this._previewVideo.src = streamUrl; + } + + // Setup seeked event listener + this._previewVideo.addEventListener('seeked', () => { + this._isPreviewSeeking = false; + + try { + const canvas = document.createElement('canvas'); + canvas.width = 160; + canvas.height = 90; + const ctx = canvas.getContext('2d'); + ctx.drawImage(this._previewVideo, 0, 0, canvas.width, canvas.height); + + const dataUrl = canvas.toDataURL('image/jpeg', 0.6); + + if (thumbEl) { + thumbEl.style.backgroundImage = `url('${dataUrl}')`; + thumbEl.style.backgroundSize = 'cover'; + thumbEl.style.backgroundPosition = 'center'; + thumbEl.classList.add('has-sprite'); + thumbEl.classList.remove('loading'); + } + } catch (e) { + console.warn('[TXAPlayer] Dynamic preview frame extraction failed (CORS restriction):', e); + } + + // Execute pending seek if requested + if (this._pendingPreviewSeekTime !== null && this._pendingPreviewSeekTime !== undefined) { + const nextTime = this._pendingPreviewSeekTime; + this._pendingPreviewSeekTime = null; + + if (Math.abs(this._previewVideo.currentTime - nextTime) > 0.3) { + this._isPreviewSeeking = true; + this._previewVideo.currentTime = nextTime; + } + } + }); + } + + _seekDynamicPreview(targetTime) { + if (!this._previewVideo) return; + + this._pendingPreviewSeekTime = targetTime; + + if (this._isPreviewSeeking) return; + + this._isPreviewSeeking = true; + this._previewVideo.currentTime = targetTime; + } + + /** + * v6.5.2 - Update preview thumbnail position based on hover/scrub position + * Supports both Legacy Sprite, Neon Core Storyboard (L1/L2/L3) and Dynamic Canvas Preview + */ + _updatePreviewThumb(pos) { + const thumbEl = this.container?.querySelector('#txa-preview-thumb'); + if (!thumbEl || !this._previewSpriteLoaded) return; + + const duration = this.video?.duration; + if (!duration || !isFinite(duration)) return; + + const targetTime = pos * duration; + let thumbW = 160, thumbH = 90; + + if (this._useDynamicPreview) { + // Dynamic Canvas Preview Logic! + thumbEl.classList.add('has-sprite'); // ensure it is visible + + // Show loading spinner initially until first frame is rendered + if (!thumbEl.style.backgroundImage || thumbEl.style.backgroundImage === 'none' || thumbEl.style.backgroundImage === 'url("")') { + thumbEl.classList.add('loading'); + } + + // Trigger seek to targetTime + this._seekDynamicPreview(targetTime); + + thumbW = 160; + thumbH = 90; + } else if (this._useStoryboard) { + const config = STORYBOARD_LEVELS[this._currentStoryboardLevel]; + const framesPerChunk = config.grid[0] * config.grid[1]; + const frameIndex = Math.floor(targetTime / config.interval); + const chunkIndex = Math.floor(frameIndex / framesPerChunk); + const frameInChunk = frameIndex % framesPerChunk; + + const chunkUrl = `${this._storyboardPath}${config.prefix}${chunkIndex}.jpg`; + const col = frameInChunk % config.grid[0]; + const row = Math.floor(frameInChunk / config.grid[0]); + + thumbW = config.size[0]; + thumbH = config.size[1]; + + thumbEl.style.backgroundImage = `url('${chunkUrl}')`; + thumbEl.style.backgroundSize = `${config.grid[0] * thumbW}px ${config.grid[1] * thumbH}px`; + thumbEl.style.backgroundPosition = `${-(col * thumbW)}px ${-(row * thumbH)}px`; + thumbEl.style.width = thumbW + 'px'; + thumbEl.style.height = thumbH + 'px'; + } else { + // Legacy Logic + const frameIndex = Math.min(99, Math.floor(targetTime / 10)); + const col = frameIndex % 10; + const row = Math.floor(frameIndex / 10); + thumbEl.style.backgroundPosition = `${-(col * 160)}px ${-(row * 90)}px`; + thumbEl.style.width = '160px'; + thumbEl.style.height = '90px'; + } + + // Clamp to container bounds + const pWrap = this.container?.querySelector('#txa-progress'); + if (pWrap) { + const wrapW = pWrap.offsetWidth; + const half = thumbW / 2; + const leftPx = pos * wrapW; + + if (leftPx < half) { + thumbEl.style.left = half + 'px'; + thumbEl.style.transform = 'translateX(-50%)'; + } else if (leftPx > wrapW - half) { + thumbEl.style.left = (wrapW - half) + 'px'; + thumbEl.style.transform = 'translateX(-50%)'; + } else { + thumbEl.style.left = (pos * 100) + '%'; + thumbEl.style.transform = 'translateX(-50%)'; + } + } + } + + generateQualityList() { + const list = this.container.querySelector('#txa-list-quality'); + if (!list) return; + list.innerHTML = ''; + + let levels = []; + let currentLevel = -1; + + if (this.hls) { + levels = this.hls.levels; + currentLevel = this.hls.currentLevel; + } else if (this.dashPlayer) { + levels = this.dashPlayer.getBitrateInfoListFor('video'); + currentLevel = this.dashPlayer.getQualityFor('video'); + } else if (this._mp4Levels.length > 0) { + levels = this._mp4Levels.map((l, i) => ({ ...l, originalIndex: i })); + // Find current active level by URL + currentLevel = this._mp4Levels.findIndex(l => l.url === (this._lastMP4Url || this.options.videoUrl)); + if (currentLevel !== -1) currentLevel = levels[currentLevel].originalIndex; // Map to originalIndex + } + + // Parse whitelist / manual quality list + const maxQRaw = this.options.maxQuality || 'auto'; + const qList = maxQRaw.split(',').map(s => s.trim().toLowerCase()); + const isAutoAllowed = qList.includes('auto'); + + // Allow single manual quality (e.g. "1080p") to show menu if provided + const hasManualQualities = qList.length > 0 && !(qList.length === 1 && qList[0] === 'auto'); + const hasMultipleLevels = levels && levels.length > 1; + + if (!hasMultipleLevels && !hasManualQualities) { + this.container.querySelector('#txa-item-quality').style.display = 'none'; + return; + } + + this.container.querySelector('#txa-item-quality').style.display = 'flex'; + + // Filter levels for UI + const isWhitelisted = (lvl) => { + if (qList.length === 0 || (qList.length === 1 && qList[0] === 'auto')) return true; + const h = lvl.height || 0; + const label = h + 'p'; + return qList.some(q => { + if (q === label) return true; // Exact match: "360p" === "360p" + if (q === '4k' && h >= 2160) return true; + if (q === '2k' && h >= 1440) return true; + if (q === 'fullhd' && h >= 1080) return true; + if (q === 'fhd' && h >= 1080) return true; + if (q === 'hd' && h >= 720 && h < 1080) return true; // HD = 720p only + if (['cam', 'sd'].includes(q)) return true; + return false; + }); + }; + + const availableLevels = levels.map((l, i) => ({ ...l, originalIndex: i })); + const filteredLevels = availableLevels.filter(isWhitelisted); + + let uiLevels = filteredLevels.length > 0 ? filteredLevels : availableLevels; + + // Dummy Logic if no levels found but Manual Quality is Enforced (e.g. Single MP4 with label) + if (uiLevels.length === 0 && hasManualQualities && (!levels || levels.length === 0)) { + uiLevels = qList.filter(q => q !== 'auto').map((q, i) => ({ + height: parseInt(q.replace(/\D/g, '')) || 0, + name: q.toUpperCase(), + originalIndex: -100 - i // Dummy Index + })); + // Force first one active if no HLS + if (currentLevel === -1 && uiLevels.length > 0) currentLevel = uiLevels[0].originalIndex; + } + + // Special check: if we are using MP4 Predictive levels, levels are ALREADY uiLevels + if (this._mp4Levels.length > 0 && uiLevels.length === 0) { + uiLevels = levels; + } + + // Auto Option (Only if we have real HLS/DASH switching capability) + if (isAutoAllowed && (hasMultipleLevels || levels.length > 0)) { + const autoItem = document.createElement('div'); + autoItem.className = 'txa-menu-item' + (currentLevel === -1 ? ' active' : ''); + autoItem.dataset.quality = -1; + + let autoLabel = 'Auto'; + if (uiLevels.length < levels.length && levels.length > 0) { + const sorted = [...uiLevels].sort((a, b) => a.height - b.height); + const minH = sorted[0]?.height || '?'; + const maxH = sorted[sorted.length - 1]?.height || '?'; + autoLabel = `Auto (${minH}p — ${maxH}p)`; + } + + autoItem.innerHTML = `${autoLabel}`; + + if (this.options.isGuest) { + autoItem.classList.add('disabled'); + autoItem.onclick = (e) => { e.stopPropagation(); this.showToast('Vui lòng đăng nhập để chỉnh chất lượng', 'warning'); }; + } else { + autoItem.onclick = (e) => { + e.stopPropagation(); + this.setQuality(-1); + this.updateQualityUI(-1); + }; + } + list.appendChild(autoItem); + } + + // Sort levels high to low for UI + const sortedUiLevels = [...uiLevels].sort((a, b) => b.height - a.height); + + sortedUiLevels.forEach((level) => { + const item = document.createElement('div'); + item.className = 'txa-menu-item' + (currentLevel === level.originalIndex ? ' active' : ''); + item.dataset.quality = level.originalIndex; // Ensure dataset is set + + if (this.options.isGuest) item.classList.add('disabled'); + + let label = ''; + + // Priority 1: Resolution based + if (level.height && level.height > 0) { + label = level.height + 'p'; + if (level.height >= 2160) label = '2160p 4K'; + else if (level.height >= 1440) label = '1440p 2K'; + else if (level.height >= 1080) label = '1080p FHD'; + else if (level.height >= 720) label = '720p HD'; + } + + // Priority 2: Level Name from Manifest + if ((!label || label === '0p') && level.name) { + label = level.name; + } + + // Priority 3: Inference from Config (Single Custom Label) + if (!label || label === '0p') { + const specialLabels = qList.filter(q => + q !== 'auto' && !q.endsWith('p') && !['4k', '2k', 'fullhd', 'hd'].includes(q.toLowerCase()) + ); + + if (specialLabels.length === 1) { + label = specialLabels[0]; // Keep original case + } else if (specialLabels.length > 1) { + label = level.bitrate ? `SD (${(level.bitrate / 1000).toFixed(0)}k)` : `Quality ${level.originalIndex}`; + } else { + label = level.bitrate ? `SD (${(level.bitrate / 1000).toFixed(0)}k)` : 'Original'; + } + } + + const bitrate = level.bitrate ? ` ${(level.bitrate / 1000000).toFixed(1)} Mbps` : ''; + const isPremiumQuality = level.height >= 1080; + if (this.options.isGuest && isPremiumQuality) { + item.innerHTML = `${label}PRO`; + item.style.opacity = '0.7'; + item.onclick = (e) => { + e.stopPropagation(); + this.showToast('Vui lòng đăng nhập để xem chất lượng ' + label, 'warning'); + }; + } else { + item.innerHTML = `${label}${bitrate}`; + item.onclick = (e) => { + e.stopPropagation(); + this.setQuality(level.originalIndex); + this.updateQualityUI(level.originalIndex); + + // For dummy levels (MP4), give immediate feedback as setQuality HLS logic won't run + if (level.originalIndex <= -100) { + this.showFeedback('text', `Quality: ${label}`); + } + }; + } + list.appendChild(item); + }); + + // Ensure "Auto" is the default selection if currentLevel is -1 + this.updateQualityUI(currentLevel); + + // Apply Default Quality Logic (Moved inside function) + let targetLevel = null; + const savedQ = localStorage.getItem('txa-quality'); + + // Check against `uiLevels` (variable from above scope) + if (savedQ !== null && !this.options.isGuest) { + const parsed = parseInt(savedQ); + const isStillAllowed = parsed === -1 || uiLevels.some(l => l.originalIndex === parsed); + if (isStillAllowed) { + targetLevel = parsed; + } else { + targetLevel = -1; + localStorage.removeItem('txa-quality'); + } + } else if (this.options.maxQuality && !this.options.isGuest) { + targetLevel = -1; + } + + if (targetLevel !== null && targetLevel !== undefined) { + this.setQuality(targetLevel); + this.updateQualityUI(targetLevel); + } + + if (uiLevels.length < levels.length) { + this.enforceQualityRestriction(availableLevels, uiLevels); + } + } + + /** + * HARD QUALITY ENFORCEMENT + * Physically removes disallowed levels from HLS.js manifest + * and sets autoLevelCapping + LEVEL_SWITCHING interceptor as fallback. + * This ensures ABR can NEVER select a quality outside admin's config. + */ + enforceQualityRestriction(allLevels, allowedLevels) { + const allowedIndices = new Set(allowedLevels.map(l => l.originalIndex)); + + if (this.hls) { + // Strategy 1: Remove levels from HLS.js (v1.4+) + // We must remove from highest index to lowest to avoid index shifting + const toRemove = allLevels + .filter(l => !allowedIndices.has(l.originalIndex)) + .sort((a, b) => b.originalIndex - a.originalIndex); + + if (typeof this.hls.removeLevel === 'function') { + // Build index mapping: old index → new index after removals + this._qualityIndexMap = {}; + let newIdx = 0; + + for (const lvl of allLevels.sort((a, b) => a.originalIndex - b.originalIndex)) { + if (allowedIndices.has(lvl.originalIndex)) { + this._qualityIndexMap[lvl.originalIndex] = newIdx; + newIdx++; + } + } + + // Actually remove the levels (reverse order to keep indices stable) + toRemove.forEach(lvl => { + try { + this.hls.removeLevel(lvl.originalIndex); + } catch (e) { + // Silently fail if removeLevel not available on this version + } + }); + + // After removal: cap auto to available levels + const newMaxIdx = this.hls.levels.length - 1; + if (newMaxIdx >= 0) { + this.hls.autoLevelCapping = newMaxIdx; + } + + // Remap onclick handlers for quality items + const qualityItems = this.container.querySelectorAll('#txa-list-quality .txa-menu-item[data-quality]'); + // Items' data-quality may refer to old indices which no longer exist + } else { + // Strategy 2: Fallback for older HLS.js without removeLevel + // Use autoLevelCapping for max, and LEVEL_SWITCHING to block disallowed + const maxAllowed = Math.max(...allowedIndices); + this.hls.autoLevelCapping = maxAllowed; + + // Intercept level switching to block non-allowed levels + this.hls.on(Hls.Events.LEVEL_SWITCHING, (event, data) => { + if (!allowedIndices.has(data.level)) { + // Force back to nearest allowed level + const nearest = [...allowedIndices].sort((a, b) => + Math.abs(a - data.level) - Math.abs(b - data.level) + )[0]; + if (nearest !== undefined) { + this.hls.currentLevel = nearest; + } + } + }); + } + } else if (this.dashPlayer) { + // DashJS: Use maxBitrate and minBitrate constraints + const allowedBitrates = allowedLevels.map(l => l.bitrate).filter(Boolean); + if (allowedBitrates.length > 0) { + const maxBr = Math.max(...allowedBitrates); + const minBr = Math.min(...allowedBitrates); + this.dashPlayer.updateSettings({ + 'streaming': { + 'abr': { + 'maxBitrate': { 'video': maxBr }, + 'minBitrate': { 'video': minBr } + } + } + }); + } + } + } + + setQuality(levelIndex) { + if (this.options.isGuest) return; + + // Show immediate loading indicator when switching quality + if (this.showLoader) { + this.showLoader(50); + const loadText = this.container.querySelector('#txa-load-text'); + if (loadText) loadText.textContent = 'Đang chuyển đổi chất lượng...'; + } + + if (this.hls) { + // Check if we need to force a redraw or buffer clear + const wasPlaying = !this.video.paused; + this.hls.currentLevel = levelIndex; + + // Fix for "stuck/frozen" frames on some browsers: + // Briefly pause and play to force-refresh the decoder if it was playing + if (wasPlaying) { + setTimeout(() => { + if (this.video.paused) this.video.play().catch(() => { }); + }, 100); + } + } else if (this.dashPlayer) { + const wasPlaying = !this.video.paused; + if (levelIndex === -1) { + this.dashPlayer.updateSettings({ 'streaming': { 'abr': { 'autoSwitchBitrate': { 'video': true } } } }); + } else { + this.dashPlayer.updateSettings({ 'streaming': { 'abr': { 'autoSwitchBitrate': { 'video': false } } } }); + this.dashPlayer.setQualityFor('video', levelIndex); + } + if (wasPlaying) { + setTimeout(() => { + if (this.video.paused) this.video.play().catch(() => { }); + }, 100); + } + + // For DASH, hide loader after a short delay or logic (simplification) + setTimeout(() => this.hideLoader && this.hideLoader(), 1500); + } else if (this._mp4Levels.length > 0 && levelIndex >= 0) { + // v6.5.2 Switching between Direct MP4 files + // Handle originalIndex mapping back to our _mp4Levels + const newLevel = this._mp4Levels.find(l => l.originalIndex === levelIndex) || this._mp4Levels[levelIndex]; + + if (newLevel && newLevel.url !== (this._lastMP4Url || this.options.videoUrl)) { + const currentTime = this.video.currentTime; + const wasPlaying = !this.video.paused; + + if (this.showLoader) this.showLoader(50); + + this._lastMP4Url = newLevel.url; + this.video.src = newLevel.url; + + this.video.onloadedmetadata = () => { + this.video.currentTime = currentTime; + if (wasPlaying) this.video.play().catch(() => { }); + this.hideLoader && this.hideLoader(); + this.generateQualityList(); // Update UI active state + this.video.onloadedmetadata = null; + }; + } + } + + // Save preference + localStorage.setItem('txa-quality', levelIndex); + + // Close settings menu + this.navSettings('main'); + } + + updateQualityUI(levelIndex) { + const items = this.container.querySelectorAll('#txa-list-quality .txa-menu-item'); + let activeLabel = 'Auto'; + let shortLabel = 'Auto'; + let realResolution = ''; // New: Track actual playing resolution + + // 1. Detect Real Resolution used by Auto (-1) + if (levelIndex === -1 && this.hls) { + // HLS: Use currentLevel (playing) or loadLevel (loading) + const lvlIdx = this.hls.currentLevel !== -1 ? this.hls.currentLevel : this.hls.loadLevel; + if (lvlIdx !== -1 && this.hls.levels && this.hls.levels[lvlIdx]) { + const lvl = this.hls.levels[lvlIdx]; + if (lvl && lvl.height) realResolution = lvl.height; + } + } else if (levelIndex === -1 && this.dashPlayer) { + // DASH: Logic if needed + } + + items.forEach(item => { + item.classList.remove('active'); + const icon = item.querySelector('.fa-check'); + if (icon) icon.remove(); + + if (parseInt(item.dataset.quality) === levelIndex) { + item.classList.add('active'); + + const check = document.createElement('i'); + check.className = 'fas fa-check'; + check.style.marginLeft = 'auto'; + check.style.color = 'var(--txa-brand)'; + check.style.fontSize = '12px'; + item.appendChild(check); + + const textSpan = item.querySelector('span'); + if (textSpan) { + activeLabel = textSpan.textContent; + + // Generate Short Label for Badge + if (levelIndex === -1) { + shortLabel = 'Auto'; + // Keep pure Auto for badge text to avoid clutter, + // but we will use realResolution for color coding below + } else { + shortLabel = activeLabel + .replace(' UHD', '') + .replace(' QHD', '') + .replace(' FHD', '') + .replace(' HD', '') + .replace('p', ''); + } + } + } + }); + + // Update Parent Menu Text + const lbl = this.container.querySelector('#txa-lbl-quality'); + if (lbl) { + // If Auto, append real resolution dynamically + if (levelIndex === -1 && realResolution) { + lbl.textContent = `Auto (${realResolution}p)`; + } else { + lbl.textContent = activeLabel; + } + } + + // Update Settings Button Badge + const badge = this.container.querySelector('#txa-quality-badge'); + if (badge) { + // If Auto, show actual res if we have it? Or just 'Auto'? + // "SHOW CURENT QUALITY ON BAGE ICON SETTINGS" -> User wants to see resolution + if (levelIndex === -1 && realResolution) { + badge.textContent = `${realResolution}p`; // e.g. "720p" + } else { + badge.textContent = shortLabel; // "1080", "AUTO" + } + + // Color Coding + badge.style.background = 'rgba(255,255,255,0.2)'; + badge.style.color = '#fff'; + badge.style.fontWeight = 'normal'; + badge.style.boxShadow = 'none'; + + // Determine effective resolution for styling + let effectiveRes = realResolution ? parseInt(realResolution) : 0; + if (levelIndex !== -1) effectiveRes = parseInt(shortLabel) || 0; + if (shortLabel.includes('4K')) effectiveRes = 2160; + + if (effectiveRes >= 2160) { // 4K + badge.style.background = '#f43f5e'; // Rose + badge.style.boxShadow = '0 0 10px rgba(244, 63, 94, 0.4)'; + badge.style.fontWeight = 'bold'; + } else if (effectiveRes >= 1080) { // FHD + badge.style.background = '#eab308'; // Yellow + badge.style.color = '#000'; + badge.style.fontWeight = '800'; + } else if (effectiveRes >= 720) { // HD + badge.style.background = '#3b82f6'; // Blue + } else if (activeLabel === 'Auto' || levelIndex === -1) { + // Low res auto or unknown + badge.style.background = 'var(--txa-brand)'; + } + } + + // Toast Notification + if (this._lastQualityIndex !== levelIndex) { + if (this._lastQualityIndex !== undefined) { + let msg = `Đã chuyển sang: ${activeLabel}`; + if (levelIndex === -1 && realResolution) msg = `Tự động (${realResolution}p)`; + this.showToast(msg, 'info'); + } + this._lastQualityIndex = levelIndex; + } + } + + renderMarkers() { + const container = this.container.querySelector('#txa-markers'); + if (!container) return; + + // Always reset markers first, even if duration is not ready + container.innerHTML = ''; + + if (!this.video || !this.video.duration || !this.options.markers) return; + + const dur = this.video.duration; + const { intro, outro } = this.options.markers; + + if (intro && intro[1] > intro[0]) { + const zone = document.createElement('div'); + zone.className = 'txa-marker-zone intro'; + zone.style.left = (intro[0] / dur * 100) + '%'; + zone.style.width = ((intro[1] - intro[0]) / dur * 100) + '%'; + container.appendChild(zone); + + const dotStart = document.createElement('div'); + dotStart.className = 'txa-marker-dot intro-start'; + dotStart.style.left = (intro[0] / dur * 100) + '%'; + container.appendChild(dotStart); + + const dotEnd = document.createElement('div'); + dotEnd.className = 'txa-marker-dot intro-end'; + dotEnd.style.left = (intro[1] / dur * 100) + '%'; + container.appendChild(dotEnd); + } + + if (outro && (outro[1] > outro[0] || (outro[0] > 0 && (outro[1] === 0 || !outro[1])))) { + const effectiveOutroOut = (outro[1] > 0) ? outro[1] : dur; + const zone = document.createElement('div'); + zone.className = 'txa-marker-zone outro'; + zone.style.left = (outro[0] / dur * 100) + '%'; + zone.style.width = ((effectiveOutroOut - outro[0]) / dur * 100) + '%'; + container.appendChild(zone); + + const dotStart = document.createElement('div'); + dotStart.className = 'txa-marker-dot outro-start'; + dotStart.style.left = (outro[0] / dur * 100) + '%'; + container.appendChild(dotStart); + + const dotEnd = document.createElement('div'); + dotEnd.className = 'txa-marker-dot outro-end'; + dotEnd.style.left = (effectiveOutroOut / dur * 100) + '%'; + container.appendChild(dotEnd); + } + } + + initSubtitles() { + const subs = this.options.subtitles || []; + const hasSubs = subs.length > 0; + + // 1. Update Internal Toolbar Track support if needed + // (Clearing old tracks first) + // Remove existing track elements from video to prevent duplicates + Array.from(this.video.children).filter(child => child.tagName === 'TRACK').forEach(track => track.remove()); + + subs.forEach((sub, index) => { + const track = document.createElement('track'); + track.kind = 'subtitles'; + track.label = sub.label || sub.lang; + track.srclang = sub.lang; + // Handle both URL (src/file) and inline content + if (sub.src || sub.file) { + track.src = sub.src || sub.file; + } else if (sub.content) { + // Create blob URL for inline VTT content + const blob = new Blob([sub.content], { type: 'text/vtt' }); + track.src = URL.createObjectURL(blob); + } + this.video.appendChild(track); + }); + + // 2. Update Settings Menu UI + const list = this.container.querySelector('#txa-list-subs'); + const itemSubs = this.container.querySelector('#txa-item-subs'); + const btnSubs = this.container.querySelector('#txa-cc'); + + if (itemSubs) itemSubs.style.display = hasSubs ? 'flex' : 'none'; + if (btnSubs) { + btnSubs.style.display = hasSubs ? '' : 'none'; + const icon = btnSubs.querySelector('i'); + if (icon) { + icon.style.opacity = hasSubs ? '1' : '0.4'; + icon.style.filter = hasSubs ? 'none' : 'grayscale(1)'; + } + const tip = btnSubs.querySelector('.txa-tooltip'); + if (tip) tip.textContent = hasSubs ? 'Subtitles (c)' : 'No Subtitles'; + } + + if (list) { + list.innerHTML = `
Off
`; + subs.forEach((sub, index) => { + const item = document.createElement('div'); + item.className = 'txa-menu-item'; + item.dataset.sub = index; + item.innerHTML = `${sub.label || sub.lang}${sub.lang || ''}`; + item.onclick = (e) => { + e.stopPropagation(); + this.toggleSub(index); + }; + list.appendChild(item); + }); + + // Auto-load first subtitle if enabled or newly switched + // If activeSubIdx is -1 (Off) and there are subs, default to first + // If activeSubIdx is set, try to re-activate it + if (hasSubs) { + if (this.activeSubIdx === undefined || this.activeSubIdx === -1) { + this.toggleSub(0); + list.querySelector('[data-sub="0"]')?.classList.add('active'); + } else { + this.toggleSub(this.activeSubIdx); + list.querySelector(`[data-sub="${this.activeSubIdx}"]`)?.classList.add('active'); + } + } else { + this.toggleSub(-1); // Ensure subtitles are off if none are available + list.querySelector('[data-sub="-1"]')?.classList.add('active'); + } + } + } + + + bindEvents() { + const el = (s) => this.container.querySelector(s); + + // Play/Pause + const toggle = () => this.togglePlay(); + const playBtnMain = el('#txa-play'); + if (playBtnMain) playBtnMain.onclick = toggle; + + // Prev/Next Navigation + const prevBtn = el('#txa-prev'); + const nextBtn = el('#txa-next'); + if (prevBtn) prevBtn.onclick = (e) => { + if (e) e.preventDefault(); + if (this.options.prevEpisodeUrl && typeof window.switchEpisodeSeamless === 'function') { + window.switchEpisodeSeamless(this.options.prevEpisodeUrl); + } else if (this.options.prevEpisodeUrl) { + window.location.href = this.options.prevEpisodeUrl; + } + }; + if (nextBtn) nextBtn.onclick = (e) => { + if (e) e.preventDefault(); + if (this.options.nextEpisodeUrl && typeof window.switchEpisodeSeamless === 'function') { + window.switchEpisodeSeamless(this.options.nextEpisodeUrl); + } else if (this.options.nextEpisodeUrl) { + window.location.href = this.options.nextEpisodeUrl; + } + }; + if (this.video) this.video.onclick = toggle; + + const centerPlay = el('#txa-center-play'); + if (centerPlay) centerPlay.onclick = toggle; + + const zoneL = el('#txa-zone-l'); + if (zoneL) zoneL.onclick = (e) => { + if (e.detail === 1) { + this._clickTimer = setTimeout(() => toggle(), 250); + } else if (e.detail > 1) { + clearTimeout(this._clickTimer); + } + }; + + const zoneR = el('#txa-zone-r'); + if (zoneR) zoneR.onclick = (e) => { + if (e.detail === 1) { + this._clickTimer = setTimeout(() => toggle(), 250); + } else if (e.detail > 1) { + clearTimeout(this._clickTimer); + } + }; + + const replayBtnMain = el('#txa-replay-btn'); + if (replayBtnMain) replayBtnMain.onclick = () => { + if (this.video) { + this.video.currentTime = 0; + this.video.play(); + } + const replayDiv = el('#txa-replay'); + if (replayDiv) replayDiv.classList.remove('show'); + }; + + this.video.addEventListener('play', () => { + if (this.destroyed) return; + const playBtn = el('#txa-play'); + if (playBtn) playBtn.innerHTML = '
Pause (k)
'; + this.animateCenter('play'); + const replayBtn = el('#txa-replay'); + if (replayBtn) replayBtn.classList.remove('show'); + if (this.wrapper) this.wrapper.classList.add('video-playing'); + const cp = el('#txa-center-play'); + if (cp) cp.classList.remove('show'); + this.showUI(); // Auto hide after playing starts + }); + + this.video.addEventListener('pause', () => { + if (this.destroyed) return; + const playBtn = el('#txa-play'); + if (playBtn) playBtn.innerHTML = '
Play (k)
'; + this.animateCenter('pause'); + this.showUI(false); // Maintain UI while paused + if (this.wrapper) this.wrapper.classList.remove('video-playing'); + const cp = el('#txa-center-play'); + if (cp) cp.classList.add('show'); + }); + + // Video Error Handler + this.video.addEventListener('error', () => { + if (this.destroyed) return; + + const error = this.video.error; + if (!error) return; + + // Report native video error to database + this.reportErrorToServer('nativeVideoError', error.message || 'Lỗi phát video HTML5', { code: error.code }); + + let errorMsg = 'Lỗi không xác định'; + let shouldRetry = false; + + switch (error.code) { + case MediaError.MEDIA_ERR_ABORTED: + errorMsg = 'Phát video bị hủy'; + break; + case MediaError.MEDIA_ERR_NETWORK: + errorMsg = 'Lỗi mạng khi load video'; + shouldRetry = true; + break; + case MediaError.MEDIA_ERR_DECODE: + errorMsg = 'Lỗi giải mã video'; + break; + case MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED: + errorMsg = 'Nguồn video không hỗ trợ'; + break; + } + + console.error('[TXAPlayer] Video error:', error.code, errorMsg); + + // Hide loader + const loader = el('#txa-loader'); + if (loader) loader.classList.add('hidden'); + + // Show error toast + this.showToast(`❌ ${errorMsg}`); + + // Auto retry for network errors + if (shouldRetry && !this._isRetryingVideo) { + this._isRetryingVideo = true; + setTimeout(() => { + if (!this.destroyed && this.options.videoUrl) { + console.log('[TXAPlayer] Retrying video load...'); + this.showToast('🔄 Đang thử load lại video...'); + + // Reload video source + this.video.src = this.options.videoUrl; + this.video.load(); + + // Show loader again + if (loader) loader.classList.remove('hidden'); + + setTimeout(() => { + this._isRetryingVideo = false; + }, 2000); + } + }, 1500); + } + }); + + this.video.addEventListener('ended', () => { + if (this.destroyed) return; + if (this.wrapper) this.wrapper.classList.remove('video-playing'); + if (!this.video.loop) { + // Check if auto-next is enabled and we have next episode + if (this.settings.autoNextEpisode && this.options.nextEpisodeUrl && !this._isAutoNextTriggered) { + // Show countdown overlay + this._showAutoNextCountdown(); + } else { + // Show replay button only if auto-next is not active + const replayBtn = el('#txa-replay'); + if (replayBtn) replayBtn.classList.add('show'); + if (this.wrapper) this.wrapper.classList.add('active-ui'); + } + } + }); + + this.video.ondurationchange = () => { + if (this.destroyed) return; + this.renderMarkers(); + }; + + const pWrap = el('#txa-progress'); + let pendingSeekPct = -1; + + + + const updateScrubbingUI = (pos, isDragOrClick = false) => { + const duration = this.video?.duration || 0; + const targetTime = pos * duration; + + // Only update the actual progress bar and main time if we are DRAGGING or explicitly CLICKING + if (isDragOrClick || this.isDragging) { + const playedEl = el('#txa-played'); + if (playedEl) playedEl.style.width = (pos * 100) + '%'; + + const timeEl = el('#txa-time'); + if (timeEl) timeEl.textContent = this.formatTimeDisplay(targetTime); + + pendingSeekPct = pos; + } + + // Tooltip and Preview ALWAYS follow on hover + const tip = el('#txa-hover-time'); + if (tip) { + const needHours = duration >= 3600; + tip.textContent = this.formatTime(targetTime, needHours); + tip.style.left = (pos * 100) + '%'; + } + + this._updatePreviewThumb(pos); + }; + + const updateHoverTooltip = (e, isDragOrClick = false) => { + if (!pWrap) return; + const rect = pWrap.getBoundingClientRect(); + const pos = Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width)); + updateScrubbingUI(pos, isDragOrClick); + return pos; + }; + + pWrap.onmousemove = (e) => { + updateHoverTooltip(e, false); // Just hover tooltip + }; + pWrap.onmousedown = (e) => { + if (e.button !== 0) return; // Left click only + this.isDragging = true; + pWrap.classList.add('dragging'); + updateHoverTooltip(e, true); + }; + + // Desktop Long Press (2x Speed) + let deskPressTimer = null; + let isDeskLongPress = false; + + this.video.onmousedown = (e) => { + if (this.detectMobile()) return; + if (e.button !== 0) return; // Left click only + + deskPressTimer = setTimeout(() => { + if (!this.video.paused) { + isDeskLongPress = true; + if (!this.originalSpeed) this.originalSpeed = this.video.playbackRate; + this.video.playbackRate = 2.0; + + let speedOverlay = this.container.querySelector('.txa-speed-overlay'); + if (!speedOverlay) { + speedOverlay = document.createElement('div'); + speedOverlay.className = 'txa-speed-overlay'; + speedOverlay.innerHTML = ' 2x Tốc độ'; + this.container.appendChild(speedOverlay); + } + this.wrapper.classList.add('hide-controls'); + setTimeout(() => speedOverlay.classList.add('show'), 10); + } + }, 500); + }; + pWrap.onclick = (e) => { + if (!this.isDragging) { + const rect = pWrap.getBoundingClientRect(); + const pos = Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width)); + this.safeSeek(pos * this.video.duration); + } + }; + + // Improved Mobile Touch Interaction + const handleTouchProgress = (e) => { + if (e.touches && e.touches[0]) { + const rect = pWrap.getBoundingClientRect(); + const pos = Math.max(0, Math.min(1, (e.touches[0].clientX - rect.left) / rect.width)); + updateScrubbingUI(pos); + // Show UI to prevent controls hiding while dragging + this.wrapper.classList.add('active-ui'); + e.preventDefault(); // Stop browser back/scroll + e.stopPropagation(); + } + }; + + pWrap.addEventListener('touchstart', (e) => { + this.isDragging = true; + pWrap.classList.add('dragging'); + handleTouchProgress(e); + }, { passive: false }); + + pWrap.addEventListener('touchmove', (e) => { + if (this.isDragging) handleTouchProgress(e); + }, { passive: false }); + + const endTouchProgress = (e) => { + if (this.isDragging) { + this.isDragging = false; + pWrap.classList.remove('dragging'); + if (pendingSeekPct !== -1) { + this.safeSeek(pendingSeekPct * this.video.duration); + pendingSeekPct = -1; + } + } + }; + + pWrap.addEventListener('touchend', endTouchProgress); + pWrap.addEventListener('touchcancel', endTouchProgress); + + this._handlers.winMouseMove = (e) => { + if (this.isDragging) { + const rect = pWrap.getBoundingClientRect(); + const pos = Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width)); + updateScrubbingUI(pos); + } + }; + this._handlers.winMouseUp = () => { + if (this.isDragging) { + this.isDragging = false; + pWrap.classList.remove('dragging'); + if (pendingSeekPct !== -1) { + this.safeSeek(pendingSeekPct * this.video.duration); + pendingSeekPct = -1; + } + } + + if (deskPressTimer) clearTimeout(deskPressTimer); + if (isDeskLongPress) { + isDeskLongPress = false; + this.video.playbackRate = this.originalSpeed || 1.0; + const speedOverlay = this.container.querySelector('.txa-speed-overlay'); + if (speedOverlay) speedOverlay.classList.remove('show'); + this.wrapper.classList.remove('hide-controls'); + } + }; + + window.addEventListener('mousemove', this._handlers.winMouseMove); + window.addEventListener('mouseup', this._handlers.winMouseUp); + + this.video.addEventListener('timeupdate', () => { + if (this.destroyed) return; + this.updateProgress(); + }); + + this.video.addEventListener('play', () => this.showUI()); + this.video.addEventListener('pause', () => this.showUI(false)); + this.video.addEventListener('playing', () => this.showUI()); + + // v6.4.1 - Enhanced Mobile UI Handling + if (this.detectMobile()) { + // Remove redundant touchstart on video which might reset timer too often + // Instead rely on handleMobileEvents wrapper listener + + // Listen for orientation/resize to update clock visibility immediately + window.addEventListener('resize', () => this.updateClockVisibility()); + window.addEventListener('orientationchange', () => { + setTimeout(() => this.updateClockVisibility(), 200); + }); + } + + el('#txa-mute').onclick = () => { this.video.muted = !this.video.muted; this.updateVolUI(); this.saveSettings(); }; + const volSlider = el('#txa-vol'); + const volTooltip = el('#txa-vol-tooltip'); + + const showVolTooltip = () => volTooltip?.classList.add('visible'); + const hideVolTooltip = () => { if (!this._isVolDragging) volTooltip?.classList.remove('visible'); }; + + volSlider.oninput = (e) => { + this.video.volume = e.target.value; + this.video.muted = false; + this.updateVolUI(); + showVolTooltip(); + }; + + // v6.5.2 - Centralized volume/rate sync to always save state correctly + this.video.addEventListener('volumechange', () => { + this.updateVolUI(); + this.saveSettings(); + }); + + this.video.addEventListener('ratechange', () => { + this.saveSettings(); + }); + + volSlider.onmousedown = () => { this._isVolDragging = true; showVolTooltip(); }; + volSlider.onmouseenter = showVolTooltip; + volSlider.onmouseleave = hideVolTooltip; + + window.addEventListener('mouseup', () => { + if (this._isVolDragging) { + this._isVolDragging = false; + hideVolTooltip(); + } + }); + + el('#txa-settings').onclick = (e) => { e.stopPropagation(); el('#txa-panel').classList.toggle('active'); this.navSettings('main'); }; + el('#txa-fs').onclick = () => this.toggleFS(); + el('#txa-pip').onclick = () => this.toggleNativePiP(); + + // TXA PRO Toggles + const autoSkipBtn = el('#txa-auto-skip'); + if (autoSkipBtn) autoSkipBtn.onclick = (e) => { e.stopPropagation(); this.toggleAutoSkipIntro(); }; + + const autoNextBtn = el('#txa-auto-next'); + if (autoNextBtn) autoNextBtn.onclick = (e) => { e.stopPropagation(); this.toggleAutoNextEpisode(); }; + + // DETECTION PIP/FS TO UPDATE UI + this.video.onenterpictureinpicture = () => { + const pipBtn = el('#txa-pip'); // Added null check + if (pipBtn) pipBtn.innerHTML = '
Exit Mini Player (p)
'; + }; + this.video.onleavepictureinpicture = () => { + const pipBtn = el('#txa-pip'); // Added null check + if (pipBtn) pipBtn.innerHTML = '
Mini Player (p)
'; + }; + this._handlers.docFSChange = () => { + const fsBtn = el('#txa-fs'); + if (document.fullscreenElement) { + this.wrapper.classList.add('fullscreen-mode'); + if (fsBtn) fsBtn.innerHTML = '
Exit Fullscreen (f)
'; + } else { + this.wrapper.classList.remove('fullscreen-mode'); + if (fsBtn) fsBtn.innerHTML = '
Fullscreen (f)
'; + } + this.showUI(); // Trigger timer on FS change + this.updateClockVisibility(); + }; + document.addEventListener('fullscreenchange', this._handlers.docFSChange); + + el('#txa-nc-cancel').onclick = (e) => { + e.stopPropagation(); + + // Clear countdown interval if exists + if (this._autoNextCountdownInterval) { + clearInterval(this._autoNextCountdownInterval); + this._autoNextCountdownInterval = null; + } + + this._isAutoNextTriggered = true; // Block auto-trigger for this episode + el('#txa-next-countdown').classList.remove('show'); + if (this.wrapper) this.wrapper.classList.remove('has-countdown'); + this.showToast('Đã hủy tự động chuyển tập'); + + // Change "Skip Outro" button text if next episode exists + const skipOutro = this.container.querySelector('#txa-skip-outro'); + if (skipOutro && this.options.nextEpisodeUrl) { + skipOutro.innerHTML = ' Tập Tiếp'; + skipOutro.style.display = 'block'; // Ensure it's visible now + } + }; + + el('#txa-nc-next').onclick = (e) => { + e.preventDefault(); + e.stopPropagation(); + + // Clear countdown interval if exists + if (this._autoNextCountdownInterval) { + clearInterval(this._autoNextCountdownInterval); + this._autoNextCountdownInterval = null; + } + + this._isAutoNextTriggered = true; + el('#txa-next-countdown').classList.remove('show'); + if (this.wrapper) this.wrapper.classList.remove('has-countdown'); + + this._triggerAutoNext(); + }; + + el('#txa-skip-intro').onclick = () => this.skipIntro(); + el('#txa-skip-outro').onclick = () => this.skipOutro(); + + this.container.querySelectorAll('[data-goto]').forEach(i => i.onclick = (e) => { e.stopPropagation(); this.navSettings(i.dataset.goto); }); + this.container.querySelectorAll('[data-back]').forEach(i => i.onclick = (e) => { e.stopPropagation(); this.navSettings(i.dataset.back); }); + + // Speed Menu Clicks + this.container.querySelectorAll('[data-speed]').forEach(i => i.onclick = (e) => { + e.stopPropagation(); + this.setSpeed(parseFloat(i.dataset.speed)); + this.container.querySelectorAll('[data-speed]').forEach(o => o.classList.remove('active')); + i.classList.add('active'); + }); + + // Ratio Menu Clicks + this.container.querySelectorAll('[data-ratio]').forEach(i => i.onclick = (e) => { + e.stopPropagation(); + this.setAspectRatio(i.dataset.ratio); + this.container.querySelectorAll('[data-ratio]').forEach(o => o.classList.remove('active')); + i.classList.add('active'); + }); + + // Flip Menu Clicks + this.container.querySelectorAll('[data-flip]').forEach(i => i.onclick = (e) => { + e.stopPropagation(); + this.setVideoFlip(i.dataset.flip); + this.container.querySelectorAll('[data-flip]').forEach(o => o.classList.remove('active')); + i.classList.add('active'); + }); + + // Subtitle Size Menu + this.container.querySelectorAll('[data-subsize]').forEach(i => i.onclick = (e) => { + e.stopPropagation(); + const cap = el('#txa-captions'); + if (cap) { + cap.classList.remove('size-mini', 'size-small', 'size-medium', 'size-large', 'size-jumbo'); + cap.classList.add('size-' + i.dataset.subsize); + } + this.container.querySelectorAll('[data-subsize]').forEach(o => o.classList.remove('active')); + i.classList.add('active'); + this.saveSettings(); + }); + + // Subtitle Weight Menu + this.container.querySelectorAll('[data-subweight]').forEach(i => i.onclick = (e) => { + e.stopPropagation(); + const cap = el('#txa-captions'); + if (cap) { + cap.classList.remove('weight-normal', 'weight-bold'); + cap.classList.add('weight-' + i.dataset.subweight); + } + this.container.querySelectorAll('[data-subweight]').forEach(o => o.classList.remove('active')); + i.classList.add('active'); + this.saveSettings(); + }); + + // Subtitle Background Menu + this.container.querySelectorAll('[data-subbg]').forEach(i => i.onclick = (e) => { + e.stopPropagation(); + const cap = el('#txa-captions'); + if (cap) { + cap.classList.remove('bg-none', 'bg-dark', 'bg-light', 'bg-glass', 'bg-default'); + if (i.dataset.subbg !== 'default') cap.classList.add('bg-' + i.dataset.subbg); + } + this.container.querySelectorAll('[data-subbg]').forEach(o => o.classList.remove('active')); + i.classList.add('active'); + this.saveSettings(); + }); + + // Subtitle Color Menu + this.container.querySelectorAll('[data-subcolor]').forEach(i => i.onclick = (e) => { + e.stopPropagation(); + const cap = el('#txa-captions'); + if (cap) { + cap.classList.remove('color-white', 'color-yellow', 'color-orange', 'color-red', 'color-green', 'color-cyan', 'color-pink', 'color-violet'); + cap.classList.add('color-' + i.dataset.subcolor); + } + this.container.querySelectorAll('[data-subcolor]').forEach(o => o.classList.remove('active')); + i.classList.add('active'); + this.saveSettings(); + }); + + // Subtitle Stroke Toggle + const strokeToggle = el('#txa-substroke-toggle'); + const strokePanel = el('#txa-stroke-panel'); + if (strokeToggle) { + strokeToggle.onchange = (e) => { + const cap = el('#txa-captions'); + if (cap) { + if (e.target.checked) { + cap.classList.add('stroke-on'); + strokePanel.classList.add('active'); + } else { + cap.classList.remove('stroke-on'); + strokePanel.classList.remove('active'); + } + } + this.saveSettings(); + }; + } + + // Subtitle Stroke Color + this.container.querySelectorAll('[data-substroke]').forEach(i => i.onclick = (e) => { + e.stopPropagation(); + const cap = el('#txa-captions'); + if (cap) { + cap.classList.remove('stroke-white', 'stroke-black', 'stroke-yellow', 'stroke-red', 'stroke-blue'); + cap.classList.add('stroke-' + i.dataset.substroke); + } + this.container.querySelectorAll('[data-substroke]').forEach(o => o.classList.remove('active')); + i.classList.add('active'); + this.saveSettings(); + }); + + // Real-time Clock Toggle v6.4.0 + const clockToggle = el('#txa-clock-toggle'); + if (clockToggle) { + clockToggle.checked = this.settings.showRealTime; + clockToggle.onchange = (e) => { + this.settings.showRealTime = e.target.checked; + this.updateClockVisibility(); + this.saveSettings(); + }; + } + + // Clock Format Selection + this.container.querySelectorAll('[data-clock]').forEach(i => i.onclick = (e) => { + e.stopPropagation(); + this.settings.clockFormat = i.dataset.clock; + this.container.querySelectorAll('[data-clock]').forEach(o => o.classList.remove('active')); + i.classList.add('active'); + const lbl = el('#txa-lbl-clock'); + if (lbl) lbl.textContent = this.settings.clockFormat; + this.updateClock(); // Immediate update + this.saveSettings(); + }); + + // v6.4.5 - Robust Click/Touch Outside Logic for Panels + this._handlers.docClick = (e) => { + if (this.destroyed) return; + + const panel = el('#txa-panel'); + const settingsBtn = el('#txa-settings'); + const ctx = el('#txa-ctx'); + const stats = el('#txa-stats-panel'); + + // 1. Settings Panel Click Outside + if (panel && panel.classList.contains('active')) { + // Check if target is NOT inside panel AND NOT inside settings button + if (!panel.contains(e.target) && (!settingsBtn || !settingsBtn.contains(e.target))) { + panel.classList.remove('active'); + } + } + + // 2. Context Menu Click Outside + if (ctx && ctx.classList.contains('active')) { + if (!ctx.contains(e.target)) ctx.classList.remove('active'); + } + + // 3. Stats Panel Click Outside + if (stats && stats.classList.contains('active')) { + if (!stats.contains(e.target) && !e.target.closest('#txa-ctx-stats')) { + this.toggleStatsPanel(); // Use clear cleanup logic + } + } + }; + document.addEventListener('click', this._handlers.docClick); + document.addEventListener('touchstart', this._handlers.docClick, { passive: true }); + + + this.wrapper.onmousemove = (e) => { + if (this.detectMobile()) return; // Absolutely disable bottom hover for mobile + + const rect = this.wrapper.getBoundingClientRect(); + const y = e.clientY - rect.top; + // Only show UI if cursor is in the bottom 30% or if video is paused (Desktop) + if (y > rect.height * 0.7 || this.video.paused) { + this.showUI(); + } + }; + this.wrapper.onclick = (e) => { + // Desktop click logic (Mobile handled in handleMobileEvents) + if (!this.detectMobile()) { + if (!e.target.closest('.txa-controls,.txa-panel,.txa-ctx,.txa-replay-overlay,.txa-loader,.txa-stats-panel,.txa-resume-overlay,.txa-next-countdown,.txa-skip-btn')) this.showUI(); + } + }; + + el('#txa-zone-l').ondblclick = () => this.seekAccumulated(-10); + el('#txa-zone-r').ondblclick = () => this.seekAccumulated(10); + + // REMOVED: Scroll wheel volume control (user request) + // this.wrapper.onwheel = (e) => { ... }; + + el('#txa-cc').onclick = (e) => { e.stopPropagation(); this.toggleSubLoop(); }; + + // SUBTITLE DRAGGING + this.setupSubtitleDrag(); + + // Initialize UI timer (Auto hide) + this.showUI(); + } + + /** + * Centralized UI visibility logic + * @param {boolean} autoHide - Whether to start a timer to hide the UI + */ + showUI(autoHide = true) { + if (!this.wrapper || this.destroyed) return; + this.wrapper.classList.add('active-ui'); + if (this._uiTimer) clearTimeout(this._uiTimer); + + // Always start timer if autoHide is requested + if (autoHide && this.video) { + const delay = this.detectMobile() ? 5000 : 3000; + this._uiTimer = setTimeout(() => this.hideUI(), delay); + } + } + + hideUI() { + if (!this.wrapper || this.destroyed) return; + + // Prevent hiding if video is paused + if (!this.video || this.video.paused) return; + + // Prevent hiding if any interactable panel is open + const el = (s) => this.container.querySelector(s); + const panel = el('#txa-panel'); + const ctx = el('#txa-ctx'); + const stats = el('#txa-stats-panel'); + const shortcuts = document.querySelector('.txa-shortcuts-panel'); + + if ((panel && panel.classList.contains('active')) || + (ctx && ctx.classList.contains('active')) || + (stats && stats.classList.contains('active')) || + (shortcuts)) { + // Something is active, reset timer to try again later + this.showUI(); + return; + } + + this.wrapper.classList.remove('active-ui'); + } + + setupSubtitleDrag() { + const captions = this.container.querySelector('#txa-captions'); + if (!captions) return; + + // Load saved position & styles + const saved = this.loadSettings(); + if (saved.captionBottom) captions.style.bottom = saved.captionBottom + 'px'; + + // Fix: Use pixel positioning if available + if (saved.captionLeft !== undefined && saved.captionLeft !== null) { + if (saved.captionLeft <= 100 && saved.captionIsPercent) { + captions.style.left = saved.captionLeft + '%'; + captions.style.transform = 'translateX(-50%)'; + } else { + captions.style.left = saved.captionLeft + 'px'; + captions.style.transform = 'none'; + } + } + + // Apply saved styles + if (saved.subSize) { + captions.classList.add('size-' + saved.subSize); + this.container.querySelectorAll('[data-subsize]').forEach(i => { + i.classList.toggle('active', i.dataset.subsize === saved.subSize); + }); + } + if (saved.subBg) { + if (saved.subBg !== 'default') captions.classList.add('bg-' + saved.subBg); + this.container.querySelectorAll('[data-subbg]').forEach(i => { + i.classList.toggle('active', i.dataset.subbg === saved.subBg); + }); + } + if (saved.subColor) { + if (saved.subColor !== 'white') captions.classList.add('color-' + saved.subColor); + this.container.querySelectorAll('[data-subcolor]').forEach(i => { + i.classList.toggle('active', i.dataset.subcolor === saved.subColor); + }); + } + + let isDragging = false; + let startX = 0, startY = 0; + let startLeft = 0, startBottom = 0; + + captions.addEventListener('mousedown', (e) => { + isDragging = true; + captions.classList.add('dragging'); + startX = e.clientX; + startY = e.clientY; + const style = getComputedStyle(captions); + startBottom = parseInt(style.bottom) || 110; + const rect = captions.getBoundingClientRect(); + const pRect = this.wrapper.getBoundingClientRect(); + + // Calculate current relative position (Pixels) + startLeft = rect.left - pRect.left; + startBottom = pRect.bottom - rect.bottom; + + // Prepare for pixel drag + captions.style.left = startLeft + 'px'; + captions.style.bottom = startBottom + 'px'; + captions.style.transform = 'none'; + e.preventDefault(); + }); + + this._handlers.dragMouseMove = (e) => { + if (!isDragging) return; + const rect = this.wrapper.getBoundingClientRect(); + + // Vertical movement + const deltaY = startY - e.clientY; + const newBottom = Math.max(20, Math.min(rect.height - 80, startBottom + deltaY)); + captions.style.bottom = newBottom + 'px'; + + // Horizontal movement + const deltaX = e.clientX - startX; + const newLeft = Math.max(0, Math.min(rect.width - captions.offsetWidth, startLeft + deltaX)); // Boundary check + captions.style.left = newLeft + 'px'; + captions.style.transform = 'none'; + }; + + this._handlers.dragMouseUp = () => { + if (isDragging) { + isDragging = false; + captions.classList.remove('dragging'); + // Save position (Pixels) + const cfg = this.loadSettings(); + cfg.captionBottom = parseInt(captions.style.bottom); + cfg.captionLeft = parseFloat(captions.style.left); + cfg.captionIsPercent = false; + localStorage.setItem('txa-txa-cfg', JSON.stringify(cfg)); + } + }; + + window.addEventListener('mousemove', this._handlers.dragMouseMove); + window.addEventListener('mouseup', this._handlers.dragMouseUp); + } + + togglePlay() { + this._isExplicitToggle = true; + this.video.paused ? this.video.play().catch(() => { }) : this.video.pause(); + // Clear the flag after a short delay + setTimeout(() => { this._isExplicitToggle = false; }, 500); + } + + animateCenter(type) { + // Only run animation if it was an explicit user toggle + if (!this._isExplicitToggle) return; + + // Remove existing if any + let c = this.container.querySelector('.txa-center-feedback'); + if (!c) { + c = document.createElement('div'); + c.className = 'txa-center-feedback'; + this.container.appendChild(c); + } + + c.innerHTML = type === 'play' ? '' : ''; + + // Reset classes + c.classList.remove('animate', 'animate-out'); + void c.offsetWidth; // Trigger reflow + + c.classList.add('animate'); + + setTimeout(() => { + if (c) { + c.classList.add('animate-out'); + setTimeout(() => { + c.classList.remove('animate', 'animate-out'); + }, 400); + } + }, 400); + if (window.navigator.vibrate) window.navigator.vibrate(15); + } + + showFeedback(type, value = null) { + const fb = this.container.querySelector('#txa-feedback'); + if (!fb) return; + + fb.classList.remove('high-priority'); // Reset + + if (type === 'volume') { + fb.innerHTML = `${Math.round(this.video.volume * 100)}%`; + } else if (type === 'seek') { + fb.innerHTML = `${value}`; + } else if (type === 'text') { + fb.innerHTML = `${value}`; + } else if (type === 'high') { + fb.innerHTML = `${value}`; + fb.classList.add('high-priority'); + } + + fb.classList.add('show'); + clearTimeout(this.feedbackTimer); + + const duration = type === 'high' ? 3000 : 800; + this.feedbackTimer = setTimeout(() => fb.classList.remove('show'), duration); + } + + reportErrorToServer(errorType, errorMessage, errorDetails = {}) { + const payload = { + movie_slug: this.options.movieSlug || null, + movie_name: this.options.title || null, + episode_name: this.options.episodeName || null, + error_type: errorType, + error_message: errorMessage || '', + error_details: { + ...errorDetails, + video_url: this.options.videoUrl || '', + server_name: this.options.serverName || '', + settings: this.settings || {}, + txa_version: typeof TXA_VERSION !== 'undefined' ? TXA_VERSION : 'v1.0' + }, + browser_token: localStorage.getItem('zalo_browser_token') || null + }; + + fetch('/api/player/report-error', { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(payload) + }) + .then(res => res.json()) + .then(data => { + if (this.options.isAdmin) { + console.log('[TXAPlayer] Error reported to server successfully:', data); + } + }) + .catch(err => { + console.error('[TXAPlayer] Failed to report error to server:', err); + }); + } + + _txaShowHlsError(msg, hlsData = null) { + // Report HLS fatal error to database + this.reportErrorToServer('hlsError', msg, hlsData); + + const loader = this.container?.querySelector('#txa-loader'); + if (!loader) return; + + loader.classList.remove('hidden'); + loader.style.pointerEvents = 'all'; + + const spinner = loader.querySelector('.txa-spinner'); + const pctEl = loader.querySelector('#txa-load-pct'); + const barFill = loader.querySelector('#txa-load-bar-fill'); + const loadText = loader.querySelector('#txa-load-text'); + const speedEl = loader.querySelector('#txa-load-speed'); + + if (spinner) { spinner.style.borderTopColor = '#f59e0b'; spinner.style.animationPlayState = 'paused'; } + if (pctEl) { pctEl.textContent = '✕'; pctEl.style.color = '#f59e0b'; } + if (barFill) { barFill.style.background = '#f59e0b'; barFill.style.width = '100%'; } + if (speedEl) speedEl.textContent = ''; + if (loadText) { + loadText.style.color = '#fde68a'; + loadText.innerHTML = `${msg}`; + } + + if (hlsData && this.options.isAdmin) { + console.error('[TXAPlayer] HLS Fatal:', hlsData.type, hlsData.details, hlsData.response); + } + + if (!loader.querySelector('#txa-retry-btn')) { + const retryBtn = document.createElement('button'); + retryBtn.id = 'txa-retry-btn'; + retryBtn.innerHTML = 'Tải lại'; + retryBtn.style.cssText = ` + margin-top:14px; padding:8px 22px; + background:#f59e0b; color:#000; border:none; + border-radius:8px; cursor:pointer; font-size:13px; font-weight:700; + pointer-events:all; + `; + retryBtn.onclick = () => window.location.reload(); + const content = loader.querySelector('.txa-loader-content'); + if (content) content.appendChild(retryBtn); + } + } + + setAspectRatio(ratio) { + if (!this.video) return; + this.video.classList.remove('ratio-4-3', 'ratio-16-9', 'ratio-stretch'); + if (ratio !== 'default') this.video.classList.add('ratio-' + ratio); + + const lbl = this.container.querySelector('#txa-lbl-ratio'); + if (lbl) lbl.textContent = ratio === 'default' ? 'Default' : ratio.replace('-', ':').toUpperCase(); + + // Update menu status + this.container.querySelectorAll('[data-ratio]').forEach(i => i.classList.toggle('active', i.dataset.ratio === ratio)); + + this.showFeedback('text', 'Ratio: ' + (ratio === 'default' ? 'Default' : ratio)); + this.saveSettings(); + } + + setVideoFlip(flip) { + if (!this.video) return; + this.video.classList.remove('flip-h', 'flip-v', 'flip-both'); + if (flip !== 'normal') this.video.classList.add('flip-' + flip); + + const lbl = this.container.querySelector('#txa-lbl-flip'); + if (lbl) { + const names = { normal: 'Normal', h: 'Horizontal', v: 'Vertical', both: 'Both' }; + lbl.textContent = names[flip] || 'Normal'; + } + + // Update menu status + this.container.querySelectorAll('[data-flip]').forEach(i => i.classList.toggle('active', i.dataset.flip === flip)); + + this.showFeedback('text', 'Flip: ' + flip); + this.saveSettings(); + } + + seekAccumulated(sec) { + this.seekAccumulator += sec; + clearTimeout(this.seekDebounce); + const badge = this.container.querySelector(this.seekAccumulator > 0 ? '#txa-badge-r' : '#txa-badge-l'); + const other = this.container.querySelector(this.seekAccumulator > 0 ? '#txa-badge-l' : '#txa-badge-r'); + if (other) other.classList.remove('show'); // Added null check + if (badge) { // Added null check + badge.querySelector('span').textContent = `${this.seekAccumulator > 0 ? '+' : ''}${this.seekAccumulator}s`; + badge.classList.add('show'); + } + this.seekDebounce = setTimeout(() => { + this.safeSeek(this.video.currentTime + this.seekAccumulator); + this.seekAccumulator = 0; + if (badge) badge.classList.remove('show'); // Added null check + }, 700); + } + + updateVolUI() { + const v = this.video.muted ? 0 : this.video.volume; + const btn = this.container.querySelector('#txa-mute'); + const volInput = this.container.querySelector('#txa-vol'); + const volTooltip = this.container.querySelector('#txa-vol-tooltip'); + + if (volInput) { + volInput.value = v; + const pct = v * 100; + // Update the premium fill effect + volInput.style.backgroundImage = `linear-gradient(to right, var(--txa-brand) ${pct}%, rgba(255,255,255,0.15) ${pct}%)`; + + if (volTooltip) { + volTooltip.textContent = Math.round(pct) + '%'; + // Precise positioning follow thumb + const sliderWidth = 115; + const thumbWidth = 18; + const btnWidth = 42; + const usableWidth = sliderWidth - thumbWidth; + // Offset calculation relative to volume container + const leftOffset = btnWidth + 12 + (v * usableWidth) + (thumbWidth / 2); + volTooltip.style.left = leftOffset + 'px'; + } + } + if (btn) { + const icon = v === 0 ? 'mute' : v < 0.5 ? 'down' : 'up'; + btn.innerHTML = `
${v === 0 ? 'Unmute' : 'Mute'} (m)
`; + if (v === 0) btn.style.opacity = '0.6'; + else btn.style.opacity = '1'; + } + } + + formatTime(s, forceHours = false) { + if (!s || isNaN(s)) return '00:00'; + const h = Math.floor(s / 3600); + const m = Math.floor((s % 3600) / 60); + const sec = Math.floor(s % 60); + const pad = n => n < 10 ? '0' + n : n; + // If duration >= 1 hour OR forceHours, show HH:MM:SS + if (forceHours || h > 0) { + return `${pad(h)}:${pad(m)}:${pad(sec)}`; + } + return `${pad(m)}:${pad(sec)}`; + } + + /** + * Safe seek - prevents "non-finite" errors when duration/time is NaN or Infinity + */ + safeSeek(time) { + if (!this.video) return; + if (!isFinite(time) || isNaN(time)) return; + const dur = this.video.duration; + if (!isFinite(dur) || isNaN(dur) || dur <= 0) return; + this.video.currentTime = Math.max(0, Math.min(dur, time)); + } + + formatTimeDisplay() { + const current = this.video.currentTime || 0; + const duration = this.video.duration || 0; + return `${this.formatTime(current, duration >= 3600)} / ${this.formatTime(duration)}`; + } + + async toggleFS() { + try { + const isFS = document.fullscreenElement || document.webkitFullscreenElement; + if (isFS) { + if (document.exitFullscreen) await document.exitFullscreen(); + else if (document.webkitExitFullscreen) await document.webkitExitFullscreen(); + if (screen.orientation && screen.orientation.unlock) { + try { await screen.orientation.unlock(); } catch (e) { } + } + } else { + if (this.wrapper.requestFullscreen) await this.wrapper.requestFullscreen(); + else if (this.wrapper.webkitRequestFullscreen) await this.wrapper.webkitRequestFullscreen(); + else if (this.video.webkitEnterFullscreen) { + this.video.webkitEnterFullscreen(); + return; + } + if (this.detectMobile() && screen.orientation && screen.orientation.lock) { + try { await screen.orientation.lock('landscape'); } catch (e) { } + } + } + } catch (err) { + console.error('FS Error:', err); + if (this.video.webkitEnterFullscreen) this.video.webkitEnterFullscreen(); + } + } + + skipIntro() { + const intro = this.options.markers.intro; + if (intro) { + this.safeSeek(intro[1]); + this.showToast('🚀 Bỏ qua Intro'); + } + } + + skipOutro() { + const outro = this.options.markers.outro; + if (!outro) return; + + const effectiveOutroOut = (outro[1] > 0) ? outro[1] : this.video.duration; + + if (this.options.nextEpisodeUrl && Math.abs(effectiveOutroOut - this.video.duration) < 5) { + if (this.options.onAutoNext) { + this.options.onAutoNext(true); + } else if (typeof window.switchEpisodeSeamless === 'function' && this.options.nextEpisodeUrl) { + window.switchEpisodeSeamless(this.options.nextEpisodeUrl, true); + } else { + window.location.href = this.options.nextEpisodeUrl; + } + return; + } + + if (effectiveOutroOut >= this.video.duration - 5) { + this.video.pause(); + const replay = this.container.querySelector('#txa-replay'); + if (replay) replay.classList.add('show'); + } else { + this.safeSeek(outro[1]); + this.showToast('🚀 Bỏ qua Outro'); + } + } + + toggleAutoSkipIntro() { + this.settings.autoSkipIntro = !this.settings.autoSkipIntro; + this.saveSettings(); + const text = this.settings.autoSkipIntro ? 'Auto Skip Intro: Bật' : 'Auto Skip Intro: Tắt'; + this.showToast('🚀 ' + text); + this.updatePeSwitches(); + } + + toggleAutoNextEpisode() { + this.settings.autoNextEpisode = !this.settings.autoNextEpisode; + this.saveSettings(); + const text = this.settings.autoNextEpisode ? 'Auto Next: Bật' : 'Auto Next: Tắt'; + this.showToast('⏭️ ' + text); + this.updatePeSwitches(); + } + + updatePeSwitches() { + // Update Internal Toolbar Buttons + const skipBtn = this.container ? this.container.querySelector('#txa-auto-skip') : null; + if (skipBtn) { + const isOn = this.settings.autoSkipIntro; + skipBtn.classList.toggle('active', isOn); + const statusEl = skipBtn.querySelector('.txa-btn-status'); + if (statusEl) statusEl.textContent = isOn ? 'ON' : 'OFF'; + const tooltipEl = skipBtn.querySelector('.txa-tooltip'); + if (tooltipEl) tooltipEl.textContent = `Tự động bỏ qua giới thiệu (${isOn ? 'Bật' : 'Tắt'})`; + } + + const nextBtn = this.container ? this.container.querySelector('#txa-auto-next') : null; + if (nextBtn) { + const isOn = this.settings.autoNextEpisode; + nextBtn.classList.toggle('active', isOn); + const statusEl = nextBtn.querySelector('.txa-btn-status'); + if (statusEl) statusEl.textContent = isOn ? 'ON' : 'OFF'; + const tooltipEl = nextBtn.querySelector('.txa-tooltip'); + if (tooltipEl) tooltipEl.textContent = `Tự động chuyển tập (${isOn ? 'Bật' : 'Tắt'})`; + } + + // Sync external UI if needed + const extAutoSkip = document.querySelector('.pe-item.auto-skip-intro'); + if (extAutoSkip) { + extAutoSkip.classList.toggle('active-pro', this.settings.autoSkipIntro); + extAutoSkip.setAttribute('data-txa-tooltip', `Tự động bỏ qua Intro (${this.settings.autoSkipIntro ? 'BẬT' : 'TẮT'})`); + } + + const extAutoNext = document.querySelector('.pe-item.auto-next'); + if (extAutoNext) { + extAutoNext.classList.toggle('active-pro', this.settings.autoNextEpisode); + extAutoNext.setAttribute('data-txa-tooltip', `Tự động chuyển tập (${this.settings.autoNextEpisode ? 'BẬT' : 'TẮT'})`); + } + } + + /** + * Show auto-next countdown overlay when video ends (without outro markers) + */ + _showAutoNextCountdown() { + console.log('[TXAPlayer] _showAutoNextCountdown called', { + autoNextEpisode: this.settings.autoNextEpisode, + nextEpisodeUrl: this.options.nextEpisodeUrl, + isAutoNextTriggered: this._isAutoNextTriggered + }); + + const overlay = this.container.querySelector('#txa-next-countdown'); + const timeEl = this.container.querySelector('#txa-nc-timer'); + const titleEl = this.container.querySelector('#txa-nc-title'); + const badgeEl = this.container.querySelector('#txa-nc-badge'); + + if (!overlay) { + console.warn('[TXAPlayer] Countdown overlay not found in DOM'); + return; + } + + // Set title + if (titleEl) titleEl.textContent = this.options.title || 'Tập tiếp theo'; + + // Smart Badge: Try to detect next episode number + if (badgeEl) { + let nextNum = '--'; + try { + const url = this.options.nextEpisodeUrl || ''; + const curName = this.options.episodeName || ''; + const matchUrl = url.match(/(tap|ep|episode)[\-_](\d+)/i) || url.match(/-(\d+)\.html/) || url.match(/-(\d+)$/); + + if (matchUrl) { + nextNum = matchUrl[matchUrl.length - 1]; + } else { + const matchCurr = curName.match(/(\d+)/); + if (matchCurr) { + const num = parseInt(matchCurr[1]) + 1; + nextNum = (matchCurr[1].startsWith('0') && num < 10) ? '0' + num : num; + } + } + } catch (e) { } + badgeEl.innerHTML = `Tập${nextNum}`; + } + + // Show overlay + overlay.classList.add('show'); + if (this.wrapper) this.wrapper.classList.add('has-countdown'); + + // Start countdown + let countdown = 5; + if (timeEl) { + timeEl.textContent = `Bắt đầu sau 0${countdown}s`; + } + + const countdownInterval = setInterval(() => { + countdown--; + if (countdown <= 0) { + clearInterval(countdownInterval); + overlay.classList.remove('show'); + if (this.wrapper) this.wrapper.classList.remove('has-countdown'); + + // Trigger auto-next + this._isAutoNextTriggered = true; + this._triggerAutoNext(); + } else { + if (timeEl) { + timeEl.textContent = `Bắt đầu sau 0${countdown}s`; + } + } + }, 1000); + + // Store interval ID to clear if needed + this._autoNextCountdownInterval = countdownInterval; + } + + /** + * Trigger auto-next episode switch + */ + _triggerAutoNext() { + // Always prefer window.switchEpisodeSeamless if available (for seamless SPA experience) + if (typeof window.switchEpisodeSeamless === 'function' && this.options.nextEpisodeUrl) { + console.log('[TXAPlayer] Using switchEpisodeSeamless for auto-next'); + window.switchEpisodeSeamless(this.options.nextEpisodeUrl, true); + } else if (this.options.onAutoNext) { + this.options.onAutoNext(true); + } else if (window.loadEpisode && typeof window.loadEpisode === 'function') { + window.loadEpisode(this.options.nextEpisodeUrl); + } else if (this.options.nextEpisodeUrl) { + console.warn('[TXAPlayer] No seamless switch available, falling back to page reload'); + window.location.href = this.options.nextEpisodeUrl; + } + } + + checkMarkers() { + const ct = this.video.currentTime; + const dur = this.video.duration; + const { intro, outro } = this.options.markers; + + // Player Internal Buttons + const skipIntro = this.container.querySelector('#txa-skip-intro'); + const skipOutro = this.container.querySelector('#txa-skip-outro'); + + // External Buttons (for TPhimX Tools) + const extIntro = document.querySelector('.skip-intro-btn'); + const extOutro = document.querySelector('.skip-outro-btn'); + + // Initial UI sync for external switches + if (!this._peSwitchesInited) { + this.updatePeSwitches(); + this._peSwitchesInited = true; + } + + // Skip Intro logic + if (intro && ct >= intro[0] && ct <= intro[1]) { + if (skipIntro) skipIntro.style.display = 'block'; + if (extIntro) extIntro.classList.remove('d-none'); + + if (this.settings.autoSkipIntro && ct < intro[1]) { + this.safeSeek(intro[1]); + this.showToast('🚀 Đã tự động bỏ qua Intro'); + } + } else { + if (skipIntro) skipIntro.style.display = 'none'; + if (extIntro) extIntro.classList.add('d-none'); + } + + // Skip Outro / Next Episode logic + // STRICT CHECK: Only trigger if Outro is VALID (Start > 0) per user request + const isValidOutro = outro && (outro[1] > outro[0] || (outro[0] > 0 && (outro[1] === 0 || !outro[1]))) && outro[0] > 0; + const effectiveOutroOut = isValidOutro ? (outro[1] > 0 ? outro[1] : dur) : 0; + + if (isValidOutro && ct >= outro[0] && ct <= effectiveOutroOut) { + if (skipOutro) { + skipOutro.style.display = 'block'; + // If we are very close to end, change text + if (this.options.nextEpisodeUrl && Math.abs(dur - ct) < 15) { + skipOutro.innerHTML = ' Tập Tiếp'; + } + } + if (extOutro) extOutro.classList.remove('d-none'); + + // Auto Next Countdown & Logic + // Only runs if Auto Next is enabled AND we have a valid Outro + if (this.settings.autoNextEpisode && this.options.nextEpisodeUrl && !this._isAutoNextTriggered) { + const triggerWait = 5; // 5s countdown + const overlay = this.container.querySelector('#txa-next-countdown'); + const timeEl = this.container.querySelector('#txa-nc-timer'); + const titleEl = this.container.querySelector('#txa-nc-title'); + const badgeEl = this.container.querySelector('#txa-nc-badge'); + + // Show Overlay + if (overlay && !overlay.classList.contains('show')) { + if (titleEl) titleEl.textContent = this.options.title || 'Tập tiếp theo'; + + // Smart Badge: Try to detect next episode number + if (badgeEl) { + let nextNum = '--'; + try { + const url = this.options.nextEpisodeUrl || ''; + const curName = this.options.episodeName || ''; + const matchUrl = url.match(/(tap|ep|episode)[\-_](\d+)/i) || url.match(/-(\d+)\.html/) || url.match(/-(\d+)$/); + + if (matchUrl) { + nextNum = matchUrl[matchUrl.length - 1]; + } else { + const matchCurr = curName.match(/(\d+)/); + if (matchCurr) { + const num = parseInt(matchCurr[1]) + 1; + nextNum = (matchCurr[1].startsWith('0') && num < 10) ? '0' + num : num; + } + } + } catch (e) { } + badgeEl.innerHTML = `Tập${nextNum}`; + } + + overlay.classList.add('show'); + this.wrapper.classList.add('has-countdown'); + if (skipOutro) skipOutro.style.display = 'none'; + } + + // Calculate Countdown + const elapsedInOutro = ct - outro[0]; + const remain = Math.max(0, triggerWait - Math.floor(elapsedInOutro)); + + if (timeEl) { + const fmt = (remain < 10 ? '0' + remain : remain) + 's'; + timeEl.textContent = `Bắt đầu sau ${fmt}`; + } + + // Trigger Next + if (elapsedInOutro >= triggerWait) { + this._isAutoNextTriggered = true; + if (overlay) overlay.classList.remove('show'); + this.wrapper.classList.remove('has-countdown'); + + this._triggerAutoNext(); + } + } + } else { + // Not in Outro / Invalid Outro + if (skipOutro) skipOutro.style.display = 'none'; + if (extOutro) extOutro.classList.add('d-none'); + + // Clean up if we sought out of outro + const overlay = this.container.querySelector('#txa-next-countdown'); + if (overlay && overlay.classList.contains('show')) { + overlay.classList.remove('show'); + this.wrapper.classList.remove('has-countdown'); + } + } + } + + setupShortcuts() { + this._handlers.winKeyDown = (e) => { + if (this.destroyed) return; + if (['INPUT', 'TEXTAREA'].includes(e.target.tagName)) return; + const k = e.key.toLowerCase(); + + // Prevent scrolling for arrow keys if player is in focus or just generally + if ([' ', 'k', 'f', 'm', 'p', 'arrowup', 'arrowdown', 'arrowleft', 'arrowright'].includes(k)) { + // Only prevent default if it's a player key + } + + switch (k) { + case ' ': case 'k': e.preventDefault(); this.togglePlay(); break; + case 'f': this.toggleFS(); break; + case 'm': this.video.muted = !this.video.muted; this.updateVolUI(); this.showFeedback('volume'); this.saveSettings(); break; + case 'p': this.toggleNativePiP(); break; + case 'j': case 'arrowleft': this.seekAccumulated(-10); break; + case 'l': case 'arrowright': this.seekAccumulated(10); break; + case 'arrowup': e.preventDefault(); this.video.volume = Math.min(1, this.video.volume + 0.05); this.updateVolUI(); this.showFeedback('volume'); this.saveSettings(); break; + case 'arrowdown': e.preventDefault(); this.video.volume = Math.max(0, this.video.volume - 0.05); this.updateVolUI(); this.showFeedback('volume'); this.saveSettings(); break; + case 'c': this.toggleSubLoop(); break; + case 'i': this.skipIntro(); break; + case 'o': this.skipOutro(); break; + case 't': this.toggleTheaterMode(); break; // v5.8.0 - Theater Mode + case 'a': this.toggleCinemaMode(); break; // v5.8.0 - Ambient Light + case 'escape': { + const el = (s) => this.container.querySelector(s); + + // 1. Close dynamic shortcuts panel + const sc = document.querySelector('.txa-shortcuts-panel'); + if (sc) sc.remove(); + + // 2. Toggle off Stats Panel if active + const stats = el('#txa-stats-panel'); + if (stats && stats.classList.contains('active')) this.toggleStatsPanel(); + + // 3. Hide Settings Panel + const settings = el('#txa-panel'); + if (settings && settings.classList.contains('active')) settings.classList.remove('active'); + + // 4. Hide Context Menu + const ctx = el('#txa-ctx'); + if (ctx && ctx.classList.contains('active')) ctx.classList.remove('active'); + + // 5. Hide Resume Overlay + const resume = el('#txa-resume'); + if (resume && resume.classList.contains('show')) { + resume.classList.remove('show'); + this.resumeShown = true; + } + + // 6. Cancel Next Episode Countdown + const next = el('#txa-next-countdown'); + if (next && next.classList.contains('show')) { + next.classList.remove('show'); + this._isAutoNextTriggered = true; + } + + break; + } + case '/': { + if (e.shiftKey) { + e.preventDefault(); + this.showShortcuts(); + } else { + // Search Shortcut Focus + e.preventDefault(); + setTimeout(() => { + const searchInput = document.querySelector('input[name="keyword"]') || + document.querySelector('#search-keyword') || + document.querySelector('.search-input'); + if (searchInput) { + searchInput.focus(); + searchInput.select(); + } + }, 50); + } + break; + } + default: + if (k >= '0' && k <= '9') { + const pct = parseInt(k) * 10; + const t = (pct / 100) * this.video.duration; + this.safeSeek(t); + this.showFeedback('seek', `${pct}% (${this.formatTime(t)})`); + } + } + }; + window.addEventListener('keydown', this._handlers.winKeyDown); + } + + // initSubtitles merged with version above to avoid duplication logic bugs + + + async toggleSub(idx) { + const lbl = this.container.querySelector('#txa-lbl-subs'); + const btn = this.container.querySelector('#txa-cc'); + const subs = this.options.subtitles; + + // Clear previous subtitles immediately to avoid "stuck" captions while loading + this.currentSubCues = []; + this.renderSubtitles(); + + if (idx === -1) { + if (lbl) lbl.textContent = 'Off'; // Added null check + this.activeSubIdx = -1; + if (btn) btn.classList.remove('cc-active'); // Added null check + this.showFeedback('text', 'Subtitles: Off'); + } else { + const sub = subs && subs[idx]; + if (!sub) { + if (lbl) lbl.textContent = 'Off'; + this.activeSubIdx = -1; + if (btn) btn.classList.remove('cc-active'); + return; + } + if (lbl) lbl.textContent = sub.label || sub.lang; // Added null check + this.activeSubIdx = idx; + if (btn) btn.classList.add('cc-active'); // Added null check + this.showFeedback('text', `Subtitles: ${sub.label || sub.lang}`); + + let txt = sub.content || ''; + if (sub.file) { + try { + txt = await (await fetch(sub.file)).text(); + } catch (e) { + console.error('Subtitle fetch failed:', e); + this.showToast('Lỗi tải phụ đề'); + } + } + + this.currentSubCues = this.parseVTT(txt); + // Re-render immediately so the correct subtitle shows up at current time + this.renderSubtitles(); + } + this.navSettings('main'); + + // Update active class in menu list + const list = this.container.querySelector('#txa-list-subs'); + if (list) { + list.querySelectorAll('.txa-menu-item').forEach(o => o.classList.remove('active')); + list.querySelector(`[data-sub="${idx}"]`)?.classList.add('active'); + } + } + + toggleSubLoop() { + if (this.currentSubCues.length > 0) this.toggleSub(-1); + else if (this.options.subtitles?.length > 0) this.toggleSub(0); + } + + renderSubtitles() { + const box = this.container.querySelector('#txa-captions'); + if (!box) return; // Added null check + if (!this.currentSubCues.length) { box.innerHTML = ''; return; } + const ct = this.video.currentTime; + const cue = this.currentSubCues.find(c => ct >= c.start && ct <= c.end); + box.innerHTML = cue ? `
${cue.text}
` : ''; + } + + parseVTT(content) { + if (!content) return []; + const cues = []; + // Clean up content: Remove WEBVTT header and metadata + let processed = content.replace(/^WEBVTT.*\r?\n/i, ''); + // Convert SRT commas to dots for universal parsing + processed = processed.replace(/(\d+:\d+:\d+),(\d+)/g, '$1.$2'); + + const lines = processed.split(/\r?\n/); + let start = null, end = null, text = []; + + const parseTime = (t) => { + t = t.trim().replace(/[\[\]]/g, ''); + const p = t.split(':'); + if (p.length === 3) { + // HH:MM:SS.mmm or MM:SS.mmm + const hours = parseInt(p[0]) || 0; + const minutes = parseInt(p[1]) || 0; + const seconds = parseFloat(p[2].replace(',', '.')) || 0; + return hours * 3600 + minutes * 60 + seconds; + } else if (p.length === 2) { + const minutes = parseInt(p[0]) || 0; + const seconds = parseFloat(p[1].replace(',', '.')) || 0; + return minutes * 60 + seconds; + } + return parseFloat(t) || 0; + }; + + lines.forEach(line => { + const l = line.trim(); + if (l.includes('-->')) { + // Time range line + if (start !== null && text.length > 0) { + cues.push({ start, end: end || start + 5, text: text.join('
') }); + text = []; + } + const p = l.split('-->'); + start = parseTime(p[0]); + end = parseTime(p[1]); + } else if (l === '') { + // Separator + if (start !== null && text.length > 0) { + cues.push({ start, end: end || start + 5, text: text.join('
') }); + start = null; end = null; text = []; + } + } else if (/^\d+$/.test(l)) { + // Index line (SRT) - ignore + } else if (l !== '') { + // Text line + if (start !== null) text.push(l); + } + }); + + // Push last cue + if (start !== null && text.length > 0) { + cues.push({ start, end: end || start + 5, text: text.join('
') }); + } + + return cues; + } + + navSettings(view) { + const p = this.container.querySelector('#txa-panel'); + if (!p) return; // Added null check + p.querySelectorAll('[id^="txa-view-"]').forEach(d => d.classList.add('txa-hidden')); + const target = p.querySelector(`#txa-view-${view}`); + if (target) target.classList.remove('txa-hidden'); + } + + setSpeed(rate) { + this.video.playbackRate = rate; + const speedLabel = this.container.querySelector('#txa-lbl-speed'); // Added null check + if (speedLabel) speedLabel.textContent = rate === 1 ? 'Normal' : rate + 'x'; // Added null check + this.navSettings('main'); + this.saveSettings(); + } + + setupContextMenu() { + const el = (s) => this.container.querySelector(s); + const ctx = el('#txa-ctx'); + if (!ctx) return; + + if (this.detectMobile()) { + this.wrapper.oncontextmenu = (e) => { + if (this.destroyed) return; + e.preventDefault(); + return false; + }; + return; + } + + this.wrapper.oncontextmenu = (e) => { + if (this.destroyed) return; + e.preventDefault(); + const r = this.wrapper.getBoundingClientRect(); + // Collision detection + let left = e.clientX - r.left; + let top = e.clientY - r.top; + + // If menu goes off right edge + if (left + 250 > r.width) left = r.width - 250; + // If menu goes off bottom edge + if (top + 280 > r.height) top = r.height - 280; + + ctx.style.left = Math.max(10, left) + 'px'; + ctx.style.top = Math.max(10, top) + 'px'; + ctx.classList.add('active'); + }; + // Redundant ctxClick removed - now handled by docClick in bindEvents() + /* + this._handlers.ctxClick = (e) => { + if (this.destroyed) return; + if (ctx && !ctx.contains(e.target)) ctx.classList.remove('active'); + }; + document.addEventListener('click', this._handlers.ctxClick); + */ + + // Ensure these el() calls find elements correctly + const bindCtx = (id, fn) => { + const item = el(id); + if (item) item.onclick = () => { + if (ctx) ctx.classList.remove('active'); + fn(); + }; + }; + + bindCtx('#txa-ctx-snap', () => this.takeSnapshot()); + bindCtx('#txa-ctx-url', () => { navigator.clipboard.writeText(location.href); this.showToast('URL Copied!'); }); + bindCtx('#txa-ctx-loop', () => { + this.video.loop = !this.video.loop; + const state = this.video.loop ? 'On' : 'Off'; + const loopStat = el('#txa-loop-stat'); // Added null check + if (loopStat) loopStat.textContent = state; // Added null check + this.showFeedback('text', `Loop Mode: ${state}`); + }); + bindCtx('#txa-ctx-stats', () => this.toggleStatsPanel()); + bindCtx('#txa-ctx-sc', () => this.showShortcuts()); + + // Auto Toggle Handlers + const introSw = el('#txa-sw-intro'); + if (introSw) { + introSw.onchange = (e) => { + this.settings.autoSkipIntro = e.target.checked; + this.saveSettings(); + this.showToast(`Auto Skip Intro: ${e.target.checked ? 'ON' : 'OFF'}`); + }; + } + const nextSw = el('#txa-sw-next'); + if (nextSw) { + nextSw.onchange = (e) => { + this.settings.autoNextEpisode = e.target.checked; + this.saveSettings(); + this.showToast(`Auto Next: ${e.target.checked ? 'ON' : 'OFF'}`); + }; + } + } + + showToast(msg) { + const t = document.createElement('div'); + t.className = 'txa-feedback show'; + t.innerHTML = `${msg}`; + if (this.container) this.container.appendChild(t); // Added null check + setTimeout(() => t.remove(), 2500); + } + showShortcuts() { + // Removed redundant pointer check that might fail on some Windows desktops + + + const o = document.createElement('div'); + o.className = 'txa-shortcuts-panel active'; + o.id = 'txa-sc-panel'; + + const css = ` + .txa-shortcuts-panel { + background: rgba(0, 0, 0, 0.75); backdrop-filter: blur(25px); + z-index: 10000; + display: flex; align-items: center; justify-content: center; + opacity: 0; animation: txafadeIn 0.3s forwards; + } + .txa-shortcuts-content { + width: 900px; max-width: 90%; + background: #0d0d0d; border: 1px solid rgba(255,255,255,0.1); + border-radius: 24px; padding: 40px; + position: relative; box-shadow: 0 30px 60px rgba(0,0,0,0.8); + } + .txa-shortcuts-header { + display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 40px; + } + .txa-sc-title h3 { margin: 0; font-size: 28px; font-weight: 900; color: #fff; letter-spacing: -1px; } + .txa-sc-title p { margin: 8px 0 0; font-size: 14px; color: #64748b; font-weight: 500; } + .txa-sc-close { + width: 44px; height: 44px; border-radius: 14px; border: none; + background: rgba(255,255,255,0.05); color: #fff; cursor: pointer; + transition: 0.3s; display: flex; align-items: center; justify-content: center; + } + .txa-sc-close:hover { background: #ef4444; transform: rotate(90deg); } + + .txa-sc-grid { + display: grid; grid-template-columns: repeat(3, 1fr); gap: 30px; + } + + .txa-sc-column { + display: flex; flex-direction: column; gap: 15px; + } + + .txa-sc-group-label { + font-size: 11px; text-transform: uppercase; letter-spacing: 2px; + color: var(--txa-brand, #8b5cf6); font-weight: 800; opacity: 0.8; + padding-bottom: 10px; border-bottom: 1px solid rgba(255,255,255,0.05); + } + + .txa-sc-item { + display: flex; justify-content: space-between; align-items: center; + padding: 12px 16px; background: rgba(255,255,255,0.02); + border-radius: 12px; border: 1px solid transparent; transition: 0.2s; + } + .txa-sc-item:hover { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.1); } + + .txa-sc-name { color: #cbd5e1; font-size: 14px; font-weight: 500; } + .txa-sc-keys { display: flex; gap: 6px; } + + kbd { + background: #1a1a1a; border: 1px solid #333; border-bottom-width: 3px; + color: #fff; border-radius: 6px; padding: 4px 8px; + font-family: inherit; font-size: 11px; font-weight: 700; + min-width: 20px; text-align: center; + } + .txa-sc-footer { + margin-top: 40px; padding: 20px; border-radius: 16px; + background: linear-gradient(to right, rgba(139,92,246,0.1), transparent); + border: 1px solid rgba(139,92,246,0.2); display: flex; align-items: center; gap: 15px; + } + .txa-sc-footer i { font-size: 20px; color: #8b5cf6; } + .txa-sc-footer p { margin: 0; font-size: 13px; color: #94a3b8; line-height: 1.5; } + `; + + o.innerHTML = ` + +
+
+
+

PHÍM TẮT

+

Trải nghiệm điều khiển điện ảnh với TPhimX Player

+
+ +
+ +
+
+ ĐiềU KHIỂN CHÍNH +
Phát / Dừng
Space
+
Tua lại 10s
J /
+
Tua tiếp 10s
L /
+
Nhảy nhanh
0-9
+
+ +
+ ÂM THANH & SUB +
Tăng âm lượng
+
Giảm âm lượng
+
Tắt tiếng
M
+
Đổi phụ đề
C
+
+ +
+ GIAO DIỆN +
Toàn màn hình
F
+
Thu nhỏ (PiP)
P
+
Rạp chiếu phim
T
+
Đóng Menu
Esc
+
+
+ + +
+ `; + + const closeBtn = o.querySelector('.txa-sc-close'); + if (closeBtn) { + closeBtn.onclick = (e) => { e.stopPropagation(); o.remove(); }; + } + + o.onclick = (e) => { o.remove(); }; + if (this.wrapper) this.wrapper.appendChild(o); + } + + loadInitialSettings() { + const el = (s) => this.container.querySelector(s); + if (this.settings.volume !== undefined) { + this.video.volume = this.settings.volume; + this.video.muted = this.settings.muted || false; + this.updateVolUI(); + } + if (this.settings.playbackRate) { + this.setSpeed(this.settings.playbackRate); + } + + // v6.5.2 - Load Aspect Ratio & Flip + if (this.settings.aspectRatio) { + this.setAspectRatio(this.settings.aspectRatio); + } + if (this.settings.videoFlip) { + this.setVideoFlip(this.settings.videoFlip); + } + + if (this.settings.loop !== undefined) { + this.video.loop = this.settings.loop; + const loopStat = this.container.querySelector('#txa-loop-stat'); + if (loopStat) loopStat.textContent = this.video.loop ? 'On' : 'Off'; + } + if (this.settings.activeSubIdx !== undefined && this.settings.activeSubIdx !== -1) { + setTimeout(() => this.toggleSub(this.settings.activeSubIdx), 500); + } + const cap = el('#txa-captions'); + const s = this.settings; + if (cap && s.subStyle) { + if (s.subStyle.size) { + cap.classList.add('size-' + s.subStyle.size); + this.container.querySelectorAll('[data-subsize]').forEach(o => { + o.classList.toggle('active', o.dataset.subsize === s.subStyle.size); + }); + } + if (s.subStyle.weight) { + cap.classList.add('weight-' + s.subStyle.weight); + this.container.querySelectorAll('[data-subweight]').forEach(o => { + o.classList.toggle('active', o.dataset.subweight === s.subStyle.weight); + }); + } + if (s.subStyle.bg) { + if (s.subStyle.bg !== 'default') cap.classList.add('bg-' + s.subStyle.bg); + this.container.querySelectorAll('[data-subbg]').forEach(o => { + o.classList.toggle('active', o.dataset.subbg === s.subStyle.bg); + }); + } + if (s.subStyle.color) { + cap.classList.add('color-' + s.subStyle.color); + this.container.querySelectorAll('[data-subcolor]').forEach(o => { + o.classList.toggle('active', o.dataset.subcolor === s.subStyle.color); + }); + } + if (s.subStyle.stroke) { + cap.classList.add('stroke-on'); + const strokeToggle = el('#txa-substroke-toggle'); + if (strokeToggle) strokeToggle.checked = true; + const strokePanel = el('#txa-stroke-panel'); + if (strokePanel) strokePanel.classList.add('active'); + } + if (s.subStyle.strokeColor) { + cap.classList.add('stroke-' + s.subStyle.strokeColor); + this.container.querySelectorAll('[data-substroke]').forEach(o => { + if (o.dataset.substroke === s.subStyle.strokeColor) o.classList.add('active'); + else o.classList.remove('active'); + }); + } + } + + // v6.4.0 - Real-time clock initial state + const clockToggle = el('#txa-clock-toggle'); + if (clockToggle) clockToggle.checked = this.settings.showRealTime; + + if (this.settings.clockFormat) { + const lbl = el('#txa-lbl-clock'); + if (lbl) lbl.textContent = this.settings.clockFormat; + this.container.querySelectorAll('[data-clock]').forEach(o => { + o.classList.toggle('active', o.dataset.clock === this.settings.clockFormat); + }); + } + this.updateClockVisibility(); + + // v6.1.0 - Sync external switches + this.updatePeSwitches(); + } + loadSettings() { + const key = 'txa-p-conf'; + let saved = localStorage.getItem(key); + if (!saved) { + // Migration for old keys + const oldKeys = ['txa-txa-cfg', 'txa_player_settings', 'txa-player-v4-settings']; + for (const ok of oldKeys) { + const oldData = localStorage.getItem(ok); + if (oldData) { + localStorage.setItem(key, oldData); + // Cleanup old keys + oldKeys.forEach(k => localStorage.removeItem(k)); + localStorage.removeItem('txa_player_state'); + return JSON.parse(oldData); + } + } + return {}; + } + try { return JSON.parse(saved) || {}; } catch { return {}; } + } + saveSettings() { + if (!this.video || this.destroyed) return; + const el = (s) => this.container.querySelector(s); + const cap = el('#txa-captions'); + const strokeToggle = el('#txa-substroke-toggle'); + + // Extract Aspect Ratio and Flip from classList + const aspectRatio = Array.from(this.video.classList).find(c => c.startsWith('ratio-'))?.replace('ratio-', '') || 'default'; + const videoFlip = Array.from(this.video.classList).find(c => c.startsWith('flip-'))?.replace('flip-', '') || 'normal'; + + const cfg = { + volume: this.video.volume, + muted: this.video.muted, + playbackRate: this.video.playbackRate, + loop: this.video.loop, + activeSubIdx: this.activeSubIdx, + aspectRatio: aspectRatio, + videoFlip: videoFlip, + subStyle: cap ? { + size: Array.from(cap.classList).find(c => c.startsWith('size-'))?.replace('size-', ''), + weight: Array.from(cap.classList).find(c => c.startsWith('weight-'))?.replace('weight-', ''), + bg: Array.from(cap.classList).find(c => c.startsWith('bg-'))?.replace('bg-', '') || 'default', + color: Array.from(cap.classList).find(c => c.startsWith('color-'))?.replace('color-', ''), + stroke: strokeToggle ? strokeToggle.checked : false, + strokeColor: Array.from(cap.classList).find(c => c.startsWith('stroke-'))?.replace('stroke-', '') + } : {}, + captionBottom: cap ? parseInt(cap.style.bottom) : 110, + captionLeft: (cap && cap.style.left) ? parseFloat(cap.style.left) : undefined, + autoSkipIntro: this.settings.autoSkipIntro, + autoNextEpisode: this.settings.autoNextEpisode, + brightness: this.options.brightness || 1, + showRealTime: this.settings.showRealTime, + clockFormat: this.settings.clockFormat + }; + localStorage.setItem('txa-p-conf', JSON.stringify(cfg)); + + // v6.0.0 - Sync to Cloud if saveSettingsUrl is provided + if (this.options.saveSettingsUrl && this.options.csrfToken) { + fetch(this.options.saveSettingsUrl, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'X-CSRF-TOKEN': this.options.csrfToken + }, + body: JSON.stringify({ settings: cfg }) + }).catch(e => console.warn('[TXAPlayer] Settings sync failed:', e)); + } + } + + takeSnapshot() { + try { + const c = document.createElement('canvas'); + c.width = this.video.videoWidth; + c.height = this.video.videoHeight; + const ctx = c.getContext('2d'); + + // Draw video frame + ctx.drawImage(this.video, 0, 0); + + const watermark = `TPHIMX Player - ${TXA_VERSION} `; + const fontSize = Math.max(18, c.height * 0.03); + ctx.font = `bold ${fontSize}px Inter, sans - serif`; + ctx.fillStyle = 'rgba(255, 255, 255, 0.6)'; + ctx.textAlign = 'right'; + ctx.textBaseline = 'bottom'; + ctx.shadowColor = 'rgba(0, 0, 0, 0.7)'; + ctx.shadowBlur = 6; + ctx.fillText(watermark, c.width - 25, c.height - 20); + + const a = document.createElement('a'); + a.download = `tphimx - snapshot - ${Date.now()}.png`; + a.href = c.toDataURL('image/png', 1.0); + a.click(); + this.showToast('Snapshot 4K Captured!'); + } catch (e) { + console.error('TXAPlayer Snapshot Error:', e); + if (e.name === 'SecurityError') { + this.showToast('Lỗi bảo mật: Không thể chụp ảnh từ máy chủ này (CORS)'); + } else { + this.showToast('Không thể chụp ảnh màn hình lúc này'); + } + } + } + + toggleView(v) { + if (v === 'shortcuts') this.showShortcuts(); + if (v === 'stats') this.toggleStatsPanel(); + } + + toggleStatsPanel() { + const panel = this.container.querySelector('#txa-stats-panel'); + if (!panel) return; + + if (panel.classList.contains('active')) { + panel.classList.remove('active'); + if (this._statsInterval) { clearInterval(this._statsInterval); this._statsInterval = null; } + return; + } + + panel.classList.add('active'); + this.updateStatsPanel(); + + // Update every 1s + this._statsInterval = setInterval(() => { + if (this.destroyed || !panel.classList.contains('active')) { + clearInterval(this._statsInterval); + this._statsInterval = null; + return; + } + this.updateStatsPanel(); + }, 1000); + + // Close button + const closeBtn = this.container.querySelector('#txa-stats-close'); + if (closeBtn) closeBtn.onclick = () => this.toggleStatsPanel(); + } + + updateStatsPanel() { + const grid = this.container.querySelector('#txa-stats-grid'); + if (!grid || !this.video) return; + const v = this.video; + const fmt = window.txaformat; + + // Gather stats + const resolution = `${v.videoWidth || '?'}×${v.videoHeight || '?'} `; + const currentTime = this.formatTime(v.currentTime); + const duration = this.formatTime(v.duration); + const ahead = (v.buffered && v.buffered.length > 0) ? (v.buffered.end(v.buffered.length - 1) - v.currentTime) : 0; + + // Fast DOM Update + const html = ` + < div class="txa-stat-item" >
Resolution
${resolution}
+
Speed
${v.playbackRate}x
+
Progress
${currentTime} / ${duration}
+
Buffer
${ahead.toFixed(1)}s ahead
+
Volume
${v.muted ? 'Muted' : Math.round(v.volume * 100) + '%'}
+
Player
TXAPlayer ${TXA_VERSION}
+ `; + + if (this._lastStatsHTML !== html) { + grid.innerHTML = html; + this._lastStatsHTML = html; + } + } + toggleNativePiP() { document.pictureInPictureElement ? document.exitPictureInPicture() : this.video.requestPictureInPicture(); } + + destroy() { + this.destroyed = true; + + if (this._devCheck) clearInterval(this._devCheck); + if (this._statsInterval) clearInterval(this._statsInterval); + if (this._autoNextCountdownInterval) clearInterval(this._autoNextCountdownInterval); + + // Stop playback & Cleanup Video + if (this.video) { + try { + this.video.ontimeupdate = null; // Unbind immediately + this.video.pause(); + this.video.src = ""; + this.video.load(); + this.video.remove(); + } catch (e) { } + } + + // Destroy dashjs + if (this.dashPlayer) { + try { this.dashPlayer.destroy(); } catch (e) { } + this.dashPlayer = null; + } + + // Destroy Hls + if (this.hls) { + try { this.hls.destroy(); } catch (e) { } + this.hls = null; + } + + // Cleanup dynamic preview engine on destroy + if (this._previewVideo) { + try { + this._previewVideo.pause(); + this._previewVideo.src = ""; + this._previewVideo.load(); + this._previewVideo.remove(); + } catch (e) { } + this._previewVideo = null; + } + if (this._previewHls) { + try { this._previewHls.destroy(); } catch (e) { } + this._previewHls = null; + } + + // Remove global listeners + if (this._handlers) { + if (this._handlers.winMouseMove) window.removeEventListener('mousemove', this._handlers.winMouseMove); + if (this._handlers.winMouseUp) window.removeEventListener('mouseup', this._handlers.winMouseUp); + if (this._handlers.winKeyDown) window.removeEventListener('keydown', this._handlers.winKeyDown); + if (this._handlers.docClick) document.removeEventListener('click', this._handlers.docClick); + if (this._handlers.docFSChange) document.removeEventListener('fullscreenchange', this._handlers.docFSChange); + if (this._handlers.dragMouseMove) window.removeEventListener('mousemove', this._handlers.dragMouseMove); + if (this._handlers.dragMouseUp) window.removeEventListener('mouseup', this._handlers.dragMouseUp); + if (this._handlers.ctxClick) document.removeEventListener('click', this._handlers.ctxClick); + if (this._handlers.theaterEscape) window.removeEventListener('keydown', this._handlers.theaterEscape); // v5.8.0 + } + + if (this.feedbackTimer) clearTimeout(this.feedbackTimer); + if (this.seekDebounce) clearTimeout(this.seekDebounce); + if (this._clickTimer) clearTimeout(this._clickTimer); + if (this._progressSaveInterval) clearInterval(this._progressSaveInterval); // v5.8.0 - Clear progress save interval + + // v5.8.0 - Stop ambient light animation + this.stopAmbientLight(); + + // v5.8.0 - Save final progress + this.saveWatchProgress(); + + // Clear UI + if (this.container) this.container.innerHTML = ""; + + console.log("TXAPlayer: Destroyed instance"); + } + + detectDevTools() { + if (this.options.isAdmin) return; + if (this.detectMobile()) return; // Skip on mobile as requested + + const threshold = 160; + this._devCheck = setInterval(() => { + if (this.destroyed) return; + + const start = performance.now(); + debugger; + const end = performance.now(); + + if (end - start > threshold) { + this.tamperAlert(true); + } else { + this.tamperAlert(false); + } + }, 2000); // 2s check to be less noisy + } + + tamperAlert(isBlocked) { + const overlay = this.container.querySelector('#txa-tamper'); + if (!overlay || this.isTamperPermanent) return; + + if (isBlocked) { + // Once detected, it becomes permanent + this.isTamperPermanent = true; + overlay.classList.remove('txa-hidden'); + + console.warn('[TXA] Tamper detected! Locking player.'); + + // Aggressively stop video + if (this.video) { + try { + this.video.pause(); + this.video.muted = true; + this.video.removeAttribute('src'); // Remove src attr + this.video.load(); + } catch (e) { } + } + + if (this.hls) { + try { + this.hls.stopLoad(); + this.hls.detachMedia(); + this.hls.destroy(); + } catch (e) { } + this.hls = null; + } + + if (this.dashPlayer) { + try { + this.dashPlayer.reset(); + this.dashPlayer.destroy(); + } catch (e) { } + this.dashPlayer = null; + } + + // Disable interaction + if (this.wrapper) { + this.wrapper.style.pointerEvents = 'none'; + this.wrapper.style.opacity = '0.1'; + } + overlay.style.pointerEvents = 'all'; // Allow clicking reload button + + } else { + // Safe state + overlay.classList.add('txa-hidden'); + } + } + + // ============================================================ + // v5.8.0 NEW FEATURES + // ============================================================ + + /** + * Theater Mode - Expand player to full screen overlay (not browser fullscreen) + */ + toggleTheaterMode() { + this.isTheaterMode = !this.isTheaterMode; + const btn = this.container.querySelector('#txa-theater'); + + if (this.isTheaterMode) { + this.wrapper.classList.add('theater-mode'); + document.body.classList.add('theater-mode-active'); + if (btn) btn.classList.add('mode-active'); + this.showFeedback('text', 'Theater Mode: On'); + } else { + this.wrapper.classList.remove('theater-mode'); + document.body.classList.remove('theater-mode-active'); + if (btn) btn.classList.remove('mode-active'); + this.showFeedback('text', 'Theater Mode: Off'); + } + } + + /** + * Cinema Mode - Ambient light effect that extracts colors from video + */ + toggleCinemaMode() { + this.isCinemaMode = !this.isCinemaMode; + const btn = this.container.querySelector('#txa-cinema'); + + if (this.isCinemaMode) { + this.wrapper.classList.add('cinema-mode'); + this.container.classList.add('cinema-active'); + if (btn) btn.classList.add('mode-active'); + this.startAmbientLight(); + this.showFeedback('text', 'Ánh sáng: Bật'); + } else { + this.wrapper.classList.remove('cinema-mode'); + this.container.classList.remove('cinema-active'); + if (btn) btn.classList.remove('mode-active'); + this.stopAmbientLight(); + this.showFeedback('text', 'Ánh sáng: Tắt'); + } + } + + startAmbientLight() { + const canvas = this.container.querySelector('#txa-ambient'); + if (!canvas) return; + + const ctx = canvas.getContext('2d'); + canvas.width = 32; // Low resolution for blur effect + canvas.height = 18; + + this._ambientFrame = () => { + if (!this.isCinemaMode || this.destroyed) return; + if (this.video && !this.video.paused && this.video.readyState >= 2) { + try { + ctx.drawImage(this.video, 0, 0, canvas.width, canvas.height); + } catch (e) { + // Cross-origin video might fail, just ignore + } + } + requestAnimationFrame(this._ambientFrame); + }; + requestAnimationFrame(this._ambientFrame); + } + + stopAmbientLight() { + this._ambientFrame = null; + } + + /** + * Speed Preview - Long press to fast forward at 2x speed + */ + startSpeedPreview() { + if (this.isSpeedPreview) return; + this.isSpeedPreview = true; + this.originalSpeed = this.video.playbackRate; + this.video.playbackRate = 2; + + const indicator = this.container.querySelector('#txa-speed-indicator'); + if (indicator) indicator.classList.add('show'); + if (this.wrapper) this.wrapper.classList.add('hide-controls'); + + // Play if paused + if (this.video.paused) { + this._wasPausedBeforePreview = true; + this.video.play().catch(() => { }); + } + } + + stopSpeedPreview() { + if (!this.isSpeedPreview) return; + this.isSpeedPreview = false; + this.video.playbackRate = this.originalSpeed || 1; + + const indicator = this.container.querySelector('#txa-speed-indicator'); + if (indicator) indicator.classList.remove('show'); + if (this.wrapper) this.wrapper.classList.remove('hide-controls'); + + // Pause if was paused before + if (this._wasPausedBeforePreview) { + this.video.pause(); + this._wasPausedBeforePreview = false; + } + } + + /** + * Watch Progress Resume - Save and restore watch position + */ + getVideoId() { + // Generate unique ID based on movie ID and episode info for stability + const base = this.options.movieId || this.options.title || 'unknown'; + const ep = this.options.episodeSlug || this.options.episodeName || 'single'; + return 'txa-progress-' + this.hashCode(base + '-' + ep); + } + + hashCode(str) { + let hash = 0; + for (let i = 0; i < str.length; i++) { + const char = str.charCodeAt(i); + hash = ((hash << 5) - hash) + char; + hash = hash & hash; + } + return Math.abs(hash).toString(36); + } + + saveWatchProgress(useApi = false) { + if (!this.video || this.video.duration < 10) return; + + const ct = this.video.currentTime; + const dur = this.video.duration; + const opt = this.options; + + // 1. App LocalStorage Sync (ContinueWatching) + if (window.ContinueWatching && opt.movieSlug) { + window.ContinueWatching.save( + opt.movieSlug, + opt.title.split(' - ')[0], // Assume Title is "Movie - Episode" + opt.movieThumb, + opt.episodeSlug, + opt.title.split(' - ')[1]?.replace('Tập ', '') || '1', + ct, + dur, + opt.epCount || 1 + ); + } + + // 2. App API Sync (Database) + if (useApi && opt.saveUrl && opt.movieId && opt.csrfToken) { + fetch(opt.saveUrl, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'X-CSRF-TOKEN': opt.csrfToken + }, + body: JSON.stringify({ + movie_id: opt.movieId, + episode_id: opt.episodeId, + current_time: ct, + duration: dur + }) + }).catch(e => console.warn('Player: Progress sync failed', e)); + } + + // 3. Player Internal Backup (Fallback) + if (ct > 10 && ct < dur - 30) { + localStorage.setItem(this.getVideoId(), JSON.stringify({ + time: ct, + duration: dur, + timestamp: Date.now() + })); + } + } + + async checkWatchResume() { + if (this.resumeShown) return; + const opt = this.options; + let resumeTime = 0; + let duration = 0; + + // Try API first (Best source of truth) + if (opt.restoreUrl && opt.movieId) { + try { + const res = await fetch(opt.restoreUrl); + const data = await res.json(); + + if (data && data.current_time > 10) { + // Check if same episode (ID or Name/Slug match for multi-server) + // Relaxed Match: If restoreUrl is specific, we trust the data + const epIdMatch = (data.episode_id == opt.episodeId); + + // Normalize "Tập 01" -> "1", "01" -> "1" + const norm = (s) => (s || '').toString().toLowerCase().replace('tập ', '').replace(/^0+/, '').trim(); + + const epNameMatch = norm(data.episode_name) === norm(opt.episodeName); + // Slug match is usually safer but relies on consistent slugs + const slugMatch = (data.episode_slug && opt.episodeSlug && data.episode_slug === opt.episodeSlug); + + if (epIdMatch || epNameMatch || slugMatch || opt.restoreUrl.includes(opt.episodeId)) { + resumeTime = data.current_time; + duration = data.duration || 0; + } + } + } catch (e) { console.warn('Player: Restore API failed', e); } + } + + // Fallback to Player's internal LocalStorage + if (!resumeTime) { + const saved = localStorage.getItem(this.getVideoId()); + if (saved) { + try { + const data = JSON.parse(saved); + // Check if valid timestamp (within 30 days) + if (Date.now() - data.timestamp < 30 * 24 * 60 * 60 * 1000) { + resumeTime = data.time; + duration = data.duration; + } + } catch (e) { } + } + } + + if (resumeTime > 15) { + this.resumeShown = true; + const timeStr = this.formatTime(resumeTime, duration >= 3600); + + // MOBILE: Use SweetAlert2 (Premium & Out-of-player) + // Ensure Swal is available, otherwise fallback to standard overlay + if (this.detectMobile() && typeof Swal !== 'undefined') { + Swal.fire({ + title: 'Tiếp tục xem?', + text: `Hệ thống ghi nhận bạn đã xem đến ${timeStr}. Bạn có muốn tiếp tục từ đây không ? `, + icon: 'question', + showCancelButton: true, + confirmButtonText: 'Có, tiếp tục', + cancelButtonText: 'Xem từ đầu', + background: '#141414', + color: '#fff', + confirmButtonColor: '#8b5cf6', + cancelButtonColor: '#334155', + heightAuto: false, + backdrop: `rgba(0, 0, 0, 0.6)`, + allowOutsideClick: false // Prevent accidental close + }).then((result) => { + if (result.isConfirmed) { + this.safeSeek(resumeTime); + this.video.play().catch(() => { }); + this.showFeedback('text', `Đã tiếp tục từ ${timeStr} `); + } else if (result.dismiss === Swal.DismissReason.cancel) { + localStorage.removeItem(this.getVideoId()); + // Don't auto play if cancelled, let user decide + } + }); + return; + } + + // DESKTOP or Mobile-Fallback: Classic Overlay + const overlay = this.container.querySelector('#txa-resume'); + const timeEl = this.container.querySelector('#txa-resume-time'); + + if (overlay && timeEl) { + timeEl.textContent = timeStr; + + // Ensure overlay is visible + overlay.style.display = 'flex'; + // Trigger animation + requestAnimationFrame(() => { + overlay.classList.add('show'); + }); + + // Auto-hide after 30s if no interaction (increased from 15s) + const autoHideTimer = setTimeout(() => { + if (overlay.classList.contains('show')) { + overlay.classList.remove('show'); + setTimeout(() => overlay.style.display = 'none', 500); + } + }, 30000); + + const handleYes = (e) => { + if (e) e.stopPropagation(); + clearTimeout(autoHideTimer); + this.safeSeek(resumeTime); + overlay.classList.remove('show'); + setTimeout(() => overlay.style.display = 'none', 500); + this.video.play().catch(() => { }); + this.showFeedback('text', `Đã tiếp tục từ ${timeStr} `); + }; + + const handleNo = (e) => { + if (e) e.stopPropagation(); + clearTimeout(autoHideTimer); + overlay.classList.remove('show'); + setTimeout(() => overlay.style.display = 'none', 500); + localStorage.removeItem(this.getVideoId()); + }; + + const yesBtn = overlay.querySelector('#txa-resume-yes'); + const noBtn = overlay.querySelector('#txa-resume-no'); + + if (yesBtn) { + yesBtn.onclick = handleYes; + yesBtn.ontouchstart = (e) => { e.preventDefault(); handleYes(e); }; + } + if (noBtn) { + noBtn.onclick = handleNo; + noBtn.ontouchstart = (e) => { e.preventDefault(); handleNo(e); }; + } + } + } + } + + /** + * Double-tap Ripple Effect - Visual feedback for double-tap seek + */ + createRipple(x, y) { + const ripple = document.createElement('div'); + ripple.className = 'txa-ripple'; + ripple.style.left = (x - 50) + 'px'; + ripple.style.top = (y - 50) + 'px'; + this.wrapper.appendChild(ripple); + + // Remove after animation + setTimeout(() => ripple.remove(), 600); + } + + /** + * Setup new feature event bindings + */ + setupNewFeatures() { + + const el = (s) => this.container.querySelector(s); + + // Theater Mode Button + const theaterBtn = el('#txa-theater'); + if (theaterBtn) { + theaterBtn.onclick = () => this.toggleTheaterMode(); + } + + // Cinema Mode Button + const cinemaBtn = el('#txa-cinema'); + if (cinemaBtn) { + cinemaBtn.onclick = () => this.toggleCinemaMode(); + } + + // Speed Preview - Long press on video + let speedTimeout = null; + const startSpeed = () => { + speedTimeout = setTimeout(() => { + this.startSpeedPreview(); + }, 500); + }; + const endSpeed = () => { + clearTimeout(speedTimeout); + this.stopSpeedPreview(); + }; + + if (this.detectMobile()) { + this.video.addEventListener('mousedown', startSpeed); + this.video.addEventListener('mouseup', endSpeed); + this.video.addEventListener('mouseleave', endSpeed); + } + + // Touch support for Speed Preview + this.video.addEventListener('touchstart', startSpeed, { passive: true }); + this.video.addEventListener('touchend', endSpeed); + this.video.addEventListener('touchcancel', endSpeed); + + // Watch Resume - Check on video ready + this.video.addEventListener('loadedmetadata', () => { + this.checkWatchResume(); + }); + + // Save progress periodically (LocalStorage: 10s, API: 30s) + let lastApiSave = Date.now(); + this._progressSaveInterval = setInterval(() => { + if (!this.destroyed && this.video && !this.video.paused) { + const now = Date.now(); + const useApi = (now - lastApiSave) >= 30000; + this.saveWatchProgress(useApi); + if (useApi) lastApiSave = now; + } + }, 10000); + + // Save on pause and before unload + this.video.addEventListener('pause', () => this.saveWatchProgress(true)); + window.addEventListener('beforeunload', () => this.saveWatchProgress(true)); + + // Ripple effect on double-tap zones + const addRippleToZone = (zone, seekFn) => { + if (!zone) return; + zone.addEventListener('dblclick', (e) => { + const rect = this.wrapper.getBoundingClientRect(); + this.createRipple(e.clientX - rect.left, e.clientY - rect.top); + }); + }; + + addRippleToZone(el('#txa-zone-l')); + addRippleToZone(el('#txa-zone-r')); + + // Escape key to exit Theater Mode + this._handlers.theaterEscape = (e) => { + if (e.key === 'Escape' && this.isTheaterMode) { + this.toggleTheaterMode(); + } + }; + window.addEventListener('keydown', this._handlers.theaterEscape); + + // v6.3.0 - Screen Width Warning (<100px) + const checkWidth = () => { + if (window.innerWidth < 100 && !window._txa_too_small) { + window._txa_too_small = true; + // Hide header/nav via CSS first just in case document.write is blocked or delayed + const header = document.querySelector('.header'); + if (header) header.style.display = 'none'; + + document.open(); + document.write(` + < html > + + TPhimX - Màn hình quá nhỏ + + + +
+ +

MÀN HÌNH QUÁ NHỎ

+

Vui lòng phóng to trình duyệt hoặc xoay ngang điện thoại để có trải nghiệm xem phim tốt nhất tại TPhimX.

+
+ + + diff --git a/src/pages/admin/binh-luan.astro b/src/pages/admin/binh-luan.astro new file mode 100644 index 0000000000000000000000000000000000000000..a97b74283004109f65b064b58a200a25323de5fb --- /dev/null +++ b/src/pages/admin/binh-luan.astro @@ -0,0 +1,663 @@ +--- +import AdminLayout from '../../layouts/AdminLayout.astro'; +import { txasupabase } from '../../lib/txasupabase.js'; + +// Kiểm tra quyền truy cập Admin trước khi render +const token = Astro.cookies.get('auth_token')?.value; +let user = null; +if (token) { + try { + user = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + } catch (e) {} +} + +if (!user || user.role !== 'admin') { + return Astro.redirect('/dang-nhap'); +} + +// Lấy danh sách bình luận ban đầu từ API +const bannedUsers = await txasupabase.getSetting('banned_commenters') || []; + +// Để tối ưu hóa tốc độ, chúng ta load danh sách thông qua Client-side fetch trong script, +// Nhưng chúng ta vẫn truyền danh sách bannedUsers từ Server-side. +--- + + +
+
+

Quản lý Bình luận

+

Giám sát, kiểm duyệt nội dung phản hồi, gắn thẻ spoil và cấm tài khoản vi phạm chính sách chỉ với 1-click.

+
+ + +
+
+ Người dùng bị cấm +
{bannedUsers.length}
+
+
+
+ +
+ +
+ +
+ + +
+ + +
+ + + +
+
+ + +
+ + + + + + + + + + + + + + + + +
+ + Thành viênPhim / TậpNội dung bình luậnThời gianThao tác
+ +

Đang nạp toàn bộ bình luận của hệ thống...

+
+
+
+ + +
+
+ + Đã chọn: 0 +
+
+ + + +
+ +
+
+ + + + diff --git a/src/pages/admin/cai-dat.astro b/src/pages/admin/cai-dat.astro new file mode 100644 index 0000000000000000000000000000000000000000..df747618b07b4283318e772c27364eba31a0e65f --- /dev/null +++ b/src/pages/admin/cai-dat.astro @@ -0,0 +1,671 @@ +--- +import AdminLayout from '../../layouts/AdminLayout.astro'; +import { txasupabase } from '../../lib/txasupabase.js'; + +const settings = await txasupabase.getSettings(); +--- + + +
+

Cấu hình Hệ thống

+

Thiết lập toàn bộ tham số hoạt động của website, máy chủ SMTP email và cơ chế xác thực người dùng.

+
+ +
+ +
+ + + + +
+ + +
+ +
+
+
+ + +

Hiển thị ở hậu tố tiêu đề các trang (Ví dụ: Trang chủ | TPHIMX).

+
+
+ + +

Đường dẫn đầy đủ dùng để sinh link xác minh tài khoản, khôi phục mật khẩu.

+
+
+
+ + +
+
+ + +

Các từ khóa cách nhau bởi dấu phẩy, giúp các công cụ tìm kiếm dễ dàng tìm thấy website.

+
+
+ + + + + + + + + + + +
+ +
+
+
+
+ + + + diff --git a/src/pages/admin/crawl-nang-cao.astro b/src/pages/admin/crawl-nang-cao.astro new file mode 100644 index 0000000000000000000000000000000000000000..3794a7527cc59b8d6c781ccfc5e40c16ec418593 --- /dev/null +++ b/src/pages/admin/crawl-nang-cao.astro @@ -0,0 +1,1104 @@ +--- +import AdminLayout from '../../layouts/AdminLayout.astro'; +--- + + + +
+
+ +
+
+

Trang cào nâng cao dành riêng cho Desktop

+

+ Giao diện cào phim nâng cao với trình soạn thảo JSON thời gian thực, bảng so khớp dữ liệu song song và chế độ cấu hình chi tiết được thiết kế và tối ưu tốt nhất trên thiết bị màn hình lớn. Vui lòng chuyển sang **máy tính để bàn (Desktop)** để có trải nghiệm điều khiển tối ưu nhất. +

+
+
+ +
+

Tìm kiếm & Cào phim Trực tuyến

+

Tìm kiếm phim online từ API KKPhim, đối chiếu trạng thái database và tùy chọn cào từng tập phim tùy ý.

+
+ +
+ +
+ +
+
+
+ +
+
+

Tìm kiếm phim online

+

Tìm kiếm từ kho dữ liệu trực tuyến của KKPhim

+
+
+ +
+
+ +
+ +
+
+ + +
+
+ Kết quả tìm kiếm + Sẵn sàng tìm kiếm... +
+ +
+ + + + + + + + + + + + + + + +
+ + PhimTập phim / NămCó trên Web?Hành động
Nhập từ khóa phía trên để tìm kiếm phim trực tuyến
+
+ + + +
+
+ + +
+ +
+
+

Tiến trình cào

+ Đang chờ lệnh +
+ + +
+
+ Chưa có tiến trình nào chạy... + 0% +
+
+
+
+
+ + +
+
+ Thành công + 0 +
+
+ Bỏ qua + 0 +
+
+ Thất bại + 0 +
+
+
+ + +
+
+ Trạng thái chi tiết + Chờ chạy... +
+ +
+ + + + + + + + + + + + + +
STTTên phimKết quả
Chưa bắt đầu tiến trình cào dữ liệu
+
+
+ + +
+
+ Nhật ký hoạt động + +
+ +
+
// Hệ thống sẵn sàng. Chọn phim và bấm cào để bắt đầu...
+
+
+
+
+ + + +
+ + diff --git a/src/pages/admin/crawl.astro b/src/pages/admin/crawl.astro new file mode 100644 index 0000000000000000000000000000000000000000..473b42d03f47f1ed9f10ef11eb6bdcef6d564d68 --- /dev/null +++ b/src/pages/admin/crawl.astro @@ -0,0 +1,1925 @@ +--- +import AdminLayout from '../../layouts/AdminLayout.astro'; +--- + + +
+

Hệ thống Thu thập phim (Crawler)

+

Thu thập phim tự động từ nguồn dữ liệu KKPhim trực tiếp vào cơ sở dữ liệu tệp tin cục bộ.

+
+ +
+ +
+ +
+
+ + + +
+ + +
+
+ +

Mỗi dòng là một link phim KKPhim hoặc slug phim. Ví dụ:
https://kkphim.vip/phim/dau-pha-thuong-khung hoặc tay-du-ky

+ +
+ + +
+ Trạng thái phân tích: +
+ 0 Hợp lệ + 0 Không hợp lệ +
+
+ + +
+ + + + + + +
+ + +
+
+
+ +
+
+

Cào theo quốc gia

+

Crawl phim từ KKPhim theo từng quốc gia cụ thể

+
+
+ +
+
+ + +
+ +
+
+ + +
+
+ + +
+
+ +

Hệ thống sẽ tải toàn bộ danh sách phim của quốc gia này trên các trang được chọn trước khi cào chi tiết.

+ + +
+
+ + +
+
+
+ +
+
+

Cào theo thể loại

+

Crawl phim từ KKPhim theo từng thể loại cụ thể

+
+
+ +
+
+ + +
+ +
+
+ + +
+
+ + +
+
+ +

Hệ thống sẽ tải toàn bộ danh sách phim của thể loại này trên các trang được chọn trước khi cào chi tiết.

+ + +
+
+
+ + +
+ +
+
+

Trạng thái tiến trình

+ Đang chờ lệnh +
+ + +
+
+ Chưa có phim nào đang xử lý... + 0% +
+
+
+
+
+ + + + + + + + +
+
+ Thành công + 0 +
+
+ Bỏ qua + 0 +
+
+ Thất bại + 0 +
+
+
+ + +
+
+ Bảng tiến trình chi tiết + Chờ chạy... +
+ + + + +
+ + + + + + + + + + + + + + + +
+ + STTTên phimKết quảChi tiết
Chưa bắt đầu tiến trình cào dữ liệu
+
+
+ + +
+
+ Nhật ký hoạt động chi tiết + +
+ + +
+
// Hệ thống đã sẵn sàng. Hãy cấu hình và nhấn Bắt đầu thu thập...
+
+
+
+
+
+ + + + diff --git a/src/pages/admin/dien-vien.astro b/src/pages/admin/dien-vien.astro new file mode 100644 index 0000000000000000000000000000000000000000..cb88fcfa7ec4aecf7cd725a2107e3794a8f31101 --- /dev/null +++ b/src/pages/admin/dien-vien.astro @@ -0,0 +1,360 @@ +--- +import AdminLayout from '../../layouts/AdminLayout.astro'; +import { getActors } from '../../lib/localDb.js'; + +const actors = await getActors(); +--- + + +
+
+

Quản lý Diễn viên

+

Danh sách diễn viên tham gia diễn xuất trong các bộ phim của hệ thống.

+
+
+ + +
+
+ + + + +
+ +
+
+ + +
+
+ +
+ + + + + + + + + + + +
+ + Tên Diễn viênThao tác
+
+
+
+ + + + diff --git a/src/pages/admin/duyet-zalo.astro b/src/pages/admin/duyet-zalo.astro new file mode 100644 index 0000000000000000000000000000000000000000..447320a2995422a05806e58b6603dbbac201fb74 --- /dev/null +++ b/src/pages/admin/duyet-zalo.astro @@ -0,0 +1,762 @@ +--- +import AdminLayout from '../../layouts/AdminLayout.astro'; +import { txasupabase } from '../../lib/txasupabase.js'; + +// Kiểm tra quyền truy cập Admin trước khi render +const token = Astro.cookies.get('auth_token')?.value; +let user = null; +if (token) { + try { + user = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + } catch (e) {} +} + +if (!user || user.role !== 'admin') { + return Astro.redirect('/dang-nhap'); +} + +// Lấy toàn bộ danh sách đăng ký Zalo từ Supabase +const requests = await txasupabase.getZaloAccessRequests(); + +// Thống kê nhanh ban đầu +const total = requests.length; +const pending = requests.filter(r => r.status === 'pending').length; +const approved = requests.filter(r => r.status === 'approved').length; +const rejected = requests.filter(r => r.status === 'rejected').length; +--- + + +
+
+

Quản lý Người Dùng & Duyệt Quyền

+

Quản lý danh sách thành viên, phê duyệt quyền truy cập Zalo của hệ thống TPHIMX.

+
+
+ + +
+
+
+ Tổng yêu cầu + {total} +
+
+
+ Đang chờ duyệt + {pending} +
+
+
+ Đã phê duyệt + {approved} +
+
+
+ Đã từ chối + {rejected} +
+
+ + +
+ +
+ +
+
+

+ Công cụ giải mã Token (TxaCipher) +

+

Nhập mã trình duyệt token tk_... để giải ngược thông tin thiết bị, địa chỉ IP và vị trí nguồn.

+
+ +
+
+ +
+ +
+
+ + + +
+ + +
+
+ Danh sách yêu cầu truy cập + + +
+
+ + +
+ + +
+
+ + +
+ + + + + + + + + + + + + + +
+ + Nick ZaloMã Trình Duyệt (Token)Ngày yêu cầuTrạng tháiHành động
+
+ + + +
+ + +
+
+ + Đã chọn: 0 +
+
+ + + +
+ +
+
+ + + + diff --git a/src/pages/admin/email.astro b/src/pages/admin/email.astro new file mode 100644 index 0000000000000000000000000000000000000000..a6da23a611185a99980470c1e59fc0a32ee83a44 --- /dev/null +++ b/src/pages/admin/email.astro @@ -0,0 +1,441 @@ +--- +import AdminLayout from '../../layouts/AdminLayout.astro'; +import { txasupabase } from '../../lib/txasupabase.js'; + +const logs = await txasupabase.getEmailLogs(); +--- + + +
+

Nhật ký Email

+

Giám sát và kiểm tra toàn bộ hòm thư gửi đi, trạng thái SMTP và xem trước nội dung email của hệ thống.

+
+ + +
+ +
+
+ Lịch sử thư gửi + Tổng: {logs.length} +
+ + +
+ + +
+ + +
+ +
+
+ + + +
+ + + +
+ + + + diff --git a/src/pages/admin/index.astro b/src/pages/admin/index.astro new file mode 100644 index 0000000000000000000000000000000000000000..d5c2f4459a9b4ddf8ba9b5b00ca9b2a6774e9ed7 --- /dev/null +++ b/src/pages/admin/index.astro @@ -0,0 +1,204 @@ +--- +import AdminLayout from '../../layouts/AdminLayout.astro'; +import { txasupabase } from '../../lib/txasupabase.js'; + +// Fetch real statistics from Supabase +const localMovies = await txasupabase.getLocalMovies(); +const totalMovies = Object.keys(localMovies).length; + +const users = await txasupabase.getUsers(); +const totalUsers = users.length; + +// Fetch real count for comments +const { count: commentsCount } = await txasupabase.supabase + .from('comments') + .select('*', { count: 'exact', head: true }); + +// Fetch real count for email logs (báo lỗi/gửi mail) +const { count: emailLogsCount } = await txasupabase.supabase + .from('email_logs') + .select('*', { count: 'exact', head: true }); + +const stats = [ + { label: 'Tổng số phim (Cục bộ)', value: String(totalMovies), icon: 'fas fa-film', color: 'text-blue-500' }, + { label: 'Tổng thành viên', value: String(totalUsers), icon: 'fas fa-user-plus', color: 'text-green-500' }, + { label: 'Tổng bình luận', value: String(commentsCount || 0), icon: 'fas fa-comments', color: 'text-purple-500' }, + { label: 'Lịch sử gửi Email', value: String(emailLogsCount || 0), icon: 'fas fa-envelope-open-text', color: 'text-red-500' }, +]; + +// Phim mới cập nhật từ Database cục bộ +const newestMovies = Object.values(localMovies) + .sort((a: any, b: any) => { + const timeA = new Date(a.movie.modified?.time || a.movie.created?.time || 0).getTime(); + const timeB = new Date(b.movie.modified?.time || b.movie.created?.time || 0).getTime(); + return timeB - timeA; + }) + .slice(0, 5); + +const formatImageUrl = (url: string) => { + if (!url) return '/placeholder-poster.jpg'; + if (url.startsWith('http')) return url; + const cleanUrl = url.startsWith('/') ? url : `/${url}`; + return `https://phimimg.com${cleanUrl}`; +}; +--- + + +
+
+

Bảng điều khiển

+

Chào mừng bạn trở lại, hệ thống đang hoạt động ổn định.

+
+
+ + +
+
+ +
+ {stats.map(stat => ( +
+
+
+ +
+
+

{stat.label}

+

{stat.value}

+
+
+ +
+
+ ))} +
+ +
+
+
+

Phim mới cập nhật

+ Xem tất cả +
+
+ + + + + + + + + + + {newestMovies.length > 0 ? newestMovies.map((m: any) => { + const movie = m.movie; + const poster = formatImageUrl(movie.poster_url || movie.thumb_url); + const genres = movie.category ? movie.category.map((c: any) => c.name).join(', ') : 'Chưa phân loại'; + const modifiedTime = movie.modified?.time || movie.created?.time || new Date().toISOString(); + const views = movie.view || 0; + return ( + + + + + + + ); + }) : ( + + + + )} + +
PhimNgày cập nhậtLượt xemHành động
+
+
+ {movie.name} +
+
+ {movie.name} + {genres} +
+
+
+
+ + + + +
+
Chưa có phim nào trong cơ sở dữ liệu cục bộ.
+
+
+ +
+

Báo cáo gần đây

+
+ {[1,2,3,4].map(i => ( +
+
+ +
+
+ Lỗi không xem được tập {i} + Phim: Trục Ngọc +
+
+ ))} +
+
+
+
+ + + + diff --git a/src/pages/admin/nguoi-dung.astro b/src/pages/admin/nguoi-dung.astro new file mode 100644 index 0000000000000000000000000000000000000000..a19bb78d89e78d800b2a674f369f1fb27a11b3ed --- /dev/null +++ b/src/pages/admin/nguoi-dung.astro @@ -0,0 +1,943 @@ +--- +import AdminLayout from '../../layouts/AdminLayout.astro'; +import { txasupabase } from '../../lib/txasupabase.js'; + +// 1. Bảo mật: Kiểm tra quyền truy cập Admin trước khi render trang +const token = Astro.cookies.get('auth_token')?.value; +let currentUser = null; +if (token) { + try { + currentUser = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + } catch (e) {} +} + +if (!currentUser || currentUser.role !== 'admin') { + return Astro.redirect('/dang-nhap'); +} + +// 2. Lấy danh sách người dùng từ database Supabase +const usersList = await txasupabase.getUsers(); + +// Thống kê nhanh ban đầu +const total = usersList.length; +const admins = usersList.filter(u => u.role === 'admin').length; +const normals = usersList.filter(u => u.role === 'user').length; +const newLast7Days = usersList.filter(u => { + if (!u.created_at) return false; + const d = new Date(u.created_at); + const diffTime = Math.abs(Date.now() - d.getTime()); + const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)); + return diffDays <= 7; +}).length; +--- + + +
+
+

Quản lý Thành Viên

+

Quản lý tài khoản đăng ký, phân quyền quản trị và định vị thành viên trên hệ thống TPHIMX.

+
+
+ +
+
+ + +
+
+
+ Tổng thành viên + {total} +
+
+
+ Quản trị viên + {admins} +
+
+
+ Thành viên thường + {normals} +
+
+
+ Mới (7 ngày) + {newLast7Days} +
+
+ + +
+
+ Danh sách tài khoản người dùng + + +
+
+ + +
+ + +
+
+ + +
+ + + + + + + + + + + + + + + +
+ + Tài khoảnEmailThành Phố / Xã PhườngNgày tham giaVai tròHành động
+
+ + + +
+ + +
+
+ + Đã chọn: 0 +
+
+ + + +
+ +
+
+ + + + diff --git a/src/pages/admin/phim/chinh-sua.astro b/src/pages/admin/phim/chinh-sua.astro new file mode 100644 index 0000000000000000000000000000000000000000..01af9eb7a3e398deaafabc8200e3c844241ee357 --- /dev/null +++ b/src/pages/admin/phim/chinh-sua.astro @@ -0,0 +1,2109 @@ +--- +import AdminLayout from '../../../layouts/AdminLayout.astro'; +import { getMovieDetail, formatImageUrl } from '../../../lib/api.js'; +import { getLocalMovies, getServers } from '../../../lib/localDb.js'; + +const slug = Astro.url.searchParams.get('slug') || ''; +if (!slug) { + return Astro.redirect('/admin/phim/them-moi'); +} +const localMovies = await getLocalMovies(); +const servers = await getServers(); + +let movieData = null; + +if (slug) { + // 1. Kiểm tra database nội bộ trước + if (localMovies[slug]) { + movieData = localMovies[slug]; + } else { + // 2. Lấy dữ liệu từ API phimapi + try { + const apiDetail = await getMovieDetail(slug); + if (apiDetail && apiDetail.movie) { + movieData = { + movie: apiDetail.movie, + episodes: apiDetail.episodes || [] + }; + } + } catch (e) { + console.error('Error fetching movie details for admin edit:', e); + } + } +} + +// 3. Khởi tạo dữ liệu rỗng cho phim mới hoàn toàn +if (!movieData) { + movieData = { + movie: { + name: '', + origin_name: '', + slug: '', + type: 'series', + status: 'ongoing', + year: new Date().getFullYear(), + quality: 'FHD', + lang: 'Vietsub', + poster_url: '', + thumb_url: '', + category: '', + country: '', + director: '', + actor: '', + content: '', + isLocal: true + }, + episodes: [] + }; +} + +const isEditMode = !!slug; +const isApiMovie = isEditMode && !movieData.movie.isLocal; + +const categoryValue = Array.isArray(movieData.movie.category) + ? movieData.movie.category.map((c: any) => typeof c === 'string' ? c : (c.name || '')).filter(Boolean).join(', ') + : (movieData.movie.category || ''); + +const countryValue = Array.isArray(movieData.movie.country) + ? movieData.movie.country.map((c: any) => typeof c === 'string' ? c : (c.name || '')).filter(Boolean).join(', ') + : (movieData.movie.country || ''); + +const directorValue = Array.isArray(movieData.movie.director) + ? movieData.movie.director.join(', ') + : (movieData.movie.director || ''); + +const actorValue = Array.isArray(movieData.movie.actor) + ? movieData.movie.actor.join(', ') + : (movieData.movie.actor || ''); +--- + + +
+
+
+ Quản lý phim + + {isEditMode ? 'Chỉnh sửa phim' : 'Thêm phim mới'} +
+

+ {isEditMode ? `Sửa phim: ${movieData.movie.name}` : 'Thêm phim mới'} +

+
+
+ +
+
+ +
+ +
+ + {isApiMovie ? ( +
+
+
+

+ Bảng điều khiển API & Đồng bộ +

+

Phim này được liên kết từ hệ thống phim gốc KKPhim/OPhim. Sử dụng các chức năng dưới đây để đồng bộ nhanh dữ liệu hoặc khôi phục dữ liệu gốc.

+ +
+ + +
+
+
+ ) : ( +
+
+
+

+ Nhập nhanh dữ liệu phim +

+

Dán đường dẫn chi tiết phim từ KKPhim/OPhim hoặc link Youtube để hệ thống tự động tải và điền toàn bộ thông tin phim + danh sách tập phim.

+ +
+
+ + +
+ +
+
+
+ )} + + +
+

Thông tin cơ bản

+ +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+
+ + +
+
+ + +
+
+
+ +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ +
+
+ + + + +
+
+ + + + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ +
+ + +
+
+ + +
+
+

Danh sách Server & Tập phim

+
+ {isEditMode && ( + + + )} +
+
+ + +
+ +
+
+
+ + +
+ +
+

Phân loại chất lượng

+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+ + +
+

+ Lịch chiếu tập tiếp +

+ + + + +

Đặt ngày giờ phát sóng tập tiếp theo. Thông tin này sẽ hiển thị banner thông báo trên trang chi tiết và xem phim.

+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + + + + +
+ + +
+

+ Máy đổi giây nhanh +

+

Nhập giờ, phút, giây để tính nhanh tổng số giây.

+ +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ Kết quả + 0 giây +
+ + +
+
+
+ + +
+
+
+

+ + Cấu hình Tập phim +

+ +
+ +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + +
+

Cấu hình bỏ qua đoạn phim (giây)

+ +
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+
+
+
+ +
+
+ + + +
+ + + + + + + diff --git a/src/pages/admin/phim/index.astro b/src/pages/admin/phim/index.astro new file mode 100644 index 0000000000000000000000000000000000000000..086c8736982c4810183088ccdbb860feab84a3d8 --- /dev/null +++ b/src/pages/admin/phim/index.astro @@ -0,0 +1,683 @@ +--- +import AdminLayout from '../../../layouts/AdminLayout.astro'; +import { getNewestMovies, searchMovies, formatImageUrl } from '../../../lib/api.js'; +import { getLocalMovies, getDeletedMovies } from '../../../lib/localDb.js'; + +// Kiểm tra phiên đăng nhập và quyền Admin được thực hiện tự động trong AdminLayout + +const page = parseInt(Astro.url.searchParams.get('page') || '1'); +const keyword = Astro.url.searchParams.get('keyword') || ''; +const tab = Astro.url.searchParams.get('tab') || 'all'; // all, local, deleted + +// Đọc database cục bộ +const localMovies = await getLocalMovies(); +const deletedSlugs = await getDeletedMovies(); + +let items = []; +let pagination = { currentPage: page, totalPages: 1, totalItems: 0 }; + +if (tab === 'local') { + // Chỉ lấy phim tự tạo hoặc đã chỉnh sửa lưu trong movies.json + const allLocal = Object.values(localMovies); + items = allLocal.map(m => ({ + _id: m.movie.id || m.movie.slug, + name: m.movie.name, + slug: m.movie.slug, + origin_name: m.movie.origin_name, + thumb_url: m.movie.thumb_url, + poster_url: m.movie.poster_url, + year: m.movie.year, + quality: m.movie.quality || 'FHD', + lang: m.movie.lang || 'Vietsub', + episode_current: m.movie.episode_current || 'Tập 1', + isLocal: m.movie.isLocal, + hasLocalEdits: !m.movie.isLocal + })); + + // Lọc tìm kiếm trên tập local + if (keyword) { + const k = keyword.toLowerCase(); + items = items.filter(item => + item.name?.toLowerCase().includes(k) || + item.origin_name?.toLowerCase().includes(k) || + item.slug?.includes(k) + ); + } + + pagination = { + currentPage: 1, + totalPages: 1, + totalItems: items.length + }; +} else if (tab === 'deleted') { + // Chỉ lấy danh sách các phim đã bị ẩn + items = deletedSlugs.map(slug => { + const local = localMovies[slug]; + return { + _id: slug, + slug, + name: local?.movie?.name || `Phim từ API (${slug})`, + origin_name: local?.movie?.origin_name || 'Đã ẩn', + thumb_url: local?.movie?.thumb_url || '', + year: local?.movie?.year || '', + isDeleted: true + }; + }); + + if (keyword) { + const k = keyword.toLowerCase(); + items = items.filter(item => + item.name?.toLowerCase().includes(k) || + item.slug?.includes(k) + ); + } + + pagination = { + currentPage: 1, + totalPages: 1, + totalItems: items.length + }; +} else { + // Tab 'all': Lấy từ API và trộn dữ liệu cục bộ qua api.js + if (keyword) { + const result = await searchMovies(keyword, page, { grouped: false }); + items = result.items || []; + pagination = result.pagination || pagination; + } else { + const result = await getNewestMovies(page, { grouped: false }); + items = result.items || []; + pagination = result.pagination || pagination; + } +} + +// Thống kê số lượng +const countLocalCustom = Object.values(localMovies).filter(m => m.movie.isLocal).length; +const countLocalEdits = Object.values(localMovies).filter(m => !m.movie.isLocal).length; +const countDeleted = deletedSlugs.length; + +const stats = [ + { label: 'Phim tự tạo', value: countLocalCustom, icon: 'fas fa-plus-circle', color: 'text-emerald-500' }, + { label: 'Phim đã sửa', value: countLocalEdits, icon: 'fas fa-edit', color: 'text-amber-500' }, + { label: 'Phim đã ẩn', value: countDeleted, icon: 'fas fa-eye-slash', color: 'text-red-500' }, +]; +--- + + +
+
+

Quản lý phim

+

Chỉnh sửa, thêm bớt tập phim, ẩn hiện phim và cập nhật nguồn video hàng loạt.

+
+ +
+ + +
+ {stats.map(stat => ( +
+
+
+ +
+
+

{stat.label}

+

{stat.value}

+
+
+
+ ))} +
+ + + + + +
+
+ + + + + + + + + + + + + {items.length === 0 ? ( + + + + ) : ( + items.map(item => { + const isLocal = item.isLocal; + const hasLocalEdits = localMovies[item.slug] && !isLocal; + const isDeleted = item.isDeleted; + const thumb = item.thumb_url ? formatImageUrl(item.thumb_url) : '/no-cover.jpg'; + + const require_login = localMovies[item.slug]?.movie?.require_login === true || localMovies[item.slug]?.movie?.only_login === true; + return ( + + + + + + + + + ); + }) + )} + +
+ + PhimNăm / LoạiTrạng tháiNguồn gốcHành động
+ + Không tìm thấy phim nào phù hợp! +
+ + +
+
+ +
+
+
+ {item.name} + {require_login && ( + + Login + + )} +
+ {item.origin_name} + {item.slug} +
+
+
+
+ {item.year || 'N/A'} + {item.type || 'N/A'} +
+
+
+ {item.episode_current || 'N/A'} +
+
+ {isLocal ? ( + Nội bộ + ) : hasLocalEdits ? ( + Đã sửa + ) : isDeleted ? ( + Đã ẩn + ) : ( + API Gốc + )} + +
+ {!isDeleted && ( + + + + )} + + {isDeleted ? ( + + ) : ( + + )} + + {hasLocalEdits && ( + + )} +
+
+
+ + + {tab === 'all' && pagination.totalPages > 1 && ( +
+ + Trang {pagination.currentPage} / {pagination.totalPages} + +
+ {pagination.currentPage > 1 && ( + Trang trước + )} + + + {[-2, -1, 0, 1, 2].map(offset => { + const pageNum = pagination.currentPage + offset; + if (pageNum > 0 && pagination.totalPages >= pageNum) { + return ( + + {pageNum} + + ); + } + return null; + })} + + {pagination.currentPage < pagination.totalPages && ( + Trang tiếp + )} +
+
+ )} +
+ + +
+
+
0
+ +
+ +
+ {/* Set nhanh trạng thái */} +
+ Trạng thái: + + + +
+ + {/* Ẩn / Hiện */} +
+ + +
+ + {/* Yêu cầu đăng nhập */} +
+ + +
+ + {/* Xóa vĩnh viễn */} + + + {/* Đặt lại gốc (chỉ hiển thị ở tab tương thích) */} + {tab === 'local' && ( + + )} + + + + +
+
+
+ + + + diff --git a/src/pages/admin/phim/them-moi.astro b/src/pages/admin/phim/them-moi.astro new file mode 100644 index 0000000000000000000000000000000000000000..52d348494744b2bcf31c70f8020d130025897e04 --- /dev/null +++ b/src/pages/admin/phim/them-moi.astro @@ -0,0 +1,1558 @@ +--- +import AdminLayout from '../../../layouts/AdminLayout.astro'; +import { getServers, getLocalMovies } from '../../../lib/localDb.js'; + +const localMovies = await getLocalMovies(); +const servers = await getServers(); + +const movieData = { + movie: { + name: '', + origin_name: '', + slug: '', + type: 'series', + status: 'ongoing', + year: new Date().getFullYear(), + quality: 'FHD', + lang: 'Vietsub', + poster_url: '', + thumb_url: '', + category: '', + country: '', + director: '', + actor: '', + content: '', + isLocal: true + }, + episodes: [] +}; + +const isEditMode = false; +const categoryValue = ''; +const countryValue = ''; +const directorValue = ''; +const actorValue = ''; +--- + + +
+
+
+ Quản lý phim + + Thêm phim mới +
+

Thêm phim mới

+
+
+ +
+
+ +
+ +
+ +
+
+
+

+ Nhập nhanh dữ liệu phim +

+

Dán đường dẫn chi tiết phim từ KKPhim/OPhim hoặc link Youtube để hệ thống tự động tải và điền toàn bộ thông tin phim + danh sách tập phim.

+ +
+
+ + +
+ +
+
+
+ + +
+

Thông tin cơ bản

+ +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+
+ + +
+
+ + +
+
+
+ +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ +
+
+ + + + +
+
+ + + + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ +
+ + +
+
+ + +
+
+

Danh sách Server & Tập phim

+
+ +
+
+ + +
+ +
+
+
+ + +
+ +
+

Phân loại chất lượng

+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+ + +
+

+ Lịch chiếu tập tiếp +

+ + + + +

Đặt ngày giờ phát sóng tập tiếp theo. Thông tin này sẽ hiển thị banner thông báo trên trang chi tiết và xem phim.

+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + + + + +
+ + +
+

+ Máy đổi giây nhanh +

+

Nhập giờ, phút, giây để tính nhanh tổng số giây.

+ +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ Kết quả + 0 giây +
+ + +
+
+
+ + +
+
+
+

+ + Cấu hình Tập phim +

+ +
+ +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + +
+

Cấu hình bỏ qua đoạn phim (giây)

+ +
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+
+
+
+ +
+
+ + + +
+ + + + + + + diff --git a/src/pages/admin/quoc-gia.astro b/src/pages/admin/quoc-gia.astro new file mode 100644 index 0000000000000000000000000000000000000000..a77e4d7a8567e44354537d098337f995c10e456d --- /dev/null +++ b/src/pages/admin/quoc-gia.astro @@ -0,0 +1,416 @@ +--- +import AdminLayout from '../../layouts/AdminLayout.astro'; +import { getCountries } from '../../lib/localDb.js'; + +const countries = await getCountries(); +--- + + +
+
+

Quản lý Quốc gia

+

Danh mục quốc gia giúp người xem dễ dàng phân loại phim theo vùng lãnh thổ.

+
+
+ + +
+
+ + + + +
+ +
+
+ + +
+
+ +
+ + + + + + + + + + + + +
+ + Tên Quốc giaSlugThao tác
+
+
+
+ + + + diff --git a/src/pages/admin/server.astro b/src/pages/admin/server.astro new file mode 100644 index 0000000000000000000000000000000000000000..2a6c0191e17bade4c26b48bbb41bbd7c97c20b0a --- /dev/null +++ b/src/pages/admin/server.astro @@ -0,0 +1,374 @@ +--- +import AdminLayout from '../../layouts/AdminLayout.astro'; +import { getServers } from '../../lib/localDb.js'; + +const servers = await getServers(); +--- + + +
+
+

Quản lý Server

+

Xem, tạo mới và đồng bộ hóa các máy chủ phát phim của hệ thống.

+
+
+ + +
+
+ + + + +
+ +
+
+ + +
+
+ +
+ + + + + + + + + + + +
+ + Tên ServerThao tác
+
+
+
+ + + + diff --git a/src/pages/admin/the-loai.astro b/src/pages/admin/the-loai.astro new file mode 100644 index 0000000000000000000000000000000000000000..fd5aa23fd849f200f882d68f8886356bacc4a17c --- /dev/null +++ b/src/pages/admin/the-loai.astro @@ -0,0 +1,417 @@ +--- +import AdminLayout from '../../layouts/AdminLayout.astro'; +import { getGenres } from '../../lib/localDb.js'; + +const genres = await getGenres(); +--- + + +
+
+

Quản lý Thể loại

+

Danh mục thể loại phim dùng để phân loại và lọc tìm kiếm trên hệ thống.

+
+
+ + +
+
+ + + + +
+ +
+
+ + +
+
+ +
+ + + + + + + + + + + + +
+ + Tên Thể loạiSlugThao tác
+
+
+
+ + + + diff --git a/src/pages/api/access/request.js b/src/pages/api/access/request.js new file mode 100644 index 0000000000000000000000000000000000000000..ba7ecca4158fbf2924e87d3468c11760beda77e3 --- /dev/null +++ b/src/pages/api/access/request.js @@ -0,0 +1,86 @@ +import { txasupabase } from '../../../lib/txasupabase.js'; + +export const POST = async ({ request }) => { + try { + const body = await request.json(); + const { browser_token, zalo_nickname } = body; + + if (!browser_token || !zalo_nickname) { + return new Response(JSON.stringify({ error: 'Thiếu thông tin yêu cầu!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + // 1. Tạo hoặc cập nhật request vào database + const accessRequest = await txasupabase.createZaloAccessRequest(browser_token, zalo_nickname); + + // 2. Ghi lại log hoạt động hệ thống + await txasupabase.createLog( + 'zalo_access_request', + 'info', + `Thành viên Zalo "${zalo_nickname}" gửi yêu cầu truy cập từ trình duyệt ${browser_token}`, + { browser_token, zalo_nickname } + ); + + // 3. Gửi email thông báo cho Admin + try { + const settings = await txasupabase.getSettings(); + + // Tìm email Admin nhận thông báo + let adminEmail = settings.admin_email || settings.smtp_user; + if (!adminEmail) { + // Tìm user admin đầu tiên từ DB làm dự phòng + const { data: adminUsers } = await txasupabase.supabase + .from('users') + .select('email') + .eq('role', 'admin') + .limit(1); + if (adminUsers && adminUsers.length > 0) { + adminEmail = adminUsers[0].email; + } + } + + if (adminEmail && settings.smtp_user && settings.smtp_pass) { + const siteUrl = settings.site_url || 'http://localhost:4321'; + const approveUrl = `${siteUrl}/admin/duyet-zalo`; // Trang duyệt chuyên dụng riêng biệt + + await txasupabase.sendMail({ + to: adminEmail, + subject: `[TPHIMX] Yêu cầu duyệt quyền truy cập mới từ Zalo: ${zalo_nickname}`, + templateName: 'zalo_access_request', + placeholders: { + zalo_nickname, + browser_token, + request_time: new Date().toLocaleString('vi-VN'), + approve_url: approveUrl + } + }); + } else { + console.log('[Access Request API]: SMTP not configured or Admin email missing, skipped email notification.'); + } + } catch (mailErr) { + console.error('[Access Request Mail Error]:', mailErr); + await txasupabase.createLog( + 'zalo_access_request_mail_failed', + 'warn', + `Lỗi gửi mail thông báo Zalo access cho "${zalo_nickname}": ${mailErr.message}` + ); + } + + return new Response(JSON.stringify({ + success: true, + message: 'Gửi yêu cầu thành công! Vui lòng chờ Admin duyệt nick Zalo của bạn.', + data: accessRequest + }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } catch (err) { + console.error('Error handling access request API:', err); + return new Response(JSON.stringify({ error: 'Có lỗi xảy ra trên hệ thống!' }), { + status: 500, + headers: { 'Content-Type': 'application/json' } + }); + } +}; diff --git a/src/pages/api/access/status.js b/src/pages/api/access/status.js new file mode 100644 index 0000000000000000000000000000000000000000..5edf51ba3b8be8def416dbc0a98885712028ed35 --- /dev/null +++ b/src/pages/api/access/status.js @@ -0,0 +1,51 @@ +import { txasupabase } from '../../../lib/txasupabase.js'; + +export const GET = async ({ url }) => { + try { + const token = url.searchParams.get('token'); + + if (!token) { + return new Response(JSON.stringify({ error: 'Thiếu mã nhận diện trình duyệt!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + if (token === 'txabypass' || token === 'bypass') { + return new Response(JSON.stringify({ + success: true, + id: 'bypass', + zalo_nickname: 'Bypass Admin', + status: 'approved' + }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } + + const access = await txasupabase.getZaloAccessByToken(token); + + if (!access) { + return new Response(JSON.stringify({ status: 'not_found' }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } + + return new Response(JSON.stringify({ + success: true, + id: access.id, + zalo_nickname: access.zalo_nickname, + status: access.status + }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } catch (err) { + console.error('Error handling access status API:', err); + return new Response(JSON.stringify({ error: 'Có lỗi xảy ra trên hệ thống!' }), { + status: 500, + headers: { 'Content-Type': 'application/json' } + }); + } +}; diff --git a/src/pages/api/admin/actors.js b/src/pages/api/admin/actors.js new file mode 100644 index 0000000000000000000000000000000000000000..9c7355b13cb2c3d73793509d25d86663b0e388aa --- /dev/null +++ b/src/pages/api/admin/actors.js @@ -0,0 +1,59 @@ +import { getActors, saveActor, deleteActor, bulkDeleteActors, syncFromMovies } from '../../../lib/localDb.js'; + +export async function GET({ request }) { + try { + const list = await getActors(); + return new Response(JSON.stringify(list)); + } catch (e) { + return new Response(JSON.stringify({ error: e.message }), { status: 500 }); + } +} + +export async function POST({ request }) { + const cookies = request.headers.get('cookie') || ''; + if (!cookies.includes('auth_token=')) { + return new Response(JSON.stringify({ error: 'Unauthorized' }), { status: 401 }); + } + + try { + const { name, originalName, sync } = await request.json(); + if (sync) { + const list = await syncFromMovies('actors'); + return new Response(JSON.stringify({ message: 'Đồng bộ diễn viên thành công!', list })); + } + + if (!name) { + return new Response(JSON.stringify({ error: 'Tên diễn viên không được để trống' }), { status: 400 }); + } + + const list = await saveActor(name, originalName); + return new Response(JSON.stringify({ message: 'Lưu diễn viên thành công!', list })); + } catch (e) { + return new Response(JSON.stringify({ error: e.message }), { status: 500 }); + } +} + +export async function DELETE({ request }) { + const cookies = request.headers.get('cookie') || ''; + if (!cookies.includes('auth_token=')) { + return new Response(JSON.stringify({ error: 'Unauthorized' }), { status: 401 }); + } + + try { + const { name, names } = await request.json(); + let list; + if (names && Array.isArray(names)) { + list = await bulkDeleteActors(names); + return new Response(JSON.stringify({ message: `Đã xóa hàng loạt ${names.length} diễn viên!`, list })); + } + + if (!name) { + return new Response(JSON.stringify({ error: 'Thiếu tên diễn viên để xóa' }), { status: 400 }); + } + + list = await deleteActor(name); + return new Response(JSON.stringify({ message: 'Xóa diễn viên thành công!', list })); + } catch (e) { + return new Response(JSON.stringify({ error: e.message }), { status: 500 }); + } +} diff --git a/src/pages/api/admin/bao-cao-loi.js b/src/pages/api/admin/bao-cao-loi.js new file mode 100644 index 0000000000000000000000000000000000000000..c9ff00023129e4bbef1299a42d8b46c01dee8fa5 --- /dev/null +++ b/src/pages/api/admin/bao-cao-loi.js @@ -0,0 +1,83 @@ +import { txasupabase } from '../../../lib/txasupabase.js'; + +export const POST = async ({ request, cookies }) => { + try { + // 1. Xác thực quyền Admin + const token = cookies.get('auth_token')?.value; + let user = null; + if (token) { + try { + user = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + } catch(e) {} + } + + if (!user || user.role !== 'admin') { + return new Response(JSON.stringify({ error: 'Bạn không có quyền quản trị!' }), { + status: 403, + headers: { 'Content-Type': 'application/json' } + }); + } + + const body = await request.json(); + const { id, action } = body; + + if (!id || !action) { + return new Response(JSON.stringify({ error: 'Thiếu thông tin ID hoặc hành động!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + if (action === 'resolve') { + // Cập nhật trạng thái báo cáo lỗi thành 'resolved' + const { data, error } = await txasupabase.supabase + .from('reports') + .update({ status: 'resolved' }) + .eq('id', id); + + if (error) throw error; + + await txasupabase.createLog( + 'bug_report_resolved', + 'info', + `Admin "${user.username}" đánh dấu báo cáo lỗi ID ${id} là Đã khắc phục`, + { record_id: id, resolved_by: user.username } + ); + + } else if (action === 'delete') { + // Xóa báo cáo lỗi khỏi cơ sở dữ liệu + const { data, error } = await txasupabase.supabase + .from('reports') + .delete() + .eq('id', id); + + if (error) throw error; + + await txasupabase.createLog( + 'bug_report_deleted', + 'warn', + `Admin "${user.username}" xóa báo cáo lỗi ID ${id}`, + { record_id: id, deleted_by: user.username } + ); + } else { + return new Response(JSON.stringify({ error: 'Hành động không hợp lệ!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + return new Response(JSON.stringify({ + success: true, + message: `Đã ${action === 'resolve' ? 'đánh dấu khắc phục' : 'xóa báo cáo'} thành công!` + }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } catch (err) { + console.error('Error handling admin report status API:', err); + return new Response(JSON.stringify({ error: err.message || 'Có lỗi xảy ra trên hệ thống!' }), { + status: 500, + headers: { 'Content-Type': 'application/json' } + }); + } +}; diff --git a/src/pages/api/admin/countries.js b/src/pages/api/admin/countries.js new file mode 100644 index 0000000000000000000000000000000000000000..975d9e734f498f010604d8fdf3b2a7485f7b1195 --- /dev/null +++ b/src/pages/api/admin/countries.js @@ -0,0 +1,59 @@ +import { getCountries, saveCountry, deleteCountry, bulkDeleteCountries, syncFromMovies } from '../../../lib/localDb.js'; + +export async function GET({ request }) { + try { + const list = await getCountries(); + return new Response(JSON.stringify(list)); + } catch (e) { + return new Response(JSON.stringify({ error: e.message }), { status: 500 }); + } +} + +export async function POST({ request }) { + const cookies = request.headers.get('cookie') || ''; + if (!cookies.includes('auth_token=')) { + return new Response(JSON.stringify({ error: 'Unauthorized' }), { status: 401 }); + } + + try { + const { slug, name, sync } = await request.json(); + if (sync) { + const list = await syncFromMovies('countries'); + return new Response(JSON.stringify({ message: 'Đồng bộ quốc gia thành công!', list })); + } + + if (!slug || !name) { + return new Response(JSON.stringify({ error: 'Slug và Tên quốc gia không được để trống' }), { status: 400 }); + } + + const list = await saveCountry(slug, name); + return new Response(JSON.stringify({ message: 'Lưu quốc gia thành công!', list })); + } catch (e) { + return new Response(JSON.stringify({ error: e.message }), { status: 500 }); + } +} + +export async function DELETE({ request }) { + const cookies = request.headers.get('cookie') || ''; + if (!cookies.includes('auth_token=')) { + return new Response(JSON.stringify({ error: 'Unauthorized' }), { status: 401 }); + } + + try { + const { slug, slugs } = await request.json(); + let list; + if (slugs && Array.isArray(slugs)) { + list = await bulkDeleteCountries(slugs); + return new Response(JSON.stringify({ message: `Đã xóa hàng loạt ${slugs.length} quốc gia!`, list })); + } + + if (!slug) { + return new Response(JSON.stringify({ error: 'Thiếu slug quốc gia để xóa' }), { status: 400 }); + } + + list = await deleteCountry(slug); + return new Response(JSON.stringify({ message: 'Xóa quốc gia thành công!', list })); + } catch (e) { + return new Response(JSON.stringify({ error: e.message }), { status: 500 }); + } +} diff --git a/src/pages/api/admin/crawl-single-episode.js b/src/pages/api/admin/crawl-single-episode.js new file mode 100644 index 0000000000000000000000000000000000000000..aa4f95ca897e23cbde099d815b4edc0bb4174a9f --- /dev/null +++ b/src/pages/api/admin/crawl-single-episode.js @@ -0,0 +1,232 @@ +import { getLocalMovies, saveLocalMovie, syncFromMovies } from '../../../lib/localDb.js'; + +// Cấu hình timeout cho fetch +async function fetchWithTimeout(resource, options = {}) { + const { timeout = 8000 } = options; + const controller = new AbortController(); + const id = setTimeout(() => controller.abort(), timeout); + try { + const response = await fetch(resource, { + ...options, + signal: controller.signal + }); + return response; + } finally { + clearTimeout(id); + } +} + +// Định dạng tên tập phim +function formatEpisodeName(name) { + if (!name) return name; + let str = name.trim(); + if (/^\d+$/.test(str)) { + const num = parseInt(str, 10); + return `Tập ${num.toString().padStart(2, '0')}`; + } + const match = str.match(/^(tập|tap)\s+(\d+)$/i); + if (match) { + const num = parseInt(match[2], 10); + return `Tập ${num.toString().padStart(2, '0')}`; + } + return str; +} + +// Lọc server phát phim +function cleanAndFilterServers(episodes) { + if (!Array.isArray(episodes)) return []; + const tempMap = new Map(); + + for (const srv of episodes) { + if (!srv || !srv.server_name) continue; + let rawName = srv.server_name.trim(); + let cleanName = ''; + + if (/vietsub/i.test(rawName)) { + cleanName = 'Vietsub'; + } else if (/thuyết minh|thuyet minh/i.test(rawName)) { + cleanName = 'Thuyết Minh'; + } else if (/lồng tiếng|long tieng/i.test(rawName)) { + cleanName = 'Lồng Tiếng'; + } else { + cleanName = rawName.replace(/#\s*/g, '').replace(/\([^)]*\)/g, '').trim(); + if (!cleanName) cleanName = 'Vietsub'; + } + + if (cleanName !== 'Vietsub' && cleanName !== 'Thuyết Minh' && cleanName !== 'Lồng Tiếng') { + continue; + } + + if (!tempMap.has(cleanName)) { + srv.server_name = cleanName; + tempMap.set(cleanName, srv); + } + } + + const result = []; + if (tempMap.has('Vietsub')) result.push(tempMap.get('Vietsub')); + if (tempMap.has('Thuyết Minh')) result.push(tempMap.get('Thuyết Minh')); + if (result.length < 2 && tempMap.has('Lồng Tiếng')) { + result.push(tempMap.get('Lồng Tiếng')); + } + if (result.length === 0 && episodes.length > 0) { + const fallbackSrv = episodes[0]; + fallbackSrv.server_name = fallbackSrv.server_name.replace(/#\s*/g, '').replace(/\([^)]*\)/g, '').trim() || 'Vietsub'; + result.push(fallbackSrv); + } + + return result; +} + +// Gộp tập phim +function mergeEpisodes(existingServerList, crawledServerList) { + let addedCount = 0; + const existingList = JSON.parse(JSON.stringify(existingServerList || [])); + + for (const crawledServer of crawledServerList) { + let existingServer = existingList.find(s => s.server_name === crawledServer.server_name); + + if (!existingServer) { + crawledServer.server_data.forEach(ep => { + ep.name = formatEpisodeName(ep.name); + }); + existingList.push(crawledServer); + addedCount += crawledServer.server_data.length; + continue; + } + + existingServer.server_data.forEach(ep => { + ep.name = formatEpisodeName(ep.name); + }); + + const existingMap = new Map(existingServer.server_data.map((e, idx) => [e.name, { ep: e, idx }])); + + for (const crawledEp of crawledServer.server_data) { + crawledEp.name = formatEpisodeName(crawledEp.name); + const matched = existingMap.get(crawledEp.name); + + if (matched) { + existingServer.server_data[matched.idx] = { + ...crawledEp, + introStart: matched.ep.introStart, + introEnd: matched.ep.introEnd, + outroStart: matched.ep.outroStart, + outroEnd: matched.ep.outroEnd + }; + } else { + existingServer.server_data.push(crawledEp); + addedCount++; + } + } + } + + return { merged: existingList, addedCount }; +} + +export async function POST({ request }) { + // Check quyền admin từ cookie auth_token + const cookies = request.headers.get('cookie') || ''; + const hasToken = cookies.includes('auth_token='); + if (!hasToken) { + return new Response(JSON.stringify({ error: 'Unauthorized' }), { status: 401, headers: { 'Content-Type': 'application/json' } }); + } + + try { + const { slug, selectedEpisodes } = await request.json(); + if (!slug) { + return new Response(JSON.stringify({ error: 'Missing slug parameter' }), { status: 400, headers: { 'Content-Type': 'application/json' } }); + } + + const localMovies = await getLocalMovies(); + + const res = await fetchWithTimeout(`https://phimapi.com/phim/${slug}`); + if (!res.ok) { + throw new Error(`Phim không tồn tại trên KKPhim (HTTP ${res.status})`); + } + const data = await res.json(); + if (!data.status || !data.movie) { + throw new Error('Dữ liệu API KKPhim bị rỗng hoặc không đúng định dạng'); + } + + const crawledMovie = data.movie; + const crawledEpisodes = cleanAndFilterServers(data.episodes || []); + + // Lọc tập phim nếu admin chọn cụ thể + if (Array.isArray(selectedEpisodes) && selectedEpisodes.length > 0) { + crawledEpisodes.forEach(server => { + if (server.server_data) { + server.server_data = server.server_data.filter(ep => { + const formattedName = formatEpisodeName(ep.name); + return selectedEpisodes.includes(formattedName); + }); + } + }); + } + + const existing = localMovies[slug]; + let status = 'success'; + let addedCount = 0; + let message = ''; + + if (existing) { + // So sánh gộp tập phim + const { merged, addedCount: added } = mergeEpisodes(existing.episodes, crawledEpisodes); + addedCount = added; + + const hasSelectedEpisodes = Array.isArray(selectedEpisodes) && selectedEpisodes.length > 0; + if (addedCount > 0 || hasSelectedEpisodes) { + existing.movie = { + ...existing.movie, + ...crawledMovie, + episode_current: crawledMovie.episode_current || existing.movie.episode_current, + episode_total: crawledMovie.episode_total || existing.movie.episode_total || null, + modified: { time: new Date().toISOString() } + }; + existing.episodes = merged; + + await saveLocalMovie(slug, existing); + status = 'updated'; + message = hasSelectedEpisodes && addedCount === 0 + ? `Thành công (Cập nhật liên kết ${selectedEpisodes.length} tập)` + : `Thành công (Cập nhật +${addedCount} tập mới)`; + } else { + status = 'skipped'; + message = 'Bỏ qua (Đã đầy đủ tập, không có tập mới)'; + } + } else { + // Phim mới hoàn toàn + crawledEpisodes.forEach(srv => { + if (srv.server_data) { + srv.server_data.forEach(ep => { + ep.name = formatEpisodeName(ep.name); + }); + } + }); + const newMovie = { + movie: crawledMovie, + episodes: crawledEpisodes + }; + await saveLocalMovie(slug, newMovie); + status = 'success'; + message = 'Thành công (Phim mới)'; + } + + // Tự động đồng bộ các danh mục Thể loại, Quốc gia, Diễn viên và Server ngay lập tức! + await syncFromMovies('genres'); + await syncFromMovies('countries'); + await syncFromMovies('actors'); + await syncFromMovies('servers'); + + return new Response(JSON.stringify({ + success: true, + status, + slug, + name: crawledMovie.name, + added: addedCount, + message + }), { headers: { 'Content-Type': 'application/json' } }); + + } catch (err) { + return new Response(JSON.stringify({ success: false, error: err.message }), { status: 500, headers: { 'Content-Type': 'application/json' } }); + } +} diff --git a/src/pages/api/admin/crawl.js b/src/pages/api/admin/crawl.js new file mode 100644 index 0000000000000000000000000000000000000000..92680e5b254a8d3e80d67ee606930cebe368aaca --- /dev/null +++ b/src/pages/api/admin/crawl.js @@ -0,0 +1,655 @@ +import { getLocalMovies, saveLocalMovie, syncFromMovies } from '../../../lib/localDb.js'; + +// Cấu hình timeout cho fetch +async function fetchWithTimeout(resource, options = {}) { + const { timeout = 8000 } = options; + const controller = new AbortController(); + const id = setTimeout(() => controller.abort(), timeout); + try { + const response = await fetch(resource, { + ...options, + signal: controller.signal + }); + return response; + } finally { + clearTimeout(id); + } +} + +// Trích xuất slug từ URL hoặc chuỗi nhập vào +function extractSlug(input) { + if (!input) return null; + const trimmed = input.trim(); + if (!trimmed) return null; + + try { + if (trimmed.startsWith('http://') || trimmed.startsWith('https://')) { + const url = new URL(trimmed); + const pathname = url.pathname; + const parts = pathname.split('/').filter(Boolean); + if (parts.length > 0) { + return parts[parts.length - 1]; + } + } + } catch (e) {} + + const parts = trimmed.split('/').filter(Boolean); + if (parts.length > 0) { + return parts[parts.length - 1]; + } + return trimmed; +} + +// Định dạng tên tập phim thành 2 chữ số (ví dụ: Tập 01, Tập 02, Tập 09 thay vì Tập 1, Tập 2) +function formatEpisodeName(name) { + if (!name) return name; + let str = name.trim(); + // Check if name is pure number, e.g. "1", "2", "03" + if (/^\d+$/.test(str)) { + const num = parseInt(str, 10); + return `Tập ${num.toString().padStart(2, '0')}`; + } + // Check if name starts with "tập" followed by space and numbers, e.g., "Tập 1", "tap 2", "Tập 03" + const match = str.match(/^(tập|tap)\s+(\d+)$/i); + if (match) { + const num = parseInt(match[2], 10); + return `Tập ${num.toString().padStart(2, '0')}`; + } + return str; +} + +// Hàm dọn dẹp và giới hạn máy chủ phát phim (Ví dụ: #Hà Nội (Thuyết Minh 1), #Hà Nội (Vietsub) -> Vietsub & Thuyết Minh) +// Chỉ giữ tối đa 2 server phát phim chính (ưu tiên Vietsub, Thuyết Minh, Lồng Tiếng) để tránh quá tải danh sách server +function cleanAndFilterServers(episodes) { + if (!Array.isArray(episodes)) return []; + + const tempMap = new Map(); + + for (const srv of episodes) { + if (!srv || !srv.server_name) continue; + + let rawName = srv.server_name.trim(); + let cleanName = ''; + + if (/vietsub/i.test(rawName)) { + cleanName = 'Vietsub'; + } else if (/thuyết minh|thuyet minh/i.test(rawName)) { + cleanName = 'Thuyết Minh'; + } else if (/lồng tiếng|long tieng/i.test(rawName)) { + cleanName = 'Lồng Tiếng'; + } else { + cleanName = rawName.replace(/#\s*/g, '').replace(/\([^)]*\)/g, '').trim(); + if (!cleanName) cleanName = 'Vietsub'; + } + + // Chỉ giữ các máy chủ chuẩn + if (cleanName !== 'Vietsub' && cleanName !== 'Thuyết Minh' && cleanName !== 'Lồng Tiếng') { + continue; + } + + // Lưu tập phim của máy chủ đầu tiên xuất hiện cho mỗi loại + if (!tempMap.has(cleanName)) { + srv.server_name = cleanName; + tempMap.set(cleanName, srv); + } + } + + // Dựng lại danh sách máy chủ theo độ ưu tiên: 1. Vietsub, 2. Thuyết Minh + const result = []; + if (tempMap.has('Vietsub')) result.push(tempMap.get('Vietsub')); + if (tempMap.has('Thuyết Minh')) result.push(tempMap.get('Thuyết Minh')); + + // Nếu vẫn chưa đủ 2 server và có Lồng Tiếng, thêm Lồng Tiếng vào + if (result.length < 2 && tempMap.has('Lồng Tiếng')) { + result.push(tempMap.get('Lồng Tiếng')); + } + + // Trường hợp không phát hiện máy chủ chuẩn nào, giữ lại máy chủ gốc đầu tiên nhưng dọn tên + if (result.length === 0 && episodes.length > 0) { + const fallbackSrv = episodes[0]; + fallbackSrv.server_name = fallbackSrv.server_name.replace(/#\s*/g, '').replace(/\([^)]*\)/g, '').trim() || 'Vietsub'; + result.push(fallbackSrv); + } + + return result; +} + +// Hàm gộp tập phim tránh đè cấu hình Intro/Outro của Admin +function mergeEpisodes(existingServerList, crawledServerList) { + let addedCount = 0; + // Nhân bản sâu danh sách tập phim hiện tại để tránh tham chiếu và dễ gộp + const existingList = JSON.parse(JSON.stringify(existingServerList || [])); + + for (const crawledServer of crawledServerList) { + let existingServer = existingList.find(s => s.server_name === crawledServer.server_name); + + if (!existingServer) { + crawledServer.server_data.forEach(ep => { + ep.name = formatEpisodeName(ep.name); + }); + existingList.push(crawledServer); + addedCount += crawledServer.server_data.length; + continue; + } + + // Đồng bộ lại toàn bộ định dạng tên tập hiện tại để so khớp chính xác + existingServer.server_data.forEach(ep => { + ep.name = formatEpisodeName(ep.name); + }); + + // Map nhanh theo tên tập và ghi nhớ vị trí index gốc + const existingMap = new Map(existingServer.server_data.map((e, idx) => [e.name, { ep: e, idx }])); + + for (const crawledEp of crawledServer.server_data) { + crawledEp.name = formatEpisodeName(crawledEp.name); + const matched = existingMap.get(crawledEp.name); + + if (matched) { + // Cập nhật link cào mới nhất, bảo tồn các mốc Intro/Outro admin đã cấu hình thủ công + existingServer.server_data[matched.idx] = { + ...crawledEp, + introStart: matched.ep.introStart, + introEnd: matched.ep.introEnd, + outroStart: matched.ep.outroStart, + outroEnd: matched.ep.outroEnd + }; + } else { + // Thêm tập mới vào server + existingServer.server_data.push(crawledEp); + addedCount++; + } + } + } + + return { merged: existingList, addedCount }; +} + +export async function POST({ request }) { + // Check quyền admin từ cookie auth_token + const cookies = request.headers.get('cookie') || ''; + const hasToken = cookies.includes('auth_token='); + if (!hasToken) { + return new Response(JSON.stringify({ error: 'Unauthorized' }), { status: 401 }); + } + + const { type, urls, pageStart, pageEnd, scanOnly, countrySlug, genreSlug, selectedEpisodes } = await request.json(); + const encoder = new TextEncoder(); + + const stream = new ReadableStream({ + async start(controller) { + const send = (data) => { + try { + controller.enqueue(encoder.encode(`data: ${JSON.stringify(data)}\n\n`)); + } catch (e) { + // Ignore if the controller is already closed + } + }; + + try { + // Bơm mồi (padding) 2KB thông qua payload data hợp lệ để ép Vercel xả (flush) stream ngay lập tức + send({ action: 'connected', padding: 'x'.repeat(2048) }); + + const localMovies = await getLocalMovies(); + let slugsToCrawl = []; + + if (type === 'url') { + // Xử lý crawl theo danh sách URL + const urlList = Array.isArray(urls) ? urls : [urls]; + const results = []; + + for (const rawUrl of urlList) { + const slug = extractSlug(rawUrl); + if (slug) { + try { + // Fetch chi tiết từ API KKPhim để có thông tin chính xác về tên phim và số tập + const res = await fetchWithTimeout(`https://phimapi.com/phim/${slug}`); + if (!res.ok) { + throw new Error(`Phim không tồn tại trên KKPhim (HTTP ${res.status})`); + } + const data = await res.json(); + if (!data.status || !data.movie) { + throw new Error('Dữ liệu API KKPhim không đúng định dạng'); + } + + const crawledMovie = data.movie; + const crawledEpisodes = cleanAndFilterServers(data.episodes || []); + + // Tính số tập hiện có trên KKPhim + let crawledEpCount = 0; + if (crawledEpisodes.length > 0) { + crawledEpCount = Math.max(...crawledEpisodes.map(s => s.server_data?.length || 0)); + } + + const existing = localMovies[slug]; + let expectedNew = crawledEpCount; + let exists = false; + + if (existing) { + exists = true; + const { addedCount } = mergeEpisodes(existing.episodes, crawledEpisodes); + expectedNew = addedCount; + } + + slugsToCrawl.push({ + raw: crawledMovie.name, + slug, + totalEpisodes: crawledEpCount, + expectedNew, + exists + }); + + send({ + action: 'scan_found', + name: crawledMovie.name, + slug: slug, + totalEpisodes: crawledEpCount, + expectedNew, + exists + }); + } catch (e) { + // Fallback nếu fetch lỗi + slugsToCrawl.push({ + raw: slug, + slug, + totalEpisodes: 0, + expectedNew: 0, + exists: false + }); + send({ + action: 'scan_found', + name: slug, + slug: slug, + totalEpisodes: 0, + expectedNew: 0, + exists: false + }); + } + } else { + results.push({ raw: rawUrl, status: 'invalid', message: 'URL không hợp lệ' }); + } + } + + send({ action: 'detect', count: slugsToCrawl.length, invalid: results }); + } else if (type === 'country') { + // Xử lý crawl theo quốc gia + const start = parseInt(pageStart || '1'); + const end = parseInt(pageEnd || '1'); + send({ status: 'info', message: `Đang quét danh sách phim quốc gia: ${countrySlug} từ trang ${start} đến ${end}...` }); + + for (let p = start; p <= end; p++) { + try { + const res = await fetchWithTimeout(`https://phimapi.com/v1/api/quoc-gia/${countrySlug}?page=${p}`); + if (!res.ok) throw new Error(`HTTP ${res.status}`); + const resData = await res.json(); + const items = resData.data?.items || []; + for (const item of items) { + if (item.slug && !slugsToCrawl.some(s => s.slug === item.slug)) { + const existing = localMovies[item.slug]; + let skip = false; + let skipReason = ''; + let expectedNew = 1; + let exists = false; + + if (existing) { + exists = true; + const localStatus = (existing.movie?.episode_current || '').toLowerCase(); + const remoteStatus = (item.episode_current || '').toLowerCase(); + + const isStatusEqual = localStatus === remoteStatus && remoteStatus !== ''; + const isBothCompleted = (localStatus.includes('hoàn tất') || localStatus.includes('full') || localStatus.includes('complete') || localStatus.includes('12/12')) && + (remoteStatus.includes('hoàn tất') || remoteStatus.includes('full') || remoteStatus.includes('complete') || remoteStatus.includes('12/12')); + + if (isStatusEqual || isBothCompleted) { + skip = true; + skipReason = remoteStatus.includes('hoàn tất') ? 'Phim đã hoàn tất' : 'Số tập trùng khớp'; + expectedNew = 0; + } + } + + slugsToCrawl.push({ + raw: item.name, + slug: item.slug, + totalEpisodes: item.episode_total || (item.episode_current ? item.episode_current : '?'), + expectedNew, + exists, + skip, + skipReason + }); + + send({ + action: 'scan_found', + name: item.name, + slug: item.slug, + totalEpisodes: item.episode_total || (item.episode_current ? item.episode_current : '?'), + expectedNew, + exists, + skip, + skipReason + }); + } + } + } catch (e) { + send({ status: 'warning', message: `Không thể lấy danh sách trang ${p}: ${e.message}` }); + } + } + send({ action: 'detect', count: slugsToCrawl.length, invalid: [] }); + } else if (type === 'genre') { + // Xử lý crawl theo thể loại + const start = parseInt(pageStart || '1'); + const end = parseInt(pageEnd || '1'); + send({ status: 'info', message: `Đang quét danh sách phim thể loại: ${genreSlug} từ trang ${start} đến ${end}...` }); + + for (let p = start; p <= end; p++) { + try { + let apiUrl = `https://phimapi.com/v1/api/the-loai/${genreSlug}?page=${p}`; + const listSlugs = ['hoat-hinh', 'phim-chieu-rap', 'phim-le', 'phim-bo', 'tv-shows']; + if (listSlugs.includes(genreSlug)) { + apiUrl = `https://phimapi.com/v1/api/danh-sach/${genreSlug}?page=${p}`; + } + + const res = await fetchWithTimeout(apiUrl); + if (!res.ok) throw new Error(`HTTP ${res.status}`); + const resData = await res.json(); + const items = resData.data?.items || []; + for (const item of items) { + if (item.slug && !slugsToCrawl.some(s => s.slug === item.slug)) { + const existing = localMovies[item.slug]; + let skip = false; + let skipReason = ''; + let expectedNew = 1; + let exists = false; + + if (existing) { + exists = true; + const localStatus = (existing.movie?.episode_current || '').toLowerCase(); + const remoteStatus = (item.episode_current || '').toLowerCase(); + + const isStatusEqual = localStatus === remoteStatus && remoteStatus !== ''; + const isBothCompleted = (localStatus.includes('hoàn tất') || localStatus.includes('full') || localStatus.includes('complete') || localStatus.includes('12/12')) && + (remoteStatus.includes('hoàn tất') || remoteStatus.includes('full') || remoteStatus.includes('complete') || remoteStatus.includes('12/12')); + + if (isStatusEqual || isBothCompleted) { + skip = true; + skipReason = remoteStatus.includes('hoàn tất') ? 'Phim đã hoàn tất' : 'Số tập trùng khớp'; + expectedNew = 0; + } + } + + slugsToCrawl.push({ + raw: item.name, + slug: item.slug, + totalEpisodes: item.episode_total || (item.episode_current ? item.episode_current : '?'), + expectedNew, + exists, + skip, + skipReason + }); + + send({ + action: 'scan_found', + name: item.name, + slug: item.slug, + totalEpisodes: item.episode_total || (item.episode_current ? item.episode_current : '?'), + expectedNew, + exists, + skip, + skipReason + }); + } + } + } catch (e) { + send({ status: 'warning', message: `Không thể lấy danh sách trang ${p}: ${e.message}` }); + } + } + send({ action: 'detect', count: slugsToCrawl.length, invalid: [] }); + } else if (type === 'batch') { + // Xử lý crawl batch theo trang phim mới cập nhật + const start = parseInt(pageStart || '1'); + const end = parseInt(pageEnd || '1'); + send({ status: 'info', message: `Đang quét danh sách phim mới từ trang ${start} đến ${end}...` }); + + for (let p = start; p <= end; p++) { + try { + const res = await fetchWithTimeout(`https://phimapi.com/danh-sach/phim-moi-cap-nhat?page=${p}`); + if (!res.ok) throw new Error(`HTTP ${res.status}`); + const data = await res.json(); + const items = data.items || []; + for (const item of items) { + if (item.slug && !slugsToCrawl.some(s => s.slug === item.slug)) { + slugsToCrawl.push({ raw: item.name, slug: item.slug }); + send({ action: 'scan_found', name: item.name, slug: item.slug }); + } + } + } catch (e) { + send({ status: 'warning', message: `Không thể lấy danh sách trang ${p}: ${e.message}` }); + } + } + send({ action: 'detect', count: slugsToCrawl.length, invalid: [] }); + } else if (type === 'all') { + // Xử lý crawl toàn bộ phim trên API KKPhim + send({ status: 'info', message: 'Đang kết nối API KKPhim để lấy thông tin tổng số trang...' }); + let totalPages = 1; + try { + const firstRes = await fetchWithTimeout(`https://phimapi.com/danh-sach/phim-moi-cap-nhat?page=1`); + if (firstRes.ok) { + const firstData = await firstRes.json(); + if (firstData.pagination && firstData.pagination.totalPages) { + totalPages = firstData.pagination.totalPages; + } + } + } catch (e) { + send({ status: 'warning', message: `Không thể lấy thông tin trang 1: ${e.message}` }); + } + + send({ status: 'info', message: `Phát hiện tổng số ${totalPages} trang danh sách (khoảng ${totalPages * 30} phim). Đang lấy danh sách slugs toàn bộ phim...` }); + + // Tải danh sách song song (concurrency = 20) để cực kỳ nhanh + const pageNumbers = Array.from({ length: totalPages }, (_, i) => i + 1); + const concurrency = 20; + + for (let i = 0; i < pageNumbers.length; i += concurrency) { + const batch = pageNumbers.slice(i, i + concurrency); + await Promise.all( + batch.map(async (p) => { + try { + const res = await fetchWithTimeout(`https://phimapi.com/danh-sach/phim-moi-cap-nhat?page=${p}`); + if (!res.ok) return; + const data = await res.json(); + const items = data.items || []; + for (const item of items) { + if (item.slug && !slugsToCrawl.some(s => s.slug === item.slug)) { + slugsToCrawl.push({ raw: item.name, slug: item.slug }); + send({ action: 'scan_found', name: item.name, slug: item.slug }); + } + } + } catch (e) { + // Lỗi nhỏ bỏ qua để tiếp tục + } + }) + ); + send({ status: 'info', message: `Đang tải danh sách: đã lấy được ${slugsToCrawl.length} phim...` }); + } + + send({ action: 'detect', count: slugsToCrawl.length, invalid: [] }); + } + + if (slugsToCrawl.length === 0) { + send({ action: 'done', message: 'Không có phim nào để crawl!' }); + return; + } + + if (scanOnly) { + send({ action: 'scan_complete', slugs: slugsToCrawl }); + return; + } + + // Elegant 1.5s delay to visually separate the Analysis/Queuing phase from the Downloading/Supabase-saving phase + await new Promise(r => setTimeout(r, 1500)); + + let successCount = 0; + let failCount = 0; + let skipCount = 0; + + // Bắt đầu crawl từng phim một + for (let i = 0; i < slugsToCrawl.length; i++) { + const item = slugsToCrawl[i]; + + if (item.skip) { + skipCount++; + send({ + action: 'result', + slug: item.slug, + name: item.raw, + status: 'skipped', + message: `Bỏ qua (100% không có tập mới - ${item.skipReason})` + }); + continue; + } + + send({ + action: 'progress', + index: i + 1, + total: slugsToCrawl.length, + slug: item.slug, + name: item.raw, + status: 'processing' + }); + + try { + const res = await fetchWithTimeout(`https://phimapi.com/phim/${item.slug}`); + if (!res.ok) { + throw new Error(`Phim không tồn tại trên KKPhim (HTTP ${res.status})`); + } + const data = await res.json(); + if (!data.status || !data.movie) { + throw new Error('Dữ liệu API KKPhim bị rỗng hoặc không đúng định dạng'); + } + + const crawledMovie = data.movie; + const crawledEpisodes = cleanAndFilterServers(data.episodes || []); + + // Lọc tập phim nếu admin chọn cụ thể + if (Array.isArray(selectedEpisodes) && selectedEpisodes.length > 0) { + crawledEpisodes.forEach(server => { + if (server.server_data) { + server.server_data = server.server_data.filter(ep => { + const formattedName = formatEpisodeName(ep.name); + return selectedEpisodes.includes(formattedName); + }); + } + }); + } + + const existing = localMovies[item.slug]; + if (existing) { + // So sánh gộp tập phim + const { merged, addedCount } = mergeEpisodes(existing.episodes, crawledEpisodes); + + const hasSelectedEpisodes = Array.isArray(selectedEpisodes) && selectedEpisodes.length > 0; + if (addedCount > 0 || hasSelectedEpisodes) { + // Có tập mới hoặc cập nhật tập đã chọn! Cập nhật dữ liệu + existing.movie = { + ...existing.movie, + ...crawledMovie, + episode_current: crawledMovie.episode_current || existing.movie.episode_current, + episode_total: crawledMovie.episode_total || existing.movie.episode_total || null, + modified: { time: new Date().toISOString() } + }; + existing.episodes = merged; + + await saveLocalMovie(item.slug, existing); + successCount++; + send({ + action: 'result', + slug: item.slug, + name: crawledMovie.name, + status: 'updated', + added: addedCount, + message: hasSelectedEpisodes && addedCount === 0 + ? `Thành công (Cập nhật liên kết ${selectedEpisodes.length} tập)` + : `Thành công (Cập nhật +${addedCount} tập mới)` + }); + } else { + // Không có tập mới nào, bỏ qua + skipCount++; + send({ + action: 'result', + slug: item.slug, + name: crawledMovie.name, + status: 'skipped', + message: 'Bỏ qua (Đã đầy đủ tập, không có tập mới)' + }); + } + } else { + // Phim mới hoàn toàn + crawledEpisodes.forEach(srv => { + if (srv.server_data) { + srv.server_data.forEach(ep => { + ep.name = formatEpisodeName(ep.name); + }); + } + }); + const newMovie = { + movie: crawledMovie, + episodes: crawledEpisodes + }; + await saveLocalMovie(item.slug, newMovie); + successCount++; + send({ + action: 'result', + slug: item.slug, + name: crawledMovie.name, + status: 'success', + message: 'Thành công (Phim mới)' + }); + } + + // Tự động đồng bộ các danh mục Thể loại, Quốc gia, Diễn viên và Server ngay lập tức! + await syncFromMovies('genres'); + await syncFromMovies('countries'); + await syncFromMovies('actors'); + await syncFromMovies('servers'); + + } catch (e) { + failCount++; + send({ + action: 'result', + slug: item.slug, + name: item.raw, + status: 'failed', + message: `Thất bại: ${e.message}` + }); + } + + // Tránh bị rate limit bởi server KKPhim + await new Promise(r => setTimeout(r, 400)); + } + + send({ + action: 'complete', + success: successCount, + failed: failCount, + skipped: skipCount + }); + + } catch (err) { + send({ action: 'error', message: err.message }); + } finally { + try { + controller.close(); + } catch (e) { + // Ignore if already closed + } + } + } + }); + + return new Response(stream, { + headers: { + 'Content-Type': 'text/event-stream', + 'Cache-Control': 'no-cache, no-transform', + 'Connection': 'keep-alive', + 'X-Accel-Buffering': 'no' + } + }); +} diff --git a/src/pages/api/admin/duyet-zalo.js b/src/pages/api/admin/duyet-zalo.js new file mode 100644 index 0000000000000000000000000000000000000000..406c728ecdb9f70bc7ef0f7a52a605552a2cdc73 --- /dev/null +++ b/src/pages/api/admin/duyet-zalo.js @@ -0,0 +1,99 @@ +import { txasupabase } from '../../../lib/txasupabase.js'; + +export const POST = async ({ request, cookies }) => { + try { + // 1. Kiểm tra quyền Admin bảo mật + const token = cookies.get('auth_token')?.value; + let user = null; + if (token) { + try { + user = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + } catch(e) {} + } + + if (!user || user.role !== 'admin') { + return new Response(JSON.stringify({ error: 'Bạn không có quyền quản trị!' }), { + status: 403, + headers: { 'Content-Type': 'application/json' } + }); + } + + const body = await request.json(); + const { id, ids, action } = body; + + if ((!id && !ids) || !action) { + return new Response(JSON.stringify({ error: 'Thiếu thông tin ID hoặc hành động!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + const idList = ids ? ids : [id]; + + if (action === 'approve') { + const { data, error } = await txasupabase.supabase + .from('zalo_access') + .update({ status: 'approved' }) + .in('id', idList); + + if (error) throw error; + + // Ghi log hoạt động + await txasupabase.createLog( + 'zalo_access_approved_bulk', + 'info', + `Admin "${user.username}" phê duyệt đồng loạt quyền truy cập cho ${idList.length} yêu cầu`, + { record_ids: idList, approved_by: user.username } + ); + + } else if (action === 'reject') { + const { data, error } = await txasupabase.supabase + .from('zalo_access') + .update({ status: 'rejected' }) + .in('id', idList); + + if (error) throw error; + + await txasupabase.createLog( + 'zalo_access_rejected_bulk', + 'warn', + `Admin "${user.username}" từ chối đồng loạt quyền truy cập cho ${idList.length} yêu cầu`, + { record_ids: idList, rejected_by: user.username } + ); + + } else if (action === 'delete') { + const { data, error } = await txasupabase.supabase + .from('zalo_access') + .delete() + .in('id', idList); + + if (error) throw error; + + await txasupabase.createLog( + 'zalo_access_deleted_bulk', + 'warn', + `Admin "${user.username}" xóa đồng loạt ${idList.length} yêu cầu truy cập`, + { record_ids: idList, deleted_by: user.username } + ); + } else { + return new Response(JSON.stringify({ error: 'Hành động không hợp lệ!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + return new Response(JSON.stringify({ + success: true, + message: `Đã thực hiện ${action === 'approve' ? 'phê duyệt' : action === 'reject' ? 'từ chối' : 'xóa'} thành công cho ${idList.length} yêu cầu!` + }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } catch (err) { + console.error('Error handling admin duyet-zalo API:', err); + return new Response(JSON.stringify({ error: err.message || 'Có lỗi xảy ra trên hệ thống!' }), { + status: 500, + headers: { 'Content-Type': 'application/json' } + }); + } +}; diff --git a/src/pages/api/admin/genres.js b/src/pages/api/admin/genres.js new file mode 100644 index 0000000000000000000000000000000000000000..cfeec6779c970d4c203c5a74acd61dc1f7ba0677 --- /dev/null +++ b/src/pages/api/admin/genres.js @@ -0,0 +1,59 @@ +import { getGenres, saveGenre, deleteGenre, bulkDeleteGenres, syncFromMovies } from '../../../lib/localDb.js'; + +export async function GET({ request }) { + try { + const list = await getGenres(); + return new Response(JSON.stringify(list)); + } catch (e) { + return new Response(JSON.stringify({ error: e.message }), { status: 500 }); + } +} + +export async function POST({ request }) { + const cookies = request.headers.get('cookie') || ''; + if (!cookies.includes('auth_token=')) { + return new Response(JSON.stringify({ error: 'Unauthorized' }), { status: 401 }); + } + + try { + const { slug, name, sync } = await request.json(); + if (sync) { + const list = await syncFromMovies('genres'); + return new Response(JSON.stringify({ message: 'Đồng bộ thể loại thành công!', list })); + } + + if (!slug || !name) { + return new Response(JSON.stringify({ error: 'Slug và Tên thể loại không được để trống' }), { status: 400 }); + } + + const list = await saveGenre(slug, name); + return new Response(JSON.stringify({ message: 'Lưu thể loại thành công!', list })); + } catch (e) { + return new Response(JSON.stringify({ error: e.message }), { status: 500 }); + } +} + +export async function DELETE({ request }) { + const cookies = request.headers.get('cookie') || ''; + if (!cookies.includes('auth_token=')) { + return new Response(JSON.stringify({ error: 'Unauthorized' }), { status: 401 }); + } + + try { + const { slug, slugs } = await request.json(); + let list; + if (slugs && Array.isArray(slugs)) { + list = await bulkDeleteGenres(slugs); + return new Response(JSON.stringify({ message: `Đã xóa hàng loạt ${slugs.length} thể loại!`, list })); + } + + if (!slug) { + return new Response(JSON.stringify({ error: 'Thiếu slug thể loại để xóa' }), { status: 400 }); + } + + list = await deleteGenre(slug); + return new Response(JSON.stringify({ message: 'Xóa thể loại thành công!', list })); + } catch (e) { + return new Response(JSON.stringify({ error: e.message }), { status: 500 }); + } +} diff --git a/src/pages/api/admin/movie/bulk.js b/src/pages/api/admin/movie/bulk.js new file mode 100644 index 0000000000000000000000000000000000000000..e9a9eaeadf6fe8ee5e3ba4d62c85dd7ef11c4387 --- /dev/null +++ b/src/pages/api/admin/movie/bulk.js @@ -0,0 +1,116 @@ +import { deleteLocalMovie, restoreLocalMovie, resetLocalMovie } from '../../../../lib/localDb.js'; +import { txasupabase } from '../../../../lib/txasupabase.js'; + +export async function POST({ request, cookies }) { + const token = cookies.get('auth_token')?.value; + let user = null; + if (token) { + try { + user = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + } catch (e) {} + } + + if (!user || user.role !== 'admin') { + return new Response( + JSON.stringify({ error: 'Từ chối truy cập! Yêu cầu quyền quản trị viên.' }), + { status: 403, headers: { 'Content-Type': 'application/json' } } + ); + } + + try { + const { slugs, action, value } = await request.json(); + if (!slugs || !Array.isArray(slugs) || slugs.length === 0) { + return new Response( + JSON.stringify({ error: 'Danh sách slug rỗng hoặc không hợp lệ!' }), + { status: 400, headers: { 'Content-Type': 'application/json' } } + ); + } + + const validActions = ['delete', 'restore', 'reset', 'hard-delete', 'status', 'require-login', 'free-login']; + if (!validActions.includes(action)) { + return new Response( + JSON.stringify({ error: 'Hành động hàng loạt không hợp lệ!' }), + { status: 400, headers: { 'Content-Type': 'application/json' } } + ); + } + + let processedCount = 0; + + for (const slug of slugs) { + if (action === 'delete') { + await deleteLocalMovie(slug); + processedCount++; + } else if (action === 'restore') { + const success = await restoreLocalMovie(slug); + if (success) processedCount++; + } else if (action === 'reset') { + const success = await resetLocalMovie(slug); + if (success) processedCount++; + } else if (action === 'hard-delete') { + // Xóa hoàn toàn phim khỏi cả bảng movies và deleted_movies + await txasupabase.supabase.from('movies').delete().eq('slug', slug); + await txasupabase.supabase.from('deleted_movies').delete().eq('slug', slug); + processedCount++; + } else if (action === 'status') { + const movieObj = await txasupabase.getMovieBySlug(slug); + if (movieObj) { + movieObj.movie.status = value; + // Cập nhật text hiển thị tương ứng + if (value === 'completed') { + movieObj.movie.episode_current = 'Hoàn Thành'; + } else if (value === 'ongoing') { + movieObj.movie.episode_current = 'Đang Chiếu'; + } else if (value === 'trailer') { + movieObj.movie.episode_current = 'Trailer / Sắp chiếu'; + } + await txasupabase.saveLocalMovie(slug, movieObj); + processedCount++; + } + } else if (action === 'require-login') { + const movieObj = await txasupabase.getMovieBySlug(slug); + if (movieObj) { + movieObj.movie.require_login = true; + movieObj.movie.only_login = true; + await txasupabase.saveLocalMovie(slug, movieObj); + processedCount++; + } + } else if (action === 'free-login') { + const movieObj = await txasupabase.getMovieBySlug(slug); + if (movieObj) { + movieObj.movie.require_login = false; + movieObj.movie.only_login = false; + await txasupabase.saveLocalMovie(slug, movieObj); + processedCount++; + } + } + } + + let message = ''; + if (action === 'delete') { + message = `Đã ẩn thành công ${processedCount} phim được chọn!`; + } else if (action === 'restore') { + message = `Đã khôi phục hiển thị thành công ${processedCount} phim được chọn!`; + } else if (action === 'reset') { + message = `Đã đặt lại thành công ${processedCount} phim được chọn về dữ liệu gốc!`; + } else if (action === 'hard-delete') { + message = `Đã xóa vĩnh viễn thành công ${processedCount} phim được chọn khỏi cơ sở dữ liệu!`; + } else if (action === 'status') { + const statusNames = { completed: 'Hoàn thành', ongoing: 'Đang chiếu', trailer: 'Sắp ra mắt' }; + message = `Đã đổi nhanh trạng thái thành công cho ${processedCount} phim thành "${statusNames[value] || value}"!`; + } else if (action === 'require-login') { + message = `Đã thiết lập bắt buộc đăng nhập thành công cho ${processedCount} phim!`; + } else if (action === 'free-login') { + message = `Đã mở khóa tự do xem phim không cần đăng nhập cho ${processedCount} phim!`; + } + + return new Response( + JSON.stringify({ message, processedCount }), + { status: 200, headers: { 'Content-Type': 'application/json' } } + ); + } catch (error) { + return new Response( + JSON.stringify({ error: 'Gặp lỗi khi thực hiện bulk action: ' + error.message }), + { status: 500, headers: { 'Content-Type': 'application/json' } } + ); + } +} diff --git a/src/pages/api/admin/movie/delete.js b/src/pages/api/admin/movie/delete.js new file mode 100644 index 0000000000000000000000000000000000000000..fd1025afc1ff6e0af3bf0bfdba0584bf4d04bfae --- /dev/null +++ b/src/pages/api/admin/movie/delete.js @@ -0,0 +1,43 @@ +import { deleteLocalMovie } from '../../../../lib/localDb.js'; + +export async function POST({ request, cookies }) { + const token = cookies.get('auth_token')?.value; + let user = null; + if (token) { + try { + user = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + } catch (e) {} + } + + if (!user || user.role !== 'admin') { + return new Response( + JSON.stringify({ error: 'Từ chối truy cập! Yêu cầu quyền quản trị viên.' }), + { status: 403, headers: { 'Content-Type': 'application/json' } } + ); + } + + try { + const { slug } = await request.json(); + if (!slug) { + return new Response( + JSON.stringify({ error: 'Thiếu thông số slug phim!' }), + { status: 400, headers: { 'Content-Type': 'application/json' } } + ); + } + + const result = await deleteLocalMovie(slug); + const msg = result.isLocalOnly + ? 'Đã xóa hoàn toàn phim nội bộ ra khỏi hệ thống!' + : 'Đã ẩn phim này khỏi trang chủ và công cụ tìm kiếm!'; + + return new Response( + JSON.stringify({ message: msg }), + { status: 200, headers: { 'Content-Type': 'application/json' } } + ); + } catch (error) { + return new Response( + JSON.stringify({ error: 'Gặp lỗi trong quá trình xóa: ' + error.message }), + { status: 500, headers: { 'Content-Type': 'application/json' } } + ); + } +} diff --git a/src/pages/api/admin/movie/edit-comment.js b/src/pages/api/admin/movie/edit-comment.js new file mode 100644 index 0000000000000000000000000000000000000000..04f2a4c6dde0edf4fde6dd409aa061d3acd14e4f --- /dev/null +++ b/src/pages/api/admin/movie/edit-comment.js @@ -0,0 +1,133 @@ +import { txasupabase } from '../../../../lib/txasupabase.js'; + +export async function POST({ request, cookies }) { + // Check Admin privilege + const token = cookies.get('auth_token')?.value; + let user = null; + if (token) { + try { + user = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + } catch (e) {} + } + + if (!user || user.role !== 'admin') { + return new Response(JSON.stringify({ error: 'Bạn không có quyền quản trị để thực hiện!' }), { + status: 403, + headers: { 'Content-Type': 'application/json' } + }); + } + + try { + const { commentId, commentIds, isSpoiler, usernames, action } = await request.json(); + + if (!action) { + return new Response(JSON.stringify({ error: 'Thiếu hành động!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + // A. BẬT / TẮT SPOILER ĐƠN + if (action === 'toggle_spoiler') { + if (!commentId) { + return new Response(JSON.stringify({ error: 'Thiếu ID bình luận!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + const { error } = await txasupabase.supabase + .from('comments') + .update({ is_spoiler: !!isSpoiler }) + .eq('id', commentId); + + if (error) throw error; + + return new Response(JSON.stringify({ message: 'Cập nhật trạng thái Spoiler thành công!' }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } + + // B. XÓA HÀNG LOẠT BÌNH LUẬN + if (action === 'bulk_delete') { + if (!Array.isArray(commentIds) || commentIds.length === 0) { + return new Response(JSON.stringify({ error: 'Chưa chọn bình luận nào để xóa!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + const { error } = await txasupabase.supabase + .from('comments') + .delete() + .in('id', commentIds); + + if (error) throw error; + + return new Response(JSON.stringify({ message: `Đã xóa thành công ${commentIds.length} bình luận!` }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } + + // C. BẬT / TẮT SPOILER HÀNG LOẠT + if (action === 'bulk_spoiler') { + if (!Array.isArray(commentIds) || commentIds.length === 0) { + return new Response(JSON.stringify({ error: 'Chưa chọn bình luận nào để cập nhật!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + const { error } = await txasupabase.supabase + .from('comments') + .update({ is_spoiler: !!isSpoiler }) + .in('id', commentIds); + + if (error) throw error; + + return new Response(JSON.stringify({ message: `Đã cập nhật Spoiler thành công cho ${commentIds.length} bình luận!` }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } + + // D. CHẶN HÀNG LOẠT NGƯỜI DÙNG + if (action === 'bulk_ban') { + if (!Array.isArray(usernames) || usernames.length === 0) { + return new Response(JSON.stringify({ error: 'Chưa chọn người dùng nào để chặn!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + let bannedUsers = await txasupabase.getSetting('banned_commenters') || []; + if (!Array.isArray(bannedUsers)) bannedUsers = []; + + usernames.forEach(uname => { + if (!bannedUsers.includes(uname)) { + bannedUsers.push(uname); + } + }); + + await txasupabase.saveSetting('banned_commenters', bannedUsers); + + return new Response(JSON.stringify({ message: `Đã chặn bình luận thành công đối với ${usernames.length} tài khoản!` }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } + + return new Response(JSON.stringify({ error: 'Hành động không được hỗ trợ!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + + } catch (error) { + return new Response(JSON.stringify({ error: 'Lỗi máy chủ: ' + error.message }), { + status: 500, + headers: { 'Content-Type': 'application/json' } + }); + } +} diff --git a/src/pages/api/admin/movie/reset.js b/src/pages/api/admin/movie/reset.js new file mode 100644 index 0000000000000000000000000000000000000000..7aad9aae4d4297dc63b73f0f4b1c7c33f43a599d --- /dev/null +++ b/src/pages/api/admin/movie/reset.js @@ -0,0 +1,46 @@ +import { resetLocalMovie } from '../../../../lib/localDb.js'; + +export async function POST({ request, cookies }) { + const token = cookies.get('auth_token')?.value; + let user = null; + if (token) { + try { + user = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + } catch (e) {} + } + + if (!user || user.role !== 'admin') { + return new Response( + JSON.stringify({ error: 'Từ chối truy cập! Yêu cầu quyền quản trị viên.' }), + { status: 403, headers: { 'Content-Type': 'application/json' } } + ); + } + + try { + const { slug } = await request.json(); + if (!slug) { + return new Response( + JSON.stringify({ error: 'Thiếu thông số slug phim!' }), + { status: 400, headers: { 'Content-Type': 'application/json' } } + ); + } + + const success = await resetLocalMovie(slug); + if (success) { + return new Response( + JSON.stringify({ message: 'Đã xóa bỏ các thay đổi cục bộ, đưa phim về trạng thái gốc từ API!' }), + { status: 200, headers: { 'Content-Type': 'application/json' } } + ); + } else { + return new Response( + JSON.stringify({ error: 'Phim này không có thay đổi cục bộ nào để đặt lại!' }), + { status: 400, headers: { 'Content-Type': 'application/json' } } + ); + } + } catch (error) { + return new Response( + JSON.stringify({ error: 'Gặp lỗi trong quá trình đặt lại: ' + error.message }), + { status: 500, headers: { 'Content-Type': 'application/json' } } + ); + } +} diff --git a/src/pages/api/admin/movie/restore.js b/src/pages/api/admin/movie/restore.js new file mode 100644 index 0000000000000000000000000000000000000000..ce7bf016eef9bd6e5079b7ad0d80a90362829a75 --- /dev/null +++ b/src/pages/api/admin/movie/restore.js @@ -0,0 +1,46 @@ +import { restoreLocalMovie } from '../../../../lib/localDb.js'; + +export async function POST({ request, cookies }) { + const token = cookies.get('auth_token')?.value; + let user = null; + if (token) { + try { + user = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + } catch (e) {} + } + + if (!user || user.role !== 'admin') { + return new Response( + JSON.stringify({ error: 'Từ chối truy cập! Yêu cầu quyền quản trị viên.' }), + { status: 403, headers: { 'Content-Type': 'application/json' } } + ); + } + + try { + const { slug } = await request.json(); + if (!slug) { + return new Response( + JSON.stringify({ error: 'Thiếu thông số slug phim!' }), + { status: 400, headers: { 'Content-Type': 'application/json' } } + ); + } + + const success = await restoreLocalMovie(slug); + if (success) { + return new Response( + JSON.stringify({ message: 'Khôi phục hiển thị phim thành công!' }), + { status: 200, headers: { 'Content-Type': 'application/json' } } + ); + } else { + return new Response( + JSON.stringify({ error: 'Không tìm thấy phim này trong danh sách ẩn!' }), + { status: 400, headers: { 'Content-Type': 'application/json' } } + ); + } + } catch (error) { + return new Response( + JSON.stringify({ error: 'Gặp lỗi trong quá trình khôi phục: ' + error.message }), + { status: 500, headers: { 'Content-Type': 'application/json' } } + ); + } +} diff --git a/src/pages/api/admin/movie/save.js b/src/pages/api/admin/movie/save.js new file mode 100644 index 0000000000000000000000000000000000000000..287e5784531a9fe2a54374dfe9fa3f4e9b551559 --- /dev/null +++ b/src/pages/api/admin/movie/save.js @@ -0,0 +1,40 @@ +import { saveLocalMovie } from '../../../../lib/localDb.js'; + +export async function POST({ request, cookies }) { + // 1. Kiểm tra quyền Admin + const token = cookies.get('auth_token')?.value; + let user = null; + if (token) { + try { + user = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + } catch (e) {} + } + + if (!user || user.role !== 'admin') { + return new Response( + JSON.stringify({ error: 'Từ chối truy cập! Yêu cầu quyền quản trị viên.' }), + { status: 403, headers: { 'Content-Type': 'application/json' } } + ); + } + + try { + const { slug, movie, episodes } = await request.json(); + if (!slug) { + return new Response( + JSON.stringify({ error: 'Thiếu thông số slug phim!' }), + { status: 400, headers: { 'Content-Type': 'application/json' } } + ); + } + + const savedMovie = await saveLocalMovie(slug, { movie, episodes }); + return new Response( + JSON.stringify({ message: 'Lưu phim thành công!', data: savedMovie }), + { status: 200, headers: { 'Content-Type': 'application/json' } } + ); + } catch (error) { + return new Response( + JSON.stringify({ error: 'Gặp lỗi trong quá trình lưu: ' + error.message }), + { status: 500, headers: { 'Content-Type': 'application/json' } } + ); + } +} diff --git a/src/pages/api/admin/movie/sync-episodes.js b/src/pages/api/admin/movie/sync-episodes.js new file mode 100644 index 0000000000000000000000000000000000000000..826b04000ff3c237251dc6d5e57b6acd3ea85bd9 --- /dev/null +++ b/src/pages/api/admin/movie/sync-episodes.js @@ -0,0 +1,141 @@ +import { getLocalMovies, saveLocalMovie } from '../../../../lib/localDb.js'; + +export async function POST({ request }) { + // Check quyền admin từ cookie + const cookies = request.headers.get('cookie') || ''; + const hasToken = cookies.includes('auth_token='); + if (!hasToken) { + return new Response(JSON.stringify({ error: 'Unauthorized' }), { status: 401 }); + } + + const { slug, type } = await request.json(); + if (!slug) { + return new Response(JSON.stringify({ error: 'Thiếu slug phim' }), { status: 400 }); + } + + try { + const localMovies = await getLocalMovies(); + const movieData = localMovies[slug]; + if (!movieData) { + return new Response(JSON.stringify({ error: 'Không tìm thấy phim trong database cục bộ' }), { status: 404 }); + } + + // Gọi API KKPhim gốc + const res = await fetch(`https://phimapi.com/phim/${slug}`); + if (!res.ok) { + return new Response(JSON.stringify({ error: `Không thể gọi API KKPhim (HTTP ${res.status})` }), { status: 500 }); + } + + const apiData = await res.json(); + if (!apiData.status || !apiData.episodes) { + return new Response(JSON.stringify({ error: 'Dữ liệu API KKPhim rỗng' }), { status: 500 }); + } + + const apiEpisodes = apiData.episodes || []; + const localEpisodes = movieData.episodes || []; + let updatedCount = 0; + let addedCount = 0; + + if (type === 'sync_new') { + // Chỉ quét và thêm tập phim mới + const updatedEpisodes = []; + + for (const apiServer of apiEpisodes) { + const localServer = localEpisodes.find(s => s.server_name === apiServer.server_name); + if (!localServer) { + updatedEpisodes.push(apiServer); + addedCount += apiServer.server_data.length; + continue; + } + + const mergedData = [...localServer.server_data]; + const localNames = new Set(localServer.server_data.map(e => e.name)); + + for (const apiEp of apiServer.server_data) { + if (!localNames.has(apiEp.name)) { + mergedData.push(apiEp); + addedCount++; + } + } + + updatedEpisodes.push({ + server_name: apiServer.server_name, + server_data: mergedData + }); + } + + movieData.episodes = updatedEpisodes; + movieData.movie.episode_current = apiData.movie.episode_current || movieData.movie.episode_current; + movieData.movie.episode_total = apiData.movie.episode_total || movieData.movie.episode_total || null; + movieData.movie.modified = { time: new Date().toISOString() }; + + await saveLocalMovie(slug, movieData); + return new Response(JSON.stringify({ + message: `Đồng bộ thành công! Đã thêm ${addedCount} tập phim mới.`, + episodes: updatedEpisodes, + episode_current: movieData.movie.episode_current + })); + + } else if (type === 'sync_all') { + // Cập nhật lại toàn bộ link stream của tất cả các tập, giữ nguyên Intro/Outro + const updatedEpisodes = []; + + for (const apiServer of apiEpisodes) { + const localServer = localEpisodes.find(s => s.server_name === apiServer.server_name); + if (!localServer) { + updatedEpisodes.push(apiServer); + updatedCount += apiServer.server_data.length; + continue; + } + + const mergedData = []; + const localMap = new Map(localServer.server_data.map(e => [e.name, e])); + + for (const apiEp of apiServer.server_data) { + const localEp = localMap.get(apiEp.name); + if (localEp) { + // Giữ lại cấu hình Intro/Outro cũ + mergedData.push({ + ...apiEp, + introStart: localEp.introStart, + introEnd: localEp.introEnd, + outroStart: localEp.outroStart, + outroEnd: localEp.outroEnd, + // Tương thích với các trường cũ nếu có + time_intro_start: localEp.time_intro_start || 0, + time_intro_end: localEp.time_intro_end || 0, + time_outro_start: localEp.time_outro_start || 0, + time_outro_end: localEp.time_outro_end || 0 + }); + updatedCount++; + } else { + mergedData.push(apiEp); + addedCount++; + } + } + + updatedEpisodes.push({ + server_name: apiServer.server_name, + server_data: mergedData + }); + } + + movieData.episodes = updatedEpisodes; + movieData.movie.episode_current = apiData.movie.episode_current || movieData.movie.episode_current; + movieData.movie.episode_total = apiData.movie.episode_total || movieData.movie.episode_total || null; + movieData.movie.modified = { time: new Date().toISOString() }; + + await saveLocalMovie(slug, movieData); + return new Response(JSON.stringify({ + message: `Đồng bộ thành công! Làm mới ${updatedCount} link tập và thêm ${addedCount} tập mới.`, + episodes: updatedEpisodes, + episode_current: movieData.movie.episode_current + })); + } + + return new Response(JSON.stringify({ error: 'Loại đồng bộ không hợp lệ' }), { status: 400 }); + + } catch (e) { + return new Response(JSON.stringify({ error: e.message }), { status: 500 }); + } +} diff --git a/src/pages/api/admin/nguoi-dung.js b/src/pages/api/admin/nguoi-dung.js new file mode 100644 index 0000000000000000000000000000000000000000..8f7321e42995b50d82bdd6b61ada56d957fab693 --- /dev/null +++ b/src/pages/api/admin/nguoi-dung.js @@ -0,0 +1,273 @@ +import { txasupabase } from '../../../lib/txasupabase.js'; + +export const POST = async ({ request, cookies }) => { + try { + // 1. Kiểm tra quyền Admin bảo mật + const token = cookies.get('auth_token')?.value; + let currentUser = null; + if (token) { + try { + currentUser = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + } catch (e) {} + } + + if (!currentUser || currentUser.role !== 'admin') { + return new Response(JSON.stringify({ error: 'Bạn không có quyền quản trị!' }), { + status: 403, + headers: { 'Content-Type': 'application/json' } + }); + } + + const body = await request.json(); + const { username, usernames, action, role, email, password, province, ward, avatar_url } = body; + + if (!action) { + return new Response(JSON.stringify({ error: 'Thiếu thông tin hành động (action)!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + // --- HÀNH ĐỘNG 1: THÊM MỚI NGƯỜI DÙNG (CREATE) --- + if (action === 'create') { + if (!username || !email || !password) { + return new Response(JSON.stringify({ error: 'Vui lòng cung cấp đầy đủ Tài khoản, Email và Mật khẩu!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + const cleanUsername = username.trim(); + const cleanEmail = email.trim(); + + // Kiểm tra xem tên đăng nhập đã tồn tại chưa + const existingUser = await txasupabase.getUserByUsername(cleanUsername); + if (existingUser) { + return new Response(JSON.stringify({ error: 'Tên tài khoản này đã tồn tại trên hệ thống!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + // Kiểm tra xem email đã được sử dụng chưa + const { data: existingEmail } = await txasupabase.supabase + .from('users') + .select('username') + .eq('email', cleanEmail) + .maybeSingle(); + + if (existingEmail) { + return new Response(JSON.stringify({ error: 'Địa chỉ Email này đã được đăng ký cho tài khoản khác!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + const defaultAvatar = txasupabase.getGravatarUrl(cleanEmail); + + const { data, error } = await txasupabase.supabase + .from('users') + .insert({ + username: cleanUsername, + email: cleanEmail, + password: password, + province: province || '', + ward: ward || '', + role: role || 'user', + avatar_url: avatar_url || defaultAvatar, + favorites: [], + history: [], + created_at: new Date().toISOString() + }) + .select() + .single(); + + if (error) throw error; + + // Ghi log hoạt động + await txasupabase.supabase.from('logs').insert({ + action: 'user_created', + level: 'info', + message: `Admin "${currentUser.username}" đã tạo mới tài khoản "${cleanUsername}" với quyền "${role || 'user'}"`, + details: JSON.stringify({ username: cleanUsername, role: role || 'user', created_by: currentUser.username }) + }); + + return new Response(JSON.stringify({ + success: true, + message: `Đã tạo tài khoản "${cleanUsername}" thành công!`, + user: data + }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } + + // --- HÀNH ĐỘNG 2: CHỈNH SỬA THÔNG TIN NGƯỜI DÙNG (UPDATE) --- + if (action === 'update') { + if (!username) { + return new Response(JSON.stringify({ error: 'Thiếu Tên tài khoản cần cập nhật!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + // Chặn Admin tự hạ quyền của chính mình khi cập nhật + if (username === currentUser.username && role === 'user') { + return new Response(JSON.stringify({ error: 'Bạn không thể tự hạ quyền quản trị của chính mình!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + // Kiểm tra trùng lặp email nếu email bị thay đổi + if (email) { + const cleanEmail = email.trim(); + const { data: dupEmail } = await txasupabase.supabase + .from('users') + .select('username') + .eq('email', cleanEmail) + .neq('username', username) + .maybeSingle(); + + if (dupEmail) { + return new Response(JSON.stringify({ error: 'Địa chỉ Email này đã được sử dụng bởi tài khoản khác!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + } + + const updateData = { + email: email ? email.trim() : undefined, + province: province !== undefined ? province : undefined, + ward: ward !== undefined ? ward : undefined, + role: role !== undefined ? role : undefined, + avatar_url: avatar_url !== undefined ? avatar_url : undefined + }; + + // Chỉ cập nhật mật khẩu mới nếu được điền + if (password && password.trim() !== '') { + updateData.password = password; + } + + // Loại bỏ các trường undefined để tránh ghi đè null vô lý + Object.keys(updateData).forEach(key => updateData[key] === undefined && delete updateData[key]); + + const { data, error } = await txasupabase.supabase + .from('users') + .update(updateData) + .eq('username', username) + .select() + .single(); + + if (error) throw error; + + // Ghi log hoạt động + await txasupabase.supabase.from('logs').insert({ + action: 'user_updated', + level: 'info', + message: `Admin "${currentUser.username}" đã cập nhật thông tin tài khoản "${username}"`, + details: JSON.stringify({ username, updated_fields: Object.keys(updateData), updated_by: currentUser.username }) + }); + + return new Response(JSON.stringify({ + success: true, + message: `Đã cập nhật thông tin tài khoản "${username}" thành công!`, + user: data + }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } + + // --- HÀNH ĐỘNG 3: ĐỔI VAI TRÒ NHANH (CHANGE ROLE) --- + if (action === 'change_role') { + if ((!username && !usernames) || !role) { + return new Response(JSON.stringify({ error: 'Thiếu thông tin người dùng hoặc vai trò!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + const userList = usernames ? usernames : [username]; + + // Ngăn không cho admin tự hạ quyền của chính mình + if (userList.includes(currentUser.username)) { + return new Response(JSON.stringify({ error: 'Bạn không thể tự hạ quyền hoặc thay đổi vai trò của chính mình!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + const { error } = await txasupabase.supabase + .from('users') + .update({ role: role }) + .in('username', userList); + + if (error) throw error; + + await txasupabase.supabase.from('logs').insert({ + action: 'user_role_changed_bulk', + level: 'info', + message: `Admin "${currentUser.username}" đã đổi quyền của ${userList.length} tài khoản thành "${role}"`, + details: JSON.stringify({ usernames: userList, new_role: role, changed_by: currentUser.username }) + }); + + return new Response(JSON.stringify({ + success: true, + message: `Đã chuyển đổi quyền của ${userList.length} tài khoản thành công!` + }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } + + // --- HÀNH ĐỘNG 4: XÓA TÀI KHOẢN (DELETE & BULK DELETE) --- + if (action === 'delete') { + const userList = usernames ? usernames : [username]; + + // Ngăn không cho admin tự xóa chính mình + const cleanUserList = userList.filter(u => u !== currentUser.username); + if (cleanUserList.length === 0) { + return new Response(JSON.stringify({ error: 'Không thể tự xóa tài khoản quản trị của chính bạn!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + const { error } = await txasupabase.supabase + .from('users') + .delete() + .in('username', cleanUserList); + + if (error) throw error; + + await txasupabase.supabase.from('logs').insert({ + action: 'user_deleted_bulk', + level: 'warn', + message: `Admin "${currentUser.username}" đã xóa đồng loạt ${cleanUserList.length} tài khoản người dùng`, + details: JSON.stringify({ deleted_usernames: cleanUserList, deleted_by: currentUser.username }) + }); + + return new Response(JSON.stringify({ + success: true, + message: `Đã xóa thành công ${cleanUserList.length} tài khoản người dùng!` + }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } + + return new Response(JSON.stringify({ error: 'Hành động không hợp lệ!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + + } catch (err) { + console.error('Error handling admin user management API:', err); + return new Response(JSON.stringify({ error: err.message || 'Có lỗi xảy ra trên hệ thống!' }), { + status: 500, + headers: { 'Content-Type': 'application/json' } + }); + } +}; diff --git a/src/pages/api/admin/notifications.js b/src/pages/api/admin/notifications.js new file mode 100644 index 0000000000000000000000000000000000000000..1aa68194bfa56c352edb38e1f5a14ebf87115931 --- /dev/null +++ b/src/pages/api/admin/notifications.js @@ -0,0 +1,70 @@ +import { txasupabase } from '../../../lib/txasupabase.js'; + +export const GET = async ({ cookies }) => { + try { + // 1. Kiểm tra quyền Admin bảo mật + const token = cookies.get('auth_token')?.value; + let user = null; + if (token) { + try { + user = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + } catch (e) {} + } + + if (!user || user.role !== 'admin') { + return new Response(JSON.stringify({ error: 'Bạn không có quyền quản trị!' }), { + status: 403, + headers: { 'Content-Type': 'application/json' } + }); + } + + // 2. Lấy số lượng Zalo Access đang chờ duyệt + const { count: pendingZalo, error: zaloErr } = await txasupabase.supabase + .from('zalo_access') + .select('*', { count: 'exact', head: true }) + .eq('status', 'pending'); + + if (zaloErr) throw zaloErr; + + // 3. Lấy số lượng Báo cáo lỗi đang chờ xử lý + const { count: pendingReports, error: reportErr } = await txasupabase.supabase + .from('reports') + .select('*', { count: 'exact', head: true }) + .eq('status', 'pending'); + + if (reportErr) throw reportErr; + + // 4. Lấy số lượng bình luận và thông tin bình luận mới nhất + const { data: commentsData, error: commentErr } = await txasupabase.supabase + .from('comments') + .select('id, created_at') + .order('created_at', { ascending: false }); + + if (commentErr) throw commentErr; + + const totalComments = commentsData ? commentsData.length : 0; + const latestCommentTime = commentsData && commentsData.length > 0 ? commentsData[0].created_at : null; + + return new Response(JSON.stringify({ + success: true, + pendingZalo: pendingZalo || 0, + pendingReports: pendingReports || 0, + totalComments, + latestCommentTime, + comments: commentsData || [] + }), { + status: 200, + headers: { + 'Content-Type': 'application/json', + 'Cache-Control': 'no-store, max-age=0' + } + }); + + } catch (err) { + console.error('Error in admin notifications API:', err); + return new Response(JSON.stringify({ error: err.message || 'Lỗi hệ thống!' }), { + status: 500, + headers: { 'Content-Type': 'application/json' } + }); + } +}; diff --git a/src/pages/api/admin/scan.js b/src/pages/api/admin/scan.js new file mode 100644 index 0000000000000000000000000000000000000000..9c975905ae182d78b8ec1a8303a246db08bc091c --- /dev/null +++ b/src/pages/api/admin/scan.js @@ -0,0 +1,352 @@ +import { getLocalMovies } from '../../../lib/localDb.js'; + +// Cấu hình timeout cho fetch +async function fetchWithTimeout(resource, options = {}) { + const { timeout = 8000 } = options; + const controller = new AbortController(); + const id = setTimeout(() => controller.abort(), timeout); + try { + const response = await fetch(resource, { + ...options, + signal: controller.signal + }); + return response; + } finally { + clearTimeout(id); + } +} + +// Trích xuất slug từ URL hoặc chuỗi nhập vào +function extractSlug(input) { + if (!input) return null; + const trimmed = input.trim(); + if (!trimmed) return null; + + try { + if (trimmed.startsWith('http://') || trimmed.startsWith('https://')) { + const url = new URL(trimmed); + const pathname = url.pathname; + const parts = pathname.split('/').filter(Boolean); + if (parts.length > 0) { + return parts[parts.length - 1]; + } + } + } catch (e) {} + + const parts = trimmed.split('/').filter(Boolean); + if (parts.length > 0) { + return parts[parts.length - 1]; + } + return trimmed; +} + +// Hàm gộp tập phim để nhẩm tính số tập mới +function checkEpisodesDiff(existingEpisodes, crawledEpisodes) { + let addedCount = 0; + const existingList = existingEpisodes || []; + + for (const crawledServer of crawledEpisodes) { + let existingServer = existingList.find(s => s.server_name === crawledServer.server_name); + if (!existingServer) { + addedCount += crawledServer.server_data?.length || 0; + continue; + } + + const existingNames = new Set((existingServer.server_data || []).map(e => e.name)); + for (const crawledEp of crawledServer.server_data || []) { + if (!existingNames.has(crawledEp.name)) { + addedCount++; + } + } + } + return addedCount; +} + +// Dọn dẹp máy chủ +function cleanAndFilterServers(episodes) { + if (!Array.isArray(episodes)) return []; + const tempMap = new Map(); + + for (const srv of episodes) { + if (!srv || !srv.server_name) continue; + let rawName = srv.server_name.trim(); + let cleanName = ''; + + if (/vietsub/i.test(rawName)) { + cleanName = 'Vietsub'; + } else if (/thuyết minh|thuyet minh/i.test(rawName)) { + cleanName = 'Thuyết Minh'; + } else if (/lồng tiếng|long tieng/i.test(rawName)) { + cleanName = 'Lồng Tiếng'; + } else { + cleanName = rawName.replace(/#\s*/g, '').replace(/\([^)]*\)/g, '').trim(); + if (!cleanName) cleanName = 'Vietsub'; + } + + if (cleanName !== 'Vietsub' && cleanName !== 'Thuyết Minh' && cleanName !== 'Lồng Tiếng') { + continue; + } + + if (!tempMap.has(cleanName)) { + srv.server_name = cleanName; + tempMap.set(cleanName, srv); + } + } + + const result = []; + if (tempMap.has('Vietsub')) result.push(tempMap.get('Vietsub')); + if (tempMap.has('Thuyết Minh')) result.push(tempMap.get('Thuyết Minh')); + if (result.length < 2 && tempMap.has('Lồng Tiếng')) { + result.push(tempMap.get('Lồng Tiếng')); + } + if (result.length === 0 && episodes.length > 0) { + const fallbackSrv = episodes[0]; + fallbackSrv.server_name = fallbackSrv.server_name.replace(/#\s*/g, '').replace(/\([^)]*\)/g, '').trim() || 'Vietsub'; + result.push(fallbackSrv); + } + + return result; +} + +export async function POST({ request }) { + // Check quyền admin từ cookie auth_token + const cookies = request.headers.get('cookie') || ''; + const hasToken = cookies.includes('auth_token='); + if (!hasToken) { + return new Response(JSON.stringify({ error: 'Unauthorized' }), { status: 401, headers: { 'Content-Type': 'application/json' } }); + } + + try { + const { type, urls, pageStart, pageEnd, countrySlug, genreSlug } = await request.json(); + const localMovies = await getLocalMovies(); + const slugsToCrawl = []; + + if (type === 'url') { + const urlList = Array.isArray(urls) ? urls : [urls]; + for (const rawUrl of urlList) { + const slug = extractSlug(rawUrl); + if (slug) { + try { + const res = await fetchWithTimeout(`https://phimapi.com/phim/${slug}`); + if (!res.ok) throw new Error(`HTTP ${res.status}`); + const data = await res.json(); + + if (data.status && data.movie) { + const crawledMovie = data.movie; + const crawledEpisodes = cleanAndFilterServers(data.episodes || []); + + let crawledEpCount = 0; + if (crawledEpisodes.length > 0) { + crawledEpCount = Math.max(...crawledEpisodes.map(s => s.server_data?.length || 0)); + } + + const existing = localMovies[slug]; + let expectedNew = crawledEpCount; + let exists = false; + let skip = false; + let skipReason = ''; + + if (existing) { + exists = true; + const addedCount = checkEpisodesDiff(existing.episodes, crawledEpisodes); + expectedNew = addedCount; + if (addedCount === 0) { + skip = true; + skipReason = 'Đã đủ tập'; + } + } + + slugsToCrawl.push({ + raw: crawledMovie.name, + slug, + totalEpisodes: crawledEpCount, + expectedNew, + exists, + skip, + skipReason + }); + } + } catch (e) { + slugsToCrawl.push({ + raw: slug, + slug, + totalEpisodes: 0, + expectedNew: 0, + exists: false, + skip: false, + skipReason: `Lỗi quét: ${e.message}` + }); + } + } + } + } else if (type === 'country') { + const start = parseInt(pageStart || '1'); + const end = parseInt(pageEnd || '1'); + + for (let p = start; p <= end; p++) { + try { + const res = await fetchWithTimeout(`https://phimapi.com/v1/api/quoc-gia/${countrySlug}?page=${p}`); + if (!res.ok) throw new Error(`HTTP ${res.status}`); + const resData = await res.json(); + const items = resData.data?.items || []; + + for (const item of items) { + if (item.slug && !slugsToCrawl.some(s => s.slug === item.slug)) { + const existing = localMovies[item.slug]; + let skip = false; + let skipReason = ''; + let expectedNew = 1; + let exists = false; + + if (existing) { + exists = true; + const localStatus = (existing.movie?.episode_current || '').toLowerCase(); + const remoteStatus = (item.episode_current || '').toLowerCase(); + const isStatusEqual = localStatus === remoteStatus && remoteStatus !== ''; + const isBothCompleted = (localStatus.includes('hoàn tất') || localStatus.includes('full') || localStatus.includes('complete') || localStatus.includes('12/12')) && + (remoteStatus.includes('hoàn tất') || remoteStatus.includes('full') || remoteStatus.includes('complete') || remoteStatus.includes('12/12')); + + if (isStatusEqual || isBothCompleted) { + skip = true; + skipReason = remoteStatus.includes('hoàn tất') ? 'Phim đã hoàn tất' : 'Số tập trùng khớp'; + expectedNew = 0; + } + } + + slugsToCrawl.push({ + raw: item.name, + slug: item.slug, + totalEpisodes: item.episode_total || (item.episode_current ? item.episode_current : '?'), + expectedNew, + exists, + skip, + skipReason + }); + } + } + } catch (e) { + console.error(`Error scanning page ${p}:`, e); + } + } + } else if (type === 'genre') { + const start = parseInt(pageStart || '1'); + const end = parseInt(pageEnd || '1'); + + for (let p = start; p <= end; p++) { + try { + let apiUrl = `https://phimapi.com/v1/api/the-loai/${genreSlug}?page=${p}`; + const listSlugs = ['hoat-hinh', 'phim-chieu-rap', 'phim-le', 'phim-bo', 'tv-shows']; + if (listSlugs.includes(genreSlug)) { + apiUrl = `https://phimapi.com/v1/api/danh-sach/${genreSlug}?page=${p}`; + } + + const res = await fetchWithTimeout(apiUrl); + if (!res.ok) throw new Error(`HTTP ${res.status}`); + const resData = await res.json(); + const items = resData.data?.items || []; + + for (const item of items) { + if (item.slug && !slugsToCrawl.some(s => s.slug === item.slug)) { + const existing = localMovies[item.slug]; + let skip = false; + let skipReason = ''; + let expectedNew = 1; + let exists = false; + + if (existing) { + exists = true; + const localStatus = (existing.movie?.episode_current || '').toLowerCase(); + const remoteStatus = (item.episode_current || '').toLowerCase(); + const isStatusEqual = localStatus === remoteStatus && remoteStatus !== ''; + const isBothCompleted = (localStatus.includes('hoàn tất') || localStatus.includes('full') || localStatus.includes('complete') || localStatus.includes('12/12')) && + (remoteStatus.includes('hoàn tất') || remoteStatus.includes('full') || remoteStatus.includes('complete') || remoteStatus.includes('12/12')); + + if (isStatusEqual || isBothCompleted) { + skip = true; + skipReason = remoteStatus.includes('hoàn tất') ? 'Phim đã hoàn tất' : 'Số tập trùng khớp'; + expectedNew = 0; + } + } + + slugsToCrawl.push({ + raw: item.name, + slug: item.slug, + totalEpisodes: item.episode_total || (item.episode_current ? item.episode_current : '?'), + expectedNew, + exists, + skip, + skipReason + }); + } + } + } catch (e) { + console.error(`Error scanning genre page ${p}:`, e); + } + } + } else if (type === 'batch') { + const start = parseInt(pageStart || '1'); + const end = parseInt(pageEnd || '1'); + + for (let p = start; p <= end; p++) { + try { + const res = await fetchWithTimeout(`https://phimapi.com/danh-sach/phim-moi-cap-nhat?page=${p}`); + if (!res.ok) throw new Error(`HTTP ${res.status}`); + const data = await res.json(); + const items = data.items || []; + + for (const item of items) { + if (item.slug && !slugsToCrawl.some(s => s.slug === item.slug)) { + const existing = localMovies[item.slug]; + let skip = false; + let skipReason = ''; + let expectedNew = 1; + let exists = false; + + if (existing) { + exists = true; + // Nhẩm tính thử + } + + slugsToCrawl.push({ + raw: item.name, + slug: item.slug, + totalEpisodes: item.episode_total || '?', + expectedNew, + exists, + skip, + skipReason + }); + } + } + } catch (e) { + console.error(`Error scanning batch page ${p}:`, e); + } + } + } else if (type === 'all') { + // Vì scan all có thể mất thời gian nếu lấy hết nghìn slugs, ta chỉ quét trang 1-2 để đảm bảo không timeout + // Hoặc trả về nhanh 1 danh sách + const res = await fetchWithTimeout(`https://phimapi.com/danh-sach/phim-moi-cap-nhat?page=1`); + if (res.ok) { + const data = await res.json(); + const items = data.items || []; + for (const item of items) { + slugsToCrawl.push({ + raw: item.name, + slug: item.slug, + totalEpisodes: '?', + expectedNew: 1, + exists: !!localMovies[item.slug], + skip: false, + skipReason: '' + }); + } + } + } + + return new Response(JSON.stringify({ success: true, count: slugsToCrawl.length, slugs: slugsToCrawl }), { + headers: { 'Content-Type': 'application/json' } + }); + } catch (err) { + return new Response(JSON.stringify({ error: err.message }), { status: 500, headers: { 'Content-Type': 'application/json' } }); + } +} diff --git a/src/pages/api/admin/search-online.js b/src/pages/api/admin/search-online.js new file mode 100644 index 0000000000000000000000000000000000000000..a8a75bef214ae5a2e7556a449b7ff9d5410c6eee --- /dev/null +++ b/src/pages/api/admin/search-online.js @@ -0,0 +1,96 @@ +import { getLocalMovies } from '../../../lib/localDb.js'; + +// Cấu hình timeout cho fetch +async function fetchWithTimeout(resource, options = {}) { + const { timeout = 8000 } = options; + const controller = new AbortController(); + const id = setTimeout(() => controller.abort(), timeout); + try { + const response = await fetch(resource, { + ...options, + signal: controller.signal + }); + return response; + } finally { + clearTimeout(id); + } +} + +export async function GET({ request }) { + // Check quyền admin từ cookie auth_token + const cookies = request.headers.get('cookie') || ''; + const hasToken = cookies.includes('auth_token='); + if (!hasToken) { + return new Response(JSON.stringify({ error: 'Unauthorized' }), { status: 401 }); + } + + const url = new URL(request.url); + const keyword = url.searchParams.get('keyword') || ''; + + if (!keyword.trim()) { + return new Response(JSON.stringify({ items: [], APP_DOMAIN_CDN_IMAGE: '' }), { + headers: { 'Content-Type': 'application/json' } + }); + } + + try { + // 1. Gọi API tìm kiếm trực tuyến của KKPhim + const kkRes = await fetchWithTimeout( + `https://phimapi.com/v1/api/tim-kiem?keyword=${encodeURIComponent(keyword)}&limit=40` + ); + if (!kkRes.ok) { + throw new Error(`API KKPhim trả về HTTP ${kkRes.status}`); + } + + const searchData = await kkRes.json(); + if (searchData.status !== 'success') { + throw new Error(searchData.message || 'Lỗi API KKPhim'); + } + + const items = searchData.data?.items || []; + const imageDomain = searchData.data?.APP_DOMAIN_CDN_IMAGE || 'https://phimimg.com'; + + // 2. Load phim cục bộ để đối chiếu + const localMovies = await getLocalMovies(); + + // 3. Map kết quả đối chiếu + const mappedItems = items.map(item => { + const existing = localMovies[item.slug]; + + let localEpCount = 0; + if (existing && Array.isArray(existing.episodes)) { + localEpCount = Math.max(...existing.episodes.map(s => s.server_data?.length || 0), 0); + } + + return { + name: item.name, + origin_name: item.origin_name, + slug: item.slug, + type: item.type, + thumb_url: item.thumb_url.startsWith('http') ? item.thumb_url : `${imageDomain}/${item.thumb_url}`, + poster_url: item.poster_url.startsWith('http') ? item.poster_url : `${imageDomain}/${item.poster_url}`, + year: item.year || 'N/A', + episode_current: item.episode_current || 'N/A', + exists: !!existing, + local_episode_count: localEpCount, + existing_status: existing ? (existing.movie.status || 'N/A') : null, + existing_episodes: existing && Array.isArray(existing.episodes) + ? existing.episodes.flatMap(s => s.server_data?.map(ep => ep.name) || []) + : [] + }; + }); + + return new Response(JSON.stringify({ + items: mappedItems, + APP_DOMAIN_CDN_IMAGE: imageDomain + }), { + headers: { 'Content-Type': 'application/json' } + }); + + } catch (err) { + return new Response(JSON.stringify({ error: err.message }), { + status: 500, + headers: { 'Content-Type': 'application/json' } + }); + } +} diff --git a/src/pages/api/admin/servers.js b/src/pages/api/admin/servers.js new file mode 100644 index 0000000000000000000000000000000000000000..3d453c9b8d9ba4897254525cd88c38ad9b448d87 --- /dev/null +++ b/src/pages/api/admin/servers.js @@ -0,0 +1,59 @@ +import { getServers, saveServer, deleteServer, bulkDeleteServers, syncFromMovies } from '../../../lib/localDb.js'; + +export async function GET({ request }) { + try { + const list = await getServers(); + return new Response(JSON.stringify(list)); + } catch (e) { + return new Response(JSON.stringify({ error: e.message }), { status: 500 }); + } +} + +export async function POST({ request }) { + const cookies = request.headers.get('cookie') || ''; + if (!cookies.includes('auth_token=')) { + return new Response(JSON.stringify({ error: 'Unauthorized' }), { status: 401 }); + } + + try { + const { name, originalName, sync } = await request.json(); + if (sync) { + const list = await syncFromMovies('servers'); + return new Response(JSON.stringify({ message: 'Đồng bộ danh sách máy chủ thành công!', list })); + } + + if (!name) { + return new Response(JSON.stringify({ error: 'Tên máy chủ không được để trống' }), { status: 400 }); + } + + const list = await saveServer(name, originalName); + return new Response(JSON.stringify({ message: 'Lưu máy chủ thành công!', list })); + } catch (e) { + return new Response(JSON.stringify({ error: e.message }), { status: 500 }); + } +} + +export async function DELETE({ request }) { + const cookies = request.headers.get('cookie') || ''; + if (!cookies.includes('auth_token=')) { + return new Response(JSON.stringify({ error: 'Unauthorized' }), { status: 401 }); + } + + try { + const { name, names } = await request.json(); + let list; + if (names && Array.isArray(names)) { + list = await bulkDeleteServers(names); + return new Response(JSON.stringify({ message: `Đã xóa hàng loạt ${names.length} máy chủ!`, list })); + } + + if (!name) { + return new Response(JSON.stringify({ error: 'Thiếu tên máy chủ để xóa' }), { status: 400 }); + } + + list = await deleteServer(name); + return new Response(JSON.stringify({ message: 'Xóa máy chủ thành công!', list })); + } catch (e) { + return new Response(JSON.stringify({ error: e.message }), { status: 500 }); + } +} diff --git a/src/pages/api/admin/settings.js b/src/pages/api/admin/settings.js new file mode 100644 index 0000000000000000000000000000000000000000..6154fea0a8e0a796895018a3ad8c2611fdff8324 --- /dev/null +++ b/src/pages/api/admin/settings.js @@ -0,0 +1,62 @@ +import { txasupabase } from '../../../lib/txasupabase.js'; + +export async function GET({ cookies }) { + const token = cookies.get('auth_token')?.value; + let user = null; + if (token) { + try { + user = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + } catch (e) {} + } + + if (!user || user.role !== 'admin') { + return new Response( + JSON.stringify({ error: 'Từ chối truy cập! Yêu cầu quyền quản trị viên.' }), + { status: 403, headers: { 'Content-Type': 'application/json' } } + ); + } + + try { + const settings = await txasupabase.getSettings(); + return new Response(JSON.stringify(settings), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } catch (error) { + return new Response(JSON.stringify({ error: 'Lỗi máy chủ: ' + error.message }), { + status: 500, + headers: { 'Content-Type': 'application/json' } + }); + } +} + +export async function POST({ request, cookies }) { + const token = cookies.get('auth_token')?.value; + let user = null; + if (token) { + try { + user = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + } catch (e) {} + } + + if (!user || user.role !== 'admin') { + return new Response( + JSON.stringify({ error: 'Từ chối truy cập! Yêu cầu quyền quản trị viên.' }), + { status: 403, headers: { 'Content-Type': 'application/json' } } + ); + } + + try { + const settingsObj = await request.json(); + await txasupabase.saveSettings(settingsObj); + return new Response(JSON.stringify({ message: 'Lưu cài đặt thành công!' }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } catch (error) { + return new Response(JSON.stringify({ error: 'Lỗi máy chủ: ' + error.message }), { + status: 500, + headers: { 'Content-Type': 'application/json' } + }); + } +} diff --git a/src/pages/api/admin/test-email.js b/src/pages/api/admin/test-email.js new file mode 100644 index 0000000000000000000000000000000000000000..aa69e4e173ef64831d738987b1b60ee2bfa59e7a --- /dev/null +++ b/src/pages/api/admin/test-email.js @@ -0,0 +1,56 @@ +import { txasupabase } from '../../../lib/txasupabase.js'; + +export async function POST({ request, cookies }) { + const token = cookies.get('auth_token')?.value; + let user = null; + if (token) { + try { + user = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + } catch (e) {} + } + + if (!user || user.role !== 'admin') { + return new Response( + JSON.stringify({ error: 'Từ chối truy cập! Yêu cầu quyền quản trị viên.' }), + { status: 403, headers: { 'Content-Type': 'application/json' } } + ); + } + + try { + const { toEmail, smtpOptions } = await request.json(); + + if (!toEmail) { + return new Response( + JSON.stringify({ error: 'Vui lòng nhập địa chỉ email nhận test!' }), + { status: 400, headers: { 'Content-Type': 'application/json' } } + ); + } + + // Gửi thư test bằng hàm sendMail sử dụng template test_email mới và cấu hình động chưa lưu + const res = await txasupabase.sendMail({ + to: toEmail, + subject: 'Thư điện tử thử nghiệm kết nối SMTP - TPHIMX', + templateName: 'test_email', + placeholders: { + username: 'Quản Trị Viên', + test_time: new Date().toLocaleString('vi-VN', { timeZone: 'Asia/Ho_Chi_Minh' }), + smtp_host: smtpOptions.smtp_host || 'smtp.gmail.com', + smtp_port: String(smtpOptions.smtp_port || 465), + smtp_secure: smtpOptions.smtp_secure || 'SSL', + smtp_user: smtpOptions.smtp_user || '' + }, + smtpConfigOverride: smtpOptions + }); + + return new Response(JSON.stringify({ message: 'Gửi email test thành công! Hãy kiểm tra hòm thư của bạn.', data: res }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } catch (error) { + console.error('[SMTP Test Error]:', error); + return new Response(JSON.stringify({ error: 'Gửi thất bại! Lỗi chi tiết: ' + error.message }), { + status: 500, + headers: { 'Content-Type': 'application/json' } + }); + } +} diff --git a/src/pages/api/auth/login.js b/src/pages/api/auth/login.js new file mode 100644 index 0000000000000000000000000000000000000000..803927456d6fad04454825f68ff24967a7efd992 --- /dev/null +++ b/src/pages/api/auth/login.js @@ -0,0 +1,59 @@ +import crypto from 'node:crypto'; +import { txasupabase } from '../../../lib/txasupabase.js'; + +export const POST = async ({ request, cookies }) => { + try { + const body = await request.json(); + const { identity, password } = body; + + // Kiểm tra dữ liệu rỗng đầu vào + if (!identity || !password) { + return new Response( + JSON.stringify({ error: 'Vui lòng điền đầy đủ tài khoản và mật khẩu nha!' }), + { status: 400, headers: { 'Content-Type': 'application/json' } } + ); + } + + // Mã hóa mật khẩu đầu vào bằng SHA-256 để so sánh + const hashedPassword = crypto.createHash('sha256').update(password).digest('hex'); + + // Tìm kiếm tài khoản trùng khớp (Username hoặc Email) + const { data: user, error } = await txasupabase.supabase + .from('users') + .select('*') + .or(`username.eq.${identity},email.eq.${identity}`) + .eq('password', hashedPassword) + .maybeSingle(); + + if (error || !user) { + return new Response( + JSON.stringify({ error: 'Tài khoản hoặc mật khẩu không chính xác rồi bạn ơi!' }), + { status: 401, headers: { 'Content-Type': 'application/json' } } + ); + } + + // Khởi tạo thông tin Session đơn giản (Mã hóa Base64) + const userData = { id: user.id, username: user.username, email: user.email, role: user.role, avatar_url: user.avatar_url }; + const token = Buffer.from(JSON.stringify(userData)).toString('base64'); + + // Thiết lập HTTP-Only Cookie đảm bảo an toàn bảo mật + cookies.set('auth_token', token, { + path: '/', + httpOnly: true, + secure: process.env.NODE_ENV === 'production', + sameSite: 'lax', + maxAge: 60 * 60 * 24 * 7 // Hiệu lực trong 1 tuần + }); + + return new Response( + JSON.stringify({ message: 'Đăng nhập thành công!', user: userData }), + { status: 200, headers: { 'Content-Type': 'application/json' } } + ); + } catch (error) { + console.error('[Auth Login Error]:', error); + return new Response( + JSON.stringify({ error: 'Gặp sự cố lỗi hệ thống khi đăng nhập!' }), + { status: 500, headers: { 'Content-Type': 'application/json' } } + ); + } +}; \ No newline at end of file diff --git a/src/pages/api/auth/logout.js b/src/pages/api/auth/logout.js new file mode 100644 index 0000000000000000000000000000000000000000..27bafed43327cb783e769357df83bbb356596f55 --- /dev/null +++ b/src/pages/api/auth/logout.js @@ -0,0 +1,7 @@ +export const POST = async ({ cookies }) => { + cookies.delete('auth_token', { path: '/' }); + return new Response(JSON.stringify({ message: 'Đăng xuất thành công!' }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); +}; diff --git a/src/pages/api/auth/me.js b/src/pages/api/auth/me.js new file mode 100644 index 0000000000000000000000000000000000000000..616a967f83ac2b3198c0ccc0d71d92c317ec9ce7 --- /dev/null +++ b/src/pages/api/auth/me.js @@ -0,0 +1,23 @@ +export const GET = async ({ cookies }) => { + const token = cookies.get('auth_token')?.value; + + if (!token) { + return new Response(JSON.stringify({ user: null }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } + + try { + const userData = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + return new Response(JSON.stringify({ user: userData }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } catch (err) { + return new Response(JSON.stringify({ user: null }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } +}; diff --git a/src/pages/api/auth/register.js b/src/pages/api/auth/register.js new file mode 100644 index 0000000000000000000000000000000000000000..e4b24fb77351bcea66ca8c5b37c53bc06992020e --- /dev/null +++ b/src/pages/api/auth/register.js @@ -0,0 +1,83 @@ +import crypto from 'node:crypto'; +import { txasupabase } from '../../../lib/txasupabase.js'; + +export const POST = async ({ request }) => { + try { + const body = await request.json(); + const { username, email, password, province, ward } = body; + + // Kiểm tra dữ liệu đầu vào phía Backend + if (!username || !email || !password) { + return new Response( + JSON.stringify({ error: 'Thiếu thông tin đăng ký bắt buộc!' }), + { status: 400, headers: { 'Content-Type': 'application/json' } } + ); + } + + // Kiểm tra miền email được phép + const allowedDomains = ['gmail.com', 'outlook.com', 'icloud.com', 'hotmail.com.vn']; + const emailDomain = email.split('@')[1]?.toLowerCase(); + if (!allowedDomains.includes(emailDomain)) { + return new Response( + JSON.stringify({ error: 'Chỉ chấp nhận đăng ký bằng các email thuộc: gmail.com, outlook.com, icloud.com, hotmail.com.vn!' }), + { status: 400, headers: { 'Content-Type': 'application/json' } } + ); + } + + // Kiểm tra trùng lặp tài khoản hoặc email trong hệ thống + const { data: existingUser, error: checkError } = await txasupabase.supabase + .from('users') + .select('username, email') + .or(`username.eq.${username},email.eq.${email}`) + .maybeSingle(); + + if (checkError) { + throw checkError; + } + + if (existingUser) { + if (existingUser.username.toLowerCase() === username.toLowerCase()) { + return new Response( + JSON.stringify({ error: 'Tên tài khoản này đã có người đăng ký rồi bạn ơi!' }), + { status: 400, headers: { 'Content-Type': 'application/json' } } + ); + } + if (existingUser.email.toLowerCase() === email.toLowerCase()) { + return new Response( + JSON.stringify({ error: 'Địa chỉ Email này đã tồn tại trên hệ thống!' }), + { status: 400, headers: { 'Content-Type': 'application/json' } } + ); + } + } + + // Tiến hành băm mật khẩu (Mã hóa SHA-256) + const hashedPassword = crypto.createHash('sha256').update(password).digest('hex'); + + // Khởi tạo Object cấu trúc User mới và lưu vào Supabase + const newUser = { + id: crypto.randomUUID(), + username, + email, + password: hashedPassword, + province: province || '', + ward: ward || '', + role: 'user', + favorites: [], + history: [], + createdAt: new Date().toISOString() + }; + + await txasupabase.saveUser(newUser); + + return new Response( + JSON.stringify({ message: 'Tạo tài khoản thành công!', user: { username, email } }), + { status: 201, headers: { 'Content-Type': 'application/json' } } + ); + } catch (error) { + console.error('[Auth Register Error]:', error); + return new Response( + JSON.stringify({ error: 'Gặp sự cố lỗi hệ thống khi đăng ký!' }), + { status: 500, headers: { 'Content-Type': 'application/json' } } + ); + } +}; \ No newline at end of file diff --git a/src/pages/api/movie/comments.js b/src/pages/api/movie/comments.js new file mode 100644 index 0000000000000000000000000000000000000000..96716466f07e7ec0892a9239f23f4cdc5501ab56 --- /dev/null +++ b/src/pages/api/movie/comments.js @@ -0,0 +1,402 @@ +import { txasupabase } from '../../../lib/txasupabase.js'; + +// 1. TẢI DANH SÁCH BÌNH LUẬN + DANH SÁCH BỊ CHẶN +export async function GET({ request, cookies }) { + const url = new URL(request.url); + const slug = url.searchParams.get('slug'); + + const token = cookies.get('auth_token')?.value; + let user = null; + if (token) { + try { + user = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + } catch (e) {} + } + + if (slug === 'all') { + if (!user || user.role !== 'admin') { + return new Response(JSON.stringify({ error: 'Bạn không có quyền truy cập dữ liệu này!' }), { + status: 403, + headers: { 'Content-Type': 'application/json' } + }); + } + } else if (!slug) { + return new Response(JSON.stringify({ error: 'Thiếu slug phim!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + try { + let query = txasupabase.supabase + .from('comments') + .select('*') + .order('created_at', { ascending: false }); + + if (slug !== 'all') { + query = query.eq('movie_slug', slug); + } + + const { data: comments, error } = await query; + + if (error) throw error; + + const bannedUsers = await txasupabase.getSetting('banned_commenters') || []; + + // Nạp thông tin hồ sơ người dùng (profile) phục vụ cho popup khi hover + const usernames = comments ? [...new Set(comments.map(c => c.username).filter(Boolean))] : []; + const userProfiles = {}; + + if (usernames.length > 0) { + // 1. Tải danh sách user (tỉnh, xã, phim yêu thích, avatar_url) + const { data: users } = await txasupabase.supabase + .from('users') + .select('username, province, ward, favorites, avatar_url') + .in('username', usernames); + + // 2. Tải số lượng bình luận của các user này trên toàn hệ thống + const { data: allUserComments } = await txasupabase.supabase + .from('comments') + .select('username') + .in('username', usernames); + + const userCommentsCounts = {}; + if (allUserComments) { + allUserComments.forEach(item => { + userCommentsCounts[item.username] = (userCommentsCounts[item.username] || 0) + 1; + }); + } + + if (users) { + users.forEach(u => { + userProfiles[u.username] = { + username: u.username, + province: u.province || '', + ward: u.ward || '', + avatar_url: u.avatar_url || '', + likesCount: Array.isArray(u.favorites) ? u.favorites.length : 0, + commentsCount: userCommentsCounts[u.username] || 0 + }; + }); + } + } + + // Nếu tải cho admin, lấy thêm tên các phim để map hiển thị + let movieMap = {}; + if (slug === 'all') { + const { data: dbMovies } = await txasupabase.supabase + .from('movies') + .select('slug, movie'); + if (dbMovies) { + dbMovies.forEach(m => { + movieMap[m.slug] = m.movie?.name || m.slug; + }); + } + } + + return new Response(JSON.stringify({ + comments: comments || [], + bannedUsers, + userProfiles, + movieMap + }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } catch (error) { + return new Response(JSON.stringify({ error: 'Lỗi tải bình luận: ' + error.message }), { + status: 500, + headers: { 'Content-Type': 'application/json' } + }); + } +} + +// 2. GỬI BÌNH LUẬN MỚI +export async function POST({ request, cookies }) { + // Kiểm tra đăng nhập + const token = cookies.get('auth_token')?.value; + let user = null; + if (token) { + try { + user = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + } catch (e) {} + } + + if (!user) { + return new Response(JSON.stringify({ error: 'Vui lòng đăng nhập trước khi bình luận!' }), { + status: 401, + headers: { 'Content-Type': 'application/json' } + }); + } + + try { + // Kiểm tra xem người dùng có bị Admin chặn bình luận không + const bannedUsers = await txasupabase.getSetting('banned_commenters') || []; + if (Array.isArray(bannedUsers) && bannedUsers.includes(user.username)) { + return new Response( + JSON.stringify({ error: 'Tài khoản của bạn đã bị quản trị viên chặn bình luận trên hệ thống!' }), + { status: 403, headers: { 'Content-Type': 'application/json' } } + ); + } + + const { movieSlug, content, isSpoiler, episodeName, serverName, movieType } = await request.json(); + + if (!movieSlug || !content) { + return new Response(JSON.stringify({ error: 'Thiếu thông tin bình luận!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + // Tự động làm sạch & chuẩn hóa tên tập phim trước khi lưu + let finalEpisodeName = null; + if (episodeName) { + const isSingle = movieType === 'single' || movieType === 'movie'; + if (isSingle) { + finalEpisodeName = 'Full'; + } else { + const numMatch = String(episodeName).match(/\d+/); + if (numMatch) { + const num = parseInt(numMatch[0], 10); + finalEpisodeName = `Tập ${num}`; + } else { + let cleaned = String(episodeName).trim().replace(/^tập\s*/i, ''); + finalEpisodeName = `Tập ${cleaned}`; + } + } + } + + const { data, error } = await txasupabase.supabase + .from('comments') + .insert({ + movie_slug: movieSlug, + username: user.username, + content: content.trim(), + is_spoiler: !!isSpoiler, + episode_name: finalEpisodeName, + server_name: serverName || null, + likes: [], + dislikes: [] + }) + .select(); + + if (error) throw error; + + return new Response(JSON.stringify({ message: 'Gửi bình luận thành công!', data: data?.[0] }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } catch (error) { + return new Response(JSON.stringify({ error: 'Lỗi gửi bình luận: ' + error.message }), { + status: 500, + headers: { 'Content-Type': 'application/json' } + }); + } +} + +// 3. TƯƠNG TÁC THÍCH / GHÉT & CẤM BÌNH LUẬN +export async function PUT({ request, cookies }) { + const token = cookies.get('auth_token')?.value; + let user = null; + if (token) { + try { + user = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + } catch (e) {} + } + + if (!user) { + return new Response(JSON.stringify({ error: 'Vui lòng đăng nhập!' }), { + status: 401, + headers: { 'Content-Type': 'application/json' } + }); + } + + try { + const body = await request.json(); + const { commentId, action } = body; + + if (!action) { + return new Response(JSON.stringify({ error: 'Thiếu hành động tương tác!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + // A. XỬ LÝ ADMIN CẤM / MỞ CHẶN NGƯỜI DÙNG + if (action === 'ban' || action === 'unban') { + if (user.role !== 'admin') { + return new Response(JSON.stringify({ error: 'Bạn không có quyền quản trị để thực hiện!' }), { + status: 403, + headers: { 'Content-Type': 'application/json' } + }); + } + + const { targetUsername } = body; + if (!targetUsername) { + return new Response(JSON.stringify({ error: 'Thiếu tên tài khoản cần xử lý!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + let bannedUsers = await txasupabase.getSetting('banned_commenters') || []; + if (!Array.isArray(bannedUsers)) bannedUsers = []; + + if (action === 'ban') { + if (!bannedUsers.includes(targetUsername)) { + bannedUsers.push(targetUsername); + } + } else { + bannedUsers = bannedUsers.filter(u => u !== targetUsername); + } + + await txasupabase.saveSetting('banned_commenters', bannedUsers); + + return new Response(JSON.stringify({ + message: action === 'ban' ? `Đã chặn bình luận của @${targetUsername} thành công!` : `Đã mở chặn bình luận cho @${targetUsername}!`, + bannedUsers + }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } + + // B. XỬ LÝ THÍCH / GHÉT BÌNH LUẬN + if (!commentId || !['like', 'dislike'].includes(action)) { + return new Response(JSON.stringify({ error: 'Hành động không hợp lệ!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + const { data: comment, error: fetchError } = await txasupabase.supabase + .from('comments') + .select('*') + .eq('id', commentId) + .maybeSingle(); + + if (fetchError || !comment) { + return new Response(JSON.stringify({ error: 'Bình luận không tồn tại!' }), { + status: 404, + headers: { 'Content-Type': 'application/json' } + }); + } + + let likes = comment.likes || []; + let dislikes = comment.dislikes || []; + const username = user.username; + + if (action === 'like') { + if (likes.includes(username)) { + // Tắt like + likes = likes.filter(u => u !== username); + } else { + // Bật like, tắt dislike + likes.push(username); + dislikes = dislikes.filter(u => u !== username); + } + } else if (action === 'dislike') { + if (dislikes.includes(username)) { + // Tắt dislike + dislikes = dislikes.filter(u => u !== username); + } else { + // Bật dislike, tắt like + dislikes.push(username); + likes = likes.filter(u => u !== username); + } + } + + const { data: updatedComment, error: updateError } = await txasupabase.supabase + .from('comments') + .update({ likes, dislikes }) + .eq('id', commentId) + .select() + .single(); + + if (updateError) throw updateError; + + return new Response(JSON.stringify({ + message: 'Tương tác thành công!', + likesCount: updatedComment.likes?.length || 0, + dislikesCount: updatedComment.dislikes?.length || 0, + likes: updatedComment.likes || [], + dislikes: updatedComment.dislikes || [] + }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } catch (error) { + return new Response(JSON.stringify({ error: 'Lỗi xử lý tương tác: ' + error.message }), { + status: 500, + headers: { 'Content-Type': 'application/json' } + }); + } +} + +// 4. XÓA BÌNH LUẬN +export async function DELETE({ request, cookies }) { + const token = cookies.get('auth_token')?.value; + let user = null; + if (token) { + try { + user = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + } catch (e) {} + } + + if (!user) { + return new Response(JSON.stringify({ error: 'Vui lòng đăng nhập!' }), { + status: 401, + headers: { 'Content-Type': 'application/json' } + }); + } + + try { + const { commentId } = await request.json(); + + if (!commentId) { + return new Response(JSON.stringify({ error: 'Thiếu ID bình luận cần xóa!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + // Lấy thông tin bình luận + const { data: comment, error: fetchError } = await txasupabase.supabase + .from('comments') + .select('*') + .eq('id', commentId) + .maybeSingle(); + + if (fetchError || !comment) { + return new Response(JSON.stringify({ error: 'Bình luận không tồn tại!' }), { + status: 404, + headers: { 'Content-Type': 'application/json' } + }); + } + + // Kiểm tra quyền xóa: Phải là chủ nhân bình luận hoặc là Admin + if (comment.username !== user.username && user.role !== 'admin') { + return new Response(JSON.stringify({ error: 'Bạn không có quyền xóa bình luận này!' }), { + status: 403, + headers: { 'Content-Type': 'application/json' } + }); + } + + const { error: deleteError = null } = await txasupabase.supabase + .from('comments') + .delete() + .eq('id', commentId); + + if (deleteError) throw deleteError; + + return new Response(JSON.stringify({ message: 'Xóa bình luận thành công!' }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } catch (error) { + return new Response(JSON.stringify({ error: 'Lỗi xóa bình luận: ' + error.message }), { + status: 500, + headers: { 'Content-Type': 'application/json' } + }); + } +} diff --git a/src/pages/api/movie/rate.js b/src/pages/api/movie/rate.js new file mode 100644 index 0000000000000000000000000000000000000000..a3653b2c2d1f4e9999d4d64e631e60bc6aba6953 --- /dev/null +++ b/src/pages/api/movie/rate.js @@ -0,0 +1,68 @@ +import { txasupabase } from '../../../lib/txasupabase.js'; + +export const POST = async ({ request, cookies }) => { + const token = cookies.get('auth_token')?.value; + if (!token) return new Response(JSON.stringify({ error: 'Bạn cần đăng nhập để đánh giá!' }), { status: 401 }); + + // Lấy địa chỉ IP của người dùng + const ip = request.headers.get('x-forwarded-for') || request.headers.get('cf-connecting-ip') || '127.0.0.1'; + + try { + const { movieSlug, score } = await request.json(); + const userData = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + + if (score < 1 || score > 10) return new Response(JSON.stringify({ error: 'Điểm không hợp lệ!' }), { status: 400 }); + + const ratingObj = await txasupabase.getRatingBySlug(movieSlug); + + let totalScore = ratingObj ? Number(ratingObj.total_score) : 0; + let count = ratingObj ? ratingObj.count : 0; + let userRatings = ratingObj ? ratingObj.user_ratings : {}; + let ipRatings = ratingObj ? ratingObj.ip_ratings : {}; + + // Giới hạn 1 người / 1 phim duy nhất + if (userRatings[userData.username]) { + return new Response(JSON.stringify({ error: 'Bạn đã đánh giá bộ phim này rồi! Mỗi thành viên chỉ được đánh giá một lần.' }), { status: 403 }); + } + + // Kiểm tra xem IP đã được đánh giá chưa + if (ipRatings[ip]) { + return new Response(JSON.stringify({ error: 'Mỗi địa chỉ IP chỉ được đánh giá phim này một lần!' }), { status: 403 }); + } + + totalScore += score; + count += 1; + + userRatings[userData.username] = score; + ipRatings[ip] = score; + + await txasupabase.saveRating(movieSlug, count, totalScore, userRatings, ipRatings); + + return new Response(JSON.stringify({ + message: 'Cảm ơn bạn đã đánh giá!', + average: totalScore / count, + count: count + }), { status: 200 }); + } catch (err) { + console.error('[Rate POST Error]:', err); + return new Response(JSON.stringify({ error: 'Lỗi hệ thống!' }), { status: 500 }); + } +}; + +export const GET = async ({ url }) => { + const movieSlug = new URL(url).searchParams.get('slug'); + if (!movieSlug) return new Response(JSON.stringify({ average: 0, count: 0 }), { status: 200 }); + + try { + const ratingObj = await txasupabase.getRatingBySlug(movieSlug); + if (!ratingObj || ratingObj.count === 0) return new Response(JSON.stringify({ average: 0, count: 0 }), { status: 200 }); + + return new Response(JSON.stringify({ + average: ratingObj.total_score / ratingObj.count, + count: ratingObj.count + }), { status: 200 }); + } catch (err) { + console.error('[Rate GET Error]:', err); + return new Response(JSON.stringify({ average: 0, count: 0 }), { status: 200 }); + } +}; diff --git a/src/pages/api/movie/search.js b/src/pages/api/movie/search.js new file mode 100644 index 0000000000000000000000000000000000000000..a54df7bd98d6c7bea8fb1fd09d72b8c3e1985ff5 --- /dev/null +++ b/src/pages/api/movie/search.js @@ -0,0 +1,29 @@ +import { searchMovies } from '../../../lib/api.js'; + +export const GET = async ({ url }) => { + const q = url.searchParams.get('q') || ''; + const page = parseInt(url.searchParams.get('page') || '1'); + + if (!q) { + return new Response(JSON.stringify({ items: [], pagination: { totalItems: 0, currentPage: page, totalPages: 1 } }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } + + try { + const data = await searchMovies(q, page); + return new Response(JSON.stringify({ + items: data.items || [], + pagination: data.pagination || { totalItems: data.items?.length || 0, currentPage: page, totalPages: 1 } + }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } catch (err) { + return new Response(JSON.stringify({ error: 'Failed to search movies', items: [], pagination: { totalItems: 0, currentPage: page, totalPages: 1 } }), { + status: 500, + headers: { 'Content-Type': 'application/json' } + }); + } +}; diff --git a/src/pages/api/movies.js b/src/pages/api/movies.js new file mode 100644 index 0000000000000000000000000000000000000000..f4a4c2df69e644c977e37a89e2d44ac140e1da03 --- /dev/null +++ b/src/pages/api/movies.js @@ -0,0 +1,142 @@ +import { + getNewestMovies, + getSeriesMovies, + getSingleMovies, + getCartoonMovies, + getMoviesByCategory, + getMoviesByCountry, + getMoviesByTopic +} from '../../lib/api.js'; + +const fetchWithTimeout = async (url, options = {}) => { + const { timeout = 5000 } = options; + const controller = new AbortController(); + const id = setTimeout(() => controller.abort(), timeout); + try { + const response = await fetch(url, { ...options, signal: controller.signal }); + clearTimeout(id); + return response; + } catch (e) { + clearTimeout(id); + throw e; + } +}; + +export const GET = async ({ url }) => { + const type = url.searchParams.get('type') || ''; + const category = url.searchParams.get('category') || ''; + const country = url.searchParams.get('country') || ''; + const topic = url.searchParams.get('topic') || ''; + const keyword = url.searchParams.get('keyword') || url.searchParams.get('q') || ''; + const page = parseInt(url.searchParams.get('page') || '1'); + + try { + let result = { items: [] }; + + if (keyword) { + result = await import('../../lib/api.js').then(m => m.searchMovies(keyword, page)); + } else if (topic) { + result = await getMoviesByTopic(topic, page); + } else if (country) { + result = await getMoviesByCountry(country, page); + } else if (category) { + if (category === 'phim-moi-cap-nhat') { + result = await getNewestMovies(page); + } else { + result = await getMoviesByCategory(category, page); + } + } else if (type === 'newest') { + result = await getNewestMovies(page); + } else if (type === 'series') { + result = await getSeriesMovies(page); + } else if (type === 'single') { + result = await getSingleMovies(page); + } else if (type === 'cartoon') { + result = await getCartoonMovies(page); + } + + // FALLBACK SYSTEM: If less than 4 movies in local DB, fetch from public KKPhim API! + if (!result.items || result.items.length < 4) { + try { + let fallbackUrl = ''; + if (country) { + fallbackUrl = `https://phimapi.com/v1/api/quoc-gia/${country}?page=${page}`; + } else if (category) { + const defaultTypes = { + 'phim-bo': 'phim-bo', + 'phim-le': 'phim-le', + 'hoat-hinh': 'hoat-hinh', + 'tv-shows': 'tv-shows' + }; + if (defaultTypes[category]) { + fallbackUrl = `https://phimapi.com/v1/api/danh-sach/${defaultTypes[category]}?page=${page}`; + } else if (category === 'phim-chieu-rap') { + fallbackUrl = `https://phimapi.com/v1/api/the-loai/hanh-dong?page=${page}`; + } else { + fallbackUrl = `https://phimapi.com/v1/api/the-loai/${category}?page=${page}`; + } + } else if (type === 'newest') { + fallbackUrl = `https://phimapi.com/danh-sach/phim-moi-cap-nhat?page=${page}`; + } else if (type === 'series') { + fallbackUrl = `https://phimapi.com/v1/api/danh-sach/phim-bo?page=${page}`; + } else if (type === 'single') { + fallbackUrl = `https://phimapi.com/v1/api/danh-sach/phim-le?page=${page}`; + } else if (type === 'cartoon') { + fallbackUrl = `https://phimapi.com/v1/api/danh-sach/hoat-hinh?page=${page}`; + } + + if (fallbackUrl) { + const res = await fetchWithTimeout(fallbackUrl); + if (res.ok) { + const data = await res.json(); + let items = []; + if (fallbackUrl.includes('danh-sach/phim-moi-cap-nhat')) { + items = data.items || []; + } else if (data.data && data.data.items) { + items = data.data.items || []; + } + + const mapped = items.map(item => ({ + _id: item._id, + name: item.name, + slug: item.slug, + origin_name: item.origin_name, + thumb_url: item.thumb_url, + poster_url: item.poster_url, + year: item.year, + quality: item.quality || 'FHD', + lang: item.lang || 'Vietsub', + episode_current: item.episode_current || 'Tập 1', + type: item.type || 'single', + isLocal: false + })); + + const localItems = result.items || []; + const mergedItems = [...localItems]; + + for (const item of mapped) { + if (!mergedItems.some(x => x.slug === item.slug)) { + mergedItems.push(item); + } + } + + result.items = mergedItems.slice(0, 12); + } + } + } catch (err) { + console.error('[API FALLBACK ERROR]', err); + } + } + + return new Response(JSON.stringify(result), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } catch (err) { + console.error('Error fetching movies API:', err); + return new Response(JSON.stringify({ error: err.message, items: [] }), { + status: 500, + headers: { 'Content-Type': 'application/json' } + }); + } +}; diff --git a/src/pages/api/player/report-error.js b/src/pages/api/player/report-error.js new file mode 100644 index 0000000000000000000000000000000000000000..fae92cedaa611cc7da8aed9adf732b3686566f76 --- /dev/null +++ b/src/pages/api/player/report-error.js @@ -0,0 +1,222 @@ +import { txasupabase } from '../../../lib/txasupabase.js'; + +// Decryption Helper for Browser Token +function decryptToken(token, key) { + if (!token || !token.startsWith('tk_')) return null; + try { + const rawToken = token.substring(3); + let str = rawToken.replace(/-/g, '+').replace(/_/g, '/'); + while (str.length % 4) str += '='; + + // Decode base64 to binary string + const text = Buffer.from(str, 'base64').toString('binary'); + + let utf8Text = ''; + for (let i = 0; i < text.length; i++) { + const charCode = text.charCodeAt(i); + const keyChar = key.charCodeAt(i % key.length); + const decryptedChar = charCode ^ keyChar; + utf8Text += String.fromCharCode(decryptedChar); + } + + return decodeURIComponent(escape(utf8Text)); + } catch (e) { + console.error('[Telemetry] Decryption failed:', e); + return null; + } +} + +// User-Agent Parser for Device & Browser +function parseUserAgent(ua) { + let device = 'Thiết bị khác'; + let browser = 'Trình duyệt khác'; + + if (!ua) return { device, browser }; + + // OS / Device detection + if (ua.includes('Windows NT 10.0')) { + device = 'Windows 10/11'; + } else if (ua.includes('Windows NT 6.1')) { + device = 'Windows 7'; + } else if (ua.includes('Windows NT 6.2') || ua.includes('Windows NT 6.3')) { + device = 'Windows 8/8.1'; + } else if (ua.includes('Android')) { + const androidMatch = ua.match(/Android\s+([^;)]+)/); + const modelMatch = ua.match(/Android\s+[^;]+;\s+([^;)]+)/); + const deviceName = modelMatch ? modelMatch[1].trim() : (androidMatch ? androidMatch[0] : 'Android Device'); + device = `Android (${deviceName})`; + } else if (ua.includes('iPhone')) { + const iphoneMatch = ua.match(/iPhone;\s+CPU\s+iPhone\s+OS\s+([^;)]+)/); + const osVer = iphoneMatch ? iphoneMatch[1].replace(/_/g, '.') : ''; + device = osVer ? `iPhone (iOS ${osVer})` : 'iPhone'; + } else if (ua.includes('iPad')) { + device = 'iPad'; + } else if (ua.includes('Macintosh') || ua.includes('Mac OS X')) { + device = 'macOS'; + } else if (ua.includes('Linux')) { + device = 'Linux'; + } + + // Browser detection + if (ua.includes('Edg/')) { + browser = 'Microsoft Edge'; + } else if (ua.includes('Chrome/') && !ua.includes('Chromium')) { + browser = 'Google Chrome'; + } else if (ua.includes('Safari/') && !ua.includes('Chrome')) { + browser = 'Safari'; + } else if (ua.includes('Firefox/')) { + browser = 'Mozilla Firefox'; + } else if (ua.includes('OPR/') || ua.includes('Opera/')) { + browser = 'Opera'; + } else if (ua.includes('Zalo/')) { + browser = 'Zalo Browser'; + } + + return { device, browser }; +} + +export const POST = async ({ request }) => { + try { + const body = await request.json(); + const { movie_slug, movie_name, episode_name, error_type, error_message, error_details, browser_token } = body; + + if (!error_type) { + return new Response(JSON.stringify({ error: 'Error type is required!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + const userAgent = request.headers.get('user-agent') || ''; + const fallbackIp = request.headers.get('cf-connecting-ip') || + request.headers.get('x-real-ip') || + request.headers.get('x-forwarded-for')?.split(',')[0].trim() || + '127.0.0.1'; + + // Decrypt and parse browser, IP, location & device details + let decryptedInfo = null; + let parsedDevice = 'Không rõ'; + let parsedBrowser = 'Không rõ'; + let parsedIp = fallbackIp; + let parsedLocation = null; + + if (browser_token) { + if (browser_token.startsWith('tk_')) { + decryptedInfo = decryptToken(browser_token, 'phimtxadinhvaikk'); + if (decryptedInfo) { + const parts = decryptedInfo.split(' - '); + const ua = parts[0] || ''; + + // Get IP from token + const ipPart = parts.find(p => p.startsWith('IP: ')); + if (ipPart) { + parsedIp = ipPart.replace('IP: ', ''); + } + + // Get Location from token + const locParts = parts.filter(p => !p.startsWith('IP: ') && p !== ua); + if (locParts.length > 0) { + parsedLocation = locParts.join(', '); + } + + // Parse UA from token + const parsed = parseUserAgent(ua); + parsedDevice = parsed.device; + parsedBrowser = parsed.browser; + } else { + // Decryption failed but we still have request UA + const parsed = parseUserAgent(userAgent); + parsedDevice = parsed.device; + parsedBrowser = parsed.browser; + } + } else if (browser_token.startsWith('txanot-')) { + // Fallback token format: txanot-[ip]-[uaHash] + const parts = browser_token.split('-'); + if (parts[1]) { + parsedIp = parts[1]; + } + const parsed = parseUserAgent(userAgent); + parsedDevice = parsed.device; + parsedBrowser = parsed.browser; + } + } else { + // No token provided, fallback to request headers + const parsed = parseUserAgent(userAgent); + parsedDevice = parsed.device; + parsedBrowser = parsed.browser; + } + + const enrichedDetails = { + ...(error_details || {}), + parsed_device: parsedDevice, + parsed_browser: parsedBrowser, + parsed_ip: parsedIp, + parsed_location: parsedLocation, + decrypted_raw: decryptedInfo + }; + + // Insert into txa_player_errors + const { data, error } = await txasupabase.client + .from('txa_player_errors') + .insert({ + movie_slug: movie_slug || null, + movie_name: movie_name || null, + episode_name: episode_name || null, + error_type, + error_message: error_message || null, + error_details: enrichedDetails, + user_agent: userAgent, + ip: parsedIp, + browser_token: browser_token || null + }) + .select() + .single(); + + if (error) { + console.error('Error inserting player error into Supabase:', error); + return new Response(JSON.stringify({ error: error.message }), { + status: 500, + headers: { 'Content-Type': 'application/json' } + }); + } + + // Write a unified system log featuring decrypted info + const locationStr = parsedLocation ? ` (${parsedLocation})` : ''; + const logMessage = `Lỗi Player (${error_type}) trên phim "${movie_name || 'Không rõ'}" (${episode_name || 'Không rõ'}): ${error_message || ''}. Thiết bị: ${parsedDevice} | Trình duyệt: ${parsedBrowser} | IP: ${parsedIp}${locationStr}`; + + try { + if (typeof txasupabase.createLog === 'function') { + await txasupabase.createLog( + 'player_error', + 'error', + logMessage, + { movie_slug, movie_name, episode_name, error_type, error_message, ip: parsedIp, browser_token, parsed_device: parsedDevice, parsed_browser: parsedBrowser } + ); + } else { + await txasupabase.client.from('logs').insert({ + action: 'player_error', + level: 'error', + message: logMessage, + details: JSON.stringify({ movie_slug, movie_name, episode_name, error_type, error_message, ip: parsedIp, browser_token, parsed_device: parsedDevice, parsed_browser: parsedBrowser }) + }); + } + } catch (logErr) { + console.error('Failed to write to logs table:', logErr); + } + + return new Response(JSON.stringify({ + success: true, + message: 'Player error reported successfully.', + data + }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } catch (err) { + console.error('Error in report-error API:', err); + return new Response(JSON.stringify({ error: 'Internal system error!' }), { + status: 500, + headers: { 'Content-Type': 'application/json' } + }); + } +}; diff --git a/src/pages/api/proxy-media.js b/src/pages/api/proxy-media.js new file mode 100644 index 0000000000000000000000000000000000000000..95f27c938a89b60308ecf771e8efe7650d303854 --- /dev/null +++ b/src/pages/api/proxy-media.js @@ -0,0 +1,148 @@ +export const OPTIONS = async () => { + return new Response(null, { + status: 204, + headers: { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Methods': 'GET, OPTIONS', + 'Access-Control-Allow-Headers': 'Content-Type, Range', + 'Access-Control-Max-Age': '86400', + }, + }); +}; + +export const GET = async ({ request, url }) => { + const targetUrl = url.searchParams.get('url'); + + if (!targetUrl) { + return new Response(JSON.stringify({ error: 'Missing target URL' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + try { + const headers = new Headers(); + // Use the origin of the target URL as the referer to bypass simple checks + const targetOrigin = new URL(targetUrl).origin; + headers.set('Referer', targetOrigin + '/'); + headers.set('Origin', targetOrigin); + headers.set('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'); + + // Forward Range header for smooth scrubbing/seeking (HTTP 206 Partial Content support) + const rangeHeader = request.headers.get('Range') || request.headers.get('range'); + if (rangeHeader) { + headers.set('Range', rangeHeader); + } + + const response = await fetch(targetUrl, { headers }); + + if (!response.ok) { + // If it's an image and it's not found, return a transparent 1x1 pixel + // This prevents the player from retrying and avoids broken image icons in the UI + const isImage = targetUrl.match(/\.(jpg|jpeg|png|gif|webp|svg)(\?.*)?$/i) || + targetUrl.toLowerCase().includes('preview.jpg') || + targetUrl.toLowerCase().includes('thumb.jpg'); + + if (isImage && response.status === 404) { + // 1x1 transparent GIF + const transparentPixel = Buffer.from('R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7', 'base64'); + return new Response(transparentPixel, { + status: 200, + headers: { + 'Content-Type': 'image/gif', + 'Access-Control-Allow-Origin': '*', + 'Cache-Control': 'public, max-age=86400' + } + }); + } + + console.warn(`[Proxy] Failed to fetch ${targetUrl}: ${response.status} ${response.statusText}`); + return new Response(null, { status: response.status }); + } + + const contentType = response.headers.get('Content-Type') || ''; + + // If it's a playlist (m3u8), we might need to rewrite relative paths to absolute ones + // so that the player doesn't try to load them relative to the proxy URL. + if (contentType.includes('mpegurl') || contentType.includes('x-mpegURL') || targetUrl.endsWith('.m3u8')) { + let text = await response.text(); + const urlObj = new URL(targetUrl); + const baseUrl = targetUrl.substring(0, targetUrl.lastIndexOf('/') + 1); + + // Rewrite relative paths to absolute URLs pointing back to the proxy + // This ensures that all segments also go through the proxy to bypass CORS + const proxiedText = text.split('\n').map(line => { + const trimmed = line.trim(); + if (!trimmed) return line; + + // If it is a tag/comment line + if (trimmed.startsWith('#')) { + // Check for URI attribute in EXT tags (like EXT-X-KEY, EXT-X-MAP, EXT-X-MEDIA) + if (trimmed.includes('URI=')) { + return trimmed.replace(/URI=(["'])([^"'\r\n]+)\1/g, (match, quote, p1) => { + let absolutePath = p1; + if (!p1.startsWith('http')) { + absolutePath = p1.startsWith('/') + ? urlObj.origin + p1 + : baseUrl + p1; + } + return `URI=${quote}/api/proxy-media?url=${encodeURIComponent(absolutePath)}${quote}`; + }); + } + return line; + } + + // If it is a segment URL (non-tag line) + // If it's already an absolute URL, wrap it in proxy + if (trimmed.startsWith('http')) { + return `/api/proxy-media?url=${encodeURIComponent(trimmed)}`; + } + // If it's a relative path, make it absolute and wrap it + const absolutePath = trimmed.startsWith('/') + ? urlObj.origin + trimmed + : baseUrl + trimmed; + return `/api/proxy-media?url=${encodeURIComponent(absolutePath)}`; + }).join('\n'); + + return new Response(proxiedText, { + status: 200, + headers: { + 'Content-Type': 'application/x-mpegURL', + 'Access-Control-Allow-Origin': '*', + 'Cache-Control': 'no-cache' + } + }); + } + + // For other media (images, segments), stream the response directly to the browser + // This achieves zero-latency start and supports seeking (206 Partial Content) + const status = response.status; + const responseHeaders = new Headers({ + 'Content-Type': contentType, + 'Access-Control-Allow-Origin': '*', + 'Cache-Control': 'public, max-age=3600' + }); + + // Copy Range-related headers from destination response if they exist + const contentRange = response.headers.get('Content-Range') || response.headers.get('content-range'); + if (contentRange) { + responseHeaders.set('Content-Range', contentRange); + } + const contentLength = response.headers.get('Content-Length') || response.headers.get('content-length'); + if (contentLength) { + responseHeaders.set('Content-Length', contentLength); + } + const acceptRanges = response.headers.get('Accept-Ranges') || response.headers.get('accept-ranges'); + if (acceptRanges) { + responseHeaders.set('Accept-Ranges', acceptRanges); + } + + return new Response(response.body, { + status: status, + headers: responseHeaders + }); + } catch (error) { + console.error(`[Proxy] Error:`, error); + return new Response(null, { status: 500 }); + } +}; diff --git a/src/pages/api/report.js b/src/pages/api/report.js new file mode 100644 index 0000000000000000000000000000000000000000..5c96f1412f66d091bf2e107ab066a2753909b8fb --- /dev/null +++ b/src/pages/api/report.js @@ -0,0 +1,92 @@ +import { txasupabase } from '../../lib/txasupabase.js'; + +export const POST = async ({ request }) => { + try { + const body = await request.json(); + const { movie_slug, movie_name, episode_name, error_type, description } = body; + + if (!error_type) { + return new Response(JSON.stringify({ error: 'Vui lòng chọn loại lỗi!' }), { + status: 400, + headers: { 'Content-Type': 'application/json' } + }); + } + + // 1. Lưu báo cáo lỗi vào cơ sở dữ liệu + const report = await txasupabase.createReport( + movie_slug || '', + movie_name || '', + episode_name || '', + error_type, + description || '' + ); + + // 2. Ghi lại log hoạt động + await txasupabase.createLog( + 'bug_report', + 'warn', + `Báo cáo lỗi phim "${movie_name || 'Không rõ'}" (${episode_name || 'Không rõ'}): ${error_type}`, + { movie_slug, movie_name, episode_name, error_type, description } + ); + + // 3. Gửi email thông báo cho Admin + try { + const settings = await txasupabase.getSettings(); + + // Tìm email Admin nhận thông báo + let adminEmail = settings.admin_email || settings.smtp_user; + if (!adminEmail) { + const { data: adminUsers } = await txasupabase.supabase + .from('users') + .select('email') + .eq('role', 'admin') + .limit(1); + if (adminUsers && adminUsers.length > 0) { + adminEmail = adminUsers[0].email; + } + } + + if (adminEmail && settings.smtp_user && settings.smtp_pass) { + const siteUrl = settings.site_url || 'http://localhost:4321'; + const adminUrl = `${siteUrl}/admin/bao-cao-loi`; // URL trang quản lý lỗi của admin + + await txasupabase.sendMail({ + to: adminEmail, + subject: `[TPHIMX - BÁO CÁO LỖI PHIM]: Phim "${movie_name || 'Không rõ'}" bị lỗi ${error_type}`, + templateName: 'bug_report', + placeholders: { + movie_name: movie_name || 'Không rõ', + episode_name: episode_name || 'Không rõ', + error_type, + description: description || 'Người dùng không để lại mô tả bổ sung.', + admin_url: adminUrl + } + }); + } else { + console.log('[Report API]: SMTP not configured or Admin email missing, skipped email notification.'); + } + } catch (mailErr) { + console.error('[Report Mail Error]:', mailErr); + await txasupabase.createLog( + 'bug_report_mail_failed', + 'warn', + `Lỗi gửi mail báo cáo lỗi cho phim "${movie_name || 'Không rõ'}": ${mailErr.message}` + ); + } + + return new Response(JSON.stringify({ + success: true, + message: 'Cảm ơn bạn đã báo cáo lỗi! Admin sẽ kiểm tra và khắc phục sớm nhất.', + data: report + }), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); + } catch (err) { + console.error('Error handling report API:', err); + return new Response(JSON.stringify({ error: 'Có lỗi xảy ra trên hệ thống!' }), { + status: 500, + headers: { 'Content-Type': 'application/json' } + }); + } +}; diff --git a/src/pages/api/user/favorite.js b/src/pages/api/user/favorite.js new file mode 100644 index 0000000000000000000000000000000000000000..d3293dc6bde34fcb149e8fd4c50eb5a253874b57 --- /dev/null +++ b/src/pages/api/user/favorite.js @@ -0,0 +1,52 @@ +import { txasupabase } from '../../../lib/txasupabase.js'; + +export const POST = async ({ request, cookies }) => { + const token = cookies.get('auth_token')?.value; + if (!token) return new Response(JSON.stringify({ error: 'Bạn cần đăng nhập để thực hiện!' }), { status: 401 }); + + try { + const { movieSlug, movieName, movieThumb } = await request.json(); + const userData = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + + // Tìm người dùng trên Supabase dựa vào ID + const user = await txasupabase.getUserById(userData.id); + if (!user) return new Response(JSON.stringify({ error: 'Không tìm thấy người dùng!' }), { status: 404 }); + + const favorites = user.favorites || []; + const favIndex = favorites.findIndex(f => f.slug === movieSlug); + let action = ''; + + if (favIndex === -1) { + favorites.push({ slug: movieSlug, name: movieName, thumb: movieThumb, addedAt: new Date().toISOString() }); + action = 'added'; + } else { + favorites.splice(favIndex, 1); + action = 'removed'; + } + + // Cập nhật lại thông tin phim yêu thích lên Supabase + await txasupabase.saveUser({ + ...user, + favorites + }); + + return new Response(JSON.stringify({ message: action === 'added' ? 'Đã thêm vào yêu thích!' : 'Đã xóa khỏi yêu thích!', action }), { status: 200 }); + } catch (err) { + console.error('[Favorite POST Error]:', err); + return new Response(JSON.stringify({ error: 'Lỗi hệ thống!' }), { status: 500 }); + } +}; + +export const GET = async ({ url, cookies }) => { + const token = cookies.get('auth_token')?.value; + if (!token) return new Response(JSON.stringify({ favorites: [] }), { status: 200 }); + + try { + const userData = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + const user = await txasupabase.getUserById(userData.id); + return new Response(JSON.stringify({ favorites: user?.favorites || [] }), { status: 200 }); + } catch (err) { + console.error('[Favorite GET Error]:', err); + return new Response(JSON.stringify({ favorites: [] }), { status: 200 }); + } +}; diff --git a/src/pages/api/user/history.js b/src/pages/api/user/history.js new file mode 100644 index 0000000000000000000000000000000000000000..6bbc4987898d9e646a8e7c93c3183529a8bb4dbd --- /dev/null +++ b/src/pages/api/user/history.js @@ -0,0 +1,114 @@ +import { txasupabase } from '../../../lib/txasupabase.js'; + +export const POST = async ({ request, cookies }) => { + const token = cookies.get('auth_token')?.value; + if (!token) return new Response(JSON.stringify({ error: 'Chưa đăng nhập' }), { status: 401 }); + + try { + const { movieSlug, movieName, movieThumb, episodeName, currentTime, duration } = await request.json(); + const userData = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + + // Tìm người dùng trên Supabase dựa vào ID + const user = await txasupabase.getUserById(userData.id); + if (!user) return new Response(JSON.stringify({ error: 'User not found' }), { status: 404 }); + + const history = user.history || []; + + // Xóa mục lịch sử cũ của phim này nếu đã có để đưa lên đầu danh sách + const historyIndex = history.findIndex(h => h.slug === movieSlug); + if (historyIndex !== -1) { + history.splice(historyIndex, 1); + } + + // Thêm lịch sử xem phim mới lên đầu mảng + history.unshift({ + slug: movieSlug, + name: movieName, + thumb: movieThumb, + episode: episodeName, + currentTime: currentTime || 0, + duration: duration || 0, + watchedAt: new Date().toISOString() + }); + + // Giới hạn tối đa 50 lượt xem phim gần nhất + const limitedHistory = history.slice(0, 50); + + // Cập nhật lại lịch sử xem phim lên Supabase + await txasupabase.saveUser({ + ...user, + history: limitedHistory + }); + + return new Response(JSON.stringify({ success: true }), { status: 200 }); + } catch (err) { + console.error('[History POST Error]:', err); + return new Response(JSON.stringify({ error: 'System error' }), { status: 500 }); + } +}; + +export const GET = async ({ cookies, url }) => { + const token = cookies.get('auth_token')?.value; + if (!token) return new Response(JSON.stringify({ history: [] }), { status: 200 }); + + try { + const userData = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + const user = await txasupabase.getUserById(userData.id); + + if (!user) return new Response(JSON.stringify({ history: [] }), { status: 200 }); + + const slug = url.searchParams.get('slug'); + if (slug) { + const item = user.history?.find(h => h.slug === slug); + if (item) { + return new Response(JSON.stringify({ + movieSlug: item.slug, + currentTime: item.currentTime, + duration: item.duration, + episodeName: item.episode, + watchedAt: item.watchedAt, + // Hỗ trợ tham số cũ cho trình phát TXAPlayer + current_time: item.currentTime, + episode_name: item.episode + }), { status: 200 }); + } + return new Response(JSON.stringify({ error: 'Not found' }), { status: 404 }); + } + + return new Response(JSON.stringify({ history: user.history || [] }), { status: 200 }); + } catch (err) { + console.error('[History GET Error]:', err); + return new Response(JSON.stringify({ history: [] }), { status: 200 }); + } +}; + +export const DELETE = async ({ request, cookies }) => { + const token = cookies.get('auth_token')?.value; + if (!token) return new Response(JSON.stringify({ error: 'Chưa đăng nhập' }), { status: 401 }); + + try { + const { movieSlugs, clearAll } = await request.json(); + const userData = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + + const user = await txasupabase.getUserById(userData.id); + if (!user) return new Response(JSON.stringify({ error: 'User not found' }), { status: 404 }); + + let history = user.history || []; + if (clearAll) { + history = []; + } else if (movieSlugs && Array.isArray(movieSlugs)) { + history = history.filter(h => !movieSlugs.includes(h.slug)); + } + + // Cập nhật lại lịch sử đã lọc lên Supabase + await txasupabase.saveUser({ + ...user, + history + }); + + return new Response(JSON.stringify({ success: true, message: 'Đã xóa lịch sử xem!' }), { status: 200 }); + } catch (err) { + console.error('[History DELETE Error]:', err); + return new Response(JSON.stringify({ error: 'System error' }), { status: 500 }); + } +}; diff --git a/src/pages/api/video/resolve.js b/src/pages/api/video/resolve.js new file mode 100644 index 0000000000000000000000000000000000000000..cc0ac2e9e23ca1cfdb3bb32f1681436f958deefc --- /dev/null +++ b/src/pages/api/video/resolve.js @@ -0,0 +1,61 @@ +// src/pages/api/video/resolve.js +// Ultra-Premium SSL Guard Auto-Resolver +// Automatically upgrades untrusted SSL direct streams to use Cloudflare R2 Proxy + +export const prerender = false; + +export async function GET({ request }) { + const urlObj = new URL(request.url); + const base64Url = urlObj.searchParams.get('url'); + + if (!base64Url) { + return new Response(JSON.stringify({ success: false, error: 'Missing parameter: url' }), { + status: 400, + headers: { + 'Content-Type': 'application/json', + 'Access-Control-Allow-Origin': '*' + } + }); + } + + try { + // Decode base64 URL sent by txaplayer SSL Guard + const decodedUrl = atob(decodeURIComponent(base64Url)); + console.log('[API Video Resolve] SSL Guard triggered for:', decodedUrl); + + const cloudflareProxy = import.meta.env.PUBLIC_CLOUDFLARE_PROXY_URL; + let resolvedUrl = decodedUrl; + + // Check if the domain is known to geo-block or block Cloudflare Workers (e.g., phimmoi.net) + const isCloudflareBlocked = decodedUrl.includes('phimmoi.net') || + decodedUrl.includes('streamvda.top'); + + if (isCloudflareBlocked) { + resolvedUrl = `/api/proxy-media?url=${encodeURIComponent(decodedUrl)}`; + console.log('[API Video Resolve] Upgrading to Vercel Fallback Proxy (Forced due to geo-blocking/Cloudflare restriction):', resolvedUrl); + } else if (cloudflareProxy) { + resolvedUrl = `${cloudflareProxy}/?url=${encodeURIComponent(decodedUrl)}`; + console.log('[API Video Resolve] Upgrading to Cloudflare Proxy:', resolvedUrl); + } else { + resolvedUrl = `/api/proxy-media?url=${encodeURIComponent(decodedUrl)}`; + console.log('[API Video Resolve] Upgrading to Vercel Fallback Proxy:', resolvedUrl); + } + + return new Response(JSON.stringify({ success: true, url: resolvedUrl }), { + status: 200, + headers: { + 'Content-Type': 'application/json', + 'Access-Control-Allow-Origin': '*' + } + }); + } catch (e) { + console.error('[API Video Resolve] Error decoding URL:', e); + return new Response(JSON.stringify({ success: false, error: e.message }), { + status: 500, + headers: { + 'Content-Type': 'application/json', + 'Access-Control-Allow-Origin': '*' + } + }); + } +} diff --git a/src/pages/ca-nhan/lich-su.astro b/src/pages/ca-nhan/lich-su.astro new file mode 100644 index 0000000000000000000000000000000000000000..42e39af7df6908a5b90ec6f0a61f0a65ccaf7fc4 --- /dev/null +++ b/src/pages/ca-nhan/lich-su.astro @@ -0,0 +1,400 @@ +--- +import Layout from '../../layouts/Layout.astro'; +import { txasupabase } from '../../lib/txasupabase.js'; +import { formatImageUrl } from '../../lib/image.js'; + +const token = Astro.cookies.get('auth_token')?.value; +if (!token) { + return Astro.redirect('/dang-nhap'); +} + +let user = null; +let history = []; + +try { + const userData = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + user = await txasupabase.getUserById(userData.id); + history = user?.history || []; +} catch (err) { + console.error('History page error:', err); +} + +const formatEpisodeName = (name) => { + if (!name) return ''; + const str = String(name); + if (str.toLowerCase().includes('tập')) return str; + return `Tập ${str}`; +}; +--- + + +
+
+
+
+ +

+ Lịch sử xem phim +

+
+

+ Tự động đồng bộ trên các thiết bị của bạn +

+
+ + {history.length > 0 && ( +
+ + + + + +
+ )} +
+ + {history.length === 0 ? ( +
+
+ +
+

Chưa có lịch sử xem

+

Bạn chưa xem bộ phim nào gần đây hoặc đã xóa lịch sử xem. Khám phá các bộ phim mới ngay!

+ + Khám phá ngay + +
+ ) : ( +
+ {history.map((item) => { + const poster = formatImageUrl(item.thumb); + const percent = item.duration > 0 ? Math.min(Math.round((item.currentTime / item.duration) * 100), 100) : 0; + + return ( +
+ {/* Select Checkbox (Overlay in selection mode) */} + + + {/* Individual delete button */} + + +
+ {item.name} + + {/* Overlay Gradient */} +
+ + {/* Play Resume Button Overlay */} +
+ + + +
+ + {/* Bottom Status Info */} +
+
+ + {formatEpisodeName(item.episode)} + + {percent > 0 && ( + + {percent}% + + )} +
+ + {/* Custom Watch Progress Bar */} + {percent > 0 && ( +
+
+
+ )} +
+
+ +
+
+

+ {item.name} +

+

+ Xem lúc: {new Date(item.watchedAt).toLocaleDateString('vi-VN')} +

+
+
+
+ ); + })} +
+ )} +
+ + + + + diff --git a/src/pages/ca-nhan/yeu-thich.astro b/src/pages/ca-nhan/yeu-thich.astro new file mode 100644 index 0000000000000000000000000000000000000000..ffc058d4dc026c8a0e1eb13490179ec4a6f2e80b --- /dev/null +++ b/src/pages/ca-nhan/yeu-thich.astro @@ -0,0 +1,170 @@ +--- +import Layout from '../../layouts/Layout.astro'; +import { txasupabase } from '../../lib/txasupabase.js'; +import { formatImageUrl } from '../../lib/image.js'; + +const token = Astro.cookies.get('auth_token')?.value; +if (!token) { + return Astro.redirect('/dang-nhap'); +} + +let user = null; +let favorites = []; + +try { + const userData = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + user = await txasupabase.getUserById(userData.id); + favorites = user?.favorites || []; +} catch (err) { + console.error('Favorites page error:', err); +} +--- + + +
+
+
+ +

+ Phim yêu thích +

+
+

+ Danh sách phim bạn đã đánh dấu quan tâm +

+
+ + {favorites.length === 0 ? ( +
+
+ +
+

Chưa có phim yêu thích

+

Bạn chưa lưu bộ phim nào. Hãy bấm nút Yêu thích ở trang chi tiết phim để lưu trữ tại đây.

+ + Khám phá ngay + +
+ ) : ( +
+ {favorites.map((item) => { + const poster = formatImageUrl(item.thumb); + return ( +
+ {/* Delete button */} + + +
+ {item.name} + + {/* Overlay Gradient */} +
+ + {/* Info / Navigation overlay */} + +
+ +
+
+

+ {item.name} +

+ {item.addedAt && ( +

+ Đã thêm: {new Date(item.addedAt).toLocaleDateString('vi-VN')} +

+ )} +
+
+
+ ); + })} +
+ )} +
+ + + diff --git a/src/pages/chinh-sach.astro b/src/pages/chinh-sach.astro new file mode 100644 index 0000000000000000000000000000000000000000..e8421759f875fd9104cd3400f5a10321abd8dd27 --- /dev/null +++ b/src/pages/chinh-sach.astro @@ -0,0 +1,62 @@ +--- +import Layout from '../layouts/Layout.astro'; + +const title = "Chính sách bảo mật | TPHIMX"; +--- + + +
+
+

Chính sách bảo mật

+ +
+
+

1. Cam kết bảo mật

+

Tại TPHIMX, chúng tôi cam kết bảo vệ tuyệt đối thông tin cá nhân và quyền riêng tư của người dùng. Mọi dữ liệu thu thập đều nhằm mục đích nâng cao trải nghiệm của bạn.

+
+ +
+

2. Thu thập thông tin

+

Chúng tôi thu thập các thông tin như tên tài khoản, email, địa chỉ (Tỉnh/Xã) khi bạn đăng ký thành viên. Ngoài ra, hệ thống cũng tự động thu thập dữ liệu truy cập như địa chỉ IP, loại trình duyệt để tối ưu hóa hiệu suất kỹ thuật.

+
+ +
+

3. Mục đích sử dụng

+
    +
  • Cung cấp và duy trì các tính năng của dịch vụ xem phim.
  • +
  • Giao tiếp, hỗ trợ khách hàng và thông báo về các cập nhật mới.
  • +
  • Phân tích dữ liệu để cải thiện giao diện và nội dung phim.
  • +
  • Ngăn chặn các hành vi gian lận hoặc tấn công hệ thống.
  • +
+
+ +
+

4. Chia sẻ thông tin

+

TPHIMX cam kết không bán, trao đổi thông tin cá nhân của bạn cho bên thứ ba vì mục đích thương mại. Chúng tôi chỉ chia sẻ dữ liệu khi có sự đồng ý của bạn, hoặc khi được yêu cầu bởi các cơ quan pháp luật có thẩm quyền.

+
+ +
+

5. Bảo mật dữ liệu

+

Chúng tôi áp dụng các biện pháp mã hóa (SHA-256 cho mật khẩu) và bảo mật hiện đại để bảo vệ thông tin. Tuy nhiên, không có phương thức truyền tải qua internet nào là an toàn 100%, vì vậy chúng tôi mong bạn tự bảo quản mật khẩu cẩn thận.

+
+ +
+

6. Quyền lợi người dùng

+

Bạn có toàn quyền truy cập, cập nhật hoặc yêu cầu xóa bỏ thông tin cá nhân của mình trong phần cài đặt tài khoản. Chúng tôi tôn trọng mọi quyết định của người dùng về dữ liệu cá nhân.

+
+ +
+

7. Cookies

+

Chúng tôi sử dụng Cookies để ghi nhớ phiên đăng nhập và tùy chọn cá nhân của bạn, giúp bạn không phải đăng nhập lại nhiều lần.

+
+
+ + +
+
+
diff --git a/src/pages/chu-de/[slug].astro b/src/pages/chu-de/[slug].astro new file mode 100644 index 0000000000000000000000000000000000000000..606ba0ca2fed7b6c356f6eb6a777fc7b419bab07 --- /dev/null +++ b/src/pages/chu-de/[slug].astro @@ -0,0 +1,74 @@ +--- +import Layout from '../../layouts/Layout.astro'; +import PaginatedGrid from '../../components/PaginatedGrid.jsx'; +import { getMoviesByTopic } from '../../lib/api.js'; +import { TOPICS } from '../../lib/topics.js'; + +const { slug } = Astro.params; +const page = parseInt(Astro.url.searchParams.get('page') || '1'); + +if (!slug) return Astro.redirect('/chu-de'); + +const topic = TOPICS.find((t) => t.slug === slug); +if (!topic) return Astro.redirect('/chu-de'); + +const data = await getMoviesByTopic(slug, page); +const title = topic.name; +--- + + +
+ + + + + Tất cả chủ đề + + + +
+ +
+ +
+
+
+ + {topic.badge} + +
+

+ {title} +

+

+ {topic.description} +

+
+ +
+ {topic.slug === 'the-gioi-netflix' ? ( + + ) : ( + + )} +
+
+
+ + + + +
+
diff --git a/src/pages/chu-de/index.astro b/src/pages/chu-de/index.astro new file mode 100644 index 0000000000000000000000000000000000000000..bcaf31c635bbdedd249e3d8e8963925e454e4081 --- /dev/null +++ b/src/pages/chu-de/index.astro @@ -0,0 +1,77 @@ +--- +import Layout from '../../layouts/Layout.astro'; +import { TOPICS } from '../../lib/topics.js'; +--- + + +
+ + +
+
+
+
+ + Tuyển chọn đặc biệt + +

+ CHỦ ĐỀ ĐIỆN ẢNH +

+

+ Khám phá các vũ trụ điện ảnh kỳ vĩ, bộ sưu tập phim nguyên bản độc quyền và những tuyển tập bom tấn được cập nhật tự động liên tục. +

+
+ + + + +
+
diff --git a/src/pages/dang-ky.astro b/src/pages/dang-ky.astro new file mode 100644 index 0000000000000000000000000000000000000000..c1a9e3c209d07d44164c8ebd8d3bde45729ba2d6 --- /dev/null +++ b/src/pages/dang-ky.astro @@ -0,0 +1,457 @@ +--- +import Layout from '../layouts/Layout.astro'; + +const title = "Đăng ký | DPTXA - Thiên đường điện ảnh"; +const description = "Tham gia cộng đồng DPTXA ngay hôm nay để nhận thông báo về những bộ phim mới nhất và trải nghiệm xem phim không giới hạn."; +--- + + + + +
+
+ Background +
+
+ +
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+

Chào mừng bạn!

+

Đăng ký để khám phá thế giới phim ảnh DPTXA

+
+ +
+
+ +
+ + + +
+

+
+ +
+ +
+ + + +
+

+
+ +
+
+ +
+ + + +
+

+
+
+ +
+ + + +
+

+
+
+ + +
+
+ +
+ + + +
+

+
+
+ +
+ + + +
+

+
+
+ + + + +
+ +
+

+ Đã có tài khoản rồi? + Đăng nhập ngay +

+
+
+
+
+ + + + \ No newline at end of file diff --git a/src/pages/dang-nhap.astro b/src/pages/dang-nhap.astro new file mode 100644 index 0000000000000000000000000000000000000000..cdb8ee5223fc89e9bc5a54c67296a4f11371fc7c --- /dev/null +++ b/src/pages/dang-nhap.astro @@ -0,0 +1,401 @@ +--- +import Layout from '../layouts/Layout.astro'; + +const title = "Đăng nhập | DPTXA - Thiên đường điện ảnh"; +const description = "Đăng nhập vào tài khoản DPTXA để trải nghiệm kho phim khổng lồ và lưu lại những bộ phim yêu thích của bạn."; +--- + + + + +
+
+ Background +
+
+ +
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+

Mừng bạn trở lại!

+

Đăng nhập để tiếp tục xem phim nào

+
+ +
+
+ +
+ + + +
+

+
+ +
+
+ + Quên mật khẩu? +
+
+ + +
+ + +
+
+

+
+ + + + + +
+
+ Hoặc tiếp tục với +
+
+ +
+ + +
+
+ +
+

+ Chưa có tài khoản? + Đăng ký tại đây +

+
+
+
+
+ + + + \ No newline at end of file diff --git a/src/pages/danh-sach/[category].astro b/src/pages/danh-sach/[category].astro new file mode 100644 index 0000000000000000000000000000000000000000..8c5e9744cf165d9ffc8daea99c27d56af61e778a --- /dev/null +++ b/src/pages/danh-sach/[category].astro @@ -0,0 +1,48 @@ +--- +import Layout from '../../layouts/Layout.astro'; +import PaginatedGrid from '../../components/PaginatedGrid.jsx'; +import { getMoviesByCategory, getNewestMovies } from '../../lib/api.js'; + +const { category } = Astro.params; +const page = parseInt(Astro.url.searchParams.get('page') || '1'); +if (!category) return Astro.redirect('/'); + +const data = category === 'phim-moi-cap-nhat' + ? await getNewestMovies(page) + : await getMoviesByCategory(category, page); + +const titles = { + 'phim-moi-cap-nhat': 'Phim mới cập nhật', + 'phim-bo': 'Phim bộ', + 'phim-le': 'Phim lẻ', + 'hoat-hinh': 'Hoạt hình', + 'tv-shows': 'TV Shows' +}; + +const title = titles[category] || 'Danh sách phim'; +--- + + +
+
+
+ +

+ {title} +

+
+

Khám phá thế giới điện ảnh đỉnh cao tại DPTXA

+
+ + +
+
diff --git a/src/pages/dien-vien.astro b/src/pages/dien-vien.astro new file mode 100644 index 0000000000000000000000000000000000000000..107844482e0d3f1e2d53e0aae8b90a8012dad870 --- /dev/null +++ b/src/pages/dien-vien.astro @@ -0,0 +1,149 @@ +--- +import Layout from '../layouts/Layout.astro'; +import { txasupabase } from '../lib/txasupabase.js'; + +const title = "Diễn viên - ROPHIm"; +const description = "Khám phá danh sách các diễn viên, ngôi sao điện ảnh hàng đầu tham gia trong các bộ phim bom tấn trên ROPHIm."; + +const actors = await txasupabase.getActors().catch(() => []); + +// Sắp xếp diễn viên theo tên +const sortedActors = [...actors].sort((a, b) => a.name.localeCompare(b.name, 'vi')); + +// Avatar gradient palettes +const gradients = [ + 'from-pink-500 to-rose-600 shadow-rose-500/20', + 'from-purple-500 to-indigo-600 shadow-indigo-500/20', + 'from-blue-500 to-cyan-600 shadow-cyan-500/20', + 'from-emerald-500 to-teal-600 shadow-teal-500/20', + 'from-amber-500 to-orange-600 shadow-orange-500/20', + 'from-fuchsia-500 to-purple-600 shadow-purple-500/20', + 'from-sky-500 to-blue-600 shadow-blue-500/20' +]; +--- + + +
+ + +
+
+ + +
+
+ + Ngôi sao Điện ảnh +
+

+ Dàn Diễn Viên Xuất Sắc +

+

+ Khám phá toàn bộ dàn diễn viên, ngôi sao điện ảnh và những gương mặt tài năng góp phần làm nên sự thành công của các tác phẩm bom tấn trên hệ thống ROPHIm. +

+
+ + +
+
+ + +
+ + Tổng số: {sortedActors.length} diễn viên + +
+ + +
+ {sortedActors.map((actor, idx) => { + const char = actor.name.trim().charAt(0).toUpperCase(); + const gradient = gradients[idx % gradients.length]; + + return ( + + {/* Ambient hover glowing background */} + + + + + +
+
+ + diff --git a/src/pages/dieu-khoan.astro b/src/pages/dieu-khoan.astro new file mode 100644 index 0000000000000000000000000000000000000000..5c9f174562b2073deff913ac16feb969e7527683 --- /dev/null +++ b/src/pages/dieu-khoan.astro @@ -0,0 +1,56 @@ +--- +import Layout from '../layouts/Layout.astro'; + +const title = "Điều khoản sử dụng | TPHIMX"; +--- + + +
+
+

Điều khoản sử dụng

+ +
+
+

1. Chấp nhận điều khoản

+

Việc sử dụng dịch vụ tại TPHIMX đồng nghĩa với việc bạn hoàn toàn đồng ý và tuân thủ các điều khoản sử dụng này. Nếu bạn không đồng ý với bất kỳ điều khoản nào, vui lòng ngừng sử dụng dịch vụ của chúng tôi.

+
+ +
+

2. Tài khoản người dùng

+

Người dùng chịu trách nhiệm hoàn toàn về việc bảo mật thông tin tài khoản và mật khẩu của mình. Bạn cam kết cung cấp thông tin chính xác khi đăng ký và chịu trách nhiệm cho mọi hoạt động diễn ra dưới tài khoản của mình.

+
+ +
+

3. Hành vi bị cấm

+
    +
  • Nghiêm cấm vi phạm bản quyền, sao chép nội dung trái phép từ TPHIMX.
  • +
  • Không được can thiệp vào hệ thống kỹ thuật, mã nguồn hoặc hạ tầng của trang web.
  • +
  • Nghiêm cấm sử dụng dịch vụ cho mục đích thương mại trái phép hoặc phát tán nội dung độc hại, vi phạm pháp luật.
  • +
+
+ +
+

4. Thay đổi dịch vụ

+

TPHIMX có quyền thay đổi, tạm ngừng hoặc chấm dứt cung cấp dịch vụ bất cứ lúc nào mà không cần thông báo trước để bảo trì hoặc nâng cấp hệ thống.

+
+ +
+

5. Miễn trừ trách nhiệm

+

Chúng tôi không chịu trách nhiệm về các lỗi kỹ thuật khách quan, sự cố đường truyền hoặc nội dung do bên thứ ba cung cấp. TPHIMX nỗ lực mang lại trải nghiệm tốt nhất nhưng không đảm bảo dịch vụ sẽ luôn không bị gián đoạn.

+
+ +
+

6. Sở hữu trí tuệ

+

Toàn bộ nội dung, logo, giao diện và công nghệ trên TPHIMX thuộc sở hữu của chúng tôi hoặc các đối tác được cấp phép. Mọi hành vi xâm phạm sẽ bị xử lý theo quy định của pháp luật.

+
+
+ + +
+
+
diff --git a/src/pages/index.astro b/src/pages/index.astro new file mode 100644 index 0000000000000000000000000000000000000000..8eabead10865d9c831b378104d6b50567aac94a0 --- /dev/null +++ b/src/pages/index.astro @@ -0,0 +1,781 @@ +--- +import Layout from '../layouts/Layout.astro'; +import { txasupabase } from '../lib/txasupabase.js'; + +// Kiểm tra xem đã có cookie duyệt chưa từ phía máy chủ để hiển thị nút thích hợp nếu cần +const isApprovedServer = Astro.cookies.get('zalo_access_approved')?.value === 'true'; +--- + + + +
+
+
+
+ +
+ +
+ + Nền tảng điện ảnh độc quyền +
+ + +

+ KHÁM PHÁ THẾ GIỚI + ĐIỆN ẢNH TUYỆT MỸ +

+ +

+ Chào mừng bạn đến với DPTXA. Trải nghiệm xem phim Full HD tốc độ cao không quảng cáo, cùng tham gia cộng đồng mọt phim chất lượng cao. +

+ + +
+ + +
+ + +
+
+ +

Đặc quyền tại DPTXA

+ +
+ +
+ +
+
+
+ +
+

Đường truyền cực hạn

+

Băng thông không giới hạn, tối ưu hóa phát luồng HLS cho tốc độ tải phim tức thì, không giật lag.

+
+ + +
+
+
+ +
+

Không Quảng Cáo

+

Nói không với các quảng cáo pop-up, banner phản cảm che mắt người xem. Trải nghiệm xem phim thuần khiết nhất.

+
+ + +
+
+
+ +
+

Cộng đồng Giao lưu

+

Kết nối trực tiếp với hàng ngàn mọt phim chất lượng cao qua nhóm Zalo, thảo luận những tập phim mới nhất mỗi ngày.

+
+
+
+
+ + + +
+ + + + diff --git a/src/pages/khong-tim-thay.astro b/src/pages/khong-tim-thay.astro new file mode 100644 index 0000000000000000000000000000000000000000..58c7b55b72ffe67697a48bcd25cbd888e649f145 --- /dev/null +++ b/src/pages/khong-tim-thay.astro @@ -0,0 +1,137 @@ +--- +import Layout from '../layouts/Layout.astro'; +--- + + +
+ +
+
+
+ + +
+
+
+
+
+
+
+ +
+ + +
+
+
+
+ + +
+
+ + +
+ +
+ + +
+
+ + +
+

+ 404 +

+ +
+ 404 +
+
+ + +

+ Tuyệt tác điện ảnh chưa bắt đầu +

+ +

+ Bộ phim hoặc phân cảnh bạn đang tìm kiếm không tồn tại, đã bị di dời hoặc đang được chúng tôi khởi chiếu ở một vũ trụ khác. +

+ + +
+ + + Về trang chủ + + +
+
+
+
+ + diff --git a/src/pages/lich-chieu.astro b/src/pages/lich-chieu.astro new file mode 100644 index 0000000000000000000000000000000000000000..d1374fc04d7e6d5d475c2fc089b7bf3d8cfc4318 --- /dev/null +++ b/src/pages/lich-chieu.astro @@ -0,0 +1,202 @@ +--- +import Layout from '../layouts/Layout.astro'; +import { formatImageUrl } from '../lib/api.js'; +import { txasupabase } from '../lib/txasupabase.js'; + +// Lấy tất cả phim có lịch chiếu tập tiếp theo +let scheduledMovies = []; +try { + const localMovies = await txasupabase.getLocalMovies().catch(() => ({})); + scheduledMovies = Object.entries(localMovies) + .map(([slug, m]) => { + if (!m || !m.movie) return null; + return { + ...m.movie, + slug + }; + }) + .filter(Boolean) + .filter(movie => movie.next_episode_time) + .filter(movie => { + const nextTime = new Date(movie.next_episode_time); + const minTime = new Date(Date.now() - 7 * 86400000); + return nextTime >= minTime; + }) + .sort((a, b) => new Date(a.next_episode_time).getTime() - new Date(b.next_episode_time).getTime()); +} catch (e) { + console.error('[lich-chieu] Error fetching schedule:', e); +} + +// Nhóm phim theo ngày +const getVietnamDateString = (date) => { + return new Date(date).toLocaleDateString('en-CA', { timeZone: 'Asia/Ho_Chi_Minh' }); +}; + +const today = new Date(new Date().toLocaleDateString('en-US', { timeZone: 'Asia/Ho_Chi_Minh' })); +today.setHours(0, 0, 0, 0); + +// Tạo danh sách 7 ngày từ hôm nay +const days = []; +for (let i = 0; i < 7; i++) { + const d = new Date(today); + d.setDate(d.getDate() + i); + days.push(d); +} + +const dayNames = ['Chủ Nhật', 'Thứ Hai', 'Thứ Ba', 'Thứ Tư', 'Thứ Năm', 'Thứ Sáu', 'Thứ Bảy']; + +function getMoviesForDate(date: Date) { + const targetStr = getVietnamDateString(date); + return scheduledMovies.filter(m => { + return getVietnamDateString(m.next_episode_time) === targetStr; + }); +} +--- + + +
+
+ + +
+
+ Trang chủ + + Lịch chiếu +
+

+ Lịch chiếu +

+
+ + +
+
+ {days.map((d, i) => { + const dd = String(d.getDate()).padStart(2, '0'); + const mm = String(d.getMonth() + 1).padStart(2, '0'); + const dayName = dayNames[d.getDay()]; + const isToday = i === 0; + const count = getMoviesForDate(d).length; + return ( + + ); + })} +
+
+ + + {days.map((d, i) => { + const moviesForDay = getMoviesForDate(d); + return ( +
+ {moviesForDay.length === 0 ? ( +
+
+
+ +
+

Không có phim nào dự kiến phát sóng vào ngày này.

+

Đón xem các cập nhật mới nhất từ ban quản trị hệ thống.

+
+ ) : ( +
+ {moviesForDay.map(m => { + const poster = formatImageUrl(m.poster_url || m.thumb_url); + const epLabel = m.next_episode_name || m.episode_current || 'Tập mới'; + const timeStr = new Date(m.next_episode_time).toLocaleTimeString('vi-VN', { hour: '2-digit', minute: '2-digit', hour12: false, timeZone: 'Asia/Ho_Chi_Minh' }); + return ( + + +
+ + +
+ {m.name} +
+
+ + +
+ + + Sắp phát sóng + +
{m.name}
+ +
+ + + {timeStr} + + + {epLabel} + +
+
+ + +
+ +
+
+ ); + })} +
+ )} +
+ ); + })} + +
+
+
+ + diff --git a/src/pages/phim/[slug].astro b/src/pages/phim/[slug].astro new file mode 100644 index 0000000000000000000000000000000000000000..2e4f9794ceb3e21880cc2f89cfb182227c13c8ac --- /dev/null +++ b/src/pages/phim/[slug].astro @@ -0,0 +1,834 @@ +--- +import Layout from '../../layouts/Layout.astro'; +import EpisodeList from '../../components/EpisodeList.jsx'; +import { getMovieDetail, getMoviesByCategory, formatImageUrl } from '../../lib/api.js'; +import MovieCard from '../../components/MovieCard.jsx'; +import { txasupabase } from '../../lib/txasupabase.js'; + +const { slug } = Astro.params; +if (!slug) return Astro.redirect('/'); + +const data = await getMovieDetail(slug); +if (!data?.movie) return Astro.redirect('/khong-tim-thay'); + +const movie = data.movie; + +const getEpisodeNumber = (name) => { + if (!name) return 0; + const match = String(name).match(/\d+/); + return match ? parseInt(match[0], 10) : 0; +}; + +let rawEpisodes = data.episodes || []; +let episodes = JSON.parse(JSON.stringify(rawEpisodes)); +if (movie.next_episode_time && movie.next_episode_name) { + const nextTime = new Date(movie.next_episode_time); + if (nextTime > new Date()) { + const nextEpNum = getEpisodeNumber(movie.next_episode_name); + episodes.forEach(server => { + if (server.server_data) { + server.server_data = server.server_data.filter(ep => { + const epNum = getEpisodeNumber(ep.name); + if (nextEpNum > 0 && epNum > 0) { + return epNum < nextEpNum; + } + return ep.name !== movie.next_episode_name; + }); + } + }); + episodes = episodes.filter(server => server.server_data && server.server_data.length > 0); + } +} + +const isUpcoming = movie.status === 'trailer' || + (movie.next_episode_time && new Date(movie.next_episode_time) > new Date()) || + (!episodes || episodes.length === 0 || !episodes[0]?.server_data || episodes[0].server_data.length === 0); + +const currentEpisodeLabel = isUpcoming + ? "Sắp chiếu" + : (movie.episode_current && movie.episode_current !== "Full" + ? (String(movie.episode_current).toLowerCase().includes("tập") ? movie.episode_current : `Tập ${movie.episode_current}`) + : (episodes[0]?.server_data?.length ? `${episodes[0].server_data.length} Tập` : "Full") + ); + +const thumb = formatImageUrl(movie.thumb_url || movie.poster_url); +const bg = formatImageUrl(movie.poster_url || movie.thumb_url); +const year = movie.year || (movie.modified?.time ? new Date(movie.modified.time).getFullYear() : ''); +const categories = movie.category?.map((c) => c.name).join(', ') || ''; +const countries = movie.country?.map((c) => c.name).join(', ') || ''; +const ensureArray = (val) => { + if (!val) return []; + if (Array.isArray(val)) return val; + if (typeof val === 'string') { + return val.split(',').map(s => s.trim()).filter(Boolean); + } + return []; +}; + +const actorList = ensureArray(movie.actor); +const directorList = ensureArray(movie.director); + +const actors = actorList.join(', '); +const directors = directorList.join(', '); +const content = movie.content?.replace(/<[^>]*>/g, '') || ''; + +// Base Name Season / Part grouping helpers +function getBaseMovieName(name: string) { + if (!name) return ''; + let clean = name; + // 1. Xóa các cụm chứa ngoặc đơn hoặc ngoặc vuông chứa Phần/Part/Season (ví dụ: "(Phần 2)", "[Season 3]") + clean = clean.replace(/\s*[([\])]*\s*(Phần|Part|Season|SS|EP|Ep|Tập)\s*(\d+|[IVXLCDM]+)\s*[([\])]*/gi, ''); + // 2. Xóa các cụm Phần/Part/Season đứng độc lập ở cuối + clean = clean.replace(/\s*[-–—|:]?\s*(Phần|Part|Season|SS|EP|Ep|Tập)\s*(\d+|[IVXLCDM]+)\b/gi, ''); + // 3. Xóa các số hoặc ký tự số La Mã cô độc ở cuối + clean = clean.replace(/\s*[-–—|:]?\s*(\d+|[IVXLCDM]+)$/gi, ''); + // 4. Dọn dẹp sạch các dấu ngoặc đơn/ngoặc vuông rỗng còn sót lại ở cuối chuỗi + clean = clean.replace(/\s*[([\])]+\s*$/gi, ''); + return clean.trim(); +} + +function getMoviePartLabel(name: string) { + if (!name) return 'Phần 1'; + // 1. Tìm các từ khóa rõ ràng + const match = name.match(/(Phần\s*\d+|Phần\s*[IVXLCDM]+|Part\s*\d+|Season\s*\d+|SS\s*\d+|EP\s*\d+|Ep\s*\d+)/i); + if (match) return match[1]; + + // 2. Nếu không có từ khóa, tìm số/số la mã ở cuối tên + const trailingMatch = name.match(/\s*[-–—|:]?\s*(\d+|[IVXLCDM]+)$/i); + if (trailingMatch) { + return `Phần ${trailingMatch[1]}`; + } + + return 'Phần 1'; +} + +let movieParts = []; +const baseName = getBaseMovieName(movie.name); +if (baseName && baseName.length > 2) { + try { + const { data: matchedMovies, error } = await txasupabase.client + .from('movies') + .select('slug, movie'); + + if (error) { + console.error('Error fetching movie parts from Supabase:', error); + } else if (matchedMovies) { + const mapped = matchedMovies.map(m => ({ + slug: m.slug, + name: (m.movie as any)?.name || '' + })); + movieParts = mapped + .filter(m => getBaseMovieName(m.name).toLowerCase() === baseName.toLowerCase()) + .sort((a, b) => a.name.localeCompare(b.name, 'vi', { numeric: true })); + } + } catch (err) { + console.error('Error fetching movie parts:', err); + } +} + +// Lấy địa chỉ IP của Client +let clientIp = '127.0.0.1'; +try { + clientIp = Astro.clientAddress || Astro.request.headers.get('x-real-ip') || Astro.request.headers.get('x-forwarded-for')?.split(',')[0].trim() || '127.0.0.1'; +} catch (e) {} + +// Tăng lượt xem phim thực tế khi trang thông tin phim được tải (Giới hạn 1 IP / 1 ngày) +await txasupabase.incrementViews(slug, clientIp).catch(e => console.error('[Views Increment Error]:', e)); + +// Check Favorite & Rating on Server +const token = Astro.cookies.get('auth_token')?.value; +let isFavorite = false; +let userRating = 0; +let loggedInUser = null; + +if (token) { + try { + loggedInUser = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + const user = await txasupabase.getUserById(loggedInUser.id); + isFavorite = user?.favorites?.some(f => f.slug === slug) || false; + + const ratingObj = await txasupabase.getRatingBySlug(slug); + userRating = ratingObj?.user_ratings?.[loggedInUser.username] || 0; + } catch (e) {} +} + +// Get average rating (API + Local) +let avgScore = movie.tmdb?.vote_average || 0; +let voteCount = movie.tmdb?.vote_count || 0; + +try { + const ratingObj = await txasupabase.getRatingBySlug(slug); + if (ratingObj) { + const totalScore = (avgScore * voteCount) + Number(ratingObj.total_score); + voteCount += ratingObj.count; + avgScore = voteCount > 0 ? (totalScore / voteCount).toFixed(1) : 0; + } +} catch (e) {} + +// Fetch related movies +let relatedMovies = []; +if (movie.category && movie.category[0]) { + const categoryResult = await getMoviesByCategory(movie.category[0].slug, 1); + relatedMovies = categoryResult?.items?.filter(m => m.slug !== movie.slug).slice(0, 12) || []; +} + +// Lấy danh sách Top phim xem nhiều nhất +let topViewedMovies = await txasupabase.getTopViewedMovies(12).catch(() => []); +if (!topViewedMovies || topViewedMovies.length === 0) { + topViewedMovies = relatedMovies.slice(0, 12); +} + +const schema = { + "@context": "https://schema.org", + "@type": "Movie", + name: movie.name, + description: content, + image: thumb, + datePublished: year, + director: directors ? directors.split(', ').map((d) => ({ "@type": "Person", name: d })) : undefined, + actor: actors ? actors.split(', ').map((a) => ({ "@type": "Person", name: a })) : undefined, + genre: categories ? categories.split(', ') : undefined, + url: `https://dongmephim.online/phim/${slug}` +}; +--- + + + + + + + diff --git a/src/pages/quoc-gia/[country].astro b/src/pages/quoc-gia/[country].astro new file mode 100644 index 0000000000000000000000000000000000000000..352972ec8cdc2cd345e735357600bee55626bb73 --- /dev/null +++ b/src/pages/quoc-gia/[country].astro @@ -0,0 +1,41 @@ +--- +import Layout from '../../layouts/Layout.astro'; +import PaginatedGrid from '../../components/PaginatedGrid.jsx'; +import { getMoviesByCountry } from '../../lib/api.js'; +import { txasupabase } from '../../lib/txasupabase.js'; + +const { country } = Astro.params; +const page = parseInt(Astro.url.searchParams.get('page') || '1'); +if (!country) return Astro.redirect('/'); + +const data = await getMoviesByCountry(country, page); + +const countriesList = await txasupabase.getCountries(); +const countryObj = countriesList.find((c: any) => c.slug === country); +const title = countryObj ? countryObj.name : 'Quốc gia'; +--- + + +
+
+
+ +

+ Quốc gia: {title} +

+
+

Khám phá thế giới điện ảnh đỉnh cao tại DPTXA

+
+ + +
+
diff --git a/src/pages/test-player.astro b/src/pages/test-player.astro new file mode 100644 index 0000000000000000000000000000000000000000..06795696512e5dd5dc6dac06336139d9bf6d7711 --- /dev/null +++ b/src/pages/test-player.astro @@ -0,0 +1,809 @@ +--- +// src/pages/test-player.astro +// Standalone Ultra-Premium diagnostics dashboard for TXAPlayer and Supabase connection. +// Bypasses all decoy/Zalo blocks by not using Layout.astro. + +import { txasupabase } from '../lib/txasupabase.js'; + +// Get movie details from Supabase to demonstrate active integration +const slug = 'nu-hoang-nuoc-mat'; +const movieData = await txasupabase.getMovieBySlug(slug).catch(() => null); + +const movieName = movieData?.movie?.name || 'Nữ Hoàng Nước Mắt'; +const thumbUrl = movieData?.movie?.thumb_url || ''; +const posterUrl = movieData?.movie?.poster_url || ''; + +// Extract first episode details +const episodes = movieData?.episodes || []; +const firstServer = episodes[0] || null; +const firstEpisode = firstServer?.server_data?.[0] || null; + +const directM3u8 = firstEpisode?.link_m3u8 || 'https://s2.phim1280.tv/20240310/Qah2fQHw/index.m3u8'; +const embedUrl = firstEpisode?.link_embed || 'https://player.phimapi.com/player/?url=https://s2.phim1280.tv/20240310/Qah2fQHw/index.m3u8'; + +// Verify Supabase Connection state +let isSupabaseConnected = false; +let dbErrorMsg = ''; +try { + const { data, error } = await txasupabase.client.from('settings').select('key').limit(1); + if (!error) { + isSupabaseConnected = true; + } else { + dbErrorMsg = error.message; + } +} catch (e: any) { + dbErrorMsg = e.message; +} +--- + + + + + + + TXAPlayer Diagnostics Dashboard | Platinum Premium + + + + + + + + + + + + +
+ +
+ Local Diagnostics Active +
+
+ +
+ +
+ + +
+

TXAPlayer Video Sandbox

+ + +
+ + + +
+ + +
+
+ +
+ + +
+ Đường dẫn nguồn đang phát: + {directM3u8} +
+ + +
+ + +
+
+ + +
+

Real-time Logger & CORS Diagnostician

+ +
+
+ Supabase Database: + + {isSupabaseConnected ? ( + Connected + ) : ( + Error: {dbErrorMsg} + )} + +
+ +
+ Client-Side CORS Test: + + Testing Link... + +
+ +
+ M3U8 Fetch Diagnostic: + + Awaiting Init + +
+ +
+ Local Dev Environment: + + localhost:4321 + +
+
+ +
[SYSTEM] Diagnostics Board initialized. Ready to record sandbox events...
+
+ + +
+

Technical Analysis: Why it fails on Vercel

+
+
+ Serverless Proxy Streaming Limitations +
+
+ Khi deploy trên tphimx.vercel.app (Vercel serverless platform), player bị lỗi không load được phim khi qua cổng proxy /api/proxy-media vì các giới hạn nghiêm ngặt sau của Vercel Free Plan: +
    +
  • Payload Body Size Limit (4.5 MB): Các file phân đoạn phim HLS (.ts) thường có kích thước lớn từ 3 MB đến 10 MB. Khi proxy cố tải toàn bộ file này vào memory (response.arrayBuffer()) và trả về, Vercel sẽ ngay lập tức chặn đứng response vì vượt quá giới hạn 4.5 MB, trả về mã lỗi 502 (Bad Gateway) hoặc 504 (Gateway Timeout).
  • +
  • Serverless Execution Timeout (10 giây): Quá trình tải các file segment lớn từ server phim gốc thông qua serverless function thường mất nhiều thời gian. Nếu quá 10 giây, Vercel sẽ ngắt kết nối hoàn toàn.
  • +
  • Băng thông và Giới hạn Streaming: Serverless functions không được tối ưu để stream liên tục luồng video nặng.
  • +
+
+ Giải pháp tối ưu & chuyên nghiệp: +
    +
  1. Cho phép chạy Direct (Không Proxy): Hầu hết các server phim (như NguonC, KKPhim) đã bật sẵn CORS header (Access-Control-Allow-Origin: *). Hãy ưu tiên phát link gốc trực tiếp trên client để giải phóng hoàn toàn gánh nặng cho server.
  2. +
  3. Reverse Proxy chuyên dụng: Thay vì dùng Astro endpoint (chạy serverless trên Vercel), hãy cài đặt một proxy nhẹ bằng Cloudflare Workers (miễn phí 100.000 requests/ngày, hỗ trợ streaming mượt mà) hoặc Nginx/Node.js Reverse Proxy chạy trên VPS giá rẻ.
  4. +
  5. Sử dụng nguồn Embed (Iframe): Nguồn nhúng iframe chạy hoàn toàn trên sandbox độc lập của bên thứ ba, đảm bảo 100% không bị ảnh hưởng bởi CORS hay Vercel proxy.
  6. +
+
+
+
+
+ +
+ + +
+ +
+
Movie Metadata
+ + {thumbUrl && ( +
+ {movieName} +
+ )} + +
+
+ Tên Phim + {movieName} +
+ +
+ Tập phim demo + Tập 1 - Nguồn HLS +
+ +
+ Server luồng + {firstServer?.server_name || '#Hà Nội (Vietsub)'} +
+
+
+ +
+
Sandboxing API Status
+
+
+ Astro Mode: SSR / Dynamic +
+
+ Astro Local Dev: active +
+
+ Supabase Host: jjmzipyewddbepnelawf.supabase.co +
+
+
+ +
+
Security Gatekeeper
+

+ Trang này được xây dựng độc lập và nằm ngoài bộ lọc Layout.astro. Tránh các lỗi kiểm duyệt Cookie, kiểm duyệt nguồn Referer hay chặn đứng do Zalo Gatekeeper, giúp việc lập trình và kiểm nghiệm txaplayer.js đạt hiệu quả tối đa. +

+
+ +
+
+ + + + + + + + + + + + + diff --git a/src/pages/the-loai/[category].astro b/src/pages/the-loai/[category].astro new file mode 100644 index 0000000000000000000000000000000000000000..497674442a53f7cca7ff31125ca7d033764d6241 --- /dev/null +++ b/src/pages/the-loai/[category].astro @@ -0,0 +1,41 @@ +--- +import Layout from '../../layouts/Layout.astro'; +import PaginatedGrid from '../../components/PaginatedGrid.jsx'; +import { getMoviesByCategory } from '../../lib/api.js'; +import { txasupabase } from '../../lib/txasupabase.js'; + +const { category } = Astro.params; +const page = parseInt(Astro.url.searchParams.get('page') || '1'); +if (!category) return Astro.redirect('/'); + +const data = await getMoviesByCategory(category, page); + +const genresList = await txasupabase.getGenres(); +const genreObj = genresList.find((g: any) => g.slug === category); +const title = genreObj ? genreObj.name : 'Thể loại phim'; +--- + + +
+
+
+ +

+ Thể loại: {title} +

+
+

Khám phá thế giới điện ảnh đỉnh cao tại DPTXA

+
+ + +
+
diff --git a/src/pages/tim-kiem.astro b/src/pages/tim-kiem.astro new file mode 100644 index 0000000000000000000000000000000000000000..a884410b4d543d391f3bcf708e14210bdef83604 --- /dev/null +++ b/src/pages/tim-kiem.astro @@ -0,0 +1,38 @@ +--- +import Layout from '../layouts/Layout.astro'; +import PaginatedGrid from '../components/PaginatedGrid.jsx'; +import { searchMovies } from '../lib/api.js'; + +const q = Astro.url.searchParams.get('q') || ''; +const page = parseInt(Astro.url.searchParams.get('page') || '1'); + +if (!q) { + return Astro.redirect('/'); +} + +const data = await searchMovies(q, page); +--- + + +
+
+
+ +

+ Kết quả: {q} +

+
+

Tìm thấy {data?.pagination?.totalItems || 0} kết quả phù hợp

+
+ + +
+
diff --git a/src/pages/tphim.astro b/src/pages/tphim.astro new file mode 100644 index 0000000000000000000000000000000000000000..9890d5a369582bb74c4b9a2c9eff77a6437bb112 --- /dev/null +++ b/src/pages/tphim.astro @@ -0,0 +1,111 @@ +--- +import Layout from '../layouts/Layout.astro'; +import HeroBanner from '../components/HeroBanner.jsx'; +import MovieSlider from '../components/MovieSlider.jsx'; +import DeferredHero from '../components/DeferredHero.astro'; +import DeferredTopTen from '../components/DeferredTopTen.astro'; +import HomeSectionsLoader from '../components/HomeSectionsLoader.jsx'; +import { getNewestMovies } from '../lib/api.js'; +import { TOPICS } from '../lib/topics.js'; + +// We fetch newest movies for Hero/Slider to have some initial content. +--- + + +
+ +
+ + +
+

Bạn đang quan tâm gì?

+
+ {[ + { name: 'Viễn Tưởng', color: 'from-red-600/80 to-red-900/90', slug: 'vien-tuong' }, + { name: 'Thái Lan', color: 'from-blue-600/80 to-blue-900/90', slug: 'thai-lan' }, + { name: 'Chiếu Rạp', color: 'from-purple-600/80 to-purple-900/90', slug: 'phim-chieu-rap' }, + { name: 'Kinh Dị', color: 'from-orange-600/80 to-orange-900/90', slug: 'kinh-di' }, + { name: 'Cổ Trang', color: 'from-rose-600/80 to-rose-900/90', slug: 'co-trang' }, + { name: 'Hành Động', color: 'from-emerald-600/80 to-emerald-900/90', slug: 'hanh-dong' } + ].map(cat => ( + +
+

{cat.name}

+ Khám phá +
+
+ +
+
+ ))} +
+
+ + +
+
+
+

Chủ đề nổi bật

+

Các tuyển tập phim đặc sắc được cập nhật tự động liên tục

+
+ + Xem tất cả + +
+ +
+ + +
+ +
+ +
+
+
+ {[...Array(5)].map((_, i) => ( +
+ ))} +
+
+ + + {/* Dynamic, Infinite / Scroll Triggered Sections Loader */} + +
+
+ diff --git a/src/pages/xem/[slug].astro b/src/pages/xem/[slug].astro new file mode 100644 index 0000000000000000000000000000000000000000..5ba7eb597cd4b8e2158f6b05de2526adc6f18a74 --- /dev/null +++ b/src/pages/xem/[slug].astro @@ -0,0 +1,921 @@ +--- +import Layout from '../../layouts/Layout.astro'; +import EpisodeList from '../../components/EpisodeList.jsx'; +import { getMovieDetail, getMoviesByCategory, formatImageUrl } from '../../lib/api'; +import MovieCard from '../../components/MovieCard.jsx'; +import { txasupabase } from '../../lib/txasupabase.js'; + +const { slug } = Astro.params; +const tap = Astro.url.searchParams.get('tap') || '1'; + +const data = await getMovieDetail(slug); + +if (!data || !data.movie) { + return Astro.redirect('/khong-tim-thay'); +} + +const movie = data.movie; + +const getEpisodeNumber = (name) => { + if (!name) return 0; + const match = String(name).match(/\d+/); + return match ? parseInt(match[0], 10) : 0; +}; + +let rawEpisodes = data.episodes || []; +let episodes = JSON.parse(JSON.stringify(rawEpisodes)); +if (movie.next_episode_time && movie.next_episode_name) { + const nextTime = new Date(movie.next_episode_time); + if (nextTime > new Date()) { + const nextEpNum = getEpisodeNumber(movie.next_episode_name); + episodes.forEach(server => { + if (server.server_data) { + server.server_data = server.server_data.filter(ep => { + const epNum = getEpisodeNumber(ep.name); + if (nextEpNum > 0 && epNum > 0) { + return epNum < nextEpNum; + } + return ep.name !== movie.next_episode_name; + }); + } + }); + episodes = episodes.filter(server => server.server_data && server.server_data.length > 0); + } +} + +if (!episodes || episodes.length === 0 || !episodes[0]?.server_data || episodes[0].server_data.length === 0) { + return Astro.redirect(`/phim/${slug}`); +} + +const hasRequestedTap = episodes.some(server => + server.server_data?.some(ep => ep.name === tap) +); +if (tap && !hasRequestedTap) { + return Astro.redirect(`/phim/${slug}`); +} + +const ensureArray = (val) => { + if (!val) return []; + if (Array.isArray(val)) return val; + if (typeof val === 'string') { + return val.split(',').map(s => s.trim()).filter(Boolean); + } + return []; +}; + +const actorList = ensureArray(movie.actor); + +// Deduplicate episodes +episodes.forEach(server => { + if (server.server_data) { + const uniqueEpisodes = []; + const seenNames = new Set(); + server.server_data.forEach(ep => { + if (!seenNames.has(ep.name)) { + seenNames.add(ep.name); + uniqueEpisodes.push(ep); + } + }); + server.server_data = uniqueEpisodes; + } +}); + +// Fetch related movies +let relatedMovies = []; +if (movie.category && movie.category[0]) { + const categoryResult = await getMoviesByCategory(movie.category[0].slug, 1); + relatedMovies = categoryResult?.items?.filter(m => m.slug !== movie.slug).slice(0, 12) || []; +} + +// Find episode +let currentServer = episodes[0]; +let currentEpisode = null; +let nextEpisode = null; +let prevEpisode = null; + +if (currentServer && currentServer.server_data) { + const currentIndex = currentServer.server_data.findIndex(e => e.name === tap); + currentEpisode = currentServer.server_data[currentIndex] || currentServer.server_data[0]; + + if (currentIndex !== -1) { + nextEpisode = currentServer.server_data[currentIndex + 1]; + prevEpisode = currentServer.server_data[currentIndex - 1]; + } +} + +const nextEpisodeUrl = nextEpisode ? `/xem/${movie.slug}?tap=${nextEpisode.name}` : null; +const prevEpisodeUrl = prevEpisode ? `/xem/${movie.slug}?tap=${prevEpisode.name}` : null; +const formatEpisodeName = (name) => { + if (!name) return ''; + const str = String(name); + if (str.toLowerCase().includes('tập')) return str; + return `Tập ${str}`; +}; + +const currentEpName = formatEpisodeName(currentEpisode?.name || tap); +const title = `Xem phim ${movie.name} - ${currentEpName} | DPTXA`; +const description = `Xem phim ${movie.name} ${currentEpName.toLowerCase()} chất lượng cao, Vietsub, Thuyết minh tại DPTXA. ${movie.content.substring(0, 150)}...`; + +// Auth Check +const token = Astro.cookies.get('auth_token')?.value; +const isLoggedIn = !!token; +const isRestricted = (movie.only_login === true || movie.require_login === true) && !isLoggedIn; +let isFavorite = false; +let loggedInUser = null; + +if (token) { + try { + loggedInUser = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); + const user = await txasupabase.getUserById(loggedInUser.id); + isFavorite = user?.favorites?.some(f => f.slug === slug) || false; + } catch (e) {} +} + +// Season/Part grouping +function getBaseMovieName(name: string) { + if (!name) return ''; + let clean = name.replace(/\s*[-–—|:]?\s*(Phần|Part|Season|SS|EP|Ep|Tập)\s*(\d+|[IVXLCDM]+)\b/gi, ''); + clean = clean.replace(/\s*[-–—|:]?\s*(\d+|[IVXLCDM]+)$/gi, ''); + return clean.trim(); +} + +function getMoviePartLabel(name: string) { + if (!name) return 'Phần 1'; + // 1. Tìm các từ khóa rõ ràng + const match = name.match(/(Phần\s*\d+|Phần\s*[IVXLCDM]+|Part\s*\d+|Season\s*\d+|SS\s*\d+|EP\s*\d+|Ep\s*\d+)/i); + if (match) return match[1]; + + // 2. Nếu không có từ khóa, tìm số/số la mã ở cuối tên + const trailingMatch = name.match(/\s*[-–—|:]?\s*(\d+|[IVXLCDM]+)$/i); + if (trailingMatch) { + return `Phần ${trailingMatch[1]}`; + } + + return 'Phần 1'; +} + +let movieParts = []; +const baseName = getBaseMovieName(movie.name); +if (baseName && baseName.length > 2) { + try { + const { data: matchedMovies } = await txasupabase.client + .from('movies') + .select('slug, name') + .ilike('name', `%${baseName}%`) + .order('name', { ascending: true }); + movieParts = (matchedMovies || []).filter(m => getBaseMovieName(m.name).toLowerCase() === baseName.toLowerCase()); + } catch (err) {} +} +--- + + + +
+ +
+
+ +
+ +
+
+
+ Trang chủ + + {movie.name} + + {currentEpName} +
+ + {isLoggedIn && ( +
+
+ Tự động chuyển tập + +
+
+ )} +
+ + + {movie.next_episode_time && new Date(movie.next_episode_time) > new Date() && ( +
+ +
+
+ +
+
+ +
+
+ Phát sóng tập mới +

{movie.next_episode_name || 'Tập tiếp theo'}

+

+ Dự kiến phát sóng lúc {new Date(movie.next_episode_time).toLocaleTimeString('vi-VN', { hour: '2-digit', minute: '2-digit', timeZone: 'Asia/Ho_Chi_Minh' })} ngày {new Date(movie.next_episode_time).toLocaleDateString('vi-VN', { day: '2-digit', month: '2-digit', year: 'numeric', timeZone: 'Asia/Ho_Chi_Minh' })} +

+
+
+ + +
+
+ 00 + Ngày +
+
+ 00 + Giờ +
+
+ 00 + Phút +
+
+ 00 + Giây +
+
+
+ ) +} + + +
+
+ {isRestricted ? ( +
+
+
+
+ +
+
+ +
+
+

Nội Dung Giới Hạn

+

+ Phim này yêu cầu tài khoản thành viên. Vui lòng đăng nhập hoặc đăng ký tài khoản mới để bắt đầu xem. +

+
+ +
+ + Đang chờ đăng nhập... hệ thống sẽ tự mở khóa +
+
+
+ ) : ( + <> +
+ + + )} +
+
+
+ + + {currentEpisode?.link_m3u8 && currentEpisode?.link_embed && currentEpisode.link_embed !== currentEpisode.link_m3u8 && !currentEpisode.link_embed.endsWith('.m3u8') && ( +
+ + +
+ )} + + + +
+
+ + + +
+ +
+ + +
+
+ + +
+
+
+
+

{movie.name}

+
+ {movie.origin_name} + + {currentEpName} + + + {movie.quality || 'FHD'} + + + {movie.lang || 'Vietsub'} + +
+
+ + {movieParts.length > 1 && ( +
+
+ + Season +
+
+ +
+ +
+
+
+ )} + +
+
+ +

Danh sách tập

+
+ +
+ +
+
+ +

Nội dung chi tiết

+
+
+
+ + +
+
+
+
+
+ +
+
+

Dàn diễn viên

+
+ {actorList.slice(0, 6).map(actor => ( +
+
+ {actor[0]} +
+
+ {actor} + Diễn viên +
+
+ ))} +
+
+ +
+

+ + Phim đề xuất +

+
+ {relatedMovies.slice(0, 5).map(m => ( + +
+ +
+
+

{m.name}

+

{m.origin_name}

+
+
+ ))} +
+
+
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/src/styles/global.css b/src/styles/global.css new file mode 100644 index 0000000000000000000000000000000000000000..64d61213751483df884ae05f733a9161c969e413 --- /dev/null +++ b/src/styles/global.css @@ -0,0 +1,175 @@ +@import "tailwindcss"; + +:root { + /* Dreamy Purple & Blue Theme */ + --primary: #7c3aed; + --primary-dark: #5b21b6; + --accent: #3b82f6; + --accent-light: #60a5fa; + + --dark: #0b0c10; + --dark-light: #12141d; + --dark-lighter: #1f2231; + + --glass-bg: rgba(20, 22, 34, 0.4); + --glass-border: rgba(255, 255, 255, 0.08); +} + +/* Theme Overrides (Example for later) */ +[data-theme="gold"] { + --primary: #ffcc00; + --primary-dark: #ccaa00; +} + +@theme { + --color-primary: var(--primary); + --color-primary-dark: var(--primary-dark); + --color-accent: var(--accent); + --color-accent-light: var(--accent-light); + --color-dark: var(--dark); + --color-dark-light: var(--dark-light); + --color-dark-lighter: var(--dark-lighter); +} + +html { + scroll-behavior: smooth; + font-size: 104.5%; + overflow-x: hidden; + width: 100%; +} + +body { + background-color: #0f0f0f; + color: #fff; + font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; + font-size: 15px; + overflow-x: hidden; + width: 100%; + position: relative; +} + +::-webkit-scrollbar { + width: 8px; +} + +::-webkit-scrollbar-track { + background: #1a1a1a; +} + +::-webkit-scrollbar-thumb { + background: #333; + border-radius: 4px; +} + +::-webkit-scrollbar-thumb:hover { + background: #e50914; +} + +.line-clamp-2 { + display: -webkit-box; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; + overflow: hidden; +} + +@utility glass { + background: var(--glass-bg); + backdrop-filter: blur(40px) saturate(200%); + border: 1px solid var(--glass-border); +} + +@utility glass-white { + background: rgba(255, 255, 255, 0.03); + backdrop-filter: blur(20px); + border: 1px solid rgba(255, 255, 255, 0.05); +} + +@utility scrollbar-hide { + scrollbar-width: none; + -ms-overflow-style: none; + &::-webkit-scrollbar { + display: none; + } +} + +/* Spoiler Blur Style for Comments */ +.spoiler-blur span:last-child { + filter: blur(7px); + user-select: none; + transition: filter 0.3s ease; +} + +@utility glass-sub { + background: rgba(255, 255, 255, 0.02); + backdrop-filter: blur(20px); + border: 1px solid rgba(255, 255, 255, 0.04); +} + +/* TXAToast - Liquid Glass Toast Notification System Styles */ +.txa-toast { + pointer-events: auto; + position: relative; + padding: 16px 22px; + border-radius: 24px; + color: #ffffff; + font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; + font-size: 14px; + font-weight: 600; + letter-spacing: -0.01em; + display: flex; + align-items: center; + justify-content: space-between; + gap: 14px; + overflow: hidden; + background: rgba(255, 255, 255, 0.02); + backdrop-filter: blur(30px); + -webkit-backdrop-filter: blur(30px); + border: 1px solid rgba(255, 255, 255, 0.12); + box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.2); + opacity: 0; + transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); +} + +/* Position-based Animations */ +[id*="-right"] .txa-toast { transform: translateX(120%) scale(0.9); } +[id*="-left"] .txa-toast { transform: translateX(-120%) scale(0.9); } +[id*="-center"] .txa-toast { transform: translateY(50px) scale(0.9); } +[id*="top-center"] .txa-toast { transform: translateY(-50px) scale(0.9); } + +.txa-toast.txa-show { transform: translate(0) scale(1); opacity: 1; } +.txa-toast.txa-hide { opacity: 0; scale: 0.85; } + +.txa-toast::before { + content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; + background: radial-gradient(circle, rgba(255,255,255,0.12) 0%, transparent 60%); pointer-events: none; mix-blend-mode: overlay; +} + +.txa-toast-success { border-color: rgba(16, 185, 129, 0.4); box-shadow: 0 12px 35px rgba(16, 185, 129, 0.2); } +.txa-toast-success .txa-icon { color: #10b981; } + +.txa-toast-error { border-color: rgba(239, 68, 68, 0.4); box-shadow: 0 12px 35px rgba(239, 68, 68, 0.2); } +.txa-toast-error .txa-icon { color: #ef4444; } + +.txa-toast-info { border-color: rgba(59, 130, 246, 0.4); box-shadow: 0 12px 35px rgba(59, 130, 246, 0.2); } +.txa-toast-info .txa-icon { color: #3b82f6; } + +.txa-toast-warning { border-color: rgba(245, 158, 11, 0.4); box-shadow: 0 12px 35px rgba(245, 158, 11, 0.2); } +.txa-toast-warning .txa-icon { color: #f59e0b; } + +.txa-content-wrapper { display: flex; flex-direction: row; align-items: center; gap: 12px; flex-grow: 1; } +.txa-icon { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 24px; } +.txa-message { line-height: 1.4; text-shadow: 0 1px 2px rgba(0,0,0,0.6); flex-grow: 1; } + +.txa-close { + background: transparent; border: none; color: rgba(255, 255, 255, 0.4); + cursor: pointer; padding: 6px; display: flex; align-items: center; + justify-content: center; transition: all 0.2s; border-radius: 50%; +} +.txa-close:hover { color: #ffffff; background: rgba(255,255,255,0.1); transform: rotate(90deg); } + +.txa-progress-bar { + position: absolute; bottom: 0; left: 0; height: 3px; width: 100%; + background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent); + transform-origin: left; transform: scaleX(1); +} + diff --git a/src/templates/email/bug_report.html b/src/templates/email/bug_report.html new file mode 100644 index 0000000000000000000000000000000000000000..66cc22ac5898ec6b286772656d0b12782e0a2c91 --- /dev/null +++ b/src/templates/email/bug_report.html @@ -0,0 +1,169 @@ + + + + + Báo cáo lỗi phim mới từ người dùng | TPHIMX + + + +
+
+ +
+
+

Báo cáo lỗi phim mới từ người dùng

+

Chào Admin,

+

Một người dùng vừa báo cáo lỗi liên quan đến việc xem phim trên hệ thống. Dưới đây là thông tin chi tiết về lỗi:

+ +
+
+ Tên phim: + {{movie_name}} +
+
+ Tập phim: + {{episode_name}} +
+
+ Loại lỗi: + {{error_type}} +
+
+ Mô tả lỗi: +
{{description}}
+
+
+ + + +

Vui lòng kiểm tra lại tập phim tương ứng để khắc phục lỗi kịp thời cho người dùng nhé!

+
+ +
+ + diff --git a/src/templates/email/forgot-password.html b/src/templates/email/forgot-password.html new file mode 100644 index 0000000000000000000000000000000000000000..4d6464e0fd4fb73ec907141301393ab7501e7739 --- /dev/null +++ b/src/templates/email/forgot-password.html @@ -0,0 +1,132 @@ + + + + + Khôi phục mật khẩu của bạn tại TPHIMX + + + +
+
+ +
+
+

Yêu cầu khôi phục mật khẩu

+

Xin chào {{username}},

+

Chúng tôi đã nhận được yêu cầu khôi phục lại mật khẩu cho tài khoản của bạn tại TPHIMX. Vui lòng nhấp vào liên kết bên dưới để đặt lại mật khẩu mới cho tài khoản:

+ + + +

Nếu nút phía trên không hoạt động, bạn cũng có thể sao chép liên kết này và dán vào thanh địa chỉ của trình duyệt:

+

{{reset_url}}

+ +
+

Lưu ý: Liên kết đặt lại mật khẩu này chỉ có giá trị trong vòng {{expiry_time}} giây. Nếu bạn không gửi yêu cầu khôi phục này, vui lòng bỏ qua email và mật khẩu của bạn sẽ được giữ an toàn.

+
+
+ +
+ + diff --git a/src/templates/email/new_episode.html b/src/templates/email/new_episode.html new file mode 100644 index 0000000000000000000000000000000000000000..d4e3b518fd0b23707ef821c62f48c034baa41874 --- /dev/null +++ b/src/templates/email/new_episode.html @@ -0,0 +1,150 @@ + + + + + + Cập nhật tập phim mới - TPHIMX + + + +
+
+
+ +
+
+

Chào {{ username }} thân mến!

+

Bộ phim trong danh sách Yêu thích của bạn vừa cập nhật tập phim mới cực nóng hổi trên hệ thống TPHIMX!

+ +
+
🎬 {{ movie_name }}
+

Các tập phim mới cập nhật:

+
    + {{ episode_list }} +
+
+ +

Còn chần chừ gì nữa? Hãy chuẩn bị bỏng ngô và click vào nút bên dưới để thưởng thức ngay những tập phim siêu đỉnh chất lượng Full HD vietsub cực mượt thôi nào!

+ + +
+ +
+
+ + diff --git a/src/templates/email/test_email.html b/src/templates/email/test_email.html new file mode 100644 index 0000000000000000000000000000000000000000..0146445ca2efb3fddd04db27274014be55055006 --- /dev/null +++ b/src/templates/email/test_email.html @@ -0,0 +1,185 @@ + + + + + Kết Nối SMTP Thử Nghiệm Thành Công - TPHIMX + + + +
+
+ +
+
+
SMTP TEST SUCCESS
+

Kết nối SMTP hoàn tất!

+

Xin chào quản trị viên, thư điện tử này được gửi tự động để kiểm tra và xác nhận cấu hình máy chủ gửi thư SMTP trên nền tảng {{site_name}} của bạn hoạt động hoàn hảo.

+ +

Dưới đây là thông số kết nối đã kiểm thử thành công:

+ + + + + + + + + + + + + + + + + + + + + + +
SMTP Host{{smtp_host}}
SMTP Port{{smtp_port}}
Bảo mật{{smtp_secure}}
Tài khoản gửi{{smtp_user}}
Thời gian gửi{{test_time}}
+ + + +

Nếu bạn nhận được thư này đúng hòm thư mong muốn, bạn có thể hoàn toàn yên tâm hệ thống thông báo tập mới, đặt lại mật khẩu và liên hệ của website đang hoạt động ổn định.

+
+ +
+ + diff --git a/src/templates/email/verify-email.html b/src/templates/email/verify-email.html new file mode 100644 index 0000000000000000000000000000000000000000..1fe22b3ee788bb9550dea970fe1e59b0c7b9a47b --- /dev/null +++ b/src/templates/email/verify-email.html @@ -0,0 +1,132 @@ + + + + + Xác minh tài khoản của bạn tại TPHIMX + + + +
+
+ +
+
+

Xác minh địa chỉ Email

+

Xin chào {{username}},

+

Cảm ơn bạn đã đăng ký tài khoản tại TPHIMX. Để hoàn tất quy trình kích hoạt và bắt đầu thưởng thức các bộ phim hấp dẫn, vui lòng nhấp vào liên kết dưới đây để xác minh địa chỉ email của bạn:

+ + + +

Nếu nút phía trên không hoạt động, bạn cũng có thể sao chép liên kết này và dán vào thanh địa chỉ của trình duyệt:

+

{{verify_url}}

+ +
+

Lưu ý quan trọng: Liên kết xác minh này chỉ có hiệu lực trong vòng {{expiry_time}} giây. Hết thời gian này, bạn sẽ phải thực hiện lại quy trình gửi mã xác minh.

+
+
+ +
+ + diff --git a/src/templates/email/welcome.html b/src/templates/email/welcome.html new file mode 100644 index 0000000000000000000000000000000000000000..c7cee245e962f840a950e2a9cb32e5c6a1016971 --- /dev/null +++ b/src/templates/email/welcome.html @@ -0,0 +1,115 @@ + + + + + Chào mừng bạn đến với TPHIMX + + + +
+
+ +
+
+

Chào mừng bạn, {{username}}!

+

Chúc mừng bạn đã trở thành thành viên chính thức của đại gia đình TPHIMX - Nền tảng xem phim trực tuyến chất lượng cao với âm thanh sống động và trải nghiệm rạp phim đỉnh cao ngay tại nhà.

+

Tài khoản của bạn đã được khởi tạo thành công. Hãy bắt đầu khám phá kho phim bom tấn đồ sộ, thiết lập danh sách yêu thích và đồng bộ hóa lịch sử xem phim của bạn ngay hôm nay.

+ + + +

Nếu bạn gặp bất kỳ khó khăn nào trong quá trình trải nghiệm dịch vụ, vui lòng liên hệ với ban quản trị hỗ trợ của chúng tôi để được trợ giúp sớm nhất.

+
+ +
+ + diff --git a/src/templates/email/zalo_access_request.html b/src/templates/email/zalo_access_request.html new file mode 100644 index 0000000000000000000000000000000000000000..d670caf31b5f5ebb9d8fa027087f7d68736ad1dc --- /dev/null +++ b/src/templates/email/zalo_access_request.html @@ -0,0 +1,155 @@ + + + + + Yêu cầu duyệt tham gia Zalo Group mới | TPHIMX + + + +
+
+ +
+
+

Yêu cầu phê duyệt tham gia Zalo Group

+

Chào Admin,

+

Hệ thống vừa nhận được một yêu cầu duyệt quyền truy cập mới từ một thành viên tham gia nhóm Zalo. Vui lòng kiểm tra và duyệt quyền truy cập trong trang quản trị:

+ +
+
+ Tên/Nick Zalo: + {{zalo_nickname}} +
+
+ Mã trình duyệt: + {{browser_token}} +
+
+ Thời gian gửi: + {{request_time}} +
+
+ + + +

Yêu cầu này sẽ ở trạng thái chờ duyệt cho đến khi bạn bấm xác nhận trong hệ thống quản trị.

+
+ +
+ + diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..4ae5fe02a408f8cc2564e80021e2396c74e3533a --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "./node_modules/astro/tsconfigs/strict.json", + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "react", + "baseUrl": ".", + "paths": { + "@/*": ["src/*"] + } + } +}