@geekapps/silo-elements-nextjs 0.3.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -396,9 +396,54 @@ function ImageUploader({
396
396
  ] })
397
397
  ] });
398
398
  }
399
- var CODECS = [
400
- { value: "h264", label: "H.264 (NVENC)", hint: "Compatibilidade m\xE1xima \u2014 GPU accelerated" },
401
- { value: "h265", label: "H.265 (NVENC)", hint: "Melhor compress\xE3o \u2014 GPU accelerated" }
399
+ var VIDEO_CODECS = [
400
+ {
401
+ value: "h264",
402
+ label: "H.264",
403
+ description: "Compatibilidade universal \u2014 funciona em todos os players, browsers e Smart TVs."
404
+ },
405
+ {
406
+ value: "h265",
407
+ label: "H.265",
408
+ description: "50% menor que H.264 com a mesma qualidade. Requer player moderno."
409
+ },
410
+ {
411
+ value: "av1",
412
+ label: "AV1",
413
+ description: "M\xE1xima efici\xEAncia \u2014 at\xE9 50% menor que H.265. Chrome 70+, Firefox 67+, Safari 17+.",
414
+ warning: "N\xE3o suportado em iPhones antigos (iOS < 16) e Smart TVs antigas."
415
+ }
416
+ ];
417
+ var AUDIO_SIMPLE = [
418
+ {
419
+ value: "passthrough",
420
+ label: "Preservar original",
421
+ badge: "Recomendado",
422
+ description: "Copia o \xE1udio sem reencodar quando compat\xEDvel com HLS (AAC, AC3, E-AC3). Converte para AAC est\xE9reo como fallback."
423
+ },
424
+ {
425
+ value: "aac",
426
+ label: "AAC",
427
+ description: "Compatibilidade m\xE1xima. Funciona em todos os players e dispositivos."
428
+ },
429
+ {
430
+ value: "opus",
431
+ label: "Opus",
432
+ description: "Melhor efici\xEAncia que AAC. Suportado em Chrome, Firefox e Android. N\xE3o suportado em Safari/iOS."
433
+ }
434
+ ];
435
+ var AUDIO_ADVANCED_CODEC = [
436
+ { value: "passthrough", label: "Original", description: "Passthrough quando HLS-compat\xEDvel, AAC como fallback." },
437
+ { value: "aac", label: "AAC", description: "Compatibilidade m\xE1xima." },
438
+ { value: "opus", label: "Opus", description: "Melhor efici\xEAncia que AAC. Chrome/Firefox/Android." },
439
+ { value: "ac3", label: "AC3", description: "Dolby Digital. Compat\xEDvel com HLS e home theaters." },
440
+ { value: "eac3", label: "E-AC3", description: "Dolby Digital Plus. Suporta Atmos. Netflix, Disney+, Apple TV+." }
441
+ ];
442
+ var AUDIO_CHANNELS = [
443
+ { value: "original", label: "Original", description: "Mant\xE9m os canais do arquivo fonte." },
444
+ { value: "stereo", label: "Est\xE9reo", description: "2.0 \u2014 compat\xEDvel com todos os dispositivos." },
445
+ { value: "5.1", label: "5.1", description: "Surround 5.1." },
446
+ { value: "7.1", label: "7.1", description: "Surround 7.1." }
402
447
  ];
403
448
  var RESOLUTIONS = ["144", "240", "360", "480", "720", "1080", "1440", "2160"];
404
449
  var RESOLUTION_LABELS = {
@@ -412,19 +457,40 @@ var RESOLUTION_LABELS = {
412
457
  "2160": "4K"
413
458
  };
414
459
  function optBtnStyle(active) {
415
- return active ? { border: "1px solid #6366f1", background: "#6366f1", color: "#fff", padding: "4px 10px", borderRadius: 6, fontSize: 12, fontWeight: 600, cursor: "pointer", minWidth: 36 } : { border: "1px solid rgba(255,255,255,0.2)", background: "rgba(255,255,255,0.06)", color: "rgba(255,255,255,0.8)", padding: "4px 10px", borderRadius: 6, fontSize: 12, fontWeight: 600, cursor: "pointer", minWidth: 36 };
460
+ return active ? { border: "1px solid #6366f1", background: "#6366f1", color: "#fff", padding: "4px 10px", borderRadius: 6, fontSize: 12, fontWeight: 600, cursor: "pointer" } : { border: "1px solid rgba(255,255,255,0.2)", background: "rgba(255,255,255,0.06)", color: "rgba(255,255,255,0.8)", padding: "4px 10px", borderRadius: 6, fontSize: 12, fontWeight: 600, cursor: "pointer" };
461
+ }
462
+ function SectionLabel({ children }) {
463
+ return /* @__PURE__ */ jsx("div", { style: { fontSize: 11, fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.05em", marginBottom: 6, color: "rgba(255,255,255,0.35)" }, children });
464
+ }
465
+ function Hint({ children }) {
466
+ return /* @__PURE__ */ jsx("p", { style: { marginTop: 5, fontSize: 11, color: "rgba(255,255,255,0.4)", lineHeight: 1.5 }, children });
416
467
  }
417
- function Toggle({ checked, onToggle, label }) {
418
- return /* @__PURE__ */ jsxs("div", { style: { display: "inline-flex", alignItems: "center", gap: 8, cursor: "pointer", userSelect: "none" }, onClick: onToggle, children: [
419
- /* @__PURE__ */ jsx("span", { style: { position: "relative", display: "inline-block", width: 32, height: 18, borderRadius: 9, flexShrink: 0, cursor: "pointer", background: checked ? "#6366f1" : "rgba(255,255,255,0.15)", transition: "background 150ms" }, children: /* @__PURE__ */ jsx("span", { style: { position: "absolute", top: 2, left: checked ? 16 : 2, width: 14, height: 14, borderRadius: "50%", background: "#fff", boxShadow: "0 1px 3px rgba(0,0,0,.3)", transition: "left 150ms" } }) }),
420
- /* @__PURE__ */ jsx("span", { style: { fontSize: 12, fontWeight: 500, color: "rgba(255,255,255,0.85)" }, children: label })
468
+ function Warning({ children }) {
469
+ return /* @__PURE__ */ jsx("div", { style: { marginTop: 5, display: "flex", gap: 5, background: "rgba(251,191,36,0.08)", border: "1px solid rgba(251,191,36,0.2)", borderRadius: 6, padding: "5px 8px" }, children: /* @__PURE__ */ jsxs("span", { style: { fontSize: 11, color: "#fbbf24", lineHeight: 1.5 }, children: [
470
+ "\u26A0 ",
471
+ children
472
+ ] }) });
473
+ }
474
+ function Toggle({ checked, onToggle, label, hint }) {
475
+ return /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "flex-start", gap: 8, cursor: "pointer", userSelect: "none" }, onClick: onToggle, children: [
476
+ /* @__PURE__ */ jsx("span", { style: { position: "relative", display: "inline-block", width: 32, height: 18, borderRadius: 9, flexShrink: 0, marginTop: 1, background: checked ? "#6366f1" : "rgba(255,255,255,0.15)", transition: "background 150ms" }, children: /* @__PURE__ */ jsx("span", { style: { position: "absolute", top: 2, left: checked ? 16 : 2, width: 14, height: 14, borderRadius: "50%", background: "#fff", boxShadow: "0 1px 3px rgba(0,0,0,.3)", transition: "left 150ms" } }) }),
477
+ /* @__PURE__ */ jsxs("div", { children: [
478
+ /* @__PURE__ */ jsx("span", { style: { fontSize: 12, fontWeight: 500, color: "rgba(255,255,255,0.85)" }, children: label }),
479
+ hint && /* @__PURE__ */ jsx("p", { style: { fontSize: 11, color: "rgba(255,255,255,0.4)", marginTop: 1, lineHeight: 1.4 }, children: hint })
480
+ ] })
421
481
  ] });
422
482
  }
423
483
  function VideoOptions({ value, onChange, style }) {
484
+ const [advanced, setAdvanced] = useState(false);
424
485
  const codec = value.codec ?? "h264";
425
486
  const transcoding = value.transcoding ?? "auto";
426
487
  const isAuto = transcoding === "auto";
427
488
  const selectedRes = isAuto ? [] : transcoding;
489
+ const audioCodec = value.audioCodec ?? "passthrough";
490
+ const audioChannels = value.audioChannels ?? "original";
491
+ const preserveAtmos = value.preserveAtmos ?? true;
492
+ const hdrMode = value.hdr ?? "preserve";
493
+ const selectedVideoCodec = VIDEO_CODECS.find((c) => c.value === codec);
428
494
  function toggleRes(r) {
429
495
  if (isAuto) {
430
496
  onChange({ ...value, transcoding: [r] });
@@ -433,49 +499,132 @@ function VideoOptions({ value, onChange, style }) {
433
499
  const next = selectedRes.includes(r) ? selectedRes.filter((x) => x !== r) : [...selectedRes, r];
434
500
  onChange({ ...value, transcoding: next.length === 0 ? "auto" : next });
435
501
  }
436
- function toggleFeature(key) {
437
- onChange({ ...value, [key]: !value[key] });
438
- }
439
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", style, children: [
502
+ const showAtmosOption = audioCodec === "eac3" || audioCodec === "passthrough";
503
+ const showAtmosWarning = audioCodec === "aac" || audioCodec === "opus" || audioCodec === "ac3";
504
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", style, children: [
440
505
  /* @__PURE__ */ jsxs("div", { children: [
441
- /* @__PURE__ */ jsx("div", { style: { fontSize: 11, fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.05em", marginBottom: 6, color: "rgba(255,255,255,0.4)" }, children: "Codec" }),
442
- /* @__PURE__ */ jsx("div", { className: "flex gap-1.5 flex-wrap", children: CODECS.map((c) => /* @__PURE__ */ jsx(
506
+ /* @__PURE__ */ jsx(SectionLabel, { children: "Codec de v\xEDdeo" }),
507
+ /* @__PURE__ */ jsx("div", { className: "flex gap-1.5 flex-wrap", children: VIDEO_CODECS.map((c) => /* @__PURE__ */ jsx(
443
508
  "button",
444
509
  {
445
510
  type: "button",
446
- title: c.hint,
447
511
  onClick: () => onChange({ ...value, codec: c.value }),
448
512
  style: optBtnStyle(codec === c.value),
449
513
  children: c.label
450
514
  },
451
515
  c.value
452
- )) })
516
+ )) }),
517
+ selectedVideoCodec && /* @__PURE__ */ jsx(Hint, { children: selectedVideoCodec.description }),
518
+ selectedVideoCodec?.warning && /* @__PURE__ */ jsx(Warning, { children: selectedVideoCodec.warning })
453
519
  ] }),
454
520
  /* @__PURE__ */ jsxs("div", { children: [
455
- /* @__PURE__ */ jsx("div", { style: { fontSize: 11, fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.05em", marginBottom: 6, color: "rgba(255,255,255,0.4)" }, children: "Resolu\xE7\xF5es" }),
521
+ /* @__PURE__ */ jsx(SectionLabel, { children: "Resolu\xE7\xF5es" }),
456
522
  /* @__PURE__ */ jsxs("div", { className: "flex gap-1.5 flex-wrap", children: [
457
523
  /* @__PURE__ */ jsx("button", { type: "button", onClick: () => onChange({ ...value, transcoding: "auto" }), style: optBtnStyle(isAuto), children: "Auto" }),
458
- RESOLUTIONS.map((r) => /* @__PURE__ */ jsx(
524
+ RESOLUTIONS.map((r) => /* @__PURE__ */ jsx("button", { type: "button", onClick: () => toggleRes(r), style: optBtnStyle(!isAuto && selectedRes.includes(r)), children: RESOLUTION_LABELS[r] }, r))
525
+ ] }),
526
+ isAuto && /* @__PURE__ */ jsx(Hint, { children: "Gera todas as resolu\xE7\xF5es at\xE9 a resolu\xE7\xE3o original do v\xEDdeo." })
527
+ ] }),
528
+ !advanced && /* @__PURE__ */ jsxs(Fragment, { children: [
529
+ /* @__PURE__ */ jsxs("div", { children: [
530
+ /* @__PURE__ */ jsx(SectionLabel, { children: "\xC1udio" }),
531
+ /* @__PURE__ */ jsx("div", { className: "flex gap-1.5 flex-wrap", children: AUDIO_SIMPLE.map((a) => /* @__PURE__ */ jsxs(
459
532
  "button",
460
533
  {
461
534
  type: "button",
462
- onClick: () => toggleRes(r),
463
- style: optBtnStyle(!isAuto && selectedRes.includes(r)),
464
- children: RESOLUTION_LABELS[r]
535
+ onClick: () => onChange({ ...value, audioCodec: a.value }),
536
+ style: optBtnStyle(audioCodec === a.value),
537
+ children: [
538
+ a.label,
539
+ "badge" in a && a.badge ? /* @__PURE__ */ jsx("span", { style: { marginLeft: 5, fontSize: 9, fontWeight: 700, background: "rgba(255,255,255,0.15)", borderRadius: 4, padding: "1px 4px", verticalAlign: "middle" }, children: a.badge }) : null
540
+ ]
465
541
  },
466
- r
467
- ))
542
+ a.value
543
+ )) }),
544
+ /* @__PURE__ */ jsx(Hint, { children: AUDIO_SIMPLE.find((a) => a.value === audioCodec)?.description })
545
+ ] }),
546
+ /* @__PURE__ */ jsxs("div", { children: [
547
+ /* @__PURE__ */ jsx(SectionLabel, { children: "HDR" }),
548
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2", children: /* @__PURE__ */ jsx(
549
+ Toggle,
550
+ {
551
+ checked: hdrMode === "preserve",
552
+ onToggle: () => onChange({ ...value, hdr: hdrMode === "preserve" ? "sdr" : "preserve" }),
553
+ label: "Preservar HDR",
554
+ hint: "Mant\xE9m HDR10, HDR10+, HLG e Dolby Vision quando o codec de sa\xEDda suporta (H.265 e AV1). Ignorado para H.264."
555
+ }
556
+ ) })
557
+ ] })
558
+ ] }),
559
+ advanced && /* @__PURE__ */ jsxs(Fragment, { children: [
560
+ /* @__PURE__ */ jsxs("div", { children: [
561
+ /* @__PURE__ */ jsx(SectionLabel, { children: "Codec de \xE1udio" }),
562
+ /* @__PURE__ */ jsx("div", { className: "flex gap-1.5 flex-wrap", children: AUDIO_ADVANCED_CODEC.map((a) => /* @__PURE__ */ jsx(
563
+ "button",
564
+ {
565
+ type: "button",
566
+ onClick: () => onChange({ ...value, audioCodec: a.value }),
567
+ style: optBtnStyle(audioCodec === a.value),
568
+ children: a.label
569
+ },
570
+ a.value
571
+ )) }),
572
+ /* @__PURE__ */ jsx(Hint, { children: AUDIO_ADVANCED_CODEC.find((a) => a.value === audioCodec)?.description }),
573
+ showAtmosWarning && /* @__PURE__ */ jsx(Warning, { children: "Este codec n\xE3o preserva Dolby Atmos. Use E-AC3 ou Original para manter Atmos." })
574
+ ] }),
575
+ /* @__PURE__ */ jsxs("div", { children: [
576
+ /* @__PURE__ */ jsx(SectionLabel, { children: "Canais" }),
577
+ /* @__PURE__ */ jsx("div", { className: "flex gap-1.5 flex-wrap", children: AUDIO_CHANNELS.map((c) => /* @__PURE__ */ jsx(
578
+ "button",
579
+ {
580
+ type: "button",
581
+ onClick: () => onChange({ ...value, audioChannels: c.value }),
582
+ style: optBtnStyle(audioChannels === c.value),
583
+ children: c.label
584
+ },
585
+ c.value
586
+ )) }),
587
+ /* @__PURE__ */ jsx(Hint, { children: AUDIO_CHANNELS.find((c) => c.value === audioChannels)?.description })
588
+ ] }),
589
+ showAtmosOption && /* @__PURE__ */ jsxs("div", { children: [
590
+ /* @__PURE__ */ jsx(SectionLabel, { children: "Atmos" }),
591
+ /* @__PURE__ */ jsx(
592
+ Toggle,
593
+ {
594
+ checked: preserveAtmos,
595
+ onToggle: () => onChange({ ...value, preserveAtmos: !preserveAtmos }),
596
+ label: "Preservar Dolby Atmos quando dispon\xEDvel",
597
+ hint: "Mant\xE9m os metadados Atmos no E-AC3 de sa\xEDda. Efetivo somente com codec E-AC3 ou Original."
598
+ }
599
+ )
600
+ ] }),
601
+ /* @__PURE__ */ jsxs("div", { children: [
602
+ /* @__PURE__ */ jsx(SectionLabel, { children: "HDR" }),
603
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-1.5 flex-wrap", children: [
604
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: () => onChange({ ...value, hdr: "preserve" }), style: optBtnStyle(hdrMode === "preserve"), children: "Preservar HDR" }),
605
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: () => onChange({ ...value, hdr: "sdr" }), style: optBtnStyle(hdrMode === "sdr"), children: "Converter para SDR" })
606
+ ] }),
607
+ /* @__PURE__ */ jsx(Hint, { children: hdrMode === "preserve" ? "HDR10, HDR10+, HLG e Dolby Vision s\xE3o preservados com H.265 e AV1. H.264 ignora HDR." : "Tonemapping para SDR \u2014 compat\xEDvel com todos os displays." })
468
608
  ] })
469
609
  ] }),
470
610
  /* @__PURE__ */ jsxs("div", { children: [
471
- /* @__PURE__ */ jsx("div", { style: { fontSize: 11, fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.05em", marginBottom: 8, color: "var(--silo-text-muted)" }, children: "Recursos" }),
472
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
473
- /* @__PURE__ */ jsx(Toggle, { checked: value.thumbnails ?? true, onToggle: () => toggleFeature("thumbnails"), label: "Gerar thumbnails" }),
474
- /* @__PURE__ */ jsx(Toggle, { checked: value.storyboard ?? false, onToggle: () => toggleFeature("storyboard"), label: "Gerar storyboard" }),
475
- /* @__PURE__ */ jsx(Toggle, { checked: value.autoCaptions ?? false, onToggle: () => toggleFeature("autoCaptions"), label: "Legendas autom\xE1ticas (IA)" }),
476
- /* @__PURE__ */ jsx(Toggle, { checked: value.separateAudio ?? false, onToggle: () => toggleFeature("separateAudio"), label: "Separar faixa de \xE1udio" })
611
+ /* @__PURE__ */ jsx(SectionLabel, { children: "Recursos" }),
612
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2.5", children: [
613
+ /* @__PURE__ */ jsx(Toggle, { checked: value.thumbnails ?? true, onToggle: () => onChange({ ...value, thumbnails: !(value.thumbnails ?? true) }), label: "Gerar thumbnails" }),
614
+ /* @__PURE__ */ jsx(Toggle, { checked: value.storyboard ?? false, onToggle: () => onChange({ ...value, storyboard: !value.storyboard }), label: "Gerar storyboard" }),
615
+ /* @__PURE__ */ jsx(Toggle, { checked: value.autoCaptions ?? false, onToggle: () => onChange({ ...value, autoCaptions: !value.autoCaptions }), label: "Legendas autom\xE1ticas (IA)" }),
616
+ /* @__PURE__ */ jsx(Toggle, { checked: value.separateAudio ?? false, onToggle: () => onChange({ ...value, separateAudio: !value.separateAudio }), label: "Separar faixa de \xE1udio" })
477
617
  ] })
478
- ] })
618
+ ] }),
619
+ /* @__PURE__ */ jsx(
620
+ "button",
621
+ {
622
+ type: "button",
623
+ onClick: () => setAdvanced((v) => !v),
624
+ style: { alignSelf: "flex-start", fontSize: 11, color: "rgba(255,255,255,0.35)", background: "none", border: "none", cursor: "pointer", padding: 0, textDecoration: "underline", textUnderlineOffset: 3 },
625
+ children: advanced ? "\u2190 Modo simples" : "Op\xE7\xF5es avan\xE7adas \u2192"
626
+ }
627
+ )
479
628
  ] });
