From deedea1e71dfb09b8c1634c5ca4ac35f806a7903 Mon Sep 17 00:00:00 2001 From: SashaXser <24498484+SashaXser@users.noreply.github.com> Date: Sun, 26 Jan 2025 15:09:14 +0400 Subject: [PATCH 1/2] fix: improve subtitle fetching and text cleaning logic --- dist/vot-min.user.js | 12 +-- dist/vot.user.js | 195 +++++++++++++++++++------------------------ src/index.js | 141 ++++++++++++++++--------------- src/subtitles.js | 12 +-- src/utils/utils.js | 44 ++++------ 5 files changed, 181 insertions(+), 223 deletions(-) diff --git a/dist/vot-min.user.js b/dist/vot-min.user.js index cd5fe03..104ed53 100644 --- a/dist/vot-min.user.js +++ b/dist/vot-min.user.js @@ -222,7 +222,7 @@ // ==/UserScript== /*! For license information please see vot-min.user.js.LICENSE.txt */ -(()=>{var t={"./src/styles/main.scss":()=>{GM_addStyle('.vot-button{--vot-helper-theme:var(--vot-theme-rgb,var(--vot-primary-rgb,33,150,243));--vot-helper-ontheme:var(--vot-ontheme-rgb,var(--vot-onprimary-rgb,255,255,255));box-sizing:border-box;vertical-align:middle;text-align:center;text-overflow:ellipsis;min-width:64px;height:36px;color:rgb(var(--vot-helper-ontheme));background-color:rgb(var(--vot-helper-theme));font-family:var(--vot-font-family,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system);cursor:pointer;border:none;border-radius:4px;outline:none;padding:0 16px;font-size:14px;font-weight:500;line-height:36px;transition:box-shadow .2s;display:inline-block;position:relative;box-shadow:0 3px 1px -2px rgba(0,0,0,.2),0 2px 2px rgba(0,0,0,.14),0 1px 5px rgba(0,0,0,.12)}.vot-button[hidden]{display:none!important}.vot-button::-moz-focus-inner{border:none}.vot-button:before,.vot-button:after{content:"";border-radius:inherit;opacity:0;position:absolute;top:0;bottom:0;left:0;right:0}.vot-button:before{background-color:rgb(var(--vot-helper-ontheme));transition:opacity .2s}.vot-button:after{background:radial-gradient(circle,currentColor 1%,transparent 1%) 50%/10000% 10000% no-repeat;transition:opacity 1s,background-size .5s}.vot-button:hover{box-shadow:0 2px 4px -1px rgba(0,0,0,.2),0 4px 5px rgba(0,0,0,.14),0 1px 10px rgba(0,0,0,.12)}.vot-button:hover:before{opacity:.08}.vot-button:active{box-shadow:0 5px 5px -3px rgba(0,0,0,.2),0 8px 10px 1px rgba(0,0,0,.14),0 3px 14px 2px rgba(0,0,0,.12)}.vot-button:active:after{opacity:.32;background-size:100% 100%;transition:background-size}.vot-button[disabled=true]{background-color:rgba(var(--vot-onsurface-rgb,0,0,0),.12);color:rgba(var(--vot-onsurface-rgb,0,0,0),.38);box-shadow:none;cursor:initial}.vot-button[disabled=true]:before{opacity:0}.vot-button[disabled=true]:after{opacity:0}.vot-outlined-button{--vot-helper-theme:var(--vot-theme-rgb,var(--vot-primary-rgb,33,150,243));box-sizing:border-box;border:1px solid;border-color:rgba(var(--vot-onsurface-rgb,0,0,0),.24);vertical-align:middle;text-align:center;text-overflow:ellipsis;min-width:64px;height:36px;color:rgb(var(--vot-helper-theme));font-family:var(--vot-font-family,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system);cursor:pointer;background-color:transparent;border-radius:4px;outline:none;margin:0;padding:0 16px;font-size:14px;font-weight:500;line-height:34px;display:inline-block;position:relative}.vot-outlined-button[hidden]{display:none!important}.vot-outlined-button::-moz-focus-inner{border:none}.vot-outlined-button:before,.vot-outlined-button:after{content:"";opacity:0;border-radius:3px;position:absolute;top:0;bottom:0;left:0;right:0}.vot-outlined-button:before{background-color:rgb(var(--vot-helper-theme));transition:opacity .2s}.vot-outlined-button:after{background:radial-gradient(circle,currentColor 1%,transparent 1%) 50%/10000% 10000% no-repeat;transition:opacity 1s,background-size .5s}.vot-outlined-button:hover:before{opacity:.04}.vot-outlined-button:active:after{opacity:.16;background-size:100% 100%;transition:background-size}.vot-outlined-button[disabled=true]{color:rgba(var(--vot-onsurface-rgb,0,0,0),.38);cursor:initial;background-color:transparent}.vot-outlined-button[disabled=true]:before{opacity:0}.vot-outlined-button[disabled=true]:after{opacity:0}.vot-text-button{--vot-helper-theme:var(--vot-theme-rgb,var(--vot-primary-rgb,33,150,243));box-sizing:border-box;vertical-align:middle;text-align:center;text-overflow:ellipsis;min-width:64px;height:36px;color:rgb(var(--vot-helper-theme));font-family:var(--vot-font-family,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system);cursor:pointer;background-color:transparent;border:none;border-radius:4px;outline:none;margin:0;padding:0 8px;font-size:14px;font-weight:500;line-height:36px;display:inline-block;position:relative}.vot-text-button[hidden]{display:none!important}.vot-text-button::-moz-focus-inner{border:none}.vot-text-button:before,.vot-text-button:after{content:"";border-radius:inherit;opacity:0;position:absolute;top:0;bottom:0;left:0;right:0}.vot-text-button:before{background-color:rgb(var(--vot-helper-theme));transition:opacity .2s}.vot-text-button:after{background:radial-gradient(circle,currentColor 1%,transparent 1%) 50%/10000% 10000% no-repeat;transition:opacity 1s,background-size .5s}.vot-text-button:hover:before{opacity:.04}.vot-text-button:active:after{opacity:.16;background-size:100% 100%;transition:background-size}.vot-text-button[disabled=true]{color:rgba(var(--vot-onsurface-rgb,0,0,0),.38);cursor:initial;background-color:transparent}.vot-text-button[disabled=true]:before{opacity:0}.vot-text-button[disabled=true]:after{opacity:0}.vot-icon-button{--vot-helper-onsurface:rgba(var(--vot-onsurface-rgb,0,0,0),.87);box-sizing:border-box;vertical-align:middle;text-align:center;text-overflow:ellipsis;width:36px;height:36px;fill:var(--vot-helper-onsurface);color:var(--vot-helper-onsurface);font-family:var(--vot-font-family,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system);cursor:pointer;background-color:transparent;border:none;border-radius:50%;outline:none;margin:0;padding:0;font-size:14px;font-weight:500;line-height:36px;display:inline-block;position:relative}.vot-icon-button[hidden]{display:none!important}.vot-icon-button::-moz-focus-inner{border:none}.vot-icon-button:before,.vot-icon-button:after{content:"";border-radius:inherit;opacity:0;position:absolute;top:0;bottom:0;left:0;right:0}.vot-icon-button:before{background-color:var(--vot-helper-onsurface);transition:opacity .2s}.vot-icon-button:after{background:radial-gradient(circle,currentColor 1%,transparent 1%) 50%/10000% 10000% no-repeat;transition:opacity .3s,background-size .4s}.vot-icon-button:hover:before{opacity:.04}.vot-icon-button:active:after{opacity:.32;background-size:100% 100%;transition:background-size,opacity}.vot-icon-button[disabled=true]{color:rgba(var(--vot-onsurface-rgb,0,0,0),.38);fill:rgba(var(--vot-onsurface-rgb,0,0,0),.38);cursor:initial;background-color:transparent}.vot-icon-button[disabled=true]:before{opacity:0}.vot-icon-button[disabled=true]:after{opacity:0}.vot-textfield{display:inline-block;--vot-helper-theme:rgb(var(--vot-theme-rgb,var(--vot-primary-rgb,33,150,243)))!important;--vot-helper-safari1:rgba(var(--vot-onsurface-rgb,0,0,0),.38)!important;--vot-helper-safari2:rgba(var(--vot-onsurface-rgb,0,0,0),.6)!important;--vot-helper-safari3:rgba(var(--vot-onsurface-rgb,0,0,0),.87)!important;font-family:var(--vot-font-family,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system)!important;text-align:start!important;padding-top:6px!important;font-size:16px!important;line-height:1.5!important;position:relative!important}.vot-textfield[hidden]{display:none!important}.vot-textfield>input,.vot-textfield>textarea{box-sizing:border-box!important;border-style:solid!important;border-width:1px!important;border-color:transparent var(--vot-helper-safari2)var(--vot-helper-safari2)!important;width:100%!important;height:inherit!important;color:rgba(var(--vot-onsurface-rgb,0,0,0),.87)!important;-webkit-text-fill-color:currentColor!important;font-family:inherit!important;font-size:inherit!important;line-height:inherit!important;caret-color:var(--vot-helper-theme)!important;background-color:transparent!important;border-radius:4px!important;margin:0!important;padding:15px 13px!important;transition:border .2s,box-shadow .2s!important;box-shadow:inset 1px 0 transparent,inset -1px 0 transparent,inset 0 -1px transparent!important}.vot-textfield>input:not(:focus):not(.vot-show-placeholer)::-moz-placeholder{color:transparent!important}.vot-textfield>textarea:not(:focus):not(.vot-show-placeholer)::-moz-placeholder{color:transparent!important}.vot-textfield>input:not(:focus):not(.vot-show-placeholer)::-moz-placeholder{color:transparent!important}.vot-textfield>textarea:not(:focus):not(.vot-show-placeholer)::-moz-placeholder{color:transparent!important}.vot-textfield>input:not(:focus):not(.vot-show-placeholer)::-webkit-input-placeholder{color:transparent!important}.vot-textfield>textarea:not(:focus):not(.vot-show-placeholer)::-webkit-input-placeholder{color:transparent!important}.vot-textfield>input:not(:focus):placeholder-shown{border-top-color:var(--vot-helper-safari2)!important}.vot-textfield>textarea:not(:focus):placeholder-shown{border-top-color:var(--vot-helper-safari2)!important}.vot-textfield>input+span,.vot-textfield>textarea+span{font-family:inherit;width:100%!important;max-height:100%!important;color:rgba(var(--vot-onsurface-rgb,0,0,0),.6)!important;cursor:text!important;pointer-events:none!important;font-size:75%!important;line-height:15px!important;transition:color .2s,font-size .2s,line-height .2s!important;display:flex!important;position:absolute!important;top:0!important;left:0!important}.vot-textfield>input:not(:focus):placeholder-shown+span{font-size:inherit!important;line-height:68px!important}.vot-textfield>textarea:not(:focus):placeholder-shown+span{font-size:inherit!important;line-height:68px!important}.vot-textfield>input+span:before,.vot-textfield>input+span:after,.vot-textfield>textarea+span:before,.vot-textfield>textarea+span:after{content:""!important;box-sizing:border-box!important;border-top:solid 1px var(--vot-helper-safari2)!important;pointer-events:none!important;min-width:10px!important;height:8px!important;margin-top:6px!important;transition:border .2s,box-shadow .2s!important;display:block!important;box-shadow:inset 0 1px transparent!important}.vot-textfield>input+span:before,.vot-textfield>textarea+span:before{border-left:1px solid transparent!important;border-radius:4px 0!important;margin-right:4px!important}.vot-textfield>input+span:after,.vot-textfield>textarea+span:after{border-right:1px solid transparent!important;border-radius:0 4px!important;flex-grow:1!important;margin-left:4px!important}.vot-textfield>input.vot-show-placeholer+span:before,.vot-textfield>textarea.vot-show-placeholer+span:before{margin-right:0!important}.vot-textfield>input.vot-show-placeholer+span:after,.vot-textfield>textarea.vot-show-placeholer+span:after{margin-left:0!important}.vot-textfield>input:not(:focus):placeholder-shown+span:before{border-top-color:transparent!important}.vot-textfield>input:not(:focus):placeholder-shown+span:after{border-top-color:transparent!important}.vot-textfield>textarea:not(:focus):placeholder-shown+span:before{border-top-color:transparent!important}.vot-textfield>textarea:not(:focus):placeholder-shown+span:after{border-top-color:transparent!important}.vot-textfield:hover>input:not(:disabled),.vot-textfield:hover>textarea:not(:disabled){border-color:transparent var(--vot-helper-safari3)var(--vot-helper-safari3)!important}.vot-textfield:hover>input:not(:disabled)+span:before,.vot-textfield:hover>input:not(:disabled)+span:after,.vot-textfield:hover>textarea:not(:disabled)+span:before,.vot-textfield:hover>textarea:not(:disabled)+span:after{border-top-color:var(--vot-helper-safari3)!important}.vot-textfield:hover>input:not(:disabled):not(:focus):placeholder-shown{border-color:var(--vot-helper-safari3)!important}.vot-textfield:hover>textarea:not(:disabled):not(:focus):placeholder-shown{border-color:var(--vot-helper-safari3)!important}.vot-textfield>input:focus,.vot-textfield>textarea:focus{border-color:transparent var(--vot-helper-theme)var(--vot-helper-theme)!important;box-shadow:inset 1px 0 var(--vot-helper-theme),inset -1px 0 var(--vot-helper-theme),inset 0 -1px var(--vot-helper-theme)!important;outline:none!important}.vot-textfield>input:focus+span,.vot-textfield>textarea:focus+span{color:var(--vot-helper-theme)!important}.vot-textfield>input:focus+span:before,.vot-textfield>input:focus+span:after,.vot-textfield>textarea:focus+span:before,.vot-textfield>textarea:focus+span:after{border-top-color:var(--vot-helper-theme)!important;box-shadow:inset 0 1px var(--vot-helper-theme)!important}.vot-textfield>input:disabled,.vot-textfield>input:disabled+span,.vot-textfield>textarea:disabled,.vot-textfield>textarea:disabled+span{border-color:transparent var(--vot-helper-safari1)var(--vot-helper-safari1)!important;color:rgba(var(--vot-onsurface-rgb,0,0,0),.38)!important;pointer-events:none!important}.vot-textfield>input:disabled+span:before,.vot-textfield>input:disabled+span:after,.vot-textfield>textarea:disabled+span:before,.vot-textfield>textarea:disabled+span:after{border-top-color:var(--vot-helper-safari1)!important}.vot-textfield>input:disabled:placeholder-shown{border-top-color:var(--vot-helper-safari1)!important}.vot-textfield>input:disabled:placeholder-shown+span{border-top-color:var(--vot-helper-safari1)!important}.vot-textfield>textarea:disabled:placeholder-shown{border-top-color:var(--vot-helper-safari1)!important}.vot-textfield>textarea:disabled:placeholder-shown+span{border-top-color:var(--vot-helper-safari1)!important}.vot-textfield>input:disabled:placeholder-shown+span:before{border-top-color:transparent!important}.vot-textfield>input:disabled:placeholder-shown+span:after{border-top-color:transparent!important}.vot-textfield>textarea:disabled:placeholder-shown+span:before{border-top-color:transparent!important}.vot-textfield>textarea:disabled:placeholder-shown+span:after{border-top-color:transparent!important}@media not all and (-webkit-min-device-pixel-ratio:.0000264583),not all and (min-resolution:.001dpcm){@supports ((-webkit-appearance:none)){.vot-textfield>input,.vot-textfield>input+span,.vot-textfield>textarea,.vot-textfield>textarea+span,.vot-textfield>input+span:before,.vot-textfield>input+span:after,.vot-textfield>textarea+span:before,.vot-textfield>textarea+span:after{transition-duration:.1s!important}}}.vot-checkbox{--vot-helper-theme:var(--vot-theme-rgb,var(--vot-primary-rgb,33,150,243));--vot-helper-ontheme:var(--vot-ontheme-rgb,var(--vot-onprimary-rgb,255,255,255));z-index:0;color:rgba(var(--vot-onsurface-rgb,0,0,0),.87);font-family:var(--vot-font-family,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system);text-align:start;font-size:16px;line-height:1.5;display:inline-block;position:relative}.vot-checkbox-sub{padding-left:16px}.vot-checkbox[hidden]{display:none!important}.vot-checkbox>input{-webkit-appearance:none;appearance:none;z-index:10000;box-sizing:border-box;border:2px solid;border-color:rgba(var(--vot-onsurface-rgb,0,0,0),.6);cursor:pointer;background:0 0;border-radius:2px;outline:none;width:18px;height:18px;margin:3px 1px;padding:0;transition:border-color .2s,background-color .2s;display:block;position:absolute}.vot-checkbox>input+span{box-sizing:border-box;width:inherit;cursor:pointer;padding-left:30px;font-family:inherit;font-weight:400;display:inline-block;position:relative}.vot-checkbox>input+span:before{content:"";background-color:rgb(var(--vot-onsurface-rgb,0,0,0));opacity:0;pointer-events:none;border-radius:50%;width:40px;height:40px;transition:opacity .3s,transform .2s;display:block;position:absolute;top:-8px;left:-10px;transform:scale(1)}.vot-checkbox>input+span:after{content:"";z-index:10000;pointer-events:none;border:0 solid transparent;border-width:0 0 2px 2px;width:10px;height:5px;transition:border-color .2s;display:block;position:absolute;top:3px;left:1px;transform:translate(3px,4px)rotate(-45deg);box-sizing:content-box!important}.vot-checkbox>input:checked{border-color:rgb(var(--vot-helper-theme));background-color:rgb(var(--vot-helper-theme))}.vot-checkbox>input:indeterminate{border-color:rgb(var(--vot-helper-theme));background-color:rgb(var(--vot-helper-theme))}.vot-checkbox>input:checked+span:before{background-color:rgb(var(--vot-helper-theme))}.vot-checkbox>input:indeterminate+span:before{background-color:rgb(var(--vot-helper-theme))}.vot-checkbox>input:checked+span:after{border-color:rgb(var(--vot-helper-ontheme,255,255,255))}.vot-checkbox>input:indeterminate+span:after{border-color:rgb(var(--vot-helper-ontheme,255,255,255))}.vot-checkbox>input:indeterminate+span:after{border-left-width:0;transform:translate(4px,3px)}.vot-checkbox:hover>input+span:before{opacity:.04}.vot-checkbox:active>input,.vot-checkbox:active:hover>input:not(:disabled){border-color:rgb(var(--vot-helper-theme))}.vot-checkbox:active>input:checked{background-color:rgba(var(--vot-onsurface-rgb,0,0,0),.6);border-color:transparent}.vot-checkbox:active>input+span:before{opacity:1;transition:transform,opacity;transform:scale(0)}.vot-checkbox>input:disabled{border-color:rgba(var(--vot-onsurface-rgb,0,0,0),.38);cursor:initial}.vot-checkbox>input:disabled:checked{background-color:rgba(var(--vot-onsurface-rgb,0,0,0),.38);border-color:transparent}.vot-checkbox>input:disabled:indeterminate{background-color:rgba(var(--vot-onsurface-rgb,0,0,0),.38);border-color:transparent}.vot-checkbox>input:disabled+span{color:rgba(var(--vot-onsurface-rgb,0,0,0),.38);cursor:initial}.vot-checkbox>input:disabled+span:before{opacity:0;transform:scale(0)}.vot-slider{display:inline-block;--vot-safari-helper1:rgba(var(--vot-primary-rgb,33,150,243),.04)!important;--vot-safari-helper2:rgba(var(--vot-primary-rgb,33,150,243),.12)!important;--vot-safari-helper3:rgba(var(--vot-primary-rgb,33,150,243),.16)!important;--vot-safari-helper4:rgba(var(--vot-primary-rgb,33,150,243),.24)!important;width:100%!important;color:rgba(var(--vot-onsurface-rgb,0,0,0),.87)!important;font-family:var(--vot-font,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system)!important;text-align:start!important;font-size:16px!important;line-height:1.5!important}.vot-slider[hidden]{display:none!important}.vot-slider>input{-webkit-appearance:none!important;appearance:none!important;cursor:pointer!important;background-color:transparent!important;border:none!important;width:100%!important;height:36px!important;margin:0 0 -36px!important;padding:0!important;display:block!important;position:relative!important;top:24px!important}.vot-slider>input:last-child{margin:0!important;position:static!important}.vot-slider>input:before{content:""!important;width:calc(100%*var(--vot-progress,0))!important;background:rgb(var(--vot-primary-rgb,33,150,243))!important;height:2px!important;display:block!important;position:absolute!important;top:calc(50% - 1px)!important}.vot-slider>input:disabled{cursor:default!important;opacity:.38!important}.vot-slider>input:disabled+span{color:rgba(var(--vot-onsurface-rgb,0,0,0),.38)!important}.vot-slider>input:disabled::-webkit-slider-runnable-track{background-color:rgba(var(--vot-onsurface-rgb,0,0,0),.38)!important}.vot-slider>input:disabled::-moz-range-track{background-color:rgba(var(--vot-onsurface-rgb,0,0,0),.38)!important}.vot-slider>input:disabled::-ms-fill-lower{background-color:rgba(var(--vot-onsurface-rgb,0,0,0),.38)!important}.vot-slider>input:disabled::-ms-fill-upper{background-color:rgba(var(--vot-onsurface-rgb,0,0,0),.38)!important}.vot-slider>input:disabled::-moz-range-thumb{background-color:rgb(var(--vot-onsurface-rgb,0,0,0))!important;box-shadow:0 0 0 1px rgb(var(--vot-surface-rgb,255,255,255))!important;transform:scale(4)!important}.vot-slider>input:disabled::-ms-thumb{background-color:rgb(var(--vot-onsurface-rgb,0,0,0))!important;box-shadow:0 0 0 1px rgb(var(--vot-surface-rgb,255,255,255))!important;transform:scale(4)!important}.vot-slider>input:disabled::-webkit-slider-thumb{background-color:rgb(var(--vot-onsurface-rgb,0,0,0))!important;box-shadow:0 0 0 1px rgb(var(--vot-surface-rgb,255,255,255))!important;transform:scale(4)!important}.vot-slider>input:disabled::-ms-fill-upper{opacity:.38!important}.vot-slider>input:disabled::-moz-range-progress{background-color:rgba(var(--vot-onsurface-rgb,0,0,0),.87)!important}.vot-slider>input:disabled:-webkit-slider-thumb{color:rgb(var(--vot-surface-rgb,255,255,255))!important}.vot-slider>input:active::-webkit-slider-thumb{box-shadow:0 0 0 2px var(--vot-safari-helper4)!important}.vot-slider>input:active::-moz-range-thumb{box-shadow:0 0 0 2px rgba(var(--vot-primary-rgb,33,150,243),.24)!important}.vot-slider>input:active::-ms-thumb{box-shadow:0 0 0 2px rgba(var(--vot-primary-rgb,33,150,243),.24)!important}.vot-slider>input:focus{outline:none!important}.vot-slider>input::-webkit-slider-runnable-track{background-color:rgba(var(--vot-primary-rgb,33,150,243),.24)!important;border-radius:1px!important;width:100%!important;height:2px!important;margin:17px 0!important}.vot-slider>input::-moz-range-track{background-color:rgba(var(--vot-primary-rgb,33,150,243),.24)!important;border-radius:1px!important;width:100%!important;height:2px!important;margin:17px 0!important}.vot-slider>input::-ms-track{box-sizing:border-box!important;background-color:transparent!important;border:none!important;border-radius:1px!important;width:100%!important;height:2px!important;margin:17px 0!important;padding:0 17px!important}.vot-slider>input::-webkit-slider-thumb{-webkit-appearance:none!important;appearance:none!important;background-color:rgb(var(--vot-primary-rgb,33,150,243))!important;border:none!important;border-radius:50%!important;width:2px!important;height:2px!important;transition:box-shadow .2s!important;transform:scale(6)!important}.vot-slider>input::-moz-range-thumb{-webkit-appearance:none!important;appearance:none!important;background-color:rgb(var(--vot-primary-rgb,33,150,243))!important;border:none!important;border-radius:50%!important;width:2px!important;height:2px!important;transition:box-shadow .2s!important;transform:scale(6)!important}.vot-slider>input::-ms-thumb{-webkit-appearance:none!important;appearance:none!important;background-color:rgb(var(--vot-primary-rgb,33,150,243))!important;border:none!important;border-radius:50%!important;width:2px!important;height:2px!important;transition:box-shadow .2s!important;transform:scale(6)!important}.vot-slider>input::-webkit-slider-thumb{-webkit-appearance:none!important;margin:0!important}.vot-slider>input::-moz-range-thumb{-moz-appearance:none!important}.vot-slider>input::-ms-thumb{margin:0 17px!important}.vot-slider>input::-moz-range-progress{background-color:rgb(var(--vot-primary-rgb,33,150,243))!important;border-radius:1px!important;height:2px!important}.vot-slider>input::-ms-fill-lower{background-color:rgb(var(--vot-primary-rgb,33,150,243))!important;border-radius:1px!important;height:2px!important}.vot-slider>input::-ms-fill-upper{background-color:rgb(var(--vot-primary-rgb,33,150,243))!important;border-radius:1px!important;height:2px!important}.vot-slider>input::-moz-focus-outer{border:none!important}.vot-slider>span{margin-bottom:36px!important;display:inline-block!important}.vot-slider:hover>input::-webkit-slider-thumb{box-shadow:0 0 0 2px var(--vot-safari-helper1)!important}.vot-slider:hover>input::-ms-thumb{box-shadow:0 0 0 2px rgba(var(--vot-primary-rgb,33,150,243),.04)!important}.vot-slider:hover>input:hover::-moz-range-thumb{box-shadow:0 0 0 2px rgba(var(--vot-primary-rgb,33,150,243),.04)!important}.vot-select{font-family:var(--vot-font-family,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system);text-align:start;color:var(--vot-helper-theme);fill:var(--vot-helper-theme);justify-content:space-between;align-items:center;font-size:14px;font-weight:400;line-height:1.5;display:flex;--vot-helper-theme-rgb:var(--vot-onsurface-rgb,0,0,0)!important;--vot-helper-theme:rgba(var(--vot-helper-theme-rgb),.87)!important;--vot-helper-safari1:rgba(var(--vot-onsurface-rgb,0,0,0),.6)!important;--vot-helper-safari2:rgba(var(--vot-onsurface-rgb,0,0,0),.87)!important}.vot-select[hidden]{display:none!important}.vot-select-label{font-family:inherit;font-size:16px}.vot-select-outer{cursor:pointer;justify-content:space-between;align-items:center;width:120px;max-width:120px;padding:0 5px;display:flex;border-style:solid!important;border-width:1px!important;border-color:var(--vot-helper-safari1)!important;border-radius:4px!important;transition:border .2s!important}.vot-select-outer:hover{border-color:var(--vot-helper-safari2)!important}.vot-select-title{text-overflow:ellipsis;white-space:nowrap;font-family:inherit;overflow:hidden}.vot-select-arrow-icon{justify-content:center;align-items:center;width:20px;height:32px;display:flex}.vot-select-content-list{flex-direction:column;display:flex}.vot-select-content-list .vot-select-content-item{cursor:pointer;border-radius:8px;padding:5px 10px}.vot-select-content-list .vot-select-content-item:not([inert]):hover{background-color:#2a2c31}.vot-select-content-list .vot-select-content-item[data-vot-selected=true]{color:rgb(var(--vot-primary-rgb,33,150,243));background-color:rgba(var(--vot-primary-rgb,33,150,243),.2)}.vot-select-content-list .vot-select-content-item[data-vot-selected=true]:hover{background-color:rgba(var(--vot-primary-rgb,33,150,243),.1)!important}.vot-select-content-list .vot-select-content-item[data-vot-disabled=true]{cursor:default}.vot-select-content-list .vot-select-content-item[hidden]{display:none!important}.vot-header{color:rgba(var(--vot-helper-onsurface-rgb),.87);font-family:var(--vot-font-family,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system);text-align:start;font-weight:700;line-height:1.5}.vot-header[hidden]{display:none!important}.vot-header:not(:first-child){padding-top:8px}.vot-header-level-1{font-size:2em}.vot-header-level-2{font-size:1.5em}.vot-header-level-3{font-size:1.17em}.vot-header-level-4{font-size:1em}.vot-header-level-5{font-size:.83em}.vot-header-level-6{font-size:.67em}.vot-info{color:rgba(var(--vot-helper-onsurface-rgb),.87);font-family:var(--vot-font-family,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system);text-align:start;-webkit-user-select:text;user-select:text;font-size:16px;line-height:1.5;display:flex}.vot-info[hidden]{display:none!important}.vot-info>:not(:first-child){color:rgba(var(--vot-helper-onsurface-rgb),.5);flex:1;margin-left:8px}.vot-details{color:rgba(var(--vot-helper-onsurface-rgb),.87);font-family:var(--vot-font-family,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system);text-align:start;cursor:pointer;border-radius:.5em;justify-content:space-between;align-items:center;margin:0 -.5em;padding:.5em;font-size:16px;line-height:1.5;transition:background .5s;display:flex}.vot-details[hidden]{display:none!important}.vot-details-arrow-icon{width:20px;height:32px;fill:rgba(var(--vot-helper-onsurface-rgb),.87);justify-content:center;align-items:center;display:flex;transform:scale(1.25)rotate(-90deg)}.vot-details:hover{background:rgba(var(--vot-onsurface-rgb,0,0,0),.04)}.vot-lang-select{--vot-helper-theme-rgb:var(--vot-onsurface-rgb,0,0,0);--vot-helper-theme:rgba(var(--vot-helper-theme-rgb),.87);color:var(--vot-helper-theme);fill:var(--vot-helper-theme);justify-content:space-between;align-items:center;display:flex}.vot-lang-select[hidden]{display:none!important}.vot-lang-select-icon{justify-content:center;align-items:center;width:32px;height:32px;display:flex}.vot-segmented-button{--vot-helper-theme-rgb:var(--vot-onsurface-rgb,0,0,0);--vot-helper-theme:rgba(var(--vot-helper-theme-rgb),.87);-webkit-user-select:none;user-select:none;background:rgb(var(--vot-surface-rgb,255,255,255));max-width:100vw;height:32px;color:var(--vot-helper-theme);fill:var(--vot-helper-theme);font-family:var(--vot-font-family,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system);cursor:default;z-index:2147483647;border-radius:4px;align-items:center;font-size:16px;line-height:1.5;transition:opacity .5s;display:flex;position:absolute;top:5rem;left:50%;overflow:hidden;transform:translate(-50%)}.vot-segmented-button[hidden]{display:none!important}.vot-segmented-button *{box-sizing:border-box!important}.vot-segmented-button .vot-separator{background:rgba(var(--vot-helper-theme-rgb),.1);width:1px;height:50%}.vot-segmented-button .vot-separator[hidden]{display:none!important}.vot-segmented-button .vot-segment,.vot-segmented-button .vot-segment-only-icon{height:100%;color:inherit;background-color:transparent;border:none;justify-content:center;align-items:center;padding:0 8px;transition:background-color .1s ease-in-out;display:flex;position:relative;overflow:hidden}.vot-segmented-button .vot-segment[hidden],.vot-segmented-button [hidden].vot-segment-only-icon{display:none!important}.vot-segmented-button .vot-segment:before,.vot-segmented-button .vot-segment-only-icon:before,.vot-segmented-button .vot-segment:after,.vot-segmented-button .vot-segment-only-icon:after{content:"";border-radius:inherit;opacity:0;position:absolute;top:0;bottom:0;left:0;right:0}.vot-segmented-button .vot-segment:before,.vot-segmented-button .vot-segment-only-icon:before{background-color:rgb(var(--vot-helper-theme-rgb));transition:opacity .2s}.vot-segmented-button .vot-segment:after,.vot-segmented-button .vot-segment-only-icon:after{background:radial-gradient(circle,currentColor 1%,transparent 1%) 50%/10000% 10000% no-repeat;transition:opacity 1s,background-size .5s}.vot-segmented-button .vot-segment:hover:before,.vot-segmented-button .vot-segment-only-icon:hover:before{opacity:.04}.vot-segmented-button .vot-segment:active:after,.vot-segmented-button .vot-segment-only-icon:active:after{opacity:.16;background-size:100% 100%;transition:background-size}.vot-segmented-button .vot-segment-only-icon{min-width:32px;padding:0}.vot-segmented-button .vot-segment-label{white-space:nowrap;color:inherit;margin-left:8px;font-weight:400}.vot-segmented-button[data-status=success] .vot-translate-button{color:rgb(var(--vot-primary-rgb,33,150,243));fill:rgb(var(--vot-primary-rgb,33,150,243))}.vot-segmented-button[data-status=error] .vot-translate-button{color:#f28b82;fill:#f28b82}.vot-segmented-button[data-loading=true] #vot-loading-icon{display:block!important}.vot-segmented-button[data-loading=true] #vot-translate-icon{display:none!important}.vot-segmented-button[data-direction=column]{flex-direction:column;height:fit-content}.vot-segmented-button[data-direction=column] .vot-segment-label{display:none}.vot-segmented-button[data-direction=column]>.vot-segment-only-icon,.vot-segmented-button[data-direction=column]>.vot-segment{padding:8px}.vot-segmented-button[data-direction=column] .vot-separator{width:50%;height:1px}.vot-segmented-button[data-position=left]{top:12.5vh;left:50px}.vot-segmented-button[data-position=right]{top:12.5vh;left:auto;right:0}.vot-segmented-button svg{width:24px}.vot-menu{--vot-helper-surface-rgb:var(--vot-surface-rgb,255,255,255);--vot-helper-surface:rgb(var(--vot-helper-surface-rgb));--vot-helper-onsurface-rgb:var(--vot-onsurface-rgb,0,0,0);--vot-helper-onsurface:rgba(var(--vot-helper-onsurface-rgb),.87);-webkit-user-select:none;user-select:none;background-color:var(--vot-helper-surface);color:var(--vot-helper-onsurface);font-family:var(--vot-font-family,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system);cursor:default;z-index:2147483647;visibility:visible;opacity:1;transform-origin:top;border-radius:8px;min-width:300px;font-size:16px;line-height:1.5;transition:opacity .3s,transform .1s;position:absolute;top:calc(5rem + 48px);left:50%;overflow:hidden;transform:translate(-50%)scale(1)}.vot-menu *{box-sizing:border-box!important}.vot-menu[hidden]{pointer-events:none;visibility:hidden;opacity:0;transform:translate(-50%)scale(0);display:block!important}.vot-menu-content-wrapper{min-height:100px;max-height:calc(var(--vot-container-height,75vh) - (5rem + 32px + 16px)*2);flex-direction:column;display:flex;overflow:auto}.vot-menu-header-container{flex-shrink:0;align-items:flex-start;min-height:31px;display:flex}.vot-menu-header-container:empty{padding:0 0 16px}.vot-menu-header-container>.vot-icon-button{margin-inline-end:4px;margin-top:4px}.vot-menu-title-container{font-size:inherit;font-weight:inherit;text-align:start;outline:0;flex:1;margin:0;display:flex}.vot-menu-title{padding-bottom:16px;padding-inline-start:16px;padding-inline-end:16px;flex:1;padding-top:16px;font-size:16px;font-weight:400;line-height:1}.vot-menu-body-container{box-sizing:border-box;overscroll-behavior:contain;flex-direction:column;gap:8px;min-height:1.375rem;padding:0 16px;display:flex;overflow:auto;scrollbar-color:rgba(var(--vot-helper-onsurface-rgb),.1)var(--vot-helper-surface)!important}.vot-menu-body-container::-webkit-scrollbar{background:var(--vot-helper-surface)!important;width:12px!important;height:12px!important}.vot-menu-body-container::-webkit-scrollbar-track{background:var(--vot-helper-surface)!important;width:12px!important;height:12px!important}.vot-menu-body-container::-webkit-scrollbar-thumb{background:rgba(var(--vot-helper-onsurface-rgb),.1)!important;border:5px solid var(--vot-helper-surface)!important;-webkit-border-radius:1ex!important}.vot-menu-body-container::-webkit-scrollbar-thumb:hover{border:3px solid var(--vot-helper-surface)!important}.vot-menu-body-container::-webkit-scrollbar-corner{background:var(--vot-helper-surface)!important}.vot-menu-footer-container{padding-bottom:16px;padding-inline-start:16px;padding-inline-end:16px;flex-shrink:0;justify-content:flex-end;padding-top:16px;display:flex}.vot-menu-footer-container:empty{padding:16px 0 0}.vot-menu[data-position=left]{top:12.5vh;left:240px}.vot-menu[data-position=right]{top:12.5vh;left:auto;right:-80px}.vot-dialog{--vot-helper-surface-rgb:var(--vot-surface-rgb,255,255,255);--vot-helper-surface:rgb(var(--vot-helper-surface-rgb));--vot-helper-onsurface-rgb:var(--vot-onsurface-rgb,0,0,0);--vot-helper-onsurface:rgba(var(--vot-helper-onsurface-rgb),.87);max-width:initial;max-height:initial;width:min(var(--vot-dialog-width,512px),100%);top:50%;bottom:50%;background-color:var(--vot-helper-surface);height:fit-content;color:var(--vot-helper-onsurface);font-family:var(--vot-font-family,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system);-webkit-user-select:none;user-select:none;visibility:visible;opacity:1;transform-origin:50%;border-radius:8px;margin:auto;padding:0;font-size:16px;line-height:1.5;transition:opacity .3s,transform .1s;display:block;position:fixed;top:0;bottom:0;left:0;right:0;overflow-x:auto;overflow-y:hidden;transform:scale(1);box-shadow:0 0 16px rgba(0,0,0,.12),0 16px 16px rgba(0,0,0,.24)}[hidden]>.vot-dialog{pointer-events:none;opacity:0;transition:opacity .1s,transform .2s;transform:scale(.5)}.vot-dialog-container{visibility:visible;z-index:2147483647;position:absolute}.vot-dialog-container[hidden]{pointer-events:none;visibility:hidden;display:block!important}.vot-dialog-container *{box-sizing:border-box!important}.vot-dialog-backdrop{opacity:1;background-color:rgba(0,0,0,.6);transition:opacity .3s;position:fixed;top:0;bottom:0;left:0;right:0}[hidden]>.vot-dialog-backdrop{pointer-events:none;opacity:0}.vot-dialog-content-wrapper{flex-direction:column;max-height:75vh;display:flex;overflow:auto}.vot-dialog-header-container{flex-shrink:0;align-items:flex-start;min-height:31px;display:flex}.vot-dialog-header-container:empty{padding:0 0 20px}.vot-dialog-header-container>.vot-icon-button{margin-inline-end:4px;margin-top:4px}.vot-dialog-title-container{font-size:inherit;font-weight:inherit;outline:0;flex:1;margin:0;display:flex}.vot-dialog-title{padding-bottom:16px;padding-inline-start:20px;padding-inline-end:20px;flex:1;padding-top:20px;font-size:115.385%;font-weight:700;line-height:1}.vot-dialog-body-container{box-sizing:border-box;overscroll-behavior:contain;flex-direction:column;gap:16px;min-height:1.375rem;padding:0 20px;display:flex;overflow:auto;scrollbar-color:rgba(var(--vot-helper-onsurface-rgb),.1)var(--vot-helper-surface)!important}.vot-dialog-body-container::-webkit-scrollbar{background:var(--vot-helper-surface)!important;width:12px!important;height:12px!important}.vot-dialog-body-container::-webkit-scrollbar-track{background:var(--vot-helper-surface)!important;width:12px!important;height:12px!important}.vot-dialog-body-container::-webkit-scrollbar-thumb{background:rgba(var(--vot-helper-onsurface-rgb),.1)!important;border:5px solid var(--vot-helper-surface)!important;-webkit-border-radius:1ex!important}.vot-dialog-body-container::-webkit-scrollbar-thumb:hover{border:3px solid var(--vot-helper-surface)!important}.vot-dialog-body-container::-webkit-scrollbar-corner{background:var(--vot-helper-surface)!important}.vot-dialog-footer-container{padding-bottom:16px;padding-inline-start:16px;padding-inline-end:16px;flex-shrink:0;justify-content:flex-end;padding-top:16px;display:flex}.vot-dialog-footer-container:empty{padding:20px 0 0}.vot-subtitles{--vot-subtitles-background:rgba(var(--vot-surface-rgb,46,47,52),var(--vot-subtitles-opacity,.8));background:var(--vot-subtitles-background,rgba(46,47,52,.8));width:max-content;max-width:100%;max-height:100%;color:var(--vot-subtitles-color,#e3e3e3);pointer-events:all;font-size:20px;font-family:var(--vot-font-family,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system);box-sizing:border-box;-webkit-user-select:none;user-select:none;border-radius:.5em;padding:.5em;line-height:normal;position:relative}.vot-subtitles-widget{z-index:2147483647;pointer-events:none;justify-content:center;align-items:center;width:50%;min-height:20%;max-height:100%;display:flex;position:absolute;top:75%;left:25%}.vot-subtitles span{-webkit-user-select:text;user-select:text;font-size:inherit!important;font-family:inherit!important;line-height:normal!important}.vot-subtitles .passed{color:var(--vot-subtitles-passed-color,#2196f3)}:root{--vot-font-family:"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system;--vot-primary-rgb:139,180,245;--vot-onprimary-rgb:32,33,36;--vot-surface-rgb:32,33,36;--vot-onsurface-rgb:227,227,227;--vot-subtitles-color:rgb(var(--vot-onsurface-rgb,227,227,227));--vot-subtitles-passed-color:rgb(var(--vot-primary-rgb,33,150,243))}vot-block{font-family:inherit;display:block;visibility:visible!important}')},"./node_modules/bowser/es5.js":function(t){t.exports=function(t){var e={};function i(o){if(e[o])return e[o].exports;var a=e[o]={i:o,l:!1,exports:{}};return t[o].call(a.exports,a,a.exports,i),a.l=!0,a.exports}return i.m=t,i.c=e,i.d=function(t,e,o){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(i.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)i.d(o,a,function(e){return t[e]}.bind(null,a));return o},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=90)}({17:function(t,e,i){"use strict";e.__esModule=!0,e.default=void 0;var o=i(18),a=function(){function t(){}return t.getFirstMatch=function(t,e){var i=e.match(t);return i&&i.length>0&&i[1]||""},t.getSecondMatch=function(t,e){var i=e.match(t);return i&&i.length>1&&i[2]||""},t.matchAndReturnConst=function(t,e,i){if(t.test(e))return i},t.getWindowsVersionName=function(t){switch(t){case"NT":return"NT";case"XP":case"NT 5.1":return"XP";case"NT 5.0":return"2000";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}},t.getMacOSVersionName=function(t){var e=t.split(".").splice(0,2).map((function(t){return parseInt(t,10)||0}));if(e.push(0),10===e[0])switch(e[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}},t.getAndroidVersionName=function(t){var e=t.split(".").splice(0,2).map((function(t){return parseInt(t,10)||0}));if(e.push(0),!(1===e[0]&&e[1]<5))return 1===e[0]&&e[1]<6?"Cupcake":1===e[0]&&e[1]>=6?"Donut":2===e[0]&&e[1]<2?"Eclair":2===e[0]&&2===e[1]?"Froyo":2===e[0]&&e[1]>2?"Gingerbread":3===e[0]?"Honeycomb":4===e[0]&&e[1]<1?"Ice Cream Sandwich":4===e[0]&&e[1]<4?"Jelly Bean":4===e[0]&&e[1]>=4?"KitKat":5===e[0]?"Lollipop":6===e[0]?"Marshmallow":7===e[0]?"Nougat":8===e[0]?"Oreo":9===e[0]?"Pie":void 0},t.getVersionPrecision=function(t){return t.split(".").length},t.compareVersions=function(e,i,o){void 0===o&&(o=!1);var a=t.getVersionPrecision(e),n=t.getVersionPrecision(i),r=Math.max(a,n),s=0,l=t.map([e,i],(function(e){var i=r-t.getVersionPrecision(e),o=e+new Array(i+1).join(".0");return t.map(o.split("."),(function(t){return new Array(20-t.length).join("0")+t})).reverse()}));for(o&&(s=r-Math.min(a,n)),r-=1;r>=s;){if(l[0][r]>l[1][r])return 1;if(l[0][r]===l[1][r]){if(r===s)return 0;r-=1}else if(l[0][r]<l[1][r])return-1}},t.map=function(t,e){var i,o=[];if(Array.prototype.map)return Array.prototype.map.call(t,e);for(i=0;i<t.length;i+=1)o.push(e(t[i]));return o},t.find=function(t,e){var i,o;if(Array.prototype.find)return Array.prototype.find.call(t,e);for(i=0,o=t.length;i<o;i+=1){var a=t[i];if(e(a,i))return a}},t.assign=function(t){for(var e,i,o=t,a=arguments.length,n=new Array(a>1?a-1:0),r=1;r<a;r++)n[r-1]=arguments[r];if(Object.assign)return Object.assign.apply(Object,[t].concat(n));var s=function(){var t=n[e];"object"==typeof t&&null!==t&&Object.keys(t).forEach((function(e){o[e]=t[e]}))};for(e=0,i=n.length;e<i;e+=1)s();return t},t.getBrowserAlias=function(t){return o.BROWSER_ALIASES_MAP[t]},t.getBrowserTypeByAlias=function(t){return o.BROWSER_MAP[t]||""},t}();e.default=a,t.exports=e.default},18:function(t,e,i){"use strict";e.__esModule=!0,e.ENGINE_MAP=e.OS_MAP=e.PLATFORMS_MAP=e.BROWSER_MAP=e.BROWSER_ALIASES_MAP=void 0,e.BROWSER_ALIASES_MAP={"Amazon Silk":"amazon_silk","Android Browser":"android",Bada:"bada",BlackBerry:"blackberry",Chrome:"chrome",Chromium:"chromium",Electron:"electron",Epiphany:"epiphany",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot","Internet Explorer":"ie","K-Meleon":"k_meleon",Maxthon:"maxthon","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver",Opera:"opera","Opera Coast":"opera_coast",PhantomJS:"phantomjs",Puffin:"puffin",QupZilla:"qupzilla",QQ:"qq",QQLite:"qqlite",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SeaMonkey:"seamonkey",Sleipnir:"sleipnir",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat","Yandex Browser":"yandex",Roku:"roku"},e.BROWSER_MAP={amazon_silk:"Amazon Silk",android:"Android Browser",bada:"Bada",blackberry:"BlackBerry",chrome:"Chrome",chromium:"Chromium",electron:"Electron",epiphany:"Epiphany",firefox:"Firefox",focus:"Focus",generic:"Generic",googlebot:"Googlebot",google_search:"Google Search",ie:"Internet Explorer",k_meleon:"K-Meleon",maxthon:"Maxthon",edge:"Microsoft Edge",mz:"MZ Browser",naver:"NAVER Whale Browser",opera:"Opera",opera_coast:"Opera Coast",phantomjs:"PhantomJS",puffin:"Puffin",qupzilla:"QupZilla",qq:"QQ Browser",qqlite:"QQ Browser Lite",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",sleipnir:"Sleipnir",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yandex:"Yandex Browser"},e.PLATFORMS_MAP={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},e.OS_MAP={WindowsPhone:"Windows Phone",Windows:"Windows",MacOS:"macOS",iOS:"iOS",Android:"Android",WebOS:"WebOS",BlackBerry:"BlackBerry",Bada:"Bada",Tizen:"Tizen",Linux:"Linux",ChromeOS:"Chrome OS",PlayStation4:"PlayStation 4",Roku:"Roku"},e.ENGINE_MAP={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"}},90:function(t,e,i){"use strict";e.__esModule=!0,e.default=void 0;var o,a=(o=i(91))&&o.__esModule?o:{default:o},n=i(18);function r(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}var s=function(){function t(){}var e,i,o;return t.getParser=function(t,e){if(void 0===e&&(e=!1),"string"!=typeof t)throw new Error("UserAgent should be a string");return new a.default(t,e)},t.parse=function(t){return new a.default(t).getResult()},e=t,o=[{key:"BROWSER_MAP",get:function(){return n.BROWSER_MAP}},{key:"ENGINE_MAP",get:function(){return n.ENGINE_MAP}},{key:"OS_MAP",get:function(){return n.OS_MAP}},{key:"PLATFORMS_MAP",get:function(){return n.PLATFORMS_MAP}}],(i=null)&&r(e.prototype,i),o&&r(e,o),t}();e.default=s,t.exports=e.default},91:function(t,e,i){"use strict";e.__esModule=!0,e.default=void 0;var o=l(i(92)),a=l(i(93)),n=l(i(94)),r=l(i(95)),s=l(i(17));function l(t){return t&&t.__esModule?t:{default:t}}var d=function(){function t(t,e){if(void 0===e&&(e=!1),null==t||""===t)throw new Error("UserAgent parameter can't be empty");this._ua=t,this.parsedResult={},!0!==e&&this.parse()}var e=t.prototype;return e.getUA=function(){return this._ua},e.test=function(t){return t.test(this._ua)},e.parseBrowser=function(){var t=this;this.parsedResult.browser={};var e=s.default.find(o.default,(function(e){if("function"==typeof e.test)return e.test(t);if(e.test instanceof Array)return e.test.some((function(e){return t.test(e)}));throw new Error("Browser's test function is not valid")}));return e&&(this.parsedResult.browser=e.describe(this.getUA())),this.parsedResult.browser},e.getBrowser=function(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()},e.getBrowserName=function(t){return t?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""},e.getBrowserVersion=function(){return this.getBrowser().version},e.getOS=function(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()},e.parseOS=function(){var t=this;this.parsedResult.os={};var e=s.default.find(a.default,(function(e){if("function"==typeof e.test)return e.test(t);if(e.test instanceof Array)return e.test.some((function(e){return t.test(e)}));throw new Error("Browser's test function is not valid")}));return e&&(this.parsedResult.os=e.describe(this.getUA())),this.parsedResult.os},e.getOSName=function(t){var e=this.getOS().name;return t?String(e).toLowerCase()||"":e||""},e.getOSVersion=function(){return this.getOS().version},e.getPlatform=function(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()},e.getPlatformType=function(t){void 0===t&&(t=!1);var e=this.getPlatform().type;return t?String(e).toLowerCase()||"":e||""},e.parsePlatform=function(){var t=this;this.parsedResult.platform={};var e=s.default.find(n.default,(function(e){if("function"==typeof e.test)return e.test(t);if(e.test instanceof Array)return e.test.some((function(e){return t.test(e)}));throw new Error("Browser's test function is not valid")}));return e&&(this.parsedResult.platform=e.describe(this.getUA())),this.parsedResult.platform},e.getEngine=function(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()},e.getEngineName=function(t){return t?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""},e.parseEngine=function(){var t=this;this.parsedResult.engine={};var e=s.default.find(r.default,(function(e){if("function"==typeof e.test)return e.test(t);if(e.test instanceof Array)return e.test.some((function(e){return t.test(e)}));throw new Error("Browser's test function is not valid")}));return e&&(this.parsedResult.engine=e.describe(this.getUA())),this.parsedResult.engine},e.parse=function(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this},e.getResult=function(){return s.default.assign({},this.parsedResult)},e.satisfies=function(t){var e=this,i={},o=0,a={},n=0;if(Object.keys(t).forEach((function(e){var r=t[e];"string"==typeof r?(a[e]=r,n+=1):"object"==typeof r&&(i[e]=r,o+=1)})),o>0){var r=Object.keys(i),l=s.default.find(r,(function(t){return e.isOS(t)}));if(l){var d=this.satisfies(i[l]);if(void 0!==d)return d}var u=s.default.find(r,(function(t){return e.isPlatform(t)}));if(u){var c=this.satisfies(i[u]);if(void 0!==c)return c}}if(n>0){var h=Object.keys(a),p=s.default.find(h,(function(t){return e.isBrowser(t,!0)}));if(void 0!==p)return this.compareVersion(a[p])}},e.isBrowser=function(t,e){void 0===e&&(e=!1);var i=this.getBrowserName().toLowerCase(),o=t.toLowerCase(),a=s.default.getBrowserTypeByAlias(o);return e&&a&&(o=a.toLowerCase()),o===i},e.compareVersion=function(t){var e=[0],i=t,o=!1,a=this.getBrowserVersion();if("string"==typeof a)return">"===t[0]||"<"===t[0]?(i=t.substr(1),"="===t[1]?(o=!0,i=t.substr(2)):e=[],">"===t[0]?e.push(1):e.push(-1)):"="===t[0]?i=t.substr(1):"~"===t[0]&&(o=!0,i=t.substr(1)),e.indexOf(s.default.compareVersions(a,i,o))>-1},e.isOS=function(t){return this.getOSName(!0)===String(t).toLowerCase()},e.isPlatform=function(t){return this.getPlatformType(!0)===String(t).toLowerCase()},e.isEngine=function(t){return this.getEngineName(!0)===String(t).toLowerCase()},e.is=function(t,e){return void 0===e&&(e=!1),this.isBrowser(t,e)||this.isOS(t)||this.isPlatform(t)},e.some=function(t){var e=this;return void 0===t&&(t=[]),t.some((function(t){return e.is(t)}))},t}();e.default=d,t.exports=e.default},92:function(t,e,i){"use strict";e.__esModule=!0,e.default=void 0;var o,a=(o=i(17))&&o.__esModule?o:{default:o},n=/version\/(\d+(\.?_?\d+)+)/i,r=[{test:[/googlebot/i],describe:function(t){var e={name:"Googlebot"},i=a.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,t)||a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/opera/i],describe:function(t){var e={name:"Opera"},i=a.default.getFirstMatch(n,t)||a.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/opr\/|opios/i],describe:function(t){var e={name:"Opera"},i=a.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,t)||a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/SamsungBrowser/i],describe:function(t){var e={name:"Samsung Internet for Android"},i=a.default.getFirstMatch(n,t)||a.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/Whale/i],describe:function(t){var e={name:"NAVER Whale Browser"},i=a.default.getFirstMatch(n,t)||a.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/MZBrowser/i],describe:function(t){var e={name:"MZ Browser"},i=a.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,t)||a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/focus/i],describe:function(t){var e={name:"Focus"},i=a.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,t)||a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/swing/i],describe:function(t){var e={name:"Swing"},i=a.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,t)||a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/coast/i],describe:function(t){var e={name:"Opera Coast"},i=a.default.getFirstMatch(n,t)||a.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe:function(t){var e={name:"Opera Touch"},i=a.default.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,t)||a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/yabrowser/i],describe:function(t){var e={name:"Yandex Browser"},i=a.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,t)||a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/ucbrowser/i],describe:function(t){var e={name:"UC Browser"},i=a.default.getFirstMatch(n,t)||a.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/Maxthon|mxios/i],describe:function(t){var e={name:"Maxthon"},i=a.default.getFirstMatch(n,t)||a.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/epiphany/i],describe:function(t){var e={name:"Epiphany"},i=a.default.getFirstMatch(n,t)||a.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/puffin/i],describe:function(t){var e={name:"Puffin"},i=a.default.getFirstMatch(n,t)||a.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/sleipnir/i],describe:function(t){var e={name:"Sleipnir"},i=a.default.getFirstMatch(n,t)||a.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/k-meleon/i],describe:function(t){var e={name:"K-Meleon"},i=a.default.getFirstMatch(n,t)||a.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/micromessenger/i],describe:function(t){var e={name:"WeChat"},i=a.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,t)||a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/qqbrowser/i],describe:function(t){var e={name:/qqbrowserlite/i.test(t)?"QQ Browser Lite":"QQ Browser"},i=a.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,t)||a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/msie|trident/i],describe:function(t){var e={name:"Internet Explorer"},i=a.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/\sedg\//i],describe:function(t){var e={name:"Microsoft Edge"},i=a.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/edg([ea]|ios)/i],describe:function(t){var e={name:"Microsoft Edge"},i=a.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/vivaldi/i],describe:function(t){var e={name:"Vivaldi"},i=a.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/seamonkey/i],describe:function(t){var e={name:"SeaMonkey"},i=a.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/sailfish/i],describe:function(t){var e={name:"Sailfish"},i=a.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,t);return i&&(e.version=i),e}},{test:[/silk/i],describe:function(t){var e={name:"Amazon Silk"},i=a.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/phantom/i],describe:function(t){var e={name:"PhantomJS"},i=a.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/slimerjs/i],describe:function(t){var e={name:"SlimerJS"},i=a.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(t){var e={name:"BlackBerry"},i=a.default.getFirstMatch(n,t)||a.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/(web|hpw)[o0]s/i],describe:function(t){var e={name:"WebOS Browser"},i=a.default.getFirstMatch(n,t)||a.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/bada/i],describe:function(t){var e={name:"Bada"},i=a.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/tizen/i],describe:function(t){var e={name:"Tizen"},i=a.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,t)||a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/qupzilla/i],describe:function(t){var e={name:"QupZilla"},i=a.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,t)||a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/firefox|iceweasel|fxios/i],describe:function(t){var e={name:"Firefox"},i=a.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/electron/i],describe:function(t){var e={name:"Electron"},i=a.default.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/MiuiBrowser/i],describe:function(t){var e={name:"Miui"},i=a.default.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/chromium/i],describe:function(t){var e={name:"Chromium"},i=a.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,t)||a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/chrome|crios|crmo/i],describe:function(t){var e={name:"Chrome"},i=a.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/GSA/i],describe:function(t){var e={name:"Google Search"},i=a.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:function(t){var e=!t.test(/like android/i),i=t.test(/android/i);return e&&i},describe:function(t){var e={name:"Android Browser"},i=a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/playstation 4/i],describe:function(t){var e={name:"PlayStation 4"},i=a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/safari|applewebkit/i],describe:function(t){var e={name:"Safari"},i=a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/.*/i],describe:function(t){var e=-1!==t.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:a.default.getFirstMatch(e,t),version:a.default.getSecondMatch(e,t)}}}];e.default=r,t.exports=e.default},93:function(t,e,i){"use strict";e.__esModule=!0,e.default=void 0;var o,a=(o=i(17))&&o.__esModule?o:{default:o},n=i(18),r=[{test:[/Roku\/DVP/],describe:function(t){var e=a.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,t);return{name:n.OS_MAP.Roku,version:e}}},{test:[/windows phone/i],describe:function(t){var e=a.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,t);return{name:n.OS_MAP.WindowsPhone,version:e}}},{test:[/windows /i],describe:function(t){var e=a.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,t),i=a.default.getWindowsVersionName(e);return{name:n.OS_MAP.Windows,version:e,versionName:i}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(t){var e={name:n.OS_MAP.iOS},i=a.default.getSecondMatch(/(Version\/)(\d[\d.]+)/,t);return i&&(e.version=i),e}},{test:[/macintosh/i],describe:function(t){var e=a.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,t).replace(/[_\s]/g,"."),i=a.default.getMacOSVersionName(e),o={name:n.OS_MAP.MacOS,version:e};return i&&(o.versionName=i),o}},{test:[/(ipod|iphone|ipad)/i],describe:function(t){var e=a.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,t).replace(/[_\s]/g,".");return{name:n.OS_MAP.iOS,version:e}}},{test:function(t){var e=!t.test(/like android/i),i=t.test(/android/i);return e&&i},describe:function(t){var e=a.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,t),i=a.default.getAndroidVersionName(e),o={name:n.OS_MAP.Android,version:e};return i&&(o.versionName=i),o}},{test:[/(web|hpw)[o0]s/i],describe:function(t){var e=a.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,t),i={name:n.OS_MAP.WebOS};return e&&e.length&&(i.version=e),i}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(t){var e=a.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,t)||a.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,t)||a.default.getFirstMatch(/\bbb(\d+)/i,t);return{name:n.OS_MAP.BlackBerry,version:e}}},{test:[/bada/i],describe:function(t){var e=a.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,t);return{name:n.OS_MAP.Bada,version:e}}},{test:[/tizen/i],describe:function(t){var e=a.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,t);return{name:n.OS_MAP.Tizen,version:e}}},{test:[/linux/i],describe:function(){return{name:n.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return{name:n.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(t){var e=a.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,t);return{name:n.OS_MAP.PlayStation4,version:e}}}];e.default=r,t.exports=e.default},94:function(t,e,i){"use strict";e.__esModule=!0,e.default=void 0;var o,a=(o=i(17))&&o.__esModule?o:{default:o},n=i(18),r=[{test:[/googlebot/i],describe:function(){return{type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(t){var e=a.default.getFirstMatch(/(can-l01)/i,t)&&"Nova",i={type:n.PLATFORMS_MAP.mobile,vendor:"Huawei"};return e&&(i.model=e),i}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:n.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:n.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(){return{type:n.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:n.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:n.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return{type:n.PLATFORMS_MAP.tablet}}},{test:function(t){var e=t.test(/ipod|iphone/i),i=t.test(/like (ipod|iphone)/i);return e&&!i},describe:function(t){var e=a.default.getFirstMatch(/(ipod|iphone)/i,t);return{type:n.PLATFORMS_MAP.mobile,vendor:"Apple",model:e}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:n.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return{type:n.PLATFORMS_MAP.mobile}}},{test:function(t){return"blackberry"===t.getBrowserName(!0)},describe:function(){return{type:n.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(t){return"bada"===t.getBrowserName(!0)},describe:function(){return{type:n.PLATFORMS_MAP.mobile}}},{test:function(t){return"windows phone"===t.getBrowserName()},describe:function(){return{type:n.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(t){var e=Number(String(t.getOSVersion()).split(".")[0]);return"android"===t.getOSName(!0)&&e>=3},describe:function(){return{type:n.PLATFORMS_MAP.tablet}}},{test:function(t){return"android"===t.getOSName(!0)},describe:function(){return{type:n.PLATFORMS_MAP.mobile}}},{test:function(t){return"macos"===t.getOSName(!0)},describe:function(){return{type:n.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(t){return"windows"===t.getOSName(!0)},describe:function(){return{type:n.PLATFORMS_MAP.desktop}}},{test:function(t){return"linux"===t.getOSName(!0)},describe:function(){return{type:n.PLATFORMS_MAP.desktop}}},{test:function(t){return"playstation 4"===t.getOSName(!0)},describe:function(){return{type:n.PLATFORMS_MAP.tv}}},{test:function(t){return"roku"===t.getOSName(!0)},describe:function(){return{type:n.PLATFORMS_MAP.tv}}}];e.default=r,t.exports=e.default},95:function(t,e,i){"use strict";e.__esModule=!0,e.default=void 0;var o,a=(o=i(17))&&o.__esModule?o:{default:o},n=i(18),r=[{test:function(t){return"microsoft edge"===t.getBrowserName(!0)},describe:function(t){if(/\sedg\//i.test(t))return{name:n.ENGINE_MAP.Blink};var e=a.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,t);return{name:n.ENGINE_MAP.EdgeHTML,version:e}}},{test:[/trident/i],describe:function(t){var e={name:n.ENGINE_MAP.Trident},i=a.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:function(t){return t.test(/presto/i)},describe:function(t){var e={name:n.ENGINE_MAP.Presto},i=a.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:function(t){var e=t.test(/gecko/i),i=t.test(/like gecko/i);return e&&!i},describe:function(t){var e={name:n.ENGINE_MAP.Gecko},i=a.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return{name:n.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(t){var e={name:n.ENGINE_MAP.WebKit},i=a.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}}];e.default=r,t.exports=e.default}})},"./node_modules/requestidlecallback-polyfill/index.js":()=>{window.requestIdleCallback=window.requestIdleCallback||function(t){var e=Date.now();return setTimeout((function(){t({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-e))}})}),1)},window.cancelIdleCallback=window.cancelIdleCallback||function(t){clearTimeout(t)}}},e={};function i(o){var a=e[o];if(void 0!==a)return a.exports;var n=e[o]={exports:{}};return t[o].call(n.exports,n,n.exports,i),n.exports}(()=>{"use strict";var t=i("./node_modules/bowser/es5.js");const e=globalThis,o=e.trustedTypes,a=o?o.createPolicy("lit-html",{createHTML:t=>t}):void 0,n="$lit$",r=`lit$${Math.random().toFixed(9).slice(2)}$`,s="?"+r,l=`<${s}>`,d=document,u=()=>d.createComment(""),c=t=>null===t||"object"!=typeof t&&"function"!=typeof t,h=Array.isArray,p=t=>h(t)||"function"==typeof t?.[Symbol.iterator],g="[ \t\n\f\r]",m=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,v=/-->/g,f=/>/g,b=RegExp(`>|${g}(?:([^\\s"'>=/]+)(${g}*=${g}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),w=/'/g,y=/"/g,x=/^(?:script|style|textarea|title)$/i,S=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),k=S(1),T=S(2),C=(S(3),Symbol.for("lit-noChange")),I=Symbol.for("lit-nothing"),P=new WeakMap,L=d.createTreeWalker(d,129);function _(t,e){if(!h(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==a?a.createHTML(e):e}const A=(t,e)=>{const i=t.length-1,o=[];let a,s=2===e?"<svg>":3===e?"<math>":"",d=m;for(let e=0;e<i;e++){const i=t[e];let u,c,h=-1,p=0;for(;p<i.length&&(d.lastIndex=p,c=d.exec(i),null!==c);)p=d.lastIndex,d===m?"!--"===c[1]?d=v:void 0!==c[1]?d=f:void 0!==c[2]?(x.test(c[2])&&(a=RegExp("</"+c[2],"g")),d=b):void 0!==c[3]&&(d=b):d===b?">"===c[0]?(d=a??m,h=-1):void 0===c[1]?h=-2:(h=d.lastIndex-c[2].length,u=c[1],d=void 0===c[3]?b:'"'===c[3]?y:w):d===y||d===w?d=b:d===v||d===f?d=m:(d=b,a=void 0);const g=d===b&&t[e+1].startsWith("/>")?" ":"";s+=d===m?i+l:h>=0?(o.push(u),i.slice(0,h)+n+i.slice(h)+r+g):i+r+(-2===h?e:g)}return[_(t,s+(t[i]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),o]};class O{constructor({strings:t,_$litType$:e},i){let a;this.parts=[];let l=0,d=0;const c=t.length-1,h=this.parts,[p,g]=A(t,e);if(this.el=O.createElement(p,i),L.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(a=L.nextNode())&&h.length<c;){if(1===a.nodeType){if(a.hasAttributes())for(const t of a.getAttributeNames())if(t.endsWith(n)){const e=g[d++],i=a.getAttribute(t).split(r),o=/([.?@])?(.*)/.exec(e);h.push({type:1,index:l,name:o[2],strings:i,ctor:"."===o[1]?N:"?"===o[1]?R:"@"===o[1]?$:B}),a.removeAttribute(t)}else t.startsWith(r)&&(h.push({type:6,index:l}),a.removeAttribute(t));if(x.test(a.tagName)){const t=a.textContent.split(r),e=t.length-1;if(e>0){a.textContent=o?o.emptyScript:"";for(let i=0;i<e;i++)a.append(t[i],u()),L.nextNode(),h.push({type:2,index:++l});a.append(t[e],u())}}}else if(8===a.nodeType)if(a.data===s)h.push({type:2,index:l});else{let t=-1;for(;-1!==(t=a.data.indexOf(r,t+1));)h.push({type:7,index:l}),t+=r.length-1}l++}}static createElement(t,e){const i=d.createElement("template");return i.innerHTML=t,i}}function V(t,e,i=t,o){if(e===C)return e;let a=void 0!==o?i.o?.[o]:i.l;const n=c(e)?void 0:e._$litDirective$;return a?.constructor!==n&&(a?._$AO?.(!1),void 0===n?a=void 0:(a=new n(t),a._$AT(t,i,o)),void 0!==o?(i.o??=[])[o]=a:i.l=a),void 0!==a&&(e=V(t,a._$AS(t,e.values),a,o)),e}class M{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:i}=this._$AD,o=(t?.creationScope??d).importNode(e,!0);L.currentNode=o;let a=L.nextNode(),n=0,r=0,s=i[0];for(;void 0!==s;){if(n===s.index){let e;2===s.type?e=new E(a,a.nextSibling,this,t):1===s.type?e=new s.ctor(a,s.name,s.strings,this,t):6===s.type&&(e=new D(a,this,t)),this._$AV.push(e),s=i[++r]}n!==s?.index&&(a=L.nextNode(),n++)}return L.currentNode=d,o}p(t){let e=0;for(const i of this._$AV)void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class E{get _$AU(){return this._$AM?._$AU??this.v}constructor(t,e,i,o){this.type=2,this._$AH=I,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=o,this.v=o?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=V(this,t,e),c(t)?t===I||null==t||""===t?(this._$AH!==I&&this._$AR(),this._$AH=I):t!==this._$AH&&t!==C&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):p(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==I&&c(this._$AH)?this._$AA.nextSibling.data=t:this.T(d.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:i}=t,o="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=O.createElement(_(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===o)this._$AH.p(e);else{const t=new M(o,this),i=t.u(this.options);t.p(e),this.T(i),this._$AH=t}}_$AC(t){let e=P.get(t.strings);return void 0===e&&P.set(t.strings,e=new O(t)),e}k(t){h(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,o=0;for(const a of t)o===e.length?e.push(i=new E(this.O(u()),this.O(u()),this,this.options)):i=e[o],i._$AI(a),o++;o<e.length&&(this._$AR(i&&i._$AB.nextSibling,o),e.length=o)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){void 0===this._$AM&&(this.v=t,this._$AP?.(t))}}class B{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,o,a){this.type=1,this._$AH=I,this._$AN=void 0,this.element=t,this.name=e,this._$AM=o,this.options=a,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=I}_$AI(t,e=this,i,o){const a=this.strings;let n=!1;if(void 0===a)t=V(this,t,e,0),n=!c(t)||t!==this._$AH&&t!==C,n&&(this._$AH=t);else{const o=t;let r,s;for(t=a[0],r=0;r<a.length-1;r++)s=V(this,o[i+r],e,r),s===C&&(s=this._$AH[r]),n||=!c(s)||s!==this._$AH[r],s===I?t=I:t!==I&&(t+=(s??"")+a[r+1]),this._$AH[r]=s}n&&!o&&this.j(t)}j(t){t===I?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class N extends B{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===I?void 0:t}}class R extends B{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==I)}}class $ extends B{constructor(t,e,i,o,a){super(t,e,i,o,a),this.type=5}_$AI(t,e=this){if((t=V(this,t,e,0)??I)===C)return;const i=this._$AH,o=t===I&&i!==I||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,a=t!==I&&(i===I||o);o&&this.element.removeEventListener(this.name,this,i),a&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class D{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){V(this,t)}}const F=e.litHtmlPolyfillSupport;F?.(O,E),(e.litHtmlVersions??=[]).push("3.2.0");const U=(t,e,i)=>{const o=i?.renderBefore??e;let a=o._$litPart$;if(void 0===a){const t=i?.renderBefore??null;o._$litPart$=a=new E(e.insertBefore(u(),t),t,void 0,i??{})}return a._$AI(t),a};function q(t){return String(t).split("").map((t=>t.charCodeAt(0)))}function z(t){return new Uint8Array(q(t))}function H(t){const e=new ArrayBuffer(2*t.length),i=new Uint8Array(e);return new Uint16Array(e).set(q(t)),i}function j(t){const e=255;return[t>>>24&e,t>>>16&e,t>>>8&e,t&e]}function W(t){return 11+t}function G(t,e,i,o){return 11+e+1+1+(o?2+2*(i+1):i+1)+t}function Y(t){let e=0;return t.forEach((t=>{e+=2+2*t[0].length+2+2+2*t[1].length+2})),11+e}function J(t,e){const i=2*e;let o=0;return t.forEach((t=>{o+=2+2*t[0].length+2+4})),18+i+2+o}class K{_setIntegerFrame(t,e){const i=parseInt(e,10);this.frames.push({name:t,value:i,size:W(i.toString().length)})}_setStringFrame(t,e){const i=e.toString();let o=13+2*i.length;"TDAT"===t&&(o=W(i.length)),this.frames.push({name:t,value:i,size:o})}_setPictureFrame(t,e,i,o){const a=function(t){if(!t||!t.length)return null;if(255===t[0]&&216===t[1]&&255===t[2])return"image/jpeg";if(137===t[0]&&80===t[1]&&78===t[2]&&71===t[3])return"image/png";if(71===t[0]&&73===t[1]&&70===t[2])return"image/gif";if(87===t[8]&&69===t[9]&&66===t[10]&&80===t[11])return"image/webp";const e=73===t[0]&&73===t[1]&&42===t[2]&&0===t[3],i=77===t[0]&&77===t[1]&&0===t[2]&&42===t[3];return e||i?"image/tiff":66===t[0]&&77===t[1]?"image/bmp":0===t[0]&&0===t[1]&&1===t[2]&&0===t[3]?"image/x-icon":null}(new Uint8Array(e)),n=i.toString();if(!a)throw new Error("Unknown picture MIME type");i||(o=!1),this.frames.push({name:"APIC",value:e,pictureType:t,mimeType:a,useUnicodeEncoding:o,description:n,size:G(e.byteLength,a.length,n.length,o)})}_setLyricsFrame(t,e,i){const o=t.split("").map((t=>t.charCodeAt(0))),a=e.toString(),n=i.toString();var r,s;this.frames.push({name:"USLT",value:n,language:o,description:a,size:(r=a.length,s=n.length,16+2*r+2+2+2*s)})}_setCommentFrame(t,e,i){const o=t.split("").map((t=>t.charCodeAt(0))),a=e.toString(),n=i.toString();var r,s;this.frames.push({name:"COMM",value:n,language:o,description:a,size:(r=a.length,s=n.length,16+2*r+2+2+2*s)})}_setPrivateFrame(t,e){const i=t.toString();var o,a;this.frames.push({name:"PRIV",value:e,id:i,size:(o=i.length,a=e.byteLength,10+o+1+a)})}_setUserStringFrame(t,e){const i=t.toString(),o=e.toString();var a,n;this.frames.push({name:"TXXX",description:i,value:o,size:(a=i.length,n=o.length,13+2*a+2+2+2*n)})}_setUrlLinkFrame(t,e){const i=e.toString();var o;this.frames.push({name:t,value:i,size:(o=i.length,10+o)})}_setPairedTextFrame(t,e){this.frames.push({name:t,value:e,size:Y(e)})}_setSynchronisedLyricsFrame(t,e,i,o,a){const n=a.toString(),r=o.split("").map((t=>t.charCodeAt(0)));this.frames.push({name:"SYLT",value:e,language:r,description:n,type:t,timestampFormat:i,size:J(e,n.length)})}constructor(t){if(!t||"object"!=typeof t||!("byteLength"in t))throw new Error("First argument should be an instance of ArrayBuffer or Buffer");this.arrayBuffer=t,this.padding=4096,this.frames=[],this.url=""}setFrame(t,e){switch(t){case"TPE1":case"TCOM":case"TCON":{if(!Array.isArray(e))throw new Error(`${t} frame value should be an array of strings`);const i="TCON"===t?";":"/",o=e.join(i);this._setStringFrame(t,o);break}case"TLAN":case"TIT1":case"TIT2":case"TIT3":case"TALB":case"TPE2":case"TPE3":case"TPE4":case"TRCK":case"TPOS":case"TMED":case"TPUB":case"TCOP":case"TKEY":case"TEXT":case"TDAT":case"TSRC":this._setStringFrame(t,e);break;case"TBPM":case"TLEN":case"TYER":this._setIntegerFrame(t,e);break;case"USLT":if(e.language=e.language||"eng","object"!=typeof e||!("description"in e)||!("lyrics"in e))throw new Error("USLT frame value should be an object with keys description and lyrics");if(e.language&&!e.language.match(/[a-z]{3}/i))throw new Error("Language must be coded following the ISO 639-2 standards");this._setLyricsFrame(e.language,e.description,e.lyrics);break;case"APIC":if("object"!=typeof e||!("type"in e)||!("data"in e)||!("description"in e))throw new Error("APIC frame value should be an object with keys type, data and description");if(e.type<0||e.type>20)throw new Error("Incorrect APIC frame picture type");this._setPictureFrame(e.type,e.data,e.description,!!e.useUnicodeEncoding);break;case"TXXX":if("object"!=typeof e||!("description"in e)||!("value"in e))throw new Error("TXXX frame value should be an object with keys description and value");this._setUserStringFrame(e.description,e.value);break;case"WCOM":case"WCOP":case"WOAF":case"WOAR":case"WOAS":case"WORS":case"WPAY":case"WPUB":this._setUrlLinkFrame(t,e);break;case"COMM":if(e.language=e.language||"eng","object"!=typeof e||!("description"in e)||!("text"in e))throw new Error("COMM frame value should be an object with keys description and text");if(e.language&&!e.language.match(/[a-z]{3}/i))throw new Error("Language must be coded following the ISO 639-2 standards");this._setCommentFrame(e.language,e.description,e.text);break;case"PRIV":if("object"!=typeof e||!("id"in e)||!("data"in e))throw new Error("PRIV frame value should be an object with keys id and data");this._setPrivateFrame(e.id,e.data);break;case"IPLS":if(!Array.isArray(e)||!Array.isArray(e[0]))throw new Error("IPLS frame value should be an array of pairs");this._setPairedTextFrame(t,e);break;case"SYLT":if("object"!=typeof e||!("type"in e)||!("text"in e)||!("timestampFormat"in e))throw new Error("SYLT frame value should be an object with keys type, text and timestampFormat");if(!Array.isArray(e.text)||!Array.isArray(e.text[0]))throw new Error("SYLT frame text value should be an array of pairs");if(e.type<0||e.type>6)throw new Error("Incorrect SYLT frame content type");if(e.timestampFormat<1||e.timestampFormat>2)throw new Error("Incorrect SYLT frame time stamp format");e.language=e.language||"eng",e.description=e.description||"",this._setSynchronisedLyricsFrame(e.type,e.text,e.timestampFormat,e.language,e.description);break;default:throw new Error(`Unsupported frame ${t}`)}return this}removeTag(){if(this.arrayBuffer.byteLength<10)return;const t=new Uint8Array(this.arrayBuffer),e=t[3],i=((o=[t[6],t[7],t[8],t[9]])[0]<<21)+(o[1]<<14)+(o[2]<<7)+o[3]+10;var o,a;73!==(a=t)[0]||68!==a[1]||51!==a[2]||e<2||e>4||(this.arrayBuffer=new Uint8Array(t.subarray(i)).buffer)}addTag(){this.removeTag();const t=[255,254],e=10+this.frames.reduce(((t,e)=>t+e.size),0)+this.padding,i=new ArrayBuffer(this.arrayBuffer.byteLength+e),o=new Uint8Array(i);let a=0,n=[];return n=[73,68,51,3],o.set(n,a),a+=n.length,a++,a++,n=function(t){const e=127;return[t>>>21&e,t>>>14&e,t>>>7&e,t&e]}(e-10),o.set(n,a),a+=n.length,this.frames.forEach((e=>{switch(n=z(e.name),o.set(n,a),a+=n.length,n=j(e.size-10),o.set(n,a),a+=n.length,a+=2,e.name){case"WCOM":case"WCOP":case"WOAF":case"WOAR":case"WOAS":case"WORS":case"WPAY":case"WPUB":n=z(e.value),o.set(n,a),a+=n.length;break;case"TPE1":case"TCOM":case"TCON":case"TLAN":case"TIT1":case"TIT2":case"TIT3":case"TALB":case"TPE2":case"TPE3":case"TPE4":case"TRCK":case"TPOS":case"TKEY":case"TMED":case"TPUB":case"TCOP":case"TEXT":case"TSRC":n=[1].concat(t),o.set(n,a),a+=n.length,n=H(e.value),o.set(n,a),a+=n.length;break;case"TXXX":case"USLT":case"COMM":n=[1],"USLT"!==e.name&&"COMM"!==e.name||(n=n.concat(e.language)),n=n.concat(t),o.set(n,a),a+=n.length,n=H(e.description),o.set(n,a),a+=n.length,n=[0,0].concat(t),o.set(n,a),a+=n.length,n=H(e.value),o.set(n,a),a+=n.length;break;case"TBPM":case"TLEN":case"TDAT":case"TYER":a++,n=z(e.value),o.set(n,a),a+=n.length;break;case"PRIV":n=z(e.id),o.set(n,a),a+=n.length,a++,o.set(new Uint8Array(e.value),a),a+=e.value.byteLength;break;case"APIC":n=[e.useUnicodeEncoding?1:0],o.set(n,a),a+=n.length,n=z(e.mimeType),o.set(n,a),a+=n.length,n=[0,e.pictureType],o.set(n,a),a+=n.length,e.useUnicodeEncoding?(n=[].concat(t),o.set(n,a),a+=n.length,n=H(e.description),o.set(n,a),a+=n.length,a+=2):(n=z(e.description),o.set(n,a),a+=n.length,a++),o.set(new Uint8Array(e.value),a),a+=e.value.byteLength;break;case"IPLS":n=[1],o.set(n,a),a+=n.length,e.value.forEach((e=>{n=[].concat(t),o.set(n,a),a+=n.length,n=H(e[0].toString()),o.set(n,a),a+=n.length,n=[0,0].concat(t),o.set(n,a),a+=n.length,n=H(e[1].toString()),o.set(n,a),a+=n.length,n=[0,0],o.set(n,a),a+=n.length}));break;case"SYLT":n=[1].concat(e.language).concat(e.timestampFormat).concat(e.type),o.set(n,a),a+=n.length,n=[].concat(t),o.set(n,a),a+=n.length,n=H(e.description),o.set(n,a),a+=n.length,a+=2,e.value.forEach((e=>{n=[].concat(t),o.set(n,a),a+=n.length,n=H(e[0].toString()),o.set(n,a),a+=n.length,n=[0,0],o.set(n,a),a+=n.length,n=j(e[1]),o.set(n,a),a+=n.length}))}})),a+=this.padding,o.set(new Uint8Array(this.arrayBuffer),a),this.arrayBuffer=i,i}getBlob(){return new Blob([this.arrayBuffer],{type:"audio/mpeg"})}getURL(){return this.url||(this.url=URL.createObjectURL(this.getBlob())),this.url}revokeURL(){URL.revokeObjectURL(this.url)}}const Z={version:"1.0.3",debug:!1,fetchFn:fetch.bind(window)};class X{constructor(){this._vector=new Float32Array,this._position=0,this._frameCount=0}get vector(){return this._vector}get position(){return this._position}get startIndex(){return 2*this._position}get frameCount(){return this._frameCount}get endIndex(){return 2*(this._position+this._frameCount)}clear(){this.receive(this._frameCount),this.rewind()}put(t){this._frameCount+=t}putSamples(t,e,i=0){const o=2*(e=e||0);i>=0||(i=(t.length-o)/2);const a=2*i;this.ensureCapacity(i+this._frameCount);const n=this.endIndex;this.vector.set(t.subarray(o,o+a),n),this._frameCount+=i}putBuffer(t,e,i=0){e=e||0,i>=0||(i=t.frameCount-e),this.putSamples(t.vector,t.position+e,i)}receive(t){t>=0&&!(t>this._frameCount)||(t=this.frameCount),this._frameCount-=t,this._position+=t}receiveSamples(t,e=0){const i=2*e,o=this.startIndex;t.set(this._vector.subarray(o,o+i)),this.receive(e)}extract(t,e=0,i=0){const o=this.startIndex+2*e,a=2*i;t.set(this._vector.subarray(o,o+a))}ensureCapacity(t=0){const e=parseInt(2*t);if(this._vector.length<e){const t=new Float32Array(e);t.set(this._vector.subarray(this.startIndex,this.endIndex)),this._vector=t,this._position=0}else this.rewind()}ensureAdditionalCapacity(t=0){this.ensureCapacity(this._frameCount+t)}rewind(){this._position>0&&(this._vector.set(this._vector.subarray(this.startIndex,this.endIndex)),this._position=0)}}class Q{constructor(t){t?(this._inputBuffer=new X,this._outputBuffer=new X):this._inputBuffer=this._outputBuffer=null}get inputBuffer(){return this._inputBuffer}set inputBuffer(t){this._inputBuffer=t}get outputBuffer(){return this._outputBuffer}set outputBuffer(t){this._outputBuffer=t}clear(){this._inputBuffer.clear(),this._outputBuffer.clear()}}class tt extends Q{constructor(t){super(t),this.reset(),this._rate=1}set rate(t){this._rate=t}reset(){this.slopeCount=0,this.prevSampleL=0,this.prevSampleR=0}clone(){const t=new tt;return t.rate=this._rate,t}process(){const t=this._inputBuffer.frameCount;this._outputBuffer.ensureAdditionalCapacity(t/this._rate+1);const e=this.transpose(t);this._inputBuffer.receive(),this._outputBuffer.put(e)}transpose(t=0){if(0===t)return 0;const e=this._inputBuffer.vector,i=this._inputBuffer.startIndex,o=this._outputBuffer.vector,a=this._outputBuffer.endIndex;let n=0,r=0;for(;this.slopeCount<1;)o[a+2*r]=(1-this.slopeCount)*this.prevSampleL+this.slopeCount*e[i],o[a+2*r+1]=(1-this.slopeCount)*this.prevSampleR+this.slopeCount*e[i+1],r+=1,this.slopeCount+=this._rate;if(this.slopeCount-=1,1!==t)t:for(;;){for(;this.slopeCount>1;)if(this.slopeCount-=1,n+=1,n>=t-1)break t;const s=i+2*n;o[a+2*r]=(1-this.slopeCount)*e[s]+this.slopeCount*e[s+2],o[a+2*r+1]=(1-this.slopeCount)*e[s+1]+this.slopeCount*e[s+3],r+=1,this.slopeCount+=this._rate}return this.prevSampleL=e[i+2*t-2],this.prevSampleR=e[i+2*t-1],r}}class et{constructor(t){this._pipe=t}get pipe(){return this._pipe}get inputBuffer(){return this._pipe.inputBuffer}get outputBuffer(){return this._pipe.outputBuffer}fillInputBuffer(){throw new Error("fillInputBuffer() not overridden")}fillOutputBuffer(t=0){for(;this.outputBuffer.frameCount<t;){const t=16384-this.inputBuffer.frameCount;if(this.fillInputBuffer(t),this.inputBuffer.frameCount<16384)break;this._pipe.process()}}clear(){this._pipe.clear()}}const it=function(){};class ot extends et{constructor(t,e,i=it){super(e),this.callback=i,this.sourceSound=t,this.historyBufferSize=22050,this._sourcePosition=0,this.outputBufferPosition=0,this._position=0}get position(){return this._position}set position(t){if(t>this._position)throw new RangeError("New position may not be greater than current position");const e=this.outputBufferPosition-(this._position-t);if(e<0)throw new RangeError("New position falls outside of history buffer");this.outputBufferPosition=e,this._position=t}get sourcePosition(){return this._sourcePosition}set sourcePosition(t){this.clear(),this._sourcePosition=t}onEnd(){this.callback()}fillInputBuffer(t=0){const e=new Float32Array(2*t),i=this.sourceSound.extract(e,t,this._sourcePosition);this._sourcePosition+=i,this.inputBuffer.putSamples(e,0,i)}extract(t,e=0){this.fillOutputBuffer(this.outputBufferPosition+e);const i=Math.min(e,this.outputBuffer.frameCount-this.outputBufferPosition);this.outputBuffer.extract(t,this.outputBufferPosition,i);const o=this.outputBufferPosition+i;return this.outputBufferPosition=Math.min(this.historyBufferSize,o),this.outputBuffer.receive(Math.max(o-this.historyBufferSize,0)),this._position+=i,i}handleSampleData(t){this.extract(t.data,4096)}clear(){super.clear(),this.outputBufferPosition=0}}const at=[[124,186,248,310,372,434,496,558,620,682,744,806,868,930,992,1054,1116,1178,1240,1302,1364,1426,1488,0],[-100,-75,-50,-25,25,50,75,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[-20,-15,-10,-5,5,10,15,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[-4,-3,-2,-1,1,2,3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],nt=-10/1.5;class rt extends Q{constructor(t){super(t),this._quickSeek=!0,this.midBufferDirty=!1,this.midBuffer=null,this.overlapLength=0,this.autoSeqSetting=!0,this.autoSeekSetting=!0,this._tempo=1,this.setParameters(44100,0,0,8)}clear(){super.clear(),this.clearMidBuffer()}clearMidBuffer(){this.midBufferDirty&&(this.midBufferDirty=!1,this.midBuffer=null)}setParameters(t,e,i,o){t>0&&(this.sampleRate=t),o>0&&(this.overlapMs=o),e>0?(this.sequenceMs=e,this.autoSeqSetting=!1):this.autoSeqSetting=!0,i>0?(this.seekWindowMs=i,this.autoSeekSetting=!1):this.autoSeekSetting=!0,this.calculateSequenceParameters(),this.calculateOverlapLength(this.overlapMs),this.tempo=this._tempo}set tempo(t){let e;this._tempo=t,this.calculateSequenceParameters(),this.nominalSkip=this._tempo*(this.seekWindowLength-this.overlapLength),this.skipFract=0,e=Math.floor(this.nominalSkip+.5),this.sampleReq=Math.max(e+this.overlapLength,this.seekWindowLength)+this.seekLength}get tempo(){return this._tempo}get inputChunkSize(){return this.sampleReq}get outputChunkSize(){return this.overlapLength+Math.max(0,this.seekWindowLength-2*this.overlapLength)}calculateOverlapLength(t=0){let e;e=this.sampleRate*t/1e3,e=e<16?16:e,e-=e%8,this.overlapLength=e,this.refMidBuffer=new Float32Array(2*this.overlapLength),this.midBuffer=new Float32Array(2*this.overlapLength)}checkLimits(t,e,i){return t<e?e:t>i?i:t}calculateSequenceParameters(){let t,e;this.autoSeqSetting&&(t=150+-50*this._tempo,t=this.checkLimits(t,50,125),this.sequenceMs=Math.floor(t+.5)),this.autoSeekSetting&&(e=28.333333333333332+nt*this._tempo,e=this.checkLimits(e,15,25),this.seekWindowMs=Math.floor(e+.5)),this.seekWindowLength=Math.floor(this.sampleRate*this.sequenceMs/1e3),this.seekLength=Math.floor(this.sampleRate*this.seekWindowMs/1e3)}set quickSeek(t){this._quickSeek=t}clone(){const t=new rt;return t.tempo=this._tempo,t.setParameters(this.sampleRate,this.sequenceMs,this.seekWindowMs,this.overlapMs),t}seekBestOverlapPosition(){return this._quickSeek?this.seekBestOverlapPositionStereoQuick():this.seekBestOverlapPositionStereo()}seekBestOverlapPositionStereo(){let t,e,i,o=0;for(this.preCalculateCorrelationReferenceStereo(),t=0,e=Number.MIN_VALUE;o<this.seekLength;o+=1)i=this.calculateCrossCorrelationStereo(2*o,this.refMidBuffer),i>e&&(e=i,t=o);return t}seekBestOverlapPositionStereoQuick(){let t,e,i,o,a,n=0;for(this.preCalculateCorrelationReferenceStereo(),e=Number.MIN_VALUE,t=0,o=0,a=0;n<4;n+=1){let r=0;for(;at[n][r]&&(a=o+at[n][r],!(a>=this.seekLength));)i=this.calculateCrossCorrelationStereo(2*a,this.refMidBuffer),i>e&&(e=i,t=a),r+=1;o=t}return t}preCalculateCorrelationReferenceStereo(){let t,e,i=0;for(;i<this.overlapLength;i+=1)e=i*(this.overlapLength-i),t=2*i,this.refMidBuffer[t]=this.midBuffer[t]*e,this.refMidBuffer[t+1]=this.midBuffer[t+1]*e}calculateCrossCorrelationStereo(t,e){const i=this._inputBuffer.vector;t+=this._inputBuffer.startIndex;let o=0,a=2;const n=2*this.overlapLength;let r;for(;a<n;a+=2)r=a+t,o+=i[r]*e[a]+i[r+1]*e[a+1];return o}overlap(t){this.overlapStereo(2*t)}overlapStereo(t){const e=this._inputBuffer.vector;t+=this._inputBuffer.startIndex;const i=this._outputBuffer.vector,o=this._outputBuffer.endIndex;let a,n,r=0;const s=1/this.overlapLength;let l,d,u;for(;r<this.overlapLength;r+=1)n=(this.overlapLength-r)*s,l=r*s,a=2*r,d=a+t,u=a+o,i[u+0]=e[d+0]*l+this.midBuffer[a+0]*n,i[u+1]=e[d+1]*l+this.midBuffer[a+1]*n}process(){let t,e,i;if(null===this.midBuffer){if(this._inputBuffer.frameCount<this.overlapLength)return;this.midBuffer=new Float32Array(2*this.overlapLength),this._inputBuffer.receiveSamples(this.midBuffer,this.overlapLength)}for(;this._inputBuffer.frameCount>=this.sampleReq;){t=this.seekBestOverlapPosition(),this._outputBuffer.ensureAdditionalCapacity(this.overlapLength),this.overlap(Math.floor(t)),this._outputBuffer.put(this.overlapLength),e=this.seekWindowLength-2*this.overlapLength,e>0&&this._outputBuffer.putBuffer(this._inputBuffer,t+this.overlapLength,e);const o=this._inputBuffer.startIndex+2*(t+this.seekWindowLength-this.overlapLength);this.midBuffer.set(this._inputBuffer.vector.subarray(o,o+2*this.overlapLength)),this.skipFract+=this.nominalSkip,i=Math.floor(this.skipFract),this.skipFract-=i,this._inputBuffer.receive(i)}}}const st=function(t,e){return(t>e?t-e:e-t)>1e-10};class lt{constructor(){this.transposer=new tt(!1),this.stretch=new rt(!1),this._inputBuffer=new X,this._intermediateBuffer=new X,this._outputBuffer=new X,this._rate=0,this._tempo=0,this.virtualPitch=1,this.virtualRate=1,this.virtualTempo=1,this.calculateEffectiveRateAndTempo()}clear(){this.transposer.clear(),this.stretch.clear()}clone(){const t=new lt;return t.rate=this.rate,t.tempo=this.tempo,t}get rate(){return this._rate}set rate(t){this.virtualRate=t,this.calculateEffectiveRateAndTempo()}set rateChange(t){this._rate=1+.01*t}get tempo(){return this._tempo}set tempo(t){this.virtualTempo=t,this.calculateEffectiveRateAndTempo()}set tempoChange(t){this.tempo=1+.01*t}set pitch(t){this.virtualPitch=t,this.calculateEffectiveRateAndTempo()}set pitchOctaves(t){this.pitch=Math.exp(.69314718056*t),this.calculateEffectiveRateAndTempo()}set pitchSemitones(t){this.pitchOctaves=t/12}get inputBuffer(){return this._inputBuffer}get outputBuffer(){return this._outputBuffer}calculateEffectiveRateAndTempo(){const t=this._tempo,e=this._rate;this._tempo=this.virtualTempo/this.virtualPitch,this._rate=this.virtualRate*this.virtualPitch,st(this._tempo,t)&&(this.stretch.tempo=this._tempo),st(this._rate,e)&&(this.transposer.rate=this._rate),this._rate>1?this._outputBuffer!=this.transposer.outputBuffer&&(this.stretch.inputBuffer=this._inputBuffer,this.stretch.outputBuffer=this._intermediateBuffer,this.transposer.inputBuffer=this._intermediateBuffer,this.transposer.outputBuffer=this._outputBuffer):this._outputBuffer!=this.stretch.outputBuffer&&(this.transposer.inputBuffer=this._inputBuffer,this.transposer.outputBuffer=this._intermediateBuffer,this.stretch.inputBuffer=this._intermediateBuffer,this.stretch.outputBuffer=this._outputBuffer)}process(){this._rate>1?(this.stretch.process(),this.transposer.process()):(this.transposer.process(),this.stretch.process())}}class dt{constructor(t){this.buffer=t,this._position=0}get dualChannel(){return this.buffer.numberOfChannels>1}get position(){return this._position}set position(t){this._position=t}extract(t,e=0,i=0){this.position=i;let o=this.buffer.getChannelData(0),a=this.dualChannel?this.buffer.getChannelData(1):this.buffer.getChannelData(0),n=0;for(;n<e;n++)t[2*n]=o[n+i],t[2*n+1]=a[n+i];return Math.min(e,o.length-i)}}const ut=function(t){const e=Math.floor(t/60);return`${e}:${function(t,e,i){return i=i||"0",(t+="").length>=e?t:new Array(e-t.length+1).join(i)+t}(parseInt(t-60*e),2)}`},ct=function(t){const e=this.timePlayed,i=this.sampleRate;if(this.sourcePosition=t,this.timePlayed=t/i,e!==this.timePlayed){const t=new CustomEvent("play",{detail:{timePlayed:this.timePlayed,formattedTimePlayed:this.formattedTimePlayed,percentagePlayed:this.percentagePlayed}});this._node.dispatchEvent(t)}};class ht{constructor(t,e,i,o=it){this._soundtouch=new lt;const a=new dt(e);this.timePlayed=0,this.sourcePosition=0,this._filter=new ot(a,this._soundtouch,o),this._node=function(t,e,i=it,o=4096){const a=t.createScriptProcessor(o,2,2),n=new Float32Array(2*o);return a.onaudioprocess=t=>{let a=t.outputBuffer.getChannelData(0),r=t.outputBuffer.getChannelData(1),s=e.extract(n,o);i(e.sourcePosition),0===s&&e.onEnd();let l=0;for(;l<s;l++)a[l]=n[2*l],r[l]=n[2*l+1]},a}(t,this._filter,(t=>ct.call(this,t)),i),this.tempo=1,this.rate=1,this.duration=e.duration,this.sampleRate=t.sampleRate,this.listeners=[]}get formattedDuration(){return ut(this.duration)}get formattedTimePlayed(){return ut(this.timePlayed)}get percentagePlayed(){return 100*this._filter.sourcePosition/(this.duration*this.sampleRate)}set percentagePlayed(t){this._filter.sourcePosition=parseInt(t*this.duration*this.sampleRate),this.sourcePosition=this._filter.sourcePosition,this.timePlayed=this.sourcePosition/this.sampleRate}get node(){return this._node}set pitch(t){this._soundtouch.pitch=t}set pitchSemitones(t){this._soundtouch.pitchSemitones=t}set rate(t){this._soundtouch.rate=t}set tempo(t){this._soundtouch.tempo=t}connect(t){this._node.connect(t)}disconnect(){this._node.disconnect()}on(t,e){this.listeners.push({name:t,cb:e}),this._node.addEventListener(t,(t=>e(t.detail)))}off(t=null){let e=this.listeners;t&&(e=e.filter((e=>e.name===t))),e.forEach((t=>{this._node.removeEventListener(t.name,(e=>t.cb(e.detail)))}))}}const pt=(...t)=>{if(Z.debug)return console.log(`%c✦ chaimu.js v${Z.version} ✦`,"background: #000; color: #fff; padding: 0 8px",...t)},gt=["playing","ratechange","play","waiting","pause","seeked"];function mt(){const t=window.AudioContext||window.webkitAudioContext;return t?new t:void 0}class vt{static name="BasePlayer";chaimu;_src;fetch;constructor(t,e){this.chaimu=t,this._src=e,this.fetch=Z.fetchFn}async init(){return new Promise((t=>t(this)))}clear(){return new Promise((t=>t(this)))}lipSync(t=!1){return this}handleVideoEvent=t=>(pt(`handle video ${t.type}`),this.lipSync(t.type),this);removeVideoEvents(){for(const t of gt)this.chaimu.video.removeEventListener(t,this.handleVideoEvent);return this}addVideoEvents(){for(const t of gt)this.chaimu.video.addEventListener(t,this.handleVideoEvent);return this}async play(){return new Promise((t=>t(this)))}async pause(){return new Promise((t=>t(this)))}get name(){return this.constructor.name}set src(t){this._src=t}get src(){return this._src}get currentSrc(){return this._src}set volume(t){}get volume(){return 0}get playbackRate(){return 0}set playbackRate(t){}get currentTime(){return 0}}class ft extends vt{static name="AudioPlayer";audio;gainNode;audioSource;constructor(t,e){super(t,e),this.updateAudio()}initAudioBooster(){return this.chaimu.audioContext?(this.gainNode&&this.audioSource&&(this.audioSource.disconnect(this.gainNode),this.gainNode.disconnect()),this.gainNode=this.chaimu.audioContext.createGain(),this.gainNode.connect(this.chaimu.audioContext.destination),this.audioSource=this.chaimu.audioContext.createMediaElementSource(this.audio),this.audioSource.connect(this.gainNode),this):this}updateAudio(){return this.audio=new Audio(this.src),this.audio.crossOrigin="anonymous",this}async init(){return new Promise((t=>(this.updateAudio(),this.initAudioBooster(),t(this))))}audioErrorHandle=t=>{console.error("[AudioPlayer]",t)};lipSync(t=!1){if(pt("[AudioPlayer] lipsync video",this.chaimu.video),!this.chaimu.video)return this;if(this.audio.currentTime=this.chaimu.video.currentTime,this.audio.playbackRate=this.chaimu.video.playbackRate,!t)return pt("[AudioPlayer] lipsync mode isn't set"),this;switch(pt(`[AudioPlayer] lipsync mode is ${t}`),t){case"play":case"playing":case"seeked":return this.chaimu.video.paused||this.syncPlay(),this;case"pause":case"waiting":return this.pause(),this;default:return this}}async clear(){return new Promise((t=>(this.audio.pause(),this.audio.src="",this.audio.removeAttribute("src"),t(this))))}syncPlay(){return pt("[AudioPlayer] sync play called"),this.audio.play().catch(this.audioErrorHandle),this}async play(){return pt("[AudioPlayer] play called"),await this.audio.play().catch(this.audioErrorHandle),this}async pause(){return new Promise((t=>(pt("[AudioPlayer] pause called"),this.audio.pause(),t(this))))}set src(t){this._src=t,t?this.audio.src=t:this.clear()}get src(){return this._src}get currentSrc(){return this.audio.currentSrc}set volume(t){this.gainNode?this.gainNode.gain.value=t:this.audio.volume=t}get volume(){return this.gainNode?this.gainNode.gain.value:this.audio.volume}get playbackRate(){return this.audio.playbackRate}set playbackRate(t){this.audio.playbackRate=t}get currentTime(){return this.audio.currentTime}}class bt extends vt{static name="ChaimuPlayer";audioBuffer;sourceNode;gainNode;audioShifter;cleanerRunned=!1;async fetchAudio(){if(!this._src)throw new Error("No audio source provided");if(!this.chaimu.audioContext)throw new Error("No audio context available");pt(`[ChaimuPlayer] Fetching audio from ${this._src}...`);try{const t=await this.fetch(this._src);pt("[ChaimuPlayer] Decoding fetched audio...");const e=await t.arrayBuffer();this.audioBuffer=await this.chaimu.audioContext.decodeAudioData(e)}catch(t){throw new Error(`Failed to fetch audio file, because ${t.message}`)}return this}initAudioBooster(){return this.chaimu.audioContext?(this.gainNode&&this.gainNode.disconnect(),this.gainNode=this.chaimu.audioContext.createGain(),this):this}async init(){return await this.fetchAudio(),this.initAudioBooster(),this}lipSync(t=!1){if(pt("[ChaimuPlayer] lipsync video",this.chaimu.video,this),!this.chaimu.video)return this;if(!t)return pt("[ChaimuPlayer] lipsync mode isn't set"),this;switch(pt(`[ChaimuPlayer] lipsync mode is ${t}`),t){case"play":case"playing":case"ratechange":case"seeked":return this.chaimu.video.paused||this.start(),this;case"pause":case"waiting":return this.pause(),this;default:return this}}async reopenCtx(){if(!this.chaimu.audioContext)throw new Error("No audio context available");try{await this.chaimu.audioContext.close()}catch{}return this}async clear(){if(!this.chaimu.audioContext)throw new Error("No audio context available");if(pt("clear audio context"),this.cleanerRunned=!0,await this.pause(),!this.gainNode)return this.cleanerRunned=!1,this;this.sourceNode&&(this.sourceNode.stop(),this.sourceNode.disconnect(this.gainNode),this.sourceNode=void 0),this.audioShifter&&(this.audioShifter._node.disconnect(this.gainNode),this.audioShifter=void 0),this.gainNode.disconnect();const t=this.volume;return this.gainNode=void 0,await this.reopenCtx(),this.chaimu.audioContext=mt(),this.initAudioBooster(),this.volume=t,this.cleanerRunned=!1,this}async start(){if(!this.chaimu.audioContext)throw new Error("No audio context available");if(!this.audioBuffer)throw new Error("The player isn't initialized");return!this.gainNode||this.audioShifter&&this.audioShifter.duration<this.chaimu.video.currentTime?(pt("Skip starting player"),this):this.cleanerRunned?(pt("The other cleaner is still running, waiting..."),this):(pt("starting audio"),await this.clear(),await this.play(),this.audioShifter=new ht(this.chaimu.audioContext,this.audioBuffer,1024),this.audioShifter.tempo=this.chaimu.video.playbackRate,this.audioShifter.percentagePlayed=this.chaimu.video.currentTime/this.audioShifter.duration,this.sourceNode=this.chaimu.audioContext.createBufferSource(),this.sourceNode.buffer=null,this.sourceNode.connect(this.gainNode),this.audioShifter.connect(this.gainNode),this.gainNode.connect(this.chaimu.audioContext.destination),this.sourceNode.start(void 0,this.chaimu.video.currentTime),this)}async pause(){if(!this.chaimu.audioContext)throw new Error("No audio context available");return"running"!==this.chaimu.audioContext.state||await this.chaimu.audioContext.suspend(),this}async play(){if(!this.chaimu.audioContext)throw new Error("No audio context available");return await this.chaimu.audioContext.resume(),this}set src(t){this._src=t}get src(){return this._src}get currentSrc(){return this._src}set volume(t){this.gainNode&&(this.gainNode.gain.value=t)}get volume(){return this.gainNode?this.gainNode.gain.value:0}set playbackRate(t){if(!this.audioShifter)throw new Error("No audio source available");this.audioShifter.pitch=t}get playbackRate(){return this.audioShifter?._soundtouch?.tempo??0}get currentTime(){return this.chaimu.video.currentTime}}class wt{_debug=!1;audioContext;player;video;constructor({url:t,video:e,debug:i=!1,fetchFn:o=Z.fetchFn,preferAudio:a=!1}){this._debug=Z.debug=i,Z.fetchFn=o,this.audioContext=mt(),this.player=this.audioContext&&!a?new bt(this,t):new ft(this,t),this.video=e}async init(){await this.player.init(),this.video&&!this.video.paused&&this.player.lipSync("play"),this.player.addVideoEvents()}set debug(t){this._debug=Z.debug=t}get debug(){return this._debug}}const yt={host:"api.browser.yandex.ru",hostVOT:"vot.toil.cc/v1",hostWorker:"vot-worker.toil.cc",mediaProxy:"media-proxy.toil.cc",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 YaBrowser/24.12.0.0 Safari/537.36",componentVersion:"24.12.3.780",hmac:"bt8xH3VOlb4mqf0nqAibnDOoiPlXsisf",defaultDuration:343,minChunkSize:5295308,loggerLevel:1,version:"2.2.0"};var xt;!function(t){t[t.DEBUG=0]="DEBUG",t[t.INFO=1]="INFO",t[t.WARN=2]="WARN",t[t.ERROR=3]="ERROR",t[t.SILENCE=4]="SILENCE"}(xt||(xt={}));class St{static prefix=`[vot.js v${yt.version}]`;static canLog(t){return yt.loggerLevel<=t}static log(...t){St.canLog(xt.DEBUG)&&console.log(St.prefix,...t)}static info(...t){St.canLog(xt.INFO)&&console.info(St.prefix,...t)}static warn(...t){St.canLog(xt.WARN)&&console.warn(St.prefix,...t)}static error(...t){St.canLog(xt.ERROR)&&console.error(St.prefix,...t)}}function kt(){let t=0,e=0;for(let i=0;i<28;i+=7){let o=this.buf[this.pos++];if(t|=(127&o)<<i,0==(128&o))return this.assertBounds(),[t,e]}let i=this.buf[this.pos++];if(t|=(15&i)<<28,e=(112&i)>>4,0==(128&i))return this.assertBounds(),[t,e];for(let i=3;i<=31;i+=7){let o=this.buf[this.pos++];if(e|=(127&o)<<i,0==(128&o))return this.assertBounds(),[t,e]}throw new Error("invalid varint")}function Tt(t,e,i){for(let o=0;o<28;o+=7){const a=t>>>o,n=!(a>>>7==0&&0==e),r=255&(n?128|a:a);if(i.push(r),!n)return}const o=t>>>28&15|(7&e)<<4,a=!(e>>3==0);if(i.push(255&(a?128|o:o)),a){for(let t=3;t<31;t+=7){const o=e>>>t,a=!(o>>>7==0),n=255&(a?128|o:o);if(i.push(n),!a)return}i.push(e>>>31&1)}}const Ct=4294967296;function It(t){const e="-"===t[0];e&&(t=t.slice(1));const i=1e6;let o=0,a=0;function n(e,n){const r=Number(t.slice(e,n));a*=i,o=o*i+r,o>=Ct&&(a+=o/Ct|0,o%=Ct)}return n(-24,-18),n(-18,-12),n(-12,-6),n(-6),e?_t(o,a):Lt(o,a)}function Pt(t,e){if(({lo:t,hi:e}=function(t,e){return{lo:t>>>0,hi:e>>>0}}(t,e)),e<=2097151)return String(Ct*e+t);const i=16777215&(t>>>24|e<<8),o=e>>16&65535;let a=(16777215&t)+6777216*i+6710656*o,n=i+8147497*o,r=2*o;const s=1e7;return a>=s&&(n+=Math.floor(a/s),a%=s),n>=s&&(r+=Math.floor(n/s),n%=s),r.toString()+At(n)+At(a)}function Lt(t,e){return{lo:0|t,hi:0|e}}function _t(t,e){return e=~e,t?t=1+~t:e+=1,Lt(t,e)}const At=t=>{const e=String(t);return"0000000".slice(e.length)+e};function Ot(t,e){if(t>=0){for(;t>127;)e.push(127&t|128),t>>>=7;e.push(t)}else{for(let i=0;i<9;i++)e.push(127&t|128),t>>=7;e.push(1)}}function Vt(){let t=this.buf[this.pos++],e=127&t;if(0==(128&t))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(127&t)<<7,0==(128&t))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(127&t)<<14,0==(128&t))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(127&t)<<21,0==(128&t))return this.assertBounds(),e;t=this.buf[this.pos++],e|=(15&t)<<28;for(let e=5;0!=(128&t)&&e<10;e++)t=this.buf[this.pos++];if(0!=(128&t))throw new Error("invalid varint");return this.assertBounds(),e>>>0}const Mt=Et();function Et(){const t=new DataView(new ArrayBuffer(8));if("function"==typeof BigInt&&"function"==typeof t.getBigInt64&&"function"==typeof t.getBigUint64&&"function"==typeof t.setBigInt64&&"function"==typeof t.setBigUint64&&("object"!=typeof process||"object"!=typeof process.env||"1"!==process.env.BUF_BIGINT_DISABLE)){const e=BigInt("-9223372036854775808"),i=BigInt("9223372036854775807"),o=BigInt("0"),a=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(t){const o="bigint"==typeof t?t:BigInt(t);if(o>i||o<e)throw new Error(`invalid int64: ${t}`);return o},uParse(t){const e="bigint"==typeof t?t:BigInt(t);if(e>a||e<o)throw new Error(`invalid uint64: ${t}`);return e},enc(e){return t.setBigInt64(0,this.parse(e),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},uEnc(e){return t.setBigInt64(0,this.uParse(e),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},dec:(e,i)=>(t.setInt32(0,e,!0),t.setInt32(4,i,!0),t.getBigInt64(0,!0)),uDec:(e,i)=>(t.setInt32(0,e,!0),t.setInt32(4,i,!0),t.getBigUint64(0,!0))}}return{zero:"0",supported:!1,parse:t=>("string"!=typeof t&&(t=t.toString()),Bt(t),t),uParse:t=>("string"!=typeof t&&(t=t.toString()),Nt(t),t),enc:t=>("string"!=typeof t&&(t=t.toString()),Bt(t),It(t)),uEnc:t=>("string"!=typeof t&&(t=t.toString()),Nt(t),It(t)),dec:(t,e)=>function(t,e){let i=Lt(t,e);const o=2147483648&i.hi;o&&(i=_t(i.lo,i.hi));const a=Pt(i.lo,i.hi);return o?"-"+a:a}(t,e),uDec:(t,e)=>Pt(t,e)}}function Bt(t){if(!/^-?[0-9]+$/.test(t))throw new Error("invalid int64: "+t)}function Nt(t){if(!/^[0-9]+$/.test(t))throw new Error("invalid uint64: "+t)}const Rt=Symbol.for("@bufbuild/protobuf/text-encoding");function $t(){if(null==globalThis[Rt]){const t=new globalThis.TextEncoder,e=new globalThis.TextDecoder;globalThis[Rt]={encodeUtf8:e=>t.encode(e),decodeUtf8:t=>e.decode(t),checkUtf8(t){try{return encodeURIComponent(t),!0}catch(t){return!1}}}}return globalThis[Rt]}var Dt;!function(t){t[t.Varint=0]="Varint",t[t.Bit64=1]="Bit64",t[t.LengthDelimited=2]="LengthDelimited",t[t.StartGroup=3]="StartGroup",t[t.EndGroup=4]="EndGroup",t[t.Bit32=5]="Bit32"}(Dt||(Dt={}));const Ft=34028234663852886e22,Ut=-34028234663852886e22;class qt{constructor(t=$t().encodeUtf8){this.encodeUtf8=t,this.stack=[],this.chunks=[],this.buf=[]}finish(){this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]);let t=0;for(let e=0;e<this.chunks.length;e++)t+=this.chunks[e].length;let e=new Uint8Array(t),i=0;for(let t=0;t<this.chunks.length;t++)e.set(this.chunks[t],i),i+=this.chunks[t].length;return this.chunks=[],e}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let t=this.finish(),e=this.stack.pop();if(!e)throw new Error("invalid state, fork stack empty");return this.chunks=e.chunks,this.buf=e.buf,this.uint32(t.byteLength),this.raw(t)}tag(t,e){return this.uint32((t<<3|e)>>>0)}raw(t){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(t),this}uint32(t){for(jt(t);t>127;)this.buf.push(127&t|128),t>>>=7;return this.buf.push(t),this}int32(t){return Ht(t),Ot(t,this.buf),this}bool(t){return this.buf.push(t?1:0),this}bytes(t){return this.uint32(t.byteLength),this.raw(t)}string(t){let e=this.encodeUtf8(t);return this.uint32(e.byteLength),this.raw(e)}float(t){!function(t){if("string"==typeof t){const e=t;if(t=Number(t),isNaN(t)&&"NaN"!==e)throw new Error("invalid float32: "+e)}else if("number"!=typeof t)throw new Error("invalid float32: "+typeof t);if(Number.isFinite(t)&&(t>Ft||t<Ut))throw new Error("invalid float32: "+t)}(t);let e=new Uint8Array(4);return new DataView(e.buffer).setFloat32(0,t,!0),this.raw(e)}double(t){let e=new Uint8Array(8);return new DataView(e.buffer).setFloat64(0,t,!0),this.raw(e)}fixed32(t){jt(t);let e=new Uint8Array(4);return new DataView(e.buffer).setUint32(0,t,!0),this.raw(e)}sfixed32(t){Ht(t);let e=new Uint8Array(4);return new DataView(e.buffer).setInt32(0,t,!0),this.raw(e)}sint32(t){return Ht(t),Ot(t=(t<<1^t>>31)>>>0,this.buf),this}sfixed64(t){let e=new Uint8Array(8),i=new DataView(e.buffer),o=Mt.enc(t);return i.setInt32(0,o.lo,!0),i.setInt32(4,o.hi,!0),this.raw(e)}fixed64(t){let e=new Uint8Array(8),i=new DataView(e.buffer),o=Mt.uEnc(t);return i.setInt32(0,o.lo,!0),i.setInt32(4,o.hi,!0),this.raw(e)}int64(t){let e=Mt.enc(t);return Tt(e.lo,e.hi,this.buf),this}sint64(t){let e=Mt.enc(t),i=e.hi>>31;return Tt(e.lo<<1^i,(e.hi<<1|e.lo>>>31)^i,this.buf),this}uint64(t){let e=Mt.uEnc(t);return Tt(e.lo,e.hi,this.buf),this}}class zt{constructor(t,e=$t().decodeUtf8){this.decodeUtf8=e,this.varint64=kt,this.uint32=Vt,this.buf=t,this.len=t.length,this.pos=0,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength)}tag(){let t=this.uint32(),e=t>>>3,i=7&t;if(e<=0||i<0||i>5)throw new Error("illegal tag: field no "+e+" wire type "+i);return[e,i]}skip(t,e){let i=this.pos;switch(t){case Dt.Varint:for(;128&this.buf[this.pos++];);break;case Dt.Bit64:this.pos+=4;case Dt.Bit32:this.pos+=4;break;case Dt.LengthDelimited:let i=this.uint32();this.pos+=i;break;case Dt.StartGroup:for(;;){const[t,i]=this.tag();if(i===Dt.EndGroup){if(void 0!==e&&t!==e)throw new Error("invalid end group tag");break}this.skip(i,t)}break;default:throw new Error("cant skip wire type "+t)}return this.assertBounds(),this.buf.subarray(i,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){let t=this.uint32();return t>>>1^-(1&t)}int64(){return Mt.dec(...this.varint64())}uint64(){return Mt.uDec(...this.varint64())}sint64(){let[t,e]=this.varint64(),i=-(1&t);return t=(t>>>1|(1&e)<<31)^i,e=e>>>1^i,Mt.dec(t,e)}bool(){let[t,e]=this.varint64();return 0!==t||0!==e}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return Mt.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return Mt.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let t=this.uint32(),e=this.pos;return this.pos+=t,this.assertBounds(),this.buf.subarray(e,e+t)}string(){return this.decodeUtf8(this.bytes())}}function Ht(t){if("string"==typeof t)t=Number(t);else if("number"!=typeof t)throw new Error("invalid int32: "+typeof t);if(!Number.isInteger(t)||t>2147483647||t<-2147483648)throw new Error("invalid int32: "+t)}function jt(t){if("string"==typeof t)t=Number(t);else if("number"!=typeof t)throw new Error("invalid uint32: "+typeof t);if(!Number.isInteger(t)||t>4294967295||t<0)throw new Error("invalid uint32: "+t)}var Wt;function Gt(t){switch(t){case 0:case"NO_CONNECTION":return Wt.NO_CONNECTION;case 10:case"TRANSLATING":return Wt.TRANSLATING;case 20:case"STREAMING":return Wt.STREAMING;default:return Wt.UNRECOGNIZED}}!function(t){t[t.NO_CONNECTION=0]="NO_CONNECTION",t[t.TRANSLATING=10]="TRANSLATING",t[t.STREAMING=20]="STREAMING",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Wt||(Wt={}));const Yt={encode:(t,e=new qt)=>(""!==t.target&&e.uint32(10).string(t.target),""!==t.targetUrl&&e.uint32(18).string(t.targetUrl),e),decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={target:"",targetUrl:""};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 1:if(10!==t)break;a.target=i.string();continue;case 2:if(18!==t)break;a.targetUrl=i.string();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({target:he(t.target)?globalThis.String(t.target):"",targetUrl:he(t.targetUrl)?globalThis.String(t.targetUrl):""}),toJSON(t){const e={};return""!==t.target&&(e.target=t.target),""!==t.targetUrl&&(e.targetUrl=t.targetUrl),e},create:t=>Yt.fromPartial(t??{}),fromPartial(t){const e={target:"",targetUrl:""};return e.target=t.target??"",e.targetUrl=t.targetUrl??"",e}};const Jt={encode(t,e=new qt){""!==t.url&&e.uint32(26).string(t.url),void 0!==t.deviceId&&e.uint32(34).string(t.deviceId),!1!==t.firstRequest&&e.uint32(40).bool(t.firstRequest),0!==t.duration&&e.uint32(49).double(t.duration),0!==t.unknown0&&e.uint32(56).int32(t.unknown0),""!==t.language&&e.uint32(66).string(t.language),!1!==t.forceSourceLang&&e.uint32(72).bool(t.forceSourceLang),0!==t.unknown1&&e.uint32(80).int32(t.unknown1);for(const i of t.translationHelp)Yt.encode(i,e.uint32(90).fork()).join();return!1!==t.wasStream&&e.uint32(104).bool(t.wasStream),""!==t.responseLanguage&&e.uint32(114).string(t.responseLanguage),0!==t.unknown2&&e.uint32(120).int32(t.unknown2),0!==t.unknown3&&e.uint32(128).int32(t.unknown3),!1!==t.bypassCache&&e.uint32(136).bool(t.bypassCache),!1!==t.useNewModel&&e.uint32(144).bool(t.useNewModel),""!==t.videoTitle&&e.uint32(154).string(t.videoTitle),e},decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={url:"",deviceId:void 0,firstRequest:!1,duration:0,unknown0:0,language:"",forceSourceLang:!1,unknown1:0,translationHelp:[],wasStream:!1,responseLanguage:"",unknown2:0,unknown3:0,bypassCache:!1,useNewModel:!1,videoTitle:""};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 3:if(26!==t)break;a.url=i.string();continue;case 4:if(34!==t)break;a.deviceId=i.string();continue;case 5:if(40!==t)break;a.firstRequest=i.bool();continue;case 6:if(49!==t)break;a.duration=i.double();continue;case 7:if(56!==t)break;a.unknown0=i.int32();continue;case 8:if(66!==t)break;a.language=i.string();continue;case 9:if(72!==t)break;a.forceSourceLang=i.bool();continue;case 10:if(80!==t)break;a.unknown1=i.int32();continue;case 11:if(90!==t)break;a.translationHelp.push(Yt.decode(i,i.uint32()));continue;case 13:if(104!==t)break;a.wasStream=i.bool();continue;case 14:if(114!==t)break;a.responseLanguage=i.string();continue;case 15:if(120!==t)break;a.unknown2=i.int32();continue;case 16:if(128!==t)break;a.unknown3=i.int32();continue;case 17:if(136!==t)break;a.bypassCache=i.bool();continue;case 18:if(144!==t)break;a.useNewModel=i.bool();continue;case 19:if(154!==t)break;a.videoTitle=i.string();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({url:he(t.url)?globalThis.String(t.url):"",deviceId:he(t.deviceId)?globalThis.String(t.deviceId):void 0,firstRequest:!!he(t.firstRequest)&&globalThis.Boolean(t.firstRequest),duration:he(t.duration)?globalThis.Number(t.duration):0,unknown0:he(t.unknown0)?globalThis.Number(t.unknown0):0,language:he(t.language)?globalThis.String(t.language):"",forceSourceLang:!!he(t.forceSourceLang)&&globalThis.Boolean(t.forceSourceLang),unknown1:he(t.unknown1)?globalThis.Number(t.unknown1):0,translationHelp:globalThis.Array.isArray(t?.translationHelp)?t.translationHelp.map((t=>Yt.fromJSON(t))):[],wasStream:!!he(t.wasStream)&&globalThis.Boolean(t.wasStream),responseLanguage:he(t.responseLanguage)?globalThis.String(t.responseLanguage):"",unknown2:he(t.unknown2)?globalThis.Number(t.unknown2):0,unknown3:he(t.unknown3)?globalThis.Number(t.unknown3):0,bypassCache:!!he(t.bypassCache)&&globalThis.Boolean(t.bypassCache),useNewModel:!!he(t.useNewModel)&&globalThis.Boolean(t.useNewModel),videoTitle:he(t.videoTitle)?globalThis.String(t.videoTitle):""}),toJSON(t){const e={};return""!==t.url&&(e.url=t.url),void 0!==t.deviceId&&(e.deviceId=t.deviceId),!1!==t.firstRequest&&(e.firstRequest=t.firstRequest),0!==t.duration&&(e.duration=t.duration),0!==t.unknown0&&(e.unknown0=Math.round(t.unknown0)),""!==t.language&&(e.language=t.language),!1!==t.forceSourceLang&&(e.forceSourceLang=t.forceSourceLang),0!==t.unknown1&&(e.unknown1=Math.round(t.unknown1)),t.translationHelp?.length&&(e.translationHelp=t.translationHelp.map((t=>Yt.toJSON(t)))),!1!==t.wasStream&&(e.wasStream=t.wasStream),""!==t.responseLanguage&&(e.responseLanguage=t.responseLanguage),0!==t.unknown2&&(e.unknown2=Math.round(t.unknown2)),0!==t.unknown3&&(e.unknown3=Math.round(t.unknown3)),!1!==t.bypassCache&&(e.bypassCache=t.bypassCache),!1!==t.useNewModel&&(e.useNewModel=t.useNewModel),""!==t.videoTitle&&(e.videoTitle=t.videoTitle),e},create:t=>Jt.fromPartial(t??{}),fromPartial(t){const e={url:"",deviceId:void 0,firstRequest:!1,duration:0,unknown0:0,language:"",forceSourceLang:!1,unknown1:0,translationHelp:[],wasStream:!1,responseLanguage:"",unknown2:0,unknown3:0,bypassCache:!1,useNewModel:!1,videoTitle:""};return e.url=t.url??"",e.deviceId=t.deviceId??void 0,e.firstRequest=t.firstRequest??!1,e.duration=t.duration??0,e.unknown0=t.unknown0??0,e.language=t.language??"",e.forceSourceLang=t.forceSourceLang??!1,e.unknown1=t.unknown1??0,e.translationHelp=t.translationHelp?.map((t=>Yt.fromPartial(t)))||[],e.wasStream=t.wasStream??!1,e.responseLanguage=t.responseLanguage??"",e.unknown2=t.unknown2??0,e.unknown3=t.unknown3??0,e.bypassCache=t.bypassCache??!1,e.useNewModel=t.useNewModel??!1,e.videoTitle=t.videoTitle??"",e}};const Kt={encode:(t,e=new qt)=>(void 0!==t.url&&e.uint32(10).string(t.url),void 0!==t.duration&&e.uint32(17).double(t.duration),0!==t.status&&e.uint32(32).int32(t.status),void 0!==t.remainingTime&&e.uint32(40).int32(t.remainingTime),void 0!==t.unknown0&&e.uint32(48).int32(t.unknown0),""!==t.translationId&&e.uint32(58).string(t.translationId),void 0!==t.language&&e.uint32(66).string(t.language),void 0!==t.message&&e.uint32(74).string(t.message),e),decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={url:void 0,duration:void 0,status:0,remainingTime:void 0,unknown0:void 0,translationId:"",language:void 0,message:void 0};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 1:if(10!==t)break;a.url=i.string();continue;case 2:if(17!==t)break;a.duration=i.double();continue;case 4:if(32!==t)break;a.status=i.int32();continue;case 5:if(40!==t)break;a.remainingTime=i.int32();continue;case 6:if(48!==t)break;a.unknown0=i.int32();continue;case 7:if(58!==t)break;a.translationId=i.string();continue;case 8:if(66!==t)break;a.language=i.string();continue;case 9:if(74!==t)break;a.message=i.string();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({url:he(t.url)?globalThis.String(t.url):void 0,duration:he(t.duration)?globalThis.Number(t.duration):void 0,status:he(t.status)?globalThis.Number(t.status):0,remainingTime:he(t.remainingTime)?globalThis.Number(t.remainingTime):void 0,unknown0:he(t.unknown0)?globalThis.Number(t.unknown0):void 0,translationId:he(t.translationId)?globalThis.String(t.translationId):"",language:he(t.language)?globalThis.String(t.language):void 0,message:he(t.message)?globalThis.String(t.message):void 0}),toJSON(t){const e={};return void 0!==t.url&&(e.url=t.url),void 0!==t.duration&&(e.duration=t.duration),0!==t.status&&(e.status=Math.round(t.status)),void 0!==t.remainingTime&&(e.remainingTime=Math.round(t.remainingTime)),void 0!==t.unknown0&&(e.unknown0=Math.round(t.unknown0)),""!==t.translationId&&(e.translationId=t.translationId),void 0!==t.language&&(e.language=t.language),void 0!==t.message&&(e.message=t.message),e},create:t=>Kt.fromPartial(t??{}),fromPartial(t){const e={url:void 0,duration:void 0,status:0,remainingTime:void 0,unknown0:void 0,translationId:"",language:void 0,message:void 0};return e.url=t.url??void 0,e.duration=t.duration??void 0,e.status=t.status??0,e.remainingTime=t.remainingTime??void 0,e.unknown0=t.unknown0??void 0,e.translationId=t.translationId??"",e.language=t.language??void 0,e.message=t.message??void 0,e}};function Zt(){return{audioFile:new Uint8Array(0),fileId:""}}const Xt={encode:(t,e=new qt)=>(0!==t.audioFile.length&&e.uint32(18).bytes(t.audioFile),""!==t.fileId&&e.uint32(10).string(t.fileId),e),decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a=Zt();for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 2:if(18!==t)break;a.audioFile=i.bytes();continue;case 1:if(10!==t)break;a.fileId=i.string();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({audioFile:he(t.audioFile)?ce(t.audioFile):new Uint8Array(0),fileId:he(t.fileId)?globalThis.String(t.fileId):""}),toJSON(t){const e={};return 0!==t.audioFile.length&&(e.audioFile=function(t){if(globalThis.Buffer)return globalThis.Buffer.from(t).toString("base64");{const e=[];return t.forEach((t=>{e.push(globalThis.String.fromCharCode(t))})),globalThis.btoa(e.join(""))}}(t.audioFile)),""!==t.fileId&&(e.fileId=t.fileId),e},create:t=>Xt.fromPartial(t??{}),fromPartial(t){const e=Zt();return e.audioFile=t.audioFile??new Uint8Array(0),e.fileId=t.fileId??"",e}};const Qt={encode:(t,e=new qt)=>(0!==t.audioPartsLength&&e.uint32(16).int32(t.audioPartsLength),void 0!==t.audioBuffer&&Xt.encode(t.audioBuffer,e.uint32(10).fork()).join(),""!==t.fileId&&e.uint32(26).string(t.fileId),0!==t.unknown0&&e.uint32(32).int32(t.unknown0),e),decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={audioPartsLength:0,audioBuffer:void 0,fileId:"",unknown0:0};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 2:if(16!==t)break;a.audioPartsLength=i.int32();continue;case 1:if(10!==t)break;a.audioBuffer=Xt.decode(i,i.uint32());continue;case 3:if(26!==t)break;a.fileId=i.string();continue;case 4:if(32!==t)break;a.unknown0=i.int32();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({audioPartsLength:he(t.audioPartsLength)?globalThis.Number(t.audioPartsLength):0,audioBuffer:he(t.audioBuffer)?Xt.fromJSON(t.audioBuffer):void 0,fileId:he(t.fileId)?globalThis.String(t.fileId):"",unknown0:he(t.unknown0)?globalThis.Number(t.unknown0):0}),toJSON(t){const e={};return 0!==t.audioPartsLength&&(e.audioPartsLength=Math.round(t.audioPartsLength)),void 0!==t.audioBuffer&&(e.audioBuffer=Xt.toJSON(t.audioBuffer)),""!==t.fileId&&(e.fileId=t.fileId),0!==t.unknown0&&(e.unknown0=Math.round(t.unknown0)),e},create:t=>Qt.fromPartial(t??{}),fromPartial(t){const e={audioPartsLength:0,audioBuffer:void 0,fileId:"",unknown0:0};return e.audioPartsLength=t.audioPartsLength??0,e.audioBuffer=void 0!==t.audioBuffer&&null!==t.audioBuffer?Xt.fromPartial(t.audioBuffer):void 0,e.fileId=t.fileId??"",e.unknown0=t.unknown0??0,e}};const te={encode:(t,e=new qt)=>(""!==t.translationId&&e.uint32(10).string(t.translationId),""!==t.url&&e.uint32(18).string(t.url),void 0!==t.partialAudioInfo&&Qt.encode(t.partialAudioInfo,e.uint32(34).fork()).join(),void 0!==t.audioInfo&&Xt.encode(t.audioInfo,e.uint32(50).fork()).join(),e),decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={translationId:"",url:"",partialAudioInfo:void 0,audioInfo:void 0};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 1:if(10!==t)break;a.translationId=i.string();continue;case 2:if(18!==t)break;a.url=i.string();continue;case 4:if(34!==t)break;a.partialAudioInfo=Qt.decode(i,i.uint32());continue;case 6:if(50!==t)break;a.audioInfo=Xt.decode(i,i.uint32());continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({translationId:he(t.translationId)?globalThis.String(t.translationId):"",url:he(t.url)?globalThis.String(t.url):"",partialAudioInfo:he(t.partialAudioInfo)?Qt.fromJSON(t.partialAudioInfo):void 0,audioInfo:he(t.audioInfo)?Xt.fromJSON(t.audioInfo):void 0}),toJSON(t){const e={};return""!==t.translationId&&(e.translationId=t.translationId),""!==t.url&&(e.url=t.url),void 0!==t.partialAudioInfo&&(e.partialAudioInfo=Qt.toJSON(t.partialAudioInfo)),void 0!==t.audioInfo&&(e.audioInfo=Xt.toJSON(t.audioInfo)),e},create:t=>te.fromPartial(t??{}),fromPartial(t){const e={translationId:"",url:"",partialAudioInfo:void 0,audioInfo:void 0};return e.translationId=t.translationId??"",e.url=t.url??"",e.partialAudioInfo=void 0!==t.partialAudioInfo&&null!==t.partialAudioInfo?Qt.fromPartial(t.partialAudioInfo):void 0,e.audioInfo=void 0!==t.audioInfo&&null!==t.audioInfo?Xt.fromPartial(t.audioInfo):void 0,e}};const ee={encode(t,e=new qt){0!==t.status&&e.uint32(8).int32(t.status);for(const i of t.remainingChunks)e.uint32(18).string(i);return e},decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={status:0,remainingChunks:[]};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 1:if(8!==t)break;a.status=i.int32();continue;case 2:if(18!==t)break;a.remainingChunks.push(i.string());continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({status:he(t.status)?globalThis.Number(t.status):0,remainingChunks:globalThis.Array.isArray(t?.remainingChunks)?t.remainingChunks.map((t=>globalThis.String(t))):[]}),toJSON(t){const e={};return 0!==t.status&&(e.status=Math.round(t.status)),t.remainingChunks?.length&&(e.remainingChunks=t.remainingChunks),e},create:t=>ee.fromPartial(t??{}),fromPartial(t){const e={status:0,remainingChunks:[]};return e.status=t.status??0,e.remainingChunks=t.remainingChunks?.map((t=>t))||[],e}};const ie={encode:(t,e=new qt)=>(""!==t.language&&e.uint32(10).string(t.language),""!==t.url&&e.uint32(18).string(t.url),0!==t.unknown0&&e.uint32(24).int32(t.unknown0),""!==t.translatedLanguage&&e.uint32(34).string(t.translatedLanguage),""!==t.translatedUrl&&e.uint32(42).string(t.translatedUrl),0!==t.unknown1&&e.uint32(48).int32(t.unknown1),0!==t.unknown2&&e.uint32(56).int32(t.unknown2),e),decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={language:"",url:"",unknown0:0,translatedLanguage:"",translatedUrl:"",unknown1:0,unknown2:0};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 1:if(10!==t)break;a.language=i.string();continue;case 2:if(18!==t)break;a.url=i.string();continue;case 3:if(24!==t)break;a.unknown0=i.int32();continue;case 4:if(34!==t)break;a.translatedLanguage=i.string();continue;case 5:if(42!==t)break;a.translatedUrl=i.string();continue;case 6:if(48!==t)break;a.unknown1=i.int32();continue;case 7:if(56!==t)break;a.unknown2=i.int32();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({language:he(t.language)?globalThis.String(t.language):"",url:he(t.url)?globalThis.String(t.url):"",unknown0:he(t.unknown0)?globalThis.Number(t.unknown0):0,translatedLanguage:he(t.translatedLanguage)?globalThis.String(t.translatedLanguage):"",translatedUrl:he(t.translatedUrl)?globalThis.String(t.translatedUrl):"",unknown1:he(t.unknown1)?globalThis.Number(t.unknown1):0,unknown2:he(t.unknown2)?globalThis.Number(t.unknown2):0}),toJSON(t){const e={};return""!==t.language&&(e.language=t.language),""!==t.url&&(e.url=t.url),0!==t.unknown0&&(e.unknown0=Math.round(t.unknown0)),""!==t.translatedLanguage&&(e.translatedLanguage=t.translatedLanguage),""!==t.translatedUrl&&(e.translatedUrl=t.translatedUrl),0!==t.unknown1&&(e.unknown1=Math.round(t.unknown1)),0!==t.unknown2&&(e.unknown2=Math.round(t.unknown2)),e},create:t=>ie.fromPartial(t??{}),fromPartial(t){const e={language:"",url:"",unknown0:0,translatedLanguage:"",translatedUrl:"",unknown1:0,unknown2:0};return e.language=t.language??"",e.url=t.url??"",e.unknown0=t.unknown0??0,e.translatedLanguage=t.translatedLanguage??"",e.translatedUrl=t.translatedUrl??"",e.unknown1=t.unknown1??0,e.unknown2=t.unknown2??0,e}};const oe={encode:(t,e=new qt)=>(""!==t.url&&e.uint32(10).string(t.url),""!==t.language&&e.uint32(18).string(t.language),e),decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={url:"",language:""};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 1:if(10!==t)break;a.url=i.string();continue;case 2:if(18!==t)break;a.language=i.string();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({url:he(t.url)?globalThis.String(t.url):"",language:he(t.language)?globalThis.String(t.language):""}),toJSON(t){const e={};return""!==t.url&&(e.url=t.url),""!==t.language&&(e.language=t.language),e},create:t=>oe.fromPartial(t??{}),fromPartial(t){const e={url:"",language:""};return e.url=t.url??"",e.language=t.language??"",e}};const ae={encode(t,e=new qt){!1!==t.waiting&&e.uint32(8).bool(t.waiting);for(const i of t.subtitles)ie.encode(i,e.uint32(18).fork()).join();return e},decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={waiting:!1,subtitles:[]};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 1:if(8!==t)break;a.waiting=i.bool();continue;case 2:if(18!==t)break;a.subtitles.push(ie.decode(i,i.uint32()));continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({waiting:!!he(t.waiting)&&globalThis.Boolean(t.waiting),subtitles:globalThis.Array.isArray(t?.subtitles)?t.subtitles.map((t=>ie.fromJSON(t))):[]}),toJSON(t){const e={};return!1!==t.waiting&&(e.waiting=t.waiting),t.subtitles?.length&&(e.subtitles=t.subtitles.map((t=>ie.toJSON(t)))),e},create:t=>ae.fromPartial(t??{}),fromPartial(t){const e={waiting:!1,subtitles:[]};return e.waiting=t.waiting??!1,e.subtitles=t.subtitles?.map((t=>ie.fromPartial(t)))||[],e}};const ne={encode:(t,e=new qt)=>(""!==t.url&&e.uint32(10).string(t.url),""!==t.timestamp&&e.uint32(18).string(t.timestamp),e),decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={url:"",timestamp:""};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 1:if(10!==t)break;a.url=i.string();continue;case 2:if(18!==t)break;a.timestamp=i.string();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({url:he(t.url)?globalThis.String(t.url):"",timestamp:he(t.timestamp)?globalThis.String(t.timestamp):""}),toJSON(t){const e={};return""!==t.url&&(e.url=t.url),""!==t.timestamp&&(e.timestamp=t.timestamp),e},create:t=>ne.fromPartial(t??{}),fromPartial(t){const e={url:"",timestamp:""};return e.url=t.url??"",e.timestamp=t.timestamp??"",e}};const re={encode:(t,e=new qt)=>(""!==t.url&&e.uint32(10).string(t.url),""!==t.language&&e.uint32(18).string(t.language),""!==t.responseLanguage&&e.uint32(26).string(t.responseLanguage),e),decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={url:"",language:"",responseLanguage:""};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 1:if(10!==t)break;a.url=i.string();continue;case 2:if(18!==t)break;a.language=i.string();continue;case 3:if(26!==t)break;a.responseLanguage=i.string();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({url:he(t.url)?globalThis.String(t.url):"",language:he(t.language)?globalThis.String(t.language):"",responseLanguage:he(t.responseLanguage)?globalThis.String(t.responseLanguage):""}),toJSON(t){const e={};return""!==t.url&&(e.url=t.url),""!==t.language&&(e.language=t.language),""!==t.responseLanguage&&(e.responseLanguage=t.responseLanguage),e},create:t=>re.fromPartial(t??{}),fromPartial(t){const e={url:"",language:"",responseLanguage:""};return e.url=t.url??"",e.language=t.language??"",e.responseLanguage=t.responseLanguage??"",e}};const se={encode:(t,e=new qt)=>(0!==t.interval&&e.uint32(8).int32(t.interval),void 0!==t.translatedInfo&&ne.encode(t.translatedInfo,e.uint32(18).fork()).join(),void 0!==t.pingId&&e.uint32(24).int32(t.pingId),e),decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={interval:0,translatedInfo:void 0,pingId:void 0};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 1:if(8!==t)break;a.interval=i.int32();continue;case 2:if(18!==t)break;a.translatedInfo=ne.decode(i,i.uint32());continue;case 3:if(24!==t)break;a.pingId=i.int32();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({interval:he(t.interval)?Gt(t.interval):0,translatedInfo:he(t.translatedInfo)?ne.fromJSON(t.translatedInfo):void 0,pingId:he(t.pingId)?globalThis.Number(t.pingId):void 0}),toJSON(t){const e={};return 0!==t.interval&&(e.interval=function(t){switch(t){case Wt.NO_CONNECTION:return"NO_CONNECTION";case Wt.TRANSLATING:return"TRANSLATING";case Wt.STREAMING:return"STREAMING";case Wt.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(t.interval)),void 0!==t.translatedInfo&&(e.translatedInfo=ne.toJSON(t.translatedInfo)),void 0!==t.pingId&&(e.pingId=Math.round(t.pingId)),e},create:t=>se.fromPartial(t??{}),fromPartial(t){const e={interval:0,translatedInfo:void 0,pingId:void 0};return e.interval=t.interval??0,e.translatedInfo=void 0!==t.translatedInfo&&null!==t.translatedInfo?ne.fromPartial(t.translatedInfo):void 0,e.pingId=t.pingId??void 0,e}};const le={encode:(t,e=new qt)=>(0!==t.pingId&&e.uint32(8).int32(t.pingId),e),decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={pingId:0};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 1:if(8!==t)break;a.pingId=i.int32();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({pingId:he(t.pingId)?globalThis.Number(t.pingId):0}),toJSON(t){const e={};return 0!==t.pingId&&(e.pingId=Math.round(t.pingId)),e},create:t=>le.fromPartial(t??{}),fromPartial(t){const e={pingId:0};return e.pingId=t.pingId??0,e}};const de={encode:(t,e=new qt)=>(""!==t.uuid&&e.uint32(10).string(t.uuid),""!==t.module&&e.uint32(18).string(t.module),e),decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={uuid:"",module:""};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 1:if(10!==t)break;a.uuid=i.string();continue;case 2:if(18!==t)break;a.module=i.string();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({uuid:he(t.uuid)?globalThis.String(t.uuid):"",module:he(t.module)?globalThis.String(t.module):""}),toJSON(t){const e={};return""!==t.uuid&&(e.uuid=t.uuid),""!==t.module&&(e.module=t.module),e},create:t=>de.fromPartial(t??{}),fromPartial(t){const e={uuid:"",module:""};return e.uuid=t.uuid??"",e.module=t.module??"",e}};const ue={encode:(t,e=new qt)=>(""!==t.secretKey&&e.uint32(10).string(t.secretKey),0!==t.expires&&e.uint32(16).int32(t.expires),e),decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={secretKey:"",expires:0};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 1:if(10!==t)break;a.secretKey=i.string();continue;case 2:if(16!==t)break;a.expires=i.int32();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({secretKey:he(t.secretKey)?globalThis.String(t.secretKey):"",expires:he(t.expires)?globalThis.Number(t.expires):0}),toJSON(t){const e={};return""!==t.secretKey&&(e.secretKey=t.secretKey),0!==t.expires&&(e.expires=Math.round(t.expires)),e},create:t=>ue.fromPartial(t??{}),fromPartial(t){const e={secretKey:"",expires:0};return e.secretKey=t.secretKey??"",e.expires=t.expires??0,e}};function ce(t){if(globalThis.Buffer)return Uint8Array.from(globalThis.Buffer.from(t,"base64"));{const e=globalThis.atob(t),i=new Uint8Array(e.length);for(let t=0;t<e.length;++t)i[t]=e.charCodeAt(t);return i}}function he(t){return null!=t}const pe=new TextEncoder;async function ge(t,e,i){const o=await async function(){return"undefined"!=typeof window&&window.crypto?window.crypto:await Promise.resolve().then((function(){var t=new Error("Cannot find module 'node:crypto'");throw t.code="MODULE_NOT_FOUND",t}))}(),a=await o.subtle.importKey("raw",pe.encode(e),{name:"HMAC",hash:{name:t}},!1,["sign","verify"]);return await o.subtle.sign("HMAC",a,i)}async function me(t){const e=await ge("SHA-256",yt.hmac,t);return new Uint8Array(e).reduce(((t,e)=>t+e.toString(16).padStart(2,"0")),"")}async function ve(t,e,i,o){const{secretKey:a,uuid:n}=e,r=await me(i),s=`${n}:${o}:${yt.componentVersion}`,l=pe.encode(s);return{[`${t}-Signature`]:r,[`Sec-${t}-Sk`]:a,[`Sec-${t}-Token`]:`${await me(l)}:${s}`}}const fe={afr:"af",aka:"ak",alb:"sq",amh:"am",ara:"ar",arm:"hy",asm:"as",aym:"ay",aze:"az",baq:"eu",bel:"be",ben:"bn",bos:"bs",bul:"bg",bur:"my",cat:"ca",chi:"zh",cos:"co",cze:"cs",dan:"da",div:"dv",dut:"nl",eng:"en",epo:"eo",est:"et",ewe:"ee",fin:"fi",fre:"fr",fry:"fy",geo:"ka",ger:"de",gla:"gd",gle:"ga",glg:"gl",gre:"el",grn:"gn",guj:"gu",hat:"ht",hau:"ha",hin:"hi",hrv:"hr",hun:"hu",ibo:"ig",ice:"is",ind:"id",ita:"it",jav:"jv",jpn:"ja",kan:"kn",kaz:"kk",khm:"km",kin:"rw",kir:"ky",kor:"ko",kur:"ku",lao:"lo",lat:"la",lav:"lv",lin:"ln",lit:"lt",ltz:"lb",lug:"lg",mac:"mk",mal:"ml",mao:"mi",mar:"mr",may:"ms",mlg:"mg",mlt:"mt",mon:"mn",nep:"ne",nor:"no",nya:"ny",ori:"or",orm:"om",pan:"pa",per:"fa",pol:"pl",por:"pt",pus:"ps",que:"qu",rum:"ro",rus:"ru",san:"sa",sin:"si",slo:"sk",slv:"sl",smo:"sm",sna:"sn",snd:"sd",som:"so",sot:"st",spa:"es",srp:"sr",sun:"su",swa:"sw",swe:"sv",tam:"ta",tat:"tt",tel:"te",tgk:"tg",tha:"th",tir:"ti",tso:"ts",tuk:"tk",tur:"tr",uig:"ug",ukr:"uk",urd:"ur",uzb:"uz",vie:"vi",wel:"cy",xho:"xh",yid:"yi",yor:"yo",zul:"zu"};async function be(t,e={headers:{"User-Agent":yt.userAgent}}){const{timeout:i=3e3,...o}=e,a=new AbortController,n=setTimeout((()=>a.abort()),i),r=await fetch(t,{signal:a.signal,...o});return clearTimeout(n),r}function we(t){return 3===t.length?fe[t]:t.toLowerCase().split(/[_;-]/)[0].trim()}function ye(t,e="mp4"){const i=`https://${yt.mediaProxy}/v1/proxy/video.${e}?format=base64&force=true`;return t instanceof URL?`${i}&url=${btoa(t.href)}&origin=${t.origin}&referer=${t.origin}`:`${i}&url=${btoa(t)}`}class xe{static encodeTranslationRequest(t,e,i,o,a,{forceSourceLang:n=!1,wasStream:r=!1,videoTitle:s="",bypassCache:l=!1,useNewModel:d=!0}={}){return Jt.encode({url:t,firstRequest:!0,duration:e,unknown0:1,language:i,forceSourceLang:n,unknown1:0,translationHelp:a||[],responseLanguage:o,wasStream:r,unknown2:1,unknown3:1,bypassCache:l,useNewModel:d,videoTitle:s}).finish()}static decodeTranslationResponse(t){return Kt.decode(new Uint8Array(t))}static encodeTranslationAudioRequest(t,e,i,o){return te.encode({url:t,translationId:e,...o?{partialAudioInfo:{...o,audioBuffer:i}}:{audioInfo:i}}).finish()}static decodeTranslationAudioResponse(t){return ee.decode(new Uint8Array(t))}static encodeSubtitlesRequest(t,e){return oe.encode({url:t,language:e}).finish()}static decodeSubtitlesResponse(t){return ae.decode(new Uint8Array(t))}static encodeStreamPingRequest(t){return le.encode({pingId:t}).finish()}static encodeStreamRequest(t,e,i){return re.encode({url:t,language:e,responseLanguage:i}).finish()}static decodeStreamResponse(t){return se.decode(new Uint8Array(t))}}class Se{static encodeSessionRequest(t,e){return de.encode({uuid:t,module:e}).finish()}static decodeSessionResponse(t){return ue.decode(new Uint8Array(t))}}var ke,Te,Ce;!function(t){t[t.FAILED=0]="FAILED",t[t.FINISHED=1]="FINISHED",t[t.WAITING=2]="WAITING",t[t.LONG_WAITING=3]="LONG_WAITING",t[t.PART_CONTENT=5]="PART_CONTENT",t[t.AUDIO_REQUESTED=6]="AUDIO_REQUESTED"}(ke||(ke={})),function(t){t.WEB_API_GET_ALL_GENERATING_URLS_DATA_FROM_IFRAME="web_api_get_all_generating_urls_data_from_iframe",t.WEB_API_REPLACED_FETCH_INSIDE_IFRAME="web_api_replaced_fetch_inside_iframe",t.WEB_API_REPLACED_FETCH_FORCE_REQUEST_WITH_SEEK="web_api_replaced_fetch_force_request_with_seek",t.WEB_API_REPLACED_FETCH="web_api_replaced_fetch",t.ANDROID_API="android_api",t.WEB_API_SLOW="web_api_slow"}(Te||(Te={})),function(t){t.custom="custom",t.directlink="custom",t.youtube="youtube",t.piped="piped",t.invidious="invidious",t.vk="vk",t.nine_gag="nine_gag",t.gag="nine_gag",t.twitch="twitch",t.proxitok="proxitok",t.tiktok="tiktok",t.vimeo="vimeo",t.xvideos="xvideos",t.pornhub="pornhub",t.twitter="twitter",t.x="twitter",t.rumble="rumble",t.facebook="facebook",t.rutube="rutube",t.coub="coub",t.bilibili="bilibili",t.mail_ru="mailru",t.mailru="mailru",t.bitchute="bitchute",t.eporner="eporner",t.peertube="peertube",t.dailymotion="dailymotion",t.trovo="trovo",t.yandexdisk="yandexdisk",t.ok_ru="okru",t.okru="okru",t.googledrive="googledrive",t.bannedvideo="bannedvideo",t.weverse="weverse",t.newgrounds="newgrounds",t.egghead="egghead",t.youku="youku",t.archive="archive",t.kodik="kodik",t.patreon="patreon",t.reddit="reddit",t.kick="kick",t.apple_developer="apple_developer",t.appledeveloper="apple_developer",t.poketube="poketube",t.epicgames="epicgames",t.nineanimetv="nineanimetv",t.odysee="odysee",t.coursehunterLike="coursehunterLike",t.sap="sap",t.watchpornto="watchpornto",t.linkedin="linkedin",t.ricktube="ricktube",t.incestflix="incestflix",t.porntn="porntn",t.dzen="dzen",t.cloudflarestream="cloudflarestream",t.loom="loom",t.rtnews="rtnews",t.bitview="bitview"}(Ce||(Ce={}));const Ie=JSON.parse('{"recommended":"recommended","translateVideo":"Translate video","disableTranslate":"Turn off","translationSettings":"Translation settings","subtitlesSettings":"Subtitles settings","about":"About extension","resetSettings":"Reset settings","videoBeingTranslated":"The video is being translated","videoLanguage":"Video language","translationLanguage":"Translation language","translationTake":"The translation will take","translationTakeMoreThanHour":"The translation will take more than an hour","translationTakeAboutMinute":"The translation will take about a minute","translationTakeFewMinutes":"The translation will take a few minutes","translationTakeApproximatelyMinutes":"The translation will take approximately {0} minutes","translationTakeApproximatelyMinute":"The translation will take approximately {0} minutes","requestTranslationFailed":"Failed to request video translation","audioNotReceived":"Audio link not received","audioFormatNotSupported":"The audio format is not supported","VOTAutoTranslate":"Translate on open","VOTDontTranslateYourLang":"Don\'t translate from my language","VOTVolume":"Video volume","VOTVolumeTranslation":"Translation Volume","VOTAutoSetVolume":"Reduce video volume to ","VOTShowVideoSlider":"Video volume slider","VOTSyncVolume":"Link translation and video volume","VOTDisableFromYourLang":"You have disabled the translation of the video in your language","VOTVideoIsTooLong":"Video is too long","VOTNoVideoIDFound":"No video ID found","VOTSubtitles":"Subtitles","VOTSubtitlesDisabled":"Disabled","VOTSubtitlesMaxLength":"Subtitles max length","VOTHighlightWords":"Highlight words","VOTTranslatedFrom":"translated from","VOTAutogenerated":"autogenerated","VOTSettings":"VOT Settings","VOTMenuLanguage":"Menu language","VOTAuthors":"Authors","VOTVersion":"Version","VOTLoader":"Loader","VOTBrowser":"Browser","VOTShowPiPButton":"Show PiP button","langs":{"auto":"Auto","af":"Afrikaans","ak":"Akan","sq":"Albanian","am":"Amharic","ar":"Arabic","hy":"Armenian","as":"Assamese","ay":"Aymara","az":"Azerbaijani","bn":"Bangla","eu":"Basque","be":"Belarusian","bho":"Bhojpuri","bs":"Bosnian","bg":"Bulgarian","my":"Burmese","ca":"Catalan","ceb":"Cebuano","zh":"Chinese","zh-Hans":"Chinese (Simplified)","zh-Hant":"Chinese (Traditional)","co":"Corsican","hr":"Croatian","cs":"Czech","da":"Danish","dv":"Divehi","nl":"Dutch","en":"English","eo":"Esperanto","et":"Estonian","ee":"Ewe","fil":"Filipino","fi":"Finnish","fr":"French","gl":"Galician","lg":"Ganda","ka":"Georgian","de":"German","el":"Greek","gn":"Guarani","gu":"Gujarati","ht":"Haitian Creole","ha":"Hausa","haw":"Hawaiian","iw":"Hebrew","hi":"Hindi","hmn":"Hmong","hu":"Hungarian","is":"Icelandic","ig":"Igbo","id":"Indonesian","ga":"Irish","it":"Italian","ja":"Japanese","jv":"Javanese","kn":"Kannada","kk":"Kazakh","km":"Khmer","rw":"Kinyarwanda","ko":"Korean","kri":"Krio","ku":"Kurdish","ky":"Kyrgyz","lo":"Lao","la":"Latin","lv":"Latvian","ln":"Lingala","lt":"Lithuanian","lb":"Luxembourgish","mk":"Macedonian","mg":"Malagasy","ms":"Malay","ml":"Malayalam","mt":"Maltese","mi":"Māori","mr":"Marathi","mn":"Mongolian","ne":"Nepali","nso":"Northern Sotho","no":"Norwegian","ny":"Nyanja","or":"Odia","om":"Oromo","ps":"Pashto","fa":"Persian","pl":"Polish","pt":"Portuguese","pa":"Punjabi","qu":"Quechua","ro":"Romanian","ru":"Russian","sm":"Samoan","sa":"Sanskrit","gd":"Scottish Gaelic","sr":"Serbian","sn":"Shona","sd":"Sindhi","si":"Sinhala","sk":"Slovak","sl":"Slovenian","so":"Somali","st":"Southern Sotho","es":"Spanish","su":"Sundanese","sw":"Swahili","sv":"Swedish","tg":"Tajik","ta":"Tamil","tt":"Tatar","te":"Telugu","th":"Thai","ti":"Tigrinya","ts":"Tsonga","tr":"Turkish","tk":"Turkmen","uk":"Ukrainian","ur":"Urdu","ug":"Uyghur","uz":"Uzbek","vi":"Vietnamese","cy":"Welsh","fy":"Western Frisian","xh":"Xhosa","yi":"Yiddish","yo":"Yoruba","zu":"Zulu"},"streamNoConnectionToServer":"There is no connection to the server","searchField":"Search...","VOTTranslateAPIErrors":"Translate errors from the API","VOTDetectService":"Language detection service","VOTProxyWorkerHost":"Enter the proxy worker address","VOTM3u8ProxyHost":"Enter the address of the m3u8 proxy worker","proxySettings":"Proxy Settings","translationTakeApproximatelyMinute2":"The translation will take approximately {0} minutes","VOTAudioBooster":"Extended translation volume increase","VOTSubtitlesDesign":"Subtitles design","VOTSubtitlesFontSize":"Font size of subtitles","VOTSubtitlesOpacity":"Transparency of the subtitle background","VOTPressNewHotkey":"Press the new hotkey...","VOTCreateTranslationHotkey":"Create Hotkey for Translation","VOTChangeHotkeyWithCurrent":"Change Hotkey (Current: {0})","VOTSubtitlesDownloadFormat":"The format for downloading subtitles","VOTDownloadWithName":"Download files with the video name","VOTUpdateLocaleFiles":"Update localization files","VOTLocaleHash":"Locale hash","VOTUpdatedAt":"Updated at","VOTNeedWebAudioAPI":"To enable this, you must have a Web Audio API","VOTMediaCSPEnabledOnSite":"Media CSP is enabled on this site","VOTOnlyBypassMediaCSP":"Use it only for bypassing Media CSP","VOTNewAudioPlayer":"Use the new audio player","VOTUseNewModel":"Use an experimental variation of Yandex voices for some videos","VOTTranslationErrorsService":"Error translation service","TranslationDelayed":"The translation is slightly delayed","VOTTranslationCompletedNotify":"The translation on the {0} has been completed!","VOTSendNotifyOnComplete":"Send a notification that the video has been translated","VOTBugReport":"Report a bug","VOTTranslateProxyDisabled":"Disabled","VOTTranslateProxyEnabled":"Enabled","VOTTranslateProxyEverything":"Proxy everything","VOTTranslateProxyStatus":"Proxying mode"}'),Pe={log:(...t)=>{}},Le="media-proxy.toil.cc/v1/proxy/m3u8",_e="vot-worker.toil.cc",Ae=.15,Oe="yandexbrowser",Ve="yandexbrowser",Me=["FireMonkey","Greasemonkey","AdGuard","OrangeMonkey","Userscripts","Other (Polyfill)"];async function Ee(t,e,i,o,a=void 0){(a??t[e])===i&&(t[e]=o,await Be.set(e,o),console.log(`[VOT] Old ${e} converted to new ${o}`))}const Be=new class{gmSupport;constructor(){this.gmSupport="function"==typeof GM_getValue,Pe.log(`GM Storage Status: ${this.gmSupport}`)}syncGet(t,e=void 0){if(this.gmSupport)return GM_getValue(t,e);const i="number"==typeof e;const o=window.localStorage.getItem(t)??e;return i?Number(o):o}async get(t,e=void 0){return this.gmSupport?await GM_getValue(t,e):Promise.resolve(this.syncGet(t,e))}syncSet(t,e){return this.gmSupport?GM_setValue(t,e):window.localStorage.setItem(t,e)}async set(t,e){return this.gmSupport?await GM_setValue(t,e):Promise.resolve(this.syncSet(t,e))}syncDelete(t){return this.gmSupport?GM_deleteValue(t):window.localStorage.removeItem(t)}async delete(t){return this.gmSupport?await GM_deleteValue(t):Promise.resolve(this.syncDelete(t))}syncList(){return this.gmSupport?GM_listValues():["autoTranslate","dontTranslateLanguage","dontTranslateYourLang","autoSetVolumeYandexStyle","autoVolume","buttonPos","showVideoSlider","syncVolume","subtitlesMaxLength","highlightWords","responseLanguage","defaultVolume","audioProxy","showPiPButton","translateAPIErrors","translationService","detectService","m3u8ProxyHost","translateProxyEnabled","hotkeyButton","proxyWorkerHost","audioBooster","locale-version","locale-lang","locale-phrases"]}async list(){return this.gmSupport?await GM_listValues():Promise.resolve(this.syncList())}},Ne=navigator.language||navigator.userLanguage,Re=Ne?.substr(0,2)?.toLowerCase()??"en";function $e(){return"pictureInPictureEnabled"in document&&document.pictureInPictureEnabled}function De(){return"undefined"!=typeof Hls&&Hls?.isSupported()?new Hls({debug:!1,lowLatencyMode:!0,backBufferLength:90}):void 0}const Fe=new RegExp([/(?:https?|ftp):\/\/\S+/g,/https?:\/\/\S+|www\.\S+/gm,/\b\S+\.\S+/gm,/#[^\s#]+/g,/Auto-generated by YouTube/g,/Provided to YouTube by/g,/Released on/g,/0x[a-fA-F0-9]{40}/g,/[13][a-km-zA-HJ-NP-Z1-9]{25,34}/g,/4[0-9AB][1-9A-HJ-NP-Za-km-z]{93}/g,/Paypal/g].map((t=>t.source)).join("|"));function Ue(t,e){const i=URL.createObjectURL(t),o=document.createElement("a");o.href=i,o.download=e,o.click(),URL.revokeObjectURL(i)}function qe(t){return 0===t.trim().length?(new Date).toLocaleDateString("en-us").replaceAll("/","-"):t.replace(/[\\/:*?"'<>|]/g,"")}async function ze(t,e={}){const{timeout:i=15e3,...o}=e,a=new AbortController;try{if(t.includes("api.browser.yandex.ru"))throw new Error("Preventing yandex cors");return await fetch(t,{signal:a.signal,...o})}catch(e){return Pe.log("GM_fetch preventing CORS by GM_xmlhttpRequest",e.message),new Promise(((e,a)=>{GM_xmlhttpRequest({method:o.method||"GET",url:t,responseType:"blob",data:o.body,timeout:i,headers:o.headers||{},onload:t=>{const i=t.responseHeaders.split(/\r?\n/).reduce(((t,e)=>{const[,i,o]=e.match(/^([\w-]+): (.+)$/)||[];return i&&(t[i]=o),t}),{}),o=new Response(t.response,{status:t.status,headers:i});Object.defineProperty(o,"url",{value:t.finalUrl??""}),e(o)},ontimeout:()=>a(new Error("Timeout")),onerror:t=>a(new Error(t)),onabort:()=>a(new Error("AbortError"))})}))}}function He(){return Math.floor(Date.now()/1e3)}const je="https://raw.githubusercontent.com/ilyhalight/voice-over-translation/master/src/localization",We=["auto","en","ru","af","am","ar","az","bg","bn","bs","ca","cs","cy","da","de","el","es","et","eu","fa","fi","fr","gl","hi","hr","hu","hy","id","it","ja","jv","kk","km","kn","ko","lo","mk","ml","mn","ms","mt","my","ne","nl","pa","pl","pt","ro","si","sk","sl","sq","sr","su","sv","sw","tr","uk","ur","uz","vi","zh","zu"];const Ge=new class{constructor(){this.gmValues=["locale-phrases","locale-lang","locale-hash","locale-updated-at","locale-lang-override"],this.lang=this.getLang(),this.locale={},this.setLocaleFromJsonString(Be.syncGet("locale-phrases",""))}getLang(){const t=Be.syncGet("locale-lang-override","auto");return"auto"!==t?t:Re}reset(){for(const t of this.gmValues)Be.syncDelete(t)}async checkUpdates(t=!1){Pe.log("Check locale updates...");try{const e=await ze(`${je}/hashes.json${t?`?timestamp=${He()}`:""}`);if(!e.ok)throw e.status;const i=await e.json();return await Be.get("locale-hash")!==i[this.lang]&&i[this.lang]}catch(t){return console.error("[VOT] [localizationProvider] Failed to get locales hash:",t),!1}}async update(t=!1){const e=await Be.get("locale-updated-at",0);if(!t&&e+7200>He()&&await Be.get("locale-lang")===this.lang)return;const i=await this.checkUpdates(t);if(await Be.set("locale-updated-at",He()),i){Pe.log("Updating locale...");try{const e=await ze(`${je}/locales/${this.lang}.json${t?`?timestamp=${He()}`:""}`);if(!e.ok)throw e.status;const o=await e.text();await Be.set("locale-phrases",o),await Be.set("locale-hash",i),await Be.set("locale-lang",this.lang),this.setLocaleFromJsonString(o)}catch(t){console.error("[VOT] [localizationProvider] Failed to get locale:",t),this.setLocaleFromJsonString(await Be.get("locale-phrases",""))}}}setLocaleFromJsonString(t){try{this.locale=JSON.parse(t)||{}}catch(t){console.error("[VOT] [localizationProvider]",t),this.locale={}}}getFromLocale(t,e){return e.split(".").reduce(((t,e)=>t?.[e]),t)??this.warnMissingKey(t,e)}warnMissingKey(t,e){console.warn("[VOT] [localizationProvider] locale",t,"doesn't contain key",e)}getDefault(t){return this.getFromLocale(Ie,t)??t}get(t){return this.getFromLocale(this.locale,t)??this.getDefault(t)}};class Ye extends Error{constructor(t){super(Ge.getDefault(t)),this.name="VOTLocalizedError",this.unlocalizedMessage=t,this.localizedMessage=Ge.get(t)}}class Je extends Error{data;constructor(t,e=void 0){super(t),this.data=e,this.name="VOTJSError",this.message=t}}class Ke{host;schema;fetch;fetchOpts;sessions={};userAgent=yt.userAgent;headers={"User-Agent":this.userAgent,Accept:"application/x-protobuf","Accept-Language":"en","Content-Type":"application/x-protobuf",Pragma:"no-cache","Cache-Control":"no-cache"};hostSchemaRe=/(http(s)?):\/\//;constructor({host:t=yt.host,fetchFn:e=be,fetchOpts:i={},headers:o={}}={}){const a=this.hostSchemaRe.exec(t)?.[1];this.host=a?t.replace(`${a}://`,""):t,this.schema=a??"https",this.fetch=e,this.fetchOpts=i,this.headers={...this.headers,...o}}async request(t,e,i={},o="POST"){const a=this.getOpts(new Blob([e]),i,o);try{const e=await this.fetch(`${this.schema}://${this.host}${t}`,a),i=await e.arrayBuffer();return{success:200===e.status,data:i}}catch(t){return{success:!1,data:t?.message}}}async requestJSON(t,e=null,i={},o="POST"){const a=this.getOpts(e,{"Content-Type":"application/json",...i},o);try{const e=await this.fetch(`${this.schema}://${this.host}${t}`,a),i=await e.json();return{success:200===e.status,data:i}}catch(t){return{success:!1,data:t?.message}}}getOpts(t,e={},i="POST"){return{method:i,headers:{...this.headers,...e},body:t,...this.fetchOpts}}async getSession(t){const e=Math.floor(Date.now()/1e3),i=this.sessions[t];if(i&&i.timestamp+i.expires>e)return i;const{secretKey:o,expires:a,uuid:n}=await this.createSession(t);return this.sessions[t]={secretKey:o,expires:a,timestamp:e,uuid:n},this.sessions[t]}async createSession(t){const e=function(){let t="";for(let e=0;e<32;e++)t+="0123456789ABCDEF"[Math.floor(16*Math.random())];return t}(),i=Se.encodeSessionRequest(e,t),o=await this.request("/session/create",i,{"Vtrans-Signature":await me(i)});if(!o.success)throw new Je("Failed to request create session",o);return{...Se.decodeSessionResponse(o.data),uuid:e}}}class Ze extends Ke{hostVOT;schemaVOT;requestLang;responseLang;paths={videoTranslation:"/video-translation/translate",videoTranslationFailAudio:"/video-translation/fail-audio-js",videoTranslationAudio:"/video-translation/audio",videoSubtitles:"/video-subtitles/get-subtitles",streamPing:"/stream-translation/ping-stream",streamTranslation:"/stream-translation/translate-stream"};isCustomLink(t){return!!(/\.(m3u8|m4(a|v)|mpd)/.exec(t)??/^https:\/\/cdn\.qstv\.on\.epicgames\.com/.exec(t))}headersVOT={"User-Agent":`vot.js/${yt.version}`,"Content-Type":"application/json",Pragma:"no-cache","Cache-Control":"no-cache"};constructor({host:t,hostVOT:e=yt.hostVOT,fetchFn:i,fetchOpts:o,requestLang:a="en",responseLang:n="ru",headers:r}={}){super({host:t,fetchFn:i,fetchOpts:o,headers:r});const s=this.hostSchemaRe.exec(e)?.[1];this.hostVOT=s?e.replace(`${s}://`,""):e,this.schemaVOT=s??"https",this.requestLang=a,this.responseLang=n}async requestVOT(t,e,i={}){const o=this.getOpts(JSON.stringify(e),{...this.headersVOT,...i});try{const e=await this.fetch(`${this.schemaVOT}://${this.hostVOT}${t}`,o),i=await e.json();return{success:200===e.status,data:i}}catch(t){return{success:!1,data:t?.message}}}async translateVideoYAImpl({videoData:t,requestLang:e=this.requestLang,responseLang:i=this.responseLang,translationHelp:o=null,headers:a={},extraOpts:n={},shouldSendFailedAudio:r=!0}){const{url:s,duration:l=yt.defaultDuration}=t,d=await this.getSession("video-translation"),u=xe.encodeTranslationRequest(s,l,e,i,o,n),c=this.paths.videoTranslation,h=await ve("Vtrans",d,u,c),p=await this.request(c,u,{...h,...a});if(!p.success)throw new Ye("requestTranslationFailed");const g=xe.decodeTranslationResponse(p.data);St.log("translateVideo",g);const{status:m,translationId:v}=g;switch(m){case ke.FAILED:throw g?.message?new Je("Yandex couldn't translate video",g):new Ye("requestTranslationFailed");case ke.FINISHED:case ke.PART_CONTENT:if(!g.url)throw new Ye("audioNotReceived");return{translationId:v,translated:!0,url:g.url,status:m,remainingTime:g.remainingTime??-1};case ke.WAITING:case ke.LONG_WAITING:return{translationId:v,translated:!1,status:m,remainingTime:g.remainingTime};case ke.AUDIO_REQUESTED:return s.startsWith("https://youtu.be/")&&r?(await this.requestVtransFailAudio(s),await this.requestVtransAudio(s,g.translationId,{audioFile:new Uint8Array,fileId:Te.WEB_API_GET_ALL_GENERATING_URLS_DATA_FROM_IFRAME}),await this.translateVideoYAImpl({videoData:t,requestLang:e,responseLang:i,translationHelp:o,headers:a,shouldSendFailedAudio:!1})):{translationId:v,translated:!1,status:m,remainingTime:g.remainingTime??-1};default:throw St.error("Unknown response",g),new Je("Unknown response from Yandex",g)}}async translateVideoVOTImpl({url:t,videoId:e,service:i,requestLang:o=this.requestLang,responseLang:a=this.responseLang,headers:n={}}){const r=function(t,e,i){return t===Ce.patreon?{service:"mux",videoId:new URL(i).pathname.slice(1)}:{service:t,videoId:e}}(i,e,t),s=await this.requestVOT(this.paths.videoTranslation,{provider:"yandex",service:r.service,videoId:r.videoId,fromLang:o,toLang:a,rawVideo:t},n);if(!s.success)throw new Ye("requestTranslationFailed");const l=s.data;switch(l.status){case"failed":throw new Je("Yandex couldn't translate video",l);case"success":if(!l.translatedUrl)throw new Ye("audioNotReceived");return{translationId:String(l.id),translated:!0,url:l.translatedUrl,status:1,remainingTime:-1};case"waiting":return{translationId:"",translated:!1,remainingTime:l.remainingTime,status:2,message:l.message}}}async requestVtransFailAudio(t){const e=await this.requestJSON(this.paths.videoTranslationFailAudio,JSON.stringify({video_url:t}),void 0,"PUT");if(!e.data||"string"==typeof e.data||1!==e.data.status)throw new Je("Failed to request to fake video translation fail audio js",e);return e}async requestVtransAudio(t,e,i,o,a={}){const n=await this.getSession("video-translation"),r=xe.encodeTranslationAudioRequest(t,e,i,o),s=this.paths.videoTranslationAudio,l=await ve("Vtrans",n,r,s),d=await this.request(s,r,{...l,...a},"PUT");if(!d.success)throw new Je("Failed to request video translation audio",d);return xe.decodeTranslationAudioResponse(d.data)}async translateVideo({videoData:t,requestLang:e=this.requestLang,responseLang:i=this.responseLang,translationHelp:o=null,headers:a={},extraOpts:n={},shouldSendFailedAudio:r=!0}){const{url:s,videoId:l,host:d}=t;return this.isCustomLink(s)?await this.translateVideoVOTImpl({url:s,videoId:l,service:d,requestLang:e,responseLang:i,headers:a}):await this.translateVideoYAImpl({videoData:t,requestLang:e,responseLang:i,translationHelp:o,headers:a,extraOpts:n,shouldSendFailedAudio:r})}async getSubtitles({videoData:t,requestLang:e=this.requestLang,headers:i={}}){const{url:o}=t;if(this.isCustomLink(o))return{waiting:!1,subtitles:[]};const a=await this.getSession("video-translation"),n=xe.encodeSubtitlesRequest(o,e),r=this.paths.videoSubtitles,s=await ve("Vsubs",a,n,r),l=await this.request(r,n,{...s,...i});if(!l.success)throw new Je("Failed to request video subtitles",l);return xe.decodeSubtitlesResponse(l.data)}async pingStream({pingId:t,headers:e={}}){const i=await this.getSession("video-translation"),o=xe.encodeStreamPingRequest(t),a=this.paths.streamPing,n=await ve("Vtrans",i,o,a),r=await this.request(a,o,{...n,...e});if(!r.success)throw new Je("Failed to request stream ping",r);return!0}async translateStream({videoData:t,requestLang:e=this.requestLang,responseLang:i=this.responseLang,headers:o={}}){const{url:a}=t;if(this.isCustomLink(a))throw new Ye("VOTStreamNotSupportedUrl");const n=await this.getSession("video-translation"),r=xe.encodeStreamRequest(a,e,i),s=this.paths.streamTranslation,l=await ve("Vtrans",n,r,s),d=await this.request(s,r,{...l,...o});if(!d.success)throw new Je("Failed to request stream translation",d);const u=xe.decodeStreamResponse(d.data),c=u.interval;switch(c){case Wt.NO_CONNECTION:case Wt.TRANSLATING:return{translated:!1,interval:c,message:c===Wt.NO_CONNECTION?"streamNoConnectionToServer":"translationTakeFewMinutes"};case Wt.STREAMING:return{translated:!0,interval:c,pingId:u.pingId,result:u.translatedInfo};default:throw St.error("Unknown response",u),new Je("Unknown response from Yandex",u)}}}class Xe extends Ze{constructor(t={}){t.host=t.host??yt.hostWorker,super(t)}async request(t,e,i={},o="POST"){const a=this.getOpts(JSON.stringify({headers:{...this.headers,...i},body:Array.from(e)}),{"Content-Type":"application/json"},o);try{const e=await this.fetch(`${this.schema}://${this.host}${t}`,a),i=await e.arrayBuffer();return{success:200===e.status,data:i}}catch(t){return{success:!1,data:t?.message}}}async requestJSON(t,e=null,i={},o="POST"){const a=this.getOpts(JSON.stringify({headers:{...this.headers,"Content-Type":"application/json",Accept:"application/json",...i},body:e}),{Accept:"application/json","Content-Type":"application/json"},o);try{const e=await this.fetch(`${this.schema}://${this.host}${t}`,a),i=await e.json();return{success:200===e.status,data:i}}catch(t){return{success:!1,data:t?.message}}}}const{componentVersion:Qe}=yt,ti={"sec-ch-ua":`"Chromium";v="130", "YaBrowser";v="${Qe.slice(0,5)}", "Not?A_Brand";v="99", "Yowser";v="2.5"`,"sec-ch-ua-full-version-list":`"Chromium";v="130.0.6723.152", "YaBrowser";v="${Qe}", "Not?A_Brand";v="99.0.0.0", "Yowser";v="2.5"`,"Sec-Fetch-Mode":"no-cors"};class ei extends Ze{constructor(t){super(t),this.headers={...ti,...this.headers}}}class ii extends Xe{constructor(t){super(t),this.headers={...ti,...this.headers}}}class oi extends Error{constructor(t){super(t),this.name="VideoDataError",this.message=t}}const ai=/(file:\/\/(\/)?|(http(s)?:\/\/)(127\.0\.0\.1|localhost|192\.168\.(\d){1,3}\.(\d){1,3}))/;var ni;!function(t){t.udemy="udemy",t.coursera="coursera",t.douyin="douyin",t.artstation="artstation"}(ni||(ni={}));const ri=[{additionalData:"mobile",host:Ce.youtube,url:"https://youtu.be/",match:/^m.youtube.com$/,selector:"shorts-video #player",needExtraData:!0},{additionalData:"mobile",host:Ce.youtube,url:"https://youtu.be/",match:/^m.youtube.com$/,selector:".player-container",needExtraData:!0},{host:Ce.youtube,url:"https://youtu.be/",match:/^(www.)?youtube(-nocookie|kids)?.com$/,selector:".html5-video-container:not(#inline-player *)",needExtraData:!0},{host:Ce.invidious,url:"https://youtu.be/",match:["yewtu.be","yt.artemislena.eu","invidious.flokinet.to","iv.melmac.space","inv.nadeko.net","inv.tux.pizza","invidious.private.coffee","yt.drgnz.club","vid.puffyan.us","invidious.dhusch.de"],selector:"#player",needBypassCSP:!0},{host:Ce.piped,url:"https://youtu.be/",match:["piped.video","piped.tokhmi.xyz","piped.moomoo.me","piped.syncpundit.io","piped.mha.fi","watch.whatever.social","piped.garudalinux.org","efy.piped.pages.dev","watch.leptons.xyz","piped.lunar.icu","yt.dc09.ru","piped.mint.lgbt","il.ax","piped.privacy.com.de","piped.esmailelbob.xyz","piped.projectsegfau.lt","piped.in.projectsegfau.lt","piped.us.projectsegfau.lt","piped.privacydev.net","piped.palveluntarjoaja.eu","piped.smnz.de","piped.adminforge.de","piped.qdi.fi","piped.hostux.net","piped.chauvet.pro","piped.jotoma.de","piped.pfcd.me","piped.frontendfriendly.xyz"],selector:".shaka-video-container",needBypassCSP:!0},{host:Ce.poketube,url:"https://youtu.be/",match:["poketube.fun","pt.sudovanilla.org","poke.ggtyler.dev","poke.uk2.littlekai.co.uk","poke.blahai.gay"],selector:".video-player-container"},{host:Ce.ricktube,url:"https://youtu.be/",match:["ricktube.ru"],selector:"#oframeplayer > pjsdiv:has(video)"},{additionalData:"mobile",host:Ce.vk,url:"https://vk.com/video?z=",match:[/^m.vk.(com|ru)$/,/^m.vkvideo.ru$/],selector:"vk-video-player",shadowRoot:!0,needExtraData:!0},{additionalData:"clips",host:Ce.vk,url:"https://vk.com/video?z=",match:/^(www.|m.)?vk.(com|ru)$/,selector:'div[data-testid="clipcontainer-video"]',needExtraData:!0},{host:Ce.vk,url:"https://vk.com/video?z=",match:[/^(www.|m.)?vk.(com|ru)$/,/^(www.|m.)?vkvideo.ru$/],selector:".videoplayer_media",needExtraData:!0},{host:Ce.nine_gag,url:"https://9gag.com/gag/",match:/^9gag.com$/,selector:".video-post"},{host:Ce.twitch,url:"https://twitch.tv/",match:[/^m.twitch.tv$/,/^(www.)?twitch.tv$/,/^clips.twitch.tv$/,/^player.twitch.tv$/],selector:".video-ref, main > div > section > div > div > div"},{host:Ce.proxitok,url:"https://www.tiktok.com/",match:["proxitok.pabloferreiro.es","proxitok.pussthecat.org","tok.habedieeh.re","proxitok.esmailelbob.xyz","proxitok.privacydev.net","tok.artemislena.eu","tok.adminforge.de","tt.vern.cc","cringe.whatever.social","proxitok.lunar.icu","proxitok.privacy.com.de"],selector:".column.has-text-centered"},{host:Ce.tiktok,url:"https://www.tiktok.com/",match:/^(www.)?tiktok.com$/,selector:null},{host:ni.douyin,url:"https://www.douyin.com/",match:/^(www.)?douyin.com/,selector:".xg-video-container",needExtraData:!0,needBypassCSP:!0},{host:Ce.vimeo,url:"https://vimeo.com/",match:/^vimeo.com$/,needExtraData:!0,selector:".player"},{host:Ce.vimeo,url:"https://player.vimeo.com/",match:/^player.vimeo.com$/,additionalData:"embed",needExtraData:!0,needBypassCSP:!0,selector:".player"},{host:Ce.xvideos,url:"https://www.xvideos.com/",match:[/^(www.)?xvideos(-ar)?.com$/,/^(www.)?xvideos(\d\d\d).com$/,/^(www.)?xv-ru.com$/],selector:"#hlsplayer",needBypassCSP:!0},{host:Ce.pornhub,url:"https://rt.pornhub.com/view_video.php?viewkey=",match:/^[a-z]+.pornhub.com$/,selector:".mainPlayerDiv > .video-element-wrapper-js > div",eventSelector:".mgp_eventCatcher"},{additionalData:"embed",host:Ce.pornhub,url:"https://rt.pornhub.com/view_video.php?viewkey=",match:t=>t.host.includes("pornhub.com")&&t.pathname.startsWith("/embed/"),selector:"#player"},{host:Ce.twitter,url:"https://twitter.com/i/status/",match:/^(twitter|x).com$/,selector:'div[data-testid="videoComponent"] > div:nth-child(1) > div',eventSelector:'div[data-testid="videoPlayer"]',needBypassCSP:!0},{host:Ce.rumble,url:"https://rumble.com/",match:/^rumble.com$/,selector:"#videoPlayer > .videoPlayer-Rumble-cls > div"},{host:Ce.facebook,url:"https://facebook.com/",match:t=>t.host.includes("facebook.com")&&t.pathname.includes("/videos/"),selector:'div[role="main"] div[data-pagelet$="video" i]',needBypassCSP:!0},{additionalData:"reels",host:Ce.facebook,url:"https://facebook.com/",match:t=>t.host.includes("facebook.com")&&t.pathname.includes("/reel/"),selector:'div[role="main"]',needBypassCSP:!0},{host:Ce.rutube,url:"https://rutube.ru/video/",match:/^rutube.ru$/,selector:".video-player > div > div > div:nth-child(2)"},{additionalData:"embed",host:Ce.rutube,url:"https://rutube.ru/video/",match:/^rutube.ru$/,selector:"#app > div > div"},{host:Ce.bilibili,url:"https://www.bilibili.com/",match:/^(www|m|player).bilibili.com$/,selector:".bpx-player-video-wrap"},{additionalData:"old",host:Ce.bilibili,url:"https://www.bilibili.com/",match:/^(www|m).bilibili.com$/,selector:null},{host:Ce.mailru,url:"https://my.mail.ru/",match:/^my.mail.ru$/,selector:"#b-video-wrapper"},{host:Ce.bitchute,url:"https://www.bitchute.com/video/",match:/^(www.)?bitchute.com$/,selector:".video-js"},{host:Ce.eporner,url:"https://www.eporner.com/",match:/^(www.)?eporner.com$/,selector:".vjs-v7"},{host:Ce.peertube,url:"stub",match:["peertube.1312.media","tube.shanti.cafe","bee-tube.fr","video.sadmin.io","dalek.zone","review.peertube.biz","peervideo.club","tube.la-dina.net","peertube.tmp.rcp.tf","peertube.su","video.blender.org","videos.viorsan.com","tube-sciences-technologies.apps.education.fr","tube-numerique-educatif.apps.education.fr","tube-arts-lettres-sciences-humaines.apps.education.fr","beetoons.tv","comics.peertube.biz","makertube.net"],selector:".vjs-v7"},{host:Ce.dailymotion,url:"https://dai.ly/",match:/^geo([\d]+)?.dailymotion.com$/,selector:".player"},{host:Ce.trovo,url:"https://trovo.live/s/",match:/^trovo.live$/,selector:".player-video"},{host:Ce.yandexdisk,url:"https://yadi.sk/",match:/^disk.yandex.(ru|kz|com(\.(am|ge|tr))?|by|az|co\.il|ee|lt|lv|md|net|tj|tm|uz)$/,selector:".video-player__player > div:nth-child(1)",eventSelector:".video-player__player",needBypassCSP:!0,needExtraData:!0},{host:Ce.okru,url:"https://ok.ru/video/",match:/^ok.ru$/,selector:"vk-video-player",shadowRoot:!0},{host:Ce.googledrive,url:"https://drive.google.com/file/d/",match:/^youtube.googleapis.com$/,selector:".html5-video-container"},{host:Ce.bannedvideo,url:"https://madmaxworld.tv/watch?id=",match:/^(www.)?banned.video|madmaxworld.tv$/,selector:".vjs-v7",needExtraData:!0},{host:Ce.weverse,url:"https://weverse.io/",match:/^weverse.io$/,selector:".webplayer-internal-source-wrapper",needExtraData:!0},{host:Ce.newgrounds,url:"https://www.newgrounds.com/",match:/^(www.)?newgrounds.com$/,selector:".ng-video-player"},{host:Ce.egghead,url:"https://egghead.io/",match:/^egghead.io$/,selector:".cueplayer-react-video-holder"},{host:Ce.youku,url:"https://v.youku.com/",match:/^v.youku.com$/,selector:"#ykPlayer"},{host:Ce.archive,url:"https://archive.org/details/",match:/^archive.org$/,selector:".jw-media"},{host:Ce.kodik,url:"stub",match:/^kodik.(info|biz|cc)$/,selector:".fp-player",needExtraData:!0},{host:Ce.patreon,url:"stub",match:/^(www.)?patreon.com$/,selector:'div[data-tag="post-card"] div[elevation="subtle"] > div > div > div > div',needExtraData:!0},{additionalData:"old",host:Ce.reddit,url:"stub",match:/^old.reddit.com$/,selector:".reddit-video-player-root",needExtraData:!0,needBypassCSP:!0},{host:Ce.reddit,url:"stub",match:/^(www.|new.)?reddit.com$/,selector:"div[slot=post-media-container]",shadowRoot:!0,needExtraData:!0,needBypassCSP:!0},{host:Ce.kick,url:"https://kick.com/",match:/^kick.com$/,selector:"#injected-embedded-channel-player-video > div",needExtraData:!0},{host:Ce.appledeveloper,url:"https://developer.apple.com/",match:/^developer.apple.com$/,selector:".developer-video-player",needExtraData:!0,needBypassCSP:!0},{host:Ce.epicgames,url:"https://dev.epicgames.com/community/learning/",match:/^dev.epicgames.com$/,selector:".vjs-v7",needExtraData:!0},{host:Ce.nineanimetv,url:"https://9animetv.to/watch/",match:/^rapid-cloud.co$/,selector:".jw-media",needExtraData:!0},{host:Ce.odysee,url:"stub",match:/^odysee.com$/,selector:".vjs-v7",needExtraData:!0},{host:Ce.coursehunterLike,url:"stub",match:["coursehunter.net","coursetrain.net"],selector:"#oframeplayer > pjsdiv:has(video)",needExtraData:!0},{host:Ce.sap,url:"https://learning.sap.com/courses/",match:/^learning.sap.com$/,selector:".playkit-container",eventSelector:".playkit-player",needExtraData:!0,needBypassCSP:!0},{host:ni.udemy,url:"https://www.udemy.com/",match:/udemy.com$/,selector:'div[data-purpose="curriculum-item-viewer-content"] > section > div > div > div > div:nth-of-type(2)',needExtraData:!0},{host:ni.coursera,url:"https://www.coursera.org/",match:/coursera.org$/,selector:".vjs-v8",needExtraData:!0},{host:Ce.watchpornto,url:"https://watchporn.to/",match:/^watchporn.to$/,selector:".fp-player"},{host:Ce.linkedin,url:"https://www.linkedin.com/learning/",match:/^(www.)?linkedin.com$/,selector:".vjs-v7",needExtraData:!0,needBypassCSP:!0},{host:Ce.incestflix,url:"https://www.incestflix.net/watch/",match:/^(www.)?incestflix.(net|to|com)$/,selector:"#incflix-stream",needExtraData:!0},{host:Ce.porntn,url:"https://porntn.com/videos/",match:/^porntn.com$/,selector:".fp-player",needExtraData:!0},{host:Ce.dzen,url:"https://dzen.ru/video/watch/",match:/^dzen.ru$/,selector:".zen-ui-video-video-player"},{host:Ce.cloudflarestream,url:"stub",match:/^(watch|embed|iframe|customer-[^.]+).cloudflarestream.com$/,selector:null},{host:Ce.loom,url:"https://www.loom.com/share/",match:/^(www.)?loom.com$/,selector:".VideoLayersContainer",needExtraData:!0},{host:ni.artstation,url:"https://www.artstation.com/learning/",match:/^(www.)?artstation.com$/,selector:".vjs-v7",needExtraData:!0},{host:Ce.rtnews,url:"https://www.rt.com/",match:/^(www.)?rt.com$/,selector:".jw-media",needExtraData:!0},{host:Ce.bitview,url:"https://www.bitview.net/watch?v=",match:/^(www.)?bitview.net$/,selector:".vlScreen",needExtraData:!0},{host:Ce.custom,url:"stub",match:t=>/([^.]+).(mp4|webm)/.test(t.pathname),rawResult:!0}];class si extends Error{constructor(t){super(t),this.name="VideoHelper",this.message=t}}class li{API_ORIGIN=window.location.origin;fetch;extraInfo;referer;origin;service;video;language;constructor({fetchFn:t=be,extraInfo:e=!0,referer:i=document.referrer??window.location.origin+"/",origin:o=window.location.origin,service:a,video:n,language:r="en"}={}){this.fetch=t,this.extraInfo=e,this.referer=i,this.origin=/^(http(s)?):\/\//.test(String(o))?o:window.location.origin,this.service=a,this.video=n,this.language=r}async getVideoData(t){}async getVideoId(t){}returnBaseData(t){if(this.service)return{url:this.service.url+t,videoId:t,host:this.service.host,duration:void 0}}}class di extends li{SUBTITLE_SOURCE="videojs";SUBTITLE_FORMAT="vtt";static getPlayer(){return document.querySelector(".video-js")?.player}getVideoDataByPlayer(t){try{const e=di.getPlayer();if(!e)throw new Error(`Video player doesn't have player option, videoId ${t}`);const i=e.duration(),o=Array.isArray(e.currentSources)?e.currentSources:e.getCache()?.sources,{tracks_:a}=e.textTracks(),n=o.find((t=>"video/mp4"===t.type||"video/webm"===t.type));if(!n)throw new Error(`Failed to find video url for videoID ${t}`);const r=a.filter((t=>t.src)).map((t=>({language:we(t.language),source:this.SUBTITLE_SOURCE,format:this.SUBTITLE_FORMAT,url:t.src})));return{url:n.src,duration:i,subtitles:r}}catch(t){return void St.error("Failed to get videojs video data",t.message)}}}class ui extends li{static getPlayer(){if("undefined"==typeof Videoview)return;const t=Videoview;return t?.getPlayerObject?.call(void 0)}async getVideoData(t){const e=ui.getPlayer();if(!e)return this.returnBaseData(t);try{const{description:i,duration:o,md_title:a}=e.vars,n=(new DOMParser).parseFromString(i,"text/html"),r=Array.from(n.body.childNodes).filter((t=>"BR"!==t.nodeName)).map((t=>t.textContent)).join("\n");let s;return Object.hasOwn(e.vars,"subs")&&(s=e.vars.subs.map((t=>({language:we(t.lang),source:"vk",format:"vtt",url:t.url,isAutoGenerated:!!t.is_auto})))),{url:this.service.url+t,title:a,description:r,duration:o,subtitles:s}}catch(e){return St.error(`Failed to get VK video data, because: ${e.message}`),this.returnBaseData(t)}}async getVideoId(t){const e=/^\/(video|clip)-?\d{8,9}_\d{9}$/.exec(t.pathname);if(e)return e[0].slice(1);const i=/\/playlist\/[^/]+\/(video-?\d{8,9}_\d{9})/.exec(t.pathname);if(i)return i[1];const o=t.searchParams.get("z");if(o)return o.split("/")[0];const a=t.searchParams.get("oid"),n=t.searchParams.get("id");return a&&n?`video-${Math.abs(parseInt(a))}_${n}`:void 0}}class ci extends li{async getVideoId(t){return/([^/]+)\/video\/([^/]+)/.exec(t.pathname)?.[0]}}const hi=["auto","ru","en","zh","ko","lt","lv","ar","fr","it","es","de","ja"],pi=["ru","en","kk"],gi=["srt","vtt","json"];class mi extends li{static isMobile(){return/^m\.youtube\.com$/.test(window.location.hostname)}static getPlayer(){return window.location.pathname.startsWith("/shorts/")&&!mi.isMobile()?document.querySelector("#shorts-player"):document.querySelector("#movie_player")}static getPlayerResponse(){return mi.getPlayer()?.getPlayerResponse?.call(void 0)}static getPlayerData(){return mi.getPlayer()?.getVideoData?.call(void 0)}static getVolume(){const t=mi.getPlayer();return t?.getVolume?t.getVolume()/100:1}static setVolume(t){const e=mi.getPlayer();return!!e?.setVolume&&(e.setVolume(Math.round(100*t)),!0)}static isMuted(){const t=mi.getPlayer();return!!t?.isMuted&&t.isMuted()}static videoSeek(t,e){St.log("videoSeek",e);const i=(mi.getPlayer()?.getProgressState()?.seekableEnd??t.currentTime)-e;t.currentTime=i}static getSubtitles(t){const e=mi.getPlayerResponse(),i=e?.captions?.playerCaptionsTracklistRenderer;if(!i)return[];const o=i.captionTracks??[],a=(i.translationLanguages??[]).find((e=>e.languageCode===t)),n=o.find((t=>"asr"===t?.kind)),r=n?.languageCode??"en",s=o.reduce(((e,i)=>{if(!("languageCode"in i))return e;const o=i.languageCode?we(i.languageCode):void 0,n=i.baseUrl;if(!o||!n)return e;const s=`${n.startsWith("http")?n:`${window.location.origin}/${n}`}&fmt=json3`;return e.push({source:"youtube",format:"json",language:o,isAutoGenerated:"asr"===i?.kind,url:s}),a&&i.isTranslatable&&i.languageCode===r&&t!==o&&e.push({source:"youtube",format:"json",language:t,isAutoGenerated:"asr"===i?.kind,translatedFromLanguage:o,url:`${s}&tlang=${t}`}),e}),[]);return St.log("youtube subtitles:",s),s}static getLanguage(){if(!mi.isMobile()){const t=mi.getPlayer(),e=t?.getAudioTrack?.call(void 0)?.getLanguageInfo();if(e&&"und"!==e.id)return we(e.id.split(".")[0])}const t=mi.getPlayerResponse(),e=t?.captions?.playerCaptionsTracklistRenderer.captionTracks.find((t=>"asr"===t.kind&&t.languageCode));return e?we(e.languageCode):void 0}async getVideoData(t){const{title:e}=mi.getPlayerData()??{},{shortDescription:i,isLive:o,title:a}=mi.getPlayerResponse()?.videoDetails??{},n=mi.getSubtitles(this.language);let r=mi.getLanguage();r&&!hi.includes(r)&&(r=void 0);const s=mi.getPlayer()?.getDuration?.call(void 0)??void 0;return{url:this.service.url+t,isStream:o,title:a,localizedTitle:e,detectedLanguage:r,description:i,subtitles:n,duration:s}}async getVideoId(t){if("youtu.be"===t.hostname&&(t.search=`?v=${t.pathname.replace("/","")}`,t.pathname="/watch"),t.searchParams.has("enablejsapi")){const e=mi.getPlayer()?.getVideoUrl();t=e?new URL(e):t}return/(?:watch|embed|shorts|live)\/([^/]+)/.exec(t.pathname)?.[1]??t.searchParams.get("v")}}class vi extends di{API_ORIGIN="https://www.coursera.org/api";SUBTITLE_SOURCE="coursera";async getCourseData(t){try{const e=await this.fetch(`${this.API_ORIGIN}/onDemandCourses.v1/${t}`),i=await e.json();return i?.elements?.[0]}catch(e){return void St.error(`Failed to get course data by courseId: ${t}`,e.message)}}static getPlayer(){return super.getPlayer()}async getVideoData(t){const e=this.getVideoDataByPlayer(t);if(!e)return;const{options_:i}=vi.getPlayer()??{};!e.subtitles?.length&&i&&(e.subtitles=i.tracks.map((t=>({url:t.src,language:we(t.srclang),source:this.SUBTITLE_SOURCE,format:this.SUBTITLE_FORMAT}))));const o=i?.courseId;if(!o)return e;let a="en";const n=await this.getCourseData(o);if(n){const{primaryLanguageCodes:[t]}=n;a=t?we(t):"en"}hi.includes(a)||(a="en");const r=e.subtitles.find((t=>t.language===a))??e.subtitles?.[0],s=r?.url;s||St.warn("Failed to find any subtitle file");const{url:l,duration:d}=e,u=s?[{target:"subtitles_file_url",targetUrl:s},{target:"video_file_url",targetUrl:l}]:null;return{...s?{url:this.service?.url+t,translationHelp:u}:{url:l,translationHelp:u},detectedLanguage:a,duration:d}}async getVideoId(t){const e=/learn\/([^/]+)\/lecture\/([^/]+)/.exec(t.pathname)??/lecture\/([^/]+)\/([^/]+)/.exec(t.pathname);return e?.[0]}}class fi extends li{static getPlayer(){if("undefined"!=typeof player)return player}async getVideoData(t){const e=fi.getPlayer();if(!e)return;const{config:{url:i,duration:o,lang:a,isLive:n}}=e;if(!i)return;const r=i.find((t=>t.src.includes("www.douyin.com/aweme/v1/play/")));return r?{url:ye(r.src),duration:o,isStream:n,...hi.includes(a)?{detectedLanguage:a}:{}}:void 0}async getVideoId(t){const e=/video\/([\d]+)/.exec(t.pathname)?.[0];return e||fi.getPlayer()?.config.vid}}var bi;!function(t){t.Channel="Channel",t.Video="Video"}(bi||(bi={}));const wi={[Ce.mailru]:class extends li{API_ORIGIN="https://my.mail.ru";async getVideoMeta(t){try{const e=await this.fetch(`${this.API_ORIGIN}/+/video/meta/${t}?xemail=&ajax_call=1&func_name=&mna=&mnb=&ext=1&_=${(new Date).getTime()}`);return await e.json()}catch(t){return void St.error("Failed to get mail.ru video data",t.message)}}async getVideoId(t){const e=t.pathname;if(/\/(v|mail|bk|inbox)\//.exec(e))return e.slice(1);const i=/video\/embed\/([^/]+)/.exec(e)?.[1];if(!i)return;const o=await this.getVideoMeta(i);return o?o.meta.url.replace("//my.mail.ru/",""):void 0}},[Ce.weverse]:class extends li{API_ORIGIN="https://global.apis.naver.com/weverse/wevweb";API_APP_ID="be4d79eb8fc7bd008ee82c8ec4ff6fd4";API_HMAC_KEY="1b9cb6378d959b45714bec49971ade22e6e24e42";HEADERS={Accept:"application/json, text/plain, */*",Origin:"https://weverse.io",Referer:"https://weverse.io/"};getURLData(){return{appId:this.API_APP_ID,language:"en",os:"WEB",platform:"WEB",wpf:"pc"}}async createHash(t){const e=Date.now(),i=t.substring(0,Math.min(255,t.length))+e,o=await async function(t,e){try{const i=pe.encode(e),o=await ge("SHA-1",t,i);return btoa(String.fromCharCode(...new Uint8Array(o)))}catch(t){return St.error(t),!1}}(this.API_HMAC_KEY,i);if(!o)throw new si("Failed to get weverse HMAC signature");return{wmsgpad:e.toString(),wmd:o}}async getHashURLParams(t){const e=await this.createHash(t);return new URLSearchParams(e).toString()}async getPostPreview(t){const e=`/post/v1.0/post-${t}/preview?`+new URLSearchParams({fieldSet:"postForPreview",...this.getURLData()}).toString();try{const t=await this.getHashURLParams(e),i=await this.fetch(this.API_ORIGIN+e+"&"+t,{headers:this.HEADERS});return await i.json()}catch(e){return St.error(`Failed to get weverse post preview by postId: ${t}`,e.message),!1}}async getVideoInKey(t){const e=`/video/v1.1/vod/${t}/inKey?`+new URLSearchParams({gcc:"RU",...this.getURLData()}).toString();try{const t=await this.getHashURLParams(e),i=await this.fetch(this.API_ORIGIN+e+"&"+t,{method:"POST",headers:this.HEADERS});return await i.json()}catch(e){return St.error(`Failed to get weverse InKey by videoId: ${t}`,e.message),!1}}async getVideoInfo(t,e,i){const o=Date.now();try{const a=new URLSearchParams({key:e,sid:i,nonce:o.toString(),devt:"html5_pc",prv:"N",aup:"N",stpb:"N",cpl:"en",env:"prod",lc:"en",adi:JSON.stringify([{adSystem:null}]),adu:"/"}).toString(),n=await this.fetch(`https://global.apis.naver.com/rmcnmv/rmcnmv/vod/play/v2.0/${t}?`+a,{headers:this.HEADERS});return await n.json()}catch(o){return St.error(`Failed to get weverse video info (infraVideoId: ${t}, inkey: ${e}, serviceId: ${i}`,o.message),!1}}extractVideoInfo(t){return t.find((t=>!1===t.useP2P&&t.source.includes(".mp4")))}async getVideoData(t){const e=await this.getPostPreview(t);if(!e)return;const{videoId:i,serviceId:o,infraVideoId:a}=e.extension.video;if(!(i&&o&&a))return;const n=await this.getVideoInKey(i);if(!n)return;const r=await this.getVideoInfo(a,n.inKey,o);if(!r)return;const s=this.extractVideoInfo(r.videos.list);return s?{url:s.source,duration:s.duration}:void 0}async getVideoId(t){return/([^/]+)\/(live|media)\/([^/]+)/.exec(t.pathname)?.[3]}},[Ce.kodik]:class extends li{API_ORIGIN=window.location.origin;async getSecureData(t){try{const e=await this.fetch(`${this.API_ORIGIN}${t}`,{headers:{"User-Agent":yt.userAgent,Origin:this.API_ORIGIN,Referer:this.API_ORIGIN}}),i=await e.text(),[o,a,n]=t.split("/").filter((t=>t)),r=(new DOMParser).parseFromString(i,"text/html"),s=Array.from(r.getElementsByTagName("script")).filter((t=>t.innerHTML.includes(`videoId = "${a}"`)));if(!s.length)throw new si("Failed to find secure script");const l=/'{[^']+}'/.exec(s[0].textContent.trim())?.[0];if(!l)throw new si("Secure json wasn't found in secure script");const d=JSON.parse(l.replaceAll("'",""));return{videoType:o,videoId:a,hash:n,...d}}catch(e){return St.error(`Failed to get kodik secure data by videoPath: ${t}.`,e.message),!1}}async getFtor(t){const{videoType:e,videoId:i,hash:o,d:a,d_sign:n,pd:r,pd_sign:s,ref:l,ref_sign:d}=t;try{const t=await this.fetch(this.API_ORIGIN+"/ftor",{method:"POST",headers:{"User-Agent":yt.userAgent,Origin:this.API_ORIGIN,Referer:`${this.API_ORIGIN}/${e}/${i}/${o}/360p`},body:new URLSearchParams({d:a,d_sign:n,pd:r,pd_sign:s,ref:decodeURIComponent(l),ref_sign:d,bad_user:"false",cdn_is_working:"true",info:"{}",type:e,hash:o,id:i})});return await t.json()}catch(t){return St.error(`Failed to get kodik video data (type: ${e}, id: ${i}, hash: ${o})`,t.message),!1}}decryptUrl(t){const e=atob(t.replace(/[a-zA-Z]/g,(function(t){const e=t.charCodeAt(0)+13,i=t<="Z"?90:122;return String.fromCharCode(i>=e?e:e-26)})));return"https:"+e}async getVideoData(t){const e=await this.getSecureData(t);if(!e)return;const i=await this.getFtor(e);if(!i)return;const o=Object.entries(i.links[i.default.toString()]),a=o.find((([,t])=>"application/x-mpegURL"===t.type))?.[1];return a?{url:this.decryptUrl(a.src)}:void 0}async getVideoId(t){return/\/(seria|video)\/([^/]+)\/([^/]+)\/([\d]+)p/.exec(t.pathname)?.[0]}},[Ce.patreon]:class extends li{API_ORIGIN="https://www.patreon.com/api";async getPosts(t){try{const e=await this.fetch(`${this.API_ORIGIN}/posts/${t}?json-api-use-default-includes=false`);return await e.json()}catch(e){return St.error(`Failed to get patreon posts by postId: ${t}.`,e.message),!1}}async getVideoData(t){const e=await this.getPosts(t);if(!e)return;const i=e.data.attributes.post_file.url;return i?{url:i}:void 0}async getVideoId(t){const e=/posts\/([^/]+)/.exec(t.pathname)?.[1];if(e)return e.replace(/[^\d.]/g,"")}},[Ce.reddit]:class extends li{API_ORIGIN="https://www.reddit.com";async getContentUrl(t){if("old"!==this.service?.additionalData)return document.querySelector("shreddit-player-2")?.src;const e=document.querySelector("[data-hls-url]");return e?.dataset.hlsUrl?.replaceAll("&","&")}async getVideoData(t){try{const e=await this.getContentUrl(t);if(!e)throw new si("Failed to find content url");return{url:decodeURIComponent(e)}}catch(e){return void St.error(`Failed to get reddit video data by video ID: ${t}`,e.message)}}async getVideoId(t){return/\/r\/(([^/]+)\/([^/]+)\/([^/]+)\/([^/]+))/.exec(t.pathname)?.[1]}},[Ce.bannedvideo]:class extends li{API_ORIGIN="https://api.banned.video";async getVideoInfo(t){try{const e=await this.fetch(`${this.API_ORIGIN}/graphql`,{method:"POST",body:JSON.stringify({operationName:"GetVideo",query:"query GetVideo($id: String!) {\n getVideo(id: $id) {\n title\n description: summary\n duration: videoDuration\n videoUrl: directUrl\n isStream: live\n }\n }",variables:{id:t}}),headers:{"User-Agent":"bannedVideoFrontEnd","apollographql-client-name":"banned-web","apollographql-client-version":"1.3","content-type":"application/json"}});return await e.json()}catch(e){return console.error(`Failed to get bannedvideo video info by videoId: ${t}.`,e.message),!1}}async getVideoData(t){const e=await this.getVideoInfo(t);if(!e)return;const{videoUrl:i,duration:o,isStream:a,description:n,title:r}=e.data.getVideo;return{url:i,duration:o,isStream:a,title:r,description:n}}async getVideoId(t){return t.searchParams.get("id")??void 0}},[Ce.kick]:class extends li{API_ORIGIN="https://kick.com/api";async getClipInfo(t){try{const e=await this.fetch(`${this.API_ORIGIN}/v2/clips/${t}`),i=await e.json(),{clip_url:o,duration:a,title:n}=i.clip;return{url:o,duration:a,title:n}}catch(e){return void St.error(`Failed to get kick clip info by clipId: ${t}.`,e.message)}}async getVideoInfo(t){try{const e=await this.fetch(`${this.API_ORIGIN}/v1/video/${t}`),i=await e.json(),{source:o,livestream:a}=i,{session_title:n,duration:r}=a;return{url:o,duration:Math.round(r/1e3),title:n}}catch(e){return void St.error(`Failed to get kick video info by videoId: ${t}.`,e.message)}}async getVideoData(t){return t.startsWith("videos")?await this.getVideoInfo(t.replace("videos/","")):await this.getClipInfo(t.replace("clips/",""))}async getVideoId(t){return/([^/]+)\/((videos|clips)\/([^/]+))/.exec(t.pathname)?.[2]}},[Ce.appledeveloper]:class extends li{API_ORIGIN="https://developer.apple.com";async getVideoData(t){try{const t=document.querySelector("meta[property='og:video']")?.content;if(!t)throw new si("Failed to find content url");return{url:t}}catch(e){return void St.error(`Failed to get apple developer video data by video ID: ${t}`,e.message)}}async getVideoId(t){return/videos\/play\/([^/]+)\/([\d]+)/.exec(t.pathname)?.[0]}},[Ce.epicgames]:class extends li{API_ORIGIN="https://dev.epicgames.com/community/api/learning";async getPostInfo(t){try{const e=await this.fetch(`${this.API_ORIGIN}/post.json?hash_id=${t}`);return await e.json()}catch(e){return St.error(`Failed to get epicgames post info by videoId: ${t}.`,e.message),!1}}getVideoBlock(){const t=/videoUrl\s?=\s"([^"]+)"?/,e=Array.from(document.body.querySelectorAll("script")).find((e=>t.exec(e.innerHTML)));if(!e)return;const i=e.innerHTML.trim(),o=t.exec(i)?.[1]?.replace("qsep://","https://");if(!o)return;let a=/sources\s?=\s(\[([^\]]+)\])?/.exec(i)?.[1];if(!a)return{playlistUrl:o,subtitles:[]};try{a=(a.replace(/src:(\s)+?(videoUrl)/g,'src:"removed"').substring(0,a.lastIndexOf("},"))+"]").split("\n").map((t=>t.replace(/([^\s]+):\s?(?!.*\1)/,'"$1":'))).join("\n");const t=JSON.parse(a);return{playlistUrl:o,subtitles:t.filter((t=>"captions"===t.type))}}catch{return{playlistUrl:o,subtitles:[]}}}async getVideoData(t){const e=t.split(":")?.[1],i=await this.getPostInfo(e);if(!i)return;const o=this.getVideoBlock();if(!o)return;const{playlistUrl:a,subtitles:n}=o,{title:r,description:s}=i;return{url:a,title:r,description:s,subtitles:n.map((t=>({language:we(t.srclang),source:"epicgames",format:"vtt",url:t.src})))}}async getVideoId(t){return new Promise((t=>{const e="https://dev.epicgames.com",i=btoa(window.location.href);window.addEventListener("message",(i=>{if(i.origin!==e)return;if("string"!=typeof i.data||!i.data.startsWith("getVideoId:"))return;const o=i.data.replace("getVideoId:","");return t(o)})),window.top.postMessage(`getVideoId:${i}`,e)}))}},[Ce.nineanimetv]:class extends li{API_ORIGIN="https://9animetv.to/ajax/episode";RAPID_CLOUD_ORIGIN="https://rapid-cloud.co/ajax/embed-6-v2";async getSourceId(t){try{const e=await this.fetch(`${this.API_ORIGIN}/servers?episodeId=${t}`),i=await e.json();return!!i.html&&/data-id="(\d+)"/.exec(i.html)?.[1]}catch(e){return St.error(`Failed to get 9animetv servers info by episodeId: ${t}.`,e.message),!1}}async getPlayerLink(t){try{const e=await this.fetch(`${this.API_ORIGIN}/sources?id=${t}`),i=await e.json();return!!i.link.includes("rapid-cloud.co")&&i.link}catch(e){return St.error(`Failed to get player link by sourceId: ${t}.`,e.message),!1}}async getRapidCloudData(t){try{const e=await this.fetch(`${this.RAPID_CLOUD_ORIGIN}/getSources?id=${t}`),i=await e.json();return i.encrypted?(St.warn("Encrypted RapidCloud data found. Let us know about it",i),!1):i}catch(e){return St.error(`Failed to get rapid cloud data by rapidId: ${t}.`,e.message),!1}}async getVideoData(t){const e=t.split("?ep=")[1],i=await this.getSourceId(e);if(!i)return;const o=await this.getPlayerLink(i);if(!o)return;const a=/\/([^/?]+)\?/.exec(o)?.[1];if(!a)return;const n=await this.getRapidCloudData(a);if(!n)return;const r=n.sources.find((t=>"hls"===t.type))?.file;if(!r)return;const s=n.tracks.reduce(((t,e)=>{const i=/([\w+]+)(-\d)?\.vtt/.exec(e.file)?.[1];if(!i)return t;const o=we(3===i.length?i:e.label);return t.find((t=>t.language===o))||t.push({language:o,source:"nineanimetv",format:"vtt",url:e.file}),t}),[]);return{url:r,subtitles:s}}async getVideoId(t){return new Promise((t=>{const e="https://9animetv.to";window.addEventListener("message",(i=>{if(i.origin===e&&"string"==typeof i.data&&i.data.startsWith("getVideoId:")){const e=i.data.replace("getVideoId:","");return t(e)}})),window.top.postMessage("getVideoId",e)}))}},[Ce.odysee]:class extends li{API_ORIGIN="https://odysee.com";async getVideoData(t){try{const e=await this.fetch(`${this.API_ORIGIN}/${t}`),i=await e.text(),o=/"contentUrl":(\s)?"([^"]+)"/.exec(i)?.[2];if(!o)throw new Error("Odysee url doesn't parsed");return{url:o}}catch(e){return void St.error(`Failed to get odysee video data by video ID: ${t}`,e.message)}}async getVideoId(t){return t.pathname.slice(1)}},[Ce.coursehunterLike]:class extends li{API_ORIGIN=this.origin??"https://coursehunter.net";async getCourseId(){const t=window.course_id;return void 0!==t?String(t):document.querySelector('input[name="course_id"]')?.value}async getLessonsData(t){const e=window.lessons;if(e?.length)return e;try{const e=await this.fetch(`${this.API_ORIGIN}/api/v1/course/${t}/lessons`);return await e.json()}catch(e){return void St.error(`Failed to get CoursehunterLike lessons data by courseId: ${t}, because ${e.message}`)}}getLessondId(t){let e=t.split("?lesson=")?.[1];if(e)return+e;const i=document.querySelector(".lessons-item_active");return e=i?.dataset?.index,e?+e:1}async getVideoData(t){const e=await this.getCourseId();if(!e)return;const i=await this.getLessonsData(e);if(!i)return;const o=this.getLessondId(t),a=i?.[o-1],{file:n,duration:r,title:s}=a;return n?{url:n,duration:r,title:s}:void 0}async getVideoId(t){const e=/course\/([^/]+)/.exec(t.pathname)?.[0];return e?e+t.search:void 0}},[Ce.twitch]:class extends li{API_ORIGIN="https://clips.twitch.tv";async getClipLink(t,e){const i=document.querySelector("script[type='application/ld+json']"),o=t.slice(1);if(i){const t=JSON.parse(i.innerText),e=t["@graph"].find((t=>"VideoObject"===t["@type"]))?.creator.url;if(!e)throw new si("Failed to find channel link");return`${e.replace("https://www.twitch.tv/","")}/clip/${o}`}const a="embed"===o,n=document.querySelector(a?".tw-link[data-test-selector='stream-info-card-component__stream-avatar-link']":".clips-player a:not([class])");if(!n)return;return`${n.href.replace("https://www.twitch.tv/","")}/clip/${a?e:o}`}async getVideoId(t){const e=t.pathname;if(/^m\.twitch\.tv$/.test(e))return/videos\/([^/]+)/.exec(t.href)?.[0]??e.slice(1);if(/^player\.twitch\.tv$/.test(t.hostname))return`videos/${t.searchParams.get("video")}`;const i=/([^/]+)\/(?:clip)\/([^/]+)/.exec(e);if(i)return i[0];return/^clips\.twitch\.tv$/.test(t.hostname)?await this.getClipLink(e,t.searchParams.get("clip")):/(?:videos)\/([^/]+)/.exec(e)?.[0]}},[Ce.sap]:class extends li{API_ORIGIN="https://learning.sap.com/";async requestKaltura(t,e,i){try{const o=await this.fetch(`https://${t}/api_v3/service/multirequest`,{method:"POST",body:JSON.stringify({1:{service:"session",action:"startWidgetSession",widgetId:`_${e}`},2:{service:"baseEntry",action:"list",ks:"{1:result:ks}",filter:{redirectFromEntryId:i},responseProfile:{type:1,fields:"id,referenceId,name,description,dataUrl,duration,flavorParamsIds,type,dvrStatus,externalSourceType,createdAt,updatedAt,endDate,plays,views,downloadUrl,creatorId"}},3:{service:"baseEntry",action:"getPlaybackContext",entryId:"{2:result:objects:0:id}",ks:"{1:result:ks}",contextDataParams:{objectType:"KalturaContextDataParams",flavorTags:"all"}},apiVersion:"3.3.0",format:1,ks:"",clientTag:"html5:v3.17.22",partnerId:e}),headers:{"Content-Type":"application/json"}});return await o.json()}catch(t){return void St.error("Failed to request kaltura data",t.message)}}async getKalturaData(t){try{const e=document.querySelector('script[data-nscript="beforeInteractive"]');if(!e)throw new si("Failed to find script element");const i=/https:\/\/([^"]+)\/p\/([^"]+)\/embedPlaykitJs\/uiconf_id\/([^"]+)/.exec(e?.src);if(!i)throw new si(`Failed to get sap data for videoId: ${t}`);const[,o,a]=i;let n=document.querySelector("#shadow")?.firstChild?.getAttribute("id");if(!n){const t=document.querySelector("#__NEXT_DATA__");if(!t)throw new si("Failed to find next data element");n=/"sourceId":\s?"([^"]+)"/.exec(t.innerText)?.[1]}if(!o||Number.isNaN(+a)||!n)throw new si(`One of the necessary parameters for getting a link to a sap video in wasn't found for ${t}. Params: kalturaDomain = ${o}, partnerId = ${a}, entryId = ${n}`);return await this.requestKaltura(o,a,n)}catch(t){return void St.error("Failed to get kaltura data",t.message)}}async getVideoData(t){const e=await this.getKalturaData(t);if(!e)return;const[,i,o]=e,{duration:a}=i.objects[0],n=o.sources.find((t=>"url"===t.format&&"http,https"===t.protocols&&t.url.includes(".mp4")))?.url;if(!n)return;return{url:n,subtitles:o.playbackCaptions.map((t=>({language:we(t.languageCode),source:"sap",format:"vtt",url:t.webVttUrl,isAutoGenerated:t.label.includes("auto-generated")}))),duration:a}}async getVideoId(t){return/((courses|learning-journeys)\/([^/]+)(\/[^/]+)?)/.exec(t.pathname)?.[1]}},[Ce.linkedin]:class extends di{SUBTITLE_SOURCE="linkedin";async getVideoData(t){const e=this.getVideoDataByPlayer(t);if(!e)return;const{url:i,duration:o,subtitles:a}=e;return{url:ye(new URL(i)),duration:o,subtitles:a}}async getVideoId(t){return/\/learning\/(([^/]+)\/([^/]+))/.exec(t.pathname)?.[1]}},[Ce.vimeo]:class extends li{API_KEY="";DEFAULT_SITE_ORIGIN="https://vimeo.com";SITE_ORIGIN=this.isPrivatePlayer()?this.service?.url?.slice(0,-1)??this.DEFAULT_SITE_ORIGIN:this.DEFAULT_SITE_ORIGIN;isErrorData(t){return Object.hasOwn(t,"error")}isPrivatePlayer(){return this.referer&&!this.referer.includes("vimeo.com")}async getViewerData(){try{const t=await this.fetch("https://vimeo.com/_next/viewer"),e=await t.json(),{apiUrl:i,jwt:o}=e;return this.API_ORIGIN=`https://${i}`,this.API_KEY=`jwt ${o}`,e}catch(t){return St.error("Failed to get default viewer data.",t.message),!1}}async getVideoInfo(t){try{const e=new URLSearchParams({fields:"name,link,description,duration"}).toString(),i=await this.fetch(`${this.API_ORIGIN}/videos/${t}?${e}`,{headers:{Authorization:this.API_KEY}}),o=await i.json();if(this.isErrorData(o))throw new Error(o.developer_message??o.error);return o}catch(e){return St.error(`Failed to get video info by video ID: ${t}`,e.message),!1}}async getPrivateVideoSource(t){try{const{default_cdn:e,cdns:i}=t.dash,o=i[e].url,a=await this.fetch(o);if(200!==a.status)throw new si(await a.text());const n=await a.json(),r=new URL(o),s=Array.from(n.base_url.matchAll(/\.\.\//g)).length+1,l=r.pathname.split("/");let d=n.base_url.replaceAll("../","");d=d&&!d.startsWith("/")?`/${d}`:d,r.pathname=l.slice(0,l.length-s).join("/")+d,r.pathname.endsWith("/")||(r.pathname+="/");const u=n.audio.find((t=>"audio/mp4"===t.mime_type&&"dash"===t.format));if(!u)throw new si("Failed to find video data");const c=u.segments?.[0]?.url;if(!c)throw new si("Failed to find first segment url");const[h,p]=c.split("?",2),g=new URLSearchParams(p);return g.delete("range"),r.pathname+=`${u.base_url}${h}`,r.href=r.href.split("?")[0]+"?"+g.toString(),r.href}catch(t){return St.error("Failed to get private video source",t.message),!1}}async getPrivateVideoInfo(t){try{if("undefined"==typeof playerConfig)return;const e=playerConfig,i=await this.getPrivateVideoSource(e.request.files);if(!i)throw new si("Failed to get private video source");const{video:{title:o,duration:a},request:{text_tracks:n}}=e;return{url:`${this.SITE_ORIGIN}/${t}`,video_url:i,title:o,duration:a,subs:n}}catch(e){return St.error(`Failed to get private video info by video ID: ${t}`,e.message),!1}}async getSubsInfo(t){try{const e=new URLSearchParams({per_page:"100",fields:"language,type,link"}).toString(),i=await this.fetch(`${this.API_ORIGIN}/videos/${t}/texttracks?${e}`,{headers:{Authorization:this.API_KEY}}),o=await i.json();if(this.isErrorData(o))throw new Error(o.developer_message??o.error);return o}catch(e){return St.error(`Failed to get subtitles info by video ID: ${t}`,e.message),!1}}async getVideoData(t){const e=this.isPrivatePlayer();if(!this.extraInfo)return this.returnBaseData(t);if(e){const e=await this.getPrivateVideoInfo(t);if(!e)return;const{url:i,subs:o,video_url:a,title:n,duration:r}=e,s=o.map((t=>({language:we(t.lang),source:"vimeo",format:"vtt",url:this.SITE_ORIGIN+t.url,isAutoGenerated:t.lang.includes("autogenerated")}))),l=s.length?[{target:"video_file_url",targetUrl:a},{target:"subtitles_file_url",targetUrl:s[0].url}]:null;return{...l?{url:i,translationHelp:l}:{url:a},subtitles:s,title:n,duration:r}}t.startsWith("video/")&&(t=t.replace("video/","")),t.includes("/")&&(t=t.replace("/",":"));if(!await this.getViewerData())return this.returnBaseData(t);const i=await this.getVideoInfo(t);if(!i)return this.returnBaseData(t);const o=await this.getSubsInfo(t),a=o?o.data.map((t=>({language:we(t.language),source:"vimeo",format:"vtt",url:t.link,isAutoGenerated:t.language.includes("autogen")}))):[],{link:n,duration:r,name:s,description:l}=i;return{url:n,title:s,description:l,subtitles:a,duration:r}}async getVideoId(t){const e=/[^/]+\/[^/]+$/.exec(t.pathname)?.[0];return this.isPrivatePlayer()?e:e?.startsWith("video/")?e.replace("video/",""):e??/[^/]+$/.exec(t.pathname)?.[0]}},[Ce.yandexdisk]:class extends li{API_ORIGIN=window.location.origin;CLIENT_PREFIX="/client/disk";INLINE_PREFIX="/i/";DISK_PREFIX="/d/";isErrorData(t){return Object.hasOwn(t,"error")}async getClientVideoData(t){const e=new URL(window.location.href).searchParams.get("idDialog");if(!e)return;const i=document.querySelector("#preloaded-data");if(i)try{const t=JSON.parse(i.innerText),{idClient:o,sk:a}=t.config,n=await this.fetch(this.API_ORIGIN+"/models/?_m=resource",{method:"POST",body:new URLSearchParams({idClient:o,sk:a,"_model.0":"resource","id.0":e.replaceAll(" ","+")}).toString().replaceAll(/%2B/g,"+"),headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}}),r=await n.json();if(!r.models)throw new si("Failed to get resource info");const s=r.models[0].data;if(this.isErrorData(s))throw new si(s.error?.message);const{meta:{short_url:l,video_info:d},name:u}=s;if(!d)throw new si("There's no video open right now");if(!l)throw new si("Access to the video is limited");const c=this.clearTitle(u);return{url:l,title:c,duration:Math.round(d.duration/1e3)}}catch(e){return void St.error(`Failed to get yandex disk video data by video ID: ${t}, because ${e.message}`)}}clearTitle(t){return t.replace(/(\.[^.]+)$/,"")}getBodyHash(t,e){const i=JSON.stringify({hash:t,sk:e});return encodeURIComponent(i)}async fetchList(t,e){const i=this.getBodyHash(t,e),o=await this.fetch(this.API_ORIGIN+"/public/api/fetch-list",{method:"POST",body:i}),a=await o.json();if(Object.hasOwn(a,"error"))throw new si("Failed to fetch folder list");return a.resources}async getDownloadUrl(t,e){const i=this.getBodyHash(t,e),o=await this.fetch(this.API_ORIGIN+"/public/api/download-url",{method:"POST",body:i}),a=await o.json();if(a.error)throw new si("Failed to get download url");return a.data.url}async getDiskVideoData(t){try{const e=document.getElementById("store-prefetch");if(!e)throw new si("Failed to get prefetch data");const i=t.split("/").slice(3);if(!i.length)throw new si("Failed to find video file path");const o=JSON.parse(e.innerText),{resources:a,rootResourceId:n,environment:{sk:r}}=o,s=a[n],l=i.length-1,d=i.filter(((t,e)=>e!==l)).join("/");let u=Object.values(a);d.includes("/")&&(u=await this.fetchList(`${s.hash}:/${d}`,r));const c=u.find((t=>t.name===i[l]));if(!c)throw new si("Failed to find resource");if(c&&"dir"===c.type)throw new si("Path is dir, but expected file");const{meta:{short_url:h,mediatype:p,videoDuration:g},path:m,name:v}=c;if("video"!==p)throw new si("Resource isn't a video");const f=this.clearTitle(v),b=Math.round(g/1e3);if(h)return{url:h,duration:b,title:f};const w=await this.getDownloadUrl(m,r);return{url:ye(new URL(w)),duration:b,title:f}}catch(e){return void St.error(`Failed to get yandex disk video data by disk video ID: ${t}`,e.message)}}async getVideoData(t){return t.startsWith(this.INLINE_PREFIX)?{url:this.service.url+t.slice(1)}:(t=decodeURIComponent(t)).startsWith(this.CLIENT_PREFIX)?await this.getClientVideoData(t):await this.getDiskVideoData(t)}async getVideoId(t){if(t.pathname.startsWith(this.CLIENT_PREFIX))return t.pathname+t.search;const e=/\/i\/([^/]+)/.exec(t.pathname)?.[0];return e||(/\/d\/([^/]+)\/([^/]+)/.exec(t.pathname)?t.pathname:void 0)}},[Ce.vk]:ui,[Ce.trovo]:class extends li{async getVideoId(t){const e=t.searchParams.get("vid"),i=/([^/]+)\/([\d]+)/.exec(t.pathname)?.[0];if(e&&i)return`${i}?vid=${e}`}},[Ce.incestflix]:class extends li{async getVideoData(t){try{const t=document.querySelector("#incflix-stream source:first-of-type");if(!t)throw new si("Failed to find source element");const e=t.getAttribute("src");if(!e)throw new si("Failed to find source link");const i=new URL(e.startsWith("//")?`https:${e}`:e);return i.searchParams.append("media-proxy","video.mp4"),{url:ye(i)}}catch(e){return void St.error(`Failed to get Incestflix data by videoId: ${t}`,e.message)}}async getVideoId(t){return/\/watch\/([^/]+)/.exec(t.pathname)?.[1]}},[Ce.porntn]:class extends li{async getVideoData(t){try{if("undefined"==typeof flashvars)return;const{rnd:t,video_url:e,video_title:i}=flashvars;if(!e||!t)throw new si("Failed to find video source or rnd");const o=new URL(e);o.searchParams.append("rnd",t),St.log("PornTN get_file link",o.href);const a=await this.fetch(o.href,{method:"head"}),n=new URL(a.url);St.log("PornTN cdn link",n.href);return{url:ye(n),title:i}}catch(e){return void St.error(`Failed to get PornTN data by videoId: ${t}`,e.message)}}async getVideoId(t){return/\/videos\/(([^/]+)\/([^/]+))/.exec(t.pathname)?.[1]}},[Ce.googledrive]:class extends li{getPlayerData(){const t=document.querySelector("#movie_player");return t?.getVideoData?.call()??void 0}async getVideoId(t){return this.getPlayerData()?.video_id}},[Ce.bilibili]:class extends li{async getVideoId(t){const e=/bangumi\/play\/([^/]+)/.exec(t.pathname)?.[0];if(e)return e;const i=t.searchParams.get("bvid");if(i)return`video/${i}`;let o=/video\/([^/]+)/.exec(t.pathname)?.[0];return o&&null!==t.searchParams.get("p")&&(o+=`/?p=${t.searchParams.get("p")}`),o}},[Ce.xvideos]:class extends li{async getVideoId(t){return/[^/]+\/[^/]+$/.exec(t.pathname)?.[0]}},[Ce.watchpornto]:class extends li{async getVideoId(t){return/(video|embed)\/(\d+)(\/[^/]+\/)?/.exec(t.pathname)?.[0]}},[Ce.archive]:class extends li{async getVideoId(t){return/(details|embed)\/([^/]+)/.exec(t.pathname)?.[2]}},[Ce.dailymotion]:class extends li{async getVideoId(t){const e=Array.from(document.querySelectorAll("*")).filter((t=>t.innerHTML.trim().includes(".m3u8"))),i=e?.[1]?.lastChild?.src;return i?/\/video\/(\w+)\.m3u8/.exec(i)?.[1]:void 0}},[Ce.youku]:class extends li{async getVideoId(t){return/v_show\/id_[\w=]+/.exec(t.pathname)?.[0]}},[Ce.egghead]:class extends li{async getVideoId(t){return t.pathname.slice(1)}},[Ce.newgrounds]:class extends li{async getVideoId(t){return/([^/]+)\/(view)\/([^/]+)/.exec(t.pathname)?.[0]}},[Ce.okru]:class extends li{async getVideoId(t){return/\/video\/(\d+)/.exec(t.pathname)?.[1]}},[Ce.peertube]:class extends li{async getVideoId(t){return/\/w\/([^/]+)/.exec(t.pathname)?.[0]}},[Ce.eporner]:class extends li{async getVideoId(t){return/video-([^/]+)\/([^/]+)/.exec(t.pathname)?.[0]}},[Ce.bitchute]:class extends li{async getVideoId(t){return/(video|embed)\/([^/]+)/.exec(t.pathname)?.[2]}},[Ce.rutube]:class extends li{async getVideoId(t){return/(?:video|embed)\/([^/]+)/.exec(t.pathname)?.[1]}},[Ce.facebook]:class extends li{async getVideoId(t){return t.pathname.slice(1)}},[Ce.rumble]:class extends li{async getVideoId(t){return t.pathname.slice(1)}},[Ce.twitter]:class extends li{async getVideoId(t){const e=/status\/([^/]+)/.exec(t.pathname)?.[1];if(e)return e;const i=this.video?.closest('[data-testid="tweet"]'),o=i?.querySelector('a[role="link"][aria-label]')?.href;return o?/status\/([^/]+)/.exec(o)?.[1]:void 0}},[Ce.pornhub]:class extends li{async getVideoId(t){return t.searchParams.get("viewkey")??/embed\/([^/]+)/.exec(t.pathname)?.[1]}},[Ce.tiktok]:ci,[Ce.proxitok]:ci,[Ce.nine_gag]:class extends li{async getVideoId(t){return/gag\/([^/]+)/.exec(t.pathname)?.[1]}},[Ce.youtube]:mi,[Ce.ricktube]:mi,[Ce.invidious]:mi,[Ce.poketube]:mi,[Ce.piped]:mi,[Ce.dzen]:class extends li{async getVideoId(t){return/video\/watch\/([^/]+)/.exec(t.pathname)?.[1]}},[Ce.cloudflarestream]:class extends li{async getVideoId(t){return t.pathname+t.search}},[Ce.loom]:class extends li{getClientVersion(){if("undefined"==typeof SENTRY_RELEASE)return;return SENTRY_RELEASE.id}async getVideoData(t){try{const e=this.getClientVersion();if(!e)throw new si("Failed to get client version");const i=await this.fetch("https://www.loom.com/graphql",{headers:{"User-Agent":yt.userAgent,"content-type":"application/json","x-loom-request-source":`loom_web_${e}`,"apollographql-client-name":"web","apollographql-client-version":e,"Alt-Used":"www.loom.com"},body:`{"operationName":"FetchCaptions","variables":{"videoId":"${t}"},"query":"query FetchCaptions($videoId: ID!, $password: String) {\\n fetchVideoTranscript(videoId: $videoId, password: $password) {\\n ... on VideoTranscriptDetails {\\n id\\n captions_source_url\\n language\\n __typename\\n }\\n ... on GenericError {\\n message\\n __typename\\n }\\n __typename\\n }\\n}"}`,method:"POST"});if(200!==i.status)throw new si("Failed to get data from graphql");const o=(await i.json()).data.fetchVideoTranscript;if("GenericError"===o.__typename)throw new si(o.message);return{url:this.service.url+t,subtitles:[{format:"vtt",language:we(o.language),source:"loom",url:o.captions_source_url}]}}catch(e){return St.error(`Failed to get Loom video data, because: ${e.message}`),this.returnBaseData(t)}}async getVideoId(t){return/(embed|share)\/([^/]+)?/.exec(t.pathname)?.[2]}},[Ce.rtnews]:class extends li{async getVideoData(t){const e=document.querySelector(".jw-video, .media__video_noscript");if(!e)return;let i=e.getAttribute("src");return i?(i.endsWith(".MP4")&&(i=ye(i)),{videoId:t,url:i}):void 0}async getVideoId(t){return t.pathname.slice(1)}},[Ce.bitview]:class extends li{async getVideoData(t){try{const t=document.querySelector(".vlScreen > video")?.src;if(!t)throw new si("Failed to find video URL");return{url:t}}catch(e){return void St.error(`Failed to get Bitview data by videoId: ${t}`,e.message)}}async getVideoId(t){return t.searchParams.get("v")}},[ni.udemy]:class extends li{API_ORIGIN="https://www.udemy.com/api-2.0";getModuleData(){const t=document.querySelector(".ud-app-loader[data-module-id='course-taking']"),e=t?.dataset?.moduleArgs;if(e)return JSON.parse(e)}getLectureId(){return/learn\/lecture\/([^/]+)/.exec(window.location.pathname)?.[1]}async getLectureData(t,e){try{const i=await this.fetch(`${this.API_ORIGIN}/users/me/subscribed-courses/${t}/lectures/${e}/?`+new URLSearchParams({"fields[lecture]":"title,description,asset","fields[asset]":"length,media_sources,captions"}).toString());return await i.json()}catch(i){return void St.error(`Failed to get lecture data by courseId: ${t} and lectureId: ${e}`,i.message)}}async getCourseLang(t){try{const e=await this.fetch(`${this.API_ORIGIN}/users/me/subscribed-courses/${t}?`+new URLSearchParams({"fields[course]":"locale"}).toString());return await e.json()}catch(e){return void St.error(`Failed to get course lang by courseId: ${t}`,e.message)}}findVideoUrl(t){return t?.find((t=>"video/mp4"===t.type))?.src}findSubtitleUrl(t,e){let i=t?.find((t=>we(t.locale_id)===e));return i||(i=t?.find((t=>"en"===we(t.locale_id)))??t?.[0]),i?.url}async getVideoData(t){const e=this.getModuleData();if(!e)return;const{courseId:i}=e,o=this.getLectureId();if(St.log(`[Udemy] courseId: ${i}, lectureId: ${o}`),!o)return;const a=await this.getLectureData(i,o);if(!a)return;const{title:n,description:r,asset:s}=a,{length:l,media_sources:d,captions:u}=s,c=this.findVideoUrl(d);if(!c)return void St.log("Failed to find .mp4 video file in media_sources",d);let h="en";const p=await this.getCourseLang(i);if(p){const{locale:{locale:t}}=p;h=t?we(t):h}hi.includes(h)||(h="en");const g=this.findSubtitleUrl(u,h);return g||St.log("Failed to find subtitle file in captions",u),{...g?{url:this.service?.url+t,translationHelp:[{target:"subtitles_file_url",targetUrl:g},{target:"video_file_url",targetUrl:c}],detectedLanguage:h}:{url:c,translationHelp:null},duration:l,title:n,description:r}}async getVideoId(t){return t.pathname.slice(1)}},[ni.coursera]:vi,[ni.douyin]:fi,[ni.artstation]:class extends li{API_ORIGIN="https://www.artstation.com/api/v2/learning";getCSRFToken(){return document.querySelector('meta[name="public-csrf-token"]')?.content}async getCourseInfo(t){try{const e=await this.fetch(`${this.API_ORIGIN}/courses/${t}/autoplay.json`,{method:"POST",headers:{"PUBLIC-CSRF-TOKEN":this.getCSRFToken()}});return await e.json()}catch(e){return St.error(`Failed to get artstation course info by courseId: ${t}.`,e.message),!1}}async getVideoUrl(t){try{const e=await this.fetch(`${this.API_ORIGIN}/quicksilver/video_url.json?chapter_id=${t}`);return(await e.json()).url.replace("qsep://","https://")}catch(e){return St.error(`Failed to get artstation video url by chapterId: ${t}.`,e.message),!1}}async getVideoData(t){const[,e,,,i]=t.split("/"),o=await this.getCourseInfo(e);if(!o)return;const a=o.chapters.find((t=>t.hash_id===i));if(!a)return;const n=await this.getVideoUrl(a.id);if(!n)return;const{title:r,duration:s,subtitles:l}=a;return{url:n,title:r,duration:s,subtitles:l.filter((t=>"vtt"===t.format)).map((t=>({language:we(t.locale),source:"artstation",format:"vtt",url:t.file_url})))}}async getVideoId(t){return/courses\/(\w{3,5})\/([^/]+)\/chapters\/(\w{3,5})/.exec(t.pathname)?.[0]}}};class yi{helpersData;constructor(t={}){this.helpersData=t}getHelper(t){return new wi[t](this.helpersData)}}async function xi(t,e={}){const i=new URL(window.location.href),o=t.host;if(Object.keys(wi).includes(o)){const t=new yi(e).getHelper(o);return await t.getVideoId(i)}return o===Ce.custom?i.href:void 0}function Si(t,e=","){const i=t/1e3,o=Math.floor(i/3600),a=Math.floor(i%3600/60),n=Math.floor(i%60),r=Math.floor(t%1e3);return`${o.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}${e}${r.toString().padStart(3,"0")}`}function ki(t){const e=t.split(" ")?.[0]?.split(":");e.length<3&&e.unshift("00");const[i,o,a]=e;return 36e5*+i+6e4*+o+ +a.replace(/[,.]/,"")}function Ti(t,e="srt"){const i="vtt"===e,o=i?".":",",a=t.subtitles.map(((t,e)=>(i?"":`${e+1}\n`)+`${Si(t.startMs,o)} --\x3e ${Si(t.startMs+t.durationMs,o)}\n${t.text}\n\n`)).join("").trim();return i?`WEBVTT\n\n${a}`:a}function Ci(t,e="srt"){const i=function(t){return"string"!=typeof t?"json":/^(WEBVTT)(\r?\n)/.exec(t)?"vtt":"srt"}(t);return i===e?t:"json"===i?Ti(t,e):(t=function(t,e="srt"){const i=t.split(/\r?\n\r?\n/g);"vtt"===e&&i.shift(),/^\d+\r?\n/.exec(i?.[0]??"")&&(e="srt");const o=+("srt"===e);return{containsTokens:!1,subtitles:i.reduce(((t,e)=>{const i=e.trim().split("\n"),a=i[o],n=i.slice(o+1).join("\n");if(!(2===i.length&&e.includes(" --\x3e ")||a?.includes(" --\x3e ")))return 0===t.length||(t[t.length-1].text+=`\n\n${i.join("\n")}`),t;const[r,s]=a.split(" --\x3e "),l=ki(r),d=ki(s)-l;return t.push({text:n,startMs:l,durationMs:d,speakerId:"0"}),t}),[])}}(t,i),"json"===e?t:Ti(t,e))}class Ii{static formatYandexTokens(t){const e=t.startMs+t.durationMs;return t.tokens.reduce(((i,o,a)=>{const n=t.tokens[a+1],r=i[i.length-1],s=r?.alignRange?.end??0,l=s+o.text.length;if(o.alignRange={start:s,end:l},i.push(o),n){const t=o.startMs+o.durationMs,a=n.startMs?n.startMs-t:e-t;i.push({text:" ",startMs:t,durationMs:a,alignRange:{start:l,end:l+1}})}return i}),[])}static createTokens(t,e){const i=t.text.split(/([\n \t])/).reduce(((t,i)=>{if(!i.length)return t;const o=t[t.length-1]??e,a=o?.alignRange?.end??0,n=a+i.length;return t.push({text:i,alignRange:{start:a,end:n}}),t}),[]),o=Math.floor(t.durationMs/i.length),a=t.startMs+t.durationMs;return i.map(((e,n)=>{const r=n===i.length-1,s=t.startMs+o*n;return{...e,startMs:s,durationMs:r?a-s:o}}))}static processTokens(t,e){const i=[];let o;const{source:a,isAutoGenerated:n}=e;for(const e of t.subtitles){const t=e?.tokens?.length,r=t&&("yandex"===a||"youtube"===a&&n)?this.formatYandexTokens(e):this.createTokens(e,o);o=r[r.length-1],i.push({...e,tokens:r})}return t.containsTokens=!0,i}static formatYoutubeSubtitles(t,e=!1){if(!t?.events?.length)return console.error("[VOT] Invalid YouTube subtitles format:",t),{containsTokens:e,subtitles:[]};const i={containsTokens:e,subtitles:[]};for(let o=0;o<t.events.length;o++){const a=t.events[o];if(!a.segs)continue;let n=a.dDurationMs;t.events[o+1]&&a.tStartMs+a.dDurationMs>t.events[o+1].tStartMs&&(n=t.events[o+1].tStartMs-a.tStartMs);const r=[];let s=n;for(let t=0;t<a.segs.length;t++){const e=a.segs[t],i=e.utf8.trim();if("\n"===i)continue;const o=e.tOffsetMs??0;let l=n;const d=a.segs[t+1];d?.tOffsetMs&&(l=d.tOffsetMs-o,s-=l),r.push({text:i,startMs:a.tStartMs+o,durationMs:d?l:s})}const l=r.map((t=>t.text)).join(" ");l&&i.subtitles.push({text:l,startMs:a.tStartMs,durationMs:n,...e?{tokens:r}:{}})}return i}static cleanJsonSubtitles(t){const{containsTokens:e,subtitles:i}=t;return{containsTokens:e,subtitles:i.map((t=>({...t,text:t.text.replace(/(<([^>]+)>)/gi,"")})))}}static async fetchWithTimeout(t,e=5e3){try{return await ze(t,{timeout:e})}catch(t){throw console.error("[VOT] Fetch failed:",t),t}}static async fetchSubtitles(t){const{source:e,isAutoGenerated:i,format:o,url:a}=t;try{const n=await this.fetchWithTimeout(a);let r;if(["vtt","srt"].includes(o)){r=Ci(await n.text(),"json")}else r=await n.json();return"youtube"===e&&(r=this.formatYoutubeSubtitles(r,i)),"vk"===e&&(r=this.cleanJsonSubtitles(r)),r.subtitles=this.processTokens(r,t),console.log("[VOT] Processed subtitles:",r),r}catch(t){return console.error("[VOT] Failed to process subtitles:",t),{containsTokens:!1,subtitles:[]}}}static async getSubtitles(t,e){const{host:i,url:o,detectedLanguage:a,videoId:n,duration:r,subtitles:s=[]}=e;try{const e=await Promise.race([t.getSubtitles({videoData:{host:i,url:o,videoId:n,duration:r},requestLang:a}),new Promise(((t,e)=>setTimeout((()=>e(new Error("Timeout"))),5e3)))]);console.log("[VOT] Subtitles response:",e),e.waiting&&console.error("[VOT] Failed to get Yandex subtitles");const l=(e.subtitles??[]).reduce(((t,e)=>(e.language&&!t.find((t=>"yandex"===t.source&&t.language===e.language&&!t.translatedFromLanguage))&&t.push({source:"yandex",language:e.language,url:e.url}),e.translatedLanguage&&t.push({source:"yandex",language:e.translatedLanguage,translatedFromLanguage:e.language,url:e.translatedUrl}),t)),[]);return[...l,...s].sort(((t,e)=>{if(t.source!==e.source)return"yandex"===t.source?-1:1;if(t.language!==e.language&&(t.language===Re||e.language===Re))return t.language===Re?-1:1;if("yandex"===t.source){if(t.translatedFromLanguage!==e.translatedFromLanguage)return t.translatedFromLanguage&&e.translatedFromLanguage?t.translatedFromLanguage===a?-1:1:t.language===e.language?t.translatedFromLanguage?1:-1:t.translatedFromLanguage?-1:1;if(!t.translatedFromLanguage)return t.language===a?-1:1}return"yandex"!==t.source&&t.isAutoGenerated!==e.isAutoGenerated?t.isAutoGenerated?1:-1:0}))}catch(t){const e="Timeout"===t.message?"Failed to get Yandex subtitles: timeout":"Error in getSubtitles function";throw console.error(`[VOT] ${e}`,t),t}}}class Pi{constructor(t,e,i){this.video=t,this.container="youtube"===i.host&&"mobile"!==i.additionalData?e.parentElement:e,this.site=i,this.subtitlesContainer=this.createSubtitlesContainer(),this.position={left:25,top:75},this.dragging={active:!1,offset:{x:0,y:0}},this.subtitles=null,this.lastContent=null,this.highlightWords=!1,this.fontSize=20,this.opacity=.2,this.maxLength=300,this.abortController=new AbortController,this.bindEvents(),this.updateContainerRect()}createSubtitlesContainer(){return this.subtitlesContainer=document.createElement("vot-block"),this.subtitlesContainer.classList.add("vot-subtitles-widget"),this.container.appendChild(this.subtitlesContainer),this.subtitlesContainer}bindEvents(){const{signal:t}=this.abortController;this.onPointerDownBound=t=>this.onPointerDown(t),this.onPointerUpBound=()=>this.onPointerUp(),this.onPointerMoveBound=t=>this.onPointerMove(t),this.onTimeUpdateBound=this.debounce((()=>this.update()),100),document.addEventListener("pointerdown",this.onPointerDownBound,{signal:t}),document.addEventListener("pointerup",this.onPointerUpBound,{signal:t}),document.addEventListener("pointermove",this.onPointerMoveBound,{signal:t}),this.video?.addEventListener("timeupdate",this.onTimeUpdateBound,{signal:t}),this.resizeObserver=new ResizeObserver((()=>this.onResize())),this.resizeObserver.observe(this.container)}onPointerDown(t){if(!this.subtitlesContainer.contains(t.target))return;const e=this.subtitlesContainer.getBoundingClientRect(),i=this.container.getBoundingClientRect();this.dragging={active:!0,offset:{x:t.clientX-e.left,y:t.clientY-e.top},containerOffset:{x:i.left,y:i.top}}}onPointerUp(){this.dragging.active=!1}onPointerMove(t){if(!this.dragging.active)return;t.preventDefault();const{width:e,height:i}=this.container.getBoundingClientRect(),{containerOffset:o,offset:a}=this.dragging;this.position={left:(t.clientX-a.x-o.x)/e*100,top:(t.clientY-a.y-o.y)/i*100},this.applySubtitlePosition()}onResize(){this.updateContainerRect()}updateContainerRect(){this.containerRect=this.container.getBoundingClientRect(),this.applySubtitlePosition()}applySubtitlePosition(){const{width:t,height:e}=this.containerRect,{offsetWidth:i,offsetHeight:o}=this.subtitlesContainer,a=(t-i)/t*100,n=(e-o)/e*100;this.position.left=Math.max(0,Math.min(this.position.left,a)),this.position.top=Math.max(0,Math.min(this.position.top,n)),this.subtitlesContainer.style.left=`${this.position.left}%`,this.subtitlesContainer.style.top=`${this.position.top}%`}processTokens(t){if(t.at(-1).alignRange.end<=this.maxLength)return t;const e=[];let i=[],o=0;for(const a of t)o+=a.text.length,i.push(a),o>this.maxLength&&(e.push(this.trimChunk(i)),i=[],o=0);i.length&&e.push(this.trimChunk(i));const a=1e3*this.video.currentTime;return e.find((t=>t[0].startMs<a&&a<t.at(-1).startMs+t.at(-1).durationMs))||e[0]}trimChunk(t){return" "===t[0]?.text&&t.shift()," "===t.at(-1)?.text&&t.pop(),t}renderTokens(t,e){return t.map((t=>{const i=this.highlightWords&&(e>t.startMs+t.durationMs/2||e>t.startMs-100&&t.startMs+t.durationMs/2-e<275);return k`<span class="${i?"passed":I}"> +(()=>{var t={"./src/styles/main.scss":()=>{GM_addStyle('.vot-button{--vot-helper-theme:var(--vot-theme-rgb,var(--vot-primary-rgb,33,150,243));--vot-helper-ontheme:var(--vot-ontheme-rgb,var(--vot-onprimary-rgb,255,255,255));box-sizing:border-box;vertical-align:middle;text-align:center;text-overflow:ellipsis;min-width:64px;height:36px;color:rgb(var(--vot-helper-ontheme));background-color:rgb(var(--vot-helper-theme));font-family:var(--vot-font-family,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system);cursor:pointer;border:none;border-radius:4px;outline:none;padding:0 16px;font-size:14px;font-weight:500;line-height:36px;transition:box-shadow .2s;display:inline-block;position:relative;box-shadow:0 3px 1px -2px rgba(0,0,0,.2),0 2px 2px rgba(0,0,0,.14),0 1px 5px rgba(0,0,0,.12)}.vot-button[hidden]{display:none!important}.vot-button::-moz-focus-inner{border:none}.vot-button:before,.vot-button:after{content:"";border-radius:inherit;opacity:0;position:absolute;top:0;bottom:0;left:0;right:0}.vot-button:before{background-color:rgb(var(--vot-helper-ontheme));transition:opacity .2s}.vot-button:after{background:radial-gradient(circle,currentColor 1%,transparent 1%) 50%/10000% 10000% no-repeat;transition:opacity 1s,background-size .5s}.vot-button:hover{box-shadow:0 2px 4px -1px rgba(0,0,0,.2),0 4px 5px rgba(0,0,0,.14),0 1px 10px rgba(0,0,0,.12)}.vot-button:hover:before{opacity:.08}.vot-button:active{box-shadow:0 5px 5px -3px rgba(0,0,0,.2),0 8px 10px 1px rgba(0,0,0,.14),0 3px 14px 2px rgba(0,0,0,.12)}.vot-button:active:after{opacity:.32;background-size:100% 100%;transition:background-size}.vot-button[disabled=true]{background-color:rgba(var(--vot-onsurface-rgb,0,0,0),.12);color:rgba(var(--vot-onsurface-rgb,0,0,0),.38);box-shadow:none;cursor:initial}.vot-button[disabled=true]:before{opacity:0}.vot-button[disabled=true]:after{opacity:0}.vot-outlined-button{--vot-helper-theme:var(--vot-theme-rgb,var(--vot-primary-rgb,33,150,243));box-sizing:border-box;border:1px solid;border-color:rgba(var(--vot-onsurface-rgb,0,0,0),.24);vertical-align:middle;text-align:center;text-overflow:ellipsis;min-width:64px;height:36px;color:rgb(var(--vot-helper-theme));font-family:var(--vot-font-family,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system);cursor:pointer;background-color:transparent;border-radius:4px;outline:none;margin:0;padding:0 16px;font-size:14px;font-weight:500;line-height:34px;display:inline-block;position:relative}.vot-outlined-button[hidden]{display:none!important}.vot-outlined-button::-moz-focus-inner{border:none}.vot-outlined-button:before,.vot-outlined-button:after{content:"";opacity:0;border-radius:3px;position:absolute;top:0;bottom:0;left:0;right:0}.vot-outlined-button:before{background-color:rgb(var(--vot-helper-theme));transition:opacity .2s}.vot-outlined-button:after{background:radial-gradient(circle,currentColor 1%,transparent 1%) 50%/10000% 10000% no-repeat;transition:opacity 1s,background-size .5s}.vot-outlined-button:hover:before{opacity:.04}.vot-outlined-button:active:after{opacity:.16;background-size:100% 100%;transition:background-size}.vot-outlined-button[disabled=true]{color:rgba(var(--vot-onsurface-rgb,0,0,0),.38);cursor:initial;background-color:transparent}.vot-outlined-button[disabled=true]:before{opacity:0}.vot-outlined-button[disabled=true]:after{opacity:0}.vot-text-button{--vot-helper-theme:var(--vot-theme-rgb,var(--vot-primary-rgb,33,150,243));box-sizing:border-box;vertical-align:middle;text-align:center;text-overflow:ellipsis;min-width:64px;height:36px;color:rgb(var(--vot-helper-theme));font-family:var(--vot-font-family,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system);cursor:pointer;background-color:transparent;border:none;border-radius:4px;outline:none;margin:0;padding:0 8px;font-size:14px;font-weight:500;line-height:36px;display:inline-block;position:relative}.vot-text-button[hidden]{display:none!important}.vot-text-button::-moz-focus-inner{border:none}.vot-text-button:before,.vot-text-button:after{content:"";border-radius:inherit;opacity:0;position:absolute;top:0;bottom:0;left:0;right:0}.vot-text-button:before{background-color:rgb(var(--vot-helper-theme));transition:opacity .2s}.vot-text-button:after{background:radial-gradient(circle,currentColor 1%,transparent 1%) 50%/10000% 10000% no-repeat;transition:opacity 1s,background-size .5s}.vot-text-button:hover:before{opacity:.04}.vot-text-button:active:after{opacity:.16;background-size:100% 100%;transition:background-size}.vot-text-button[disabled=true]{color:rgba(var(--vot-onsurface-rgb,0,0,0),.38);cursor:initial;background-color:transparent}.vot-text-button[disabled=true]:before{opacity:0}.vot-text-button[disabled=true]:after{opacity:0}.vot-icon-button{--vot-helper-onsurface:rgba(var(--vot-onsurface-rgb,0,0,0),.87);box-sizing:border-box;vertical-align:middle;text-align:center;text-overflow:ellipsis;width:36px;height:36px;fill:var(--vot-helper-onsurface);color:var(--vot-helper-onsurface);font-family:var(--vot-font-family,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system);cursor:pointer;background-color:transparent;border:none;border-radius:50%;outline:none;margin:0;padding:0;font-size:14px;font-weight:500;line-height:36px;display:inline-block;position:relative}.vot-icon-button[hidden]{display:none!important}.vot-icon-button::-moz-focus-inner{border:none}.vot-icon-button:before,.vot-icon-button:after{content:"";border-radius:inherit;opacity:0;position:absolute;top:0;bottom:0;left:0;right:0}.vot-icon-button:before{background-color:var(--vot-helper-onsurface);transition:opacity .2s}.vot-icon-button:after{background:radial-gradient(circle,currentColor 1%,transparent 1%) 50%/10000% 10000% no-repeat;transition:opacity .3s,background-size .4s}.vot-icon-button:hover:before{opacity:.04}.vot-icon-button:active:after{opacity:.32;background-size:100% 100%;transition:background-size,opacity}.vot-icon-button[disabled=true]{color:rgba(var(--vot-onsurface-rgb,0,0,0),.38);fill:rgba(var(--vot-onsurface-rgb,0,0,0),.38);cursor:initial;background-color:transparent}.vot-icon-button[disabled=true]:before{opacity:0}.vot-icon-button[disabled=true]:after{opacity:0}.vot-textfield{display:inline-block;--vot-helper-theme:rgb(var(--vot-theme-rgb,var(--vot-primary-rgb,33,150,243)))!important;--vot-helper-safari1:rgba(var(--vot-onsurface-rgb,0,0,0),.38)!important;--vot-helper-safari2:rgba(var(--vot-onsurface-rgb,0,0,0),.6)!important;--vot-helper-safari3:rgba(var(--vot-onsurface-rgb,0,0,0),.87)!important;font-family:var(--vot-font-family,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system)!important;text-align:start!important;padding-top:6px!important;font-size:16px!important;line-height:1.5!important;position:relative!important}.vot-textfield[hidden]{display:none!important}.vot-textfield>input,.vot-textfield>textarea{box-sizing:border-box!important;border-style:solid!important;border-width:1px!important;border-color:transparent var(--vot-helper-safari2)var(--vot-helper-safari2)!important;width:100%!important;height:inherit!important;color:rgba(var(--vot-onsurface-rgb,0,0,0),.87)!important;-webkit-text-fill-color:currentColor!important;font-family:inherit!important;font-size:inherit!important;line-height:inherit!important;caret-color:var(--vot-helper-theme)!important;background-color:transparent!important;border-radius:4px!important;margin:0!important;padding:15px 13px!important;transition:border .2s,box-shadow .2s!important;box-shadow:inset 1px 0 transparent,inset -1px 0 transparent,inset 0 -1px transparent!important}.vot-textfield>input:not(:focus):not(.vot-show-placeholer)::-moz-placeholder{color:transparent!important}.vot-textfield>textarea:not(:focus):not(.vot-show-placeholer)::-moz-placeholder{color:transparent!important}.vot-textfield>input:not(:focus):not(.vot-show-placeholer)::-moz-placeholder{color:transparent!important}.vot-textfield>textarea:not(:focus):not(.vot-show-placeholer)::-moz-placeholder{color:transparent!important}.vot-textfield>input:not(:focus):not(.vot-show-placeholer)::-webkit-input-placeholder{color:transparent!important}.vot-textfield>textarea:not(:focus):not(.vot-show-placeholer)::-webkit-input-placeholder{color:transparent!important}.vot-textfield>input:not(:focus):placeholder-shown{border-top-color:var(--vot-helper-safari2)!important}.vot-textfield>textarea:not(:focus):placeholder-shown{border-top-color:var(--vot-helper-safari2)!important}.vot-textfield>input+span,.vot-textfield>textarea+span{font-family:inherit;width:100%!important;max-height:100%!important;color:rgba(var(--vot-onsurface-rgb,0,0,0),.6)!important;cursor:text!important;pointer-events:none!important;font-size:75%!important;line-height:15px!important;transition:color .2s,font-size .2s,line-height .2s!important;display:flex!important;position:absolute!important;top:0!important;left:0!important}.vot-textfield>input:not(:focus):placeholder-shown+span{font-size:inherit!important;line-height:68px!important}.vot-textfield>textarea:not(:focus):placeholder-shown+span{font-size:inherit!important;line-height:68px!important}.vot-textfield>input+span:before,.vot-textfield>input+span:after,.vot-textfield>textarea+span:before,.vot-textfield>textarea+span:after{content:""!important;box-sizing:border-box!important;border-top:solid 1px var(--vot-helper-safari2)!important;pointer-events:none!important;min-width:10px!important;height:8px!important;margin-top:6px!important;transition:border .2s,box-shadow .2s!important;display:block!important;box-shadow:inset 0 1px transparent!important}.vot-textfield>input+span:before,.vot-textfield>textarea+span:before{border-left:1px solid transparent!important;border-radius:4px 0!important;margin-right:4px!important}.vot-textfield>input+span:after,.vot-textfield>textarea+span:after{border-right:1px solid transparent!important;border-radius:0 4px!important;flex-grow:1!important;margin-left:4px!important}.vot-textfield>input.vot-show-placeholer+span:before,.vot-textfield>textarea.vot-show-placeholer+span:before{margin-right:0!important}.vot-textfield>input.vot-show-placeholer+span:after,.vot-textfield>textarea.vot-show-placeholer+span:after{margin-left:0!important}.vot-textfield>input:not(:focus):placeholder-shown+span:before{border-top-color:transparent!important}.vot-textfield>input:not(:focus):placeholder-shown+span:after{border-top-color:transparent!important}.vot-textfield>textarea:not(:focus):placeholder-shown+span:before{border-top-color:transparent!important}.vot-textfield>textarea:not(:focus):placeholder-shown+span:after{border-top-color:transparent!important}.vot-textfield:hover>input:not(:disabled),.vot-textfield:hover>textarea:not(:disabled){border-color:transparent var(--vot-helper-safari3)var(--vot-helper-safari3)!important}.vot-textfield:hover>input:not(:disabled)+span:before,.vot-textfield:hover>input:not(:disabled)+span:after,.vot-textfield:hover>textarea:not(:disabled)+span:before,.vot-textfield:hover>textarea:not(:disabled)+span:after{border-top-color:var(--vot-helper-safari3)!important}.vot-textfield:hover>input:not(:disabled):not(:focus):placeholder-shown{border-color:var(--vot-helper-safari3)!important}.vot-textfield:hover>textarea:not(:disabled):not(:focus):placeholder-shown{border-color:var(--vot-helper-safari3)!important}.vot-textfield>input:focus,.vot-textfield>textarea:focus{border-color:transparent var(--vot-helper-theme)var(--vot-helper-theme)!important;box-shadow:inset 1px 0 var(--vot-helper-theme),inset -1px 0 var(--vot-helper-theme),inset 0 -1px var(--vot-helper-theme)!important;outline:none!important}.vot-textfield>input:focus+span,.vot-textfield>textarea:focus+span{color:var(--vot-helper-theme)!important}.vot-textfield>input:focus+span:before,.vot-textfield>input:focus+span:after,.vot-textfield>textarea:focus+span:before,.vot-textfield>textarea:focus+span:after{border-top-color:var(--vot-helper-theme)!important;box-shadow:inset 0 1px var(--vot-helper-theme)!important}.vot-textfield>input:disabled,.vot-textfield>input:disabled+span,.vot-textfield>textarea:disabled,.vot-textfield>textarea:disabled+span{border-color:transparent var(--vot-helper-safari1)var(--vot-helper-safari1)!important;color:rgba(var(--vot-onsurface-rgb,0,0,0),.38)!important;pointer-events:none!important}.vot-textfield>input:disabled+span:before,.vot-textfield>input:disabled+span:after,.vot-textfield>textarea:disabled+span:before,.vot-textfield>textarea:disabled+span:after{border-top-color:var(--vot-helper-safari1)!important}.vot-textfield>input:disabled:placeholder-shown{border-top-color:var(--vot-helper-safari1)!important}.vot-textfield>input:disabled:placeholder-shown+span{border-top-color:var(--vot-helper-safari1)!important}.vot-textfield>textarea:disabled:placeholder-shown{border-top-color:var(--vot-helper-safari1)!important}.vot-textfield>textarea:disabled:placeholder-shown+span{border-top-color:var(--vot-helper-safari1)!important}.vot-textfield>input:disabled:placeholder-shown+span:before{border-top-color:transparent!important}.vot-textfield>input:disabled:placeholder-shown+span:after{border-top-color:transparent!important}.vot-textfield>textarea:disabled:placeholder-shown+span:before{border-top-color:transparent!important}.vot-textfield>textarea:disabled:placeholder-shown+span:after{border-top-color:transparent!important}@media not all and (-webkit-min-device-pixel-ratio:.0000264583),not all and (min-resolution:.001dpcm){@supports ((-webkit-appearance:none)){.vot-textfield>input,.vot-textfield>input+span,.vot-textfield>textarea,.vot-textfield>textarea+span,.vot-textfield>input+span:before,.vot-textfield>input+span:after,.vot-textfield>textarea+span:before,.vot-textfield>textarea+span:after{transition-duration:.1s!important}}}.vot-checkbox{--vot-helper-theme:var(--vot-theme-rgb,var(--vot-primary-rgb,33,150,243));--vot-helper-ontheme:var(--vot-ontheme-rgb,var(--vot-onprimary-rgb,255,255,255));z-index:0;color:rgba(var(--vot-onsurface-rgb,0,0,0),.87);font-family:var(--vot-font-family,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system);text-align:start;font-size:16px;line-height:1.5;display:inline-block;position:relative}.vot-checkbox-sub{padding-left:16px}.vot-checkbox[hidden]{display:none!important}.vot-checkbox>input{-webkit-appearance:none;appearance:none;z-index:10000;box-sizing:border-box;border:2px solid;border-color:rgba(var(--vot-onsurface-rgb,0,0,0),.6);cursor:pointer;background:0 0;border-radius:2px;outline:none;width:18px;height:18px;margin:3px 1px;padding:0;transition:border-color .2s,background-color .2s;display:block;position:absolute}.vot-checkbox>input+span{box-sizing:border-box;width:inherit;cursor:pointer;padding-left:30px;font-family:inherit;font-weight:400;display:inline-block;position:relative}.vot-checkbox>input+span:before{content:"";background-color:rgb(var(--vot-onsurface-rgb,0,0,0));opacity:0;pointer-events:none;border-radius:50%;width:40px;height:40px;transition:opacity .3s,transform .2s;display:block;position:absolute;top:-8px;left:-10px;transform:scale(1)}.vot-checkbox>input+span:after{content:"";z-index:10000;pointer-events:none;border:0 solid transparent;border-width:0 0 2px 2px;width:10px;height:5px;transition:border-color .2s;display:block;position:absolute;top:3px;left:1px;transform:translate(3px,4px)rotate(-45deg);box-sizing:content-box!important}.vot-checkbox>input:checked{border-color:rgb(var(--vot-helper-theme));background-color:rgb(var(--vot-helper-theme))}.vot-checkbox>input:indeterminate{border-color:rgb(var(--vot-helper-theme));background-color:rgb(var(--vot-helper-theme))}.vot-checkbox>input:checked+span:before{background-color:rgb(var(--vot-helper-theme))}.vot-checkbox>input:indeterminate+span:before{background-color:rgb(var(--vot-helper-theme))}.vot-checkbox>input:checked+span:after{border-color:rgb(var(--vot-helper-ontheme,255,255,255))}.vot-checkbox>input:indeterminate+span:after{border-color:rgb(var(--vot-helper-ontheme,255,255,255))}.vot-checkbox>input:indeterminate+span:after{border-left-width:0;transform:translate(4px,3px)}.vot-checkbox:hover>input+span:before{opacity:.04}.vot-checkbox:active>input,.vot-checkbox:active:hover>input:not(:disabled){border-color:rgb(var(--vot-helper-theme))}.vot-checkbox:active>input:checked{background-color:rgba(var(--vot-onsurface-rgb,0,0,0),.6);border-color:transparent}.vot-checkbox:active>input+span:before{opacity:1;transition:transform,opacity;transform:scale(0)}.vot-checkbox>input:disabled{border-color:rgba(var(--vot-onsurface-rgb,0,0,0),.38);cursor:initial}.vot-checkbox>input:disabled:checked{background-color:rgba(var(--vot-onsurface-rgb,0,0,0),.38);border-color:transparent}.vot-checkbox>input:disabled:indeterminate{background-color:rgba(var(--vot-onsurface-rgb,0,0,0),.38);border-color:transparent}.vot-checkbox>input:disabled+span{color:rgba(var(--vot-onsurface-rgb,0,0,0),.38);cursor:initial}.vot-checkbox>input:disabled+span:before{opacity:0;transform:scale(0)}.vot-slider{display:inline-block;--vot-safari-helper1:rgba(var(--vot-primary-rgb,33,150,243),.04)!important;--vot-safari-helper2:rgba(var(--vot-primary-rgb,33,150,243),.12)!important;--vot-safari-helper3:rgba(var(--vot-primary-rgb,33,150,243),.16)!important;--vot-safari-helper4:rgba(var(--vot-primary-rgb,33,150,243),.24)!important;width:100%!important;color:rgba(var(--vot-onsurface-rgb,0,0,0),.87)!important;font-family:var(--vot-font,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system)!important;text-align:start!important;font-size:16px!important;line-height:1.5!important}.vot-slider[hidden]{display:none!important}.vot-slider>input{-webkit-appearance:none!important;appearance:none!important;cursor:pointer!important;background-color:transparent!important;border:none!important;width:100%!important;height:36px!important;margin:0 0 -36px!important;padding:0!important;display:block!important;position:relative!important;top:24px!important}.vot-slider>input:last-child{margin:0!important;position:static!important}.vot-slider>input:before{content:""!important;width:calc(100%*var(--vot-progress,0))!important;background:rgb(var(--vot-primary-rgb,33,150,243))!important;height:2px!important;display:block!important;position:absolute!important;top:calc(50% - 1px)!important}.vot-slider>input:disabled{cursor:default!important;opacity:.38!important}.vot-slider>input:disabled+span{color:rgba(var(--vot-onsurface-rgb,0,0,0),.38)!important}.vot-slider>input:disabled::-webkit-slider-runnable-track{background-color:rgba(var(--vot-onsurface-rgb,0,0,0),.38)!important}.vot-slider>input:disabled::-moz-range-track{background-color:rgba(var(--vot-onsurface-rgb,0,0,0),.38)!important}.vot-slider>input:disabled::-ms-fill-lower{background-color:rgba(var(--vot-onsurface-rgb,0,0,0),.38)!important}.vot-slider>input:disabled::-ms-fill-upper{background-color:rgba(var(--vot-onsurface-rgb,0,0,0),.38)!important}.vot-slider>input:disabled::-moz-range-thumb{background-color:rgb(var(--vot-onsurface-rgb,0,0,0))!important;box-shadow:0 0 0 1px rgb(var(--vot-surface-rgb,255,255,255))!important;transform:scale(4)!important}.vot-slider>input:disabled::-ms-thumb{background-color:rgb(var(--vot-onsurface-rgb,0,0,0))!important;box-shadow:0 0 0 1px rgb(var(--vot-surface-rgb,255,255,255))!important;transform:scale(4)!important}.vot-slider>input:disabled::-webkit-slider-thumb{background-color:rgb(var(--vot-onsurface-rgb,0,0,0))!important;box-shadow:0 0 0 1px rgb(var(--vot-surface-rgb,255,255,255))!important;transform:scale(4)!important}.vot-slider>input:disabled::-ms-fill-upper{opacity:.38!important}.vot-slider>input:disabled::-moz-range-progress{background-color:rgba(var(--vot-onsurface-rgb,0,0,0),.87)!important}.vot-slider>input:disabled:-webkit-slider-thumb{color:rgb(var(--vot-surface-rgb,255,255,255))!important}.vot-slider>input:active::-webkit-slider-thumb{box-shadow:0 0 0 2px var(--vot-safari-helper4)!important}.vot-slider>input:active::-moz-range-thumb{box-shadow:0 0 0 2px rgba(var(--vot-primary-rgb,33,150,243),.24)!important}.vot-slider>input:active::-ms-thumb{box-shadow:0 0 0 2px rgba(var(--vot-primary-rgb,33,150,243),.24)!important}.vot-slider>input:focus{outline:none!important}.vot-slider>input::-webkit-slider-runnable-track{background-color:rgba(var(--vot-primary-rgb,33,150,243),.24)!important;border-radius:1px!important;width:100%!important;height:2px!important;margin:17px 0!important}.vot-slider>input::-moz-range-track{background-color:rgba(var(--vot-primary-rgb,33,150,243),.24)!important;border-radius:1px!important;width:100%!important;height:2px!important;margin:17px 0!important}.vot-slider>input::-ms-track{box-sizing:border-box!important;background-color:transparent!important;border:none!important;border-radius:1px!important;width:100%!important;height:2px!important;margin:17px 0!important;padding:0 17px!important}.vot-slider>input::-webkit-slider-thumb{-webkit-appearance:none!important;appearance:none!important;background-color:rgb(var(--vot-primary-rgb,33,150,243))!important;border:none!important;border-radius:50%!important;width:2px!important;height:2px!important;transition:box-shadow .2s!important;transform:scale(6)!important}.vot-slider>input::-moz-range-thumb{-webkit-appearance:none!important;appearance:none!important;background-color:rgb(var(--vot-primary-rgb,33,150,243))!important;border:none!important;border-radius:50%!important;width:2px!important;height:2px!important;transition:box-shadow .2s!important;transform:scale(6)!important}.vot-slider>input::-ms-thumb{-webkit-appearance:none!important;appearance:none!important;background-color:rgb(var(--vot-primary-rgb,33,150,243))!important;border:none!important;border-radius:50%!important;width:2px!important;height:2px!important;transition:box-shadow .2s!important;transform:scale(6)!important}.vot-slider>input::-webkit-slider-thumb{-webkit-appearance:none!important;margin:0!important}.vot-slider>input::-moz-range-thumb{-moz-appearance:none!important}.vot-slider>input::-ms-thumb{margin:0 17px!important}.vot-slider>input::-moz-range-progress{background-color:rgb(var(--vot-primary-rgb,33,150,243))!important;border-radius:1px!important;height:2px!important}.vot-slider>input::-ms-fill-lower{background-color:rgb(var(--vot-primary-rgb,33,150,243))!important;border-radius:1px!important;height:2px!important}.vot-slider>input::-ms-fill-upper{background-color:rgb(var(--vot-primary-rgb,33,150,243))!important;border-radius:1px!important;height:2px!important}.vot-slider>input::-moz-focus-outer{border:none!important}.vot-slider>span{margin-bottom:36px!important;display:inline-block!important}.vot-slider:hover>input::-webkit-slider-thumb{box-shadow:0 0 0 2px var(--vot-safari-helper1)!important}.vot-slider:hover>input::-ms-thumb{box-shadow:0 0 0 2px rgba(var(--vot-primary-rgb,33,150,243),.04)!important}.vot-slider:hover>input:hover::-moz-range-thumb{box-shadow:0 0 0 2px rgba(var(--vot-primary-rgb,33,150,243),.04)!important}.vot-select{font-family:var(--vot-font-family,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system);text-align:start;color:var(--vot-helper-theme);fill:var(--vot-helper-theme);justify-content:space-between;align-items:center;font-size:14px;font-weight:400;line-height:1.5;display:flex;--vot-helper-theme-rgb:var(--vot-onsurface-rgb,0,0,0)!important;--vot-helper-theme:rgba(var(--vot-helper-theme-rgb),.87)!important;--vot-helper-safari1:rgba(var(--vot-onsurface-rgb,0,0,0),.6)!important;--vot-helper-safari2:rgba(var(--vot-onsurface-rgb,0,0,0),.87)!important}.vot-select[hidden]{display:none!important}.vot-select-label{font-family:inherit;font-size:16px}.vot-select-outer{cursor:pointer;justify-content:space-between;align-items:center;width:120px;max-width:120px;padding:0 5px;display:flex;border-style:solid!important;border-width:1px!important;border-color:var(--vot-helper-safari1)!important;border-radius:4px!important;transition:border .2s!important}.vot-select-outer:hover{border-color:var(--vot-helper-safari2)!important}.vot-select-title{text-overflow:ellipsis;white-space:nowrap;font-family:inherit;overflow:hidden}.vot-select-arrow-icon{justify-content:center;align-items:center;width:20px;height:32px;display:flex}.vot-select-content-list{flex-direction:column;display:flex}.vot-select-content-list .vot-select-content-item{cursor:pointer;border-radius:8px;padding:5px 10px}.vot-select-content-list .vot-select-content-item:not([inert]):hover{background-color:#2a2c31}.vot-select-content-list .vot-select-content-item[data-vot-selected=true]{color:rgb(var(--vot-primary-rgb,33,150,243));background-color:rgba(var(--vot-primary-rgb,33,150,243),.2)}.vot-select-content-list .vot-select-content-item[data-vot-selected=true]:hover{background-color:rgba(var(--vot-primary-rgb,33,150,243),.1)!important}.vot-select-content-list .vot-select-content-item[data-vot-disabled=true]{cursor:default}.vot-select-content-list .vot-select-content-item[hidden]{display:none!important}.vot-header{color:rgba(var(--vot-helper-onsurface-rgb),.87);font-family:var(--vot-font-family,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system);text-align:start;font-weight:700;line-height:1.5}.vot-header[hidden]{display:none!important}.vot-header:not(:first-child){padding-top:8px}.vot-header-level-1{font-size:2em}.vot-header-level-2{font-size:1.5em}.vot-header-level-3{font-size:1.17em}.vot-header-level-4{font-size:1em}.vot-header-level-5{font-size:.83em}.vot-header-level-6{font-size:.67em}.vot-info{color:rgba(var(--vot-helper-onsurface-rgb),.87);font-family:var(--vot-font-family,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system);text-align:start;-webkit-user-select:text;user-select:text;font-size:16px;line-height:1.5;display:flex}.vot-info[hidden]{display:none!important}.vot-info>:not(:first-child){color:rgba(var(--vot-helper-onsurface-rgb),.5);flex:1;margin-left:8px}.vot-details{color:rgba(var(--vot-helper-onsurface-rgb),.87);font-family:var(--vot-font-family,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system);text-align:start;cursor:pointer;border-radius:.5em;justify-content:space-between;align-items:center;margin:0 -.5em;padding:.5em;font-size:16px;line-height:1.5;transition:background .5s;display:flex}.vot-details[hidden]{display:none!important}.vot-details-arrow-icon{width:20px;height:32px;fill:rgba(var(--vot-helper-onsurface-rgb),.87);justify-content:center;align-items:center;display:flex;transform:scale(1.25)rotate(-90deg)}.vot-details:hover{background:rgba(var(--vot-onsurface-rgb,0,0,0),.04)}.vot-lang-select{--vot-helper-theme-rgb:var(--vot-onsurface-rgb,0,0,0);--vot-helper-theme:rgba(var(--vot-helper-theme-rgb),.87);color:var(--vot-helper-theme);fill:var(--vot-helper-theme);justify-content:space-between;align-items:center;display:flex}.vot-lang-select[hidden]{display:none!important}.vot-lang-select-icon{justify-content:center;align-items:center;width:32px;height:32px;display:flex}.vot-segmented-button{--vot-helper-theme-rgb:var(--vot-onsurface-rgb,0,0,0);--vot-helper-theme:rgba(var(--vot-helper-theme-rgb),.87);-webkit-user-select:none;user-select:none;background:rgb(var(--vot-surface-rgb,255,255,255));max-width:100vw;height:32px;color:var(--vot-helper-theme);fill:var(--vot-helper-theme);font-family:var(--vot-font-family,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system);cursor:default;z-index:2147483647;border-radius:4px;align-items:center;font-size:16px;line-height:1.5;transition:opacity .5s;display:flex;position:absolute;top:5rem;left:50%;overflow:hidden;transform:translate(-50%)}.vot-segmented-button[hidden]{display:none!important}.vot-segmented-button *{box-sizing:border-box!important}.vot-segmented-button .vot-separator{background:rgba(var(--vot-helper-theme-rgb),.1);width:1px;height:50%}.vot-segmented-button .vot-separator[hidden]{display:none!important}.vot-segmented-button .vot-segment,.vot-segmented-button .vot-segment-only-icon{height:100%;color:inherit;background-color:transparent;border:none;justify-content:center;align-items:center;padding:0 8px;transition:background-color .1s ease-in-out;display:flex;position:relative;overflow:hidden}.vot-segmented-button .vot-segment[hidden],.vot-segmented-button [hidden].vot-segment-only-icon{display:none!important}.vot-segmented-button .vot-segment:before,.vot-segmented-button .vot-segment-only-icon:before,.vot-segmented-button .vot-segment:after,.vot-segmented-button .vot-segment-only-icon:after{content:"";border-radius:inherit;opacity:0;position:absolute;top:0;bottom:0;left:0;right:0}.vot-segmented-button .vot-segment:before,.vot-segmented-button .vot-segment-only-icon:before{background-color:rgb(var(--vot-helper-theme-rgb));transition:opacity .2s}.vot-segmented-button .vot-segment:after,.vot-segmented-button .vot-segment-only-icon:after{background:radial-gradient(circle,currentColor 1%,transparent 1%) 50%/10000% 10000% no-repeat;transition:opacity 1s,background-size .5s}.vot-segmented-button .vot-segment:hover:before,.vot-segmented-button .vot-segment-only-icon:hover:before{opacity:.04}.vot-segmented-button .vot-segment:active:after,.vot-segmented-button .vot-segment-only-icon:active:after{opacity:.16;background-size:100% 100%;transition:background-size}.vot-segmented-button .vot-segment-only-icon{min-width:32px;padding:0}.vot-segmented-button .vot-segment-label{white-space:nowrap;color:inherit;margin-left:8px;font-weight:400}.vot-segmented-button[data-status=success] .vot-translate-button{color:rgb(var(--vot-primary-rgb,33,150,243));fill:rgb(var(--vot-primary-rgb,33,150,243))}.vot-segmented-button[data-status=error] .vot-translate-button{color:#f28b82;fill:#f28b82}.vot-segmented-button[data-loading=true] #vot-loading-icon{display:block!important}.vot-segmented-button[data-loading=true] #vot-translate-icon{display:none!important}.vot-segmented-button[data-direction=column]{flex-direction:column;height:fit-content}.vot-segmented-button[data-direction=column] .vot-segment-label{display:none}.vot-segmented-button[data-direction=column]>.vot-segment-only-icon,.vot-segmented-button[data-direction=column]>.vot-segment{padding:8px}.vot-segmented-button[data-direction=column] .vot-separator{width:50%;height:1px}.vot-segmented-button[data-position=left]{top:12.5vh;left:50px}.vot-segmented-button[data-position=right]{top:12.5vh;left:auto;right:0}.vot-segmented-button svg{width:24px}.vot-menu{--vot-helper-surface-rgb:var(--vot-surface-rgb,255,255,255);--vot-helper-surface:rgb(var(--vot-helper-surface-rgb));--vot-helper-onsurface-rgb:var(--vot-onsurface-rgb,0,0,0);--vot-helper-onsurface:rgba(var(--vot-helper-onsurface-rgb),.87);-webkit-user-select:none;user-select:none;background-color:var(--vot-helper-surface);color:var(--vot-helper-onsurface);font-family:var(--vot-font-family,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system);cursor:default;z-index:2147483647;visibility:visible;opacity:1;transform-origin:top;border-radius:8px;min-width:300px;font-size:16px;line-height:1.5;transition:opacity .3s,transform .1s;position:absolute;top:calc(5rem + 48px);left:50%;overflow:hidden;transform:translate(-50%)scale(1)}.vot-menu *{box-sizing:border-box!important}.vot-menu[hidden]{pointer-events:none;visibility:hidden;opacity:0;transform:translate(-50%)scale(0);display:block!important}.vot-menu-content-wrapper{min-height:100px;max-height:calc(var(--vot-container-height,75vh) - (5rem + 32px + 16px)*2);flex-direction:column;display:flex;overflow:auto}.vot-menu-header-container{flex-shrink:0;align-items:flex-start;min-height:31px;display:flex}.vot-menu-header-container:empty{padding:0 0 16px}.vot-menu-header-container>.vot-icon-button{margin-inline-end:4px;margin-top:4px}.vot-menu-title-container{font-size:inherit;font-weight:inherit;text-align:start;outline:0;flex:1;margin:0;display:flex}.vot-menu-title{padding-bottom:16px;padding-inline-start:16px;padding-inline-end:16px;flex:1;padding-top:16px;font-size:16px;font-weight:400;line-height:1}.vot-menu-body-container{box-sizing:border-box;overscroll-behavior:contain;flex-direction:column;gap:8px;min-height:1.375rem;padding:0 16px;display:flex;overflow:auto;scrollbar-color:rgba(var(--vot-helper-onsurface-rgb),.1)var(--vot-helper-surface)!important}.vot-menu-body-container::-webkit-scrollbar{background:var(--vot-helper-surface)!important;width:12px!important;height:12px!important}.vot-menu-body-container::-webkit-scrollbar-track{background:var(--vot-helper-surface)!important;width:12px!important;height:12px!important}.vot-menu-body-container::-webkit-scrollbar-thumb{background:rgba(var(--vot-helper-onsurface-rgb),.1)!important;border:5px solid var(--vot-helper-surface)!important;-webkit-border-radius:1ex!important}.vot-menu-body-container::-webkit-scrollbar-thumb:hover{border:3px solid var(--vot-helper-surface)!important}.vot-menu-body-container::-webkit-scrollbar-corner{background:var(--vot-helper-surface)!important}.vot-menu-footer-container{padding-bottom:16px;padding-inline-start:16px;padding-inline-end:16px;flex-shrink:0;justify-content:flex-end;padding-top:16px;display:flex}.vot-menu-footer-container:empty{padding:16px 0 0}.vot-menu[data-position=left]{top:12.5vh;left:240px}.vot-menu[data-position=right]{top:12.5vh;left:auto;right:-80px}.vot-dialog{--vot-helper-surface-rgb:var(--vot-surface-rgb,255,255,255);--vot-helper-surface:rgb(var(--vot-helper-surface-rgb));--vot-helper-onsurface-rgb:var(--vot-onsurface-rgb,0,0,0);--vot-helper-onsurface:rgba(var(--vot-helper-onsurface-rgb),.87);max-width:initial;max-height:initial;width:min(var(--vot-dialog-width,512px),100%);top:50%;bottom:50%;background-color:var(--vot-helper-surface);height:fit-content;color:var(--vot-helper-onsurface);font-family:var(--vot-font-family,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system);-webkit-user-select:none;user-select:none;visibility:visible;opacity:1;transform-origin:50%;border-radius:8px;margin:auto;padding:0;font-size:16px;line-height:1.5;transition:opacity .3s,transform .1s;display:block;position:fixed;top:0;bottom:0;left:0;right:0;overflow-x:auto;overflow-y:hidden;transform:scale(1);box-shadow:0 0 16px rgba(0,0,0,.12),0 16px 16px rgba(0,0,0,.24)}[hidden]>.vot-dialog{pointer-events:none;opacity:0;transition:opacity .1s,transform .2s;transform:scale(.5)}.vot-dialog-container{visibility:visible;z-index:2147483647;position:absolute}.vot-dialog-container[hidden]{pointer-events:none;visibility:hidden;display:block!important}.vot-dialog-container *{box-sizing:border-box!important}.vot-dialog-backdrop{opacity:1;background-color:rgba(0,0,0,.6);transition:opacity .3s;position:fixed;top:0;bottom:0;left:0;right:0}[hidden]>.vot-dialog-backdrop{pointer-events:none;opacity:0}.vot-dialog-content-wrapper{flex-direction:column;max-height:75vh;display:flex;overflow:auto}.vot-dialog-header-container{flex-shrink:0;align-items:flex-start;min-height:31px;display:flex}.vot-dialog-header-container:empty{padding:0 0 20px}.vot-dialog-header-container>.vot-icon-button{margin-inline-end:4px;margin-top:4px}.vot-dialog-title-container{font-size:inherit;font-weight:inherit;outline:0;flex:1;margin:0;display:flex}.vot-dialog-title{padding-bottom:16px;padding-inline-start:20px;padding-inline-end:20px;flex:1;padding-top:20px;font-size:115.385%;font-weight:700;line-height:1}.vot-dialog-body-container{box-sizing:border-box;overscroll-behavior:contain;flex-direction:column;gap:16px;min-height:1.375rem;padding:0 20px;display:flex;overflow:auto;scrollbar-color:rgba(var(--vot-helper-onsurface-rgb),.1)var(--vot-helper-surface)!important}.vot-dialog-body-container::-webkit-scrollbar{background:var(--vot-helper-surface)!important;width:12px!important;height:12px!important}.vot-dialog-body-container::-webkit-scrollbar-track{background:var(--vot-helper-surface)!important;width:12px!important;height:12px!important}.vot-dialog-body-container::-webkit-scrollbar-thumb{background:rgba(var(--vot-helper-onsurface-rgb),.1)!important;border:5px solid var(--vot-helper-surface)!important;-webkit-border-radius:1ex!important}.vot-dialog-body-container::-webkit-scrollbar-thumb:hover{border:3px solid var(--vot-helper-surface)!important}.vot-dialog-body-container::-webkit-scrollbar-corner{background:var(--vot-helper-surface)!important}.vot-dialog-footer-container{padding-bottom:16px;padding-inline-start:16px;padding-inline-end:16px;flex-shrink:0;justify-content:flex-end;padding-top:16px;display:flex}.vot-dialog-footer-container:empty{padding:20px 0 0}.vot-subtitles{--vot-subtitles-background:rgba(var(--vot-surface-rgb,46,47,52),var(--vot-subtitles-opacity,.8));background:var(--vot-subtitles-background,rgba(46,47,52,.8));width:max-content;max-width:100%;max-height:100%;color:var(--vot-subtitles-color,#e3e3e3);pointer-events:all;font-size:20px;font-family:var(--vot-font-family,"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system);box-sizing:border-box;-webkit-user-select:none;user-select:none;border-radius:.5em;padding:.5em;line-height:normal;position:relative}.vot-subtitles-widget{z-index:2147483647;pointer-events:none;justify-content:center;align-items:center;width:50%;min-height:20%;max-height:100%;display:flex;position:absolute;top:75%;left:25%}.vot-subtitles span{-webkit-user-select:text;user-select:text;font-size:inherit!important;font-family:inherit!important;line-height:normal!important}.vot-subtitles .passed{color:var(--vot-subtitles-passed-color,#2196f3)}:root{--vot-font-family:"Roboto","Segoe UI",BlinkMacSystemFont,system-ui,-apple-system;--vot-primary-rgb:139,180,245;--vot-onprimary-rgb:32,33,36;--vot-surface-rgb:32,33,36;--vot-onsurface-rgb:227,227,227;--vot-subtitles-color:rgb(var(--vot-onsurface-rgb,227,227,227));--vot-subtitles-passed-color:rgb(var(--vot-primary-rgb,33,150,243))}vot-block{font-family:inherit;display:block;visibility:visible!important}')},"./node_modules/bowser/es5.js":function(t){t.exports=function(t){var e={};function i(o){if(e[o])return e[o].exports;var a=e[o]={i:o,l:!1,exports:{}};return t[o].call(a.exports,a,a.exports,i),a.l=!0,a.exports}return i.m=t,i.c=e,i.d=function(t,e,o){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(i.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)i.d(o,a,function(e){return t[e]}.bind(null,a));return o},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=90)}({17:function(t,e,i){"use strict";e.__esModule=!0,e.default=void 0;var o=i(18),a=function(){function t(){}return t.getFirstMatch=function(t,e){var i=e.match(t);return i&&i.length>0&&i[1]||""},t.getSecondMatch=function(t,e){var i=e.match(t);return i&&i.length>1&&i[2]||""},t.matchAndReturnConst=function(t,e,i){if(t.test(e))return i},t.getWindowsVersionName=function(t){switch(t){case"NT":return"NT";case"XP":case"NT 5.1":return"XP";case"NT 5.0":return"2000";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}},t.getMacOSVersionName=function(t){var e=t.split(".").splice(0,2).map((function(t){return parseInt(t,10)||0}));if(e.push(0),10===e[0])switch(e[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}},t.getAndroidVersionName=function(t){var e=t.split(".").splice(0,2).map((function(t){return parseInt(t,10)||0}));if(e.push(0),!(1===e[0]&&e[1]<5))return 1===e[0]&&e[1]<6?"Cupcake":1===e[0]&&e[1]>=6?"Donut":2===e[0]&&e[1]<2?"Eclair":2===e[0]&&2===e[1]?"Froyo":2===e[0]&&e[1]>2?"Gingerbread":3===e[0]?"Honeycomb":4===e[0]&&e[1]<1?"Ice Cream Sandwich":4===e[0]&&e[1]<4?"Jelly Bean":4===e[0]&&e[1]>=4?"KitKat":5===e[0]?"Lollipop":6===e[0]?"Marshmallow":7===e[0]?"Nougat":8===e[0]?"Oreo":9===e[0]?"Pie":void 0},t.getVersionPrecision=function(t){return t.split(".").length},t.compareVersions=function(e,i,o){void 0===o&&(o=!1);var a=t.getVersionPrecision(e),n=t.getVersionPrecision(i),r=Math.max(a,n),s=0,l=t.map([e,i],(function(e){var i=r-t.getVersionPrecision(e),o=e+new Array(i+1).join(".0");return t.map(o.split("."),(function(t){return new Array(20-t.length).join("0")+t})).reverse()}));for(o&&(s=r-Math.min(a,n)),r-=1;r>=s;){if(l[0][r]>l[1][r])return 1;if(l[0][r]===l[1][r]){if(r===s)return 0;r-=1}else if(l[0][r]<l[1][r])return-1}},t.map=function(t,e){var i,o=[];if(Array.prototype.map)return Array.prototype.map.call(t,e);for(i=0;i<t.length;i+=1)o.push(e(t[i]));return o},t.find=function(t,e){var i,o;if(Array.prototype.find)return Array.prototype.find.call(t,e);for(i=0,o=t.length;i<o;i+=1){var a=t[i];if(e(a,i))return a}},t.assign=function(t){for(var e,i,o=t,a=arguments.length,n=new Array(a>1?a-1:0),r=1;r<a;r++)n[r-1]=arguments[r];if(Object.assign)return Object.assign.apply(Object,[t].concat(n));var s=function(){var t=n[e];"object"==typeof t&&null!==t&&Object.keys(t).forEach((function(e){o[e]=t[e]}))};for(e=0,i=n.length;e<i;e+=1)s();return t},t.getBrowserAlias=function(t){return o.BROWSER_ALIASES_MAP[t]},t.getBrowserTypeByAlias=function(t){return o.BROWSER_MAP[t]||""},t}();e.default=a,t.exports=e.default},18:function(t,e,i){"use strict";e.__esModule=!0,e.ENGINE_MAP=e.OS_MAP=e.PLATFORMS_MAP=e.BROWSER_MAP=e.BROWSER_ALIASES_MAP=void 0,e.BROWSER_ALIASES_MAP={"Amazon Silk":"amazon_silk","Android Browser":"android",Bada:"bada",BlackBerry:"blackberry",Chrome:"chrome",Chromium:"chromium",Electron:"electron",Epiphany:"epiphany",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot","Internet Explorer":"ie","K-Meleon":"k_meleon",Maxthon:"maxthon","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver",Opera:"opera","Opera Coast":"opera_coast",PhantomJS:"phantomjs",Puffin:"puffin",QupZilla:"qupzilla",QQ:"qq",QQLite:"qqlite",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SeaMonkey:"seamonkey",Sleipnir:"sleipnir",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat","Yandex Browser":"yandex",Roku:"roku"},e.BROWSER_MAP={amazon_silk:"Amazon Silk",android:"Android Browser",bada:"Bada",blackberry:"BlackBerry",chrome:"Chrome",chromium:"Chromium",electron:"Electron",epiphany:"Epiphany",firefox:"Firefox",focus:"Focus",generic:"Generic",googlebot:"Googlebot",google_search:"Google Search",ie:"Internet Explorer",k_meleon:"K-Meleon",maxthon:"Maxthon",edge:"Microsoft Edge",mz:"MZ Browser",naver:"NAVER Whale Browser",opera:"Opera",opera_coast:"Opera Coast",phantomjs:"PhantomJS",puffin:"Puffin",qupzilla:"QupZilla",qq:"QQ Browser",qqlite:"QQ Browser Lite",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",sleipnir:"Sleipnir",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yandex:"Yandex Browser"},e.PLATFORMS_MAP={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},e.OS_MAP={WindowsPhone:"Windows Phone",Windows:"Windows",MacOS:"macOS",iOS:"iOS",Android:"Android",WebOS:"WebOS",BlackBerry:"BlackBerry",Bada:"Bada",Tizen:"Tizen",Linux:"Linux",ChromeOS:"Chrome OS",PlayStation4:"PlayStation 4",Roku:"Roku"},e.ENGINE_MAP={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"}},90:function(t,e,i){"use strict";e.__esModule=!0,e.default=void 0;var o,a=(o=i(91))&&o.__esModule?o:{default:o},n=i(18);function r(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}var s=function(){function t(){}var e,i,o;return t.getParser=function(t,e){if(void 0===e&&(e=!1),"string"!=typeof t)throw new Error("UserAgent should be a string");return new a.default(t,e)},t.parse=function(t){return new a.default(t).getResult()},e=t,o=[{key:"BROWSER_MAP",get:function(){return n.BROWSER_MAP}},{key:"ENGINE_MAP",get:function(){return n.ENGINE_MAP}},{key:"OS_MAP",get:function(){return n.OS_MAP}},{key:"PLATFORMS_MAP",get:function(){return n.PLATFORMS_MAP}}],(i=null)&&r(e.prototype,i),o&&r(e,o),t}();e.default=s,t.exports=e.default},91:function(t,e,i){"use strict";e.__esModule=!0,e.default=void 0;var o=l(i(92)),a=l(i(93)),n=l(i(94)),r=l(i(95)),s=l(i(17));function l(t){return t&&t.__esModule?t:{default:t}}var d=function(){function t(t,e){if(void 0===e&&(e=!1),null==t||""===t)throw new Error("UserAgent parameter can't be empty");this._ua=t,this.parsedResult={},!0!==e&&this.parse()}var e=t.prototype;return e.getUA=function(){return this._ua},e.test=function(t){return t.test(this._ua)},e.parseBrowser=function(){var t=this;this.parsedResult.browser={};var e=s.default.find(o.default,(function(e){if("function"==typeof e.test)return e.test(t);if(e.test instanceof Array)return e.test.some((function(e){return t.test(e)}));throw new Error("Browser's test function is not valid")}));return e&&(this.parsedResult.browser=e.describe(this.getUA())),this.parsedResult.browser},e.getBrowser=function(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()},e.getBrowserName=function(t){return t?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""},e.getBrowserVersion=function(){return this.getBrowser().version},e.getOS=function(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()},e.parseOS=function(){var t=this;this.parsedResult.os={};var e=s.default.find(a.default,(function(e){if("function"==typeof e.test)return e.test(t);if(e.test instanceof Array)return e.test.some((function(e){return t.test(e)}));throw new Error("Browser's test function is not valid")}));return e&&(this.parsedResult.os=e.describe(this.getUA())),this.parsedResult.os},e.getOSName=function(t){var e=this.getOS().name;return t?String(e).toLowerCase()||"":e||""},e.getOSVersion=function(){return this.getOS().version},e.getPlatform=function(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()},e.getPlatformType=function(t){void 0===t&&(t=!1);var e=this.getPlatform().type;return t?String(e).toLowerCase()||"":e||""},e.parsePlatform=function(){var t=this;this.parsedResult.platform={};var e=s.default.find(n.default,(function(e){if("function"==typeof e.test)return e.test(t);if(e.test instanceof Array)return e.test.some((function(e){return t.test(e)}));throw new Error("Browser's test function is not valid")}));return e&&(this.parsedResult.platform=e.describe(this.getUA())),this.parsedResult.platform},e.getEngine=function(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()},e.getEngineName=function(t){return t?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""},e.parseEngine=function(){var t=this;this.parsedResult.engine={};var e=s.default.find(r.default,(function(e){if("function"==typeof e.test)return e.test(t);if(e.test instanceof Array)return e.test.some((function(e){return t.test(e)}));throw new Error("Browser's test function is not valid")}));return e&&(this.parsedResult.engine=e.describe(this.getUA())),this.parsedResult.engine},e.parse=function(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this},e.getResult=function(){return s.default.assign({},this.parsedResult)},e.satisfies=function(t){var e=this,i={},o=0,a={},n=0;if(Object.keys(t).forEach((function(e){var r=t[e];"string"==typeof r?(a[e]=r,n+=1):"object"==typeof r&&(i[e]=r,o+=1)})),o>0){var r=Object.keys(i),l=s.default.find(r,(function(t){return e.isOS(t)}));if(l){var d=this.satisfies(i[l]);if(void 0!==d)return d}var u=s.default.find(r,(function(t){return e.isPlatform(t)}));if(u){var c=this.satisfies(i[u]);if(void 0!==c)return c}}if(n>0){var h=Object.keys(a),p=s.default.find(h,(function(t){return e.isBrowser(t,!0)}));if(void 0!==p)return this.compareVersion(a[p])}},e.isBrowser=function(t,e){void 0===e&&(e=!1);var i=this.getBrowserName().toLowerCase(),o=t.toLowerCase(),a=s.default.getBrowserTypeByAlias(o);return e&&a&&(o=a.toLowerCase()),o===i},e.compareVersion=function(t){var e=[0],i=t,o=!1,a=this.getBrowserVersion();if("string"==typeof a)return">"===t[0]||"<"===t[0]?(i=t.substr(1),"="===t[1]?(o=!0,i=t.substr(2)):e=[],">"===t[0]?e.push(1):e.push(-1)):"="===t[0]?i=t.substr(1):"~"===t[0]&&(o=!0,i=t.substr(1)),e.indexOf(s.default.compareVersions(a,i,o))>-1},e.isOS=function(t){return this.getOSName(!0)===String(t).toLowerCase()},e.isPlatform=function(t){return this.getPlatformType(!0)===String(t).toLowerCase()},e.isEngine=function(t){return this.getEngineName(!0)===String(t).toLowerCase()},e.is=function(t,e){return void 0===e&&(e=!1),this.isBrowser(t,e)||this.isOS(t)||this.isPlatform(t)},e.some=function(t){var e=this;return void 0===t&&(t=[]),t.some((function(t){return e.is(t)}))},t}();e.default=d,t.exports=e.default},92:function(t,e,i){"use strict";e.__esModule=!0,e.default=void 0;var o,a=(o=i(17))&&o.__esModule?o:{default:o},n=/version\/(\d+(\.?_?\d+)+)/i,r=[{test:[/googlebot/i],describe:function(t){var e={name:"Googlebot"},i=a.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,t)||a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/opera/i],describe:function(t){var e={name:"Opera"},i=a.default.getFirstMatch(n,t)||a.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/opr\/|opios/i],describe:function(t){var e={name:"Opera"},i=a.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,t)||a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/SamsungBrowser/i],describe:function(t){var e={name:"Samsung Internet for Android"},i=a.default.getFirstMatch(n,t)||a.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/Whale/i],describe:function(t){var e={name:"NAVER Whale Browser"},i=a.default.getFirstMatch(n,t)||a.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/MZBrowser/i],describe:function(t){var e={name:"MZ Browser"},i=a.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,t)||a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/focus/i],describe:function(t){var e={name:"Focus"},i=a.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,t)||a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/swing/i],describe:function(t){var e={name:"Swing"},i=a.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,t)||a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/coast/i],describe:function(t){var e={name:"Opera Coast"},i=a.default.getFirstMatch(n,t)||a.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe:function(t){var e={name:"Opera Touch"},i=a.default.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,t)||a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/yabrowser/i],describe:function(t){var e={name:"Yandex Browser"},i=a.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,t)||a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/ucbrowser/i],describe:function(t){var e={name:"UC Browser"},i=a.default.getFirstMatch(n,t)||a.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/Maxthon|mxios/i],describe:function(t){var e={name:"Maxthon"},i=a.default.getFirstMatch(n,t)||a.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/epiphany/i],describe:function(t){var e={name:"Epiphany"},i=a.default.getFirstMatch(n,t)||a.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/puffin/i],describe:function(t){var e={name:"Puffin"},i=a.default.getFirstMatch(n,t)||a.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/sleipnir/i],describe:function(t){var e={name:"Sleipnir"},i=a.default.getFirstMatch(n,t)||a.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/k-meleon/i],describe:function(t){var e={name:"K-Meleon"},i=a.default.getFirstMatch(n,t)||a.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/micromessenger/i],describe:function(t){var e={name:"WeChat"},i=a.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,t)||a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/qqbrowser/i],describe:function(t){var e={name:/qqbrowserlite/i.test(t)?"QQ Browser Lite":"QQ Browser"},i=a.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,t)||a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/msie|trident/i],describe:function(t){var e={name:"Internet Explorer"},i=a.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/\sedg\//i],describe:function(t){var e={name:"Microsoft Edge"},i=a.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/edg([ea]|ios)/i],describe:function(t){var e={name:"Microsoft Edge"},i=a.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/vivaldi/i],describe:function(t){var e={name:"Vivaldi"},i=a.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/seamonkey/i],describe:function(t){var e={name:"SeaMonkey"},i=a.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/sailfish/i],describe:function(t){var e={name:"Sailfish"},i=a.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,t);return i&&(e.version=i),e}},{test:[/silk/i],describe:function(t){var e={name:"Amazon Silk"},i=a.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/phantom/i],describe:function(t){var e={name:"PhantomJS"},i=a.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/slimerjs/i],describe:function(t){var e={name:"SlimerJS"},i=a.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(t){var e={name:"BlackBerry"},i=a.default.getFirstMatch(n,t)||a.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/(web|hpw)[o0]s/i],describe:function(t){var e={name:"WebOS Browser"},i=a.default.getFirstMatch(n,t)||a.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/bada/i],describe:function(t){var e={name:"Bada"},i=a.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/tizen/i],describe:function(t){var e={name:"Tizen"},i=a.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,t)||a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/qupzilla/i],describe:function(t){var e={name:"QupZilla"},i=a.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,t)||a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/firefox|iceweasel|fxios/i],describe:function(t){var e={name:"Firefox"},i=a.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/electron/i],describe:function(t){var e={name:"Electron"},i=a.default.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/MiuiBrowser/i],describe:function(t){var e={name:"Miui"},i=a.default.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/chromium/i],describe:function(t){var e={name:"Chromium"},i=a.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,t)||a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/chrome|crios|crmo/i],describe:function(t){var e={name:"Chrome"},i=a.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/GSA/i],describe:function(t){var e={name:"Google Search"},i=a.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:function(t){var e=!t.test(/like android/i),i=t.test(/android/i);return e&&i},describe:function(t){var e={name:"Android Browser"},i=a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/playstation 4/i],describe:function(t){var e={name:"PlayStation 4"},i=a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/safari|applewebkit/i],describe:function(t){var e={name:"Safari"},i=a.default.getFirstMatch(n,t);return i&&(e.version=i),e}},{test:[/.*/i],describe:function(t){var e=-1!==t.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:a.default.getFirstMatch(e,t),version:a.default.getSecondMatch(e,t)}}}];e.default=r,t.exports=e.default},93:function(t,e,i){"use strict";e.__esModule=!0,e.default=void 0;var o,a=(o=i(17))&&o.__esModule?o:{default:o},n=i(18),r=[{test:[/Roku\/DVP/],describe:function(t){var e=a.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,t);return{name:n.OS_MAP.Roku,version:e}}},{test:[/windows phone/i],describe:function(t){var e=a.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,t);return{name:n.OS_MAP.WindowsPhone,version:e}}},{test:[/windows /i],describe:function(t){var e=a.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,t),i=a.default.getWindowsVersionName(e);return{name:n.OS_MAP.Windows,version:e,versionName:i}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(t){var e={name:n.OS_MAP.iOS},i=a.default.getSecondMatch(/(Version\/)(\d[\d.]+)/,t);return i&&(e.version=i),e}},{test:[/macintosh/i],describe:function(t){var e=a.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,t).replace(/[_\s]/g,"."),i=a.default.getMacOSVersionName(e),o={name:n.OS_MAP.MacOS,version:e};return i&&(o.versionName=i),o}},{test:[/(ipod|iphone|ipad)/i],describe:function(t){var e=a.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,t).replace(/[_\s]/g,".");return{name:n.OS_MAP.iOS,version:e}}},{test:function(t){var e=!t.test(/like android/i),i=t.test(/android/i);return e&&i},describe:function(t){var e=a.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,t),i=a.default.getAndroidVersionName(e),o={name:n.OS_MAP.Android,version:e};return i&&(o.versionName=i),o}},{test:[/(web|hpw)[o0]s/i],describe:function(t){var e=a.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,t),i={name:n.OS_MAP.WebOS};return e&&e.length&&(i.version=e),i}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(t){var e=a.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,t)||a.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,t)||a.default.getFirstMatch(/\bbb(\d+)/i,t);return{name:n.OS_MAP.BlackBerry,version:e}}},{test:[/bada/i],describe:function(t){var e=a.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,t);return{name:n.OS_MAP.Bada,version:e}}},{test:[/tizen/i],describe:function(t){var e=a.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,t);return{name:n.OS_MAP.Tizen,version:e}}},{test:[/linux/i],describe:function(){return{name:n.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return{name:n.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(t){var e=a.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,t);return{name:n.OS_MAP.PlayStation4,version:e}}}];e.default=r,t.exports=e.default},94:function(t,e,i){"use strict";e.__esModule=!0,e.default=void 0;var o,a=(o=i(17))&&o.__esModule?o:{default:o},n=i(18),r=[{test:[/googlebot/i],describe:function(){return{type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(t){var e=a.default.getFirstMatch(/(can-l01)/i,t)&&"Nova",i={type:n.PLATFORMS_MAP.mobile,vendor:"Huawei"};return e&&(i.model=e),i}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:n.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:n.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(){return{type:n.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:n.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:n.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return{type:n.PLATFORMS_MAP.tablet}}},{test:function(t){var e=t.test(/ipod|iphone/i),i=t.test(/like (ipod|iphone)/i);return e&&!i},describe:function(t){var e=a.default.getFirstMatch(/(ipod|iphone)/i,t);return{type:n.PLATFORMS_MAP.mobile,vendor:"Apple",model:e}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:n.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return{type:n.PLATFORMS_MAP.mobile}}},{test:function(t){return"blackberry"===t.getBrowserName(!0)},describe:function(){return{type:n.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(t){return"bada"===t.getBrowserName(!0)},describe:function(){return{type:n.PLATFORMS_MAP.mobile}}},{test:function(t){return"windows phone"===t.getBrowserName()},describe:function(){return{type:n.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(t){var e=Number(String(t.getOSVersion()).split(".")[0]);return"android"===t.getOSName(!0)&&e>=3},describe:function(){return{type:n.PLATFORMS_MAP.tablet}}},{test:function(t){return"android"===t.getOSName(!0)},describe:function(){return{type:n.PLATFORMS_MAP.mobile}}},{test:function(t){return"macos"===t.getOSName(!0)},describe:function(){return{type:n.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(t){return"windows"===t.getOSName(!0)},describe:function(){return{type:n.PLATFORMS_MAP.desktop}}},{test:function(t){return"linux"===t.getOSName(!0)},describe:function(){return{type:n.PLATFORMS_MAP.desktop}}},{test:function(t){return"playstation 4"===t.getOSName(!0)},describe:function(){return{type:n.PLATFORMS_MAP.tv}}},{test:function(t){return"roku"===t.getOSName(!0)},describe:function(){return{type:n.PLATFORMS_MAP.tv}}}];e.default=r,t.exports=e.default},95:function(t,e,i){"use strict";e.__esModule=!0,e.default=void 0;var o,a=(o=i(17))&&o.__esModule?o:{default:o},n=i(18),r=[{test:function(t){return"microsoft edge"===t.getBrowserName(!0)},describe:function(t){if(/\sedg\//i.test(t))return{name:n.ENGINE_MAP.Blink};var e=a.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,t);return{name:n.ENGINE_MAP.EdgeHTML,version:e}}},{test:[/trident/i],describe:function(t){var e={name:n.ENGINE_MAP.Trident},i=a.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:function(t){return t.test(/presto/i)},describe:function(t){var e={name:n.ENGINE_MAP.Presto},i=a.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:function(t){var e=t.test(/gecko/i),i=t.test(/like gecko/i);return e&&!i},describe:function(t){var e={name:n.ENGINE_MAP.Gecko},i=a.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return{name:n.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(t){var e={name:n.ENGINE_MAP.WebKit},i=a.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,t);return i&&(e.version=i),e}}];e.default=r,t.exports=e.default}})},"./node_modules/requestidlecallback-polyfill/index.js":()=>{window.requestIdleCallback=window.requestIdleCallback||function(t){var e=Date.now();return setTimeout((function(){t({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-e))}})}),1)},window.cancelIdleCallback=window.cancelIdleCallback||function(t){clearTimeout(t)}}},e={};function i(o){var a=e[o];if(void 0!==a)return a.exports;var n=e[o]={exports:{}};return t[o].call(n.exports,n,n.exports,i),n.exports}(()=>{"use strict";var t=i("./node_modules/bowser/es5.js");const e=globalThis,o=e.trustedTypes,a=o?o.createPolicy("lit-html",{createHTML:t=>t}):void 0,n="$lit$",r=`lit$${Math.random().toFixed(9).slice(2)}$`,s="?"+r,l=`<${s}>`,d=document,u=()=>d.createComment(""),c=t=>null===t||"object"!=typeof t&&"function"!=typeof t,h=Array.isArray,p=t=>h(t)||"function"==typeof t?.[Symbol.iterator],g="[ \t\n\f\r]",m=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,v=/-->/g,f=/>/g,b=RegExp(`>|${g}(?:([^\\s"'>=/]+)(${g}*=${g}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),w=/'/g,y=/"/g,x=/^(?:script|style|textarea|title)$/i,S=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),k=S(1),T=S(2),C=(S(3),Symbol.for("lit-noChange")),I=Symbol.for("lit-nothing"),P=new WeakMap,L=d.createTreeWalker(d,129);function _(t,e){if(!h(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==a?a.createHTML(e):e}const A=(t,e)=>{const i=t.length-1,o=[];let a,s=2===e?"<svg>":3===e?"<math>":"",d=m;for(let e=0;e<i;e++){const i=t[e];let u,c,h=-1,p=0;for(;p<i.length&&(d.lastIndex=p,c=d.exec(i),null!==c);)p=d.lastIndex,d===m?"!--"===c[1]?d=v:void 0!==c[1]?d=f:void 0!==c[2]?(x.test(c[2])&&(a=RegExp("</"+c[2],"g")),d=b):void 0!==c[3]&&(d=b):d===b?">"===c[0]?(d=a??m,h=-1):void 0===c[1]?h=-2:(h=d.lastIndex-c[2].length,u=c[1],d=void 0===c[3]?b:'"'===c[3]?y:w):d===y||d===w?d=b:d===v||d===f?d=m:(d=b,a=void 0);const g=d===b&&t[e+1].startsWith("/>")?" ":"";s+=d===m?i+l:h>=0?(o.push(u),i.slice(0,h)+n+i.slice(h)+r+g):i+r+(-2===h?e:g)}return[_(t,s+(t[i]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),o]};class O{constructor({strings:t,_$litType$:e},i){let a;this.parts=[];let l=0,d=0;const c=t.length-1,h=this.parts,[p,g]=A(t,e);if(this.el=O.createElement(p,i),L.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(a=L.nextNode())&&h.length<c;){if(1===a.nodeType){if(a.hasAttributes())for(const t of a.getAttributeNames())if(t.endsWith(n)){const e=g[d++],i=a.getAttribute(t).split(r),o=/([.?@])?(.*)/.exec(e);h.push({type:1,index:l,name:o[2],strings:i,ctor:"."===o[1]?N:"?"===o[1]?$:"@"===o[1]?R:B}),a.removeAttribute(t)}else t.startsWith(r)&&(h.push({type:6,index:l}),a.removeAttribute(t));if(x.test(a.tagName)){const t=a.textContent.split(r),e=t.length-1;if(e>0){a.textContent=o?o.emptyScript:"";for(let i=0;i<e;i++)a.append(t[i],u()),L.nextNode(),h.push({type:2,index:++l});a.append(t[e],u())}}}else if(8===a.nodeType)if(a.data===s)h.push({type:2,index:l});else{let t=-1;for(;-1!==(t=a.data.indexOf(r,t+1));)h.push({type:7,index:l}),t+=r.length-1}l++}}static createElement(t,e){const i=d.createElement("template");return i.innerHTML=t,i}}function V(t,e,i=t,o){if(e===C)return e;let a=void 0!==o?i.o?.[o]:i.l;const n=c(e)?void 0:e._$litDirective$;return a?.constructor!==n&&(a?._$AO?.(!1),void 0===n?a=void 0:(a=new n(t),a._$AT(t,i,o)),void 0!==o?(i.o??=[])[o]=a:i.l=a),void 0!==a&&(e=V(t,a._$AS(t,e.values),a,o)),e}class M{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:i}=this._$AD,o=(t?.creationScope??d).importNode(e,!0);L.currentNode=o;let a=L.nextNode(),n=0,r=0,s=i[0];for(;void 0!==s;){if(n===s.index){let e;2===s.type?e=new E(a,a.nextSibling,this,t):1===s.type?e=new s.ctor(a,s.name,s.strings,this,t):6===s.type&&(e=new D(a,this,t)),this._$AV.push(e),s=i[++r]}n!==s?.index&&(a=L.nextNode(),n++)}return L.currentNode=d,o}p(t){let e=0;for(const i of this._$AV)void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class E{get _$AU(){return this._$AM?._$AU??this.v}constructor(t,e,i,o){this.type=2,this._$AH=I,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=o,this.v=o?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=V(this,t,e),c(t)?t===I||null==t||""===t?(this._$AH!==I&&this._$AR(),this._$AH=I):t!==this._$AH&&t!==C&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):p(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==I&&c(this._$AH)?this._$AA.nextSibling.data=t:this.T(d.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:i}=t,o="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=O.createElement(_(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===o)this._$AH.p(e);else{const t=new M(o,this),i=t.u(this.options);t.p(e),this.T(i),this._$AH=t}}_$AC(t){let e=P.get(t.strings);return void 0===e&&P.set(t.strings,e=new O(t)),e}k(t){h(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,o=0;for(const a of t)o===e.length?e.push(i=new E(this.O(u()),this.O(u()),this,this.options)):i=e[o],i._$AI(a),o++;o<e.length&&(this._$AR(i&&i._$AB.nextSibling,o),e.length=o)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){void 0===this._$AM&&(this.v=t,this._$AP?.(t))}}class B{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,o,a){this.type=1,this._$AH=I,this._$AN=void 0,this.element=t,this.name=e,this._$AM=o,this.options=a,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=I}_$AI(t,e=this,i,o){const a=this.strings;let n=!1;if(void 0===a)t=V(this,t,e,0),n=!c(t)||t!==this._$AH&&t!==C,n&&(this._$AH=t);else{const o=t;let r,s;for(t=a[0],r=0;r<a.length-1;r++)s=V(this,o[i+r],e,r),s===C&&(s=this._$AH[r]),n||=!c(s)||s!==this._$AH[r],s===I?t=I:t!==I&&(t+=(s??"")+a[r+1]),this._$AH[r]=s}n&&!o&&this.j(t)}j(t){t===I?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class N extends B{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===I?void 0:t}}class $ extends B{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==I)}}class R extends B{constructor(t,e,i,o,a){super(t,e,i,o,a),this.type=5}_$AI(t,e=this){if((t=V(this,t,e,0)??I)===C)return;const i=this._$AH,o=t===I&&i!==I||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,a=t!==I&&(i===I||o);o&&this.element.removeEventListener(this.name,this,i),a&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class D{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){V(this,t)}}const F=e.litHtmlPolyfillSupport;F?.(O,E),(e.litHtmlVersions??=[]).push("3.2.0");const U=(t,e,i)=>{const o=i?.renderBefore??e;let a=o._$litPart$;if(void 0===a){const t=i?.renderBefore??null;o._$litPart$=a=new E(e.insertBefore(u(),t),t,void 0,i??{})}return a._$AI(t),a};function q(t){return String(t).split("").map((t=>t.charCodeAt(0)))}function z(t){return new Uint8Array(q(t))}function H(t){const e=new ArrayBuffer(2*t.length),i=new Uint8Array(e);return new Uint16Array(e).set(q(t)),i}function j(t){const e=255;return[t>>>24&e,t>>>16&e,t>>>8&e,t&e]}function W(t){return 11+t}function G(t,e,i,o){return 11+e+1+1+(o?2+2*(i+1):i+1)+t}function Y(t){let e=0;return t.forEach((t=>{e+=2+2*t[0].length+2+2+2*t[1].length+2})),11+e}function J(t,e){const i=2*e;let o=0;return t.forEach((t=>{o+=2+2*t[0].length+2+4})),18+i+2+o}class K{_setIntegerFrame(t,e){const i=parseInt(e,10);this.frames.push({name:t,value:i,size:W(i.toString().length)})}_setStringFrame(t,e){const i=e.toString();let o=13+2*i.length;"TDAT"===t&&(o=W(i.length)),this.frames.push({name:t,value:i,size:o})}_setPictureFrame(t,e,i,o){const a=function(t){if(!t||!t.length)return null;if(255===t[0]&&216===t[1]&&255===t[2])return"image/jpeg";if(137===t[0]&&80===t[1]&&78===t[2]&&71===t[3])return"image/png";if(71===t[0]&&73===t[1]&&70===t[2])return"image/gif";if(87===t[8]&&69===t[9]&&66===t[10]&&80===t[11])return"image/webp";const e=73===t[0]&&73===t[1]&&42===t[2]&&0===t[3],i=77===t[0]&&77===t[1]&&0===t[2]&&42===t[3];return e||i?"image/tiff":66===t[0]&&77===t[1]?"image/bmp":0===t[0]&&0===t[1]&&1===t[2]&&0===t[3]?"image/x-icon":null}(new Uint8Array(e)),n=i.toString();if(!a)throw new Error("Unknown picture MIME type");i||(o=!1),this.frames.push({name:"APIC",value:e,pictureType:t,mimeType:a,useUnicodeEncoding:o,description:n,size:G(e.byteLength,a.length,n.length,o)})}_setLyricsFrame(t,e,i){const o=t.split("").map((t=>t.charCodeAt(0))),a=e.toString(),n=i.toString();var r,s;this.frames.push({name:"USLT",value:n,language:o,description:a,size:(r=a.length,s=n.length,16+2*r+2+2+2*s)})}_setCommentFrame(t,e,i){const o=t.split("").map((t=>t.charCodeAt(0))),a=e.toString(),n=i.toString();var r,s;this.frames.push({name:"COMM",value:n,language:o,description:a,size:(r=a.length,s=n.length,16+2*r+2+2+2*s)})}_setPrivateFrame(t,e){const i=t.toString();var o,a;this.frames.push({name:"PRIV",value:e,id:i,size:(o=i.length,a=e.byteLength,10+o+1+a)})}_setUserStringFrame(t,e){const i=t.toString(),o=e.toString();var a,n;this.frames.push({name:"TXXX",description:i,value:o,size:(a=i.length,n=o.length,13+2*a+2+2+2*n)})}_setUrlLinkFrame(t,e){const i=e.toString();var o;this.frames.push({name:t,value:i,size:(o=i.length,10+o)})}_setPairedTextFrame(t,e){this.frames.push({name:t,value:e,size:Y(e)})}_setSynchronisedLyricsFrame(t,e,i,o,a){const n=a.toString(),r=o.split("").map((t=>t.charCodeAt(0)));this.frames.push({name:"SYLT",value:e,language:r,description:n,type:t,timestampFormat:i,size:J(e,n.length)})}constructor(t){if(!t||"object"!=typeof t||!("byteLength"in t))throw new Error("First argument should be an instance of ArrayBuffer or Buffer");this.arrayBuffer=t,this.padding=4096,this.frames=[],this.url=""}setFrame(t,e){switch(t){case"TPE1":case"TCOM":case"TCON":{if(!Array.isArray(e))throw new Error(`${t} frame value should be an array of strings`);const i="TCON"===t?";":"/",o=e.join(i);this._setStringFrame(t,o);break}case"TLAN":case"TIT1":case"TIT2":case"TIT3":case"TALB":case"TPE2":case"TPE3":case"TPE4":case"TRCK":case"TPOS":case"TMED":case"TPUB":case"TCOP":case"TKEY":case"TEXT":case"TDAT":case"TSRC":this._setStringFrame(t,e);break;case"TBPM":case"TLEN":case"TYER":this._setIntegerFrame(t,e);break;case"USLT":if(e.language=e.language||"eng","object"!=typeof e||!("description"in e)||!("lyrics"in e))throw new Error("USLT frame value should be an object with keys description and lyrics");if(e.language&&!e.language.match(/[a-z]{3}/i))throw new Error("Language must be coded following the ISO 639-2 standards");this._setLyricsFrame(e.language,e.description,e.lyrics);break;case"APIC":if("object"!=typeof e||!("type"in e)||!("data"in e)||!("description"in e))throw new Error("APIC frame value should be an object with keys type, data and description");if(e.type<0||e.type>20)throw new Error("Incorrect APIC frame picture type");this._setPictureFrame(e.type,e.data,e.description,!!e.useUnicodeEncoding);break;case"TXXX":if("object"!=typeof e||!("description"in e)||!("value"in e))throw new Error("TXXX frame value should be an object with keys description and value");this._setUserStringFrame(e.description,e.value);break;case"WCOM":case"WCOP":case"WOAF":case"WOAR":case"WOAS":case"WORS":case"WPAY":case"WPUB":this._setUrlLinkFrame(t,e);break;case"COMM":if(e.language=e.language||"eng","object"!=typeof e||!("description"in e)||!("text"in e))throw new Error("COMM frame value should be an object with keys description and text");if(e.language&&!e.language.match(/[a-z]{3}/i))throw new Error("Language must be coded following the ISO 639-2 standards");this._setCommentFrame(e.language,e.description,e.text);break;case"PRIV":if("object"!=typeof e||!("id"in e)||!("data"in e))throw new Error("PRIV frame value should be an object with keys id and data");this._setPrivateFrame(e.id,e.data);break;case"IPLS":if(!Array.isArray(e)||!Array.isArray(e[0]))throw new Error("IPLS frame value should be an array of pairs");this._setPairedTextFrame(t,e);break;case"SYLT":if("object"!=typeof e||!("type"in e)||!("text"in e)||!("timestampFormat"in e))throw new Error("SYLT frame value should be an object with keys type, text and timestampFormat");if(!Array.isArray(e.text)||!Array.isArray(e.text[0]))throw new Error("SYLT frame text value should be an array of pairs");if(e.type<0||e.type>6)throw new Error("Incorrect SYLT frame content type");if(e.timestampFormat<1||e.timestampFormat>2)throw new Error("Incorrect SYLT frame time stamp format");e.language=e.language||"eng",e.description=e.description||"",this._setSynchronisedLyricsFrame(e.type,e.text,e.timestampFormat,e.language,e.description);break;default:throw new Error(`Unsupported frame ${t}`)}return this}removeTag(){if(this.arrayBuffer.byteLength<10)return;const t=new Uint8Array(this.arrayBuffer),e=t[3],i=((o=[t[6],t[7],t[8],t[9]])[0]<<21)+(o[1]<<14)+(o[2]<<7)+o[3]+10;var o,a;73!==(a=t)[0]||68!==a[1]||51!==a[2]||e<2||e>4||(this.arrayBuffer=new Uint8Array(t.subarray(i)).buffer)}addTag(){this.removeTag();const t=[255,254],e=10+this.frames.reduce(((t,e)=>t+e.size),0)+this.padding,i=new ArrayBuffer(this.arrayBuffer.byteLength+e),o=new Uint8Array(i);let a=0,n=[];return n=[73,68,51,3],o.set(n,a),a+=n.length,a++,a++,n=function(t){const e=127;return[t>>>21&e,t>>>14&e,t>>>7&e,t&e]}(e-10),o.set(n,a),a+=n.length,this.frames.forEach((e=>{switch(n=z(e.name),o.set(n,a),a+=n.length,n=j(e.size-10),o.set(n,a),a+=n.length,a+=2,e.name){case"WCOM":case"WCOP":case"WOAF":case"WOAR":case"WOAS":case"WORS":case"WPAY":case"WPUB":n=z(e.value),o.set(n,a),a+=n.length;break;case"TPE1":case"TCOM":case"TCON":case"TLAN":case"TIT1":case"TIT2":case"TIT3":case"TALB":case"TPE2":case"TPE3":case"TPE4":case"TRCK":case"TPOS":case"TKEY":case"TMED":case"TPUB":case"TCOP":case"TEXT":case"TSRC":n=[1].concat(t),o.set(n,a),a+=n.length,n=H(e.value),o.set(n,a),a+=n.length;break;case"TXXX":case"USLT":case"COMM":n=[1],"USLT"!==e.name&&"COMM"!==e.name||(n=n.concat(e.language)),n=n.concat(t),o.set(n,a),a+=n.length,n=H(e.description),o.set(n,a),a+=n.length,n=[0,0].concat(t),o.set(n,a),a+=n.length,n=H(e.value),o.set(n,a),a+=n.length;break;case"TBPM":case"TLEN":case"TDAT":case"TYER":a++,n=z(e.value),o.set(n,a),a+=n.length;break;case"PRIV":n=z(e.id),o.set(n,a),a+=n.length,a++,o.set(new Uint8Array(e.value),a),a+=e.value.byteLength;break;case"APIC":n=[e.useUnicodeEncoding?1:0],o.set(n,a),a+=n.length,n=z(e.mimeType),o.set(n,a),a+=n.length,n=[0,e.pictureType],o.set(n,a),a+=n.length,e.useUnicodeEncoding?(n=[].concat(t),o.set(n,a),a+=n.length,n=H(e.description),o.set(n,a),a+=n.length,a+=2):(n=z(e.description),o.set(n,a),a+=n.length,a++),o.set(new Uint8Array(e.value),a),a+=e.value.byteLength;break;case"IPLS":n=[1],o.set(n,a),a+=n.length,e.value.forEach((e=>{n=[].concat(t),o.set(n,a),a+=n.length,n=H(e[0].toString()),o.set(n,a),a+=n.length,n=[0,0].concat(t),o.set(n,a),a+=n.length,n=H(e[1].toString()),o.set(n,a),a+=n.length,n=[0,0],o.set(n,a),a+=n.length}));break;case"SYLT":n=[1].concat(e.language).concat(e.timestampFormat).concat(e.type),o.set(n,a),a+=n.length,n=[].concat(t),o.set(n,a),a+=n.length,n=H(e.description),o.set(n,a),a+=n.length,a+=2,e.value.forEach((e=>{n=[].concat(t),o.set(n,a),a+=n.length,n=H(e[0].toString()),o.set(n,a),a+=n.length,n=[0,0],o.set(n,a),a+=n.length,n=j(e[1]),o.set(n,a),a+=n.length}))}})),a+=this.padding,o.set(new Uint8Array(this.arrayBuffer),a),this.arrayBuffer=i,i}getBlob(){return new Blob([this.arrayBuffer],{type:"audio/mpeg"})}getURL(){return this.url||(this.url=URL.createObjectURL(this.getBlob())),this.url}revokeURL(){URL.revokeObjectURL(this.url)}}const Z={version:"1.0.3",debug:!1,fetchFn:fetch.bind(window)};class X{constructor(){this._vector=new Float32Array,this._position=0,this._frameCount=0}get vector(){return this._vector}get position(){return this._position}get startIndex(){return 2*this._position}get frameCount(){return this._frameCount}get endIndex(){return 2*(this._position+this._frameCount)}clear(){this.receive(this._frameCount),this.rewind()}put(t){this._frameCount+=t}putSamples(t,e,i=0){const o=2*(e=e||0);i>=0||(i=(t.length-o)/2);const a=2*i;this.ensureCapacity(i+this._frameCount);const n=this.endIndex;this.vector.set(t.subarray(o,o+a),n),this._frameCount+=i}putBuffer(t,e,i=0){e=e||0,i>=0||(i=t.frameCount-e),this.putSamples(t.vector,t.position+e,i)}receive(t){t>=0&&!(t>this._frameCount)||(t=this.frameCount),this._frameCount-=t,this._position+=t}receiveSamples(t,e=0){const i=2*e,o=this.startIndex;t.set(this._vector.subarray(o,o+i)),this.receive(e)}extract(t,e=0,i=0){const o=this.startIndex+2*e,a=2*i;t.set(this._vector.subarray(o,o+a))}ensureCapacity(t=0){const e=parseInt(2*t);if(this._vector.length<e){const t=new Float32Array(e);t.set(this._vector.subarray(this.startIndex,this.endIndex)),this._vector=t,this._position=0}else this.rewind()}ensureAdditionalCapacity(t=0){this.ensureCapacity(this._frameCount+t)}rewind(){this._position>0&&(this._vector.set(this._vector.subarray(this.startIndex,this.endIndex)),this._position=0)}}class Q{constructor(t){t?(this._inputBuffer=new X,this._outputBuffer=new X):this._inputBuffer=this._outputBuffer=null}get inputBuffer(){return this._inputBuffer}set inputBuffer(t){this._inputBuffer=t}get outputBuffer(){return this._outputBuffer}set outputBuffer(t){this._outputBuffer=t}clear(){this._inputBuffer.clear(),this._outputBuffer.clear()}}class tt extends Q{constructor(t){super(t),this.reset(),this._rate=1}set rate(t){this._rate=t}reset(){this.slopeCount=0,this.prevSampleL=0,this.prevSampleR=0}clone(){const t=new tt;return t.rate=this._rate,t}process(){const t=this._inputBuffer.frameCount;this._outputBuffer.ensureAdditionalCapacity(t/this._rate+1);const e=this.transpose(t);this._inputBuffer.receive(),this._outputBuffer.put(e)}transpose(t=0){if(0===t)return 0;const e=this._inputBuffer.vector,i=this._inputBuffer.startIndex,o=this._outputBuffer.vector,a=this._outputBuffer.endIndex;let n=0,r=0;for(;this.slopeCount<1;)o[a+2*r]=(1-this.slopeCount)*this.prevSampleL+this.slopeCount*e[i],o[a+2*r+1]=(1-this.slopeCount)*this.prevSampleR+this.slopeCount*e[i+1],r+=1,this.slopeCount+=this._rate;if(this.slopeCount-=1,1!==t)t:for(;;){for(;this.slopeCount>1;)if(this.slopeCount-=1,n+=1,n>=t-1)break t;const s=i+2*n;o[a+2*r]=(1-this.slopeCount)*e[s]+this.slopeCount*e[s+2],o[a+2*r+1]=(1-this.slopeCount)*e[s+1]+this.slopeCount*e[s+3],r+=1,this.slopeCount+=this._rate}return this.prevSampleL=e[i+2*t-2],this.prevSampleR=e[i+2*t-1],r}}class et{constructor(t){this._pipe=t}get pipe(){return this._pipe}get inputBuffer(){return this._pipe.inputBuffer}get outputBuffer(){return this._pipe.outputBuffer}fillInputBuffer(){throw new Error("fillInputBuffer() not overridden")}fillOutputBuffer(t=0){for(;this.outputBuffer.frameCount<t;){const t=16384-this.inputBuffer.frameCount;if(this.fillInputBuffer(t),this.inputBuffer.frameCount<16384)break;this._pipe.process()}}clear(){this._pipe.clear()}}const it=function(){};class ot extends et{constructor(t,e,i=it){super(e),this.callback=i,this.sourceSound=t,this.historyBufferSize=22050,this._sourcePosition=0,this.outputBufferPosition=0,this._position=0}get position(){return this._position}set position(t){if(t>this._position)throw new RangeError("New position may not be greater than current position");const e=this.outputBufferPosition-(this._position-t);if(e<0)throw new RangeError("New position falls outside of history buffer");this.outputBufferPosition=e,this._position=t}get sourcePosition(){return this._sourcePosition}set sourcePosition(t){this.clear(),this._sourcePosition=t}onEnd(){this.callback()}fillInputBuffer(t=0){const e=new Float32Array(2*t),i=this.sourceSound.extract(e,t,this._sourcePosition);this._sourcePosition+=i,this.inputBuffer.putSamples(e,0,i)}extract(t,e=0){this.fillOutputBuffer(this.outputBufferPosition+e);const i=Math.min(e,this.outputBuffer.frameCount-this.outputBufferPosition);this.outputBuffer.extract(t,this.outputBufferPosition,i);const o=this.outputBufferPosition+i;return this.outputBufferPosition=Math.min(this.historyBufferSize,o),this.outputBuffer.receive(Math.max(o-this.historyBufferSize,0)),this._position+=i,i}handleSampleData(t){this.extract(t.data,4096)}clear(){super.clear(),this.outputBufferPosition=0}}const at=[[124,186,248,310,372,434,496,558,620,682,744,806,868,930,992,1054,1116,1178,1240,1302,1364,1426,1488,0],[-100,-75,-50,-25,25,50,75,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[-20,-15,-10,-5,5,10,15,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[-4,-3,-2,-1,1,2,3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],nt=-10/1.5;class rt extends Q{constructor(t){super(t),this._quickSeek=!0,this.midBufferDirty=!1,this.midBuffer=null,this.overlapLength=0,this.autoSeqSetting=!0,this.autoSeekSetting=!0,this._tempo=1,this.setParameters(44100,0,0,8)}clear(){super.clear(),this.clearMidBuffer()}clearMidBuffer(){this.midBufferDirty&&(this.midBufferDirty=!1,this.midBuffer=null)}setParameters(t,e,i,o){t>0&&(this.sampleRate=t),o>0&&(this.overlapMs=o),e>0?(this.sequenceMs=e,this.autoSeqSetting=!1):this.autoSeqSetting=!0,i>0?(this.seekWindowMs=i,this.autoSeekSetting=!1):this.autoSeekSetting=!0,this.calculateSequenceParameters(),this.calculateOverlapLength(this.overlapMs),this.tempo=this._tempo}set tempo(t){let e;this._tempo=t,this.calculateSequenceParameters(),this.nominalSkip=this._tempo*(this.seekWindowLength-this.overlapLength),this.skipFract=0,e=Math.floor(this.nominalSkip+.5),this.sampleReq=Math.max(e+this.overlapLength,this.seekWindowLength)+this.seekLength}get tempo(){return this._tempo}get inputChunkSize(){return this.sampleReq}get outputChunkSize(){return this.overlapLength+Math.max(0,this.seekWindowLength-2*this.overlapLength)}calculateOverlapLength(t=0){let e;e=this.sampleRate*t/1e3,e=e<16?16:e,e-=e%8,this.overlapLength=e,this.refMidBuffer=new Float32Array(2*this.overlapLength),this.midBuffer=new Float32Array(2*this.overlapLength)}checkLimits(t,e,i){return t<e?e:t>i?i:t}calculateSequenceParameters(){let t,e;this.autoSeqSetting&&(t=150+-50*this._tempo,t=this.checkLimits(t,50,125),this.sequenceMs=Math.floor(t+.5)),this.autoSeekSetting&&(e=28.333333333333332+nt*this._tempo,e=this.checkLimits(e,15,25),this.seekWindowMs=Math.floor(e+.5)),this.seekWindowLength=Math.floor(this.sampleRate*this.sequenceMs/1e3),this.seekLength=Math.floor(this.sampleRate*this.seekWindowMs/1e3)}set quickSeek(t){this._quickSeek=t}clone(){const t=new rt;return t.tempo=this._tempo,t.setParameters(this.sampleRate,this.sequenceMs,this.seekWindowMs,this.overlapMs),t}seekBestOverlapPosition(){return this._quickSeek?this.seekBestOverlapPositionStereoQuick():this.seekBestOverlapPositionStereo()}seekBestOverlapPositionStereo(){let t,e,i,o=0;for(this.preCalculateCorrelationReferenceStereo(),t=0,e=Number.MIN_VALUE;o<this.seekLength;o+=1)i=this.calculateCrossCorrelationStereo(2*o,this.refMidBuffer),i>e&&(e=i,t=o);return t}seekBestOverlapPositionStereoQuick(){let t,e,i,o,a,n=0;for(this.preCalculateCorrelationReferenceStereo(),e=Number.MIN_VALUE,t=0,o=0,a=0;n<4;n+=1){let r=0;for(;at[n][r]&&(a=o+at[n][r],!(a>=this.seekLength));)i=this.calculateCrossCorrelationStereo(2*a,this.refMidBuffer),i>e&&(e=i,t=a),r+=1;o=t}return t}preCalculateCorrelationReferenceStereo(){let t,e,i=0;for(;i<this.overlapLength;i+=1)e=i*(this.overlapLength-i),t=2*i,this.refMidBuffer[t]=this.midBuffer[t]*e,this.refMidBuffer[t+1]=this.midBuffer[t+1]*e}calculateCrossCorrelationStereo(t,e){const i=this._inputBuffer.vector;t+=this._inputBuffer.startIndex;let o=0,a=2;const n=2*this.overlapLength;let r;for(;a<n;a+=2)r=a+t,o+=i[r]*e[a]+i[r+1]*e[a+1];return o}overlap(t){this.overlapStereo(2*t)}overlapStereo(t){const e=this._inputBuffer.vector;t+=this._inputBuffer.startIndex;const i=this._outputBuffer.vector,o=this._outputBuffer.endIndex;let a,n,r=0;const s=1/this.overlapLength;let l,d,u;for(;r<this.overlapLength;r+=1)n=(this.overlapLength-r)*s,l=r*s,a=2*r,d=a+t,u=a+o,i[u+0]=e[d+0]*l+this.midBuffer[a+0]*n,i[u+1]=e[d+1]*l+this.midBuffer[a+1]*n}process(){let t,e,i;if(null===this.midBuffer){if(this._inputBuffer.frameCount<this.overlapLength)return;this.midBuffer=new Float32Array(2*this.overlapLength),this._inputBuffer.receiveSamples(this.midBuffer,this.overlapLength)}for(;this._inputBuffer.frameCount>=this.sampleReq;){t=this.seekBestOverlapPosition(),this._outputBuffer.ensureAdditionalCapacity(this.overlapLength),this.overlap(Math.floor(t)),this._outputBuffer.put(this.overlapLength),e=this.seekWindowLength-2*this.overlapLength,e>0&&this._outputBuffer.putBuffer(this._inputBuffer,t+this.overlapLength,e);const o=this._inputBuffer.startIndex+2*(t+this.seekWindowLength-this.overlapLength);this.midBuffer.set(this._inputBuffer.vector.subarray(o,o+2*this.overlapLength)),this.skipFract+=this.nominalSkip,i=Math.floor(this.skipFract),this.skipFract-=i,this._inputBuffer.receive(i)}}}const st=function(t,e){return(t>e?t-e:e-t)>1e-10};class lt{constructor(){this.transposer=new tt(!1),this.stretch=new rt(!1),this._inputBuffer=new X,this._intermediateBuffer=new X,this._outputBuffer=new X,this._rate=0,this._tempo=0,this.virtualPitch=1,this.virtualRate=1,this.virtualTempo=1,this.calculateEffectiveRateAndTempo()}clear(){this.transposer.clear(),this.stretch.clear()}clone(){const t=new lt;return t.rate=this.rate,t.tempo=this.tempo,t}get rate(){return this._rate}set rate(t){this.virtualRate=t,this.calculateEffectiveRateAndTempo()}set rateChange(t){this._rate=1+.01*t}get tempo(){return this._tempo}set tempo(t){this.virtualTempo=t,this.calculateEffectiveRateAndTempo()}set tempoChange(t){this.tempo=1+.01*t}set pitch(t){this.virtualPitch=t,this.calculateEffectiveRateAndTempo()}set pitchOctaves(t){this.pitch=Math.exp(.69314718056*t),this.calculateEffectiveRateAndTempo()}set pitchSemitones(t){this.pitchOctaves=t/12}get inputBuffer(){return this._inputBuffer}get outputBuffer(){return this._outputBuffer}calculateEffectiveRateAndTempo(){const t=this._tempo,e=this._rate;this._tempo=this.virtualTempo/this.virtualPitch,this._rate=this.virtualRate*this.virtualPitch,st(this._tempo,t)&&(this.stretch.tempo=this._tempo),st(this._rate,e)&&(this.transposer.rate=this._rate),this._rate>1?this._outputBuffer!=this.transposer.outputBuffer&&(this.stretch.inputBuffer=this._inputBuffer,this.stretch.outputBuffer=this._intermediateBuffer,this.transposer.inputBuffer=this._intermediateBuffer,this.transposer.outputBuffer=this._outputBuffer):this._outputBuffer!=this.stretch.outputBuffer&&(this.transposer.inputBuffer=this._inputBuffer,this.transposer.outputBuffer=this._intermediateBuffer,this.stretch.inputBuffer=this._intermediateBuffer,this.stretch.outputBuffer=this._outputBuffer)}process(){this._rate>1?(this.stretch.process(),this.transposer.process()):(this.transposer.process(),this.stretch.process())}}class dt{constructor(t){this.buffer=t,this._position=0}get dualChannel(){return this.buffer.numberOfChannels>1}get position(){return this._position}set position(t){this._position=t}extract(t,e=0,i=0){this.position=i;let o=this.buffer.getChannelData(0),a=this.dualChannel?this.buffer.getChannelData(1):this.buffer.getChannelData(0),n=0;for(;n<e;n++)t[2*n]=o[n+i],t[2*n+1]=a[n+i];return Math.min(e,o.length-i)}}const ut=function(t){const e=Math.floor(t/60);return`${e}:${function(t,e,i){return i=i||"0",(t+="").length>=e?t:new Array(e-t.length+1).join(i)+t}(parseInt(t-60*e),2)}`},ct=function(t){const e=this.timePlayed,i=this.sampleRate;if(this.sourcePosition=t,this.timePlayed=t/i,e!==this.timePlayed){const t=new CustomEvent("play",{detail:{timePlayed:this.timePlayed,formattedTimePlayed:this.formattedTimePlayed,percentagePlayed:this.percentagePlayed}});this._node.dispatchEvent(t)}};class ht{constructor(t,e,i,o=it){this._soundtouch=new lt;const a=new dt(e);this.timePlayed=0,this.sourcePosition=0,this._filter=new ot(a,this._soundtouch,o),this._node=function(t,e,i=it,o=4096){const a=t.createScriptProcessor(o,2,2),n=new Float32Array(2*o);return a.onaudioprocess=t=>{let a=t.outputBuffer.getChannelData(0),r=t.outputBuffer.getChannelData(1),s=e.extract(n,o);i(e.sourcePosition),0===s&&e.onEnd();let l=0;for(;l<s;l++)a[l]=n[2*l],r[l]=n[2*l+1]},a}(t,this._filter,(t=>ct.call(this,t)),i),this.tempo=1,this.rate=1,this.duration=e.duration,this.sampleRate=t.sampleRate,this.listeners=[]}get formattedDuration(){return ut(this.duration)}get formattedTimePlayed(){return ut(this.timePlayed)}get percentagePlayed(){return 100*this._filter.sourcePosition/(this.duration*this.sampleRate)}set percentagePlayed(t){this._filter.sourcePosition=parseInt(t*this.duration*this.sampleRate),this.sourcePosition=this._filter.sourcePosition,this.timePlayed=this.sourcePosition/this.sampleRate}get node(){return this._node}set pitch(t){this._soundtouch.pitch=t}set pitchSemitones(t){this._soundtouch.pitchSemitones=t}set rate(t){this._soundtouch.rate=t}set tempo(t){this._soundtouch.tempo=t}connect(t){this._node.connect(t)}disconnect(){this._node.disconnect()}on(t,e){this.listeners.push({name:t,cb:e}),this._node.addEventListener(t,(t=>e(t.detail)))}off(t=null){let e=this.listeners;t&&(e=e.filter((e=>e.name===t))),e.forEach((t=>{this._node.removeEventListener(t.name,(e=>t.cb(e.detail)))}))}}const pt=(...t)=>{if(Z.debug)return console.log(`%c✦ chaimu.js v${Z.version} ✦`,"background: #000; color: #fff; padding: 0 8px",...t)},gt=["playing","ratechange","play","waiting","pause","seeked"];function mt(){const t=window.AudioContext||window.webkitAudioContext;return t?new t:void 0}class vt{static name="BasePlayer";chaimu;_src;fetch;constructor(t,e){this.chaimu=t,this._src=e,this.fetch=Z.fetchFn}async init(){return new Promise((t=>t(this)))}clear(){return new Promise((t=>t(this)))}lipSync(t=!1){return this}handleVideoEvent=t=>(pt(`handle video ${t.type}`),this.lipSync(t.type),this);removeVideoEvents(){for(const t of gt)this.chaimu.video.removeEventListener(t,this.handleVideoEvent);return this}addVideoEvents(){for(const t of gt)this.chaimu.video.addEventListener(t,this.handleVideoEvent);return this}async play(){return new Promise((t=>t(this)))}async pause(){return new Promise((t=>t(this)))}get name(){return this.constructor.name}set src(t){this._src=t}get src(){return this._src}get currentSrc(){return this._src}set volume(t){}get volume(){return 0}get playbackRate(){return 0}set playbackRate(t){}get currentTime(){return 0}}class ft extends vt{static name="AudioPlayer";audio;gainNode;audioSource;constructor(t,e){super(t,e),this.updateAudio()}initAudioBooster(){return this.chaimu.audioContext?(this.gainNode&&this.audioSource&&(this.audioSource.disconnect(this.gainNode),this.gainNode.disconnect()),this.gainNode=this.chaimu.audioContext.createGain(),this.gainNode.connect(this.chaimu.audioContext.destination),this.audioSource=this.chaimu.audioContext.createMediaElementSource(this.audio),this.audioSource.connect(this.gainNode),this):this}updateAudio(){return this.audio=new Audio(this.src),this.audio.crossOrigin="anonymous",this}async init(){return new Promise((t=>(this.updateAudio(),this.initAudioBooster(),t(this))))}audioErrorHandle=t=>{console.error("[AudioPlayer]",t)};lipSync(t=!1){if(pt("[AudioPlayer] lipsync video",this.chaimu.video),!this.chaimu.video)return this;if(this.audio.currentTime=this.chaimu.video.currentTime,this.audio.playbackRate=this.chaimu.video.playbackRate,!t)return pt("[AudioPlayer] lipsync mode isn't set"),this;switch(pt(`[AudioPlayer] lipsync mode is ${t}`),t){case"play":case"playing":case"seeked":return this.chaimu.video.paused||this.syncPlay(),this;case"pause":case"waiting":return this.pause(),this;default:return this}}async clear(){return new Promise((t=>(this.audio.pause(),this.audio.src="",this.audio.removeAttribute("src"),t(this))))}syncPlay(){return pt("[AudioPlayer] sync play called"),this.audio.play().catch(this.audioErrorHandle),this}async play(){return pt("[AudioPlayer] play called"),await this.audio.play().catch(this.audioErrorHandle),this}async pause(){return new Promise((t=>(pt("[AudioPlayer] pause called"),this.audio.pause(),t(this))))}set src(t){this._src=t,t?this.audio.src=t:this.clear()}get src(){return this._src}get currentSrc(){return this.audio.currentSrc}set volume(t){this.gainNode?this.gainNode.gain.value=t:this.audio.volume=t}get volume(){return this.gainNode?this.gainNode.gain.value:this.audio.volume}get playbackRate(){return this.audio.playbackRate}set playbackRate(t){this.audio.playbackRate=t}get currentTime(){return this.audio.currentTime}}class bt extends vt{static name="ChaimuPlayer";audioBuffer;sourceNode;gainNode;audioShifter;cleanerRunned=!1;async fetchAudio(){if(!this._src)throw new Error("No audio source provided");if(!this.chaimu.audioContext)throw new Error("No audio context available");pt(`[ChaimuPlayer] Fetching audio from ${this._src}...`);try{const t=await this.fetch(this._src);pt("[ChaimuPlayer] Decoding fetched audio...");const e=await t.arrayBuffer();this.audioBuffer=await this.chaimu.audioContext.decodeAudioData(e)}catch(t){throw new Error(`Failed to fetch audio file, because ${t.message}`)}return this}initAudioBooster(){return this.chaimu.audioContext?(this.gainNode&&this.gainNode.disconnect(),this.gainNode=this.chaimu.audioContext.createGain(),this):this}async init(){return await this.fetchAudio(),this.initAudioBooster(),this}lipSync(t=!1){if(pt("[ChaimuPlayer] lipsync video",this.chaimu.video,this),!this.chaimu.video)return this;if(!t)return pt("[ChaimuPlayer] lipsync mode isn't set"),this;switch(pt(`[ChaimuPlayer] lipsync mode is ${t}`),t){case"play":case"playing":case"ratechange":case"seeked":return this.chaimu.video.paused||this.start(),this;case"pause":case"waiting":return this.pause(),this;default:return this}}async reopenCtx(){if(!this.chaimu.audioContext)throw new Error("No audio context available");try{await this.chaimu.audioContext.close()}catch{}return this}async clear(){if(!this.chaimu.audioContext)throw new Error("No audio context available");if(pt("clear audio context"),this.cleanerRunned=!0,await this.pause(),!this.gainNode)return this.cleanerRunned=!1,this;this.sourceNode&&(this.sourceNode.stop(),this.sourceNode.disconnect(this.gainNode),this.sourceNode=void 0),this.audioShifter&&(this.audioShifter._node.disconnect(this.gainNode),this.audioShifter=void 0),this.gainNode.disconnect();const t=this.volume;return this.gainNode=void 0,await this.reopenCtx(),this.chaimu.audioContext=mt(),this.initAudioBooster(),this.volume=t,this.cleanerRunned=!1,this}async start(){if(!this.chaimu.audioContext)throw new Error("No audio context available");if(!this.audioBuffer)throw new Error("The player isn't initialized");return!this.gainNode||this.audioShifter&&this.audioShifter.duration<this.chaimu.video.currentTime?(pt("Skip starting player"),this):this.cleanerRunned?(pt("The other cleaner is still running, waiting..."),this):(pt("starting audio"),await this.clear(),await this.play(),this.audioShifter=new ht(this.chaimu.audioContext,this.audioBuffer,1024),this.audioShifter.tempo=this.chaimu.video.playbackRate,this.audioShifter.percentagePlayed=this.chaimu.video.currentTime/this.audioShifter.duration,this.sourceNode=this.chaimu.audioContext.createBufferSource(),this.sourceNode.buffer=null,this.sourceNode.connect(this.gainNode),this.audioShifter.connect(this.gainNode),this.gainNode.connect(this.chaimu.audioContext.destination),this.sourceNode.start(void 0,this.chaimu.video.currentTime),this)}async pause(){if(!this.chaimu.audioContext)throw new Error("No audio context available");return"running"!==this.chaimu.audioContext.state||await this.chaimu.audioContext.suspend(),this}async play(){if(!this.chaimu.audioContext)throw new Error("No audio context available");return await this.chaimu.audioContext.resume(),this}set src(t){this._src=t}get src(){return this._src}get currentSrc(){return this._src}set volume(t){this.gainNode&&(this.gainNode.gain.value=t)}get volume(){return this.gainNode?this.gainNode.gain.value:0}set playbackRate(t){if(!this.audioShifter)throw new Error("No audio source available");this.audioShifter.pitch=t}get playbackRate(){return this.audioShifter?._soundtouch?.tempo??0}get currentTime(){return this.chaimu.video.currentTime}}class wt{_debug=!1;audioContext;player;video;constructor({url:t,video:e,debug:i=!1,fetchFn:o=Z.fetchFn,preferAudio:a=!1}){this._debug=Z.debug=i,Z.fetchFn=o,this.audioContext=mt(),this.player=this.audioContext&&!a?new bt(this,t):new ft(this,t),this.video=e}async init(){await this.player.init(),this.video&&!this.video.paused&&this.player.lipSync("play"),this.player.addVideoEvents()}set debug(t){this._debug=Z.debug=t}get debug(){return this._debug}}const yt={host:"api.browser.yandex.ru",hostVOT:"vot.toil.cc/v1",hostWorker:"vot-worker.toil.cc",mediaProxy:"media-proxy.toil.cc",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 YaBrowser/24.12.0.0 Safari/537.36",componentVersion:"24.12.3.780",hmac:"bt8xH3VOlb4mqf0nqAibnDOoiPlXsisf",defaultDuration:343,minChunkSize:5295308,loggerLevel:1,version:"2.2.0"};var xt;!function(t){t[t.DEBUG=0]="DEBUG",t[t.INFO=1]="INFO",t[t.WARN=2]="WARN",t[t.ERROR=3]="ERROR",t[t.SILENCE=4]="SILENCE"}(xt||(xt={}));class St{static prefix=`[vot.js v${yt.version}]`;static canLog(t){return yt.loggerLevel<=t}static log(...t){St.canLog(xt.DEBUG)&&console.log(St.prefix,...t)}static info(...t){St.canLog(xt.INFO)&&console.info(St.prefix,...t)}static warn(...t){St.canLog(xt.WARN)&&console.warn(St.prefix,...t)}static error(...t){St.canLog(xt.ERROR)&&console.error(St.prefix,...t)}}function kt(){let t=0,e=0;for(let i=0;i<28;i+=7){let o=this.buf[this.pos++];if(t|=(127&o)<<i,0==(128&o))return this.assertBounds(),[t,e]}let i=this.buf[this.pos++];if(t|=(15&i)<<28,e=(112&i)>>4,0==(128&i))return this.assertBounds(),[t,e];for(let i=3;i<=31;i+=7){let o=this.buf[this.pos++];if(e|=(127&o)<<i,0==(128&o))return this.assertBounds(),[t,e]}throw new Error("invalid varint")}function Tt(t,e,i){for(let o=0;o<28;o+=7){const a=t>>>o,n=!(a>>>7==0&&0==e),r=255&(n?128|a:a);if(i.push(r),!n)return}const o=t>>>28&15|(7&e)<<4,a=!(e>>3==0);if(i.push(255&(a?128|o:o)),a){for(let t=3;t<31;t+=7){const o=e>>>t,a=!(o>>>7==0),n=255&(a?128|o:o);if(i.push(n),!a)return}i.push(e>>>31&1)}}const Ct=4294967296;function It(t){const e="-"===t[0];e&&(t=t.slice(1));const i=1e6;let o=0,a=0;function n(e,n){const r=Number(t.slice(e,n));a*=i,o=o*i+r,o>=Ct&&(a+=o/Ct|0,o%=Ct)}return n(-24,-18),n(-18,-12),n(-12,-6),n(-6),e?_t(o,a):Lt(o,a)}function Pt(t,e){if(({lo:t,hi:e}=function(t,e){return{lo:t>>>0,hi:e>>>0}}(t,e)),e<=2097151)return String(Ct*e+t);const i=16777215&(t>>>24|e<<8),o=e>>16&65535;let a=(16777215&t)+6777216*i+6710656*o,n=i+8147497*o,r=2*o;const s=1e7;return a>=s&&(n+=Math.floor(a/s),a%=s),n>=s&&(r+=Math.floor(n/s),n%=s),r.toString()+At(n)+At(a)}function Lt(t,e){return{lo:0|t,hi:0|e}}function _t(t,e){return e=~e,t?t=1+~t:e+=1,Lt(t,e)}const At=t=>{const e=String(t);return"0000000".slice(e.length)+e};function Ot(t,e){if(t>=0){for(;t>127;)e.push(127&t|128),t>>>=7;e.push(t)}else{for(let i=0;i<9;i++)e.push(127&t|128),t>>=7;e.push(1)}}function Vt(){let t=this.buf[this.pos++],e=127&t;if(0==(128&t))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(127&t)<<7,0==(128&t))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(127&t)<<14,0==(128&t))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(127&t)<<21,0==(128&t))return this.assertBounds(),e;t=this.buf[this.pos++],e|=(15&t)<<28;for(let e=5;0!=(128&t)&&e<10;e++)t=this.buf[this.pos++];if(0!=(128&t))throw new Error("invalid varint");return this.assertBounds(),e>>>0}const Mt=Et();function Et(){const t=new DataView(new ArrayBuffer(8));if("function"==typeof BigInt&&"function"==typeof t.getBigInt64&&"function"==typeof t.getBigUint64&&"function"==typeof t.setBigInt64&&"function"==typeof t.setBigUint64&&("object"!=typeof process||"object"!=typeof process.env||"1"!==process.env.BUF_BIGINT_DISABLE)){const e=BigInt("-9223372036854775808"),i=BigInt("9223372036854775807"),o=BigInt("0"),a=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(t){const o="bigint"==typeof t?t:BigInt(t);if(o>i||o<e)throw new Error(`invalid int64: ${t}`);return o},uParse(t){const e="bigint"==typeof t?t:BigInt(t);if(e>a||e<o)throw new Error(`invalid uint64: ${t}`);return e},enc(e){return t.setBigInt64(0,this.parse(e),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},uEnc(e){return t.setBigInt64(0,this.uParse(e),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},dec:(e,i)=>(t.setInt32(0,e,!0),t.setInt32(4,i,!0),t.getBigInt64(0,!0)),uDec:(e,i)=>(t.setInt32(0,e,!0),t.setInt32(4,i,!0),t.getBigUint64(0,!0))}}return{zero:"0",supported:!1,parse:t=>("string"!=typeof t&&(t=t.toString()),Bt(t),t),uParse:t=>("string"!=typeof t&&(t=t.toString()),Nt(t),t),enc:t=>("string"!=typeof t&&(t=t.toString()),Bt(t),It(t)),uEnc:t=>("string"!=typeof t&&(t=t.toString()),Nt(t),It(t)),dec:(t,e)=>function(t,e){let i=Lt(t,e);const o=2147483648&i.hi;o&&(i=_t(i.lo,i.hi));const a=Pt(i.lo,i.hi);return o?"-"+a:a}(t,e),uDec:(t,e)=>Pt(t,e)}}function Bt(t){if(!/^-?[0-9]+$/.test(t))throw new Error("invalid int64: "+t)}function Nt(t){if(!/^[0-9]+$/.test(t))throw new Error("invalid uint64: "+t)}const $t=Symbol.for("@bufbuild/protobuf/text-encoding");function Rt(){if(null==globalThis[$t]){const t=new globalThis.TextEncoder,e=new globalThis.TextDecoder;globalThis[$t]={encodeUtf8:e=>t.encode(e),decodeUtf8:t=>e.decode(t),checkUtf8(t){try{return encodeURIComponent(t),!0}catch(t){return!1}}}}return globalThis[$t]}var Dt;!function(t){t[t.Varint=0]="Varint",t[t.Bit64=1]="Bit64",t[t.LengthDelimited=2]="LengthDelimited",t[t.StartGroup=3]="StartGroup",t[t.EndGroup=4]="EndGroup",t[t.Bit32=5]="Bit32"}(Dt||(Dt={}));const Ft=34028234663852886e22,Ut=-34028234663852886e22;class qt{constructor(t=Rt().encodeUtf8){this.encodeUtf8=t,this.stack=[],this.chunks=[],this.buf=[]}finish(){this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]);let t=0;for(let e=0;e<this.chunks.length;e++)t+=this.chunks[e].length;let e=new Uint8Array(t),i=0;for(let t=0;t<this.chunks.length;t++)e.set(this.chunks[t],i),i+=this.chunks[t].length;return this.chunks=[],e}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let t=this.finish(),e=this.stack.pop();if(!e)throw new Error("invalid state, fork stack empty");return this.chunks=e.chunks,this.buf=e.buf,this.uint32(t.byteLength),this.raw(t)}tag(t,e){return this.uint32((t<<3|e)>>>0)}raw(t){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(t),this}uint32(t){for(jt(t);t>127;)this.buf.push(127&t|128),t>>>=7;return this.buf.push(t),this}int32(t){return Ht(t),Ot(t,this.buf),this}bool(t){return this.buf.push(t?1:0),this}bytes(t){return this.uint32(t.byteLength),this.raw(t)}string(t){let e=this.encodeUtf8(t);return this.uint32(e.byteLength),this.raw(e)}float(t){!function(t){if("string"==typeof t){const e=t;if(t=Number(t),isNaN(t)&&"NaN"!==e)throw new Error("invalid float32: "+e)}else if("number"!=typeof t)throw new Error("invalid float32: "+typeof t);if(Number.isFinite(t)&&(t>Ft||t<Ut))throw new Error("invalid float32: "+t)}(t);let e=new Uint8Array(4);return new DataView(e.buffer).setFloat32(0,t,!0),this.raw(e)}double(t){let e=new Uint8Array(8);return new DataView(e.buffer).setFloat64(0,t,!0),this.raw(e)}fixed32(t){jt(t);let e=new Uint8Array(4);return new DataView(e.buffer).setUint32(0,t,!0),this.raw(e)}sfixed32(t){Ht(t);let e=new Uint8Array(4);return new DataView(e.buffer).setInt32(0,t,!0),this.raw(e)}sint32(t){return Ht(t),Ot(t=(t<<1^t>>31)>>>0,this.buf),this}sfixed64(t){let e=new Uint8Array(8),i=new DataView(e.buffer),o=Mt.enc(t);return i.setInt32(0,o.lo,!0),i.setInt32(4,o.hi,!0),this.raw(e)}fixed64(t){let e=new Uint8Array(8),i=new DataView(e.buffer),o=Mt.uEnc(t);return i.setInt32(0,o.lo,!0),i.setInt32(4,o.hi,!0),this.raw(e)}int64(t){let e=Mt.enc(t);return Tt(e.lo,e.hi,this.buf),this}sint64(t){let e=Mt.enc(t),i=e.hi>>31;return Tt(e.lo<<1^i,(e.hi<<1|e.lo>>>31)^i,this.buf),this}uint64(t){let e=Mt.uEnc(t);return Tt(e.lo,e.hi,this.buf),this}}class zt{constructor(t,e=Rt().decodeUtf8){this.decodeUtf8=e,this.varint64=kt,this.uint32=Vt,this.buf=t,this.len=t.length,this.pos=0,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength)}tag(){let t=this.uint32(),e=t>>>3,i=7&t;if(e<=0||i<0||i>5)throw new Error("illegal tag: field no "+e+" wire type "+i);return[e,i]}skip(t,e){let i=this.pos;switch(t){case Dt.Varint:for(;128&this.buf[this.pos++];);break;case Dt.Bit64:this.pos+=4;case Dt.Bit32:this.pos+=4;break;case Dt.LengthDelimited:let i=this.uint32();this.pos+=i;break;case Dt.StartGroup:for(;;){const[t,i]=this.tag();if(i===Dt.EndGroup){if(void 0!==e&&t!==e)throw new Error("invalid end group tag");break}this.skip(i,t)}break;default:throw new Error("cant skip wire type "+t)}return this.assertBounds(),this.buf.subarray(i,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){let t=this.uint32();return t>>>1^-(1&t)}int64(){return Mt.dec(...this.varint64())}uint64(){return Mt.uDec(...this.varint64())}sint64(){let[t,e]=this.varint64(),i=-(1&t);return t=(t>>>1|(1&e)<<31)^i,e=e>>>1^i,Mt.dec(t,e)}bool(){let[t,e]=this.varint64();return 0!==t||0!==e}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return Mt.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return Mt.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let t=this.uint32(),e=this.pos;return this.pos+=t,this.assertBounds(),this.buf.subarray(e,e+t)}string(){return this.decodeUtf8(this.bytes())}}function Ht(t){if("string"==typeof t)t=Number(t);else if("number"!=typeof t)throw new Error("invalid int32: "+typeof t);if(!Number.isInteger(t)||t>2147483647||t<-2147483648)throw new Error("invalid int32: "+t)}function jt(t){if("string"==typeof t)t=Number(t);else if("number"!=typeof t)throw new Error("invalid uint32: "+typeof t);if(!Number.isInteger(t)||t>4294967295||t<0)throw new Error("invalid uint32: "+t)}var Wt;function Gt(t){switch(t){case 0:case"NO_CONNECTION":return Wt.NO_CONNECTION;case 10:case"TRANSLATING":return Wt.TRANSLATING;case 20:case"STREAMING":return Wt.STREAMING;default:return Wt.UNRECOGNIZED}}!function(t){t[t.NO_CONNECTION=0]="NO_CONNECTION",t[t.TRANSLATING=10]="TRANSLATING",t[t.STREAMING=20]="STREAMING",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Wt||(Wt={}));const Yt={encode:(t,e=new qt)=>(""!==t.target&&e.uint32(10).string(t.target),""!==t.targetUrl&&e.uint32(18).string(t.targetUrl),e),decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={target:"",targetUrl:""};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 1:if(10!==t)break;a.target=i.string();continue;case 2:if(18!==t)break;a.targetUrl=i.string();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({target:he(t.target)?globalThis.String(t.target):"",targetUrl:he(t.targetUrl)?globalThis.String(t.targetUrl):""}),toJSON(t){const e={};return""!==t.target&&(e.target=t.target),""!==t.targetUrl&&(e.targetUrl=t.targetUrl),e},create:t=>Yt.fromPartial(t??{}),fromPartial(t){const e={target:"",targetUrl:""};return e.target=t.target??"",e.targetUrl=t.targetUrl??"",e}};const Jt={encode(t,e=new qt){""!==t.url&&e.uint32(26).string(t.url),void 0!==t.deviceId&&e.uint32(34).string(t.deviceId),!1!==t.firstRequest&&e.uint32(40).bool(t.firstRequest),0!==t.duration&&e.uint32(49).double(t.duration),0!==t.unknown0&&e.uint32(56).int32(t.unknown0),""!==t.language&&e.uint32(66).string(t.language),!1!==t.forceSourceLang&&e.uint32(72).bool(t.forceSourceLang),0!==t.unknown1&&e.uint32(80).int32(t.unknown1);for(const i of t.translationHelp)Yt.encode(i,e.uint32(90).fork()).join();return!1!==t.wasStream&&e.uint32(104).bool(t.wasStream),""!==t.responseLanguage&&e.uint32(114).string(t.responseLanguage),0!==t.unknown2&&e.uint32(120).int32(t.unknown2),0!==t.unknown3&&e.uint32(128).int32(t.unknown3),!1!==t.bypassCache&&e.uint32(136).bool(t.bypassCache),!1!==t.useNewModel&&e.uint32(144).bool(t.useNewModel),""!==t.videoTitle&&e.uint32(154).string(t.videoTitle),e},decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={url:"",deviceId:void 0,firstRequest:!1,duration:0,unknown0:0,language:"",forceSourceLang:!1,unknown1:0,translationHelp:[],wasStream:!1,responseLanguage:"",unknown2:0,unknown3:0,bypassCache:!1,useNewModel:!1,videoTitle:""};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 3:if(26!==t)break;a.url=i.string();continue;case 4:if(34!==t)break;a.deviceId=i.string();continue;case 5:if(40!==t)break;a.firstRequest=i.bool();continue;case 6:if(49!==t)break;a.duration=i.double();continue;case 7:if(56!==t)break;a.unknown0=i.int32();continue;case 8:if(66!==t)break;a.language=i.string();continue;case 9:if(72!==t)break;a.forceSourceLang=i.bool();continue;case 10:if(80!==t)break;a.unknown1=i.int32();continue;case 11:if(90!==t)break;a.translationHelp.push(Yt.decode(i,i.uint32()));continue;case 13:if(104!==t)break;a.wasStream=i.bool();continue;case 14:if(114!==t)break;a.responseLanguage=i.string();continue;case 15:if(120!==t)break;a.unknown2=i.int32();continue;case 16:if(128!==t)break;a.unknown3=i.int32();continue;case 17:if(136!==t)break;a.bypassCache=i.bool();continue;case 18:if(144!==t)break;a.useNewModel=i.bool();continue;case 19:if(154!==t)break;a.videoTitle=i.string();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({url:he(t.url)?globalThis.String(t.url):"",deviceId:he(t.deviceId)?globalThis.String(t.deviceId):void 0,firstRequest:!!he(t.firstRequest)&&globalThis.Boolean(t.firstRequest),duration:he(t.duration)?globalThis.Number(t.duration):0,unknown0:he(t.unknown0)?globalThis.Number(t.unknown0):0,language:he(t.language)?globalThis.String(t.language):"",forceSourceLang:!!he(t.forceSourceLang)&&globalThis.Boolean(t.forceSourceLang),unknown1:he(t.unknown1)?globalThis.Number(t.unknown1):0,translationHelp:globalThis.Array.isArray(t?.translationHelp)?t.translationHelp.map((t=>Yt.fromJSON(t))):[],wasStream:!!he(t.wasStream)&&globalThis.Boolean(t.wasStream),responseLanguage:he(t.responseLanguage)?globalThis.String(t.responseLanguage):"",unknown2:he(t.unknown2)?globalThis.Number(t.unknown2):0,unknown3:he(t.unknown3)?globalThis.Number(t.unknown3):0,bypassCache:!!he(t.bypassCache)&&globalThis.Boolean(t.bypassCache),useNewModel:!!he(t.useNewModel)&&globalThis.Boolean(t.useNewModel),videoTitle:he(t.videoTitle)?globalThis.String(t.videoTitle):""}),toJSON(t){const e={};return""!==t.url&&(e.url=t.url),void 0!==t.deviceId&&(e.deviceId=t.deviceId),!1!==t.firstRequest&&(e.firstRequest=t.firstRequest),0!==t.duration&&(e.duration=t.duration),0!==t.unknown0&&(e.unknown0=Math.round(t.unknown0)),""!==t.language&&(e.language=t.language),!1!==t.forceSourceLang&&(e.forceSourceLang=t.forceSourceLang),0!==t.unknown1&&(e.unknown1=Math.round(t.unknown1)),t.translationHelp?.length&&(e.translationHelp=t.translationHelp.map((t=>Yt.toJSON(t)))),!1!==t.wasStream&&(e.wasStream=t.wasStream),""!==t.responseLanguage&&(e.responseLanguage=t.responseLanguage),0!==t.unknown2&&(e.unknown2=Math.round(t.unknown2)),0!==t.unknown3&&(e.unknown3=Math.round(t.unknown3)),!1!==t.bypassCache&&(e.bypassCache=t.bypassCache),!1!==t.useNewModel&&(e.useNewModel=t.useNewModel),""!==t.videoTitle&&(e.videoTitle=t.videoTitle),e},create:t=>Jt.fromPartial(t??{}),fromPartial(t){const e={url:"",deviceId:void 0,firstRequest:!1,duration:0,unknown0:0,language:"",forceSourceLang:!1,unknown1:0,translationHelp:[],wasStream:!1,responseLanguage:"",unknown2:0,unknown3:0,bypassCache:!1,useNewModel:!1,videoTitle:""};return e.url=t.url??"",e.deviceId=t.deviceId??void 0,e.firstRequest=t.firstRequest??!1,e.duration=t.duration??0,e.unknown0=t.unknown0??0,e.language=t.language??"",e.forceSourceLang=t.forceSourceLang??!1,e.unknown1=t.unknown1??0,e.translationHelp=t.translationHelp?.map((t=>Yt.fromPartial(t)))||[],e.wasStream=t.wasStream??!1,e.responseLanguage=t.responseLanguage??"",e.unknown2=t.unknown2??0,e.unknown3=t.unknown3??0,e.bypassCache=t.bypassCache??!1,e.useNewModel=t.useNewModel??!1,e.videoTitle=t.videoTitle??"",e}};const Kt={encode:(t,e=new qt)=>(void 0!==t.url&&e.uint32(10).string(t.url),void 0!==t.duration&&e.uint32(17).double(t.duration),0!==t.status&&e.uint32(32).int32(t.status),void 0!==t.remainingTime&&e.uint32(40).int32(t.remainingTime),void 0!==t.unknown0&&e.uint32(48).int32(t.unknown0),""!==t.translationId&&e.uint32(58).string(t.translationId),void 0!==t.language&&e.uint32(66).string(t.language),void 0!==t.message&&e.uint32(74).string(t.message),e),decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={url:void 0,duration:void 0,status:0,remainingTime:void 0,unknown0:void 0,translationId:"",language:void 0,message:void 0};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 1:if(10!==t)break;a.url=i.string();continue;case 2:if(17!==t)break;a.duration=i.double();continue;case 4:if(32!==t)break;a.status=i.int32();continue;case 5:if(40!==t)break;a.remainingTime=i.int32();continue;case 6:if(48!==t)break;a.unknown0=i.int32();continue;case 7:if(58!==t)break;a.translationId=i.string();continue;case 8:if(66!==t)break;a.language=i.string();continue;case 9:if(74!==t)break;a.message=i.string();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({url:he(t.url)?globalThis.String(t.url):void 0,duration:he(t.duration)?globalThis.Number(t.duration):void 0,status:he(t.status)?globalThis.Number(t.status):0,remainingTime:he(t.remainingTime)?globalThis.Number(t.remainingTime):void 0,unknown0:he(t.unknown0)?globalThis.Number(t.unknown0):void 0,translationId:he(t.translationId)?globalThis.String(t.translationId):"",language:he(t.language)?globalThis.String(t.language):void 0,message:he(t.message)?globalThis.String(t.message):void 0}),toJSON(t){const e={};return void 0!==t.url&&(e.url=t.url),void 0!==t.duration&&(e.duration=t.duration),0!==t.status&&(e.status=Math.round(t.status)),void 0!==t.remainingTime&&(e.remainingTime=Math.round(t.remainingTime)),void 0!==t.unknown0&&(e.unknown0=Math.round(t.unknown0)),""!==t.translationId&&(e.translationId=t.translationId),void 0!==t.language&&(e.language=t.language),void 0!==t.message&&(e.message=t.message),e},create:t=>Kt.fromPartial(t??{}),fromPartial(t){const e={url:void 0,duration:void 0,status:0,remainingTime:void 0,unknown0:void 0,translationId:"",language:void 0,message:void 0};return e.url=t.url??void 0,e.duration=t.duration??void 0,e.status=t.status??0,e.remainingTime=t.remainingTime??void 0,e.unknown0=t.unknown0??void 0,e.translationId=t.translationId??"",e.language=t.language??void 0,e.message=t.message??void 0,e}};function Zt(){return{audioFile:new Uint8Array(0),fileId:""}}const Xt={encode:(t,e=new qt)=>(0!==t.audioFile.length&&e.uint32(18).bytes(t.audioFile),""!==t.fileId&&e.uint32(10).string(t.fileId),e),decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a=Zt();for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 2:if(18!==t)break;a.audioFile=i.bytes();continue;case 1:if(10!==t)break;a.fileId=i.string();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({audioFile:he(t.audioFile)?ce(t.audioFile):new Uint8Array(0),fileId:he(t.fileId)?globalThis.String(t.fileId):""}),toJSON(t){const e={};return 0!==t.audioFile.length&&(e.audioFile=function(t){if(globalThis.Buffer)return globalThis.Buffer.from(t).toString("base64");{const e=[];return t.forEach((t=>{e.push(globalThis.String.fromCharCode(t))})),globalThis.btoa(e.join(""))}}(t.audioFile)),""!==t.fileId&&(e.fileId=t.fileId),e},create:t=>Xt.fromPartial(t??{}),fromPartial(t){const e=Zt();return e.audioFile=t.audioFile??new Uint8Array(0),e.fileId=t.fileId??"",e}};const Qt={encode:(t,e=new qt)=>(0!==t.audioPartsLength&&e.uint32(16).int32(t.audioPartsLength),void 0!==t.audioBuffer&&Xt.encode(t.audioBuffer,e.uint32(10).fork()).join(),""!==t.fileId&&e.uint32(26).string(t.fileId),0!==t.unknown0&&e.uint32(32).int32(t.unknown0),e),decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={audioPartsLength:0,audioBuffer:void 0,fileId:"",unknown0:0};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 2:if(16!==t)break;a.audioPartsLength=i.int32();continue;case 1:if(10!==t)break;a.audioBuffer=Xt.decode(i,i.uint32());continue;case 3:if(26!==t)break;a.fileId=i.string();continue;case 4:if(32!==t)break;a.unknown0=i.int32();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({audioPartsLength:he(t.audioPartsLength)?globalThis.Number(t.audioPartsLength):0,audioBuffer:he(t.audioBuffer)?Xt.fromJSON(t.audioBuffer):void 0,fileId:he(t.fileId)?globalThis.String(t.fileId):"",unknown0:he(t.unknown0)?globalThis.Number(t.unknown0):0}),toJSON(t){const e={};return 0!==t.audioPartsLength&&(e.audioPartsLength=Math.round(t.audioPartsLength)),void 0!==t.audioBuffer&&(e.audioBuffer=Xt.toJSON(t.audioBuffer)),""!==t.fileId&&(e.fileId=t.fileId),0!==t.unknown0&&(e.unknown0=Math.round(t.unknown0)),e},create:t=>Qt.fromPartial(t??{}),fromPartial(t){const e={audioPartsLength:0,audioBuffer:void 0,fileId:"",unknown0:0};return e.audioPartsLength=t.audioPartsLength??0,e.audioBuffer=void 0!==t.audioBuffer&&null!==t.audioBuffer?Xt.fromPartial(t.audioBuffer):void 0,e.fileId=t.fileId??"",e.unknown0=t.unknown0??0,e}};const te={encode:(t,e=new qt)=>(""!==t.translationId&&e.uint32(10).string(t.translationId),""!==t.url&&e.uint32(18).string(t.url),void 0!==t.partialAudioInfo&&Qt.encode(t.partialAudioInfo,e.uint32(34).fork()).join(),void 0!==t.audioInfo&&Xt.encode(t.audioInfo,e.uint32(50).fork()).join(),e),decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={translationId:"",url:"",partialAudioInfo:void 0,audioInfo:void 0};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 1:if(10!==t)break;a.translationId=i.string();continue;case 2:if(18!==t)break;a.url=i.string();continue;case 4:if(34!==t)break;a.partialAudioInfo=Qt.decode(i,i.uint32());continue;case 6:if(50!==t)break;a.audioInfo=Xt.decode(i,i.uint32());continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({translationId:he(t.translationId)?globalThis.String(t.translationId):"",url:he(t.url)?globalThis.String(t.url):"",partialAudioInfo:he(t.partialAudioInfo)?Qt.fromJSON(t.partialAudioInfo):void 0,audioInfo:he(t.audioInfo)?Xt.fromJSON(t.audioInfo):void 0}),toJSON(t){const e={};return""!==t.translationId&&(e.translationId=t.translationId),""!==t.url&&(e.url=t.url),void 0!==t.partialAudioInfo&&(e.partialAudioInfo=Qt.toJSON(t.partialAudioInfo)),void 0!==t.audioInfo&&(e.audioInfo=Xt.toJSON(t.audioInfo)),e},create:t=>te.fromPartial(t??{}),fromPartial(t){const e={translationId:"",url:"",partialAudioInfo:void 0,audioInfo:void 0};return e.translationId=t.translationId??"",e.url=t.url??"",e.partialAudioInfo=void 0!==t.partialAudioInfo&&null!==t.partialAudioInfo?Qt.fromPartial(t.partialAudioInfo):void 0,e.audioInfo=void 0!==t.audioInfo&&null!==t.audioInfo?Xt.fromPartial(t.audioInfo):void 0,e}};const ee={encode(t,e=new qt){0!==t.status&&e.uint32(8).int32(t.status);for(const i of t.remainingChunks)e.uint32(18).string(i);return e},decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={status:0,remainingChunks:[]};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 1:if(8!==t)break;a.status=i.int32();continue;case 2:if(18!==t)break;a.remainingChunks.push(i.string());continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({status:he(t.status)?globalThis.Number(t.status):0,remainingChunks:globalThis.Array.isArray(t?.remainingChunks)?t.remainingChunks.map((t=>globalThis.String(t))):[]}),toJSON(t){const e={};return 0!==t.status&&(e.status=Math.round(t.status)),t.remainingChunks?.length&&(e.remainingChunks=t.remainingChunks),e},create:t=>ee.fromPartial(t??{}),fromPartial(t){const e={status:0,remainingChunks:[]};return e.status=t.status??0,e.remainingChunks=t.remainingChunks?.map((t=>t))||[],e}};const ie={encode:(t,e=new qt)=>(""!==t.language&&e.uint32(10).string(t.language),""!==t.url&&e.uint32(18).string(t.url),0!==t.unknown0&&e.uint32(24).int32(t.unknown0),""!==t.translatedLanguage&&e.uint32(34).string(t.translatedLanguage),""!==t.translatedUrl&&e.uint32(42).string(t.translatedUrl),0!==t.unknown1&&e.uint32(48).int32(t.unknown1),0!==t.unknown2&&e.uint32(56).int32(t.unknown2),e),decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={language:"",url:"",unknown0:0,translatedLanguage:"",translatedUrl:"",unknown1:0,unknown2:0};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 1:if(10!==t)break;a.language=i.string();continue;case 2:if(18!==t)break;a.url=i.string();continue;case 3:if(24!==t)break;a.unknown0=i.int32();continue;case 4:if(34!==t)break;a.translatedLanguage=i.string();continue;case 5:if(42!==t)break;a.translatedUrl=i.string();continue;case 6:if(48!==t)break;a.unknown1=i.int32();continue;case 7:if(56!==t)break;a.unknown2=i.int32();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({language:he(t.language)?globalThis.String(t.language):"",url:he(t.url)?globalThis.String(t.url):"",unknown0:he(t.unknown0)?globalThis.Number(t.unknown0):0,translatedLanguage:he(t.translatedLanguage)?globalThis.String(t.translatedLanguage):"",translatedUrl:he(t.translatedUrl)?globalThis.String(t.translatedUrl):"",unknown1:he(t.unknown1)?globalThis.Number(t.unknown1):0,unknown2:he(t.unknown2)?globalThis.Number(t.unknown2):0}),toJSON(t){const e={};return""!==t.language&&(e.language=t.language),""!==t.url&&(e.url=t.url),0!==t.unknown0&&(e.unknown0=Math.round(t.unknown0)),""!==t.translatedLanguage&&(e.translatedLanguage=t.translatedLanguage),""!==t.translatedUrl&&(e.translatedUrl=t.translatedUrl),0!==t.unknown1&&(e.unknown1=Math.round(t.unknown1)),0!==t.unknown2&&(e.unknown2=Math.round(t.unknown2)),e},create:t=>ie.fromPartial(t??{}),fromPartial(t){const e={language:"",url:"",unknown0:0,translatedLanguage:"",translatedUrl:"",unknown1:0,unknown2:0};return e.language=t.language??"",e.url=t.url??"",e.unknown0=t.unknown0??0,e.translatedLanguage=t.translatedLanguage??"",e.translatedUrl=t.translatedUrl??"",e.unknown1=t.unknown1??0,e.unknown2=t.unknown2??0,e}};const oe={encode:(t,e=new qt)=>(""!==t.url&&e.uint32(10).string(t.url),""!==t.language&&e.uint32(18).string(t.language),e),decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={url:"",language:""};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 1:if(10!==t)break;a.url=i.string();continue;case 2:if(18!==t)break;a.language=i.string();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({url:he(t.url)?globalThis.String(t.url):"",language:he(t.language)?globalThis.String(t.language):""}),toJSON(t){const e={};return""!==t.url&&(e.url=t.url),""!==t.language&&(e.language=t.language),e},create:t=>oe.fromPartial(t??{}),fromPartial(t){const e={url:"",language:""};return e.url=t.url??"",e.language=t.language??"",e}};const ae={encode(t,e=new qt){!1!==t.waiting&&e.uint32(8).bool(t.waiting);for(const i of t.subtitles)ie.encode(i,e.uint32(18).fork()).join();return e},decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={waiting:!1,subtitles:[]};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 1:if(8!==t)break;a.waiting=i.bool();continue;case 2:if(18!==t)break;a.subtitles.push(ie.decode(i,i.uint32()));continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({waiting:!!he(t.waiting)&&globalThis.Boolean(t.waiting),subtitles:globalThis.Array.isArray(t?.subtitles)?t.subtitles.map((t=>ie.fromJSON(t))):[]}),toJSON(t){const e={};return!1!==t.waiting&&(e.waiting=t.waiting),t.subtitles?.length&&(e.subtitles=t.subtitles.map((t=>ie.toJSON(t)))),e},create:t=>ae.fromPartial(t??{}),fromPartial(t){const e={waiting:!1,subtitles:[]};return e.waiting=t.waiting??!1,e.subtitles=t.subtitles?.map((t=>ie.fromPartial(t)))||[],e}};const ne={encode:(t,e=new qt)=>(""!==t.url&&e.uint32(10).string(t.url),""!==t.timestamp&&e.uint32(18).string(t.timestamp),e),decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={url:"",timestamp:""};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 1:if(10!==t)break;a.url=i.string();continue;case 2:if(18!==t)break;a.timestamp=i.string();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({url:he(t.url)?globalThis.String(t.url):"",timestamp:he(t.timestamp)?globalThis.String(t.timestamp):""}),toJSON(t){const e={};return""!==t.url&&(e.url=t.url),""!==t.timestamp&&(e.timestamp=t.timestamp),e},create:t=>ne.fromPartial(t??{}),fromPartial(t){const e={url:"",timestamp:""};return e.url=t.url??"",e.timestamp=t.timestamp??"",e}};const re={encode:(t,e=new qt)=>(""!==t.url&&e.uint32(10).string(t.url),""!==t.language&&e.uint32(18).string(t.language),""!==t.responseLanguage&&e.uint32(26).string(t.responseLanguage),e),decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={url:"",language:"",responseLanguage:""};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 1:if(10!==t)break;a.url=i.string();continue;case 2:if(18!==t)break;a.language=i.string();continue;case 3:if(26!==t)break;a.responseLanguage=i.string();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({url:he(t.url)?globalThis.String(t.url):"",language:he(t.language)?globalThis.String(t.language):"",responseLanguage:he(t.responseLanguage)?globalThis.String(t.responseLanguage):""}),toJSON(t){const e={};return""!==t.url&&(e.url=t.url),""!==t.language&&(e.language=t.language),""!==t.responseLanguage&&(e.responseLanguage=t.responseLanguage),e},create:t=>re.fromPartial(t??{}),fromPartial(t){const e={url:"",language:"",responseLanguage:""};return e.url=t.url??"",e.language=t.language??"",e.responseLanguage=t.responseLanguage??"",e}};const se={encode:(t,e=new qt)=>(0!==t.interval&&e.uint32(8).int32(t.interval),void 0!==t.translatedInfo&&ne.encode(t.translatedInfo,e.uint32(18).fork()).join(),void 0!==t.pingId&&e.uint32(24).int32(t.pingId),e),decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={interval:0,translatedInfo:void 0,pingId:void 0};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 1:if(8!==t)break;a.interval=i.int32();continue;case 2:if(18!==t)break;a.translatedInfo=ne.decode(i,i.uint32());continue;case 3:if(24!==t)break;a.pingId=i.int32();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({interval:he(t.interval)?Gt(t.interval):0,translatedInfo:he(t.translatedInfo)?ne.fromJSON(t.translatedInfo):void 0,pingId:he(t.pingId)?globalThis.Number(t.pingId):void 0}),toJSON(t){const e={};return 0!==t.interval&&(e.interval=function(t){switch(t){case Wt.NO_CONNECTION:return"NO_CONNECTION";case Wt.TRANSLATING:return"TRANSLATING";case Wt.STREAMING:return"STREAMING";case Wt.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(t.interval)),void 0!==t.translatedInfo&&(e.translatedInfo=ne.toJSON(t.translatedInfo)),void 0!==t.pingId&&(e.pingId=Math.round(t.pingId)),e},create:t=>se.fromPartial(t??{}),fromPartial(t){const e={interval:0,translatedInfo:void 0,pingId:void 0};return e.interval=t.interval??0,e.translatedInfo=void 0!==t.translatedInfo&&null!==t.translatedInfo?ne.fromPartial(t.translatedInfo):void 0,e.pingId=t.pingId??void 0,e}};const le={encode:(t,e=new qt)=>(0!==t.pingId&&e.uint32(8).int32(t.pingId),e),decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={pingId:0};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 1:if(8!==t)break;a.pingId=i.int32();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({pingId:he(t.pingId)?globalThis.Number(t.pingId):0}),toJSON(t){const e={};return 0!==t.pingId&&(e.pingId=Math.round(t.pingId)),e},create:t=>le.fromPartial(t??{}),fromPartial(t){const e={pingId:0};return e.pingId=t.pingId??0,e}};const de={encode:(t,e=new qt)=>(""!==t.uuid&&e.uint32(10).string(t.uuid),""!==t.module&&e.uint32(18).string(t.module),e),decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={uuid:"",module:""};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 1:if(10!==t)break;a.uuid=i.string();continue;case 2:if(18!==t)break;a.module=i.string();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({uuid:he(t.uuid)?globalThis.String(t.uuid):"",module:he(t.module)?globalThis.String(t.module):""}),toJSON(t){const e={};return""!==t.uuid&&(e.uuid=t.uuid),""!==t.module&&(e.module=t.module),e},create:t=>de.fromPartial(t??{}),fromPartial(t){const e={uuid:"",module:""};return e.uuid=t.uuid??"",e.module=t.module??"",e}};const ue={encode:(t,e=new qt)=>(""!==t.secretKey&&e.uint32(10).string(t.secretKey),0!==t.expires&&e.uint32(16).int32(t.expires),e),decode(t,e){const i=t instanceof zt?t:new zt(t);let o=void 0===e?i.len:i.pos+e;const a={secretKey:"",expires:0};for(;i.pos<o;){const t=i.uint32();switch(t>>>3){case 1:if(10!==t)break;a.secretKey=i.string();continue;case 2:if(16!==t)break;a.expires=i.int32();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return a},fromJSON:t=>({secretKey:he(t.secretKey)?globalThis.String(t.secretKey):"",expires:he(t.expires)?globalThis.Number(t.expires):0}),toJSON(t){const e={};return""!==t.secretKey&&(e.secretKey=t.secretKey),0!==t.expires&&(e.expires=Math.round(t.expires)),e},create:t=>ue.fromPartial(t??{}),fromPartial(t){const e={secretKey:"",expires:0};return e.secretKey=t.secretKey??"",e.expires=t.expires??0,e}};function ce(t){if(globalThis.Buffer)return Uint8Array.from(globalThis.Buffer.from(t,"base64"));{const e=globalThis.atob(t),i=new Uint8Array(e.length);for(let t=0;t<e.length;++t)i[t]=e.charCodeAt(t);return i}}function he(t){return null!=t}const pe=new TextEncoder;async function ge(t,e,i){const o=await async function(){return"undefined"!=typeof window&&window.crypto?window.crypto:await Promise.resolve().then((function(){var t=new Error("Cannot find module 'node:crypto'");throw t.code="MODULE_NOT_FOUND",t}))}(),a=await o.subtle.importKey("raw",pe.encode(e),{name:"HMAC",hash:{name:t}},!1,["sign","verify"]);return await o.subtle.sign("HMAC",a,i)}async function me(t){const e=await ge("SHA-256",yt.hmac,t);return new Uint8Array(e).reduce(((t,e)=>t+e.toString(16).padStart(2,"0")),"")}async function ve(t,e,i,o){const{secretKey:a,uuid:n}=e,r=await me(i),s=`${n}:${o}:${yt.componentVersion}`,l=pe.encode(s);return{[`${t}-Signature`]:r,[`Sec-${t}-Sk`]:a,[`Sec-${t}-Token`]:`${await me(l)}:${s}`}}const fe={afr:"af",aka:"ak",alb:"sq",amh:"am",ara:"ar",arm:"hy",asm:"as",aym:"ay",aze:"az",baq:"eu",bel:"be",ben:"bn",bos:"bs",bul:"bg",bur:"my",cat:"ca",chi:"zh",cos:"co",cze:"cs",dan:"da",div:"dv",dut:"nl",eng:"en",epo:"eo",est:"et",ewe:"ee",fin:"fi",fre:"fr",fry:"fy",geo:"ka",ger:"de",gla:"gd",gle:"ga",glg:"gl",gre:"el",grn:"gn",guj:"gu",hat:"ht",hau:"ha",hin:"hi",hrv:"hr",hun:"hu",ibo:"ig",ice:"is",ind:"id",ita:"it",jav:"jv",jpn:"ja",kan:"kn",kaz:"kk",khm:"km",kin:"rw",kir:"ky",kor:"ko",kur:"ku",lao:"lo",lat:"la",lav:"lv",lin:"ln",lit:"lt",ltz:"lb",lug:"lg",mac:"mk",mal:"ml",mao:"mi",mar:"mr",may:"ms",mlg:"mg",mlt:"mt",mon:"mn",nep:"ne",nor:"no",nya:"ny",ori:"or",orm:"om",pan:"pa",per:"fa",pol:"pl",por:"pt",pus:"ps",que:"qu",rum:"ro",rus:"ru",san:"sa",sin:"si",slo:"sk",slv:"sl",smo:"sm",sna:"sn",snd:"sd",som:"so",sot:"st",spa:"es",srp:"sr",sun:"su",swa:"sw",swe:"sv",tam:"ta",tat:"tt",tel:"te",tgk:"tg",tha:"th",tir:"ti",tso:"ts",tuk:"tk",tur:"tr",uig:"ug",ukr:"uk",urd:"ur",uzb:"uz",vie:"vi",wel:"cy",xho:"xh",yid:"yi",yor:"yo",zul:"zu"};async function be(t,e={headers:{"User-Agent":yt.userAgent}}){const{timeout:i=3e3,...o}=e,a=new AbortController,n=setTimeout((()=>a.abort()),i),r=await fetch(t,{signal:a.signal,...o});return clearTimeout(n),r}function we(t){return 3===t.length?fe[t]:t.toLowerCase().split(/[_;-]/)[0].trim()}function ye(t,e="mp4"){const i=`https://${yt.mediaProxy}/v1/proxy/video.${e}?format=base64&force=true`;return t instanceof URL?`${i}&url=${btoa(t.href)}&origin=${t.origin}&referer=${t.origin}`:`${i}&url=${btoa(t)}`}class xe{static encodeTranslationRequest(t,e,i,o,a,{forceSourceLang:n=!1,wasStream:r=!1,videoTitle:s="",bypassCache:l=!1,useNewModel:d=!0}={}){return Jt.encode({url:t,firstRequest:!0,duration:e,unknown0:1,language:i,forceSourceLang:n,unknown1:0,translationHelp:a||[],responseLanguage:o,wasStream:r,unknown2:1,unknown3:1,bypassCache:l,useNewModel:d,videoTitle:s}).finish()}static decodeTranslationResponse(t){return Kt.decode(new Uint8Array(t))}static encodeTranslationAudioRequest(t,e,i,o){return te.encode({url:t,translationId:e,...o?{partialAudioInfo:{...o,audioBuffer:i}}:{audioInfo:i}}).finish()}static decodeTranslationAudioResponse(t){return ee.decode(new Uint8Array(t))}static encodeSubtitlesRequest(t,e){return oe.encode({url:t,language:e}).finish()}static decodeSubtitlesResponse(t){return ae.decode(new Uint8Array(t))}static encodeStreamPingRequest(t){return le.encode({pingId:t}).finish()}static encodeStreamRequest(t,e,i){return re.encode({url:t,language:e,responseLanguage:i}).finish()}static decodeStreamResponse(t){return se.decode(new Uint8Array(t))}}class Se{static encodeSessionRequest(t,e){return de.encode({uuid:t,module:e}).finish()}static decodeSessionResponse(t){return ue.decode(new Uint8Array(t))}}var ke,Te,Ce;!function(t){t[t.FAILED=0]="FAILED",t[t.FINISHED=1]="FINISHED",t[t.WAITING=2]="WAITING",t[t.LONG_WAITING=3]="LONG_WAITING",t[t.PART_CONTENT=5]="PART_CONTENT",t[t.AUDIO_REQUESTED=6]="AUDIO_REQUESTED"}(ke||(ke={})),function(t){t.WEB_API_GET_ALL_GENERATING_URLS_DATA_FROM_IFRAME="web_api_get_all_generating_urls_data_from_iframe",t.WEB_API_REPLACED_FETCH_INSIDE_IFRAME="web_api_replaced_fetch_inside_iframe",t.WEB_API_REPLACED_FETCH_FORCE_REQUEST_WITH_SEEK="web_api_replaced_fetch_force_request_with_seek",t.WEB_API_REPLACED_FETCH="web_api_replaced_fetch",t.ANDROID_API="android_api",t.WEB_API_SLOW="web_api_slow"}(Te||(Te={})),function(t){t.custom="custom",t.directlink="custom",t.youtube="youtube",t.piped="piped",t.invidious="invidious",t.vk="vk",t.nine_gag="nine_gag",t.gag="nine_gag",t.twitch="twitch",t.proxitok="proxitok",t.tiktok="tiktok",t.vimeo="vimeo",t.xvideos="xvideos",t.pornhub="pornhub",t.twitter="twitter",t.x="twitter",t.rumble="rumble",t.facebook="facebook",t.rutube="rutube",t.coub="coub",t.bilibili="bilibili",t.mail_ru="mailru",t.mailru="mailru",t.bitchute="bitchute",t.eporner="eporner",t.peertube="peertube",t.dailymotion="dailymotion",t.trovo="trovo",t.yandexdisk="yandexdisk",t.ok_ru="okru",t.okru="okru",t.googledrive="googledrive",t.bannedvideo="bannedvideo",t.weverse="weverse",t.newgrounds="newgrounds",t.egghead="egghead",t.youku="youku",t.archive="archive",t.kodik="kodik",t.patreon="patreon",t.reddit="reddit",t.kick="kick",t.apple_developer="apple_developer",t.appledeveloper="apple_developer",t.poketube="poketube",t.epicgames="epicgames",t.nineanimetv="nineanimetv",t.odysee="odysee",t.coursehunterLike="coursehunterLike",t.sap="sap",t.watchpornto="watchpornto",t.linkedin="linkedin",t.ricktube="ricktube",t.incestflix="incestflix",t.porntn="porntn",t.dzen="dzen",t.cloudflarestream="cloudflarestream",t.loom="loom",t.rtnews="rtnews",t.bitview="bitview"}(Ce||(Ce={}));const Ie=JSON.parse('{"recommended":"recommended","translateVideo":"Translate video","disableTranslate":"Turn off","translationSettings":"Translation settings","subtitlesSettings":"Subtitles settings","about":"About extension","resetSettings":"Reset settings","videoBeingTranslated":"The video is being translated","videoLanguage":"Video language","translationLanguage":"Translation language","translationTake":"The translation will take","translationTakeMoreThanHour":"The translation will take more than an hour","translationTakeAboutMinute":"The translation will take about a minute","translationTakeFewMinutes":"The translation will take a few minutes","translationTakeApproximatelyMinutes":"The translation will take approximately {0} minutes","translationTakeApproximatelyMinute":"The translation will take approximately {0} minutes","requestTranslationFailed":"Failed to request video translation","audioNotReceived":"Audio link not received","audioFormatNotSupported":"The audio format is not supported","VOTAutoTranslate":"Translate on open","VOTDontTranslateYourLang":"Don\'t translate from my language","VOTVolume":"Video volume","VOTVolumeTranslation":"Translation Volume","VOTAutoSetVolume":"Reduce video volume to ","VOTShowVideoSlider":"Video volume slider","VOTSyncVolume":"Link translation and video volume","VOTDisableFromYourLang":"You have disabled the translation of the video in your language","VOTVideoIsTooLong":"Video is too long","VOTNoVideoIDFound":"No video ID found","VOTSubtitles":"Subtitles","VOTSubtitlesDisabled":"Disabled","VOTSubtitlesMaxLength":"Subtitles max length","VOTHighlightWords":"Highlight words","VOTTranslatedFrom":"translated from","VOTAutogenerated":"autogenerated","VOTSettings":"VOT Settings","VOTMenuLanguage":"Menu language","VOTAuthors":"Authors","VOTVersion":"Version","VOTLoader":"Loader","VOTBrowser":"Browser","VOTShowPiPButton":"Show PiP button","langs":{"auto":"Auto","af":"Afrikaans","ak":"Akan","sq":"Albanian","am":"Amharic","ar":"Arabic","hy":"Armenian","as":"Assamese","ay":"Aymara","az":"Azerbaijani","bn":"Bangla","eu":"Basque","be":"Belarusian","bho":"Bhojpuri","bs":"Bosnian","bg":"Bulgarian","my":"Burmese","ca":"Catalan","ceb":"Cebuano","zh":"Chinese","zh-Hans":"Chinese (Simplified)","zh-Hant":"Chinese (Traditional)","co":"Corsican","hr":"Croatian","cs":"Czech","da":"Danish","dv":"Divehi","nl":"Dutch","en":"English","eo":"Esperanto","et":"Estonian","ee":"Ewe","fil":"Filipino","fi":"Finnish","fr":"French","gl":"Galician","lg":"Ganda","ka":"Georgian","de":"German","el":"Greek","gn":"Guarani","gu":"Gujarati","ht":"Haitian Creole","ha":"Hausa","haw":"Hawaiian","iw":"Hebrew","hi":"Hindi","hmn":"Hmong","hu":"Hungarian","is":"Icelandic","ig":"Igbo","id":"Indonesian","ga":"Irish","it":"Italian","ja":"Japanese","jv":"Javanese","kn":"Kannada","kk":"Kazakh","km":"Khmer","rw":"Kinyarwanda","ko":"Korean","kri":"Krio","ku":"Kurdish","ky":"Kyrgyz","lo":"Lao","la":"Latin","lv":"Latvian","ln":"Lingala","lt":"Lithuanian","lb":"Luxembourgish","mk":"Macedonian","mg":"Malagasy","ms":"Malay","ml":"Malayalam","mt":"Maltese","mi":"Māori","mr":"Marathi","mn":"Mongolian","ne":"Nepali","nso":"Northern Sotho","no":"Norwegian","ny":"Nyanja","or":"Odia","om":"Oromo","ps":"Pashto","fa":"Persian","pl":"Polish","pt":"Portuguese","pa":"Punjabi","qu":"Quechua","ro":"Romanian","ru":"Russian","sm":"Samoan","sa":"Sanskrit","gd":"Scottish Gaelic","sr":"Serbian","sn":"Shona","sd":"Sindhi","si":"Sinhala","sk":"Slovak","sl":"Slovenian","so":"Somali","st":"Southern Sotho","es":"Spanish","su":"Sundanese","sw":"Swahili","sv":"Swedish","tg":"Tajik","ta":"Tamil","tt":"Tatar","te":"Telugu","th":"Thai","ti":"Tigrinya","ts":"Tsonga","tr":"Turkish","tk":"Turkmen","uk":"Ukrainian","ur":"Urdu","ug":"Uyghur","uz":"Uzbek","vi":"Vietnamese","cy":"Welsh","fy":"Western Frisian","xh":"Xhosa","yi":"Yiddish","yo":"Yoruba","zu":"Zulu"},"streamNoConnectionToServer":"There is no connection to the server","searchField":"Search...","VOTTranslateAPIErrors":"Translate errors from the API","VOTDetectService":"Language detection service","VOTProxyWorkerHost":"Enter the proxy worker address","VOTM3u8ProxyHost":"Enter the address of the m3u8 proxy worker","proxySettings":"Proxy Settings","translationTakeApproximatelyMinute2":"The translation will take approximately {0} minutes","VOTAudioBooster":"Extended translation volume increase","VOTSubtitlesDesign":"Subtitles design","VOTSubtitlesFontSize":"Font size of subtitles","VOTSubtitlesOpacity":"Transparency of the subtitle background","VOTPressNewHotkey":"Press the new hotkey...","VOTCreateTranslationHotkey":"Create Hotkey for Translation","VOTChangeHotkeyWithCurrent":"Change Hotkey (Current: {0})","VOTSubtitlesDownloadFormat":"The format for downloading subtitles","VOTDownloadWithName":"Download files with the video name","VOTUpdateLocaleFiles":"Update localization files","VOTLocaleHash":"Locale hash","VOTUpdatedAt":"Updated at","VOTNeedWebAudioAPI":"To enable this, you must have a Web Audio API","VOTMediaCSPEnabledOnSite":"Media CSP is enabled on this site","VOTOnlyBypassMediaCSP":"Use it only for bypassing Media CSP","VOTNewAudioPlayer":"Use the new audio player","VOTUseNewModel":"Use an experimental variation of Yandex voices for some videos","VOTTranslationErrorsService":"Error translation service","TranslationDelayed":"The translation is slightly delayed","VOTTranslationCompletedNotify":"The translation on the {0} has been completed!","VOTSendNotifyOnComplete":"Send a notification that the video has been translated","VOTBugReport":"Report a bug","VOTTranslateProxyDisabled":"Disabled","VOTTranslateProxyEnabled":"Enabled","VOTTranslateProxyEverything":"Proxy everything","VOTTranslateProxyStatus":"Proxying mode"}'),Pe={log:(...t)=>{}},Le="media-proxy.toil.cc/v1/proxy/m3u8",_e="vot-worker.toil.cc",Ae=.15,Oe="yandexbrowser",Ve="yandexbrowser",Me=["FireMonkey","Greasemonkey","AdGuard","OrangeMonkey","Userscripts","Other (Polyfill)"];async function Ee(t,e,i,o,a=void 0){(a??t[e])===i&&(t[e]=o,await Be.set(e,o),console.log(`[VOT] Old ${e} converted to new ${o}`))}const Be=new class{gmSupport;constructor(){this.gmSupport="function"==typeof GM_getValue,Pe.log(`GM Storage Status: ${this.gmSupport}`)}syncGet(t,e=void 0){if(this.gmSupport)return GM_getValue(t,e);const i="number"==typeof e;const o=window.localStorage.getItem(t)??e;return i?Number(o):o}async get(t,e=void 0){return this.gmSupport?await GM_getValue(t,e):Promise.resolve(this.syncGet(t,e))}syncSet(t,e){return this.gmSupport?GM_setValue(t,e):window.localStorage.setItem(t,e)}async set(t,e){return this.gmSupport?await GM_setValue(t,e):Promise.resolve(this.syncSet(t,e))}syncDelete(t){return this.gmSupport?GM_deleteValue(t):window.localStorage.removeItem(t)}async delete(t){return this.gmSupport?await GM_deleteValue(t):Promise.resolve(this.syncDelete(t))}syncList(){return this.gmSupport?GM_listValues():["autoTranslate","dontTranslateLanguage","dontTranslateYourLang","autoSetVolumeYandexStyle","autoVolume","buttonPos","showVideoSlider","syncVolume","subtitlesMaxLength","highlightWords","responseLanguage","defaultVolume","audioProxy","showPiPButton","translateAPIErrors","translationService","detectService","m3u8ProxyHost","translateProxyEnabled","hotkeyButton","proxyWorkerHost","audioBooster","locale-version","locale-lang","locale-phrases"]}async list(){return this.gmSupport?await GM_listValues():Promise.resolve(this.syncList())}},Ne=navigator.language||navigator.userLanguage,$e=Ne?.substring(0,2).toLowerCase()||"en";function Re(){return"pictureInPictureEnabled"in document&&document.pictureInPictureEnabled}function De(){return"undefined"!=typeof Hls&&Hls?.isSupported()?new Hls({debug:!1,lowLatencyMode:!0,backBufferLength:90}):void 0}const Fe=new RegExp([/(?:https?|www|\bhttp\s+)[^\s/]*?(?:\.\s*[a-z]{2,}|\/)[^\s]*/gi,/#[^\s#]+|Auto-generated\s+by\s+YouTube|Provided\s+to\s+YouTube\s+by|Released\s+on|PayPal?/gi,/0x[\da-f]{40}|[13][a-km-zA-HJ-NP-Z1-9]{25,34}|4[0-9AB][1-9A-HJ-NP-Za-km-z]{93}/g].map((t=>t.source)).join("|"),"gi");function Ue(t,e){const i=URL.createObjectURL(t),o=document.createElement("a");o.href=i,o.download=e,o.click(),URL.revokeObjectURL(i)}function qe(t){return 0===t.trim().length?(new Date).toLocaleDateString("en-us").replaceAll("/","-"):t.replace(/[\\/:*?"'<>|]/g,"")}async function ze(t,e={}){const{timeout:i=15e3,...o}=e,a=new AbortController;try{if(t.includes("api.browser.yandex.ru"))throw new Error("Preventing yandex cors");return await fetch(t,{signal:a.signal,...o})}catch(e){return Pe.log("GM_fetch preventing CORS by GM_xmlhttpRequest",e.message),new Promise(((e,a)=>{GM_xmlhttpRequest({method:o.method||"GET",url:t,responseType:"blob",data:o.body,timeout:i,headers:o.headers||{},onload:t=>{const i=t.responseHeaders.split(/\r?\n/).reduce(((t,e)=>{const[,i,o]=e.match(/^([\w-]+): (.+)$/)||[];return i&&(t[i]=o),t}),{}),o=new Response(t.response,{status:t.status,headers:i});Object.defineProperty(o,"url",{value:t.finalUrl??""}),e(o)},ontimeout:()=>a(new Error("Timeout")),onerror:t=>a(new Error(t)),onabort:()=>a(new Error("AbortError"))})}))}}function He(){return Math.floor(Date.now()/1e3)}const je="https://raw.githubusercontent.com/ilyhalight/voice-over-translation/master/src/localization",We=["auto","en","ru","af","am","ar","az","bg","bn","bs","ca","cs","cy","da","de","el","es","et","eu","fa","fi","fr","gl","hi","hr","hu","hy","id","it","ja","jv","kk","km","kn","ko","lo","mk","ml","mn","ms","mt","my","ne","nl","pa","pl","pt","ro","si","sk","sl","sq","sr","su","sv","sw","tr","uk","ur","uz","vi","zh","zu"];const Ge=new class{constructor(){this.gmValues=["locale-phrases","locale-lang","locale-hash","locale-updated-at","locale-lang-override"],this.lang=this.getLang(),this.locale={},this.setLocaleFromJsonString(Be.syncGet("locale-phrases",""))}getLang(){const t=Be.syncGet("locale-lang-override","auto");return"auto"!==t?t:$e}reset(){for(const t of this.gmValues)Be.syncDelete(t)}async checkUpdates(t=!1){Pe.log("Check locale updates...");try{const e=await ze(`${je}/hashes.json${t?`?timestamp=${He()}`:""}`);if(!e.ok)throw e.status;const i=await e.json();return await Be.get("locale-hash")!==i[this.lang]&&i[this.lang]}catch(t){return console.error("[VOT] [localizationProvider] Failed to get locales hash:",t),!1}}async update(t=!1){const e=await Be.get("locale-updated-at",0);if(!t&&e+7200>He()&&await Be.get("locale-lang")===this.lang)return;const i=await this.checkUpdates(t);if(await Be.set("locale-updated-at",He()),i){Pe.log("Updating locale...");try{const e=await ze(`${je}/locales/${this.lang}.json${t?`?timestamp=${He()}`:""}`);if(!e.ok)throw e.status;const o=await e.text();await Be.set("locale-phrases",o),await Be.set("locale-hash",i),await Be.set("locale-lang",this.lang),this.setLocaleFromJsonString(o)}catch(t){console.error("[VOT] [localizationProvider] Failed to get locale:",t),this.setLocaleFromJsonString(await Be.get("locale-phrases",""))}}}setLocaleFromJsonString(t){try{this.locale=JSON.parse(t)||{}}catch(t){console.error("[VOT] [localizationProvider]",t),this.locale={}}}getFromLocale(t,e){return e.split(".").reduce(((t,e)=>t?.[e]),t)??this.warnMissingKey(t,e)}warnMissingKey(t,e){console.warn("[VOT] [localizationProvider] locale",t,"doesn't contain key",e)}getDefault(t){return this.getFromLocale(Ie,t)??t}get(t){return this.getFromLocale(this.locale,t)??this.getDefault(t)}};class Ye extends Error{constructor(t){super(Ge.getDefault(t)),this.name="VOTLocalizedError",this.unlocalizedMessage=t,this.localizedMessage=Ge.get(t)}}class Je extends Error{data;constructor(t,e=void 0){super(t),this.data=e,this.name="VOTJSError",this.message=t}}class Ke{host;schema;fetch;fetchOpts;sessions={};userAgent=yt.userAgent;headers={"User-Agent":this.userAgent,Accept:"application/x-protobuf","Accept-Language":"en","Content-Type":"application/x-protobuf",Pragma:"no-cache","Cache-Control":"no-cache"};hostSchemaRe=/(http(s)?):\/\//;constructor({host:t=yt.host,fetchFn:e=be,fetchOpts:i={},headers:o={}}={}){const a=this.hostSchemaRe.exec(t)?.[1];this.host=a?t.replace(`${a}://`,""):t,this.schema=a??"https",this.fetch=e,this.fetchOpts=i,this.headers={...this.headers,...o}}async request(t,e,i={},o="POST"){const a=this.getOpts(new Blob([e]),i,o);try{const e=await this.fetch(`${this.schema}://${this.host}${t}`,a),i=await e.arrayBuffer();return{success:200===e.status,data:i}}catch(t){return{success:!1,data:t?.message}}}async requestJSON(t,e=null,i={},o="POST"){const a=this.getOpts(e,{"Content-Type":"application/json",...i},o);try{const e=await this.fetch(`${this.schema}://${this.host}${t}`,a),i=await e.json();return{success:200===e.status,data:i}}catch(t){return{success:!1,data:t?.message}}}getOpts(t,e={},i="POST"){return{method:i,headers:{...this.headers,...e},body:t,...this.fetchOpts}}async getSession(t){const e=Math.floor(Date.now()/1e3),i=this.sessions[t];if(i&&i.timestamp+i.expires>e)return i;const{secretKey:o,expires:a,uuid:n}=await this.createSession(t);return this.sessions[t]={secretKey:o,expires:a,timestamp:e,uuid:n},this.sessions[t]}async createSession(t){const e=function(){let t="";for(let e=0;e<32;e++)t+="0123456789ABCDEF"[Math.floor(16*Math.random())];return t}(),i=Se.encodeSessionRequest(e,t),o=await this.request("/session/create",i,{"Vtrans-Signature":await me(i)});if(!o.success)throw new Je("Failed to request create session",o);return{...Se.decodeSessionResponse(o.data),uuid:e}}}class Ze extends Ke{hostVOT;schemaVOT;requestLang;responseLang;paths={videoTranslation:"/video-translation/translate",videoTranslationFailAudio:"/video-translation/fail-audio-js",videoTranslationAudio:"/video-translation/audio",videoSubtitles:"/video-subtitles/get-subtitles",streamPing:"/stream-translation/ping-stream",streamTranslation:"/stream-translation/translate-stream"};isCustomLink(t){return!!(/\.(m3u8|m4(a|v)|mpd)/.exec(t)??/^https:\/\/cdn\.qstv\.on\.epicgames\.com/.exec(t))}headersVOT={"User-Agent":`vot.js/${yt.version}`,"Content-Type":"application/json",Pragma:"no-cache","Cache-Control":"no-cache"};constructor({host:t,hostVOT:e=yt.hostVOT,fetchFn:i,fetchOpts:o,requestLang:a="en",responseLang:n="ru",headers:r}={}){super({host:t,fetchFn:i,fetchOpts:o,headers:r});const s=this.hostSchemaRe.exec(e)?.[1];this.hostVOT=s?e.replace(`${s}://`,""):e,this.schemaVOT=s??"https",this.requestLang=a,this.responseLang=n}async requestVOT(t,e,i={}){const o=this.getOpts(JSON.stringify(e),{...this.headersVOT,...i});try{const e=await this.fetch(`${this.schemaVOT}://${this.hostVOT}${t}`,o),i=await e.json();return{success:200===e.status,data:i}}catch(t){return{success:!1,data:t?.message}}}async translateVideoYAImpl({videoData:t,requestLang:e=this.requestLang,responseLang:i=this.responseLang,translationHelp:o=null,headers:a={},extraOpts:n={},shouldSendFailedAudio:r=!0}){const{url:s,duration:l=yt.defaultDuration}=t,d=await this.getSession("video-translation"),u=xe.encodeTranslationRequest(s,l,e,i,o,n),c=this.paths.videoTranslation,h=await ve("Vtrans",d,u,c),p=await this.request(c,u,{...h,...a});if(!p.success)throw new Ye("requestTranslationFailed");const g=xe.decodeTranslationResponse(p.data);St.log("translateVideo",g);const{status:m,translationId:v}=g;switch(m){case ke.FAILED:throw g?.message?new Je("Yandex couldn't translate video",g):new Ye("requestTranslationFailed");case ke.FINISHED:case ke.PART_CONTENT:if(!g.url)throw new Ye("audioNotReceived");return{translationId:v,translated:!0,url:g.url,status:m,remainingTime:g.remainingTime??-1};case ke.WAITING:case ke.LONG_WAITING:return{translationId:v,translated:!1,status:m,remainingTime:g.remainingTime};case ke.AUDIO_REQUESTED:return s.startsWith("https://youtu.be/")&&r?(await this.requestVtransFailAudio(s),await this.requestVtransAudio(s,g.translationId,{audioFile:new Uint8Array,fileId:Te.WEB_API_GET_ALL_GENERATING_URLS_DATA_FROM_IFRAME}),await this.translateVideoYAImpl({videoData:t,requestLang:e,responseLang:i,translationHelp:o,headers:a,shouldSendFailedAudio:!1})):{translationId:v,translated:!1,status:m,remainingTime:g.remainingTime??-1};default:throw St.error("Unknown response",g),new Je("Unknown response from Yandex",g)}}async translateVideoVOTImpl({url:t,videoId:e,service:i,requestLang:o=this.requestLang,responseLang:a=this.responseLang,headers:n={}}){const r=function(t,e,i){return t===Ce.patreon?{service:"mux",videoId:new URL(i).pathname.slice(1)}:{service:t,videoId:e}}(i,e,t),s=await this.requestVOT(this.paths.videoTranslation,{provider:"yandex",service:r.service,videoId:r.videoId,fromLang:o,toLang:a,rawVideo:t},n);if(!s.success)throw new Ye("requestTranslationFailed");const l=s.data;switch(l.status){case"failed":throw new Je("Yandex couldn't translate video",l);case"success":if(!l.translatedUrl)throw new Ye("audioNotReceived");return{translationId:String(l.id),translated:!0,url:l.translatedUrl,status:1,remainingTime:-1};case"waiting":return{translationId:"",translated:!1,remainingTime:l.remainingTime,status:2,message:l.message}}}async requestVtransFailAudio(t){const e=await this.requestJSON(this.paths.videoTranslationFailAudio,JSON.stringify({video_url:t}),void 0,"PUT");if(!e.data||"string"==typeof e.data||1!==e.data.status)throw new Je("Failed to request to fake video translation fail audio js",e);return e}async requestVtransAudio(t,e,i,o,a={}){const n=await this.getSession("video-translation"),r=xe.encodeTranslationAudioRequest(t,e,i,o),s=this.paths.videoTranslationAudio,l=await ve("Vtrans",n,r,s),d=await this.request(s,r,{...l,...a},"PUT");if(!d.success)throw new Je("Failed to request video translation audio",d);return xe.decodeTranslationAudioResponse(d.data)}async translateVideo({videoData:t,requestLang:e=this.requestLang,responseLang:i=this.responseLang,translationHelp:o=null,headers:a={},extraOpts:n={},shouldSendFailedAudio:r=!0}){const{url:s,videoId:l,host:d}=t;return this.isCustomLink(s)?await this.translateVideoVOTImpl({url:s,videoId:l,service:d,requestLang:e,responseLang:i,headers:a}):await this.translateVideoYAImpl({videoData:t,requestLang:e,responseLang:i,translationHelp:o,headers:a,extraOpts:n,shouldSendFailedAudio:r})}async getSubtitles({videoData:t,requestLang:e=this.requestLang,headers:i={}}){const{url:o}=t;if(this.isCustomLink(o))return{waiting:!1,subtitles:[]};const a=await this.getSession("video-translation"),n=xe.encodeSubtitlesRequest(o,e),r=this.paths.videoSubtitles,s=await ve("Vsubs",a,n,r),l=await this.request(r,n,{...s,...i});if(!l.success)throw new Je("Failed to request video subtitles",l);return xe.decodeSubtitlesResponse(l.data)}async pingStream({pingId:t,headers:e={}}){const i=await this.getSession("video-translation"),o=xe.encodeStreamPingRequest(t),a=this.paths.streamPing,n=await ve("Vtrans",i,o,a),r=await this.request(a,o,{...n,...e});if(!r.success)throw new Je("Failed to request stream ping",r);return!0}async translateStream({videoData:t,requestLang:e=this.requestLang,responseLang:i=this.responseLang,headers:o={}}){const{url:a}=t;if(this.isCustomLink(a))throw new Ye("VOTStreamNotSupportedUrl");const n=await this.getSession("video-translation"),r=xe.encodeStreamRequest(a,e,i),s=this.paths.streamTranslation,l=await ve("Vtrans",n,r,s),d=await this.request(s,r,{...l,...o});if(!d.success)throw new Je("Failed to request stream translation",d);const u=xe.decodeStreamResponse(d.data),c=u.interval;switch(c){case Wt.NO_CONNECTION:case Wt.TRANSLATING:return{translated:!1,interval:c,message:c===Wt.NO_CONNECTION?"streamNoConnectionToServer":"translationTakeFewMinutes"};case Wt.STREAMING:return{translated:!0,interval:c,pingId:u.pingId,result:u.translatedInfo};default:throw St.error("Unknown response",u),new Je("Unknown response from Yandex",u)}}}class Xe extends Ze{constructor(t={}){t.host=t.host??yt.hostWorker,super(t)}async request(t,e,i={},o="POST"){const a=this.getOpts(JSON.stringify({headers:{...this.headers,...i},body:Array.from(e)}),{"Content-Type":"application/json"},o);try{const e=await this.fetch(`${this.schema}://${this.host}${t}`,a),i=await e.arrayBuffer();return{success:200===e.status,data:i}}catch(t){return{success:!1,data:t?.message}}}async requestJSON(t,e=null,i={},o="POST"){const a=this.getOpts(JSON.stringify({headers:{...this.headers,"Content-Type":"application/json",Accept:"application/json",...i},body:e}),{Accept:"application/json","Content-Type":"application/json"},o);try{const e=await this.fetch(`${this.schema}://${this.host}${t}`,a),i=await e.json();return{success:200===e.status,data:i}}catch(t){return{success:!1,data:t?.message}}}}const{componentVersion:Qe}=yt,ti={"sec-ch-ua":`"Chromium";v="130", "YaBrowser";v="${Qe.slice(0,5)}", "Not?A_Brand";v="99", "Yowser";v="2.5"`,"sec-ch-ua-full-version-list":`"Chromium";v="130.0.6723.152", "YaBrowser";v="${Qe}", "Not?A_Brand";v="99.0.0.0", "Yowser";v="2.5"`,"Sec-Fetch-Mode":"no-cors"};class ei extends Ze{constructor(t){super(t),this.headers={...ti,...this.headers}}}class ii extends Xe{constructor(t){super(t),this.headers={...ti,...this.headers}}}class oi extends Error{constructor(t){super(t),this.name="VideoDataError",this.message=t}}const ai=/(file:\/\/(\/)?|(http(s)?:\/\/)(127\.0\.0\.1|localhost|192\.168\.(\d){1,3}\.(\d){1,3}))/;var ni;!function(t){t.udemy="udemy",t.coursera="coursera",t.douyin="douyin",t.artstation="artstation"}(ni||(ni={}));const ri=[{additionalData:"mobile",host:Ce.youtube,url:"https://youtu.be/",match:/^m.youtube.com$/,selector:"shorts-video #player",needExtraData:!0},{additionalData:"mobile",host:Ce.youtube,url:"https://youtu.be/",match:/^m.youtube.com$/,selector:".player-container",needExtraData:!0},{host:Ce.youtube,url:"https://youtu.be/",match:/^(www.)?youtube(-nocookie|kids)?.com$/,selector:".html5-video-container:not(#inline-player *)",needExtraData:!0},{host:Ce.invidious,url:"https://youtu.be/",match:["yewtu.be","yt.artemislena.eu","invidious.flokinet.to","iv.melmac.space","inv.nadeko.net","inv.tux.pizza","invidious.private.coffee","yt.drgnz.club","vid.puffyan.us","invidious.dhusch.de"],selector:"#player",needBypassCSP:!0},{host:Ce.piped,url:"https://youtu.be/",match:["piped.video","piped.tokhmi.xyz","piped.moomoo.me","piped.syncpundit.io","piped.mha.fi","watch.whatever.social","piped.garudalinux.org","efy.piped.pages.dev","watch.leptons.xyz","piped.lunar.icu","yt.dc09.ru","piped.mint.lgbt","il.ax","piped.privacy.com.de","piped.esmailelbob.xyz","piped.projectsegfau.lt","piped.in.projectsegfau.lt","piped.us.projectsegfau.lt","piped.privacydev.net","piped.palveluntarjoaja.eu","piped.smnz.de","piped.adminforge.de","piped.qdi.fi","piped.hostux.net","piped.chauvet.pro","piped.jotoma.de","piped.pfcd.me","piped.frontendfriendly.xyz"],selector:".shaka-video-container",needBypassCSP:!0},{host:Ce.poketube,url:"https://youtu.be/",match:["poketube.fun","pt.sudovanilla.org","poke.ggtyler.dev","poke.uk2.littlekai.co.uk","poke.blahai.gay"],selector:".video-player-container"},{host:Ce.ricktube,url:"https://youtu.be/",match:["ricktube.ru"],selector:"#oframeplayer > pjsdiv:has(video)"},{additionalData:"mobile",host:Ce.vk,url:"https://vk.com/video?z=",match:[/^m.vk.(com|ru)$/,/^m.vkvideo.ru$/],selector:"vk-video-player",shadowRoot:!0,needExtraData:!0},{additionalData:"clips",host:Ce.vk,url:"https://vk.com/video?z=",match:/^(www.|m.)?vk.(com|ru)$/,selector:'div[data-testid="clipcontainer-video"]',needExtraData:!0},{host:Ce.vk,url:"https://vk.com/video?z=",match:[/^(www.|m.)?vk.(com|ru)$/,/^(www.|m.)?vkvideo.ru$/],selector:".videoplayer_media",needExtraData:!0},{host:Ce.nine_gag,url:"https://9gag.com/gag/",match:/^9gag.com$/,selector:".video-post"},{host:Ce.twitch,url:"https://twitch.tv/",match:[/^m.twitch.tv$/,/^(www.)?twitch.tv$/,/^clips.twitch.tv$/,/^player.twitch.tv$/],selector:".video-ref, main > div > section > div > div > div"},{host:Ce.proxitok,url:"https://www.tiktok.com/",match:["proxitok.pabloferreiro.es","proxitok.pussthecat.org","tok.habedieeh.re","proxitok.esmailelbob.xyz","proxitok.privacydev.net","tok.artemislena.eu","tok.adminforge.de","tt.vern.cc","cringe.whatever.social","proxitok.lunar.icu","proxitok.privacy.com.de"],selector:".column.has-text-centered"},{host:Ce.tiktok,url:"https://www.tiktok.com/",match:/^(www.)?tiktok.com$/,selector:null},{host:ni.douyin,url:"https://www.douyin.com/",match:/^(www.)?douyin.com/,selector:".xg-video-container",needExtraData:!0,needBypassCSP:!0},{host:Ce.vimeo,url:"https://vimeo.com/",match:/^vimeo.com$/,needExtraData:!0,selector:".player"},{host:Ce.vimeo,url:"https://player.vimeo.com/",match:/^player.vimeo.com$/,additionalData:"embed",needExtraData:!0,needBypassCSP:!0,selector:".player"},{host:Ce.xvideos,url:"https://www.xvideos.com/",match:[/^(www.)?xvideos(-ar)?.com$/,/^(www.)?xvideos(\d\d\d).com$/,/^(www.)?xv-ru.com$/],selector:"#hlsplayer",needBypassCSP:!0},{host:Ce.pornhub,url:"https://rt.pornhub.com/view_video.php?viewkey=",match:/^[a-z]+.pornhub.com$/,selector:".mainPlayerDiv > .video-element-wrapper-js > div",eventSelector:".mgp_eventCatcher"},{additionalData:"embed",host:Ce.pornhub,url:"https://rt.pornhub.com/view_video.php?viewkey=",match:t=>t.host.includes("pornhub.com")&&t.pathname.startsWith("/embed/"),selector:"#player"},{host:Ce.twitter,url:"https://twitter.com/i/status/",match:/^(twitter|x).com$/,selector:'div[data-testid="videoComponent"] > div:nth-child(1) > div',eventSelector:'div[data-testid="videoPlayer"]',needBypassCSP:!0},{host:Ce.rumble,url:"https://rumble.com/",match:/^rumble.com$/,selector:"#videoPlayer > .videoPlayer-Rumble-cls > div"},{host:Ce.facebook,url:"https://facebook.com/",match:t=>t.host.includes("facebook.com")&&t.pathname.includes("/videos/"),selector:'div[role="main"] div[data-pagelet$="video" i]',needBypassCSP:!0},{additionalData:"reels",host:Ce.facebook,url:"https://facebook.com/",match:t=>t.host.includes("facebook.com")&&t.pathname.includes("/reel/"),selector:'div[role="main"]',needBypassCSP:!0},{host:Ce.rutube,url:"https://rutube.ru/video/",match:/^rutube.ru$/,selector:".video-player > div > div > div:nth-child(2)"},{additionalData:"embed",host:Ce.rutube,url:"https://rutube.ru/video/",match:/^rutube.ru$/,selector:"#app > div > div"},{host:Ce.bilibili,url:"https://www.bilibili.com/",match:/^(www|m|player).bilibili.com$/,selector:".bpx-player-video-wrap"},{additionalData:"old",host:Ce.bilibili,url:"https://www.bilibili.com/",match:/^(www|m).bilibili.com$/,selector:null},{host:Ce.mailru,url:"https://my.mail.ru/",match:/^my.mail.ru$/,selector:"#b-video-wrapper"},{host:Ce.bitchute,url:"https://www.bitchute.com/video/",match:/^(www.)?bitchute.com$/,selector:".video-js"},{host:Ce.eporner,url:"https://www.eporner.com/",match:/^(www.)?eporner.com$/,selector:".vjs-v7"},{host:Ce.peertube,url:"stub",match:["peertube.1312.media","tube.shanti.cafe","bee-tube.fr","video.sadmin.io","dalek.zone","review.peertube.biz","peervideo.club","tube.la-dina.net","peertube.tmp.rcp.tf","peertube.su","video.blender.org","videos.viorsan.com","tube-sciences-technologies.apps.education.fr","tube-numerique-educatif.apps.education.fr","tube-arts-lettres-sciences-humaines.apps.education.fr","beetoons.tv","comics.peertube.biz","makertube.net"],selector:".vjs-v7"},{host:Ce.dailymotion,url:"https://dai.ly/",match:/^geo([\d]+)?.dailymotion.com$/,selector:".player"},{host:Ce.trovo,url:"https://trovo.live/s/",match:/^trovo.live$/,selector:".player-video"},{host:Ce.yandexdisk,url:"https://yadi.sk/",match:/^disk.yandex.(ru|kz|com(\.(am|ge|tr))?|by|az|co\.il|ee|lt|lv|md|net|tj|tm|uz)$/,selector:".video-player__player > div:nth-child(1)",eventSelector:".video-player__player",needBypassCSP:!0,needExtraData:!0},{host:Ce.okru,url:"https://ok.ru/video/",match:/^ok.ru$/,selector:"vk-video-player",shadowRoot:!0},{host:Ce.googledrive,url:"https://drive.google.com/file/d/",match:/^youtube.googleapis.com$/,selector:".html5-video-container"},{host:Ce.bannedvideo,url:"https://madmaxworld.tv/watch?id=",match:/^(www.)?banned.video|madmaxworld.tv$/,selector:".vjs-v7",needExtraData:!0},{host:Ce.weverse,url:"https://weverse.io/",match:/^weverse.io$/,selector:".webplayer-internal-source-wrapper",needExtraData:!0},{host:Ce.newgrounds,url:"https://www.newgrounds.com/",match:/^(www.)?newgrounds.com$/,selector:".ng-video-player"},{host:Ce.egghead,url:"https://egghead.io/",match:/^egghead.io$/,selector:".cueplayer-react-video-holder"},{host:Ce.youku,url:"https://v.youku.com/",match:/^v.youku.com$/,selector:"#ykPlayer"},{host:Ce.archive,url:"https://archive.org/details/",match:/^archive.org$/,selector:".jw-media"},{host:Ce.kodik,url:"stub",match:/^kodik.(info|biz|cc)$/,selector:".fp-player",needExtraData:!0},{host:Ce.patreon,url:"stub",match:/^(www.)?patreon.com$/,selector:'div[data-tag="post-card"] div[elevation="subtle"] > div > div > div > div',needExtraData:!0},{additionalData:"old",host:Ce.reddit,url:"stub",match:/^old.reddit.com$/,selector:".reddit-video-player-root",needExtraData:!0,needBypassCSP:!0},{host:Ce.reddit,url:"stub",match:/^(www.|new.)?reddit.com$/,selector:"div[slot=post-media-container]",shadowRoot:!0,needExtraData:!0,needBypassCSP:!0},{host:Ce.kick,url:"https://kick.com/",match:/^kick.com$/,selector:"#injected-embedded-channel-player-video > div",needExtraData:!0},{host:Ce.appledeveloper,url:"https://developer.apple.com/",match:/^developer.apple.com$/,selector:".developer-video-player",needExtraData:!0,needBypassCSP:!0},{host:Ce.epicgames,url:"https://dev.epicgames.com/community/learning/",match:/^dev.epicgames.com$/,selector:".vjs-v7",needExtraData:!0},{host:Ce.nineanimetv,url:"https://9animetv.to/watch/",match:/^rapid-cloud.co$/,selector:".jw-media",needExtraData:!0},{host:Ce.odysee,url:"stub",match:/^odysee.com$/,selector:".vjs-v7",needExtraData:!0},{host:Ce.coursehunterLike,url:"stub",match:["coursehunter.net","coursetrain.net"],selector:"#oframeplayer > pjsdiv:has(video)",needExtraData:!0},{host:Ce.sap,url:"https://learning.sap.com/courses/",match:/^learning.sap.com$/,selector:".playkit-container",eventSelector:".playkit-player",needExtraData:!0,needBypassCSP:!0},{host:ni.udemy,url:"https://www.udemy.com/",match:/udemy.com$/,selector:'div[data-purpose="curriculum-item-viewer-content"] > section > div > div > div > div:nth-of-type(2)',needExtraData:!0},{host:ni.coursera,url:"https://www.coursera.org/",match:/coursera.org$/,selector:".vjs-v8",needExtraData:!0},{host:Ce.watchpornto,url:"https://watchporn.to/",match:/^watchporn.to$/,selector:".fp-player"},{host:Ce.linkedin,url:"https://www.linkedin.com/learning/",match:/^(www.)?linkedin.com$/,selector:".vjs-v7",needExtraData:!0,needBypassCSP:!0},{host:Ce.incestflix,url:"https://www.incestflix.net/watch/",match:/^(www.)?incestflix.(net|to|com)$/,selector:"#incflix-stream",needExtraData:!0},{host:Ce.porntn,url:"https://porntn.com/videos/",match:/^porntn.com$/,selector:".fp-player",needExtraData:!0},{host:Ce.dzen,url:"https://dzen.ru/video/watch/",match:/^dzen.ru$/,selector:".zen-ui-video-video-player"},{host:Ce.cloudflarestream,url:"stub",match:/^(watch|embed|iframe|customer-[^.]+).cloudflarestream.com$/,selector:null},{host:Ce.loom,url:"https://www.loom.com/share/",match:/^(www.)?loom.com$/,selector:".VideoLayersContainer",needExtraData:!0},{host:ni.artstation,url:"https://www.artstation.com/learning/",match:/^(www.)?artstation.com$/,selector:".vjs-v7",needExtraData:!0},{host:Ce.rtnews,url:"https://www.rt.com/",match:/^(www.)?rt.com$/,selector:".jw-media",needExtraData:!0},{host:Ce.bitview,url:"https://www.bitview.net/watch?v=",match:/^(www.)?bitview.net$/,selector:".vlScreen",needExtraData:!0},{host:Ce.custom,url:"stub",match:t=>/([^.]+).(mp4|webm)/.test(t.pathname),rawResult:!0}];class si extends Error{constructor(t){super(t),this.name="VideoHelper",this.message=t}}class li{API_ORIGIN=window.location.origin;fetch;extraInfo;referer;origin;service;video;language;constructor({fetchFn:t=be,extraInfo:e=!0,referer:i=document.referrer??window.location.origin+"/",origin:o=window.location.origin,service:a,video:n,language:r="en"}={}){this.fetch=t,this.extraInfo=e,this.referer=i,this.origin=/^(http(s)?):\/\//.test(String(o))?o:window.location.origin,this.service=a,this.video=n,this.language=r}async getVideoData(t){}async getVideoId(t){}returnBaseData(t){if(this.service)return{url:this.service.url+t,videoId:t,host:this.service.host,duration:void 0}}}class di extends li{SUBTITLE_SOURCE="videojs";SUBTITLE_FORMAT="vtt";static getPlayer(){return document.querySelector(".video-js")?.player}getVideoDataByPlayer(t){try{const e=di.getPlayer();if(!e)throw new Error(`Video player doesn't have player option, videoId ${t}`);const i=e.duration(),o=Array.isArray(e.currentSources)?e.currentSources:e.getCache()?.sources,{tracks_:a}=e.textTracks(),n=o.find((t=>"video/mp4"===t.type||"video/webm"===t.type));if(!n)throw new Error(`Failed to find video url for videoID ${t}`);const r=a.filter((t=>t.src)).map((t=>({language:we(t.language),source:this.SUBTITLE_SOURCE,format:this.SUBTITLE_FORMAT,url:t.src})));return{url:n.src,duration:i,subtitles:r}}catch(t){return void St.error("Failed to get videojs video data",t.message)}}}class ui extends li{static getPlayer(){if("undefined"==typeof Videoview)return;const t=Videoview;return t?.getPlayerObject?.call(void 0)}async getVideoData(t){const e=ui.getPlayer();if(!e)return this.returnBaseData(t);try{const{description:i,duration:o,md_title:a}=e.vars,n=(new DOMParser).parseFromString(i,"text/html"),r=Array.from(n.body.childNodes).filter((t=>"BR"!==t.nodeName)).map((t=>t.textContent)).join("\n");let s;return Object.hasOwn(e.vars,"subs")&&(s=e.vars.subs.map((t=>({language:we(t.lang),source:"vk",format:"vtt",url:t.url,isAutoGenerated:!!t.is_auto})))),{url:this.service.url+t,title:a,description:r,duration:o,subtitles:s}}catch(e){return St.error(`Failed to get VK video data, because: ${e.message}`),this.returnBaseData(t)}}async getVideoId(t){const e=/^\/(video|clip)-?\d{8,9}_\d{9}$/.exec(t.pathname);if(e)return e[0].slice(1);const i=/\/playlist\/[^/]+\/(video-?\d{8,9}_\d{9})/.exec(t.pathname);if(i)return i[1];const o=t.searchParams.get("z");if(o)return o.split("/")[0];const a=t.searchParams.get("oid"),n=t.searchParams.get("id");return a&&n?`video-${Math.abs(parseInt(a))}_${n}`:void 0}}class ci extends li{async getVideoId(t){return/([^/]+)\/video\/([^/]+)/.exec(t.pathname)?.[0]}}const hi=["auto","ru","en","zh","ko","lt","lv","ar","fr","it","es","de","ja"],pi=["ru","en","kk"],gi=["srt","vtt","json"];class mi extends li{static isMobile(){return/^m\.youtube\.com$/.test(window.location.hostname)}static getPlayer(){return window.location.pathname.startsWith("/shorts/")&&!mi.isMobile()?document.querySelector("#shorts-player"):document.querySelector("#movie_player")}static getPlayerResponse(){return mi.getPlayer()?.getPlayerResponse?.call(void 0)}static getPlayerData(){return mi.getPlayer()?.getVideoData?.call(void 0)}static getVolume(){const t=mi.getPlayer();return t?.getVolume?t.getVolume()/100:1}static setVolume(t){const e=mi.getPlayer();return!!e?.setVolume&&(e.setVolume(Math.round(100*t)),!0)}static isMuted(){const t=mi.getPlayer();return!!t?.isMuted&&t.isMuted()}static videoSeek(t,e){St.log("videoSeek",e);const i=(mi.getPlayer()?.getProgressState()?.seekableEnd??t.currentTime)-e;t.currentTime=i}static getSubtitles(t){const e=mi.getPlayerResponse(),i=e?.captions?.playerCaptionsTracklistRenderer;if(!i)return[];const o=i.captionTracks??[],a=(i.translationLanguages??[]).find((e=>e.languageCode===t)),n=o.find((t=>"asr"===t?.kind)),r=n?.languageCode??"en",s=o.reduce(((e,i)=>{if(!("languageCode"in i))return e;const o=i.languageCode?we(i.languageCode):void 0,n=i.baseUrl;if(!o||!n)return e;const s=`${n.startsWith("http")?n:`${window.location.origin}/${n}`}&fmt=json3`;return e.push({source:"youtube",format:"json",language:o,isAutoGenerated:"asr"===i?.kind,url:s}),a&&i.isTranslatable&&i.languageCode===r&&t!==o&&e.push({source:"youtube",format:"json",language:t,isAutoGenerated:"asr"===i?.kind,translatedFromLanguage:o,url:`${s}&tlang=${t}`}),e}),[]);return St.log("youtube subtitles:",s),s}static getLanguage(){if(!mi.isMobile()){const t=mi.getPlayer(),e=t?.getAudioTrack?.call(void 0)?.getLanguageInfo();if(e&&"und"!==e.id)return we(e.id.split(".")[0])}const t=mi.getPlayerResponse(),e=t?.captions?.playerCaptionsTracklistRenderer.captionTracks.find((t=>"asr"===t.kind&&t.languageCode));return e?we(e.languageCode):void 0}async getVideoData(t){const{title:e}=mi.getPlayerData()??{},{shortDescription:i,isLive:o,title:a}=mi.getPlayerResponse()?.videoDetails??{},n=mi.getSubtitles(this.language);let r=mi.getLanguage();r&&!hi.includes(r)&&(r=void 0);const s=mi.getPlayer()?.getDuration?.call(void 0)??void 0;return{url:this.service.url+t,isStream:o,title:a,localizedTitle:e,detectedLanguage:r,description:i,subtitles:n,duration:s}}async getVideoId(t){if("youtu.be"===t.hostname&&(t.search=`?v=${t.pathname.replace("/","")}`,t.pathname="/watch"),t.searchParams.has("enablejsapi")){const e=mi.getPlayer()?.getVideoUrl();t=e?new URL(e):t}return/(?:watch|embed|shorts|live)\/([^/]+)/.exec(t.pathname)?.[1]??t.searchParams.get("v")}}class vi extends di{API_ORIGIN="https://www.coursera.org/api";SUBTITLE_SOURCE="coursera";async getCourseData(t){try{const e=await this.fetch(`${this.API_ORIGIN}/onDemandCourses.v1/${t}`),i=await e.json();return i?.elements?.[0]}catch(e){return void St.error(`Failed to get course data by courseId: ${t}`,e.message)}}static getPlayer(){return super.getPlayer()}async getVideoData(t){const e=this.getVideoDataByPlayer(t);if(!e)return;const{options_:i}=vi.getPlayer()??{};!e.subtitles?.length&&i&&(e.subtitles=i.tracks.map((t=>({url:t.src,language:we(t.srclang),source:this.SUBTITLE_SOURCE,format:this.SUBTITLE_FORMAT}))));const o=i?.courseId;if(!o)return e;let a="en";const n=await this.getCourseData(o);if(n){const{primaryLanguageCodes:[t]}=n;a=t?we(t):"en"}hi.includes(a)||(a="en");const r=e.subtitles.find((t=>t.language===a))??e.subtitles?.[0],s=r?.url;s||St.warn("Failed to find any subtitle file");const{url:l,duration:d}=e,u=s?[{target:"subtitles_file_url",targetUrl:s},{target:"video_file_url",targetUrl:l}]:null;return{...s?{url:this.service?.url+t,translationHelp:u}:{url:l,translationHelp:u},detectedLanguage:a,duration:d}}async getVideoId(t){const e=/learn\/([^/]+)\/lecture\/([^/]+)/.exec(t.pathname)??/lecture\/([^/]+)\/([^/]+)/.exec(t.pathname);return e?.[0]}}class fi extends li{static getPlayer(){if("undefined"!=typeof player)return player}async getVideoData(t){const e=fi.getPlayer();if(!e)return;const{config:{url:i,duration:o,lang:a,isLive:n}}=e;if(!i)return;const r=i.find((t=>t.src.includes("www.douyin.com/aweme/v1/play/")));return r?{url:ye(r.src),duration:o,isStream:n,...hi.includes(a)?{detectedLanguage:a}:{}}:void 0}async getVideoId(t){const e=/video\/([\d]+)/.exec(t.pathname)?.[0];return e||fi.getPlayer()?.config.vid}}var bi;!function(t){t.Channel="Channel",t.Video="Video"}(bi||(bi={}));const wi={[Ce.mailru]:class extends li{API_ORIGIN="https://my.mail.ru";async getVideoMeta(t){try{const e=await this.fetch(`${this.API_ORIGIN}/+/video/meta/${t}?xemail=&ajax_call=1&func_name=&mna=&mnb=&ext=1&_=${(new Date).getTime()}`);return await e.json()}catch(t){return void St.error("Failed to get mail.ru video data",t.message)}}async getVideoId(t){const e=t.pathname;if(/\/(v|mail|bk|inbox)\//.exec(e))return e.slice(1);const i=/video\/embed\/([^/]+)/.exec(e)?.[1];if(!i)return;const o=await this.getVideoMeta(i);return o?o.meta.url.replace("//my.mail.ru/",""):void 0}},[Ce.weverse]:class extends li{API_ORIGIN="https://global.apis.naver.com/weverse/wevweb";API_APP_ID="be4d79eb8fc7bd008ee82c8ec4ff6fd4";API_HMAC_KEY="1b9cb6378d959b45714bec49971ade22e6e24e42";HEADERS={Accept:"application/json, text/plain, */*",Origin:"https://weverse.io",Referer:"https://weverse.io/"};getURLData(){return{appId:this.API_APP_ID,language:"en",os:"WEB",platform:"WEB",wpf:"pc"}}async createHash(t){const e=Date.now(),i=t.substring(0,Math.min(255,t.length))+e,o=await async function(t,e){try{const i=pe.encode(e),o=await ge("SHA-1",t,i);return btoa(String.fromCharCode(...new Uint8Array(o)))}catch(t){return St.error(t),!1}}(this.API_HMAC_KEY,i);if(!o)throw new si("Failed to get weverse HMAC signature");return{wmsgpad:e.toString(),wmd:o}}async getHashURLParams(t){const e=await this.createHash(t);return new URLSearchParams(e).toString()}async getPostPreview(t){const e=`/post/v1.0/post-${t}/preview?`+new URLSearchParams({fieldSet:"postForPreview",...this.getURLData()}).toString();try{const t=await this.getHashURLParams(e),i=await this.fetch(this.API_ORIGIN+e+"&"+t,{headers:this.HEADERS});return await i.json()}catch(e){return St.error(`Failed to get weverse post preview by postId: ${t}`,e.message),!1}}async getVideoInKey(t){const e=`/video/v1.1/vod/${t}/inKey?`+new URLSearchParams({gcc:"RU",...this.getURLData()}).toString();try{const t=await this.getHashURLParams(e),i=await this.fetch(this.API_ORIGIN+e+"&"+t,{method:"POST",headers:this.HEADERS});return await i.json()}catch(e){return St.error(`Failed to get weverse InKey by videoId: ${t}`,e.message),!1}}async getVideoInfo(t,e,i){const o=Date.now();try{const a=new URLSearchParams({key:e,sid:i,nonce:o.toString(),devt:"html5_pc",prv:"N",aup:"N",stpb:"N",cpl:"en",env:"prod",lc:"en",adi:JSON.stringify([{adSystem:null}]),adu:"/"}).toString(),n=await this.fetch(`https://global.apis.naver.com/rmcnmv/rmcnmv/vod/play/v2.0/${t}?`+a,{headers:this.HEADERS});return await n.json()}catch(o){return St.error(`Failed to get weverse video info (infraVideoId: ${t}, inkey: ${e}, serviceId: ${i}`,o.message),!1}}extractVideoInfo(t){return t.find((t=>!1===t.useP2P&&t.source.includes(".mp4")))}async getVideoData(t){const e=await this.getPostPreview(t);if(!e)return;const{videoId:i,serviceId:o,infraVideoId:a}=e.extension.video;if(!(i&&o&&a))return;const n=await this.getVideoInKey(i);if(!n)return;const r=await this.getVideoInfo(a,n.inKey,o);if(!r)return;const s=this.extractVideoInfo(r.videos.list);return s?{url:s.source,duration:s.duration}:void 0}async getVideoId(t){return/([^/]+)\/(live|media)\/([^/]+)/.exec(t.pathname)?.[3]}},[Ce.kodik]:class extends li{API_ORIGIN=window.location.origin;async getSecureData(t){try{const e=await this.fetch(`${this.API_ORIGIN}${t}`,{headers:{"User-Agent":yt.userAgent,Origin:this.API_ORIGIN,Referer:this.API_ORIGIN}}),i=await e.text(),[o,a,n]=t.split("/").filter((t=>t)),r=(new DOMParser).parseFromString(i,"text/html"),s=Array.from(r.getElementsByTagName("script")).filter((t=>t.innerHTML.includes(`videoId = "${a}"`)));if(!s.length)throw new si("Failed to find secure script");const l=/'{[^']+}'/.exec(s[0].textContent.trim())?.[0];if(!l)throw new si("Secure json wasn't found in secure script");const d=JSON.parse(l.replaceAll("'",""));return{videoType:o,videoId:a,hash:n,...d}}catch(e){return St.error(`Failed to get kodik secure data by videoPath: ${t}.`,e.message),!1}}async getFtor(t){const{videoType:e,videoId:i,hash:o,d:a,d_sign:n,pd:r,pd_sign:s,ref:l,ref_sign:d}=t;try{const t=await this.fetch(this.API_ORIGIN+"/ftor",{method:"POST",headers:{"User-Agent":yt.userAgent,Origin:this.API_ORIGIN,Referer:`${this.API_ORIGIN}/${e}/${i}/${o}/360p`},body:new URLSearchParams({d:a,d_sign:n,pd:r,pd_sign:s,ref:decodeURIComponent(l),ref_sign:d,bad_user:"false",cdn_is_working:"true",info:"{}",type:e,hash:o,id:i})});return await t.json()}catch(t){return St.error(`Failed to get kodik video data (type: ${e}, id: ${i}, hash: ${o})`,t.message),!1}}decryptUrl(t){const e=atob(t.replace(/[a-zA-Z]/g,(function(t){const e=t.charCodeAt(0)+13,i=t<="Z"?90:122;return String.fromCharCode(i>=e?e:e-26)})));return"https:"+e}async getVideoData(t){const e=await this.getSecureData(t);if(!e)return;const i=await this.getFtor(e);if(!i)return;const o=Object.entries(i.links[i.default.toString()]),a=o.find((([,t])=>"application/x-mpegURL"===t.type))?.[1];return a?{url:this.decryptUrl(a.src)}:void 0}async getVideoId(t){return/\/(seria|video)\/([^/]+)\/([^/]+)\/([\d]+)p/.exec(t.pathname)?.[0]}},[Ce.patreon]:class extends li{API_ORIGIN="https://www.patreon.com/api";async getPosts(t){try{const e=await this.fetch(`${this.API_ORIGIN}/posts/${t}?json-api-use-default-includes=false`);return await e.json()}catch(e){return St.error(`Failed to get patreon posts by postId: ${t}.`,e.message),!1}}async getVideoData(t){const e=await this.getPosts(t);if(!e)return;const i=e.data.attributes.post_file.url;return i?{url:i}:void 0}async getVideoId(t){const e=/posts\/([^/]+)/.exec(t.pathname)?.[1];if(e)return e.replace(/[^\d.]/g,"")}},[Ce.reddit]:class extends li{API_ORIGIN="https://www.reddit.com";async getContentUrl(t){if("old"!==this.service?.additionalData)return document.querySelector("shreddit-player-2")?.src;const e=document.querySelector("[data-hls-url]");return e?.dataset.hlsUrl?.replaceAll("&","&")}async getVideoData(t){try{const e=await this.getContentUrl(t);if(!e)throw new si("Failed to find content url");return{url:decodeURIComponent(e)}}catch(e){return void St.error(`Failed to get reddit video data by video ID: ${t}`,e.message)}}async getVideoId(t){return/\/r\/(([^/]+)\/([^/]+)\/([^/]+)\/([^/]+))/.exec(t.pathname)?.[1]}},[Ce.bannedvideo]:class extends li{API_ORIGIN="https://api.banned.video";async getVideoInfo(t){try{const e=await this.fetch(`${this.API_ORIGIN}/graphql`,{method:"POST",body:JSON.stringify({operationName:"GetVideo",query:"query GetVideo($id: String!) {\n getVideo(id: $id) {\n title\n description: summary\n duration: videoDuration\n videoUrl: directUrl\n isStream: live\n }\n }",variables:{id:t}}),headers:{"User-Agent":"bannedVideoFrontEnd","apollographql-client-name":"banned-web","apollographql-client-version":"1.3","content-type":"application/json"}});return await e.json()}catch(e){return console.error(`Failed to get bannedvideo video info by videoId: ${t}.`,e.message),!1}}async getVideoData(t){const e=await this.getVideoInfo(t);if(!e)return;const{videoUrl:i,duration:o,isStream:a,description:n,title:r}=e.data.getVideo;return{url:i,duration:o,isStream:a,title:r,description:n}}async getVideoId(t){return t.searchParams.get("id")??void 0}},[Ce.kick]:class extends li{API_ORIGIN="https://kick.com/api";async getClipInfo(t){try{const e=await this.fetch(`${this.API_ORIGIN}/v2/clips/${t}`),i=await e.json(),{clip_url:o,duration:a,title:n}=i.clip;return{url:o,duration:a,title:n}}catch(e){return void St.error(`Failed to get kick clip info by clipId: ${t}.`,e.message)}}async getVideoInfo(t){try{const e=await this.fetch(`${this.API_ORIGIN}/v1/video/${t}`),i=await e.json(),{source:o,livestream:a}=i,{session_title:n,duration:r}=a;return{url:o,duration:Math.round(r/1e3),title:n}}catch(e){return void St.error(`Failed to get kick video info by videoId: ${t}.`,e.message)}}async getVideoData(t){return t.startsWith("videos")?await this.getVideoInfo(t.replace("videos/","")):await this.getClipInfo(t.replace("clips/",""))}async getVideoId(t){return/([^/]+)\/((videos|clips)\/([^/]+))/.exec(t.pathname)?.[2]}},[Ce.appledeveloper]:class extends li{API_ORIGIN="https://developer.apple.com";async getVideoData(t){try{const t=document.querySelector("meta[property='og:video']")?.content;if(!t)throw new si("Failed to find content url");return{url:t}}catch(e){return void St.error(`Failed to get apple developer video data by video ID: ${t}`,e.message)}}async getVideoId(t){return/videos\/play\/([^/]+)\/([\d]+)/.exec(t.pathname)?.[0]}},[Ce.epicgames]:class extends li{API_ORIGIN="https://dev.epicgames.com/community/api/learning";async getPostInfo(t){try{const e=await this.fetch(`${this.API_ORIGIN}/post.json?hash_id=${t}`);return await e.json()}catch(e){return St.error(`Failed to get epicgames post info by videoId: ${t}.`,e.message),!1}}getVideoBlock(){const t=/videoUrl\s?=\s"([^"]+)"?/,e=Array.from(document.body.querySelectorAll("script")).find((e=>t.exec(e.innerHTML)));if(!e)return;const i=e.innerHTML.trim(),o=t.exec(i)?.[1]?.replace("qsep://","https://");if(!o)return;let a=/sources\s?=\s(\[([^\]]+)\])?/.exec(i)?.[1];if(!a)return{playlistUrl:o,subtitles:[]};try{a=(a.replace(/src:(\s)+?(videoUrl)/g,'src:"removed"').substring(0,a.lastIndexOf("},"))+"]").split("\n").map((t=>t.replace(/([^\s]+):\s?(?!.*\1)/,'"$1":'))).join("\n");const t=JSON.parse(a);return{playlistUrl:o,subtitles:t.filter((t=>"captions"===t.type))}}catch{return{playlistUrl:o,subtitles:[]}}}async getVideoData(t){const e=t.split(":")?.[1],i=await this.getPostInfo(e);if(!i)return;const o=this.getVideoBlock();if(!o)return;const{playlistUrl:a,subtitles:n}=o,{title:r,description:s}=i;return{url:a,title:r,description:s,subtitles:n.map((t=>({language:we(t.srclang),source:"epicgames",format:"vtt",url:t.src})))}}async getVideoId(t){return new Promise((t=>{const e="https://dev.epicgames.com",i=btoa(window.location.href);window.addEventListener("message",(i=>{if(i.origin!==e)return;if("string"!=typeof i.data||!i.data.startsWith("getVideoId:"))return;const o=i.data.replace("getVideoId:","");return t(o)})),window.top.postMessage(`getVideoId:${i}`,e)}))}},[Ce.nineanimetv]:class extends li{API_ORIGIN="https://9animetv.to/ajax/episode";RAPID_CLOUD_ORIGIN="https://rapid-cloud.co/ajax/embed-6-v2";async getSourceId(t){try{const e=await this.fetch(`${this.API_ORIGIN}/servers?episodeId=${t}`),i=await e.json();return!!i.html&&/data-id="(\d+)"/.exec(i.html)?.[1]}catch(e){return St.error(`Failed to get 9animetv servers info by episodeId: ${t}.`,e.message),!1}}async getPlayerLink(t){try{const e=await this.fetch(`${this.API_ORIGIN}/sources?id=${t}`),i=await e.json();return!!i.link.includes("rapid-cloud.co")&&i.link}catch(e){return St.error(`Failed to get player link by sourceId: ${t}.`,e.message),!1}}async getRapidCloudData(t){try{const e=await this.fetch(`${this.RAPID_CLOUD_ORIGIN}/getSources?id=${t}`),i=await e.json();return i.encrypted?(St.warn("Encrypted RapidCloud data found. Let us know about it",i),!1):i}catch(e){return St.error(`Failed to get rapid cloud data by rapidId: ${t}.`,e.message),!1}}async getVideoData(t){const e=t.split("?ep=")[1],i=await this.getSourceId(e);if(!i)return;const o=await this.getPlayerLink(i);if(!o)return;const a=/\/([^/?]+)\?/.exec(o)?.[1];if(!a)return;const n=await this.getRapidCloudData(a);if(!n)return;const r=n.sources.find((t=>"hls"===t.type))?.file;if(!r)return;const s=n.tracks.reduce(((t,e)=>{const i=/([\w+]+)(-\d)?\.vtt/.exec(e.file)?.[1];if(!i)return t;const o=we(3===i.length?i:e.label);return t.find((t=>t.language===o))||t.push({language:o,source:"nineanimetv",format:"vtt",url:e.file}),t}),[]);return{url:r,subtitles:s}}async getVideoId(t){return new Promise((t=>{const e="https://9animetv.to";window.addEventListener("message",(i=>{if(i.origin===e&&"string"==typeof i.data&&i.data.startsWith("getVideoId:")){const e=i.data.replace("getVideoId:","");return t(e)}})),window.top.postMessage("getVideoId",e)}))}},[Ce.odysee]:class extends li{API_ORIGIN="https://odysee.com";async getVideoData(t){try{const e=await this.fetch(`${this.API_ORIGIN}/${t}`),i=await e.text(),o=/"contentUrl":(\s)?"([^"]+)"/.exec(i)?.[2];if(!o)throw new Error("Odysee url doesn't parsed");return{url:o}}catch(e){return void St.error(`Failed to get odysee video data by video ID: ${t}`,e.message)}}async getVideoId(t){return t.pathname.slice(1)}},[Ce.coursehunterLike]:class extends li{API_ORIGIN=this.origin??"https://coursehunter.net";async getCourseId(){const t=window.course_id;return void 0!==t?String(t):document.querySelector('input[name="course_id"]')?.value}async getLessonsData(t){const e=window.lessons;if(e?.length)return e;try{const e=await this.fetch(`${this.API_ORIGIN}/api/v1/course/${t}/lessons`);return await e.json()}catch(e){return void St.error(`Failed to get CoursehunterLike lessons data by courseId: ${t}, because ${e.message}`)}}getLessondId(t){let e=t.split("?lesson=")?.[1];if(e)return+e;const i=document.querySelector(".lessons-item_active");return e=i?.dataset?.index,e?+e:1}async getVideoData(t){const e=await this.getCourseId();if(!e)return;const i=await this.getLessonsData(e);if(!i)return;const o=this.getLessondId(t),a=i?.[o-1],{file:n,duration:r,title:s}=a;return n?{url:n,duration:r,title:s}:void 0}async getVideoId(t){const e=/course\/([^/]+)/.exec(t.pathname)?.[0];return e?e+t.search:void 0}},[Ce.twitch]:class extends li{API_ORIGIN="https://clips.twitch.tv";async getClipLink(t,e){const i=document.querySelector("script[type='application/ld+json']"),o=t.slice(1);if(i){const t=JSON.parse(i.innerText),e=t["@graph"].find((t=>"VideoObject"===t["@type"]))?.creator.url;if(!e)throw new si("Failed to find channel link");return`${e.replace("https://www.twitch.tv/","")}/clip/${o}`}const a="embed"===o,n=document.querySelector(a?".tw-link[data-test-selector='stream-info-card-component__stream-avatar-link']":".clips-player a:not([class])");if(!n)return;return`${n.href.replace("https://www.twitch.tv/","")}/clip/${a?e:o}`}async getVideoId(t){const e=t.pathname;if(/^m\.twitch\.tv$/.test(e))return/videos\/([^/]+)/.exec(t.href)?.[0]??e.slice(1);if(/^player\.twitch\.tv$/.test(t.hostname))return`videos/${t.searchParams.get("video")}`;const i=/([^/]+)\/(?:clip)\/([^/]+)/.exec(e);if(i)return i[0];return/^clips\.twitch\.tv$/.test(t.hostname)?await this.getClipLink(e,t.searchParams.get("clip")):/(?:videos)\/([^/]+)/.exec(e)?.[0]}},[Ce.sap]:class extends li{API_ORIGIN="https://learning.sap.com/";async requestKaltura(t,e,i){try{const o=await this.fetch(`https://${t}/api_v3/service/multirequest`,{method:"POST",body:JSON.stringify({1:{service:"session",action:"startWidgetSession",widgetId:`_${e}`},2:{service:"baseEntry",action:"list",ks:"{1:result:ks}",filter:{redirectFromEntryId:i},responseProfile:{type:1,fields:"id,referenceId,name,description,dataUrl,duration,flavorParamsIds,type,dvrStatus,externalSourceType,createdAt,updatedAt,endDate,plays,views,downloadUrl,creatorId"}},3:{service:"baseEntry",action:"getPlaybackContext",entryId:"{2:result:objects:0:id}",ks:"{1:result:ks}",contextDataParams:{objectType:"KalturaContextDataParams",flavorTags:"all"}},apiVersion:"3.3.0",format:1,ks:"",clientTag:"html5:v3.17.22",partnerId:e}),headers:{"Content-Type":"application/json"}});return await o.json()}catch(t){return void St.error("Failed to request kaltura data",t.message)}}async getKalturaData(t){try{const e=document.querySelector('script[data-nscript="beforeInteractive"]');if(!e)throw new si("Failed to find script element");const i=/https:\/\/([^"]+)\/p\/([^"]+)\/embedPlaykitJs\/uiconf_id\/([^"]+)/.exec(e?.src);if(!i)throw new si(`Failed to get sap data for videoId: ${t}`);const[,o,a]=i;let n=document.querySelector("#shadow")?.firstChild?.getAttribute("id");if(!n){const t=document.querySelector("#__NEXT_DATA__");if(!t)throw new si("Failed to find next data element");n=/"sourceId":\s?"([^"]+)"/.exec(t.innerText)?.[1]}if(!o||Number.isNaN(+a)||!n)throw new si(`One of the necessary parameters for getting a link to a sap video in wasn't found for ${t}. Params: kalturaDomain = ${o}, partnerId = ${a}, entryId = ${n}`);return await this.requestKaltura(o,a,n)}catch(t){return void St.error("Failed to get kaltura data",t.message)}}async getVideoData(t){const e=await this.getKalturaData(t);if(!e)return;const[,i,o]=e,{duration:a}=i.objects[0],n=o.sources.find((t=>"url"===t.format&&"http,https"===t.protocols&&t.url.includes(".mp4")))?.url;if(!n)return;return{url:n,subtitles:o.playbackCaptions.map((t=>({language:we(t.languageCode),source:"sap",format:"vtt",url:t.webVttUrl,isAutoGenerated:t.label.includes("auto-generated")}))),duration:a}}async getVideoId(t){return/((courses|learning-journeys)\/([^/]+)(\/[^/]+)?)/.exec(t.pathname)?.[1]}},[Ce.linkedin]:class extends di{SUBTITLE_SOURCE="linkedin";async getVideoData(t){const e=this.getVideoDataByPlayer(t);if(!e)return;const{url:i,duration:o,subtitles:a}=e;return{url:ye(new URL(i)),duration:o,subtitles:a}}async getVideoId(t){return/\/learning\/(([^/]+)\/([^/]+))/.exec(t.pathname)?.[1]}},[Ce.vimeo]:class extends li{API_KEY="";DEFAULT_SITE_ORIGIN="https://vimeo.com";SITE_ORIGIN=this.isPrivatePlayer()?this.service?.url?.slice(0,-1)??this.DEFAULT_SITE_ORIGIN:this.DEFAULT_SITE_ORIGIN;isErrorData(t){return Object.hasOwn(t,"error")}isPrivatePlayer(){return this.referer&&!this.referer.includes("vimeo.com")}async getViewerData(){try{const t=await this.fetch("https://vimeo.com/_next/viewer"),e=await t.json(),{apiUrl:i,jwt:o}=e;return this.API_ORIGIN=`https://${i}`,this.API_KEY=`jwt ${o}`,e}catch(t){return St.error("Failed to get default viewer data.",t.message),!1}}async getVideoInfo(t){try{const e=new URLSearchParams({fields:"name,link,description,duration"}).toString(),i=await this.fetch(`${this.API_ORIGIN}/videos/${t}?${e}`,{headers:{Authorization:this.API_KEY}}),o=await i.json();if(this.isErrorData(o))throw new Error(o.developer_message??o.error);return o}catch(e){return St.error(`Failed to get video info by video ID: ${t}`,e.message),!1}}async getPrivateVideoSource(t){try{const{default_cdn:e,cdns:i}=t.dash,o=i[e].url,a=await this.fetch(o);if(200!==a.status)throw new si(await a.text());const n=await a.json(),r=new URL(o),s=Array.from(n.base_url.matchAll(/\.\.\//g)).length+1,l=r.pathname.split("/");let d=n.base_url.replaceAll("../","");d=d&&!d.startsWith("/")?`/${d}`:d,r.pathname=l.slice(0,l.length-s).join("/")+d,r.pathname.endsWith("/")||(r.pathname+="/");const u=n.audio.find((t=>"audio/mp4"===t.mime_type&&"dash"===t.format));if(!u)throw new si("Failed to find video data");const c=u.segments?.[0]?.url;if(!c)throw new si("Failed to find first segment url");const[h,p]=c.split("?",2),g=new URLSearchParams(p);return g.delete("range"),r.pathname+=`${u.base_url}${h}`,r.href=r.href.split("?")[0]+"?"+g.toString(),r.href}catch(t){return St.error("Failed to get private video source",t.message),!1}}async getPrivateVideoInfo(t){try{if("undefined"==typeof playerConfig)return;const e=playerConfig,i=await this.getPrivateVideoSource(e.request.files);if(!i)throw new si("Failed to get private video source");const{video:{title:o,duration:a},request:{text_tracks:n}}=e;return{url:`${this.SITE_ORIGIN}/${t}`,video_url:i,title:o,duration:a,subs:n}}catch(e){return St.error(`Failed to get private video info by video ID: ${t}`,e.message),!1}}async getSubsInfo(t){try{const e=new URLSearchParams({per_page:"100",fields:"language,type,link"}).toString(),i=await this.fetch(`${this.API_ORIGIN}/videos/${t}/texttracks?${e}`,{headers:{Authorization:this.API_KEY}}),o=await i.json();if(this.isErrorData(o))throw new Error(o.developer_message??o.error);return o}catch(e){return St.error(`Failed to get subtitles info by video ID: ${t}`,e.message),!1}}async getVideoData(t){const e=this.isPrivatePlayer();if(!this.extraInfo)return this.returnBaseData(t);if(e){const e=await this.getPrivateVideoInfo(t);if(!e)return;const{url:i,subs:o,video_url:a,title:n,duration:r}=e,s=o.map((t=>({language:we(t.lang),source:"vimeo",format:"vtt",url:this.SITE_ORIGIN+t.url,isAutoGenerated:t.lang.includes("autogenerated")}))),l=s.length?[{target:"video_file_url",targetUrl:a},{target:"subtitles_file_url",targetUrl:s[0].url}]:null;return{...l?{url:i,translationHelp:l}:{url:a},subtitles:s,title:n,duration:r}}t.startsWith("video/")&&(t=t.replace("video/","")),t.includes("/")&&(t=t.replace("/",":"));if(!await this.getViewerData())return this.returnBaseData(t);const i=await this.getVideoInfo(t);if(!i)return this.returnBaseData(t);const o=await this.getSubsInfo(t),a=o?o.data.map((t=>({language:we(t.language),source:"vimeo",format:"vtt",url:t.link,isAutoGenerated:t.language.includes("autogen")}))):[],{link:n,duration:r,name:s,description:l}=i;return{url:n,title:s,description:l,subtitles:a,duration:r}}async getVideoId(t){const e=/[^/]+\/[^/]+$/.exec(t.pathname)?.[0];return this.isPrivatePlayer()?e:e?.startsWith("video/")?e.replace("video/",""):e??/[^/]+$/.exec(t.pathname)?.[0]}},[Ce.yandexdisk]:class extends li{API_ORIGIN=window.location.origin;CLIENT_PREFIX="/client/disk";INLINE_PREFIX="/i/";DISK_PREFIX="/d/";isErrorData(t){return Object.hasOwn(t,"error")}async getClientVideoData(t){const e=new URL(window.location.href).searchParams.get("idDialog");if(!e)return;const i=document.querySelector("#preloaded-data");if(i)try{const t=JSON.parse(i.innerText),{idClient:o,sk:a}=t.config,n=await this.fetch(this.API_ORIGIN+"/models/?_m=resource",{method:"POST",body:new URLSearchParams({idClient:o,sk:a,"_model.0":"resource","id.0":e.replaceAll(" ","+")}).toString().replaceAll(/%2B/g,"+"),headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}}),r=await n.json();if(!r.models)throw new si("Failed to get resource info");const s=r.models[0].data;if(this.isErrorData(s))throw new si(s.error?.message);const{meta:{short_url:l,video_info:d},name:u}=s;if(!d)throw new si("There's no video open right now");if(!l)throw new si("Access to the video is limited");const c=this.clearTitle(u);return{url:l,title:c,duration:Math.round(d.duration/1e3)}}catch(e){return void St.error(`Failed to get yandex disk video data by video ID: ${t}, because ${e.message}`)}}clearTitle(t){return t.replace(/(\.[^.]+)$/,"")}getBodyHash(t,e){const i=JSON.stringify({hash:t,sk:e});return encodeURIComponent(i)}async fetchList(t,e){const i=this.getBodyHash(t,e),o=await this.fetch(this.API_ORIGIN+"/public/api/fetch-list",{method:"POST",body:i}),a=await o.json();if(Object.hasOwn(a,"error"))throw new si("Failed to fetch folder list");return a.resources}async getDownloadUrl(t,e){const i=this.getBodyHash(t,e),o=await this.fetch(this.API_ORIGIN+"/public/api/download-url",{method:"POST",body:i}),a=await o.json();if(a.error)throw new si("Failed to get download url");return a.data.url}async getDiskVideoData(t){try{const e=document.getElementById("store-prefetch");if(!e)throw new si("Failed to get prefetch data");const i=t.split("/").slice(3);if(!i.length)throw new si("Failed to find video file path");const o=JSON.parse(e.innerText),{resources:a,rootResourceId:n,environment:{sk:r}}=o,s=a[n],l=i.length-1,d=i.filter(((t,e)=>e!==l)).join("/");let u=Object.values(a);d.includes("/")&&(u=await this.fetchList(`${s.hash}:/${d}`,r));const c=u.find((t=>t.name===i[l]));if(!c)throw new si("Failed to find resource");if(c&&"dir"===c.type)throw new si("Path is dir, but expected file");const{meta:{short_url:h,mediatype:p,videoDuration:g},path:m,name:v}=c;if("video"!==p)throw new si("Resource isn't a video");const f=this.clearTitle(v),b=Math.round(g/1e3);if(h)return{url:h,duration:b,title:f};const w=await this.getDownloadUrl(m,r);return{url:ye(new URL(w)),duration:b,title:f}}catch(e){return void St.error(`Failed to get yandex disk video data by disk video ID: ${t}`,e.message)}}async getVideoData(t){return t.startsWith(this.INLINE_PREFIX)?{url:this.service.url+t.slice(1)}:(t=decodeURIComponent(t)).startsWith(this.CLIENT_PREFIX)?await this.getClientVideoData(t):await this.getDiskVideoData(t)}async getVideoId(t){if(t.pathname.startsWith(this.CLIENT_PREFIX))return t.pathname+t.search;const e=/\/i\/([^/]+)/.exec(t.pathname)?.[0];return e||(/\/d\/([^/]+)\/([^/]+)/.exec(t.pathname)?t.pathname:void 0)}},[Ce.vk]:ui,[Ce.trovo]:class extends li{async getVideoId(t){const e=t.searchParams.get("vid"),i=/([^/]+)\/([\d]+)/.exec(t.pathname)?.[0];if(e&&i)return`${i}?vid=${e}`}},[Ce.incestflix]:class extends li{async getVideoData(t){try{const t=document.querySelector("#incflix-stream source:first-of-type");if(!t)throw new si("Failed to find source element");const e=t.getAttribute("src");if(!e)throw new si("Failed to find source link");const i=new URL(e.startsWith("//")?`https:${e}`:e);return i.searchParams.append("media-proxy","video.mp4"),{url:ye(i)}}catch(e){return void St.error(`Failed to get Incestflix data by videoId: ${t}`,e.message)}}async getVideoId(t){return/\/watch\/([^/]+)/.exec(t.pathname)?.[1]}},[Ce.porntn]:class extends li{async getVideoData(t){try{if("undefined"==typeof flashvars)return;const{rnd:t,video_url:e,video_title:i}=flashvars;if(!e||!t)throw new si("Failed to find video source or rnd");const o=new URL(e);o.searchParams.append("rnd",t),St.log("PornTN get_file link",o.href);const a=await this.fetch(o.href,{method:"head"}),n=new URL(a.url);St.log("PornTN cdn link",n.href);return{url:ye(n),title:i}}catch(e){return void St.error(`Failed to get PornTN data by videoId: ${t}`,e.message)}}async getVideoId(t){return/\/videos\/(([^/]+)\/([^/]+))/.exec(t.pathname)?.[1]}},[Ce.googledrive]:class extends li{getPlayerData(){const t=document.querySelector("#movie_player");return t?.getVideoData?.call()??void 0}async getVideoId(t){return this.getPlayerData()?.video_id}},[Ce.bilibili]:class extends li{async getVideoId(t){const e=/bangumi\/play\/([^/]+)/.exec(t.pathname)?.[0];if(e)return e;const i=t.searchParams.get("bvid");if(i)return`video/${i}`;let o=/video\/([^/]+)/.exec(t.pathname)?.[0];return o&&null!==t.searchParams.get("p")&&(o+=`/?p=${t.searchParams.get("p")}`),o}},[Ce.xvideos]:class extends li{async getVideoId(t){return/[^/]+\/[^/]+$/.exec(t.pathname)?.[0]}},[Ce.watchpornto]:class extends li{async getVideoId(t){return/(video|embed)\/(\d+)(\/[^/]+\/)?/.exec(t.pathname)?.[0]}},[Ce.archive]:class extends li{async getVideoId(t){return/(details|embed)\/([^/]+)/.exec(t.pathname)?.[2]}},[Ce.dailymotion]:class extends li{async getVideoId(t){const e=Array.from(document.querySelectorAll("*")).filter((t=>t.innerHTML.trim().includes(".m3u8"))),i=e?.[1]?.lastChild?.src;return i?/\/video\/(\w+)\.m3u8/.exec(i)?.[1]:void 0}},[Ce.youku]:class extends li{async getVideoId(t){return/v_show\/id_[\w=]+/.exec(t.pathname)?.[0]}},[Ce.egghead]:class extends li{async getVideoId(t){return t.pathname.slice(1)}},[Ce.newgrounds]:class extends li{async getVideoId(t){return/([^/]+)\/(view)\/([^/]+)/.exec(t.pathname)?.[0]}},[Ce.okru]:class extends li{async getVideoId(t){return/\/video\/(\d+)/.exec(t.pathname)?.[1]}},[Ce.peertube]:class extends li{async getVideoId(t){return/\/w\/([^/]+)/.exec(t.pathname)?.[0]}},[Ce.eporner]:class extends li{async getVideoId(t){return/video-([^/]+)\/([^/]+)/.exec(t.pathname)?.[0]}},[Ce.bitchute]:class extends li{async getVideoId(t){return/(video|embed)\/([^/]+)/.exec(t.pathname)?.[2]}},[Ce.rutube]:class extends li{async getVideoId(t){return/(?:video|embed)\/([^/]+)/.exec(t.pathname)?.[1]}},[Ce.facebook]:class extends li{async getVideoId(t){return t.pathname.slice(1)}},[Ce.rumble]:class extends li{async getVideoId(t){return t.pathname.slice(1)}},[Ce.twitter]:class extends li{async getVideoId(t){const e=/status\/([^/]+)/.exec(t.pathname)?.[1];if(e)return e;const i=this.video?.closest('[data-testid="tweet"]'),o=i?.querySelector('a[role="link"][aria-label]')?.href;return o?/status\/([^/]+)/.exec(o)?.[1]:void 0}},[Ce.pornhub]:class extends li{async getVideoId(t){return t.searchParams.get("viewkey")??/embed\/([^/]+)/.exec(t.pathname)?.[1]}},[Ce.tiktok]:ci,[Ce.proxitok]:ci,[Ce.nine_gag]:class extends li{async getVideoId(t){return/gag\/([^/]+)/.exec(t.pathname)?.[1]}},[Ce.youtube]:mi,[Ce.ricktube]:mi,[Ce.invidious]:mi,[Ce.poketube]:mi,[Ce.piped]:mi,[Ce.dzen]:class extends li{async getVideoId(t){return/video\/watch\/([^/]+)/.exec(t.pathname)?.[1]}},[Ce.cloudflarestream]:class extends li{async getVideoId(t){return t.pathname+t.search}},[Ce.loom]:class extends li{getClientVersion(){if("undefined"==typeof SENTRY_RELEASE)return;return SENTRY_RELEASE.id}async getVideoData(t){try{const e=this.getClientVersion();if(!e)throw new si("Failed to get client version");const i=await this.fetch("https://www.loom.com/graphql",{headers:{"User-Agent":yt.userAgent,"content-type":"application/json","x-loom-request-source":`loom_web_${e}`,"apollographql-client-name":"web","apollographql-client-version":e,"Alt-Used":"www.loom.com"},body:`{"operationName":"FetchCaptions","variables":{"videoId":"${t}"},"query":"query FetchCaptions($videoId: ID!, $password: String) {\\n fetchVideoTranscript(videoId: $videoId, password: $password) {\\n ... on VideoTranscriptDetails {\\n id\\n captions_source_url\\n language\\n __typename\\n }\\n ... on GenericError {\\n message\\n __typename\\n }\\n __typename\\n }\\n}"}`,method:"POST"});if(200!==i.status)throw new si("Failed to get data from graphql");const o=(await i.json()).data.fetchVideoTranscript;if("GenericError"===o.__typename)throw new si(o.message);return{url:this.service.url+t,subtitles:[{format:"vtt",language:we(o.language),source:"loom",url:o.captions_source_url}]}}catch(e){return St.error(`Failed to get Loom video data, because: ${e.message}`),this.returnBaseData(t)}}async getVideoId(t){return/(embed|share)\/([^/]+)?/.exec(t.pathname)?.[2]}},[Ce.rtnews]:class extends li{async getVideoData(t){const e=document.querySelector(".jw-video, .media__video_noscript");if(!e)return;let i=e.getAttribute("src");return i?(i.endsWith(".MP4")&&(i=ye(i)),{videoId:t,url:i}):void 0}async getVideoId(t){return t.pathname.slice(1)}},[Ce.bitview]:class extends li{async getVideoData(t){try{const t=document.querySelector(".vlScreen > video")?.src;if(!t)throw new si("Failed to find video URL");return{url:t}}catch(e){return void St.error(`Failed to get Bitview data by videoId: ${t}`,e.message)}}async getVideoId(t){return t.searchParams.get("v")}},[ni.udemy]:class extends li{API_ORIGIN="https://www.udemy.com/api-2.0";getModuleData(){const t=document.querySelector(".ud-app-loader[data-module-id='course-taking']"),e=t?.dataset?.moduleArgs;if(e)return JSON.parse(e)}getLectureId(){return/learn\/lecture\/([^/]+)/.exec(window.location.pathname)?.[1]}async getLectureData(t,e){try{const i=await this.fetch(`${this.API_ORIGIN}/users/me/subscribed-courses/${t}/lectures/${e}/?`+new URLSearchParams({"fields[lecture]":"title,description,asset","fields[asset]":"length,media_sources,captions"}).toString());return await i.json()}catch(i){return void St.error(`Failed to get lecture data by courseId: ${t} and lectureId: ${e}`,i.message)}}async getCourseLang(t){try{const e=await this.fetch(`${this.API_ORIGIN}/users/me/subscribed-courses/${t}?`+new URLSearchParams({"fields[course]":"locale"}).toString());return await e.json()}catch(e){return void St.error(`Failed to get course lang by courseId: ${t}`,e.message)}}findVideoUrl(t){return t?.find((t=>"video/mp4"===t.type))?.src}findSubtitleUrl(t,e){let i=t?.find((t=>we(t.locale_id)===e));return i||(i=t?.find((t=>"en"===we(t.locale_id)))??t?.[0]),i?.url}async getVideoData(t){const e=this.getModuleData();if(!e)return;const{courseId:i}=e,o=this.getLectureId();if(St.log(`[Udemy] courseId: ${i}, lectureId: ${o}`),!o)return;const a=await this.getLectureData(i,o);if(!a)return;const{title:n,description:r,asset:s}=a,{length:l,media_sources:d,captions:u}=s,c=this.findVideoUrl(d);if(!c)return void St.log("Failed to find .mp4 video file in media_sources",d);let h="en";const p=await this.getCourseLang(i);if(p){const{locale:{locale:t}}=p;h=t?we(t):h}hi.includes(h)||(h="en");const g=this.findSubtitleUrl(u,h);return g||St.log("Failed to find subtitle file in captions",u),{...g?{url:this.service?.url+t,translationHelp:[{target:"subtitles_file_url",targetUrl:g},{target:"video_file_url",targetUrl:c}],detectedLanguage:h}:{url:c,translationHelp:null},duration:l,title:n,description:r}}async getVideoId(t){return t.pathname.slice(1)}},[ni.coursera]:vi,[ni.douyin]:fi,[ni.artstation]:class extends li{API_ORIGIN="https://www.artstation.com/api/v2/learning";getCSRFToken(){return document.querySelector('meta[name="public-csrf-token"]')?.content}async getCourseInfo(t){try{const e=await this.fetch(`${this.API_ORIGIN}/courses/${t}/autoplay.json`,{method:"POST",headers:{"PUBLIC-CSRF-TOKEN":this.getCSRFToken()}});return await e.json()}catch(e){return St.error(`Failed to get artstation course info by courseId: ${t}.`,e.message),!1}}async getVideoUrl(t){try{const e=await this.fetch(`${this.API_ORIGIN}/quicksilver/video_url.json?chapter_id=${t}`);return(await e.json()).url.replace("qsep://","https://")}catch(e){return St.error(`Failed to get artstation video url by chapterId: ${t}.`,e.message),!1}}async getVideoData(t){const[,e,,,i]=t.split("/"),o=await this.getCourseInfo(e);if(!o)return;const a=o.chapters.find((t=>t.hash_id===i));if(!a)return;const n=await this.getVideoUrl(a.id);if(!n)return;const{title:r,duration:s,subtitles:l}=a;return{url:n,title:r,duration:s,subtitles:l.filter((t=>"vtt"===t.format)).map((t=>({language:we(t.locale),source:"artstation",format:"vtt",url:t.file_url})))}}async getVideoId(t){return/courses\/(\w{3,5})\/([^/]+)\/chapters\/(\w{3,5})/.exec(t.pathname)?.[0]}}};class yi{helpersData;constructor(t={}){this.helpersData=t}getHelper(t){return new wi[t](this.helpersData)}}async function xi(t,e={}){const i=new URL(window.location.href),o=t.host;if(Object.keys(wi).includes(o)){const t=new yi(e).getHelper(o);return await t.getVideoId(i)}return o===Ce.custom?i.href:void 0}function Si(t,e=","){const i=t/1e3,o=Math.floor(i/3600),a=Math.floor(i%3600/60),n=Math.floor(i%60),r=Math.floor(t%1e3);return`${o.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}${e}${r.toString().padStart(3,"0")}`}function ki(t){const e=t.split(" ")?.[0]?.split(":");e.length<3&&e.unshift("00");const[i,o,a]=e;return 36e5*+i+6e4*+o+ +a.replace(/[,.]/,"")}function Ti(t,e="srt"){const i="vtt"===e,o=i?".":",",a=t.subtitles.map(((t,e)=>(i?"":`${e+1}\n`)+`${Si(t.startMs,o)} --\x3e ${Si(t.startMs+t.durationMs,o)}\n${t.text}\n\n`)).join("").trim();return i?`WEBVTT\n\n${a}`:a}function Ci(t,e="srt"){const i=function(t){return"string"!=typeof t?"json":/^(WEBVTT)(\r?\n)/.exec(t)?"vtt":"srt"}(t);return i===e?t:"json"===i?Ti(t,e):(t=function(t,e="srt"){const i=t.split(/\r?\n\r?\n/g);"vtt"===e&&i.shift(),/^\d+\r?\n/.exec(i?.[0]??"")&&(e="srt");const o=+("srt"===e);return{containsTokens:!1,subtitles:i.reduce(((t,e)=>{const i=e.trim().split("\n"),a=i[o],n=i.slice(o+1).join("\n");if(!(2===i.length&&e.includes(" --\x3e ")||a?.includes(" --\x3e ")))return 0===t.length||(t[t.length-1].text+=`\n\n${i.join("\n")}`),t;const[r,s]=a.split(" --\x3e "),l=ki(r),d=ki(s)-l;return t.push({text:n,startMs:l,durationMs:d,speakerId:"0"}),t}),[])}}(t,i),"json"===e?t:Ti(t,e))}class Ii{static formatYandexTokens(t){const e=t.startMs+t.durationMs;return t.tokens.reduce(((i,o,a)=>{const n=t.tokens[a+1],r=i[i.length-1],s=r?.alignRange?.end??0,l=s+o.text.length;if(o.alignRange={start:s,end:l},i.push(o),n){const t=o.startMs+o.durationMs,a=n.startMs?n.startMs-t:e-t;i.push({text:" ",startMs:t,durationMs:a,alignRange:{start:l,end:l+1}})}return i}),[])}static createTokens(t,e){const i=t.text.split(/([\n \t])/).reduce(((t,i)=>{if(!i.length)return t;const o=t[t.length-1]??e,a=o?.alignRange?.end??0,n=a+i.length;return t.push({text:i,alignRange:{start:a,end:n}}),t}),[]),o=Math.floor(t.durationMs/i.length),a=t.startMs+t.durationMs;return i.map(((e,n)=>{const r=n===i.length-1,s=t.startMs+o*n;return{...e,startMs:s,durationMs:r?a-s:o}}))}static processTokens(t,e){const i=[];let o;const{source:a,isAutoGenerated:n}=e;for(const e of t.subtitles){const t=e?.tokens?.length,r=t&&("yandex"===a||"youtube"===a&&n)?this.formatYandexTokens(e):this.createTokens(e,o);o=r[r.length-1],i.push({...e,tokens:r})}return t.containsTokens=!0,i}static formatYoutubeSubtitles(t,e=!1){if(!t?.events?.length)return console.error("[VOT] Invalid YouTube subtitles format:",t),{containsTokens:e,subtitles:[]};const i={containsTokens:e,subtitles:[]};for(let o=0;o<t.events.length;o++){const a=t.events[o];if(!a.segs)continue;let n=a.dDurationMs;t.events[o+1]&&a.tStartMs+a.dDurationMs>t.events[o+1].tStartMs&&(n=t.events[o+1].tStartMs-a.tStartMs);const r=[];let s=n;for(let t=0;t<a.segs.length;t++){const e=a.segs[t],i=e.utf8.trim();if("\n"===i)continue;const o=e.tOffsetMs??0;let l=n;const d=a.segs[t+1];d?.tOffsetMs&&(l=d.tOffsetMs-o,s-=l),r.push({text:i,startMs:a.tStartMs+o,durationMs:d?l:s})}const l=r.map((t=>t.text)).join(" ");l&&i.subtitles.push({text:l,startMs:a.tStartMs,durationMs:n,...e?{tokens:r}:{}})}return i}static cleanJsonSubtitles(t){const{containsTokens:e,subtitles:i}=t;return{containsTokens:e,subtitles:i.map((t=>({...t,text:t.text.replace(/(<([^>]+)>)/gi,"")})))}}static async fetchSubtitles(t){const{source:e,isAutoGenerated:i,format:o,url:a}=t;try{const n=await ze(a,{timeout:7e3});let r;if(["vtt","srt"].includes(o)){r=Ci(await n.text(),"json")}else r=await n.json();return"youtube"===e&&(r=this.formatYoutubeSubtitles(r,i)),"vk"===e&&(r=this.cleanJsonSubtitles(r)),r.subtitles=this.processTokens(r,t),console.log("[VOT] Processed subtitles:",r),r}catch(t){return console.error("[VOT] Failed to process subtitles:",t),{containsTokens:!1,subtitles:[]}}}static async getSubtitles(t,e){const{host:i,url:o,detectedLanguage:a,videoId:n,duration:r,subtitles:s=[]}=e;try{const e=await Promise.race([t.getSubtitles({videoData:{host:i,url:o,videoId:n,duration:r},requestLang:a}),new Promise(((t,e)=>setTimeout((()=>e(new Error("Timeout"))),5e3)))]);console.log("[VOT] Subtitles response:",e),e.waiting&&console.error("[VOT] Failed to get Yandex subtitles");const l=(e.subtitles??[]).reduce(((t,e)=>(e.language&&!t.find((t=>"yandex"===t.source&&t.language===e.language&&!t.translatedFromLanguage))&&t.push({source:"yandex",language:e.language,url:e.url}),e.translatedLanguage&&t.push({source:"yandex",language:e.translatedLanguage,translatedFromLanguage:e.language,url:e.translatedUrl}),t)),[]);return[...l,...s].sort(((t,e)=>{if(t.source!==e.source)return"yandex"===t.source?-1:1;if(t.language!==e.language&&(t.language===$e||e.language===$e))return t.language===$e?-1:1;if("yandex"===t.source){if(t.translatedFromLanguage!==e.translatedFromLanguage)return t.translatedFromLanguage&&e.translatedFromLanguage?t.translatedFromLanguage===a?-1:1:t.language===e.language?t.translatedFromLanguage?1:-1:t.translatedFromLanguage?-1:1;if(!t.translatedFromLanguage)return t.language===a?-1:1}return"yandex"!==t.source&&t.isAutoGenerated!==e.isAutoGenerated?t.isAutoGenerated?1:-1:0}))}catch(t){const e="Timeout"===t.message?"Failed to get Yandex subtitles: timeout":"Error in getSubtitles function";throw console.error(`[VOT] ${e}`,t),t}}}class Pi{constructor(t,e,i){this.video=t,this.container="youtube"===i.host&&"mobile"!==i.additionalData?e.parentElement:e,this.site=i,this.subtitlesContainer=this.createSubtitlesContainer(),this.position={left:25,top:75},this.dragging={active:!1,offset:{x:0,y:0}},this.subtitles=null,this.lastContent=null,this.highlightWords=!1,this.fontSize=20,this.opacity=.2,this.maxLength=300,this.abortController=new AbortController,this.bindEvents(),this.updateContainerRect()}createSubtitlesContainer(){return this.subtitlesContainer=document.createElement("vot-block"),this.subtitlesContainer.classList.add("vot-subtitles-widget"),this.container.appendChild(this.subtitlesContainer),this.subtitlesContainer}bindEvents(){const{signal:t}=this.abortController;this.onPointerDownBound=t=>this.onPointerDown(t),this.onPointerUpBound=()=>this.onPointerUp(),this.onPointerMoveBound=t=>this.onPointerMove(t),this.onTimeUpdateBound=this.debounce((()=>this.update()),100),document.addEventListener("pointerdown",this.onPointerDownBound,{signal:t}),document.addEventListener("pointerup",this.onPointerUpBound,{signal:t}),document.addEventListener("pointermove",this.onPointerMoveBound,{signal:t}),this.video?.addEventListener("timeupdate",this.onTimeUpdateBound,{signal:t}),this.resizeObserver=new ResizeObserver((()=>this.onResize())),this.resizeObserver.observe(this.container)}onPointerDown(t){if(!this.subtitlesContainer.contains(t.target))return;const e=this.subtitlesContainer.getBoundingClientRect(),i=this.container.getBoundingClientRect();this.dragging={active:!0,offset:{x:t.clientX-e.left,y:t.clientY-e.top},containerOffset:{x:i.left,y:i.top}}}onPointerUp(){this.dragging.active=!1}onPointerMove(t){if(!this.dragging.active)return;t.preventDefault();const{width:e,height:i}=this.container.getBoundingClientRect(),{containerOffset:o,offset:a}=this.dragging;this.position={left:(t.clientX-a.x-o.x)/e*100,top:(t.clientY-a.y-o.y)/i*100},this.applySubtitlePosition()}onResize(){this.updateContainerRect()}updateContainerRect(){this.containerRect=this.container.getBoundingClientRect(),this.applySubtitlePosition()}applySubtitlePosition(){const{width:t,height:e}=this.containerRect,{offsetWidth:i,offsetHeight:o}=this.subtitlesContainer,a=(t-i)/t*100,n=(e-o)/e*100;this.position.left=Math.max(0,Math.min(this.position.left,a)),this.position.top=Math.max(0,Math.min(this.position.top,n)),this.subtitlesContainer.style.left=`${this.position.left}%`,this.subtitlesContainer.style.top=`${this.position.top}%`}processTokens(t){if(t.at(-1).alignRange.end<=this.maxLength)return t;const e=[];let i=[],o=0;for(const a of t)o+=a.text.length,i.push(a),o>this.maxLength&&(e.push(this.trimChunk(i)),i=[],o=0);i.length&&e.push(this.trimChunk(i));const a=1e3*this.video.currentTime;return e.find((t=>t[0].startMs<a&&a<t.at(-1).startMs+t.at(-1).durationMs))||e[0]}trimChunk(t){return" "===t[0]?.text&&t.shift()," "===t.at(-1)?.text&&t.pop(),t}renderTokens(t,e){return t.map((t=>{const i=this.highlightWords&&(e>t.startMs+t.durationMs/2||e>t.startMs-100&&t.startMs+t.durationMs/2-e<275);return k`<span class="${i?"passed":I}"> ${t.text.replace("\\n","<br>")} </span>`}))}debounce(t,e){let i;return(...o)=>{clearTimeout(i),i=setTimeout((()=>t.apply(this,o)),e)}}setContent(t){if(!t||!this.video)return this.subtitles=null,void U(null,this.subtitlesContainer);this.subtitles=t,this.update()}setMaxLength(t){"number"==typeof t&&t>0&&(this.maxLength=t,this.update())}setHighlightWords(t){this.highlightWords=Boolean(t),this.update()}setFontSize(t){this.fontSize=t;const e=this.subtitlesContainer?.querySelector(".vot-subtitles");e&&(e.style.fontSize=`${t}px`)}setOpacity(t){this.opacity=((100-+t)/100).toFixed(2);const e=this.subtitlesContainer?.querySelector(".vot-subtitles");e&&e.style.setProperty("--vot-subtitles-opacity",this.opacity)}update(){if(!this.video||!this.subtitles)return;const t=1e3*this.video.currentTime,e=this.subtitles.subtitles.findLast((e=>e.startMs<t&&t<e.startMs+e.durationMs));if(!e)return void U(null,this.subtitlesContainer);const i=this.processTokens(e.tokens),o=this.renderTokens(i,t),a=JSON.stringify(o);a!==this.lastContent&&(this.lastContent=a,U(k`<vot-block class="vot-subtitles" @@ -285,7 +285,7 @@ <path d="M647-440H200q-17 0-28.5-11.5T160-480q0-17 11.5-28.5T200-520h447L451-716q-12-12-11.5-28t12.5-28q12-11 28-11.5t28 11.5l264 264q6 6 8.5 13t2.5 15q0 8-2.5 15t-8.5 13L508-188q-11 11-27.5 11T452-188q-12-12-12-28.5t12-28.5l195-195Z" /> - </svg>`,c);const h=this.createVOTSelect(n,r,s,{onSelectCb:l});return d.append(u.container,c,h.container),{container:d,fromSelect:u,icon:c,toSelect:h}}static createDetails(t){const e=document.createElement("vot-block");e.classList.add("vot-details");const i=document.createElement("vot-block");i.append(t);const o=document.createElement("vot-block");return o.classList.add("vot-details-arrow-icon"),U(this.arrowIconRaw,o),e.append(i,o),{container:e,header:i,arrowIcon:o}}static animateLoader(t,e="139, 180, 245"){const i=t.querySelector(".vot-loader-helper"),o=t.querySelector(".vot-loader-main");anime.timeline({...this.animeOpts,targets:[i,o],duration:250}).add({"fill-opacity":0,"stroke-width":2,d:"M 12 1.5 C 17.799 1.5 22.5 6.201 22.5 12 C 22.5 17.799 17.799 22.5 12 22.5 C 6.201 22.5 1.5 17.799 1.5 12 C 1.5 6.201 6.201 1.5 12 1.5 Z",duration:0}).add({targets:i,stroke:`rgb(${e})`,"stroke-opacity":0,duration:0},0).add({targets:o,stroke:"#888888","stroke-opacity":.25},0);const a=anime.timeline({targets:i,easing:"easeInOutSine",duration:1e3,autoplay:!1}).add({strokeOpacity:1,duration:0},0).add({strokeDashoffset:[anime.setDashoffset,0]},0);return t=>a.seek(a.duration*(t/100))}static afterAnimateLoader(t,e="139, 180, 245"){const i=t.querySelector(".vot-loader-helper"),o=t.querySelector(".vot-loader-main");anime.timeline({...this.animeOpts,targets:o,duration:600}).add({d:"M 9.0596 14.8571 L 9.7667 15.5642 L 10.4738 14.8571 L 17.0071 8.3238 C 17.0457 8.2852 17.0937 8.25 17.2333 8.25 C 17.373 8.25 17.421 8.2852 17.4596 8.3238 C 17.4981 8.3624 17.5333 8.4104 17.5333 8.55 C 17.5333 8.6896 17.4981 8.7376 17.4596 8.7762 L 9.9929 16.2429 C 9.9011 16.3346 9.8397 16.35 9.7667 16.35 C 9.6937 16.35 9.6322 16.3346 9.5404 16.2429 L 6.0738 12.7762 C 6.0352 12.7376 6 12.6897 6 12.55 C 6 12.4103 6.0352 12.3624 6.0738 12.3238 C 6.1124 12.2852 6.1603 12.25 6.3 12.25 C 6.4397 12.25 6.4876 12.2852 6.5262 12.3238 L 9.0596 14.8571 Z",duration:0}).add({strokeDashoffset:[anime.setDashoffset,0],stroke:`rgb(${e})`,"stroke-opacity":1}),setTimeout((()=>{anime.timeline({...this.animeOpts,targets:o,duration:600}).add({d:"M12 15.575C11.8667 15.575 11.7417 15.5542 11.625 15.5125C11.5083 15.4708 11.4 15.4 11.3 15.3L7.7 11.7C7.5 11.5 7.40417 11.2667 7.4125 11C7.42083 10.7333 7.51667 10.5 7.7 10.3C7.9 10.1 8.1375 9.99583 8.4125 9.9875C8.6875 9.97917 8.925 10.075 9.125 10.275L11 12.15V5C11 4.71667 11.0958 4.47917 11.2875 4.2875C11.4792 4.09583 11.7167 4 12 4C12.2833 4 12.5208 4.09583 12.7125 4.2875C12.9042 4.47917 13 4.71667 13 5V12.15L14.875 10.275C15.075 10.075 15.3125 9.97917 15.5875 9.9875C15.8625 9.99583 16.1 10.1 16.3 10.3C16.4833 10.5 16.5792 10.7333 16.5875 11C16.5958 11.2667 16.5 11.5 16.3 11.7L12.7 15.3C12.6 15.4 12.4917 15.4708 12.375 15.5125C12.2583 15.5542 12.1333 15.575 12 15.575ZM6 20C5.45 20 4.97917 19.8042 4.5875 19.4125C4.19583 19.0208 4 18.55 4 18V16C4 15.7167 4.09583 15.4792 4.2875 15.2875C4.47917 15.0958 4.71667 15 5 15C5.28333 15 5.52083 15.0958 5.7125 15.2875C5.90417 15.4792 6 15.7167 6 16V18H18V16C18 15.7167 18.0958 15.4792 18.2875 15.2875C18.4792 15.0958 18.7167 15 19 15C19.2833 15 19.5208 15.0958 19.7125 15.2875C19.9042 15.4792 20 15.7167 20 16V18C20 18.55 19.8042 19.0208 19.4125 19.4125C19.0208 19.8042 18.55 20 18 20H6Z",duration:100}).add({targets:i,d:"",duration:200},0).add({targets:o,"stroke-width":"0",stroke:`rgba(${e}), 0)`,"fill-opacity":"1","stroke-dasharray":"0","stroke-dashoffset":"0",duration:0})}),2e3)}}i("./node_modules/requestidlecallback-polyfill/index.js");class _i{constructor(){this.listeners=new Set}addListener(t){if(this.listeners.has(t))throw new Error("[VOT] The listener has already been added.");this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}dispatch(...t){for(const e of this.listeners)try{e(...t)}catch(t){console.error("[VOT]",t)}}}class Ai{static adKeywords=new Set(["advertise","promo","sponsor","banner","commercial","preroll","midroll","postroll","ad-container","sponsored"]);constructor(){this.videoCache=new WeakSet,this.observedNodes={added:new Set,removed:new Set},this.onVideoAdded=new _i,this.onVideoRemoved=new _i,this.observer=new MutationObserver(this.handleMutations)}isAdRelated(t){if(!t)return!1;const e=[Array.from(t.classList),[t.id,t.title]];for(const t of e)for(const e of t)if(Ai.adKeywords.has(e.toLowerCase()))return!0;return!1}isValidVideo(t){if(this.isAdRelated(t))return!1;let e=t.parentElement;for(;e&&!this.isAdRelated(e);)e=e.parentElement;if(e)return!1;return!(t.hasAttribute("muted")&&!t.classList.contains("vjs-tech")&&!t.preload||t.src.includes("v.redd.it"))||(Pe.log("Ignoring video element:",t),!1)}traverseDOM(t){const e=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:t=>"VIDEO"===t.tagName||t.shadowRoot?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;e.nextNode();){const t=e.currentNode;t instanceof HTMLVideoElement&&this.checkVideoState(t),t.shadowRoot&&this.traverseDOM(t.shadowRoot)}}checkVideoState(t){!this.videoCache.has(t)&&this.isValidVideo(t)&&(this.videoCache.add(t),t.addEventListener("timeupdate",(()=>this.onVideoAdded.dispatch(t)),{once:!0}))}handleMutations=t=>{for(const e of t)if("childList"===e.type){for(const t of e.addedNodes)this.observedNodes.added.add(t);for(const t of e.removedNodes)this.observedNodes.removed.add(t)}window.requestIdleCallback((()=>{for(const t of this.observedNodes.added)this.traverseDOM(t);for(const t of this.observedNodes.removed)if(t.querySelectorAll){const e=t.querySelectorAll("video");for(const t of e)t.isConnected||(this.onVideoRemoved.dispatch(t),this.videoCache.delete(t))}this.observedNodes.added.clear(),this.observedNodes.removed.clear()}),{timeout:1e3})};enable(){this.observer.observe(document.documentElement,{childList:!0,subtree:!0}),this.traverseDOM(document.documentElement)}disable(){this.observer.disconnect(),this.videoCache=new WeakSet}}const Oi=new class{isFOSWLYError(t){return Object.hasOwn(t,"error")}async request(t,e={}){try{const i=await ze(`https://translate.toil.cc/v2${t}`,{timeout:3e3,...e}),o=await i.json();if(this.isFOSWLYError(o))throw o.error;return o}catch(t){return void console.error(`[VOT] Failed to get data from FOSWLY Translate API, because ${t.message}`)}}async translate(t,e,i){const o=await this.request(`/translate?${new URLSearchParams({text:t,lang:e,service:i})}`);return o?o.translations[0]:t}async detect(t,e){const i=await this.request(`/detect?${new URLSearchParams({text:t,service:e})}`);return i?i.lang:"en"}},Vi={async detect(t){try{const e=await ze("https://rust-server-531j.onrender.com/detect",{method:"POST",body:t,timeout:3e3});return await e.text()}catch(t){return console.error(`[VOT] Error getting lang from text, because ${t.message}`),"en"}}};const Mi=["yandexbrowser","msedge"],Ei=[...Mi,"rust-server"],Bi=t.getParser(window.navigator.userAgent).getResult();function Ni(t,e){return t.map((t=>({label:Ge.get("langs")[t]??t.toUpperCase(),value:t,selected:e===t})))}const Ri=t=>t?Ge.get("VOTChangeHotkeyWithCurrent").replace("{0}",t.replace("Key","")):Ge.get("VOTCreateTranslationHotkey");let $i;class Di{translateFromLang="auto";translateToLang=Re;timer;videoData="";firstPlay=!0;audioContext=mt();hls=De();votClient;audioPlayer;videoTranslations=[];videoTranslationTTL=7200;cachedTranslation;downloadTranslationUrl=null;autoRetry;streamPing;votOpts;volumeOnStart;tempOriginalVolume;tempVolume;firstSyncVolume=!0;longWaitingResCount=0;subtitlesList=[];subtitlesListVideoId=null;dragging;constructor(t,e,i){Pe.log("[VideoHandler] add video:",t,"container:",e,this),this.video=t,this.container=e,this.site=i,this.abortController=new AbortController,this.extraEvents=[],this.init()}async translateVideoImpl(t,e,i,o=null){if(clearTimeout(this.autoRetry),Pe.log(t,`Translate video (requestLang: ${e}, responseLang: ${i})`),await xi(this.site,{fetchFn:ze,video:this.video})!==t.videoId)return null;try{const a=await this.votClient.translateVideo({videoData:t,requestLang:e,responseLang:i,translationHelp:o,extraOpts:{useNewModel:this.data?.useNewModel,videoTitle:this.videoData.title}});if(Pe.log("Translate video result",a),a.translated&&a.remainingTime<1)return Pe.log("Video translation finished with this data: ",a),a;const n=a.message??Ge.get("translationTakeFewMinutes");await this.updateTranslationErrorMsg(a.remainingTime>0?function(t){let e=Math.floor(t/60),i=Math.floor(t%60);return i/60>=.66&&(e+=1,i=0),e>=60?Ge.get("translationTakeMoreThanHour"):1===e||0===e&&i>0?Ge.get("translationTakeAboutMinute"):11!==e&&e%10==1?Ge.get("translationTakeApproximatelyMinute2").replace("{0}",e):![12,13,14].includes(e)&&[2,3,4].includes(e%10)?Ge.get("translationTakeApproximatelyMinute").replace("{0}",e):Ge.get("translationTakeApproximatelyMinutes").replace("{0}",e)}(a.remainingTime):n)}catch(t){return console.error("[VOT] Failed to translate video",t),await this.updateTranslationErrorMsg(t.data?.message??t),null}return new Promise((a=>{const n=this.subtitlesList.some((t=>"yandex"===t.source))?2e4:3e4;this.autoRetry=setTimeout((async()=>{const n=await this.translateVideoImpl(t,e,i,o);(!n||n.translated&&n.remainingTime<1)&&a(n)}),n)}))}async translateStreamImpl(t,e,i){if(clearTimeout(this.autoRetry),Pe.log(t,`Translate stream (requestLang: ${e}, responseLang: ${i})`),await xi(this.site,{fetchFn:ze,video:this.video})!==t.videoId)return null;try{const o=await this.votClient.translateStream({videoData:t,requestLang:e,responseLang:i});if(Pe.log("Translate stream result",o),!o.translated&&10===o.interval)return await this.updateTranslationErrorMsg(Ge.get("translationTakeFewMinutes")),new Promise((a=>{this.autoRetry=setTimeout((async()=>{const o=await this.translateStreamImpl(t,e,i);o&&!o.translated&&10===o.interval||a(o)}),1e3*o.interval)}));if(o.message)throw Pe.log(`Stream translation aborted! Message: ${o.message}`),new Ye("streamNoConnectionToServer");if(!o.result)throw Pe.log("Failed to find translation result! Data:",o),new Ye("audioNotReceived");return Pe.log("Stream translated successfully. Running...",o),this.streamPing=setInterval((async()=>{Pe.log("Ping stream translation",o.pingId),this.votClient.pingStream({pingId:o.pingId})}),1e3*o.interval),o}catch(t){return console.error("[VOT] Failed to translate stream",t),await this.updateTranslationErrorMsg(t.data?.message??t),null}}async autoTranslate(){if(this.firstPlay&&1===this.data.autoTranslate&&this.videoData.videoId){this.firstPlay=!1;try{await this.translateExecutor(this.videoData.videoId)}catch(t){console.error("[VOT]",t),this.transformBtn("error","VOTLocalizedError"===t?.name?t.localizedMessage:t)}}}getPreferAudio(){return!this.audioContext||(!this.data.newAudioPlayer||(!!this.videoData.isStream||!(this.data.newAudioPlayer&&!this.data.onlyBypassMediaCSP)&&!this.site.needBypassCSP))}createPlayer(){const t=this.getPreferAudio();return Pe.log("preferAudio:",t),this.audioPlayer=new wt({video:this.video,debug:!1,fetchFn:ze,preferAudio:t}),this}async init(){if(this.initialized)return;const t={autoTranslate:Be.get("autoTranslate",0),dontTranslateLanguage:Be.get("dontTranslateLanguage",[Re]),dontTranslateYourLang:Be.get("dontTranslateYourLang",1),autoSetVolumeYandexStyle:Be.get("autoSetVolumeYandexStyle",1),autoVolume:Be.get("autoVolume",Ae),buttonPos:Be.get("buttonPos","default"),showVideoSlider:Be.get("showVideoSlider",1),syncVolume:Be.get("syncVolume",0),downloadWithName:Be.get("downloadWithName",1),sendNotifyOnComplete:Be.get("sendNotifyOnComplete",0),subtitlesMaxLength:Be.get("subtitlesMaxLength",300),highlightWords:Be.get("highlightWords",0),subtitlesFontSize:Be.get("subtitlesFontSize",20),subtitlesOpacity:Be.get("subtitlesOpacity",20),subtitlesDownloadFormat:Be.get("subtitlesDownloadFormat","srt"),responseLanguage:Be.get("responseLanguage",Re),defaultVolume:Be.get("defaultVolume",100),onlyBypassMediaCSP:Be.get("onlyBypassMediaCSP",Number(!!this.audioContext)),newAudioPlayer:Be.get("newAudioPlayer",Number(!!this.audioContext)),showPiPButton:Be.get("showPiPButton",0),translateAPIErrors:Be.get("translateAPIErrors",1),translationService:Be.get("translationService",Oe),detectService:Be.get("detectService",Ve),hotkeyButton:Be.get("hotkeyButton",null),m3u8ProxyHost:Be.get("m3u8ProxyHost",Le),proxyWorkerHost:Be.get("proxyWorkerHost",_e),translateProxyEnabled:Be.get("translateProxyEnabled",0),audioBooster:Be.get("audioBooster",0),useNewModel:Be.get("useNewModel",1),localeHash:Be.get("locale-hash",""),localeUpdatedAt:Be.get("locale-updated-at",0)};if(this.data=Object.fromEntries(await Promise.all(Object.entries(t).map((async([t,e])=>[t,await e])))),console.log("[VOT] data from db: ",this.data),await Ee(this.data,"m3u8ProxyHost","m3u8-proxy.toil.cc",Le),await Ee(this.data,"proxyWorkerHost","vot.toil.cc",_e),await Ee(this.data,"detectService","yandex",Ve),await Ee(this.data,"translationService","yandex",Oe),await Ee(this.data,"dontTranslateLanguage",!1,[this.data.dontTranslateLanguage],Array.isArray(this.data.dontTranslateLanguage)),!this.data.translateProxyEnabled&&GM_info?.scriptHandler&&Me.includes(GM_info.scriptHandler)&&(this.data.translateProxyEnabled=1),$i)"UA"===$i&&(this.data.translateProxyEnabled=2);else try{const t=await ze("https://speed.cloudflare.com/meta",{timeout:7e3});({country:$i}=await t.json()),"UA"===$i&&(this.data.translateProxyEnabled=2)}catch(t){console.error("[VOT] Error getting country:",t)}Pe.log("translateProxyEnabled",this.data.translateProxyEnabled),Pe.log("Extension compatibility passed..."),this.initVOTClient(),this.subtitlesWidget=new Pi(this.video,this.container,this.site),this.subtitlesWidget.setMaxLength(this.data.subtitlesMaxLength),this.subtitlesWidget.setHighlightWords(this.data.highlightWords),this.subtitlesWidget.setFontSize(this.data.subtitlesFontSize),this.subtitlesWidget.setOpacity(this.data.subtitlesOpacity),this.initUI(),this.initUIEvents(),this.videoData=await this.getVideoData(),this.createPlayer(),this.setSelectMenuValues(this.videoData.detectedLanguage,this.data.responseLanguage??"ru"),this.translateToLang=this.data.responseLanguage??"ru",this.initExtraEvents(),await this.autoTranslate(),this.initialized=!0}initVOTClient(){return this.votOpts={fetchFn:ze,hostVOT:"https://vot.toil.cc/v1",host:this.data.translateProxyEnabled?this.data.proxyWorkerHost:"api.browser.yandex.ru"},this.votClient=new(this.data.translateProxyEnabled?ii:ei)(this.votOpts),this}isLoadingText(t){return t.includes(Ge.get("translationTake"))||t.includes(Ge.get("TranslationDelayed"))}transformBtn(t,e){this.votButton.container.dataset.status=t;const i="error"===t&&this.isLoadingText(e);return this.setLoadingBtn(i),this.votButton.label.textContent=e,this.votButton.container.title="error"===t?e:"",this}setLoadingBtn(t=!1){return this.votButton.container.dataset.loading=t,this}initUI(){this.votButton=Li.createVOTButton(Ge.get("translateVideo")),this.votButton.container.style.opacity=0,this.data?.buttonPos&&"default"!==this.data?.buttonPos&&this.container.clientWidth>550?(this.votButton.container.dataset.direction="column",this.votButton.container.dataset.position=this.data?.buttonPos):(this.votButton.container.dataset.direction="row",this.votButton.container.dataset.position="default"),this.container.appendChild(this.votButton.container),this.votButton.pipButton.hidden=!$e()||!this.data?.showPiPButton,this.votButton.separator2.hidden=!$e()||!this.data?.showPiPButton,this.votButton.container.addEventListener("click",(t=>{t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()})),this.votMenu=Li.createVOTMenu(Ge.get("VOTSettings")),this.votMenu.container.dataset.position=this.container.clientWidth&&this.container.clientWidth>550?this.data?.buttonPos:"default",this.container.appendChild(this.votMenu.container),this.votDownloadButton=Li.createIconButton(T`<svg + </svg>`,c);const h=this.createVOTSelect(n,r,s,{onSelectCb:l});return d.append(u.container,c,h.container),{container:d,fromSelect:u,icon:c,toSelect:h}}static createDetails(t){const e=document.createElement("vot-block");e.classList.add("vot-details");const i=document.createElement("vot-block");i.append(t);const o=document.createElement("vot-block");return o.classList.add("vot-details-arrow-icon"),U(this.arrowIconRaw,o),e.append(i,o),{container:e,header:i,arrowIcon:o}}static animateLoader(t,e="139, 180, 245"){const i=t.querySelector(".vot-loader-helper"),o=t.querySelector(".vot-loader-main");anime.timeline({...this.animeOpts,targets:[i,o],duration:250}).add({"fill-opacity":0,"stroke-width":2,d:"M 12 1.5 C 17.799 1.5 22.5 6.201 22.5 12 C 22.5 17.799 17.799 22.5 12 22.5 C 6.201 22.5 1.5 17.799 1.5 12 C 1.5 6.201 6.201 1.5 12 1.5 Z",duration:0}).add({targets:i,stroke:`rgb(${e})`,"stroke-opacity":0,duration:0},0).add({targets:o,stroke:"#888888","stroke-opacity":.25},0);const a=anime.timeline({targets:i,easing:"easeInOutSine",duration:1e3,autoplay:!1}).add({strokeOpacity:1,duration:0},0).add({strokeDashoffset:[anime.setDashoffset,0]},0);return t=>a.seek(a.duration*(t/100))}static afterAnimateLoader(t,e="139, 180, 245"){const i=t.querySelector(".vot-loader-helper"),o=t.querySelector(".vot-loader-main");anime.timeline({...this.animeOpts,targets:o,duration:600}).add({d:"M 9.0596 14.8571 L 9.7667 15.5642 L 10.4738 14.8571 L 17.0071 8.3238 C 17.0457 8.2852 17.0937 8.25 17.2333 8.25 C 17.373 8.25 17.421 8.2852 17.4596 8.3238 C 17.4981 8.3624 17.5333 8.4104 17.5333 8.55 C 17.5333 8.6896 17.4981 8.7376 17.4596 8.7762 L 9.9929 16.2429 C 9.9011 16.3346 9.8397 16.35 9.7667 16.35 C 9.6937 16.35 9.6322 16.3346 9.5404 16.2429 L 6.0738 12.7762 C 6.0352 12.7376 6 12.6897 6 12.55 C 6 12.4103 6.0352 12.3624 6.0738 12.3238 C 6.1124 12.2852 6.1603 12.25 6.3 12.25 C 6.4397 12.25 6.4876 12.2852 6.5262 12.3238 L 9.0596 14.8571 Z",duration:0}).add({strokeDashoffset:[anime.setDashoffset,0],stroke:`rgb(${e})`,"stroke-opacity":1}),setTimeout((()=>{anime.timeline({...this.animeOpts,targets:o,duration:600}).add({d:"M12 15.575C11.8667 15.575 11.7417 15.5542 11.625 15.5125C11.5083 15.4708 11.4 15.4 11.3 15.3L7.7 11.7C7.5 11.5 7.40417 11.2667 7.4125 11C7.42083 10.7333 7.51667 10.5 7.7 10.3C7.9 10.1 8.1375 9.99583 8.4125 9.9875C8.6875 9.97917 8.925 10.075 9.125 10.275L11 12.15V5C11 4.71667 11.0958 4.47917 11.2875 4.2875C11.4792 4.09583 11.7167 4 12 4C12.2833 4 12.5208 4.09583 12.7125 4.2875C12.9042 4.47917 13 4.71667 13 5V12.15L14.875 10.275C15.075 10.075 15.3125 9.97917 15.5875 9.9875C15.8625 9.99583 16.1 10.1 16.3 10.3C16.4833 10.5 16.5792 10.7333 16.5875 11C16.5958 11.2667 16.5 11.5 16.3 11.7L12.7 15.3C12.6 15.4 12.4917 15.4708 12.375 15.5125C12.2583 15.5542 12.1333 15.575 12 15.575ZM6 20C5.45 20 4.97917 19.8042 4.5875 19.4125C4.19583 19.0208 4 18.55 4 18V16C4 15.7167 4.09583 15.4792 4.2875 15.2875C4.47917 15.0958 4.71667 15 5 15C5.28333 15 5.52083 15.0958 5.7125 15.2875C5.90417 15.4792 6 15.7167 6 16V18H18V16C18 15.7167 18.0958 15.4792 18.2875 15.2875C18.4792 15.0958 18.7167 15 19 15C19.2833 15 19.5208 15.0958 19.7125 15.2875C19.9042 15.4792 20 15.7167 20 16V18C20 18.55 19.8042 19.0208 19.4125 19.4125C19.0208 19.8042 18.55 20 18 20H6Z",duration:100}).add({targets:i,d:"",duration:200},0).add({targets:o,"stroke-width":"0",stroke:`rgba(${e}), 0)`,"fill-opacity":"1","stroke-dasharray":"0","stroke-dashoffset":"0",duration:0})}),2e3)}}i("./node_modules/requestidlecallback-polyfill/index.js");class _i{constructor(){this.listeners=new Set}addListener(t){if(this.listeners.has(t))throw new Error("[VOT] The listener has already been added.");this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}dispatch(...t){for(const e of this.listeners)try{e(...t)}catch(t){console.error("[VOT]",t)}}}class Ai{static adKeywords=new Set(["advertise","promo","sponsor","banner","commercial","preroll","midroll","postroll","ad-container","sponsored"]);constructor(){this.videoCache=new WeakSet,this.observedNodes={added:new Set,removed:new Set},this.onVideoAdded=new _i,this.onVideoRemoved=new _i,this.observer=new MutationObserver(this.handleMutations)}isAdRelated(t){if(!t)return!1;const e=[Array.from(t.classList),[t.id,t.title]];for(const t of e)for(const e of t)if(Ai.adKeywords.has(e.toLowerCase()))return!0;return!1}isValidVideo(t){if(this.isAdRelated(t))return!1;let e=t.parentElement;for(;e&&!this.isAdRelated(e);)e=e.parentElement;if(e)return!1;return!(t.hasAttribute("muted")&&!t.classList.contains("vjs-tech")&&!t.preload||t.src.includes("v.redd.it"))||(Pe.log("Ignoring video element:",t),!1)}traverseDOM(t){const e=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:t=>"VIDEO"===t.tagName||t.shadowRoot?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;e.nextNode();){const t=e.currentNode;t instanceof HTMLVideoElement&&this.checkVideoState(t),t.shadowRoot&&this.traverseDOM(t.shadowRoot)}}checkVideoState(t){!this.videoCache.has(t)&&this.isValidVideo(t)&&(this.videoCache.add(t),t.addEventListener("timeupdate",(()=>this.onVideoAdded.dispatch(t)),{once:!0}))}handleMutations=t=>{for(const e of t)if("childList"===e.type){for(const t of e.addedNodes)this.observedNodes.added.add(t);for(const t of e.removedNodes)this.observedNodes.removed.add(t)}window.requestIdleCallback((()=>{for(const t of this.observedNodes.added)this.traverseDOM(t);for(const t of this.observedNodes.removed)if(t.querySelectorAll){const e=t.querySelectorAll("video");for(const t of e)t.isConnected||(this.onVideoRemoved.dispatch(t),this.videoCache.delete(t))}this.observedNodes.added.clear(),this.observedNodes.removed.clear()}),{timeout:1e3})};enable(){this.observer.observe(document.documentElement,{childList:!0,subtree:!0}),this.traverseDOM(document.documentElement)}disable(){this.observer.disconnect(),this.videoCache=new WeakSet}}const Oi=new class{isFOSWLYError(t){return Object.hasOwn(t,"error")}async request(t,e={}){try{const i=await ze(`https://translate.toil.cc/v2${t}`,{timeout:3e3,...e}),o=await i.json();if(this.isFOSWLYError(o))throw o.error;return o}catch(t){return void console.error(`[VOT] Failed to get data from FOSWLY Translate API, because ${t.message}`)}}async translate(t,e,i){const o=await this.request(`/translate?${new URLSearchParams({text:t,lang:e,service:i})}`);return o?o.translations[0]:t}async detect(t,e){const i=await this.request(`/detect?${new URLSearchParams({text:t,service:e})}`);return i?i.lang:"en"}},Vi={async detect(t){try{const e=await ze("https://rust-server-531j.onrender.com/detect",{method:"POST",body:t,timeout:3e3});return await e.text()}catch(t){return console.error(`[VOT] Error getting lang from text, because ${t.message}`),"en"}}};const Mi=["yandexbrowser","msedge"],Ei=[...Mi,"rust-server"],Bi=t.getParser(window.navigator.userAgent).getResult();function Ni(t,e){return t.map((t=>({label:Ge.get("langs")[t]??t.toUpperCase(),value:t,selected:e===t})))}const $i=t=>t?Ge.get("VOTChangeHotkeyWithCurrent").replace("{0}",t.replace("Key","")):Ge.get("VOTCreateTranslationHotkey");let Ri;class Di{translateFromLang="auto";translateToLang=$e;timer;videoData="";firstPlay=!0;audioContext=mt();hls=De();votClient;audioPlayer;videoTranslations=new Map;videoTranslationTTL=7200;cachedTranslation;downloadTranslationUrl=null;autoRetry;streamPing;votOpts;volumeOnStart;tempOriginalVolume;tempVolume;firstSyncVolume=!0;longWaitingResCount=0;subtitlesList=[];subtitlesListVideoId=null;dragging;constructor(t,e,i){Pe.log("[VideoHandler] add video:",t,"container:",e,this),this.video=t,this.container=e,this.site=i,this.abortController=new AbortController,this.extraEvents=[],this.init()}async translateVideoImpl(t,e,i,o=null){if(clearTimeout(this.autoRetry),Pe.log(t,`Translate video (requestLang: ${e}, responseLang: ${i})`),await xi(this.site,{fetchFn:ze,video:this.video})!==t.videoId)return null;try{const a=await this.votClient.translateVideo({videoData:t,requestLang:e,responseLang:i,translationHelp:o,extraOpts:{useNewModel:this.data?.useNewModel,videoTitle:this.videoData.title}});if(Pe.log("Translate video result",a),a.translated&&a.remainingTime<1)return Pe.log("Video translation finished with this data: ",a),a;const n=a.message??Ge.get("translationTakeFewMinutes");await this.updateTranslationErrorMsg(a.remainingTime>0?function(t){let e=Math.floor(t/60),i=Math.floor(t%60);return i/60>=.66&&(e+=1,i=0),e>=60?Ge.get("translationTakeMoreThanHour"):1===e||0===e&&i>0?Ge.get("translationTakeAboutMinute"):11!==e&&e%10==1?Ge.get("translationTakeApproximatelyMinute2").replace("{0}",e):![12,13,14].includes(e)&&[2,3,4].includes(e%10)?Ge.get("translationTakeApproximatelyMinute").replace("{0}",e):Ge.get("translationTakeApproximatelyMinutes").replace("{0}",e)}(a.remainingTime):n)}catch(t){return console.error("[VOT] Failed to translate video",t),await this.updateTranslationErrorMsg(t.data?.message??t),null}return new Promise((a=>{this.autoRetry=setTimeout((async()=>{const n=await this.translateVideoImpl(t,e,i,o);(!n||n.translated&&n.remainingTime<1)&&a(n)}),2e4)}))}async translateStreamImpl(t,e,i){if(clearTimeout(this.autoRetry),Pe.log(t,`Translate stream (requestLang: ${e}, responseLang: ${i})`),await xi(this.site,{fetchFn:ze,video:this.video})!==t.videoId)return null;try{const o=await this.votClient.translateStream({videoData:t,requestLang:e,responseLang:i});if(Pe.log("Translate stream result",o),!o.translated&&10===o.interval)return await this.updateTranslationErrorMsg(Ge.get("translationTakeFewMinutes")),new Promise((a=>{this.autoRetry=setTimeout((async()=>{const o=await this.translateStreamImpl(t,e,i);o&&!o.translated&&10===o.interval||a(o)}),1e3*o.interval)}));if(o.message)throw Pe.log(`Stream translation aborted! Message: ${o.message}`),new Ye("streamNoConnectionToServer");if(!o.result)throw Pe.log("Failed to find translation result! Data:",o),new Ye("audioNotReceived");return Pe.log("Stream translated successfully. Running...",o),this.streamPing=setInterval((async()=>{Pe.log("Ping stream translation",o.pingId),this.votClient.pingStream({pingId:o.pingId})}),1e3*o.interval),o}catch(t){return console.error("[VOT] Failed to translate stream",t),await this.updateTranslationErrorMsg(t.data?.message??t),null}}async autoTranslate(){if(this.firstPlay&&1===this.data.autoTranslate&&this.videoData.videoId){this.firstPlay=!1;try{await this.translateExecutor(this.videoData.videoId)}catch(t){console.error("[VOT]",t),this.transformBtn("error","VOTLocalizedError"===t?.name?t.localizedMessage:t)}}}getPreferAudio(){return!this.audioContext||(!this.data.newAudioPlayer||(!!this.videoData.isStream||!(this.data.newAudioPlayer&&!this.data.onlyBypassMediaCSP)&&!this.site.needBypassCSP))}createPlayer(){const t=this.getPreferAudio();return Pe.log("preferAudio:",t),this.audioPlayer=new wt({video:this.video,debug:!1,fetchFn:ze,preferAudio:t}),this}async init(){if(this.initialized)return;const t={autoTranslate:Be.get("autoTranslate",0),dontTranslateLanguage:Be.get("dontTranslateLanguage",[$e]),dontTranslateYourLang:Be.get("dontTranslateYourLang",1),autoSetVolumeYandexStyle:Be.get("autoSetVolumeYandexStyle",1),autoVolume:Be.get("autoVolume",Ae),buttonPos:Be.get("buttonPos","default"),showVideoSlider:Be.get("showVideoSlider",1),syncVolume:Be.get("syncVolume",0),downloadWithName:Be.get("downloadWithName",1),sendNotifyOnComplete:Be.get("sendNotifyOnComplete",0),subtitlesMaxLength:Be.get("subtitlesMaxLength",300),highlightWords:Be.get("highlightWords",0),subtitlesFontSize:Be.get("subtitlesFontSize",20),subtitlesOpacity:Be.get("subtitlesOpacity",20),subtitlesDownloadFormat:Be.get("subtitlesDownloadFormat","srt"),responseLanguage:Be.get("responseLanguage",$e),defaultVolume:Be.get("defaultVolume",100),onlyBypassMediaCSP:Be.get("onlyBypassMediaCSP",Number(!!this.audioContext)),newAudioPlayer:Be.get("newAudioPlayer",Number(!!this.audioContext)),showPiPButton:Be.get("showPiPButton",0),translateAPIErrors:Be.get("translateAPIErrors",1),translationService:Be.get("translationService",Oe),detectService:Be.get("detectService",Ve),hotkeyButton:Be.get("hotkeyButton",null),m3u8ProxyHost:Be.get("m3u8ProxyHost",Le),proxyWorkerHost:Be.get("proxyWorkerHost",_e),translateProxyEnabled:Be.get("translateProxyEnabled",0),audioBooster:Be.get("audioBooster",0),useNewModel:Be.get("useNewModel",1),localeHash:Be.get("locale-hash",""),localeUpdatedAt:Be.get("locale-updated-at",0)};if(this.data=Object.fromEntries(await Promise.all(Object.entries(t).map((async([t,e])=>[t,await e])))),console.log("[VOT] data from db: ",this.data),await Ee(this.data,"m3u8ProxyHost","m3u8-proxy.toil.cc",Le),await Ee(this.data,"proxyWorkerHost","vot.toil.cc",_e),await Ee(this.data,"detectService","yandex",Ve),await Ee(this.data,"translationService","yandex",Oe),await Ee(this.data,"dontTranslateLanguage",!1,[this.data.dontTranslateLanguage],Array.isArray(this.data.dontTranslateLanguage)),!this.data.translateProxyEnabled&&GM_info?.scriptHandler&&Me.includes(GM_info.scriptHandler)&&(this.data.translateProxyEnabled=1),Ri)"UA"===Ri&&(this.data.translateProxyEnabled=2);else try{const t=await ze("https://speed.cloudflare.com/meta",{timeout:7e3});({country:Ri}=await t.json()),"UA"===Ri&&(this.data.translateProxyEnabled=2)}catch(t){console.error("[VOT] Error getting country:",t)}Pe.log("translateProxyEnabled",this.data.translateProxyEnabled),Pe.log("Extension compatibility passed..."),this.initVOTClient(),this.subtitlesWidget=new Pi(this.video,this.container,this.site),this.subtitlesWidget.setMaxLength(this.data.subtitlesMaxLength),this.subtitlesWidget.setHighlightWords(this.data.highlightWords),this.subtitlesWidget.setFontSize(this.data.subtitlesFontSize),this.subtitlesWidget.setOpacity(this.data.subtitlesOpacity),this.initUI(),this.initUIEvents(),this.videoData=await this.getVideoData(),this.createPlayer(),this.setSelectMenuValues(this.videoData.detectedLanguage,this.data.responseLanguage??"ru"),this.translateToLang=this.data.responseLanguage??"ru",this.initExtraEvents(),await this.autoTranslate(),this.initialized=!0}initVOTClient(){return this.votOpts={fetchFn:ze,hostVOT:"https://vot.toil.cc/v1",host:this.data.translateProxyEnabled?this.data.proxyWorkerHost:"api.browser.yandex.ru"},this.votClient=new(this.data.translateProxyEnabled?ii:ei)(this.votOpts),this}isLoadingText(t){return t.includes(Ge.get("translationTake"))||t.includes(Ge.get("TranslationDelayed"))}transformBtn(t,e){this.votButton.container.dataset.status=t;const i="error"===t&&this.isLoadingText(e);return this.setLoadingBtn(i),this.votButton.label.textContent=e,this.votButton.container.title="error"===t?e:"",this}setLoadingBtn(t=!1){return this.votButton.container.dataset.loading=t,this}initUI(){this.votButton=Li.createVOTButton(Ge.get("translateVideo")),this.votButton.container.style.opacity=0,this.data?.buttonPos&&"default"!==this.data?.buttonPos&&this.container.clientWidth>550?(this.votButton.container.dataset.direction="column",this.votButton.container.dataset.position=this.data?.buttonPos):(this.votButton.container.dataset.direction="row",this.votButton.container.dataset.position="default"),this.container.appendChild(this.votButton.container),this.votButton.pipButton.hidden=!Re()||!this.data?.showPiPButton,this.votButton.separator2.hidden=!Re()||!this.data?.showPiPButton,this.votButton.container.addEventListener("click",(t=>{t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()})),this.votMenu=Li.createVOTMenu(Ge.get("VOTSettings")),this.votMenu.container.dataset.position=this.container.clientWidth&&this.container.clientWidth>550?this.data?.buttonPos:"default",this.container.appendChild(this.votMenu.container),this.votDownloadButton=Li.createIconButton(T`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="100%" @@ -318,10 +318,10 @@ /> </svg>`),this.votMenu.headerContainer.appendChild(this.votSettingsButton),this.votTranslationLanguageSelect=Li.createVOTLanguageSelect({fromTitle:Ge.get("langs")[this.video.detectedLanguage],fromDialogTitle:Ge.get("videoLanguage"),fromItems:Ni(hi,this.videoData.detectedLanguage),fromOnSelectCB:async t=>{Pe.log("[fromOnSelectCB] select from language",t.target.dataset.votValue),this.videoData=await this.getVideoData(),this.setSelectMenuValues(t.target.dataset.votValue,this.videoData.responseLanguage)},toTitle:Ge.get("langs")[this.video.responseLanguage],toDialogTitle:Ge.get("translationLanguage"),toItems:Ni(pi,this.videoData.responseLanguage),toOnSelectCB:async t=>{const e=t.target.dataset.votValue;Pe.log("[toOnSelectCB] select to language",e),this.data.responseLanguage=this.translateToLang=e,await Be.set("responseLanguage",this.data.responseLanguage),Pe.log("Response Language value changed. New value: ",this.data.responseLanguage),this.videoData=await this.getVideoData(),this.setSelectMenuValues(this.videoData.detectedLanguage,this.data.responseLanguage)}}),this.votMenu.bodyContainer.appendChild(this.votTranslationLanguageSelect.container),this.votSubtitlesSelect=Li.createVOTSelect(Ge.get("VOTSubtitlesDisabled"),Ge.get("VOTSubtitles"),[{label:Ge.get("VOTSubtitlesDisabled"),value:"disabled",selected:!0,disabled:!1}],{onSelectCb:async t=>{await this.changeSubtitlesLang(t.target.dataset.votValue)},labelElement:Li.createVOTSelectLabel(Ge.get("VOTSubtitles")),onBeforeOpen:async()=>{this.videoData.videoId&&this.videoData.videoId!==this.subtitlesListVideoId&&(this.setLoadingBtn(!0),await this.loadSubtitles(),this.setLoadingBtn(!1))}}),this.votMenu.bodyContainer.appendChild(this.votSubtitlesSelect.container),this.votVideoVolumeSlider=Li.createSlider(k`${Ge.get("VOTVolume")}: <strong>${100*this.getVideoVolume()}%</strong>`,100*this.getVideoVolume()),this.votVideoVolumeSlider.container.hidden=1!==this.data.showVideoSlider||"success"!==this.votButton.container.dataset.status,this.votMenu.bodyContainer.appendChild(this.votVideoVolumeSlider.container),this.votVideoTranslationVolumeSlider=Li.createSlider(k`${Ge.get("VOTVolumeTranslation")}: - <strong>${this.data?.defaultVolume??100}%</strong>`,this.data?.defaultVolume??100,0,this.data.audioBooster?900:100),this.votVideoTranslationVolumeSlider.container.hidden="success"!==this.votButton.container.dataset.status,this.votMenu.bodyContainer.appendChild(this.votVideoTranslationVolumeSlider.container),this.votMenu.container.addEventListener("click",(t=>{t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()}));{this.votSettingsDialog=Li.createDialog(Ge.get("VOTSettings")),document.documentElement.appendChild(this.votSettingsDialog.container),this.votTranslationHeader=Li.createHeader(Ge.get("translationSettings")),this.votSettingsDialog.bodyContainer.appendChild(this.votTranslationHeader),this.votAutoTranslateCheckbox=Li.createCheckbox(Ge.get("VOTAutoTranslate"),this.data?.autoTranslate??!1),this.votSettingsDialog.bodyContainer.appendChild(this.votAutoTranslateCheckbox.container),this.votDontTranslateYourLangSelect=Li.createVOTSelect(this.data.dontTranslateLanguage.map((t=>Ge.get("langs")[t])).join(", ")||Ge.get("langs")[Re],Ge.get("VOTDontTranslateYourLang"),Ni(hi).map((t=>({...t,selected:this.data.dontTranslateLanguage.includes(t.value)}))),{multiSelect:!0,onSelectCb:async(t,e)=>{this.data.dontTranslateLanguage=e,await Be.set("dontTranslateLanguage",this.data.dontTranslateLanguage),this.votDontTranslateYourLangSelect.setTitle(e.map((t=>Ge.get("langs")[t])).join(", ")||Ge.get("langs")[Re])},labelElement:Li.createCheckbox(Ge.get("VOTDontTranslateYourLang"),this.data?.dontTranslateYourLang??!0).container}),this.votSettingsDialog.bodyContainer.appendChild(this.votDontTranslateYourLangSelect.container),this.changehotkeyButton=Li.createOutlinedButton(Ri(this.data.hotkeyButton)),this.votSettingsDialog.bodyContainer.appendChild(this.changehotkeyButton),this.votAutoSetVolumeCheckbox=Li.createCheckbox(`${Ge.get("VOTAutoSetVolume")}`,this.data?.autoSetVolumeYandexStyle??!0),this.votSettingsDialog.bodyContainer.appendChild(this.votAutoSetVolumeCheckbox.container),this.votAutoSetVolumeSlider=Li.createSlider(k`<strong + <strong>${this.data?.defaultVolume??100}%</strong>`,this.data?.defaultVolume??100,0,this.data.audioBooster?900:100),this.votVideoTranslationVolumeSlider.container.hidden="success"!==this.votButton.container.dataset.status,this.votMenu.bodyContainer.appendChild(this.votVideoTranslationVolumeSlider.container),this.votMenu.container.addEventListener("click",(t=>{t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()}));{this.votSettingsDialog=Li.createDialog(Ge.get("VOTSettings")),document.documentElement.appendChild(this.votSettingsDialog.container),this.votTranslationHeader=Li.createHeader(Ge.get("translationSettings")),this.votSettingsDialog.bodyContainer.appendChild(this.votTranslationHeader),this.votAutoTranslateCheckbox=Li.createCheckbox(Ge.get("VOTAutoTranslate"),this.data?.autoTranslate??!1),this.votSettingsDialog.bodyContainer.appendChild(this.votAutoTranslateCheckbox.container),this.votDontTranslateYourLangSelect=Li.createVOTSelect(this.data.dontTranslateLanguage.map((t=>Ge.get("langs")[t])).join(", ")||Ge.get("langs")[$e],Ge.get("VOTDontTranslateYourLang"),Ni(hi).map((t=>({...t,selected:this.data.dontTranslateLanguage.includes(t.value)}))),{multiSelect:!0,onSelectCb:async(t,e)=>{this.data.dontTranslateLanguage=e,await Be.set("dontTranslateLanguage",this.data.dontTranslateLanguage),this.votDontTranslateYourLangSelect.setTitle(e.map((t=>Ge.get("langs")[t])).join(", ")||Ge.get("langs")[$e])},labelElement:Li.createCheckbox(Ge.get("VOTDontTranslateYourLang"),this.data?.dontTranslateYourLang??!0).container}),this.votSettingsDialog.bodyContainer.appendChild(this.votDontTranslateYourLangSelect.container),this.changehotkeyButton=Li.createOutlinedButton($i(this.data.hotkeyButton)),this.votSettingsDialog.bodyContainer.appendChild(this.changehotkeyButton),this.votAutoSetVolumeCheckbox=Li.createCheckbox(`${Ge.get("VOTAutoSetVolume")}`,this.data?.autoSetVolumeYandexStyle??!0),this.votSettingsDialog.bodyContainer.appendChild(this.votAutoSetVolumeCheckbox.container),this.votAutoSetVolumeSlider=Li.createSlider(k`<strong >${Math.round(100*(this.data?.autoVolume??Ae))}%</strong - >`,Math.round(100*(this.data?.autoVolume??Ae)),0,100),this.votSettingsDialog.bodyContainer.appendChild(this.votAutoSetVolumeSlider.container),this.votShowVideoSliderCheckbox=Li.createCheckbox(Ge.get("VOTShowVideoSlider"),this.data?.showVideoSlider??!1),this.votSettingsDialog.bodyContainer.appendChild(this.votShowVideoSliderCheckbox.container),this.votAudioBoosterCheckbox=Li.createCheckbox(Ge.get("VOTAudioBooster"),this.data?.audioBooster??!1),this.audioContext||(this.votAudioBoosterCheckbox.input.disabled=!0,this.votAudioBoosterCheckbox.container.title=Ge.get("VOTNeedWebAudioAPI")),this.votSettingsDialog.bodyContainer.appendChild(this.votAudioBoosterCheckbox.container),this.votSyncVolumeCheckbox=Li.createCheckbox(Ge.get("VOTSyncVolume"),this.data?.syncVolume??!1),this.votSettingsDialog.bodyContainer.appendChild(this.votSyncVolumeCheckbox.container),this.votDownloadWithNameCheckbox=Li.createCheckbox(Ge.get("VOTDownloadWithName"),this.data?.downloadWithName??!1),this.votSettingsDialog.bodyContainer.appendChild(this.votDownloadWithNameCheckbox.container),this.votSendNotifyOnCompleteCheckbox=Li.createCheckbox(Ge.get("VOTSendNotifyOnComplete"),this.data?.sendNotifyOnComplete??!1),this.votSettingsDialog.bodyContainer.appendChild(this.votSendNotifyOnCompleteCheckbox.container),this.votUseNewModelCheckbox=Li.createCheckbox(Ge.get("VOTUseNewModel"),this.data?.useNewModel??!1),this.votSettingsDialog.bodyContainer.appendChild(this.votUseNewModelCheckbox.container),this.votTranslationErrorsServiceSelect=Li.createVOTSelect(this.data.translationService.toUpperCase(),Ge.get("VOTTranslationErrorsService"),Ni(Mi,this.data.translationService),{onSelectCb:async t=>{this.data.translationService=t.target.dataset.votValue,await Be.set("translationService",this.data.translationService)},labelElement:Li.createCheckbox(Ge.get("VOTTranslateAPIErrors"),this.data.translateAPIErrors??!0).container}),this.votTranslationErrorsServiceSelect.container.hidden="ru"===Ge.lang,this.votSettingsDialog.bodyContainer.appendChild(this.votTranslationErrorsServiceSelect.container),this.votDetectServiceSelect=Li.createVOTSelect(this.data.detectService.toUpperCase(),Ge.get("VOTDetectService"),Ni(Ei,this.data.detectService),{onSelectCb:async t=>{this.data.detectService=t.target.dataset.votValue,await Be.set("detectService",this.data.detectService)},labelElement:Li.createVOTSelectLabel(Ge.get("VOTDetectService"))}),this.votSettingsDialog.bodyContainer.appendChild(this.votDetectServiceSelect.container),this.votSubtitlesHeader=Li.createHeader(Ge.get("subtitlesSettings")),this.votSettingsDialog.bodyContainer.appendChild(this.votSubtitlesHeader),this.votSubtitlesDetails=Li.createDetails(Ge.get("VOTSubtitlesDesign")),this.votSettingsDialog.bodyContainer.appendChild(this.votSubtitlesDetails.container),this.votProxyHeader=Li.createHeader(Ge.get("proxySettings")),this.votSettingsDialog.bodyContainer.appendChild(this.votProxyHeader),this.votM3u8ProxyHostTextfield=Li.createTextfield(Ge.get("VOTM3u8ProxyHost"),this.data?.m3u8ProxyHost,Le),this.votSettingsDialog.bodyContainer.appendChild(this.votM3u8ProxyHostTextfield.container),this.votProxyWorkerHostTextfield=Li.createTextfield(Ge.get("VOTProxyWorkerHost"),this.data?.proxyWorkerHost,_e),this.votSettingsDialog.bodyContainer.appendChild(this.votProxyWorkerHostTextfield.container);const t=[Ge.get("VOTTranslateProxyDisabled"),Ge.get("VOTTranslateProxyEnabled"),Ge.get("VOTTranslateProxyEverything")];this.votTranslateProxyEnabledSelect=Li.createVOTSelect(t[this.data.translateProxyEnabled],Ge.get("VOTTranslateProxyStatus"),Ni(t,t[this.data.translateProxyEnabled]),{onSelectCb:async(e,i)=>{this.data.translateProxyEnabled=t.findIndex((t=>t===i))??0,await Be.set("translateProxyEnabled",this.data.translateProxyEnabled),this.initVOTClient(),this.videoTranslations=[]},labelElement:Li.createVOTSelectLabel(Ge.get("VOTTranslateProxyStatus"))}),this.votSettingsDialog.bodyContainer.appendChild(this.votTranslateProxyEnabledSelect.container),this.votNewAudioPlayerCheckbox=Li.createCheckbox(Ge.get("VOTNewAudioPlayer"),this.data?.newAudioPlayer??!1),this.audioContext||(this.votNewAudioPlayerCheckbox.input.disabled=!0,this.votNewAudioPlayerCheckbox.container.title=Ge.get("VOTNeedWebAudioAPI")),this.votSettingsDialog.bodyContainer.appendChild(this.votNewAudioPlayerCheckbox.container),this.votOnlyBypassMediaCSPCheckbox=Li.createCheckbox(Ge.get("VOTOnlyBypassMediaCSP")+(this.site.needBypassCSP?` (${Ge.get("VOTMediaCSPEnabledOnSite")})`:""),this.data?.onlyBypassMediaCSP??!1),this.votOnlyBypassMediaCSPCheckbox.container.classList.add("vot-checkbox-sub"),this.audioContext||(this.votOnlyBypassMediaCSPCheckbox.container.title=Ge.get("VOTNeedWebAudioAPI")),this.votOnlyBypassMediaCSPCheckbox.input.disabled=!this.data.newAudioPlayer&&this.audioContext,this.data.newAudioPlayer||(this.votOnlyBypassMediaCSPCheckbox.container.hidden=!0),this.votSettingsDialog.bodyContainer.appendChild(this.votOnlyBypassMediaCSPCheckbox.container),this.votAboutHeader=Li.createHeader(Ge.get("about")),this.votSettingsDialog.bodyContainer.appendChild(this.votAboutHeader),this.votLanguageSelect=Li.createVOTSelect(Ge.get("langs")[Be.syncGet("locale-lang-override","auto")],Ge.get("VOTMenuLanguage"),Ni(We,Be.syncGet("locale-lang-override","auto")),{onSelectCb:async t=>{await Be.set("locale-lang-override",t.target.dataset.votValue)},labelElement:Li.createVOTSelectLabel(Ge.get("VOTMenuLanguage"))}),this.votSettingsDialog.bodyContainer.appendChild(this.votLanguageSelect.container),this.votShowPiPButtonCheckbox=Li.createCheckbox(Ge.get("VOTShowPiPButton"),this.data?.showPiPButton??!1),this.votShowPiPButtonCheckbox.container.hidden=!$e(),this.votSettingsDialog.bodyContainer.appendChild(this.votShowPiPButtonCheckbox.container),this.votVersionInfo=Li.createInformation(`${Ge.get("VOTVersion")}:`,GM_info.script.version),this.votSettingsDialog.bodyContainer.appendChild(this.votVersionInfo.container),this.votAuthorsInfo=Li.createInformation(`${Ge.get("VOTAuthors")}:`,GM_info.script.author),this.votSettingsDialog.bodyContainer.appendChild(this.votAuthorsInfo.container),this.votLoaderInfo=Li.createInformation(`${Ge.get("VOTLoader")}:`,`${GM_info.scriptHandler} v${GM_info.version}`),this.votSettingsDialog.bodyContainer.appendChild(this.votLoaderInfo.container),this.votBrowserInfo=Li.createInformation(`${Ge.get("VOTBrowser")}:`,`${Bi.browser.name} ${Bi.browser.version} (${Bi.os.name} ${Bi.os.version})`),this.votSettingsDialog.bodyContainer.appendChild(this.votBrowserInfo.container),this.votLocaleInfo=Li.createInformation(`${Ge.get("VOTLocaleHash")}:`,k`${this.data.localeHash}<br />(${Ge.get("VOTUpdatedAt")} - ${new Date(1e3*this.data.localeUpdatedAt).toLocaleString()})`),this.votSettingsDialog.bodyContainer.appendChild(this.votLocaleInfo.container),this.votBugReportButton=Li.createOutlinedButton(Ge.get("VOTBugReport")),this.votSettingsDialog.bodyContainer.appendChild(this.votBugReportButton),this.votUpdateLocaleFilesButton=Li.createOutlinedButton(Ge.get("VOTUpdateLocaleFiles")),this.votSettingsDialog.bodyContainer.appendChild(this.votUpdateLocaleFilesButton),this.votResetSettingsButton=Li.createButton(Ge.get("resetSettings")),this.votSettingsDialog.bodyContainer.appendChild(this.votResetSettingsButton)}}async handleTranslationBtnClick(){if(Pe.log("[click translationBtn]",this.audioPlayer,this.audioPlayer.player),this.audioPlayer.player.src)return Pe.log("[click translationBtn] audio.src is not empty",this.audioPlayer.player.src),void this.stopTranslate();if(this.hls.url)return Pe.log("[click translationBtn] hls is not empty",this.hls.url),void this.stopTranslate();try{if(Pe.log("[click translationBtn] trying execute translation"),!this.videoData.videoId)throw new Ye("VOTNoVideoIDFound");("vk"===this.site.host&&"clips"===this.site.additionalData||"douyin"===this.site.host)&&(this.videoData=await this.getVideoData()),await this.translateExecutor(this.videoData.videoId)}catch(t){console.error("[VOT]",t),"VOTLocalizedError"===t?.name?this.transformBtn("error",t.localizedMessage):this.transformBtn("error",t?.message)}}initUIEvents(){{this.votButton.translateButton.addEventListener("pointerdown",(async()=>{await this.handleTranslationBtnClick()})),this.votButton.pipButton.addEventListener("pointerdown",(async()=>{const t=this.video===document.pictureInPictureElement;await(t?document.exitPictureInPicture():this.video.requestPictureInPicture())})),this.votButton.menuButton.addEventListener("pointerdown",(async()=>{this.votMenu.container.hidden?this.votMenu.container.hidden=!1:this.votMenu.container.hidden=!0}));const t=async t=>{const e=this.container.clientWidth>550,i=e?t<=44?"left":t>=66?"right":"default":"default";this.data.buttonPos=i,this.votButton.container.dataset.direction="default"===i?"row":"column",this.votButton.container.dataset.position=i,this.votMenu.container.dataset.position=i,e&&await Be.set("buttonPos",i)},e=async(e,i,o=this.container.getBoundingClientRect())=>{if(!this.dragging)return;e.preventDefault();const a=(o?i-o.left:i)/(o?o.width:this.container.clientWidth)*100;await t(a)};this.votButton.container.addEventListener("pointerdown",(t=>{this.dragging=!0,t.preventDefault()})),this.container.addEventListener("pointerup",(()=>this.dragging=!1)),this.container.addEventListener("pointermove",(t=>e(t,t.clientX))),this.votButton.container.addEventListener("touchstart",(t=>{this.dragging=!0,t.preventDefault()}),{passive:!1}),this.container.addEventListener("touchend",(()=>this.dragging=!1)),this.container.addEventListener("touchmove",(t=>{e(t,t.touches[0].clientX,this.container.getBoundingClientRect())}),{passive:!1});for(const t of["pointercancel","touchcancel"])document.addEventListener(t,(()=>this.dragging=!1))}this.votDownloadButton.addEventListener("click",(async()=>{if(!this.downloadTranslationUrl)return;if(!this.data.downloadWithName)return window.open(this.downloadTranslationUrl,"_blank").focus();const t=document.querySelector("#vot-loader-download"),e=getComputedStyle(this.votMenu.container).getPropertyValue("--vot-primary-rgb"),i=Li.animateLoader(t,e),o=await ze(this.downloadTranslationUrl),a=o.body.getReader(),n=+o.headers.get("Content-Length");let r=0;const s=[];for(;;){const{done:t,value:e}=await a.read();if(t)break;s.push(e),r+=e.length,i(Math.round(r/n*100))}Li.afterAnimateLoader(t,e);const l=new Blob(s),d=qe(this.videoData.downloadTitle),u=await l.arrayBuffer(),c=new K(u);c.setFrame("TIT2",d),c.addTag(),Ue(c.getBlob(),`${d}.mp3`)})),this.votDownloadSubtitlesButton.addEventListener("click",(async()=>{const t=this.data.subtitlesDownloadFormat,e=Ci(this.yandexSubtitles,t);Ue(new Blob(["json"===t?JSON.stringify(e):e],{type:"text/plain"}),`${this.data.downloadWithName?qe(this.videoData.downloadTitle):`subtitles_${this.videoData.videoId}`}.${t}`)})),this.votSettingsButton.addEventListener("click",(()=>{this.votSettingsDialog.container.hidden=!this.votSettingsDialog.container.hidden,(document.fullscreenElement||document.webkitFullscreenElement)&&(document.webkitExitFullscreen&&document.webkitExitFullscreen(),document.exitFullscreen&&document.exitFullscreen())})),this.votVideoVolumeSlider.input.addEventListener("input",(t=>{const e=Number(t.target.value);this.votVideoVolumeSlider.label.querySelector("strong").textContent=`${e}%`,this.setVideoVolume(e/100),this.data.syncVolume&&this.syncVolumeWrapper("video",e)})),this.votVideoTranslationVolumeSlider.input.addEventListener("input",(t=>{(async()=>{this.data.defaultVolume=Number(t.target.value),await Be.set("defaultVolume",this.data.defaultVolume),this.votVideoTranslationVolumeSlider.label.querySelector("strong").textContent=`${this.data.defaultVolume}%`,this.audioPlayer.player.volume=this.data.defaultVolume/100,this.data.syncVolume&&(this.syncVolumeWrapper("translation",this.data.defaultVolume),["youtube","googledrive"].includes(this.site.host)&&"mobile"!==this.site.additionalData&&this.setVideoVolume(this.tempOriginalVolume/100))})()}));{this.votAutoTranslateCheckbox.input.addEventListener("change",(t=>{(async()=>{this.data.autoTranslate=Number(t.target.checked),await Promise.all([Be.set("autoTranslate",this.data.autoTranslate),this.autoTranslate()]),Pe.log("autoTranslate value changed. New value: ",this.data.autoTranslate)})()})),this.votDontTranslateYourLangSelect.labelElement.addEventListener("change",(t=>{(async()=>{this.data.dontTranslateYourLang=Number(t.target.checked),await Be.set("dontTranslateYourLang",this.data.dontTranslateYourLang),Pe.log("dontTranslateYourLang value changed. New value: ",this.data.dontTranslateYourLang)})()}));const t=async t=>{await Be.set("hotkeyButton",t),this.data.hotkeyButton=t,this.changehotkeyButton.textContent=Ri(t)},e=i=>{const o="Escape"===i.code?null:i.code;t(o),document.removeEventListener("keydown",e)};this.changehotkeyButton.addEventListener("click",(()=>{this.changehotkeyButton.textContent=Ge.get("VOTPressNewHotkey"),document.addEventListener("keydown",e)})),this.votAutoSetVolumeCheckbox.input.addEventListener("change",(t=>{(async()=>{this.data.autoSetVolumeYandexStyle=Number(t.target.checked),await Be.set("autoSetVolumeYandexStyle",this.data.autoSetVolumeYandexStyle),Pe.log("autoSetVolumeYandexStyle value changed. New value: ",this.data.autoSetVolumeYandexStyle)})()})),this.votAutoSetVolumeSlider.input.addEventListener("input",(t=>{(async()=>{const e=Number(t.target.value);this.data.autoVolume=(e/100).toFixed(2),await Be.set("autoVolume",this.data.autoVolume),this.votAutoSetVolumeSlider.label.querySelector("strong").textContent=`${e}%`})()})),this.votShowVideoSliderCheckbox.input.addEventListener("change",(t=>{(async()=>{this.data.showVideoSlider=Number(t.target.checked),await Be.set("showVideoSlider",this.data.showVideoSlider),Pe.log("showVideoSlider value changed. New value: ",this.data.showVideoSlider),this.votVideoVolumeSlider.container.hidden=1!==this.data.showVideoSlider||"success"!==this.votButton.container.dataset.status})()})),this.votAudioBoosterCheckbox.input.addEventListener("change",(t=>{(async()=>{this.data.audioBooster=Number(t.target.checked),await Be.set("audioBooster",this.data.audioBooster),Pe.log("audioBooster value changed. New value: ",this.data.audioBooster);const e=this.votVideoTranslationVolumeSlider.input.value;this.votVideoTranslationVolumeSlider.input.max=this.data.audioBooster?900:100,this.votVideoTranslationVolumeSlider.input.value=e>100?100:e,this.votVideoTranslationVolumeSlider.input.dispatchEvent(new Event("input"))})()})),this.votSyncVolumeCheckbox.input.addEventListener("change",(t=>{(async()=>{this.data.syncVolume=Number(t.target.checked),await Be.set("syncVolume",this.data.syncVolume),Pe.log("syncVolume value changed. New value: ",this.data.syncVolume)})()})),this.votDownloadWithNameCheckbox.input.addEventListener("change",(t=>{(async()=>{this.data.downloadWithName=Number(t.target.checked),await Be.set("downloadWithName",this.data.downloadWithName),Pe.log("downloadWithName value changed. New value: ",this.data.downloadWithName)})()})),this.votSendNotifyOnCompleteCheckbox.input.addEventListener("change",(t=>{(async()=>{this.data.sendNotifyOnComplete=Number(t.target.checked),await Be.set("sendNotifyOnComplete",this.data.sendNotifyOnComplete),Pe.log("sendNotifyOnComplete value changed. New value: ",this.data.sendNotifyOnComplete)})()})),this.votUseNewModelCheckbox.input.addEventListener("change",(t=>{(async()=>{this.data.useNewModel=Number(t.target.checked),await Be.set("useNewModel",this.data.useNewModel),Pe.log("useNewModel value changed. New value: ",this.data.useNewModel),this.stopTranslate()})()})),this.votTranslationErrorsServiceSelect.labelElement.addEventListener("change",(t=>{(async()=>{this.data.translateAPIErrors=Number(t.target.checked),await Be.set("translateAPIErrors",this.data.translateAPIErrors),Pe.log("translateAPIErrors value changed. New value: ",this.data.translateAPIErrors)})()})),this.votSubtitlesDetails.container.addEventListener("click",(()=>{this.votSubtitlesDialog=Li.createDialog(Ge.get("VOTSubtitlesDesign")),this.votSubtitlesDialog.container.classList.add("vot-dialog-temp"),this.votSubtitlesDialog.container.hidden=!1,this.votSubtitlesDialog.backdrop.onclick=this.votSubtitlesDialog.closeButton.onclick=()=>{this.votSubtitlesDialog.container.remove()},this.votSubtitlesHighlightWordsCheckbox=Li.createCheckbox(Ge.get("VOTHighlightWords"),this.data?.highlightWords??!1),this.votSubtitlesDialog.bodyContainer.appendChild(this.votSubtitlesHighlightWordsCheckbox.container),this.votSubtitlesDownloadFormatSelect=Li.createVOTSelect(this.data.subtitlesDownloadFormat.toUpperCase(),Ge.get("VOTSubtitlesDownloadFormat"),Ni(gi,this.data.subtitlesDownloadFormat),{onSelectCb:async t=>{this.data.subtitlesDownloadFormat=t.target.dataset.votValue,await Be.set("subtitlesDownloadFormat",this.data.subtitlesDownloadFormat)},labelElement:Li.createVOTSelectLabel(Ge.get("VOTSubtitlesDownloadFormat"))}),this.votSubtitlesDialog.bodyContainer.appendChild(this.votSubtitlesDownloadFormatSelect.container),this.votSubtitlesMaxLengthSlider=Li.createSlider(k`${Ge.get("VOTSubtitlesMaxLength")}: + >`,Math.round(100*(this.data?.autoVolume??Ae)),0,100),this.votSettingsDialog.bodyContainer.appendChild(this.votAutoSetVolumeSlider.container),this.votShowVideoSliderCheckbox=Li.createCheckbox(Ge.get("VOTShowVideoSlider"),this.data?.showVideoSlider??!1),this.votSettingsDialog.bodyContainer.appendChild(this.votShowVideoSliderCheckbox.container),this.votAudioBoosterCheckbox=Li.createCheckbox(Ge.get("VOTAudioBooster"),this.data?.audioBooster??!1),this.audioContext||(this.votAudioBoosterCheckbox.input.disabled=!0,this.votAudioBoosterCheckbox.container.title=Ge.get("VOTNeedWebAudioAPI")),this.votSettingsDialog.bodyContainer.appendChild(this.votAudioBoosterCheckbox.container),this.votSyncVolumeCheckbox=Li.createCheckbox(Ge.get("VOTSyncVolume"),this.data?.syncVolume??!1),this.votSettingsDialog.bodyContainer.appendChild(this.votSyncVolumeCheckbox.container),this.votDownloadWithNameCheckbox=Li.createCheckbox(Ge.get("VOTDownloadWithName"),this.data?.downloadWithName??!1),this.votSettingsDialog.bodyContainer.appendChild(this.votDownloadWithNameCheckbox.container),this.votSendNotifyOnCompleteCheckbox=Li.createCheckbox(Ge.get("VOTSendNotifyOnComplete"),this.data?.sendNotifyOnComplete??!1),this.votSettingsDialog.bodyContainer.appendChild(this.votSendNotifyOnCompleteCheckbox.container),this.votUseNewModelCheckbox=Li.createCheckbox(Ge.get("VOTUseNewModel"),this.data?.useNewModel??!1),this.votSettingsDialog.bodyContainer.appendChild(this.votUseNewModelCheckbox.container),this.votTranslationErrorsServiceSelect=Li.createVOTSelect(this.data.translationService.toUpperCase(),Ge.get("VOTTranslationErrorsService"),Ni(Mi,this.data.translationService),{onSelectCb:async t=>{this.data.translationService=t.target.dataset.votValue,await Be.set("translationService",this.data.translationService)},labelElement:Li.createCheckbox(Ge.get("VOTTranslateAPIErrors"),this.data.translateAPIErrors??!0).container}),this.votTranslationErrorsServiceSelect.container.hidden="ru"===Ge.lang,this.votSettingsDialog.bodyContainer.appendChild(this.votTranslationErrorsServiceSelect.container),this.votDetectServiceSelect=Li.createVOTSelect(this.data.detectService.toUpperCase(),Ge.get("VOTDetectService"),Ni(Ei,this.data.detectService),{onSelectCb:async t=>{this.data.detectService=t.target.dataset.votValue,await Be.set("detectService",this.data.detectService)},labelElement:Li.createVOTSelectLabel(Ge.get("VOTDetectService"))}),this.votSettingsDialog.bodyContainer.appendChild(this.votDetectServiceSelect.container),this.votSubtitlesHeader=Li.createHeader(Ge.get("subtitlesSettings")),this.votSettingsDialog.bodyContainer.appendChild(this.votSubtitlesHeader),this.votSubtitlesDetails=Li.createDetails(Ge.get("VOTSubtitlesDesign")),this.votSettingsDialog.bodyContainer.appendChild(this.votSubtitlesDetails.container),this.votProxyHeader=Li.createHeader(Ge.get("proxySettings")),this.votSettingsDialog.bodyContainer.appendChild(this.votProxyHeader),this.votM3u8ProxyHostTextfield=Li.createTextfield(Ge.get("VOTM3u8ProxyHost"),this.data?.m3u8ProxyHost,Le),this.votSettingsDialog.bodyContainer.appendChild(this.votM3u8ProxyHostTextfield.container),this.votProxyWorkerHostTextfield=Li.createTextfield(Ge.get("VOTProxyWorkerHost"),this.data?.proxyWorkerHost,_e),this.votSettingsDialog.bodyContainer.appendChild(this.votProxyWorkerHostTextfield.container);const t=[Ge.get("VOTTranslateProxyDisabled"),Ge.get("VOTTranslateProxyEnabled"),Ge.get("VOTTranslateProxyEverything")];this.votTranslateProxyEnabledSelect=Li.createVOTSelect(t[this.data.translateProxyEnabled],Ge.get("VOTTranslateProxyStatus"),Ni(t,t[this.data.translateProxyEnabled]),{onSelectCb:async(e,i)=>{this.data.translateProxyEnabled=t.findIndex((t=>t===i))??0,await Be.set("translateProxyEnabled",this.data.translateProxyEnabled),this.initVOTClient(),this.videoTranslations.clear()},labelElement:Li.createVOTSelectLabel(Ge.get("VOTTranslateProxyStatus"))}),this.votSettingsDialog.bodyContainer.appendChild(this.votTranslateProxyEnabledSelect.container),this.votNewAudioPlayerCheckbox=Li.createCheckbox(Ge.get("VOTNewAudioPlayer"),this.data?.newAudioPlayer??!1),this.audioContext||(this.votNewAudioPlayerCheckbox.input.disabled=!0,this.votNewAudioPlayerCheckbox.container.title=Ge.get("VOTNeedWebAudioAPI")),this.votSettingsDialog.bodyContainer.appendChild(this.votNewAudioPlayerCheckbox.container),this.votOnlyBypassMediaCSPCheckbox=Li.createCheckbox(Ge.get("VOTOnlyBypassMediaCSP")+(this.site.needBypassCSP?` (${Ge.get("VOTMediaCSPEnabledOnSite")})`:""),this.data?.onlyBypassMediaCSP??!1),this.votOnlyBypassMediaCSPCheckbox.container.classList.add("vot-checkbox-sub"),this.audioContext||(this.votOnlyBypassMediaCSPCheckbox.container.title=Ge.get("VOTNeedWebAudioAPI")),this.votOnlyBypassMediaCSPCheckbox.input.disabled=!this.data.newAudioPlayer&&this.audioContext,this.data.newAudioPlayer||(this.votOnlyBypassMediaCSPCheckbox.container.hidden=!0),this.votSettingsDialog.bodyContainer.appendChild(this.votOnlyBypassMediaCSPCheckbox.container),this.votAboutHeader=Li.createHeader(Ge.get("about")),this.votSettingsDialog.bodyContainer.appendChild(this.votAboutHeader),this.votLanguageSelect=Li.createVOTSelect(Ge.get("langs")[Be.syncGet("locale-lang-override","auto")],Ge.get("VOTMenuLanguage"),Ni(We,Be.syncGet("locale-lang-override","auto")),{onSelectCb:async t=>{await Be.set("locale-lang-override",t.target.dataset.votValue)},labelElement:Li.createVOTSelectLabel(Ge.get("VOTMenuLanguage"))}),this.votSettingsDialog.bodyContainer.appendChild(this.votLanguageSelect.container),this.votShowPiPButtonCheckbox=Li.createCheckbox(Ge.get("VOTShowPiPButton"),this.data?.showPiPButton??!1),this.votShowPiPButtonCheckbox.container.hidden=!Re(),this.votSettingsDialog.bodyContainer.appendChild(this.votShowPiPButtonCheckbox.container),this.votVersionInfo=Li.createInformation(`${Ge.get("VOTVersion")}:`,GM_info.script.version),this.votSettingsDialog.bodyContainer.appendChild(this.votVersionInfo.container),this.votAuthorsInfo=Li.createInformation(`${Ge.get("VOTAuthors")}:`,GM_info.script.author),this.votSettingsDialog.bodyContainer.appendChild(this.votAuthorsInfo.container),this.votLoaderInfo=Li.createInformation(`${Ge.get("VOTLoader")}:`,`${GM_info.scriptHandler} v${GM_info.version}`),this.votSettingsDialog.bodyContainer.appendChild(this.votLoaderInfo.container),this.votBrowserInfo=Li.createInformation(`${Ge.get("VOTBrowser")}:`,`${Bi.browser.name} ${Bi.browser.version} (${Bi.os.name} ${Bi.os.version})`),this.votSettingsDialog.bodyContainer.appendChild(this.votBrowserInfo.container),this.votLocaleInfo=Li.createInformation(`${Ge.get("VOTLocaleHash")}:`,k`${this.data.localeHash}<br />(${Ge.get("VOTUpdatedAt")} + ${new Date(1e3*this.data.localeUpdatedAt).toLocaleString()})`),this.votSettingsDialog.bodyContainer.appendChild(this.votLocaleInfo.container),this.votBugReportButton=Li.createOutlinedButton(Ge.get("VOTBugReport")),this.votSettingsDialog.bodyContainer.appendChild(this.votBugReportButton),this.votUpdateLocaleFilesButton=Li.createOutlinedButton(Ge.get("VOTUpdateLocaleFiles")),this.votSettingsDialog.bodyContainer.appendChild(this.votUpdateLocaleFilesButton),this.votResetSettingsButton=Li.createButton(Ge.get("resetSettings")),this.votSettingsDialog.bodyContainer.appendChild(this.votResetSettingsButton)}}async handleTranslationBtnClick(){if(Pe.log("[click translationBtn]",this.audioPlayer,this.audioPlayer.player),this.audioPlayer.player.src)return Pe.log("[click translationBtn] audio.src is not empty",this.audioPlayer.player.src),void this.stopTranslate();if(this.hls.url)return Pe.log("[click translationBtn] hls is not empty",this.hls.url),void this.stopTranslate();try{if(Pe.log("[click translationBtn] trying execute translation"),!this.videoData.videoId)throw new Ye("VOTNoVideoIDFound");("vk"===this.site.host&&"clips"===this.site.additionalData||"douyin"===this.site.host)&&(this.videoData=await this.getVideoData()),await this.translateExecutor(this.videoData.videoId)}catch(t){console.error("[VOT]",t),"VOTLocalizedError"===t?.name?this.transformBtn("error",t.localizedMessage):this.transformBtn("error",t?.message)}}initUIEvents(){{this.votButton.translateButton.addEventListener("pointerdown",(async()=>{await this.handleTranslationBtnClick()})),this.votButton.pipButton.addEventListener("pointerdown",(async()=>{const t=this.video===document.pictureInPictureElement;await(t?document.exitPictureInPicture():this.video.requestPictureInPicture())})),this.votButton.menuButton.addEventListener("pointerdown",(async()=>{this.votMenu.container.hidden?this.votMenu.container.hidden=!1:this.votMenu.container.hidden=!0}));const t=async t=>{const e=this.container.clientWidth>550,i=e?t<=44?"left":t>=66?"right":"default":"default";this.data.buttonPos=i,this.votButton.container.dataset.direction="default"===i?"row":"column",this.votButton.container.dataset.position=i,this.votMenu.container.dataset.position=i,e&&await Be.set("buttonPos",i)},e=async(e,i,o=this.container.getBoundingClientRect())=>{if(!this.dragging)return;e.preventDefault();const a=(o?i-o.left:i)/(o?o.width:this.container.clientWidth)*100;await t(a)};this.votButton.container.addEventListener("pointerdown",(t=>{this.dragging=!0,t.preventDefault()})),this.container.addEventListener("pointerup",(()=>this.dragging=!1)),this.container.addEventListener("pointermove",(t=>e(t,t.clientX))),this.votButton.container.addEventListener("touchstart",(t=>{this.dragging=!0,t.preventDefault()}),{passive:!1}),this.container.addEventListener("touchend",(()=>this.dragging=!1)),this.container.addEventListener("touchmove",(t=>{e(t,t.touches[0].clientX,this.container.getBoundingClientRect())}),{passive:!1});for(const t of["pointercancel","touchcancel"])document.addEventListener(t,(()=>this.dragging=!1))}this.votDownloadButton.addEventListener("click",(async()=>{if(this.downloadTranslationUrl)try{if(!this.data.downloadWithName)return void window.open(this.downloadTranslationUrl,"_blank").focus();this.votLoader=document.querySelector("#vot-loader-download");const t=getComputedStyle(this.votMenu.container).getPropertyValue("--vot-primary-rgb"),e=Li.animateLoader(this.votLoader,t),i=await ze(this.downloadTranslationUrl);if(!i.ok)throw new Error(`HTTP ${i.status}`);const o=+i.headers.get("Content-Length"),a=i.body.getReader(),n=new Uint8Array(o);let r=0;for(;;){const{done:t,value:i}=await a.read();if(t)break;n.set(i,r),r+=i.length,e(Math.round(r/o*100))}Li.afterAnimateLoader(this.votLoader,t);const s=qe(this.videoData.downloadTitle),l=new K(n.buffer);l.setFrame("TIT2",s),l.addTag(),Ue(l.getBlob(),`${s}.mp3`)}catch(t){console.error("Download failed:",t),this.transformBtn("error",Ge.get("downloadFailed"))}})),this.votDownloadSubtitlesButton.addEventListener("click",(async()=>{const t=this.data.subtitlesDownloadFormat,e=Ci(this.yandexSubtitles,t);Ue(new Blob(["json"===t?JSON.stringify(e):e],{type:"text/plain"}),`${this.data.downloadWithName?qe(this.videoData.downloadTitle):`subtitles_${this.videoData.videoId}`}.${t}`)})),this.votSettingsButton.addEventListener("click",(()=>{this.votSettingsDialog.container.hidden=!this.votSettingsDialog.container.hidden,(document.fullscreenElement||document.webkitFullscreenElement)&&(document.webkitExitFullscreen&&document.webkitExitFullscreen(),document.exitFullscreen&&document.exitFullscreen())})),this.votVideoVolumeSlider.input.addEventListener("input",(t=>{const e=Number(t.target.value);this.votVideoVolumeSlider.label.querySelector("strong").textContent=`${e}%`,this.setVideoVolume(e/100),this.data.syncVolume&&this.syncVolumeWrapper("video",e)})),this.votVideoTranslationVolumeSlider.input.addEventListener("input",(t=>{(async()=>{this.data.defaultVolume=Number(t.target.value),await Be.set("defaultVolume",this.data.defaultVolume),this.votVideoTranslationVolumeSlider.label.querySelector("strong").textContent=`${this.data.defaultVolume}%`,this.audioPlayer.player.volume=this.data.defaultVolume/100,this.data.syncVolume&&(this.syncVolumeWrapper("translation",this.data.defaultVolume),["youtube","googledrive"].includes(this.site.host)&&"mobile"!==this.site.additionalData&&this.setVideoVolume(this.tempOriginalVolume/100))})()}));{this.votAutoTranslateCheckbox.input.addEventListener("change",(t=>{(async()=>{this.data.autoTranslate=Number(t.target.checked),await Promise.all([Be.set("autoTranslate",this.data.autoTranslate),this.autoTranslate()]),Pe.log("autoTranslate value changed. New value: ",this.data.autoTranslate)})()})),this.votDontTranslateYourLangSelect.labelElement.addEventListener("change",(t=>{(async()=>{this.data.dontTranslateYourLang=Number(t.target.checked),await Be.set("dontTranslateYourLang",this.data.dontTranslateYourLang),Pe.log("dontTranslateYourLang value changed. New value: ",this.data.dontTranslateYourLang)})()}));const t=async t=>{await Be.set("hotkeyButton",t),this.data.hotkeyButton=t,this.changehotkeyButton.textContent=$i(t)},e=i=>{const o="Escape"===i.code?null:i.code;t(o),document.removeEventListener("keydown",e)};this.changehotkeyButton.addEventListener("click",(()=>{this.changehotkeyButton.textContent=Ge.get("VOTPressNewHotkey"),document.addEventListener("keydown",e)})),this.votAutoSetVolumeCheckbox.input.addEventListener("change",(t=>{(async()=>{this.data.autoSetVolumeYandexStyle=Number(t.target.checked),await Be.set("autoSetVolumeYandexStyle",this.data.autoSetVolumeYandexStyle),Pe.log("autoSetVolumeYandexStyle value changed. New value: ",this.data.autoSetVolumeYandexStyle)})()})),this.votAutoSetVolumeSlider.input.addEventListener("input",(t=>{(async()=>{const e=Number(t.target.value);this.data.autoVolume=(e/100).toFixed(2),await Be.set("autoVolume",this.data.autoVolume),this.votAutoSetVolumeSlider.label.querySelector("strong").textContent=`${e}%`})()})),this.votShowVideoSliderCheckbox.input.addEventListener("change",(t=>{(async()=>{this.data.showVideoSlider=Number(t.target.checked),await Be.set("showVideoSlider",this.data.showVideoSlider),Pe.log("showVideoSlider value changed. New value: ",this.data.showVideoSlider),this.votVideoVolumeSlider.container.hidden=1!==this.data.showVideoSlider||"success"!==this.votButton.container.dataset.status})()})),this.votAudioBoosterCheckbox.input.addEventListener("change",(t=>{(async()=>{this.data.audioBooster=Number(t.target.checked),await Be.set("audioBooster",this.data.audioBooster),Pe.log("audioBooster value changed. New value: ",this.data.audioBooster);const e=this.votVideoTranslationVolumeSlider.input.value;this.votVideoTranslationVolumeSlider.input.max=this.data.audioBooster?900:100,this.votVideoTranslationVolumeSlider.input.value=e>100?100:e,this.votVideoTranslationVolumeSlider.input.dispatchEvent(new Event("input"))})()})),this.votSyncVolumeCheckbox.input.addEventListener("change",(t=>{(async()=>{this.data.syncVolume=Number(t.target.checked),await Be.set("syncVolume",this.data.syncVolume),Pe.log("syncVolume value changed. New value: ",this.data.syncVolume)})()})),this.votDownloadWithNameCheckbox.input.addEventListener("change",(t=>{(async()=>{this.data.downloadWithName=Number(t.target.checked),await Be.set("downloadWithName",this.data.downloadWithName),Pe.log("downloadWithName value changed. New value: ",this.data.downloadWithName)})()})),this.votSendNotifyOnCompleteCheckbox.input.addEventListener("change",(t=>{(async()=>{this.data.sendNotifyOnComplete=Number(t.target.checked),await Be.set("sendNotifyOnComplete",this.data.sendNotifyOnComplete),Pe.log("sendNotifyOnComplete value changed. New value: ",this.data.sendNotifyOnComplete)})()})),this.votUseNewModelCheckbox.input.addEventListener("change",(t=>{(async()=>{this.data.useNewModel=Number(t.target.checked),await Be.set("useNewModel",this.data.useNewModel),Pe.log("useNewModel value changed. New value: ",this.data.useNewModel),this.stopTranslate()})()})),this.votTranslationErrorsServiceSelect.labelElement.addEventListener("change",(t=>{(async()=>{this.data.translateAPIErrors=Number(t.target.checked),await Be.set("translateAPIErrors",this.data.translateAPIErrors),Pe.log("translateAPIErrors value changed. New value: ",this.data.translateAPIErrors)})()})),this.votSubtitlesDetails.container.addEventListener("click",(()=>{this.votSubtitlesDialog=Li.createDialog(Ge.get("VOTSubtitlesDesign")),this.votSubtitlesDialog.container.classList.add("vot-dialog-temp"),this.votSubtitlesDialog.container.hidden=!1,this.votSubtitlesDialog.backdrop.onclick=this.votSubtitlesDialog.closeButton.onclick=()=>{this.votSubtitlesDialog.container.remove()},this.votSubtitlesHighlightWordsCheckbox=Li.createCheckbox(Ge.get("VOTHighlightWords"),this.data?.highlightWords??!1),this.votSubtitlesDialog.bodyContainer.appendChild(this.votSubtitlesHighlightWordsCheckbox.container),this.votSubtitlesDownloadFormatSelect=Li.createVOTSelect(this.data.subtitlesDownloadFormat.toUpperCase(),Ge.get("VOTSubtitlesDownloadFormat"),Ni(gi,this.data.subtitlesDownloadFormat),{onSelectCb:async t=>{this.data.subtitlesDownloadFormat=t.target.dataset.votValue,await Be.set("subtitlesDownloadFormat",this.data.subtitlesDownloadFormat)},labelElement:Li.createVOTSelectLabel(Ge.get("VOTSubtitlesDownloadFormat"))}),this.votSubtitlesDialog.bodyContainer.appendChild(this.votSubtitlesDownloadFormatSelect.container),this.votSubtitlesMaxLengthSlider=Li.createSlider(k`${Ge.get("VOTSubtitlesMaxLength")}: <strong>${this.data?.subtitlesMaxLength??300}</strong>`,this.data?.subtitlesMaxLength??300,50,300),this.votSubtitlesDialog.bodyContainer.appendChild(this.votSubtitlesMaxLengthSlider.container),this.votSubtitlesFontSizeSlider=Li.createSlider(k`${Ge.get("VOTSubtitlesFontSize")}: <strong>${this.data?.subtitlesFontSize??20}</strong>`,this.data?.subtitlesFontSize??20,8,50),this.votSubtitlesDialog.bodyContainer.appendChild(this.votSubtitlesFontSizeSlider.container),this.votSubtitlesOpacitySlider=Li.createSlider(k`${Ge.get("VOTSubtitlesOpacity")}: - <strong>${this.data?.subtitlesOpacity??20}</strong>`,this.data?.subtitlesOpacity??20,0,100),this.votSubtitlesDialog.bodyContainer.appendChild(this.votSubtitlesOpacitySlider.container),this.votSubtitlesHighlightWordsCheckbox.input.addEventListener("change",(t=>{(async()=>{this.data.highlightWords=Number(t.target.checked),await Be.set("highlightWords",this.data.highlightWords),Pe.log("highlightWords value changed. New value: ",this.data.highlightWords),this.subtitlesWidget.setHighlightWords(this.data.highlightWords)})()})),this.votSubtitlesMaxLengthSlider.input.addEventListener("input",(t=>{(async()=>{this.data.subtitlesMaxLength=Number(t.target.value),await Be.set("subtitlesMaxLength",this.data.subtitlesMaxLength),this.votSubtitlesMaxLengthSlider.label.querySelector("strong").textContent=`${this.data.subtitlesMaxLength}`,this.subtitlesWidget.setMaxLength(this.data.subtitlesMaxLength)})()})),this.votSubtitlesFontSizeSlider.input.addEventListener("input",(t=>{(async()=>{this.data.subtitlesFontSize=Number(t.target.value),await Be.set("subtitlesFontSize",this.data.subtitlesFontSize),this.votSubtitlesFontSizeSlider.label.querySelector("strong").textContent=`${this.data.subtitlesFontSize}`,this.subtitlesWidget.setFontSize(this.data.subtitlesFontSize)})()})),this.votSubtitlesOpacitySlider.input.addEventListener("input",(t=>{(async()=>{this.data.subtitlesOpacity=Number(t.target.value),await Be.set("subtitlesOpacity",this.data.subtitlesOpacity),this.votSubtitlesOpacitySlider.label.querySelector("strong").textContent=`${this.data.subtitlesOpacity}`,this.subtitlesWidget.setOpacity(this.data.subtitlesOpacity)})()})),document.documentElement.appendChild(this.votSubtitlesDialog.container)})),this.votShowPiPButtonCheckbox.input.addEventListener("change",(t=>{(async()=>{this.data.showPiPButton=Number(t.target.checked),await Be.set("showPiPButton",this.data.showPiPButton),Pe.log("showPiPButton value changed. New value: ",this.data.showPiPButton),this.votButton.pipButton.hidden=this.votButton.separator2.hidden=!$e()||!this.data.showPiPButton})()})),this.votM3u8ProxyHostTextfield.input.addEventListener("change",(t=>{(async()=>{this.data.m3u8ProxyHost=t.target.value||Le,await Be.set("m3u8ProxyHost",this.data.m3u8ProxyHost),Pe.log("m3u8ProxyHost value changed. New value: ",this.data.m3u8ProxyHost)})()})),this.votProxyWorkerHostTextfield.input.addEventListener("change",(t=>{(async()=>{this.data.proxyWorkerHost=t.target.value||_e,await Be.set("proxyWorkerHost",this.data.proxyWorkerHost),Pe.log("proxyWorkerHost value changed. New value: ",this.data.proxyWorkerHost),this.data.translateProxyEnabled&&(this.votClient.host=this.data.proxyWorkerHost)})()})),this.votOnlyBypassMediaCSPCheckbox.input.addEventListener("change",(t=>{(async()=>{this.data.onlyBypassMediaCSP=Number(t.target.checked),await Be.set("onlyBypassMediaCSP",this.data.onlyBypassMediaCSP),Pe.log("onlyBypassMediaCSP value changed. New value: ",this.data.onlyBypassMediaCSP),this.stopTranslate(),this.createPlayer()})()})),this.votNewAudioPlayerCheckbox.input.addEventListener("change",(t=>{(async()=>{const e=t.target.checked;this.data.newAudioPlayer=Number(e),await Be.set("newAudioPlayer",this.data.newAudioPlayer),Pe.log("newAudioPlayer value changed. New value: ",this.data.newAudioPlayer),this.stopTranslate(),this.createPlayer(),this.votOnlyBypassMediaCSPCheckbox.input.disabled=this.votOnlyBypassMediaCSPCheckbox.container.hidden=!e})()})),this.votBugReportButton.addEventListener("click",(()=>{const t=new URLSearchParams(this.collectReportInfo()).toString();window.open(`https://github.com/ilyhalight/voice-over-translation/issues/new?${t}`,"_blank").focus()})),this.votUpdateLocaleFilesButton.addEventListener("click",(()=>{(async()=>{await Be.set("locale-hash",""),await Ge.update(!0),window.location.reload()})()})),this.votResetSettingsButton.addEventListener("click",(()=>{(async()=>{Ge.reset();const t=await Be.list();for(let e=0;e<t.length;e++){const i=t[e];Ge.gmValues.includes(i)||Be.syncDelete(i)}window.location.reload()})()}))}}collectReportInfo(){const t=`${Bi.os.name} ${Bi.os.version}`,e=`Autogenerated by VOT:\n- OS: ${t}\n- Browser: ${Bi.browser.name} ${Bi.browser.version}\n- Loader: ${GM_info.scriptHandler} v${GM_info.version}\n- Script version: ${GM_info.script.version}\n- URL: \`${window.location.href}\``;return{assignees:"ilyhalight",template:"bug.yml",os:t,"script-version":GM_info.script.version,"additional-info":e}}releaseExtraEvents(){this.abortController.abort(),this.resizeObserver?.disconnect(),["youtube","googledrive"].includes(this.site.host)&&"mobile"!==this.site.additionalData&&this.syncVolumeObserver?.disconnect()}getEventContainer(){return this.site.eventSelector?"twitter"===this.site.host?this.container.closest(this.site.eventSelector):document.querySelector(this.site.eventSelector):this.container}initExtraEvents(){const{signal:t}=this.abortController,e=(e,i,o)=>{this.extraEvents.push({element:e,event:i,handler:o}),e.addEventListener(i,o,{signal:t})},i=(t,i,o)=>{for(const a of i)e(t,a,o)};if(this.resizeObserver=new ResizeObserver((t=>{for(let e=0;e<t.length;e++){const i=t[e];this.votMenu.container.setAttribute("style",`--vot-container-height: ${i.contentRect.height}px`)}const e=this.container.clientWidth>550;this.votButton.container.dataset.position=this.votMenu.container.dataset.position=e?this.data?.buttonPos:"default",this.votButton.container.dataset.direction=this.data?.buttonPos&&"default"!==this.data?.buttonPos&&e?"column":"row"})),this.resizeObserver.observe(this.video),this.votMenu.container.setAttribute("style",`--vot-container-height: ${this.video.getBoundingClientRect().height}px`),["youtube","googledrive"].includes(this.site.host)&&"mobile"!==this.site.additionalData){this.syncVolumeObserver=new MutationObserver((t=>{if(this.audioPlayer.player.src&&this.data.syncVolume)for(let e=0;e<t.length;e++){const i=t[e];if("attributes"===i.type&&"aria-valuenow"===i.attributeName){if(this.firstSyncVolume)return void(this.firstSyncVolume=!1);const t=this.isMuted()?0:100*this.getVideoVolume(),e=Math.round(t);this.data.defaultVolume=e,this.audioPlayer.player.volume=this.data.defaultVolume/100,this.syncVolumeWrapper("video",e)}}}));const t=document.querySelector(".ytp-volume-panel");t&&this.syncVolumeObserver.observe(t,{attributes:!0,childList:!1,subtree:!0,attributeOldValue:!0})}document.addEventListener("click",(t=>{const e=t.target,i=this.votButton.container,o=this.votMenu.container,a=this.container,n=this.votSettingsDialog.container,r=document.querySelector(".vot-dialog-temp"),s=i.contains(e),l=o.contains(e),d=a.contains(e),u=n.contains(e),c=r?.contains(e)??!1;Pe.log(`[document click] ${s} ${l} ${d} ${u} ${c}`),s||l||u||c||(d||this.logout(0),this.votMenu.container.hidden=!0)}),{signal:t}),document.addEventListener("keydown",(async t=>{const e=t.code,i=document.activeElement;["input","textarea"].includes(i.tagName.toLowerCase())||i.isContentEditable||e!==this.data.hotkeyButton||await this.handleTranslationBtnClick()}),{signal:t});let o=this.getEventContainer();o&&i(o,["pointermove","pointerout"],this.resetTimer),e(this.votButton.container,"pointermove",this.changeOpacityOnEvent),e(this.votMenu.container,"pointermove",this.changeOpacityOnEvent),"xvideos"!==this.site.host&&e(document,"touchmove",this.resetTimer),e(this.votButton.container,"pointerdown",(t=>{t.stopImmediatePropagation()})),i(this.votMenu.container,["pointerdown","mousedown"],(t=>{t.stopImmediatePropagation()})),"youtube"===this.site.host&&(this.container.draggable=!1),"googledrive"===this.site.host&&(this.container.style.height="100%"),e(this.video,"canplay",(async()=>{"rutube"===this.site.host&&this.video.src||await this.setCanPlay()})),e(this.video,"emptied",(async()=>{this.video.src&&await xi(this.site,{fetchFn:ze,video:this.video})===this.videoData.videoId||(Pe.log("lipsync mode is emptied"),this.videoData="",this.stopTranslation())})),["rutube","ok"].includes(this.site.host)||e(this.video,"volumechange",(()=>{this.syncVideoVolumeSlider()})),"youtube"!==this.site.host||this.site.additionalData||e(document,"yt-page-data-updated",(async()=>{Pe.log("yt-page-data-updated"),window.location.pathname.includes("/shorts/")&&await this.setCanPlay()}))}async setCanPlay(){await xi(this.site,{fetchFn:ze,video:this.video})!==this.videoData.videoId&&(await this.handleSrcChanged(),await this.autoTranslate(),Pe.log("lipsync mode is canplay"))}logout(t){this.votMenu.container.hidden&&(this.votButton.container.style.opacity=t)}resetTimer=()=>{clearTimeout(this.timer),this.logout(1),this.timer=setTimeout((()=>{this.logout(0)}),1e3)};changeOpacityOnEvent=t=>{clearTimeout(this.timer),this.logout(1),t.stopPropagation()};async changeSubtitlesLang(t){if(Pe.log("[onchange] subtitles",t),this.votSubtitlesSelect.setSelected(t),"disabled"===t)this.votSubtitlesSelect.setTitle(Ge.get("VOTSubtitlesDisabled")),this.subtitlesWidget.setContent(null),this.votDownloadSubtitlesButton.hidden=!0,this.yandexSubtitles=null;else{const e=this.subtitlesList.at(parseInt(t));if(2===this.data.translateProxyEnabled&&e.url.startsWith("https://brosubs.s3-private.mds.yandex.net/vtrans/")){const t=e.url.replace("https://brosubs.s3-private.mds.yandex.net/vtrans/","");e.url=`https://${this.data.proxyWorkerHost}/video-subtitles/subtitles-proxy/${t}`,console.log(`[VOT] Subs proxied via ${e.url}`)}this.yandexSubtitles=await Ii.fetchSubtitles(e),this.subtitlesWidget.setContent(this.yandexSubtitles),this.votDownloadSubtitlesButton.hidden=!1}}async updateSubtitlesLangSelect(){if(!this.subtitlesList||0===this.subtitlesList.length){const t=[{label:Ge.get("VOTSubtitlesDisabled"),value:"disabled",selected:!0,disabled:!1}];return this.votSubtitlesSelect.updateItems(t),void await this.changeSubtitlesLang(t[0].value)}const t=[{label:Ge.get("VOTSubtitlesDisabled"),value:"disabled",selected:!0,disabled:!1},...this.subtitlesList.map(((t,e)=>({label:(Ge.get("langs")[t.language]??t.language.toUpperCase())+(t.translatedFromLanguage?` ${Ge.get("VOTTranslatedFrom")} ${Ge.get("langs")[t.translatedFromLanguage]??t.translatedFromLanguage.toUpperCase()}`:"")+("yandex"!==t.source?`, ${window.location.hostname}`:"")+(t.isAutoGenerated?` (${Ge.get("VOTAutogenerated")})`:""),value:e,selected:!1,disabled:!1})))];this.votSubtitlesSelect.updateItems(t),await this.changeSubtitlesLang(t[0].value)}async loadSubtitles(){if(!this.videoData.videoId)return console.error(`[VOT] ${Ge.getDefault("VOTNoVideoIDFound")}`),this.subtitlesList=[],void(this.subtitlesListVideoId=null);try{this.subtitlesList=await Ii.getSubtitles(this.votClient,this.videoData),this.subtitlesList&&(this.subtitlesListVideoId=this.videoData.videoId)}catch(t){console.error("[VOT] Failed to load subtitles:",t),this.subtitlesList=[],this.subtitlesListVideoId=null}await this.updateSubtitlesLangSelect()}getVideoVolume(){let t=this.video?.volume;return["youtube","googledrive"].includes(this.site.host)&&(t=mi.getVolume()??t),t}setVideoVolume(t){if(["youtube","googledrive"].includes(this.site.host)){if(mi.setVolume(t))return this}return this.video.volume=t,this}isMuted(){return["youtube","googledrive"].includes(this.site.host)?mi.isMuted():this.video?.muted}syncVideoVolumeSlider(){const t=this.isMuted()?0:100*this.getVideoVolume(),e=Math.round(t);this.votVideoVolumeSlider.input.value=e,this.votVideoVolumeSlider.label.querySelector("strong").textContent=`${e}%`,Li.updateSlider(this.votVideoVolumeSlider.input),1===this.data.syncVolume&&(this.tempOriginalVolume=Number(e))}setSelectMenuValues(t,e){this.votTranslationLanguageSelect.fromSelect.setTitle(Ge.get("langs")[t]),this.votTranslationLanguageSelect.toSelect.setTitle(Ge.get("langs")[e]),this.votTranslationLanguageSelect.fromSelect.setSelected(t),this.votTranslationLanguageSelect.toSelect.setSelected(e),console.log(`[VOT] Set translation from ${t} to ${e}`),this.videoData.detectedLanguage=t,this.videoData.responseLanguage=e}syncVolumeWrapper(t,e){const i="translation"===t?this.votVideoVolumeSlider:this.votVideoTranslationVolumeSlider,o=Number(i.input.value),a=function(t,e,i,o){let a=e;return e>o?(a=i+(e-o),a=a>100?100:Math.max(a,0),t.volume=a/100):e<o&&(a=i-(o-e),a=a>100?100:Math.max(a,0),t.volume=a/100),a}("translation"===t?this.video:this.audioPlayer.player,e,o,"translation"===t?this.tempVolume:this.tempOriginalVolume);i.input.value=a,i.label.querySelector("strong").textContent=`${a}%`,Li.updateSlider(i.input),this.tempOriginalVolume="translation"===t?a:e,this.tempVolume="translation"===t?e:a}async getVideoData(){const{duration:t,url:e,videoId:i,host:o,title:a,translationHelp:n=null,localizedTitle:r,description:s,detectedLanguage:l,subtitles:d,isStream:u=!1}=await async function(t,e={}){const i=await xi(t,e);if(!i)throw new oi(`Entered unsupported link: "${t.host}"`);const o=window.location.origin;if([Ce.peertube,Ce.coursehunterLike,Ce.cloudflarestream].includes(t.host)&&(t.url=o),t.rawResult)return{url:i,videoId:i,host:t.host,duration:void 0};if(!t.needExtraData)return{url:t.url+i,videoId:i,host:t.host,duration:void 0};const a=new yi({...e,service:t,origin:o}).getHelper(t.host),n=await a.getVideoData(i);if(!n)throw new oi(`Failed to get video raw url for ${t.host}`);return{...n,videoId:i,host:t.host}}(this.site,{fetchFn:ze,video:this.video,language:Ge.lang});let c=l??this.translateFromLang;if(!l&&a){const t=function(t,e){return`${t} ${e?e.split("\n").filter((t=>!Fe.test(t))).join(" "):""}`.slice(0,450).replace(/[^\p{L}\s]+|\s+/gu," ").trim()}(a,s);Pe.log(`Detecting language text: ${t}`);const e=await async function(t){const e=await Be.get("detectService",Ve);switch(e){case"yandexbrowser":case"msedge":return await Oi.detect(t,e);case"rust-server":return await Vi.detect(t);default:return"en"}}(t);hi.includes(e)&&(c=e)}const h={translationHelp:n,isStream:u,duration:t||this.video?.duration||yt.defaultDuration,videoId:i,url:e,host:o,detectedLanguage:c,responseLanguage:this.translateToLang,subtitles:d,title:a,localizedTitle:r,downloadTitle:r??a??i};if(console.log("[VOT] Detected language:",c),["rutube","ok.ru","mail_ru"].includes(this.site.host))h.detectedLanguage="ru";else if("youku"===this.site.host)h.detectedLanguage="zh";else if("vk"===this.site.host){const t=document.getElementsByTagName("track")?.[0]?.srclang;h.detectedLanguage=t||"auto"}else"weverse"===this.site.host&&(h.detectedLanguage="ko");return h}videoValidator(){if(Pe.log("VideoValidator videoData: ",this.videoData),1===this.data.dontTranslateYourLang&&this.data.dontTranslateLanguage?.includes(this.videoData.detectedLanguage))throw new Ye("VOTDisableFromYourLang");if(!this.videoData.isStream&&this.videoData.duration>14400)throw new Ye("VOTVideoIsTooLong");return!0}stopTranslate(){this.audioPlayer.player.removeVideoEvents(),this.audioPlayer.player.clear(),this.audioPlayer.player.src=void 0,Pe.log("audioPlayer after stopTranslate",this.audioPlayer),this.votVideoVolumeSlider.container.hidden=!0,this.votVideoTranslationVolumeSlider.container.hidden=!0,this.votDownloadButton.hidden=!0,this.downloadTranslationUrl=null,this.longWaitingResCount=0,this.transformBtn("none",Ge.get("translateVideo")),Pe.log(`Volume on start: ${this.volumeOnStart}`),this.volumeOnStart&&this.setVideoVolume(this.volumeOnStart),clearInterval(this.streamPing),clearTimeout(this.autoRetry),this.hls?.destroy(),this.hls=De(),this.firstSyncVolume=!0}async translateExecutor(t){Pe.log("Run translateFunc",t),await this.translateFunc(t,this.videoData.isStream,this.videoData.detectedLanguage,this.videoData.responseLanguage,this.videoData.translationHelp)}async updateTranslationErrorMsg(t){const e=Ge.get("translationTake"),i=Ge.lang;if(this.longWaitingResCount=t===Ge.get("translationTakeAboutMinute")?this.longWaitingResCount+1:0,Pe.log("longWaitingResCount",this.longWaitingResCount),this.longWaitingResCount>5&&(t=new Ye("TranslationDelayed")),"VOTLocalizedError"===t?.name)this.transformBtn("error",t.localizedMessage);else if(t instanceof Error)this.transformBtn("error",t?.message);else if(1!==this.data.translateAPIErrors||"ru"===i||t.includes(e))this.transformBtn("error",t);else{this.setLoadingBtn(!0);const e=await async function(t,e="",i="ru"){const o=await Be.get("translationService",Oe);switch(o){case"yandexbrowser":case"msedge":{const a=e&&i?`${e}-${i}`:i;return await Oi.translate(t,a,o)}default:return t}}(t,"ru",i);this.transformBtn("error",e)}["Подготавливаем перевод","Видео передано в обработку","Ожидаем перевод видео","Загружаем переведенное аудио"].includes(t)&&this.setLoadingBtn(!0)}afterUpdateTranslation(t){const e="success"===this.votButton.container.dataset.status;this.votVideoVolumeSlider.container.hidden=1!==this.data.showVideoSlider||!e,this.votVideoTranslationVolumeSlider.container.hidden=!e,1===this.data.autoSetVolumeYandexStyle&&(this.votVideoVolumeSlider.input.value=100*this.data.autoVolume,this.votVideoVolumeSlider.label.querySelector("strong").textContent=100*this.data.autoVolume+"%",Li.updateSlider(this.votVideoVolumeSlider.input)),this.videoData.isStream||(this.votDownloadButton.hidden=!1,this.downloadTranslationUrl=t),Pe.log("afterUpdateTranslation downloadTranslationUrl",this.downloadTranslationUrl),this.data.sendNotifyOnComplete&&this.longWaitingResCount&&e&&GM_notification({text:Ge.get("VOTTranslationCompletedNotify").replace("{0}",window.location.hostname),title:GM_info.script.name,highlight:!0,timeout:5e3,silent:!0,tag:"VOTTranslationCompleted",url:window.location.href,onclick:t=>{t.preventDefault(),window.focus()}})}async validateAudioUrl(t){try{const e=await ze(t,{method:"HEAD"});if(Pe.log("Test audio response",e),404!==e.status)return Pe.log("Valid audioUrl",t),t;Pe.log("Yandex returned not valid audio, trying to fix...");let i=await this.translateVideoImpl(this.videoData,this.videoData.detectedLanguage="auto",this.videoData.responseLanguage,this.videoData.translationHelp);this.setSelectMenuValues(this.videoData.detectedLanguage,this.videoData.responseLanguage),t=i.url,Pe.log("Fixed audio audioUrl",t)}catch(t){Pe.log("Test audio error:",t)}return t}proxifyAudio(t){if(2===this.data.translateProxyEnabled&&t.startsWith("https://vtrans.s3-private.mds.yandex.net/tts/prod/")){const e=t.replace("https://vtrans.s3-private.mds.yandex.net/tts/prod/","");t=`https://${this.data.proxyWorkerHost}/video-translation/audio-proxy/${e}`,console.log(`[VOT] Audio proxied via ${t}`)}return t}async updateTranslation(t){this.cachedTranslation?.url!==this.audioPlayer.player.currentSrc&&(t=await this.validateAudioUrl(this.proxifyAudio(t))),this.audioPlayer.player.src!==t&&(this.audioPlayer.player.src=t);try{this.audioPlayer.init()}catch(t){Pe.log("this.audioPlayer.init() error",t),this.videoHandler.transformBtn("error",t.message)}this.setupAudioSettings(),"twitter"===this.site.host&&document.querySelector('button[data-testid="app-bar-back"][role="button"]').addEventListener("click",this.stopTranslation),this.transformBtn("success",Ge.get("disableTranslate")),this.afterUpdateTranslation(t)}async translateFunc(t,e,i,o,a){if(console.log("[VOT] Video Data: ",this.videoData),Pe.log("Run videoValidator"),this.videoValidator(),this.setLoadingBtn(!0),this.volumeOnStart=this.getVideoVolume(),e){let t=await this.translateStreamImpl(this.videoData,i,o);if(!t)return void Pe.log("Skip translation");this.transformBtn("success",Ge.get("disableTranslate"));try{this.audioPlayer.init()}catch(t){Pe.log("this.audioPlayer.init() error",t),this.videoHandler.transformBtn("error",t.message)}const e=this.setHLSSource(t.result.url);return"youtube"===this.site.host&&mi.videoSeek(this.video,10),this.setupAudioSettings(),this.video.src||this.video.currentSrc||this.video.srcObject?this.afterUpdateTranslation(e):this.stopTranslation()}if(this.cachedTranslation=this.videoTranslations.find((e=>e.videoId===t&&e.expires>He()&&e.from===i&&e.to===o&&e.useNewModel===this.data.useNewModel)),this.cachedTranslation)return await this.updateTranslation(this.cachedTranslation.url),void Pe.log("[translateFunc] Cached translation was received");let n=await this.translateVideoImpl(this.videoData,i,o,a);Pe.log("[translateRes]",n),n?(await this.updateTranslation(n.url),this.subtitlesList.some((t=>"yandex"===t.source&&t.translatedFromLanguage===this.videoData.detectedLanguage&&t.language===this.videoData.responseLanguage))||(this.subtitlesList=await Ii.getSubtitles(this.votClient,this.videoData),await this.updateSubtitlesLangSelect()),this.videoTranslations.push({videoId:t,from:i,to:o,url:this.downloadTranslationUrl,expires:He()+this.videoTranslationTTL,useNewModel:this.data?.useNewModel})):Pe.log("Skip translation")}setupHLS(t){this.hls.on(Hls.Events.MEDIA_ATTACHED,(function(){Pe.log("audio and hls.js are now bound together !")})),this.hls.on(Hls.Events.MANIFEST_PARSED,(function(t){Pe.log("manifest loaded, found "+t?.levels?.length+" quality level")})),this.hls.loadSource(t),this.hls.attachMedia(this.audioPlayer.player.audio),this.hls.on(Hls.Events.ERROR,(function(t){if(t.fatal)switch(t.type){case Hls.ErrorTypes.MEDIA_ERROR:console.log("fatal media error encountered, try to recover"),this.hls.recoverMediaError();break;case Hls.ErrorTypes.NETWORK_ERROR:console.error("fatal network error encountered",t);break;default:this.hls.destroy()}})),Pe.log(this.hls)}setHLSSource(t){const e=`https://${this.data.m3u8ProxyHost}/?all=yes&origin=${encodeURIComponent("https://strm.yandex.ru")}&referer=${encodeURIComponent("https://strm.yandex.ru")}&url=${encodeURIComponent(t)}`;if(this.hls)this.setupHLS(e);else{if(!this.audioPlayer.player.audio.canPlayType("application/vnd.apple.mpegurl"))throw new Ye("audioFormatNotSupported");this.audioPlayer.player.src=e}return e}setupAudioSettings(){"number"==typeof this.data.defaultVolume&&(this.audioPlayer.player.volume=this.data.defaultVolume/100),"number"==typeof this.data.autoSetVolumeYandexStyle&&this.data.autoSetVolumeYandexStyle&&this.setVideoVolume(this.data.autoVolume)}stopTranslation=()=>{this.stopTranslate(),this.syncVideoVolumeSlider()};async handleSrcChanged(){Pe.log("[VideoHandler] src changed",this),this.firstPlay=!0,this.stopTranslation();const t=!this.video.src&&!this.video.currentSrc&&!this.video.srcObject;this.votButton.container.hidden=t,t&&(this.votMenu.container.hidden=t),this.site.selector||(this.container=this.video.parentElement),this.container.contains(this.votButton.container)||this.container.append(this.votButton.container,this.votMenu.container),this.videoData=await this.getVideoData(),this.subtitlesListVideoId!==this.videoData.videoId&&(this.subtitlesList=[],this.subtitlesListVideoId=null,await this.updateSubtitlesLangSelect()),this.translateToLang=this.data.responseLanguage??"ru",this.setSelectMenuValues(this.videoData.detectedLanguage,this.videoData.responseLanguage)}async release(){Pe.log("[VideoHandler] release"),this.initialized=!1,this.releaseExtraEvents(),this.subtitlesWidget.release(),this.votButton.container.remove(),this.votMenu.container.remove()}}const Fi=new Ai,Ui=new WeakMap;function qi(t,e){if(!t||!e)return null;if(t instanceof Document)return t.querySelector(e);const i=t.closest(e);if(i)return i;const o=t.getRootNode();return qi(o instanceof Document?o:o.host,e)}function zi(t,e){if(Pe.log("findContainer",t,e),t.shadowRoot){let i=qi(e,t.selector);return Pe.log("findContainer with site.shadowRoot",i),i??e.parentElement}Pe.log("findContainer without shadowRoot");const i=Bi.browser.version?.split(".")?.[0];if(t.selector?.includes(":not")&&t.selector?.includes("*")&&i&&("Chrome"===Bi.browser.name&&Number(i)<88||"Firefox"===Bi.browser.name&&Number(i)<84)){const i=t.selector.split(" *")[0];return i?Array.from(document.querySelectorAll(i)).find((t=>t.contains(e))):e.parentElement}return t.selector?Array.from(document.querySelectorAll(t.selector)).find((t=>t.contains(e))):e.parentElement}(async function(){Pe.log("Loading extension..."),await Ge.update(),Pe.log(`Selected menu language: ${Ge.lang}`),"https://9animetv.to"!==window.location.origin?"https://dev.epicgames.com"===window.location.origin&&window.location.pathname.includes("/community/learning/")&&window.addEventListener("message",(t=>{if("https://dev.epicgames.com"!==t.origin)return;if("string"!=typeof t.data||!t.data.startsWith("getVideoId:"))return;const e=t.data.replace("getVideoId:",""),i=atob(e),o=/\/(\w{3,5})\/[^/]+$/.exec(window.location.pathname)?.[1],a=document.querySelector(`electra-player > iframe[src="${i}"]`)?.contentWindow;a.postMessage(`${t.data}:${o}`,"https://dev.epicgames.com")})):window.addEventListener("message",(t=>{if("https://rapid-cloud.co"!==t.origin)return;if("getVideoId"!==t.data)return;const e=/[^/]+$/.exec(window.location.href)?.[0],i=document.querySelector("#iframe-embed")?.contentWindow;i.postMessage(`getVideoId:${e}`,"https://rapid-cloud.co")})),Fi.onVideoAdded.addListener((t=>{for(const e of function(){if(ai.exec(window.location.href))return[];const t=window.location.hostname,e=new URL(window.location.href),i=i=>i instanceof RegExp?i.test(t):"string"==typeof i?t.includes(i):"function"==typeof i&&i(e);return ri.filter((t=>(Array.isArray(t.match)?t.match.some(i):i(t.match))&&t.host&&t.url))}()){if(!e)continue;let i=zi(e,t);if(i&&(("rumble"!==e.host||t.style.display)&&(["peertube","directlink"].includes(e.host)&&(e.url=window.location.origin),!Ui.has(t)))){Ui.set(t,new Di(t,i,e));break}}})),Fi.onVideoRemoved.addListener((async t=>{Ui.has(t)&&(await Ui.get(t).release(),Ui.delete(t))})),Fi.enable()})().catch((t=>{console.error("[VOT]",t)}))})()})(); \ No newline at end of file + <strong>${this.data?.subtitlesOpacity??20}</strong>`,this.data?.subtitlesOpacity??20,0,100),this.votSubtitlesDialog.bodyContainer.appendChild(this.votSubtitlesOpacitySlider.container),this.votSubtitlesHighlightWordsCheckbox.input.addEventListener("change",(t=>{(async()=>{this.data.highlightWords=Number(t.target.checked),await Be.set("highlightWords",this.data.highlightWords),Pe.log("highlightWords value changed. New value: ",this.data.highlightWords),this.subtitlesWidget.setHighlightWords(this.data.highlightWords)})()})),this.votSubtitlesMaxLengthSlider.input.addEventListener("input",(t=>{(async()=>{this.data.subtitlesMaxLength=Number(t.target.value),await Be.set("subtitlesMaxLength",this.data.subtitlesMaxLength),this.votSubtitlesMaxLengthSlider.label.querySelector("strong").textContent=`${this.data.subtitlesMaxLength}`,this.subtitlesWidget.setMaxLength(this.data.subtitlesMaxLength)})()})),this.votSubtitlesFontSizeSlider.input.addEventListener("input",(t=>{(async()=>{this.data.subtitlesFontSize=Number(t.target.value),await Be.set("subtitlesFontSize",this.data.subtitlesFontSize),this.votSubtitlesFontSizeSlider.label.querySelector("strong").textContent=`${this.data.subtitlesFontSize}`,this.subtitlesWidget.setFontSize(this.data.subtitlesFontSize)})()})),this.votSubtitlesOpacitySlider.input.addEventListener("input",(t=>{(async()=>{this.data.subtitlesOpacity=Number(t.target.value),await Be.set("subtitlesOpacity",this.data.subtitlesOpacity),this.votSubtitlesOpacitySlider.label.querySelector("strong").textContent=`${this.data.subtitlesOpacity}`,this.subtitlesWidget.setOpacity(this.data.subtitlesOpacity)})()})),document.documentElement.appendChild(this.votSubtitlesDialog.container)})),this.votShowPiPButtonCheckbox.input.addEventListener("change",(t=>{(async()=>{this.data.showPiPButton=Number(t.target.checked),await Be.set("showPiPButton",this.data.showPiPButton),Pe.log("showPiPButton value changed. New value: ",this.data.showPiPButton),this.votButton.pipButton.hidden=this.votButton.separator2.hidden=!Re()||!this.data.showPiPButton})()})),this.votM3u8ProxyHostTextfield.input.addEventListener("change",(t=>{(async()=>{this.data.m3u8ProxyHost=t.target.value||Le,await Be.set("m3u8ProxyHost",this.data.m3u8ProxyHost),Pe.log("m3u8ProxyHost value changed. New value: ",this.data.m3u8ProxyHost)})()})),this.votProxyWorkerHostTextfield.input.addEventListener("change",(t=>{(async()=>{this.data.proxyWorkerHost=t.target.value||_e,await Be.set("proxyWorkerHost",this.data.proxyWorkerHost),Pe.log("proxyWorkerHost value changed. New value: ",this.data.proxyWorkerHost),this.data.translateProxyEnabled&&(this.votClient.host=this.data.proxyWorkerHost)})()})),this.votOnlyBypassMediaCSPCheckbox.input.addEventListener("change",(t=>{(async()=>{this.data.onlyBypassMediaCSP=Number(t.target.checked),await Be.set("onlyBypassMediaCSP",this.data.onlyBypassMediaCSP),Pe.log("onlyBypassMediaCSP value changed. New value: ",this.data.onlyBypassMediaCSP),this.stopTranslate(),this.createPlayer()})()})),this.votNewAudioPlayerCheckbox.input.addEventListener("change",(t=>{(async()=>{const e=t.target.checked;this.data.newAudioPlayer=Number(e),await Be.set("newAudioPlayer",this.data.newAudioPlayer),Pe.log("newAudioPlayer value changed. New value: ",this.data.newAudioPlayer),this.stopTranslate(),this.createPlayer(),this.votOnlyBypassMediaCSPCheckbox.input.disabled=this.votOnlyBypassMediaCSPCheckbox.container.hidden=!e})()})),this.votBugReportButton.addEventListener("click",(()=>{const t=new URLSearchParams(this.collectReportInfo()).toString();window.open(`https://github.com/ilyhalight/voice-over-translation/issues/new?${t}`,"_blank").focus()})),this.votUpdateLocaleFilesButton.addEventListener("click",(()=>{(async()=>{await Be.set("locale-hash",""),await Ge.update(!0),window.location.reload()})()})),this.votResetSettingsButton.addEventListener("click",(()=>{(async()=>{Ge.reset();const t=await Be.list();for(let e=0;e<t.length;e++){const i=t[e];Ge.gmValues.includes(i)||Be.syncDelete(i)}window.location.reload()})()}))}}collectReportInfo(){const t=`${Bi.os.name} ${Bi.os.version}`,e=`Autogenerated by VOT:\n- OS: ${t}\n- Browser: ${Bi.browser.name} ${Bi.browser.version}\n- Loader: ${GM_info.scriptHandler} v${GM_info.version}\n- Script version: ${GM_info.script.version}\n- URL: \`${window.location.href}\``;return{assignees:"ilyhalight",template:"bug.yml",os:t,"script-version":GM_info.script.version,"additional-info":e}}releaseExtraEvents(){this.abortController.abort(),this.resizeObserver?.disconnect(),["youtube","googledrive"].includes(this.site.host)&&"mobile"!==this.site.additionalData&&this.syncVolumeObserver?.disconnect()}getEventContainer(){return this.site.eventSelector?"twitter"===this.site.host?this.container.closest(this.site.eventSelector):document.querySelector(this.site.eventSelector):this.container}initExtraEvents(){const{signal:t}=this.abortController,e=(e,i,o)=>{this.extraEvents.push({element:e,event:i,handler:o}),e.addEventListener(i,o,{signal:t})},i=(t,i,o)=>{for(const a of i)e(t,a,o)};if(this.resizeObserver=new ResizeObserver((t=>{for(let e=0;e<t.length;e++){const i=t[e];this.votMenu.container.setAttribute("style",`--vot-container-height: ${i.contentRect.height}px`)}const e=this.container.clientWidth>550;this.votButton.container.dataset.position=this.votMenu.container.dataset.position=e?this.data?.buttonPos:"default",this.votButton.container.dataset.direction=this.data?.buttonPos&&"default"!==this.data?.buttonPos&&e?"column":"row"})),this.resizeObserver.observe(this.video),this.votMenu.container.setAttribute("style",`--vot-container-height: ${this.video.getBoundingClientRect().height}px`),["youtube","googledrive"].includes(this.site.host)&&"mobile"!==this.site.additionalData){this.syncVolumeObserver=new MutationObserver((t=>{if(this.audioPlayer.player.src&&this.data.syncVolume)for(let e=0;e<t.length;e++){const i=t[e];if("attributes"===i.type&&"aria-valuenow"===i.attributeName){if(this.firstSyncVolume)return void(this.firstSyncVolume=!1);const t=this.isMuted()?0:100*this.getVideoVolume(),e=Math.round(t);this.data.defaultVolume=e,this.audioPlayer.player.volume=this.data.defaultVolume/100,this.syncVolumeWrapper("video",e)}}}));const t=document.querySelector(".ytp-volume-panel");t&&this.syncVolumeObserver.observe(t,{attributes:!0,childList:!1,subtree:!0,attributeOldValue:!0})}document.addEventListener("click",(t=>{const e=t.target,i=this.votButton.container,o=this.votMenu.container,a=this.container,n=this.votSettingsDialog.container,r=document.querySelector(".vot-dialog-temp"),s=i.contains(e),l=o.contains(e),d=a.contains(e),u=n.contains(e),c=r?.contains(e)??!1;Pe.log(`[document click] ${s} ${l} ${d} ${u} ${c}`),s||l||u||c||(d||this.logout(0),this.votMenu.container.hidden=!0)}),{signal:t}),document.addEventListener("keydown",(async t=>{const e=t.code,i=document.activeElement;["input","textarea"].includes(i.tagName.toLowerCase())||i.isContentEditable||e!==this.data.hotkeyButton||await this.handleTranslationBtnClick()}),{signal:t});let o=this.getEventContainer();o&&i(o,["pointermove","pointerout"],this.resetTimer),e(this.votButton.container,"pointermove",this.changeOpacityOnEvent),e(this.votMenu.container,"pointermove",this.changeOpacityOnEvent),"xvideos"!==this.site.host&&e(document,"touchmove",this.resetTimer),e(this.votButton.container,"pointerdown",(t=>{t.stopImmediatePropagation()})),i(this.votMenu.container,["pointerdown","mousedown"],(t=>{t.stopImmediatePropagation()})),"youtube"===this.site.host&&(this.container.draggable=!1),"googledrive"===this.site.host&&(this.container.style.height="100%"),e(this.video,"canplay",(async()=>{"rutube"===this.site.host&&this.video.src||await this.setCanPlay()})),e(this.video,"emptied",(async()=>{this.video.src&&await xi(this.site,{fetchFn:ze,video:this.video})===this.videoData.videoId||(Pe.log("lipsync mode is emptied"),this.videoData="",this.stopTranslation())})),["rutube","ok"].includes(this.site.host)||e(this.video,"volumechange",(()=>{this.syncVideoVolumeSlider()})),"youtube"!==this.site.host||this.site.additionalData||e(document,"yt-page-data-updated",(async()=>{Pe.log("yt-page-data-updated"),window.location.pathname.includes("/shorts/")&&await this.setCanPlay()}))}async setCanPlay(){await xi(this.site,{fetchFn:ze,video:this.video})!==this.videoData.videoId&&(await this.handleSrcChanged(),await this.autoTranslate(),Pe.log("lipsync mode is canplay"))}logout(t){this.votMenu.container.hidden&&(this.votButton.container.style.opacity=t)}resetTimer=()=>{clearTimeout(this.timer),this.logout(1),this.timer=setTimeout((()=>{this.logout(0)}),1e3)};changeOpacityOnEvent=t=>{clearTimeout(this.timer),this.logout(1),t.stopPropagation()};async changeSubtitlesLang(t){if(Pe.log("[onchange] subtitles",t),this.votSubtitlesSelect.setSelected(t),"disabled"===t)this.votSubtitlesSelect.setTitle(Ge.get("VOTSubtitlesDisabled")),this.subtitlesWidget.setContent(null),this.votDownloadSubtitlesButton.hidden=!0,this.yandexSubtitles=null;else{const e=this.subtitlesList.at(parseInt(t));if(2===this.data.translateProxyEnabled&&e.url.startsWith("https://brosubs.s3-private.mds.yandex.net/vtrans/")){const t=e.url.replace("https://brosubs.s3-private.mds.yandex.net/vtrans/","");e.url=`https://${this.data.proxyWorkerHost}/video-subtitles/subtitles-proxy/${t}`,console.log(`[VOT] Subs proxied via ${e.url}`)}this.yandexSubtitles=await Ii.fetchSubtitles(e),this.subtitlesWidget.setContent(this.yandexSubtitles),this.votDownloadSubtitlesButton.hidden=!1}}async updateSubtitlesLangSelect(){if(!this.subtitlesList||0===this.subtitlesList.length){const t=[{label:Ge.get("VOTSubtitlesDisabled"),value:"disabled",selected:!0,disabled:!1}];return this.votSubtitlesSelect.updateItems(t),void await this.changeSubtitlesLang(t[0].value)}const t=[{label:Ge.get("VOTSubtitlesDisabled"),value:"disabled",selected:!0,disabled:!1},...this.subtitlesList.map(((t,e)=>({label:(Ge.get("langs")[t.language]??t.language.toUpperCase())+(t.translatedFromLanguage?` ${Ge.get("VOTTranslatedFrom")} ${Ge.get("langs")[t.translatedFromLanguage]??t.translatedFromLanguage.toUpperCase()}`:"")+("yandex"!==t.source?`, ${window.location.hostname}`:"")+(t.isAutoGenerated?` (${Ge.get("VOTAutogenerated")})`:""),value:e,selected:!1,disabled:!1})))];this.votSubtitlesSelect.updateItems(t),await this.changeSubtitlesLang(t[0].value)}async loadSubtitles(){if(!this.videoData.videoId)return console.error(`[VOT] ${Ge.getDefault("VOTNoVideoIDFound")}`),this.subtitlesList=[],void(this.subtitlesListVideoId=null);try{this.subtitlesList=await Ii.getSubtitles(this.votClient,this.videoData),this.subtitlesList&&(this.subtitlesListVideoId=this.videoData.videoId)}catch(t){console.error("[VOT] Failed to load subtitles:",t),this.subtitlesList=[],this.subtitlesListVideoId=null}await this.updateSubtitlesLangSelect()}getVideoVolume(){let t=this.video?.volume;return["youtube","googledrive"].includes(this.site.host)&&(t=mi.getVolume()??t),t}setVideoVolume(t){if(["youtube","googledrive"].includes(this.site.host)){if(mi.setVolume(t))return this}return this.video.volume=t,this}isMuted(){return["youtube","googledrive"].includes(this.site.host)?mi.isMuted():this.video?.muted}syncVideoVolumeSlider(){const t=this.isMuted()?0:100*this.getVideoVolume(),e=Math.round(t);this.votVideoVolumeSlider.input.value=e,this.votVideoVolumeSlider.label.querySelector("strong").textContent=`${e}%`,Li.updateSlider(this.votVideoVolumeSlider.input),1===this.data.syncVolume&&(this.tempOriginalVolume=Number(e))}setSelectMenuValues(t,e){this.votTranslationLanguageSelect.fromSelect.setTitle(Ge.get("langs")[t]),this.votTranslationLanguageSelect.toSelect.setTitle(Ge.get("langs")[e]),this.votTranslationLanguageSelect.fromSelect.setSelected(t),this.votTranslationLanguageSelect.toSelect.setSelected(e),console.log(`[VOT] Set translation from ${t} to ${e}`),this.videoData.detectedLanguage=t,this.videoData.responseLanguage=e}syncVolumeWrapper(t,e){const i="translation"===t?this.votVideoVolumeSlider:this.votVideoTranslationVolumeSlider,o=Number(i.input.value),a=function(t,e,i,o){let a=e;return e>o?(a=i+(e-o),a=a>100?100:Math.max(a,0),t.volume=a/100):e<o&&(a=i-(o-e),a=a>100?100:Math.max(a,0),t.volume=a/100),a}("translation"===t?this.video:this.audioPlayer.player,e,o,"translation"===t?this.tempVolume:this.tempOriginalVolume);i.input.value=a,i.label.querySelector("strong").textContent=`${a}%`,Li.updateSlider(i.input),this.tempOriginalVolume="translation"===t?a:e,this.tempVolume="translation"===t?e:a}async getVideoData(){const{duration:t,url:e,videoId:i,host:o,title:a,translationHelp:n=null,localizedTitle:r,description:s,detectedLanguage:l,subtitles:d,isStream:u=!1}=await async function(t,e={}){const i=await xi(t,e);if(!i)throw new oi(`Entered unsupported link: "${t.host}"`);const o=window.location.origin;if([Ce.peertube,Ce.coursehunterLike,Ce.cloudflarestream].includes(t.host)&&(t.url=o),t.rawResult)return{url:i,videoId:i,host:t.host,duration:void 0};if(!t.needExtraData)return{url:t.url+i,videoId:i,host:t.host,duration:void 0};const a=new yi({...e,service:t,origin:o}).getHelper(t.host),n=await a.getVideoData(i);if(!n)throw new oi(`Failed to get video raw url for ${t.host}`);return{...n,videoId:i,host:t.host}}(this.site,{fetchFn:ze,video:this.video,language:Ge.lang});let c=l??this.translateFromLang;if(!l&&a){const t=function(t,e){return(t+" "+(e||"")).replace(Fe,"").replace(/(?:[\s\u200B]+|\.{2,})/g," ").replace(/[^\p{L}\s]/gu,"").replace(/\s+/g," ").substring(0,450).trim()}(a,s);Pe.log(`Detecting language text: ${t}`);const e=await async function(t){const e=await Be.get("detectService",Ve);switch(e){case"yandexbrowser":case"msedge":return await Oi.detect(t,e);case"rust-server":return await Vi.detect(t);default:return"en"}}(t);hi.includes(e)&&(c=e)}const h={translationHelp:n,isStream:u,duration:t||this.video?.duration||yt.defaultDuration,videoId:i,url:e,host:o,detectedLanguage:c,responseLanguage:this.translateToLang,subtitles:d,title:a,localizedTitle:r,downloadTitle:r??a??i};if(console.log("[VOT] Detected language:",c),["rutube","ok.ru","mail_ru"].includes(this.site.host))h.detectedLanguage="ru";else if("youku"===this.site.host)h.detectedLanguage="zh";else if("vk"===this.site.host){const t=document.getElementsByTagName("track")?.[0]?.srclang;h.detectedLanguage=t||"auto"}else"weverse"===this.site.host&&(h.detectedLanguage="ko");return h}videoValidator(){if(Pe.log("VideoValidator videoData: ",this.videoData),1===this.data.dontTranslateYourLang&&this.data.dontTranslateLanguage?.includes(this.videoData.detectedLanguage))throw new Ye("VOTDisableFromYourLang");if(!this.videoData.isStream&&this.videoData.duration>14400)throw new Ye("VOTVideoIsTooLong");return!0}stopTranslate(){this.audioPlayer.player.removeVideoEvents(),this.audioPlayer.player.clear(),this.audioPlayer.player.src=void 0,Pe.log("audioPlayer after stopTranslate",this.audioPlayer),this.votVideoVolumeSlider.container.hidden=!0,this.votVideoTranslationVolumeSlider.container.hidden=!0,this.votDownloadButton.hidden=!0,this.downloadTranslationUrl=null,this.longWaitingResCount=0,this.transformBtn("none",Ge.get("translateVideo")),Pe.log(`Volume on start: ${this.volumeOnStart}`),this.volumeOnStart&&this.setVideoVolume(this.volumeOnStart),clearInterval(this.streamPing),clearTimeout(this.autoRetry),this.hls?.destroy(),this.hls=De(),this.firstSyncVolume=!0}async translateExecutor(t){Pe.log("Run translateFunc",t),await this.translateFunc(t,this.videoData.isStream,this.videoData.detectedLanguage,this.videoData.responseLanguage,this.videoData.translationHelp)}async updateTranslationErrorMsg(t){const e=Ge.get("translationTake"),i=Ge.lang;if(this.longWaitingResCount=t===Ge.get("translationTakeAboutMinute")?this.longWaitingResCount+1:0,Pe.log("longWaitingResCount",this.longWaitingResCount),this.longWaitingResCount>5&&(t=new Ye("TranslationDelayed")),"VOTLocalizedError"===t?.name)this.transformBtn("error",t.localizedMessage);else if(t instanceof Error)this.transformBtn("error",t?.message);else if(1!==this.data.translateAPIErrors||"ru"===i||t.includes(e))this.transformBtn("error",t);else{this.setLoadingBtn(!0);const e=await async function(t,e="",i="ru"){const o=await Be.get("translationService",Oe);switch(o){case"yandexbrowser":case"msedge":{const a=e&&i?`${e}-${i}`:i;return await Oi.translate(t,a,o)}default:return t}}(t,"ru",i);this.transformBtn("error",e)}["Подготавливаем перевод","Видео передано в обработку","Ожидаем перевод видео","Загружаем переведенное аудио"].includes(t)&&this.setLoadingBtn(!0)}afterUpdateTranslation(t){const e="success"===this.votButton.container.dataset.status;this.votVideoVolumeSlider.container.hidden=1!==this.data.showVideoSlider||!e,this.votVideoTranslationVolumeSlider.container.hidden=!e,1===this.data.autoSetVolumeYandexStyle&&(this.votVideoVolumeSlider.input.value=100*this.data.autoVolume,this.votVideoVolumeSlider.label.querySelector("strong").textContent=100*this.data.autoVolume+"%",Li.updateSlider(this.votVideoVolumeSlider.input)),this.videoData.isStream||(this.votDownloadButton.hidden=!1,this.downloadTranslationUrl=t),Pe.log("afterUpdateTranslation downloadTranslationUrl",this.downloadTranslationUrl),this.data.sendNotifyOnComplete&&this.longWaitingResCount&&e&&GM_notification({text:Ge.get("VOTTranslationCompletedNotify").replace("{0}",window.location.hostname),title:GM_info.script.name,highlight:!0,timeout:5e3,silent:!0,tag:"VOTTranslationCompleted",url:window.location.href,onclick:t=>{t.preventDefault(),window.focus()}})}async validateAudioUrl(t){try{const e=await ze(t,{method:"HEAD"});if(Pe.log("Test audio response",e),e.ok)return Pe.log("Valid audioUrl",t),t;{Pe.log("Yandex returned not valid audio, trying to fix...");let e=await this.translateVideoImpl(this.videoData,this.videoData.detectedLanguage="auto",this.videoData.responseLanguage,this.videoData.translationHelp);this.setSelectMenuValues(this.videoData.detectedLanguage,this.videoData.responseLanguage),t=e.url,Pe.log("Fixed audio audioUrl",t)}}catch(t){Pe.log("Test audio error:",t)}return t}proxifyAudio(t){if(2===this.data.translateProxyEnabled&&t.startsWith("https://vtrans.s3-private.mds.yandex.net/tts/prod/")){const e=t.replace("https://vtrans.s3-private.mds.yandex.net/tts/prod/","");t=`https://${this.data.proxyWorkerHost}/video-translation/audio-proxy/${e}`,console.log(`[VOT] Audio proxied via ${t}`)}return t}async updateTranslation(t){this.cachedTranslation?.url!==this.audioPlayer.player.currentSrc&&(t=await this.validateAudioUrl(this.proxifyAudio(t))),this.audioPlayer.player.src!==t&&(this.audioPlayer.player.src=t);try{this.audioPlayer.init()}catch(t){Pe.log("this.audioPlayer.init() error",t),this.videoHandler.transformBtn("error",t.message)}this.setupAudioSettings(),"twitter"===this.site.host&&document.querySelector('button[data-testid="app-bar-back"][role="button"]').addEventListener("click",this.stopTranslation),this.transformBtn("success",Ge.get("disableTranslate")),this.afterUpdateTranslation(t)}async translateFunc(t,e,i,o,a){if(console.log("[VOT] Video Data: ",this.videoData),Pe.log("Run videoValidator"),this.videoValidator(),this.setLoadingBtn(!0),this.volumeOnStart=this.getVideoVolume(),e){let t=await this.translateStreamImpl(this.videoData,i,o);if(!t)return void Pe.log("Skip translation");this.transformBtn("success",Ge.get("disableTranslate"));try{this.audioPlayer.init()}catch(t){Pe.log("this.audioPlayer.init() error",t),this.videoHandler.transformBtn("error",t.message)}const e=this.setHLSSource(t.result.url);return"youtube"===this.site.host&&mi.videoSeek(this.video,10),this.setupAudioSettings(),this.video.src||this.video.currentSrc||this.video.srcObject?this.afterUpdateTranslation(e):this.stopTranslation()}const n=`${t}_${i}_${o}_${this.data.useNewModel}`;this.cachedTranslation=this.videoTranslations.get(n);const r=He();if(this.cachedTranslation&&this.cachedTranslation.expires>r)return await this.updateTranslation(this.cachedTranslation.url),void Pe.log("[translateFunc] Cached translation was received");let s=await this.translateVideoImpl(this.videoData,i,o,a);Pe.log("[translateRes]",s),s?(await this.updateTranslation(s.url),this.subtitlesList.some((t=>"yandex"===t.source&&t.translatedFromLanguage===this.videoData.detectedLanguage&&t.language===this.videoData.responseLanguage))||(await this.loadSubtitles(),await this.updateSubtitlesLangSelect()),this.videoTranslations.set(n,{videoId:t,from:i,to:o,url:this.downloadTranslationUrl,expires:r+this.videoTranslationTTL,useNewModel:this.data?.useNewModel})):Pe.log("Skip translation")}setupHLS(t){this.hls.on(Hls.Events.MEDIA_ATTACHED,(function(){Pe.log("audio and hls.js are now bound together !")})),this.hls.on(Hls.Events.MANIFEST_PARSED,(function(t){Pe.log("manifest loaded, found "+t?.levels?.length+" quality level")})),this.hls.loadSource(t),this.hls.attachMedia(this.audioPlayer.player.audio),this.hls.on(Hls.Events.ERROR,(function(t){if(t.fatal)switch(t.type){case Hls.ErrorTypes.MEDIA_ERROR:console.log("fatal media error encountered, try to recover"),this.hls.recoverMediaError();break;case Hls.ErrorTypes.NETWORK_ERROR:console.error("fatal network error encountered",t);break;default:this.hls.destroy()}})),Pe.log(this.hls)}setHLSSource(t){const e=`https://${this.data.m3u8ProxyHost}/?all=yes&origin=${encodeURIComponent("https://strm.yandex.ru")}&referer=${encodeURIComponent("https://strm.yandex.ru")}&url=${encodeURIComponent(t)}`;if(this.hls)this.setupHLS(e);else{if(!this.audioPlayer.player.audio.canPlayType("application/vnd.apple.mpegurl"))throw new Ye("audioFormatNotSupported");this.audioPlayer.player.src=e}return e}setupAudioSettings(){"number"==typeof this.data.defaultVolume&&(this.audioPlayer.player.volume=this.data.defaultVolume/100),"number"==typeof this.data.autoSetVolumeYandexStyle&&this.data.autoSetVolumeYandexStyle&&this.setVideoVolume(this.data.autoVolume)}stopTranslation=()=>{this.stopTranslate(),this.syncVideoVolumeSlider()};async handleSrcChanged(){Pe.log("[VideoHandler] src changed",this),this.firstPlay=!0,this.stopTranslation();const t=!this.video.src&&!this.video.currentSrc&&!this.video.srcObject;this.votButton.container.hidden=t,t&&(this.votMenu.container.hidden=t),this.site.selector||(this.container=this.video.parentElement),this.container.contains(this.votButton.container)||this.container.append(this.votButton.container,this.votMenu.container),this.videoData=await this.getVideoData(),this.subtitlesListVideoId!==this.videoData.videoId&&(this.subtitlesList=[],this.subtitlesListVideoId=null,await this.updateSubtitlesLangSelect()),this.translateToLang=this.data.responseLanguage??"ru",this.setSelectMenuValues(this.videoData.detectedLanguage,this.videoData.responseLanguage)}async release(){Pe.log("[VideoHandler] release"),this.initialized=!1,this.releaseExtraEvents(),this.subtitlesWidget.release(),this.votButton.container.remove(),this.votMenu.container.remove()}}const Fi=new Ai,Ui=new WeakMap;function qi(t,e){if(!t||!e)return null;if(t instanceof Document)return t.querySelector(e);const i=t.closest(e);if(i)return i;const o=t.getRootNode();return qi(o instanceof Document?o:o.host,e)}function zi(t,e){if(Pe.log("findContainer",t,e),t.shadowRoot){let i=qi(e,t.selector);return Pe.log("findContainer with site.shadowRoot",i),i??e.parentElement}Pe.log("findContainer without shadowRoot");const i=Bi.browser.version?.split(".")?.[0];if(t.selector?.includes(":not")&&t.selector?.includes("*")&&i&&("Chrome"===Bi.browser.name&&Number(i)<88||"Firefox"===Bi.browser.name&&Number(i)<84)){const i=t.selector.split(" *")[0];return i?Array.from(document.querySelectorAll(i)).find((t=>t.contains(e))):e.parentElement}return t.selector?Array.from(document.querySelectorAll(t.selector)).find((t=>t.contains(e))):e.parentElement}(async function(){Pe.log("Loading extension..."),await Ge.update(),Pe.log(`Selected menu language: ${Ge.lang}`),"https://9animetv.to"!==window.location.origin?"https://dev.epicgames.com"===window.location.origin&&window.location.pathname.includes("/community/learning/")&&window.addEventListener("message",(t=>{if("https://dev.epicgames.com"!==t.origin)return;if("string"!=typeof t.data||!t.data.startsWith("getVideoId:"))return;const e=t.data.replace("getVideoId:",""),i=atob(e),o=/\/(\w{3,5})\/[^/]+$/.exec(window.location.pathname)?.[1],a=document.querySelector(`electra-player > iframe[src="${i}"]`)?.contentWindow;a.postMessage(`${t.data}:${o}`,"https://dev.epicgames.com")})):window.addEventListener("message",(t=>{if("https://rapid-cloud.co"!==t.origin)return;if("getVideoId"!==t.data)return;const e=/[^/]+$/.exec(window.location.href)?.[0],i=document.querySelector("#iframe-embed")?.contentWindow;i.postMessage(`getVideoId:${e}`,"https://rapid-cloud.co")})),Fi.onVideoAdded.addListener((t=>{for(const e of function(){if(ai.exec(window.location.href))return[];const t=window.location.hostname,e=new URL(window.location.href),i=i=>i instanceof RegExp?i.test(t):"string"==typeof i?t.includes(i):"function"==typeof i&&i(e);return ri.filter((t=>(Array.isArray(t.match)?t.match.some(i):i(t.match))&&t.host&&t.url))}()){if(!e)continue;let i=zi(e,t);if(i&&(("rumble"!==e.host||t.style.display)&&(["peertube","directlink"].includes(e.host)&&(e.url=window.location.origin),!Ui.has(t)))){Ui.set(t,new Di(t,i,e));break}}})),Fi.onVideoRemoved.addListener((async t=>{Ui.has(t)&&(await Ui.get(t).release(),Ui.delete(t))})),Fi.enable()})().catch((t=>{console.error("[VOT]",t)}))})()})(); \ No newline at end of file diff --git a/dist/vot.user.js b/dist/vot.user.js index 7d7de3f..38a53d6 100644 --- a/dist/vot.user.js +++ b/dist/vot.user.js @@ -4810,7 +4810,7 @@ const votStorage = new (class { const userlang = navigator.language || navigator.userLanguage; const MAX_SECS_FRACTION = 0.66; -const lang = userlang?.substr(0, 2)?.toLowerCase() ?? "en"; +const lang = userlang?.substring(0, 2).toLowerCase() || "en"; function secsToStrTime(secs) { let minutes = Math.floor(secs / 60); @@ -4861,34 +4861,24 @@ function initHls() { : undefined; } -const deletefilter = [ - /(?:https?|ftp):\/\/\S+/g, - /https?:\/\/\S+|www\.\S+/gm, - /\b\S+\.\S+/gm, - /#[^\s#]+/g, - /Auto-generated by YouTube/g, - /Provided to YouTube by/g, - /Released on/g, - /0x[a-fA-F0-9]{40}/g, - /[13][a-km-zA-HJ-NP-Z1-9]{25,34}/g, - /4[0-9AB][1-9A-HJ-NP-Za-km-z]{93}/g, - /Paypal/g, -]; +const textFilters = (() => { + const patterns = [ + /(?:https?|www|\bhttp\s+)[^\s/]*?(?:\.\s*[a-z]{2,}|\/)[^\s]*/gi, + /#[^\s#]+|Auto-generated\s+by\s+YouTube|Provided\s+to\s+YouTube\s+by|Released\s+on|PayPal?/gi, + /0x[\da-f]{40}|[13][a-km-zA-HJ-NP-Z1-9]{25,34}|4[0-9AB][1-9A-HJ-NP-Za-km-z]{93}/g, + ]; -const combinedRegex = new RegExp( - deletefilter.map((regex) => regex.source).join("|"), -); + return new RegExp(patterns.map((p) => p.source).join("|"), "gi"); +})(); function cleanText(title, description) { - const cleanedDescription = description - ? description - .split("\n") - .filter((line) => !combinedRegex.test(line)) - .join(" ") - : ""; - - const fullText = `${title} ${cleanedDescription}`.slice(0, 450); - return fullText.replace(/[^\p{L}\s]+|\s+/gu, " ").trim(); + return (title + " " + (description || "")) + .replace(textFilters, "") + .replace(/(?:[\s\u200B]+|\.{2,})/g, " ") + .replace(/[^\p{L}\s]/gu, "") + .replace(/\s+/g, " ") + .substring(0, 450) + .trim(); } /** * Download binary file with entered filename @@ -9196,21 +9186,11 @@ class SubtitlesProcessor { }; } - static async fetchWithTimeout(url, timeout = 5000) { - try { - const response = await GM_fetch(url, { timeout }); - return response; - } catch (error) { - console.error("[VOT] Fetch failed:", error); - throw error; - } - } - static async fetchSubtitles(subtitlesObject) { const { source, isAutoGenerated, format, url } = subtitlesObject; try { - const response = await this.fetchWithTimeout(url); + const response = await GM_fetch(url, { timeout: 7000 }); let subtitles; if (["vtt", "srt"].includes(format)) { @@ -10836,7 +10816,7 @@ class VideoHandler { */ audioPlayer; - videoTranslations = []; // list of video translations + videoTranslations = new Map(); // map of video translations videoTranslationTTL = 7200; // 2 hours cachedTranslation; // cached video translation @@ -10943,11 +10923,6 @@ class VideoHandler { } return new Promise((resolve) => { - const timeoutDuration = this.subtitlesList.some( - (item) => item.source === "yandex", - ) - ? 20_000 - : 30_000; this.autoRetry = setTimeout(async () => { const res = await this.translateVideoImpl( videoData, @@ -10958,7 +10933,7 @@ class VideoHandler { if (!res || (res.translated && res.remainingTime < 1)) { resolve(res); } - }, timeoutDuration); + }, 20_000); }); } @@ -11728,7 +11703,7 @@ class VideoHandler { this.data.translateProxyEnabled, ); this.initVOTClient(); - this.videoTranslations = []; + this.videoTranslations.clear(); }, labelElement: UI.createVOTSelectLabel( localizationProvider.get("VOTTranslateProxyStatus"), @@ -12039,46 +12014,55 @@ class VideoHandler { // VOT Menu { this.votDownloadButton.addEventListener("click", async () => { - if (!this.downloadTranslationUrl) { - return; - } + if (!this.downloadTranslationUrl) return; - if (!this.data.downloadWithName) { - return window.open(this.downloadTranslationUrl, "_blank").focus(); - } + try { + if (!this.data.downloadWithName) { + window.open(this.downloadTranslationUrl, "_blank").focus(); + return; + } - const votLoader = document.querySelector("#vot-loader-download"); - const primaryColor = getComputedStyle( - this.votMenu.container, - ).getPropertyValue("--vot-primary-rgb"); - const updateAnimation = UI.animateLoader(votLoader, primaryColor); + this.votLoader = document.querySelector("#vot-loader-download"); + const primaryColor = getComputedStyle( + this.votMenu.container, + ).getPropertyValue("--vot-primary-rgb"); + const updateAnimation = UI.animateLoader( + this.votLoader, + primaryColor, + ); - const res = await GM_fetch(this.downloadTranslationUrl); - const reader = res.body.getReader(); - const contentLength = +res.headers.get("Content-Length"); + const res = await GM_fetch(this.downloadTranslationUrl); - let receivedLength = 0; - const chunks = []; - while (true) { - const { done, value } = await reader.read(); + if (!res.ok) throw new Error(`HTTP ${res.status}`); - if (done) { - break; - } + const contentLength = +res.headers.get("Content-Length"); + const reader = res.body.getReader(); + const chunksBuffer = new Uint8Array(contentLength); + let offset = 0; - chunks.push(value); - receivedLength += value.length; - updateAnimation(Math.round((receivedLength / contentLength) * 100)); - } + while (true) { + const { done, value } = await reader.read(); + if (done) break; - UI.afterAnimateLoader(votLoader, primaryColor); - const blob = new Blob(chunks); - const filename = clearFileName(this.videoData.downloadTitle); - const arrayBuffer = await blob.arrayBuffer(); - const writer = new o(arrayBuffer); - writer.setFrame("TIT2", filename); - writer.addTag(); - downloadBlob(writer.getBlob(), `${filename}.mp3`); + chunksBuffer.set(value, offset); + offset += value.length; + + updateAnimation(Math.round((offset / contentLength) * 100)); + } + UI.afterAnimateLoader(this.votLoader, primaryColor); + const filename = clearFileName(this.videoData.downloadTitle); + const writer = new o(chunksBuffer.buffer); + writer.setFrame("TIT2", filename); + writer.addTag(); + + downloadBlob(writer.getBlob(), `${filename}.mp3`); + } catch (err) { + console.error("Download failed:", err); + this.transformBtn( + "error", + localizationProvider.get("downloadFailed"), + ); + } }); this.votDownloadSubtitlesButton.addEventListener("click", async () => { @@ -13287,24 +13271,24 @@ class VideoHandler { method: "HEAD", }); utils_debug.log("Test audio response", response); - if (response.status !== 404) { + if (response.ok) { utils_debug.log("Valid audioUrl", audioUrl); return audioUrl; + } else { + utils_debug.log("Yandex returned not valid audio, trying to fix..."); + let translateRes = await this.translateVideoImpl( + this.videoData, + (this.videoData.detectedLanguage = "auto"), + this.videoData.responseLanguage, + this.videoData.translationHelp, + ); + this.setSelectMenuValues( + this.videoData.detectedLanguage, + this.videoData.responseLanguage, + ); + audioUrl = translateRes.url; + utils_debug.log("Fixed audio audioUrl", audioUrl); } - - utils_debug.log("Yandex returned not valid audio, trying to fix..."); - let translateRes = await this.translateVideoImpl( - this.videoData, - (this.videoData.detectedLanguage = "auto"), - this.videoData.responseLanguage, - this.videoData.translationHelp, - ); - this.setSelectMenuValues( - this.videoData.detectedLanguage, - this.videoData.responseLanguage, - ); - audioUrl = translateRes.url; - utils_debug.log("Fixed audio audioUrl", audioUrl); } catch (err) { utils_debug.log("Test audio error:", err); } @@ -13409,16 +13393,14 @@ class VideoHandler { return this.afterUpdateTranslation(streamURL); } - this.cachedTranslation = this.videoTranslations.find( - (t) => - t.videoId === VIDEO_ID && - t.expires > utils_getTimestamp() && - t.from === requestLang && - t.to === responseLang && - t.useNewModel === this.data.useNewModel, - ); + const cacheKey = `${VIDEO_ID}_${requestLang}_${responseLang}_${this.data.useNewModel}`; + this.cachedTranslation = this.videoTranslations.get(cacheKey); - if (this.cachedTranslation) { + const currentTimestamp = utils_getTimestamp(); + if ( + this.cachedTranslation && + this.cachedTranslation.expires > currentTimestamp + ) { await this.updateTranslation(this.cachedTranslation.url); utils_debug.log("[translateFunc] Cached translation was received"); return; @@ -13447,19 +13429,16 @@ class VideoHandler { item.language === this.videoData.responseLanguage, ) ) { - this.subtitlesList = await SubtitlesProcessor.getSubtitles( - this.votClient, - this.videoData, - ); + await this.loadSubtitles(); await this.updateSubtitlesLangSelect(); } - this.videoTranslations.push({ + this.videoTranslations.set(cacheKey, { videoId: VIDEO_ID, from: requestLang, to: responseLang, url: this.downloadTranslationUrl, - expires: utils_getTimestamp() + this.videoTranslationTTL, + expires: currentTimestamp + this.videoTranslationTTL, useNewModel: this.data?.useNewModel, }); } diff --git a/src/index.js b/src/index.js index 746450b..66c92b9 100644 --- a/src/index.js +++ b/src/index.js @@ -127,7 +127,7 @@ class VideoHandler { */ audioPlayer; - videoTranslations = []; // list of video translations + videoTranslations = new Map(); // map of video translations videoTranslationTTL = 7200; // 2 hours cachedTranslation; // cached video translation @@ -234,11 +234,6 @@ class VideoHandler { } return new Promise((resolve) => { - const timeoutDuration = this.subtitlesList.some( - (item) => item.source === "yandex", - ) - ? 20_000 - : 30_000; this.autoRetry = setTimeout(async () => { const res = await this.translateVideoImpl( videoData, @@ -249,7 +244,7 @@ class VideoHandler { if (!res || (res.translated && res.remainingTime < 1)) { resolve(res); } - }, timeoutDuration); + }, 20_000); }); } @@ -1019,7 +1014,7 @@ class VideoHandler { this.data.translateProxyEnabled, ); this.initVOTClient(); - this.videoTranslations = []; + this.videoTranslations.clear(); }, labelElement: ui.createVOTSelectLabel( localizationProvider.get("VOTTranslateProxyStatus"), @@ -1330,46 +1325,55 @@ class VideoHandler { // VOT Menu { this.votDownloadButton.addEventListener("click", async () => { - if (!this.downloadTranslationUrl) { - return; - } + if (!this.downloadTranslationUrl) return; - if (!this.data.downloadWithName) { - return window.open(this.downloadTranslationUrl, "_blank").focus(); - } + try { + if (!this.data.downloadWithName) { + window.open(this.downloadTranslationUrl, "_blank").focus(); + return; + } - const votLoader = document.querySelector("#vot-loader-download"); - const primaryColor = getComputedStyle( - this.votMenu.container, - ).getPropertyValue("--vot-primary-rgb"); - const updateAnimation = ui.animateLoader(votLoader, primaryColor); + this.votLoader = document.querySelector("#vot-loader-download"); + const primaryColor = getComputedStyle( + this.votMenu.container, + ).getPropertyValue("--vot-primary-rgb"); + const updateAnimation = ui.animateLoader( + this.votLoader, + primaryColor, + ); - const res = await GM_fetch(this.downloadTranslationUrl); - const reader = res.body.getReader(); - const contentLength = +res.headers.get("Content-Length"); + const res = await GM_fetch(this.downloadTranslationUrl); - let receivedLength = 0; - const chunks = []; - while (true) { - const { done, value } = await reader.read(); + if (!res.ok) throw new Error(`HTTP ${res.status}`); - if (done) { - break; - } + const contentLength = +res.headers.get("Content-Length"); + const reader = res.body.getReader(); + const chunksBuffer = new Uint8Array(contentLength); + let offset = 0; - chunks.push(value); - receivedLength += value.length; - updateAnimation(Math.round((receivedLength / contentLength) * 100)); - } + while (true) { + const { done, value } = await reader.read(); + if (done) break; - ui.afterAnimateLoader(votLoader, primaryColor); - const blob = new Blob(chunks); - const filename = clearFileName(this.videoData.downloadTitle); - const arrayBuffer = await blob.arrayBuffer(); - const writer = new ID3Writer(arrayBuffer); - writer.setFrame("TIT2", filename); - writer.addTag(); - downloadBlob(writer.getBlob(), `${filename}.mp3`); + chunksBuffer.set(value, offset); + offset += value.length; + + updateAnimation(Math.round((offset / contentLength) * 100)); + } + ui.afterAnimateLoader(this.votLoader, primaryColor); + const filename = clearFileName(this.videoData.downloadTitle); + const writer = new ID3Writer(chunksBuffer.buffer); + writer.setFrame("TIT2", filename); + writer.addTag(); + + downloadBlob(writer.getBlob(), `${filename}.mp3`); + } catch (err) { + console.error("Download failed:", err); + this.transformBtn( + "error", + localizationProvider.get("downloadFailed"), + ); + } }); this.votDownloadSubtitlesButton.addEventListener("click", async () => { @@ -2578,24 +2582,24 @@ class VideoHandler { method: "HEAD", }); debug.log("Test audio response", response); - if (response.status !== 404) { + if (response.ok) { debug.log("Valid audioUrl", audioUrl); return audioUrl; + } else { + debug.log("Yandex returned not valid audio, trying to fix..."); + let translateRes = await this.translateVideoImpl( + this.videoData, + (this.videoData.detectedLanguage = "auto"), + this.videoData.responseLanguage, + this.videoData.translationHelp, + ); + this.setSelectMenuValues( + this.videoData.detectedLanguage, + this.videoData.responseLanguage, + ); + audioUrl = translateRes.url; + debug.log("Fixed audio audioUrl", audioUrl); } - - debug.log("Yandex returned not valid audio, trying to fix..."); - let translateRes = await this.translateVideoImpl( - this.videoData, - (this.videoData.detectedLanguage = "auto"), - this.videoData.responseLanguage, - this.videoData.translationHelp, - ); - this.setSelectMenuValues( - this.videoData.detectedLanguage, - this.videoData.responseLanguage, - ); - audioUrl = translateRes.url; - debug.log("Fixed audio audioUrl", audioUrl); } catch (err) { debug.log("Test audio error:", err); } @@ -2700,16 +2704,14 @@ class VideoHandler { return this.afterUpdateTranslation(streamURL); } - this.cachedTranslation = this.videoTranslations.find( - (t) => - t.videoId === VIDEO_ID && - t.expires > getTimestamp() && - t.from === requestLang && - t.to === responseLang && - t.useNewModel === this.data.useNewModel, - ); + const cacheKey = `${VIDEO_ID}_${requestLang}_${responseLang}_${this.data.useNewModel}`; + this.cachedTranslation = this.videoTranslations.get(cacheKey); - if (this.cachedTranslation) { + const currentTimestamp = getTimestamp(); + if ( + this.cachedTranslation && + this.cachedTranslation.expires > currentTimestamp + ) { await this.updateTranslation(this.cachedTranslation.url); debug.log("[translateFunc] Cached translation was received"); return; @@ -2738,19 +2740,16 @@ class VideoHandler { item.language === this.videoData.responseLanguage, ) ) { - this.subtitlesList = await SubtitlesProcessor.getSubtitles( - this.votClient, - this.videoData, - ); + await this.loadSubtitles(); await this.updateSubtitlesLangSelect(); } - this.videoTranslations.push({ + this.videoTranslations.set(cacheKey, { videoId: VIDEO_ID, from: requestLang, to: responseLang, url: this.downloadTranslationUrl, - expires: getTimestamp() + this.videoTranslationTTL, + expires: currentTimestamp + this.videoTranslationTTL, useNewModel: this.data?.useNewModel, }); } diff --git a/src/subtitles.js b/src/subtitles.js index 0268f6a..4732c92 100644 --- a/src/subtitles.js +++ b/src/subtitles.js @@ -163,21 +163,11 @@ export class SubtitlesProcessor { }; } - static async fetchWithTimeout(url, timeout = 5000) { - try { - const response = await GM_fetch(url, { timeout }); - return response; - } catch (error) { - console.error("[VOT] Fetch failed:", error); - throw error; - } - } - static async fetchSubtitles(subtitlesObject) { const { source, isAutoGenerated, format, url } = subtitlesObject; try { - const response = await this.fetchWithTimeout(url); + const response = await GM_fetch(url, { timeout: 7000 }); let subtitles; if (["vtt", "srt"].includes(format)) { diff --git a/src/utils/utils.js b/src/utils/utils.js index a3723c5..30ad366 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -3,7 +3,7 @@ import debug from "./debug.ts"; const userlang = navigator.language || navigator.userLanguage; const MAX_SECS_FRACTION = 0.66; -export const lang = userlang?.substr(0, 2)?.toLowerCase() ?? "en"; +export const lang = userlang?.substring(0, 2).toLowerCase() || "en"; function secsToStrTime(secs) { let minutes = Math.floor(secs / 60); @@ -54,34 +54,24 @@ function initHls() { : undefined; } -const deletefilter = [ - /(?:https?|ftp):\/\/\S+/g, - /https?:\/\/\S+|www\.\S+/gm, - /\b\S+\.\S+/gm, - /#[^\s#]+/g, - /Auto-generated by YouTube/g, - /Provided to YouTube by/g, - /Released on/g, - /0x[a-fA-F0-9]{40}/g, - /[13][a-km-zA-HJ-NP-Z1-9]{25,34}/g, - /4[0-9AB][1-9A-HJ-NP-Za-km-z]{93}/g, - /Paypal/g, -]; - -const combinedRegex = new RegExp( - deletefilter.map((regex) => regex.source).join("|"), -); +const textFilters = (() => { + const patterns = [ + /(?:https?|www|\bhttp\s+)[^\s/]*?(?:\.\s*[a-z]{2,}|\/)[^\s]*/gi, + /#[^\s#]+|Auto-generated\s+by\s+YouTube|Provided\s+to\s+YouTube\s+by|Released\s+on|PayPal?/gi, + /0x[\da-f]{40}|[13][a-km-zA-HJ-NP-Z1-9]{25,34}|4[0-9AB][1-9A-HJ-NP-Za-km-z]{93}/g, + ]; + + return new RegExp(patterns.map((p) => p.source).join("|"), "gi"); +})(); function cleanText(title, description) { - const cleanedDescription = description - ? description - .split("\n") - .filter((line) => !combinedRegex.test(line)) - .join(" ") - : ""; - - const fullText = `${title} ${cleanedDescription}`.slice(0, 450); - return fullText.replace(/[^\p{L}\s]+|\s+/gu, " ").trim(); + return (title + " " + (description || "")) + .replace(textFilters, "") + .replace(/(?:[\s\u200B]+|\.{2,})/g, " ") + .replace(/[^\p{L}\s]/gu, "") + .replace(/\s+/g, " ") + .substring(0, 450) + .trim(); } /** * Download binary file with entered filename From d6b763aaaf6c516c8fcaf4fa1e153298739fd781 Mon Sep 17 00:00:00 2001 From: Toil <62353659+ilyhalight@users.noreply.github.com> Date: Mon, 27 Jan 2025 01:58:36 +0300 Subject: [PATCH 2/2] style: fix styling --- src/index.js | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/src/index.js b/src/index.js index 66c92b9..e8ff969 100644 --- a/src/index.js +++ b/src/index.js @@ -1325,7 +1325,9 @@ class VideoHandler { // VOT Menu { this.votDownloadButton.addEventListener("click", async () => { - if (!this.downloadTranslationUrl) return; + if (!this.downloadTranslationUrl) { + return; + } try { if (!this.data.downloadWithName) { @@ -1333,7 +1335,9 @@ class VideoHandler { return; } - this.votLoader = document.querySelector("#vot-loader-download"); + this.votLoader = this.votDownloadButton.querySelector( + "#vot-loader-download", + ); const primaryColor = getComputedStyle( this.votMenu.container, ).getPropertyValue("--vot-primary-rgb"); @@ -1343,8 +1347,9 @@ class VideoHandler { ); const res = await GM_fetch(this.downloadTranslationUrl); - - if (!res.ok) throw new Error(`HTTP ${res.status}`); + if (!res.ok) { + throw new Error(`HTTP ${res.status}`); + } const contentLength = +res.headers.get("Content-Length"); const reader = res.body.getReader(); @@ -1353,7 +1358,9 @@ class VideoHandler { while (true) { const { done, value } = await reader.read(); - if (done) break; + if (done) { + break; + } chunksBuffer.set(value, offset); offset += value.length; @@ -2585,21 +2592,21 @@ class VideoHandler { if (response.ok) { debug.log("Valid audioUrl", audioUrl); return audioUrl; - } else { - debug.log("Yandex returned not valid audio, trying to fix..."); - let translateRes = await this.translateVideoImpl( - this.videoData, - (this.videoData.detectedLanguage = "auto"), - this.videoData.responseLanguage, - this.videoData.translationHelp, - ); - this.setSelectMenuValues( - this.videoData.detectedLanguage, - this.videoData.responseLanguage, - ); - audioUrl = translateRes.url; - debug.log("Fixed audio audioUrl", audioUrl); } + + debug.log("Yandex returned not valid audio, trying to fix..."); + let translateRes = await this.translateVideoImpl( + this.videoData, + (this.videoData.detectedLanguage = "auto"), + this.videoData.responseLanguage, + this.videoData.translationHelp, + ); + this.setSelectMenuValues( + this.videoData.detectedLanguage, + this.videoData.responseLanguage, + ); + audioUrl = translateRes.url; + debug.log("Fixed audio audioUrl", audioUrl); } catch (err) { debug.log("Test audio error:", err); }