(e=>{"function"==typeof define&&define.amd?define("myListings",e):e()})(function(){function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}jQuery(function(n){var t={listing_id:null,listing_name:null,package_id:null},a=n("#promo-modal .sign-in-box"),i=(n(".listing-dashboard-action-promote").click(function(e){t.listing_id=n(e.target).data("listing-id"),t.listing_name=n(e.target).data("listing-name"),n("#promo-modal .listing-name").text('"'+t.listing_name+'"')}),n("#promo-modal .promo-product-item, .promo-product-item .process-promotion").click(function(e){e.preventDefault();e=n(e.currentTarget);if(e.data("package-id")&&(t.package_id=e.data("package-id")),e.data("listing-id")&&(t.listing_id=e.data("listing-id")),e.data("process")?t.process=e.data("process"):t.process="buy-package","cancel-package"===t.process&&!confirm(CASE27.l10n.irreversible_action))return!1;a.addClass("cts-processing-login"),jQuery.ajax({url:"".concat(CASE27.mylisting_ajax_url,"&action=cts_promotions&security=").concat(CASE27.ajax_nonce),type:"POST",dataType:"json",data:{listing_id:t.listing_id,package_id:t.package_id,process:t.process},success:function(e){"object"===r(e)&&(e.redirect&&window.location.replace(e.redirect),"error"===e.status)&&e.message&&alert(e.message)},error:function(e,t,n){console.log("Failed",e,t,n)},complete:function(){a.removeClass("cts-processing-login")}})}),n(".cts-listing-action-duplicate a").on("click",function(e){e.preventDefault();var t=n(e.target);t.parents(".listing-cell").addClass("cell-busy"),n.ajax({url:"".concat(CASE27.mylisting_ajax_url,"&action=post_duplicate&security=").concat(CASE27.ajax_nonce),type:"POST",dataType:"json",data:{listing_id:t.data("listing-id")},success:function(e){t.parents(".listing-cell").removeClass("cell-busy"),e&&e.success&&e.redirect&&window.location.replace(e.redirect)},error:function(){t.parents(".listing-cell").removeClass("cell-busy")}})}),n(".cts-listing-action-status a").on("click",function(e){e.preventDefault();var t=n(e.target);t.parents(".listing-cell").addClass("cell-busy"),n.ajax({url:"".concat(CASE27.mylisting_ajax_url,"&action=post_status&security=").concat(CASE27.ajax_nonce),type:"POST",dataType:"json",data:{listing_id:t.data("listing-id")},success:function(e){t.parents(".listing-cell").removeClass("cell-busy"),e&&e.success&&e.redirect&&window.location.replace(e.redirect)},error:function(){t.parents(".listing-cell").removeClass("cell-busy")}})}),document.querySelector(".filter-listing-type-select")),c=document.querySelector(".filter-listings-select"),l=document.querySelector(".filter-stats-select"),o=document.querySelector('input[name="search"]'),e=document.querySelector(".search-my-listings form");function s(){var e=null==i?void 0:i.value,t=null==c?void 0:c.value,n=null==l?void 0:l.value,a=[];if(e&&(e=new URL(e).searchParams.get("filter_by_type"))&&a.push("filter_by_type=".concat(e)),t){var e=new URL(t).searchParams.get("status");if(e)a.push("status=".concat(e));else{e=null==c?void 0:c.options[c.selectedIndex];if(null!=e&&e.classList.contains("claim-requests"))return void(window.location.href=t)}}n&&(e=new URL(n).searchParams.get("state_type"))&&a.push("state_type=".concat(e));var t=a.join("&"),n=null==o?void 0:o.value,e=n?"search=".concat(n):"",n=(null==i||null==(a=i.querySelector(":first-child"))?void 0:a.value)||(null==l||null==(n=l.querySelector(":first-child"))?void 0:n.value)||(null==c||null==(a=c.querySelector(":first-child"))?void 0:a.value);window.location.href=t||e?"".concat(n,"?").concat(t).concat(e?"&".concat(e):""):n}i&&(i.onchange=s),l&&(l.onchange=s),c&&(c.onchange=s),e&&e.addEventListener("submit",function(e){e.preventDefault(),s()}),n(".dashboard-filter-stats").change(function(e){e.preventDefault();var t=n(this).data("url");parseInt(e.target.value,10)&&(t+="?listing="+parseInt(e.target.value,10)),window.location.href=t}),n(".job-dashboard-action-delete").click(function(){return window.confirm(CASE27.l10n.irreversible_action)})})});
