(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-accounts', 'items': [{'id': 'crud-accounts-widget', component: 'crud', data: {'id': 'crud-accounts'}}]}"></grid>
</app>`;

    Vue.component('module-accounts', config);
    window.Kiwi.components.registerCustom('module-accounts', 'module-accounts');

        window.Kiwi.navigation.push({path: '/accounts', label: 'modules.accounts'});
    window.Kiwi.router.addRoutes([{path: '/accounts', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-contacts', 'items': [{'id': 'crud-contacts-widget', component: 'crud', data: {'id': 'crud-contacts'}}]}"></grid>
</app>`;

    Vue.component('module-contacts', config);
    window.Kiwi.components.registerCustom('module-contacts', 'module-contacts');

        window.Kiwi.navigation.push({path: '/contacts', label: 'modules.contacts'});
    window.Kiwi.router.addRoutes([{path: '/contacts', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-emails', 'items': [{'id': 'crud-emails-widget', component: 'crud', data: {'id': 'crud-emails'}}]}"></grid>
</app>`;

    Vue.component('module-emails', config);
    window.Kiwi.components.registerCustom('module-emails', 'module-emails');

        window.Kiwi.navigation.push({path: '/emails', label: 'modules.emails'});
    window.Kiwi.router.addRoutes([{path: '/emails', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-projects', 'items': [{'id': 'crud-projects-widget', component: 'crud', data: {'id': 'crud-projects'}}]}"></grid>
</app>`;

    Vue.component('module-projects', config);
    window.Kiwi.components.registerCustom('module-projects', 'module-projects');

        window.Kiwi.navigation.push({path: '/projects', label: 'modules.projects'});
    window.Kiwi.router.addRoutes([{path: '/projects', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {
    data() {
        return {
            config: null
        }
    },
    mounted() {
        Kiwi.request().post('/api/db/central-quote-form-config').then(response => {
            this.config = JSON.parse(response.data.default[0].config)
        })
    }
};
    config.template = `<div style="old-background:#fff;padding:.5rem">
	<kiwi-form v-if="config" no-config :override="config" />
</div>`;

    Vue.component('central-quote-form', config);
    window.Kiwi.components.registerCustom('central-quote-form', 'central-quote-form');

        window.Kiwi.navigation.push({path: '/central-quote-form', label: 'Ajánlatkérés form'});
    window.Kiwi.router.addRoutes([{path: '/central-quote-form', component: config, meta: { auth: 0 }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-resources-locations', 'items': [{'id': 'crud-resources-locations-widget', component: 'crud', data: {'id': 'crud-resources-locations'}}]}"></grid>
</app>`;

    Vue.component('module-resources-locations', config);
    window.Kiwi.components.registerCustom('module-resources-locations', 'module-resources-locations');

        window.Kiwi.navigation.push({path: '/resources-locations', label: 'modules.resources_locations'});
    window.Kiwi.router.addRoutes([{path: '/resources-locations', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-invoices', 'items': [{'id': 'crud-sys-invoices-widget', component: 'crud', data: {'id': 'crud-sys-invoices'}}]}"></grid>
</app>`;

    Vue.component('module-sys-invoices', config);
    window.Kiwi.components.registerCustom('module-sys-invoices', 'module-sys-invoices');

        window.Kiwi.navigation.push({path: '/sys-invoices', label: 'modules.sys_invoices'});
    window.Kiwi.router.addRoutes([{path: '/sys-invoices', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-invoices-items', 'items': [{'id': 'crud-sys-invoices-items-widget', component: 'crud', data: {'id': 'crud-sys-invoices-items'}}]}"></grid>
</app>`;

    Vue.component('module-sys-invoices-items', config);
    window.Kiwi.components.registerCustom('module-sys-invoices-items', 'module-sys-invoices-items');

        window.Kiwi.navigation.push({path: '/sys-invoices-items', label: 'modules.sys_invoices_items'});
    window.Kiwi.router.addRoutes([{path: '/sys-invoices-items', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-owners', 'items': [{'id': 'crud-sys-owners-widget', component: 'crud', data: {'id': 'crud-sys-owners'}}]}"></grid>
</app>`;

    Vue.component('module-sys-owners', config);
    window.Kiwi.components.registerCustom('module-sys-owners', 'module-sys-owners');

        window.Kiwi.navigation.push({path: '/sys-owners', label: 'modules.sys_owners'});
    window.Kiwi.router.addRoutes([{path: '/sys-owners', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-owners-module-options', 'items': [{'id': 'crud-sys-owners-module-options-widget', component: 'crud', data: {'id': 'crud-sys-owners-module-options'}}]}"></grid>
</app>`;

    Vue.component('module-sys-owners-module-options', config);
    window.Kiwi.components.registerCustom('module-sys-owners-module-options', 'module-sys-owners-module-options');

        window.Kiwi.navigation.push({path: '/sys-owners-module-options', label: 'modules.sys_owners_module_options'});
    window.Kiwi.router.addRoutes([{path: '/sys-owners-module-options', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-package-manager', 'items': [{'id': 'crud-sys-package-manager-widget', component: 'crud', data: {'id': 'crud-sys-package-manager'}}]}"></grid>
</app>`;

    Vue.component('module-sys-package-manager', config);
    window.Kiwi.components.registerCustom('module-sys-package-manager', 'module-sys-package-manager');

        window.Kiwi.navigation.push({path: '/sys-package-manager', label: 'modules.sys_package_manager'});
    window.Kiwi.router.addRoutes([{path: '/sys-package-manager', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-replication', 'items': [{'id': 'crud-sys-replication-widget', component: 'crud', data: {'id': 'crud-sys-replication'}}]}"></grid>
</app>`;

    Vue.component('module-sys-replication', config);
    window.Kiwi.components.registerCustom('module-sys-replication', 'module-sys-replication');

        window.Kiwi.navigation.push({path: '/sys-replication', label: 'modules.sys_replication'});
    window.Kiwi.router.addRoutes([{path: '/sys-replication', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-report-custom-template', 'items': [{'id': 'crud-sys-report-custom-template-widget', component: 'crud', data: {'id': 'crud-sys-report-custom-template'}}]}"></grid>
</app>`;

    Vue.component('module-sys-report-custom-template', config);
    window.Kiwi.components.registerCustom('module-sys-report-custom-template', 'module-sys-report-custom-template');

        window.Kiwi.navigation.push({path: '/sys-report-custom-template', label: 'modules.sys_report_custom_template'});
    window.Kiwi.router.addRoutes([{path: '/sys-report-custom-template', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-report-frame', 'items': [{'id': 'crud-sys-report-frame-widget', component: 'crud', data: {'id': 'crud-sys-report-frame'}}]}"></grid>
</app>`;

    Vue.component('module-sys-report-frame', config);
    window.Kiwi.components.registerCustom('module-sys-report-frame', 'module-sys-report-frame');

        window.Kiwi.navigation.push({path: '/sys-report-frame', label: 'modules.sys_report_frame'});
    window.Kiwi.router.addRoutes([{path: '/sys-report-frame', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-reports', 'items': [{'id': 'crud-sys-reports-widget', component: 'crud', data: {'id': 'crud-sys-reports'}}]}"></grid>
</app>`;

    Vue.component('module-sys-reports', config);
    window.Kiwi.components.registerCustom('module-sys-reports', 'module-sys-reports');

        window.Kiwi.navigation.push({path: '/sys-reports', label: 'modules.sys_reports'});
    window.Kiwi.router.addRoutes([{path: '/sys-reports', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-report-scheduler', 'items': [{'id': 'crud-sys-report-scheduler-widget', component: 'crud', data: {'id': 'crud-sys-report-scheduler'}}]}"></grid>
</app>`;

    Vue.component('module-sys-report-scheduler', config);
    window.Kiwi.components.registerCustom('module-sys-report-scheduler', 'module-sys-report-scheduler');

        window.Kiwi.navigation.push({path: '/sys-report-scheduler', label: 'modules.sys_report_scheduler'});
    window.Kiwi.router.addRoutes([{path: '/sys-report-scheduler', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-report-sql', 'items': [{'id': 'crud-sys-report-sql-widget', component: 'crud', data: {'id': 'crud-sys-report-sql'}}]}"></grid>
</app>`;

    Vue.component('module-sys-report-sql', config);
    window.Kiwi.components.registerCustom('module-sys-report-sql', 'module-sys-report-sql');

        window.Kiwi.navigation.push({path: '/sys-report-sql', label: 'modules.sys_report_sql'});
    window.Kiwi.router.addRoutes([{path: '/sys-report-sql', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-report-trigger', 'items': [{'id': 'crud-sys-report-trigger-widget', component: 'crud', data: {'id': 'crud-sys-report-trigger'}}]}"></grid>
</app>`;

    Vue.component('module-sys-report-trigger', config);
    window.Kiwi.components.registerCustom('module-sys-report-trigger', 'module-sys-report-trigger');

        window.Kiwi.navigation.push({path: '/sys-report-trigger', label: 'modules.sys_report_trigger'});
    window.Kiwi.router.addRoutes([{path: '/sys-report-trigger', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-tasks-sql-worker', 'items': [{'id': 'crud-sys-tasks-sql-worker-widget', component: 'crud', data: {'id': 'crud-sys-tasks-sql-worker'}}]}"></grid>
</app>`;

    Vue.component('module-sys-tasks-sql-worker', config);
    window.Kiwi.components.registerCustom('module-sys-tasks-sql-worker', 'module-sys-tasks-sql-worker');

        window.Kiwi.navigation.push({path: '/sys-tasks-sql-worker', label: 'modules.sys_tasks_sql_worker'});
    window.Kiwi.router.addRoutes([{path: '/sys-tasks-sql-worker', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-users', 'items': [{'id': 'crud-sys-users-widget', component: 'crud', data: {'id': 'crud-sys-users'}}]}"></grid>
</app>`;

    Vue.component('module-sys-users', config);
    window.Kiwi.components.registerCustom('module-sys-users', 'module-sys-users');

        window.Kiwi.navigation.push({path: '/sys-users', label: 'modules.sys_users'});
    window.Kiwi.router.addRoutes([{path: '/sys-users', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-werbforms', 'items': [{'id': 'crud-sys-werbforms-widget', component: 'crud', data: {'id': 'crud-sys-werbforms'}}]}"></grid>
</app>`;

    Vue.component('module-sys-werbforms', config);
    window.Kiwi.components.registerCustom('module-sys-werbforms', 'module-sys-werbforms');

        window.Kiwi.navigation.push({path: '/sys-werbforms', label: 'modules.sys_werbforms'});
    window.Kiwi.router.addRoutes([{path: '/sys-werbforms', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-wizards', 'items': [{'id': 'crud-sys-wizards-widget', component: 'crud', data: {'id': 'crud-sys-wizards'}}]}"></grid>
</app>`;

    Vue.component('module-sys-wizards', config);
    window.Kiwi.components.registerCustom('module-sys-wizards', 'module-sys-wizards');

        window.Kiwi.navigation.push({path: '/sys-wizards', label: 'modules.sys_wizards'});
    window.Kiwi.router.addRoutes([{path: '/sys-wizards', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-wizards-items', 'items': [{'id': 'crud-sys-wizards-items-widget', component: 'crud', data: {'id': 'crud-sys-wizards-items'}}]}"></grid>
</app>`;

    Vue.component('module-sys-wizards-items', config);
    window.Kiwi.components.registerCustom('module-sys-wizards-items', 'module-sys-wizards-items');

        window.Kiwi.navigation.push({path: '/sys-wizards-items', label: 'modules.sys_wizards_items'});
    window.Kiwi.router.addRoutes([{path: '/sys-wizards-items', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-trigger-sql-worker', 'items': [{'id': 'crud-sys-trigger-sql-worker-widget', component: 'crud', data: {'id': 'crud-sys-trigger-sql-worker'}}]}"></grid>
</app>`;

    Vue.component('module-sys-trigger-sql-worker', config);
    window.Kiwi.components.registerCustom('module-sys-trigger-sql-worker', 'module-sys-trigger-sql-worker');

        window.Kiwi.navigation.push({path: '/sys-trigger-sql-worker', label: 'modules.sys_trigger_sql_worker'});
    window.Kiwi.router.addRoutes([{path: '/sys-trigger-sql-worker', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-resources-locations-rooms', 'items': [{'id': 'crud-resources-locations-rooms-widget', component: 'crud', data: {'id': 'crud-resources-locations-rooms'}}]}"></grid>
</app>`;

    Vue.component('module-resources-locations-rooms', config);
    window.Kiwi.components.registerCustom('module-resources-locations-rooms', 'module-resources-locations-rooms');

        window.Kiwi.navigation.push({path: '/resources-locations-rooms', label: 'modules.resources_locations_rooms'});
    window.Kiwi.router.addRoutes([{path: '/resources-locations-rooms', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-resources-locations-reservations', 'items': [{'id': 'crud-resources-locations-reservations-widget', component: 'crud', data: {'id': 'crud-resources-locations-reservations'}}]}"></grid>
</app>`;

    Vue.component('module-resources-locations-reservations', config);
    window.Kiwi.components.registerCustom('module-resources-locations-reservations', 'module-resources-locations-reservations');

        window.Kiwi.navigation.push({path: '/resources-locations-reservations', label: 'modules.resources_locations_reservations'});
    window.Kiwi.router.addRoutes([{path: '/resources-locations-reservations', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-resources-locations-reservations-items', 'items': [{'id': 'crud-resources-locations-reservations-items-widget', component: 'crud', data: {'id': 'crud-resources-locations-reservations-items'}}]}"></grid>
</app>`;

    Vue.component('module-resources-locations-reservations-items', config);
    window.Kiwi.components.registerCustom('module-resources-locations-reservations-items', 'module-resources-locations-reservations-items');

        window.Kiwi.navigation.push({path: '/resources-locations-reservations-items', label: 'modules.resources_locations_reservations_items'});
    window.Kiwi.router.addRoutes([{path: '/resources-locations-reservations-items', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-sql-widgets', 'items': [{'id': 'crud-sys-sql-widgets-widget', component: 'crud', data: {'id': 'crud-sys-sql-widgets'}}]}"></grid>
</app>`;

    Vue.component('module-sys-sql-widgets', config);
    window.Kiwi.components.registerCustom('module-sys-sql-widgets', 'module-sys-sql-widgets');

        window.Kiwi.navigation.push({path: '/sys-sql-widgets', label: 'modules.sys_sql_widgets'});
    window.Kiwi.router.addRoutes([{path: '/sys-sql-widgets', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-webforms-groups', 'items': [{'id': 'crud-sys-webforms-groups-widget', component: 'crud', data: {'id': 'crud-sys-webforms-groups'}}]}"></grid>
</app>`;

    Vue.component('module-sys-webforms-groups', config);
    window.Kiwi.components.registerCustom('module-sys-webforms-groups', 'module-sys-webforms-groups');

        window.Kiwi.navigation.push({path: '/sys-webforms-groups', label: 'modules.sys_webforms_groups'});
    window.Kiwi.router.addRoutes([{path: '/sys-webforms-groups', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-plc-sync-areas', 'items': [{'id': 'crud-sys-plc-sync-areas-widget', component: 'crud', data: {'id': 'crud-sys-plc-sync-areas'}}]}"></grid>
</app>`;

    Vue.component('module-sys-plc-sync-areas', config);
    window.Kiwi.components.registerCustom('module-sys-plc-sync-areas', 'module-sys-plc-sync-areas');

        window.Kiwi.navigation.push({path: '/sys-plc-sync-areas', label: 'modules.sys_plc_sync_areas'});
    window.Kiwi.router.addRoutes([{path: '/sys-plc-sync-areas', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-desktop-settings', 'items': [{'id': 'crud-sys-desktop-settings-widget', component: 'crud', data: {'id': 'crud-sys-desktop-settings'}}]}"></grid>
</app>`;

    Vue.component('module-sys-desktop-settings', config);
    window.Kiwi.components.registerCustom('module-sys-desktop-settings', 'module-sys-desktop-settings');

        window.Kiwi.navigation.push({path: '/sys-desktop-settings', label: 'modules.sys_desktop_settings'});
    window.Kiwi.router.addRoutes([{path: '/sys-desktop-settings', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-import-scheduler', 'items': [{'id': 'crud-sys-import-scheduler-widget', component: 'crud', data: {'id': 'crud-sys-import-scheduler'}}]}"></grid>
</app>`;

    Vue.component('module-sys-import-scheduler', config);
    window.Kiwi.components.registerCustom('module-sys-import-scheduler', 'module-sys-import-scheduler');

        window.Kiwi.navigation.push({path: '/sys-import-scheduler', label: 'modules.sys_import_scheduler'});
    window.Kiwi.router.addRoutes([{path: '/sys-import-scheduler', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-import-settings', 'items': [{'id': 'crud-sys-import-settings-widget', component: 'crud', data: {'id': 'crud-sys-import-settings'}}]}"></grid>
</app>`;

    Vue.component('module-sys-import-settings', config);
    window.Kiwi.components.registerCustom('module-sys-import-settings', 'module-sys-import-settings');

        window.Kiwi.navigation.push({path: '/sys-import-settings', label: 'modules.sys_import_settings'});
    window.Kiwi.router.addRoutes([{path: '/sys-import-settings', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-import-tasks', 'items': [{'id': 'crud-sys-import-tasks-widget', component: 'crud', data: {'id': 'crud-sys-import-tasks'}}]}"></grid>
</app>`;

    Vue.component('module-sys-import-tasks', config);
    window.Kiwi.components.registerCustom('module-sys-import-tasks', 'module-sys-import-tasks');

        window.Kiwi.navigation.push({path: '/sys-import-tasks', label: 'modules.sys_import_tasks'});
    window.Kiwi.router.addRoutes([{path: '/sys-import-tasks', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-triggers-sql-worker-db', 'items': [{'id': 'crud-sys-triggers-sql-worker-db-widget', component: 'crud', data: {'id': 'crud-sys-triggers-sql-worker-db'}}]}"></grid>
</app>`;

    Vue.component('module-sys-triggers-sql-worker-db', config);
    window.Kiwi.components.registerCustom('module-sys-triggers-sql-worker-db', 'module-sys-triggers-sql-worker-db');

        window.Kiwi.navigation.push({path: '/sys-triggers-sql-worker-db', label: 'modules.sys_triggers_sql_worker_db'});
    window.Kiwi.router.addRoutes([{path: '/sys-triggers-sql-worker-db', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-api', 'items': [{'id': 'crud-sys-api-widget', component: 'crud', data: {'id': 'crud-sys-api'}}]}"></grid>
</app>`;

    Vue.component('module-sys-api', config);
    window.Kiwi.components.registerCustom('module-sys-api', 'module-sys-api');

        window.Kiwi.navigation.push({path: '/sys-api', label: 'modules.sys_api'});
    window.Kiwi.router.addRoutes([{path: '/sys-api', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-webforms-stats', 'items': [{'id': 'crud-sys-webforms-stats-widget', component: 'crud', data: {'id': 'crud-sys-webforms-stats'}}]}"></grid>
</app>`;

    Vue.component('module-sys-webforms-stats', config);
    window.Kiwi.components.registerCustom('module-sys-webforms-stats', 'module-sys-webforms-stats');

        window.Kiwi.navigation.push({path: '/sys-webforms-stats', label: 'modules.sys_webforms_stats'});
    window.Kiwi.router.addRoutes([{path: '/sys-webforms-stats', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-webforms-sqls', 'items': [{'id': 'crud-sys-webforms-widget', component: 'crud', data: {'id': 'crud-sys-webforms-sqls'}}]}"></grid>
</app>`;

    Vue.component('module-sys-webforms-sqls', config);
    window.Kiwi.components.registerCustom('module-sys-webforms-sqls', 'module-sys-webforms-sqls');

        window.Kiwi.navigation.push({path: '/sys-webforms-sqls', label: 'modules.sys_webforms_sqls'});
    window.Kiwi.router.addRoutes([{path: '/sys-webforms-sqls', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-webforms-styles', 'items': [{'id': 'crud-sys-webforms-styles-widget', component: 'crud', data: {'id': 'crud-sys-webforms-styles'}}]}"></grid>
</app>`;

    Vue.component('module-sys-webforms-styles', config);
    window.Kiwi.components.registerCustom('module-sys-webforms-styles', 'module-sys-webforms-styles');

        window.Kiwi.navigation.push({path: '/sys-webforms-styles', label: 'modules.sys_webforms_styles'});
    window.Kiwi.router.addRoutes([{path: '/sys-webforms-styles', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-sys-tasks-sql-worker-db', 'items': [{'id': 'crud-sys-tasks-sql-worker-db-widget', component: 'crud', data: {'id': 'crud-sys-tasks-sql-worker-db'}}]}"></grid>
</app>`;

    Vue.component('module-sys-tasks-sql-worker-db', config);
    window.Kiwi.components.registerCustom('module-sys-tasks-sql-worker-db', 'module-sys-tasks-sql-worker-db');

        window.Kiwi.navigation.push({path: '/sys-tasks-sql-worker-db', label: 'modules.sys_tasks_sql_worker_db'});
    window.Kiwi.router.addRoutes([{path: '/sys-tasks-sql-worker-db', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-resources-locations-reservations-active', 'items': [{'id': 'crud-resources-locations-reservations-active-widget', component: 'crud', data: {'id': 'crud-resources-locations-reservations-active'}}]}"></grid>
</app>`;

    Vue.component('module-resources-locations-reservations-active', config);
    window.Kiwi.components.registerCustom('module-resources-locations-reservations-active', 'module-resources-locations-reservations-active');

        window.Kiwi.navigation.push({path: '/resources-locations-reservations-active', label: 'modules.resources_locations_reservations_active'});
    window.Kiwi.router.addRoutes([{path: '/resources-locations-reservations-active', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-events', 'items': [{'id': 'crud-events-widget', component: 'crud', data: {'id': 'crud-events'}}]}"></grid>
</app>`;

    Vue.component('module-events', config);
    window.Kiwi.components.registerCustom('module-events', 'module-events');

        window.Kiwi.navigation.push({path: '/events', label: 'modules.events'});
    window.Kiwi.router.addRoutes([{path: '/events', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-leads', 'items': [{'id': 'crud-leads-widget', component: 'crud', data: {'id': 'crud-leads'}}]}"></grid>
</app>`;

    Vue.component('module-leads', config);
    window.Kiwi.components.registerCustom('module-leads', 'module-leads');

        window.Kiwi.navigation.push({path: '/leads', label: 'modules.leads'});
    window.Kiwi.router.addRoutes([{path: '/leads', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {
    data() {
        return {
            events: [],
            event: {},
            settings: {},
            subscription: {},
            from: null,
            to: null,
            polling: null,
            loading: true,
            visibleHours: [],
            newReservation: {
                reservation_date: null,
                reservation_time: null,
                number_of_people: 1,
                lastname: '',
                firstname: '',
                egyseg: '1',
                phone: '+36',
                email: null,
                notes: '',
                allergen: '',
                json_result: '',
                visszaigazolas: 0,
                lang: 'en',
            },
            eventTemplate: `
                    <div style="cursor:pointer;" class="rounded-0 w-100 mb-1" :class="eventData.css" v-html="eventTitle"></div>
                `
        }
    },
    methods: {

        load(from, to) {
            this.from = from
            this.to = to

            this.stopPolling()
            this.loading = true

            Kiwi.request().get('/api/db/free_table_places?from_date='+ from +'&to_date='+ to)
                .then(response => {
                    this.events = response.data.default
                    this.restartPolling()
                    this.loading = false
                })
        },

        setVisibleHours(from, to) {
            this.visibleHours = []

            Kiwi.request().get('/api/db/reservation-places-open-close-data?from_date='+ from +'&to_date='+ to)
                .then(response => {
                    let open = response.data.default[0]['open']
                    let close = response.data.default[0]['close']
                    let openTime = moment(open, [moment.ISO_8601, 'HH:mm'])

                    let openedNumberOfHours = moment(close, [moment.ISO_8601, 'HH:mm'])
                        .diff(openTime, 'hours')

                    for (let i = 0; i <= openedNumberOfHours; i++) {
                        this.visibleHours.push(openTime.format('HH:mm'))
                        openTime.add(1, 'hour')
                    }
                })
        },

        reload(from, to) {
            this.load(from, to)
        },

        handleChangeInterval(from, to) {
            this.loading = true
            this.setVisibleHours(from, to)
            this.reload(from, to)
        },

        loadSettings() {
            Kiwi.request().get('/api/db/reservation-calendar-settings')
                .then(response => this.settings = response.data.default[0])
        },

        handleEventClick(event) {
            this.stopPolling()
            this.event = event
            this.newReservation.reservation_date = event.date.split(' ')[0]
            this.newReservation.reservation_time = event.date.split(' ')[1]
            this.newReservation.egyseg = event.place_id
            
            console.log(this.newReservation, event);
            this.$refs.createModal.show()
        },

        setDefaultReservation() {
            this.newReservation.reservation_date = null
            this.newReservation.reservation_time = null
            this.newReservation.number_of_people = 1
            this.newReservation.lastname = ''
            this.newReservation.firstname = ''
            this.newReservation.egyseg = '1'
            this.newReservation.phone = '+36'
            this.newReservation.email = null
            this.newReservation.notes = ''
            this.newReservation.allergen = ''
            this.newReservation.json_result = ''
            this.newReservation.visszaigazolas = 0
            this.newReservation.lang = 'en'
        },
        
        submit() {
            console.log(this.newReservation);
            this.newReservation.json_result = JSON.stringify(this.newReservation)
            Kiwi.request().post('/api/db/table_reservation', this.newReservation).then(() => {
                this.$toasted.success(this.__('common.reservation_success')) // Az asztalfoglalás sikerült.
                this.restartPolling()
                this.reload(this.from, this.to)
                this.setDefaultReservation()
                this.$refs.createModal.hide()
                Kiwi.ui.component('crud-leads').action('reload')
            }).catch(() => {
                this.$toasted.error(this.__('common.reservation_failed')) // Az asztalfoglalás NEM SIKERÜLT.
            })
        },

        getSubscription() {
            Kiwi.request().get('/api/db/subscription').then(response => {
                this.subscription = response.data.default[0]
            })
        },

        startPolling() {
            this.polling = setInterval(() => {
                this.reload(this.from, this.to)
            }, 20000)
        },

        restartPolling() {
            clearInterval(this.polling)
            this.startPolling()
        },

        stopPolling() {
            clearInterval(this.polling)
        }
    },
    computed: {
        hasAccess() {
            return parseInt(this.subscription?.reservation_calendar) === 1
        }
    },
    beforeDestroy() {
        this.stopPolling()
    },
    mounted() {
        this.getSubscription()
        this.startPolling()
        this.loadSettings()

        Kiwi.ui.component('crud-leads').listen('deleted', () => this.reload(this.from, this.to))
    }
};;
    config.template = `<div class="reservation-calendar">
    <div
            class="b-skeleton b-skeleton-text b-skeleton-animate-wave bg-primary text-center text-white fade-in-delay"
            style="height: 1.5rem;font-size: 0.9em;line-height: 1.5rem;--delay: 10ms"
            :class="{'invisible':  ! loading}"

    ><i class="fas fa-circle-notch fa-spin"></i> {{ __('loading') }} ...</div>

    <calendar2
            ref="calendar"
            :events="events"
            default-view="WEEK"
            title="title"
            dateFrom="date"
            dateTo="date"
            @selectEvent="handleEventClick"
            @changeInterval="handleChangeInterval"
            :visible-hours="visibleHours"
            :template="eventTemplate"
    ></calendar2>
    <b-modal ref="createModal" :title="__('common.table_reservation')" ok-only hide-footer size="lg">
        <form :style="hasAccess ? '' : 'height: 370px;overflow: hidden;'" @submit.prevent="submit" class="position-relative">
            <h2 class="d-flex justify-content-between">
                <div>
                    {{ newReservation.reservation_date | kiwiDate:'YYYY. MMM. DD.' }} {{ newReservation.reservation_time?.replace(':00', '') }}
                </div>
                <div>
                    <span class="p-1" style="font-size: inherit !important;" :class="event.css" v-show="newReservation.egyseg == 1">Étterem</span>
                    <span class="p-1" style="font-size: inherit !important;" :class="event.css" v-show="newReservation.egyseg == 2">Kávéház</span>
                </div>
            </h2>
            <h3 class="text-danger" v-show="settings.unlimited_places == 0">{{ __('res_calendar.max_number_of_people') }}: {{ event.free_places }}</h3>
            <div class="row">
                <div class="form-group col-12 col-sm-6">
                    <label>{{ __('common.last_name') }}</label>
                    <input type="text" v-focus :placeholder="__('common.last_name')" v-model="newReservation.lastname" class="form-control" />
                </div>
                <div class="form-group col-12 col-sm-6">
                    <label>{{ __('common.first_name') }}</label>
                    <input type="text" :placeholder="__('common.first_name')" v-model="newReservation.firstname" class="form-control" />
                </div>
            </div>
            <div class="row">
                <div class="form-group col-12 col-sm-6">
                    <label>{{ __('common.phone') }}</label>
                    <input type="text" :placeholder="__('common.phone')" v-model="newReservation.phone" class="form-control" />
                </div>
                <div class="form-group col-12 col-sm-6">
                    <label>{{ __('common.email') }}</label>
                    <input type="email" :placeholder="__('common.email')" v-model="newReservation.email" class="form-control" />
                    <label for="notification_cb">
                        <input type="checkbox" id="notification_cb" v-model="newReservation.visszaigazolas" :true-value="1" :false-value="0">
                        {{ __('res_calendar.requests_confirmation') }}
                    </label>
                </div>
            </div>
            <div class="form-group">
                <label>{{ __('Megjegyzés') }}</label>
                <textarea v-model="newReservation.notes" class="form-control"></textarea>
            </div>
            <div class="form-group">
                <label>{{ __('Allergén') }}</label>
                <textarea v-model="newReservation.allergen" class="form-control"></textarea>
            </div>
            <div class="form-group">
                <label>{{ __('Vendégek száma') }}</label>
                <input type="number" :max="event.free_places" min="1" :placeholder="__('Vendégek száma')" v-model="newReservation.number_of_people" class="form-control" />
                <button type="button" tabindex="-1" @click.prevent="newReservation.number_of_people = i" v-show="i <= event.free_places" class="btn btn-dark mr-1 mt-1 text-white" v-for="i in [1,2,3,4,5,6,7,8,9,10]">{{ i }}</button>
            </div>
            <div class="form-group">
                <label>{{ __('res_calendar.communications_lang') }}</label>

                <select v-model="newReservation.lang" class="form-control">
                    <option value="en">English</option>
                    <option value="hu">Hungarian</option>
                    <option value="de">German</option>
                </select>

                <div class="d-flex mt-2" style="gap: .4rem">
                    <img src="https://flagcdn.com/gb.svg" width="32" alt="English" style="cursor:pointer;" @click.prevent="newReservation.lang = 'en'" />
                    <img src="https://flagcdn.com/hu.svg" width="32" alt="Hungarian" style="cursor:pointer;" @click.prevent="newReservation.lang = 'hu'" />
                    <img src="https://flagcdn.com/de.svg" width="32" alt="German" style="cursor:pointer;" @click.prevent="newReservation.lang = 'de'" />
                </div>
            </div>

            <input type="submit" class="btn btn-primary" :value="__('Küldés')">

            <div v-if="! hasAccess" class="calendar-lock-overlay"><i class="fas fa-unlock-alt"></i></div>
        </form>

        <div v-if="! hasAccess" class="alert alert-warning mt-4">
            <div class="font-weight-bold">
                {{ __('Calendar Not Available') }}
            </div>
            <div>
                {{ __('Calendar Not Available Content') }}
            </div>
            <a href="#" class="btn btn-warning mt-4">{{ __('Compare Plans') }}</a>
        </div>
    </b-modal>
</div>`;

    Vue.component('reservation-calendar', config);
    window.Kiwi.components.registerCustom('reservation-calendar', 'reservation-calendar');

        window.Kiwi.navigation.push({path: '/asztalfoglalas-naptar', label: 'Asztalfoglalás naptár'});
    window.Kiwi.router.addRoutes([{path: '/asztalfoglalas-naptar', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {
    data() {
        return {
            events: [],
            event: {},
            from: null,
            to: null,
            polling: null,
            newReservation: {
                reservation_date: null,
                reservation_time: null,
                number_of_people: 1,
                lastname: '',
                firstname: '',
                egyseg: '1',
                phone: '+36',
                email: null,
                notes: '',
                json_result: '',
                visszaigazolas: 0,
            },
            eventTemplate: `
                    <div style="cursor:pointer;" class="rounded-0 w-100 mb-1" :class="eventData.css" v-html="eventTitle"></div>
                `
        }
    },
    methods: {

        load(from, to) {
            this.from = from
            this.to = to

            Kiwi.request().get('/api/db/free_table_places-test?from_date='+ from +'&to_date='+ to)
                .then(response => {
                    this.events = response.data.default
                })
        },

        reload(from, to) {
            this.load(from, to)
        },

        handleEventClick(event) {
            this.stopPolling()
            this.event = event
            this.newReservation.reservation_date = event.date.split(' ')[0]
            this.newReservation.reservation_time = event.date.split(' ')[1]
            this.newReservation.egyseg = event.place_id
            
            console.log(this.newReservation, event);
            this.$refs.createModal.show()
        },

        setDefaultReservation() {
            this.newReservation.reservation_date = null
            this.newReservation.reservation_time = null
            this.newReservation.number_of_people = 1
            this.newReservation.lastname = ''
            this.newReservation.firstname = ''
            this.newReservation.egyseg = '1'
            this.newReservation.phone = '+36'
            this.newReservation.email = null
            this.newReservation.notes = ''
            this.newReservation.json_result = ''
            this.newReservation.visszaigazolas = 0
        },
        
        submit() {
            console.log(this.newReservation);
            this.newReservation.json_result = JSON.stringify(this.newReservation)
            Kiwi.request().post('/api/db/table_reservation-test', this.newReservation).then(() => {
                this.$toasted.success('Az asztalfoglalás sikerült.')
                this.restartPolling()
                this.reload(this.from, this.to)
                this.setDefaultReservation()
                this.$refs.createModal.hide()
            }).catch(() => {
                this.$toasted.error('Az asztalfoglalás NEM SIKERÜLT.')
            })
        },

        startPolling() {
            this.polling = setInterval(() => {
                this.reload(this.from, this.to)
            }, 20000)
        },

        restartPolling() {
            clearInterval(this.polling)
            this.startPolling()
        },

        stopPolling() {
            clearInterval(this.polling)
        }
    },
    mounted() {
        this.startPolling()

        Kiwi.ui.component('crud-leads').listen('deleted', () => this.reload(this.from, this.to))
    }
};;
    config.template = `<div class="reservation-calendar">
    <calendar2
            ref="calendar"
            :events="events"
            default-view="WEEK"
            title="title"
            dateFrom="date"
            dateTo="date"
            @selectEvent="handleEventClick"
            @changeInterval="reload"
            :visible-hours="['08:00','09:00','10:00','11:00','12:00','13:00','14:00','15:00','16:00','17:00','18:00','19:00','20:00','21:00','22:00','23:00']"
            :template="eventTemplate"
    ></calendar2>
    <b-modal ref="createModal" title="Asztalfoglalás" ok-only hide-footer size="lg">
        <form @submit.prevent="submit">
            <h2 class="d-flex justify-content-between">
                <div>
                    {{ newReservation.reservation_date | kiwiDate:'YYYY. MMM. DD.' }} {{ newReservation.reservation_time?.replace(':00', '') }}
                </div>
                <div>
                    <span class="p-1" style="font-size: inherit !important;" :class="event.css" v-show="newReservation.egyseg == 1">Étterem</span>
                    <span class="p-1" style="font-size: inherit !important;" :class="event.css" v-show="newReservation.egyseg == 2">Kávéház</span>
                </div>
            </h2>
            <h3 class="text-danger">Max létszám: {{ event.free_places }}</h3>
            <div class="row">
                <div class="form-group col-12 col-sm-6">
                    <label>Vezetéknév</label>
                    <input type="text" v-focus placeholder="Vezetéknév" v-model="newReservation.lastname" class="form-control" />
                </div>
                <div class="form-group col-12 col-sm-6">
                    <label>Keresztnév</label>
                    <input type="text" placeholder="Keresztnév" v-model="newReservation.firstname" class="form-control" />
                </div>
            </div>
            <div class="row">
                <div class="form-group col-12 col-sm-6">
                    <label>Telefon</label>
                    <input type="text" placeholder="Telefon" v-model="newReservation.phone" class="form-control" />
                </div>
                <div class="form-group col-12 col-sm-6">
                    <label>Email</label>
                    <input type="text" placeholder="Email" v-model="newReservation.email" class="form-control" />
                    <label for="notification_cb">
                        <input type="checkbox" id="notification_cb" v-model="newReservation.visszaigazolas" :true-value="1" :false-value="0">
                        Visszaigazolást kér
                    </label>
                </div>
            </div>
            <div class="form-group">
                <label>Megjegyzés</label>
                <textarea v-model="newReservation.notes" class="form-control"></textarea>
            </div>
            <div class="form-group">
                <label>Vendégek száma</label>
                <input type="number" :max="event.free_places" min="1" placeholder="Vendégek száma" v-model="newReservation.number_of_people" class="form-control" />
                <button type="button" tabindex="-1" @click.prevent="newReservation.number_of_people = i" v-show="i <= event.free_places" class="btn btn-dark mr-1 mt-1 text-white" v-for="i in [1,2,3,4,5,6,7,8,9,10]">{{ i }}</button>
            </div>

            <input type="submit" class="btn btn-primary" value="Mentés">
        </form>
    </b-modal>
</div>`;

    Vue.component('reservation-calendar-test', config);
    window.Kiwi.components.registerCustom('reservation-calendar-test', 'reservation-calendar-test');

        window.Kiwi.navigation.push({path: '/asztalfoglalas-naptar-teszt', label: 'Asztalfoglalás naptár'});
    window.Kiwi.router.addRoutes([{path: '/asztalfoglalas-naptar-teszt', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {
    inject: ['tableSetup'],
    props: {
        defaults: Array,
        types: Array,
    },
    data() {
        return {
            newData: {
                dateFrom: null,
                dateTo: null,
                conditions: [],
                validConditions: [],
                isClosed: false,
                note: '',
            },
            params: {},
            errors: [],
            conditionsIdsOrdered: [],
            groupId: null,
            groupCreated: false,
            loading: false,
            datesVerified: false,
            moment: window.moment
        }
    },
    computed: {
    },
    watch: {
        'newData.dateFrom': function() {
            if(! this.newData.dateTo) {
                this.newData.dateTo = moment(this.newData.dateFrom).endOf('day').format('YYYY-MM-DD HH:mm:ss')
            }
        },
        'newData.dateTo': function(val) {
            if(! this.newData.dateTo) {
                this.newData.dateTo = moment(val).endOf('day').format('YYYY-MM-DD HH:mm:ss')
            }
        },
    },
    methods: {
        verify() {
            this.validConditions = []

            if(! this.newData.dateTo || ! this.newData.dateFrom) {
                return this.$toasted.error(this.__('ts.custom_validation_period_required'))
            }

            if(moment(this.newData.dateFrom).diff(moment(), 'day') < 0) {
                return this.$toasted.error(this.__('ts.custom_validation_period_past'))
            }

            if(moment(this.newData.dateTo).diff(moment(this.newData.dateFrom)) < 0) {
                return this.$toasted.error(this.__('ts.custom_validation_period_invalid'))
            }

            Kiwi.request().post('/api/db/check-params-interval', {...this.newData, place_id: this.tableSetup.selectedPlace.id}).then(response => {
                if(parseInt(response.data.default[0]['available']) === 1) {
                    this.datesVerified = true
                    this.$toasted.success(this.__('ts.custom_period_free'))

                    response.data.conditions.forEach(condition => {
                        if(parseInt(condition.valid) === 1) {
                            this.validConditions.push(condition.id)
                        }
                    })

                    this._createGroup()
                } else {
                    this.$toasted.error(this.__('ts.custom_period_already_exists'))
                }
            })
        },
        _createGroup() {
            return new Promise((resolve => {
                Kiwi.request().post('/api/db/create-group', {name: this.newData.note, place_id: this.tableSetup.selectedPlace.id}).then(response => {
                    this.groupId = parseInt(response.data['insert'][0]['group_id'])
                    this.groupCreated = true
                    resolve()
                })
            }))
        },
        validate() {
            this.errors = []
            let valid = true

            Object.keys(this.params).forEach(conditionId => {
                this.params[conditionId].forEach(param => {
                    if (param.default) {
                        return
                    }

                    if(param.is_time == 1) {
                        let regex = /^(\d{2}:\d{2}-\d{2}:\d{2}){1}(\s\d{2}:\d{2}-\d{2}:\d{2})*$/;
                        if (! regex.test(param.value)) {
                            this.errors.push(
                                'A(z) "'+ param.name + ' ' + param.condition +'" paraméter helyes formátuma: 10:00-12:00' +
                                ' vagy 08:00-12:00 14:00-20:00. Kérjük ellenőrizze!'
                            )

                            valid = false
                        }
                    }
                })
            })

            return valid
        },
        save() {
            if(! this.validate()) {
                return
            }

            this.loading = true

            this.tableSetup._applyReservationParameters(this.newData.dateFrom, moment(this.newData.dateTo).endOf('day').format('YYYY-MM-DD HH:mm:ss')).then(() => {
                // this.generateParams()
                this.loading = false
                this.$emit('success')
                this.reset()
                this.$refs.customModal.hide()
            })
        },

        reset() {
            this.newData = {
                dateFrom: null,
                dateTo: null,
                conditions: [],
                isClosed: false,
                note: '',
            }

            this.groupId = null
            this.groupCreated = false
            this.datesVerified = false
            this.validConditions = []
            this.conditionsIdsOrdered = []
        },

        handleDefaultChange(event, param) {
            event.target.closest('.input-group').querySelector('.form-control').focus()
        },

        openModal() {
            this.$refs.customModal.show()
        }

    },
    beforeMount() {
    },
    mounted() {
        this.$root.$on('tablesCustomParams.open', () => this.openModal())
    }
};;
    config.template = `<div>
    <button type="button" class="card btn-light btn-block h-100" @click="openModal()">
        <span class="card-icon">
            <icon main="far fa-calendar-alt"></icon>
        </span>
        <span class="card-header">{{ __('ts.custom_params') }}</span>
        <span class="card-body text-left">
            {{ __('ts.custom_params_short_description') }}
        </span>
    </button>

<!--    <button class="btn btn-light" @click.prevent="openModal()">{{ __('ts.custom_params') }}</button>-->

    <b-modal ref="customModal" size="full" :title="__('ts.custom_params')" hide-footer>
        <p class="lead">{{ __('ts.custom_params_desc') }}</p>

        <form @submit.prevent="save()">
            <div class="row">
                <div class="col-12">
                    <div :class="'form-group '+ (datesVerified ? 'is-valid' : '')">
                        <label>{{ __('ts.name') }} *</label>
                        <input type="text" :placeholder="__('ts.name') +'...'" v-model="newData.note" class="form-control" :readonly="datesVerified" required>
                    </div>
                </div>
                <div class="col-12">
                    <label>{{ __('ts.date_range_title') }}</label>
                </div>
                <div :class="'col-12 col-sm-6 '+ (datesVerified ? 'is-valid' : '')">
                    <datepicker placeholder="Dátumtól" required v-model="newData.dateFrom" :disabled="datesVerified" />
                    <span class="text-gray-600" v-if="newData.dateFrom">{{ moment(newData.dateFrom).format('dddd') }}</span>
                </div>
                <div :class="'col-12 col-sm-6 '+ (datesVerified ? 'is-valid' : '')">
                    <datepicker placeholder="Dátumig" required v-model="newData.dateTo" :disabled="datesVerified" />
                    <span class="text-gray-600" v-if="newData.dateTo">{{ moment(newData.dateTo).format('dddd') }}</span>
                </div>
                <div class="col-12 mt-3" v-if="! datesVerified">
                    <button
                            type="button"
                            class="btn btn-primary text-white"
                            @click.prevent="verify"
                            :disabled="! this.newData.dateTo || ! this.newData.dateFrom"
                    >
                        <i class="fa fa-spinner fa-spin" v-show="loading"></i> {{ __('common.continue') }}
                    </button>
                </div>

                <div v-if="datesVerified && groupCreated" class="col-12 mt-3">
                    <tables-params-editor
                            :place-id="tableSetup.selectedPlace.id"
                            :group-id="groupId"
                            :custom-date-from="newData.dateFrom"
                            :custom-date-to="newData.dateTo"
                            :visible-conditions="validConditions"
                            custom
                    />
                </div>

                <div v-if="datesVerified" class="col-12 mt-3">

                    <div class="alert alert-danger mt-3" v-for="error in errors" v-text="error"></div>

                    <button
                            type="submit"
                            class="btn btn-primary text-white mt-2"
                            :disabled="loading"
                    >
                        <i class="fa fa-spinner fa-spin" v-show="loading"></i> {{ __('common.apply') }}
                    </button>

                    <button
                            type="button"
                            class="btn btn-danger text-white mt-2"
                            :disabled="loading"
                            @click="reset()"
                    >
                        <i class="fa fa-spinner fa-spin" v-show="loading"></i> {{ __('common.delete') }}
                    </button>

                    <div v-if="loading" class="ml-3 fade-in-delay text-right" style="--delay: 5s"><i class="fa fa-info-circle"></i> {{ __('common.still_loading') }}</div>
                </div>
            </div>
        </form>
    </b-modal>
</div>`;

    Vue.component('tables-custom-params', config);
    window.Kiwi.components.registerCustom('tables-custom-params', 'tables-custom-params');

    }).call();
(function() {
    const config = {
    data() {
        return {
            config: null
        }
    },
    mounted() {
        Kiwi.request().post('/api/db/erhardt-reservation-form-config').then(response => {
            this.config = JSON.parse(response.data.default[0].group_config_9)
        })
    }
};
    config.template = `<div style="old-background:#fff;padding:.5rem">
	<kiwi-form v-if="config" no-config :override="config" />
</div>`;

    Vue.component('erhardt-reservation-form', config);
    window.Kiwi.components.registerCustom('erhardt-reservation-form', 'erhardt-reservation-form');

        window.Kiwi.navigation.push({path: '/erhardt-reservation-form-old', label: 'Erhardt Asztalfoglalás form'});
    window.Kiwi.router.addRoutes([{path: '/erhardt-reservation-form-old', component: config, meta: { auth: 0 }}]);
    }).call();
(function() {
    const config = {
    provide() {
        return {
            tableSetup: this
        }
    },
    data() {
        return {
            years: [],
            months: [],
            selectedYear: null, // int
            selectedMonth: null, // Moment object
            selectedPlace: {},
            data: {},
            defaults: [],
            types: [],
            conditions: [],
            conditionsIdsOrdered: [],
            groups: [],
            places: [],
            params: {},
            defaultParamsChanged: {},
            groupsFilters: {
                name: '',
                dateFrom: null,
                dateTo: null
            },
            openedGroupFilter: '',
            selectedParams: [],
            customParamsLoading: false,
            defaultsSaving: false,
            weekdays: [],
            openedGroup: {
                data: {},
                params: []
            },
            moment: window.moment
        }
    },
    computed: {
        days() {
            return this.selectedMonth.daysInMonth()
        },
        newSettingDisabled() {
            return this.customParamsLoading || (
                (this.selectedParams.length === 0 && ! this.newSetting.isClosed)
                    || this.newSetting.conditions.length === 0
            ) || (! this.newSetting.dateFrom || ! this.newSetting.dateTo)
        },
        filteredGroupParams() {
            return _.groupBy(this.openedGroup.params.filter(item => {
                    return item.type.toLowerCase().includes(this.openedGroupFilter.toLowerCase()) ||
                        item.condition.toLowerCase().includes(this.openedGroupFilter.toLowerCase())
                }), 'condition')
        }
    },
    watch: {
        selectedMonth(newVal) {
            this.getData()
            this.getDefaults()
            this.getGroups()
        },
        selectedYear(newVal) {
            this.getData()
            this.getDefaults()
            this.getGroups()
        },
        'selectedPlace.id': {
            handler(newVal) {
                this.getData()
                this.getDefaults()
                this.getGroups()
            },
            deep: true
        },
        groupsFilters: {
            handler: _.debounce(function(value) { this.getGroups() }, 400),
            deep: true
        }
    },
    methods: {
        getPlaces() {
            Kiwi.request().get('/api/leads_list_collectings_2?filter_exact[owner_id]='+ Kiwi.auth.user.owner_id).then((response) => {
                this.places = response.data
            })
        },

        getData() {
            if(! this.selectedPlace.id) {
                return
            }

            let dateFrom = moment({year: this.selectedYear, month: this.selectedMonth.month(), day: 1}).format('YYYY-MM-DD')
            let dateTo = moment({year: this.selectedYear, month: this.selectedMonth.month(), day: this.days}).format('YYYY-MM-DD')

            this.data = {}

            Kiwi.request().get('/api/db/get-table-config?place='+ this.selectedPlace.id +'&date_from='+ dateFrom +'&date_to='+ dateTo).then(response => {
                response.data.default.forEach(item => {
                    this.$set(this.data, item.day, item)
                })

                this.generateDays()
            })
        },

        getDefaults() {
            if(! this.selectedPlace.id) {
                return
            }

            this.defaultParamsChanged = {}

            Kiwi.request().get('/api/db/get-default-reservation-params?place_id='+ this.selectedPlace.id).then(response => {
                let defaults = response.data.default

                // defaults.forEach(param => {
                //     if(parseInt(param.is_time) === 1) {
                //         //param.start = param.value.split('-')[0]
                //         //param.end = param.value.split('-')[1]
                //         //param.openTime = param.value;
                //     }
                // })
                //
                // this.defaults = _.groupBy(defaults, 'condition_id')
                // this.conditionsIdsOrdered = Object.keys(this.defaults).sort(
                //     (a, b) => this.defaults[a][0]['order'] - this.defaults[b][0]['order']
                // )

                this.defaults = defaults

                console.log('def', this.defaults);
                // this.defaults = Object.keys(this.defaults)
                //     .sort((a, b) => this.defaults[a][0]['order'] - this.defaults[b][0]['order'])
            })
        },

        getTypes() {
            Kiwi.request().get('/api/db/get-reservation-types').then(response => {
                this.types = response.data.default

               /*this.types.forEach(type => {
                    if(parseInt(type.is_time) === 1) {
                        type.start = '00:00'
                        type.end = '24:00'
                    }
                })*/
            })
        },

        getConditions() {
            Kiwi.request().get('/api/db/get-reservation-conditions').then(response => {
                this.conditions = response.data.default
            })
        },

        getGroups() {
            if(! this.selectedPlace.id) {
                return
            }

            let data = this.groupsFilters
            data.place_id = this.selectedPlace.id

            Kiwi.request().post('/api/db/get-reservation-groups', data).then(response => {
                this.groups = response.data.default
            })
        },

        generateDays() {
            this.weekdays = []
            let month = this.selectedMonth.clone()

            Array.from({length: this.days}).forEach((nothing, dayIndex) => {
                this.weekdays.push(month.add(dayIndex, 'day'))
            })
        },
        
        handleDefaultParamChange(param, event) {
            let data = {
                type_id: param.id,
                value: param.value,
                place_id: this.selectedPlace.id,
                condition_id: param.condition_id,
            }
            
            if(param.is_time == 1) {
                let regex = /^(\d{2}:\d{2}-\d{2}:\d{2}){1}(\s\d{2}:\d{2}-\d{2}:\d{2})*$/;
                if(regex.test(data.value)){
                    event.target.classList.remove('is-invalid');
                }else{
                    alert('A "Nyitvatartás" helyes formátuma: 10:00-12:00 vagy 08:00-12:00 14:00-20:00');
                    event.target.classList.add('is-invalid');
                    return;
                }
                //data.value = `${param.start}-${param.end}`;
            }
            
            const key = `${data.type_id}-${data.place_id}-${data.condition_id}`

            this.$set(this.defaultParamsChanged, key, data)
        },

        saveDefaults() {
            let saveCount = 0
            this.defaultsSaving = true

            Object.keys(this.defaultParamsChanged).forEach(key => {
                Kiwi.request().patch('/api/db/update-default-reservation-parameters', this.defaultParamsChanged[key]).then(response => {
                    // this.$toasted.success('Az alapértelmezett paraméter sikeresen módosult.')
                })
                    .catch((error) => error.response.status === 422 || this.$toasted.error('A módosítás egy szerverhiba miatt meghiúsult. Kérjük vegye fel a kapcsolatot az ügyfélszolgálattal.'))
                    .finally(() => {
                        saveCount++

                        if(saveCount >= Object.keys(this.defaultParamsChanged).length) {
                            this._applyReservationParameters().then(() => {
                                this.defaultsSaving = false
                                this.getDefaults()
                                this.getData()
                                this.defaultParamsChanged = {}
                                this.$toasted.success('Az alapértelmezett paraméterek sikeresen elmentve.')
                            })
                        }
                    })
            })
        },

        handleCustomParamsSuccess() {
            this.getGroups()
            this.getData()
        },

        _applyReservationParameters(dateFrom = null, dateTo = null) {
            return Kiwi.request().post('/api/db/apply-reservation-parameters', {
                place_id: this.selectedPlace.id,
                date_from: dateFrom,
                date_to: dateTo
            })
        },

        openGroup(group) {
            this.openedGroup.data = group

            Kiwi.request().get('/api/db/get-parameters-by-group?group_id='+ group.id).then(response => {
                this.openedGroup.params = response.data.default
                this.$refs.groupModal.show()
            })
        },

        deleteGroup(group) {
            let vm = this

            Kiwi.bus.$emit('confirm', {
                title: 'Biztosan törölni szeretné?',
                content: 'A kiválasztott időszakra a beállítások törölve lesznek.',
                callback() {
                    Kiwi.request()
                        .post('/api/db/delete-reservation-group', {group_id: group.id})
                        .then(() => {
                            vm.$toasted.success('Beállítások törölve.')
                            vm._applyReservationParameters(group.date_from, group.date_to)
                            vm.getGroups()
                        })
                        .catch(() => vm.$toasted.error('A beállításokat nem lehetett törölni egy szerverhiba miatt.'))
                }
            })
        },

        openDefaultsModal() {
            this.$refs.defaultsModal.show()
        }
    },
    beforeMount() {
        for (let i = 0; i < 12; i++) {
            this.months.push(moment({year: 2022, month: i}))
        }

        this.selectedMonth = this.months[moment().month()]

        this.years = [
            moment().year(),
            moment().add(1, 'year').year(),
        ]

        this.selectedYear = this.years[0]
    },
    mounted() {
        this.getTypes()
        this.getConditions()
        this.getPlaces()
    }
};;
    config.template = `<app>
    <div class="row">
        <div class="col-sm-6 col-lg-4 col-xl-3 mb-4">
            <tables-global-settings
                    class="h-100"
                    v-if="selectedPlace.id"
            ></tables-global-settings>
        </div>
        <div class="col-sm-6 col-lg-4 col-xl-3 mb-4">
            <tables-custom-params
                    :defaults="defaults"
                    :types="types"
                    class="h-100"
                    v-if="Object.keys(defaults).length > 0 && types.length > 0"
                    @success="handleCustomParamsSuccess"
            ></tables-custom-params>
        </div>
    </div>

    <div class="card" :class="'border-'+ selectedPlace.color">
        <div class="card-header d-flex justify-content-between">
            <div>{{ __('ts.tables_setup') }}</div>
            <div>
                <tables-place-switcher
                    v-if="places.length > 0"
                    v-model="selectedPlace"
                    :places="places"
                />
            </div>
        </div>
        <div class="card-body">
            <!-- FEJLÉC, SZŰRŐK, FUNKCIÓK -->
            <div class="mb-3">
                <!--<button type="button" class="btn btn-light mr-1" @click="openDefaultsModal()">{{ __('ts.default_settings') }}</button>-->
            </div>

            <p class="lead">{{ __('ts.default_settings_help') }}</p>

            <tables-params-editor
                    v-if="selectedPlace.id"
                    :place-id="selectedPlace.id"
            ></tables-params-editor>

        </div>
    </div>

    <!-- ---------- -->
    <!-- IDŐSZAKOS BEÁLLÍTÁSOK LISTA -->
    <div class="card mt-3">
        <div class="card-header">{{ __('ts.temporary_settings') }}</div>
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-borderless">
                    <thead>
                    <th style="width: 100px"></th>
                    <th>{{ __('ts.name') }}</th>
                    <th style="width:210px">{{ __('ts.period') }}</th>
                    </thead>
                    <thead>
                    <th></th>
                    <th>
                        <input type="text" class="form-control" v-model="groupsFilters.name" :placeholder="__('common.filter') + '...'" />
                    </th>
                    <th>
                        <div class="d-flex">
                            <div class="input-group">
                                <datepicker v-model="groupsFilters.dateFrom" :placeholder="__('common.filter') + '...'" />
                                <datepicker v-model="groupsFilters.dateTo" :placeholder="__('common.filter') + '...'" />
                            </div>
                            <button class="btn btn-sm btn-light ml-1" @click="groupsFilters.dateFrom = null;groupsFilters.dateTo = null;">
                                <i class="fa fa-times text-gray-700"></i>
                            </button>
                        </div>
                    </th>
                    </thead>
                    <tbody>
                    <tr v-for="group in groups">
                        <td>
                            <button class="btn btn-secondary btn-sm" @click="openGroup(group)">
                                <i class="fa fa-eye"></i>
                            </button>
                            <button class="btn btn-secondary text-danger btn-sm" @click="deleteGroup(group)">
                                <i class="fa fa-trash"></i>
                            </button>
                        </td>
                        <td>{{ group.name }}</td>
                        <td>
                            <span class="badge badge-primary">{{ moment(group.date_from).format('YYYY. MM. DD.') }}</span> &mdash;
                            <span class="badge badge-primary">{{ moment(group.date_to).format('YYYY. MM. DD.') }}</span>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>


    <!-- ---------- -->
    <!-- BEÁLLÍTÁS MODALOK -->
    <b-modal ref="defaultsModal" size="full" hide-header ok-title="Bezárás" ok-only ok-variant="light">
        <div class="d-flex justify-content-between align-items-center mb-3">
            <h5>{{ __('ts.default_settings') }}</h5>
            <div>
                <tables-place-switcher
                    v-if="places.length > 0"
                    v-model="selectedPlace"
                    :places="places"
                />
            </div>
        </div>

        <p class="lead">{{ __('ts.default_settings_help') }}</p>

        <tables-params-editor
                v-if="selectedPlace.id"
                :place-id="selectedPlace.id"
        ></tables-params-editor>
    </b-modal>

    <b-modal ref="groupModal" size="full" :title="__('ts.show_period_settings')" hide-footer>
        <table class="table table-borderless">
            <tbody>
            <tr>
                <td>{{ __('common.notes') }}:</td>
                <td class="text-right">{{ openedGroup.data.name }}</td>
            </tr>
            <tr>
                <td>{{ __('ts.period') }}:</td>
                <td class="text-right">
                    {{ moment(openedGroup.data.date_from).format('YYYY. MM. DD.') }} — {{ moment(openedGroup.data.date_to).format('YYYY. MM. DD.') }}
                </td>
            </tr>
            </tbody>
        </table>
<!--        <div class="form-group mt-5">-->
<!--            <input type="text" v-model="openedGroupFilter" class="form-control" :placeholder="__('common.filter') + '...'">-->
<!--            <p class="small muted form-text">{{ __('ts.period_settings_example') }}</p>-->
<!--        </div>-->
        <tables-params-editor
                v-if="selectedPlace.id && openedGroup.data.id"
                :place-id="selectedPlace.id"
                :group-id="openedGroup.data.id"
                :custom-date-from="openedGroup.data.date_from"
                :custom-date-to="openedGroup.data.date_to"
                custom
        ></tables-params-editor>
        <table v-if="false" class="table table-borderless table-striped table-hover params-table">
            <thead>
            <tr>
                <th></th>
                <th v-for="type in types">{{ __(type.name) }}</th>
            </tr>
            </thead>
            <tbody>
            <tr v-for="(params, condition) in filteredGroupParams">
                <td>{{ __(condition) }}</td>
                <td v-for="type in types">
                    <span v-for="param in params" v-if="type.id == param.type_id">{{ param.value }}</span>
                </td>
            </tr>
            </tbody>
        </table>
    </b-modal>
</app>`;

    Vue.component('tables-setup', config);
    window.Kiwi.components.registerCustom('tables-setup', 'tables-setup');

        window.Kiwi.navigation.push({path: '/asztalok-beallitasa', label: 'modules.reservation_settings'});
    window.Kiwi.router.addRoutes([{path: '/asztalok-beallitasa', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {
    props: ['value', 'places'],

    beforeMount() {
        if(! this.value.id) {
            this.$emit('input', this.places[0])
        }
    }
};;
    config.template = `<select
    :class="'form-control bg-'+ value.bg_color + ' text-' + value.color"
    :value="places.indexOf(value)"
    @input="$emit('input', places[$event.target.value])"
>
    <option :value="index" v-for="(place, index) in places">{{ place.name }}</option>
</select>`;

    Vue.component('tables-place-switcher', config);
    window.Kiwi.components.registerCustom('tables-place-switcher', 'tables-place-switcher');

    }).call();
(function() {
    // Létszám szerinti szorzók beállítás ID
const PEOPLE_MULTI = 103

// Ezek a beállítások csak egyszerű értékek
const SINGLE_VALUE_SETTINGS = [1, 101, 102, 105]

const config = {
    inject: ['tableSetup'],

    data() {
        return {
            settings: {},
            peopleModifiers: [],
            loading: false,
            saving: false,
        }
    },

    methods: {
        load() {
            this.loading = true
            this.peopleModifiers = []
            this.settings = {}

            Kiwi.request().get('/api/db/get-global-settings?place_id='+ this.tableSetup.selectedPlace.id).then(response => {
                response.data.default.forEach(item => {

                    if(parseInt(item.type_id) === PEOPLE_MULTI) {
                        if(! this.settings[item.type_id]) {
                            this.$set(this.settings, item.type_id, [ReservationSetting.parse(item)])
                        } else {
                            this.settings[item.type_id].push(ReservationSetting.parse(item))
                        }
                    } else {
                        this.$set(this.settings, item.type_id, ReservationSetting.parse(item))
                    }

                })
                console.log(this.settings);
                this.updatePeopleModifiers()
            }).finally(() => this.loading = false)
        },

        updatePeopleModifiers() {
            let settings = this.settings[PEOPLE_MULTI]

            if(! settings) {
                this.addPeopleModifier()
                return
            }

            settings.forEach(setting => {
                this.addPeopleModifier(new ReservationModifier(setting.option_1, setting.option_2, setting.value))
            })

        },

        addPeopleModifier(modifier) {
            if(! modifier && this.peopleModifiers.length > 0) {
                // Az előző modifier max értékéhez igazítjuk a következőt
                this.peopleModifiers.push(new ReservationModifier(
                    this.peopleModifiers[this.peopleModifiers.length - 1]['max'] + 1,
                    this.peopleModifiers[this.peopleModifiers.length - 1]['max'] + 1)
                )

                return
            }

            this.peopleModifiers.push(modifier || new ReservationModifier())
        },

        peopleModifierMinValue(modifier, index) {
            // A legelső elem esetén a min. létszám 0
            if(index === 0) {
                return 0
            }

            let previousMax = this.peopleModifiers[index - 1]['max']

            if(previousMax) {
                return previousMax + 1
            }

            return 0
        },

        save() {
            this.saving = true
            let saveCount = 0
            const count = () => {
                saveCount--

                if(saveCount <= 0) {
                    this.$toasted.success('A mentés sikerült.')
                    this.saving = false
                }
            }

            Object.keys(this.settings).forEach(key => {
                if(SINGLE_VALUE_SETTINGS.includes(parseInt(key))) {
                    saveCount++
                    this._saveSingleValue(key).finally(() => count())
                } else if(parseInt(key) === PEOPLE_MULTI) {
                    Kiwi.request()
                        .post('/api/db/delete-global-settings', {type_id: PEOPLE_MULTI, place_id: this.tableSetup.selectedPlace.id})
                        .then(() => {
                            this.peopleModifiers.forEach(modifier => {
                                saveCount++
                                Kiwi.request().post(
                                    '/api/db/create-global-settings',
                                    {
                                        type_id: PEOPLE_MULTI,
                                        place_id: this.tableSetup.selectedPlace.id,
                                        value: modifier.multiplier,
                                        option_1: modifier.min,
                                        option_2: modifier.max
                                    }
                                ).finally(() => count())
                            })
                        })
                }
            })

        },

        _saveSingleValue(type_id) {
            let data = {
                type_id,
                place_id: this.settings[type_id]['place_id'],
                value: this.settings[type_id]['value'],
                option_1: null,
                option_2: null
            }

            return Kiwi.request().post('/api/db/update-global-settings', data)
        },

        open() {
            this.load()
            this.$refs.modal.show()
        }
    },

    watch: {
        'tableSetup.selectedPlace.id': function () {
            if(this.$refs.modal.isShow) {
                this.load()
            }
        }
    }
};

class ReservationSetting {
    constructor() {
        this.place_id = null
        this.type_id = null
        this.value = null
        this.option_1 = null
        this.option_2 = null
    }

    static parse(params = {}) {
        let object = new this

        object.place_id = params.place_id
        object.type_id = params.type_id
        object.value = params.value
        object.option_1 = params.option_1
        object.option_2 = params.option_2

        return object
    }
}

class ReservationModifier {
    constructor(min = 0, max = 0, multiplier = 1) {
        this.min = parseInt(min)
        this.max = parseInt(max)
        this.multiplier = parseFloat(multiplier)
    }
};
    config.template = `<div>
    <button type="button" class="card btn-light btn-block h-100" @click="open()">
        <span class="card-icon">
            <icon main="fa fa-cog"></icon>
        </span>
        <span class="card-header">{{ __('ts.global_settings') }}</span>
        <span class="card-body text-left">
            {{ __('ts.global_settings_short_description') }}
        </span>
    </button>
    <!--<button type="button" class="btn btn-light" @click="open()">{{ __('ts.global_settings') }}</button>-->

    <b-modal ref="modal" size="full" hide-header :ok-title="__('common.close')" ok-only ok-variant="light" hide-footer>
        <div class="d-flex justify-content-between align-items-center mb-5">
            <h5>{{ __('ts.global_settings') }}</h5>
            <div>
                <tables-place-switcher
                        v-if="tableSetup.places.length > 0"
                        v-model="tableSetup.selectedPlace"
                        :places="tableSetup.places"
                />
            </div>
        </div>

        <div class="alert alert-info" v-show="loading"><i class="fa fa-spinner fa-spin mr-2"></i> {{ __('common.loading') }} ...</div>

        <div class="alert alert-primary">
            <p>
                {{ __('ts.global_settings_top_info') }}
            </p>

            <a href="" class="btn btn-primary" @click.prevent="tableSetup.openDefaultsModal()">{{ __('ts.default_settings') }}</a>
            <a href="" class="btn btn-primary" @click.prevent="$root.$emit('tablesCustomParams.open')">{{ __('ts.scheduled_settings') }}</a>
        </div>

        <form @submit.prevent="save()" class="" v-if="! loading && Object.keys(settings).length > 0">
            <!--
            <div class="row mt-3 pb-3 border-bottom">
                <div class="col-12 col-md-7">
                    <p class="mb-1 font-weight-bold text-gray-800">Szabad helyek ellenőrzése</p>
                    <p class="text-gray-700">
                        A rendszer foglaláskor képes automatikusan ellenőrizni a szabad férőhelyeket, ha ezt kikapcsolja,
                        akkor a foglalásokat kézzel kell jóváhagyni.
                    </p>
                </div>
                <div class="col-12 col-md-3 offset-md-2 d-flex align-items-center">
                    <select v-model="settings[1]['value']" class="form-control">
                        <option value="1">Automatikus</option>
                        <option value="0">Manuális</option>
                    </select>
                </div>
            </div>
            -->
            <div class="row mt-3 pb-3 border-bottom">
                <div class="col-12 col-md-7">
                    <p class="mb-1 font-weight-bold text-gray-800">{{ __('ts.min_reservation_time') }}</p>
                    <p class="text-gray-700">
                        {{ __('ts.min_reservation_time_desc') }}
                    </p>
                </div>
                <div class="col-12 col-md-3 offset-md-2 d-flex flex-column justify-content-center">
                    <div class="input-group">
                        <input type="number" v-model="settings[101]['value']" class="form-control" required min="5" />
                        <div class="input-group-append"><span class="input-group-text">{{ __('common.minutes') }}</span></div>
                    </div>
                    <div class="text-gray-700">
                        ~ {{ moment().add(settings[101]['value'], 'minute').fromNow(true) }}
                    </div>
                    <div>
                        <a href="" class="btn btn-sm btn-light mr-1" @click.prevent="settings[101]['value'] = 180"><i class="fa fa-magic"></i> 3 {{ __('common.hours') }}</a>
                        <a href="" class="btn btn-sm btn-light mr-1" @click.prevent="settings[101]['value'] = 720"><i class="fa fa-magic"></i> 12 {{ __('common.hours') }}</a>
                        <a href="" class="btn btn-sm btn-light mr-1" @click.prevent="settings[101]['value'] = 1440"><i class="fa fa-magic"></i> 24 {{ __('common.hours') }}</a>
                        <a href="" class="btn btn-sm btn-light mr-1" @click.prevent="settings[101]['value'] = 2160"><i class="fa fa-magic"></i> 36 {{ __('common.hours') }}</a>
                    </div>
                </div>
            </div>
            <div class="row mt-3 pb-3 border-bottom">
                <div class="col-12 col-md-7">
                    <p class="mb-1 font-weight-bold text-gray-800">{{ __('ts.max_reservation_people') }}</p>
                    <p class="text-gray-700">
                        {{ __('ts.max_reservation_people_desc') }}
                    </p>
                </div>
                <div class="col-12 col-md-3 offset-md-2 d-flex flex-column justify-content-center">
                    <div class="input-group">
                        <input type="number" v-model="settings[105]['value']" class="form-control" required min="1" max="200" />
                        <div class="input-group-append"><span class="input-group-text">{{ __('common.number_of_people_short') }}</span></div>
                    </div>
                </div>
            </div>
            <div class="row mt-3 pb-3">
                <div class="col-12 col-md-7">
                    <p class="mb-1 font-weight-bold text-gray-800">{{ __('ts.max_reservation_time') }}</p>
                    <p class="text-gray-700">
                        {{ __('ts.max_reservation_time_desc') }}
                    </p>
                </div>
                <div class="col-12 col-md-3 offset-md-2 d-flex flex-column justify-content-center">
                    <div class="input-group">
                        <input type="number" v-model="settings[102]['value']" class="form-control" required min="1" step=".5" />
                        <div class="input-group-append"><span class="input-group-text">{{ __('common.day') }}</span></div>
                    </div>
                    <div class="text-gray-700">
                        ~ {{ moment().add(settings[102]['value'], 'day').fromNow(true) }}
                    </div>
                    <div>
                        <a href="" class="btn btn-sm btn-light mr-1" @click.prevent="settings[102]['value'] = 90"><i class="fa fa-magic"></i> 3 {{ __('common.months') }}</a>
                        <a href="" class="btn btn-sm btn-light mr-1" @click.prevent="settings[102]['value'] = 180"><i class="fa fa-magic"></i> {{ __('common.half_year') }}</a>
                        <a href="" class="btn btn-sm btn-light mr-1" @click.prevent="settings[102]['value'] = 365"><i class="fa fa-magic"></i> {{ __('common.one_year') }}</a>
                    </div>
                </div>
            </div>

            <div>
                <h5>{{ __('ts.setup_multipliers') }}</h5>

                <div class="row mt-3 pb-3 ">
                    <div class="col-12 col-md-6">
                        <p class="mb-1 font-weight-bold text-gray-800">{{ __('ts.number_of_people_multiplier') }}</p>
                        <p class="text-gray-700">
                            {{ __('ts.number_of_people_multiplier_desc') }}
                            <a href="" @click.prevent id="peopleMultiplierExample" style="text-decoration: underline dotted">{{ __('common.example') }}</a>
                            <b-tooltip target="peopleMultiplierExample" custom-class="tooltip-lg" :boundary-padding="0">
                                <span>
                                    {{ __('ts.example_desc') }}
                                </span>

                                <img
                                    src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAxYAAAEQCAMAAAAaphKhAAABL1BMVEX////t8vbL1eBKVWhxgJZlb35xe4r7+/ytsrtjbn/09vjV3ObS2uR0g5j6+vtbZXXw8vXt8PTP1NxTXnD8/f3p6+3y8/Xk5urh5u3Z3uRNWGq4vcaqsr/a4enZ4OhibHtWYXP3+PnM0dmDkKPl6vDX3ufR2eOapbWAjaF3hpvU2eDIzdWVoLF6h5ymr73d4OSepK9ocYHW2Nze4+iutcKboazs7vDR1dzEytSzusVganvp7vLX3OPb3ODCx9CnrLaRnK6Hk6Z1hJl1fYtdZ3j29vjP0te5wMueqLejqbOLl6nm6ey9w86PlqKIj5uFjJlQW23z9Pbq7vKpr7iXnqmTmqV6gpCOmauBiJXh5OivtL2irLqxt8GNk599hZO+w8p8ip5vd4ZqdIN3gI7m6/DFGNk0AAAQbUlEQVR42uzcTU8aURSA4cM5QShDGFHSIgakRlnYhVCjVql1gZoYK5r6EWOqC9v//xtKqK7MzFDGFO7lfRfObD33PoFhGISIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIaKzmq0FLibyuFVTnZfS6RSWaiYpdGa1SQ3X9dyEnnqSaSZmqeJcq08gV1tZVGyPt9EJRg7J4FCxgEV050GJBEisVtV4Rn4IFLGKq1LWYk6QaWhe/ggUsYqtrQxLqauDXawUsYJFQJdAfEl9RvbqugAUskitrUWLL6Lr4FixgkdC6zktcVV0T34IFLBJa06rEFWhBfAsWsEiooIHE1VJv7uLBAhajVtKWxOXhvwwLWCSmCgs2AixgAQtYwAIWsIAFLGABC1hMfCp+TgMWbARYwAIWsIAFLGABC1jAAhawmPhU/JwGLNgIsIAFLGABC1jAAhYTZzF/5uTD77DwgMWHm5XbaWRx9rBiVns8EOdKwyJhnRzMSRb3WTPLTiGL5UWrzQ1g2Im4VhoWCevkYE6y6Debl1PJ4q529VHkoGfNkjhW5FS+X/89ls8/RU0jbp1g8T/LTyWL48/Dw6aZc2+joqZS7tj28OTcemNcW+RhEdtMsHiuZPZNHCtyKlv71h4cbuypCgtYpGBxYrYpjhU9lfq+nWaurVPNwAIW47PYmbOeuFbMVBpH9suy1QwsYDEui93l7dD678W14qaytGjhVgYWsBiXxbENyot7xU2lbWZ5WMwmi9t3r1v9141Qerh7Z5dt936LMYbFqe1/Ce0nLGaSxcXc6xbGubbY7Fi4I44VzeLKjpYyG03bg8UssnjDD2g7di6OFTmVvIVfB4eFZm0ZFrBIwULatiKOFXk7b665MTxZXXyEBSzSsNizUBwrciprG88nC11YwGIMFpV8SYb1PXoT9RKfRMFivI1waE+bMujepy9/wMIRFodhGC5abfD3cLpY7PTMmhf9rNm2uFYqFsnr5FgusmjbS+3pYiGVq96lmWWXxblSsUheJ8dykcVUP7SaO9h1714eD63Cgp84gAUsYAELWMACFrCAxcSn4uc0YMFGgAUsYAELWMACFrCABSxgAYuJT8XPacCCjQALWMACFrCABSzemkVLc+JbsIBFQiVtSVyBOvl1UFjAIk0FDSSu6h/27iDFQSAIoGhTG8FugoEsstGV5hLewjPM/c8wMIuB4Iya7NK+d4b6hIBdFWOqjSxksWOMe9rSxZRqIwtZ7JiiS5tKXFNlZCGLbdcoadsc+SMvJMpCFu9qcixpxxB9qossZLGpj2E/nRJ9Xb8XspDFhqaP0qRdbYlc1f8LWcjif9ccpT2UzxAxje3H3Q6VhSxec2nHKWJo0jFLCTiFsqTjunt+BFTtke9dAgAAAAAAAAAAAAB8WM55vfhh+ewZEidR5nTMZYiYvtpqltF6tOrR6t+a30erVhycehBk8eaKg4uFOJUPgiye3H4W4lifdvpBkMV6fZplmwZBFk9uOZZkNbNBkMVqNbNF/gZBFqtF/s6+GARZrM6+OBJmEGSxOhLmpKRBkMXqpKQDxAZBFu5yy0IWspCFLL7Zt6OetMEojOPHPCnKTTttxFmyUc2u5AKKKTo254VIYjYEoxAkKtF9/++wRmqcGshY2ngOef4XwvWT9ydQKFmQBVmQBVm8+yrLuQZZ8CCQBVmQBVmQBVmQBVmQBVmQBVm8+yrLuQZZ8CCQBVmQBVmQBVmQBVmQBVmQBVm8+yrLuYZRFu5J5UEbi0bluSOxVT4stgaVobzIraTdi+LMsogBXxuLDp6ria3yYDF2ADjyoibSQlGcVRYNePpYuJtpPXTFWDNX+XU1fVzvVhdlcR6G/dcsrhGkI4nijLJwHYz1sXiqhra5W+BnrbIeIX580sXJf6yx9ppFA23Rn1EWMUY1vSxO0BFrzVxlv4V68jDAw8csWBxC9YcK0ywa8DcballMcCvmmr3KpxbOVq4QJSoyYFHGSPRnkoXroCxqWZx65j5vz1/lcxu/4SQqsmAxRtc9OtD+HtMkixgj0cuijILYa94q2z68/ZVsWJyh6AOIfojmLLJoIGwqZnGHidhr3ip1AGuZsfBvL+MIQVkUZ5DFThETyYHFsPi23cUPwkUQuGKvOSzO0Dr0cJMNC5msi8jqANgSvRlkcYVzyYNFr/C2jcUPwsTEpZYFWFyivb2yF+JrJizS3BY0v1zYY1EDokJShKBQqOp7E9XDQAw2c5U1eN+Th40wKGfIQm5VX66zx6KDvyrrY9FW/W9w8a/zCuHe45Nd/y5LFrHqCxP2WKyWplXhl0quOhargLVfCc5f5cte+mTjW5YsRuiJ3uyxmKb2StRPQPWvfbJaZXEWHySpWU1n6uNG9EYWGR+EA2BHDJY7i3FQTIYZol4Ska17tE9Fb2SR8UGYoC8Wy4HFsed5PoLk77GIREBVpBoCUXfYh6P6NZUsMmZxjJZYLAcWdTxVF5EYfklEml0HQNj7IJqzy4I3rSpZ5V/XOLqQaReda1EeWZAF7+UmC7IgC7IgC7IgC7IgC7IgCwWrLOcaZMGDQBZkQRZkQRZ/2LmD1AhhMAzDP98mkARRcOFGV8ZLeAvP0PufobvC0Dax05aZ+X2fI0heRDAfWZAFWZAFWZAFWTz8qfh8GmTBQSALsiALsvhlFpuCeUMWZNHQabOapGfffyMLI4u/FpWsZtJq3pAFWTSsmqymVzFvyIIsGop6q8oazBmyIIu6QdnqdqXRfCELsqgKSYc1LJrNF7Igi6pZSzudrNnX+4IsyKIizMrBmmJWcvV9QRZk8b0hKcdT+SxSWeMrrtOTBVn8QBfXIi3BzjmygEvIh53XT2kT4NqWpudedQMAAAAAAAAAAAAAAAAAAAD+AT+WA/f/WL5zDQkXkXc7p1uk8hbdjNFyaZVLq18LH5dWmTi49EEgizsnDjoGcZwfBLK4Mc7KwZhPu/xBIIvP82mMbXIQyOLGmHQY08wcBLJ4Z+9Om5OGwjAMP/q+GmUmLJKAAVQWZwh7K12gUgp0gQJamVaxtmrV//8fTALVIDOKCnrSOfeHnrRp+XDmXENSIJm7NLO8kL9cCJLF3IX85W1f5EKQLOZu+yJvEiYXgmQxd5MweUtJuRAki7lbSsobEMuFIFnI+3JLFpKFZCFZSBaShWQhWUgWksV/n5WbORuShVwIkoVkIVlIFpKFZCFZSBaShWQhWUgW/31WbuZsSBarXQhKIoLFGyUULJYws3Iz14hksdqFUOa+trihFvewUOLMys1cI5LFShfCkNXt3zF0FcVP0vMKJokzKzdzjXiThT+qiMginQ5hpm3u5LFw3V+oCKpcx7c8y2IQgeB5k0X8U4xi+7visVD5AdzpnU4Dkxq1IH5Rnk0dP0tnTuBbHmARff3kDWbbenFAdCcOofMki2OiT2f7FDsSnoVyYWBakQ38Il9Wx8/bHo7wPdFZvLtDlgDMFFmng5PPRGcQOS+y2KXwLoBT2lFEZ+GqzwYEbhUsXiaTr35k8YlO/MBRmD5C4LzIYo82YXeHKh5iYXqUxfBsMoZeFP7g3OLeDywGlBzBKk4HIn/u04ssXtLpdGwKzuK83M70agD83Q2Vs4nEJYBUt2WOE4a9lbguBGDQ7WXaF1XYhRJNHDaL7Q0DwPaFWSzAaSNxDjt/s2e2LxJWgxWzCK3TprPxgvaXwCJOJ7BTArQNcfMiizjtw26dzsVm8YBZLTFnU/DxpBLgy1iDypwAInydjtAFO6nOA0S5r7edb6NKj+3qsMtNHt/X4lLLZLv8qp8tqju0Zg2v6fPDJbA4o004ndAxxM2LLIIxugQQpXWxT7kbaq7ghz7mOjRjm3loGBWgzO0qlEa/ASiGXb5kEwl2+gVdqbTYVBwWuVI7HWxkuN8qDbeiRe5EXCzGnD0EupYdPbXyc4tHO3R864zWLRV/z2KPXsLp2NoQNy+yQOEVvd09XI89E5pFKMcNWEU6uRGQYjZgl+ECZqpzJmVLgN3W5BGizEUfAAuTGZ28YJH+ziLInRGsWpz/F6fcjw/oC92xVCyBxUcK+GGl79AHiJsnWeCUiAKxptivW3Q5C6cLzrtYtLgOdxXmCr7X5+6ERRBw/irt+vGURZr7U1D1VbNwMsIUqN5aCovDA3rvB3Z3XtFdiJsnWezF3myGiV6nhGbR4qnbODddLJrM5S18K5Vxre2tfNfkxIRFBHadKYsib3xnsc1t2G3w8J+wWCOie8thgWaMkl926MOpfLZYcu/orR+HpzHa15a5AN7cny/9FyxMvjKdSlx3sUCXmbMNTEtwW4GTfnnFzCqX3SxKUxZZN4sRqzoArc3n/4LFMe3UAnS5HBaovD2I7d/T9ug9xM2DLAaxV4fO/AZob5kL4OTufA/+gsUVt4vTCm4WGCQ6Fgwf7BqsRuEUZ27Vzv3ZBVhgg/s6UmXu4x+wOKUD41Y+SfVlsHDSALymTYibB1nE6S2cNumuyAdRffchjpsF4Ot2uOVsmNyFU5NLzv6FWGgZZlPl1uE/YHGPAg1reJCMxZfEwukOFSBuHmSxRmtwOqKwyCwuuDfP4jqDOej8zliD05hrWJhFnGu1ctdQsHoWobvJvLORDn9YIotzepWCuHmQxdH1k0SdvojMIs9cndlVw/e0Dlect53r33bnYddagIWS68Odb25Y4qw8zU83Hjz/OxZBuHor9KmFF1koYTqGlR6geyKzQJkzjovqOazanNUARNqOjjTnFESueIhpGc4CCBZ5ARYh7kTc/8tSa7ODKG8VnGHxLnY/BeD0TAGCrym8BYHzIAscJenT8eVZmF76xWPB6qQ0oPWYixvlMY9hNWQ2E0V/QeXMRbzF3AWs/WbGKW3vbm8UO1cLHUSNuVTs9XqJuM1um3k8OwjCYi8QCIQpZn3dA7BOVAC2khQ42Y9R+Agi50UWiL4JE9HOsYgv511XAKBdlphZzZ7DSimzVRWDbM4aTXt/hq+rQaurzKWy78EiLKJ8XU9DJMdxwD0IwmKNrlsDsEnhCAD9TYyIPuxC6DzJAtAqR0ERP7T6Y/5ofqBgWrBhjGCl6Y0I5hsZUQ0LtZVphwbVaqXQY84Dh1EArkGYz1vMtjuCk//ZkdAHUB5m4Z1LHKyiMhtw8ps8/O+zcvtGrhHJ4ms7d6wSMRBFYfhyGAhkxpCAQkCSwk2C4FqtnbKFlfW2Nr7/UyiKnU62EJJc/+8RDvcnBEI2dwhvobYvt+Fm8VXk8kbIYnOH8P214eVD2BWLryKXN0IWmzuEp+ewez3eXe/Cvl5+Fbm8EbLY3iEcXi5CCPf74xpWWXyNT2RBFmbV1aFZySorWOMDWZCF2YpW8bkGWXAIZEEWZEEWZEEWZEEWZEEWZEEWi6/icw3LmbTmP4WSxRpWcbhGpclyokrzhizIYkapaDmtBvOGLMhixqDWcmqN5g1ZkMWMUbVlJTXmDFmQRV6jZHmPipfmC1mQRVYRdbIZvTrzhSzIIqtTP59OUufreUEWZJFRdEqFzSqToqv3C7Igi981Uak8K59eGoeyMifIgix+VpXDKPWFneeUBPwL6WTnq9s4CXBtim1tAAAAAAAAAAAAAAAAAAAAAAAAAADgT7wDhuD3YiJfq2oAAAAASUVORK5CYII="
                                    class="img-fluid mt-2 rounded"
                                >
                            </b-tooltip>
                        </p>
                    </div>
                    <div class="col-12 col-md-4 offset-md-2 d-flex flex-column justify-content-center align-items-start">
                        <div class="d-flex align-items-center w-100">
                            <div class="form-control font-weight-bold border-0 bg-transparent">{{ __('ts.number_of_people_multiplier_from') }}</div>
                            <div class="px-2"></div>
                            <div class="form-control font-weight-bold border-0 bg-transparent">{{ __('ts.number_of_people_multiplier_to') }}</div>
                            <div class="px-2"></div>
                            <div class="form-control font-weight-bold border-0 bg-transparent">{{ __('ts.number_of_people_multiplier_multiplier') }}</div>
                            <div class="px-2 invisible"><i class="fa fa-trash-alt"></i></div>
                        </div>
                        <div class="input-group mb-2" v-for="(modifier, index) in peopleModifiers">
                            <input type="number" :min="peopleModifierMinValue(modifier, index)" class="form-control text-right" :placeholder="__('ts.number_of_people_multiplier_from') +'...'" v-model.number="modifier.min" required>
                            <div class="input-group-append"><span class="input-group-text border-right-0">&mdash;</span></div>
                            <input type="number" :min="modifier.min" class="form-control" :placeholder="__('ts.number_of_people_multiplier_to') +'...'" v-model.number="modifier.max" :required="index < (peopleModifiers.length - 1)">
                            <div class="input-group-append"><span class="input-group-text border-right-0">&times;</span></div>
                            <input type="number" min="0" step=".01" class="form-control" :placeholder="__('ts.number_of_people_multiplier_multiplier') + '...'" v-model.number="modifier.multiplier" >
                            <div class="input-group-append">
                                <button
                                        @click.prevent="peopleModifiers.splice(index, 1)"
                                        :disabled="peopleModifiers.length === 1"
                                        class="btn btn-sm btn-danger text-white"
                                        type="button"
                                ><i class="fa fa-trash-alt"></i></button>
                            </div>
                        </div>
                        <button type="button" class="btn btn-sm btn-primary text-white mt-2" @click.prevent="addPeopleModifier()">
                            <i class="fa fa-plus"></i> {{ __('ts.number_of_people_multiplier_new_line') }}
                        </button>
                    </div>
                </div>
            </div>

            <div class="mt-3">
                <button type="submit" class="btn btn-primary text-white" :disabled="saving">
                    <i class="fa fa-spinner fa-spin" v-show="saving"></i> {{ __('common.save') }}
                </button>
                <button type="button" @click.prevent="$refs.modal.hide()" class="btn btn-secondary" :disabled="saving">
                    <i class="fa fa-spinner fa-spin" v-show="saving"></i> {{ __('common.close') }}
                </button>
            </div>
        </form>
    </b-modal>
</div>`;

    Vue.component('tables-global-settings', config);
    window.Kiwi.components.registerCustom('tables-global-settings', 'tables-global-settings');

    }).call();
(function() {
    const config = {
    data() {
        return {
            config: null
        }
    },
    mounted() {
        Kiwi.request().post('/api/db/{CONFIG_API_NAME}').then(response => {
            this.config = JSON.parse(response.data.default[0].group_config_9)
        })
    }
};
    config.template = `<div style="old-background:#fff;padding:.5rem">
	<kiwi-form v-if="config" no-config :override="config" />
</div>`;

    Vue.component('sablon-reservation-form', config);
    window.Kiwi.components.registerCustom('sablon-reservation-form', 'sablon-reservation-form');

    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-leads-list-collectings-2', 'items': [{'id': 'crud-leads-list-collectings-2-widget', component: 'crud', data: {'id': 'crud-leads-list-collectings-2'}}]}"></grid>
</app>`;

    Vue.component('module-leads-list-collectings-2', config);
    window.Kiwi.components.registerCustom('module-leads-list-collectings-2', 'module-leads-list-collectings-2');

        window.Kiwi.navigation.push({path: '/leads-list-collectings-2', label: 'modules.leads-list-collectings-2'});
    window.Kiwi.router.addRoutes([{path: '/leads-list-collectings-2', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {
    data() {
        return {
            places: [],
            formLanguages: ['en', 'de', 'hu'],
            selectedLanguage: 'en',
            selectedPlace: {},
            data: {
                color: '',
                allergies: false,
                purpose: false,
                privacy: ''
            },
            formConfig: '',
            formRoutePath: '',
            formKey: 0,

            loading: false,
            parsed: false
        }
    },
    methods: {
        init() {
            this.getFormConfig()
        },
        getFormConfig() {
            this.loading = true
            this.parsed = false
            this.formConfig = ''
            this.formRoutePath = ''

            Kiwi.request().get('/api/db/get-form-settings').then((response) => {
                this.formConfig = response.data.default[0]['config']
                this.formRoutePath = response.data.default[0]['route_path']

                this.parseConfig()
            }).finally(() => this.loading = false)
        },

        parseConfig() {
            let config = JSON.parse(this.formConfig)

            this.data.color = config.primary_color

            config.fields[0].forEach(field => {
                if(field.name === 'adatvedelem') {
                    this.data.privacy = field.attrs.url
                } else if(field.name === 'purpose') {
                    this.data.purpose = field.visible !== false
                } else if(field.name === 'allergen') {
                    this.data.allergies = field.visible !== false
                }
            })

            this.parsed = true
        },
        
        overrideConfig() {
            let config = JSON.parse(this.formConfig)

            config.primary_color = this.data.color

            config.fields[0].forEach(field => {
                if(field.name === 'adatvedelem') {
                    field.attrs.url = this.data.privacy
                } else if(field.name === 'purpose') {
                    field.visible = this.data.purpose
                } else if(field.name === 'allergen') {
                    field.visible = this.data.allergies
                }
            })

            this.formConfig = JSON.stringify(config)
            this.formKey = ! this.formKey
        },

        save() {
            let data = {
                place_id: this.selectedPlace.id,
                noquote_config: this.formConfig
            }

            Kiwi.request().post('/api/db/update-form-settings', data).then(response => {
                this.$toasted.success('The embed form settings has been saved.')
            })
        }
    },
    computed: {
        embedCode() {
            let url = window.location.origin + '/' + this.formRoutePath + '?lang=' + this.selectedLanguage
            return '<iframe src="'+ url +'" width="900" height="1200" frameborder="0" />'
        }
    },
    watch: {
    },
    beforeMount() {
        this.init()
    }
};
    config.template = `<app>
    <div class="row">
        <div class="col-12 col-md-3 mt-3">
            <div class="card">
                <div class="card-header">{{ __('Embed Form Settings') }}</div>
                <div class="card-body" v-if="parsed && ! loading">
                    <form @submit.prevent="save">
                        <div class="form-group mb-4">
                            <label class="font-weight-bold">{{ __('Primary Color') }}</label>
                            <input type="color" v-model="data.color" class="form-control" @change="overrideConfig">
                        </div>
                        <div class="form-group mb-4">
                            <label class="font-weight-bold">{{ __('Optional Fields') }}</label>

                            <b-form-checkbox v-model="data.allergies" @change="overrideConfig">
                                {{ __('Allergies Field') }}
                            </b-form-checkbox>

                            <b-form-checkbox v-model="data.purpose" @change="overrideConfig">
                                {{ __('Purpose Field') }}
                            </b-form-checkbox>
                        </div>
                        <div class="form-group mb-4">
                            <label class="font-weight-bold">{{ __('Your Privacy Policy URL') }}</label>

                            <input type="text" class="form-control" v-model="data.privacy" @change="overrideConfig" />
                        </div>
                        <div class="form-group mb-4">
                            <button class="btn btn-primary text-white" type="submit">{{ __('Save Changes') }}</button>
                        </div>
                        <div class="form-group mb-4">
                            <label class="font-weight-bold">{{ __('Your Embed Code') }}</label>
                            <p>{{ __('Your Embed Code Help') }}</p>

                            <div class="d-flex align-items-center flex-wrap mb-1">
                                <span class="col-9 col-sm-9 col-md-12 col-xl-8 p-0">{{ __('Form Language') }}:</span>
                                <select class="form-control col-3 col-sm-3 col-md-12 col-xl-4" style="appearance: auto" v-model="selectedLanguage">
                                    <option :value="lang" v-for="lang in formLanguages">{{ __('languages.'+ lang) }}</option>
                                </select>
                            </div>
                            <textarea class="form-control" rows="3" readonly="readonly" :value="embedCode"></textarea>
                        </div>
                    </form>
                </div>
                <div class="card-body" v-else>
                    <b-skeleton animation="wave" width="85%"></b-skeleton>
                    <b-skeleton animation="wave" width="55%"></b-skeleton>
                    <b-skeleton animation="wave" width="70%"></b-skeleton>
                </div>
            </div>
        </div>
        <div class="col-12 col-md-9 mt-3">
            <div class="card">
                <div class="card-header d-flex align-items-center justify-content-between">
                    <div>{{ __('Embed Form Preview') }}</div>
                </div>
                <div class="card-body" v-if="parsed && ! loading">
                    <p class="text-gray-700">{{ __('Embed Form Preview Description') }}</p>
                    <kiwi-form :data="formConfig" :key="formKey" v-if="formConfig.length" no-config :override="{primary_color: data.color}"></kiwi-form>
                </div>
                <div class="card-body" v-else>
                    <b-skeleton animation="wave" width="85%"></b-skeleton>
                    <b-skeleton animation="wave" width="55%"></b-skeleton>
                    <b-skeleton animation="wave" width="70%"></b-skeleton>
                </div>
            </div>
        </div>

        <div class="col-12 mt-3">
            <div class="card">
                <div class="card-header">{{ __('tv.reservation_purposes') }}</div>
                <div class="card-body">
                    <crud :data="{id: 'crud-leads-list-collectings-3'}"></crud>
                </div>
            </div>
        </div>
    </div>
</app>`;

    Vue.component('tables-form-configurator', config);
    window.Kiwi.components.registerCustom('tables-form-configurator', 'tables-form-configurator');

        window.Kiwi.navigation.push({path: '/embed-form', label: 'My Embed Form'});
    window.Kiwi.router.addRoutes([{path: '/embed-form', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {
    inject: ['form'],
    props: {
        value: {
            type: Number,
            default: null
        },
    },
    data() {
        return {
            loading: false,
            attributes: {
                max: 10
            },
            settings: [],
            key: 0,
        }
    },
    methods: {
        load() {
            this.loading = true

            Kiwi.request().get('/api/db/get-guests-limit?owner_id='+ this.$attrs.owner_id).then((response) => {
                this.settings = response.data.default
                this.updateField(this.form.place_id)
            }).catch(() => {
                this.attributes = {
                    max: 10,
                }
            }).finally(() => this.loading = false)
        },
        updateField(placeId) {
            console.log('place', placeId);
            if(placeId) {
                this.settings.forEach(setting => {
                    console.log('place', parseInt(setting.place_id), parseInt(placeId));
                    if(parseInt(setting.place_id) === parseInt(placeId)) {
                        console.log('place id, max', placeId, setting.max);
                        this.attributes = {
                            max: parseInt(setting.max),
                        }
                    }
                })
            }

            this.key++
        },
        handleInput(event) {
            this.$emit('input', event)
            this.$emit('change', event)
        },
        checkErrors: function() {
            let value = parseInt(this.value);
            console.log('check errors', value, this.attributes.max, value > this.attributes.max);

            if(! this.value || value < 1) {
                this.$emit('update:errors', [this.__('Number of People required.')]);
                return true
            }

            if(value > this.attributes.max) {
                this.$emit('update:errors', [this.__('Number of People Limit') + ': '+ this.attributes.max]);
                return true
            }

            this.$emit('update:errors', []);
            return false
        }
    },
    watch: {
        'form.place_id': {
            handler(placeId) {
                this.updateField(placeId)
            },
            deep: true
        }
    },
    beforeMount() {
        this.load()
    }
};
    config.template = `<number
        integer
        unsigned
        min="1"
        v-if="! loading"
        v-bind="attributes"
        :value="value"
        @input="$emit('input', $event)"
        @change="$emit('change', $event)"
        ref="field"
        :key="key"
></number>
`;

    Vue.component('tablev-max-people', config);
    window.Kiwi.components.registerCustom('tablev-max-people', 'tablev-max-people');

    }).call();
(function() {
    const config = {
    data() {
        return {
            config: null
        }
    },
    mounted() {
        Kiwi.request().post('/api/db/reservation-form-owner-39').then(response => {
            this.config = JSON.parse(response.data.default[0].group_config_9)
        })
    }
};
    config.template = `<div style="background:#F0ECE2;padding:.5rem">
	<kiwi-form v-if="config" no-config :override="config" />
</div>`;

    Vue.component('reservation-form-owner-39', config);
    window.Kiwi.components.registerCustom('reservation-form-owner-39', 'reservation-form-owner-39');

        window.Kiwi.navigation.push({path: '/reservation-form-35', label: ''});
    window.Kiwi.router.addRoutes([{path: '/reservation-form-35', component: config, meta: { auth: false }}]);
    }).call();
(function() {
    const config = {
    data() {
        return {
            config: null
        }
    },
    mounted() {
        Kiwi.request().post('/api/db/reservation-form-owner-11').then(response => {
            this.config = JSON.parse(response.data.default[0].group_config_9)
        })
    }
};
    config.template = `<div style="background:#fff;padding:.5rem">
	<kiwi-form v-if="config" no-config :override="config" />
</div>`;

    Vue.component('reservation-form-owner-11', config);
    window.Kiwi.components.registerCustom('reservation-form-owner-11', 'reservation-form-owner-11');

        window.Kiwi.navigation.push({path: '/erhardt-reservation-form', label: ''});
    window.Kiwi.router.addRoutes([{path: '/erhardt-reservation-form', component: config, meta: { auth: false }}]);
    }).call();
(function() {
    const config = {
    data() {
        return {
            config: null
        }
    },
    mounted() {
        Kiwi.request().post('/api/db/reservation-form-owner-40').then(response => {
            this.config = JSON.parse(response.data.default[0].group_config_9)
        })
    }
};
    config.template = `<div style="background:#fff;padding:.5rem" class="gundel-reservation-form">
	<kiwi-form v-if="config" no-config :override="config" />
</div>`;

    Vue.component('reservation-form-owner-40', config);
    window.Kiwi.components.registerCustom('reservation-form-owner-40', 'reservation-form-owner-40');

        window.Kiwi.navigation.push({path: '/reservation-form-40', label: ''});
    window.Kiwi.router.addRoutes([{path: '/reservation-form-40', component: config, meta: { auth: false }}]);
    }).call();
(function() {
    const config = {
    data() {
        return {
            config: null
        }
    },
    mounted() {
        Kiwi.request().post('/api/db/reservation-form-owner-42').then(response => {
            this.config = JSON.parse(response.data.default[0].group_config_9)
        })
    }
};
    config.template = `<div class="new-york-form" style="background:#fff;padding:.5rem">
	<kiwi-form v-if="config" no-config :override="config" />
</div>`;

    Vue.component('reservation-form-owner-42', config);
    window.Kiwi.components.registerCustom('reservation-form-owner-42', 'reservation-form-owner-42');

        window.Kiwi.navigation.push({path: '/reservation-form-42', label: ''});
    window.Kiwi.router.addRoutes([{path: '/reservation-form-42', component: config, meta: { auth: false }}]);
    }).call();
(function() {
    const config = {};;
    config.template = `<app>
	<grid :data="{id: 'grid-leads-list-collectings-3', 'items': [{'id': 'crud-leads-list-collectings-3-widget', component: 'crud', data: {'id': 'crud-leads-list-collectings-3'}}]}"></grid>
</app>`;

    Vue.component('module-leads-list-collectings-3', config);
    window.Kiwi.components.registerCustom('module-leads-list-collectings-3', 'module-leads-list-collectings-3');

        window.Kiwi.navigation.push({path: '/leads-list-collectings-3', label: 'modules.leads-list-collectings-3'});
    window.Kiwi.router.addRoutes([{path: '/leads-list-collectings-3', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {
    data() {
        return {
            config: null
        }
    },
    mounted() {
        Kiwi.request().post('/api/db/reservation-form-owner-44').then(response => {
            this.config = JSON.parse(response.data.default[0].group_config_9)
        })
    }
};
    config.template = `<div style="background:#fff;padding:.5rem">
	<kiwi-form v-if="config" no-config :override="config" />
</div>`;

    Vue.component('reservation-form-owner-44', config);
    window.Kiwi.components.registerCustom('reservation-form-owner-44', 'reservation-form-owner-44');

        window.Kiwi.navigation.push({path: '/reservation-form-44', label: ''});
    window.Kiwi.router.addRoutes([{path: '/reservation-form-44', component: config, meta: { auth: false }}]);
    }).call();
(function() {
    const config = {
    data() {
        return {
            config: null
        }
    },
    mounted() {
        Kiwi.request().post('/api/db/reservation-form-owner-45').then(response => {
            this.config = JSON.parse(response.data.default[0].group_config_9)
        })
    }
};
    config.template = `<div style="old-background:#fff;padding:.5rem">
	<kiwi-form v-if="config" no-config :override="config" />
</div>`;

    Vue.component('reservation-form-owner-45', config);
    window.Kiwi.components.registerCustom('reservation-form-owner-45', 'reservation-form-owner-45');

        window.Kiwi.navigation.push({path: '/reservation-form-45', label: ''});
    window.Kiwi.router.addRoutes([{path: '/reservation-form-45', component: config, meta: { auth: false }}]);
    }).call();
(function() {
    const config = {
    data() {
        return {
            config: null
        }
    },
    mounted() {
        Kiwi.request().post('/api/db/reservation-form-owner-46').then(response => {
            this.config = JSON.parse(response.data.default[0].group_config_9)
        })
    }
};
    config.template = `<div style="background:#fff;padding:.5rem">
	<kiwi-form v-if="config" no-config :override="config" />
</div>`;

    Vue.component('reservation-form-owner-46', config);
    window.Kiwi.components.registerCustom('reservation-form-owner-46', 'reservation-form-owner-46');

        window.Kiwi.navigation.push({path: '/reservation-form-54', label: ''});
    window.Kiwi.router.addRoutes([{path: '/reservation-form-54', component: config, meta: { auth: false }}]);
    }).call();
(function() {
    const config = {
    data() {
        return {
            loading: true,
            error: false,
            completed: false,
            processing: false,

            data: {
                owner_name: null,
                owner_website: null,
                owner_phone_primary: null,
                owner_email_primary: null,
                user_name: null,
                user_username: null,
                user_email: null,
                coll2_name: null,
                noquote_form_languages: [],
                password: '',
                password_confirmation: '',

                coll2_short_name: null,
                owner_mode: 1,
                subscription_id: null,
            },

            availableLanguages: [],

            errors: {}
        }
    },
    methods: {
        submit() {
            this.errors = {}
            this.processing = true

            if (this.data.noquote_form_languages.length === 0) {
                this.$toasted.error(this.__('new_customer.languages_required'))
                this.processing = false
                return;
            }

            Kiwi.request().post('/api/db/generator-main-datas', this.data)
                .then(response => {
                    console.log('200', response.data);
                    this.completed = true
                })
                .catch(error => {
                    if(error.response.status === 422) {
                        console.log('422', error.response.data);
                        this.errors = error.response.data.errors
                    }
                })
                .finally(() => this.processing = false)

            console.log(this.data);
            console.log('Submit')
        },


        getLanguages() {
            Kiwi.request().get('/api/db/sys_languages').then(response => {
                this.availableLanguages = response.data.default
            })
        }
    },

    mounted() {
        let token = this.$route.query.token

        if(! token) {
            this.loading = false
            return this.error = true
        }

        Kiwi.request().get('/api/db/check-owner-by-token?token='+ token)
            .then(response => {
                if(response.data.default[0]?.result != 1) {
                    this.error = true
                }

                this.data.subscription_id = token
                this.getLanguages()
            })
            .catch(error => this.error = true)
            .finally(() => this.loading = false)
    }
};;
    config.template = `<public>
    <div class="d-flex justify-content-center mt-5">
        <brand></brand>
    </div>

    <h1 class="text-center mt-5">{{ __('new_customer.welcome') }}</h1>

    <div class="row" v-if="! loading && ! error && ! completed">
        <div class="col-12 col-md-6 offset-md-3">
            <p class="lead mt-5">{{ __('new_customer.intro') }}</p>

            <form @submit.prevent="submit">
                <div class="form-group required">
                    <label for="owner_name">{{ __('new_customer.owner_name') }}</label>
                    <input type="text" id="owner_name" v-model="data.owner_name" class="form-control" required>
                </div>
                <div class="form-group required">
                    <label for="owner_website">{{ __('new_customer.owner_website') }}</label>
                    <input type="text" id="owner_website" v-model="data.owner_website" class="form-control" required>
                </div>
                <div class="form-group required">
                    <label for="owner_email_primary">{{ __('new_customer.owner_email_primary') }}</label>
                    <input type="email" id="owner_email_primary" v-model="data.owner_email_primary" class="form-control" required>
                </div>
                <div class="form-group required">
                    <label for="owner_phone_primary">{{ __('new_customer.owner_phone_primary') }}</label>
                    <field type="phone" id="owner_phone_primary" v-model="data.owner_phone_primary" field-class="d-block" required></field>
                </div>
                <div class="form-group required">
                    <label for="coll2_name">{{ __('new_customer.coll2_name') }}</label>
                    <input type="text" id="coll2_name" v-model="data.coll2_name" class="form-control" required>
                </div>
                <div class="form-group required">
                    <label for="user_name">{{ __('new_customer.user_name') }}</label>
                    <input type="text" id="user_name" v-model="data.user_name" class="form-control" required>
                </div>
                <div class="form-group required">
                    <label for="user_username">{{ __('new_customer.user_username') }}</label>
                    <input type="text" id="user_username" v-model="data.user_username" class="form-control" required>
                    <span class="form-text text-danger" v-if="errors.user_username">{{ errors.user_username[0] }}</span>
                </div>
                <div class="form-group required">
                    <label for="user_email">{{ __('new_customer.user_email') }}</label>
                    <input type="email" id="user_email" v-model="data.user_email" class="form-control" required>
                    <span class="form-text text-danger" v-if="errors.user_email">{{ errors.user_email[0] }}</span>
                </div>
                <div class="form-group required">
                    <label for="password">{{ __('new_customer.password') }}</label>
                    <input type="password" id="password" v-model="data.password" class="form-control" required>
                    <span class="form-text text-danger" v-if="errors.password">{{ errors.password[0] }}</span>
                </div>
                <div class="form-group required">
                    <label for="password_confirmation">{{ __('new_customer.password_confirmation') }}</label>
                    <input type="password" id="password_confirmation" v-model="data.password_confirmation" class="form-control" required>
                </div>
                <div class="form-group required">
                    <label id="noquote_form_languages">{{ __('new_customer.languages') }}</label>

                    <b-checkbox
                            v-model="data.noquote_form_languages"
                            :value="lang.id"
                            v-for="lang in availableLanguages"
                            :key="lang.id"
                    >
                        {{ lang.name }}
                    </b-checkbox>
                    <span class="form-text">{{ __('new_customer.languages_help') }}</span>
                </div>

                <button class="btn btn-primary" :class="{'disabled': processing}" type="submit" :disabled="processing">
                    <i class="fa fa-spinner fa-spin" v-show="processing"></i>
                    {{ __('common.continue') }}
                </button>
            </form>
        </div>
    </div>
    <div class="row" v-else-if="completed">
        <div class="col-12 col-md-6 offset-md-3 text-center mt-5">
            <div class="alert alert-success">
                {{ __('new_customer.completed') }}
            </div>

            <a class="btn btn-primary" href="/login">{{ __('new_customer.go_to_login') }}</a>
        </div>
    </div>
    <div class="row" v-else-if="loading">
        <div class="col-md-6 offset-md-3">
            <div class="alert alert-info mt-5">
                <i class="fa fa-spinner fa-spin"></i> {{ __('common.loading') }}
            </div>
        </div>
    </div>
    <div class="row" v-else>
        <div class="col-md-6 offset-md-3">
            <div class="alert alert-warning mt-5">
                {{ __('new_customer.wrongUrl') }}
            </div>
        </div>
    </div>
</public>`;

    Vue.component('tables-new-customer', config);
    window.Kiwi.components.registerCustom('tables-new-customer', 'tables-new-customer');

        window.Kiwi.navigation.push({path: '/create-customer', label: ''});
    window.Kiwi.router.addRoutes([{path: '/create-customer', component: config, meta: { auth: false }}]);
    }).call();
(function() {
    const config = {
    data() {
        return {
            loading: false,
            subscription: null
        }
    },
    methods: {
        getSubscription() {
            Kiwi.request().get('/api/db/subscription').then(response => {
                this.subscription = response.data.default[0]
            })
        },

        handleClick() {
            // this.subscription = {subscription_id: '09dbdfa8-04cb-4e09-9b64-bfd481bf95aa'}

            if(! this.subscription) {
                return;
            }

            this.loading = true

            Kiwi.request().get('https://reservation.tableversum.com/api-service/2?subscription_id='+ this.subscription.subscription_id)
                .then(response => {
                    try {
                        let loginUrl = response.data.data.tasks.link.sqls.root.login_url

                        window.open(loginUrl, '_blank')
                    } catch (e) {

                    }
                })
                .finally(() => this.loading = false)

        }
    },

    mounted() {
        this.getSubscription()
    }
};;
    config.template = `<button class="d-block w-100 text-left" @click.prevent="handleClick" :disabled="loading">
    <i class="fa fa-spinner fa-spin" v-show="loading"></i>
    {{ __('manage_my_subscription') }}
</button>`;

    Vue.component('kiwi-portal-link', config);
    window.Kiwi.components.registerCustom('kiwi-portal-link', 'kiwi-portal-link');

    }).call();
(function() {
    const config = {
  inject: ['crud', 'form'],
  data() {
    return {
      configurationFields: [
        ConfigField.make('trKeys1', 'Keys', 'key-value')
      ],
      translations:{},
      relKeys:{},
      languages:[],
      selectedLangCode:''
    }
  },
  computed:{
    relId(){
      if(!!this.$attrs['rel-id']){
        return this.$attrs['rel-id'];
      }else if(!!this.crud){
        return this.form ? this.crud.editingResource?.id : this.crud.openedResource;
      }else{
        return null;
      }
    },
    relName(){
      if(!!this.$attrs['rel-name']){
        return this.$attrs['rel-name'];
      }else if(!!this.crud){
        return this.crud.api;
      }else{
        return null;
      }
    }
  },
  methods:{
    save(translation){
      if(!translation.tr_value){
        if(translation.id !== null){
          axios.post('/api/db/related-translations-delete',{id:translation.id}).then((res) => {
            translation.id = null;
          });
        }
      }else{
        let postData = {
          lang_code: translation.lang_code,
          tr_value: translation.tr_value,
          rel_name: this.relName,
          rel_id: this.relId,
          rel_key: translation.rel_key,
          is_client_key: 0
        };
        if(translation.id !== null){
          postData['_method'] = 'PATCH';
        }
        axios.post('/api/sys_translation'+(translation.id === null ? '' : '/'+translation.id),postData).then((res) => {
          translation.id = res.data.id;
        });
      }
    },
    load(){
      axios.get('/api/sys_translation',{
        params:{
          'filter_exact[rel_id]': this.relId,
          'filter_exact[rel_name]': this.relName
        }
      }).then((res)=>{
        for(let i in res.data){
          let d = res.data[i];
          for(let j in d){
            this.translations[d.lang_code][d.rel_key][j] = d[j];
          }
        }
      });
    },
    initLanguages(){
      axios.get('api/db/related-translations-get-selected-languages').
      then((res)=>{
        for(let i in res.data.default){
          this.languages.push(res.data.default[i].lang_code);
        }
        for(var i in this.languages){
          let k = this.languages[i];
          this.$set(this.translations,k,{});
          for(var j in this.relKeys){
            this.$set(this.translations[k],j,{
              id:null,
              lang_code:k,
              tr_key:null,
              tr_value:'',
              rel_name:this.relName,
              rel_id:this.relId,
              rel_key:j,
              is_client_key:0
            });
          }
        }
        this.selectedLangCode = this.languages[0];
        this.load();
      });
    },
    initKeys(){
      if(!!this.$attrs['rel-keys']){
        let o = JSON.parse(this.$attrs['rel-keys']);
        for(let i in o){
          this.relKeys[i] = o[i];
        }
      }
    }
  },
  mounted(){
    this.initKeys();
    this.initLanguages();
    if(!!this.crud){
      if (this.form) {
        this.$watch('crud.editingResource.id',this.load);
      } else {
        this.$watch('crud.openedResource',this.load);
      }
    }
  }
};;
    config.template = `<div class="mt-3">
  <div>
    {{__($attrs['label'])}}
  </div>
  <div class="mt-3">
    <span class="text-gray-500 mr-2" >{{__('email.languages')}}</span>
    <button v-for="langCode in languages" @click="selectedLangCode = langCode" class="btn btn-sm px-3 mr-1" :class="langCode === selectedLangCode ? 'btn-info' : 'btn-light'">{{langCode}}</button>
  </div>
  <div class="mt-2">
    <div v-for="(translation,key) in translations[selectedLangCode]" class="mt-2 text-gray-500">
      <span>{{__(relKeys[key])}}</span>
      <textarea v-model="translation.tr_value" @change="save(translation)" class="form-control"></textarea>
    </div>
  </div>
</div>`;

    Vue.component('related-translations', config);
    window.Kiwi.components.registerCustom('related-translations', 'related-translations');

    }).call();
(function() {
    const config = {
    data() {
        return {
            token: '',

            error: false,
            loading: true,
            success: false
        }
    },

    methods: {
        init() {
            this.loading = true
            this.token = this.$route.query.token

            if (! this.token) {
                this.error = true
            }

            this.loading = false
        },

        submit() {
            Kiwi.request().post('/api/db/reservation-resign', {resign: 1, tableres_id: this.token})
                .then(() => this.success = true)
                .catch(() => this.error = true)
        }
    },

    mounted() {
        Kiwi.bus.$on('localization:load', () => this.init())
    }
};;
    config.template = `<div class="container">
    <div class="row pt-5">
        <div class="col-lg-6 offset-lg-3">
            <brand class="mb-4"></brand>
            <div class="alert alert-success" v-if="success">
                <i class="fa fa-check mr-1"></i> {{ __('cancel_reservation.success') }}
            </div>
            <div class="card" v-else-if="! error && ! loading">
                <div class="card-header">{{ __('cancel_reservation.title') }}</div>
                <div class="card-body">
                    {{ __('cancel_reservation.desc') }}

<!--
                    <p class="d-flex justify-content-between mt-4 mb-0 text-muted">
                        <span>Dátum:</span>
                        <strong>2023. május 17. 18:00</strong>
                    </p>
                    <p class="d-flex justify-content-between text-muted">
                        <span>Létszám:</span>
                        <strong>4 fő</strong>
                    </p>
-->
                </div>
                <div class="card-footer  text-right">
<!--                    <button class="btn btn-primary">Foglalásom módosítása</button>-->
                    <button class="btn btn-danger" @click.prevent="submit">{{ __('cancel_reservation.confirm') }}</button>
                </div>
            </div>
            <div class="card" v-else-if="! loading">
                <div class="card-header"></div>
                <div class="card-body">
                    {{ __('cancel_reservation.has_error') }}
                </div>
            </div>
            <div class="card" v-else>
                <div class="card-header"></div>
                <div class="card-body">
                    {{ __('common.loading') }}
                </div>
            </div>
        </div>
    </div>
</div>`;

    Vue.component('tables-cancel-reservation', config);
    window.Kiwi.components.registerCustom('tables-cancel-reservation', 'tables-cancel-reservation');

        window.Kiwi.navigation.push({path: '/cancel-reservation', label: ''});
    window.Kiwi.router.addRoutes([{path: '/cancel-reservation', component: config, meta: { auth: false }}]);
    }).call();
(function() {
    const config = {
    data() {
        return {
            date: '',
            restaurants: [],
            guests: 1,
            form: {
                firstname: '',
                lastname: '',
                reservation_date: null,
                reservation_time: null,
                number_of_people: 1,
                notes: '',
                owner_id: null,
                phone: '',
                email: '',
                place_id: null,
                lang: 'en',
                allergen: '',
                purpose: null,
            },

            loading: false,
        }
    },

    methods: {
        getRestaurants: _.debounce(function() {
            this.restaurants = []
            this.loading = true

            Kiwi.request().get('/api/db/receptionist-get-restaurants?date='+ this.date + '&seats='+ this.guests).then((response) => {
                this.restaurants = response.data.data
            }).finally(() => this.loading = false)
        }, 500),

        submit() {
            this.loading = true
            this.form.reservation_date = this.date
            this.form.number_of_people = this.guests

            Kiwi.request().post('/api/db/table_reservation_receptionist', {...this.form, json_result: JSON.stringify(this.form)}).then((response) => {
                this.$refs.modal.hide()
                this.$toasted.success('Sikeres foglalás')
                this.getRestaurants()
            }).finally(() => this.loading = false)
        },

        increment() {
            this.guests++
        },

        decrement() {
            if(this.guests > 1) {
                this.guests--
            }
        },

        openModal(restaurant, item) {
            this.form.reservation_time = item.reservation_time
            this.form.place_id = item.place_id
            this.form.owner_id = restaurant.owner_id
            this.$refs.modal.show()
        },

        hasFreeTimes(restaurant) {
            let times = []
            restaurant.items.forEach((place) => {
                times = [...times, ...place.items]
            })

            return times.length > 0
        },

        nextDate() {
            this.date = moment(this.date).add(1, 'day').format('YYYY-MM-DD')
        },

        prevDate() {
            this.date = moment(this.date).subtract(1, 'day').format('YYYY-MM-DD')
        }
    },

    watch: {
        date() {
            this.getRestaurants()
        },
        guests() {
            if(! this.guests) {
                return
            }

            if(this.guests < 1) {
                this.guests = 1;
                return
            }

            this.getRestaurants()
        }
    },

    beforeMount() {
        this.date = moment().format('YYYY-MM-DD')
    }
};;
    config.template = `<app>
    <div class="card">
        <div class="card-header text-center">{{ __('rrf.title') }}</div>
        <div class="card-body">
            <div class="container">
                <div class="row justify-content-center">
                    <div class="col-lg-6 col-xl-3">
                        <div class="d-flex align-items-center" style="gap: .3rem">
                            <a href="" @click.prevent="prevDate" class="btn btn-light"><i class="fa fa-chevron-left"></i></a>
                            <datepicker class="text-center" format="d" v-model="date"></datepicker>
                            <a href="" @click.prevent="nextDate" class="btn btn-light"><i class="fa fa-chevron-right"></i></a>
                        </div>
                        <div class="d-flex flex-column mt-3">
                            <label class="d-block text-left">Létszám</label>
<!--                            <b-form-spinbutton v-model="guests" min="1" max="20"></b-form-spinbutton>-->

                            <div>
                                <b-input-group class="border rounded">
                                    <b-input-group-prepend>
                                        <button type="button" class="btn" @click.prevent="decrement()"><i class="fa fa-minus"></i></button>
                                    </b-input-group-prepend>

                                    <input type="number" v-model="guests" min="1" class="form-control border-0 text-center">

                                    <b-input-group-append>
                                        <button type="button" class="btn" @click.prevent="increment()"><i class="fa fa-plus"></i></button>
                                    </b-input-group-append>
                                </b-input-group>
                            </div>
                        </div>
                    </div>
                    <div class="col-12 mt-3">
                        <div class="row">
                            <div class="col-12">
                                <div
                                        class="b-skeleton b-skeleton-text b-skeleton-animate-wave bg-primary text-center text-white fade-in-delay"
                                        style="height: 1.5rem;font-size: 0.9em;line-height: 1.5rem;--delay: 10ms"
                                        :class="{'invisible':  ! loading}"

                                ><i class="fas fa-circle-notch fa-spin"></i> {{ __('loading') }} ...</div>
                            </div>
                            <div class="col-md-3 mb-3" v-for="restaurant in restaurants" v-if="hasFreeTimes(restaurant)">
                                <div class="card">
                                    <div class="card-body pt-2">
                                        <p class="font-weight-bold">{{ restaurant.name }}</p>

                                        <template v-for="place in restaurant.items" v-if="place.items.length > 0">

                                            <template v-if="guests > place.max_reservation_places">
                                                <div class="alert alert-info">
                                                    {{ place.max_reservation_places }} főnél nagyobb létszám esetén kérjük telefonon
                                                    vegye fel a kapcsolatot az étteremmel: <a :href="'tel:'+ restaurant.phone">+{{ restaurant.phone }}</a>
                                                </div>
                                            </template>
                                            <template v-else>
                                                <p class="mb-1 text-primary" v-show="restaurant.items.length > 1">{{ place.place_name }}:</p>
                                                <div class="d-flex flex-wrap mb-2" style="gap: .3rem">
                                                    <a href="#" @click.prevent="openModal(restaurant, time)" v-for="time in place.items" class="bg-light px-3 py-2 rounded-sm">{{ time.reservation_time }}</a>
                                                </div>
                                            </template>
                                        </template>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div v-show="restaurants.length === 0 && ! loading" class="alert alert-warning text-center">
                            Sajnos a kiválasztott napon és létszámmal nem találtunk szabad asztalt.
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <b-modal ref="modal" title="Foglalás rögzítése" hide-footer>
        <form @submit.prevent="submit">
            <div class="row">
                <div class="col-sm-6">
                    <field
                            type="text"
                            label="Vezetéknév"
                            v-model="form.lastname"
                            field-class="d-block"
                            :required="true"
                    ></field>
                </div>
                <div class="col-sm-6">
                    <field
                            type="text"
                            label="Keresztnév"
                            v-model="form.firstname"
                            field-class="d-block"
                            :required="true"
                    ></field>
                </div>
                <div class="col-sm-6">
                    <field
                            type="text"
                            label="Telefonszám"
                            v-model="form.phone"
                            field-class="d-block"
                    ></field>
                </div>
                <div class="col-sm-6">
                    <field
                            type="text"
                            label="Email cím"
                            v-model="form.email"
                            field-class="d-block"
                    ></field>
                </div>
                <div class="col-sm-6">
                    <field
                            type="text"
                            label="Ételallergia"
                            v-model="form.allergen"
                            field-class="d-block"
                    ></field>
                </div>
                <div class="col-sm-12">
                    <field
                            type="multitext"
                            label="Megjegyzés"
                            v-model="form.notes"
                            field-class="d-block"
                    ></field>
                </div>
                <div class="col-sm-12">
                    <div class="form-group">
                        <label>Kommunikáció nyelve</label>

                        <select v-model="form.lang" class="form-control">
                            <option value="en">English</option>
                            <option value="hu">Hungarian</option>
                            <option value="de">German</option>
                        </select>

                        <div class="d-flex mt-2" style="gap: .4rem">
                            <img src="https://flagcdn.com/gb.svg" width="32" alt="English" style="cursor:pointer;" @click.prevent="form.lang = 'en'" />
                            <img src="https://flagcdn.com/hu.svg" width="32" alt="Hungarian" style="cursor:pointer;" @click.prevent="form.lang = 'hu'" />
                            <img src="https://flagcdn.com/de.svg" width="32" alt="German" style="cursor:pointer;" @click.prevent="form.lang = 'de'" />
                        </div>
                    </div>
                </div>
                <div class="col-sm-12">
                    <button type="submit" class="btn btn-primary">Foglalás rögzítése</button>
                </div>
            </div>
        </form>
    </b-modal>
</app>`;

    Vue.component('receptionist-reservation-form', config);
    window.Kiwi.components.registerCustom('receptionist-reservation-form', 'receptionist-reservation-form');

        window.Kiwi.navigation.push({path: '/receptionist-reservation-form', label: 'Foglalás'});
    window.Kiwi.router.addRoutes([{path: '/receptionist-reservation-form', component: config, meta: { auth: true }}]);
    }).call();
(function() {
    const config = {
    data() {
        return {
            config: null
        }
    },
    mounted() {
        Kiwi.request().post('/api/db/reservation-form-owner-71').then(response => {
            this.config = JSON.parse(response.data.default[0].group_config_9)
        })
    }
};
    config.template = `<div style="background:#FAFAFA;padding:.5rem">
	<kiwi-form v-if="config" no-config :override="config" />
</div>`;

    Vue.component('reservation-form-owner-71', config);
    window.Kiwi.components.registerCustom('reservation-form-owner-71', 'reservation-form-owner-71');

        window.Kiwi.navigation.push({path: '/reservation-form-85', label: ''});
    window.Kiwi.router.addRoutes([{path: '/reservation-form-85', component: config, meta: { auth: false }}]);
    }).call();
(function() {
    const config = {
    data() {
        return {
            config: null
        }
    },
    mounted() {
        Kiwi.request().post('/api/db/reservation-form-owner-72').then(response => {
            this.config = JSON.parse(response.data.default[0].group_config_9)
        })
    }
};
    config.template = `<div style="old-background:#fff;padding:.5rem">
	<kiwi-form v-if="config" no-config :override="config" />
</div>`;

    Vue.component('reservation-form-owner-72', config);
    window.Kiwi.components.registerCustom('reservation-form-owner-72', 'reservation-form-owner-72');

        window.Kiwi.navigation.push({path: '/reservation-form-86', label: ''});
    window.Kiwi.router.addRoutes([{path: '/reservation-form-86', component: config, meta: { auth: false }}]);
    }).call();
(function() {
    const config = {
    data() {
        return {
            config: null
        }
    },
    mounted() {
        Kiwi.request().post('/api/db/reservation-form-owner-73').then(response => {
            this.config = JSON.parse(response.data.default[0].group_config_9)
        })
    }
};
    config.template = `<div style="old-background:#fff;padding:.5rem">
	<kiwi-form v-if="config" no-config :override="config" />
</div>`;

    Vue.component('reservation-form-owner-73', config);
    window.Kiwi.components.registerCustom('reservation-form-owner-73', 'reservation-form-owner-73');

        window.Kiwi.navigation.push({path: '/reservation-form-87', label: ''});
    window.Kiwi.router.addRoutes([{path: '/reservation-form-87', component: config, meta: { auth: false }}]);
    }).call();
(function() {
    const config = {
    data() {
        return {
            config: null
        }
    },
    mounted() {
        Kiwi.request().post('/api/db/reservation-form-owner-74').then(response => {
            this.config = JSON.parse(response.data.default[0].group_config_9)
        })
    }
};
    config.template = `<div style="background:#fff;padding:.5rem" class="gundel-reservation-form">
	<kiwi-form v-if="config" no-config :override="config" />
</div>`;

    Vue.component('reservation-form-owner-74', config);
    window.Kiwi.components.registerCustom('reservation-form-owner-74', 'reservation-form-owner-74');

        window.Kiwi.navigation.push({path: '/reservation-form-89', label: ''});
    window.Kiwi.router.addRoutes([{path: '/reservation-form-89', component: config, meta: { auth: false }}]);
    }).call();
(function() {
    const config = {
	data() {
		return {
			reservationForm: null
		}
	},
	
	mounted() {
		this.reservationForm = this.$refs.reservationForm
	}
};
    config.template = `<div class="w-100">
	<div style="position:absolute;left:0;top:0;width:100%;height:100%;z-index:-1;background: url('https://spoonboat.hu/wp-content/uploads/2023/08/Spoon-kezdokep-1920jpg.jpg') no-repeat center;background-size:cover"></div>
	<div style="background: #fff; border-radius: 9px; width: 650px;padding: 2rem;margin: 30px auto;">

		<tableversum-reservation-form :owner-id="$route.params.id" ref="reservationForm"></tableversum-reservation-form>
	
		<tableversum-form-customization v-if="reservationForm" :reservation-form="reservationForm"></tableversum-form-customization>
	</div>
</div>`;

    Vue.component('fullscreen-reservation-form', config);
    window.Kiwi.components.registerCustom('fullscreen-reservation-form', 'fullscreen-reservation-form');

        window.Kiwi.navigation.push({path: '/reservation-forms/:id', label: ''});
    window.Kiwi.router.addRoutes([{path: '/reservation-forms/:id', component: config, meta: { auth: false }}]);
    }).call();
(function() {
    const config = {
    inject: {
        tableSetup: {
            default: null
        }
    },
    props: {
        // Array of conditions IDs to show
        visibleConditions: {
            type: Array,
            default: ['*']
        },

        placeId: {
            type: Number,
            default: null
        },

        groupId: {
            type: Number,
            default: null
        },

        // The parameters to edit
        data: {
            type: Array,
            default: []
        },

        custom: {
            type: Boolean,
            default: false
        },

        readonly: {
            type: Boolean,
            default: false
        },

        customDateFrom: {
            type: String,
            default: null
        },

        customDateTo: {
            type: String,
            default: null
        }
    },
    data() {
        return {
            editingSetting: null,
            editMode: false,
            settings: [],
            configurations: [],
            conditions: [],
            paramTypes: [],
            defaultShifts: [],
            shifts: [],
            rawParams: [],
            isOpen: true, // Nyitvatartás igen/nem

            openParamTypeId: Param.openParamTypeId,
            saving: false,
        }
    },

    computed: {

        zones() {
            let zones = [
                new Zone('00:00 - 06:00', 0),
                new Zone('06:00 - 12:00', 6),
                new Zone('12:00 - 18:00', 12),
                new Zone('18:00 - 23:59', 18),
            ]

            this.settings.forEach(setting => {
                let settingStartingHour = parseInt(setting.from.split(':')[0])
                let settingEndingHour = parseInt(setting.to.split(':')[0])

                let zone = zones.find(zone => settingStartingHour >= zone.startingHour && settingStartingHour < zone.startingHour + 6)

                if (zone) {
                    zone.add(setting)
                }
            })

            console.log('zones', zones, this.settings);
            return zones
        }
    },

    methods: {
        createSetting(condition) {
            if(this.readonly) {
                return
            }

            this.editMode = false
            this.editingSetting = new Setting('08:00:00', '08:00:00', condition)

            let addParams = () => {
                this.paramTypes.forEach((paramType) => {
                    let param = new Param(null, paramType.name, paramType.id, 0)

                    if(parseInt(paramType.is_bool) === 1) {
                        param.value = 1
                        param.boolean()
                    }

                    this.editingSetting.addParam(param)
                })
            }

            addParams()

            this.isOpen = this.editingSetting.isOpen

            this.$refs.tvParamsModal.show()
        },
        editSetting(setting) {
            // if(this.readonly) {
            //     return
            // }

            this.isOpen = setting.isOpen

            this.editMode = true
            this.editingSetting = setting.clone()

            this.$refs.tvParamsModal.show()
        },

        _generateSettings() {
            let settings = []

            this.configurations.forEach(configuration => {
                let condition = this.conditions.find(condition => parseInt(condition.id) === parseInt(configuration.condition_id))

                if (! condition) {
                    return
                }

                let setting = new Setting(configuration.time_from, configuration.time_to, condition)

                setting.setId(configuration.id)
                setting.addShift(configuration.shift_id)

                let params = this.rawParams.filter(param => configuration.params.includes(param.param_id))

                params.forEach(rawParam => {
                    let param = new Param(rawParam.param_id, rawParam.name, rawParam.type_id, rawParam.value)

                    if (parseInt(rawParam.is_bool) === 1) {
                        param.boolean()
                    }

                    setting.addParam(param)
                })

                settings.push(setting)
            })

            /*
            let hasOpenParam = timeSpans[timeSpan].params.find(param => parseInt(param.typeId) === Param.openParamTypeId)

            if(! hasOpenParam) {
                let type = this.paramTypes.find(type => parseInt(type.id) === Param.openParamTypeId)
                let openParam = new Param(null, type.name, type.id, 0)
                timeSpans[timeSpan].addParam(openParam.boolean())
            }
            */

            this.settings = settings;
        },

        _createSetting() {
            let saveCounter = 0;
            let paramIds = [];

            this.saving = true

            if (this.editingSetting.shift) {
                this.saveShift(this.editingSetting.shift)
            }

            // Elmentjük a param-okat majd utána létrehozunk egy ilyen reservation_configuration_group -ot
            this.editingSetting.params.forEach(param => {
                this._updateReservationParameters(param)
                    .then(response => {
                        let id = response.data.default[0]?.id

                        paramIds.push(id)
                    })
                    .finally(() => {
                        saveCounter++

                        saveConfiguration()
                    })
            })

            let saveConfiguration = () => {

                // Ha létrehoztuk az összes paramétert akkor létrehozzuk a reservation_configuration_group -ot
                if (saveCounter >= this.editingSetting.params.length) {
                    let config = new ReservationConfigurationGroup({
                        place_id: this.placeId,
                        condition_id: this.editingSetting.condition.id,
                        time_from: this.editingSetting.from,
                        time_to: this.editingSetting.to,
                        shift_id: this.editingSetting.shift,
                        params: paramIds,
                        is_custom: this.custom ? 1 : 0,
                        date_from: this.custom ? moment(this.customDateFrom).startOf('day').format('YYYY-MM-DD HH:mm:ss') : null,
                        date_to: this.custom ? moment(this.customDateTo).endOf('day').format('YYYY-MM-DD HH:mm:ss') : null,
                        group_id: this.groupId
                    });

                    config.$save().then(response => {
                        if(this.tableSetup) {
                            this.tableSetup._applyReservationParameters(moment(this.customDateFrom).startOf('day').format('YYYY-MM-DD HH:mm:ss'), moment(this.customDateTo).endOf('day').format('YYYY-MM-DD HH:mm:ss'))
                        }

                        this.$refs.tvParamsModal.hide()
                        this.$toasted.success(this.__('tpedit.success'))
                        this.refresh()
                    }).catch(error => {
                        this.$toasted.error('Error creating the setting, please try again later.')
                        console.error(error);
                    }).finally(() => this.saving = false)
                }
            }
        },


        _updateSetting() {
            let saveCounter = 0;
            let paramIds = [];

            this.saving = true

            if (this.editingSetting.shift) {
                this.saveShift(this.editingSetting.shift)
            } else {
                this.deleteShift(this.editingSetting.shift)
            }

            this.editingSetting.params.forEach(param => {
                this._updateReservationParameters(param)
                    .then(response => {
                        let id = response.data.default[0]?.id

                        paramIds.push(id)
                    })
                    .finally(() => {
                        saveCounter++

                        saveConfiguration()
                    })
            })

            let saveConfiguration = () => {

                // Ha létrehoztuk az összes paramétert akkor létrehozzuk a reservation_configuration_group -ot
                if (saveCounter >= this.editingSetting.params.length) {
                    let config = new ReservationConfigurationGroup({
                        id: this.editingSetting.id,
                        place_id: this.placeId,
                        condition_id: this.editingSetting.condition.id,
                        time_from: this.editingSetting.from,
                        time_to: this.editingSetting.to,
                        shift_id: this.editingSetting.shift,
                        params: paramIds,
                        is_custom: this.custom ? 1 : 0,
                        date_from: this.custom ? this.customDateFrom : null,
                        date_to: this.custom ? this.customDateTo : null,
                        group_id: this.groupId
                    });

                    config.$save().then(response => {
                        if(this.tableSetup) {
                            this.tableSetup._applyReservationParameters(moment(this.customDateFrom).startOf('day').format('YYYY-MM-DD HH:mm:ss'), moment(this.customDateTo).endOf('day').format('YYYY-MM-DD HH:mm:ss'))
                        }

                        this.$refs.tvParamsModal.hide()
                        this.$toasted.success(this.__('tpedit.success'))
                        this.refresh()
                    }).catch(error => {
                        this.$toasted.error('Error creating the setting, please try again later.')
                        console.error(error);
                    }).finally(() => this.saving = false)
                }
            }
        },

        /**
         *
         * @param param
         * @private
         * @returns {Promise<*>}
         */
        _updateReservationParameters(param) {
            if(this.custom) {
                return this._updateCustomReservationParameters(param)
            }

            return Kiwi.request().patch('/api/db/update-default-reservation-parameters', {
                id: this.editMode ? param.id : null,
                place_id: this.placeId,
                type_id: param.typeId,
                condition_id: this.editingSetting.condition.id,
                time_from: this.editingSetting.from,
                time_to: this.editingSetting.to,
                value: param.value
            })
        },

        /**
         * Update custom reservation parameters
         * @param param
         * @returns {Promise<*>}
         * @private
         */
        _updateCustomReservationParameters(param) {
            return Kiwi.request().patch('/api/db/update-custom-reservation-parameters', {
                id: this.editMode ? param.id : null,
                place_id: this.placeId,
                type_id: param.typeId,
                condition_id: this.editingSetting.condition.id,
                time_from: this.editingSetting.from,
                time_to: this.editingSetting.to,
                date_from: moment(this.customDateFrom).startOf('day').format('YYYY-MM-DD HH:mm:ss'),
                date_to: moment(this.customDateTo).endOf('day').format('YYYY-MM-DD HH:mm:ss'),
                value: param.value,
                group_id: this.groupId
            })
        },

        save() {
            if (! this.editingSetting || this.readonly) {
                return
            }

            let collidingSetting = this.settings.find(setting => {
                return setting.id !== this.editingSetting.id && setting.from <= this.editingSetting.to && setting.to >= this.editingSetting.from && setting.condition.id === this.editingSetting.condition.id
            })

            if(collidingSetting) {
                this.$toasted.error(this.__('tpedit.colliding_setting') + ' ' + collidingSetting.from + ' - ' + collidingSetting.to)
                return
            }

            if(this.editingSetting.from >= this.editingSetting.to && this.isOpen) {
                this.$toasted.error(this.__('tpedit.setting_time_invalid'))
                return
            }


            if(this.editMode) {
                this._updateSetting()
            } else {
                this._createSetting()
            }
        },

        remove(setting) {
            Kiwi.bus.$emit('confirm', {title: this.__('tpedit.delete_confirmation'), content: this.__('tpedit.delete_confirmation_text'),
                callback: () => {

                    let apiUrl = this.custom ? '/api/db/delete-custom-reservation-parameters' : '/api/db/delete-default-reservation-parameters'
                    let counter = 0

                    if (setting.shift) {
                        this.deleteShift(setting.shift)
                    }

                    Kiwi.request().post('/api/db/delete-reservation-configuration-groups', {id: setting.id})

                    setting.params.forEach(param => {
                        Kiwi.request()
                            .post(apiUrl, {id: param.id})
                            .then(response => {
                            })
                            .finally(() => {
                                counter++

                                if (counter >= setting.params.length) {
                                    this.$refs.tvParamsModal.hide()
                                    this.refresh()
                                    this.$toasted.success(this.__('tpedit.delete_success'))
                                }
                            })
                    })
                }
            })

        },

        deleteShift(shiftId) {
            return Kiwi.request().post('/api/db/delete-reservation-shift', {
                condition_id: this.editingSetting.condition.id,
                time_from: this.editingSetting.from,
                time_to: this.editingSetting.to,
                date_from: null,
                date_to: null,
                place_id: this.placeId,
                shift_id: shiftId
            })
        },

        saveShift(shiftId, cb = (createdId) => {}) {
            if(this.editMode) {
                this.deleteShift(shiftId)
            }

            Kiwi.request().post('/api/db/create-reservation-shift', {
                condition_id: this.editingSetting.condition.id,
                time_from: this.editingSetting.from,
                time_to: this.editingSetting.to,
                date_from: null,
                date_to: null,
                place_id: this.placeId,
                shift_id: shiftId
            }).then(response => {
                cb(response.data['insert'][0].id)
            })
        },

        getShift(id) {
            return this.defaultShifts.find(shift => parseInt(shift.id) === parseInt(id)) || {}
        },

        getParamTypes() {
            return Kiwi.request().get('/api/db/get-reservation-types').then(response => {
                this.paramTypes = response.data.default
            })
        },
        getShifts() {
            return Kiwi.request().get('/api/db/get-reservation-shifts?place_id='+ this.placeId).then(response => {
                response.data.default.forEach((shift) => {
                    if(parseInt(shift.is_default) === 1) {
                        this.defaultShifts.push(shift)
                    } else {
                        this.shifts.push(shift)
                    }
                })
            })
        },
        getConditions() {
            return Kiwi.request().get('/api/db/get-reservation-conditions').then(response => {
                this.conditions = response.data.default

                if (this.visibleConditions[0] === '*') {
                    return
                }

                this.conditions = this.conditions.filter(condition => this.visibleConditions.map(c => parseInt(c)).includes(parseInt(condition.id)))
            })
        },

        getConfigurations() {
            return Kiwi.request().get('/api/reservation-configuration_groups?filter_exact[place_id]='+ this.placeId).then(response => {
                this.configurations = response.data
            })
        },

        refresh() {
            this.$emit('update')
            this.load()
        },

        load() {
            let loadCounter = 0

            let cb = () => {
                loadCounter++

                if (loadCounter >= 3) {
                    this._generateSettings()
                }
            }

            this.getParamTypes().then(() => {
                this.getConditions().then(() => { cb() })
            })

            Kiwi.request().get(
                '/api/reservation-configuration-groups?filter_exact[is_custom]='+ (this.custom ? 1 : 0) +'&filter_exact[place_id]='+ this.placeId +
                (this.custom ? '&filter[date_from]='+ this.customDateFrom +'&filter[date_to]='+ this.customDateTo : '')
            ).then(response => {
                this.configurations = response.data
                cb()
            })

            if(this.custom) {
                Kiwi.request().get('/api/db/get-custom-reservation-params?place_id='+ this.placeId).then(response => {
                    this.rawParams = response.data.default
                    cb()
                })
            } else {
                Kiwi.request().get('/api/db/get-default-reservation-params?place_id='+ this.placeId).then(response => {
                    this.rawParams = response.data.default
                    cb()
                })
            }
        }
    },
    watch: {
        'editingSetting.from': function (val) {
            if (this.editMode) {
                return
            }

            // TODO: itt lehetne validálni
        },
        'placeId': function (val) {
            this.refresh()
        },

        'isOpen': function (val) {
            let openParam = this.editingSetting.params.find(param => parseInt(param.typeId) === Param.openParamTypeId)

            if(openParam) {
                openParam.value = val ? 1 : 0
            }

            if(! val) {
                this.editingSetting.from = '00:00'
                this.editingSetting.to = '23:59'
            }
        }
    },
    mounted() {
        if (! this.placeId) {
            console.error('The attribute place-id is required - tables-params-editor')
            return
        }

        this.load();

        this.getShifts()
    }
};

class ReservationConfigurationGroup extends Resource {
    constructor(attributes) {
        super('reservation_configuration_groups', attributes);
    }
}

class Param {
    id = null
    name = ''
    typeId = null
    value = null
    isBool = false

    constructor(id, name, typeId, value) {
        this.id = id
        this.name = name
        this.typeId = typeId
        this.value = value
    }

    // Get the ID of the "open-close" param type
    static get openParamTypeId() {
        return 101
    }

    // Mark this param as boolean
    boolean() {
        this.isBool = true
        return this
    }
}

class Setting {
    id = null
    from = '08:00:00'
    to = '08:00:00'
    condition = {}
    shift = null
    params = []

    constructor(from, to, condition, params = []) {
        this.from = from
        this.to = to
        this.condition = condition
        this.params = params
    }

    setId(id) {
        this.id = id

        return this
    }

    get isOpen() {
        // return this.params.find(param => parseInt(param.typeId) === Param.openParamTypeId) === undefined
        return this.params.find(param => parseInt(param.typeId) === Param.openParamTypeId)?.value === 1
    }

    // Get the time span of this setting in hours
    get timeSpan() {
        const from = this.from.split(':')
        const to = this.to.split(':')

        return parseInt(to[0]) - parseInt(from[0])
    }

    // Get the time span of this setting in percentage of a day
    get timeSpanPercentage() {
        return this.timeSpan / 24 * 100
    }

    get startingDayPercentage() {
        const from = this.from.split(':')
        return parseInt(from[0]) / 24 * 100
    }

    get toFormatted() {
        return this.to.split(':').slice(0, 2).join(':')
    }

    get fromFormatted() {
        return this.from.split(':').slice(0, 2).join(':')
    }

    addShift(shift) {
        this.shift = shift
        return this
    }

    addParam(param = null) {
        if (param.constructor !== Param) {
            console.error('The attribute param must be an instance of Param')
            return this
        }

        this.params.push(param)

        return this
    }

    clone() {
        let setting = new Setting(this.from, this.to, this.condition, this.params)

        Object.keys(this).forEach((key) => {
            if (typeof this[key] === 'function') {
                return
            }

            setting[key] = this[key]
        })

        return setting
    }
}

// TODO: delete
class Zone {
    name = ''
    startingHour = 0
    items = []

    constructor(name, startingHour = 0) {
        this.name = name
        this.startingHour = startingHour
    }

    /**
     * Add an item to this zone
     *
     * @param item
     */
    add(item) {
        this.items.push(item)
    }

    /**
     * Set the name of this zone
     *
     * @param name
     */
    useName(name) {
        this.name = name

        return this
    }

    /**
     * Set the starting hour
     *
     * @param hour
     */
    startsAt(hour) {
        this.startingHour = hour

        return this
    }

    static make(...params) {
        return new this(...params)
    }
}
;
    config.template = `<div class="tv-params-editor">
    <div class="tv-params-layout">
        <div class="tv-params-row">
            <div class="tv-params-column header" v-for="condition in conditions">
                <div class="header-text">{{ __(condition.name) }}</div>
            </div>
        </div>
        <div class="tv-params-row" v-for="zone in zones">
            <div class="tv-params-column" v-for="condition in conditions" @click.prevent.self="createSetting(condition)">
                <div
                        v-for="setting in zone.items"
                        class="tv-params-setting position-relative bg-blue text-white rounded p-3 shadow d-flex flex-column pb-5 mb-1"
                        v-if="parseInt(condition.id) === parseInt(setting.condition.id)"
                        :style="'min-height: calc('+ setting.timeSpanPercentage +'% - 14rem);'+ (! setting.isOpen ? 'border-top: 4px solid var(--danger);' : '')"
                        @click.prevent="editSetting(setting)"
                >
                    <span class="font-weight-bold" v-show="setting.isOpen">{{ setting.fromFormatted }} - {{ setting.toFormatted }}</span>
                    <div v-show="! setting.isOpen" class="text-center text-uppercase font-weight-bold">{{ __('tpedit.closed_title') }}</div>

                    <div class="justify-self-end position-absolute bg-indigo px-3 py-1 rounded-sm small font-weight-bold" style="bottom: .8rem" v-if="setting.shift">{{ __(getShift(setting.shift)?.name) }}</div>
                </div>

                <button type="button" v-if="! readonly" class="btn btn-light add-button btn-block mt-3" @click.prevent.self="createSetting(condition)"><i class="fa fa-plus"></i> {{ __('tpedit.new_setting') }}</button>
            </div>
        </div>
    </div>

    <b-modal ref="tvParamsModal" :title="editMode ? __('tpedit.model_title_edit') : __('tpedit.model_title_create')" hide-footer>
        <form action="" @submit.prevent="save" v-if="editingSetting && editingSetting.condition">

            <div class="form-group row justify-content-between mb-2">
                <label class="col-sm-3 col-form-label" for="condition">{{ __('tpedit.condition') }}:</label>
                <div class="col-sm-4">
                    <select id="condition" v-model="editingSetting.condition" class="form-control" :disabled="readonly">
                        <option v-for="condition in conditions" :value="condition">{{ __(condition.name) }}</option>
                    </select>
                </div>
            </div>

            <div class="form-group row justify-content-between mb-2">
                <label class="col-sm-3 col-form-label" for="is_open">{{ __('tpedit.is_open') }}:</label>
                <div class="col-sm-4">
                    <select id="is_open" v-model="isOpen" class="form-control" :disabled="readonly">
                        <option :value="true">{{ __('tpedit.is_open_yes') }}</option>
                        <option :value="false">{{ __('tpedit.is_open_no') }}</option>
                    </select>
                </div>
            </div>

            <div class="form-group row justify-content-between mb-2" v-show="isOpen">
                <label class="col-sm-3 col-form-label" for="time_from">{{ __('tpedit.setting_from') }}:</label>
                <div class="col-sm-4">
                    <b-form-timepicker id="time_from" :locale="$root.$localization.locale" v-model="editingSetting.from" :disabled="readonly"></b-form-timepicker>
                    <!--                    <datepicker format="t" v-model="editingSetting.from" />-->
                </div>
            </div>

            <div class="form-group row justify-content-between mb-2" v-show="isOpen">
                <label class="col-sm-3 col-form-label" for="time_to">{{ __('tpedit.setting_to') }}:</label>
                <div class="col-sm-4">
                    <b-form-timepicker id="time_to" :locale="$root.$localization.locale" v-model="editingSetting.to" :disabled="readonly"></b-form-timepicker>
                </div>
            </div>

            <div class="form-group row justify-content-between mb-2" v-show="isOpen" v-if="false">
                <label class="col-sm-6 col-form-label">{{ __('tpedit.shift') }}:</label>
                <div class="col-sm-4">
                    <select class="form-control" v-model="editingSetting.shift" :disabled="readonly">
                        <option :value="null">-- {{ __('tpedit.no_shift_selected') }} --</option>
                        <option :value="shift.id" v-for="shift in defaultShifts">{{ __(shift.name) }}</option>
                    </select>
                </div>
            </div>

            <!-- Reservation Params Types -->
            <div v-if="editingSetting.params" v-show="isOpen && param.typeId !== openParamTypeId" v-for="param in editingSetting.params" class="form-group row justify-content-between mb-2">
                <label class="col-sm-6 col-form-label">{{ __(param.name) }}:</label>
                <div class="col-sm-4">
                    <select class="form-control" v-if="param.isBool" v-model="param.value" required :disabled="readonly">
                        <option value="1">{{ __('common.yes') }}</option>
                        <option value="0">{{ __('common.no') }}</option>
                    </select>

                    <input type="number" class="form-control" v-else v-model="param.value" required :disabled="readonly">
                </div>
            </div>

            <div class="form-group d-flex justify-content-between mt-5" v-if="! readonly">
                <div>
                    <button type="button" @click.prevent="remove(editingSetting)" v-show="editMode" class="btn btn-danger text-white"><i class="fa fa-trash-alt"></i> {{ __('tpedit.delete_setting') }}</button>
                </div>
                <div>
                    <button :disabled="saving" type="submit" class="btn btn-primary">
                        <i class="fa fa-spinner fa-spin" v-show="saving"></i>
                        {{ __('tpedit.save_setting') }} <span v-show="saving">{{ __('common.in_progress') }}...</span>
                    </button>

                    <button type="button" :disabled="saving" @click.prevent="$refs.tvParamsModal.hide()" class="btn btn-light">{{ __('tpedit.cancel_setting') }}</button>
                </div>
            </div>

            <div v-if="saving" class="ml-3 fade-in-delay text-right" style="--delay: 5s"><i class="fa fa-info-circle"></i> {{ __('common.still_loading') }}</div>
        </form>
    </b-modal>
</div>`;

    Vue.component('tables-params-editor', config);
    window.Kiwi.components.registerCustom('tables-params-editor', 'tables-params-editor');

    }).call();
(function() {
    const config = {
	data() {
		return {
			reservationForm: null
		}
	},
	
	mounted() {
		this.reservationForm = this.$refs.reservationForm
	}
};
    config.template = `<div class="w-100 p-4">
	<tableversum-reservation-form :owner-id="$route.params.id" ref="reservationForm"></tableversum-reservation-form>
</div>`;

    Vue.component('embed-reservation-form', config);
    window.Kiwi.components.registerCustom('embed-reservation-form', 'embed-reservation-form');

        window.Kiwi.navigation.push({path: '/reservation-forms/:id/embed', label: ''});
    window.Kiwi.router.addRoutes([{path: '/reservation-forms/:id/embed', component: config, meta: { auth: false }}]);
    }).call();
