import{r as e,h as s,F as d,a as i}from"./p-e97fde0a.js";import{a as t}from"./p-401e165e.js";const n=":host{display:block}.download__details{opacity:0.75}";const o=n;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,n,o;const l=(n=(i=e===null||e===void 0?void 0:e.product)===null||i===void 0?void 0:i.downloads)===null||n===void 0?void 0:n.data.filter((e=>!e.archived));const a=(l||[]).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 r=a.reduce(((e,s)=>e+s),0);return s("sc-stacked-list-row",{href:!(e===null||e===void 0?void 0:e.revoked)?t(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,(o=e===null||e===void 0?void 0:e.product)===null||o===void 0?void 0:o.name)),s("div",{class:"download__details"},wp.i18n.sprintf(wp.i18n._n("%s file","%s files",l===null||l===void 0?void 0:l.length,"surecart"),l===null||l===void 0?void 0:l.length),!!r&&s(d,null," ","• ",s("sc-format-bytes",{value:r})))),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:"f629853f16d279b8f33d68317e5bb7df45bbed71",class:"downloads-list",error:this.error},s("span",{key:"0807ae32890dfefe14ae05375de96d8b6908494c",slot:"heading"},s("slot",{key:"1bc26c3996345419536c005a5ee8bbbf24714ac2",name:"heading"},this.heading||wp.i18n.__("Items","surecart"))),s("slot",{key:"27357e871fa44196d2859e52c311fad77349a766",name:"before"}),!!this.allLink&&s("sc-button",{key:"dd6278034e5633e01097721abf98c3d807a3de84",type:"link",href:this.allLink,slot:"end"},wp.i18n.__("View all","surecart"),s("sc-icon",{key:"6cb013c4be850389b0e02142ea75f41c6b031fb7",name:"chevron-right",slot:"suffix"})),this.renderContent(),s("slot",{key:"fa6b4eebe7a75081af5343fa13368eb194a34868",name:"after"}),this.busy&&s("sc-block-ui",{key:"e8b0165692f5a2281e4840046e930532c202a335"}))}get el(){return i(this)}};l.style=o;export{l as sc_purchase_downloads_list};
//# sourceMappingURL=p-1987d09d.entry.js.map