(()=>{"use strict";const e=window.lodash;jQuery(document).ready((function(){const t=pcpricatData.taxonomies,n=wp.template("pcpricat-select-primary-term");function c(e,t,n){const c=jQuery(`#pcpricat-primary-term-${e}`),o=jQuery("<option></option>");o.prop("value",t),o.html(n.trim()),c.append(o)}function o(e,t){jQuery(`#pcpricat-primary-term-${e}`).find(`option[value=${t}]`).remove()}jQuery((0,e.values)(t)).each((function(e,t){const i=jQuery(`#taxonomy-${t.name}`),r=n({taxonomy:t});i.append(r),function(e){const t=jQuery(`#${e}checklist input[type="checkbox"]`);1>t.length||t.each((function(t,n){(n=jQuery(n)).is(":checked")||o(e,n.val())}))}(t.name),i.on("click",'input[type="checkbox"]',function(e){return function(){jQuery(this).is(":checked")?c(e,jQuery(this).val(),jQuery(this).parent().text()):o(e,jQuery(this).val())}}(t.name)),i.on("wpListAddEnd",`#${t.name}checklist`,function(e){return function(){const t=jQuery(`#${e}checklist input[type="checkbox"]:checked`);if(1>t.length)return;const n=jQuery(`#pcpricat-primary-term-${e}`);t.each((function(t,o){o=jQuery(o),n.find(`option[value=${o.val()}]`).length||c(e,o.val(),o.parent().text())}))}}(t.name))}))}))})();