import{c as u}from"./chunk-BTWOJWRN.js";import{a as P}from"./chunk-FKJPRJ46.js";import{a as g}from"./chunk-ETIPD2TL.js";import{Bb as E,Dd as _,Ed as v,Ga as p,Ic as b,Na as n,Oa as y,Qb as s,Rc as h,Uc as O,cd as T,e as i,yb as S,zb as l}from"./chunk-RISKGE32.js";import{ca as f,ja as a}from"./chunk-6O6MLDWR.js";import{g as m,i as c,n as d}from"./chunk-CLPINNGF.js";d();m();var L=f(()=>({}));async function R(e){L.setState(e)}var re=async()=>{let e=await i("/keyboard-shortcuts/get-command-list");R(e)};async function ie(e){if(b()){A(e);return}let t=(await i("/auth/get-user"))?.user;if(!T(t)){a("toggle-force-login");return}if(e==="play-pause"||e==="play-pause-new")return C();if(e==="save-to-library")return M();if(e==="open-screenshot-mode")return k();throw new Error("Unsupported keyboard command provided")}function A(e){let t={"play-pause":{key:"q",altKey:!0},"play-pause-new":{key:"a",altKey:!0},"save-to-library":{key:"s",altKey:!0},"open-screenshot-mode":{key:"r",altKey:!0}}[e];if(!t)return;let r=new KeyboardEvent("keydown",{key:t.key,code:`Key${t.key.toUpperCase()}`,altKey:t.altKey,bubbles:!0,cancelable:!0});document.dispatchEvent(r)}async function C(){if(v().current?.id!=="player-error"){if(p(y.getPlayingState()))return u(),n.pause();s.toggleFeatureOnDomain("pill-player",!0),await n.play(),a("hide-shortcut-prompt",{},"shortcuts-prompt"),O({triggeredFrom:"Shortcut"}),u()}}async function M(){let e=await E();if(["saving","saved"].includes(e))return;let o=await l();if(!o)return;let t=await S(window.location.href);_({id:"saved-to-library",timeSensitive:!1,priority:100,duration:1e4,showOnMobile:!1,render:({dismiss:r})=>c(g,{id:"saved-to-library",savedInfo:t,removeNotification:r})}),h({timeBeforeSave:o.timeBeforeSave,triggeredFrom:"Shortcut"})}async function k(){s.toggleFeatureOnDomain("pill-player",!0),P("shortcut")}var ae=()=>{};export{L as a,R as b,re as c,ie as d,C as e,M as f,k as g,ae as h};
//# sourceMappingURL=chunk-VUIW4JA2.js.map
