System.register(["../../../common/index-legacy.sLMPZLm9.js","./style.scss-legacy.CRyeoVl3.js"],(function(e,t){"use strict";var a,o;return{setters:[e=>{a=e.s,o=e.a},null],execute:function(){((e,t,s)=>{const{__:c}=e.wp.i18n;s((()=>{s(".product-question-related-product").select2({ajax:{url:a().productsUrl,dataType:"json",delay:300,headers:{"X-WP-Nonce":a().wpNonce},data:e=>({search:e.term,page:e.page||1}),processResults:e=>({results:e.map((e=>({id:e.id,text:e.name})))})},placeholder:c("Search for related product","storeagent-ai-for-woocommerce")})})),s(document).on("click",".saai-product-data-sources-container .add-data-source",(function(){const e=s(".saai-product-data-sources-container");e.find(".data-sources-list").append(`\n        <div class="data-source-item">\n          <input type="url" name="saai_product_questions_data_sources[]" class="widefat" placeholder="${c("Enter page URL or select a post/page","storeagent-ai-for-woocommerce")}" />\n          <button type="button" class="button remove-data-source">\n            ${c("Remove","storeagent-ai-for-woocommerce")}\n          </button>\n        </div>\n      `),s(".data-source-item input").trigger("saai_init_autocomplete")})),s(document).on("click",".saai-product-data-sources-container .remove-data-source",(function(){s(this).closest(".data-source-item").remove()})),s(document).on("saai_init_autocomplete",".saai-product-data-sources-container .data-source-item input",(function(){s(this).autocomplete({source:function(e,t){o(e.term).then((e=>{t(e)}))}})})),s(".saai-product-data-sources-container .data-source-item input").trigger("saai_init_autocomplete")})(window,document,jQuery)}}}));
