import{r as e,h as s,F as d,a as i}from"./p-9add63ef.js";import{a as n}from"./p-401e165e.js";const o=":host{display:block}.download__details{opacity:0.75}";const t=o;const l=class{constructor(s){e(this,s);this.allLink=undefined;this.heading=undefined;this.busy=undefined;this.loading=undefined;this.requestNonce=undefined;this.error=undefined;this.purchases=[]}renderEmpty(){return s("div",null,s("sc-divider",{style:{"--spacing":"0"}}),s("slot",{name:"empty"},s("sc-empty",{icon:"download"},wp.i18n.__("You don't have any downloads.","surecart"))))}renderLoading(){return s("sc-card",{"no-padding":true,style:{"--overflow":"hidden"}},s("sc-stacked-list",null,s("sc-stacked-list-row",{style:{"--columns":"2"},"mobile-size":0},s("div",{style:{padding:"0.5em"}},s("sc-skeleton",{style:{width:"30%",marginBottom:"0.75em"}}),s("sc-skeleton",{style:{width:"20%"}})))))}renderList(){return this.purchases.map((e=>{var i,o,t,l,a;const c=e===null||e===void 0?void 0:e.variant;const r=(((i=c===null||c===void 0?void 0:c.downloads)===null||i===void 0?void 0:i.data)||[]).filter((e=>!e.archived));const u=(c===null||c===void 0?void 0:c.downloads_enabled)&&r.length>0;const v=u?r:((l=(t=(o=e===null||e===void 0?void 0:e.product)===null||o===void 0?void 0:o.downloads)===null||t===void 0?void 0:t.data)===null||l===void 0?void 0:l.filter((e=>!e.archived)))||[];const h=v.length;const f=(v||[]).map((e=>{var s;return(e===null||e===void 0?void 0:e.media)?(s=e===null||e===void 0?void 0:e.media)===null||s===void 0?void 0:s.byte_size:0}));const b=f.reduce(((e,s)=>e+s),0);return s("sc-stacked-list-row",{href:!(e===null||e===void 0?void 0:e.revoked)?n(window.location.href,{action:"show",model:"download",id:e.id,nonce:this.requestNonce}):null,key:e.id,"mobile-size":0},s("sc-spacing",{style:{"--spacing":"var(--sc-spacing-xx--small)"}},s("div",null,s("strong",null,(a=e===null||e===void 0?void 0:e.product)===null||a===void 0?void 0:a.name)),s("div",{class:"download__details"},wp.i18n.sprintf(wp.i18n._n("%s file","%s files",h,"surecart"),h),!!b&&s(d,null," ","• ",s("sc-format-bytes",{value:b})))),s("sc-icon",{name:"chevron-right",slot:"suffix"}))}))}renderContent(){var e;if(this.loading){return this.renderLoading()}if(((e=this.purchases)===null||e===void 0?void 0:e.length)===0){return this.renderEmpty()}return s("sc-card",{"no-padding":true,style:{"--overflow":"hidden"}},s("sc-stacked-list",null,this.renderList()))}render(){return s("sc-dashboard-module",{key:"a088dd66ad05397273b3a2ca13c432b1ed5420e2",class:"downloads-list",error:this.error},s("span",{key:"ee2b187421431ee581fd5baf683d115094c21d53",slot:"heading"},s("slot",{key:"1b83b443594a6d4cecc2a2e99359f00089d1831e",name:"heading"},this.heading||wp.i18n.__("Items","surecart"))),s("slot",{key:"501369a7bc63b18426b279d7ec1e95ab8efc5ee6",name:"before"}),!!this.allLink&&s("sc-button",{key:"3593d3bb4b1d1aadd279b4b35a28c77eabce35ec",type:"link",href:this.allLink,slot:"end"},wp.i18n.__("View all","surecart"),s("sc-icon",{key:"31cef6334166345b9f7955d8bf42f30bc4313d9e",name:"chevron-right",slot:"suffix"})),this.renderContent(),s("slot",{key:"7560eac98fa4bf7ba1093cbd428874fa4c3183c4",name:"after"}),this.busy&&s("sc-block-ui",{key:"17e6761b09ac048a1f5d7500193e5d4f2a6b5d2c"}))}get el(){return i(this)}};l.style=t;export{l as sc_purchase_downloads_list};
//# sourceMappingURL=p-42e498c0.entry.js.map