import{bJ as f,a as c,j as e,b,ak as T,bd as k,bj as w,bf as E,bk as l,a8 as p,bK as v,T as d,bL as C,I as D,a_ as L,g as R,k as M}from"./strapi-D_Y4QZhh.js";import{W as o}from"./WidgetHelpers-CriZl9tG.js";const N=f.enhanceEndpoints({addTagTypes:["RecentDocumentList"]}).injectEndpoints({overrideExisting:!0,endpoints:s=>({getRecentDocuments:s.query({query:n=>`/content-manager/homepage/recent-documents?action=${n.action}`,transformResponse:n=>n.data,providesTags:(n,a,{action:i})=>[{type:"RecentDocumentList",id:i}]})})}),{useGetRecentDocumentsQuery:x}=N,u=M(d).attrs({maxWidth:"14.4rem",display:"block"})`
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
`,h=({documents:s})=>{const{formatMessage:n}=c(),{trackUsage:a}=b(),i=T(),g=t=>{const r=t.kind==="singleType",m=r?"single-types":"collection-types",y=t.locale?`?plugins[i18n][locale]=${t.locale}`:"";return`/content-manager/${m}/${t.contentTypeUid}${r?"":"/"+t.documentId}${y}`},j=t=>()=>{a("willEditEntryFromHome");const r=g(t);i(r)};return e.jsx(k,{colCount:5,rowCount:s?.length??0,children:e.jsx(w,{children:s?.map(t=>e.jsxs(E,{onClick:j(t),cursor:"pointer",children:[e.jsx(l,{children:e.jsx(u,{title:t.title,variant:"omega",textColor:"neutral800",children:t.title})}),e.jsx(l,{children:e.jsx(u,{variant:"omega",textColor:"neutral600",children:t.kind==="singleType"?n({id:"content-manager.widget.last-edited.single-type",defaultMessage:"Single-Type"}):n({id:t.contentTypeDisplayName,defaultMessage:t.contentTypeDisplayName})})}),e.jsx(l,{children:e.jsx(p,{display:"inline-block",children:t.status?e.jsx(v,{status:t.status}):e.jsx(d,{textColor:"neutral600","aria-hidden":!0,children:"-"})})}),e.jsx(l,{children:e.jsx(d,{textColor:"neutral600",children:e.jsx(C,{timestamp:new Date(t.updatedAt)})})}),e.jsx(l,{onClick:r=>r.stopPropagation(),children:e.jsx(p,{display:"inline-block",children:e.jsx(D,{tag:L,to:g(t),onClick:()=>a("willEditEntryFromHome"),label:n({id:"content-manager.actions.edit.label",defaultMessage:"Edit"}),variant:"ghost",children:e.jsx(R,{})})})})]},t.documentId))})})},W=()=>{const{formatMessage:s}=c(),{data:n,isLoading:a,error:i}=x({action:"update"});return a?e.jsx(o.Loading,{}):i||!n?e.jsx(o.Error,{}):n.length===0?e.jsx(o.NoData,{children:s({id:"content-manager.widget.last-edited.no-data",defaultMessage:"No edited entries"})}):e.jsx(h,{documents:n})},P=()=>{const{formatMessage:s}=c(),{data:n,isLoading:a,error:i}=x({action:"publish"});return a?e.jsx(o.Loading,{}):i||!n?e.jsx(o.Error,{}):n.length===0?e.jsx(o.NoData,{children:s({id:"content-manager.widget.last-published.no-data",defaultMessage:"No published entries"})}):e.jsx(h,{documents:n})};export{W as LastEditedWidget,P as LastPublishedWidget};
