import {Calendar, DatePicker} from 'v-calendar';
import components from './components'

const App = {
    el: '#app',
    delimiters: ['[[', ']]'],
    components: {
        ...components,
        ...{
            VCalendar: Calendar,
            VDatepicker: DatePicker
        },
    },

    computed: {
        player() { return window.aircox.player; },
    },

    methods: {
        //! Delete elements from DOM using provided selector.
        deleteElements(sel) {
            for(var el of document.querySelectorAll(sel))
                el.parentNode.removeChild(el)
        },

        //! File has been selected
        //! TODO: replace using regular ref and bindings.
        fileSelected(select, input, preview) {
            const item = this.$refs[select].item
            if(item) {
                this.$refs[input].value = item.id
                if(preview)
                    preview.src = item.file
            }
        },
    }
}

export const PlayerApp = {
    el: '#player',
    delimiters: ['[[', ']]'],
    components: {...components},
}

export default App
