(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('wpcfto_image', {
    props: ['fields', 'field_label', 'field_name', 'field_id', 'field_value', 'required'],
    mixins: [wpcfto_get_image_mixin],
    data: function data() {
      return {
        value: '',
        media_modal: '',
        image_url: ''
      };
    },
    mounted: function mounted() {
      var vm = this;
      vm.value = vm.field_value;
    },
    template: `
      <div class="wpcfto_generic_field wpcfto_generic_field_image">
        <wpcfto_fields_aside_before 
          :fields="fields" 
          :field_label="field_label"
          :required="fields.required === true">
        </wpcfto_fields_aside_before>
  
        <div class="wpcfto-field-content">
          <div class="wpcfto-image" :class="{ 'has-image' : image_url && wpcfto_checkURL(image_url) }">
            <input type="text" 
                   v-model="image_url" 
                   class="wpcfto-input-url" 
                   :placeholder="fields.placeholder ? fields.placeholder : 'Enter image URL or click upload...'"
                   :required="fields.required === true" />
  
            <div class="image-field" v-if="image_url && wpcfto_checkURL(image_url)">
              <img :src="image_url" v-if="wpcfto_checkURL(image_url)"/>
            </div>
            <div class="actions">
              <div class="button" v-if="!image_url || !wpcfto_checkURL(image_url)" @click="addImage()">
                <i class="fa fa-upload"></i>Upload
              </div>
              <div class="button" v-if="image_url && wpcfto_checkURL(image_url)" @click="addImage()">
                <i class="fa fa-upload"></i>Replace
              </div>
              <div class="button button-remove" v-if="image_url && wpcfto_checkURL(image_url)" @click="removeImage()">
                <i class="fa fa-times"></i>Remove
              </div>
            </div>
          </div>
  
          <input type="hidden"
                 :name="field_name"
                 v-model="value" />
        </div>
  
        <wpcfto_fields_aside_after :fields="fields"></wpcfto_fields_aside_after>
      </div>
    `,
    methods: {
      addImage: function addImage() {
        this.media_modal = wp.media({
          frame: 'select',
          multiple: false,
          editing: true
        });
        this.media_modal.on('select', function (value) {
          var attachment = this.media_modal.state().get('selection').first().toJSON();
          this.value = attachment.id;
          this.image_url = attachment.url;
        }, this);
        this.media_modal.open();
      },
      removeImage: function removeImage() {
        this.value = this.image_url = '';
      }
    },
    watch: {
      value: function value(_value) {
        this.$emit('wpcfto-get-value', _value);
      }
    }
  });
  
//# sourceMappingURL=data:application/json;charset=utf-8;base64,[encoded data, 6296 characters]
},{}]},{},[1])