File "marketplace.js"
Full Path: /home/jlklyejr/public_html/wp-content/test/wp-content/plugins/woocommerce/assets/client/admin/chunks/marketplace.js
File size: 74.61 KB
MIME-type: text/plain
Charset: utf-8
"use strict";(globalThis.webpackChunk_wcAdmin_webpackJsonp=globalThis.webpackChunk_wcAdmin_webpackJsonp||[]).push([[9669],{73224:(e,t,o)=>{o.d(t,{Z:()=>a});var c=o(69307),r=o(70444);const a=(0,c.createElement)(r.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,c.createElement)(r.Path,{d:"M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"}))},86241:(e,t,o)=>{o.d(t,{Z:()=>a});var c=o(69307),r=o(70444);const a=(0,c.createElement)(r.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,c.createElement)(r.Path,{d:"M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z"}))},84560:(e,t,o)=>{o.d(t,{Z:()=>a});var c=o(69307),r=o(70444);const a=(0,c.createElement)(r.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,c.createElement)(r.Path,{d:"M12 3.2c-4.8 0-8.8 3.9-8.8 8.8 0 4.8 3.9 8.8 8.8 8.8 4.8 0 8.8-3.9 8.8-8.8 0-4.8-4-8.8-8.8-8.8zm0 16c-4 0-7.2-3.3-7.2-7.2C4.8 8 8 4.8 12 4.8s7.2 3.3 7.2 7.2c0 4-3.2 7.2-7.2 7.2zM11 17h2v-6h-2v6zm0-8h2V7h-2v2z"}))},85797:(e,t,o)=>{o.d(t,{Z:()=>a});var c=o(69307),r=o(70444);const a=(0,c.createElement)(r.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,c.createElement)(r.Path,{d:"M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"}))},25918:(e,t,o)=>{o.d(t,{Z:()=>a});var c=o(69307),r=o(70444);const a=(0,c.createElement)(r.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,c.createElement)(r.Path,{fillRule:"evenodd",d:"M6.5 8a1.5 1.5 0 103 0 1.5 1.5 0 00-3 0zM8 5a3 3 0 100 6 3 3 0 000-6zm6.5 11a1.5 1.5 0 103 0 1.5 1.5 0 00-3 0zm1.5-3a3 3 0 100 6 3 3 0 000-6zM5.47 17.41a.75.75 0 001.06 1.06L18.47 6.53a.75.75 0 10-1.06-1.06L5.47 17.41z",clipRule:"evenodd"}))},38582:(e,t,o)=>{o.r(t),o.d(t,{default:()=>Lt});var c=o(69307),r=o(61935);const a=(0,c.createContext)({isLoading:!1,setIsLoading:()=>{},selectedTab:"",setSelectedTab:()=>{},isProductInstalled:()=>!1,addInstalledProduct:()=>{}});function n(e){const[t,o]=(0,c.useState)(!0),[n,s]=(0,c.useState)(""),[l,i]=(0,c.useState)([]);(0,c.useEffect)((()=>{const e=(0,r.O3)("wccomHelper",{}),t=e?.installedProducts;i(t)}),[]);const m={isLoading:t,setIsLoading:o,selectedTab:n,setSelectedTab:s,isProductInstalled:function(e){return l.includes(e)},addInstalledProduct:function(e){i([...l,e])}};return(0,c.createElement)(a.Provider,{value:m},e.children)}var s=o(65736);function l(){return(0,c.createElement)("h1",{className:"woocommerce-marketplace__header-title"},(0,s.__)("Extensions","woocommerce"))}var i=o(55609),m=o(70444);const u=(0,c.createElement)(m.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,c.createElement)(m.Path,{fillRule:"evenodd",d:"M7.25 16.437a6.5 6.5 0 1 1 9.5 0V16A2.75 2.75 0 0 0 14 13.25h-4A2.75 2.75 0 0 0 7.25 16v.437Zm1.5 1.193a6.47 6.47 0 0 0 3.25.87 6.47 6.47 0 0 0 3.25-.87V16c0-.69-.56-1.25-1.25-1.25h-4c-.69 0-1.25.56-1.25 1.25v1.63ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm10-2a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z",clipRule:"evenodd"}));var p=o(23374),d=o(12532);const _=(0,c.createElement)(m.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,c.createElement)(m.Path,{d:"M15.6 7.3h-.7l1.6-3.5-.9-.4-3.9 8.5H9v1.5h2l-1.3 2.8H8.4c-2 0-3.7-1.7-3.7-3.7s1.7-3.7 3.7-3.7H10V7.3H8.4c-2.9 0-5.2 2.3-5.2 5.2 0 2.9 2.3 5.2 5.2 5.2H9l-1.4 3.2.9.4 5.7-12.5h1.4c2 0 3.7 1.7 3.7 3.7s-1.7 3.7-3.7 3.7H14v1.5h1.6c2.9 0 5.2-2.3 5.2-5.2 0-2.9-2.4-5.2-5.2-5.2z"}));function g(e){const{setIsModalOpen:t,disconnectURL:o}=e,[r,a]=(0,c.useState)(!1),n=()=>t(!1);return(0,c.createElement)(i.Modal,{title:(0,s.__)("Are you sure?","woocommerce"),onRequestClose:n,focusOnMount:!0,className:"woocommerce-marketplace__header-account-modal",style:{borderRadius:4},overlayClassName:"woocommerce-marketplace__header-account-modal-overlay"},(0,c.createElement)("p",{className:"woocommerce-marketplace__header-account-modal-text"},(0,s.__)("Keep your your account connected to manage your subscriptions, get updates and support for your extensions and themes.","woocommerce")),(0,c.createElement)(i.ButtonGroup,{className:"woocommerce-marketplace__header-account-modal-button-group"},(0,c.createElement)(i.Button,{variant:"tertiary",href:o,onClick:()=>a(!r),isBusy:r,isDestructive:!0,className:"woocommerce-marketplace__header-account-modal-button"},(0,s.__)("Disconnect account","woocommerce")),(0,c.createElement)(i.Button,{variant:"primary",onClick:n,className:"woocommerce-marketplace__header-account-modal-button"},(0,s.__)("Keep connected","woocommerce"))))}const w="discover",y="https://woo.com",E="/extensions",N="/wp-json/wccom-extensions/1.0/search",h="/wp-json/wccom-extensions/1.0/categories",M=60,v=8,k=y+"/cart/",b=y+"/document/managing-woocommerce-com-subscriptions/#transfer-a-woocommerce-com-subscription",f=r.SX+"/plugins.php";var I=o(86989),x=o.n(I),T=o(9818);let D=function(e){return e.theme="theme",e.extension="extension",e}({}),C=function(e){return e.theme="theme",e.extension="extension",e.all="all",e}({}),z=function(e){return e.Success="success",e.Error="error",e}({});const A={notices:{}},S=(0,T.createReduxStore)("woocommerce-admin/subscription-notices",{reducer(e=A,t){switch(t.type){case"ADD_NOTICE":return{...e,notices:{...e.notices,[t.productKey]:{productKey:t.productKey,message:t.message,status:t.status,options:t.options}}};case"REMOVE_NOTICE":const o={...e.notices};return o[t.productKey]&&delete o[t.productKey],{...e,notices:o}}return e},actions:{addNotice:(e,t,o,c)=>({type:"ADD_NOTICE",productKey:e,message:t,status:o,options:c}),removeNotice:e=>({type:"REMOVE_NOTICE",productKey:e})},selectors:{notices:e=>e?Object.values(e.notices):[],getNotice(e,t){if(e)return e.notices[t]}}});(0,T.register)(S);const j=100,L=new Map;function O(){for(;L.size>j;)L.delete(L.keys().next().value)}async function Q(e,t){return L.get(e)?new Promise((t=>{t(L.get(e))})):new Promise(((o,c)=>{fetch(e,{signal:t}).then((e=>{if(!e.ok)throw new Error(e.statusText);return e.json()})).then((t=>{L.set(e,t),O(),o(t)})).catch((()=>{c()}))}))}async function P(){let e="/wc/v3/marketplace/featured";r.MV.userLocale&&(e=`${e}?locale=${r.MV.userLocale}`);try{return await async function(e){const t=JSON.stringify(e);return L.get(t)?new Promise((e=>{e(L.get(t))})):new Promise(((o,c)=>{x()(e).then((e=>{L.set(t,e),O(),o(e)})).catch((()=>{c()}))}))}({path:e.toString()})}catch(e){return[]}}function U(e){if(!0===e.active)return Promise.resolve();const t=new URLSearchParams;return t.append("product_key",e.product_key),x()({path:"/wc/v3/marketplace/subscriptions/connect".toString(),method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:t})}function Y(e,t){return new Promise(((o,c)=>{window.wp.updates?window.wp.updates.ajax(e,{...t,success:e=>{o({success:!0,data:e})},error:e=>{c({success:!1,data:{message:e.errorMessage}})}}):c((0,s.__)("Please reload and try again","woocommerce"))}))}function Z(e,t){return Y("install-"+e,{slug:t})}function R(e,t,o,r){o===z.Error?(0,T.dispatch)(S).addNotice(e,t,o,r):(r?.icon||(r={...r,icon:(0,c.createElement)(i.Icon,{icon:"saved"})}),(0,T.dispatch)("core/notices").createSuccessNotice(t,r))}const B=e=>{(0,T.dispatch)(S).removeNotice(e)},G=e=>({id:e.product_id,title:e.product_name,image:"",type:e.product_type,description:"",vendorName:"",vendorUrl:"",icon:e.product_icon,url:e.product_url,price:-1,averageRating:null,reviewsCount:null,isInstallable:!1}),V=(e,t)=>{if(!e)return e;const o=new URL(e);return o?(t.forEach((([e,t])=>{o.searchParams.set(e,t)})),o.toString()):e},F=e=>V(k,[["renew_product",e.product_id.toString()],["product_key",e.product_key],["order_id",e.order_id.toString()]]),H=e=>V(k,[["add-to-cart",e.product_id.toString()]]),W=()=>{const e=(0,r.O3)("wccomHelper",{});return e.connectURL?V(e.connectURL,[["redirect_admin_url",encodeURIComponent(window.location.href)]]):""};function K(){var e,t;const[o,a]=(0,c.useState)(!1),n=()=>a(!0),l=(0,r.O3)("wccomHelper",{}),m=null!==(e=l?.isConnected)&&void 0!==e&&e,w=W(),E=l?.userEmail,N=null!==(t=l?.userAvatar)&&void 0!==t?t:u,h=y+"/my-dashboard/",M=m?h:w,v=m?(0,s.__)("Connected","woocommerce"):(0,s.__)("Not Connected","woocommerce");return(0,c.createElement)(c.Fragment,null,(0,c.createElement)(i.DropdownMenu,{className:"woocommerce-marketplace__user-menu",icon:m?(0,c.createElement)("img",{src:N,alt:"",className:"woocommerce-marketplace__menu-avatar-image"}):u,label:(0,s.__)("User options","woocommerce")},(()=>(0,c.createElement)(c.Fragment,null,(0,c.createElement)(i.MenuGroup,{className:"woocommerce-layout__homescreen-display-options",label:v},(0,c.createElement)(i.MenuItem,{className:"woocommerce-marketplace__menu-item",href:M},m?(0,c.createElement)(c.Fragment,null,(0,c.createElement)(p.Z,{icon:u,size:24,className:"woocommerce-marketplace__menu-icon"}),(0,c.createElement)("span",{className:"woocommerce-marketplace__main-text"},E)):(0,c.createElement)(c.Fragment,null,(0,c.createElement)(p.Z,{icon:u,size:24,className:"woocommerce-marketplace__menu-icon"}),(0,c.createElement)("div",{className:"woocommerce-marketplace__menu-text"},(0,s.__)("Connect account","woocommerce"),(0,c.createElement)("span",{className:"woocommerce-marketplace__sub-text"},(0,s.__)("Manage your subscriptions, get updates and support for your extensions and themes.","woocommerce"))))),(0,c.createElement)(i.MenuItem,{href:h},(0,c.createElement)(p.Z,{icon:d.Z,size:24,className:"woocommerce-marketplace__menu-icon"}),(0,s.__)("Woo.com account","woocommerce"))),m&&(0,c.createElement)(i.MenuGroup,{className:"woocommerce-layout__homescreen-display-options"},(0,c.createElement)(i.MenuItem,{onClick:n},(0,c.createElement)(p.Z,{icon:_,size:24,className:"woocommerce-marketplace__menu-icon"}),(0,s.__)("Disconnect account","woocommerce")))))),o&&(0,c.createElement)(g,{setIsModalOpen:a,disconnectURL:w}))}var J=o(87608),$=o.n(J),X=o(10431);const q={search:{name:"search",title:(0,s.__)("Search results","woocommerce")},discover:{name:"discover",title:(0,s.__)("Discover","woocommerce")},extensions:{name:"extensions",title:(0,s.__)("Browse","woocommerce")},themes:{name:"themes",title:(0,s.__)("Themes","woocommerce")},"my-subscriptions":{name:"my-subscriptions",title:(0,s.__)("My subscriptions","woocommerce")}},ee=e=>{if(""===e)return q;const t={...q};return"search"!==e&&delete t.search,t},te=e=>{const{additionalClassNames:t}=e,o=(0,c.useContext)(a),{selectedTab:r,setSelectedTab:n}=o,[s,l]=(0,c.useState)(ee("")),m=(0,X.useQuery)();return(0,c.useEffect)((()=>{m?.tab&&q[m.tab]?n(m.tab):Object.keys(m).length>0&&n(w)}),[m,n]),(0,c.useEffect)((()=>{l(ee(r))}),[r]),(0,c.createElement)("nav",{className:$()("woocommerce-marketplace__tabs",t||[])},((e,t)=>{const{selectedTab:o,setSelectedTab:r}=e,a=e=>{e!==o&&(r(e),(e=>{(0,X.navigateTo)({url:(0,X.getNewPath)({tab:e===w?void 0:e},E,{})})})(e))},n=[];for(const e in t)n.push(q[e]?.href?(0,c.createElement)("a",{className:$()("woocommerce-marketplace__tab-button","components-button",`woocommerce-marketplace__tab-${e}`),href:q[e]?.href,key:e},q[e]?.title):(0,c.createElement)(i.Button,{className:$()("woocommerce-marketplace__tab-button",`woocommerce-marketplace__tab-${e}`,{"is-active":e===o}),onClick:()=>a(e),key:e},q[e]?.title));return n})(o,s))},oe=(0,c.createElement)(m.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,c.createElement)(m.Path,{d:"M13.5 6C10.5 6 8 8.5 8 11.5c0 1.1.3 2.1.9 3l-3.4 3 1 1.1 3.4-2.9c1 .9 2.2 1.4 3.6 1.4 3 0 5.5-2.5 5.5-5.5C19 8.5 16.5 6 13.5 6zm0 9.5c-2.2 0-4-1.8-4-4s1.8-4 4-4 4 1.8 4 4-1.8 4-4 4z"})),ce=(0,s.__)("Search for extensions and themes","woocommerce"),re=function(){const[e,t]=(0,c.useState)(""),o=(0,X.useQuery)();(0,c.useEffect)((()=>{o.term?t(o.term):t("")}),[o.term]),(0,c.useEffect)((()=>{"search"!==o.tab&&t("")}),[o.tab]);const r=()=>{const t=e.trim(),o={};return""!==t&&(o.term=t,o.tab="search"),(0,X.navigateTo)({url:(0,X.getNewPath)(o,E,{})}),[]};return(0,c.createElement)("div",{className:"woocommerce-marketplace__search"},(0,c.createElement)("label",{className:"screen-reader-text",htmlFor:"woocommerce-marketplace-search-query"},ce),(0,c.createElement)("input",{id:"woocommerce-marketplace-search-query",value:e,className:"woocommerce-marketplace__search-input",type:"search",name:"woocommerce-marketplace-search-query",placeholder:ce,onChange:e=>{t(e.target.value)},onKeyUp:e=>{"Enter"===e.key&&r(),"Escape"===e.key&&t("")}}),(0,c.createElement)("button",{id:"woocommerce-marketplace-search-button",className:"woocommerce-marketplace__search-button","aria-label":(0,s.__)("Search","woocommerce"),onClick:r},(0,c.createElement)(p.Z,{icon:oe,size:32})))};function ae(){return(0,c.createElement)("header",{className:"woocommerce-marketplace__header"},(0,c.createElement)(l,null),(0,c.createElement)(te,{additionalClassNames:["woocommerce-marketplace__header-tabs"]}),(0,c.createElement)(re,null),(0,c.createElement)("div",{className:"woocommerce-marketplace__header-meta"},(0,c.createElement)(K,null)))}var ne=o(14599),se=o(67221);const le=function(e){const{product:t}=e,{user:o,currentUserCan:r}=(0,se.useUser)(),{selectedTab:n,isProductInstalled:l}=(0,c.useContext)(a);return m=t,!(o&&m&&r("install_plugins")&&m.isInstallable&&"theme"!==m.type&&"discover"!==n)||m.slug&&l(m.slug)?(0,c.createElement)(c.Fragment,null,(0,c.createElement)("div",{className:"woocommerce-marketplace__product-card__price"},(0,c.createElement)("span",{className:"woocommerce-marketplace__product-card__price-label"},0===t.price?(0,s.__)("Free download","woocommerce"):"$"+t.price),(0,c.createElement)("span",{className:"woocommerce-marketplace__product-card__price-billing"},0===t.price?"":(0,s.__)(" annually","woocommerce"))),(0,c.createElement)("div",{className:"woocommerce-marketplace__product-card__rating"},null!==t.averageRating&&(0,c.createElement)(c.Fragment,null,(0,c.createElement)("span",{className:"woocommerce-marketplace__product-card__rating-icon"},(0,c.createElement)(i.Icon,{icon:"star-filled",size:16})),(0,c.createElement)("span",{className:"woocommerce-marketplace__product-card__rating-average"},t.averageRating),(0,c.createElement)("span",{className:"woocommerce-marketplace__product-card__rating-count"},"(",t.reviewsCount,")")))):(0,c.createElement)(c.Fragment,null,(0,c.createElement)("span",{className:"woocommerce-marketplace__product-card__add-to-store"},(0,c.createElement)(i.Button,{variant:"secondary",onClick:function(){(0,ne.recordEvent)("marketplace_add_to_store_clicked",{product_id:t.id}),(0,X.navigateTo)({url:(0,X.getNewPath)({installProduct:t.id})})}},(0,s.__)("Add to Store","woocommerce"))));var m},ie=function(e){var t;const{isLoading:o,type:r}=e,a=(0,X.useQuery)(),n=null!==(t=e.product)&&void 0!==t?t:{title:"",description:"",vendorName:"",vendorUrl:"",icon:"",url:"",price:0,image:"",averageRating:null,reviewsCount:null};function l(t,o){const c=e.tracksData;c.position&&(o.position=c.position),c.label&&(o.label=c.label),c.group&&(o.group=c.group),c.searchTerm&&(o.search_term=c.searchTerm),c.category&&(o.category=c.category),(0,ne.queueRecordEvent)(t,o)}const m=r===D.theme;let u=n?.vendorName;n?.vendorName&&n?.vendorUrl&&(u=(0,c.createElement)("a",{href:n.vendorUrl,rel:"noopener noreferrer",onClick:()=>{l("marketplace_product_card_vendor_clicked",{product:n.title,vendor:n.vendorName,product_type:r})}},n.vendorName));const p=$()("woocommerce-marketplace__product-card",`woocommerce-marketplace__product-card--${r}`,{"is-loading":o,"is-small":e.small});return(0,c.createElement)(i.Card,{className:p,"aria-hidden":o},(0,c.createElement)("div",{className:"woocommerce-marketplace__product-card__content"},m&&(0,c.createElement)("div",{className:"woocommerce-marketplace__product-card__image"},!o&&(0,c.createElement)("img",{className:"woocommerce-marketplace__product-card__image-inner",src:n.image,alt:n.title})),(0,c.createElement)("div",{className:"woocommerce-marketplace__product-card__header"},(0,c.createElement)("div",{className:"woocommerce-marketplace__product-card__details"},!m&&(0,c.createElement)(c.Fragment,null,o&&(0,c.createElement)("div",{className:"woocommerce-marketplace__product-card__icon"}),!o&&n.icon&&(0,c.createElement)("img",{className:"woocommerce-marketplace__product-card__icon",src:n.icon,alt:n.title})),(0,c.createElement)("div",{className:"woocommerce-marketplace__product-card__meta"},(0,c.createElement)("h2",{className:"woocommerce-marketplace__product-card__title"},(0,c.createElement)("a",{className:"woocommerce-marketplace__product-card__link",href:a.ref?V(n.url,[["utm_content",a.ref]]):n.url,rel:"noopener noreferrer",onClick:()=>{l("marketplace_product_card_clicked",{product:n.title,vendor:n.vendorName,product_type:r})}},o?" ":n.title)),o&&(0,c.createElement)("p",{className:"woocommerce-marketplace__product-card__vendor"}),!o&&u&&(0,c.createElement)("p",{className:"woocommerce-marketplace__product-card__vendor"},(0,c.createElement)("span",null,(0,s.__)("By ","woocommerce")),u)))),!m&&(0,c.createElement)("p",{className:"woocommerce-marketplace__product-card__description"},!o&&n.description),(0,c.createElement)("footer",{className:"woocommerce-marketplace__product-card__footer"},o&&(0,c.createElement)("div",{className:"woocommerce-marketplace__product-card__price"}),!o&&e.product&&(0,c.createElement)(le,{product:e.product}))))};function me(e){const t=(0,r.O3)("wccomHelper",{}),o=$()("woocommerce-marketplace__product-list-content",e.className);return(0,c.createElement)("div",{className:o},e.products.map(((o,r)=>(0,c.createElement)(ie,{key:o.id,type:e.type,product:{id:o.id,slug:o.slug,title:o.title,image:o.image,type:o.type,icon:o.icon,vendorName:o.vendorName,vendorUrl:o.vendorUrl?V(o.vendorUrl,[["utm_source","extensionsscreen"],["utm_medium","product"],["utm_campaign","wcaddons"],["utm_content","devpartner"]]):"",price:o.price,url:V(o.url,Object.entries({...t.inAppPurchaseURLParams,...void 0!==e.productGroup?{utm_group:e.productGroup}:{}})),averageRating:o.averageRating,reviewsCount:o.reviewsCount,description:o.description,isInstallable:o.isInstallable},tracksData:{position:r+1,...o.label&&{label:o.label},...e.group&&{group:e.group},...e.searchTerm&&{searchTerm:e.searchTerm},...e.category&&{category:e.category}}}))))}var ue=o(86020);function pe(e){const{title:t,groupURL:o}=e,r=""===t,a=$()("woocommerce-marketplace__product-list-header",{"is-loading":r});return(0,c.createElement)("div",{className:a,"aria-hidden":r},(0,c.createElement)("h2",{className:"woocommerce-marketplace__product-list-title"},t),null!==o&&(0,c.createElement)("span",{className:"woocommerce-marketplace__product-list-link"},(0,c.createElement)(ue.Link,{href:o,target:"_blank",onClick:()=>{(0,ne.recordEvent)("marketplace_see_more_clicked",{group_title:t,group_url:o})}},(0,s.__)("See more","woocommerce"))))}function de(e){const{title:t,products:o,groupURL:r,type:a,productGroup:n}=e;return(0,c.createElement)("div",{className:"woocommerce-marketplace__product-list"},(0,c.createElement)(pe,{title:t,groupURL:r}),(0,c.createElement)(me,{group:t,products:o,type:a,productGroup:n}))}function _e(e){const{hasTitle:t,type:o}=e,r=e.placeholderCount||12;return(0,c.createElement)("div",{className:"woocommerce-marketplace__product-list"},!1!==t&&(0,c.createElement)(pe,{title:"",groupURL:null}),(0,c.createElement)("div",{className:"woocommerce-marketplace__product-list-content"},[...Array(r)].map(((e,t)=>(0,c.createElement)(ie,{key:t,isLoading:!0,type:o,tracksData:{}})))))}function ge(){const[e,t]=(0,c.useState)([]),o=(0,c.useContext)(a),{isLoading:r,setIsLoading:n}=o;if((0,c.useEffect)((()=>{n(!0),P().then((e=>Array.isArray(e)?e:[])).then((e=>{t(e),function(e){const t=e.flatMap((e=>e.items)).map((e=>e.id));(0,ne.recordEvent)("marketplace_discover_viewed",{view:"discover",product_ids:t})}(e)})).finally((()=>{n(!1)}))}),[]),r)return(0,c.createElement)("div",{className:"woocommerce-marketplace__discover"},(0,c.createElement)(_e,{placeholderCount:9,type:D.extension}));const s=e.flatMap((e=>e));return(0,c.createElement)("div",{className:"woocommerce-marketplace__discover"},s.map((e=>(0,c.createElement)(de,{key:e.id,productGroup:e.id,title:e.title,products:e.items,groupURL:e.url,type:e.itemType}))))}var we=o(12314);function ye(e){const t=""===e.label,o=$()("woocommerce-marketplace__category-item-button",{"woocommerce-marketplace__category-item-button--selected":e.selected,"is-loading":t});return(0,c.createElement)("button",{className:o,onClick:function(e){const t=e.currentTarget.value;t&&(0,X.navigateTo)({url:(0,X.getNewPath)({category:t})})},value:e.slug,"aria-hidden":t},e.label)}var Ee=o(86241),Ne=o(73224);function he(e){function t(t){const o=t.currentTarget.value;o&&(e.onClick(),(0,X.navigateTo)({url:(0,X.getNewPath)({category:o})}))}return(0,c.createElement)("ul",{className:"woocommerce-marketplace__category-dropdown-list"},e.categories.map((o=>(0,c.createElement)("li",{className:"woocommerce-marketplace__category-dropdown-item",key:o.slug},(0,c.createElement)("button",{className:$()("woocommerce-marketplace__category-dropdown-item-button",{"woocommerce-marketplace__category-dropdown-item-button--selected":o.slug===e.selected?.slug}),value:o.slug,onClick:t},o.label)))))}function Me(e){return(0,c.createElement)(i.Dropdown,{renderToggle:({isOpen:t,onToggle:o})=>(0,c.createElement)("button",{onClick:()=>{t||(0,ne.recordEvent)("marketplace_category_dropdown_opened",{type:e.type}),o()},className:e.buttonClassName,"aria-label":(0,s.__)("Toggle category dropdown","woocommerce")},e.label,(0,c.createElement)(p.Z,{icon:t?Ee.Z:Ne.Z,size:e.arrowIconSize})),className:e.className,renderContent:({onToggle:t})=>(0,c.createElement)(he,{categories:e.categories,selected:e.selected,onClick:t}),contentClassName:e.contentClassName})}const ve={[D.extension]:"_all",[D.theme]:"themes"};function ke(e){const[t,o]=(0,c.useState)([]),[a,n]=(0,c.useState)([]),[l,i]=(0,c.useState)(),[m,u]=(0,c.useState)(!1),p=(0,X.useQuery)();return(0,c.useEffect)((()=>{let o=ve[e.type];p.category&&(o=p.category);const c=t.concat(a).find((e=>e.slug===o));c&&i(c)}),[p.category,e.type,t,a]),(0,c.useEffect)((()=>{u(!0),function(e){const t=new URL(y+h);return r.MV.userLocale&&t.searchParams.set("locale",r.MV.userLocale),e===D.theme&&t.searchParams.set("parent","themes"),Q(t.toString()).then((e=>e)).catch((()=>[]))}(e.type).then((e=>{const t=e.map((e=>({...e,selected:!1}))).filter((e=>"_featured"!==e.slug)),c=t.slice(0,7),r=t.slice(7);o(c),n(r)})).catch((()=>{o([]),n([])})).finally((()=>{u(!1)}))}),[e.type]),m?(0,c.createElement)(c.Fragment,null,(0,c.createElement)("ul",{className:"woocommerce-marketplace__category-selector"},[...Array(5)].map(((e,t)=>(0,c.createElement)("li",{key:t,className:"woocommerce-marketplace__category-item"},(0,c.createElement)(ye,{slug:"",label:"",selected:!1})))))):(0,c.createElement)(c.Fragment,null,(0,c.createElement)("ul",{className:"woocommerce-marketplace__category-selector"},t.map((e=>(0,c.createElement)("li",{className:"woocommerce-marketplace__category-item",key:e.slug},(0,c.createElement)(ye,(0,we.Z)({},e,{selected:e.slug===l?.slug}))))),(0,c.createElement)("li",{className:"woocommerce-marketplace__category-item"},a.length>0&&(0,c.createElement)(Me,{type:e.type,label:(0,s.__)("More","woocommerce"),categories:a,buttonClassName:$()("woocommerce-marketplace__category-item-button",{"woocommerce-marketplace__category-item-button--selected":!!l&&a.find((e=>e.slug===l.slug))}),contentClassName:"woocommerce-marketplace__category-item-content",arrowIconSize:20,selected:l}))),(0,c.createElement)("div",{className:"woocommerce-marketplace__category-selector--full-width"},(0,c.createElement)(Me,{type:e.type,label:function(){const e=(0,s.__)("All Categories","woocommerce");return l?"All"===l.label?e:l.label:e}(),categories:t.concat(a),buttonClassName:"woocommerce-marketplace__category-dropdown-button",className:"woocommerce-marketplace__category-dropdown",contentClassName:"woocommerce-marketplace__category-dropdown-content",selected:l})))}function be(e){const[t,o]=(0,c.useState)(),[r,a]=(0,c.useState)(!1),n=(0,X.useQuery)(),l="search"===n.tab&&n.section,i={[C.all]:["most-popular","popular-themes"],[C.theme]:["popular-themes"],[C.extension]:["most-popular"]};return(0,c.useEffect)((()=>{a(!0),P().then((t=>{const c=i[e.type];if(!c)return;const r=t.filter((e=>c.includes(e.id)));r&&(r.forEach((e=>{e.items=e.items.slice(0,4)})),o(r))})).catch((()=>{o(void 0)})).finally((()=>{a(!1)}))}),[]),(0,c.createElement)("div",{className:"woocommerce-marketplace__no-results"},function(){if(!l)return(0,c.createElement)(c.Fragment,null);if(e.type===C.all)return(0,c.createElement)(c.Fragment,null);let t=D.extension;return e.type===C.theme&&(t=D.theme),(0,c.createElement)(ke,{type:t})}(),(0,c.createElement)("div",{className:"woocommerce-marketplace__no-results__content"},(0,c.createElement)("h2",{className:"woocommerce-marketplace__no-results__heading"},e.showHeading?e.heading:""),(0,c.createElement)("p",{className:"woocommerce-marketplace__no-results__description"},(0,s.__)("Try searching again using a different term, or take a look at our recommendations below.","woocommerce"))),(0,c.createElement)("div",{className:"woocommerce-marketplace__no-results__product-groups"},r?(0,c.createElement)(c.Fragment,null,(0,c.createElement)(_e,{type:D.extension,placeholderCount:4}),(0,c.createElement)(_e,{type:D.theme,placeholderCount:4})):t&&0!==t.length?(0,c.createElement)(c.Fragment,null,t.map((e=>{return(0,c.createElement)(de,{title:(t=e.id,"popular-themes"===t?(0,s.__)("Our favorite themes","woocommerce"):(0,s.__)("Most popular extensions","woocommerce")),products:e.items,groupURL:e.url,productGroup:e.id,type:e.itemType,key:e.id});var t}))):(0,c.createElement)(c.Fragment,null)))}const fe={[D.extension]:{label:(0,s.__)("extensions","woocommerce"),singularLabel:(0,s.__)("extension","woocommerce")},[D.theme]:{label:(0,s.__)("themes","woocommerce"),singularLabel:(0,s.__)("theme","woocommerce")}};function Ie(e){var t,o,r,n;const l=(0,c.useContext)(a),{isLoading:m}=l,u=fe[e.type].label,p=fe[e.type].singularLabel,d=(0,X.useQuery)(),_=d?.category,g=null!==(t=e.perPage)&&void 0!==t?t:M,w=null!==(o=e.showAllButton)&&void 0!==o&&o,y=null!==(r=e.products?.length)&&void 0!==r?r:0,E=null!==(n=e.products?.slice(0,g))&&void 0!==n?n:[];let N=(0,s.sprintf)((0,s.__)("0 %s found","woocommerce"),u);y>0&&(N=(0,s.sprintf)((0,s._n)("%1$s %2$s","%1$s %3$s",y,"woocommerce"),y,p,u));const h="woocommerce-marketplace__search-",v=$()(h+u),k=$()("woocommerce-marketplace__product-list-title",h+"product-list-title--"+u,{"is-loading":m}),b=$()("woocommerce-marketplace__view-all-button",h+"button-"+u);return(0,c.createElement)("div",{className:v},(0,c.createElement)("h2",{className:k},m?" ":N),function(){if(m)return(0,c.createElement)(c.Fragment,null,e.categorySelector&&(0,c.createElement)(ke,{type:e.type}),(0,c.createElement)(_e,{hasTitle:!1,type:e.type}));if(0===E.length){const t=e.type===D.extension?C.extension:C.theme;return(0,c.createElement)(be,{type:t,showHeading:!1})}const t=$()(w?"woocommerce-marketplace__product-list-content--collapsed":"");return(0,c.createElement)(c.Fragment,null,e.categorySelector&&(0,c.createElement)(ke,{type:e.type}),(0,c.createElement)(me,{products:E,type:e.type,className:t,searchTerm:e.searchTerm,category:_}),w&&(0,c.createElement)(i.Button,{className:b,variant:"secondary",text:(0,s.__)("View all","woocommerce"),onClick:()=>{return t=e.type,void(0,X.navigateTo)({url:(0,X.getNewPath)({section:t})});var t}}))}())}function xe(e){const t=e.products.filter((e=>e.type===D.extension)),o=e.products.filter((e=>e.type===D.theme)),r=(0,c.useContext)(a),{isLoading:n}=r,l=(0,X.useQuery)(),i=!!l.section,m=l.term?l.term:"";function u(e,t,o={}){var r,a,n;return(0,c.createElement)(Ie,{products:e,type:t,categorySelector:null!==(r=o.categorySelector)&&void 0!==r?r:i,searchTerm:m,showAllButton:null===(a=o.showAllButton)||void 0===a||a,perPage:null!==(n=o.perPage)&&void 0!==n?n:M})}function p(e={}){return u(t,D.extension,e)}function d(e={}){return u(o,D.theme,e)}return(0,c.createElement)("div",{className:"woocommerce-marketplace__search-results"},l?.section===C.extension?p({showAllButton:!1}):l?.section===C.theme?d({showAllButton:!1}):n?(0,c.createElement)(c.Fragment,null,p(),d()):n||0!==t.length||0!==o.length?0===o.length&&t.length>0?p({categorySelector:!0,showAllButton:!1,perPage:M}):0===t.length&&o.length>0?d({categorySelector:!0,showAllButton:!1,perPage:M}):(0,c.createElement)(c.Fragment,null,p({perPage:v}),d({perPage:v})):(0,c.createElement)(be,{type:C.all,showHeading:!0,heading:(0,s.__)("No extensions or themes found…","woocommerce")}))}const Te=(0,c.createContext)({subscriptions:[],setSubscriptions:()=>{},loadSubscriptions:()=>new Promise((()=>{})),refreshSubscriptions:()=>new Promise((()=>{})),isLoading:!0,setIsLoading:()=>{}});function De(e){const[t,o]=(0,c.useState)([]),[r,a]=(0,c.useState)(!0),n=e=>(!0===e&&a(!0),async function(){return await x()({path:"/wc/v3/marketplace/subscriptions".toString()})}().then((e=>{o(e)})).finally((()=>{e&&a(!1)}))),l=e=>(e&&a(!0),async function(){return await x()({path:"/wc/v3/marketplace/refresh".toString(),method:"POST"})}().then((e=>{o(e)})).finally((()=>{e&&a(!1)})));(0,c.useEffect)((()=>{new URLSearchParams(window.location.search).get("install")?l(!0).catch((e=>{R("woocommerce-marketplace-refresh-subscriptions",(0,s.sprintf)((0,s.__)("Error refreshing subscriptions: %s","woocommerce"),e.message),z.Error)})):n(!0).catch((e=>{R("woocommerce-marketplace-load-subscriptions",(0,s.sprintf)((0,s.__)("Error loading subscriptions: %s","woocommerce"),e.message),z.Error)}))}),[]);const i={subscriptions:t,setSubscriptions:o,loadSubscriptions:n,refreshSubscriptions:l,isLoading:r,setIsLoading:a};return(0,c.createElement)(Te.Provider,{value:i},e.children)}const Ce=[{key:"name",label:(0,s.__)("Name","woocommerce")},{key:"expiry",label:(0,s.__)("Expiry/Renewal date","woocommerce")},{key:"autoRenew",label:(0,s.__)("Auto-renew","woocommerce")},{key:"version",label:(0,s.__)("Version","woocommerce")}];function ze(e){if(e.isLoading)return(0,c.createElement)(ue.TablePlaceholder,{caption:(0,s.__)("Loading your subscriptions","woocommerce"),headers:e.headers});const t=e.headers.map((e=>({...e,cellClassName:"woocommerce-marketplace__my-subscriptions__table__header--"+e.key})));return(0,c.createElement)(ue.Table,{className:"woocommerce-marketplace__my-subscriptions__table",headers:t,rows:e.rows})}function Ae(e){const t=[...Ce,{key:"actions",label:(0,s.__)("Actions","woocommerce")}];if(!(e.isLoading||e.rows&&0!==e.rows.length)){const e=(0,X.getNewPath)({},E,{}),t=(0,c.createInterpolateElement)((0,s.__)("No extensions or themes installed. <a>Browse the Marketplace</a>","woocommerce"),{a:(0,c.createElement)("a",{href:e})});return(0,c.createElement)(ue.EmptyTable,{numberOfRows:4},t)}return(0,c.createElement)(ze,{rows:e.rows,isLoading:e.isLoading,headers:t})}function Se(e){const t=[...Ce,{key:"actions",label:(0,s.__)("Actions","woocommerce")}];return(0,c.createElement)(ze,{rows:e.rows,isLoading:e.isLoading,headers:t})}var je=o(69771);const Le=(0,c.createElement)(m.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,c.createElement)(m.Path,{d:"M10.5 4v4h3V4H15v4h1.5a1 1 0 011 1v4l-3 4v2a1 1 0 01-1 1h-3a1 1 0 01-1-1v-2l-3-4V9a1 1 0 011-1H9V4h1.5zm.5 12.5v2h2v-2l3-4v-3H8v3l3 4z"}));let Oe=function(e){return e.Warning="warning",e.Error="error",e}({});function Qe(e){var t;const[o,r]=(0,c.useState)(!1),{loadSubscriptions:a}=(0,c.useContext)(Te),n=()=>{(0,ne.recordEvent)("marketplace_product_connect_button_clicked",{product_zip_slug:e.subscription.zip_slug,product_id:e.subscription.product_id}),r(!0),B(e.subscription.product_key),U(e.subscription).then((()=>{a(!1).then((()=>{R(e.subscription.product_key,(0,s.sprintf)((0,s.__)("%s successfully connected.","woocommerce"),e.subscription.product_name),z.Success),r(!1),e.onClose&&e.onClose()}))})).catch((()=>{R(e.subscription.product_key,(0,s.sprintf)((0,s.__)("%s couldn’t be connected.","woocommerce"),e.subscription.product_name),z.Error,{actions:[{label:(0,s.__)("Try again","woocommerce"),onClick:n}]}),r(!1),e.onClose&&e.onClose()}))};return(0,c.createElement)(i.Button,{onClick:n,variant:null!==(t=e.variant)&&void 0!==t?t:"secondary",isBusy:o,disabled:o},(0,s.__)("Connect","woocommerce"))}const Pe={installingProducts:[]},Ue=(0,T.createReduxStore)("woocommerce-admin/installing",{reducer(e=Pe,t){switch(t.type){case"START_INSTALLING":return{...e,installingProducts:[...e.installingProducts,t.productKey]};case"STOP_INSTALLING":return{...e,installingProducts:[...e.installingProducts.filter((e=>e!==t.productKey))]}}return e},actions:{startInstalling:e=>({type:"START_INSTALLING",productKey:e}),stopInstalling:e=>({type:"STOP_INSTALLING",productKey:e})},selectors:{isInstalling:(e,t)=>!!e&&e.installingProducts.includes(t)}});function Ye(e){var t;const{loadSubscriptions:o}=(0,c.useContext)(Te),r=(0,T.useSelect)((t=>t(Ue).isInstalling(e.subscription.product_key)),[e.subscription.product_key]),a=()=>{(0,T.dispatch)(Ue).stopInstalling(e.subscription.product_key)},n=()=>{var t;(0,ne.recordEvent)("marketplace_product_install_button_clicked",{product_zip_slug:e.subscription.zip_slug,product_id:e.subscription.product_id,product_current_version:e.subscription.version}),(0,T.dispatch)(Ue).startInstalling(e.subscription.product_key),B(e.subscription.product_key),e.subscription.is_installable?function(e){return U(e).then((()=>Z(e.product_type,e.zip_slug).then((()=>function(e){if(!0===e.local.active)return Promise.resolve();const t=new URLSearchParams;return t.append("product_key",e.product_key),x()({path:"/wc/v3/marketplace/subscriptions/activate".toString(),method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:t}).then((()=>Promise.resolve())).catch((()=>Promise.reject({success:!1,data:{message:(0,s.sprintf)((0,s.__)("%s could not be activated. Please activate it manually.","woocommerce"),e.product_name)}})))}(e))).catch((t=>function(e){if(!1===e.active)return Promise.resolve();const t=new URLSearchParams;return t.append("product_key",e.product_key),x()({path:"/wc/v3/marketplace/subscriptions/disconnect".toString(),method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:t})}(e).finally((()=>Promise.reject(t)))))))}(e.subscription).then((()=>{o(!1).then((()=>{R(e.subscription.product_key,(0,s.sprintf)((0,s.__)("%s successfully installed.","woocommerce"),e.subscription.product_name),z.Success),a()})),(0,ne.recordEvent)("marketplace_product_installed",{product_zip_slug:e.subscription.zip_slug,product_id:e.subscription.product_id,product_current_version:e.subscription.version}),e.onSuccess&&e.onSuccess()})).catch((t=>{o(!1).then((()=>{let o=(0,s.sprintf)((0,s.__)("%s couldn’t be installed.","woocommerce"),e.subscription.product_name);!1===t?.success&&t?.data.message&&(o+=" "+t.data.message),R(e.subscription.product_key,o,z.Error,{actions:[{label:(0,s.__)("Try again","woocommerce"),onClick:n}]}),a(),e.onError&&e.onError()})),(0,ne.recordEvent)("marketplace_product_install_failed",{product_zip_slug:e.subscription.zip_slug,product_id:e.subscription.product_id,product_current_version:e.subscription.version,error_message:t?.data?.message})})):(t=e.subscription,x()({path:"/wc/v3/marketplace/subscriptions/install-url?product_key="+t.product_key}).then((e=>e?.data.url))).then((t=>{(0,ne.recordEvent)("marketplace_product_install_url",{product_zip_slug:e.subscription.zip_slug,product_id:e.subscription.product_id,product_current_version:e.subscription.version,product_install_url:t}),a(),t?window.open(t,"_self"):R(e.subscription.product_key,(0,s.sprintf)((0,s.__)("%s couldn’t be installed. Please install the product manually.","woocommerce"),e.subscription.product_name),z.Error)}))};return(0,c.createElement)(i.Button,{variant:null!==(t=e.variant)&&void 0!==t?t:"link",isBusy:r,disabled:r,onClick:n},(0,s.__)("Install","woocommerce"))}function Ze(e){var t;return(0,c.createElement)(i.Button,{href:F(e.subscription),variant:null!==(t=e.variant)&&void 0!==t?t:"secondary",onClick:function(){(0,ne.queueRecordEvent)("marketplace_renew_button_clicked",{product_zip_slug:e.subscription.zip_slug,product_id:e.subscription.product_id})}},(0,s.__)("Renew","woocommerce"))}function Re(e){var t;return(0,c.createElement)(i.Button,{href:H(e.subscription),variant:null!==(t=e.variant)&&void 0!==t?t:"secondary",onClick:function(){(0,ne.queueRecordEvent)("marketplace_subscribe_button_clicked",{product_zip_slug:e.subscription.zip_slug,product_id:e.subscription.product_id})}},(0,s.__)("Subscribe","woocommerce"))}function Be(e){return(0,c.createElement)(i.Modal,{title:(0,s.__)("Connect to update","woocommerce"),onRequestClose:e.onClose,focusOnMount:!0,className:"woocommerce-marketplace__header-account-modal",style:{borderRadius:4},overlayClassName:"woocommerce-marketplace__header-account-modal-overlay"},(0,c.createElement)("p",{className:"woocommerce-marketplace__header-account-modal-text"},(0,s.sprintf)((0,s.__)("Version %s is available. To enable this update you need to connect your subscription to this store.","woocommerce"),e.subscription.version)),(0,c.createElement)(i.ButtonGroup,{className:"woocommerce-marketplace__header-account-modal-button-group"},(0,c.createElement)(i.Button,{variant:"tertiary",onClick:e.onClose,className:"woocommerce-marketplace__header-account-modal-button"},(0,s.__)("Cancel","woocommerce")),(0,c.createElement)(Qe,{subscription:e.subscription,onClose:e.onClose,variant:"primary"})))}function Ge(e){return(0,c.createElement)(i.Modal,{title:(0,s.__)("Renew to update","woocommerce"),onRequestClose:e.onClose,focusOnMount:!0,className:"woocommerce-marketplace__header-account-modal",style:{borderRadius:4},overlayClassName:"woocommerce-marketplace__header-account-modal-overlay"},(0,c.createElement)("p",{className:"woocommerce-marketplace__header-account-modal-text"},(0,s.sprintf)((0,s.__)("Version %s is available. To enable this update you need to renew your subscription.","woocommerce"),e.subscription.version)),(0,c.createElement)(i.ButtonGroup,{className:"woocommerce-marketplace__header-account-modal-button-group"},(0,c.createElement)(i.Button,{variant:"tertiary",onClick:e.onClose,className:"woocommerce-marketplace__header-account-modal-button"},(0,s.__)("Cancel","woocommerce")),(0,c.createElement)(Ze,{subscription:e.subscription,variant:"primary"})))}function Ve(e){return(0,c.createElement)(i.Modal,{title:(0,s.__)("Subscribe to update","woocommerce"),onRequestClose:e.onClose,focusOnMount:!0,className:"woocommerce-marketplace__header-account-modal",style:{borderRadius:4},overlayClassName:"woocommerce-marketplace__header-account-modal-overlay"},(0,c.createElement)("p",{className:"woocommerce-marketplace__header-account-modal-text"},(0,s.sprintf)((0,s.__)("Version %s is available. To enable this update you need to purchase a subscription.","woocommerce"),e.subscription.version)),(0,c.createElement)(i.ButtonGroup,{className:"woocommerce-marketplace__header-account-modal-button-group"},(0,c.createElement)(i.Button,{variant:"tertiary",onClick:e.onClose,className:"woocommerce-marketplace__header-account-modal-button"},(0,s.__)("Cancel","woocommerce")),(0,c.createElement)(Re,{subscription:e.subscription,variant:"primary"})))}function Fe(e){const[t,o]=(0,c.useState)(!1),[r,a]=(0,c.useState)(!1),{loadSubscriptions:n}=(0,c.useContext)(Te),l=e.subscription.active&&e.subscription.local&&e.subscription.local.slug&&e.subscription.local.path;return(0,c.createElement)(c.Fragment,null,t?""===e.subscription.product_key?(0,c.createElement)(Ve,{onClose:()=>o(!1),subscription:e.subscription}):e.subscription.expired?(0,c.createElement)(Ge,{subscription:e.subscription,onClose:()=>o(!1)}):e.subscription.active?null:(0,c.createElement)(Be,{subscription:e.subscription,onClose:()=>o(!1)}):null,(0,c.createElement)(i.Button,{variant:"link",className:"woocommerce-marketplace__my-subscriptions-update",onClick:function t(){var c;(0,ne.recordEvent)("marketplace_product_update_button_clicked",{product_zip_slug:e.subscription.zip_slug,product_id:e.subscription.product_id,product_installed_version:e.subscription.local.installed,product_current_version:e.subscription.version}),l?(B(e.subscription.product_key),window.wp.updates?(a(!0),(c=e.subscription,Y("update-"+c.product_type,{slug:c.local.slug,[c.product_type]:c.local.path})).then((()=>{n(!1).then((()=>{R(e.subscription.product_key,(0,s.sprintf)((0,s.__)("%s updated successfully.","woocommerce"),e.subscription.product_name),z.Success),a(!1)})),(0,ne.recordEvent)("marketplace_product_updated",{product_zip_slug:e.subscription.zip_slug,product_id:e.subscription.product_id,product_installed_version:e.subscription.local.installed,product_current_version:e.subscription.version})})).catch((()=>{R(e.subscription.product_key,(0,s.sprintf)((0,s.__)("%s couldn’t be updated.","woocommerce"),e.subscription.product_name),z.Error,{actions:[{label:(0,s.__)("Try again","woocommerce"),onClick:t}]}),a(!1),(0,ne.recordEvent)("marketplace_product_update_failed",{product_zip_slug:e.subscription.zip_slug,product_id:e.subscription.product_id,product_installed_version:e.subscription.local.installed,product_current_version:e.subscription.version})}))):R(e.subscription.product_key,(0,s.sprintf)((0,s.__)("%s couldn’t be updated.","woocommerce"),e.subscription.product_name),z.Error,{actions:[{label:(0,s.__)("Reload page and try again","woocommerce"),onClick:()=>{window.location.reload()}}]})):o(!0)},isBusy:r,disabled:r,label:(0,s.sprintf)((0,s.__)("Update to %s","woocommerce"),e.subscription.version),showTooltip:!0,tooltipPosition:"top center"},r?(0,s.__)("Updating","woocommerce"):(0,s.__)("Update","woocommerce")))}(0,T.register)(Ue);var He=o(84560);function We(e){const[t,o]=(0,c.useState)(!1);return(0,c.createElement)("button",{onClick:()=>{o(!t)},className:`woocommerce-marketplace__my-subscriptions__product-status woocommerce-marketplace__my-subscriptions__product-status--${e.level}`},(0,c.createElement)(p.Z,{icon:He.Z,size:16}),e.text,""!==e.explanation&&t&&(0,c.createElement)(i.Popover,{className:"woocommerce-marketplace__my-subscriptions__popover",position:"top center"},e.explanation))}var Ke=o(85797);function Je(e){const t=[{title:(0,s.__)("Manage on Woo.com","woocommerce"),icon:(0,c.createElement)(c.Fragment,null),onClick:()=>{window.open("https://woo.com/my-account/my-subscriptions","_blank")}},{title:(0,s.__)("Manage in Plugins","woocommerce"),icon:(0,c.createElement)(c.Fragment,null),onClick:()=>{window.location.href=r.SX+"plugins.php"}}];return e.subscription.documentation_url&&t.unshift({title:(0,s.__)("View documentation","woocommerce"),icon:(0,c.createElement)(c.Fragment,null),onClick:()=>{window.open(e.subscription.documentation_url,"_blank")}}),(0,c.createElement)(i.DropdownMenu,{icon:Ke.Z,label:(0,s.__)("Actions","woocommerce"),controls:t})}function $e(e){return(0,c.createElement)("span",{className:"woocommerce-marketplace__my-subscriptions-version"},e.span)}function Xe(e){return e.local.version===e.version?(0,c.createElement)($e,{span:e.local.version}):e.local.version&&e.version?(0,c.createElement)(Fe,{subscription:e}):e.version?(0,c.createElement)($e,{span:e.version}):e.local.version?(0,c.createElement)($e,{span:e.local.version}):""}function qe(e){return V(e,[["utm_source","subscriptionsscreen"],["utm_medium","product"],["utm_campaign","wcaddons"],["utm_content","product-name"]])}function et(e){var t;let o=(0,c.createElement)(p.Z,{icon:Le,size:40});e.product_icon&&(o=(0,c.createElement)("img",{src:e.product_icon,alt:(0,s.sprintf)((0,s.__)("%s icon","woocommerce"),e.product_name)}));const r=function(e){return""===e.product_key?{text:(0,s.__)("No subscription","woocommerce"),level:Oe.Error,explanation:(0,c.createInterpolateElement)((0,s.__)("To receive updates and support, please <purchase>purchase</purchase> a subscription or use a subscription from another account by <sharing>sharing</sharing> or <transferring>transferring</transferring>.","woocommerce"),{purchase:(0,c.createElement)("a",{href:H(e),rel:"nofollow noopener noreferrer"},"renew"),sharing:(0,c.createElement)("a",{href:b,rel:"nofollow noopener noreferrer"},"sharing"),transferring:(0,c.createElement)("a",{href:b,rel:"nofollow noopener noreferrer"},"sharing")})}:e.local.installed&&!e.active?{text:(0,s.__)("Not connected","woocommerce"),level:Oe.Warning,explanation:(0,s.__)("To receive updates and support, please connect your subscription to this store.","woocommerce")}:!!e.expired&&{text:(0,s.__)("Expired","woocommerce"),level:Oe.Error,explanation:(0,c.createInterpolateElement)((0,s.__)("To receive updates and support, please <renew>renew</renew> this subscription or use a subscription from another account by <sharing>sharing</sharing> or <transferring>transferring</transferring>.","woocommerce"),{renew:(0,c.createElement)("a",{href:F(e),rel:"nofollow noopener noreferrer"},"renew"),sharing:(0,c.createElement)("a",{href:b,rel:"nofollow noopener noreferrer"},"sharing"),transferring:(0,c.createElement)("a",{href:b,rel:"nofollow noopener noreferrer"},"sharing")})}}(e);return{display:(0,c.createElement)("div",{className:"woocommerce-marketplace__my-subscriptions__product"},(0,c.createElement)("a",{href:qe(e.product_url),target:"_blank",rel:"noreferrer"},(0,c.createElement)("span",{className:"woocommerce-marketplace__my-subscriptions__product-icon"},o)),(0,c.createElement)("a",{href:qe(e.product_url),className:"woocommerce-marketplace__my-subscriptions__product-name",target:"_blank",rel:"noreferrer"},e.product_name),(0,c.createElement)("span",{className:"woocommerce-marketplace__my-subscriptions__product-statuses"},r&&(0,c.createElement)(We,{text:r.text,level:r.level,explanation:null!==(t=r.explanation)&&void 0!==t?t:""}))),value:e.product_name}}function tt(e){const t=e.expires;if(!0===e.local.installed&&""===e.product_key)return{display:"",value:""};let o=(0,s.__)("Never expires","woocommerce");return t&&(o=(0,je.gmdateI18n)("j M, Y",new Date(1e3*t))),{display:(0,c.createElement)("span",{className:"woocommerce-marketplace__my-subscriptions__expiry-date"},o),value:t}}function ot(e){return{display:e.autorenew?(0,s.__)("On","woocommerce"):(0,s.__)("Off","woocommerce"),value:e.autorenew}}function ct(e){return{display:Xe(e)}}function rt(e){let t=null;return""===e.product_key?t=(0,c.createElement)(Re,{subscription:e}):e.expired?t=(0,c.createElement)(Ze,{subscription:e}):!1===e.local.installed&&!1===e.subscription_installed?t=(0,c.createElement)(Ye,{subscription:e}):!1===e.active&&!0===e.subscription_available&&(t=(0,c.createElement)(Qe,{subscription:e,variant:"link"})),{display:(0,c.createElement)("div",{className:"woocommerce-marketplace__my-subscriptions__actions"},t,(0,c.createElement)(Je,{subscription:e}))}}const at="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEyLjAwMDIgMi4yNVY0QzE2LjQxODUgNCAyMC4wMDAzIDcuNTgxNzIgMjAuMDAwMyAxMkMyMC4wMDAzIDE1LjcyNzcgMTcuNDUwNyAxOC44NTk5IDE0LjAwMDMgMTkuNzQ4VjE5Ljc0NzlDMTMuODMwMSAxOS43OTE3IDEzLjY1NzcgMTkuODMwMSAxMy40ODMzIDE5Ljg2MjhDMTMuMzM3MSAxOS44OTA1IDEzLjE5MDYgMTkuOTE0IDEzLjA0NDIgMTkuOTMzNEwxMy4wNDQxIDE5LjkzMjVDMTIuNzAyNCAxOS45NzcgMTIuMzUzOSAyMCAxMiAyMEMxMS42NDYgMjAgMTEuMjk3NSAxOS45NzcgMTAuOTU1NiAxOS45MzI0TDEwLjk1NTYgMTkuOTMyN0MxMC45MTQ4IDE5LjkyNzMgMTAuODc0IDE5LjkyMTYgMTAuODMzMyAxOS45MTU1QzkuNjEwMzYgMTkuNzM2OSA4LjQ3NzIyIDE5LjI4MTUgNy40OTk0OSAxOC42MTVDNy4zNzM2NSAxOC41Mjk1IDcuMjUwMTEgMTguNDQwNCA3LjEyOTA0IDE4LjM0NzdMNy4xMjk1NCAxOC4zNDdDNi41NzU0NiAxNy45MjEyIDYuMDc4NzIgMTcuNDI0NSA1LjY1MjkxIDE2Ljg3MDRMNS42NTE3MSAxNi44NzEzQzUuNDg1NTEgMTYuNjU0NSA1LjMyOTQxIDE2LjQyNzYgNS4xODQzOCAxNi4xOTExQzQuNjk0NTMgMTUuMzk2MiA0LjMzOTg1IDE0LjUwOTEgNC4xNTIzOSAxMy41NjE5QzQuMTE3ODggMTMuMzg5NSA0LjA4OTI1IDEzLjIxNjggNC4wNjY0MSAxMy4wNDQxTDQuMDY3NDkgMTMuMDQzOUM0LjAyMjk3IDEyLjcwMjIgNCAxMi4zNTM4IDQgMTJDNCAxMS42NDYgNC4wMjI5OSAxMS4yOTc0IDQuMDY3NTYgMTAuOTU1NUw0LjA2NzA4IDEwLjk1NTVDNC4wNzY5NCAxMC44ODExIDQuMDg3ODQgMTAuODA3IDQuMDk5NzYgMTAuNzMzQzQuMjgxIDkuNTk0IDQuNzAyNjYgOC41MzUwNyA1LjMxMTA5IDcuNjA5OTJDNS40MTg2NCA3LjQ0NTcyIDUuNTMyMzYgNy4yODUyNSA1LjY1MjEgNy4xMjg5MUw1LjY1Mjk0IDcuMTI5NTVDNS42NTUzNSA3LjEyNjQxIDUuNjU3NzcgNy4xMjMyNyA1LjY2MDE4IDcuMTIwMTRMNi44NjAzNyA4LjAyMDI4QzYuNzQwMTUgOC4xNzUzMSA2LjYyNjc5IDguMzM1OTMgNi41MjA3NCA4LjUwMTY4QzYuMDYwNDMgOS4yMjQzOSA1Ljc0NTQgMTAuMDMzMyA1LjU5NjM5IDEwLjg3ODVDNS41MzMwMyAxMS4yNDI4IDUuNSAxMS42MTc2IDUuNSAxMkM1LjUgMTIuNDc1MSA1LjU1MDk2IDEyLjkzODIgNS42NDc3MiAxMy4zODQzQzUuNzI4OTQgMTMuNzU0NCA1Ljg0Mzk3IDE0LjEyMzMgNS45OTQ3NSAxNC40ODczQzYuMTE3NTQgMTQuNzgzNyA2LjI1OTM4IDE1LjA2NTcgNi40MTgxMyAxNS4zMzI1QzYuOTE2NzIgMTYuMTY1OCA3LjU5NjYzIDE2Ljg3ODIgOC40MDMzNSAxNy40MTUxQzkuMTc2ODIgMTcuOTI3NSAxMC4wNTQgMTguMjcxIDEwLjk3MTQgMTguNDE5MUMxMS4zMDY0IDE4LjQ3MjMgMTEuNjUgMTguNSAxMiAxOC41QzEyLjQ1MDYgMTguNSAxMi44OTA0IDE4LjQ1NDIgMTMuMzE1MSAxOC4zNjY5QzEzLjUyNjMgMTguMzIzIDEzLjczNzIgMTguMjY4MSAxMy45NDcgMTguMjAxOUwxMy45NDc0IDE4LjIwMzJDMTYuNTg1OSAxNy4zNzU4IDE4LjUgMTQuOTExNCAxOC41IDEyQzE4LjUgOC40MTAyMyAxNS41OSA1LjUwMDEzIDEyLjAwMDIgNS41VjcuMjVMOS4wMDAyNCA0Ljc1TDEyLjAwMDIgMi4yNVoiIGZpbGw9IiMwMDdDQkEiLz4KPC9zdmc+",nt="woocommerce-marketplace-refresh-subscriptions";function st(){const{refreshSubscriptions:e}=(0,c.useContext)(Te),[t,o]=(0,c.useState)(!1),r=()=>{t||(B(nt),o(!0),e().then((()=>{R(nt,(0,s.__)("Subscriptions refreshed.","woocommerce"),z.Success)})).catch((e=>{R(nt,(0,s.sprintf)((0,s.__)("Error refreshing subscriptions: %s","woocommerce"),e.message),z.Error,{actions:[{label:(0,s.__)("Try again","woocommerce"),onClick:r}]})})).finally((()=>{o(!1)})))};return(0,c.createElement)(i.Button,{className:"woocommerce-marketplace__refresh-subscriptions",onClick:r,isBusy:t},(0,c.createElement)("img",{src:at,alt:(0,s.__)("Refresh subscriptions","woocommerce"),className:"woocommerce-marketplace__refresh-subscriptions-icon"}),(0,s.__)("Refresh","woocommerce"))}const lt="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGcgaWQ9ImFsZXJ0Ij4KPHBhdGggaWQ9IlZlY3RvciIgZD0iTTEyIDIwQzE2LjQxODMgMjAgMjAgMTYuNDE4MyAyMCAxMkMyMCA3LjU4MTcyIDE2LjQxODMgNCAxMiA0QzcuNTgxNzIgNCA0IDcuNTgxNzIgNCAxMkM0IDE2LjQxODMgNy41ODE3MiAyMCAxMiAyMFoiIHN0cm9rZT0iI0NDMTgxOCIgc3Ryb2tlLXdpZHRoPSIxLjUiLz4KPHBhdGggaWQ9IlZlY3Rvcl8yIiBkPSJNMTMgN0gxMVYxM0gxM1Y3WiIgZmlsbD0iI0NDMTgxOCIvPgo8cGF0aCBpZD0iVmVjdG9yXzMiIGQ9Ik0xMyAxNUgxMVYxN0gxM1YxNVoiIGZpbGw9IiNDQzE4MTgiLz4KPC9nPgo8L3N2Zz4K";function it(){const e=(0,T.useSelect)((e=>e(S).notices()),[]),t=e=>e.options?.actions?e.options?.actions.map((e=>({...e,variant:"link",className:"is-link"}))):[],o=[];for(const r of e)o.push((0,c.createElement)(i.Notice,{className:"woocommerce-marketplace__notice--error",status:r.status,onRemove:()=>B(r.productKey),key:r.productKey,actions:t(r)},(0,c.createElement)("img",{src:lt,alt:"",width:24,height:24}),r.message));return(0,c.createElement)(c.Fragment,null,o)}function mt(e){var t;const o=new URL(W());return e.install&&o.searchParams.set("install",e.install),(0,c.createElement)(i.Button,{href:o.href,variant:null!==(t=e.variant)&&void 0!==t?t:"secondary"},(0,s.__)("Connect Account","woocommerce"))}function ut(){const e=(0,X.useQuery)(),t=e?.install,o=(0,r.O3)("wccomHelper",{}),a=!!o?.isConnected,[n,l]=(0,c.useState)(!1),[m,u]=(0,c.useState)(!1),{subscriptions:p,isLoading:d}=(0,c.useContext)(Te),_=p.find((e=>e.product_key===t)),g=(0,c.useCallback)((()=>{(0,X.navigateTo)({url:(0,X.getNewPath)({...e,install:void 0},E,{})})}),[e]);(0,c.useEffect)((()=>{d||(t&&a&&!d&&!_?(R(t,(0,s.sprintf)((0,s.__)("Could not find subscription with product key %s.","woocommerce"),t),z.Error),g()):l(!!t))}),[a,d,t,g,_]),(0,c.useEffect)((()=>{_&&_.local.installed&&u(!0)}),[_]);const w=()=>{g(),l(!1)};return n?(0,c.createElement)(i.Modal,{title:m?(0,s.__)("You are ready to go!","woocommerce"):(0,s.__)("Add to store","woocommerce"),onRequestClose:w,focusOnMount:!0,className:"woocommerce-marketplace__header-account-modal has-size-medium",style:{borderRadius:4},overlayClassName:"woocommerce-marketplace__header-account-modal-overlay"},(()=>{if(!a)return(0,c.createElement)(i.Notice,{status:"warning",isDismissible:!1},(0,s.__)("In order to install a product, you need to first connect your account.","woocommerce"));if(_){const e=m?(0,s.__)("Keep the momentum going and start setting up your extension.","woocommerce"):(0,s.__)("Would you like to install this extension?","woocommerce");return(0,c.createElement)(c.Fragment,null,(0,c.createElement)("p",{className:"woocommerce-marketplace__header-account-modal-text"},e),(0,c.createElement)(ie,{product:G(_),small:!0,tracksData:{position:1,group:"subscriptions",label:"install"}}))}})(),(()=>{const e=[];return m?(e.push((0,c.createElement)(i.Button,{variant:"secondary",href:_?.documentation_url,target:"_blank",className:"woocommerce-marketplace__header-account-modal-button",key:"docs"},(0,s.__)("View docs","woocommerce"))),e.push((0,c.createElement)(i.Button,{variant:"primary",href:f,className:"woocommerce-marketplace__header-account-modal-button",key:"plugin-list"},(0,s.__)("View in Plugins","woocommerce")))):(e.push((0,c.createElement)(i.Button,{variant:"tertiary",onClick:w,className:"woocommerce-marketplace__header-account-modal-button",key:"cancel"},(0,s.__)("Cancel","woocommerce"))),a?_&&e.push((0,c.createElement)(Ye,{subscription:_,variant:"primary",onError:w,key:"install"})):e.push((0,c.createElement)(mt,{variant:"primary",install:t,key:"connect"}))),(0,c.createElement)(i.ButtonGroup,{className:"woocommerce-marketplace__header-account-modal-button-group"},e)})()):null}function pt(){const{subscriptions:e,isLoading:t}=(0,c.useContext)(Te),o=(0,r.O3)("wccomHelper",{}),a=(0,c.createInterpolateElement)((0,s.__)("Woo.com extensions and themes installed on this store. To see all your subscriptions go to <a>your account<custom_icon /></a> on Woo.com.","woocommerce"),{a:(0,c.createElement)("a",{href:"https://woo.com/my-account/my-subscriptions",target:"_blank",rel:"nofollow noopener noreferrer"},"your account"),custom_icon:(0,c.createElement)(p.Z,{icon:d.Z,size:12})}),n=e.filter((e=>e.subscription_installed)),l=e.filter((e=>!e.subscription_installed));return o?.isConnected?(0,c.createElement)("div",{className:"woocommerce-marketplace__my-subscriptions"},(0,c.createElement)(ut,null),(0,c.createElement)("section",{className:"woocommerce-marketplace__my-subscriptions__notices"},(0,c.createElement)(it,null)),(0,c.createElement)("section",{className:"woocommerce-marketplace__my-subscriptions-section woocommerce-marketplace__my-subscriptions__installed"},(0,c.createElement)("header",{className:"woocommerce-marketplace__my-subscriptions__header"},(0,c.createElement)("div",{className:"woocommerce-marketplace__my-subscriptions__header-content"},(0,c.createElement)("h2",{className:"woocommerce-marketplace__my-subscriptions__heading"},(0,s.__)("Installed on this store","woocommerce")),(0,c.createElement)("p",{className:"woocommerce-marketplace__my-subscriptions__table-description"},a)),(0,c.createElement)("div",{className:"woocommerce-marketplace__my-subscriptions__header-refresh"},(0,c.createElement)(st,null))),(0,c.createElement)("div",{className:"woocommerce-marketplace__my-subscriptions__table-wrapper"},(0,c.createElement)(Ae,{isLoading:t,rows:n.map((e=>function(e){return[et(e),tt(e),ot(e),ct(e),rt(e)]}(e)))}))),l.length>0&&(0,c.createElement)("section",{className:"woocommerce-marketplace__my-subscriptions-section woocommerce-marketplace__my-subscriptions__available"},(0,c.createElement)("h2",{className:"woocommerce-marketplace__my-subscriptions__heading"},(0,s.__)("Available to use","woocommerce")),(0,c.createElement)("p",{className:"woocommerce-marketplace__my-subscriptions__table-description"},(0,s.__)("Woo.com subscriptions you haven't used yet.","woocommerce")),(0,c.createElement)("div",{className:"woocommerce-marketplace__my-subscriptions__table-wrapper"},(0,c.createElement)(Se,{isLoading:t,rows:l.map((e=>function(e){return[et(e),tt(e),ot(e),ct(e),rt(e)]}(e)))})))):(0,c.createElement)("div",{className:"woocommerce-marketplace__my-subscriptions--connect"},(0,c.createElement)(ut,null),(0,c.createElement)("div",{className:"woocommerce-marketplace__my-subscriptions__icon"}),(0,c.createElement)("h2",{className:"woocommerce-marketplace__my-subscriptions__header"},(0,s.__)("Manage your subscriptions","woocommerce")),(0,c.createElement)("p",{className:"woocommerce-marketplace__my-subscriptions__description"},(0,s.__)("Connect your account to get updates, manage your subscriptions, and get seamless support. Once connected, your Woo.com subscriptions will appear here.","woocommerce")),(0,c.createElement)(i.Button,{href:W(),variant:"primary"},(0,s.__)("Connect Account","woocommerce")))}var dt=function(e){return e[e.notConnected=0]="notConnected",e[e.notInstalled=1]="notInstalled",e[e.installing=2]="installing",e[e.installedCanActivate=3]="installedCanActivate",e[e.installedCannotActivate=4]="installedCannotActivate",e[e.installFailed=5]="installFailed",e[e.activating=6]="activating",e[e.activated=7]="activated",e[e.activationFailed=8]="activationFailed",e}(dt||{});const _t=function(e){const[t,o]=(0,c.useState)(dt.notInstalled),[n,l]=(0,c.useState)(),[m,u]=(0,c.useState)(),[p,d]=(0,c.useState)(),[_,g]=(0,c.useState)(),[w,y]=(0,c.useState)(),[N,h]=(0,c.useState)(!1),[M,v]=(0,c.useState)(),{addInstalledProduct:k}=(0,c.useContext)(a),b=(0,X.useQuery)();function I(){o(dt.notInstalled),v(void 0),(0,X.navigateTo)({url:(0,X.getNewPath)({...b,install:void 0,installProduct:void 0},E,{})})}return(0,c.useEffect)((()=>{const e=(0,r.O3)("wccomHelper",{});u(e?.installedProducts),d(e?.isConnected)}),[]),(0,c.useEffect)((()=>{if(h(!1),!b.installProduct)return;const t=parseInt(b.installProduct,10),c=e.products.find((e=>e.id===t));if(c){if(m&&m.find((e=>e===c.slug)))return;p?o(dt.notInstalled):(o(dt.notConnected),v({status:"warning",message:(0,s.__)("In order to install a product, you need to first connect your account.","woocommerce")})),h(!0),l(c)}}),[b,e.products,m,p]),n&&N?(0,c.createElement)(i.Modal,{title:t===dt.activated?(0,s.__)("You are ready to go!","woocommerce"):(0,s.__)("Add to Store","woocommerce"),onRequestClose:I,focusOnMount:!0,className:"woocommerce-marketplace__header-account-modal has-size-medium",style:{borderRadius:4},overlayClassName:"woocommerce-marketplace__header-account-modal-overlay"},M&&(0,c.createElement)(i.Notice,{status:M.status,isDismissible:!1},M.message),(0,c.createElement)("p",{className:"woocommerce-marketplace__header-account-modal-text"},t===dt.notConnected?"":t===dt.installedCanActivate||t===dt.activating?(0,s.__)("Extension successfully installed. Would you like to activate it?","woocommerce"):t===dt.installedCannotActivate?(0,s.__)("Extension successfully installed but we can't activate it at the moment. Please visit the plugins page to see more.","woocommerce"):t===dt.activated?(0,s.__)("Keep the momentum going and start setting up your extension.","woocommerce"):(0,s.__)("Would you like to install this extension?","woocommerce")),n&&(0,c.createElement)(ie,{product:n,small:!0,tracksData:{position:1,group:"install-flow",label:"install"}}),(0,c.createElement)(i.ButtonGroup,{className:"woocommerce-marketplace__header-account-modal-button-group"},t===dt.activated?w?(0,c.createElement)(i.Button,{variant:"tertiary",href:w,className:"woocommerce-marketplace__header-account-modal-button",key:"docs"},(0,s.__)("View Docs","woocommerce")):(0,c.createElement)(c.Fragment,null):(0,c.createElement)(i.Button,{variant:"tertiary",onClick:I,className:"woocommerce-marketplace__header-account-modal-button",key:"cancel"},(0,s.__)("Cancel","woocommerce")),t===dt.notConnected?(0,c.createElement)(mt,{variant:"primary",key:"connect"}):t===dt.installedCanActivate||t===dt.activating?(0,c.createElement)(i.Button,{variant:"primary",onClick:function(){_&&(o(dt.activating),(0,ne.recordEvent)("marketplace_activate_new_product_clicked",{product_id:n?n.id:0}),fetch(_).then((()=>{o(dt.activated)})).catch((()=>{o(dt.activationFailed),v({status:"error",message:(0,s.__)("Activation failed. Please try again from the plugins page.","woocommerce")})})))},key:"activate",isBusy:t===dt.activating,disabled:t===dt.activating},(0,s.__)("Activate","woocommerce")):t===dt.activated||t===dt.installedCannotActivate||t===dt.activationFailed?(0,c.createElement)(i.Button,{variant:"primary",href:f,className:"woocommerce-marketplace__header-account-modal-button",key:"plugin-list"},(0,s.__)("View in Plugins","woocommerce")):(0,c.createElement)(i.Button,{variant:"primary",onClick:function(){var e;n&&n.id&&((0,ne.recordEvent)("marketplace_install_new_product_clicked",{product_id:n.id}),o(dt.installing),(e=n.id,x()({path:"/wc/v3/marketplace/create-order",method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({product_id:e})})).then((e=>{if(!e.success)throw e;var t;return(0,T.dispatch)(Ue).startInstalling(n.id),y(e.data.documentation_url),n.slug&&k(null!==(t=n.slug)&&void 0!==t?t:""),Z(e.data.product_type,e.data.zip_slug).then((e=>{(0,T.dispatch)(Ue).stopInstalling(n.id),e.data.activateUrl?(g(e.data.activateUrl),o(dt.installedCanActivate)):o(dt.installedCannotActivate)}))})).catch((e=>{var t;e.data.redirect_location?(v({status:"warning",message:(0,s.__)("We need your address to complete installing this product. We will redirect you to Woo.com checkout. Afterwards, you will be able to install the product.","woocommerce")}),setTimeout((()=>{window.location.href=e.data.redirect_location}),5e3)):(o(dt.installFailed),v({status:"error",message:null!==(t=e.data.message)&&void 0!==t?t:(0,s.__)("An error occurred. Please try again later.","woocommerce")}))})))},key:"install",isBusy:t===dt.installing,disabled:t===dt.installing||t===dt.installFailed},(0,s.__)("Install","woocommerce")))):(0,c.createElement)(c.Fragment,null)};var gt=o(47642),wt=o(25918),yt=o(28601),Et=o(88502);const Nt={info:He.Z,check:gt.Z,percent:wt.Z};function ht(e){const{id:t,description:o,children:r,icon:a,isDismissible:n=!0,variant:s="info"}=e,[l,i]=(0,c.useState)("true"!==localStorage.getItem(`wc-marketplaceNoticeClosed-${t}`));if(!l)return null;const m=$()("woocommerce-marketplace__notice",`woocommerce-marketplace__notice--${s}`,{"is-dismissible":n}),u=Nt[a||"info"],d=$()("woocommerce-marketplace__notice-icon",`woocommerce-marketplace__notice-icon--${s}`);return(0,c.createElement)("div",{className:m},a&&(0,c.createElement)("span",{className:d},(0,c.createElement)(p.Z,{icon:u})),(0,c.createElement)("div",{className:"woocommerce-marketplace__notice-content"},(0,c.createElement)("p",{className:"woocommerce-marketplace__notice-description",dangerouslySetInnerHTML:(0,Et.ZP)(o)}),r&&(0,c.createElement)("div",{className:"woocommerce-marketplace__notice-children"},r)),n&&(0,c.createElement)("button",{className:"woocommerce-marketplace__notice-close","aria-label":"Close",onClick:()=>{i(!1),localStorage.setItem(`wc-marketplaceNoticeClosed-${t}`,"true")}},(0,c.createElement)(p.Z,{icon:yt.Z})))}const Mt=()=>{var e;const t=new URLSearchParams(window.location.search),o=t.get("page");if("wc-admin"!==o)return null;const a=null!==(e=window?.wcMarketplace?.promotions)&&void 0!==e?e:[],n=Date.now(),s=decodeURIComponent(t.get("path")||""),l=t.get("tab");return(0,c.createElement)(c.Fragment,null,a.map(((e,t)=>{if(!e.pages)return null;if(!e.pages.some((e=>{const t=e.path.startsWith("/")?e.path:`/${e.path}`,c=s.startsWith("/")?s:`/${s}`;return e.page===o&&t===c&&e.tab?e.tab===l:!l})))return null;const a=new Date(e.date_from_gmt).getTime(),i=new Date(e.date_to_gmt).getTime();return n<a||n>i?null:"notice"===e.format&&e?.content?(0,c.createElement)(ht,{key:t,id:null!==(m=e.menu_item_id)&&void 0!==m?m:`promotion-${t}`,description:e.content[r.MV.userLocale]||e.content.en_US,variant:e.style?e.style:"info",icon:e?.icon||"",isDismissible:e.is_dismissible||!1}):null;var m})))};function vt(){const e=(0,c.useContext)(a),[t,o]=(0,c.useState)([]),{setIsLoading:n,selectedTab:s}=e,l=(0,X.useQuery)();return(0,c.useEffect)((()=>{const e=new AbortController;if(l.tab&&["","discover"].includes(l.tab))return;n(!0),o([]);const t=new URLSearchParams;l.term&&t.append("term",l.term),l.category?t.append("category","_all"===l.category?"":l.category):"themes"===l?.tab?t.append("category","themes"):"search"===l?.tab&&t.append("category","extensions-themes");const c=(0,r.O3)("wccomHelper",!1);return c.storeCountry&&t.append("country",c.storeCountry),async function(e,t){const o=y+N+"?"+e.toString();return new Promise(((e,c)=>{Q(o,t).then((t=>{const o=t.products.map((e=>{var t,o,c;return{id:e.id,slug:e.slug,title:e.title,image:e.image,type:e.type,description:e.excerpt,vendorName:e.vendor_name,vendorUrl:e.vendor_url,icon:e.icon,url:e.link,price:null!==(t=e.raw_price)&&void 0!==t?t:e.price,averageRating:null!==(o=e.rating)&&void 0!==o?o:null,reviewsCount:null!==(c=e.reviews_count)&&void 0!==c?c:null,isInstallable:e.is_installable}}));e(o)})).catch((()=>c))}))}(t,e.signal).then((e=>{o(e)})).catch((()=>{o([])})).finally((()=>{const e={view:l?.tab,search_term:l?.term,product_type:l?.section,category:l?.category};!function(e){if(""===e.category)return;const t=e.view||"discover",o=e.search_term||null,c=e.product_type||null,r=e.category||null,a={...t&&{view:t},...o&&{search_term:o},...c&&{product_type:c},...r&&{category:r}};t&&["extensions","themes"].includes(t)&&!r&&(a.category="_all"),t&&"search"===t&&c&&!r&&(a.category="_all"),(0,ne.recordEvent)("marketplace_view",a)}(e),function(e){if(e.product_type)return;let t="extensions_view";const o=e.view||"_featured",c=e.search_term||null,r=e.category||null,a={...o&&{section:o},...c&&{search_term:c},version:"2"};switch(o){case"extensions":a.section=r||"_all";break;case"themes":a.section="themes";break;case"search":t="extensions_view_search",a.section=o,a.search_term=c||"";break;case"my-subscriptions":t="subscriptions_view",a.section="helper"}(0,ne.recordEvent)(t,a)}(e),n(!1)})),()=>{e.abort()}}),[l.term,l.category,l?.tab,n,l?.section]),(0,c.createElement)("div",{className:"woocommerce-marketplace__content"},(0,c.createElement)(Mt,null),(0,c.createElement)(_t,{products:t}),(()=>{switch(s){case"extensions":return(0,c.createElement)(Ie,{products:t,categorySelector:!0,type:D.extension});case"themes":return(0,c.createElement)(Ie,{products:t,categorySelector:!0,type:D.theme});case"search":return(0,c.createElement)(xe,{products:t,type:C.all});case"discover":return(0,c.createElement)(ge,null);case"my-subscriptions":return(0,c.createElement)(De,null,(0,c.createElement)(pt,null));default:return(0,c.createElement)(c.Fragment,null)}})())}const kt=(0,c.createElement)(m.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,c.createElement)(m.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M6.68822 16.625L5.5 17.8145L5.5 5.5L18.5 5.5L18.5 16.625L6.68822 16.625ZM7.31 18.125L19 18.125C19.5523 18.125 20 17.6773 20 17.125L20 5C20 4.44772 19.5523 4 19 4H5C4.44772 4 4 4.44772 4 5V19.5247C4 19.8173 4.16123 20.086 4.41935 20.2237C4.72711 20.3878 5.10601 20.3313 5.35252 20.0845L7.31 18.125ZM16 9.99997H8V8.49997H16V9.99997ZM8 14H13V12.5H8V14Z"})),bt=(0,c.createElement)(m.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,c.createElement)(m.Path,{d:"M12 3.176l6.75 3.068v4.574c0 3.9-2.504 7.59-6.035 8.755a2.283 2.283 0 01-1.43 0c-3.53-1.164-6.035-4.856-6.035-8.755V6.244L12 3.176zM6.75 7.21v3.608c0 3.313 2.145 6.388 5.005 7.33.159.053.331.053.49 0 2.86-.942 5.005-4.017 5.005-7.33V7.21L12 4.824 6.75 7.21z",fillRule:"evenodd",clipRule:"evenodd"}));function ft(e){const{icon:t,title:o,description:r}=e;return(0,c.createElement)("div",{className:"woocommerce-marketplace__icon-group"},(0,c.createElement)("div",{className:"woocommerce-marketplace__icon-group-headline"},(0,c.createElement)(p.Z,{icon:t,size:20,className:"woocommerce-marketplace__icon-group-icon"}),(0,c.createElement)("h3",{className:"woocommerce-marketplace__icon-group-title"},o)),(0,c.createElement)("p",{className:"woocommerce-marketplace__icon-group-description"},r))}const It="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGcgaWQ9IlciIGNsaXAtcGF0aD0idXJsKCNjbGlwMF8xMjU2XzE4NDQ2MykiPgo8cmVjdCB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9IiM2NDY5NzAiLz4KPHJlY3QgaWQ9IlJlY3RhbmdsZSAxIiB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHJ4PSIyIiBmaWxsPSIjNjQ2OTcwIi8+CjxnIGlkPSJTcGVlY2ggYnViYmxlIj4KPHBhdGggaWQ9IlZlY3RvciIgZD0iTTMuMDQ4NTUgMy44NjA0N0MzLjIwMzYgMy42NzMxMiAzLjQyOTcxIDMuNTU2ODMgMy42NzUyIDMuNTUwMzdDNC4xNzkxMSAzLjUxODA3IDQuNDY5ODMgMy43NTcxMSA0LjU0NzM1IDQuMjY3NDdDNC44NTc0NSA2LjM0NzcxIDUuMTkzMzkgOC4xMTc4NiA1LjU0ODcxIDkuNTcxNDRMNy43Mzg3OCA1LjQxMDk2QzcuOTM5MDUgNS4wMzYyNiA4LjE4NDU0IDQuODM1OTkgOC40ODgxOCA0LjgxNjYxQzguOTI3NDkgNC43ODQzIDkuMTk4ODIgNS4wNjIxIDkuMzA4NjUgNS42NTY0NUM5LjUxNTM4IDYuODE5MzIgOS44MzE5NCA3Ljk2MjgxIDEwLjI1MTkgOS4wNjc1M0MxMC41MTY3IDYuNTM1MDYgMTAuOTU2IDQuNzAwMzIgMTEuNTY5OCAzLjU2OTc1QzExLjY5MjUgMy4zMTEzNCAxMS45NDQ1IDMuMTQzMzcgMTIuMjI4NyAzLjEzMDQ1QzEyLjQ1NDkgMy4xMTEwNyAxMi42ODEgMy4xODIxMyAxMi44NTU0IDMuMzMwNzJDMTMuMDM2MyAzLjQ2NjM5IDEzLjE0NjEgMy42Nzk1OCAxMy4xNTkgMy45MDU2OUMxMy4xNzE5IDQuMDczNjYgMTMuMTM5NiA0LjI0MTYzIDEzLjA2MjEgNC4zODM3NkMxMi42NzQ1IDUuMTA3MzIgMTIuMzUxNSA2LjMwODk1IDEyLjA5OTUgNy45ODg2NUMxMS44NTQgOS42MTAyIDExLjc1NzEgMTAuODgyOSAxMS44MjE3IDExLjc5MzhDMTEuODQ3NiAxMi4wMTk5IDExLjgwMjQgMTIuMjQ2IDExLjcwNTQgMTIuNDQ2M0MxMS42MDg1IDEyLjY1MyAxMS40MDE4IDEyLjc5NTIgMTEuMTc1NyAxMi44MDgxQzEwLjkxMDggMTIuODI3NSAxMC42NTI0IDEyLjcwNDcgMTAuMzg3NSAxMi40Mzk4QzkuNDU3MjQgMTEuNDkwMiA4LjcyMDc2IDEwLjA3NTMgOC4xNzgwOCA4LjE5NTM4QzcuNTM4NTEgOS40NzQ1MyA3LjA1Mzk4IDEwLjQzNzEgNi43Mzc0MiAxMS4wNzAyQzYuMTQ5NTMgMTIuMjAwOCA1LjY0NTYyIDEyLjc3NTggNS4yMzIxNSAxMi44MDgxQzQuOTYwODIgMTIuODI3NSA0LjcyODI1IDEyLjYwMTQgNC41NDA5IDEyLjEyMzNDNC4wMzA1MyAxMC44MTgzIDMuNDgxNCA4LjI5MjI5IDIuODkzNSA0LjU0NTI3QzIuODQxODIgNC4yOTk3OCAyLjg5OTk2IDQuMDU0MjggMy4wNDg1NSAzLjg2MDQ3WiIgZmlsbD0id2hpdGUiLz4KPC9nPgo8L2c+CjxkZWZzPgo8Y2xpcFBhdGggaWQ9ImNsaXAwXzEyNTZfMTg0NDYzIj4KPHJlY3Qgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2IiBmaWxsPSJ3aGl0ZSIvPgo8L2NsaXBQYXRoPgo8L2RlZnM+Cjwvc3ZnPgo=",xt=(0,c.createInterpolateElement)((0,s.__)("30-day <a>money-back guarantee</a>","woocommerce"),{a:(0,c.createElement)("a",{href:y+"/refund-policy/"})}),Tt=(0,c.createInterpolateElement)((0,s.__)("<a>Get help</a> when you need it","woocommerce"),{a:(0,c.createElement)("a",{href:y+"/docs/"})}),Dt=(0,c.createInterpolateElement)((0,s.__)("<a>Products</a> you can trust","woocommerce"),{a:(0,c.createElement)("a",{href:y+"/products/"})});function Ct(){return(0,c.createElement)("div",{className:"woocommerce-marketplace__footer-content"},(0,c.createElement)("h2",{className:"woocommerce-marketplace__footer-title"},(0,s.__)("Hundreds of vetted products and services. Unlimited potential.","woocommerce")),(0,c.createElement)("div",{className:"woocommerce-marketplace__footer-columns"},(0,c.createElement)(ft,{icon:gt.Z,title:xt,description:(0,s.__)("If you change your mind within 30 days of your purchase, we'll give you a full refund — hassle-free.","woocommerce")}),(0,c.createElement)(ft,{icon:kt,title:Tt,description:(0,s.__)("With detailed documentation and a global support team, help is always available if you need it.","woocommerce")}),(0,c.createElement)(ft,{icon:bt,title:Dt,description:(0,s.__)("Everything in the Marketplace has been built by our own team or by our trusted partners, so you can be sure of its quality.","woocommerce")})),(0,c.createElement)("div",{className:"woocommerce-marketplace__footer-logo"},(0,c.createElement)("img",{src:It,alt:"Woo Logo","aria-hidden":"true"}),(0,c.createElement)("span",null,(0,s.__)("Woo Marketplace","woocommerce"))))}function zt(){return(0,c.createElement)("div",{className:"woocommerce-marketplace__footer"},(0,c.createElement)(Ct,null))}function At(e){const{title:t,fieldName:o,onValueChange:r,validationFailed:a}=e,n=[{value:1,emoji:"😔",label:(0,s.__)("Strongly disagree","woocommerce")},{value:2,emoji:"🙁",label:(0,s.__)("Disagree","woocommerce")},{value:3,emoji:"😐",label:(0,s.__)("Neutral","woocommerce")},{value:4,emoji:"🙂",label:(0,s.__)("Agree","woocommerce")},{value:5,emoji:"😍",label:(0,s.__)("Strongly agree","woocommerce")}],l=$()("woocommerce-marketplace__likert-scale",{"validation-failed":a});function i(e){r(parseInt(e.target.value,10))}return(0,c.createElement)(c.Fragment,null,(0,c.createElement)("h2",null,t),(0,c.createElement)("ol",{className:l},n.map((e=>{const t=`${o}_${e.value}`;return(0,c.createElement)("li",{key:t,className:"woocommerce-marketplace__likert-scale-item"},(0,c.createElement)("input",{type:"radio",name:o,value:e.value,id:t,onChange:i,className:"screen-reader-text"}),(0,c.createElement)("label",{htmlFor:t},(0,c.createElement)("div",{className:"woocommerce-marketplace__likert-scale-icon"},e.emoji),(0,c.createElement)("div",{className:"woocommerce-marketplace__likert-scale-text"},e.label)))}))))}function St(){const e="marketplace_redesign_2023_dismissals",t="marketplace_redesign_2023_last_shown_date",o=(0,c.useContext)(a),{isLoading:r}=o,n=()=>localStorage.setItem(t,(new Date).toDateString()),l=()=>parseInt(localStorage.getItem(e)||"0",10),m=()=>{n(),localStorage.setItem(e,`${l()+1}`)},[u,p]=(0,c.useState)(!1),[d,_]=(0,c.useState)(""),[g,w]=(0,c.useState)(0),[y,E]=(0,c.useState)(!1),[N,h]=(0,c.useState)(0),[M,v]=(0,c.useState)(!1),k=()=>p(!0),b=()=>{m(),p(!1)},{createNotice:f}=(0,T.useDispatch)("core/notices");function I(){f("success",(0,s.__)("How easy is it to find an extension?","woocommerce"),{type:"snackbar",icon:(0,c.createElement)(c.Fragment,null,(0,c.createElement)("svg",{color:"#fff",strokeWidth:"1.5",viewBox:"0 0 28.873 8.9823",style:{height:"8px",marginLeft:"-7px"}},(0,c.createElement)("path",{className:"l",d:"m4.1223 1.1216 19.12-0.014142 4.3982 3.38-4.3982 3.38-19.12-0.014142a3.34 3.34 0 0 1-2.39-0.97581 3.37 3.37 0 0 1 0.00707-4.773 3.34 3.34 0 0 1 2.383-0.98288z",stroke:"#fff"}),(0,c.createElement)("line",{className:"l",x1:"6.7669",x2:"6.7669",y1:"7.8533",y2:"1.1216",stroke:"#fff"}),(0,c.createElement)("path",{className:"l",d:"m23.235 1.1146 4.4053 3.3729-4.3982 3.38a6.59 6.59 0 0 1-0.89096-3.3517 6.59 6.59 0 0 1 0.88388-3.4012z",stroke:"#fff"}),(0,c.createElement)("line",{className:"l",x1:"6.7669",x2:"22.323",y1:"4.4875",y2:"4.4875",stroke:"#fff"}))),explicitDismiss:!0,onDismiss:m,actions:[{onClick:k,label:"Give feedback"}]})}return(0,c.useEffect)((function(){if(r)return;if(l()>=1)return;if((new Date).toDateString()===localStorage.getItem(t))return;const e=setTimeout(I,5e3);return n(),()=>{clearTimeout(e)}}),[r]),new Date("2024-01-01")>new Date?(0,c.createElement)(c.Fragment,null,u&&(0,c.createElement)(i.Modal,{title:(0,s.__)("How easy was it to find an extension?","woocommerce"),onRequestClose:b,className:"woocommerce-marketplace__feedback-modal"},(0,c.createElement)("p",null,(0,s.__)("Your feedback will help us create a better experience for people like you! Please tell us to what extent you agree or disagree with the statements below.","woocommerce")),(0,c.createElement)(At,{fieldName:"extension_screen_easy_to_find",title:(0,s.__)("It was easy to find an extension","woocommerce"),onValueChange:function(e){E(!1),w(e)},validationFailed:y}),(0,c.createElement)(At,{fieldName:"extension_screen_meets_my_needs",title:(0,s.__)("The Extensions screen’s functionality meets my needs","woocommerce"),onValueChange:function(e){v(!1),h(e)},validationFailed:M}),(0,c.createElement)(i.TextareaControl,{label:(0,s.__)("Additional thoughts","woocommerce"),value:d,onChange:e=>_(e)}),(0,c.createElement)("p",{className:"woocommerce-marketplace__feedback-modal-buttons"},(0,c.createElement)(i.Button,{variant:"tertiary",onClick:b,text:(0,s.__)("Cancel","woocommerce")}),(0,c.createElement)(i.Button,{variant:"primary",onClick:function(){if(0===g||0===N)return 0===g&&E(!0),void(0===N&&v(!0));(0,ne.recordEvent)("ces_feedback",{action:"marketplace_redesign_2023",score:g,score_second_question:N,score_combined:g+N,thoughts:d}),p(!1),n(),localStorage.setItem(e,"1")},text:(0,s.__)("Send","woocommerce")})))):(0,c.createElement)(c.Fragment,null)}function jt(){const{selectedTab:e}=(0,c.useContext)(a),t="woocommerce-marketplace"+(e?" woocommerce-marketplace--"+e:"");return(0,c.createElement)("div",{className:t},(0,c.createElement)(ae,null),(0,c.createElement)(vt,null),(0,c.createElement)(St,null),(0,c.createElement)(zt,null))}function Lt(){return(0,c.createElement)(n,null,(0,c.createElement)(jt,null))}}}]);