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