function page_generator_pro_reinit_selectize(){var $;($=jQuery)(page_generator_pro_selectize.fields.freeform.join(",")).each((function(){var e=void 0!==$(this).data("delimiter")?$(this).data("delimiter"):",";$(this).selectize({plugins:["drag_drop","remove_button"],delimiter:e,persist:!1,create:function(e){return{value:e,text:e}}})})),$(page_generator_pro_selectize.fields.drag_drop.join(",")).selectize({plugins:["drag_drop","remove_button"],delimiter:",",persist:!1,create:!1}).on("change",(function(){if(void 0!==$(this).data("controls")){var e=$(this).data("controls");if(0!==e.length){var t=$(this).val();if($('select[name="'+e+'"] option').attr("disabled","disabled"),t){for(var a=0;a<t.length;a++)$('select[name="'+e+'"] option[value="'+t[a]+'"]').removeAttr("disabled");$('select[name="method"]').trigger("change.page-generator-pro")}}}})).trigger("change"),$(page_generator_pro_selectize.fields.search.join(",")).each((function(){var e=$(this).data("action"),t=$(this).data("nonce"),a=$(this).data("args"),i=$(this).data("name-field"),r=$(this).data("value-field"),n=$(this).data("method"),o=$(this).data("output-fields").split(",");$(this).selectize({delimiter:",",valueField:r,labelField:i,searchField:i,options:[],create:!1,render:{option:function(e,t){for(var a=[],i=0;i<o.length;i++)a.push(e[o[i]]);return"<div>"+a.join(", ")+"</div>"}},load:function(i,r){if(!i.length||i.length<3)return r();$.ajax({url:page_generator_pro_selectize.ajaxurl,type:n,dataType:"json",data:{action:e,nonce:t,query:i,args:a},error:function(){r()},success:function(e){r(e.data)}})}})})),$(page_generator_pro_selectize.fields.api.join(",")).each((function(){var e=this;$(e).selectize({plugins:["drag_drop","remove_button"],delimiter:",",options:[],create:!1,load:function(t,a){var r=$(e).data("action"),n=$(e).data("api-call"),o=$(e).data("api-search-field");if(api_fields=$(e).data("api-fields").split(","),country_code=$(e).data("country-code"),output_fields=$(e).data("output-fields").split(","),value_field=$(e).data("value-field"),nonce=$(e).data("nonce"),!t.length||t.length<3)return a();var s={action:r,api_call:n,api_search_field:o,query:t,country_code:$('select[name="'+country_code+'"]').length>0?$('select[name="'+country_code+'"]').val():$('input[name="'+country_code+'"]').val(),nonce:nonce};for(i=0;i<api_fields.length;i++)s[api_fields[i].replace(/[\[\]']+/g,"")]=$('select[name="'+api_fields[i]+'"]').val();$.ajax({url:page_generator_pro_selectize.ajaxurl,type:"POST",async:!0,data:s,error:function(e,t,a){return wpzinc_modal_show_error_message_and_exit(e.status+" "+e.statusText)},success:function(e){if(!e.success)return wpzinc_modal_show_error_message_and_exit(e.data.message);var t=[];for(i=0;i<e.data.data.length;i++){for(var r=[],n=0;n<output_fields.length;n++)r.push(e.data.data[i][output_fields[n]]);t.push({text:r.join(", "),value:e.data.data[i][value_field]})}a(t)}})}})})),$(page_generator_pro_selectize.fields.standard.join(",")).each((function(){var e=this,t=$(e).data("action"),a=$(e).data("api-call"),r=$(e).data("country-code"),n=$(e).data("nonce");$.ajax({url:page_generator_pro_selectize.ajaxurl,type:"POST",async:!0,data:{action:t,api_call:a,country_code:$('select[name="'+r+'"]').length>0?$('select[name="'+r+'"]').val():$('input[name="'+r+'"]').val(),nonce:n},error:function(e,t,a){return wpzinc_modal_show_error_message_and_exit(e.status+" "+e.statusText)},success:function(t){var a=$(e).data("output-fields").split(",");if(value_field=$(e).data("value-field"),!t.success)return wpzinc_modal_show_error_message_and_exit(t.data.message);var r=[];for(i=0;i<t.data.data.length;i++){for(var n=[],o=0;o<a.length;o++)n.push(t.data.data[i][a[o]]);r.push({text:n.join(", "),value:t.data.data[i][value_field]})}$(e).selectize({plugins:["drag_drop","remove_button"],options:r,create:!1,delimiter:",",load:function(e,t){t(r)}})}})}))}function page_generator_pro_destroy_selectize(){!function($){for(const[e,t]of Object.entries(page_generator_pro_selectize.fields))$(t.join(", ")).selectize().each((function(){this.selectize.destroy()}))}(jQuery)}jQuery(document).ready((function($){if(void 0!==page_generator_pro_selectize.reinit_events)for(const[e,t]of Object.entries(page_generator_pro_selectize.reinit_events))$("body").on(e,t.join(","),(function(){page_generator_pro_reinit_selectize()}))})),page_generator_pro_reinit_selectize();