!function(h,v,d){h(function(){if(void 0!==v){window.wcTracks=window.wcTracks||{},window.wcTracks.recordEvent=window.wcTracks.recordEvent||function(){};var l=!1;v.suggestions_data&&(!function t(d){var u=[];h(".marketplace-suggestions-container").each(function(){var s=this.dataset.marketplaceSuggestionsContext,t=function c(t,e){var s=_.filter(t,function(t){return _.isArray(t.context)?_.contains(t.context,e):e===t.context});return s=_.filter(s,function(t){return!_.contains(v.dismissed_suggestions,t.slug)}),s=_.filter(s,function(t){return!_.contains(v.active_plugins,t.product)}),s=_.filter(s,function(t){return!t["show-if-active"]||0<_.intersection(v.active_plugins,t["show-if-active"]).length})}(d,s),n=_.sample(t,5);for(var e in n){var a=n[e]["link-text"],o=!0;n[e]["link-text"]&&(a=n[e]["link-text"],o=!1);var i=!0;!1===n[e]["allow-dismiss"]&&(i=!1);var r=g(s,n[e].product,n[e].promoted,n[e].slug,n[e].icon,n[e].title,n[e].copy,n[e].url,a,o,i);h(this).append(r),h(this).addClass("showing-suggestion"),u.push(s),m(s)||window.wcTracks.recordEvent("marketplace_suggestion_displayed",{suggestion_slug:n[e].slug,context:s,product:n[e].product||"",promoted:n[e].promoted||"",target:n[e].url||""})}h("ul.product_data_tabs li.marketplace-suggestions_options a").click(function(t){if(t.preventDefault(),"#marketplace_suggestions"!==l&&m(s))for(var e in n)window.wcTracks.recordEvent("marketplace_suggestion_displayed",{suggestion_slug:n[e].slug,context:s,product:n[e].product||"",promoted:n[e].promoted||"",target:n[e].url||""})})}),function s(t){var e=0<_.intersection(t,["products-list-empty-body","orders-list-empty-body"]).length;e&&(h("#screen-meta-links").hide(),h("#wpfooter").hide()),e||(h('.marketplace-suggestions-container[data-marketplace-suggestions-context="products-list-empty-header"]').hide(),h('.marketplace-suggestions-container[data-marketplace-suggestions-context="products-list-empty-footer"]').hide(),h('.marketplace-suggestions-container[data-marketplace-suggestions-context="orders-list-empty-header"]').hide(),h('.marketplace-suggestions-container[data-marketplace-suggestions-context="orders-list-empty-footer"]').hide())}(u),p()}(v.suggestions_data),h("ul.product_data_tabs").on("click","li a",function(t){t.preventDefault(),l=h(this).attr("href")})),function e(){h("a.marketplace-suggestion-manage-link").on("click",function(){window.wcTracks.recordEvent("marketplace_suggestions_manage_clicked")})}()}function f(e,s,n,a,o){var t=document.createElement("a");return t.classList.add("suggestion-dismiss"),t.setAttribute("title",v.i18n_marketplace_suggestions_dismiss_tooltip),t.setAttribute("href","#"),t.onclick=function(t){t.preventDefault(),function c(t,e,s,n,a){if(h("[data-suggestion-slug="+a+"]").fadeOut(function(){h(this).remove(),p()}),jQuery.post(d,{action:"woocommerce_add_dismissed_marketplace_suggestion",_wpnonce:v.dismiss_suggestion_nonce,slug:a}),_.contains(["products-list-inline"],t)){var o="woocommerce_snooze_suggestions__"+t;Cookies.set(o,"true",{expires:2});var i="woocommerce_dismissed_suggestions__"+t,r=parseInt(Cookies.get(i),10)||0;Cookies.set(i,r+1,{expires:31})}window.wcTracks.recordEvent("marketplace_suggestion_dismissed",{suggestion_slug:a,context:t,product:e||"",promoted:s||"",target:n||""})}(e,s,n,a,o)},t}function k(t,e,s,n,a,o,i){var r=document.createElement("a"),c=function u(e,t){var s={utm_source:"unknown",utm_campaign:"marketplacesuggestions",utm_medium:"product"},n=_.findKey({productstable:["products-list-inline"],productsempty:["products-list-empty-header","products-list-empty-footer","products-list-empty-body"],ordersempty:["orders-list-empty-header","orders-list-empty-footer","orders-list-empty-body"],editproduct:["product-edit-meta-tab-header","product-edit-meta-tab-footer","product-edit-meta-tab-body"]},function(t){return _.contains(t,e)});return n&&(s.utm_source=n),t+"?"+jQuery.param(s)}(t,a);if(r.setAttribute("href",c),r.setAttribute("target","blank"),r.textContent=o,r.onclick=function(){window.wcTracks.recordEvent("marketplace_suggestion_clicked",{suggestion_slug:n,context:t,product:e||"",promoted:s||"",target:a||""})},i)r.classList.add("button");else{r.classList.add("linkout");var d=document.createElement("span");d.classList.add("dashicons","dashicons-external"),r.appendChild(d)}return r}function g(t,e,s,n,a,o,i,r,c,d,u){var l=document.createElement("div");l.classList.add("marketplace-suggestion-container"),l.dataset.suggestionSlug=n;var g=function p(t){if(!t)return null;var e=document.createElement("img");return e.src=t,e.classList.add("marketplace-suggestion-icon"),e}(a);return g&&l.appendChild(g),l.appendChild(function m(t,e,s){var n=document.createElement("div");if(n.classList.add("marketplace-suggestion-container-content"),e){var a=document.createElement("h4");a.textContent=e,n.appendChild(a)}if(s){var o=document.createElement("p");o.textContent=s,n.appendChild(o)}if(-1!==["product-edit-empty-footer-browse-all","product-edit-meta-tab-footer-browse-all"].indexOf(t)){n.classList.add("has-manage-link");var i=document.createElement("a");i.classList.add("marketplace-suggestion-manage-link","linkout"),i.setAttribute("href",v.manage_suggestions_url),i.textContent=v.i18n_marketplace_suggestions_manage_suggestions,n.appendChild(i)}return n}(n,o,i)),l.appendChild(function _(t,e,s,n,a,o,i,r){var c=document.createElement("div");if(o||(o=v.i18n_marketplace_suggestions_default_cta),c.classList.add("marketplace-suggestion-container-cta"),a&&o){var d=k(t,e,s,n,a,o,i);c.appendChild(d)}return r&&c.appendChild(f(t,e,s,a,n)),c}(t,e,s,n,r,c,d,u)),l}function p(){if(h('.marketplace-suggestions-container[data-marketplace-suggestions-context="product-edit-meta-tab-body"]').children().length<=0){', .marketplace-suggestions-container[data-marketplace-suggestions-context="product-edit-meta-tab-header"]',', .marketplace-suggestions-container[data-marketplace-suggestions-context="product-edit-meta-tab-footer"]',h('.marketplace-suggestions-container[data-marketplace-suggestions-context="product-edit-meta-tab-body"], .marketplace-suggestions-container[data-marketplace-suggestions-context="product-edit-meta-tab-header"], .marketplace-suggestions-container[data-marketplace-suggestions-context="product-edit-meta-tab-footer"]').fadeOut({complete:function(){h(".marketplace-suggestions-metabox-nosuggestions-placeholder").fadeIn()}})}}function m(t){return _.includes(["product-edit-meta-tab-header","product-edit-meta-tab-body","product-edit-meta-tab-footer"],t)}})}(jQuery,marketplace_suggestions,ajaxurl);