/* empty css                   */function A(){import.meta.url,import("_").catch(()=>1),async function*(){}().next()}(function(i,F,t){const{__:s,_x:k,sprintf:m}=i.wp.i18n;t(function(){const v=i.adtObj.feed_id;let g=i.adtObj.feed_data,u=(g==null?void 0:g.status)||"",h;const b=()=>new URLSearchParams(window.location.search).get("tab")||"general",c=(e,r,a="",n=!1)=>{t(".woosea-admin-notice").remove();const o=n?'<span class="adt-loader adt-loader-secondary adt-loader-sm adt-tw-inline-block"></span>':"",d="notice notice-".concat(r," is-dismissible woosea-admin-notice"),p='\n        <div class="'.concat(d,'" id="').concat(a,'">\n          <p style="display: flex; align-items: center; gap: 8px;">').concat(o).concat(e,'</p>\n          <button type="button" class="notice-dismiss">\n            <span class="screen-reader-text">').concat(s("Dismiss this notice.","woo-product-feed-pro"),"</span>\n          </button>\n        </div>\n      ");t("#adt-edit-feed .tab-content").prepend(p),t(".woosea-admin-notice .notice-dismiss").on("click",function(){t(this).closest(".woosea-admin-notice").fadeOut(300,function(){t(this).remove()})})},l=()=>!new URLSearchParams(window.location.search).has("id"),_=(e=!1)=>{if(!t("#projectname").length)return!0;const a=t("#projectname").val(),n=typeof a=="string"?a:"",o=/^[a-zA-Z0-9-_.àèìòùÀÈÌÒÙáéíóúýÁÉÍÓÚÝâêîôûÂÊÎÔÛãñõÃÑÕäëïöüÿÄËÏÖÜŸçÇßØøÅåÆæœ ]*$/,d=3,p=30;return o.test(n)?n.length<d?(e&&c(m(s("Sorry, your project name needs to be at least %d characters long.","woo-product-feed-pro"),d),"error"),!1):n.length>p?(e&&c(m(s("Sorry, your project name cannot be over %d characters long.","woo-product-feed-pro"),p),"error"),!1):!0:(e&&c(s("Sorry, only letters, numbers, whitespaces, -, . and _ are allowed for the projectname","woo-product-feed-pro"),"error"),!1)},P=()=>{const e=b();if(l()&&e==="conversion_analytics"){let r=!0,a=[];return t.ajax({url:i.ajaxurl,type:"POST",async:!1,data:{action:"check_temp_feed_required_fields",nonce:i.adtObj.adtNonce},success:function(n){n.success===!1&&(r=!1,n.data&&n.data.errors&&Array.isArray(n.data.errors)&&n.data.errors.forEach(o=>{a.push(o)}))},error:function(){r=!1,a.push(s("Could not validate feed configuration. Please try again.","woo-product-feed-pro"))}}),r||c(a.join("<br>"),"error"),r}return!0},S=()=>{h||(h=setInterval(()=>{j(v)},1e4))},j=e=>{const r=[e];t.ajax({url:i.ajaxurl,type:"POST",data:{action:"adt_get_feed_processing_status",nonce:i.adtObj.adtNonce,feed_ids:r}}).done(a=>{if(a.success){const n=Array.isArray(a.data)?a.data.find(o=>String(o.feed_id)===String(e)):null;u=(n==null?void 0:n.status)||"",y(),x(),w()}})},w=()=>{const e=u==="processing"?"disabled":"enabled";t(".adt-edit-feed-form").find('button[type="submit"]').prop("disabled",e==="disabled")},x=()=>{t("#adt-edit-feed").attr("data-status",u)},y=()=>{u==="processing"?c(s("Feed is currently processing. Please wait for the feed generation to complete before making changes.","woo-product-feed-pro"),"error","feed-processing-notice",!0):t(".woosea-admin-notice#feed-processing-notice").remove()};(()=>{l()||(S(),y(),w())})(),t(".adt-edit-feed-form").on("submit",function(e){const r=b();if(r==="general"){if(!_(!0))return e.preventDefault(),!1}else if(r==="conversion_analytics"&&l()&&!P())return e.preventDefault(),window.scrollTo(0,0),!1;if(t("#rulevalue").length){const a=t("#rulevalue").val(),n=typeof a=="string"?a:"",o=1,d=200;if(n.length<o)return c(s("Sorry, rule value minimum length is 1 character","woo-product-feed-pro"),"error"),e.preventDefault(),!1;if(n.length>d)return c(m(s("Sorry, rule value cannot be over %d characters long.","woo-product-feed-pro"),d),"error"),e.preventDefault(),!1}return!0});const L=e=>{if(!e||!e.startsWith("http"))return!1;try{const r=new URL(window.location.href),a=new URL(e),n=r.searchParams.get("page");return a.searchParams.get("page")==="adt-edit-feed"}catch(r){return!1}};let f=!1;l()&&(t(".adt-edit-feed-form").on("submit",function(){f=!0}),t(".woo-product-feed-pro-nav-tab-wrapper .nav-tab").on("click",function(){const e=t(this).attr("href");e&&L(e)&&(f=!0,setTimeout(()=>{f=!1},100))}),t(window).on("beforeunload",function(e){if(!f){const r=s("Leaving this page will result in losing your feed configuration. Are you sure you want to leave?","woo-product-feed-pro");return e.returnValue=r,r}}))})})(window,document,jQuery);export{A as __vite_legacy_guard};
