import{e2 as A,iv as x,fH as t,i5 as N,ck as y,iY as S,iF as F,C as B,fI as P,A as H,bV as p,bU as b,Y as U,aD as m,c0 as z,gZ as G,a$ as O,d2 as _,gH as q,dG as V,jD as j}from"./strapi-ye6TfKul.js";import{W as u}from"./WidgetHelpers-DvKGKEsV.js";const Y=A.enhanceEndpoints({addTagTypes:["RecentDocumentList"]}).injectEndpoints({overrideExisting:!0,endpoints:e=>({getRecentDocuments:e.query({query:a=>`/content-manager/homepage/recent-documents?action=${a.action}`,transformResponse:a=>a.data,providesTags:(a,i,{action:o})=>[{type:"RecentDocumentList",id:o}]})})}),{useGetRecentDocumentsQuery:D}=Y,T="14.4rem",E=(e=4)=>{const o=14.4*e/4;return`${Math.round(o*10)/10}rem`},k=j(m)`
  display: block;
  max-width: ${({$maxWidth:e})=>e||T};
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
`,R=({documents:e,type:a,dynamicMaxWidth:i=T})=>{const{formatMessage:o}=x(),{trackUsage:r}=S(),c=F(),g=s=>{const h=s.kind==="singleType",n=h?"single-types":"collection-types",d=s.locale?`?plugins[i18n][locale]=${s.locale}`:"";return`/content-manager/${n}/${s.contentTypeUid}${h?"":"/"+s.documentId}${d}`},f=s=>()=>{r("willEditEntryFromHome",{entryType:a});const h=g(s);c(h)};return t.jsx(B,{colCount:5,rowCount:e?.length??0,children:t.jsx(P,{children:e?.map(s=>t.jsxs(H,{onClick:f(s),cursor:"pointer",children:[t.jsx(p,{children:t.jsx(k,{title:s.title,variant:"omega",textColor:"neutral800",$maxWidth:i,children:s.title})}),t.jsx(p,{children:t.jsx(k,{variant:"omega",textColor:"neutral600",$maxWidth:i,children:s.kind==="singleType"?o({id:"content-manager.widget.last-edited.single-type",defaultMessage:"Single-Type"}):o({id:s.contentTypeDisplayName,defaultMessage:s.contentTypeDisplayName})})}),t.jsx(p,{children:t.jsx(b,{display:"inline-block",children:s.status?t.jsx(U,{status:s.status}):t.jsx(m,{textColor:"neutral600","aria-hidden":!0,children:"-"})})}),t.jsx(p,{children:t.jsx(m,{textColor:"neutral600",children:t.jsx(z,{timestamp:new Date(s.updatedAt)})})}),t.jsx(p,{onClick:h=>h.stopPropagation(),children:t.jsx(b,{display:"inline-block",children:t.jsx(G,{tag:O,to:g(s),onClick:()=>r("willEditEntryFromHome",{type:a}),label:o({id:"content-manager.actions.edit.label",defaultMessage:"Edit"}),variant:"ghost",children:t.jsx(_,{})})})})]},`${s.documentId}-${s.locale??"default"}`))})})},tt=({columnWidth:e=6})=>{const{formatMessage:a}=x(),{data:i,isLoading:o,error:r}=D({action:"update"}),c=E(e);return o?t.jsx(u.Loading,{}):r||!i?t.jsx(u.Error,{}):i.length===0?t.jsx(u.NoData,{children:a({id:"content-manager.widget.last-edited.no-data",defaultMessage:"No edited entries"})}):t.jsx(R,{documents:i,type:"edited",dynamicMaxWidth:c})},et=({columnWidth:e=6})=>{const{formatMessage:a}=x(),{data:i,isLoading:o,error:r}=D({action:"publish"}),c=E(e);return o?t.jsx(u.Loading,{}):r||!i?t.jsx(u.Error,{}):i.length===0?t.jsx(u.NoData,{children:a({id:"content-manager.widget.last-published.no-data",defaultMessage:"No published entries"})}):t.jsx(R,{documents:i,type:"published",dynamicMaxWidth:c})},l=80,$=10,C=2*Math.PI*(l-$/2),K=j.circle`
  stroke: ${({theme:e,$arcColor:a})=>e.colors[a]};
`,v=j.tspan`
  text-transform: lowercase;
  fill: ${({theme:e,$textColor:a})=>e.colors[a]};
`,Q=j(y)`
  width: 100%;

  ${({theme:e})=>e.breakpoints.small} {
    width: auto;
  }
`,X=({data:e})=>{const{locale:a}=x(),{formatMessage:i}=x(),o=e.reduce((n,d)=>n+d.count,0),[r,c]=q.useState({visible:!1,x:0,y:0,value:null});let g=0;const f=(n,d)=>{c({visible:!0,x:n.clientX,y:n.clientY,value:d})},s=()=>{c(n=>({...n,visible:!1}))},h=(n,d)=>{c({visible:!0,x:n.currentTarget.getBoundingClientRect().width/2+n.currentTarget.getBoundingClientRect().left,y:n.currentTarget.getBoundingClientRect().height+n.currentTarget.getBoundingClientRect().top,value:d})};return t.jsxs(y,{direction:"column",gap:6,margin:"auto",children:[t.jsxs("svg",{width:l*2,height:l*2,viewBox:`0 0 ${l*2} ${l*2}`,style:{position:"relative",zIndex:1},children:[t.jsx("g",{transform:`rotate(-90 ${l} ${l})`,children:e.map(n=>{const d=n.count/o*100,w=d/100*C,W=`${w} ${C-w}`,L=C*(1-g/100),I=t.jsx(K,{cx:l,cy:l,r:l-$/2,fill:"none",strokeWidth:$,strokeDasharray:W,strokeDashoffset:L,style:{transition:"stroke-dashoffset 0.3s",cursor:"pointer"},tabIndex:0,"aria-describedby":r.visible?"chart-tooltip":void 0,onFocus:M=>h(M,n),onBlur:s,onMouseMove:M=>f(M,n),onMouseLeave:s,$arcColor:n.color},n.label);return g+=d,I})}),t.jsxs("text",{x:l,y:l,textAnchor:"middle",fontSize:"2.4rem",fontWeight:"bold",children:[t.jsx(v,{x:l,dy:"0",$textColor:"neutral800",children:new Intl.NumberFormat(a,{notation:"compact",maximumFractionDigits:1}).format(o)}),t.jsx(v,{x:l,dy:"1.4em",fontSize:"1.4rem",fontWeight:"normal",$textColor:"neutral600",children:i({id:"content-manager.widget.chart-entries.count.label",defaultMessage:"{count, plural, =0 {entries} one {entry} other {entries}}"},{count:o})})]})]}),r.visible&&r.value&&t.jsx(V,{style:{position:"fixed",left:16,top:16,zIndex:2,transform:`translate(${r.x}px, ${r.y}px)`},"data-testid":"entries-chart-tooltip",children:t.jsx(b,{background:"neutral900",padding:2,borderRadius:1,textAlign:"center",role:"tooltip","aria-live":"polite",children:t.jsx(m,{textColor:"neutral0",children:i({id:"content-manager.widget.chart-entries.tooltip",defaultMessage:"{count} items"},{count:r.value.count,label:r.value.label})})})}),t.jsx(y,{gap:4,wrap:"wrap",children:e.map(n=>n.count>0&&t.jsxs(Q,{gap:1,children:[t.jsx(b,{background:n.color,padding:2,borderRadius:1}),t.jsx(m,{variant:"pi",children:n.label})]},n.label))})]})},nt=()=>{const{formatMessage:e}=x(),{data:a,isLoading:i,error:o}=N();if(i)return t.jsx(u.Loading,{});if(o)return t.jsx(u.Error,{});const{draft:r,published:c,modified:g}=a??{draft:0,published:0,modified:0};return r+c+g?t.jsx(y,{minHeight:"100%",children:t.jsx(X,{data:[{label:e({id:"content-manager.containers.List.draft",defaultMessage:"Draft"}),count:r,color:"secondary500"},{label:e({id:"content-manager.containers.List.modified",defaultMessage:"Modified"}),count:g,color:"alternative500"},{label:e({id:"content-manager.containers.List.published",defaultMessage:"Published"}),count:c,color:"success500"}]})}):t.jsx(u.NoData,{children:e({id:"content-manager.widget.last-published.no-data",defaultMessage:"No published entries"})})};export{nt as ChartEntriesWidget,tt as LastEditedWidget,et as LastPublishedWidget};
