extract-youtube 1.0.451 → 1.0.453

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty;let o=require("react");var s,l,c;c=null!=(s=o)?e(i(s)):{},o=((e,i,o,s)=>{if(i&&"object"==typeof i||"function"==typeof i)for(var l,c=r(i),d=0,u=c.length;d<u;d++)l=c[d],a.call(e,l)||l===o||t(e,l,{get:(e=>i[e]).bind(null,l),enumerable:!(s=n(i,l))||s.enumerable});return e})(!l&&s&&s.__esModule&&a.call(s,"default")?c:t(c,"default",{value:s,enumerable:!0}),s);let d=require("lucide-react"),u=require("react/jsx-runtime"),p=require("react-dom");var g=new Map;function y(e,t){const{transcriptUrl:n,fetchTranscript:r}=t;if(r)return r(e).then(h);if(!n)return Promise.reject(new Error("No transcriptUrl or fetchTranscript provided"));const i=g.get(e);if(i)return i;const a=fetch(function(e,t){return e.includes("videoId=")?e:`${e}${e.includes("?")?"&":"?"}videoId=${encodeURIComponent(t)}`}(n,e)).then(e=>e.json()).then(h).catch(t=>{throw setTimeout(()=>{g.get(e)===a&&g.delete(e)},6e4),t});return g.set(e,a),a}function h(e){if(!e||e.error)throw new Error(e?.error||"Failed to load transcript");return e.snippets??[]}function b(e,t,n){const[r,i]=(0,o.useState)(null),[a,s]=(0,o.useState)(!1),[l,c]=(0,o.useState)(null),{transcriptUrl:d,fetchTranscript:u}=n;return(0,o.useEffect)(()=>{if(!t||!e)return;let n=!1;return s(!0),c(null),i(null),y(e,{transcriptUrl:d,fetchTranscript:u}).then(e=>{n||i(e)}).catch(e=>{n||c(e instanceof Error?e.message:"Failed to load transcript")}).finally(()=>{n||s(!1)}),()=>{n=!0}},[t,e,d,u]),{snippets:r,loading:a,error:l}}var m=/[.!?…]["')\]]*$/,x=/^(?:[A-Za-z]\.)+$|^(?:mr|mrs|ms|dr|prof|sr|jr|st|vs|etc|no|fig|approx|e\.g|i\.e)\.$/i;function f(e){const t=[];let n=[],r=0,i=0,a=0;const o=()=>{0!==n.length&&(t.push({text:n.join(" "),start:i,duration:Math.max(0,a-i)}),n=[],r=0)};for(const s of e){const e=s.text.split(/\s+/).filter(Boolean);if(0===e.length)continue;const t=s.duration>0?s.duration/e.length:0;e.forEach((e,l)=>{0===n.length&&(i=s.start+t*l),n.push(e),r+=e.length+1,a=s.start+t*(l+1),(m.test(e)&&!x.test(e)||r>=220)&&o()})}return o(),t}var v=(0,o.forwardRef)(function({snippet:e,isActive:t,currentTime:n,onSeek:r},i){const a=(0,o.useMemo)(()=>e.text.split(/\s+/).filter(Boolean),[e.text]),s=t&&e.duration>0?Math.min(a.length-1,Math.max(0,Math.floor((n-e.start)/e.duration*a.length))):-1;return(0,u.jsx)("button",{ref:i,type:"button",onClick:e=>{e.stopPropagation(),r()},className:"eyt-line"+(t?" eyt-line-active":""),children:a.map((e,t)=>(0,u.jsxs)("span",{className:t===s?"eyt-word-active":void 0,children:[e," "]},t))})});function w({videoId:e,title:t,transcriptUrl:n,fetchTranscript:r,snippets:i,trigger:a,onOpenChange:s}){const[l,c]=(0,o.useState)(!1),[p,g]=(0,o.useState)(i??null),[h,b]=(0,o.useState)(!1),[m,x]=(0,o.useState)(0),w=(0,o.useRef)(null),k=(0,o.useRef)([]),N=(0,o.useCallback)(e=>{c(e),s?.(e)},[s]);(0,o.useEffect)(()=>{if(!l||i)return;let t=!1;return b(!0),g(null),x(0),y(e,{transcriptUrl:n,fetchTranscript:r}).then(e=>{t||g(e)}).catch(()=>{}).finally(()=>{t||b(!1)}),()=>{t=!0}},[l,e,n,r,i]),(0,o.useEffect)(()=>{if(!l)return;const e=e=>{if("https://www.youtube.com"===e.origin)try{const t=JSON.parse(e.data);"infoDelivery"===t.event&&null!=t.info?.currentTime&&x(t.info.currentTime)}catch{}};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[l]),(0,o.useEffect)(()=>{if(!l)return;const e=e=>{"Escape"===e.key&&N(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[l,N]);const C=(0,o.useCallback)(()=>{w.current?.contentWindow?.postMessage(JSON.stringify({event:"listening",id:e,channel:"widget"}),"https://www.youtube.com")},[e]),S=(0,o.useCallback)(e=>{const t=w.current?.contentWindow;t&&(t.postMessage(JSON.stringify({event:"command",func:"seekTo",args:[e,!0]}),"https://www.youtube.com"),t.postMessage(JSON.stringify({event:"command",func:"playVideo",args:[]}),"https://www.youtube.com"))},[]),z=(0,o.useMemo)(()=>p?f(p):null,[p]),T=h||(z?.length??0)>0,P=(0,o.useMemo)(()=>{if(!z||0===z.length)return-1;let e=-1;for(let t=0;t<z.length&&z[t].start<=m;t++)e=t;return e},[z,m]);return(0,o.useEffect)(()=>{P<0||k.current[P]?.scrollIntoView({block:"nearest",behavior:"smooth"})},[P]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("style",{children:j}),a?(0,u.jsx)("span",{onClick:()=>N(!0),children:a}):(0,u.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),N(!0)},className:"eyt-trigger","aria-label":"View transcript",title:"Transcript",children:(0,u.jsx)(d.Captions,{size:16})}),l&&(0,u.jsx)("div",{className:"eyt-overlay",onClick:()=>N(!1),children:(0,u.jsxs)("div",{className:"eyt-modal",onClick:e=>e.stopPropagation(),role:"dialog","aria-modal":"true",children:[(0,u.jsxs)("div",{className:"eyt-header",children:[(0,u.jsx)("span",{className:"eyt-title",children:t??e}),(0,u.jsx)("button",{type:"button",className:"eyt-close",onClick:()=>N(!1),"aria-label":"Close",children:(0,u.jsx)(d.X,{size:16})})]}),(0,u.jsxs)("div",{className:"eyt-body"+(T?" eyt-body-split":""),children:[(0,u.jsx)("div",{className:"eyt-player",children:(0,u.jsx)("iframe",{ref:w,src:`https://www.youtube.com/embed/${e}?enablejsapi=1&rel=0`,title:t??e,onLoad:C,className:"eyt-iframe",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),T&&(0,u.jsxs)("div",{className:"eyt-sidebar",children:[(0,u.jsx)("div",{className:"eyt-sidebar-heading",children:"Transcript"}),(0,u.jsxs)("div",{className:"eyt-sidebar-scroll",children:[h&&(0,u.jsxs)("div",{className:"eyt-status",children:[(0,u.jsx)(d.Loader2,{size:16,className:"eyt-spin"}),"Loading transcript..."]}),z?.map((e,t)=>(0,u.jsx)(v,{ref:e=>{k.current[t]=e},snippet:e,isActive:t===P,currentTime:m,onSeek:()=>S(e.start)},t))]})]})]})]})})]})}var j="\n.eyt-trigger { display: inline-flex; align-items: center; justify-content: center; padding: 2px; border: none; background: transparent; border-radius: 4px; color: #6b7280; cursor: pointer; }\n.eyt-trigger:hover { color: #111827; background: rgba(0,0,0,0.05); }\n.eyt-overlay { position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; padding: 16px; }\n.eyt-modal { width: 100%; max-width: 1024px; max-height: 90vh; background: #fff; color: #111827; border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,0.4); }\n.eyt-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid #e5e7eb; flex-shrink: 0; }\n.eyt-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 12px; }\n.eyt-close { border: none; background: transparent; color: #6b7280; cursor: pointer; padding: 4px; border-radius: 6px; display: flex; }\n.eyt-close:hover { background: rgba(0,0,0,0.05); color: #111827; }\n.eyt-body { display: grid; grid-template-columns: 1fr; flex: 1; min-height: 0; }\n@media (min-width: 1024px) { .eyt-body-split { grid-template-columns: 1fr 360px; } }\n.eyt-player { position: relative; width: 100%; background: #000; padding-top: 56.25%; }\n.eyt-iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }\n.eyt-sidebar { display: flex; flex-direction: column; min-height: 0; border-top: 1px solid #e5e7eb; }\n@media (min-width: 1024px) { .eyt-sidebar { border-top: 0; border-left: 1px solid #e5e7eb; } }\n.eyt-sidebar-heading { padding: 8px 12px; font-size: 12px; font-weight: 500; color: #6b7280; border-bottom: 1px solid #e5e7eb; flex-shrink: 0; }\n.eyt-sidebar-scroll { flex: 1; min-height: 280px; max-height: 280px; overflow-y: auto; padding: 8px; }\n@media (min-width: 1024px) { .eyt-sidebar-scroll { max-height: none; } }\n.eyt-status { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #6b7280; padding: 12px; }\n.eyt-spin { animation: eyt-spin 1s linear infinite; }\n@keyframes eyt-spin { to { transform: rotate(360deg); } }\n.eyt-line { display: block; width: 100%; text-align: left; border: none; background: transparent; border-radius: 6px; padding: 6px 8px; font-size: 13px; line-height: 1.5; cursor: pointer; color: inherit; }\n.eyt-line:hover { background: rgba(0,0,0,0.05); }\n.eyt-line-active { background: rgba(59,130,246,0.12); }\n.eyt-word-active { background: rgba(59,130,246,0.3); border-radius: 3px; padding: 0 2px; font-weight: 500; color: #1d4ed8; }\n",k=13;function N({isPlaying:e,isMinimized:t,queueLength:n,isPipSupported:r,isPipActive:i,isSubtitlesOpen:a,showSubtitles:o,showPip:s,extraControls:l,onPlayPause:c,onPlayNext:p,onToggleMinimize:g,onTogglePip:y,onToggleSubtitles:h,onClose:b}){return(0,u.jsxs)("div",{className:"eytp-controls",children:[(0,u.jsx)("button",{type:"button",onClick:c,className:"eytp-btn","aria-label":e?"Pause video":"Play video",title:e?"Pause":"Play",children:e?(0,u.jsx)(d.Pause,{size:k}):(0,u.jsx)(d.Play,{size:k})}),l,n>0&&(0,u.jsxs)("button",{type:"button",onClick:p,className:"eytp-btn","aria-label":"Play next in queue",title:`Skip to next (${n} in queue)`,children:[(0,u.jsx)(d.SkipForward,{size:k}),(0,u.jsx)("span",{className:"eytp-btn-count",children:n})]}),o&&(0,u.jsx)("button",{type:"button",onClick:h,className:"eytp-btn"+(a?" eytp-btn-active":""),"aria-label":a?"Hide subtitles":"Show subtitles",title:a?"Hide subtitles":"Show subtitles",children:(0,u.jsx)(d.Captions,{size:k})}),s&&r&&(0,u.jsx)("button",{type:"button",onClick:y,className:"eytp-btn"+(i?" eytp-btn-active":""),"aria-label":i?"Exit picture-in-picture":"Pop out picture-in-picture",title:i?"Exit picture-in-picture":"Pop out picture-in-picture",children:(0,u.jsx)(d.PictureInPicture2,{size:k})}),(0,u.jsx)("button",{type:"button",onClick:g,className:"eytp-btn","aria-label":t?"Expand player":"Minimize player",title:t?"Expand player":"Minimize player — drag to move, resize from the edges",children:t?(0,u.jsx)(d.Maximize2,{size:k}):(0,u.jsx)(d.Minus,{size:k})}),(0,u.jsx)("button",{type:"button",onClick:b,className:"eytp-btn","aria-label":"Close video",title:"Close player",children:(0,u.jsx)(d.X,{size:k})})]})}function C({queue:e}){return 0===e.length?null:(0,u.jsxs)("div",{className:"eytp-queue",children:[(0,u.jsxs)("div",{className:"eytp-queue-heading",children:[(0,u.jsx)(d.ListVideo,{size:11}),(0,u.jsx)("span",{children:"Up next"})]}),(0,u.jsx)("p",{className:"eytp-queue-next",children:e[0].title??e[0].videoId}),e.length>1&&(0,u.jsxs)("p",{className:"eytp-queue-rest",children:["+",e.length-1," more in queue"]})]})}var S=[{edge:"left",className:"eytp-handle eytp-handle-left"},{edge:"right",className:"eytp-handle eytp-handle-right"},{edge:"bottom-left",className:"eytp-handle eytp-handle-bl"},{edge:"bottom-right",className:"eytp-handle eytp-handle-br"}];function z({isResizing:e,startResize:t}){return(0,u.jsxs)(u.Fragment,{children:[e&&(0,u.jsx)("div",{className:"eytp-resize-shield"}),S.map(({edge:e,className:n})=>(0,u.jsx)("div",{className:n,onMouseDown:n=>{n.preventDefault(),t(n.clientX,n.clientY,e)},onTouchStart:n=>t(n.touches[0].clientX,n.touches[0].clientY,e)},e))]})}var T=(0,o.forwardRef)(function({snippet:e,isActive:t,currentTime:n,onSeek:r},i){const a=(0,o.useMemo)(()=>e.text.split(/\s+/).filter(Boolean),[e.text]),s=t&&e.duration>0?Math.min(a.length-1,Math.max(0,Math.floor((n-e.start)/e.duration*a.length))):-1;return(0,u.jsx)("button",{ref:i,type:"button",onClick:e=>{e.stopPropagation(),r()},className:"eytp-line"+(t?" eytp-line-active":""),children:a.map((e,t)=>(0,u.jsxs)("span",{className:t===s?"eytp-word-active":void 0,children:[e," "]},t))})});function P({sentences:e,currentTime:t,onSeek:n}){const r=(0,o.useRef)([]),i=(0,o.useMemo)(()=>{let n=-1;for(let r=0;r<e.length&&e[r].start<=t;r++)n=r;return n},[e,t]);return(0,o.useEffect)(()=>{i<0||r.current[i]?.scrollIntoView({block:"center",behavior:"smooth"})},[i]),0===e.length?null:(0,u.jsx)("div",{className:"eytp-subtitles",children:e.map((e,a)=>(0,u.jsx)(T,{ref:e=>{r.current[a]=e},snippet:e,isActive:a===i,currentTime:t,onSeek:()=>n(e.start)},a))})}function E(e){const[t,n]=(0,o.useState)(!1),[r,i]=(0,o.useState)(!1),a=(0,o.useRef)(null);(0,o.useEffect)(()=>{n("undefined"!=typeof window&&"documentPictureInPicture"in window)},[]);const s=(0,o.useCallback)(()=>{const t=e.current,n=a.current;t&&n?.parentNode&&(n.after(t),n.remove()),a.current=null,i(!1)},[e]),l=(0,o.useCallback)(()=>{const e="undefined"==typeof window?null:window.documentPictureInPicture?.window;e&&(s(),e.close())},[s]),c=(0,o.useCallback)(async()=>{const t=window.documentPictureInPicture,n=e.current;if(!t||!n)return;if(t.window)return void l();const r=document.createComment("floating-youtube-player-pip-anchor");n.after(r),a.current=r;const o=await t.requestWindow({width:480,height:270});!function(e){Array.from(document.styleSheets).forEach(t=>{try{const n=Array.from(t.cssRules).map(e=>e.cssText).join(""),r=e.document.createElement("style");r.textContent=n,e.document.head.appendChild(r)}catch{if(t.href){const n=e.document.createElement("link");n.rel="stylesheet",n.href=t.href,e.document.head.appendChild(n)}}})}(o),o.document.body.style.margin="0",o.document.body.style.background="#000",o.document.body.style.overflow="hidden",o.document.body.appendChild(n),i(!0),o.addEventListener("pagehide",s,{once:!0})},[e,l,s]);return(0,o.useEffect)(()=>()=>l(),[l]),{isSupported:t,isActive:r,toggle:c,exit:l}}var I="https://www.youtube.com",R={2:"This video link is invalid.",5:"This video can't be played in the current browser.",100:"This video is private or has been removed.",101:"The owner doesn't allow this video to be played outside YouTube.",150:"The owner doesn't allow this video to be played outside YouTube.",153:"YouTube blocked this embed. Reload the page or watch it on YouTube."};function $(e){return R[e]??`The video player reported error ${e}.`}function L(e,t={}){const{autoplay:n=!1,controls:r=!0,startSeconds:i=0}=t,a=new URLSearchParams({enablejsapi:"1",rel:"0",controls:r?"1":"0"});n&&a.set("autoplay","1"),i>0&&a.set("start",String(Math.floor(i)));const o=function(){if("undefined"==typeof window)return null;const{origin:e}=window.location;return e&&"null"!==e?e:null}();return o&&(a.set("origin",o),a.set("widget_referrer",o)),`${I}/embed/${e}?${a.toString()}`}function M(e,t=0){const n=t>0?`&t=${Math.floor(t)}`:"";return`${I}/watch?v=${e}${n}`}function A(e){e?.contentWindow?.postMessage(JSON.stringify({event:"listening",id:e.id||"floating-youtube-player",channel:"widget"}),I)}var D=864e5;function q(e){return`${e}:positions`}function V(e,t,n){try{const r=localStorage.getItem(q(e));let i=r?JSON.parse(r):{};i[t]={savedTime:n,savedAt:Date.now()};const a=Object.entries(i);a.length>50&&(i=Object.fromEntries(a.sort(([,e],[,t])=>t.savedAt-e.savedAt).slice(0,50))),localStorage.setItem(q(e),JSON.stringify(i))}catch{}}var U={activeVideo:null,isMinimized:!1,isPlaying:!1,playbackRate:1,queue:[],startTime:0},O=U,F=new Set;function Y(e){O={...O,...e},F.forEach(e=>e())}function H(e){return F.add(e),()=>F.delete(e)}function W(){return O}function B(){return(0,o.useSyncExternalStore)(H,W,()=>U)}function X(e){return(0,o.useSyncExternalStore)(H,()=>e(O),()=>e(U))}var _={current:null},J={current:null};function Q(e,t=[]){!function(e,t,n=[]){e?.contentWindow?.postMessage(JSON.stringify({event:"command",func:t,args:n}),I)}(_.current,e,t)}var K={current:null},Z={current:null},G={play(e,t={}){const n=O.activeVideo;if(n&&n.videoId!==e.videoId&&J.current){const e=J.current();e>0&&K.current?.(n.videoId,e)}Y({activeVideo:e,isMinimized:!1,isPlaying:!0,startTime:t.startSeconds??Z.current?.(e.videoId)??0,playbackRate:t.playbackRate??O.playbackRate})},close(){Y({activeVideo:null,isPlaying:!1,isMinimized:!1,startTime:0})},setMinimized(e){Y({isMinimized:e})},resume(){Q("playVideo"),Y({isPlaying:!0})},pause(){Q("pauseVideo"),Y({isPlaying:!1})},togglePlay(){O.isPlaying?G.pause():G.resume()},seekTo(e){Q("seekTo",[e,!0]),Q("playVideo")},setPlaybackRate(e){Q("setPlaybackRate",[e]),Y({playbackRate:e})},getCurrentTime:()=>J.current?.()??0,addToQueue(e){O.queue.some(t=>t.videoId===e.videoId)||Y({queue:[...O.queue,e]})},removeFromQueue(e){Y({queue:O.queue.filter(t=>t.videoId!==e)})},setQueue(e){Y({queue:e})},clearQueue(){Y({queue:[]})},playNext(){const[e,...t]=O.queue;e?Y({activeVideo:e,queue:t,isMinimized:!1,isPlaying:!0,startTime:0}):G.close()}},ee=e=>Y({isPlaying:e}),te=e=>Y({playbackRate:e}),ne=e=>Y(e);function re({extraControls:e,renderTitle:t,showSubtitles:n,showPictureInPicture:r=!0,storageKey:i="floating-youtube-player",className:a,onClose:s,minWidth:l,maxWidth:c,transcriptUrl:p,fetchTranscript:g}){const{activeVideo:y,isMinimized:h,isPlaying:m,playbackRate:x,queue:v,startTime:w}=B(),j=(0,o.useRef)(null),k=(0,o.useRef)(null),S=(0,o.useRef)(null),{isSupported:T,isActive:I,toggle:R,exit:U}=E(S),[O,F]=(0,o.useState)(!1),[Y,H]=(0,o.useState)(0),[X,Q]=(0,o.useState)(null),[re,ie]=(0,o.useState)(0),[ae,oe]=(0,o.useState)(null),se=(0,o.useRef)(null),le=(0,o.useRef)(0),ce=(0,o.useRef)(!1),{position:de,isDragging:ue,isResizing:pe,playerWidth:ge,startDrag:ye,startResize:he}=function(e,{minWidth:t=256,maxWidth:n=800}={}){const[r,i]=(0,o.useState)(null),[a,s]=(0,o.useState)(!1),l=(0,o.useRef)(!1),c=(0,o.useRef)({x:0,y:0}),[d,u]=(0,o.useState)(null),[p,g]=(0,o.useState)(!1),y=(0,o.useRef)(!1),h=(0,o.useRef)(null),b=(0,o.useRef)({x:0,width:0,posX:0}),m=(0,o.useCallback)((t,n)=>{const r=e.current;if(!r)return;const a=r.getBoundingClientRect();c.current={x:t-a.left,y:n-a.top},i({x:a.left,y:a.top}),l.current=!0,s(!0)},[e]),x=(0,o.useCallback)((t,n,a)=>{const o=e.current;if(!o)return;const s=o.getBoundingClientRect();r||i({x:s.left,y:s.top}),b.current={x:t,width:o.offsetWidth,posX:s.left},h.current=a,y.current=!0,g(!0)},[e,r]),f=(0,o.useCallback)((t,n)=>{const r=e.current;return r?{x:Math.max(0,Math.min(window.innerWidth-r.offsetWidth,t)),y:Math.max(0,Math.min(window.innerHeight-r.offsetHeight,n))}:{x:t,y:n}},[e]);return(0,o.useEffect)(()=>{const e=e=>{const r=h.current,{x:a,width:o,posX:s}=b.current,l=e-a,c="left"===r||"bottom-left"===r,d=Math.max(t,Math.min(n,o+(c?-l:l)));u(d),c&&i(e=>e?{x:s+(o-d),y:e.y}:e)},r=()=>{if(y.current)return y.current=!1,h.current=null,void g(!1);l.current&&(l.current=!1,s(!1))},a=t=>{y.current?e(t.clientX):l.current&&i(f(t.clientX-c.current.x,t.clientY-c.current.y))},o=t=>{const n=t.touches[0];if(n)return y.current?(e(n.clientX),void t.preventDefault()):void(l.current&&(i(f(n.clientX-c.current.x,n.clientY-c.current.y)),t.preventDefault()))};return document.addEventListener("mousemove",a),document.addEventListener("mouseup",r),document.addEventListener("touchmove",o,{passive:!1}),document.addEventListener("touchend",r),document.addEventListener("touchcancel",r),window.addEventListener("blur",r),()=>{document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",r),document.removeEventListener("touchmove",o),document.removeEventListener("touchend",r),document.removeEventListener("touchcancel",r),window.removeEventListener("blur",r)}},[f,t,n]),{position:r,isDragging:a,isResizing:p,playerWidth:d,startDrag:m,startResize:x}}(k,{minWidth:l,maxWidth:c}),be=Boolean(p||g),{snippets:me}=b(y?.videoId??null,be,{transcriptUrl:p,fetchTranscript:g}),xe=(0,o.useMemo)(()=>me?f(me):[],[me]),fe=n??xe.length>0,ve=(0,o.useCallback)(e=>{j.current=e,_.current=e},[]),we=(0,o.useCallback)(()=>null!==se.current?le.current+(Date.now()-se.current)/1e3:le.current,[]),je=(0,o.useCallback)(()=>{if(!i)return;const e={activeVideo:y,isMinimized:h,playbackRate:x,queue:v};e.activeVideo&&function(e,t){try{const n={...t,savedAt:Date.now()};localStorage.setItem(e,JSON.stringify(n)),V(e,t.video.videoId,t.savedTime)}catch{}}(i,{video:e.activeVideo,isMinimized:e.isMinimized,playbackRate:e.playbackRate,queue:e.queue,savedTime:we()})},[i,y,h,x,v,we]);(0,o.useEffect)(()=>(J.current=we,K.current=i?(e,t)=>V(i,e,t):null,Z.current=i?e=>function(e,t){try{const n=localStorage.getItem(q(e));if(!n)return null;const r=JSON.parse(n),i=r[t];return i?Date.now()-i.savedAt>D?(delete r[t],localStorage.setItem(q(e),JSON.stringify(r)),null):i.savedTime:null}catch{return null}}(i,e):null,()=>{J.current=null,K.current=null,Z.current=null}),[we,i]),(0,o.useEffect)(()=>{if(!i||W().activeVideo)return;const e=function(e){try{const t=localStorage.getItem(e);if(!t)return null;const n=JSON.parse(t);return!n?.video?.videoId||Date.now()-n.savedAt>D?(localStorage.removeItem(e),null):n}catch{return null}}(i);e&&(le.current=e.savedTime,se.current=null,ne({activeVideo:e.video,isMinimized:e.isMinimized,playbackRate:e.playbackRate,queue:e.queue,startTime:e.savedTime,isPlaying:!0}))},[]);const ke=y?.videoId??null;(0,o.useEffect)(()=>{ke&&(Q(null),oe(null),ce.current=!0)},[ke]);const Ne=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(!ke)return;const e=`${ke}@${w}`;Ne.current!==e&&(Ne.current=e,le.current=w,se.current=null)},[ke,w]),(0,o.useEffect)(()=>{const e=e=>{if("https://www.youtube.com"!==e.origin)return;let t;try{t=JSON.parse(e.data)}catch{return}if("onError"===t.event){const e="number"==typeof t.info?t.info:Number(t.info?.errorCode);return void(Number.isNaN(e)||Q(e))}if("onStateChange"===t.event)return Q(null),void(1===t.info||3===t.info?(null===se.current&&(se.current=Date.now()),ee(!0),ce.current&&(ce.current=!1,1!==x&&G.setPlaybackRate(x))):2!==t.info&&0!==t.info||(null!==se.current&&(le.current+=(Date.now()-se.current)/1e3,se.current=null),ee(!1),je()));if("infoDelivery"===t.event&&t.info){if(null!=t.info.errorCode){const e=Number(t.info.errorCode);Number.isNaN(e)||Q(e)}if(null!=t.info.currentTime){const e=t.info.currentTime;le.current=e,null!==se.current&&(se.current=Date.now()),O&&H(e)}null!=t.info.playbackRate&&te(Number(t.info.playbackRate))}};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[je,O,x]),(0,o.useEffect)(()=>{if(!ke)return;let e=0;A(j.current);const t=setInterval(()=>{A(j.current),++e>=12&&clearInterval(t)},400);return()=>clearInterval(t)},[ke,re,ae,I]),(0,o.useEffect)(()=>{if(!m||!ke)return;const e=setInterval(je,1e4);return()=>clearInterval(e)},[m,ke,je]),(0,o.useEffect)(()=>{const e=()=>{"hidden"===document.visibilityState&&je()};return window.addEventListener("beforeunload",je),document.addEventListener("visibilitychange",e),()=>{window.removeEventListener("beforeunload",je),document.removeEventListener("visibilitychange",e)}},[je]);const Ce=(0,o.useCallback)(()=>{oe(we()),R()},[we,R]),Se=(0,o.useCallback)(()=>{Q(null),oe(we()),ie(e=>e+1)},[we]),ze=(0,o.useCallback)(()=>{U(),i&&function(e){try{localStorage.removeItem(e)}catch{}}(i),G.close(),s?.()},[U,i,s]),Te=(0,o.useCallback)(()=>{F(e=>{const t=!e;return t&&h&&G.setMinimized(!1),t})},[h]);if(!y)return null;const Pe={video:y,isPlaying:m,isMinimized:h,playbackRate:x,queue:v,getCurrentTime:we,player:G},Ee=y.title??"Playing video",Ie=ae??w,Re=L(y.videoId,{autoplay:!0,controls:!0,startSeconds:Ie}),$e={...de?{left:de.x,top:de.y,bottom:"auto",right:"auto"}:{},...ge&&!h?{width:ge}:{}};return(0,u.jsxs)("div",{ref:k,className:`eytp-root${h?" eytp-minimized":""}${ue||pe?" eytp-interacting":""}${a?` ${a}`:""}`,style:$e,children:[(0,u.jsxs)("div",{className:"eytp-bar"+(ue?" eytp-grabbing":""),onMouseDown:e=>{e.target.closest("button, a")||(e.preventDefault(),ye(e.clientX,e.clientY))},onTouchStart:e=>{e.target.closest("button, a")||ye(e.touches[0].clientX,e.touches[0].clientY)},children:[(0,u.jsx)("div",{className:"eytp-title",children:t?t(Pe):(0,u.jsx)("span",{className:"eytp-title-text",children:Ee})}),(0,u.jsx)(N,{isPlaying:m,isMinimized:h,queueLength:v.length,isPipSupported:T,isPipActive:I,isSubtitlesOpen:O,showSubtitles:fe,showPip:r,extraControls:"function"==typeof e?e(Pe):e,onPlayPause:G.togglePlay,onPlayNext:G.playNext,onToggleMinimize:()=>G.setMinimized(!h),onTogglePip:Ce,onToggleSubtitles:Te,onClose:ze})]}),O&&!h&&(0,u.jsx)(P,{sentences:xe,currentTime:Y,onSeek:G.seekTo}),(0,u.jsxs)("div",{ref:S,className:`eytp-video${I?" eytp-pip":""}${h&&!I?" eytp-hidden":""}`,children:[(0,u.jsx)("iframe",{ref:ve,src:Re,title:Ee,onLoad:()=>A(j.current),className:"eytp-iframe",referrerPolicy:"strict-origin-when-cross-origin",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0},re),null!==X&&(0,u.jsxs)("div",{className:"eytp-error",children:[(0,u.jsx)(d.AlertCircle,{size:18,color:"currentColor"}),(0,u.jsx)("p",{className:"eytp-error-text",children:$(X)}),(0,u.jsxs)("div",{className:"eytp-error-actions",children:[(0,u.jsx)("button",{type:"button",onClick:Se,className:"eytp-link",children:"Retry"}),(0,u.jsx)("a",{href:M(y.videoId,we()),target:"_blank",rel:"noopener noreferrer",className:"eytp-link",children:"Watch on YouTube"})]})]})]}),!h&&!I&&(0,u.jsx)(C,{queue:v}),!h&&(0,u.jsx)(z,{isResizing:pe,startResize:he})]})}function ie(e){const t=Number(e??0);if(!Number.isFinite(t)||t<0)return"0";if(t<1e3)return String(Math.trunc(t));for(const[n,r]of[[1e9,"B"],[1e6,"M"],[1e3,"K"]])if(t>=n){const e=t/n;return`${e>=100?Math.round(e):Number(e.toFixed(1))}${r}`}return String(t)}function ae(e,t=!1){if(!e)return"";const n=Date.parse(e);if(!Number.isFinite(n))return e;const r=/^\d{4}-\d{2}-\d{2}$/.test(e);return new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",...t?{day:"numeric"}:{},...r?{timeZone:"UTC"}:{}}).format(new Date(n))}function oe(e,t){return null==t||""===t?null:"boolean"===e.type?t?e.label:null:"number"===e.type&&"number"==typeof t?`${e.label}: ${t.toLocaleString()}`:String(t)}function se(e,t){return null==t||""===t?"":"boolean"===e.type?t?"✓":"":"number"===e.type&&"number"==typeof t?t.toLocaleString():String(t)}function le(e){return{videoId:e.videoId,title:e.title,meta:{channel:e.channel,publishedAt:e.publishedAt}}}function ce(e,t="mqdefault"){return`https://i.ytimg.com/vi/${encodeURIComponent(e)}/${t}.jpg`}var de='\n.eytg-root {\n --eytg-bg: #ffffff;\n --eytg-card: #ffffff;\n --eytg-fg: #0f172a;\n --eytg-muted: #64748b;\n --eytg-subtle: #f1f5f9;\n --eytg-border: #e2e8f0;\n --eytg-accent: #2563eb;\n --eytg-accent-fg: #ffffff;\n --eytg-danger: #dc2626;\n --eytg-warn: #b45309;\n --eytg-ok: #15803d;\n --eytg-gold: #ca8a04;\n --eytg-radius: 12px;\n --eytg-card-min: 240px;\n color: var(--eytg-fg);\n font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;\n font-size: 14px;\n line-height: 1.4;\n}\n@media (prefers-color-scheme: dark) {\n :root:not(.light):not([data-theme="light"]) .eytg-root {\n --eytg-bg: #0b1120; --eytg-card: #111827; --eytg-fg: #e5e7eb; --eytg-muted: #94a3b8;\n --eytg-subtle: #1e293b; --eytg-border: #273449; --eytg-accent: #60a5fa; --eytg-accent-fg: #0b1120;\n --eytg-danger: #f87171; --eytg-warn: #fbbf24; --eytg-ok: #4ade80; --eytg-gold: #facc15;\n }\n}\n.dark .eytg-root, [data-theme="dark"] .eytg-root {\n --eytg-bg: #0b1120; --eytg-card: #111827; --eytg-fg: #e5e7eb; --eytg-muted: #94a3b8;\n --eytg-subtle: #1e293b; --eytg-border: #273449; --eytg-accent: #60a5fa; --eytg-accent-fg: #0b1120;\n --eytg-danger: #f87171; --eytg-warn: #fbbf24; --eytg-ok: #4ade80; --eytg-gold: #facc15;\n}\n.eytg-root *, .eytg-root *::before, .eytg-root *::after { box-sizing: border-box; }\n\n/* ── buttons & inputs ─────────────────────────────────────────────────── */\n.eytg-icon-btn {\n display: inline-flex; align-items: center; justify-content: center;\n width: 28px; height: 28px; padding: 0; border: 0; border-radius: 8px;\n background: transparent; color: var(--eytg-muted); cursor: pointer;\n transition: background .15s, color .15s;\n}\n.eytg-icon-btn:hover:not(:disabled) { background: var(--eytg-subtle); color: var(--eytg-fg); }\n.eytg-icon-btn:disabled { opacity: .4; cursor: default; }\n.eytg-icon-btn:focus-visible, .eytg-btn:focus-visible { outline: 2px solid var(--eytg-accent); outline-offset: 1px; }\n.eytg-icon-btn.eytg-on { color: var(--eytg-gold); }\n.eytg-btn {\n display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;\n border: 1px solid var(--eytg-border); border-radius: 8px; background: var(--eytg-card);\n color: var(--eytg-fg); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;\n}\n.eytg-btn:hover:not(:disabled) { background: var(--eytg-subtle); }\n.eytg-btn:disabled { opacity: .5; cursor: default; }\n.eytg-btn-primary { background: var(--eytg-accent); border-color: var(--eytg-accent); color: var(--eytg-accent-fg); }\n.eytg-btn-primary:hover:not(:disabled) { background: var(--eytg-accent); filter: brightness(1.08); }\n.eytg-btn-danger { color: var(--eytg-danger); }\n.eytg-input, .eytg-select, .eytg-textarea {\n height: 32px; padding: 0 10px; border: 1px solid var(--eytg-border); border-radius: 8px;\n background: var(--eytg-card); color: var(--eytg-fg); font: inherit; font-size: 13px; min-width: 0;\n}\n.eytg-textarea { height: auto; min-height: 88px; padding: 8px 10px; resize: vertical; width: 100%; }\n.eytg-input:focus, .eytg-select:focus, .eytg-textarea:focus { outline: 2px solid var(--eytg-accent); outline-offset: -1px; }\n\n/* ── badges ───────────────────────────────────────────────────────────── */\n.eytg-badge {\n display: inline-flex; align-items: center; gap: 4px; max-width: 100%;\n padding: 1px 7px; border-radius: 999px; border: 1px solid var(--eytg-border);\n background: var(--eytg-subtle); color: var(--eytg-muted); font-size: 11px; font-weight: 500;\n white-space: nowrap; overflow: hidden; text-overflow: ellipsis;\n}\nbutton.eytg-badge { cursor: pointer; font-family: inherit; }\nbutton.eytg-badge:hover { color: var(--eytg-fg); }\n.eytg-badge-accent { background: var(--eytg-accent); border-color: var(--eytg-accent); color: var(--eytg-accent-fg); }\n.eytg-badge-gold { background: rgba(202, 138, 4, .14); border-color: rgba(202, 138, 4, .4); color: var(--eytg-gold); }\n.eytg-badge-warn { background: rgba(180, 83, 9, .12); border-color: rgba(180, 83, 9, .35); color: var(--eytg-warn); }\n.eytg-badge-danger { background: rgba(220, 38, 38, .1); border-color: rgba(220, 38, 38, .35); color: var(--eytg-danger); }\n.eytg-badge-ok { background: rgba(21, 128, 61, .1); border-color: rgba(21, 128, 61, .35); color: var(--eytg-ok); }\n\n/* ── grid & card ──────────────────────────────────────────────────────── */\n.eytg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--eytg-card-min)), 1fr)); gap: 16px; }\n.eytg-empty { padding: 32px 16px; text-align: center; color: var(--eytg-muted); border: 1px dashed var(--eytg-border); border-radius: var(--eytg-radius); }\n.eytg-slot { position: relative; height: 100%; }\n.eytg-card {\n position: relative; display: flex; flex-direction: column; height: 100%; overflow: hidden;\n background: var(--eytg-card); border: 1px solid var(--eytg-border); border-radius: var(--eytg-radius);\n transition: box-shadow .2s, transform .2s, border-color .2s;\n}\n.eytg-card:hover { box-shadow: 0 10px 30px -12px rgba(15, 23, 42, .35); transform: translateY(-1px); }\n.eytg-card.eytg-playing { border-color: var(--eytg-accent); box-shadow: 0 0 0 1px var(--eytg-accent); }\n.eytg-card.eytg-hidden { opacity: .6; border-style: dashed; }\n.eytg-thumb {\n position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; padding: 0; border: 0;\n background: var(--eytg-subtle); cursor: pointer; overflow: hidden;\n}\n.eytg-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s; }\n.eytg-card:hover .eytg-thumb img { transform: scale(1.03); }\n.eytg-thumb-play {\n position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;\n color: #fff; background: rgba(0, 0, 0, .35); opacity: 0; transition: opacity .2s;\n}\n.eytg-thumb:hover .eytg-thumb-play, .eytg-thumb:focus-visible .eytg-thumb-play { opacity: 1; }\n.eytg-thumb-badges { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; }\n.eytg-thumb-badges .eytg-badge { background: rgba(0, 0, 0, .7); border-color: transparent; color: #fff; }\n.eytg-thumb-badges .eytg-badge-accent { background: var(--eytg-accent); color: var(--eytg-accent-fg); }\n.eytg-thumb-badges .eytg-badge-gold { background: rgba(0, 0, 0, .7); color: #facc15; }\n.eytg-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255, 255, 255, .35); }\n.eytg-progress > span { display: block; height: 100%; background: #ef4444; }\n.eytg-card-body { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px 4px; flex: 1; min-width: 0; }\n.eytg-card-title {\n margin: 0; font-size: 14px; font-weight: 600; line-height: 1.3; color: var(--eytg-fg);\n display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;\n}\n.eytg-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; color: var(--eytg-muted); font-size: 12px; }\n.eytg-card-meta button { padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }\n.eytg-card-meta button:hover { color: var(--eytg-fg); text-decoration: underline; }\n.eytg-card-badges { display: flex; flex-wrap: wrap; gap: 4px; }\n.eytg-card-desc {\n margin: 0; color: var(--eytg-muted); font-size: 12px;\n display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;\n}\n.eytg-card-actions { display: flex; align-items: center; gap: 2px; padding: 4px 8px 8px; }\n.eytg-card-actions .eytg-spacer { flex: 1; }\n.eytg-hidden-flag { position: absolute; top: 8px; left: 8px; z-index: 2; }\n\n/* ── stack nav ────────────────────────────────────────────────────────── */\n.eytg-stack {\n display: inline-flex; align-items: center; gap: 2px; padding: 1px 4px; font-size: 11px; font-weight: 500;\n color: var(--eytg-muted); border: 1px solid var(--eytg-border); border-radius: 6px; background: var(--eytg-card);\n}\n.eytg-stack-overlay { position: absolute; top: 8px; left: 8px; z-index: 3; background: rgba(255, 255, 255, .92); box-shadow: 0 1px 3px rgba(0,0,0,.15); }\n.dark .eytg-stack-overlay, [data-theme="dark"] .eytg-stack-overlay { background: rgba(17, 24, 39, .92); }\n.eytg-stack button {\n display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px;\n padding: 0; border: 0; border-radius: 4px; background: transparent; color: inherit; cursor: pointer;\n}\n.eytg-stack button:hover { background: var(--eytg-subtle); color: var(--eytg-fg); }\n.eytg-stack-count { font-variant-numeric: tabular-nums; }\n.eytg-stack-label { max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-left: 2px; }\n\n/* ── list / table ─────────────────────────────────────────────────────── */\n.eytg-table-wrap { overflow-x: auto; border: 1px solid var(--eytg-border); border-radius: var(--eytg-radius); background: var(--eytg-card); }\n.eytg-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13px; }\n.eytg-table th {\n position: relative; text-align: left; font-weight: 600; font-size: 12px; color: var(--eytg-muted);\n padding: 8px 10px; border-bottom: 1px solid var(--eytg-border); background: var(--eytg-subtle); white-space: nowrap;\n}\n.eytg-table th.eytg-num, .eytg-table td.eytg-num { text-align: right; font-variant-numeric: tabular-nums; }\n.eytg-th-btn { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }\n.eytg-th-btn:hover { color: var(--eytg-fg); }\n.eytg-table td { padding: 6px 10px; border-bottom: 1px solid var(--eytg-border); vertical-align: middle; overflow: hidden; text-overflow: ellipsis; }\n.eytg-table tr:last-child td { border-bottom: 0; }\n.eytg-row { cursor: pointer; }\n.eytg-row:hover td { background: var(--eytg-subtle); }\n.eytg-row.eytg-playing td { background: rgba(37, 99, 235, .08); }\n.eytg-row-title { display: flex; align-items: center; gap: 10px; min-width: 0; }\n.eytg-row-thumb { flex: none; width: 96px; aspect-ratio: 16 / 9; border-radius: 6px; object-fit: cover; background: var(--eytg-subtle); }\n.eytg-row-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }\n.eytg-row-text strong { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.eytg-row-text span { color: var(--eytg-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.eytg-group-row td { background: var(--eytg-subtle); font-weight: 600; cursor: pointer; }\n.eytg-group-row:hover td { filter: brightness(.97); }\n.eytg-group-label { display: inline-flex; align-items: center; gap: 6px; }\n.eytg-group-count { color: var(--eytg-muted); font-weight: 400; font-size: 12px; }\n.eytg-levels { display: inline-flex; gap: 2px; margin-left: 8px; vertical-align: middle; }\n.eytg-levels button {\n height: 20px; min-width: 24px; padding: 0 4px; border: 1px solid var(--eytg-border); border-radius: 4px;\n background: var(--eytg-card); color: var(--eytg-muted); font: inherit; font-size: 10px; cursor: pointer;\n}\n.eytg-levels button.eytg-on { background: var(--eytg-accent); border-color: var(--eytg-accent); color: var(--eytg-accent-fg); }\n.eytg-resize { position: absolute; top: 0; right: 0; z-index: 1; width: 8px; height: 100%; cursor: col-resize; touch-action: none; user-select: none; }\n.eytg-resize:hover, .eytg-resize:active { background: rgba(37, 99, 235, .35); }\n.eytg-resizing, .eytg-resizing * { cursor: col-resize !important; user-select: none !important; }\n.eytg-row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 2px; }\n\n/* ── admin ────────────────────────────────────────────────────────────── */\n.eytg-admin { display: flex; flex-direction: column; gap: 12px; }\n.eytg-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }\n.eytg-toolbar .eytg-grow { flex: 1 1 200px; }\n.eytg-banner { padding: 8px 12px; border-radius: 8px; font-size: 13px; border: 1px solid var(--eytg-border); background: var(--eytg-subtle); }\n.eytg-banner-error { border-color: rgba(220, 38, 38, .4); color: var(--eytg-danger); background: rgba(220, 38, 38, .06); }\n.eytg-banner-ok { border-color: rgba(21, 128, 61, .35); color: var(--eytg-ok); background: rgba(21, 128, 61, .06); }\n.eytg-pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--eytg-muted); font-size: 12px; }\n.eytg-pager > div { display: flex; gap: 6px; }\n.eytg-overlay {\n position: fixed; inset: 0; z-index: 10000; display: flex; align-items: flex-start; justify-content: center;\n padding: 5vh 16px; background: rgba(15, 23, 42, .55); overflow-y: auto;\n}\n.eytg-dialog {\n width: 100%; max-width: 640px; background: var(--eytg-card); color: var(--eytg-fg);\n border: 1px solid var(--eytg-border); border-radius: var(--eytg-radius); box-shadow: 0 30px 60px -20px rgba(0,0,0,.5);\n}\n.eytg-dialog-sm { max-width: 420px; }\n.eytg-dialog header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--eytg-border); }\n.eytg-dialog header h2 { margin: 0; font-size: 16px; }\n.eytg-dialog-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }\n.eytg-dialog footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--eytg-border); }\n.eytg-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }\n@media (max-width: 560px) { .eytg-form-grid { grid-template-columns: 1fr; } }\n.eytg-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }\n.eytg-field-wide { grid-column: 1 / -1; }\n.eytg-field > span { font-size: 12px; font-weight: 600; color: var(--eytg-muted); }\n.eytg-field small { font-size: 11px; color: var(--eytg-muted); }\n.eytg-check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }\n.eytg-section-title { margin: 4px 0 0; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--eytg-muted); }\n.eytg-spin { animation: eytg-spin 1s linear infinite; }\n@keyframes eytg-spin { to { transform: rotate(360deg); } }\n',ue=(0,o.createContext)(!1);function pe({children:e}){return(0,o.useContext)(ue)?(0,u.jsx)(u.Fragment,{children:e}):(0,u.jsxs)(ue.Provider,{value:!0,children:[(0,u.jsx)("style",{"data-extract-youtube-grid":"",children:de}),e]})}function ge(e,t){return!!e&&("has"in e?e.has(t):e.includes(t))}function ye({title:e,onConfirm:t,onCancel:n}){return(0,u.jsx)("div",{className:"eytg-overlay",role:"presentation",onClick:n,children:(0,u.jsxs)("div",{className:"eytg-dialog eytg-dialog-sm",role:"alertdialog","aria-modal":"true","aria-labelledby":"eytg-hide-title",onClick:e=>e.stopPropagation(),children:[(0,u.jsx)("header",{children:(0,u.jsx)("h2",{id:"eytg-hide-title",children:"Hide this video?"})}),(0,u.jsx)("div",{className:"eytg-dialog-body",children:(0,u.jsxs)("p",{style:{margin:0},children:[e?(0,u.jsx)("strong",{children:e}):"This video"," will be hidden from your listing. You can show it again from the hidden filter."]})}),(0,u.jsxs)("footer",{children:[(0,u.jsx)("button",{type:"button",className:"eytg-btn",onClick:n,children:"Cancel"}),(0,u.jsx)("button",{type:"button",className:"eytg-btn eytg-btn-primary",onClick:t,autoFocus:!0,children:"Hide"})]})]})})}var he=(0,o.memo)(function({video:e,showThumbnail:t=!0,showDescription:n=!1,showFullDate:r=!1,overlay:i,favorites:a,hidden:s,onToggleFavorite:l,onHide:c,onUnhide:p,onPlay:g,showQueueButton:y=!0,showYouTubeLink:h=!0,onBadgeClick:b,customFields:m,getProgress:x,renderActions:f,transcriptUrl:v,fetchTranscript:j}){const{videoId:k}=e,N=X(e=>e.activeVideo?.videoId===k),C=X(e=>e.queue.some(e=>e.videoId===k)),[S,z]=(0,o.useState)(!1),T=e.title||k,P=ge(a,k),E=ge(s,k),I=x?.(k),R=()=>g?g(e):G.play(le(e)),$=(m??[]).filter(e=>e.showOnCard).map(t=>({def:t,text:oe(t,e.custom?.[t.key])})).filter(e=>null!==e.text),L=e.availability&&"available"!==e.availability,M=e=>e?b?(0,u.jsx)("button",{type:"button",onClick:()=>b(e),title:`Filter by ${e}`,children:e}):(0,u.jsx)("span",{children:e}):null;return(0,u.jsxs)(pe,{children:[(0,u.jsxs)("article",{className:`eytg-card${N?" eytg-playing":""}${E?" eytg-hidden":""}`,"aria-label":T,children:[i,E&&!i&&(0,u.jsx)("span",{className:"eytg-hidden-flag eytg-badge",children:"Hidden"}),t&&(0,u.jsxs)("button",{type:"button",className:"eytg-thumb",onClick:R,"aria-label":`Play ${T}`,children:[(0,u.jsx)("img",{src:ce(k),alt:"",loading:"lazy",decoding:"async"}),(0,u.jsx)("span",{className:"eytg-thumb-play","aria-hidden":"true",children:(0,u.jsx)(d.Play,{size:36,fill:"currentColor"})}),(0,u.jsxs)("span",{className:"eytg-thumb-badges",children:[e.featured&&(0,u.jsxs)("span",{className:"eytg-badge eytg-badge-gold",title:"Top pick",children:[(0,u.jsx)(d.Medal,{size:11})," Top pick"]}),N&&(0,u.jsx)("span",{className:"eytg-badge eytg-badge-accent",children:"Playing"}),!N&&C&&(0,u.jsx)("span",{className:"eytg-badge",children:"Queued"})]}),"number"==typeof I&&I>0&&(0,u.jsx)("span",{className:"eytg-progress","aria-label":`${Math.round(100*I)}% watched`,children:(0,u.jsx)("span",{style:{width:`${Math.min(100,Math.round(100*I))}%`}})})]}),(0,u.jsxs)("div",{className:"eytg-card-body",children:[(0,u.jsx)("h3",{className:"eytg-card-title",title:T,children:t?T:(0,u.jsx)("button",{type:"button",onClick:R,style:{all:"unset",cursor:"pointer"},"aria-label":`Play ${T}`,children:T})}),(0,u.jsxs)("div",{className:"eytg-card-meta",children:[M(e.channel),e.publishedAt&&(0,u.jsx)("span",{children:ae(e.publishedAt,r)}),"number"==typeof e.viewCount&&e.viewCount>0&&(0,u.jsxs)("span",{children:[ie(e.viewCount)," views"]}),M(e.category)]}),($.length>0||L)&&(0,u.jsxs)("div",{className:"eytg-card-badges",children:[L&&(0,u.jsx)("span",{className:"eytg-badge eytg-badge-warn",children:"not_embeddable"===e.availability?"Embedding off":"private"===e.availability?"Private":"Removed"}),$.map(({def:e,text:t})=>b?(0,u.jsx)("button",{type:"button",className:"eytg-badge",title:e.label,onClick:()=>b(t),children:t},e.key):(0,u.jsx)("span",{className:"eytg-badge",title:e.label,children:t},e.key))]}),n&&e.description&&(0,u.jsx)("p",{className:"eytg-card-desc",children:e.description})]}),(0,u.jsxs)("div",{className:"eytg-card-actions",children:[l&&(0,u.jsx)("button",{type:"button",className:"eytg-icon-btn"+(P?" eytg-on":""),onClick:()=>l(k),"aria-pressed":P,"aria-label":P?"Remove from favorites":"Add to favorites",title:P?"Remove from favorites":"Add to favorites",children:(0,u.jsx)(d.Star,{size:15,fill:P?"currentColor":"none"})}),y&&(0,u.jsx)("button",{type:"button",className:"eytg-icon-btn",onClick:()=>G.addToQueue(le(e)),disabled:N||C,"aria-label":"Add to queue",title:C?"Already queued":"Add to queue",children:(0,u.jsx)(d.ListPlus,{size:15})}),(v||j)&&(0,u.jsx)(w,{videoId:k,title:T,transcriptUrl:v,fetchTranscript:j}),h&&(0,u.jsx)("a",{className:"eytg-icon-btn",href:`https://www.youtube.com/watch?v=${encodeURIComponent(k)}`,target:"_blank",rel:"noopener noreferrer","aria-label":"Open on YouTube",title:"Open on YouTube",children:(0,u.jsx)(d.ExternalLink,{size:15})}),(0,u.jsx)("span",{className:"eytg-spacer"}),f?.(e),E?p&&(0,u.jsx)("button",{type:"button",className:"eytg-icon-btn",onClick:()=>p(k),"aria-label":"Unhide",title:"Unhide",children:(0,u.jsx)(d.Eye,{size:15})}):c&&(0,u.jsx)("button",{type:"button",className:"eytg-icon-btn",onClick:()=>z(!0),"aria-label":"Hide",title:"Hide",children:(0,u.jsx)(d.EyeOff,{size:15})})]})]}),S&&c&&(0,u.jsx)(ye,{title:T,onCancel:()=>z(!1),onConfirm:()=>{z(!1),c(k)}})]})});function be({index:e,count:t,label:n,onSelect:r,variant:i="overlay",className:a}){if(t<2)return null;const o=e=>n=>{n.preventDefault(),n.stopPropagation(),r((e+t)%t)};return(0,u.jsxs)("div",{className:`eytg-stack${"overlay"===i?" eytg-stack-overlay":""}${a?` ${a}`:""}`,onClick:e=>e.stopPropagation(),role:"group","aria-label":"Stacked playlist",children:[(0,u.jsx)(d.Layers,{size:12,"aria-hidden":"true"}),(0,u.jsx)("button",{type:"button",onClick:o(e-1),"aria-label":"Previous video in this stack",children:(0,u.jsx)(d.ChevronLeft,{size:14})}),(0,u.jsx)("span",{className:"eytg-stack-count",children:`${e+1}/${t}`}),(0,u.jsx)("button",{type:"button",onClick:o(e+1),"aria-label":"Next video in this stack",children:(0,u.jsx)(d.ChevronRight,{size:14})}),n&&(0,u.jsx)("span",{className:"eytg-stack-label",title:n,children:n})]})}function me(e,t){return e.category?.trim()||`Part ${t+1}`}function xe({videos:e,initialIndex:t=0,stackLabel:n=me,...r}){const[i,a]=(0,o.useState)(t),s=Math.min(Math.max(i,0),e.length-1),l=e[s]??e[0];return l?(0,u.jsx)("div",{className:"eytg-slot",children:(0,u.jsx)(he,{...r,video:l,overlay:e.length>1?(0,u.jsx)(be,{index:s,count:e.length,label:n(l,s),onSelect:a}):void 0})}):null}function fe(e){return"string"==typeof e.stackKey&&e.stackKey.length>0?e.stackKey:null}function ve(e,t,n=!0){const r=t??function(e){const t={};for(const n of e){const e=fe(n);e&&(t[e]??(t[e]=[])).push(n)}for(const n of Object.keys(t))t[n].sort((e,t)=>(e.stackPosition??0)-(t.stackPosition??0));return t}(e),i=[],a=new Set;return e.forEach((e,t)=>{const o=n?fe(e):null,s=o?r[o]:void 0;if(!o||!s||s.length<2)return void i.push({key:`${e.videoId}-${t}`,videos:[e],initialIndex:0});if(a.has(o))return;a.add(o);const l=Math.max(0,s.findIndex(t=>t.videoId===e.videoId));i.push({key:`stack-${o}-${t}`,videos:s,initialIndex:l})}),i}var we=(0,o.memo)(function({videos:e,stacks:t,stacksEnabled:n=!0,stackLabel:r,showThumbnails:i=!0,showDescription:a,showFullDate:s,minCardWidth:l,emptyState:c,className:d,containerRef:p,...g}){const y=(0,o.useMemo)(()=>ve(e,t,n),[e,t,n]),h=l?{"--eytg-card-min":"number"==typeof l?`${l}px`:l}:void 0;return(0,u.jsx)(pe,{children:(0,u.jsx)("div",{className:"eytg-root"+(d?` ${d}`:""),style:h,children:0===y.length?(0,u.jsx)("div",{className:"eytg-empty",children:c??"No videos to show."}):(0,u.jsx)("div",{className:"eytg-grid",ref:p,children:y.map(e=>(0,u.jsx)(xe,{videos:e.videos,initialIndex:e.initialIndex,stackLabel:r,showThumbnail:i,showDescription:a,showFullDate:s,...g},e.key))})})})}),je=e=>{const t=e.publishedAt?Date.parse(e.publishedAt):NaN;if(!Number.isFinite(t))return{kind:"year",label:"Undated",sortValue:0,trailing:!0};const n=new Date(t).getUTCFullYear();return{kind:"year",label:String(n),sortValue:-n}},ke=e=>{const t=e.channel?.trim();return{kind:"channel",label:t||"Unsorted",sortValue:t?.toLowerCase()??"",trailing:!t}},Ne=e=>{const t=e.category?.trim();return{kind:"category",label:t||"Unsorted",sortValue:t?.toLowerCase()??"",trailing:!t}};var Ce={year:je,channel:ke,category:Ne};function Se(e){if(!e)return null;const t=Date.parse(e);return Number.isFinite(t)?t:null}function ze(e,t){const n=Se(t);if(null===n)return e;const r=Se(e);return null===r||n<r?t:e}function Te(e,t){const n=Se(t);if(null===n)return e;const r=Se(e);return null===r||n>r?t:e}function Pe(e,t){return e.type!==t.type?"group"===e.type?-1:1:"group"!==e.type||"group"!==t.type?0:e.trailing!==t.trailing?e.trailing?1:-1:"number"==typeof e.sortValue&&"number"==typeof t.sortValue?e.sortValue-t.sortValue:String(e.sortValue).localeCompare(String(t.sortValue))}function Ee(e){e.sort(Pe);for(const t of e)"group"===t.type&&Ee(t.children)}function Ie(e,t){const n=[],r=new Map;for(const i of e){const e=i.videos[i.initialIndex]??i.videos[0];if(!e)continue;const a=i.videos.reduce((e,t)=>e+(t.viewCount??0),0);let o=n,s="";for(const n of t){const t=n(e);if(!t)break;s=s?`${s} / ${t.kind}:${t.label}`:`${t.kind}:${t.label}`;let l=r.get(s);l||(l={type:"group",key:s,kind:t.kind,label:t.label,children:[],videoCount:0,viewCount:0,latestDate:null,earliestDate:null,sortValue:t.sortValue,trailing:t.trailing??!1},r.set(s,l),o.push(l)),l.videoCount+=i.videos.length,l.viewCount+=a,l.latestDate=Te(l.latestDate,e.publishedAt),l.earliestDate=ze(l.earliestDate,e.publishedAt),o=l.children}o.push({type:"video",key:i.key,slot:i})}return Ee(n),n}function Re(e){let t=0;for(const n of e){const e="group"===n.type?1+Re(n.children):1;e>t&&(t=e)}return Math.max(1,t)}function $e(e,t){const n=[...e.filter(e=>"video"===e.type)].sort((e,n)=>t(e.slot,n.slot));let r=0;return e.map(e=>"group"===e.type?{...e,children:$e(e.children,t)}:n[r++])}function Le(e){return e.reduce((e,t)=>e+("group"===t.type?Le(t.children):1),0)}function Me(e,t,n=0){const r=[];for(const i of e)"group"===i.type&&(n>=t&&r.push(i.key),r.push(...Me(i.children,t,n+1)));return r}function Ae(e){const[t,n]=(0,o.useState)(e),r=(0,o.useRef)(null),i=(0,o.useRef)({x:0,width:0}),a=(0,o.useCallback)((e,n)=>{r.current=e,i.current={x:n,width:t[e]??120},document.body.classList.add("eytg-resizing")},[t]),s=(0,o.useCallback)(()=>n(e),[e]);return(0,o.useEffect)(()=>{const e=e=>{const t=r.current;if(!t)return;const a=Math.max(60,Math.min(900,i.current.width+e-i.current.x));n(e=>e[t]===a?e:{...e,[t]:a})},t=()=>{r.current&&(r.current=null,document.body.classList.remove("eytg-resizing"))},a=t=>e(t.clientX),o=t=>{r.current&&(e(t.touches[0].clientX),t.preventDefault())};return document.addEventListener("mousemove",a),document.addEventListener("mouseup",t),document.addEventListener("touchmove",o,{passive:!1}),document.addEventListener("touchend",t),()=>{document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",t),document.removeEventListener("touchmove",o),document.removeEventListener("touchend",t),document.body.classList.remove("eytg-resizing")}},[]),{widths:t,startResize:a,resetWidths:s}}function De({onResizeStart:e,label:t}){return(0,u.jsx)("span",{className:"eytg-resize",role:"separator","aria-orientation":"vertical","aria-label":t?`Resize ${t} column`:"Resize column",onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),e(t.clientX)},onTouchStart:t=>{t.stopPropagation(),e(t.touches[0].clientX)},onClick:e=>e.stopPropagation()})}function qe(e){return{key:`custom:${e.key}`,label:e.label,numeric:"number"===e.type,width:"boolean"===e.type?90:140,value:t=>{const n=t.custom?.[e.key];return"number"==typeof n?n:"boolean"==typeof n?n?1:0:(n??"").toString().toLowerCase()},render:t=>{const n=t.custom?.[e.key];return"url"===e.type&&"string"==typeof n?(0,u.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),children:"Link"}):se(e,n)}}}function Ve(e){return e.videos[e.initialIndex]??e.videos[0]}var Ue=(0,o.memo)(function({slot:e,depth:t,ctx:n}){const[r,i]=(0,o.useState)(e.initialIndex),a=Math.min(Math.max(r,0),e.videos.length-1),s=e.videos[a]??e.videos[0],l=X(e=>e.activeVideo?.videoId===s.videoId),c=X(e=>e.queue.some(e=>e.videoId===s.videoId)),p=ge(n.favorites,s.videoId),g=ge(n.hidden,s.videoId),y=e=>e.stopPropagation();return(0,u.jsxs)("tr",{className:"eytg-row"+(l?" eytg-playing":""),onClick:()=>n.onPlay?n.onPlay(s):G.play(le(s)),style:g?{opacity:.6}:void 0,"aria-label":s.title||s.videoId,children:[n.columns.map(r=>"title"===r.key?(0,u.jsx)("td",{style:{paddingLeft:10+18*t},children:(0,u.jsxs)("div",{className:"eytg-row-title",children:[n.showThumbnails&&(0,u.jsx)("img",{className:"eytg-row-thumb",src:ce(s.videoId),alt:"",loading:"lazy"}),(0,u.jsxs)("div",{className:"eytg-row-text",children:[(0,u.jsx)("strong",{title:s.title,children:s.title||s.videoId}),(0,u.jsx)("span",{children:[s.category,s.featured?"Top pick":null,c&&!l?"Queued":null].filter(Boolean).join(" · ")}),e.videos.length>1&&(0,u.jsx)("div",{onClick:y,children:(0,u.jsx)(be,{variant:"inline",index:a,count:e.videos.length,label:n.stackLabel(s,a),onSelect:i})})]})]})},"title"):(0,u.jsx)("td",{className:r.numeric?"eytg-num":void 0,children:r.render(s)},r.key)),(0,u.jsx)("td",{onClick:y,children:(0,u.jsxs)("div",{className:"eytg-row-actions",children:[n.onToggleFavorite&&(0,u.jsx)("button",{type:"button",className:"eytg-icon-btn"+(p?" eytg-on":""),onClick:()=>n.onToggleFavorite?.(s.videoId),"aria-pressed":p,"aria-label":p?"Remove from favorites":"Add to favorites",children:(0,u.jsx)(d.Star,{size:14,fill:p?"currentColor":"none"})}),!1!==n.showQueueButton&&(0,u.jsx)("button",{type:"button",className:"eytg-icon-btn",onClick:()=>G.addToQueue(le(s)),disabled:l||c,"aria-label":"Add to queue",children:(0,u.jsx)(d.ListPlus,{size:14})}),n.renderActions?.(s),g?n.onUnhide&&(0,u.jsx)("button",{type:"button",className:"eytg-icon-btn",onClick:()=>n.onUnhide?.(s.videoId),"aria-label":"Unhide",children:(0,u.jsx)(d.Eye,{size:14})}):n.onHide&&(0,u.jsx)("button",{type:"button",className:"eytg-icon-btn",onClick:()=>n.onRequestHide(s),"aria-label":"Hide",children:(0,u.jsx)(d.EyeOff,{size:14})})]})})]})});var Oe=(0,o.memo)(function({videos:e,stacks:t,stacksEnabled:n=!0,stackLabel:r=me,groupBy:i,defaultCollapseDepth:a,defaultSort:s,showThumbnails:l=!0,hideChannelColumn:c=!1,emptyState:p,className:g,customFields:y,...h}){const b=(0,o.useMemo)(()=>{const e=[{key:"title",label:"Video",width:l?420:320,value:e=>(e.title??"").toLowerCase(),render:()=>null}];c||e.push({key:"channel",label:"Channel",width:160,value:e=>(e.channel??"").toLowerCase(),render:e=>e.channel??""});for(const t of y??[])t.showInList&&e.push(qe(t));return e.push({key:"date",label:"Date",width:110,value:e=>e.publishedAt&&Date.parse(e.publishedAt)||0,render:e=>ae(e.publishedAt,!0)},{key:"views",label:"Views",numeric:!0,width:90,value:e=>e.viewCount??0,render:e=>ie(e.viewCount)}),e},[y,c,l]),m=(0,o.useMemo)(()=>Object.fromEntries(b.map(e=>[e.key,e.width])),[b]),{widths:x,startResize:f}=Ae(m),[v,w]=(0,o.useState)(s??null),[j,k]=(0,o.useState)(null),N=(0,o.useMemo)(()=>ve(e,t,n),[e,t,n]),C=(0,o.useMemo)(()=>i&&i.length>0?function(e){return e.map(e=>"string"==typeof e?Ce[e]:e)}(i):[],[i]),S=(0,o.useMemo)(()=>Ie(N,C),[N,C]),z=(0,o.useCallback)((e,t)=>{if(!v)return 0;const n=b.find(e=>e.key===v.column);if(!n)return 0;const r=n.value(Ve(e)),i=n.value(Ve(t)),a="number"==typeof r&&"number"==typeof i?r-i:String(r).localeCompare(String(i));return"asc"===v.direction?a:-a},[b,v]),T=(0,o.useMemo)(()=>v?$e(S,z):S,[S,v,z]),P=Re(S),[E,I]=(0,o.useState)(()=>new Set(a?Me(S,a-1):[])),[R,$]=(0,o.useState)(a??P),L={...h,columns:b,showThumbnails:l,stackLabel:r,onRequestHide:k},M=[],A=(e,t)=>{for(const n of e){if("video"===n.type){M.push((0,u.jsx)(Ue,{slot:n.slot,depth:t,ctx:L},n.key));continue}const e=!E.has(n.key);M.push((0,u.jsx)("tr",{className:"eytg-group-row",onClick:()=>{return e=n.key,I(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});var e},"aria-expanded":e,children:(0,u.jsx)("td",{colSpan:b.length+1,style:{paddingLeft:10+18*t},children:(0,u.jsxs)("span",{className:"eytg-group-label",children:[e?(0,u.jsx)(d.ChevronDown,{size:14}):(0,u.jsx)(d.ChevronRight,{size:14}),n.label,(0,u.jsx)("span",{className:"eytg-group-count",children:`${n.videoCount} video${1===n.videoCount?"":"s"} · ${ie(n.viewCount)} views`})]})})},n.key)),e&&A(n.children,t+1)}};return A(T,0),(0,u.jsx)(pe,{children:(0,u.jsxs)("div",{className:"eytg-root"+(g?` ${g}`:""),children:[0===Le(S)?(0,u.jsx)("div",{className:"eytg-empty",children:p??"No videos to show."}):(0,u.jsx)("div",{className:"eytg-table-wrap",children:(0,u.jsxs)("table",{className:"eytg-table",children:[(0,u.jsxs)("colgroup",{children:[b.map(e=>(0,u.jsx)("col",{style:{width:x[e.key]??e.width}},e.key)),(0,u.jsx)("col",{style:{width:120}})]}),(0,u.jsx)("thead",{children:(0,u.jsxs)("tr",{children:[b.map((e,t)=>{const n=v?.column===e.key;return(0,u.jsxs)("th",{className:e.numeric?"eytg-num":void 0,"aria-sort":n?"asc"===v?.direction?"ascending":"descending":"none",children:[(0,u.jsxs)("button",{type:"button",className:"eytg-th-btn",onClick:()=>(e=>w(t=>t?.column===e?{column:e,direction:"asc"===t.direction?"desc":"asc"}:{column:e,direction:"title"===e||"channel"===e?"asc":"desc"}))(e.key),children:[e.label,n&&("asc"===v?.direction?(0,u.jsx)(d.ChevronUp,{size:12}):(0,u.jsx)(d.ChevronDown,{size:12}))]}),0===t&&C.length>0&&P>1&&(0,u.jsx)("span",{className:"eytg-levels",role:"group","aria-label":"Tree level",children:Array.from({length:P},(e,t)=>t+1).map(e=>(0,u.jsx)("button",{type:"button",className:R===e?"eytg-on":void 0,onClick:()=>{return $(t=e),void I(new Set(Me(S,t-1)));var t},title:e===P?"Show every video":`Show ${e} level${1===e?"":"s"}`,children:`L${e}`},e))}),(0,u.jsx)(De,{label:e.label,onResizeStart:t=>f(e.key,t)})]},e.key)}),(0,u.jsx)("th",{"aria-label":"Actions"})]})}),(0,u.jsx)("tbody",{children:M})]})}),j&&h.onHide&&(0,u.jsx)(ye,{title:j.title,onCancel:()=>k(null),onConfirm:()=>{h.onHide?.(j.videoId),k(null)}})]})})});var Fe=["available","private","not_embeddable","removed"],Ye=/^[a-zA-Z0-9_-]{11}$/;var He={available:"Available",private:"Private",not_embeddable:"Embedding disabled",removed:"Removed"};function We(e,t){return"boolean"===e.type?Boolean(t):null==t?"":String(t)}function Be({client:e,video:t,customFields:n=[],categories:r=[],onClose:i,onSaved:a}){const s=null===t,l=(0,o.useMemo)(()=>function(e,t){return{videoInput:e?.videoId??"",title:e?.title??"",channel:e?.channel??"",publishedAt:e?.publishedAt?.slice(0,10)??"",viewCount:e?String(e.viewCount):"",category:e?.category??"",tags:(e?.tags??[]).join(", "),description:e?.description??"",featured:e?.featured??!1,hidden:e?.hidden??!1,availability:e?.availability??"available",custom:Object.fromEntries(t.map(t=>[t.key,We(t,e?.custom?.[t.key])]))}}(t,n),[t,n]),[c,p]=(0,o.useState)(l),[g,y]=(0,o.useState)(!1),[h,b]=(0,o.useState)(!1),[m,x]=(0,o.useState)(null),[f,v]=(0,o.useState)(null);(0,o.useEffect)(()=>p(l),[l]),(0,o.useEffect)(()=>{const e=e=>"Escape"===e.key&&i();return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[i]);const w=t?t.videoId:function(e){const t=e.trim();if(!t)return null;if(Ye.test(t))return t;try{const e=new URL(t),n=e.hostname.replace(/^www\./,"").replace(/^m\./,"");if("youtu.be"===n){const t=e.pathname.slice(1).split("/")[0];return Ye.test(t)?t:null}if("youtube.com"===n||"youtube-nocookie.com"===n){if("/watch"===e.pathname){const t=e.searchParams.get("v");return t&&Ye.test(t)?t:null}const t=e.pathname.match(/^\/(embed|shorts|live)\/([a-zA-Z0-9_-]{11})/);if(t)return t[2]}return null}catch{const e=t.match(/[?&]v=([a-zA-Z0-9_-]{11})/);if(e)return e[1];const n=t.match(/(?:embed|shorts|live|youtu\.be)\/([a-zA-Z0-9_-]{11})/);return n?n[1]:null}}(c.videoInput),j=(e,t)=>p(n=>({...n,[e]:t})),k="eytg-category-options";return(0,u.jsx)(pe,{children:(0,u.jsx)("div",{className:"eytg-root eytg-overlay",role:"presentation",onClick:i,children:(0,u.jsxs)("form",{className:"eytg-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"eytg-edit-title",onClick:e=>e.stopPropagation(),onSubmit:async t=>{if(t.preventDefault(),w)if(c.title.trim()){y(!0),x(null);try{const t=function(e,t,n){const r={},i=r=>n||e[r]!==t[r];i("title")&&(r.title=e.title),i("channel")&&(r.channel=e.channel),i("publishedAt")&&(r.publishedAt=e.publishedAt),i("viewCount")&&(r.viewCount=e.viewCount),i("category")&&(r.category=e.category),i("tags")&&(r.tags=e.tags),i("description")&&(r.description=e.description),i("featured")&&(r.featured=e.featured),i("hidden")&&(r.hidden=e.hidden),i("availability")&&(r.availability=e.availability);const a={};for(const[o,s]of Object.entries(e.custom))(n||s!==t.custom[o])&&(a[o]=s);return Object.keys(a).length>0&&(r.custom=a),r}(c,l,s);a(s?await e.create(w,t):await e.update(w,t))}catch(n){x(n instanceof Error?n.message:String(n))}finally{y(!1)}}else x("A title is required.");else x("That is not a YouTube URL or video id.")},children:[(0,u.jsxs)("header",{children:[(0,u.jsx)("h2",{id:"eytg-edit-title",children:s?"Add video":"Edit video"}),(0,u.jsx)("button",{type:"button",className:"eytg-icon-btn",onClick:i,"aria-label":"Close",children:(0,u.jsx)(d.X,{size:16})})]}),(0,u.jsxs)("div",{className:"eytg-dialog-body",children:[m&&(0,u.jsx)("div",{className:"eytg-banner eytg-banner-error",role:"alert",children:m}),f&&(0,u.jsx)("div",{className:"eytg-banner",children:f}),(0,u.jsxs)("div",{className:"eytg-form-grid",children:[(0,u.jsxs)("label",{className:"eytg-field eytg-field-wide",children:[(0,u.jsx)("span",{children:"YouTube URL or video id"}),(0,u.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,u.jsx)("input",{className:"eytg-input",style:{flex:1},value:c.videoInput,onChange:e=>j("videoInput",e.target.value),disabled:!s,placeholder:"https://www.youtube.com/watch?v=…",required:!0,autoFocus:s}),(0,u.jsxs)("button",{type:"button",className:"eytg-btn",onClick:async()=>{if(w){b(!0),x(null),v(null);try{const t=await e.autofill({videoId:w,title:c.title,channel:c.channel,description:c.description}),{fields:r}=t;p(e=>{const t={...e,custom:{...e.custom}};"string"==typeof r.title&&(t.title=r.title),"string"==typeof r.channel&&(t.channel=r.channel),"string"==typeof r.publishedAt&&(t.publishedAt=r.publishedAt.slice(0,10)),void 0!==r.viewCount&&(t.viewCount=String(r.viewCount)),"string"==typeof r.description&&(t.description=r.description),"string"==typeof r.category&&(t.category=r.category),Array.isArray(r.tags)&&(t.tags=r.tags.join(", ")),"string"==typeof r.availability&&(t.availability=r.availability);for(const i of n){const e=r.custom?.[i.key];null!=e&&""!==e&&(t.custom[i.key]=We(i,e))}return t});const i=t.sources.length>0?`Filled from ${t.sources.join(", ")}.`:"Nothing to fill in.";v([i,...t.warnings].join(" "))}catch(t){x(t instanceof Error?t.message:String(t))}finally{b(!1)}}else x("Enter a YouTube URL or video id first.")},disabled:h||!w,children:[h?(0,u.jsx)(d.Loader2,{size:14,className:"eytg-spin"}):(0,u.jsx)(d.Sparkles,{size:14}),"Auto-fill"]})]}),s&&c.videoInput&&!w&&(0,u.jsx)("small",{children:"Not a recognisable YouTube URL or id."})]}),(0,u.jsxs)("label",{className:"eytg-field eytg-field-wide",children:[(0,u.jsx)("span",{children:"Title"}),(0,u.jsx)("input",{className:"eytg-input",value:c.title,onChange:e=>j("title",e.target.value),required:!0})]}),(0,u.jsxs)("label",{className:"eytg-field",children:[(0,u.jsx)("span",{children:"Channel"}),(0,u.jsx)("input",{className:"eytg-input",value:c.channel,onChange:e=>j("channel",e.target.value)})]}),(0,u.jsxs)("label",{className:"eytg-field",children:[(0,u.jsx)("span",{children:"Published"}),(0,u.jsx)("input",{className:"eytg-input",type:"date",value:c.publishedAt,onChange:e=>j("publishedAt",e.target.value)})]}),(0,u.jsxs)("label",{className:"eytg-field",children:[(0,u.jsx)("span",{children:"Category"}),(0,u.jsx)("input",{className:"eytg-input",list:k,value:c.category,onChange:e=>j("category",e.target.value)}),(0,u.jsx)("datalist",{id:k,children:r.map(e=>(0,u.jsx)("option",{value:e},e))})]}),(0,u.jsxs)("label",{className:"eytg-field",children:[(0,u.jsx)("span",{children:"Views"}),(0,u.jsx)("input",{className:"eytg-input",type:"number",min:0,value:c.viewCount,onChange:e=>j("viewCount",e.target.value)})]}),(0,u.jsxs)("label",{className:"eytg-field eytg-field-wide",children:[(0,u.jsx)("span",{children:"Tags"}),(0,u.jsx)("input",{className:"eytg-input",value:c.tags,onChange:e=>j("tags",e.target.value),placeholder:"comma, separated"})]}),(0,u.jsxs)("label",{className:"eytg-field",children:[(0,u.jsx)("span",{children:"Availability"}),(0,u.jsx)("select",{className:"eytg-select",value:c.availability,onChange:e=>j("availability",e.target.value),children:Fe.map(e=>(0,u.jsx)("option",{value:e,children:He[e]},e))})]}),(0,u.jsxs)("div",{className:"eytg-field",style:{justifyContent:"flex-end",gap:8},children:[(0,u.jsxs)("label",{className:"eytg-check",children:[(0,u.jsx)("input",{type:"checkbox",checked:c.featured,onChange:e=>j("featured",e.target.checked)}),"Top pick"]}),(0,u.jsxs)("label",{className:"eytg-check",children:[(0,u.jsx)("input",{type:"checkbox",checked:c.hidden,onChange:e=>j("hidden",e.target.checked)}),"Hidden from public listings"]})]}),(0,u.jsxs)("label",{className:"eytg-field eytg-field-wide",children:[(0,u.jsx)("span",{children:"Description"}),(0,u.jsx)("textarea",{className:"eytg-textarea",value:c.description,onChange:e=>j("description",e.target.value),rows:4}),(0,u.jsx)("small",{children:"Links to other videos in the library stack them together."})]})]}),n.length>0&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("h3",{className:"eytg-section-title",children:"Custom fields"}),(0,u.jsx)("div",{className:"eytg-form-grid",children:n.map(e=>(0,u.jsx)(Xe,{def:e,value:c.custom[e.key],onChange:t=>((e,t)=>p(n=>({...n,custom:{...n.custom,[e]:t}})))(e.key,t)},e.key))})]})]}),(0,u.jsxs)("footer",{children:[(0,u.jsx)("button",{type:"button",className:"eytg-btn",onClick:i,children:"Cancel"}),(0,u.jsxs)("button",{type:"submit",className:"eytg-btn eytg-btn-primary",disabled:g,children:[g&&(0,u.jsx)(d.Loader2,{size:14,className:"eytg-spin"}),s?"Add video":"Save changes"]})]})]})})})}function Xe({def:e,value:t,onChange:n}){if("boolean"===e.type)return(0,u.jsxs)("div",{className:"eytg-field",style:{justifyContent:"flex-end"},children:[(0,u.jsxs)("label",{className:"eytg-check",children:[(0,u.jsx)("input",{type:"checkbox",checked:Boolean(t),onChange:e=>n(e.target.checked)}),e.label]}),e.help&&(0,u.jsx)("small",{children:e.help})]});const r="string"==typeof t?t:"";return(0,u.jsxs)("label",{className:"eytg-field"+("textarea"===e.type?" eytg-field-wide":""),children:[(0,u.jsx)("span",{children:e.label}),"select"===e.type?(0,u.jsxs)("select",{className:"eytg-select",value:r,onChange:e=>n(e.target.value),children:[(0,u.jsx)("option",{value:"",children:"—"}),(e.options??[]).map(e=>(0,u.jsx)("option",{value:e,children:e},e))]}):"textarea"===e.type?(0,u.jsx)("textarea",{className:"eytg-textarea",value:r,rows:3,onChange:e=>n(e.target.value)}):(0,u.jsx)("input",{className:"eytg-input",type:"number"===e.type?"number":"url"===e.type?"url":"text",value:r,onChange:e=>n(e.target.value)}),e.help&&(0,u.jsx)("small",{children:e.help})]})}var _e={available:{label:"Available",tone:"eytg-badge-ok"},private:{label:"Private",tone:"eytg-badge-warn"},not_embeddable:{label:"No embed",tone:"eytg-badge-warn"},removed:{label:"Removed",tone:"eytg-badge-danger"}},Je=[{key:"title",label:"Video"},{key:"published",label:"Published"},{key:"views",label:"Views",numeric:!0}];function Qe({column:e,sort:t,dir:n,onSort:r}){const i=t===e.key;return(0,u.jsx)("th",{className:e.numeric?"eytg-num":void 0,"aria-sort":i?"asc"===n?"ascending":"descending":"none",children:(0,u.jsxs)("button",{type:"button",className:"eytg-th-btn",onClick:()=>r(e.key),children:[e.label,i&&("asc"===n?(0,u.jsx)(d.ChevronUp,{size:12}):(0,u.jsx)(d.ChevronDown,{size:12}))]})})}var Ke={private:{text:"Private",tone:"eytg-badge-warn",hint:"The uploader made it private. It may come back."},not_embeddable:{text:"Embedding off",tone:"eytg-badge-warn",hint:"Still on YouTube, but it will not play inside your site."},removed:{text:"Removed",tone:"eytg-badge-danger",hint:"Deleted or rejected. This is permanent."}};exports.ColumnResizeHandle=De,exports.CustomFieldInput=Xe,exports.FloatingYouTubePlayer=function(e){const[t,n]=(0,o.useState)(!1);return(0,o.useEffect)(()=>{!function(e){if(!e||e.getElementById("extract-youtube-floating-player-styles"))return;const t=e.createElement("style");t.id="extract-youtube-floating-player-styles",t.textContent='\n.eytp-root {\n --eytp-bg: #ffffff;\n --eytp-fg: #111827;\n --eytp-muted: #6b7280;\n --eytp-bar: #f3f4f6;\n --eytp-border: #e5e7eb;\n --eytp-accent: #3b82f6;\n --eytp-danger: #dc2626;\n position: fixed;\n z-index: 9999;\n bottom: 24px;\n right: 16px;\n width: 380px;\n max-width: calc(100vw - 2rem);\n background: var(--eytp-bg);\n color: var(--eytp-fg);\n border: 1px solid var(--eytp-border);\n border-radius: 12px;\n overflow: hidden;\n box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);\n font-family: system-ui, -apple-system, "Segoe UI", sans-serif;\n transition: width 0.3s ease, height 0.3s ease;\n}\n@media (prefers-color-scheme: dark) {\n .eytp-root {\n --eytp-bg: #0b0f19;\n --eytp-fg: #f3f4f6;\n --eytp-muted: #9ca3af;\n --eytp-bar: #161b26;\n --eytp-border: #2a3040;\n }\n}\n.eytp-root.eytp-minimized { width: 260px; }\n/* The width transition is for the minimize/expand toggle. During a resize it\n would make the widget rubber-band behind the pointer, so it\'s off mid-gesture. */\n.eytp-root.eytp-interacting { transition: none; }\n\n.eytp-bar {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n padding: 6px 10px;\n background: var(--eytp-bar);\n cursor: grab;\n user-select: none;\n touch-action: none;\n}\n.eytp-bar.eytp-grabbing { cursor: grabbing; }\n.eytp-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; overflow: hidden; }\n.eytp-title-text { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n\n.eytp-controls { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }\n.eytp-btn {\n display: inline-flex;\n align-items: center;\n gap: 2px;\n padding: 4px;\n border: none;\n border-radius: 4px;\n background: transparent;\n color: var(--eytp-muted);\n cursor: pointer;\n line-height: 0;\n}\n.eytp-btn:hover { color: var(--eytp-fg); background: rgba(127, 127, 127, 0.18); }\n.eytp-btn-active { color: var(--eytp-accent); background: rgba(59, 130, 246, 0.14); }\n.eytp-btn-count { font-size: 10px; font-variant-numeric: tabular-nums; line-height: 1; }\n\n.eytp-video { position: relative; width: 100%; padding-top: 56.25%; background: #000; }\n.eytp-video.eytp-hidden { display: none; }\n.eytp-video.eytp-pip { position: absolute; inset: 0; width: 100%; height: 100%; padding-top: 0; }\n.eytp-iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }\n\n.eytp-error {\n position: absolute;\n inset: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 8px;\n padding: 16px;\n text-align: center;\n background: var(--eytp-bg);\n}\n.eytp-error-text { font-size: 12px; color: var(--eytp-muted); margin: 0; }\n.eytp-error-actions { display: flex; gap: 8px; }\n.eytp-link {\n border: 1px solid var(--eytp-border);\n border-radius: 6px;\n padding: 4px 10px;\n font-size: 12px;\n font-weight: 500;\n background: transparent;\n color: inherit;\n text-decoration: none;\n cursor: pointer;\n}\n.eytp-link:hover { background: rgba(127, 127, 127, 0.14); }\n\n.eytp-queue { border-top: 1px solid var(--eytp-border); background: var(--eytp-bar); padding: 6px 10px; }\n.eytp-queue-heading {\n display: flex;\n align-items: center;\n gap: 4px;\n font-size: 10px;\n text-transform: uppercase;\n letter-spacing: 0.06em;\n color: var(--eytp-muted);\n margin-bottom: 2px;\n}\n.eytp-queue-next { font-size: 12px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.eytp-queue-rest { font-size: 10px; color: var(--eytp-muted); margin: 2px 0 0; }\n\n.eytp-subtitles { max-height: 190px; overflow-y: auto; border-bottom: 1px solid var(--eytp-border); padding: 6px; }\n\n.eytp-line {\n display: block;\n width: 100%;\n line-height: 1.5;\n text-align: left;\n border: none;\n background: transparent;\n border-radius: 6px;\n padding: 4px 6px;\n font-size: 12px;\n color: inherit;\n cursor: pointer;\n}\n.eytp-line:hover { background: rgba(127, 127, 127, 0.14); }\n.eytp-line-active { background: rgba(59, 130, 246, 0.14); }\n.eytp-word-active { background: rgba(59, 130, 246, 0.3); border-radius: 3px; padding: 0 2px; font-weight: 500; }\n\n.eytp-handle { position: absolute; }\n.eytp-handle:hover { background: rgba(59, 130, 246, 0.2); }\n.eytp-handle-left { left: 0; top: 0; bottom: 0; width: 6px; cursor: ew-resize; }\n.eytp-handle-right { right: 0; top: 0; bottom: 0; width: 6px; cursor: ew-resize; }\n.eytp-handle-bl { left: 0; bottom: 0; width: 12px; height: 12px; cursor: nesw-resize; z-index: 1; }\n.eytp-handle-br { right: 0; bottom: 0; width: 12px; height: 12px; cursor: nwse-resize; z-index: 1; }\n/* Swallows pointer events over the iframe mid-resize, which would otherwise\n capture the drag and freeze the gesture. */\n.eytp-resize-shield { position: absolute; inset: 0; z-index: 10; }\n',e.head.appendChild(t)}(document),n(!0)},[]),t?(0,p.createPortal)((0,u.jsx)(re,{...e}),document.body):null},exports.GRID_STYLES=de,exports.GridStylesProvider=pe,exports.HideConfirm=ye,exports.StackNav=be,exports.StackedVideoCard=xe,exports.VideoAvailabilityPanel=function({client:e,limit:t=100,onChange:n,className:r}){const[i,a]=(0,o.useState)(null),[s,l]=(0,o.useState)(null),[c,p]=(0,o.useState)(null),g=(0,o.useCallback)(()=>{p(null),e.unavailable(t).then(a).catch(e=>p(e instanceof Error?e.message:String(e)))},[e,t]);(0,o.useEffect)(g,[g]);const y=async(e,t)=>{l(e),p(null);try{await t(),a(t=>t?.filter(t=>t.videoId!==e)??null),n?.()}catch(r){p(r instanceof Error?r.message:String(r))}finally{l(null)}};return(0,u.jsx)(pe,{children:(0,u.jsxs)("section",{className:"eytg-root eytg-admin"+(r?` ${r}`:""),"aria-label":"Unavailable videos",children:[(0,u.jsxs)("div",{className:"eytg-toolbar",children:[(0,u.jsxs)("strong",{style:{flex:1},children:["Unavailable on YouTube",i?` (${i.length})`:""]}),(0,u.jsxs)("button",{type:"button",className:"eytg-btn",onClick:g,children:[(0,u.jsx)(d.RefreshCw,{size:14})," Reload"]})]}),c&&(0,u.jsx)("div",{className:"eytg-banner eytg-banner-error",role:"alert",children:c}),null===i?(0,u.jsx)("div",{className:"eytg-empty",children:(0,u.jsx)(d.Loader2,{size:16,className:"eytg-spin"})}):0===i.length?(0,u.jsx)("div",{className:"eytg-empty",children:"Every video in the library is playable. Run a resync to re-check."}):(0,u.jsx)("div",{className:"eytg-table-wrap",children:(0,u.jsxs)("table",{className:"eytg-table",children:[(0,u.jsxs)("colgroup",{children:[(0,u.jsx)("col",{}),(0,u.jsx)("col",{style:{width:140}}),(0,u.jsx)("col",{style:{width:120}}),(0,u.jsx)("col",{style:{width:200}})]}),(0,u.jsx)("thead",{children:(0,u.jsxs)("tr",{children:[(0,u.jsx)("th",{children:"Video"}),(0,u.jsx)("th",{children:"Status"}),(0,u.jsx)("th",{children:"Checked"}),(0,u.jsx)("th",{"aria-label":"Actions"})]})}),(0,u.jsx)("tbody",{children:i.map(t=>{const n=Ke[t.availability]??Ke.removed;return(0,u.jsxs)("tr",{children:[(0,u.jsx)("td",{children:(0,u.jsxs)("div",{className:"eytg-row-text",children:[(0,u.jsx)("strong",{children:t.title||t.videoId}),(0,u.jsx)("span",{children:t.channel})]})}),(0,u.jsx)("td",{children:(0,u.jsx)("span",{className:`eytg-badge ${n.tone}`,title:n.hint,children:n.text})}),(0,u.jsx)("td",{children:ae(t.updatedAt,!0)}),(0,u.jsx)("td",{children:(0,u.jsxs)("div",{className:"eytg-row-actions",children:[(0,u.jsx)("a",{className:"eytg-icon-btn",href:`https://www.youtube.com/watch?v=${encodeURIComponent(t.videoId)}`,target:"_blank",rel:"noopener noreferrer","aria-label":"Check on YouTube",title:"Check on YouTube",children:(0,u.jsx)(d.ExternalLink,{size:14})}),(0,u.jsxs)("button",{type:"button",className:"eytg-btn",disabled:null!==s,onClick:()=>y(t.videoId,()=>e.markAvailable(t.videoId)),children:[s===t.videoId?(0,u.jsx)(d.Loader2,{size:14,className:"eytg-spin"}):(0,u.jsx)(d.CheckCircle2,{size:14})," Mark available"]}),(0,u.jsx)("button",{type:"button",className:"eytg-icon-btn eytg-btn-danger",disabled:null!==s,onClick:()=>y(t.videoId,()=>e.remove(t.videoId)),"aria-label":"Remove from the library",title:"Remove from the library",children:(0,u.jsx)(d.Trash2,{size:14})})]})})]},t.videoId)})})]})})]})})},exports.VideoCard=he,exports.VideoEditDialog=Be,exports.VideoGrid=we,exports.VideoLibraryAdmin=function({client:e,customFields:t,pageSize:n=25,hideMaintenance:r=!1,onChange:i,className:a}){const[s,l]=(0,o.useState)(""),[c,p]=(0,o.useState)(""),[g,y]=(0,o.useState)(""),[h,b]=(0,o.useState)(""),[m,x]=(0,o.useState)(!1),[f,v]=(0,o.useState)("published"),[w,j]=(0,o.useState)("desc"),[k,N]=(0,o.useState)(1),[C,S]=(0,o.useState)([]),[z,T]=(0,o.useState)(0),[P,E]=(0,o.useState)(1),[I,R]=(0,o.useState)([]),[$,L]=(0,o.useState)([]),[M,A]=(0,o.useState)(!0),[D,q]=(0,o.useState)(null),[V,U]=(0,o.useState)(null),[O,F]=(0,o.useState)(null),[Y,H]=(0,o.useState)(null),[W,B]=(0,o.useState)(null),[X,_]=(0,o.useState)(0),[J,Q]=(0,o.useState)(null),K=t??$,Z=(0,o.useMemo)(()=>K.filter(e=>e.showInList),[K]);(0,o.useEffect)(()=>{const e=setTimeout(()=>{p(s),N(1)},250);return()=>clearTimeout(e)},[s]),(0,o.useEffect)(()=>{t||e.fields().then(L).catch(()=>L([]))},[e,t]),(0,o.useEffect)(()=>{e.categories().then(R).catch(()=>{})},[e,X]),(0,o.useEffect)(()=>{r||e.resyncStatus().then(e=>Q({configured:e.configured,quotaCost:e.quotaCost})).catch(()=>Q(null))},[e,r,X]),(0,o.useEffect)(()=>{let t=!1;return A(!0),e.list({q:c||null,category:g||null,availability:h||null,featured:m||null,includeHidden:!0,sort:f,dir:w,page:k,limit:n}).then(e=>{t||(S(e.videos),T(e.total),E(e.pageCount),e.page!==k&&N(e.page),U(null))}).catch(e=>!t&&U(e instanceof Error?e.message:String(e))).finally(()=>!t&&A(!1)),()=>{t=!0}},[e,c,g,h,m,f,w,k,n,X]);const G=(0,o.useCallback)(()=>{_(e=>e+1),i?.()},[i]),ee=async(e,t)=>{q(e),U(null),F(null);try{F(await t()),G()}catch(n){U(n instanceof Error?n.message:String(n))}finally{q(null)}},te=e=>{f===e?j("asc"===w?"desc":"asc"):(v(e),j("title"===e?"asc":"desc")),N(1)};return(0,u.jsx)(pe,{children:(0,u.jsxs)("div",{className:"eytg-root eytg-admin"+(a?` ${a}`:""),children:[(0,u.jsxs)("div",{className:"eytg-toolbar",children:[(0,u.jsxs)("label",{className:"eytg-grow",style:{position:"relative",display:"flex"},children:[(0,u.jsx)(d.Search,{size:14,style:{position:"absolute",left:10,top:9,color:"var(--eytg-muted)"},"aria-hidden":"true"}),(0,u.jsx)("input",{className:"eytg-input",style:{paddingLeft:30,width:"100%"},type:"search",placeholder:"Search title, channel, description, id…",value:s,onChange:e=>l(e.target.value),"aria-label":"Search the library"})]}),(0,u.jsxs)("select",{className:"eytg-select",value:g,onChange:e=>{y(e.target.value),N(1)},"aria-label":"Category",children:[(0,u.jsx)("option",{value:"",children:"All categories"}),I.map(e=>(0,u.jsx)("option",{value:e,children:e},e))]}),(0,u.jsxs)("select",{className:"eytg-select",value:h,onChange:e=>{b(e.target.value),N(1)},"aria-label":"Availability",children:[(0,u.jsx)("option",{value:"",children:"Any availability"}),Fe.map(e=>(0,u.jsx)("option",{value:e,children:_e[e].label},e))]}),(0,u.jsxs)("label",{className:"eytg-check",children:[(0,u.jsx)("input",{type:"checkbox",checked:m,onChange:e=>{x(e.target.checked),N(1)}}),"Top picks"]}),(0,u.jsxs)("button",{type:"button",className:"eytg-btn eytg-btn-primary",onClick:()=>H("new"),children:[(0,u.jsx)(d.Plus,{size:14})," Add video"]})]}),!r&&(0,u.jsxs)("div",{className:"eytg-toolbar",children:[(0,u.jsxs)("button",{type:"button",className:"eytg-btn",disabled:null!==D||!1===J?.configured,onClick:()=>ee("resync",async()=>{const t=await e.resync();return`Checked ${t.videosChecked} videos: ${t.viewCountsUpdated} view counts and ${t.availabilityChanged} availability changes updated.`}),title:!1===J?.configured?"Needs a YouTube Data API key on the server (youtubeApiKey)":"Refresh view counts and takedown status from the YouTube Data API"+(J?` (about ${J.quotaCost} quota units)`:""),children:["resync"===D?(0,u.jsx)(d.Loader2,{size:14,className:"eytg-spin"}):(0,u.jsx)(d.RefreshCw,{size:14})," Resync from YouTube"]}),(0,u.jsxs)("button",{type:"button",className:"eytg-btn",disabled:null!==D,onClick:()=>ee("stacks",async()=>{const{moved:t}=await e.recomputeStacks();return 0===t?"Stacks are up to date.":`Re-stacked ${t} video${1===t?"":"s"}.`}),title:"Rebuild stacked playlists from the links in descriptions",children:["stacks"===D?(0,u.jsx)(d.Loader2,{size:14,className:"eytg-spin"}):(0,u.jsx)(d.Layers,{size:14})," Recompute stacks"]}),(0,u.jsxs)("span",{style:{color:"var(--eytg-muted)",fontSize:12},children:[z," video",1===z?"":"s"]})]}),V&&(0,u.jsx)("div",{className:"eytg-banner eytg-banner-error",role:"alert",children:V}),O&&(0,u.jsx)("div",{className:"eytg-banner eytg-banner-ok",role:"status",children:O}),(0,u.jsx)("div",{className:"eytg-table-wrap",children:(0,u.jsxs)("table",{className:"eytg-table",children:[(0,u.jsxs)("colgroup",{children:[(0,u.jsx)("col",{style:{width:360}}),(0,u.jsx)("col",{style:{width:130}}),(0,u.jsx)("col",{style:{width:110}}),(0,u.jsx)("col",{style:{width:80}}),Z.map(e=>(0,u.jsx)("col",{style:{width:130}},e.key)),(0,u.jsx)("col",{style:{width:110}}),(0,u.jsx)("col",{style:{width:150}})]}),(0,u.jsx)("thead",{children:(0,u.jsxs)("tr",{children:[Je.slice(0,1).map(e=>(0,u.jsx)(Qe,{column:e,sort:f,dir:w,onSort:te},e.key)),(0,u.jsx)("th",{children:"Category"}),Je.slice(1).map(e=>(0,u.jsx)(Qe,{column:e,sort:f,dir:w,onSort:te},e.key)),Z.map(e=>(0,u.jsx)("th",{children:e.label},e.key)),(0,u.jsx)("th",{children:"Status"}),(0,u.jsx)("th",{"aria-label":"Actions"})]})}),(0,u.jsx)("tbody",{children:M&&0===C.length?(0,u.jsx)("tr",{children:(0,u.jsx)("td",{colSpan:6+Z.length,style:{textAlign:"center",padding:24},children:(0,u.jsx)(d.Loader2,{size:16,className:"eytg-spin"})})}):0===C.length?(0,u.jsx)("tr",{children:(0,u.jsx)("td",{colSpan:6+Z.length,style:{textAlign:"center",padding:24,color:"var(--eytg-muted)"},children:"No videos match."})}):C.map(t=>(0,u.jsxs)("tr",{style:{opacity:M?.6:t.hidden?.7:1},children:[(0,u.jsx)("td",{children:(0,u.jsxs)("div",{className:"eytg-row-title",children:[(0,u.jsx)("img",{className:"eytg-row-thumb",style:{width:72},src:ce(t.videoId),alt:"",loading:"lazy"}),(0,u.jsxs)("div",{className:"eytg-row-text",children:[(0,u.jsx)("strong",{title:t.title,children:t.title||t.videoId}),(0,u.jsxs)("span",{children:[t.channel," · ",(0,u.jsx)("code",{children:t.videoId})]})]})]})}),(0,u.jsx)("td",{children:t.category??""}),(0,u.jsx)("td",{children:ae(t.publishedAt,!0)}),(0,u.jsx)("td",{className:"eytg-num",children:ie(t.viewCount)}),Z.map(e=>(0,u.jsx)("td",{children:se(e,t.custom?.[e.key])},e.key)),(0,u.jsx)("td",{children:(0,u.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:[(0,u.jsx)("span",{className:`eytg-badge ${_e[t.availability].tone}`,children:_e[t.availability].label}),t.hidden&&(0,u.jsx)("span",{className:"eytg-badge",children:"Hidden"}),t.stackKey&&(0,u.jsxs)("span",{className:"eytg-badge",title:`Stack ${t.stackKey}`,children:["Stack ",t.stackPosition+1]})]})}),(0,u.jsx)("td",{children:(0,u.jsxs)("div",{className:"eytg-row-actions",children:[(0,u.jsx)("button",{type:"button",className:"eytg-icon-btn"+(t.featured?" eytg-on":""),onClick:()=>((t,n)=>ee(`${n}-${t.videoId}`,async()=>(await e.update(t.videoId,{[n]:!t[n]}),`${t.title}: ${"featured"===n?t.featured?"no longer a top pick":"marked as a top pick":t.hidden?"visible again":"hidden"}.`)))(t,"featured"),disabled:null!==D,"aria-pressed":t.featured,"aria-label":t.featured?"Unmark top pick":"Mark as top pick",title:t.featured?"Unmark top pick":"Mark as top pick",children:(0,u.jsx)(d.Star,{size:14,fill:t.featured?"currentColor":"none"})}),(0,u.jsx)("button",{type:"button",className:"eytg-icon-btn",onClick:()=>H(t),"aria-label":"Edit",title:"Edit",children:(0,u.jsx)(d.Pencil,{size:14})}),(0,u.jsx)("button",{type:"button",className:"eytg-icon-btn eytg-btn-danger",onClick:()=>B(t),"aria-label":"Remove",title:"Remove from the library",children:(0,u.jsx)(d.Trash2,{size:14})})]})})]},t.videoId))})]})}),(0,u.jsxs)("div",{className:"eytg-pager",children:[(0,u.jsxs)("span",{children:["Page ",k," of ",P]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("button",{type:"button",className:"eytg-btn",disabled:k<=1||M,onClick:()=>N(k-1),children:"Previous"}),(0,u.jsx)("button",{type:"button",className:"eytg-btn",disabled:k>=P||M,onClick:()=>N(k+1),children:"Next"})]})]}),Y&&(0,u.jsx)(Be,{client:e,video:"new"===Y?null:Y,customFields:K,categories:I,onClose:()=>H(null),onSaved:e=>{H(null),F(`Saved “${e.title}”.`),G()}}),W&&(0,u.jsx)("div",{className:"eytg-overlay",role:"presentation",onClick:()=>B(null),children:(0,u.jsxs)("div",{className:"eytg-dialog eytg-dialog-sm",role:"alertdialog","aria-modal":"true",onClick:e=>e.stopPropagation(),children:[(0,u.jsx)("header",{children:(0,u.jsx)("h2",{children:"Remove this video?"})}),(0,u.jsx)("div",{className:"eytg-dialog-body",children:(0,u.jsxs)("p",{style:{margin:0},children:[(0,u.jsx)("strong",{children:W.title})," will be deleted from the library and excluded from future imports. To show it less prominently instead, hide it."]})}),(0,u.jsxs)("footer",{children:[(0,u.jsx)("button",{type:"button",className:"eytg-btn",onClick:()=>B(null),children:"Cancel"}),(0,u.jsx)("button",{type:"button",className:"eytg-btn eytg-btn-primary",style:{background:"var(--eytg-danger)",borderColor:"var(--eytg-danger)"},onClick:()=>{const t=W;B(null),ee(`delete-${t.videoId}`,async()=>(await e.remove(t.videoId),`Removed “${t.title}”.`))},children:"Remove"})]})]})})]})})},exports.VideoList=Oe,exports.YouTubeTranscriptModal=w,exports.buildEmbedUrl=L,exports.defaultStackLabel=me,exports.describePlayerError=$,exports.formatCustomCell=se,exports.formatCustomValue=oe,exports.formatTime=function(e){const t=Math.max(0,Math.floor(e)),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60,a=n>0?r.toString().padStart(2,"0"):r.toString(),o=i.toString().padStart(2,"0");return n>0?`${n}:${a}:${o}`:`${a}:${o}`},exports.formatVideoDate=ae,exports.formatViewCount=ie,exports.getPlayerState=W,exports.groupByCategory=Ne,exports.groupByChannel=ke,exports.groupByCustomField=function(e,t={}){return n=>{const r=n.custom?.[e],i=null==r?"":String(r).trim();return i?{kind:e,label:i,sortValue:i.toLowerCase()}:t.skipEmpty?null:{kind:e,label:"Unsorted",sortValue:"",trailing:!0}}},exports.groupByYear=je,exports.groupIntoSentences=f,exports.loadTranscript=y,exports.sendPlayerCommand=Q,exports.thumbnailFor=ce,exports.thumbnailUrl=function(e,t="hq"){return`https://img.youtube.com/vi/${e}/${"default"===t?"default":`${t}default`}.jpg`},exports.toPlayerVideo=le,exports.usePlayerSelector=X,exports.usePlayerState=B,exports.useResizableColumns=Ae,exports.useTranscript=b,exports.useVideoLibrary=function(e,t={}){const[n,r]=(0,o.useState)(null),[i,a]=(0,o.useState)({}),[s,l]=(0,o.useState)(!0),[c,d]=(0,o.useState)(null),[u,p]=(0,o.useState)(0),g=(0,o.useRef)({}),y=JSON.stringify(t);(0,o.useEffect)(()=>{let t=!1;return l(!0),d(null),(async()=>{try{const n=await e.list(JSON.parse(y));if(t)return;r(n);const i=function(e){const t=[],n=new Set;for(const r of e){const e=fe(r);e&&!n.has(e)&&(n.add(e),t.push(e))}return t}(n.videos).filter(e=>!g.current[e]);if(i.length>0){const n=await e.stacks(i);if(t)return;g.current={...g.current,...n}}a(g.current)}catch(n){t||d(n instanceof Error?n.message:String(n))}finally{t||l(!1)}})(),()=>{t=!0}},[e,y,u]);const h=(0,o.useCallback)(()=>{g.current={},p(e=>e+1)},[]);return{page:n,videos:n?.videos??[],stacks:i,loading:s,error:c,reload:h}},exports.watchUrl=M,exports.youtubePlayer=G;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty;let o=require("react");var s,l,c;c=null!=(s=o)?e(i(s)):{},o=((e,i,o,s)=>{if(i&&"object"==typeof i||"function"==typeof i)for(var l,c=r(i),d=0,u=c.length;d<u;d++)l=c[d],a.call(e,l)||l===o||t(e,l,{get:(e=>i[e]).bind(null,l),enumerable:!(s=n(i,l))||s.enumerable});return e})(!l&&s&&s.__esModule&&a.call(s,"default")?c:t(c,"default",{value:s,enumerable:!0}),s);let d=require("lucide-react"),u=require("react/jsx-runtime"),p=require("react-dom");var g=new Map;function y(e,t){const{transcriptUrl:n,fetchTranscript:r}=t;if(r)return r(e).then(h);if(!n)return Promise.reject(new Error("No transcriptUrl or fetchTranscript provided"));const i=g.get(e);if(i)return i;const a=fetch(function(e,t){return e.includes("videoId=")?e:`${e}${e.includes("?")?"&":"?"}videoId=${encodeURIComponent(t)}`}(n,e)).then(e=>e.json()).then(h).catch(t=>{throw setTimeout(()=>{g.get(e)===a&&g.delete(e)},6e4),t});return g.set(e,a),a}function h(e){if(!e||e.error)throw new Error(e?.error||"Failed to load transcript");return e.snippets??[]}function b(e,t,n){const[r,i]=(0,o.useState)(null),[a,s]=(0,o.useState)(!1),[l,c]=(0,o.useState)(null),{transcriptUrl:d,fetchTranscript:u}=n;return(0,o.useEffect)(()=>{if(!t||!e)return;let n=!1;return s(!0),c(null),i(null),y(e,{transcriptUrl:d,fetchTranscript:u}).then(e=>{n||i(e)}).catch(e=>{n||c(e instanceof Error?e.message:"Failed to load transcript")}).finally(()=>{n||s(!1)}),()=>{n=!0}},[t,e,d,u]),{snippets:r,loading:a,error:l}}var m=/[.!?…]["')\]]*$/,x=/^(?:[A-Za-z]\.)+$|^(?:mr|mrs|ms|dr|prof|sr|jr|st|vs|etc|no|fig|approx|e\.g|i\.e)\.$/i;function f(e){const t=[];let n=[],r=0,i=0,a=0;const o=()=>{0!==n.length&&(t.push({text:n.join(" "),start:i,duration:Math.max(0,a-i)}),n=[],r=0)};for(const s of e){const e=s.text.split(/\s+/).filter(Boolean);if(0===e.length)continue;const t=s.duration>0?s.duration/e.length:0;e.forEach((e,l)=>{0===n.length&&(i=s.start+t*l),n.push(e),r+=e.length+1,a=s.start+t*(l+1),(m.test(e)&&!x.test(e)||r>=220)&&o()})}return o(),t}var v=(0,o.forwardRef)(function({snippet:e,isActive:t,currentTime:n,onSeek:r},i){const a=(0,o.useMemo)(()=>e.text.split(/\s+/).filter(Boolean),[e.text]),s=t&&e.duration>0?Math.min(a.length-1,Math.max(0,Math.floor((n-e.start)/e.duration*a.length))):-1;return(0,u.jsx)("button",{ref:i,type:"button",onClick:e=>{e.stopPropagation(),r()},className:"eyt-line"+(t?" eyt-line-active":""),children:a.map((e,t)=>(0,u.jsxs)("span",{className:t===s?"eyt-word-active":void 0,children:[e," "]},t))})});function w({videoId:e,title:t,transcriptUrl:n,fetchTranscript:r,snippets:i,trigger:a,onOpenChange:s}){const[l,c]=(0,o.useState)(!1),[p,g]=(0,o.useState)(i??null),[h,b]=(0,o.useState)(!1),[m,x]=(0,o.useState)(0),w=(0,o.useRef)(null),k=(0,o.useRef)([]),N=(0,o.useCallback)(e=>{c(e),s?.(e)},[s]);(0,o.useEffect)(()=>{if(!l||i)return;let t=!1;return b(!0),g(null),x(0),y(e,{transcriptUrl:n,fetchTranscript:r}).then(e=>{t||g(e)}).catch(()=>{}).finally(()=>{t||b(!1)}),()=>{t=!0}},[l,e,n,r,i]),(0,o.useEffect)(()=>{if(!l)return;const e=e=>{if("https://www.youtube.com"===e.origin)try{const t=JSON.parse(e.data);"infoDelivery"===t.event&&null!=t.info?.currentTime&&x(t.info.currentTime)}catch{}};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[l]),(0,o.useEffect)(()=>{if(!l)return;const e=e=>{"Escape"===e.key&&N(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[l,N]);const C=(0,o.useCallback)(()=>{w.current?.contentWindow?.postMessage(JSON.stringify({event:"listening",id:e,channel:"widget"}),"https://www.youtube.com")},[e]),S=(0,o.useCallback)(e=>{const t=w.current?.contentWindow;t&&(t.postMessage(JSON.stringify({event:"command",func:"seekTo",args:[e,!0]}),"https://www.youtube.com"),t.postMessage(JSON.stringify({event:"command",func:"playVideo",args:[]}),"https://www.youtube.com"))},[]),z=(0,o.useMemo)(()=>p?f(p):null,[p]),T=h||(z?.length??0)>0,P=(0,o.useMemo)(()=>{if(!z||0===z.length)return-1;let e=-1;for(let t=0;t<z.length&&z[t].start<=m;t++)e=t;return e},[z,m]);return(0,o.useEffect)(()=>{P<0||k.current[P]?.scrollIntoView({block:"nearest",behavior:"smooth"})},[P]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("style",{children:j}),a?(0,u.jsx)("span",{onClick:()=>N(!0),children:a}):(0,u.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),N(!0)},className:"eyt-trigger","aria-label":"View transcript",title:"Transcript",children:(0,u.jsx)(d.Captions,{size:16})}),l&&(0,u.jsx)("div",{className:"eyt-overlay",onClick:()=>N(!1),children:(0,u.jsxs)("div",{className:"eyt-modal",onClick:e=>e.stopPropagation(),role:"dialog","aria-modal":"true",children:[(0,u.jsxs)("div",{className:"eyt-header",children:[(0,u.jsx)("span",{className:"eyt-title",children:t??e}),(0,u.jsx)("button",{type:"button",className:"eyt-close",onClick:()=>N(!1),"aria-label":"Close",children:(0,u.jsx)(d.X,{size:16})})]}),(0,u.jsxs)("div",{className:"eyt-body"+(T?" eyt-body-split":""),children:[(0,u.jsx)("div",{className:"eyt-player",children:(0,u.jsx)("iframe",{ref:w,src:`https://www.youtube.com/embed/${e}?enablejsapi=1&rel=0`,title:t??e,onLoad:C,className:"eyt-iframe",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),T&&(0,u.jsxs)("div",{className:"eyt-sidebar",children:[(0,u.jsx)("div",{className:"eyt-sidebar-heading",children:"Transcript"}),(0,u.jsxs)("div",{className:"eyt-sidebar-scroll",children:[h&&(0,u.jsxs)("div",{className:"eyt-status",children:[(0,u.jsx)(d.Loader2,{size:16,className:"eyt-spin"}),"Loading transcript..."]}),z?.map((e,t)=>(0,u.jsx)(v,{ref:e=>{k.current[t]=e},snippet:e,isActive:t===P,currentTime:m,onSeek:()=>S(e.start)},t))]})]})]})]})})]})}var j="\n.eyt-trigger { display: inline-flex; align-items: center; justify-content: center; padding: 2px; border: none; background: transparent; border-radius: 4px; color: #6b7280; cursor: pointer; }\n.eyt-trigger:hover { color: #111827; background: rgba(0,0,0,0.05); }\n.eyt-overlay { position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; padding: 16px; }\n.eyt-modal { width: 100%; max-width: 1024px; max-height: 90vh; background: #fff; color: #111827; border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,0.4); }\n.eyt-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid #e5e7eb; flex-shrink: 0; }\n.eyt-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 12px; }\n.eyt-close { border: none; background: transparent; color: #6b7280; cursor: pointer; padding: 4px; border-radius: 6px; display: flex; }\n.eyt-close:hover { background: rgba(0,0,0,0.05); color: #111827; }\n.eyt-body { display: grid; grid-template-columns: 1fr; flex: 1; min-height: 0; }\n@media (min-width: 1024px) { .eyt-body-split { grid-template-columns: 1fr 360px; } }\n.eyt-player { position: relative; width: 100%; background: #000; padding-top: 56.25%; }\n.eyt-iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }\n.eyt-sidebar { display: flex; flex-direction: column; min-height: 0; border-top: 1px solid #e5e7eb; }\n@media (min-width: 1024px) { .eyt-sidebar { border-top: 0; border-left: 1px solid #e5e7eb; } }\n.eyt-sidebar-heading { padding: 8px 12px; font-size: 12px; font-weight: 500; color: #6b7280; border-bottom: 1px solid #e5e7eb; flex-shrink: 0; }\n.eyt-sidebar-scroll { flex: 1; min-height: 280px; max-height: 280px; overflow-y: auto; padding: 8px; }\n@media (min-width: 1024px) { .eyt-sidebar-scroll { max-height: none; } }\n.eyt-status { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #6b7280; padding: 12px; }\n.eyt-spin { animation: eyt-spin 1s linear infinite; }\n@keyframes eyt-spin { to { transform: rotate(360deg); } }\n.eyt-line { display: block; width: 100%; text-align: left; border: none; background: transparent; border-radius: 6px; padding: 6px 8px; font-size: 13px; line-height: 1.5; cursor: pointer; color: inherit; }\n.eyt-line:hover { background: rgba(0,0,0,0.05); }\n.eyt-line-active { background: rgba(59,130,246,0.12); }\n.eyt-word-active { background: rgba(59,130,246,0.3); border-radius: 3px; padding: 0 2px; font-weight: 500; color: #1d4ed8; }\n",k=13;function N({isPlaying:e,isMinimized:t,queueLength:n,isPipSupported:r,isPipActive:i,isSubtitlesOpen:a,showSubtitles:o,showPip:s,extraControls:l,onPlayPause:c,onPlayNext:p,onToggleMinimize:g,onTogglePip:y,onToggleSubtitles:h,onClose:b}){return(0,u.jsxs)("div",{className:"eytp-controls",children:[(0,u.jsx)("button",{type:"button",onClick:c,className:"eytp-btn","aria-label":e?"Pause video":"Play video",title:e?"Pause":"Play",children:e?(0,u.jsx)(d.Pause,{size:k}):(0,u.jsx)(d.Play,{size:k})}),l,n>0&&(0,u.jsxs)("button",{type:"button",onClick:p,className:"eytp-btn","aria-label":"Play next in queue",title:`Skip to next (${n} in queue)`,children:[(0,u.jsx)(d.SkipForward,{size:k}),(0,u.jsx)("span",{className:"eytp-btn-count",children:n})]}),o&&(0,u.jsx)("button",{type:"button",onClick:h,className:"eytp-btn"+(a?" eytp-btn-active":""),"aria-label":a?"Hide subtitles":"Show subtitles",title:a?"Hide subtitles":"Show subtitles",children:(0,u.jsx)(d.Captions,{size:k})}),s&&r&&(0,u.jsx)("button",{type:"button",onClick:y,className:"eytp-btn"+(i?" eytp-btn-active":""),"aria-label":i?"Exit picture-in-picture":"Pop out picture-in-picture",title:i?"Exit picture-in-picture":"Pop out picture-in-picture",children:(0,u.jsx)(d.PictureInPicture2,{size:k})}),(0,u.jsx)("button",{type:"button",onClick:g,className:"eytp-btn","aria-label":t?"Expand player":"Minimize player",title:t?"Expand player":"Minimize player — drag to move, resize from the edges",children:t?(0,u.jsx)(d.Maximize2,{size:k}):(0,u.jsx)(d.Minus,{size:k})}),(0,u.jsx)("button",{type:"button",onClick:b,className:"eytp-btn","aria-label":"Close video",title:"Close player",children:(0,u.jsx)(d.X,{size:k})})]})}function C({queue:e}){return 0===e.length?null:(0,u.jsxs)("div",{className:"eytp-queue",children:[(0,u.jsxs)("div",{className:"eytp-queue-heading",children:[(0,u.jsx)(d.ListVideo,{size:11}),(0,u.jsx)("span",{children:"Up next"})]}),(0,u.jsx)("p",{className:"eytp-queue-next",children:e[0].title??e[0].videoId}),e.length>1&&(0,u.jsxs)("p",{className:"eytp-queue-rest",children:["+",e.length-1," more in queue"]})]})}var S=[{edge:"left",className:"eytp-handle eytp-handle-left"},{edge:"right",className:"eytp-handle eytp-handle-right"},{edge:"bottom-left",className:"eytp-handle eytp-handle-bl"},{edge:"bottom-right",className:"eytp-handle eytp-handle-br"}];function z({isResizing:e,startResize:t}){return(0,u.jsxs)(u.Fragment,{children:[e&&(0,u.jsx)("div",{className:"eytp-resize-shield"}),S.map(({edge:e,className:n})=>(0,u.jsx)("div",{className:n,onMouseDown:n=>{n.preventDefault(),t(n.clientX,n.clientY,e)},onTouchStart:n=>t(n.touches[0].clientX,n.touches[0].clientY,e)},e))]})}var T=(0,o.forwardRef)(function({snippet:e,isActive:t,currentTime:n,onSeek:r},i){const a=(0,o.useMemo)(()=>e.text.split(/\s+/).filter(Boolean),[e.text]),s=t&&e.duration>0?Math.min(a.length-1,Math.max(0,Math.floor((n-e.start)/e.duration*a.length))):-1;return(0,u.jsx)("button",{ref:i,type:"button",onClick:e=>{e.stopPropagation(),r()},className:"eytp-line"+(t?" eytp-line-active":""),children:a.map((e,t)=>(0,u.jsxs)("span",{className:t===s?"eytp-word-active":void 0,children:[e," "]},t))})});function P({sentences:e,currentTime:t,onSeek:n}){const r=(0,o.useRef)([]),i=(0,o.useMemo)(()=>{let n=-1;for(let r=0;r<e.length&&e[r].start<=t;r++)n=r;return n},[e,t]);return(0,o.useEffect)(()=>{i<0||r.current[i]?.scrollIntoView({block:"center",behavior:"smooth"})},[i]),0===e.length?null:(0,u.jsx)("div",{className:"eytp-subtitles",children:e.map((e,a)=>(0,u.jsx)(T,{ref:e=>{r.current[a]=e},snippet:e,isActive:a===i,currentTime:t,onSeek:()=>n(e.start)},a))})}function E(e){const[t,n]=(0,o.useState)(!1),[r,i]=(0,o.useState)(!1),[a,s]=(0,o.useState)(null),l=(0,o.useRef)(null);(0,o.useEffect)(()=>{n("undefined"!=typeof window&&"documentPictureInPicture"in window)},[]);const c=(0,o.useCallback)(()=>{const t=e.current,n=l.current;t&&n?.parentNode&&(n.after(t),n.remove()),l.current=null,i(!1),s(null)},[e]),d=(0,o.useCallback)(()=>{const e="undefined"==typeof window?null:window.documentPictureInPicture?.window;e&&(c(),e.close())},[c]),u=(0,o.useCallback)(async()=>{const t=window.documentPictureInPicture,n=e.current;if(!t||!n)return;if(t.window)return void d();const r=document.createComment("floating-youtube-player-pip-anchor");n.after(r),l.current=r;const a=await t.requestWindow({width:480,height:270});!function(e){try{const t=e.document;t.open(),t.write("<!doctype html><html><head></head><body></body></html>"),t.close()}catch{}}(a),function(e){Array.from(document.styleSheets).forEach(t=>{try{const n=Array.from(t.cssRules).map(e=>e.cssText).join(""),r=e.document.createElement("style");r.textContent=n,e.document.head.appendChild(r)}catch{if(t.href){const n=e.document.createElement("link");n.rel="stylesheet",n.href=t.href,e.document.head.appendChild(n)}}})}(a),a.document.body.style.margin="0",a.document.body.style.background="#000",a.document.body.style.overflow="hidden",a.document.body.appendChild(n),i(!0),s(a),a.addEventListener("pagehide",c,{once:!0})},[e,d,c]);return(0,o.useEffect)(()=>()=>d(),[d]),{isSupported:t,isActive:r,pipWindow:a,toggle:u,exit:d}}var I="https://www.youtube.com",R={2:"This video link is invalid.",5:"This video can't be played in the current browser.",100:"This video is private or has been removed.",101:"The owner doesn't allow this video to be played outside YouTube.",150:"The owner doesn't allow this video to be played outside YouTube.",153:"YouTube blocked this embed. Reload the page or watch it on YouTube."};function $(e){return R[e]??`The video player reported error ${e}.`}function L(e,t={}){const{autoplay:n=!1,controls:r=!0,startSeconds:i=0}=t,a=new URLSearchParams({enablejsapi:"1",rel:"0",controls:r?"1":"0"});n&&a.set("autoplay","1"),i>0&&a.set("start",String(Math.floor(i)));const o=function(){if("undefined"==typeof window)return null;const{origin:e}=window.location;return e&&"null"!==e?e:null}();return o&&(a.set("origin",o),a.set("widget_referrer",o)),`${I}/embed/${e}?${a.toString()}`}function M(e,t=0){const n=t>0?`&t=${Math.floor(t)}`:"";return`${I}/watch?v=${e}${n}`}function A(e){e?.contentWindow?.postMessage(JSON.stringify({event:"listening",id:e.id||"floating-youtube-player",channel:"widget"}),I)}var D=864e5;function q(e){return`${e}:positions`}function V(e,t,n){try{const r=localStorage.getItem(q(e));let i=r?JSON.parse(r):{};i[t]={savedTime:n,savedAt:Date.now()};const a=Object.entries(i);a.length>50&&(i=Object.fromEntries(a.sort(([,e],[,t])=>t.savedAt-e.savedAt).slice(0,50))),localStorage.setItem(q(e),JSON.stringify(i))}catch{}}var U={activeVideo:null,isMinimized:!1,isPlaying:!1,playbackRate:1,queue:[],startTime:0},O=U,F=new Set;function Y(e){O={...O,...e},F.forEach(e=>e())}function W(e){return F.add(e),()=>F.delete(e)}function H(){return O}function B(){return(0,o.useSyncExternalStore)(W,H,()=>U)}function X(e){return(0,o.useSyncExternalStore)(W,()=>e(O),()=>e(U))}var _={current:null},J={current:null};function Q(e,t=[]){!function(e,t,n=[]){e?.contentWindow?.postMessage(JSON.stringify({event:"command",func:t,args:n}),I)}(_.current,e,t)}var K={current:null},Z={current:null},G={play(e,t={}){const n=O.activeVideo;if(n&&n.videoId!==e.videoId&&J.current){const e=J.current();e>0&&K.current?.(n.videoId,e)}Y({activeVideo:e,isMinimized:!1,isPlaying:!0,startTime:t.startSeconds??Z.current?.(e.videoId)??0,playbackRate:t.playbackRate??O.playbackRate})},close(){Y({activeVideo:null,isPlaying:!1,isMinimized:!1,startTime:0})},setMinimized(e){Y({isMinimized:e})},resume(){Q("playVideo"),Y({isPlaying:!0})},pause(){Q("pauseVideo"),Y({isPlaying:!1})},togglePlay(){O.isPlaying?G.pause():G.resume()},seekTo(e){Q("seekTo",[e,!0]),Q("playVideo")},setPlaybackRate(e){Q("setPlaybackRate",[e]),Y({playbackRate:e})},getCurrentTime:()=>J.current?.()??0,addToQueue(e){O.queue.some(t=>t.videoId===e.videoId)||Y({queue:[...O.queue,e]})},removeFromQueue(e){Y({queue:O.queue.filter(t=>t.videoId!==e)})},setQueue(e){Y({queue:e})},clearQueue(){Y({queue:[]})},playNext(){const[e,...t]=O.queue;e?Y({activeVideo:e,queue:t,isMinimized:!1,isPlaying:!0,startTime:0}):G.close()}},ee=e=>Y({isPlaying:e}),te=e=>Y({playbackRate:e}),ne=e=>Y(e);function re({extraControls:e,renderTitle:t,showSubtitles:n,showPictureInPicture:r=!0,storageKey:i="floating-youtube-player",className:a,onClose:s,minWidth:l,maxWidth:c,transcriptUrl:p,fetchTranscript:g}){const{activeVideo:y,isMinimized:h,isPlaying:m,playbackRate:x,queue:v,startTime:w}=B(),j=(0,o.useRef)(null),k=(0,o.useRef)(null),S=(0,o.useRef)(null),{isSupported:T,isActive:I,pipWindow:R,toggle:U,exit:O}=E(S),[F,Y]=(0,o.useState)(!1),[W,X]=(0,o.useState)(0),[Q,re]=(0,o.useState)(null),[ie,ae]=(0,o.useState)(0),[oe,se]=(0,o.useState)(null),le=(0,o.useRef)(null),ce=(0,o.useRef)(0),de=(0,o.useRef)(!1),{position:ue,isDragging:pe,isResizing:ge,playerWidth:ye,startDrag:he,startResize:be}=function(e,{minWidth:t=256,maxWidth:n=800}={}){const[r,i]=(0,o.useState)(null),[a,s]=(0,o.useState)(!1),l=(0,o.useRef)(!1),c=(0,o.useRef)({x:0,y:0}),[d,u]=(0,o.useState)(null),[p,g]=(0,o.useState)(!1),y=(0,o.useRef)(!1),h=(0,o.useRef)(null),b=(0,o.useRef)({x:0,width:0,posX:0}),m=(0,o.useCallback)((t,n)=>{const r=e.current;if(!r)return;const a=r.getBoundingClientRect();c.current={x:t-a.left,y:n-a.top},i({x:a.left,y:a.top}),l.current=!0,s(!0)},[e]),x=(0,o.useCallback)((t,n,a)=>{const o=e.current;if(!o)return;const s=o.getBoundingClientRect();r||i({x:s.left,y:s.top}),b.current={x:t,width:o.offsetWidth,posX:s.left},h.current=a,y.current=!0,g(!0)},[e,r]),f=(0,o.useCallback)((t,n)=>{const r=e.current;return r?{x:Math.max(0,Math.min(window.innerWidth-r.offsetWidth,t)),y:Math.max(0,Math.min(window.innerHeight-r.offsetHeight,n))}:{x:t,y:n}},[e]);return(0,o.useEffect)(()=>{const e=e=>{const r=h.current,{x:a,width:o,posX:s}=b.current,l=e-a,c="left"===r||"bottom-left"===r,d=Math.max(t,Math.min(n,o+(c?-l:l)));u(d),c&&i(e=>e?{x:s+(o-d),y:e.y}:e)},r=()=>{if(y.current)return y.current=!1,h.current=null,void g(!1);l.current&&(l.current=!1,s(!1))},a=t=>{y.current?e(t.clientX):l.current&&i(f(t.clientX-c.current.x,t.clientY-c.current.y))},o=t=>{const n=t.touches[0];if(n)return y.current?(e(n.clientX),void t.preventDefault()):void(l.current&&(i(f(n.clientX-c.current.x,n.clientY-c.current.y)),t.preventDefault()))};return document.addEventListener("mousemove",a),document.addEventListener("mouseup",r),document.addEventListener("touchmove",o,{passive:!1}),document.addEventListener("touchend",r),document.addEventListener("touchcancel",r),window.addEventListener("blur",r),()=>{document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",r),document.removeEventListener("touchmove",o),document.removeEventListener("touchend",r),document.removeEventListener("touchcancel",r),window.removeEventListener("blur",r)}},[f,t,n]),{position:r,isDragging:a,isResizing:p,playerWidth:d,startDrag:m,startResize:x}}(k,{minWidth:l,maxWidth:c}),me=Boolean(p||g),{snippets:xe}=b(y?.videoId??null,me,{transcriptUrl:p,fetchTranscript:g}),fe=(0,o.useMemo)(()=>xe?f(xe):[],[xe]),ve=n??fe.length>0,we=(0,o.useCallback)(e=>{j.current=e,_.current=e},[]),je=(0,o.useCallback)(()=>null!==le.current?ce.current+(Date.now()-le.current)/1e3:ce.current,[]),ke=(0,o.useCallback)(()=>{if(!i)return;const e={activeVideo:y,isMinimized:h,playbackRate:x,queue:v};e.activeVideo&&function(e,t){try{const n={...t,savedAt:Date.now()};localStorage.setItem(e,JSON.stringify(n)),V(e,t.video.videoId,t.savedTime)}catch{}}(i,{video:e.activeVideo,isMinimized:e.isMinimized,playbackRate:e.playbackRate,queue:e.queue,savedTime:je()})},[i,y,h,x,v,je]);(0,o.useEffect)(()=>(J.current=je,K.current=i?(e,t)=>V(i,e,t):null,Z.current=i?e=>function(e,t){try{const n=localStorage.getItem(q(e));if(!n)return null;const r=JSON.parse(n),i=r[t];return i?Date.now()-i.savedAt>D?(delete r[t],localStorage.setItem(q(e),JSON.stringify(r)),null):i.savedTime:null}catch{return null}}(i,e):null,()=>{J.current=null,K.current=null,Z.current=null}),[je,i]),(0,o.useEffect)(()=>{if(!i||H().activeVideo)return;const e=function(e){try{const t=localStorage.getItem(e);if(!t)return null;const n=JSON.parse(t);return!n?.video?.videoId||Date.now()-n.savedAt>D?(localStorage.removeItem(e),null):n}catch{return null}}(i);e&&(ce.current=e.savedTime,le.current=null,ne({activeVideo:e.video,isMinimized:e.isMinimized,playbackRate:e.playbackRate,queue:e.queue,startTime:e.savedTime,isPlaying:!0}))},[]);const Ne=y?.videoId??null;(0,o.useEffect)(()=>{Ne&&(re(null),se(null),de.current=!0)},[Ne]);const Ce=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(!Ne)return;const e=`${Ne}@${w}`;Ce.current!==e&&(Ce.current=e,ce.current=w,le.current=null)},[Ne,w]),(0,o.useEffect)(()=>{const e=e=>{if("https://www.youtube.com"!==e.origin)return;let t;try{t=JSON.parse(e.data)}catch{return}if("onError"===t.event){const e="number"==typeof t.info?t.info:Number(t.info?.errorCode);return void(Number.isNaN(e)||re(e))}if("onStateChange"===t.event)return re(null),void(1===t.info||3===t.info?(null===le.current&&(le.current=Date.now()),ee(!0),de.current&&(de.current=!1,1!==x&&G.setPlaybackRate(x))):2!==t.info&&0!==t.info||(null!==le.current&&(ce.current+=(Date.now()-le.current)/1e3,le.current=null),ee(!1),ke()));if("infoDelivery"===t.event&&t.info){if(null!=t.info.errorCode){const e=Number(t.info.errorCode);Number.isNaN(e)||re(e)}if(null!=t.info.currentTime){const e=t.info.currentTime;ce.current=e,null!==le.current&&(le.current=Date.now()),F&&X(e)}null!=t.info.playbackRate&&te(Number(t.info.playbackRate))}};return window.addEventListener("message",e),R?.addEventListener("message",e),()=>{window.removeEventListener("message",e),R?.removeEventListener("message",e)}},[ke,F,x,R]),(0,o.useEffect)(()=>{if(!Ne)return;let e=0;A(j.current);const t=setInterval(()=>{A(j.current),++e>=12&&clearInterval(t)},400);return()=>clearInterval(t)},[Ne,ie,oe,I]),(0,o.useEffect)(()=>{if(!m||!Ne)return;const e=setInterval(ke,1e4);return()=>clearInterval(e)},[m,Ne,ke]),(0,o.useEffect)(()=>{const e=()=>{"hidden"===document.visibilityState&&ke()};return window.addEventListener("beforeunload",ke),document.addEventListener("visibilitychange",e),()=>{window.removeEventListener("beforeunload",ke),document.removeEventListener("visibilitychange",e)}},[ke]);const Se=(0,o.useCallback)(()=>{se(je()),U()},[je,U]),ze=(0,o.useCallback)(()=>{re(null),se(je()),ae(e=>e+1)},[je]),Te=(0,o.useCallback)(()=>{O(),i&&function(e){try{localStorage.removeItem(e)}catch{}}(i),G.close(),s?.()},[O,i,s]),Pe=(0,o.useCallback)(()=>{Y(e=>{const t=!e;return t&&h&&G.setMinimized(!1),t})},[h]);if(!y)return null;const Ee={video:y,isPlaying:m,isMinimized:h,playbackRate:x,queue:v,getCurrentTime:je,player:G},Ie=y.title??"Playing video",Re=oe??w,$e=L(y.videoId,{autoplay:!0,controls:!0,startSeconds:Re}),Le={...ue?{left:ue.x,top:ue.y,bottom:"auto",right:"auto"}:{},...ye&&!h?{width:ye}:{}};return(0,u.jsxs)("div",{ref:k,className:`eytp-root${h?" eytp-minimized":""}${pe||ge?" eytp-interacting":""}${a?` ${a}`:""}`,style:Le,children:[(0,u.jsxs)("div",{className:"eytp-bar"+(pe?" eytp-grabbing":""),onMouseDown:e=>{e.target.closest("button, a")||(e.preventDefault(),he(e.clientX,e.clientY))},onTouchStart:e=>{e.target.closest("button, a")||he(e.touches[0].clientX,e.touches[0].clientY)},children:[(0,u.jsx)("div",{className:"eytp-title",children:t?t(Ee):(0,u.jsx)("span",{className:"eytp-title-text",children:Ie})}),(0,u.jsx)(N,{isPlaying:m,isMinimized:h,queueLength:v.length,isPipSupported:T,isPipActive:I,isSubtitlesOpen:F,showSubtitles:ve,showPip:r,extraControls:"function"==typeof e?e(Ee):e,onPlayPause:G.togglePlay,onPlayNext:G.playNext,onToggleMinimize:()=>G.setMinimized(!h),onTogglePip:Se,onToggleSubtitles:Pe,onClose:Te})]}),F&&!h&&(0,u.jsx)(P,{sentences:fe,currentTime:W,onSeek:G.seekTo}),(0,u.jsxs)("div",{ref:S,className:`eytp-video${I?" eytp-pip":""}${h&&!I?" eytp-hidden":""}`,children:[(0,u.jsx)("iframe",{ref:we,src:$e,title:Ie,onLoad:()=>A(j.current),className:"eytp-iframe",referrerPolicy:"strict-origin-when-cross-origin",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0},ie),null!==Q&&(0,u.jsxs)("div",{className:"eytp-error",children:[(0,u.jsx)(d.AlertCircle,{size:18,color:"currentColor"}),(0,u.jsx)("p",{className:"eytp-error-text",children:$(Q)}),(0,u.jsxs)("div",{className:"eytp-error-actions",children:[(0,u.jsx)("button",{type:"button",onClick:ze,className:"eytp-link",children:"Retry"}),(0,u.jsx)("a",{href:M(y.videoId,je()),target:"_blank",rel:"noopener noreferrer",className:"eytp-link",children:"Watch on YouTube"})]})]})]}),!h&&!I&&(0,u.jsx)(C,{queue:v}),!h&&(0,u.jsx)(z,{isResizing:ge,startResize:be})]})}function ie(e){const t=Number(e??0);if(!Number.isFinite(t)||t<0)return"0";if(t<1e3)return String(Math.trunc(t));for(const[n,r]of[[1e9,"B"],[1e6,"M"],[1e3,"K"]])if(t>=n){const e=t/n;return`${e>=100?Math.round(e):Number(e.toFixed(1))}${r}`}return String(t)}function ae(e,t=!1){if(!e)return"";const n=Date.parse(e);if(!Number.isFinite(n))return e;const r=/^\d{4}-\d{2}-\d{2}$/.test(e);return new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",...t?{day:"numeric"}:{},...r?{timeZone:"UTC"}:{}}).format(new Date(n))}function oe(e,t){return null==t||""===t?null:"boolean"===e.type?t?e.label:null:"number"===e.type&&"number"==typeof t?`${e.label}: ${t.toLocaleString()}`:String(t)}function se(e,t){return null==t||""===t?"":"boolean"===e.type?t?"✓":"":"number"===e.type&&"number"==typeof t?t.toLocaleString():String(t)}function le(e){return{videoId:e.videoId,title:e.title,meta:{channel:e.channel,publishedAt:e.publishedAt}}}function ce(e,t="mqdefault"){return`https://i.ytimg.com/vi/${encodeURIComponent(e)}/${t}.jpg`}var de='\n.eytg-root {\n --eytg-bg: #ffffff;\n --eytg-card: #ffffff;\n --eytg-fg: #0f172a;\n --eytg-muted: #64748b;\n --eytg-subtle: #f1f5f9;\n --eytg-border: #e2e8f0;\n --eytg-accent: #2563eb;\n --eytg-accent-fg: #ffffff;\n --eytg-danger: #dc2626;\n --eytg-warn: #b45309;\n --eytg-ok: #15803d;\n --eytg-gold: #ca8a04;\n --eytg-radius: 12px;\n --eytg-card-min: 240px;\n color: var(--eytg-fg);\n font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;\n font-size: 14px;\n line-height: 1.4;\n}\n@media (prefers-color-scheme: dark) {\n :root:not(.light):not([data-theme="light"]) .eytg-root {\n --eytg-bg: #0b1120; --eytg-card: #111827; --eytg-fg: #e5e7eb; --eytg-muted: #94a3b8;\n --eytg-subtle: #1e293b; --eytg-border: #273449; --eytg-accent: #60a5fa; --eytg-accent-fg: #0b1120;\n --eytg-danger: #f87171; --eytg-warn: #fbbf24; --eytg-ok: #4ade80; --eytg-gold: #facc15;\n }\n}\n.dark .eytg-root, [data-theme="dark"] .eytg-root {\n --eytg-bg: #0b1120; --eytg-card: #111827; --eytg-fg: #e5e7eb; --eytg-muted: #94a3b8;\n --eytg-subtle: #1e293b; --eytg-border: #273449; --eytg-accent: #60a5fa; --eytg-accent-fg: #0b1120;\n --eytg-danger: #f87171; --eytg-warn: #fbbf24; --eytg-ok: #4ade80; --eytg-gold: #facc15;\n}\n.eytg-root *, .eytg-root *::before, .eytg-root *::after { box-sizing: border-box; }\n\n/* ── buttons & inputs ─────────────────────────────────────────────────── */\n.eytg-icon-btn {\n display: inline-flex; align-items: center; justify-content: center;\n width: 28px; height: 28px; padding: 0; border: 0; border-radius: 8px;\n background: transparent; color: var(--eytg-muted); cursor: pointer;\n transition: background .15s, color .15s;\n}\n.eytg-icon-btn:hover:not(:disabled) { background: var(--eytg-subtle); color: var(--eytg-fg); }\n.eytg-icon-btn:disabled { opacity: .4; cursor: default; }\n.eytg-icon-btn:focus-visible, .eytg-btn:focus-visible { outline: 2px solid var(--eytg-accent); outline-offset: 1px; }\n.eytg-icon-btn.eytg-on { color: var(--eytg-gold); }\n.eytg-btn {\n display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;\n border: 1px solid var(--eytg-border); border-radius: 8px; background: var(--eytg-card);\n color: var(--eytg-fg); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;\n}\n.eytg-btn:hover:not(:disabled) { background: var(--eytg-subtle); }\n.eytg-btn:disabled { opacity: .5; cursor: default; }\n.eytg-btn-primary { background: var(--eytg-accent); border-color: var(--eytg-accent); color: var(--eytg-accent-fg); }\n.eytg-btn-primary:hover:not(:disabled) { background: var(--eytg-accent); filter: brightness(1.08); }\n.eytg-btn-danger { color: var(--eytg-danger); }\n.eytg-input, .eytg-select, .eytg-textarea {\n height: 32px; padding: 0 10px; border: 1px solid var(--eytg-border); border-radius: 8px;\n background: var(--eytg-card); color: var(--eytg-fg); font: inherit; font-size: 13px; min-width: 0;\n}\n.eytg-textarea { height: auto; min-height: 88px; padding: 8px 10px; resize: vertical; width: 100%; }\n.eytg-input:focus, .eytg-select:focus, .eytg-textarea:focus { outline: 2px solid var(--eytg-accent); outline-offset: -1px; }\n\n/* ── badges ───────────────────────────────────────────────────────────── */\n.eytg-badge {\n display: inline-flex; align-items: center; gap: 4px; max-width: 100%;\n padding: 1px 7px; border-radius: 999px; border: 1px solid var(--eytg-border);\n background: var(--eytg-subtle); color: var(--eytg-muted); font-size: 11px; font-weight: 500;\n white-space: nowrap; overflow: hidden; text-overflow: ellipsis;\n}\nbutton.eytg-badge { cursor: pointer; font-family: inherit; }\nbutton.eytg-badge:hover { color: var(--eytg-fg); }\n.eytg-badge-accent { background: var(--eytg-accent); border-color: var(--eytg-accent); color: var(--eytg-accent-fg); }\n.eytg-badge-gold { background: rgba(202, 138, 4, .14); border-color: rgba(202, 138, 4, .4); color: var(--eytg-gold); }\n.eytg-badge-warn { background: rgba(180, 83, 9, .12); border-color: rgba(180, 83, 9, .35); color: var(--eytg-warn); }\n.eytg-badge-danger { background: rgba(220, 38, 38, .1); border-color: rgba(220, 38, 38, .35); color: var(--eytg-danger); }\n.eytg-badge-ok { background: rgba(21, 128, 61, .1); border-color: rgba(21, 128, 61, .35); color: var(--eytg-ok); }\n\n/* ── grid & card ──────────────────────────────────────────────────────── */\n.eytg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--eytg-card-min)), 1fr)); gap: 16px; }\n.eytg-empty { padding: 32px 16px; text-align: center; color: var(--eytg-muted); border: 1px dashed var(--eytg-border); border-radius: var(--eytg-radius); }\n.eytg-slot { position: relative; height: 100%; }\n.eytg-card {\n position: relative; display: flex; flex-direction: column; height: 100%; overflow: hidden;\n background: var(--eytg-card); border: 1px solid var(--eytg-border); border-radius: var(--eytg-radius);\n transition: box-shadow .2s, transform .2s, border-color .2s;\n}\n.eytg-card:hover { box-shadow: 0 10px 30px -12px rgba(15, 23, 42, .35); transform: translateY(-1px); }\n.eytg-card.eytg-playing { border-color: var(--eytg-accent); box-shadow: 0 0 0 1px var(--eytg-accent); }\n.eytg-card.eytg-hidden { opacity: .6; border-style: dashed; }\n.eytg-thumb {\n position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; padding: 0; border: 0;\n background: var(--eytg-subtle); cursor: pointer; overflow: hidden;\n}\n.eytg-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s; }\n.eytg-card:hover .eytg-thumb img { transform: scale(1.03); }\n.eytg-thumb-play {\n position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;\n color: #fff; background: rgba(0, 0, 0, .35); opacity: 0; transition: opacity .2s;\n}\n.eytg-thumb:hover .eytg-thumb-play, .eytg-thumb:focus-visible .eytg-thumb-play { opacity: 1; }\n.eytg-thumb-badges { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; }\n.eytg-thumb-badges .eytg-badge { background: rgba(0, 0, 0, .7); border-color: transparent; color: #fff; }\n.eytg-thumb-badges .eytg-badge-accent { background: var(--eytg-accent); color: var(--eytg-accent-fg); }\n.eytg-thumb-badges .eytg-badge-gold { background: rgba(0, 0, 0, .7); color: #facc15; }\n.eytg-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255, 255, 255, .35); }\n.eytg-progress > span { display: block; height: 100%; background: #ef4444; }\n.eytg-card-body { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px 4px; flex: 1; min-width: 0; }\n.eytg-card-title {\n margin: 0; font-size: 14px; font-weight: 600; line-height: 1.3; color: var(--eytg-fg);\n display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;\n}\n.eytg-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; color: var(--eytg-muted); font-size: 12px; }\n.eytg-card-meta button { padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }\n.eytg-card-meta button:hover { color: var(--eytg-fg); text-decoration: underline; }\n.eytg-card-badges { display: flex; flex-wrap: wrap; gap: 4px; }\n.eytg-card-desc {\n margin: 0; color: var(--eytg-muted); font-size: 12px;\n display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;\n}\n.eytg-card-actions { display: flex; align-items: center; gap: 2px; padding: 4px 8px 8px; }\n.eytg-card-actions .eytg-spacer { flex: 1; }\n.eytg-hidden-flag { position: absolute; top: 8px; left: 8px; z-index: 2; }\n\n/* ── stack nav ────────────────────────────────────────────────────────── */\n.eytg-stack {\n display: inline-flex; align-items: center; gap: 2px; padding: 1px 4px; font-size: 11px; font-weight: 500;\n color: var(--eytg-muted); border: 1px solid var(--eytg-border); border-radius: 6px; background: var(--eytg-card);\n}\n.eytg-stack-overlay { position: absolute; top: 8px; left: 8px; z-index: 3; background: rgba(255, 255, 255, .92); box-shadow: 0 1px 3px rgba(0,0,0,.15); }\n.dark .eytg-stack-overlay, [data-theme="dark"] .eytg-stack-overlay { background: rgba(17, 24, 39, .92); }\n.eytg-stack button {\n display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px;\n padding: 0; border: 0; border-radius: 4px; background: transparent; color: inherit; cursor: pointer;\n}\n.eytg-stack button:hover { background: var(--eytg-subtle); color: var(--eytg-fg); }\n.eytg-stack-count { font-variant-numeric: tabular-nums; }\n.eytg-stack-label { max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-left: 2px; }\n\n/* ── list / table ─────────────────────────────────────────────────────── */\n.eytg-table-wrap { overflow-x: auto; border: 1px solid var(--eytg-border); border-radius: var(--eytg-radius); background: var(--eytg-card); }\n.eytg-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13px; }\n.eytg-table th {\n position: relative; text-align: left; font-weight: 600; font-size: 12px; color: var(--eytg-muted);\n padding: 8px 10px; border-bottom: 1px solid var(--eytg-border); background: var(--eytg-subtle); white-space: nowrap;\n}\n.eytg-table th.eytg-num, .eytg-table td.eytg-num { text-align: right; font-variant-numeric: tabular-nums; }\n.eytg-th-btn { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }\n.eytg-th-btn:hover { color: var(--eytg-fg); }\n.eytg-table td { padding: 6px 10px; border-bottom: 1px solid var(--eytg-border); vertical-align: middle; overflow: hidden; text-overflow: ellipsis; }\n.eytg-table tr:last-child td { border-bottom: 0; }\n.eytg-row { cursor: pointer; }\n.eytg-row:hover td { background: var(--eytg-subtle); }\n.eytg-row.eytg-playing td { background: rgba(37, 99, 235, .08); }\n.eytg-row-title { display: flex; align-items: center; gap: 10px; min-width: 0; }\n.eytg-row-thumb { flex: none; width: 96px; aspect-ratio: 16 / 9; border-radius: 6px; object-fit: cover; background: var(--eytg-subtle); }\n.eytg-row-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }\n.eytg-row-text strong { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.eytg-row-text span { color: var(--eytg-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.eytg-group-row td { background: var(--eytg-subtle); font-weight: 600; cursor: pointer; }\n.eytg-group-row:hover td { filter: brightness(.97); }\n.eytg-group-label { display: inline-flex; align-items: center; gap: 6px; }\n.eytg-group-count { color: var(--eytg-muted); font-weight: 400; font-size: 12px; }\n.eytg-levels { display: inline-flex; gap: 2px; margin-left: 8px; vertical-align: middle; }\n.eytg-levels button {\n height: 20px; min-width: 24px; padding: 0 4px; border: 1px solid var(--eytg-border); border-radius: 4px;\n background: var(--eytg-card); color: var(--eytg-muted); font: inherit; font-size: 10px; cursor: pointer;\n}\n.eytg-levels button.eytg-on { background: var(--eytg-accent); border-color: var(--eytg-accent); color: var(--eytg-accent-fg); }\n.eytg-resize { position: absolute; top: 0; right: 0; z-index: 1; width: 8px; height: 100%; cursor: col-resize; touch-action: none; user-select: none; }\n.eytg-resize:hover, .eytg-resize:active { background: rgba(37, 99, 235, .35); }\n.eytg-resizing, .eytg-resizing * { cursor: col-resize !important; user-select: none !important; }\n.eytg-row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 2px; }\n\n/* ── admin ────────────────────────────────────────────────────────────── */\n.eytg-admin { display: flex; flex-direction: column; gap: 12px; }\n.eytg-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }\n.eytg-toolbar .eytg-grow { flex: 1 1 200px; }\n.eytg-banner { padding: 8px 12px; border-radius: 8px; font-size: 13px; border: 1px solid var(--eytg-border); background: var(--eytg-subtle); }\n.eytg-banner-error { border-color: rgba(220, 38, 38, .4); color: var(--eytg-danger); background: rgba(220, 38, 38, .06); }\n.eytg-banner-ok { border-color: rgba(21, 128, 61, .35); color: var(--eytg-ok); background: rgba(21, 128, 61, .06); }\n.eytg-pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--eytg-muted); font-size: 12px; }\n.eytg-pager > div { display: flex; gap: 6px; }\n.eytg-overlay {\n position: fixed; inset: 0; z-index: 10000; display: flex; align-items: flex-start; justify-content: center;\n padding: 5vh 16px; background: rgba(15, 23, 42, .55); overflow-y: auto;\n}\n.eytg-dialog {\n width: 100%; max-width: 640px; background: var(--eytg-card); color: var(--eytg-fg);\n border: 1px solid var(--eytg-border); border-radius: var(--eytg-radius); box-shadow: 0 30px 60px -20px rgba(0,0,0,.5);\n}\n.eytg-dialog-sm { max-width: 420px; }\n.eytg-dialog header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--eytg-border); }\n.eytg-dialog header h2 { margin: 0; font-size: 16px; }\n.eytg-dialog-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }\n.eytg-dialog footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--eytg-border); }\n.eytg-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }\n@media (max-width: 560px) { .eytg-form-grid { grid-template-columns: 1fr; } }\n.eytg-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }\n.eytg-field-wide { grid-column: 1 / -1; }\n.eytg-field > span { font-size: 12px; font-weight: 600; color: var(--eytg-muted); }\n.eytg-field small { font-size: 11px; color: var(--eytg-muted); }\n.eytg-check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }\n.eytg-section-title { margin: 4px 0 0; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--eytg-muted); }\n.eytg-spin { animation: eytg-spin 1s linear infinite; }\n@keyframes eytg-spin { to { transform: rotate(360deg); } }\n',ue=(0,o.createContext)(!1);function pe({children:e}){return(0,o.useContext)(ue)?(0,u.jsx)(u.Fragment,{children:e}):(0,u.jsxs)(ue.Provider,{value:!0,children:[(0,u.jsx)("style",{"data-extract-youtube-grid":"",children:de}),e]})}function ge(e,t){return!!e&&("has"in e?e.has(t):e.includes(t))}function ye({title:e,onConfirm:t,onCancel:n}){return(0,u.jsx)("div",{className:"eytg-overlay",role:"presentation",onClick:n,children:(0,u.jsxs)("div",{className:"eytg-dialog eytg-dialog-sm",role:"alertdialog","aria-modal":"true","aria-labelledby":"eytg-hide-title",onClick:e=>e.stopPropagation(),children:[(0,u.jsx)("header",{children:(0,u.jsx)("h2",{id:"eytg-hide-title",children:"Hide this video?"})}),(0,u.jsx)("div",{className:"eytg-dialog-body",children:(0,u.jsxs)("p",{style:{margin:0},children:[e?(0,u.jsx)("strong",{children:e}):"This video"," will be hidden from your listing. You can show it again from the hidden filter."]})}),(0,u.jsxs)("footer",{children:[(0,u.jsx)("button",{type:"button",className:"eytg-btn",onClick:n,children:"Cancel"}),(0,u.jsx)("button",{type:"button",className:"eytg-btn eytg-btn-primary",onClick:t,autoFocus:!0,children:"Hide"})]})]})})}var he=(0,o.memo)(function({video:e,showThumbnail:t=!0,showDescription:n=!1,showFullDate:r=!1,overlay:i,favorites:a,hidden:s,onToggleFavorite:l,onHide:c,onUnhide:p,onPlay:g,showQueueButton:y=!0,showYouTubeLink:h=!0,onBadgeClick:b,customFields:m,getProgress:x,renderActions:f,transcriptUrl:v,fetchTranscript:j}){const{videoId:k}=e,N=X(e=>e.activeVideo?.videoId===k),C=X(e=>e.queue.some(e=>e.videoId===k)),[S,z]=(0,o.useState)(!1),T=e.title||k,P=ge(a,k),E=ge(s,k),I=x?.(k),R=()=>g?g(e):G.play(le(e)),$=(m??[]).filter(e=>e.showOnCard).map(t=>({def:t,text:oe(t,e.custom?.[t.key])})).filter(e=>null!==e.text),L=e.availability&&"available"!==e.availability,M=e=>e?b?(0,u.jsx)("button",{type:"button",onClick:()=>b(e),title:`Filter by ${e}`,children:e}):(0,u.jsx)("span",{children:e}):null;return(0,u.jsxs)(pe,{children:[(0,u.jsxs)("article",{className:`eytg-card${N?" eytg-playing":""}${E?" eytg-hidden":""}`,"aria-label":T,children:[i,E&&!i&&(0,u.jsx)("span",{className:"eytg-hidden-flag eytg-badge",children:"Hidden"}),t&&(0,u.jsxs)("button",{type:"button",className:"eytg-thumb",onClick:R,"aria-label":`Play ${T}`,children:[(0,u.jsx)("img",{src:ce(k),alt:"",loading:"lazy",decoding:"async"}),(0,u.jsx)("span",{className:"eytg-thumb-play","aria-hidden":"true",children:(0,u.jsx)(d.Play,{size:36,fill:"currentColor"})}),(0,u.jsxs)("span",{className:"eytg-thumb-badges",children:[e.featured&&(0,u.jsxs)("span",{className:"eytg-badge eytg-badge-gold",title:"Top pick",children:[(0,u.jsx)(d.Medal,{size:11})," Top pick"]}),N&&(0,u.jsx)("span",{className:"eytg-badge eytg-badge-accent",children:"Playing"}),!N&&C&&(0,u.jsx)("span",{className:"eytg-badge",children:"Queued"})]}),"number"==typeof I&&I>0&&(0,u.jsx)("span",{className:"eytg-progress","aria-label":`${Math.round(100*I)}% watched`,children:(0,u.jsx)("span",{style:{width:`${Math.min(100,Math.round(100*I))}%`}})})]}),(0,u.jsxs)("div",{className:"eytg-card-body",children:[(0,u.jsx)("h3",{className:"eytg-card-title",title:T,children:t?T:(0,u.jsx)("button",{type:"button",onClick:R,style:{all:"unset",cursor:"pointer"},"aria-label":`Play ${T}`,children:T})}),(0,u.jsxs)("div",{className:"eytg-card-meta",children:[M(e.channel),e.publishedAt&&(0,u.jsx)("span",{children:ae(e.publishedAt,r)}),"number"==typeof e.viewCount&&e.viewCount>0&&(0,u.jsxs)("span",{children:[ie(e.viewCount)," views"]}),M(e.category)]}),($.length>0||L)&&(0,u.jsxs)("div",{className:"eytg-card-badges",children:[L&&(0,u.jsx)("span",{className:"eytg-badge eytg-badge-warn",children:"not_embeddable"===e.availability?"Embedding off":"private"===e.availability?"Private":"Removed"}),$.map(({def:e,text:t})=>b?(0,u.jsx)("button",{type:"button",className:"eytg-badge",title:e.label,onClick:()=>b(t),children:t},e.key):(0,u.jsx)("span",{className:"eytg-badge",title:e.label,children:t},e.key))]}),n&&e.description&&(0,u.jsx)("p",{className:"eytg-card-desc",children:e.description})]}),(0,u.jsxs)("div",{className:"eytg-card-actions",children:[l&&(0,u.jsx)("button",{type:"button",className:"eytg-icon-btn"+(P?" eytg-on":""),onClick:()=>l(k),"aria-pressed":P,"aria-label":P?"Remove from favorites":"Add to favorites",title:P?"Remove from favorites":"Add to favorites",children:(0,u.jsx)(d.Star,{size:15,fill:P?"currentColor":"none"})}),y&&(0,u.jsx)("button",{type:"button",className:"eytg-icon-btn",onClick:()=>G.addToQueue(le(e)),disabled:N||C,"aria-label":"Add to queue",title:C?"Already queued":"Add to queue",children:(0,u.jsx)(d.ListPlus,{size:15})}),(v||j)&&(0,u.jsx)(w,{videoId:k,title:T,transcriptUrl:v,fetchTranscript:j}),h&&(0,u.jsx)("a",{className:"eytg-icon-btn",href:`https://www.youtube.com/watch?v=${encodeURIComponent(k)}`,target:"_blank",rel:"noopener noreferrer","aria-label":"Open on YouTube",title:"Open on YouTube",children:(0,u.jsx)(d.ExternalLink,{size:15})}),(0,u.jsx)("span",{className:"eytg-spacer"}),f?.(e),E?p&&(0,u.jsx)("button",{type:"button",className:"eytg-icon-btn",onClick:()=>p(k),"aria-label":"Unhide",title:"Unhide",children:(0,u.jsx)(d.Eye,{size:15})}):c&&(0,u.jsx)("button",{type:"button",className:"eytg-icon-btn",onClick:()=>z(!0),"aria-label":"Hide",title:"Hide",children:(0,u.jsx)(d.EyeOff,{size:15})})]})]}),S&&c&&(0,u.jsx)(ye,{title:T,onCancel:()=>z(!1),onConfirm:()=>{z(!1),c(k)}})]})});function be({index:e,count:t,label:n,onSelect:r,variant:i="overlay",className:a}){if(t<2)return null;const o=e=>n=>{n.preventDefault(),n.stopPropagation(),r((e+t)%t)};return(0,u.jsxs)("div",{className:`eytg-stack${"overlay"===i?" eytg-stack-overlay":""}${a?` ${a}`:""}`,onClick:e=>e.stopPropagation(),role:"group","aria-label":"Stacked playlist",children:[(0,u.jsx)(d.Layers,{size:12,"aria-hidden":"true"}),(0,u.jsx)("button",{type:"button",onClick:o(e-1),"aria-label":"Previous video in this stack",children:(0,u.jsx)(d.ChevronLeft,{size:14})}),(0,u.jsx)("span",{className:"eytg-stack-count",children:`${e+1}/${t}`}),(0,u.jsx)("button",{type:"button",onClick:o(e+1),"aria-label":"Next video in this stack",children:(0,u.jsx)(d.ChevronRight,{size:14})}),n&&(0,u.jsx)("span",{className:"eytg-stack-label",title:n,children:n})]})}function me(e,t){return e.category?.trim()||`Part ${t+1}`}function xe({videos:e,initialIndex:t=0,stackLabel:n=me,...r}){const[i,a]=(0,o.useState)(t),s=Math.min(Math.max(i,0),e.length-1),l=e[s]??e[0];return l?(0,u.jsx)("div",{className:"eytg-slot",children:(0,u.jsx)(he,{...r,video:l,overlay:e.length>1?(0,u.jsx)(be,{index:s,count:e.length,label:n(l,s),onSelect:a}):void 0})}):null}function fe(e){return"string"==typeof e.stackKey&&e.stackKey.length>0?e.stackKey:null}function ve(e,t,n=!0){const r=t??function(e){const t={};for(const n of e){const e=fe(n);e&&(t[e]??(t[e]=[])).push(n)}for(const n of Object.keys(t))t[n].sort((e,t)=>(e.stackPosition??0)-(t.stackPosition??0));return t}(e),i=[],a=new Set;return e.forEach((e,t)=>{const o=n?fe(e):null,s=o?r[o]:void 0;if(!o||!s||s.length<2)return void i.push({key:`${e.videoId}-${t}`,videos:[e],initialIndex:0});if(a.has(o))return;a.add(o);const l=Math.max(0,s.findIndex(t=>t.videoId===e.videoId));i.push({key:`stack-${o}-${t}`,videos:s,initialIndex:l})}),i}var we=(0,o.memo)(function({videos:e,stacks:t,stacksEnabled:n=!0,stackLabel:r,showThumbnails:i=!0,showDescription:a,showFullDate:s,minCardWidth:l,emptyState:c,className:d,containerRef:p,...g}){const y=(0,o.useMemo)(()=>ve(e,t,n),[e,t,n]),h=l?{"--eytg-card-min":"number"==typeof l?`${l}px`:l}:void 0;return(0,u.jsx)(pe,{children:(0,u.jsx)("div",{className:"eytg-root"+(d?` ${d}`:""),style:h,children:0===y.length?(0,u.jsx)("div",{className:"eytg-empty",children:c??"No videos to show."}):(0,u.jsx)("div",{className:"eytg-grid",ref:p,children:y.map(e=>(0,u.jsx)(xe,{videos:e.videos,initialIndex:e.initialIndex,stackLabel:r,showThumbnail:i,showDescription:a,showFullDate:s,...g},e.key))})})})}),je=e=>{const t=e.publishedAt?Date.parse(e.publishedAt):NaN;if(!Number.isFinite(t))return{kind:"year",label:"Undated",sortValue:0,trailing:!0};const n=new Date(t).getUTCFullYear();return{kind:"year",label:String(n),sortValue:-n}},ke=e=>{const t=e.channel?.trim();return{kind:"channel",label:t||"Unsorted",sortValue:t?.toLowerCase()??"",trailing:!t}},Ne=e=>{const t=e.category?.trim();return{kind:"category",label:t||"Unsorted",sortValue:t?.toLowerCase()??"",trailing:!t}};var Ce={year:je,channel:ke,category:Ne};function Se(e){if(!e)return null;const t=Date.parse(e);return Number.isFinite(t)?t:null}function ze(e,t){const n=Se(t);if(null===n)return e;const r=Se(e);return null===r||n<r?t:e}function Te(e,t){const n=Se(t);if(null===n)return e;const r=Se(e);return null===r||n>r?t:e}function Pe(e,t){return e.type!==t.type?"group"===e.type?-1:1:"group"!==e.type||"group"!==t.type?0:e.trailing!==t.trailing?e.trailing?1:-1:"number"==typeof e.sortValue&&"number"==typeof t.sortValue?e.sortValue-t.sortValue:String(e.sortValue).localeCompare(String(t.sortValue))}function Ee(e){e.sort(Pe);for(const t of e)"group"===t.type&&Ee(t.children)}function Ie(e,t){const n=[],r=new Map;for(const i of e){const e=i.videos[i.initialIndex]??i.videos[0];if(!e)continue;const a=i.videos.reduce((e,t)=>e+(t.viewCount??0),0);let o=n,s="";for(const n of t){const t=n(e);if(!t)break;s=s?`${s} / ${t.kind}:${t.label}`:`${t.kind}:${t.label}`;let l=r.get(s);l||(l={type:"group",key:s,kind:t.kind,label:t.label,children:[],videoCount:0,viewCount:0,latestDate:null,earliestDate:null,sortValue:t.sortValue,trailing:t.trailing??!1},r.set(s,l),o.push(l)),l.videoCount+=i.videos.length,l.viewCount+=a,l.latestDate=Te(l.latestDate,e.publishedAt),l.earliestDate=ze(l.earliestDate,e.publishedAt),o=l.children}o.push({type:"video",key:i.key,slot:i})}return Ee(n),n}function Re(e){let t=0;for(const n of e){const e="group"===n.type?1+Re(n.children):1;e>t&&(t=e)}return Math.max(1,t)}function $e(e,t){const n=[...e.filter(e=>"video"===e.type)].sort((e,n)=>t(e.slot,n.slot));let r=0;return e.map(e=>"group"===e.type?{...e,children:$e(e.children,t)}:n[r++])}function Le(e){return e.reduce((e,t)=>e+("group"===t.type?Le(t.children):1),0)}function Me(e,t,n=0){const r=[];for(const i of e)"group"===i.type&&(n>=t&&r.push(i.key),r.push(...Me(i.children,t,n+1)));return r}function Ae(e){const[t,n]=(0,o.useState)(e),r=(0,o.useRef)(null),i=(0,o.useRef)({x:0,width:0}),a=(0,o.useCallback)((e,n)=>{r.current=e,i.current={x:n,width:t[e]??120},document.body.classList.add("eytg-resizing")},[t]),s=(0,o.useCallback)(()=>n(e),[e]);return(0,o.useEffect)(()=>{const e=e=>{const t=r.current;if(!t)return;const a=Math.max(60,Math.min(900,i.current.width+e-i.current.x));n(e=>e[t]===a?e:{...e,[t]:a})},t=()=>{r.current&&(r.current=null,document.body.classList.remove("eytg-resizing"))},a=t=>e(t.clientX),o=t=>{r.current&&(e(t.touches[0].clientX),t.preventDefault())};return document.addEventListener("mousemove",a),document.addEventListener("mouseup",t),document.addEventListener("touchmove",o,{passive:!1}),document.addEventListener("touchend",t),()=>{document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",t),document.removeEventListener("touchmove",o),document.removeEventListener("touchend",t),document.body.classList.remove("eytg-resizing")}},[]),{widths:t,startResize:a,resetWidths:s}}function De({onResizeStart:e,label:t}){return(0,u.jsx)("span",{className:"eytg-resize",role:"separator","aria-orientation":"vertical","aria-label":t?`Resize ${t} column`:"Resize column",onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),e(t.clientX)},onTouchStart:t=>{t.stopPropagation(),e(t.touches[0].clientX)},onClick:e=>e.stopPropagation()})}function qe(e){return{key:`custom:${e.key}`,label:e.label,numeric:"number"===e.type,width:"boolean"===e.type?90:140,value:t=>{const n=t.custom?.[e.key];return"number"==typeof n?n:"boolean"==typeof n?n?1:0:(n??"").toString().toLowerCase()},render:t=>{const n=t.custom?.[e.key];return"url"===e.type&&"string"==typeof n?(0,u.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),children:"Link"}):se(e,n)}}}function Ve(e){return e.videos[e.initialIndex]??e.videos[0]}var Ue=(0,o.memo)(function({slot:e,depth:t,ctx:n}){const[r,i]=(0,o.useState)(e.initialIndex),a=Math.min(Math.max(r,0),e.videos.length-1),s=e.videos[a]??e.videos[0],l=X(e=>e.activeVideo?.videoId===s.videoId),c=X(e=>e.queue.some(e=>e.videoId===s.videoId)),p=ge(n.favorites,s.videoId),g=ge(n.hidden,s.videoId),y=e=>e.stopPropagation();return(0,u.jsxs)("tr",{className:"eytg-row"+(l?" eytg-playing":""),onClick:()=>n.onPlay?n.onPlay(s):G.play(le(s)),style:g?{opacity:.6}:void 0,"aria-label":s.title||s.videoId,children:[n.columns.map(r=>"title"===r.key?(0,u.jsx)("td",{style:{paddingLeft:10+18*t},children:(0,u.jsxs)("div",{className:"eytg-row-title",children:[n.showThumbnails&&(0,u.jsx)("img",{className:"eytg-row-thumb",src:ce(s.videoId),alt:"",loading:"lazy"}),(0,u.jsxs)("div",{className:"eytg-row-text",children:[(0,u.jsx)("strong",{title:s.title,children:s.title||s.videoId}),(0,u.jsx)("span",{children:[s.category,s.featured?"Top pick":null,c&&!l?"Queued":null].filter(Boolean).join(" · ")}),e.videos.length>1&&(0,u.jsx)("div",{onClick:y,children:(0,u.jsx)(be,{variant:"inline",index:a,count:e.videos.length,label:n.stackLabel(s,a),onSelect:i})})]})]})},"title"):(0,u.jsx)("td",{className:r.numeric?"eytg-num":void 0,children:r.render(s)},r.key)),(0,u.jsx)("td",{onClick:y,children:(0,u.jsxs)("div",{className:"eytg-row-actions",children:[n.onToggleFavorite&&(0,u.jsx)("button",{type:"button",className:"eytg-icon-btn"+(p?" eytg-on":""),onClick:()=>n.onToggleFavorite?.(s.videoId),"aria-pressed":p,"aria-label":p?"Remove from favorites":"Add to favorites",children:(0,u.jsx)(d.Star,{size:14,fill:p?"currentColor":"none"})}),!1!==n.showQueueButton&&(0,u.jsx)("button",{type:"button",className:"eytg-icon-btn",onClick:()=>G.addToQueue(le(s)),disabled:l||c,"aria-label":"Add to queue",children:(0,u.jsx)(d.ListPlus,{size:14})}),n.renderActions?.(s),g?n.onUnhide&&(0,u.jsx)("button",{type:"button",className:"eytg-icon-btn",onClick:()=>n.onUnhide?.(s.videoId),"aria-label":"Unhide",children:(0,u.jsx)(d.Eye,{size:14})}):n.onHide&&(0,u.jsx)("button",{type:"button",className:"eytg-icon-btn",onClick:()=>n.onRequestHide(s),"aria-label":"Hide",children:(0,u.jsx)(d.EyeOff,{size:14})})]})})]})});var Oe=(0,o.memo)(function({videos:e,stacks:t,stacksEnabled:n=!0,stackLabel:r=me,groupBy:i,defaultCollapseDepth:a,defaultSort:s,showThumbnails:l=!0,hideChannelColumn:c=!1,emptyState:p,className:g,customFields:y,...h}){const b=(0,o.useMemo)(()=>{const e=[{key:"title",label:"Video",width:l?420:320,value:e=>(e.title??"").toLowerCase(),render:()=>null}];c||e.push({key:"channel",label:"Channel",width:160,value:e=>(e.channel??"").toLowerCase(),render:e=>e.channel??""});for(const t of y??[])t.showInList&&e.push(qe(t));return e.push({key:"date",label:"Date",width:110,value:e=>e.publishedAt&&Date.parse(e.publishedAt)||0,render:e=>ae(e.publishedAt,!0)},{key:"views",label:"Views",numeric:!0,width:90,value:e=>e.viewCount??0,render:e=>ie(e.viewCount)}),e},[y,c,l]),m=(0,o.useMemo)(()=>Object.fromEntries(b.map(e=>[e.key,e.width])),[b]),{widths:x,startResize:f}=Ae(m),[v,w]=(0,o.useState)(s??null),[j,k]=(0,o.useState)(null),N=(0,o.useMemo)(()=>ve(e,t,n),[e,t,n]),C=(0,o.useMemo)(()=>i&&i.length>0?function(e){return e.map(e=>"string"==typeof e?Ce[e]:e)}(i):[],[i]),S=(0,o.useMemo)(()=>Ie(N,C),[N,C]),z=(0,o.useCallback)((e,t)=>{if(!v)return 0;const n=b.find(e=>e.key===v.column);if(!n)return 0;const r=n.value(Ve(e)),i=n.value(Ve(t)),a="number"==typeof r&&"number"==typeof i?r-i:String(r).localeCompare(String(i));return"asc"===v.direction?a:-a},[b,v]),T=(0,o.useMemo)(()=>v?$e(S,z):S,[S,v,z]),P=Re(S),[E,I]=(0,o.useState)(()=>new Set(a?Me(S,a-1):[])),[R,$]=(0,o.useState)(a??P),L={...h,columns:b,showThumbnails:l,stackLabel:r,onRequestHide:k},M=[],A=(e,t)=>{for(const n of e){if("video"===n.type){M.push((0,u.jsx)(Ue,{slot:n.slot,depth:t,ctx:L},n.key));continue}const e=!E.has(n.key);M.push((0,u.jsx)("tr",{className:"eytg-group-row",onClick:()=>{return e=n.key,I(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});var e},"aria-expanded":e,children:(0,u.jsx)("td",{colSpan:b.length+1,style:{paddingLeft:10+18*t},children:(0,u.jsxs)("span",{className:"eytg-group-label",children:[e?(0,u.jsx)(d.ChevronDown,{size:14}):(0,u.jsx)(d.ChevronRight,{size:14}),n.label,(0,u.jsx)("span",{className:"eytg-group-count",children:`${n.videoCount} video${1===n.videoCount?"":"s"} · ${ie(n.viewCount)} views`})]})})},n.key)),e&&A(n.children,t+1)}};return A(T,0),(0,u.jsx)(pe,{children:(0,u.jsxs)("div",{className:"eytg-root"+(g?` ${g}`:""),children:[0===Le(S)?(0,u.jsx)("div",{className:"eytg-empty",children:p??"No videos to show."}):(0,u.jsx)("div",{className:"eytg-table-wrap",children:(0,u.jsxs)("table",{className:"eytg-table",children:[(0,u.jsxs)("colgroup",{children:[b.map(e=>(0,u.jsx)("col",{style:{width:x[e.key]??e.width}},e.key)),(0,u.jsx)("col",{style:{width:120}})]}),(0,u.jsx)("thead",{children:(0,u.jsxs)("tr",{children:[b.map((e,t)=>{const n=v?.column===e.key;return(0,u.jsxs)("th",{className:e.numeric?"eytg-num":void 0,"aria-sort":n?"asc"===v?.direction?"ascending":"descending":"none",children:[(0,u.jsxs)("button",{type:"button",className:"eytg-th-btn",onClick:()=>(e=>w(t=>t?.column===e?{column:e,direction:"asc"===t.direction?"desc":"asc"}:{column:e,direction:"title"===e||"channel"===e?"asc":"desc"}))(e.key),children:[e.label,n&&("asc"===v?.direction?(0,u.jsx)(d.ChevronUp,{size:12}):(0,u.jsx)(d.ChevronDown,{size:12}))]}),0===t&&C.length>0&&P>1&&(0,u.jsx)("span",{className:"eytg-levels",role:"group","aria-label":"Tree level",children:Array.from({length:P},(e,t)=>t+1).map(e=>(0,u.jsx)("button",{type:"button",className:R===e?"eytg-on":void 0,onClick:()=>{return $(t=e),void I(new Set(Me(S,t-1)));var t},title:e===P?"Show every video":`Show ${e} level${1===e?"":"s"}`,children:`L${e}`},e))}),(0,u.jsx)(De,{label:e.label,onResizeStart:t=>f(e.key,t)})]},e.key)}),(0,u.jsx)("th",{"aria-label":"Actions"})]})}),(0,u.jsx)("tbody",{children:M})]})}),j&&h.onHide&&(0,u.jsx)(ye,{title:j.title,onCancel:()=>k(null),onConfirm:()=>{h.onHide?.(j.videoId),k(null)}})]})})});var Fe=["available","private","not_embeddable","removed"],Ye=/^[a-zA-Z0-9_-]{11}$/;var We={available:"Available",private:"Private",not_embeddable:"Embedding disabled",removed:"Removed"};function He(e,t){return"boolean"===e.type?Boolean(t):null==t?"":String(t)}function Be({client:e,video:t,customFields:n=[],categories:r=[],onClose:i,onSaved:a}){const s=null===t,l=(0,o.useMemo)(()=>function(e,t){return{videoInput:e?.videoId??"",title:e?.title??"",channel:e?.channel??"",publishedAt:e?.publishedAt?.slice(0,10)??"",viewCount:e?String(e.viewCount):"",category:e?.category??"",tags:(e?.tags??[]).join(", "),description:e?.description??"",featured:e?.featured??!1,hidden:e?.hidden??!1,availability:e?.availability??"available",custom:Object.fromEntries(t.map(t=>[t.key,He(t,e?.custom?.[t.key])]))}}(t,n),[t,n]),[c,p]=(0,o.useState)(l),[g,y]=(0,o.useState)(!1),[h,b]=(0,o.useState)(!1),[m,x]=(0,o.useState)(null),[f,v]=(0,o.useState)(null);(0,o.useEffect)(()=>p(l),[l]),(0,o.useEffect)(()=>{const e=e=>"Escape"===e.key&&i();return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[i]);const w=t?t.videoId:function(e){const t=e.trim();if(!t)return null;if(Ye.test(t))return t;try{const e=new URL(t),n=e.hostname.replace(/^www\./,"").replace(/^m\./,"");if("youtu.be"===n){const t=e.pathname.slice(1).split("/")[0];return Ye.test(t)?t:null}if("youtube.com"===n||"youtube-nocookie.com"===n){if("/watch"===e.pathname){const t=e.searchParams.get("v");return t&&Ye.test(t)?t:null}const t=e.pathname.match(/^\/(embed|shorts|live)\/([a-zA-Z0-9_-]{11})/);if(t)return t[2]}return null}catch{const e=t.match(/[?&]v=([a-zA-Z0-9_-]{11})/);if(e)return e[1];const n=t.match(/(?:embed|shorts|live|youtu\.be)\/([a-zA-Z0-9_-]{11})/);return n?n[1]:null}}(c.videoInput),j=(e,t)=>p(n=>({...n,[e]:t})),k="eytg-category-options";return(0,u.jsx)(pe,{children:(0,u.jsx)("div",{className:"eytg-root eytg-overlay",role:"presentation",onClick:i,children:(0,u.jsxs)("form",{className:"eytg-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"eytg-edit-title",onClick:e=>e.stopPropagation(),onSubmit:async t=>{if(t.preventDefault(),w)if(c.title.trim()){y(!0),x(null);try{const t=function(e,t,n){const r={},i=r=>n||e[r]!==t[r];i("title")&&(r.title=e.title),i("channel")&&(r.channel=e.channel),i("publishedAt")&&(r.publishedAt=e.publishedAt),i("viewCount")&&(r.viewCount=e.viewCount),i("category")&&(r.category=e.category),i("tags")&&(r.tags=e.tags),i("description")&&(r.description=e.description),i("featured")&&(r.featured=e.featured),i("hidden")&&(r.hidden=e.hidden),i("availability")&&(r.availability=e.availability);const a={};for(const[o,s]of Object.entries(e.custom))(n||s!==t.custom[o])&&(a[o]=s);return Object.keys(a).length>0&&(r.custom=a),r}(c,l,s);a(s?await e.create(w,t):await e.update(w,t))}catch(n){x(n instanceof Error?n.message:String(n))}finally{y(!1)}}else x("A title is required.");else x("That is not a YouTube URL or video id.")},children:[(0,u.jsxs)("header",{children:[(0,u.jsx)("h2",{id:"eytg-edit-title",children:s?"Add video":"Edit video"}),(0,u.jsx)("button",{type:"button",className:"eytg-icon-btn",onClick:i,"aria-label":"Close",children:(0,u.jsx)(d.X,{size:16})})]}),(0,u.jsxs)("div",{className:"eytg-dialog-body",children:[m&&(0,u.jsx)("div",{className:"eytg-banner eytg-banner-error",role:"alert",children:m}),f&&(0,u.jsx)("div",{className:"eytg-banner",children:f}),(0,u.jsxs)("div",{className:"eytg-form-grid",children:[(0,u.jsxs)("label",{className:"eytg-field eytg-field-wide",children:[(0,u.jsx)("span",{children:"YouTube URL or video id"}),(0,u.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,u.jsx)("input",{className:"eytg-input",style:{flex:1},value:c.videoInput,onChange:e=>j("videoInput",e.target.value),disabled:!s,placeholder:"https://www.youtube.com/watch?v=…",required:!0,autoFocus:s}),(0,u.jsxs)("button",{type:"button",className:"eytg-btn",onClick:async()=>{if(w){b(!0),x(null),v(null);try{const t=await e.autofill({videoId:w,title:c.title,channel:c.channel,description:c.description}),{fields:r}=t;p(e=>{const t={...e,custom:{...e.custom}};"string"==typeof r.title&&(t.title=r.title),"string"==typeof r.channel&&(t.channel=r.channel),"string"==typeof r.publishedAt&&(t.publishedAt=r.publishedAt.slice(0,10)),void 0!==r.viewCount&&(t.viewCount=String(r.viewCount)),"string"==typeof r.description&&(t.description=r.description),"string"==typeof r.category&&(t.category=r.category),Array.isArray(r.tags)&&(t.tags=r.tags.join(", ")),"string"==typeof r.availability&&(t.availability=r.availability);for(const i of n){const e=r.custom?.[i.key];null!=e&&""!==e&&(t.custom[i.key]=He(i,e))}return t});const i=t.sources.length>0?`Filled from ${t.sources.join(", ")}.`:"Nothing to fill in.";v([i,...t.warnings].join(" "))}catch(t){x(t instanceof Error?t.message:String(t))}finally{b(!1)}}else x("Enter a YouTube URL or video id first.")},disabled:h||!w,children:[h?(0,u.jsx)(d.Loader2,{size:14,className:"eytg-spin"}):(0,u.jsx)(d.Sparkles,{size:14}),"Auto-fill"]})]}),s&&c.videoInput&&!w&&(0,u.jsx)("small",{children:"Not a recognisable YouTube URL or id."})]}),(0,u.jsxs)("label",{className:"eytg-field eytg-field-wide",children:[(0,u.jsx)("span",{children:"Title"}),(0,u.jsx)("input",{className:"eytg-input",value:c.title,onChange:e=>j("title",e.target.value),required:!0})]}),(0,u.jsxs)("label",{className:"eytg-field",children:[(0,u.jsx)("span",{children:"Channel"}),(0,u.jsx)("input",{className:"eytg-input",value:c.channel,onChange:e=>j("channel",e.target.value)})]}),(0,u.jsxs)("label",{className:"eytg-field",children:[(0,u.jsx)("span",{children:"Published"}),(0,u.jsx)("input",{className:"eytg-input",type:"date",value:c.publishedAt,onChange:e=>j("publishedAt",e.target.value)})]}),(0,u.jsxs)("label",{className:"eytg-field",children:[(0,u.jsx)("span",{children:"Category"}),(0,u.jsx)("input",{className:"eytg-input",list:k,value:c.category,onChange:e=>j("category",e.target.value)}),(0,u.jsx)("datalist",{id:k,children:r.map(e=>(0,u.jsx)("option",{value:e},e))})]}),(0,u.jsxs)("label",{className:"eytg-field",children:[(0,u.jsx)("span",{children:"Views"}),(0,u.jsx)("input",{className:"eytg-input",type:"number",min:0,value:c.viewCount,onChange:e=>j("viewCount",e.target.value)})]}),(0,u.jsxs)("label",{className:"eytg-field eytg-field-wide",children:[(0,u.jsx)("span",{children:"Tags"}),(0,u.jsx)("input",{className:"eytg-input",value:c.tags,onChange:e=>j("tags",e.target.value),placeholder:"comma, separated"})]}),(0,u.jsxs)("label",{className:"eytg-field",children:[(0,u.jsx)("span",{children:"Availability"}),(0,u.jsx)("select",{className:"eytg-select",value:c.availability,onChange:e=>j("availability",e.target.value),children:Fe.map(e=>(0,u.jsx)("option",{value:e,children:We[e]},e))})]}),(0,u.jsxs)("div",{className:"eytg-field",style:{justifyContent:"flex-end",gap:8},children:[(0,u.jsxs)("label",{className:"eytg-check",children:[(0,u.jsx)("input",{type:"checkbox",checked:c.featured,onChange:e=>j("featured",e.target.checked)}),"Top pick"]}),(0,u.jsxs)("label",{className:"eytg-check",children:[(0,u.jsx)("input",{type:"checkbox",checked:c.hidden,onChange:e=>j("hidden",e.target.checked)}),"Hidden from public listings"]})]}),(0,u.jsxs)("label",{className:"eytg-field eytg-field-wide",children:[(0,u.jsx)("span",{children:"Description"}),(0,u.jsx)("textarea",{className:"eytg-textarea",value:c.description,onChange:e=>j("description",e.target.value),rows:4}),(0,u.jsx)("small",{children:"Links to other videos in the library stack them together."})]})]}),n.length>0&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("h3",{className:"eytg-section-title",children:"Custom fields"}),(0,u.jsx)("div",{className:"eytg-form-grid",children:n.map(e=>(0,u.jsx)(Xe,{def:e,value:c.custom[e.key],onChange:t=>((e,t)=>p(n=>({...n,custom:{...n.custom,[e]:t}})))(e.key,t)},e.key))})]})]}),(0,u.jsxs)("footer",{children:[(0,u.jsx)("button",{type:"button",className:"eytg-btn",onClick:i,children:"Cancel"}),(0,u.jsxs)("button",{type:"submit",className:"eytg-btn eytg-btn-primary",disabled:g,children:[g&&(0,u.jsx)(d.Loader2,{size:14,className:"eytg-spin"}),s?"Add video":"Save changes"]})]})]})})})}function Xe({def:e,value:t,onChange:n}){if("boolean"===e.type)return(0,u.jsxs)("div",{className:"eytg-field",style:{justifyContent:"flex-end"},children:[(0,u.jsxs)("label",{className:"eytg-check",children:[(0,u.jsx)("input",{type:"checkbox",checked:Boolean(t),onChange:e=>n(e.target.checked)}),e.label]}),e.help&&(0,u.jsx)("small",{children:e.help})]});const r="string"==typeof t?t:"";return(0,u.jsxs)("label",{className:"eytg-field"+("textarea"===e.type?" eytg-field-wide":""),children:[(0,u.jsx)("span",{children:e.label}),"select"===e.type?(0,u.jsxs)("select",{className:"eytg-select",value:r,onChange:e=>n(e.target.value),children:[(0,u.jsx)("option",{value:"",children:"—"}),(e.options??[]).map(e=>(0,u.jsx)("option",{value:e,children:e},e))]}):"textarea"===e.type?(0,u.jsx)("textarea",{className:"eytg-textarea",value:r,rows:3,onChange:e=>n(e.target.value)}):(0,u.jsx)("input",{className:"eytg-input",type:"number"===e.type?"number":"url"===e.type?"url":"text",value:r,onChange:e=>n(e.target.value)}),e.help&&(0,u.jsx)("small",{children:e.help})]})}var _e={available:{label:"Available",tone:"eytg-badge-ok"},private:{label:"Private",tone:"eytg-badge-warn"},not_embeddable:{label:"No embed",tone:"eytg-badge-warn"},removed:{label:"Removed",tone:"eytg-badge-danger"}},Je=[{key:"title",label:"Video"},{key:"published",label:"Published"},{key:"views",label:"Views",numeric:!0}];function Qe({column:e,sort:t,dir:n,onSort:r}){const i=t===e.key;return(0,u.jsx)("th",{className:e.numeric?"eytg-num":void 0,"aria-sort":i?"asc"===n?"ascending":"descending":"none",children:(0,u.jsxs)("button",{type:"button",className:"eytg-th-btn",onClick:()=>r(e.key),children:[e.label,i&&("asc"===n?(0,u.jsx)(d.ChevronUp,{size:12}):(0,u.jsx)(d.ChevronDown,{size:12}))]})})}var Ke={private:{text:"Private",tone:"eytg-badge-warn",hint:"The uploader made it private. It may come back."},not_embeddable:{text:"Embedding off",tone:"eytg-badge-warn",hint:"Still on YouTube, but it will not play inside your site."},removed:{text:"Removed",tone:"eytg-badge-danger",hint:"Deleted or rejected. This is permanent."}};exports.ColumnResizeHandle=De,exports.CustomFieldInput=Xe,exports.FloatingYouTubePlayer=function(e){const[t,n]=(0,o.useState)(!1);return(0,o.useEffect)(()=>{!function(e){if(!e||e.getElementById("extract-youtube-floating-player-styles"))return;const t=e.createElement("style");t.id="extract-youtube-floating-player-styles",t.textContent='\n.eytp-root {\n --eytp-bg: #ffffff;\n --eytp-fg: #111827;\n --eytp-muted: #6b7280;\n --eytp-bar: #f3f4f6;\n --eytp-border: #e5e7eb;\n --eytp-accent: #3b82f6;\n --eytp-danger: #dc2626;\n position: fixed;\n z-index: 9999;\n bottom: 24px;\n right: 16px;\n width: 380px;\n max-width: calc(100vw - 2rem);\n background: var(--eytp-bg);\n color: var(--eytp-fg);\n border: 1px solid var(--eytp-border);\n border-radius: 12px;\n overflow: hidden;\n box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);\n font-family: system-ui, -apple-system, "Segoe UI", sans-serif;\n transition: width 0.3s ease, height 0.3s ease;\n}\n@media (prefers-color-scheme: dark) {\n .eytp-root {\n --eytp-bg: #0b0f19;\n --eytp-fg: #f3f4f6;\n --eytp-muted: #9ca3af;\n --eytp-bar: #161b26;\n --eytp-border: #2a3040;\n }\n}\n.eytp-root.eytp-minimized { width: 260px; }\n/* The width transition is for the minimize/expand toggle. During a resize it\n would make the widget rubber-band behind the pointer, so it\'s off mid-gesture. */\n.eytp-root.eytp-interacting { transition: none; }\n\n.eytp-bar {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n padding: 6px 10px;\n background: var(--eytp-bar);\n cursor: grab;\n user-select: none;\n touch-action: none;\n}\n.eytp-bar.eytp-grabbing { cursor: grabbing; }\n.eytp-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; overflow: hidden; }\n.eytp-title-text { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n\n.eytp-controls { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }\n.eytp-btn {\n display: inline-flex;\n align-items: center;\n gap: 2px;\n padding: 4px;\n border: none;\n border-radius: 4px;\n background: transparent;\n color: var(--eytp-muted);\n cursor: pointer;\n line-height: 0;\n}\n.eytp-btn:hover { color: var(--eytp-fg); background: rgba(127, 127, 127, 0.18); }\n.eytp-btn-active { color: var(--eytp-accent); background: rgba(59, 130, 246, 0.14); }\n.eytp-btn-count { font-size: 10px; font-variant-numeric: tabular-nums; line-height: 1; }\n\n.eytp-video { position: relative; width: 100%; padding-top: 56.25%; background: #000; }\n.eytp-video.eytp-hidden { display: none; }\n.eytp-video.eytp-pip { position: absolute; inset: 0; width: 100%; height: 100%; padding-top: 0; }\n.eytp-iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }\n\n.eytp-error {\n position: absolute;\n inset: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 8px;\n padding: 16px;\n text-align: center;\n background: var(--eytp-bg);\n}\n.eytp-error-text { font-size: 12px; color: var(--eytp-muted); margin: 0; }\n.eytp-error-actions { display: flex; gap: 8px; }\n.eytp-link {\n border: 1px solid var(--eytp-border);\n border-radius: 6px;\n padding: 4px 10px;\n font-size: 12px;\n font-weight: 500;\n background: transparent;\n color: inherit;\n text-decoration: none;\n cursor: pointer;\n}\n.eytp-link:hover { background: rgba(127, 127, 127, 0.14); }\n\n.eytp-queue { border-top: 1px solid var(--eytp-border); background: var(--eytp-bar); padding: 6px 10px; }\n.eytp-queue-heading {\n display: flex;\n align-items: center;\n gap: 4px;\n font-size: 10px;\n text-transform: uppercase;\n letter-spacing: 0.06em;\n color: var(--eytp-muted);\n margin-bottom: 2px;\n}\n.eytp-queue-next { font-size: 12px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.eytp-queue-rest { font-size: 10px; color: var(--eytp-muted); margin: 2px 0 0; }\n\n.eytp-subtitles { max-height: 190px; overflow-y: auto; border-bottom: 1px solid var(--eytp-border); padding: 6px; }\n\n.eytp-line {\n display: block;\n width: 100%;\n line-height: 1.5;\n text-align: left;\n border: none;\n background: transparent;\n border-radius: 6px;\n padding: 4px 6px;\n font-size: 12px;\n color: inherit;\n cursor: pointer;\n}\n.eytp-line:hover { background: rgba(127, 127, 127, 0.14); }\n.eytp-line-active { background: rgba(59, 130, 246, 0.14); }\n.eytp-word-active { background: rgba(59, 130, 246, 0.3); border-radius: 3px; padding: 0 2px; font-weight: 500; }\n\n.eytp-handle { position: absolute; }\n.eytp-handle:hover { background: rgba(59, 130, 246, 0.2); }\n.eytp-handle-left { left: 0; top: 0; bottom: 0; width: 6px; cursor: ew-resize; }\n.eytp-handle-right { right: 0; top: 0; bottom: 0; width: 6px; cursor: ew-resize; }\n.eytp-handle-bl { left: 0; bottom: 0; width: 12px; height: 12px; cursor: nesw-resize; z-index: 1; }\n.eytp-handle-br { right: 0; bottom: 0; width: 12px; height: 12px; cursor: nwse-resize; z-index: 1; }\n/* Swallows pointer events over the iframe mid-resize, which would otherwise\n capture the drag and freeze the gesture. */\n.eytp-resize-shield { position: absolute; inset: 0; z-index: 10; }\n',e.head.appendChild(t)}(document),n(!0)},[]),t?(0,p.createPortal)((0,u.jsx)(re,{...e}),document.body):null},exports.GRID_STYLES=de,exports.GridStylesProvider=pe,exports.HideConfirm=ye,exports.StackNav=be,exports.StackedVideoCard=xe,exports.VideoAvailabilityPanel=function({client:e,limit:t=100,onChange:n,className:r}){const[i,a]=(0,o.useState)(null),[s,l]=(0,o.useState)(null),[c,p]=(0,o.useState)(null),g=(0,o.useCallback)(()=>{p(null),e.unavailable(t).then(a).catch(e=>p(e instanceof Error?e.message:String(e)))},[e,t]);(0,o.useEffect)(g,[g]);const y=async(e,t)=>{l(e),p(null);try{await t(),a(t=>t?.filter(t=>t.videoId!==e)??null),n?.()}catch(r){p(r instanceof Error?r.message:String(r))}finally{l(null)}};return(0,u.jsx)(pe,{children:(0,u.jsxs)("section",{className:"eytg-root eytg-admin"+(r?` ${r}`:""),"aria-label":"Unavailable videos",children:[(0,u.jsxs)("div",{className:"eytg-toolbar",children:[(0,u.jsxs)("strong",{style:{flex:1},children:["Unavailable on YouTube",i?` (${i.length})`:""]}),(0,u.jsxs)("button",{type:"button",className:"eytg-btn",onClick:g,children:[(0,u.jsx)(d.RefreshCw,{size:14})," Reload"]})]}),c&&(0,u.jsx)("div",{className:"eytg-banner eytg-banner-error",role:"alert",children:c}),null===i?(0,u.jsx)("div",{className:"eytg-empty",children:(0,u.jsx)(d.Loader2,{size:16,className:"eytg-spin"})}):0===i.length?(0,u.jsx)("div",{className:"eytg-empty",children:"Every video in the library is playable. Run a resync to re-check."}):(0,u.jsx)("div",{className:"eytg-table-wrap",children:(0,u.jsxs)("table",{className:"eytg-table",children:[(0,u.jsxs)("colgroup",{children:[(0,u.jsx)("col",{}),(0,u.jsx)("col",{style:{width:140}}),(0,u.jsx)("col",{style:{width:120}}),(0,u.jsx)("col",{style:{width:200}})]}),(0,u.jsx)("thead",{children:(0,u.jsxs)("tr",{children:[(0,u.jsx)("th",{children:"Video"}),(0,u.jsx)("th",{children:"Status"}),(0,u.jsx)("th",{children:"Checked"}),(0,u.jsx)("th",{"aria-label":"Actions"})]})}),(0,u.jsx)("tbody",{children:i.map(t=>{const n=Ke[t.availability]??Ke.removed;return(0,u.jsxs)("tr",{children:[(0,u.jsx)("td",{children:(0,u.jsxs)("div",{className:"eytg-row-text",children:[(0,u.jsx)("strong",{children:t.title||t.videoId}),(0,u.jsx)("span",{children:t.channel})]})}),(0,u.jsx)("td",{children:(0,u.jsx)("span",{className:`eytg-badge ${n.tone}`,title:n.hint,children:n.text})}),(0,u.jsx)("td",{children:ae(t.updatedAt,!0)}),(0,u.jsx)("td",{children:(0,u.jsxs)("div",{className:"eytg-row-actions",children:[(0,u.jsx)("a",{className:"eytg-icon-btn",href:`https://www.youtube.com/watch?v=${encodeURIComponent(t.videoId)}`,target:"_blank",rel:"noopener noreferrer","aria-label":"Check on YouTube",title:"Check on YouTube",children:(0,u.jsx)(d.ExternalLink,{size:14})}),(0,u.jsxs)("button",{type:"button",className:"eytg-btn",disabled:null!==s,onClick:()=>y(t.videoId,()=>e.markAvailable(t.videoId)),children:[s===t.videoId?(0,u.jsx)(d.Loader2,{size:14,className:"eytg-spin"}):(0,u.jsx)(d.CheckCircle2,{size:14})," Mark available"]}),(0,u.jsx)("button",{type:"button",className:"eytg-icon-btn eytg-btn-danger",disabled:null!==s,onClick:()=>y(t.videoId,()=>e.remove(t.videoId)),"aria-label":"Remove from the library",title:"Remove from the library",children:(0,u.jsx)(d.Trash2,{size:14})})]})})]},t.videoId)})})]})})]})})},exports.VideoCard=he,exports.VideoEditDialog=Be,exports.VideoGrid=we,exports.VideoLibraryAdmin=function({client:e,customFields:t,pageSize:n=25,hideMaintenance:r=!1,onChange:i,className:a}){const[s,l]=(0,o.useState)(""),[c,p]=(0,o.useState)(""),[g,y]=(0,o.useState)(""),[h,b]=(0,o.useState)(""),[m,x]=(0,o.useState)(!1),[f,v]=(0,o.useState)("published"),[w,j]=(0,o.useState)("desc"),[k,N]=(0,o.useState)(1),[C,S]=(0,o.useState)([]),[z,T]=(0,o.useState)(0),[P,E]=(0,o.useState)(1),[I,R]=(0,o.useState)([]),[$,L]=(0,o.useState)([]),[M,A]=(0,o.useState)(!0),[D,q]=(0,o.useState)(null),[V,U]=(0,o.useState)(null),[O,F]=(0,o.useState)(null),[Y,W]=(0,o.useState)(null),[H,B]=(0,o.useState)(null),[X,_]=(0,o.useState)(0),[J,Q]=(0,o.useState)(null),K=t??$,Z=(0,o.useMemo)(()=>K.filter(e=>e.showInList),[K]);(0,o.useEffect)(()=>{const e=setTimeout(()=>{p(s),N(1)},250);return()=>clearTimeout(e)},[s]),(0,o.useEffect)(()=>{t||e.fields().then(L).catch(()=>L([]))},[e,t]),(0,o.useEffect)(()=>{e.categories().then(R).catch(()=>{})},[e,X]),(0,o.useEffect)(()=>{r||e.resyncStatus().then(e=>Q({configured:e.configured,quotaCost:e.quotaCost})).catch(()=>Q(null))},[e,r,X]),(0,o.useEffect)(()=>{let t=!1;return A(!0),e.list({q:c||null,category:g||null,availability:h||null,featured:m||null,includeHidden:!0,sort:f,dir:w,page:k,limit:n}).then(e=>{t||(S(e.videos),T(e.total),E(e.pageCount),e.page!==k&&N(e.page),U(null))}).catch(e=>!t&&U(e instanceof Error?e.message:String(e))).finally(()=>!t&&A(!1)),()=>{t=!0}},[e,c,g,h,m,f,w,k,n,X]);const G=(0,o.useCallback)(()=>{_(e=>e+1),i?.()},[i]),ee=async(e,t)=>{q(e),U(null),F(null);try{F(await t()),G()}catch(n){U(n instanceof Error?n.message:String(n))}finally{q(null)}},te=e=>{f===e?j("asc"===w?"desc":"asc"):(v(e),j("title"===e?"asc":"desc")),N(1)};return(0,u.jsx)(pe,{children:(0,u.jsxs)("div",{className:"eytg-root eytg-admin"+(a?` ${a}`:""),children:[(0,u.jsxs)("div",{className:"eytg-toolbar",children:[(0,u.jsxs)("label",{className:"eytg-grow",style:{position:"relative",display:"flex"},children:[(0,u.jsx)(d.Search,{size:14,style:{position:"absolute",left:10,top:9,color:"var(--eytg-muted)"},"aria-hidden":"true"}),(0,u.jsx)("input",{className:"eytg-input",style:{paddingLeft:30,width:"100%"},type:"search",placeholder:"Search title, channel, description, id…",value:s,onChange:e=>l(e.target.value),"aria-label":"Search the library"})]}),(0,u.jsxs)("select",{className:"eytg-select",value:g,onChange:e=>{y(e.target.value),N(1)},"aria-label":"Category",children:[(0,u.jsx)("option",{value:"",children:"All categories"}),I.map(e=>(0,u.jsx)("option",{value:e,children:e},e))]}),(0,u.jsxs)("select",{className:"eytg-select",value:h,onChange:e=>{b(e.target.value),N(1)},"aria-label":"Availability",children:[(0,u.jsx)("option",{value:"",children:"Any availability"}),Fe.map(e=>(0,u.jsx)("option",{value:e,children:_e[e].label},e))]}),(0,u.jsxs)("label",{className:"eytg-check",children:[(0,u.jsx)("input",{type:"checkbox",checked:m,onChange:e=>{x(e.target.checked),N(1)}}),"Top picks"]}),(0,u.jsxs)("button",{type:"button",className:"eytg-btn eytg-btn-primary",onClick:()=>W("new"),children:[(0,u.jsx)(d.Plus,{size:14})," Add video"]})]}),!r&&(0,u.jsxs)("div",{className:"eytg-toolbar",children:[(0,u.jsxs)("button",{type:"button",className:"eytg-btn",disabled:null!==D||!1===J?.configured,onClick:()=>ee("resync",async()=>{const t=await e.resync();return`Checked ${t.videosChecked} videos: ${t.viewCountsUpdated} view counts and ${t.availabilityChanged} availability changes updated.`}),title:!1===J?.configured?"Needs a YouTube Data API key on the server (youtubeApiKey)":"Refresh view counts and takedown status from the YouTube Data API"+(J?` (about ${J.quotaCost} quota units)`:""),children:["resync"===D?(0,u.jsx)(d.Loader2,{size:14,className:"eytg-spin"}):(0,u.jsx)(d.RefreshCw,{size:14})," Resync from YouTube"]}),(0,u.jsxs)("button",{type:"button",className:"eytg-btn",disabled:null!==D,onClick:()=>ee("stacks",async()=>{const{moved:t}=await e.recomputeStacks();return 0===t?"Stacks are up to date.":`Re-stacked ${t} video${1===t?"":"s"}.`}),title:"Rebuild stacked playlists from the links in descriptions",children:["stacks"===D?(0,u.jsx)(d.Loader2,{size:14,className:"eytg-spin"}):(0,u.jsx)(d.Layers,{size:14})," Recompute stacks"]}),(0,u.jsxs)("span",{style:{color:"var(--eytg-muted)",fontSize:12},children:[z," video",1===z?"":"s"]})]}),V&&(0,u.jsx)("div",{className:"eytg-banner eytg-banner-error",role:"alert",children:V}),O&&(0,u.jsx)("div",{className:"eytg-banner eytg-banner-ok",role:"status",children:O}),(0,u.jsx)("div",{className:"eytg-table-wrap",children:(0,u.jsxs)("table",{className:"eytg-table",children:[(0,u.jsxs)("colgroup",{children:[(0,u.jsx)("col",{style:{width:360}}),(0,u.jsx)("col",{style:{width:130}}),(0,u.jsx)("col",{style:{width:110}}),(0,u.jsx)("col",{style:{width:80}}),Z.map(e=>(0,u.jsx)("col",{style:{width:130}},e.key)),(0,u.jsx)("col",{style:{width:110}}),(0,u.jsx)("col",{style:{width:150}})]}),(0,u.jsx)("thead",{children:(0,u.jsxs)("tr",{children:[Je.slice(0,1).map(e=>(0,u.jsx)(Qe,{column:e,sort:f,dir:w,onSort:te},e.key)),(0,u.jsx)("th",{children:"Category"}),Je.slice(1).map(e=>(0,u.jsx)(Qe,{column:e,sort:f,dir:w,onSort:te},e.key)),Z.map(e=>(0,u.jsx)("th",{children:e.label},e.key)),(0,u.jsx)("th",{children:"Status"}),(0,u.jsx)("th",{"aria-label":"Actions"})]})}),(0,u.jsx)("tbody",{children:M&&0===C.length?(0,u.jsx)("tr",{children:(0,u.jsx)("td",{colSpan:6+Z.length,style:{textAlign:"center",padding:24},children:(0,u.jsx)(d.Loader2,{size:16,className:"eytg-spin"})})}):0===C.length?(0,u.jsx)("tr",{children:(0,u.jsx)("td",{colSpan:6+Z.length,style:{textAlign:"center",padding:24,color:"var(--eytg-muted)"},children:"No videos match."})}):C.map(t=>(0,u.jsxs)("tr",{style:{opacity:M?.6:t.hidden?.7:1},children:[(0,u.jsx)("td",{children:(0,u.jsxs)("div",{className:"eytg-row-title",children:[(0,u.jsx)("img",{className:"eytg-row-thumb",style:{width:72},src:ce(t.videoId),alt:"",loading:"lazy"}),(0,u.jsxs)("div",{className:"eytg-row-text",children:[(0,u.jsx)("strong",{title:t.title,children:t.title||t.videoId}),(0,u.jsxs)("span",{children:[t.channel," · ",(0,u.jsx)("code",{children:t.videoId})]})]})]})}),(0,u.jsx)("td",{children:t.category??""}),(0,u.jsx)("td",{children:ae(t.publishedAt,!0)}),(0,u.jsx)("td",{className:"eytg-num",children:ie(t.viewCount)}),Z.map(e=>(0,u.jsx)("td",{children:se(e,t.custom?.[e.key])},e.key)),(0,u.jsx)("td",{children:(0,u.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:[(0,u.jsx)("span",{className:`eytg-badge ${_e[t.availability].tone}`,children:_e[t.availability].label}),t.hidden&&(0,u.jsx)("span",{className:"eytg-badge",children:"Hidden"}),t.stackKey&&(0,u.jsxs)("span",{className:"eytg-badge",title:`Stack ${t.stackKey}`,children:["Stack ",t.stackPosition+1]})]})}),(0,u.jsx)("td",{children:(0,u.jsxs)("div",{className:"eytg-row-actions",children:[(0,u.jsx)("button",{type:"button",className:"eytg-icon-btn"+(t.featured?" eytg-on":""),onClick:()=>((t,n)=>ee(`${n}-${t.videoId}`,async()=>(await e.update(t.videoId,{[n]:!t[n]}),`${t.title}: ${"featured"===n?t.featured?"no longer a top pick":"marked as a top pick":t.hidden?"visible again":"hidden"}.`)))(t,"featured"),disabled:null!==D,"aria-pressed":t.featured,"aria-label":t.featured?"Unmark top pick":"Mark as top pick",title:t.featured?"Unmark top pick":"Mark as top pick",children:(0,u.jsx)(d.Star,{size:14,fill:t.featured?"currentColor":"none"})}),(0,u.jsx)("button",{type:"button",className:"eytg-icon-btn",onClick:()=>W(t),"aria-label":"Edit",title:"Edit",children:(0,u.jsx)(d.Pencil,{size:14})}),(0,u.jsx)("button",{type:"button",className:"eytg-icon-btn eytg-btn-danger",onClick:()=>B(t),"aria-label":"Remove",title:"Remove from the library",children:(0,u.jsx)(d.Trash2,{size:14})})]})})]},t.videoId))})]})}),(0,u.jsxs)("div",{className:"eytg-pager",children:[(0,u.jsxs)("span",{children:["Page ",k," of ",P]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("button",{type:"button",className:"eytg-btn",disabled:k<=1||M,onClick:()=>N(k-1),children:"Previous"}),(0,u.jsx)("button",{type:"button",className:"eytg-btn",disabled:k>=P||M,onClick:()=>N(k+1),children:"Next"})]})]}),Y&&(0,u.jsx)(Be,{client:e,video:"new"===Y?null:Y,customFields:K,categories:I,onClose:()=>W(null),onSaved:e=>{W(null),F(`Saved “${e.title}”.`),G()}}),H&&(0,u.jsx)("div",{className:"eytg-overlay",role:"presentation",onClick:()=>B(null),children:(0,u.jsxs)("div",{className:"eytg-dialog eytg-dialog-sm",role:"alertdialog","aria-modal":"true",onClick:e=>e.stopPropagation(),children:[(0,u.jsx)("header",{children:(0,u.jsx)("h2",{children:"Remove this video?"})}),(0,u.jsx)("div",{className:"eytg-dialog-body",children:(0,u.jsxs)("p",{style:{margin:0},children:[(0,u.jsx)("strong",{children:H.title})," will be deleted from the library and excluded from future imports. To show it less prominently instead, hide it."]})}),(0,u.jsxs)("footer",{children:[(0,u.jsx)("button",{type:"button",className:"eytg-btn",onClick:()=>B(null),children:"Cancel"}),(0,u.jsx)("button",{type:"button",className:"eytg-btn eytg-btn-primary",style:{background:"var(--eytg-danger)",borderColor:"var(--eytg-danger)"},onClick:()=>{const t=H;B(null),ee(`delete-${t.videoId}`,async()=>(await e.remove(t.videoId),`Removed “${t.title}”.`))},children:"Remove"})]})]})})]})})},exports.VideoList=Oe,exports.YouTubeTranscriptModal=w,exports.buildEmbedUrl=L,exports.defaultStackLabel=me,exports.describePlayerError=$,exports.formatCustomCell=se,exports.formatCustomValue=oe,exports.formatTime=function(e){const t=Math.max(0,Math.floor(e)),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60,a=n>0?r.toString().padStart(2,"0"):r.toString(),o=i.toString().padStart(2,"0");return n>0?`${n}:${a}:${o}`:`${a}:${o}`},exports.formatVideoDate=ae,exports.formatViewCount=ie,exports.getPlayerState=H,exports.groupByCategory=Ne,exports.groupByChannel=ke,exports.groupByCustomField=function(e,t={}){return n=>{const r=n.custom?.[e],i=null==r?"":String(r).trim();return i?{kind:e,label:i,sortValue:i.toLowerCase()}:t.skipEmpty?null:{kind:e,label:"Unsorted",sortValue:"",trailing:!0}}},exports.groupByYear=je,exports.groupIntoSentences=f,exports.loadTranscript=y,exports.sendPlayerCommand=Q,exports.thumbnailFor=ce,exports.thumbnailUrl=function(e,t="hq"){return`https://img.youtube.com/vi/${e}/${"default"===t?"default":`${t}default`}.jpg`},exports.toPlayerVideo=le,exports.usePlayerSelector=X,exports.usePlayerState=B,exports.useResizableColumns=Ae,exports.useTranscript=b,exports.useVideoLibrary=function(e,t={}){const[n,r]=(0,o.useState)(null),[i,a]=(0,o.useState)({}),[s,l]=(0,o.useState)(!0),[c,d]=(0,o.useState)(null),[u,p]=(0,o.useState)(0),g=(0,o.useRef)({}),y=JSON.stringify(t);(0,o.useEffect)(()=>{let t=!1;return l(!0),d(null),(async()=>{try{const n=await e.list(JSON.parse(y));if(t)return;r(n);const i=function(e){const t=[],n=new Set;for(const r of e){const e=fe(r);e&&!n.has(e)&&(n.add(e),t.push(e))}return t}(n.videos).filter(e=>!g.current[e]);if(i.length>0){const n=await e.stacks(i);if(t)return;g.current={...g.current,...n}}a(g.current)}catch(n){t||d(n instanceof Error?n.message:String(n))}finally{t||l(!1)}})(),()=>{t=!0}},[e,y,u]);const h=(0,o.useCallback)(()=>{g.current={},p(e=>e+1)},[]);return{page:n,videos:n?.videos??[],stacks:i,loading:s,error:c,reload:h}},exports.watchUrl=M,exports.youtubePlayer=G;
2
2
  //# sourceMappingURL=index.cjs.map