(function () {

    let engyjClientID = window.egyjClientID;

    const appendScript = (url, target = 'head', onload = null) => {
        var script = document.createElement("SCRIPT");
        script.src = url;
        script.type = 'text/javascript';
        script.onload = onload;
        document.getElementsByTagName(target)[0].appendChild(script);
    }

    const appendStyle = (url) => {
        var style = document.createElement("LINK");
        style.href = url;
        style.rel = 'stylesheet'; 
        document.getElementsByTagName("head")[0].appendChild(style);
    }
    
    // const engyjify = () => {
        // $(document).ready(function(){
         window.addEventListener('load', function(){
            
            let body = document.getElementsByTagName('body')[0]
            let engyjWidget =  document.createElement('div');
            body.appendChild(engyjWidget);
            engyjWidget.id = 'engyjChatWidgetRoot'

            // $('body').append($('<div />').attr('id','engyjChatWidgetRoot'));
            appendScript( 'http://ada.engyj.com/0.1/static/main.js', 'body', function () { });  

                        appendStyle( 'http://ada.engyj.com/0.1/static/css/main.d8acd0d4.chunk.css'); 
            
                        appendScript( 'http://ada.engyj.com/0.1/static/js/2.1252b13e.chunk.js', 'body', function () { }); 
                        appendScript( 'http://ada.engyj.com/0.1/static/js/main.bfc3d810.chunk.js', 'body', function () { }); 
             

        });
    // }

    // if (typeof window.jQuery === 'undefined') {
    //     appendScript( 'https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js', 'head', function () { 
    //         engyjify(window.jQuery);
    //     }); 
    // }
})();