(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
"use strict";

Vue.component('date-picker', DatePicker["default"]);

Vue.component('wpcfto_dates', {
    mixins: [window.validationMixin],
  props: ['fields', 'field_label', 'field_name', 'field_id', 'field_value', 'required'],
  data() {
    return {
      value: [],
      saveValue: []
    };
  },
  mounted() {
    if (typeof this.field_value !== 'undefined') {
      if (typeof this.field_value[0] !== 'undefined') {
        this.saveValue.push(this.field_value[0]);
        this.value.push(new Date(parseInt(this.field_value[0])));
      }
      if (typeof this.field_value[1] !== 'undefined') {
        this.saveValue.push(this.field_value[1]);
        this.value.push(new Date(parseInt(this.field_value[1])));
      }
    }
  },
  methods: {
    dateChanged(newDate) {
      if (!newDate || !newDate.length) {
        this.saveValue = [];
        this.$emit('wpcfto-get-value', []);
        return;
      }
      const customDate = [];
      if (newDate[0]) customDate.push(new Date(newDate[0]).getTime());
      if (newDate[1]) customDate.push(new Date(newDate[1]).getTime());
      this.saveValue = customDate;
      this.$emit('wpcfto-get-value', customDate);
    }
  },
  template: `
    <div class="wpcfto_generic_field wpcfto_generic_field_flex_input wpcfto_generic_field__date">

      <wpcfto_fields_aside_before 
        :fields="fields" 
        :field_label="field_label"
        :class="{ 'wpcfto-required-field': fields.required }"
        :data-field-id="field_id"
        :required="fields.required === true">
      </wpcfto_fields_aside_before>

      <div class="wpcfto-field-content">
        <div class="wpcfto_datepicker">
          <date-picker v-model="value" range lang="en" @change="dateChanged"></date-picker>

        </div>
        <input type="hidden" 
               :name="field_name" 
               v-model="saveValue"
               :required="fields.required === true" />
        <input type="hidden" 
               :name="field_name + '_start'" 
               v-model="saveValue[0]" />
        <input type="hidden" 
               :name="field_name + '_end'" 
               v-model="saveValue[1]" />
      </div>
      <wpcfto_fields_aside_after :fields="fields"></wpcfto_fields_aside_after>
    </div>
  `
});


//# sourceMappingURL=data:application/json;charset=utf-8;base64,[encoded data, 4968 characters]
},{}]},{},[1])