exports.ids = [30];
exports.modules = {

/***/ 117:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);

// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/pug-plain-loader??ref--1-oneOf-0-0!./node_modules/vue-loader/lib??vue-loader-options!./pages/add/ImportDialog.vue?vue&type=template&id=0fb47312&lang=pug&
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('v-card',[_c('v-card-title',[_vm._v(_vm._s(_vm.$t('common.import')))]),_c('v-card-text',[_c('p',{domProps:{"innerHTML":_vm._s(_vm.$t('event.import_description'))}}),_c('v-form',{ref:"form",attrs:{"lazy-validation":""},on:{"submit":function($event){$event.preventDefault();return _vm.importGeneric.apply(null, arguments)}},model:{value:(_vm.valid),callback:function ($$v) {_vm.valid=$$v},expression:"valid"}},[_c('v-row',[_c('div',{staticClass:"col-xl-5 col-lg-5 col-md-7 col-sm-12 col-xs-12"},[_c('v-text-field',{attrs:{"label":_vm.$t('common.url'),"hint":_vm.$t('event.import_URL'),"persistent-hint":"","loading":_vm.loading,"error":_vm.error,"error-messages":_vm.errorMessage},model:{value:(_vm.URL),callback:function ($$v) {_vm.URL=$$v},expression:"URL"}})],1),_c('div',{staticClass:"col"},[_c('v-file-input',{attrs:{"accept":".ics","label":_vm.$t('event.ics'),"hint":_vm.$t('event.import_ICS'),"persistent-hint":""},model:{value:(_vm.file),callback:function ($$v) {_vm.file=$$v},expression:"file"}})],1)])],1)],1),_c('v-card-actions',[_c('v-spacer'),_c('v-btn',{attrs:{"text":"","color":"warning"},on:{"click":function($event){return _vm.$emit("close")}}},[_vm._v(_vm._s(_vm.$t('common.cancel')))]),_c('v-btn',{attrs:{"text":"","loading":_vm.loading,"disabled":_vm.loading,"color":"primary"},on:{"click":_vm.importGeneric}},[_vm._v(_vm._s(_vm.$t('common.import')))])],1)],1)}
var staticRenderFns = []


// CONCATENATED MODULE: ./pages/add/ImportDialog.vue?vue&type=template&id=0fb47312&lang=pug&

// EXTERNAL MODULE: external "ical.js"
var external_ical_js_ = __webpack_require__(64);
var external_ical_js_default = /*#__PURE__*/__webpack_require__.n(external_ical_js_);

// EXTERNAL MODULE: external "lodash/get"
var get_ = __webpack_require__(59);
var get_default = /*#__PURE__*/__webpack_require__.n(get_);

// EXTERNAL MODULE: external "vuex"
var external_vuex_ = __webpack_require__(3);

// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--2-0!./node_modules/babel-loader/lib??ref--2-1!./node_modules/vue-loader/lib??vue-loader-options!./pages/add/ImportDialog.vue?vue&type=script&lang=js&
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//



/* harmony default export */ var ImportDialogvue_type_script_lang_js_ = ({
  name: 'ImportDialog',

  data() {
    return {
      file: null,
      errorMessage: '',
      error: false,
      loading: false,
      valid: false,
      URL: '',
      event: {}
    };
  },

  computed: Object(external_vuex_["mapState"])(['places']),
  methods: {
    importGeneric() {
      if (this.file) {
        this.importICS();
      } else {
        this.importURL();
      }
    },

    importICS() {
      const reader = new FileReader();
      reader.readAsText(this.file);

      reader.onload = () => {
        const ret = external_ical_js_default.a.parse(reader.result);
        const component = new external_ical_js_default.a.Component(ret);
        const events = component.getAllSubcomponents('vevent');
        const event = new external_ical_js_default.a.Event(events[0]);
        this.event = {
          title: get_default()(event, 'summary', ''),
          description: get_default()(event, 'description', ''),
          place: {
            name: get_default()(event, 'location', '')
          },
          start_datetime: get_default()(event, 'startDate', '').toUnixTime(),
          end_datetime: get_default()(event, 'endDate', '').toUnixTime()
        };
        this.$emit('imported', this.event);
      };
    },

    async importURL() {
      if (!this.URL) {
        this.errorMessage = this.$validators.required('common.url')('');
        this.error = true;
        return;
      }

      if (!this.URL.match(/^https?:\/\//)) {
        this.URL = `https://${this.URL}`;
      }

      this.error = false;
      this.errorMessage = '';
      this.loading = true;

      try {
        const ret = await this.$axios.$get('/event/import', {
          params: {
            URL: this.URL
          }
        });
        this.events = ret; // check if contain an h-event

        this.$emit('imported', ret[0]);
      } catch (e) {
        this.error = true;
        this.errorMessage = String(e);
      }

      this.loading = false;
    }

  }
});
// CONCATENATED MODULE: ./pages/add/ImportDialog.vue?vue&type=script&lang=js&
 /* harmony default export */ var add_ImportDialogvue_type_script_lang_js_ = (ImportDialogvue_type_script_lang_js_); 
// EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
var componentNormalizer = __webpack_require__(1);

// CONCATENATED MODULE: ./pages/add/ImportDialog.vue





/* normalize component */

var ImportDialog_component = Object(componentNormalizer["a" /* default */])(
  add_ImportDialogvue_type_script_lang_js_,
  render,
  staticRenderFns,
  false,
  null,
  null,
  "700b9782"
  
)

/* harmony default export */ var ImportDialog = __webpack_exports__["default"] = (ImportDialog_component.exports);

/***/ })

};;
//# sourceMappingURL=ImportDialog.js.map