import Vue from 'vue';
import documentReady from '@assets/js/documentReady';

documentReady(() => {
  new Vue({
    name: 'VueTheSearchCustomer',
    delimiters: ['{', '}'],
    el: '#vue-the-search-customer',
    components: {
      TheSearch: () => import(/* webpackChunkName: "TheSearch" */ '@components/TheSearch/index.vue'),
    },

    data() {
      return {
        openTheSearch: false,
        itemsAlreadySelected: [],
      };
    },
    created() {
      window.addEventListener('vue-the-search-customer', (event) => {
        const { callbackFunction, options } = event.detail;
        Object.assign(this, {
          singleSelect: false,
          searchOnOpen: false,
        });

        if (options) {
          Object.assign(this, options);
        }
        this.openTheSearch = true;
        this.onItemsSelected = callbackFunction;
      });
    },
    methods: {
      onItemsSelected(itemsSelected) {
      },
    }
  });

  new Vue({
    name: 'VueTheSearchPaymentAddress',
    delimiters: ['{', '}'],
    el: '#vue-the-search-payment-address',
    components: {
      TheSearch: () => import(/* webpackChunkName: "TheSearch" */ '@components/TheSearch/index.vue'),
    },

    data() {
      return {
        openTheSearch: false,
        itemsAlreadySelected: [],
        aditionalParam: '',
      };
    },
    created() {
      window.addEventListener('vue-the-search-payment-address', (event) => {
        const { callbackFunction, options } = event.detail;

        Object.assign(this, {
          singleSelect: false,
          searchOnOpen: false,
        });

        if (options) {
          Object.assign(this, options);
        }

        this.openTheSearch = true;
        this.onItemsSelected = callbackFunction;
      });
    },
    methods: {
      onItemsSelected(itemsSelected) {
      },
    }
  });

  new Vue({
    name: 'VueTheSearchShippingAddress',
    delimiters: ['{', '}'],
    el: '#vue-the-search-shipping-address',
    components: {
      TheSearch: () => import(/* webpackChunkName: "TheSearch" */ '@components/TheSearch/index.vue'),
    },

    data() {
      return {
        openTheSearch: false,
        itemsAlreadySelected: [],
        aditionalParam: '',
      };
    },
    created() {
      window.addEventListener('vue-the-search-shipping-address', (event) => {
        const { callbackFunction, options } = event.detail;

        Object.assign(this, {
          singleSelect: false,
          searchOnOpen: false,
        });

        if (options) {
          Object.assign(this, options);
        }

        this.openTheSearch = true;
        this.onItemsSelected = callbackFunction;
      });
    },
    methods: {
      onItemsSelected(itemsSelected) {
      },
    }
  });
});

