System.register(["./style.scss-legacy.C7GLHoaF.js"],function(e,t){"use strict";return{setters:[null],execute:function(){!function(e,t,o){const{__:a,_x:n,sprintf:i}=e.wp.i18n;o(function(){o("#dialog").dialog({autoOpen:!1,show:{effect:"blind",duration:1e3},hide:{effect:"explode",duration:1e3}});const e=(e,t)=>{const o=document.getElementById(e);if(!o)return console.error(`Template ${e} not found`),document.createDocumentFragment();const a=o.content.cloneNode(!0);return a.querySelectorAll("*").forEach(e=>{if(e.hasAttribute("name")){const o=e.getAttribute("name")||"";e.setAttribute("name",o.replace(/\{\{ROW_INDEX\}\}/g,String(t)))}if(e.hasAttribute("value")){const o=e.getAttribute("value")||"";e.setAttribute("value",o.replace(/\{\{ROW_INDEX\}\}/g,String(t)))}if(e.hasAttribute("class")){const o=e.getAttribute("class")||"";e.setAttribute("class",o.replace(/\{\{ROW_INDEX\}\}/g,String(t)))}}),a},t=()=>{o(document.body).trigger("init_woosea_select2")},n=()=>{const e=o("tr.rowCount:last input[type=hidden]").val();return void 0!==e?Number(e):0};o(".add-field-mapping").on("click",function(){const a=n(),i=o("#addrow").val(),r=Number(a)+Number(i),d=Number(i)+Number(1);o("#addrow").val(d);const l=e("adt-field-mapping-row-template",r);o("#woosea-fieldmapping-table tbody").append(l),t()}),o(".add-own-mapping").on("click",function(){const a=n(),i=o("#addrow").val(),r=Number(a)+Number(i),d=Number(i)+Number(1);o("#addrow").val(d);const l=e("adt-custom-field-mapping-row-template",r);o("#woosea-fieldmapping-table tbody").append(l),t()}),o("#savebutton").on("click",function(){let e=!0,t="";var n;o("#own-input-field").each(function(){const n=(e=>(e.indexOf("PARAM_")>=0?/.*/:/^[a-zA-Zа-яА-Я_-]*$/).test(e)?e.length<2?{valid:!1,message:i(a("Sorry, your custom field name needs to be at least %d letters long.","woo-product-feed-pro"),2)}:e.length>50?{valid:!1,message:i(a("Sorry, your custom field name cannot be over %d letters long.","woo-product-feed-pro"),50)}:{valid:!0}:{valid:!1,message:a("Sorry, when creating new custom fields only letters are allowed (so no white spaces, numbers or any other character are allowed).","woo-product-feed-pro")})(o(this).val());if(!n.valid)return e=!1,t=n.message||"",!1}),e?o("#fieldmapping")[0].submit():(o("form").submit(function(e){return e.preventDefault(),!1}),n=t,o(".notice").replaceWith(`<div class='notice notice-error is-dismissible'><p>${n}</p></div>`))}),o(document).on("change",".select-field",function(){const e=o(this),a=e.closest(".adt-field-mapping-select-field-wrapper"),n=a.find(".adt-static-value-wrapper"),i=a.find(".adt-page-url-attribute-wrapper"),r=a.find(".adt-post-url-attribute-wrapper"),d=n.find('input[type="text"]'),l=n.find('input[type="hidden"]'),s=i.find(".adt-page-url-select"),p=i.find('input[type="hidden"]'),c=r.find(".adt-post-url-select"),u=r.find('input[type="hidden"]');switch(n.hide(),d.prop("disabled",!0).val(""),l.prop("disabled",!0).val("false"),i.hide(),s.prop("disabled",!0).val(""),p.prop("disabled",!0).val("false"),r.hide(),c.prop("disabled",!0).val(""),u.prop("disabled",!0).val("false"),e.val()){case"static_value":n.show(),d.prop("disabled",!1),l.val("true"),l.prop("disabled",!1),d.focus();break;case"page_url":i.show(),s.prop("disabled",!1),p.val("true"),p.prop("disabled",!1),t();break;case"post_url":r.show(),c.prop("disabled",!1),u.val("true"),u.prop("disabled",!1),t()}}),o(".delete-field-mapping").on("click",function(){confirm(a("Are you sure you want to delete the selected field mappings?","woo-product-feed-pro"))&&o("table tbody").find('input[name="record"]').each(function(){o(this).is(":checked")&&o(this).parents("tr").remove()})})})}(window,document,jQuery)}}});
