import React from "react";
import { createRoot } from "react-dom/client";
import { Provider } from "react-redux";

import store from "./store";
import MusicPlayer from "./features/musicplayer/MusicPlayer";
import { setSource } from "./features/musicplayer/musicPlayerSlice";
import mseq from "./assets/Mseq_-_Journey.mp3";

const rootElement = document.getElementById("playerUI");

if (rootElement === null) {
    throw Error("DOM seems to have failed to load. Something went very wrong.");
}

const root = createRoot(rootElement);
root.render(
    <Provider store={store}>
        <MusicPlayer />
    </Provider>
);

store.dispatch(
    setSource({
        source: mseq,
        artist: "Mseq",
        name: "Journey",
        album: "Unknown album",
        length: 192052244,
    })
);
