;

jQuery(window).on('elementor:init', function() {

    'use strict';

    var e = elementor.modules.controls.BaseData.extend({

        onReady: function() {

            var e = this,

                t = e.ui.select,

                n = t.attr('data-ajax-url');

            t.select2({ ajax: { url: n, dataType: 'json', data: function(e) { var t = { s: e.term, }; return t } }, cache: !0 });

            var a = (typeof e.getControlValue() !== 'undefined') ? e.getControlValue() : '';

            if (a.isArray) { a = e.getControlValue().join() };

            jQuery.ajax({ url: n, dataType: 'json', data: { ids: String(a) } }).then(function(e) {

                if (e !== null && e.results.length > 0) {

                    jQuery.each(e.results, function(e, a) {

                        var n = new Option(a.text, a.id, !0, !0);

                        t.append(n).trigger('change')

                    });

                    t.trigger({ type: 'select2:select', params: { data: e } })

                }

            })

        },

        onBeforeDestroy: function() {

            if (this.ui.select.data('select2')) { this.ui.select.select2('destroy') };

            this.$el.remove()

        }

    });

    elementor.addControlView('ajaxselect2', e)

});