1import{_ as Yt}from"./XfmX3Fr0.js";import{G as We,g as qe,y as Oe,A as Ue,o as i,c as u,a as e,k as P,d as V,q as g,s as Wt,h as on,n as I,C as st,F as se,r as Ie,t as _,j as J,p as D,_ as rt,z as rn,a3 as un,B as Ve,as as dn,b as de,w as Ye,i as Vt,v as Pt,P as qt,m as Et,H as cn,J as vn,u as pn,S as hn,l as fn,x as gn,V as bn}from"./tzJnjie6.js";import{f as It,u as Gt}from"./BYmdwHF_.js";import{s as ot}from"./BAnZql-Z.js";import{_ as Xt}from"./BvDAbtkt.js";import{u as Jt}from"./BOyzDctL.js";import{_ as mn,a as xn,b as kn}from"./DCol-M9h.js";const yn={class:"relative w-full bg-black rounded-xl overflow-hidden shadow-lg",style:{"aspect-ratio":"16/9"}},wn={key:0,class:"absolute inset-0 grid place-items-center bg-black/80 pointer-events-none"},Cn={key:1,class:"absolute inset-0 grid place-items-center bg-black/85 text-center px-6"},Sn=We({__name:"YoutubePlayer",props:{videoId:{},ctrl:{},startAt:{}},setup(l){const S=l,b=g(null),a=g(!1);async function o(s){if(!b.value||!S.videoId)return;a.value=!1,b.value.innerHTML="";const c=document.createElement("div");b.value.appendChild(c);try{await S.ctrl.mount(c,S.videoId,s)}catch{a.value=!0}}let f=!1;function h(){if(typeof document<"u"&&document.hidden){f=!0;return}const s=f?S.ctrl?.currentTime?.value||0:S.startAt||0;f=!1,Wt(()=>o(s))}function m(){!document.hidden&&f&&h()}return qe(()=>{h(),document.addEventListener("visibilitychange",m)}),Oe(()=>document.removeEventListener("visibilitychange",m)),Ue(()=>S.videoId,()=>h()),(s,c)=>(i(),u("div",yn,[e("div",{ref_key:"host",ref:b,class:"absolute inset-0 [&>div]:w-full [&>div]:h-full [&_iframe]:w-full [&_iframe]:h-full"},null,512),!l.ctrl.ready.value&&!a.value?(i(),u("div",wn,[...c[0]||(c[0]=[e("div",{class:"flex flex-col items-center gap-3 text-white/70"},[e("div",{class:"w-9 h-9 border-[3px] border-white/25 border-t-white rounded-full animate-spin"}),e("span",{class:"text-sm"},"Äang tải videoâ¦")],-1)])])):P("",!0),a.value?(i(),u("div",Cn,[...c[1]||(c[1]=[e("div",{class:"text-white/80 text-sm"},[V(" Không tải ÄÆ°á»£c trình phát YouTube."),e("br"),e("span",{class:"text-white/50"},"Kiá»m tra kết ná»i mạng hoặc trình chặn quảng cáo rá»i tải lại trang.")],-1)])])):P("",!0)]))}}),Lt="line",mt={desktop:{enSize:23,enColor:null,enBold:!0,enItalic:!1,viSize:18,viColor:null,viBold:!0,viItalic:!0,bgColor:null,bgOpacity:100},mobile:{enSize:23,enColor:null,enBold:!0,enItalic:!1,viSize:18,viColor:null,viBold:!0,viItalic:!0,bgColor:null,bgOpacity:100}},_n=639,xt={en:"#0f172a",vi:"#1e40af",bg:"#eff6ff"},yt={min:12,max:48};function Nt(l,S){const b=S==="en"?l.enSize:l.viSize,a=S==="en"?l.enColor:l.viColor,o=S==="en"?l.enBold:l.viBold,f=S==="en"?l.enItalic:l.viItalic;return{fontSize:`${b}px`,fontWeight:o?S==="en"?600:500:400,fontStyle:f?"italic":"normal",...a?{color:a}:{}}}function $n(l){if(!l.bgColor&&l.bgOpacity===100)return;const S=l.bgColor||xt.bg,b=parseInt(S.slice(1),16),[a,o,f]=[b>>16&255,b>>8&255,b&255];return`rgba(${a}, ${o}, ${f}, ${Math.round(l.bgOpacity)/100})`}function Ot(l,S){const b={...mt[S]};if(!l||typeof l!="object")return b;for(const a of["enSize","viSize"])typeof l[a]=="number"&&(b[a]=Math.min(yt.max,Math.max(yt.min,l[a])));typeof l.bgOpacity=="number"&&(b.bgOpacity=Math.min(100,Math.max(0,l.bgOpacity)));for(const a of["enBold","enItalic","viBold","viItalic"])typeof l[a]=="boolean"&&(b[a]=l[a]);for(const a of["enColor","viColor","bgColor"])(l[a]===null||/^#[0-9a-f]{6}$/i.test(l[a]))&&(b[a]=l[a]);return b}const Mn={key:0,class:"fixed inset-x-3 bottom-[64px] z-50 sm:absolute sm:inset-auto sm:bottom-full sm:left-0 sm:mb-2 sm:z-30 sm:w-[308px] rounded-xl border-2 border-blue-500 dark:border-blue-400/60 bg-white dark:bg-slate-900 shadow-xl p-4"},Tn={class:"grid grid-cols-2 gap-1.5 mb-1.5"},Bn=["title","onClick"],En={class:"text-[11px] leading-snug text-slate-500 dark:text-slate-400 bg-slate-50 dark:bg-slate-800/60 rounded-lg px-2.5 py-2 mb-4"},In={class:"sh-group"},Ln={class:"flex items-center gap-2.5 mb-2.5"},An=["min","max","value","onInput"],Vn={class:"text-xs font-semibold tabular-nums text-slate-600 dark:text-slate-300 w-6 text-right"},Pn={class:"flex items-center gap-2.5 mb-4"},Rn=["value","onInput"],zn=["onClick"],Dn=["onClick"],Un={class:"flex items-center gap-2.5 mb-2.5"},Nn=["value"],On={class:"flex items-center gap-2.5 mb-4"},jn=["value"],Kn={class:"text-xs font-semibold tabular-nums text-slate-600 dar
1k:text-slate-300 w-9 text-right"},Hn={class:"flex items-center gap-2 mt-1"},Fn=["disabled","title"],Yn=We({__name:"SubtitleSettings",props:{modelValue:{},defaults:{},mode:{}},emits:["update:modelValue","update:mode"],setup(l,{emit:S}){const b=l,a=S,o=[{k:"line",label:"Theo dòng",hint:"Mặc Äá»nh. Hiá»n Äúng từng dòng phụ Äá» cá»§a video theo YouTube hiá»n thá» (ngắn nhưng khó hiá»u nghÄ©a)."},{k:"sentence",label:"Câu trá»n vẹn",hint:"Hiá»n thá» thà nh câu trá»n vẹn tuy dà i nhưng Äá»c dá»
hiá»u nghÄ©a hÆ¡n. Nên chá»n khi xem Äá» hiá»u ná»i dung video."}],f=g(!1),h=g(null);function m($,M){a("update:modelValue",{...b.modelValue,[$]:M})}function s(){a("update:modelValue",{...b.defaults}),a("update:mode",Lt)}const c=D(()=>b.modelValue.enColor||xt.en),y=D(()=>b.modelValue.viColor||xt.vi),d=D(()=>b.modelValue.bgColor||xt.bg),C=D(()=>b.mode===Lt&&Object.keys(b.defaults).every($=>b.modelValue[$]===b.defaults[$])),B=$=>{f.value&&h.value&&!h.value.contains($.target)&&(f.value=!1)};return qe(()=>document.addEventListener("click",B)),on(()=>document.removeEventListener("click",B)),($,M)=>(i(),u("div",{ref_key:"root",ref:h,class:"relative"},[e("button",{class:I(["sh-gear",{"sh-gear-on":f.value}]),title:"Cà i Äặt phụ Äá» hiá»n thá» dưá»i video","aria-label":"Cà i Äặt phụ Äá» hiá»n thá» dưá»i video",onClick:M[0]||(M[0]=k=>f.value=!f.value)},[...M[4]||(M[4]=[e("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e("circle",{cx:"12",cy:"12",r:"3"}),e("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.6a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9v.09a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})],-1)])],2),f.value?(i(),u("div",Mn,[M[11]||(M[11]=st('<p class="flex items-center gap-1.5 text-sm font-bold text-slate-800 dark:text-slate-100 pb-2.5 mb-3 border-b border-slate-100 dark:border-slate-800" data-v-754e093a><svg class="w-4 h-4 text-blue-500" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" data-v-754e093a><rect x="2" y="5" width="20" height="14" rx="2" data-v-754e093a></rect><path d="M6 14h4M13 14h5" stroke-linecap="round" data-v-754e093a></path></svg> Cà i Äặt phụ Äá» </p><p class="sh-group" data-v-754e093a>Kiá»u hiá»n thá»</p>',2)),e("div",Tn,[(i(),u(se,null,Ie(o,k=>e("button",{key:k.k,class:I(["sh-mode",{"sh-mode-on":l.mode===k.k}]),title:k.hint,onClick:q=>a("update:mode",k.k)},_(k.label),11,Bn)),64))]),e("p",En,_(o.find(k=>k.k===l.mode)?.hint),1),(i(),u(se,null,Ie([{key:"en",title:"Phụ Äá» gá»c",size:"enSize",color:"enColor",bold:"enBold",italic:"enItalic"},{key:"vi",title:"Bản dá»ch",size:"viSize",color:"viColor",bold:"viBold",italic:"viItalic"}],k=>(i(),u(se,{key:k.key},[e("p",In,_(k.title),1),e("div",Ln,[M[5]||(M[5]=e("label",{class:"text-xs text-slate-500 w-11 shrink-0"},"Cỡ chữ",-1)),e("input",{type:"range",min:J(yt).min,max:J(yt).max,value:l.modelValue[k.size],class:"sh-slider flex-1",onInput:q=>m(k.size,Number(q.target.value))},null,40,An),e("span",Vn,_(l.modelValue[k.size]),1)]),e("div",Pn,[M[6]||(M[6]=e("label",{class:"text-xs text-slate-500 w-11 shrink-0"},"Mà u",-1)),e("input",{type:"color",value:k.key==="en"?c.value:y.value,class:"sh-color",title:"Chá»n mà u chữ",onInput:q=>m(k.color,q.target.value)},null,40,Rn),e("button",{class:I(["sh-style font-bold",{"sh-style-on":l.modelValue[k.bold]}]),title:"Chữ Äáºm",onClick:q=>m(k.bold,!l.modelValue[k.bold])},"B",10,zn),e("button",{class:I(["sh-style italic font-serif",{"sh-style-on":l.modelValue[k.italic]}]),title:"Chữ nghiêng",onClick:q=>m(k.italic,!l.modelValue[k.italic])},"I",10,Dn)])],64))),64)),M[12]||(M[12]=e("p",{class:"sh-group"},"à thẻ phụ Äá»",-1)),e("div",Un,[M[7]||(M[7]=e("label",{class:"text-xs text-slate-500
1w-11 shrink-0"},"Mà u ná»n",-1)),e("input",{type:"color",value:d.value,class:"sh-color",title:"Mà u ná»n cá»§a ô thẻ hiá»n thá» phụ Äá» dưá»i video",onInput:M[1]||(M[1]=k=>m("bgColor",k.target.value))},null,40,Nn),M[8]||(M[8]=e("span",{class:"text-[11px] leading-snug text-slate-400"}," Ná»n cá»§a ô thẻ phụ Äá» dưá»i video ",-1))]),e("div",On,[M[9]||(M[9]=e("label",{class:"text-xs text-slate-500 w-11 shrink-0"},"Äá» Äáºm",-1)),e("input",{type:"range",min:"0",max:"100",step:"5",value:l.modelValue.bgOpacity,class:"sh-slider flex-1",title:"Kéo xuá»ng cho ná»n nhạt/trong dần",onInput:M[2]||(M[2]=k=>m("bgOpacity",Number(k.target.value)))},null,40,jn),e("span",Kn,_(l.modelValue.bgOpacity)+"% ",1)]),e("div",Hn,[e("button",{class:I(["flex-1 inline-flex items-center justify-center gap-1.5 h-9 rounded-lg border text-[13px] font-bold transition-colors",C.value?"border-slate-200 dark:border-slate-700 text-slate-400 cursor-default":"border-amber-300 bg-amber-50 text-amber-700 hover:bg-amber-100 dark:bg-amber-500/15 dark:border-amber-500/40 dark:text-amber-300"]),disabled:C.value,title:C.value?"Äang á» thiết láºp mặc Äá»nh":"Trả cỡ chữ, mà u, Äáºm/nghiêng vá» như ban Äầu",onClick:s},[...M[10]||(M[10]=[e("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"},[e("path",{d:"M3 12a9 9 0 1 0 3-6.7"}),e("path",{d:"M3 4v5h5"})],-1),V(" Äặt lại mặc Äá»nh ",-1)])],10,Fn),e("button",{class:"shrink-0 h-9 px-4 rounded-lg bg-blue-600 text-white text-[13px] font-bold hover:bg-blue-700 transition-colors",title:"Lưu và Äóng bảng cà i Äặt",onClick:M[3]||(M[3]=k=>f.value=!1)},"Lưu")])])):P("",!0)],512))}}),Wn=rt(Yn,[["__scopeId","data-v-754e093a"]]);let gt=null;function qn(){return typeof window>"u"?Promise.reject(new Error("SSR")):window.YT?.Player?Promise.resolve(window.YT):gt||(gt=new Promise((l,S)=>{const b=window.onYouTubeIframeAPIReady;window.onYouTubeIframeAPIReady=()=>{b?.(),l(window.YT)};const a=document.createElement("script");a.src="https://www.youtube.com/iframe_api",a.async=!0,a.onerror=()=>S(new Error("Không tải ÄÆ°á»£c YouTube IFrame API")),document.head.appendChild(a)}),gt)}const at=[.5,.75,1,1.25,1.5,2];function Ct(){if(typeof navigator>"u")return!1;const l=navigator.userAgent||"";return/Android|iPhone|iPad|iPod|Mobile/i.test(l)?!0:/Macintosh/.test(l)&&(navigator.maxTouchPoints||0)>1}function Gn(){if(typeof navigator>"u")return!1;const l=navigator.userAgent||"";return/iPhone|iPad|iPod/i.test(l)||/Macintosh/.test(l)&&(navigator.maxTouchPoints||0)>1}function Xn(){const a=new ArrayBuffer(80044),o=new DataView(a),f=(h,m)=>{for(let s=0;s<m.length;s++)o.setUint8(h+s,m.charCodeAt(s))};f(0,"RIFF"),o.setUint32(4,80036,!0),f(8,"WAVE"),f(12,"fmt "),o.setUint32(16,16,!0),o.setUint16(20,1,!0),o.setUint16(22,1,!0),o.setUint32(24,8e3,!0),o.setUint32(28,8e3*2,!0),o.setUint16(32,2,!0),o.setUint16(34,16,!0),f(36,"data"),o.setUint32(40,8e4,!0);for(let h=0;h<4e4;h++)o.setInt16(44+h*2,Math.round(8*Math.sin(2*Math.PI*30*h/8e3)),!0);return URL.createObjectURL(new Blob([a],{type:"audio/wav"}))}let we=null,Ne="",wt=!1,St=!1,jt=0;function Zt(){return typeof window>"u"?null:(we||(Ne=Xn(),we=new Audio(Ne),we.loop=!0,we.volume=1,we.preload="auto",we.setAttribute("playsinline",""),we.addEventListener("pause",()=>{if(!St)return;const l=Date.now();l-jt<1e3||(jt=l,we?.play().catch(()=>{}))})),we)}function bt(){Ct()&&(St=!0,Zt()?.play().then(()=>{wt=!0}).catch(()=>{}))}function kt(){St=!1;try{we?.pause()}catch{}}function Jn(){kt(),Ne&&(URL.revokeObjectURL(Ne),Ne=""),we=null,wt=!1}let z=null;function At(){return typeof window>"u"?null:(z||(z=new Audio,z.preload="auto",z.setAttribute("playsinline","")),z)}function Zn(){try{z?.pause()}catch{}if(z){z.removeAttribute("src");try{z.load()}catch{}}z=null}function Qn(){if(typeof window>"u"||!Ct())return()=>{};const l=()=>{if(wt)return b();const a=Zt();a?.play().then(()=>{wt=!0,St||a.pause(),b()}).catch(()=>{});const o=At();if(o&&o.paused){!o.getAttribute("src")&&Ne&&(o.src=Ne),o.muted=!0;try{o.volume=0}catch{}o.play().then(()=>{o.pause(),o.currentTime=0}).catch(()=>{})}},S={passive:!0},b=()=>{window.removeEventListener("pointerdown",l),window.removeEventListener("touchstart",l),window.removeEventListener("keydown",l)};return window.addEventListener("pointerdown",l,S),window.addEventListener("touchstart",l,S),window.addEventListener("keydown",l,S),b}function Kt(){return Ct()}function el(l,S){let b="";try{b=String(rn().public.apiBase||"")}catch{}const a=un(null),o=g(!1),f=g(!1),h=g(!1),m=g(0),s=g(0),c=g(1),y=g(100),d=g(!1),C=g(!1),B=g(!1),$=g(null),M=()=>.05+.04*(c.value||1),k=g(-1),q=g(null),U=g(!1);let N=0,Z=null;const T=g(!1),W=g(!1);let ae="",ce="",ve=!1,oe="",re="",pe=!1,H=null,ie=!1,Q=0;const ee=()=>typeof navigator>"u"?null:navigator.mediaSession||null;function be(n){const v=ee();if(v)try{v.playbackState=n}catch{}}function L(n){const v=ee(),x=typeof window>"u"?null:window.MediaMetadata;if(!(!v||!x))try{v.metadata=new x({title:n.title||"Shadowing",artist:n.artist||"Từ Äiá»n AV",artwork:n.artwork?[{src:n.artwork,sizes:"480x360",type:"image/jpeg"}]:[]})}catch{}}let Le=0;function Pe(n){const v=ee();if(!v?.setPositionState||!s.value)return;const x=Date.now();if(!(x-Le<1e3)){Le=x;try{v.setPositionState({duration:s.value,playbackRate:c.value||1,position:Math.max(0,Math.min(n,s.value))})}catch{}}}let te=null,Te=null;function ue(n,v){te=n,Te=v,Ce()}function Ce(){const n=ee();if(!n?.setActionHandler)return;const v=(x,R)=>
1{try{n.setActionHandler(x,R)}catch{}};v("play",()=>nt()),v("pause",()=>O()),v("previoustrack",te?()=>te?.():()=>zt()),v("nexttrack",Te?()=>Te?.():()=>Rt()),v("seekbackward",x=>Fe(Math.max(0,m.value-(x?.seekOffset||5)))),v("seekforward",x=>Fe(m.value+(x?.seekOffset||5))),v("seekto",x=>{typeof x?.seekTime=="number"&&Fe(x.seekTime)}),v("stop",()=>O())}function he(){const n=ee();if(n?.setActionHandler){for(const v of["play","pause","previoustrack","nexttrack","seekbackward","seekforward","seekto","stop"])try{n.setActionHandler(v,null)}catch{}be("none")}}function F(n){U.value=n,n?(bt(),Ke(),w()&&!T.value&&Re()):(Be(),it()),be(n?"playing":"paused")}function w(){return typeof document<"u"&&document.hidden}function p(n,v){const x=At();if(!x)return;if(oe=v?.url?n:"",ae=v?.url||"",ce=v?.proxy_url?me(v.proxy_url):"",ve=!1,W.value=!!ae,!ae){try{x.pause()}catch{}return}const R=T.value;x.src=ae;try{x.playbackRate=je()}catch{}if(!R)try{x.load()}catch{}if(fe(),R){m.value=0,xe(),Je();return}U.value&&Ke()}function me(n){return/^https?:/i.test(n)?n:`${b.replace(/\/$/,"")}${n}`}const G=Gn();function E(){return d.value?0:Math.min(1,Math.max(0,y.value/100))}function ne(){return G||T.value}let Y=0;function xe(){Y=0;const n=()=>{const v=z;!v||!U.value||(bt(),v.play().catch(()=>{Y++<3&&setTimeout(n,400*(Y+1))}))};n()}function fe(){const n=z;if(!n)return;const v=ne()&&!d.value;n.muted=!v;try{n.volume=v?E():0}catch{}}function ge(){const n=a.value;if(!n)return;const v=d.value||T.value||G&&K;try{v?n.mute?.():n.unMute?.()}catch{}}function je(){try{const n=a.value?.getPlaybackRate?.();if(typeof n=="number"&&n>0)return n}catch{}return c.value||1}let K=!1,Ge=0;function Ke(){const n=z;if(!(!n||T.value||!W.value)&&!(!oe||oe!==re)&&!(K&&!n.paused)){fe();try{n.playbackRate=je()}catch{}_e(m.value,0),n.play().then(()=>{K=!0,ge()}).catch(()=>{K=!1}),Je()}}function it(){if(!T.value){K=!1,clearTimeout(Se);try{z?.pause()}catch{}}}function Xe(){const n=z;if(!n||ve||!ce)return!1;ve=!0,K=!1;const v=m.value;n.src=ce;try{n.load()}catch{}return T.value?(_e(v,0),fe(),n.play().catch(()=>{})):U.value&&Ke(),!0}const ut=4e3;let Se=null;function Je(){clearTimeout(Se);const n=z;if(!n)return;const v=n.currentTime||0;Se=setTimeout(()=>{const x=z;if(!x||!U.value)return;const R=(x.currentTime||0)-v;!x.paused&&R>.05||Xe()||(K=!1)},ut)}function _e(n,v=.35){const x=z;if(x){if(x.readyState===0){x.addEventListener("loadedmetadata",()=>{try{x.currentTime=n}catch{}},{once:!0});return}if(Math.abs((x.currentTime||0)-n)>v)try{x.currentTime=n}catch{}}}function dt(){const n=z;if(!n||!W.value||T.value||!U.value||!oe||oe!==re)return!1;const v=K&&!n.paused;T.value=!0,Be();try{n.playbackRate=je()}catch{}G||_e(m.value,v?1:0),fe(),ge();try{a.value?.pauseVideo?.()}catch{}return v||n.play().catch(()=>{T.value=!1,K=!1,ge();try{a.value?.playVideo?.()}catch{}Re()}),!0}function _t(){if(!T.value)return;const n=z,v=n&&Number.isFinite(n.currentTime)?n.currentTime:m.value;if(T.value=!1,m.value=v,n&&(fe(),U.value?n.play().then(()=>{K=!0}).catch(()=>{K=!1}):it()),oe&&re&&oe!==re){pe=U.value;return}const x=a.value;try{x?.seekTo?.(v,!0),ge(),U.value&&x?.playVideo?.()}catch{}}function ct(){const n=At();n&&(n.addEventListener("play",()=>{T.value&&(f.value=!0)}),n.addEventListener("pause",()=>{T.value&&(f.value=!1)}),n.addEventListener("ended",()=>{T.value&&(h.value=!0,F(!1),kt())}),n.addEventListener("error",()=>{if(W.value&&!Xe()&&(W.value=!1,K=!1,clearTimeout(Se),ge(),T.value)){T.value=!1,ge();try{a.value?.playVideo?.()}catch{}Re()}}),n.addEventListener("stalled",()=>Je()))}const Ze=700,$t=40;function Re(){Z||!Ct()||(Z=ot(()=>{if(!U.value||!w())return Be();bt();let n=-1;try{n=a.value?.getPlayerState?.()??-1}catch{}if(!(n===1||n===3)){if(n===0||N++>=$t)return Be();try{a.value?.playVideo?.()}catch{}}},Ze))}function Be(){Z&&(clearInterval(Z),Z=null)}function Mt(){if(!T.value){if(U.value&&w()){Re();return}F(!1)}}let Ae=!1;function ke(){if(w()){if(Ae=!0,H&&He(),!U.value)return;bt(),dt()||Re();return}if(Ae&&(Ae=!1,_t(),Be(),N=0,H&&He(),U.value&&!f.value))try{a.value?.playVideo?.()}catch{}}const $e=D(()=>k.value>=0?l.value[k.value]??null:null);function ze(n){const v=l.value;if(!v.length)return-1;let x=k.value>=0?k.value:0;if(v[x]&&n>=v[x].start&&n<v[x].end)return x;for(let X=x;X<Math.min(v.length,x+4);X++)if(n>=v[X].start&&n<v[X].end)return X;let R=0,j=v.length-1,Me=-1;for(;R<=j;){const X=R+j>>1;
1if(n<v[X].start)j=X-1;else if(n>=v[X].end)R=X+1;else{Me=X;break}}if(Me>=0)return Me;for(let X=v.length-1;X>=0;X--)if(n>=v[X].start)return X;return-1}function ye(){return T.value||G&&K&&z&&!z.paused?z:null}const vt=.6,pt=2e3;let De=0;function t(n){const v=a.value;if(!v?.getCurrentTime||!v.seekTo)return;const x=Date.now();if(x-De<pt)return;let R=0;try{R=v.getCurrentTime()||0}catch{return}if(!(Math.abs(R-n)<=vt)){De=x;try{v.seekTo(n,!0)}catch{}}}function r(){const n=ye();if(n)try{n.pause()}catch{}if(!n||G&&!T.value)try{a.value?.pauseVideo?.()}catch{}}function A(){const n=a.value,v=ye();if(!v&&!n?.getCurrentTime)return;const x=v?v.currentTime||0:n.getCurrentTime()||0;if(m.value=x,!s.value&&n?.getDuration&&(s.value=n.getDuration()||0),Pe(x),!v&&K&&Date.now()-Ge>=1e3&&(Ge=Date.now(),_e(x)),G&&v&&!w()&&f.value&&t(x),$.value!==null){const X=$.value-M();if(!ie&&(x<X||Date.now()>Q)&&(ie=!0),ie&&x>=X){$.value=null,ie=!1,F(!1),r();return}}const j=S?.value||($e.value?{start:$e.value.start,end:$e.value.end}:null);if(j&&x>=j.end-M()){if(C.value){Fe(j.start);return}if(B.value&&f.value){F(!1),r();return}}const Me=ze(x);if(q.value!==null)if(Me!==q.value)q.value=null;else return;Me!==k.value&&(k.value=Me)}const Ee=50,le=250;let Qe=0;function He(n=w()?le:Ee){H&&Qe===n||(ht(),Qe=n,H=ot(A,n))}function ht(){H&&(clearInterval(H),H=null),Qe=0}async function Tt(n,v,x=0){const R=await qn();et(),re=v,a.value=new R.Player(n,{videoId:v,playerVars:{autoplay:0,rel:0,modestbranding:1,playsinline:1,cc_load_policy:0,iv_load_policy:3,start:Math.floor(x)},events:{onReady:j=>{o.value=!0,s.value=j.target.getDuration()||0,y.value=j.target.getVolume?.()??100,x>0&&j.target.seekTo(x,!0),ge();try{j.target.setPlaybackRate?.(c.value||1)}catch{}if(pe){pe=!1,F(!0);try{j.target.playVideo?.()}catch{}}He()},onPlaybackRateChange:j=>{const Me=Number(j?.data)||1;c.value=Me,z&&(z.playbackRate=Me)},onStateChange:j=>{f.value=j.data===R.PlayerState.PLAYING,h.value=j.data===R.PlayerState.ENDED,j.data===R.PlayerState.PLAYING?(He(),F(!0)):j.data===R.PlayerState.PAUSED?Mt():j.data===R.PlayerState.ENDED&&(F(!1),kt())}}})}function et(){if(ht(),Be(),N=0,T.value&&U.value&&w()){try{a.value?.destroy?.()}catch{}a.value=null,o.value=!1,s.value=0,k.value=-1;return}U.value=!1,kt(),T.value=!1,K=!1,ge(),clearTimeout(Se);try{z?.pause()}catch{}try{a.value?.destroy?.()}catch{}a.value=null,o.value=!1,f.value=!1,m.value=0,s.value=0,k.value=-1}const tt=()=>T.value,nt=()=>{Bt(),F(!0);const n=ye();if(n&&n.play().catch(()=>{}),!tt()&&!(!n&&w()&&dt()))try{a.value?.playVideo?.()}catch{}},O=()=>{F(!1),r()},en=()=>f.value?O():nt();function Fe(n,v=!0){Bt();const x=Math.max(0,n),R=ye();if(m.value=x,k.value=ze(x),R){try{R.currentTime=x}catch{}if(v&&(F(!0),R.play().catch(()=>{})),tt())return}const j=a.value;j?.seekTo&&(j.seekTo(x,!0),De=Date.now(),v&&(F(!0),j.playVideo()),R||A())}function tn(n,v){if(!ye()&&!a.value?.seekTo)return;$.value=v,ie=!1,Q=Date.now()+800,m.value=n;const x=ye();if(x){try{x.currentTime=Math.max(0,n)}catch{}if(F(!0),x.play().catch(()=>{}),tt())return}const R=a.value;if(R?.seekTo){R.seekTo(Math.max(0,n),!0),De=Date.now(),F(!0);try{R.playVideo?.()}catch{}}}function Bt(){$.value=null,ie=!1}function lt(n,v=!0){const x=l.value[n];x&&(q.value=n,k.value=n,Fe(x.start+.02,v))}const Rt=()=>{const n=k.value;n+1<l.value.length&<(n+1)},zt=()=>{const n=k.value;n>0?lt(n-1):n===0&<(0)},nn=()=>{k.value>=0&<(k.value)};function Dt(n){c.value=n,a.value?.setPlaybackRate?.(n),z&&(z.playbackRate=n)}function ln(n=1){const v=at.indexOf(c.value),x=at[(v+n+at.length)%at.length];Dt(x)}function an(n){y.value=n,a.value?.setVolume?.(n),n>0&&d.value&&(d.value=!1),fe(),ge()}function sn(){d.value=!d.value,fe(),ge()}let Ut=()=>{};const ft=()=>{U.value&&Ke()};return qe(()=>{Ut=Qn(),ct(),Ce(),window.addEventListener("pointerdown",ft,{passive:!0}),window.addEventListener("touchstart",ft,{passive:!0}),document.addEventListener("visibilitychange",ke),window.addEventListener("blur",ke),window.addEventListener("pagehide",ke)}),Oe(()=>{et(),Ut(),he(),Zn(),Jn(),typeof document<"u"&&(document.removeEventListener("visibilitychange",ke),window.removeEventListener("blur",ke),window.removeEventListener("pagehide",ke),window.removeEventListener("pointerdown",ft),window.removeEventListener("touchstart",ft))}
1),{player:a,ready:o,playing:f,ended:h,currentTime:m,duration:s,rate:c,volume:y,muted:d,loopOne:C,pauseAtEnd:B,stopAt:$,activeIndex:k,activeSegment:$e,pinnedIndex:q,wantPlaying:U,mount:Tt,destroy:et,play:nt,pause:O,toggle:en,seek:Fe,goToSegment:lt,playRange:tn,clearStopAt:Bt,nextSegment:Rt,prevSegment:zt,replaySegment:nn,setNowPlaying:L,setRate:Dt,cycleRate:ln,setVolume:an,toggleMute:sn,bgActive:T,bgAvailable:W,setBackgroundAudio:p,setTrackNav:ue}}function tl(){return typeof navigator>"u"?!1:/Android|iPhone|iPad|iPod|Mobile/i.test(navigator.userAgent||"")}function nl(){const l=g(!1),S=g(""),b=g(!1),a=g("");let o=null;qe(()=>{const s=window.SpeechRecognition||window.webkitSpeechRecognition;l.value=!!s});function f(){const s=window.SpeechRecognition||window.webkitSpeechRecognition;if(!s)return null;const c=new s;return c.lang="en-US",c.continuous=!0,c.interimResults=!0,c.onresult=y=>{let d="";for(let C=0;C<y.results.length;C++)d+=y.results[C][0].transcript;d=d.trim(),d&&(S.value=d)},c.onend=()=>{if(b.value)try{o?.start()}catch{}},c.onerror=y=>{const d=y?.error;!d||["no-speech","aborted"].includes(d)||(b.value=!1,a.value=d==="not-allowed"||d==="service-not-allowed"?"Trình duyá»t Äang chặn micro. Hãy cho phép quyá»n micro rá»i thá» lại.":d==="audio-capture"?"Không lấy ÄÆ°á»£c tiếng từ micro. Kiá»m tra xem ứng dụng khác có Äang chiếm mic không.":d==="network"?"Nháºn dạng giá»ng nói cần mạng â kiá»m tra kết ná»i rá»i thá» lại.":`Không nháºn dạng ÄÆ°á»£c giá»ng nói (${d}).`)},c}function h(){if(l.value){S.value="",a.value="",b.value=!0,o=f();try{o?.start()}catch{b.value=!1}}}function m(){b.value=!1;try{o?.stop()}catch{}o=null}return Oe(m),{supported:l,text:S,active:b,error:a,start:h,stop:m}}function ll(){const l=g(!1),S=g(0),b=g(""),a=g(null),o=g("");let f=null,h=[],m=null,s=null;const c=()=>["audio/webm;codecs=opus","audio/webm","audio/mp4"].find($=>window.MediaRecorder?.isTypeSupported?.($))||"";async function y(){if(b.value="",l.value)return;try{m=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{b.value="Không truy cáºp ÄÆ°á»£c micro. Hãy cho phép quyá»n micro trong trình duyá»t.";return}h=[];const B=c();f=new MediaRecorder(m,B?{mimeType:B}:void 0),f.ondataavailable=$=>{$.data.size&&h.push($.data)},f.start(),l.value=!0,S.value=0,s=ot(()=>{S.value+=.1},100)}function d(){return new Promise(B=>{if(!f||!l.value)return B(null);f.onstop=()=>{clearInterval(s),l.value=!1;const $=new Blob(h,{type:f?.mimeType||"audio/webm"});m?.getTracks().forEach(M=>M.stop()),m=null,f=null,o.value&&URL.revokeObjectURL(o.value),a.value=$,o.value=URL.createObjectURL($),B($)},f.stop()})}function C(){clearInterval(s);try{f?.stop()}catch{}m?.getTracks().forEach(B=>B.stop()),o.value&&URL.revokeObjectURL(o.value),l.value=!1}return Oe(C),{recording:l,elapsed:S,error:b,lastBlob:a,lastUrl:o,start:y,stop:d,cleanup:C}}const al={class:"bg-white dark:bg-slate-900 rounded-xl border border-slate-200 dark:border-slate-700 px-3 py-2"},sl={class:"flex items-center gap-1 flex-wrap"},ol=["title"],rl={key:0,viewBox:"0 0 24 24",fill:"currentColor"},il={key:1,viewBox:"0 0 24 24",fill:"currentColor"},ul={class:"relative group/spd"},dl={class:"sh-btn sh-btn-wide",title:"Tá»c Äá» phát"},cl={class:"absolute bottom-full left-0 mb-1 hidden group-hover/spd:block z-20 bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-lg shadow-lg py-1 min-w-[64px]"},vl=["onClick"],pl={class:"flex items-center gap-1"},hl={key:0,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},fl={key:1,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"},gl=["value"],bl={class:"ml-auto flex items-center gap-1"},ml={class:"text-xs tabular-nums text-slate-500 px-1"},xl=We({__name:"PlaybackControls",props:{ctrl:{},showEn:{type:Boolean},showVi:{type:Boolean},practiceOpen:{type:Boolean},autoScroll:{type:Boolean},theater:{type:Boolean}},emits:["update:showEn","update:showVi","update:practiceOpen","update:autoScroll","update:theater","shuffle","replay","prev","next"],setup(l,{emit:S}){const b=l,a=S,o=D(()=>b.ctrl),f=D(()=>{const m=o.value.duration.value;return m?o.value.currentTime.value/m*100:0});function h(m){const s=m.currentTarget,c=(m.clientX-s.getBoundingClientRect().left)/s.clientWidth;o.value.seek(c*o.value.duration.value,o.value.playing.value)}return(m,s)=>(i(),u("div",al,[e("div",{class:"group relative h-1.5 mb-2.5 rounded-full bg-slate-200 dark:bg-slate-700 cursor-pointer",onClick:h},[e("div",{class:"absolute inset-y-0 left-0 rounded-full bg-blue-500",style:Ve({width:`${f.value}%`})},null,4),e("div",{class:"absolute top-1/2 -translate-y-1/2 -translate-x-1/2 w-3 h-3 rounded-full bg-blue-600 shadow opacity-0 group-hover:opacity-100 transition-opacity",style:Ve({left:`${f.value}%`})},null,4)]),e("div",sl,[e("button",{class:"sh-btn",title:"Câu trưá»c (â)",onClick:s[0]||(s[0]=c=>a("prev"))}
1,[...s[14]||(s[14]=[e("svg",{viewBox:"0 0 24 24",fill:"currentColor"},[e("path",{d:"M6 6h2v12H6zm3 6 9-6v12z"})],-1)])]),e("button",{class:"sh-btn sh-btn-primary",title:o.value.playing.value?"Dừng (Space)":"Phát (Space)",onClick:s[1]||(s[1]=c=>o.value.toggle())},[o.value.playing.value?(i(),u("svg",il,[...s[16]||(s[16]=[e("path",{d:"M7 5h4v14H7zm6 0h4v14h-4z"},null,-1)])])):(i(),u("svg",rl,[...s[15]||(s[15]=[e("path",{d:"M7 5v14l12-7z"},null,-1)])]))],8,ol),e("button",{class:"sh-btn",title:"Câu sau (â)",onClick:s[2]||(s[2]=c=>a("next"))},[...s[17]||(s[17]=[e("svg",{viewBox:"0 0 24 24",fill:"currentColor"},[e("path",{d:"M16 6h2v12h-2zM6 6l9 6-9 6z"})],-1)])]),e("button",{class:"sh-btn",title:"Nghe lại trá»n câu nà y (Enter)",onClick:s[3]||(s[3]=c=>a("replay"))},[...s[18]||(s[18]=[e("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"},[e("path",{d:"M3 12a9 9 0 1 0 3-6.7"}),e("path",{d:"M3 4v5h5"})],-1)])]),e("button",{class:I(["sh-btn",{"sh-on":o.value.loopOne.value}]),title:"Lặp lại câu nà y (â)",onClick:s[4]||(s[4]=c=>o.value.loopOne.value=!o.value.loopOne.value)},[...s[19]||(s[19]=[st('<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" data-v-841bb4e0><path d="M17 2l4 4-4 4" data-v-841bb4e0></path><path d="M3 11v-1a4 4 0 0 1 4-4h14" data-v-841bb4e0></path><path d="M7 22l-4-4 4-4" data-v-841bb4e0></path><path d="M21 13v1a4 4 0 0 1-4 4H3" data-v-841bb4e0></path></svg>',1)])],2),e("button",{class:I(["sh-btn",{"sh-on":o.value.pauseAtEnd.value}]),title:"Tá»± dừng á» cuá»i má»i câu (Äá» ká»p nhại lại)",onClick:s[5]||(s[5]=c=>o.value.pauseAtEnd.value=!o.value.pauseAtEnd.value)},[...s[20]||(s[20]=[e("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"},[e("path",{d:"M6 4v16"}),e("path",{d:"M10 12h9"}),e("path",{d:"m15 8 4 4-4 4"})],-1)])],2),s[29]||(s[29]=e("span",{class:"w-px h-5 bg-slate-200 dark:bg-slate-700 mx-1"},null,-1)),e("div",ul,[e("button",dl,_(o.value.rate.value)+"x",1),e("div",cl,[(i(!0),u(se,null,Ie(J(at),c=>(i(),u("button",{key:c,class:I(["block w-full px-3 py-1 text-sm text-left hover:bg-slate-100 dark:hover:bg-slate-700",c===o.value.rate.value?"text-blue-600 font-semibold":"text-slate-600 dark:text-slate-300"]),onClick:y=>o.value.setRate(c)},_(c)+"x",11,vl))),128))])]),e("div",pl,[e("button",{class:"sh-btn",title:"Tắt/báºt tiếng (M)",onClick:s[6]||(s[6]=c=>o.value.toggleMute())},[!o.value.muted.value&&o.value.volume.value>0?(i(),u("svg",hl,[...s[21]||(s[21]=[e("path",{d:"M11 5 6 9H2v6h4l5 4z"},null,-1),e("path",{d:"M15.5 8.5a5 5 0 0 1 0 7"},null,-1)])])):(i(),u("svg",fl,[...s[22]||(s[22]=[e("path",{d:"M11 5 6 9H2v6h4l5 4z"},null,-1),e("path",{d:"m17 9 4 6M21 9l-4 6"},null,-1)])]))]),e("input",{type:"range",min:"0",max:"100",value:o.value.muted.value?0:o.value.volume.value,class:"sh-range w-16 sm:w-20",onInput:s[7]||(s[7]=c=>o.value.setVolume(Number(c.target.value)))},null,40,gl)]),s[30]||(s[30]=e("span",{class:"w-px h-5 bg-slate-200 dark:bg-slate-700 mx-1"},null,-1)),e("button",{class:I(["sh-chip",{"sh-chip-on":l.practiceOpen}]),onClick:s[8]||(s[8]=c=>a("update:practiceOpen",!l.practiceOpen))},[...s[23]||(s[23]=[e("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"},[e("path",{d:"M12 2a3 3 0 0 0-3 3v6a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z"}),e("path",{d:"M19 10v1a7 7 0 0 1-14 0v-1M12 18v4"})],-1),V(" Luyá»n táºp ",-1)])],2),e("button",{class:I(["sh-chip",{"sh-chip-on":l.showEn}]),onClick:s[9]||(s[9]=c=>a("update:showEn",!l.showEn))},[...s[24]||(s[24]=[e("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e("rect",{x:"2",y:"5",width:"20",height:"14",rx:"2"}),e("path",{d:"M6 14h4M13 14h5","stroke-linecap":"round"})],-1),V(" Phụ Äá» ",-1)])],2),e("button",{class:I(["sh-chip",{"sh-chip-on":l.showVi}]),onClick:s[10]||(s[10]=c=>a("update:showVi",!l.showVi))},[...s[25]||(s[25]=[e("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e("path",{d:"M4 5h7M8 5v3c0 3-1.6 5.6-4 7"}),e("path",{d:"M6 11c1.6 2.6 4 4.4 6 5"}),e("path",{d:"m13 20 4-9 4 9M14.5 17h5"})],-1),V(" Dá»ch ",-1)])],2),e("button",{class:I(["sh-chip",{"sh-chip-on":l.autoScroll}]),title:"Tá»± cuá»n phụ Äá» theo câu Äang phát",onClick:s[11]||(s[11]=c=>a("update:autoScroll",!l.autoScroll))},[...s[26]||(s[26]=[e("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"},[e("path",{d:"M12 5v14"}),e("path",{d:"m7 14 5 5 5-5"})],-1),V(" Tá»± cuá»n ",-1)])],2),dn(m.$slots,"chips-end",{},void 0,!0),e("div",bl,[e("span",ml,_(J(It)(o.value.currentTime.value))+" / "+_(J(It)(o.value.duration.value)),1),e("button",{class:"sh-btn",title:"Video ngẫu nhiên",onClick:s[12]||(s[12]=c=>a("shuffle"))},[...s[27]||(s[27]=[st('<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" data-v-841bb4e0><path d="M16 3h5v5" data-v-841bb4e0></path><path d="M4 20 21 3" data-v-841bb4e0></path><path d="M21 16v5h-5" data-v-841bb4e0></path><path d="m15 15 6 6" data-v-841bb4e0></path><path d="M4 4l5 5" data-v-841bb4e0></path></svg>',1)])]),e("button",{class:I(["sh-btn",{"sh-on":l.theater}]),title:"Chế Äá» rạp (ẩn phụ Äá» bên phải)",onClick:s[13]||(s[13]=c=>a("update:theater",!l.theater))},[...s[28]||(s[28]=[e("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"},[e("rect",{x:"2",y:"6",width:"20",height:"12",rx:"2"})],-1)])],2)])])]))}}),kl=rt(xl,[["__scopeId","data-v-841bb4e0"]]),yl=/[a-zA-Z0-9']+/g;function Ht(l){return(l||"").normalize("NFKD").replace(/â/g,"'").replace(/\[[^\]]*\]|\([^)]*\)/g," ").match(yl)||[]}function wl(l,S,b,a,o,f,h){let m=a,s=f,c=0,y=new Map;for(let d=a;d<o;d++){const C=new Map;for(const B of b.get(l[d])||[]){if(B<f)continue;if(B>=h)break;const $=(y.get(B-1)||0)+1;C.set(B,$),$>c&&(m=d-$+1,s=B-$+1,c=$)}y=C}return{i:m,j:s,size:c}}function Qt(l,S){const b=new Map;
1S.forEach((f,h)=>{const m=b.get(f);m?m.push(h):b.set(f,[h])});const a=[[0,l.length,0,S.length]],o=[];for(;a.length;){const[f,h,m,s]=a.pop(),c=wl(l,S,b,f,h,m,s);c.size&&(o.push(c),f<c.i&&m<c.j&&a.push([f,c.i,m,c.j]),c.i+c.size<h&&c.j+c.size<s&&a.push([c.i+c.size,h,c.j+c.size,s]))}return o.sort((f,h)=>f.i-h.i||f.j-h.j),o.push({i:l.length,j:S.length,size:0}),o}function Cl(l,S){const b=l.length+S.length;if(!b)return 1;const a=[...l],o=[...S];return 2*Qt(a,o).reduce((h,m)=>h+m.size,0)/b}function Sl(l,S){const b=Ht(l),a=b.map(y=>y.toLowerCase()),o=Ht(S).map(y=>y.toLowerCase());if(!a.length)return{score:0,words:[],missing:0,extra:0,matched:0,total:0};const f=a.map(()=>"miss");let h=0,m=0;for(const y of Qt(a,o)){if(h<y.i&&m<y.j)for(let d=0;h+d<y.i;d++){const C=m+d;if(C>=y.j)break;f[h+d]=Cl(a[h+d],o[C])>=.7?"near":"miss"}for(let d=0;d<y.size;d++)f[y.i+d]="ok";h=y.i+y.size,m=y.j+y.size}const s=f.filter(y=>y==="ok").length,c=f.filter(y=>y==="near").length;return{score:Math.round((s+.5*c)/a.length*100),words:b.map((y,d)=>({w:y,s:f[d]})),missing:f.filter(y=>y==="miss").length,extra:Math.max(0,o.length-s-c),matched:s,total:a.length}}const _l={class:"bg-white dark:bg-slate-900 rounded-xl border-2 border-blue-500 dark:border-blue-400 shadow-md shadow-blue-500/10 overflow-hidden"},$l={class:"p-2 border-b border-slate-100 dark:border-slate-800"},Ml={class:"grid grid-cols-3 gap-1.5 p-1.5 rounded-xl bg-slate-100 dark:bg-slate-800"},Tl=["title","onClick"],Bl={class:"w-[18px] h-[18px] shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},El=["d"],Il={class:"truncate"},Ll={key:0,class:"p-6 text-center text-sm text-slate-400"},Al={key:1,class:"p-4"},Vl={class:"rounded-xl border border-slate-200 dark:border-slate-700 bg-slate-50/70 dark:bg-slate-800/40 px-4 py-3"},Pl={class:"text-[20px] font-semibold leading-snug text-slate-900 dark:text-white"},Rl={key:0,class:"text-[17px] italic leading-snug text-slate-600 dark:text-slate-400 mt-1"},zl={class:"flex flex-wrap items-center gap-2 mt-4"},Dl=["disabled","title"],Ul={key:0,class:"w-2.5 h-2.5 rounded-full bg-white animate-pulse"},Nl={key:1,class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"},Ol={key:2},jl={key:3},Kl=["src"],Hl={key:0,class:"mt-3 rounded-xl border-2 border-rose-300 bg-rose-50/60 dark:bg-rose-500/10 dark:border-rose-500/40 px-4 py-3"},Fl={class:"flex items-center gap-1.5 text-[11px] font-bold uppercase tracking-wide text-rose-600 mb-1"},Yl={class:"text-[20px] leading-snug font-medium text-slate-900 dark:text-white min-h-[30px]"},Wl={key:0},ql={key:1,class:"text-slate-400 font-normal"},Gl={key:2,class:"text-slate-400 font-normal text-[17px]"},Xl={key:1,class:"mt-3 space-y-3"},Jl={class:"rounded-xl border border-slate-200 dark:border-slate-700 px-4 py-3"},Zl={class:"text-[20px] leading-snug text-slate-900 dark:text-white"},Ql={key:0},ea={key:1,class:"text-slate-400 text-[17px]"},ta={class:"flex items-center gap-3 flex-wrap"},na={class:"flex-1 min-w-[80px] h-1.5 rounded-full bg-white/70 dark:bg-slate-800 overflow-hidden max-w-[200px]"},la={class:"flex flex-wrap gap-1.5 mt-3"},aa={class:"flex flex-wrap gap-x-4 gap-y-1 mt-2.5 text-[12px] text-slate-500"},sa={key:2,class:"mt-3 text-xs text-amber-600"},oa={key:3,class:"mt-3 text-[11px] text-slate-400 leading-relaxed"},ra=["onKeydown"],ia={class:"flex flex-wrap items-center gap-2 mt-3"},ua=["disabled"],da={key:0,class:"mt-3 text-[18px] text-slate-900 dark:text-slate-100"},ca={key:1,class:"text-[17px] italic leading-snug text-slate-600 dark:text-slate-400 mt-1"},va={key:0,class:"text-xs text-slate-400 mb-2.5"},pa={key:1,class:"flex items-center gap-2 mb-2.5"},ha={class:"text-xs text-slate-500"},fa={class:"text-slate-700 dark:text-slate-300"},ga={class:"flex-1 h-1.5 rounded-full bg-slate-100 dark:bg-slate-800 overflow-hidden max-w-[180px]"},ba={class:"text-xs font-semibold text-amber-500 tabular-nums"},ma={class:"flex flex-wrap gap-1.5 rounded-lg bg-slate-50 dark:bg-slate-800/60 p-3"},xa=["title","onClick"],ka={key:2,class:"text-[17px] italic text-slate-700 dark:text-slate-400 mt-2.5"},ya={class:"flex flex-wrap items-center gap-2 mt-4"},wa=["disabled"],Ca=["disabled"],Sa=["disabled"],_a={key:3,class:"mt-4 pt-3 border-t border-slate-100 dar
1k:border-slate-800 flex items-center gap-4"},$a={class:"text-center shrink-0"},Ma={class:"text-[11px] text-slate-400"},Ta={class:"text-xs text-slate-500 leading-relaxed min-w-0"},Ba={key:0,class:"truncate"},Ea={class:"italic"},Ia={class:"mt-0.5 flex flex-wrap gap-x-3"},La={class:"text-rose-500"},Aa=We({__name:"PracticePanel",props:{segment:{},youtubeId:{},loggedIn:{type:Boolean},showVi:{type:Boolean}},emits:["next","replay","start-first","scored"],setup(l,{expose:S,emit:b}){const a=l,o=b,f=g("speak");function h(w){f.value=w,B.value=null,k.value=!1,w==="speak"&&!a.segment&&o("start-first")}const m=[{k:"speak",label:"Luyá»n nói",hint:"Äá»c theo câu mẫu â chữ hiá»n ngay theo lá»i bạn nói, rá»i Äá»i chiếu từng từ",icon:["M12 2a3 3 0 0 0-3 3v6a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z","M19 10v1a7 7 0 0 1-14 0v-1M12 18v4"]},{k:"dictation",label:"Chép chÃnh tả",hint:"Nghe rá»i gõ lại Äúng câu bạn nghe ÄÆ°á»£c",icon:["M12 20h9","M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z"]},{k:"flip",label:"Láºt từ",hint:"Câu bá» che má»t sá» từ â nhấn Tab Äá» láºt lá» dần từng từ",icon:["M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z","M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0z"]}],s=Gt(),c=Jt(),y=ll(),d=nl(),C=g(!1),B=g(null),$=g(null),M=g(""),k=g(!1),q=D(()=>!!a.segment?.en?.trim()),U=D(()=>{const w=(a.segment?.en||"").split(/\s+/).filter(Boolean);if(!w.length)return[];let p=(a.segment?.i??0)*9301+49297;const me=()=>(p=(p*9301+49297)%233280)/233280,G=Y=>Y.replace(/[^A-Za-z0-9']/g,""),E=w.map(Y=>G(Y).length>2&&me()<.35);if(!E.some(Boolean)){let Y=-1;w.forEach((xe,fe)=>{G(xe).length>2&&(Y<0||G(xe).length>G(w[Y]).length)&&(Y=fe)}),Y>=0&&(E[Y]=!0)}let ne=0;return w.map((Y,xe)=>({text:Y,hidden:E[xe],hi:E[xe]?ne++:-1}))}),N=g(new Set),Z=D(()=>U.value.filter(w=>w.hidden).length),T=D(()=>Z.value?Math.round(N.value.size/Z.value*100):0),W=w=>!w.hidden||N.value.has(w.hi),ae=w=>"â¢".repeat(Math.min(Math.max(w.text.length,3),12));function ce(w){N.value=new Set([...N.value,w])}function ve(){const w=U.value.find(p=>p.hidden&&!N.value.has(p.hi));w&&ce(w.hi)}function oe(){N.value=new Set(U.value.filter(w=>w.hidden).map(w=>w.hi))}function re(){N.value=new Set}function pe(w){if(f.value!=="flip"||!a.segment)return;const p=w.target;p&&(["INPUT","TEXTAREA","SELECT"].includes(p.tagName)||p.isContentEditable)||w.key==="Tab"&&(w.preventDefault(),ve())}qe(()=>window.addEventListener("keydown",pe)),Oe(()=>window.removeEventListener("keydown",pe)),Ue(()=>a.segment?.i,()=>{Q.value&&(Le(),y.stop()),B.value=null,$.value=null,ee.value=!1,M.value="",k.value=!1,y.lastBlob.value=null,d.text.value="",re()});const H=g(null),ie=D(()=>d.supported.value&&!tl()),Q=g(!1),ee=g(!1),be=g(0);let L=null;function Le(){Q.value=!1,clearInterval(L),d.stop()}async function Pe(){if(!a.loggedIn){H.value="login";return}if(!(!q.value||C.value)){if(Q.value){Le();const w=await y.stop();if(!w||w.size<1200){c.warning("Äoạn ghi âm quá ngắn, hãy thá» lại.");return}if(ee.value=!0,!ie.value)return;if(d.error.value){c.error(d.error.value);return}const p=d.text.value.trim();if(!p)return;const me=Sl(a.segment.en,p);$.value=me,o("scored",{index:a.segment.i,score:me.score});return}try{const w=await s.consumeSpeak();if(w&&w.allowed===!1){H.value="premium";return}}catch(w){if(w?.response?.status===401){H.value="login";return}}if(B.value=null,$.value=null,ee.value=!1,ie.value&&d.start(),await y.start(),y.error.value){d.stop(),c.error(y.error.value);return}Q.value=!0,be.value=0,L=ot(()=>{be.value=+(be.value+.1).toFixed(1)},100)}}Oe(()=>clearInterval(L));const te=D(()=>d.text.value.trim());async function Te(){if(!(!q.value||C.value||!M.value.trim())){C.value=!0;try{const w=await s.checkTyped({youtube_id:a.youtubeId,order_index:a.segment.i,reference:a.segment.en,typed:M.value,mode:"dictation"});B.value=w,k.value=!0,o("scored",{index:a.segment.i,score:w.score})}catch(w){c.error(w?.message||"Chưa chấm ÄÆ°á»£c câu nà y.")}finally{C.value=!1}}}function ue(){B.value=null,$.value=null,M.value="",k.value=!1,re(),o("next")}const Ce=w=>w>=85?"text-emerald-600":w>=60?"text-amber-500":"text-rose-500",he=w=>w>=85?"Rất tá»t!":w>=60?"Khá á»n, luyá»n thêm nhé":"Chưa khá»p, thá» lại nà o",F=w=>w==="ok"?"text-emerald-600 dark:text-emerald-400":w==="near"?"text-amber-500 underline decoration-dotted":"text-rose-500 line-through decoration-rose-300";return S({toggleRecord:Pe,recording:Q}),(w,p)=>{const me=Yt,G=Xt;return i(),u("div",_l,[e("div",$l,[e("div",Ml,[(i(),u(se,null,Ie(m,E=>e("button",{key:E.k,class:I(["inline-flex items-center justify-center gap-1.5 h-11 rounded-lg border border-transparent text-[14px] font-bold transition-all",f.value===E.k?"bg-blue-50 border-blue-300 text-blue-700 shadow-sm dark:bg-blue-500/15 dark:border-blue-500/30 dark:text-blue-300":"text-slate-600 dar
1k:text-slate-300 hover:bg-white dark:hover:bg-slate-700 hover:shadow-sm"]),title:E.hint,onClick:ne=>h(E.k)},[(i(),u("svg",Bl,[(i(!0),u(se,null,Ie(E.icon,(ne,Y)=>(i(),u("path",{key:Y,d:ne},null,8,El))),128))])),e("span",Il,_(E.label),1)],10,Tl)),64))])]),l.segment?(i(),u("div",Al,[f.value==="speak"?(i(),u(se,{key:0},[e("div",Vl,[p[6]||(p[6]=e("p",{class:"sh-label"},"Câu mẫu â Äá»c theo câu nà y",-1)),e("p",Pl,_(l.segment.en),1),l.showVi!==!1&&l.segment.vi?(i(),u("p",Rl,_(l.segment.vi),1)):P("",!0)]),e("div",zl,[e("button",{class:I(["sh-act shadow-sm",Q.value?"bg-rose-600 border-rose-600 text-white hover:bg-rose-700 hover:border-rose-700":"bg-blue-600 border-blue-600 text-white hover:bg-blue-700 hover:border-blue-700"]),disabled:C.value,title:Q.value?"Bấm Äá» dừng thu":"Bấm Äá» thu âm giá»ng bạn Äá»c câu tiếng Anh Äang hiá»n thá» (phÃm tắt: R)",onClick:Pe},[Q.value?(i(),u("span",Ul)):(i(),u("svg",Nl,[...p[7]||(p[7]=[e("path",{d:"M12 2a3 3 0 0 0-3 3v6a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z"},null,-1),e("path",{d:"M19 10v1a7 7 0 0 1-14 0v-1M12 18v4"},null,-1)])])),Q.value?(i(),u("span",Ol,"Dừng thu ("+_(be.value.toFixed(1))+"s)",1)):(i(),u("span",jl,[...p[8]||(p[8]=[V("Thu âm ",-1),e("kbd",{class:"sh-kbd-on hidden sm:inline"},"R",-1)])]))],10,Dl),e("button",{class:"sh-act border-indigo-200 bg-indigo-50 text-indigo-700 hover:bg-indigo-100 dark:bg-indigo-500/15 dark:border-indigo-500/30 dark:text-indigo-300",title:"Bấm Äá» nghe Äá»c mẫu câu tiếng Anh Äang hiá»n thá».",onClick:p[
10]||(p[0]=E=>o("replay"))},[...p[9]||(p[9]=[e("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"},[e("path",{d:"M3 12a9 9 0 1 0 3-6.7"}),e("path",{d:"M3 4v5h5"})],-1),V(" Nghe mẫu ",-1)])]),e("button",{class:"sh-act bg-slate-900 border-slate-900 text-white hover:bg-black dark:bg-slate-700 dark:border-slate-700 dark:hover:bg-slate-600",title:"Chuyá»n sang câu trá»n vẹn tiếp theo (phÃm tắt: â)",onClick:ue},[...p[10]||(p[10]=[V(" Câu tiếp ",-1),e("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"},[e("path",{d:"m9 6 6 6-6 6"})],-1)])]),J(y).lastUrl.value&&!Q.value?(i(),u("audio",{key:0,src:J(y).lastUrl.value,controls:"",title:"Nghe lại giá»ng bạn vừa thu",class:"h-9 basis-full min-w-0 sm:h-10 sm:basis-auto sm:flex-1 sm:max-w-[200px]"},null,8,Kl)):P("",!0)]),Q.value?(i(),u("div",Hl,[e("p",Fl,[p[11]||(p[11]=e("span",{class:"w-2 h-2 rounded-full bg-rose-500 animate-pulse"},null,-1)),V(" Äang nghe bạn nói⦠"+_(be.value.toFixed(1))+"s ",1)]),e("p",Yl,[J(d).text.value?(i(),u("span",Wl,_(J(d).text.value),1)):ie.value?(i(),u("span",ql," Hãy Äá»c to câu tiếng Anh á» trên⦠")):(i(),u("span",Gl," Äang thu âm⦠bấm âDừng thuâ Äá» nghe lại giá»ng mình. "))])])):ie.value&&(te.value||ee.value)?(i(),u("div",Xl,[e("div",Jl,[p[12]||(p[12]=e("p",{class:"sh-label"},"Bạn Äã nói",-1)),e("p",Zl,[te.value?(i(),u("span",Ql,"â"+_(te.value)+"â",1)):(i(),u("span",ea," Không nghe ÄÆ°á»£c gì â hãy nói to hÆ¡n và thá» lại. "))])]),$.value?(i(),u("div",{key:0,class:I(["rounded-xl border-2 px-4 py-3",$.value.score>=85?"border-emerald-200 bg-emerald-50/60 dark:bg-emerald-500/10 dark:border-emerald-500/30":$.value.score>=60?"border-amber-200 bg-amber-50/60 dark:bg-amber-500/10 dark:border-amber-500/30":"border-rose-200 bg-rose-50/60 dark:bg-rose-500/10 dark:border-rose-500/30"])},[e("div",ta,[e("p",{class:I(["text-[15px] font-bold",Ce($.value.score)])},_($.value.matched)+"/"+_($.value.total)+" từ khá»p ",3),e("div",na,[e("div",{class:I(["h-full rounded-full transition-all",$.value.score>=85?"bg-emerald-500":$.value.score>=60?"bg-amber-500":"bg-rose-500"]),style:Ve({width:`${$.value.score}%`})},null,6)]),e("p",{class:I(["text-[13px] font-semibold",Ce($.value.score)])},_(he($.value.score)),3)]),e("div",la,[(i(!0),u(se,null,Ie($.value.words,(E,ne)=>(i(),u("span",{key:ne,class:I(["px-2.5 py-1 rounded-md text-[15px] font-medium border",E.s==="ok"?"bg-emerald-100 border-emerald-200 text-emerald-800 dark:bg-emerald-500/20 dark:border-emerald-500/30 dark:text-emerald-300":E.s==="near"?"bg-amber-100 border-amber-200 text-amber-800 dark:bg-amber-500/20 dark:border-amber-500/30 dark:text-amber-300":"bg-rose-100 border-rose-200 text-rose-700 line-through decoration-rose-400 dark:bg-rose-500/20 dark:border-rose-500/30 dark:text-rose-300"])},_(E.w),3))),128))]),e("p",aa,[p[14]||(p[14]=e("span",null,[e("span",{class:"text-emerald-600"},"â"),V(" Äá»c Äúng")],-1)),p[15]||(p[15]=e("span",null,[e("span",{class:"text-amber-500"},"â"),V(" gần Äúng")],-1)),e("span",null,[p[13]||(p[13]=e("span",{class:"text-rose-500"},"â",-1)),V(" Äá»c tráºt hoặc bá» sót ("+_($.value.missing)+")",1)])])],2)):P("",!0)])):P("",!0),l.loggedIn?ie.value?P("",!0):(i(),u("p",oa," Trên Äiá»n thoại chá» ghi âm ÄÆ°á»£c, hiá»n thá» text bạn nói hãy sá» dụng máy tÃnh. ")):(i(),u("p",sa,[p[17]||(p[17]=V(" Bạn Äang xem thá» â ",-1)),de(me,{to:"/login",class:"underline font-medium"},{default:Ye(()=>[...p[16]||(p[16]=[V("ÄÄng nháºp",-1)])]),_:1}),p[18]||(p[18]=V(" Äá» lưu tiến Äá» luyá»n táºp. ",-1))]))],64)):f.value==="dictation"?(i(),u(se,{key:1},[p[22]||(p[22]=e("p",{class:"text-xs text-slate-400 mb-2"},"Nghe rá»i gõ lại Äúng câu bạn nghe ÄÆ°á»£c:",-1)),Vt(e("textarea",{"onUpdate:modelValue":p[1]||(p[1]=E=>M.value=E),rows:"2",placeholder:"Gõ câu bạn nghe ÄÆ°á»£c rá»i nhấn Kiá»m traâ¦",class:"w-full rounded-lg border border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-800 px-3 py-2 text-[18px] outline-none focus:border-blue-400 focus:ring-2 focus:ring-blue-100 text-slate-900 dark:text-slate-100 resize-none",onKeydown:qt(Et(Te,["ctrl","prevent"]),["enter"])},null,40,ra),[[Pt,M.value]]),e("div",ia,[e("button",{class:"sh-act bg-blue-600 border-blue-600 text-white hover:bg-blue-700 hover:border-blue-700 shadow-sm",disabled:C.value||!M.value.trim(),title:"Chấm câu bạn vừa gõ (phÃm tắt: Ctrl + Enter)",onClick:Te},_(C.value?"Äang chấmâ¦":"Kiá»m tra"),9,ua),e("button",{class:"sh-act border-indigo-200 bg-indigo-50 text-indigo-700 hover:bg-indigo-100 dark:bg-indigo-500/15 dark:border-indigo-500/30 dark:text-indigo-300",title:"Bấm Äá» nghe Äá»c mẫu trá»n câu tiếng Anh Äang luyá»n.",onClick:p[2]||(p[2]=E=>o("replay"))},[...p[19]||(p[19]=[e("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"},[e("path",{d:"M3 12a9 9 0 1 0 3-6.7"}),e("path",{d:"M3 4v5h5"})],-1),V(" Nghe lại ",-1)])]),e("button",{class:"sh-act border-amber-200 bg-amber-50 text-amber-700 hover:bg-amber-100 dar
1k:bg-amber-500/15 dark:border-amber-500/30 dark:text-amber-300",title:"Hiá»n câu Äúng",onClick:p[3]||(p[3]=E=>k.value=!0)},"Xem Äáp án"),e("button",{class:"sh-act ml-auto bg-slate-900 border-slate-900 text-white hover:bg-black dark:bg-slate-700 dark:border-slate-700 dark:hover:bg-slate-600",title:"Chuyá»n sang câu trá»n vẹn tiếp theo (phÃm tắt: â)",onClick:ue},[...p[20]||(p[20]=[V(" Câu tiếp ",-1),e("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"},[e("path",{d:"m9 6 6 6-6 6"})],-1)])])]),k.value?(i(),u("p",da,[p[21]||(p[21]=e("span",{class:"text-xs text-slate-400 block mb-0.5"},"Äáp án:",-1)),B.value?(i(!0),u(se,{key:0},Ie(B.value.words,(E,ne)=>(i(),u("span",{key:ne,class:I(F(E.s))},_(E.w)+_(" "),3))),128)):(i(),u(se,{key:1},[V(_(l.segment.en),1)],64))])):P("",!0),k.value&&l.showVi!==!1&&l.segment.vi?(i(),u("p",ca,_(l.segment.vi),1)):P("",!0)],64)):(i(),u(se,{key:2},[Z.value?(i(),u("div",pa,[e("span",ha,[e("strong",fa,_(N.value.size)+"/"+_(Z.value),1),p[23]||(p[23]=V(" từ Äã láºt ",-1))]),e("div",ga,[e("div",{class:"h-full bg-amber-400 rounded-full transition-all",style:Ve({width:`${T.value}%`})},null,4)]),e("span",ba,_(T.value)+"%",1)])):(i(),u("div",va," Câu nà y toà n từ ngắn nên không có từ nà o Äá» láºt. ")),e("div",ma,[(i(!0),u(se,null,Ie(U.value,(E,ne)=>(i(),u("button",{key:ne,type:"button",class:I(["px-2.5 py-1 rounded-md text-[18px] leading-snug transition-colors",W(E)?E.hidden?"bg-emerald-100 text-emerald-800 font-semibold dark:bg-emerald-500/20 dark:text-emerald-300":"bg-white text-slate-900 border border-slate-200 dark:bg-slate-700 dark:text-slate-100 dark:border-slate-600":"bg-slate-200 text-slate-400 tracking-[0.15em] hover:bg-slate-300 cursor-pointer dark:bg-slate-700 dark:text-slate-500"]),title:E.hidden&&!W(E)?"Bấm Äá» láºt từ nà y":"",onClick:Y=>E.hidden&&!W(E)?ce(E.hi):void 0},_(W(E)?E.text:ae(E)),11,xa))),128))]),l.showVi!==!1&&l.segment.vi?(i(),u("p",ka,_(l.segment.vi),1)):P("",!0),e("div",ya,[e("button",{class:"sh-act bg-blue-600 border-blue-600 text-white hover:bg-blue-700 hover:border-blue-700 shadow-sm",disabled:N.value.size>=Z.value,title:"Lá» thêm má»t từ Äang bá» che (phÃm tắt: Tab)",onClick:ve},[...p[24]||(p[24]=[e("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e("path",{d:"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z"}),e("circle",{cx:"12",cy:"12",r:"3"})],-1),V(" Láºt 1 từ ",-1),e("kbd",{class:"sh-kbd-on hidden sm:inline"},"Tab",-1)])],8,wa),e("button",{class:"sh-act border-indigo-200 bg-indigo-50 text-indigo-700 hover:bg-indigo-100 dark:bg-indigo-500/15 dark:border-indigo-500/30 dark:text-indigo-300",title:"Bấm Äá» nghe Äá»c mẫu trá»n câu tiếng Anh Äang hiá»n thá».",onClick:p[4]||(p[4]=E=>o("replay"))},[...p[25]||(p[25]=[e("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"},[e("path",{d:"M3 12a9 9 0 1 0 3-6.7"}),e("path",{d:"M3 4v5h5"})],-1),V(" Nghe lại ",-1)])]),e("button",{class:"sh-act border-amber-200 bg-amber-50 text-amber-700 hover:bg-amber-100 dark:bg-amber-500/15 dark:border-amber-500/30 dark:text-amber-300",disabled:N.value.size>=Z.value,title:"Lá» hết các từ Äang bá» che",onClick:oe},"Láºt hết",8,Ca),e("button",{class:"sh-act border-slate-200 bg-white text-slate-600 hover:bg-slate-50 dark:bg-slate-800 dark:border-slate-700 dark:text-slate-300",disabled:!N.value.size,title:"Che lại tất cả Äá» là m lại từ Äầu",onClick:re},"Che lại",8,Sa),e("button",{class:"sh-act ml-auto bg-slate-900 border-slate-900 text-white hover:bg-black dark:bg-slate-700 dark:border-slate-700 dark:hover:bg-slate-600",title:"Chuyá»n sang câu trá»n vẹn tiếp theo (phÃm tắt: â)",onClick:ue},[...p[26]||(p[26]=[V(" Câu tiếp ",-1),e("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"},[e("path",{d:"m9 6 6 6-6 6"})],-1)])])]),p[27]||(p[27]=e("div",{class:"mt-2.5 flex flex-wrap gap-x-3 gap-y-1 text-[11px] text-slate-400"},[e("span",null,[e("kbd",{class:"sh-kbd"},"Tab"),V(" Láºt 1 từ")]),e("span",null,[e("kbd",{class:"sh-kbd"},"Enter"),V(" Nghe lại trá»n câu")]),e("span",null,[e("kbd",{class:"sh-kbd"},"â"),V(" Câu tiếp")])],-1))],64)),B.value&&f.value==="dictation"?(i(),u("div",_a,[e("div",$a,[e("div",{class:I(["text-2xl font-bold tabular-nums",Ce(B.value.score)])},[V(_(B.value.score),1),p[28]||(p[28]=e("span",{class:"text-sm font-normal text-slate-400"}
1,"/100",-1))],2),e("div",Ma,_(he(B.value.score)),1)]),e("div",Ta,[B.value.heard?(i(),u("p",Ba,[p[29]||(p[29]=e("span",{class:"text-slate-400"},"Há» thá»ng nghe ÄÆ°á»£c:",-1)),e("span",Ea,"â"+_(B.value.heard)+"â",1)])):P("",!0),e("p",Ia,[p[30]||(p[30]=e("span",{class:"text-emerald-600"},"â Äúng",-1)),p[31]||(p[31]=e("span",{class:"text-amber-500"},"â gần Äúng",-1)),e("span",La,"â sai / thiếu ("+_(B.value.missing)+")",1)])])])):P("",!0)])):(i(),u("div",Ll," Bấm và o má»t câu trong phụ Äá» Äá» bắt Äầu luyá»n. ")),de(G,{variant:H.value,feature:"speak",onClose:p[5]||(p[5]=E=>H.value=null)},null,8,["variant"])])}}}),Va=rt(Aa,[["__scopeId","data-v-7371a815"]]),Pa={class:"flex flex-col h-full bg-white dark:bg-slate-900 rounded-xl border border-slate-200 dark:border-slate-700 overflow-hidden"},Ra={class:"shrink-0 px-3 py-2 border-b border-slate-100 dark:border-slate-800 flex items-center gap-2"},za={key:0,class:"text-xs text-slate-400 shrink-0"},Da={key:0,class:"flex-1 grid place-items-center p-6 text-center"},Ua={key:1,class:"flex-1 grid place-items-center p-6"},Na=["onClick"],Oa={key:2,class:"text-[15.5px] italic text-slate-400 mt-1"},ja=["title","onClick"],Ka=["fill"],Ha={key:0,class:"text-center text-sm text-slate-400 py-8"},Fa=We({__name:"TranscriptPanel",props:{segments:{},activeIndex:{},starred:{},showEn:{type:Boolean},showVi:{type:Boolean},translateStatus:{},status:{},autoScroll:{type:Boolean}},emits:["seek","star","lookup"],setup(l,{emit:S}){const b=l,a=S,o=g(null),f=g({}),h=g(""),m=D(()=>{const y=h.value.trim().toLowerCase();return y?b.segments.filter(d=>d.en.toLowerCase().includes(y)||(d.vi||"").toLowerCase().includes(y)):b.segments}),s=y=>b.starred.includes(y);Ue(()=>b.activeIndex,async y=>{if(b.autoScroll===!1||h.value)return;await Wt();const d=f.value[y],C=o.value;if(!d||!C)return;const B=d.offsetTop-C.clientHeight/2+d.clientHeight/2;C.scrollTo({top:Math.max(0,B),behavior:"smooth"})});function c(y){const d=window.getSelection()?.toString().trim();d&&/^[a-zA-Z'-]+$/.test(d)&&a("lookup",d.toLowerCase()),y.stopPropagation()}return(y,d)=>(i(),u("div",Pa,[e("div",Ra,[d[4]||(d[4]=e("svg",{class:"w-4 h-4 text-slate-400 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e("circle",{cx:"11",cy:"11",r:"7"}),e("path",{d:"m20 20-3.5-3.5","stroke-linecap":"round"})],-1)),Vt(e("input",{"onUpdate:modelValue":d[0]||(d[0]=C=>h.value=C),type:"text",placeholder:"Tìm trong phụ Äá»â¦",class:"flex-1 text-sm bg-transparent outline-none placeholder:text-slate-400 text-slate-700 dark:text-slate-200"},null,512),[[Pt,h.value]]),h.value?(i(),u("span",za,_(m.value.length)+" kết quả",1)):P("",!0),h.value?(i(),u("button",{key:1,class:"text-slate-400 hover:text-slate-600",onClick:d[1]||(d[1]=C=>h.value="")},[...d[3]||(d[3]=[e("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e("path",{d:"M18 6 6 18M6 6l12 12","stroke-linecap":"round"})],-1)])])):P("",!0)]),l.status==="missing"?(i(),u("div",Da,[...d[5]||(d[5]=[st('<div class="text-slate-400 text-sm leading-relaxed" data-v-76cdab2c><svg class="w-10 h-10 mx-auto mb-3 opacity-40" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" data-v-76cdab2c><rect x="2" y="5" width="20" height="14" rx="2" data-v-76cdab2c></rect><path d="M7 12h3M14 12h3" stroke-linecap="round" data-v-76cdab2c></path></svg> Video nà y không có phụ Äá» tiếng Anh.<br data-v-76cdab2c><span class="text-slate-400/70" data-v-76cdab2c>Hãy chá»n video khác, hoặc nhá» admin nháºp phụ Äá» thá»§ công.</span></div>',1)])])):l.segments.length?(i(),u("div",{key:2,ref_key:"listRef",ref:o,class:"flex-1 overflow-y-auto sh-scroll px-1.5 py-2"},[(i(!0),u(se,null,Ie(m.value,C=>(i(),u("div",{key:C.i,ref_for:!0,ref:B=>f.value[C.i]=B,class:I(["group relative flex gap-2.5 px-2 py-2 rounded-lg cursor-pointer transition-colors",C.i===l.activeIndex?"bg-blue-50 dark:bg-blue-500/10 ring-1 ring-blue-200 dark:ring-blue-500/30":"hover:bg-slate-50 dark:hover:bg-slate-800/60"]),onClick:B=>a("seek",C.i)},[e("span",{class:I(["shrink-0 pt-1.5 text-[13px] tabular-nums font-medium select-none",C.i===l.activeIndex?"text-blue-600":"text-slate-400"])},_(J(It)(C.start)),3),e("div",{class:I(["min-w-0 flex-1 border-l-[3px] pl-2.5 rounded-l-sm",C.i===l.activeIndex?"border-blue-600":"border-blue-300 dark:border-blue-500/40"])},[l.showEn!==!1?(i(),u("p",{key:0,class:I(["text-[18px] leading-normal text-slate-900 dark:text-white",C.i===l.activeIndex?"font-semibold":"font-normal"]),onDblclick:c},_(C.en),35)):P("",!0),l.showVi!==!1&&C.vi?(i(),u("p",{key:1,class:I(["text-[16.5px] italic leading-normal mt-1",C.i===l.activeIndex?"text-blue-800 font-medium dark:text-blue-300":"text-slate-800 dark:text-slate-300"]),onDblclick:d[2]||(d[2]=Et(()=>{},["stop"]))},_(C.vi),35)):l.showVi!==!1&&l.translateStatus==="pending"?(i(),u("p",Oa,"Äang dá»châ¦")):P("",!0)],2),e("button",{class:I(["shrink-0 self-start p-0.5 transition-opacity",s(C.i)?"opacity-100":"opacity-0 group-hover:opacity-60 hover:!opacity-100"]),title:s(C.i)?"Bá» gắn sao":"Gắn sao câu nà y",onClick:Et(B=>a("star",C),["stop"])},[(i(),u("svg",{class:I(["w-4 h-4",s(C.i)?"text-amber-400":"text-slate-400"]),viewB
1ox:"0 0 24 24",fill:s(C.i)?"currentColor":"none",stroke:"currentColor","stroke-width":"1.8"},[...d[7]||(d[7]=[e("path",{d:"m12 3 2.6 5.3 5.9.9-4.2 4.1 1 5.8-5.3-2.8-5.3 2.8 1-5.8L3.5 9.2l5.9-.9L12 3z","stroke-linejoin":"round"},null,-1)])],10,Ka))],10,ja)],10,Na))),128)),h.value&&!m.value.length?(i(),u("p",Ha," Không tìm thấy câu nà o khá»p â"+_(h.value)+"â. ",1)):P("",!0)],512)):(i(),u("div",Ua,[...d[6]||(d[6]=[e("div",{class:"flex flex-col items-center gap-3 text-slate-400"},[e("div",{class:"w-7 h-7 border-[3px] border-slate-200 border-t-slate-500 rounded-full animate-spin"}),e("span",{class:"text-sm"},"Äang lấy phụ Äá»â¦")],-1)])]))]))}}),Ya=rt(Fa,[["__scopeId","data-v-76cdab2c"]]),Wa={class:"sh-font min-h-screen bg-slate-50 dark:bg-slate-950 pb-16"},qa={class:"mx-auto max-w-[1600px] px-3 sm:px-5 pt-4"},Ga={class:"flex flex-wrap items-center justify-center gap-2 mb-4"},Xa={class:"flex gap-2 w-full max-w-xl"},Ja=["disabled"],Za={key:0,class:"w-full text-center text-[11px] text-slate-400"},Qa={key:0,class:"max-w-2xl mx-auto my-16 text-center"},es={key:0,class:"w-8 h-8 text-blue-600",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},ts={key:1,class:"w-8 h-8 text-amber-500",viewBox:"0 0 24 24",fill:"currentColor"},ns={class:"text-xl font-bold text-slate-800 dark:text-white mb-2"},ls={class:"text-slate-500 mb-5"},as={class:"mt-4"},ss={key:1,class:"max-w-2xl mx-auto my-16 text-center"},os={class:"text-slate-500 mb-5"},rs={key:2,class:"grid place-items-center py-24"},is={class:"min-w-0 space-y-3"},us=["title"],ds=["fill"],cs={key:1,class:"bg-white dark:bg-slate-900 rounded-xl border border-slate-200 dark:border-slate-700 px-4 py-3 text-center text-sm text-slate-400"},vs={class:"w-3.5 h-3.5 shrink-0 mt-px",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},ps={key:0,d:"M9 18V5l12-2v13"},hs={key:1,cx:"6",cy:"18",r:"3"},fs={key:2,cx:"18",cy:"16",r:"3"},gs={key:0},bs={key:1},ms={class:"flex flex-wrap items-center gap-3 bg-white dark:bg-slate-900 rounded-xl border border-slate-200 dark:border-slate-700 px-3 py-2"},xs={class:"text-sm font-medium text-slate-600 dark:text-slate-300 truncate max-w-[220px]"},ks={class:"text-xs text-slate-400 tabular-nums"},ys={class:"flex gap-1 ml-1"},ws=["disabled"],Cs=["disabled"],Ss={key:1,class:"ml-auto flex items-center gap-2 min-w-[160px]"},_s={class:"text-xs text-slate-400 whitespace-nowrap"},$s={class:"flex-1 h-1.5 rounded-full bg-slate-100 dark:bg-slate-800 overflow-hidden min-w-[60px]"},Ms={key:0,class:"min-w-0 lg:sticky lg:top-3 lg:self-start",style:{height:"min(calc(100vh - 2rem), 860px)"}},Ts={key:4,class:"mt-10"},Bs={key:5,class:"mt-10"},Ft="shadowing_prefs",Es=We({__name:"[youtubeId]",setup(l){const S=cn(),b=vn(),a=Gt(),o=Jt(),{isUserLoggedIn:f}=gn(),h=D(()=>String(S.params.youtubeId||"")),m=D(()=>S.query.src?Number(S.query.src):null);pn({link:[{rel:"stylesheet",href:"https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@300;400;500;600;700&display=swap"}]});const s=g(!1),c=g(!1),y=g(!0),d=g(""),C=g(null),B=g(""),$=g(null),M=g([]),k=g([]),q=g("none"),U=g("none"),N=g([]),Z=g([]),T=g(null),W=g(!0),ae=g(!0),ce=g(!0),ve=g(!0),oe=g(!1),re=g("desktop"),pe=g({desktop:{...mt.desktop},mobile:{...mt.mobile}}),H=D({get:()=>pe.value[re.value],set:t=>{pe.value[re.value]=t}}),ie=D(()=>mt[re.value]),Q=()=>{re.value=window.innerWidth<=_n?"mobile":"desktop"},ee=g(Lt),be=g(null),L=el(M,be),Le=g(null),Pe=g(null),te=g(null),Te=g(!1),ue=D(()=>L.activeSegment.value),Ce=D(()=>ue.value?N.value.includes(ue.value.i):!1),he=g(null),F=D(()=>{if(!k.value.length)return null;if(he.value!==null){const A=k.value.find(Ee=>Ee.i===he.value);if(A)return A}const t=L.activeIndex.value;if(t<0)return null;const r=L.currentTime.value;return k.value.find(A=>r>=A.start&&r<A.end)??k.value.find(A=>t>=A.seg_from&&t<=A.seg_to)??null}),w=D(()=>{const t=ee.value==="sentence"?F.value??ue.value:ue.value;return t?{en:t.en,vi:t.vi}:null}),p=D(()=>{if(ee.value!=="sentence")return;const t=H.value,r=W.value?t.enSize*1.35*2:0,A=ae.value?t.viSize*1.35*2:0;return`${Math.round(r+A+24)}px`}),me=D(()=>$n(H.value));
1Ue([()=>L.currentTime.value,()=>L.playing.value],([t,r])=>{if(he.value===null||L.stopAt.value!==null||!r)return;const A=k.value.find(Ee=>Ee.i===he.value);(!A||t<A.start-.5||t>A.end+.5)&&(he.value=null)}),Ue(F,t=>{be.value=t?{start:t.start,end:t.end}:null});const G=g(new Set),E=D(()=>k.value.length?Math.round(G.value.size/k.value.length*100):0);function ne(t){he.value=t.i,L.playRange(t.start,t.end)}function Y(){const t=F.value;t?ne(t):L.replaySegment()}function xe(){const t=F.value,r=t?k.value.find(A=>A.i===t.i+1):k.value[0];r&&ne(r)}function fe(){const t=F.value,r=t?k.value.find(A=>A.i===t.i-1):null;r&&ne(r)}function ge(){const t=k.value[0];t&&ne(t)}function je(t){he.value=null,L.goToSegment(t)}let K=null;async function Ge(){y.value=!0,d.value="",M.value=[],he.value=null,C.value=null,B.value="";try{const t=await a.videoDetail(h.value);$.value=t.video,M.value=t.segments,k.value=t.sentences||[],q.value=t.transcript_status,U.value=t.translate_status,N.value=t.starred||[],c.value=t.is_gold,G.value=new Set(t.progress?.done_indexes||[]),L.setNowPlaying({title:t.video.title,artist:t.video.channel_title||"Shadowing · Từ Äiá»n AV",artwork:t.video.thumbnail_url}),bn({title:`Shadowing: ${t.video.title}`,description:`Luyá»n nghe â nói tiếng Anh theo video â${t.video.title}â vá»i phụ Äá» AnhâViá»t Äá»ng bá».`}),t.translate_status==="pending"&&it(),Ke()}catch(t){t?.status===429?d.value=t.message:t?.status===401||t?.status===403?(C.value=t.status===401?"login":"premium",B.value=t.message||"",$e.value=C.value,ze.value=B.value):o.error(t?.message||"Không tải ÄÆ°á»£c video nà y."),L.setBackgroundAudio(h.value,null)}finally{y.value=!1}}async function Ke(){if(te.value=null,!Kt())return;const t=h.value;try{const r=await a.audioStream(t);if(t!==h.value)return;L.setBackgroundAudio(t,r),te.value=!0}catch{if(t!==h.value)return;L.setBackgroundAudio(t,null),te.value=!1}}function it(){clearInterval(K);let t=0;K=ot(async()=>{if(++t>40)return clearInterval(K);try{const r=await a.translation(h.value);if(U.value=r.status,r.status==="ready"){const A=new Map(r.items.map(le=>[le.i,le.vi]));M.value=M.value.map(le=>({...le,vi:A.get(le.i)||le.vi}));const Ee=new Map((r.sentences||[]).map(le=>[le.i,le.vi]));k.value=k.value.map(le=>({...le,vi:Ee.get(le.i)||le.vi})),clearInterval(K)}else r.status==="failed"&&clearInterval(K)}catch{clearInterval(K)}},3e3)}
1async function Xe(){if(s.value)try{const t=await a.stars();Z.value=t.stars}catch{}}async function ut(){if(!m.value){T.value=null;return}try{T.value=await a.sourceNav(m.value,h.value)}catch{T.value=null}}const Se=g([]);async function Je(){if(!s.value){Se.value=[];return}try{const t=await a.recent();Se.value=t.items||[]}catch{Se.value=[]}}const _e=D(()=>{const t=Se.value.map(r=>r.youtube_id).filter(Boolean);return t.includes(h.value)?t:[h.value,...t]}),dt=D(()=>{if(T.value?.prev)return T.value.prev;const t=_e.value.indexOf(h.value);return t>0?_e.value[t-1]:null}),_t=D(()=>{if(T.value?.next)return T.value.next;const t=_e.value.indexOf(h.value);return t>=0&&t+1<_e.value.length?_e.value[t+1]:null});function ct(t){!t||t===h.value||b.push(`/shadowing/${t}${m.value?`?src=${m.value}`:""}`)}async function Ze(t){if(!s.value){o.warning("Hãy ÄÄng nháºp Äá» gắn sao và lưu lại câu hay.");return}try{(await a.toggleStar({youtube_id:h.value,order_index:t.i,start_time:t.start,en:t.en,vi:t.vi,video_title:$.value?.title})).starred?N.value=[...N.value,t.i]:N.value=N.value.filter(A=>A!==t.i),Xe()}catch(r){o.error(r?.message||"Không lưu ÄÆ°á»£c.")}}async function $t(t){const r=Z.value.find(A=>A.id===t);try{await a.deleteStar(t),Z.value=Z.value.filter(A=>A.id!==t),r&&r.youtube_id===h.value&&(N.value=N.value.filter(A=>A!==r.order_index))}catch(A){o.error(A?.message||"Không xoá ÄÆ°á»£c.")}}function Re(t){t.youtube_id===h.value?je(t.order_index):b.push(`/shadowing/${t.youtube_id}`)}function Be({index:t,score:r}){r>=70&&(G.value=new Set([...G.value,t]))}function Mt(t){window.open(`/word/${encodeURIComponent(t)}`,"_blank")}const Ae=g(""),ke=g(!1),$e=g(null),ze=g(""),ye=g(0),vt=g(0);async function pt(){if(!s.value){$e.value="login",ze.value="";return}const t=Ae.value.trim();if(t){ke.value=!0;try{const r=await a.resolve(t);Ae.value="",b.push(`/shadowing/${r.youtube_id}`)}catch(r){r?.status===401||r?.status===403?($e.value=r.status===401?"login":"premium",ze.value=r?.message||""):o.error(r?.message||"Link không hợp lá».")}finally{ke.value=!1}}}function De(t){const r=t.target;if(!(r&&(["INPUT","TEXTAREA","SELECT"].includes(r.tagName)||r.isContentEditable))&&!(t.metaKey||t.ctrlKey||t.altKey))switch(t.key){case" ":t.preventDefault(),L.toggle();break;case"ArrowLeft":t.preventDefault(),t.shiftKey?L.cycleRate(-1):fe();break;case"ArrowRight":t.preventDefault(),t.shiftKey?L.cycleRate(1):xe();break;case"ArrowUp":t.preventDefault(),L.loopOne.value=!L.loopOne.value;break;case"ArrowDown":t.preventDefault(),L.pauseAtEnd.value=!L.pauseAtEnd.value;break;case"Enter":t.preventDefault(),Y();break;case"r":case"R":t.preventDefault(),Le.value?.toggleRecord?.();break;case"m":case"M":t.preventDefault(),L.toggleMute();break;case"s":case"S":t.preventDefault(),ue.value&&Ze(ue.value);break;case"n":case"N":T.value?.next&&b.push(`/shadowing/${T.value.next}?src=${m.value}`);break;case"p":case"P":T.value?.prev&&b.push(`/shadowing/${T.value.prev}?src=${m.value}`);break}}return qe(async()=>{s.value=f(),Te.value=Kt(),Q();try{const t=JSON.parse(localStorage.getItem(Ft)||"{}");typeof t.showEn=="boolean"&&(W.value=t.showEn),typeof t.showVi=="boolean"&&(ae.value=t.showVi),typeof t.autoScroll=="boolean"&&(ce.value=t.autoScroll),typeof t.practiceOpen=="boolean"&&(ve.value=t.practiceOpen),typeof t.rate=="number"&&L.setRate(t.rate),(t.subMode==="line"||t.subMode==="sentence")&&(ee.value=t.subMode),pe.value={desktop:Ot(t.subDesktop,"desktop"),mobile:Ot(t.subMobile,"mobile")}}catch{}window.addEventListener("keydown",De),window.addEventListener("resize",Q),a.config().then(t=>{c.value=t.is_gold,ye.value=t.free_custom_video_limit??0,vt.value=t.custom_videos_used??0}).catch(()=>{}),L.setTrackNav(()=>ct(dt.value),()=>ct(_t.value)),await Promise.all([Ge(),Xe(),ut(),Je()])}),Oe(()=>{window.removeEventListener("keydown",De),window.removeEventListener("resize",Q),clearInterval(K)}),Ue([W,ae,ce,ve,L.rate,pe,ee],()=>{localStorage.setItem(Ft,JSON.stringify({showEn:W.value,showVi:ae.value,autoScroll:ce.value,practiceOpen:ve.value,rate:L.rate.value,subMode:ee.value,subDesktop:pe.value.desktop,subMobile:pe.value.mobile}))},{deep:!0}),Ue(h,async t=>{t&&(clearInterval(K),L.activeIndex.value=-1,await Promise.all([Ge(),ut()]))}),(t,r)=>{const A=Yt,Ee=Sn,le=Wn,Qe=kl,He=Va,ht=Ya,Tt=mn,et=xn,tt=kn,nt=Xt;return i(),u("div",Wa,[e("div",qa,[e("div",Ga,[r[14]||(r[14]=e("span",{class:"text-xs text-slate-400"},"hoặc tải video theo link",-1)),e("div",Xa,[Vt(e("input",{"onUpdate:modelValue":r[0]||(r[0]=O=>Ae.value=O),type:"text",placeholder:"Dán link YouTube hoặc video ID rá»i nhấn Enterâ¦",class:"flex-1 h-9 px-3 rounded-lg border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-900 text-sm outline-none focus:border-blue-400 focus:ring-2 focus:ring-blue-100 dar
1k:text-slate-100",onKeydown:qt(pt,["enter"])},null,544),[[Pt,Ae.value]]),e("button",{class:"h-9 px-4 inline-flex items-center gap-1.5 rounded-lg bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium disabled:opacity-50",disabled:ke.value,onClick:pt},[r[13]||(r[13]=e("svg",{class:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor"},[e("path",{d:"M7 5v14l12-7z"})],-1)),V(" "+_(ke.value?"Äang tảiâ¦":"Tải video"),1)],8,Ja)]),s.value&&!c.value&&ye.value?(i(),u("p",Za," Tà i khoản thưá»ng thêm ÄÆ°á»£c tá»i Äa "+_(ye.value)+" link YouTube â Äã dùng "+_(vt.value)+"/"+_(ye.value)+". ",1)):P("",!0)]),C.value?(i(),u("div",Qa,[e("div",{class:I(["w-16 h-16 mx-auto rounded-full grid place-items-center mb-4",C.value==="login"?"bg-blue-50":"bg-amber-100"])},[C.value==="login"?(i(),u("svg",es,[...r[15]||(r[15]=[e("path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4"},null,-1),e("path",{d:"m10 17 5-5-5-5"},null,-1),e("path",{d:"M15 12H3"},null,-1)])])):(i(),u("svg",ts,[...r[16]||(r[16]=[e("path",{d:"M3 7l4 3 5-6 5 6 4-3v10a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V7z"},null,-1)])]))],2),e("h2",ns,_(C.value==="login"?"Vui lòng ÄÄng nháºp":"Yêu cầu tà i khoản Premium"),1),e("p",ls,_(B.value||"Ná»i dung nà y chá» dà nh cho thà nh viên Premium."),1),de(A,{to:C.value==="login"?"/login":"/upgrade",class:I(["inline-flex h-10 px-5 items-center rounded-lg text-white font-semibold",C.value==="login"?"bg-slate-800 hover:bg-slate-900":"bg-amber-500 hover:bg-amber-600"])},{default:Ye(()=>[V(_(C.value==="login"?"ÄÄng nháºp":"Nâng cấp Premium"),1)]),_:1},8,["to","class"]),e("p",as,[de(A,{to:"/shadowing",class:"text-sm text-blue-600 underline"},{default:Ye(()=>[...r[17]||(r[17]=[V("â Vá» danh sách video",-1)])]),_:1})])])):d.value?(i(),u("div",ss,[r[19]||(r[19]=e("div",{class:"w-16 h-16 mx-auto rounded-full bg-amber-100 grid place-items-center mb-4"},[e("svg",{class:"w-8 h-8 text-amber-500",viewBox:"0 0 24 24",fill:"currentColor"},[e("path",{d:"M3 7l4 3 5-6 5 6 4-3v10a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V7z"})])],-1)),r[20]||(r[20]=e("h2",{class:"text-xl font-bold text-slate-800 dark:text-white mb-2"},"Äã hết lượt luyá»n hôm nay",-1)),e("p",os,_(d.value),1),de(A,{to:"/upgrade",class:"inline-flex h-10 px-5 items-center rounded-lg bg-amber-500 hover:bg-amber-600 text-white font-semibold"},{default:Ye(()=>[...r[18]||(r[18]=[V("Nâng cấp VIP â há»c không giá»i hạn",-1)])]),_:1})])):y.value?(i(),u("div",rs,[...r[21]||(r[21]=[e("div",{class:"w-9 h-9 border-[3px] border-slate-200 border-t-blue-500 rounded-full animate-spin"},null,-1)])])):(i(),u("div",{key:3,class:I(["grid gap-4",oe.value?"grid-cols-1":"lg:grid-cols-[minmax(0,1fr)_480px] xl:grid-cols-[minmax(0,1fr)_552px]"])},[e("div",is,[de(Ee,{"video-id":h.value,ctrl:J(L)},null,8,["video-id","ctrl"]),ue.value?(i(),u("div",{key:0,class:I(["relative rounded-xl border border-blue-200 dark:border-blue-500/40 px-10 py-3 text-center flex flex-col justify-center",me.value?"":"bg-blue-50 dark:bg-blue-500/10"]),style:Ve({minHeight:p.value,background:me.value})},[de(hn,{name:"sub",mode:"out-in"},{default:Ye(()=>[(i(),u("div",{key:w.value?.en||"",class:"mx-auto max-w-[54ch]"},[W.value&&w.value?(i(),u("p",{key:0,class:I(["leading-snug",H.value.enColor?"":"text-slate-900 dark:text-white"]),style:Ve(J(Nt)(H.value,"en"))},_(w.value.en),7)):P("",!0),ae.value&&w.value?.vi?(i(),u("p",{key:1,class:I(["leading-snug mt-1",H.value.viColor?"":"text-blue-800 dark:text-blue-300"]),style:Ve(J(Nt)(H.value,"vi"))},_(w.value.vi),7)):P("",!0)]))]),_:1}),e("button",{class:"absolute top-2.5 right-3",title:Ce.value?"Bá» gắn sao (S)":"Gắn sao câu nà y (S)",onClick:r[1]||(r[1]=O=>Ze(ue.value))},[(i(),u("svg",{class:I(["w-5 h-5 transition-colors",Ce.value?"text-amber-400":"text-slate-300 hover:text-amber-400"]),viewBox:"0 0 24 24",fill:Ce.value?"currentColor":"none",stroke:"currentColor","stroke-width":"1.6"},[...r[22]||(r[22]=[e("path",{d:"m12 3 2.6 5.3 5.9.9-4.2 4.1 1 5.8-5.3-2.8-5.3 2.8 1-5.8L3.5 9.2l5.9-.9L12 3z","stroke-linejoin":"round"},null,-1)])],10,ds))],8,us)],6)):q.value==="ready"?(i(),u("div",cs," Bấm â¶ Äá» bắt Äầu, hoặc chá»n má»t câu trong bảng phụ Äá» bên phải. ")):P("",!0),de(Qe,{"show-en":W.value,"onUpdate:showEn":r[4]||(r[4]=O=>W.value=O),"show-vi":ae.value,"onUpdate:showVi":r[5]||(r[5]=O=>ae.value=O),"practice-open":ve.value,"onUpdate:practiceOpen":r[6]||(r[6]=O=>ve.value=O),"auto-scroll":ce.value,"onUpdate:autoScroll":r[7]||(r[7]=O=>ce.value=O),theater:oe.value,"onUpdate:theater":r[8]||(r[8]=O=>oe.value=O),ctrl:J(L),onShuffle:r[9]||(r[9]=O=>Pe.value?.randomVideo?.()),onReplay:Y,onPrev:fe,onNext:xe},{"chips-end":Ye(()=>[de(le,{modelValue:H.value,"onUpdate:modelValue":r[2]||(r[2]=O=>H.value=O),mode:ee.value,"onUpdate:mode":r[3]||(r[3]=O=>ee.value=O),defaults:ie.value},null,8,["modelValue","mode","defaults"])]),_:1},8,["show-en","show-vi","practice-open","auto-scroll","theater","ctrl"]),ve.value?(i(),fn(He,{key:2,ref_key:"practiceRef",ref:Le,segment:F.value,"youtube-id":h.value,"logged-in":s.value,"show-vi":ae.value,onNext:xe,onReplay:Y,onStartFirst:ge,onScored:Be},null,8,["segment","youtube-id","logged-in","show-vi"])):P("",!0),Te.value&&te.value!==null?(i(),u("p",{key:3,class:I(["flex items-start gap-1.5 px-1 text-[11px] leading-relaxed",te.value?"text-emerald-600":"text-slate-400"])},[(i(),u("svg",vs,[te.value?(i(),u("path",ps)):P("",!0),te.value?(i(),u("circle",hs)):P("",!0),te.value?(i(),u("circle",fs)):(i(),u(se,{key:3},[r[23]||(r[23]=e("circle",{cx:"12",cy:"12",r:"9"},null,-1)),r[24]||(r[24]=e("path",{d:"M12 8v4M12 16h.01"},null,-1))],64))])),te.value?(i(),u("span",gs,"Tắt mà n hình hoặc chuyá»n sang app khác vẫn nghe tiếp ÄÆ°á»£c â dùng thẻ nhạc á» mà n hình khoá Äá» phát/dừng.")):(i(),u("span",bs,"Video nà y chưa tách ÄÆ°á»£c luá»ng âm thanh riêng, nên tắt mà n hình có thá» bá» ngắt tiếng."))],2)):P("",!0),r[26]||(r[26]=st('<div class="flex flex-wrap gap-x-3 gap-y-1 text-[11px] text-slate-400 px-1" data-v-e8779913><span data-v-e8779913><kbd class="sh-kbd" data-v-e8779913>Space</kbd> Phát/Dừng</span><span data-v-e8779913><kbd class="sh-kbd" data-v-e8779913>â</kbd> Câu trưá»c</span><span data-v-e8779913><kbd class="sh-kbd" data-v-e8779913>â</kbd> Câu sau</span><span data-v-e8779913><kbd class="sh-kbd" data-v-e8779913>â</kbd> Lặp câu</span><span data-v-e8779913><kbd class="sh-kbd" data-v-e8779913>Enter</kbd>
1 Nghe lại</span><span data-v-e8779913><kbd class="sh-kbd" data-v-e8779913>R</kbd> Thu âm</span><span data-v-e8779913><kbd class="sh-kbd" data-v-e8779913>M</kbd> Tắt tiếng</span><span data-v-e8779913><kbd class="sh-kbd" data-v-e8779913>Shift</kbd>+<kbd class="sh-kbd" data-v-e8779913>â/â</kbd> Äá»i tá»c Äá»</span></div>',1)),e("div",ms,[T.value?.total?(i(),u(se,{key:0},[r[25]||(r[25]=e("svg",{class:"w-4 h-4 text-slate-400 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[e("rect",{x:"2",y:"7",width:"20",height:"14",rx:"2"}),e("path",{d:"m7 7 5-4 5 4","stroke-linecap":"round"})],-1)),e("span",xs,_(T.value.source.title),1),e("span",ks,_(T.value.index)+" / "+_(T.value.total),1),e("div",ys,[e("button",{class:"sh-nav",disabled:!T.value.prev,onClick:r[10]||(r[10]=O=>J(b).push(`/shadowing/${T.value.prev}?src=${m.value}`))},"â¹ Trưá»c",8,ws),e("button",{class:"sh-nav",disabled:!T.value.next,onClick:r[11]||(r[11]=O=>J(b).push(`/shadowing/${T.value.next}?src=${m.value}`))},"Tiếp âº",8,Cs)])],64)):P("",!0),k.value.length?(i(),u("div",Ss,[e("span",_s," Äã luyá»n "+_(G.value.size)+"/"+_(k.value.length)+" câu ",1),e("div",$s,[e("div",{class:"h-full bg-emerald-500 rounded-full transition-all",style:Ve({width:`${E.value}%`})},null,4)])])):P("",!0)])]),oe.value?P("",!0):(i(),u("div",Ms,[de(ht,{segments:M.value,"active-index":J(L).activeIndex.value,starred:N.value,"show-en":W.value,"show-vi":ae.value,"translate-status":U.value,status:q.value,"auto-scroll":ce.value,onSeek:je,onStar:Ze,onLookup:Mt},null,8,["segments","active-index","starred","show-en","show-vi","translate-status","status","auto-scroll"])]))],2)),!d.value&&!C.value&&!y.value?(i(),u("div",Ts,[de(Tt,{stars:Z.value,"current-video-id":h.value,onJump:Re,onRemove:$t},null,8,["stars","current-video-id"])])):P("",!0),y.value?P("",!0):(i(),u("div",Bs,[de(et,{ref_key:"exploreRef",ref:Pe,"current-video-id":h.value,"is-gold":c.value,"logged-in":s.value},null,8,["current-video-id","is-gold","logged-in"])]))]),de(tt,{playing:J(L).playing.value,"youtube-id":h.value,title:$.value?.title,thumbnail:$.value?.thumbnail_url,position:J(L).currentTime.value,"logged-in":s.value},null,8,["playing","youtube-id","title","thumbnail","position","logged-in"]),de(nt,{variant:$e.value,message:ze.value,onClose:r[12]||(r[12]=O=>$e.value=null)},null,8,["variant","message"])])}}}),Ds=rt(Es,[["__scopeId","data-v-e8779913"]]);export{Ds as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.