480
629
  }
481
630
  var DEFAULT_VIDEO_OPTS = {
@@ -1310,6 +1459,8 @@ function Video({
1310
1459
  const ageRatingWrapRef = useRef(null);
1311
1460
  const ageRatingIconRef = useRef(null);
1312
1461
  const ageRatingTextRef = useRef(null);
1462
+ const ageRatingShownRef = useRef(false);
1463
+ const ageRatingQueuedRef = useRef(false);
1313
1464
  const [clickIcon, setClickIcon] = useState(null);
1314
1465
  const clickIconTimerRef = useRef(null);
1315
1466
  const clickIconRef = useRef(null);
@@ -1384,9 +1535,6 @@ function Video({
1384
1535
  setControlsVisible(false);
1385
1536
  }, 2400);
1386
1537
  }
1387
- if (video?.paused) {
1388
- showAgeRatingRef.current?.();
1389
- }
1390
1538
  }, [autoHideControls]);
1391
1539
  useEffect(() => {
1392
1540
  if (!containerRef.current) return;
@@ -1557,7 +1705,9 @@ function Video({
1557
1705
  );
1558
1706
  }
1559
1707
  tl.to({}, { duration: HOLD });
1560
- tl.to(wrap, { opacity: 0, duration: 0.7, ease: "power2.inOut" });
1708
+ tl.to(wrap, { opacity: 0, duration: 0.7, ease: "power2.inOut", onComplete: () => {
1709
+ ageRatingShownRef.current = true;
1710
+ } });
1561
1711
  ageRatingTlRef.current = tl;
1562
1712
  };
1563
1713
  showAgeRatingRef.current = showAgeRating;
@@ -1567,10 +1717,10 @@ function Video({
1567
1717
  window.clearTimeout(ageRatingPauseTimerRef.current);
1568
1718
  ageRatingPauseTimerRef.current = null;
1569
1719
  }
1570
- setHasPlayed((prev) => {
1571
- if (!prev) showAgeRating();
1572
- return true;
1573
- });
1720
+ const shouldShow = !ageRatingShownRef.current || ageRatingQueuedRef.current;
1721
+ ageRatingQueuedRef.current = false;
1722
+ if (shouldShow) showAgeRating();
1723
+ setHasPlayed(true);
1574
1724
  showControlsTemporarily();
1575
1725
  };
1576
1726
  const onPause = () => {
@@ -1580,7 +1730,7 @@ function Video({
1580
1730
  if (parsed.ageRating?.data) {
1581
1731
  if (ageRatingPauseTimerRef.current) window.clearTimeout(ageRatingPauseTimerRef.current);
1582
1732
  ageRatingPauseTimerRef.current = window.setTimeout(() => {
1583
- showAgeRating();
1733
+ ageRatingQueuedRef.current = true;
1584
1734
  ageRatingPauseTimerRef.current = null;
1585
1735
  }, 60 * 1e3);
1586
1736
  }