import{d as H,af as S,c as i,e as n,f as l,g as s,m as f,a8 as o,ag as h,p as g,t as r,F as T,l as R,j as J}from"./NkN6QURX.js";import{u as O}from"./DzxYJzkk.js";import{d as V}from"./CGR-T3Ho.js";const Q={class:"text-center space-y-2"},W=["data-content-key"],X=["data-content-key"],Z=["data-content-key"],ee=["onClick"],te={class:"relative h-60"},ae={key:0,class:"absolute right-3 top-3 rounded-sm px-2 py-1 text-center text-[11px] font-semibold leading-tight bg-[var(--theme-primary-color)] text-[var(--theme-primary-contrast)]"},ne={class:"px-4 pb-5 pt-4 text-left space-y-3"},le={class:"text-base font-semibold line-clamp-2"},oe={class:"text-sm leading-relaxed line-clamp-3 text-[#666666]"},se=["onClick"],ie={key:1,class:"col-span-full text-center text-sm text-gray-500 py-10 border border-dashed border-slate-200 rounded-lg bg-slate-50"},re={key:2,class:"col-span-full text-center text-sm text-gray-500 py-10 border border-dashed border-slate-200 rounded-lg bg-slate-50"},ce={key:0,class:"mt-10 flex justify-center","aria-label":"Pagination"},de={class:"inline-flex flex-wrap items-center justify-center gap-[6px] text-[13px] md:text-[15px]"},ue={class:"min-w-10 rounded-[5px] bg-[#f5f5f5] px-2.5 text-center leading-[35px] text-[#222] md:min-w-[45px] md:leading-10"},ve=["disabled"],me=["onClick"],pe={key:1,class:"px-2 leading-[35px] text-slate-400 md:leading-10"},ye=["disabled"],be=H({__name:"FactoryArticlesLayout",props:{content:{default:()=>[]},editable:{type:Boolean,default:!1},activeKey:{default:null},onContentClick:{},textStyle:{},className:{},loading:{type:Boolean,default:!1}},emits:["handle-item-click","on-page-change"],setup(v,{emit:E}){const y=v,j=E,{pick:k,resolveKey:_,interactive:K,isActive:C,resolveTextStyle:A,handleClick:D}=O({content:S(y,"content"),activeKey:S(y,"activeKey"),editable:S(y,"editable"),onContentClick:y.onContentClick,textStyle:y.textStyle}),m=i(()=>k("sectionTitle")),p=i(()=>k("sectionSubtitle")),c=i(()=>k("list")),$=i(()=>c.value?.config?.button),x=i(()=>c.value?.config?.pagination||null),w=i(()=>Number(x.value?.total||0)),b=i(()=>Number(x.value?.limit||0)),d=i(()=>Number(x.value?.page||1)),B=i(()=>b.value?Math.max(1,Math.ceil(w.value/b.value)):1),U=i(()=>!!x.value?.showPagination&&w.value>b.value),q=i(()=>{const e=B.value,a=d.value;return e<=5?Array.from({length:e},(t,u)=>u+1):a<=3?[1,2,3,"...",e]:a>=e-2?[1,"...",e-2,e-1,e]:[1,"...",a,"...",e]});function G(e){return e?typeof e.images=="string"?e.images.split(/[;,]/).find(Boolean)||"":Array.isArray(e.images)?e.images.find(Boolean)||"":e.imageUrl||e.image||e.cover||e.src||e.url||e.attribute?.src||"":""}const L=i(()=>{const e=c.value;if(!e)return[];const a=Number(e.dataSource),t=Array.isArray(e.data)?e.data:[],u=Array.isArray(e.customData?.data)?e.customData.data:[],P=a===3?u:t;return P.length?P.map(I=>({...I,image:G(I)})):[]});function Y(e){return e?{yearMonth:V(e).format("YYYY-MM"),day:V(e).format("DD")}:{yearMonth:"",day:""}}function F(e){return e?.attribute?.value??""}function z(e){j("handle-item-click",e)}function M(e){e<1||e>B.value||e===d.value||j("on-page-change",{page:e,limit:b.value})}function N(e){return e.date||e.createdAt||e.created_at||e.updatedAt||e.updated_at||""}return(e,a)=>(l(),n("section",{class:g(["py-12 md:py-16 lg:py-20 px-4 md:px-8 lg:px-[12%] font-sans bg-[#f3f3f5]",v.className])},[s("div",Q,[m.value?(l(),n("div",{key:0,class:g(["text-3xl font-semibold whitespace-pre-wrap",[{"cursor-pointer":o(K),mark:v.editable&&o(C)(m.value)}]]),"data-content-key":o(_)(m.value)||void 0,style:h(o(A)(m.value)),onClick:a[0]||(a[0]=t=>o(D)(m.value))},r(F(m.value)),15,W)):f("",!0),p.value?(l(),n("div",{key:1,class:g(["text-sm font-medium whitespace-pre-wrap",[{"cursor-pointer":o(K),mark:v.editable&&o(C)(p.value)}]]),"data-content-key":o(_)(p.value)||void 0,style:h(o(A)(p.value)),onClick:a[1]||(a[1]=t=>o(D)(p.value))},r(F(p.value)),15,X)):f("",!0)]),s("div",{class:g(["mt-10 grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-4",[{mark:v.editable&&c.value&&o(C)(c.value)}]]),"data-content-key":c.value&&o(_)(c.value)||void 0,onClick:a[2]||(a[2]=t=>c.value&&o(D)(c.value))},[L.value.length?(l(!0),n(T,{key:0},R(L.value,t=>(l(),n("div",{key:t.key||t.id,class:"overflow-hidden rounded bg-white shadow-sm flex flex-col cursor-pointer",onClick:u=>z(t)},[s("div",te,[s("div",{class:"h-full bg-contain bg-center bg-no-repeat",style:h({backgroundImage:t.image?`url(${t.image})`:"linear-gradient(135deg,#e2e8f0,#cbd5f5)"})},null,4),N(t)?(l(),n("div",ae,[s("div",null,r(Y(N(t)).yearMonth),1),s("div",null,r(Y(N(t)).day),1)])):f("",!0)]),s("div",ne,[s("h3",le,r(t.nameDisplay||t.name_display||t.title||t.name||"未命名文章"),1),s("p",oe,r(t.descriptionDisplay||t.description_display||t.description||"暂无简介"),1),$.value?(l(),n("div",{key:0,class:"inline-flex items-center gap-2 text-sm font-semibold cursor-pointer",style:h(o(A)($.value)),onClick:J(u=>z(t),["stop"])},r($.value.attribute?.value),13,se)):f("",!0)])],8,ee))),128)):v.editable?(l(),n("div",ie," 请在编辑器中配置文章数据源并点击预览 ")):(l(),n("div",re," 暂无数据 "))],10,Z),U.value?(l(),n("nav",ce,[s("div",de,[s("span",ue,r(w.value)+"条",1),s("button",{type:"button",class:"min-w-10 rounded-[5px] bg-[#f5f5f5] px-2.5 leading-[35px] text-[#222] transition hover:bg-[var(--theme-primary-color)] hover:text-[var(--theme-primary-contrast)] disabled:pointer-events-none disabled:opacity-50 md:min-w-[45px] md:leading-10",disabled:d.value===1,onClick:a[3]||(a[3]=t=>M(d.value-1))}," 上一页 ",8,ve),(l(!0),n(T,null,R(q.value,(t,u)=>(l(),n(T,{key:`factory-article-page-${t}-${u}`},[typeof t=="number"?(l(),n("button",{key:0,type:"button",class:g(["min-w-10 rounded-[5px] px-2.5 leading-[35px] transition md:min-w-[45px] md:leading-10",t===d.value?"bg-[var(--theme-primary-color)] text-[var(--theme-primary-contrast)]":"bg-[#f5f5f5] text-[#222] hover:bg-[var(--theme-primary-color)] hover:text-[var(--theme-primary-contrast)]"]),onClick:P=>M(t)},r(t),11,me)):(l(),n("span",pe,r(t),1))],64))),128)),s("button",{type:"button",class:"min-w-10 rounded-[5px] bg-[#f5f5f5] px-2.5 leading-[35px] text-[#222] transition hover:bg-[var(--theme-primary-color)] hover:text-[var(--theme-primary-contrast)] disabled:pointer-events-none disabled:opacity-50 md:min-w-[45px] md:leading-10",disabled:d.value===B.value,onClick:a[4]||(a[4]=t=>M(d.value+1))}," 下一页 ",8,ye)])])):f("",!0)],2))}});export{be as default};
