const urlParams=new URLSearchParams(window.location.search),src=decodeURIComponent(urlParams.get("src")),srcParams=new URLSearchParams(src),query=srcParams.get("query"),lang=srcParams.get("lang"),dialect=srcParams.get("dialect"),ui=srcParams.get("ui"),autoplay=srcParams.get("autoplay"),scenario=srcParams.get("scenario");let widget;function onYouglishAPIReady(){widget=new YG.Widget("widget-1",{width:3500,components:8312,autoStart:+autoplay,events:{onFetchDone,onVideoChange,onCaptionConsumed,onError(e){console.warn("error",e)}}}),YG.setParnterKey("lumetrium"),widget.fetch(query,lang,dialect)}let views=0,curTrack=0,totalTracks=0;function onFetchDone(e){e.totalResult>0&&(totalTracks=e.totalResult)}function onVideoChange(e){curTrack=e.trackNumber,views=0}function onCaptionConsumed(e){"triple-repeat-next"===scenario&&(++views<3?widget.replay():curTrack<totalTracks&&widget.next())}window.addEventListener("message",(e=>{if("setCssVariables"===e.data.type){const t=e.data.value||{};Object.entries(t).forEach((([e,t])=>document.documentElement.style.setProperty(e,t)))}}));