import{r as s,h as l,g as i}from"./p-b891c2f1.js";import{_ as o,s as t,a as e}from"./p-684c85b4.js";import"./p-aafd8ea4.js";import{a as n}from"./p-1c2e2695.js";import"./p-112455b1.js";const d=class{constructor(l){s(this,l),this.purchases=[]}renderEmpty(){return l("div",null,l("sc-divider",{style:{"--spacing":"0"}}),l("slot",{name:"empty"},l("sc-empty",{icon:"download"},o("You don't have any downloads.","surecart"))))}renderLoading(){return l("sc-card",{"no-padding":!0,style:{"--overflow":"hidden"}},l("sc-stacked-list",null,l("sc-stacked-list-row",{style:{"--columns":"2"},"mobile-size":0},l("div",{style:{padding:"0.5em"}},l("sc-skeleton",{style:{width:"30%",marginBottom:"0.75em"}}),l("sc-skeleton",{style:{width:"20%"}})))))}renderList(){return this.purchases.map((s=>{var i,o,d,r,a,c,u,v,h;return l("sc-stacked-list-row",{href:(null==s?void 0:s.revoked)?null:n(window.location.href,{action:"edit",model:"download",id:s.id,nonce:this.requestNonce}),key:s.id,"mobile-size":0},l("sc-spacing",{style:{"--spacing":"var(--sc-spacing-xx--small)"}},l("div",null,l("strong",null,null===(i=null==s?void 0:s.product)||void 0===i?void 0:i.name)),l("div",{class:"download__details"},t(e("%s file","%s files",null===(r=null===(d=null===(o=null==s?void 0:s.product)||void 0===o?void 0:o.downloads)||void 0===d?void 0:d.pagination)||void 0===r?void 0:r.count,"surecart"),null===(u=null===(c=null===(a=null==s?void 0:s.product)||void 0===a?void 0:a.downloads)||void 0===c?void 0:c.pagination)||void 0===u?void 0:u.count)," ","•"," ",l("sc-format-bytes",{value:null===(h=null===(v=null==s?void 0:s.product)||void 0===v?void 0:v.downloads)||void 0===h?void 0:h.data.map((s=>{var l;return null===(l=null==s?void 0:s.media)||void 0===l?void 0:l.byte_size})).reduce(((s,l)=>s+l),0)}))),l("sc-icon",{name:"chevron-right",slot:"suffix"}))}))}renderContent(){var s;return this.loading?this.renderLoading():0===(null===(s=this.purchases)||void 0===s?void 0:s.length)?this.renderEmpty():l("sc-card",{"no-padding":!0,style:{"--overflow":"hidden"}},l("sc-stacked-list",null,this.renderList()))}render(){return l("sc-dashboard-module",{class:"downloads-list",error:this.error},l("span",{slot:"heading"},l("slot",{name:"heading"},this.heading||o("Items","surecart"))),l("slot",{name:"before"}),!!this.allLink&&l("sc-button",{type:"link",href:this.allLink,slot:"end"},o("View all","surecart"),l("sc-icon",{name:"chevron-right",slot:"suffix"})),this.renderContent(),l("slot",{name:"after"}),this.busy&&l("sc-block-ui",null))}get el(){return i(this)}};d.style=":host{display:block}.download__details{opacity:0.75}";export{d as sc_downloads_list}