contributors license let darkmode = false ; return { boolean } const darkModeToggle = ( ) : boolean => { if ( document . querySelector ( "html" ) . classList . contains ( "darkmode" ) ) { darkmode = false ; } else { darkmode = true ; } document . querySelector ( "html" ) . classList . toggle ( "darkmode" ) ; document . querySelector ( "body" ) . classList . toggle ( "darkmode" ) ; window . localStorage . setItem ( "darkmode" , darkmode ? "enabled" : "disabled" ) ; return darkmode ; } ; return { boolean } const darkModeDetect = ( ) : boolean => { if ( window . localStorage . getItem ( "darkmode" ) === "enabled" || ( window . localStorage . getItem ( "darkmode" ) === undefined && window ?. matchMedia ( "(prefers-color-scheme: dark)" ) . matches ) ) { if ( ! document . querySelector ( "html" ) . classList . contains ( "darkmode" ) ) { document . querySelector ( "html" ) . classList . add ( "darkmode" ) ; document . querySelector ( "body" ) . classList . add ( "darkmode" ) ; } return true ; } return false ; } ; export { darkModeToggle , darkModeDetect , darkmode } ;