import FormsModule from './editor/module';

// const Cool_FormKitForms = new FormsModule();

// window.Cool_FormKitForms = Cool_FormKitForms;

class CoolFormKitApp {
	constructor() {
		this.modules = {};
		this.ajax = {
            prepareArgs(args) {
                args[0] = 'cool_' + args[0]; 
                return args;
            },
            send() {
                return elementorCommon.ajax.send.apply(elementorCommon.ajax, this.prepareArgs(arguments));
            },
            addRequest() {
                return elementorCommon.ajax.addRequest.apply(elementorCommon.ajax, this.prepareArgs(arguments));
            }
        };
	}

	start() {
		jQuery(window).on('elementor:init', () => this.onElementorInit());
	}

	onElementorInit() {
		this.modules.forms = new FormsModule();
		this.modules.forms.onElementorInit(); 
	}
}

window.CoolFormKit = new CoolFormKitApp();
window.CoolFormKit.start();