1import{J as jr,r as d,j as e,A as As,ap as ms,X as ve,U as wr,V as Nr,aG as hs,q as bs,m as ze,n as T,o as vr,t as ps,v as oa,D as us,g as Ht,y as Ke,L as kr,$ as Ve,S as $,d as gs,h as bt,O as da,R as S,i as pt,Y as _t,a6 as Bt,G as Te,B as fs,H as Cr,N as Sr,aH as ge,P as Ut,T as Er,aI as Wt,ab as R,aa as we,ad as Gt,ac as qe,a5 as Ne,a4 as ys}from"./index-D82aNb1r.js";import{f as ca,c as js}from"./articleApi-BYbIFsVu.js";import{E as Dr}from"./EditAdwaItemModal-BILL3Rt7.js";import{C as ws}from"./chart-pie-D3w0RYej.js";import{T as Ns}from"./trending-up-DIAk1Wfl.js";import{C as Ir}from"./chevron-up-BT1T2G7E.js";import{R as xa,T as ma,C as vs}from"./CategoricalChart-D105qt_b.js";import{B as Ar,X as ks,Y as Cs,a as Tr}from"./BarChart-za6TeBlX.js";import{C as Ss,A as $r}from"./Area-CkStpTmT.js";import{P as Mr,a as Fr}from"./PieChart-BEY_INHh.js";import{A as Pr}from"./AreaChart-BcHRrJvK.js";import{F as pa}from"./funnel-CNI1FWtb.js";import{U as Je}from"./upload-ClJRz50d.js";import{P as Ye}from"./plus-PVxxLbiE.js";import{S as ha}from"./star-CsXaYQ1S.js";import{P as ut}from"./pen-line-DrANO68i.js";import{T as gt}from"./trash-2-x7t2PzmZ.js";import{I as zt}from"./image-B4PVkrHk.js";import{S as Lr}from"./square-check-big-BxqgUUnF.js";import{R as Rr}from"./rotate-ccw-gQ8IczoB.js";import{E as Or}from"./eye-BAMBDp1V.js";import{E as Hr}from"./external-link-DFzpHVWq.js";import{C as _r,a as Br}from"./chevrons-right-fJUzVv1T.js";import{C as Ur}from"./chevron-left-DR0CKUKS.js";import{T as ba}from"./triangle-alert-fumLllcX.js";import{S as Wr}from"./save-BtDfcIPz.js";import{F as Gr}from"./file-spreadsheet-C56MAI7H.js";import{F as zr}from"./file-code-BOcHqvi_.js";import{C as Es}from"./circle-alert-C1FYXkSG.js";import"./index-BL37p0qW.js";import"./linear-CLyw1l5w.js";/** 2 * @license lucide-react v1.34.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Kr=[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["path",{d:"m8.5 8.5 5 5",key:"a8mexj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],Vr=jr("search-x",Kr),ft={ancient:{label:"Ancient & Axum",bg:"bg-emerald-500",fill:"#059669",border:"#047857"},medieval:{label:"Medieval Era",bg:"bg-amber-500",fill:"#d97706",border:"#b45309"},imperial:{label:"Imperial Era",bg:"bg-purple-600",fill:"#9333ea",border:"#7e22ce"},modern:{label:"Modern Era",bg:"bg-blue-600",fill:"#2563eb",border:"#1d4ed8"},revolution:{label:"Revolution / Derg",bg:"bg-rose-600",fill:"#e11d48",border:"#be123c"},contemporary:{label:"Contemporary",bg:"bg-teal-500",fill:"#0d9488",border:"#0f766e"}};function Ts(n){const x=(n.era||"imperial").toLowerCase();let g=null,le=!1;if(n.gregorianDate){const w=String(n.gregorianDate).trim();if(w.toLowerCase().includes("bce")||w.toLowerCase().includes("bc")||w.startsWith("-")){le=!0;const v=w.match(/\d+/);v&&(g=-parseInt(v[0],10))}else{const v=w.match(/^(\d{1,4})/);v&&(g=parseInt(v[1],10))}}if(g===null&&n.ethiopianDate){const v=String(n.ethiopianDate).match(/(\d{3,4})\s*(?:EC|á\.á)?/i);v&&(g=parseInt(v[1],10)+8)}if(g===null)return x==="ancient"?{centuryKey:"Ancient/BCE",centuryLabel:"Ancient Era (⤠4th c.)",centuryShort:"Ancient",centuryNum:0,era:x}:x==="medieval"?{centuryKey:"13th c.",centuryLabel:"13th Century (1201â1300 CE)",centuryShort:"13th c.",centuryNum:13,era:x}:x==="imperial"?{centuryKey:"19th c.",centuryLabel:"19th Century (1801â1900 CE)",centuryShort:"19th c.",centuryNum:19,era:x}:x==="modern"?{centuryKey:"20th c.",centuryLabel:"20th Century (1901â2000 CE)",centuryShort:"20th c.",centuryNum:20,era:x}:x==="revolution"?{centuryKey:"20th c.",centuryLabel:"20th Century (1901â2000 CE)",centuryShort:"20th c.",centuryNum:20,era:x}:x==="contemporary"?{centuryKey:"21st c.",centuryLabel:"21st Century (2001âPresent)",centuryShort:"21st c.",centuryNum:21,era:x}:{centuryKey:"19th c.",centuryLabel:"19th Century (1801â1900 CE)",centuryShort:"19th c.",centuryNum:19,era:x};if(le||g<=0)return{centuryKey:"Ancient/BCE",centuryLabel:"Pre-Common Era / BCE (Ancient)",centuryShort:"BCE",centuryNum:-1,era:x};const F=Math.floor((g-1)/100)+1,P=(F-1)*100+1,K=F*100,E=(w=>{if(w>=11&&w<=13)return"th";switch(w%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}})(F);return{centuryKey:`${F}${E} c.`,centuryLabel:`${F}${E} Century (${P}â${K} CE)`,centuryShort:`${F}${E}`,centuryNum:F,era:x}}const qr=({events:n,selectedCentury:x,onSelectCentury:g,className:le=""})=>
6{const[F,P]=d.useState("bar"),[K,te]=d.useState(!1),[E,w]=d.useState(null),{centuryData:v,totalCount:O,eraDistribution:U,topCentury:H,earliestEra:yt,latestEra:Qe}=d.useMemo(()=>{const h=new Map,f={ancient:0,medieval:0,imperial:0,modern:0,revolution:0,contemporary:0};n.forEach(j=>{const{centuryKey:M,centuryLabel:ie,centuryShort:me,centuryNum:Xe,era:he}=Ts(j);f[he]=(f[he]||0)+1,h.has(M)||h.set(M,{centuryKey:M,centuryLabel:ie,centuryShort:me,centuryNum:Xe,eraCounts:{},total:0,published:0,draft:0,mediaEnriched:0,notableEvents:[]});const oe=h.get(M);oe.total+=1,j.status==="published"?oe.published+=1:oe.draft+=1,j.heroImage&&!j.heroImage.includes("placeholder")&&(oe.mediaEnriched+=1),oe.eraCounts[he]=(oe.eraCounts[he]||0)+1,j.title&&oe.notableEvents.length<3&&oe.notableEvents.push(j.title)});const N=n.length,ae=Array.from(h.values()).map(j=>{let M="imperial",ie=-1;Object.entries(j.eraCounts).forEach(([Xe,he])=>{he>ie&&(ie=he,M=Xe)});const me=ft[M]||ft.imperial;return{centuryKey:j.centuryKey,centuryLabel:j.centuryLabel,centuryShort:j.centuryShort,centuryNum:j.centuryNum,era:M,eraLabel:me.label,color:me.fill,totalEvents:j.total,publishedEvents:j.published,draftEvents:j.draft,mediaEnrichedEvents:j.mediaEnriched,percentage:N>0?Math.round(j.total/N*100):0,notableEvents:j.notableEvents}}).sort((j,M)=>j.centuryNum-M.centuryNum);let ne=ae.length>0?ae[0]:null;ae.forEach(j=>{(!ne||j.totalEvents>ne.totalEvents)&&(ne=j)});const jt=Object.entries(f).filter(([j,M])=>M>0).map(([j,M])=>{const ie=ft[j]||ft.imperial;return{name:ie.label,key:j,value:M,percentage:N>0?Math.round(M/N*100):0,color:ie.fill}}).sort((j,M)=>M.value-j.value);return{centuryData:ae,totalCount:N,eraDistribution:jt,topCentury:ne,earliestEra:ae.length>0?ae[0].centuryLabel:"N/A",latestEra:ae.length>0?ae[ae.length-1].centuryLabel:"N/A"}},[n]);return n.length===0?null:e.jsxs("div",{className:`bg-white dark:bg-slate-800 rounded-2xl border border-slate-200 dark:border-slate-700 shadow-xs overflow-hidden ${le}`,children:[e.jsxs("div",{className:"p-4 sm:p-5 bg-gradient-to-r from-slate-900 via-slate-900 to-amber-950 text-white flex flex-col md:flex-row items-start md:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2.5 bg-amber-500/20 text-amber-300 rounded-xl border border-amber-500/40 font-bold shrink-0",children:e.jsx(As,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] font-mono uppercase font-bold text-amber-400 bg-amber-950/80 px-2 py-0.5 rounded border border-amber-600/40",children:"Archival Analytics"}),e.jsxs("span",{className:"text-xs font-semibold text-slate-300",children:[v.length," Centuries Documented"]})]}),e.jsx("h3",{className:"text-base sm:text-lg font-serif font-bold text-white mt-0.5 flex items-center gap-2",children:"Historical Distribution by Century"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 w-full md:w-auto justify-between md:justify-end",children:[e.jsxs("div",{className:"bg-slate-800/90 p-1 rounded-xl border border-slate-700 flex items-center gap-1",children:[e.jsxs("button",{type:"button",onClick:()=>P("bar"),className:`px-2.5 py-1 rounded-lg text-xs font-bold transition-all flex items-center gap-1.5 ${F==="bar"?"bg-amber-500 text-slate-950 shadow-xs":"text-slate-300 hover:text-white"}`,title:"View Century Bar Chart",children:[e.jsx(ms,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Century Bars"})]}),e.jsxs("button",{type:"button",onClick:()=>P("pie"),className:`px-2.5 py-1 rounded-lg text-xs font-bold transition-all flex items-center gap-1.5 ${F==="pie"?"bg-amber-500 text-slate-950 shadow-xs":"text-slate-300 hover:text-white"}`,title:"View Era Composition Donut",children:[e.jsx(ws,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Era Donut"})]}),e.jsxs("button",{type:"button",onClick:()=>P("area"),className:`px-2.5 py-1 rounded-lg text-xs font-bold transition-all flex items-center gap-1.5 ${F==="area"?"bg-amber-500 text-slate-950 shadow-xs":"text-slate-300 hover:text-white"}`,title:"View Cumulative Timeline Density",children:[e.jsx(Ns,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Timeline Density"})]})]}),x&&g&&e.jsxs("button",{type:"button",onClick:()=>g(null),className:"bg-amber-500/20 text-amber-300 hover:bg-amber-500/30 border border-amber-400/40 px-2.5 py-1 rounded-lg text-xs font-bold flex items-center gap-1 transition-colors",title:"Clear active century filter",children:[e.jsx("span",{children:x}),e.jsx(ve,{className:"w-3 h-3"})]}),e.jsx("button",{type:"button",onClick:()=>te(!K),className:"p-1.5 bg-slate-800 hover:bg-slate-700 text-slate-300 hover:text-white rounded-lg border border-slate-700 transition-colors",title:K?"Expand Century Overview":"Collapse Century Overview",children:K?e.jsx(wr,{className:"w-4 h-4"}):e.jsx(Ir,{className:"w-4 h-4"})})]})]}),!K&&e.jsxs("div",{className:"p-4 sm:p-6 space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"bg-slate-50 dark:bg-slate-900/60 p-3.5 rounded-xl border border-slate-200 dark:border-slate-700/80",children:[e.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500 dark:text-slate-400",children:"Active Epochs"}),e.jsxs("div",{className:"text-xl sm:text-2xl font-black font-serif text-slate-900 dark:text-slate-100 mt-0.5",children:[v.length," ",e.jsx("span",{className:"text-xs font-normal text-slate-500 font-sans",children:"Centuries"})]}),e.jsxs("div",{className:"text-[11px] text-emerald-700 dark:text-emerald-400 font-medium",children:[yt.split("(")[0]," to ",Qe.split("(")[0]]})]}),e.jsxs("div",{className:"bg-slate-50 dark:bg-slate-900/60 p-3.5 rounded-xl border border-slate-200 dark:border-slate-700/80",children:[e.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500 dark:text-slate-400",children:"Peak Representation"}),e.jsx("div",{className:"text-xl sm:text-2xl font-black font-serif text-amber-700 dark:text-amber-400 mt-0.5",children:H?H.centuryShort:"N/A"}
6),e.jsx("div",{className:"text-[11px] text-slate-600 dark:text-slate-400 font-medium",children:H?`${H.totalEvents} events (${H.percentage}%)`:"0%"})]}),e.jsxs("div",{className:"bg-slate-50 dark:bg-slate-900/60 p-3.5 rounded-xl border border-slate-200 dark:border-slate-700/80",children:[e.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500 dark:text-slate-400",children:"Publication Index"}),e.jsx("div",{className:"text-xl sm:text-2xl font-black font-serif text-slate-900 dark:text-slate-100 mt-0.5",children:O>0?`${Math.round(n.filter(h=>h.status==="published").length/O*100)}%`:"0%"}),e.jsxs("div",{className:"text-[11px] text-indigo-700 dark:text-indigo-400 font-medium",children:[n.filter(h=>h.status==="published").length," Verified Records"]})]}),e.jsxs("div",{className:"bg-slate-50 dark:bg-slate-900/60 p-3.5 rounded-xl border border-slate-200 dark:border-slate-700/80",children:[e.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500 dark:text-slate-400",children:"Average Per Century"}),e.jsx("div",{className:"text-xl sm:text-2xl font-black font-serif text-slate-900 dark:text-slate-100 mt-0.5",children:v.length>0?(O/v.length).toFixed(1):0}),e.jsx("div",{className:"text-[11px] text-teal-700 dark:text-teal-400 font-medium",children:"Density Across Timeline"})]})]}),e.jsxs("div",{className:"bg-slate-50/50 dark:bg-slate-900/30 p-4 rounded-xl border border-slate-100 dark:border-slate-800",children:[F==="bar"&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-3",children:[e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-bold uppercase tracking-wider text-slate-600 dark:text-slate-300 flex items-center gap-1.5",children:[e.jsx(ms,{className:"w-3.5 h-3.5 text-amber-600"}),e.jsx("span",{children:"Historical Event Count by Century (Click bar to filter)"})]}),e.jsx("p",{className:"text-[11px] text-slate-400",children:"Color indicates the dominant historical era of each period"})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-2 text-[10px] font-medium",children:Object.entries(ft).map(([h,f])=>e.jsxs("span",{className:"inline-flex items-center gap-1 text-slate-600 dark:text-slate-400",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-xs",style:{backgroundColor:f.fill}}),e.jsx("span",{children:f.label})]},h))})]}),e.jsx("div",{className:"h-64 sm:h-72 w-full",children:e.jsx(xa,{width:"100%",height:"100%",children:e.jsxs(Ar,{data:v,margin:{top:10,right:10,left:-20,bottom:20},onClick:h=>{if(h&&h.activePayload&&h.activePayload.length>0&&g){const f=h.activePayload[0].payload;x===f.centuryKey?g(null):g(f.centuryKey)}},children:[e.jsx(Ss,{strokeDasharray:"3 3",vertical:!1,stroke:"#94a3b8",opacity:.2}),e.jsx(ks,{dataKey:"centuryShort",tick:{fontSize:11,fill:"#64748b"},interval:0,angle:-25,textAnchor:"end"}),e.jsx(Cs,{allowDecimals:!1,tick:{fontSize:11,fill:"#64748b"}}),e.jsx(ma,{content:({active:h,payload:f})=>{if(h&&f&&f.length){const N=f[0].payload;return e.jsxs("div",{className:"bg-slate-950 text-white p-3 rounded-xl shadow-xl border border-slate-700 text-xs max-w-xs space-y-1.5 z-50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-slate-800 pb-1",children:[e.jsx("span",{className:"font-serif font-bold text-amber-300",children:N.centuryLabel}),e.jsx("span",{className:"text-[10px] font-mono bg-slate-800 px-1.5 py-0.5 rounded text-amber-200",children:N.eraLabel})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px] pt-1",children:[e.jsxs("div",{children:["Total Events: ",e.jsx("strong",{className:"text-white",children:N.totalEvents})," (",N.percentage,"%)"]}),e.jsxs("div",{children:["Published: ",e.jsx("strong",{className:"text-emerald-400",children:N.publishedEvents})]}),e.jsxs("div",{children:["Drafts: ",e.jsx("strong",{className:"text-amber-400",children:N.draftEvents})]}),e.jsxs("div",{children:["Media Enriched: ",e.jsx("strong",{className:"text-teal-400",children:N.mediaEnrichedEvents})]})]}),N.notableEvents.length>0&&e.jsxs("div",{className:"border-t border-slate-800/80 pt-1.5 text-[10px] text-slate-300",children:[e.jsx("span",{className:"font-bold text-slate-400 uppercase",children:"Notable Record:"}),e.jsxs("div",{className:"italic line-clamp-2 text-slate-200 mt-0.5",children:['"',N.notableEvents[0],'"']})]}),e.jsx("div",{className:"text-[10px] text-amber-400/80 pt-1 text-center font-bold",children:"ð¡ Click bar to filter table"})]})}return null}}),e.jsx(Tr,{dataKey:"totalEvents",radius:[6,6,0,0],cursor:"pointer",children:v.map(h=>{const f=x===h.centuryKey,N=E===h.centuryKey;
6return e.jsx(vs,{fill:h.color,opacity:f?1:N?.9:x?.4:.85,stroke:f?"#f59e0b":"#000000",strokeWidth:f?2.5:0,onMouseEnter:()=>w(h.centuryKey),onMouseLeave:()=>w(null),onClick:()=>g==null?void 0:g(x===h.centuryKey?null:h.centuryKey)},`cell-${h.centuryKey}`)})})]})})})]}),F==="pie"&&e.jsxs("div",{children:[e.jsx("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-3",children:e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-bold uppercase tracking-wider text-slate-600 dark:text-slate-300 flex items-center gap-1.5",children:[e.jsx(ws,{className:"w-3.5 h-3.5 text-amber-600"}),e.jsx("span",{children:"Historical Era Archive Breakdown"})]}),e.jsx("p",{className:"text-[11px] text-slate-400",children:"Share of documented events by classical Ethiopian historical epoch"})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 items-center",children:[e.jsx("div",{className:"h-64 w-full md:col-span-2",children:e.jsx(xa,{width:"100%",height:"100%",children:e.jsxs(Mr,{children:[e.jsx(Fr,{data:U,cx:"50%",cy:"50%",innerRadius:60,outerRadius:95,paddingAngle:3,dataKey:"value",children:U.map(h=>e.jsx(vs,{fill:h.color,stroke:"#1e293b",strokeWidth:1},`pie-cell-${h.key}`))}),e.jsx(ma,{content:({active:h,payload:f})=>{if(h&&f&&f.length){const N=f[0].payload;return e.jsxs("div",{className:"bg-slate-950 text-white p-2.5 rounded-xl shadow-xl border border-slate-700 text-xs",children:[e.jsx("div",{className:"font-bold text-amber-300",children:N.name}),e.jsxs("div",{className:"text-slate-200 mt-1",children:[e.jsx("strong",{children:N.value})," historical records (",N.percentage,"% of archive)"]})]})}return null}})]})})}),e.jsx("div",{className:"space-y-2",children:U.map(h=>e.jsxs("div",{className:"bg-white dark:bg-slate-800 p-2.5 rounded-xl border border-slate-200 dark:border-slate-700/80 flex items-center justify-between text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:h.color}}),e.jsx("span",{className:"font-bold text-slate-800 dark:text-slate-200",children:h.name})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono font-bold text-slate-700 dark:text-slate-300",children:h.value}),e.jsxs("span",{className:"text-[10px] text-slate-400 font-mono",children:["(",h.percentage,"%)"]})]})]},h.key))})]})]}),F==="area"&&e.jsxs("div",{children:[e.jsx("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-3",children:e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-bold uppercase tracking-wider text-slate-600 dark:text-slate-300 flex items-center gap-1.5",children:[e.jsx(Ns,{className:"w-3.5 h-3.5 text-amber-600"}),e.jsx("span",{children:"Archival Timeline Density & Progression"})]}),e.jsx("p",{className:"text-[11px] text-slate-400",children:"Chronological event density across successive historical epochs"})]})}),e.jsx("div",{className:"h-64 sm:h-72 w-full",children:e.jsx(xa,{width:"100%",height:"100%",children:e.jsxs(Pr,{data:v,margin:{top:10,right:10,left:-20,bottom:20},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"centuryDensityGrad",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#d97706",stopOpacity:.8}),e.jsx("stop",{offset:"95%",stopColor:"#d97706",stopOpacity:.05})]})}),e.jsx(Ss,{strokeDasharray:"3 3",vertical:!1,stroke:"#94a3b8",opacity:.2}),e.jsx(ks,{dataKey:"centuryShort",tick:{fontSize:11,fill:"#64748b"},interval:0,angle:-25,textAnchor:"end"}),e.jsx(Cs,{allowDecimals:!1,tick:{fontSize:11,fill:"#64748b"}}),e.jsx(ma,{content:({active:h,payload:f})=>{if(h&&f&&f.length){const N=f[0].payload;return e.jsxs("div",{className:"bg-slate-950 text-white p-3 rounded-xl shadow-xl border border-slate-700 text-xs",children:[e.jsx("div",{className:"font-serif font-bold text-amber-300",children:N.centuryLabel}),e.jsxs("div",{className:"text-slate-300 mt-1",children:[e.jsx("strong",{children:N.totalEvents})," historical events (",N.percentage,"%)"]}),e.jsxs("div",{className:"text-[11px] text-emerald-400 mt-0.5",children:["Dominant Era: ",N.eraLabel]})]})}return null}}),e.jsx($r,{type:"monotone",dataKey:"totalEvents",stroke:"#d97706",strokeWidth:2.5,fillOpacity:1,fill:"url(#centuryDensityGrad)"})]})})})]})]}),g&&e.jsxs("div",{className:"space-y-2 pt-1 border-t border-slate-200 dark:border-slate-700",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500 dark:text-slate-400 flex items-center gap-1.5",children:[e.jsx(pa,{className:"w-3 h-3 text-amber-600"}),e.jsx("span",{children:"Filter Events by Century:"})]}),x&&e.jsx("button",{type:"button",onClick:()=>
6g(null),className:"text-[11px] text-amber-600 dark:text-amber-400 hover:underline font-bold",children:"Clear Filter"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>g(null),className:`px-2.5 py-1 rounded-lg text-xs font-bold transition-all border ${x?"bg-slate-100 dark:bg-slate-800 text-slate-700 dark:text-slate-300 border-slate-200 dark:border-slate-700 hover:bg-slate-200":"bg-slate-900 text-white border-slate-900 dark:bg-amber-500 dark:text-slate-950 dark:border-amber-500 shadow-xs"}`,children:["All (",O,")"]}),v.map(h=>{const f=x===h.centuryKey;return e.jsxs("button",{type:"button",onClick:()=>g(f?null:h.centuryKey),className:`px-2.5 py-1 rounded-lg text-xs font-bold transition-all border flex items-center gap-1.5 ${f?"bg-amber-800 text-white border-amber-900 shadow-sm ring-2 ring-amber-500":"bg-white dark:bg-slate-800 text-slate-700 dark:text-slate-300 border-slate-200 dark:border-slate-700 hover:bg-amber-50 dark:hover:bg-slate-700"}`,title:h.centuryLabel,children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:h.color}}),e.jsx("span",{children:h.centuryShort}),e.jsx("span",{className:`px-1.5 py-0.2 rounded text-[10px] font-mono ${f?"bg-amber-950 text-amber-200":"bg-slate-100 dark:bg-slate-700 text-slate-600 dark:text-slate-300"}`,children:h.totalEvents})]},h.centuryKey)})]})]})]})]})},z=[{label:"Battle of Adwa Monument",url:""},{label:"Lalibela Rock Sanctuary",url:""},{label:"Axum Obelisk Archeology",url:""},{label:"Gondar Fasil Ghebby Palace",url:""}],Ds=`title,ethiopianDate,gregorianDate,summary,content,era,heroImage,status 7"Victory of Adwa Defeats Italian Forces","Yekatit 23, 1888 EC","1896-03-01","Ethiopian forces led by Emperor Menelik II and Empress Taytu Betul decisively defeated the invading Italian army at Adwa.","The Battle of Adwa was a watershed moment in African history. On Yekatit 23, 1888 EC (March 1, 1896), the Ethiopian army mobilized from all regions under Emperor Menelik II and Empress Taytu Betul to defend national sovereignty against Italian colonial aggression, securing Ethiopia's independence and inspiring pan-African freedom movements worldwide.","imperial","","published" 8"Coronation of Emperor Haile Selassie I","Teqemt 23, 1923 EC","1930-11-02","Ras Tafari Makonnen was crowned as Emperor Haile Selassie I of Ethiopia at St. George Cathedral in Addis Ababa.","Delegations from 13 foreign nations attended the lavish coronation ceremony at St. George Cathedral in Addis Ababa as Ras Tafari Makonnen assumed the title King of Kings, Elect of God, Conquering Lion of the Tribe of Judah.","imperial","","published" 9"Discovery of Lucy (Dinkinesh) in Hadar","Hidar 15, 1967 EC","1974-11-24","Paleoanthropologists discovered the 3.2-million-year-old Australopithecus afarensis skeleton known locally as Dinkinesh.","Discovered in the Awash Valley of Hadar in the Afar region, the fossilized bones of Dinkinesh ('You Are Marvelous') provided groundbreaking scientific evidence establishing Ethiopia as a cradle of humankind.","ancient","","published" 10"Construction of Lalibela Rock-Hewn Churches","Sene 12, 1180 EC","1180-06-19","King Lalibela completed eleven monolithic rock-hewn churches carved out of solid volcanic basalt in Roha.","According to Ethiopian traditional history, King Lalibela received a divine vision to construct a New Jerusalem in the high mountains of Lasta, creating world-famous monolithic architectural marvels carved directly into living rock.","medieval","","published" 11"Signing of the Treaty of Wuchale","Miyazia 24, 1881 EC","1889-05-02","Emperor Menelik II signed the Treaty of Wuchale with Count Pietro Antonelli of Italy.","The controversial treaty contained a famous disparity between its Amharic and Italian versions regarding Article XVII, which later became the diplomatic pretext for the Battle of Adwa when Italy claimed Ethiopia had become a protectorate.","imperial","","published"`,Is=JSON.stringify([{title:"Victory of Adwa Defeats Italian Forces",ethiopianDate:"Yekatit 23, 1888 EC",gregorianDate:"1896-03-01",summary:"Ethiopian forces led by Emperor Menelik II and Empress Taytu Betul decisively defeated the invading Italian army at Adwa.",content:"The Battle of Adwa was a watershed moment in African history. On Yekatit 23, 1888 EC (March 1, 1896), the Ethiopian army mobilized from all regions under Emperor Menelik II and Empress Taytu Betul to defend national sovereignty against Ital
11ian colonial aggression, securing Ethiopia's independence and inspiring pan-African freedom movements worldwide.",era:"imperial",heroImage:"",status:"published"},{title:"Coronation of Emperor Haile Selassie I",ethiopianDate:"Teqemt 23, 1923 EC",gregorianDate:"1930-11-02",summary:"Ras Tafari Makonnen was crowned as Emperor Haile Selassie I of Ethiopia at St. George Cathedral in Addis Ababa.",content:"Delegations from 13 foreign nations attended the lavish coronation ceremony at St. George Cathedral in Addis Ababa as Ras Tafari Makonnen assumed the title King of Kings, Elect of God, Conquering Lion of the Tribe of Judah.",era:"imperial",heroImage:"",status:"published"},{title:"Discovery of Lucy (Dinkinesh) in Hadar",ethiopianDate:"Hidar 15, 1967 EC",gregorianDate:"1974-11-24",summary:"Paleoanthropologists discovered the 3.2-million-year-old Australopithecus afarensis skeleton known locally as Dinkinesh.",content:"Discovered in the Awash Valley of Hadar in the Afar region, the fossilized bones of Dinkinesh ('You Are Marvelous') provided groundbreaking scientific evidence establishing Ethiopia as a cradle of humankind.",era:"ancient",heroImage:"",status:"published"},{title:"Construction of Lalibela Rock-Hewn Churches",ethiopianDate:"Sene 12, 1180 EC",gregorianDate:"1180-06-19",summary:"King Lalibela completed eleven monolithic rock-hewn churches carved out of solid volcanic basalt in Roha.",content:"According to Ethiopian traditional history, King Lalibela received a divine vision to construct a New Jerusalem in the high mountains of Lasta, creating world-famous monolithic architectural marvels carved directly into living rock.",era:"medieval",heroImage:"",status:"published"}],null,2);function Jr(n){const x=[];let g="",le=!1;for(let E=0;E<n.length;E++){const w=n[E];w==='"'?(le=!le,g+=w):(w===` 12`||w==="\r")&&!le?(w==="\r"&&n[E+1]===` 13`&&E++,g!==""&&x.push(g),g=""):g+=w}if(g!==""&&x.push(g),x.length<2)return[];const F=x[0].includes(" ")&&(!x[0].includes(",")||x[0].split(" ").length>x[0].split(",").length)?" ":",",P=E=>{const w=[];let v="",O=!1;for(let U=0;U<E.length;U++){const H=E[U];H==='"'?O&&E[U+1]==='"'?(v+='"',U++):O=!O:H===F&&!O?(w.push(v),v=""):v+=H}return w.push(v),w},K=P(x[0]).map(E=>E.toLowerCase().replace(/[^a-z0-9]/g,""));return x.slice(1).map(E=>{const w=P(E),v={};return K.forEach((O,U)=>{let H=w[U]||"";H.startsWith('"')&&H.endsWith('"')&&(H=H.slice(1,-1).replace(/""/g,'"')),v[O]=H}),v})}function Dl(){var ds,cs,xs;const{addToast:n}=Nr(),[x,g]=d.useState([]),[le,F]=d.useState(!0),[P,K]=d.useState(""),[te,E]=d.useState("all"),[w,v]=d.useState("events"),[O,U]=d.useState([]),[H,yt]=d.useState(!1),[Qe,h]=d.useState(""),[f,N]=d.useState("all"),[ae,ne]=d.useState(null),[jt,j]=d.useState(!1),[M,ie]=d.useState(!1),me=async()=>{try{yt(!0);const t=await oa(ze(T,"adwa_figures"));if(t.empty)U(Wt);else{const s=t.docs.map(a=>({id:a.id,...a.data()}));U(s)}}catch(t){console.error("Error loading adwa_figures from Firestore:",t),U(Wt)}finally{yt(!1)}};d.useEffect(()=>{me()},[]);const Xe=async(t,s)=>{try{const a=R(T,"adwa_figures",s.id);await we(a,s,{merge:!0}),n(`Successfully saved historical figure "${s.name}"`,"success"),j(!1),ne(null),await me()}catch(a){console.error("Error saving figure:",a),n("Failed to save historical figure","error")}},he=async(t,s)=>{if(window.confirm(`Are you sure you want to delete "${s}" from the historical database?`))try{await Gt(R(T,"adwa_figures",t)),n(`Deleted figure "${s}"`,"success"),await me()}catch(a){console.error("Error deleting figure:",a),n("Failed to delete figure","error")}},oe=async()=>{try{ie(!0);for(const t of Wt)await we(R(T,"adwa_figures",t.id),t,{merge:!0});n(`Successfully synced ${Wt.length} historical figures to Firestore!`,"success"),await me()}catch(t){console.error("Error seeding default figures:",t),n("Failed to seed default figures","error")}finally{ie(!1)}},ua=d.useMemo(()=>O.filter(t=>{const s=Qe.toLowerCase().trim(),a=!s||t.name.toLowerCase().includes(s)||t.amharicName&&t.amharicName.includes(s)||t.title.toLowerCase().includes(s)||t.role.toLowerCase().includes(s)||t.biography.toLowerCase().includes(s),r=hs(t),i=f==="all"||r.includes(f);return a&&i}),[O,Qe,f]),[$s,Ze]=d.useState(!1),[V,ga]=d.useState(null),[wt,Nt]=d.useState("write"),[k,fa]=d.useState(null),[Ms,$e]=d.useState(!1),[X,vt]=d.useState("csv"),[kt,ya]=d.use
13State("file"),[Me,Ct]=d.useState(""),[q,fe]=d.useState([]),[Fs,St]=d.useState(!1),[et,ja]=d.useState(!1),[Kt,Ps]=d.useState("published"),[C,de]=d.useState(new Set),[ke,Vt]=d.useState(null),wa=d.useRef(null),[Na,Ls]=d.useState(!1),[va,Rs]=d.useState(8),[tt,ka]=d.useState({startTime:0,rate:0,eta:0,stepLabel:""}),[Ce,qt]=d.useState(null),Fe=d.useRef(!1),Jt=d.useRef(null),[l,D]=d.useState({title:"",ethiopianDate:"",gregorianDate:new Date().toISOString().split("T")[0],summary:"",content:"",heroImage:"",era:"imperial",status:"published"}),[Ca,Sa]=d.useState(!1),[Ea,Da]=d.useState(null),[Et,Ia]=d.useState(!1),[Os,Dt]=d.useState(!1),[It,Yt]=d.useState(""),[Aa,Ta]=d.useState([]),[Qt,$a]=d.useState(!1),[Se,Hs]=d.useState(null),[Yr,Ma]=d.useState(null),[Pe,_s]=d.useState("all"),[_,at]=d.useState(null),[Xt,Fa]=d.useState(null),[be,st]=d.useState("all"),[I,pe]=d.useState(null),[ye,ce]=d.useState(!1),[Bs,Zt]=d.useState(!1),[Le,Pa]=d.useState(.5),[ue,rt]=d.useState([]),[lt,La]=d.useState(!1),[Us,At]=d.useState(null),[Ws,Ra]=d.useState(!1),[nt,Oa]=d.useState(!1),[ea,Ha]=d.useState(!1),[_a,Ba]=d.useState(null),Gs=["Battle of Adwa 1896","Emperor Menelik II","Empress Taytu Betul","Rock-Hewn Churches Lalibela","Axum Obelisk","Fasil Ghebbi Gondar","Haile Selassie","Emperor Tewodros II","Harar Jugol","Ethiopian Coffee Ceremony"],Ua=async(t,s)=>{var r,i,u,o,y,c;if(!(!s||s.includes("images.unsplash.com")||s.includes("placeholder")||s===z[0].url))return s;try{const m=t.replace(/^\d{3,4}\s*[:\-ââ]\s*/,"").replace(/\(\d{3,4}\)/,"").trim()||t,p=await(await fetch("/api/history/search-image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:m})})).json();return((r=p.primaryImage)==null?void 0:r.localUrl)||((i=p.primaryImage)==null?void 0:i.sourceUrl)||((o=(u=p.candidates)==null?void 0:u[0])==null?void 0:o.localUrl)||((c=(y=p.candidates)==null?void 0:y[0])==null?void 0:c.sourceUrl)||s||z[0].url}catch(m){return console.warn("Auto image conversion notice for title:",t,m),s||z[0].url}},zs=async(t,s,a=2e3)=>{if(!(!s||s.includes("images.unsplash.com")||s.includes("placeholder")||s===z[0].url))return s;try{const i=t.replace(/^\d{3,4}\s*[:\-ââ]\s*/,"").replace(/\(\d{3,4}\)/,"").trim()||t,u=fetch("/api/history/search-image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:i})}).then(async c=>{var b,p,A,L,J,Y;if(!c.ok)return null;const m=await c.json();return((b=m.primaryImage)==null?void 0:b.localUrl)||((p=m.primaryImage)==null?void 0:p.sourceUrl)||((L=(A=m.candidates)==null?void 0:A[0])==null?void 0:L.localUrl)||((Y=(J=m.candidates)==null?void 0:J[0])==null?void 0:Y.sourceUrl)||null}).catch(()=>null),o=new Promise(c=>setTimeout(()=>c(null),a));return await Promise.race([u,o])||s||z[0].url}catch{return s||z[0].url}},Wa=async t=>{var a,r,i,u,o,y;if(!Array.isArray(t)||t.length===0)return;const s=t.filter(c=>!c.heroImage||c.heroImage.includes("images.unsplash.com")||c.heroImage.includes("placeholder")||c.heroImage===z[0].url);if(s.length!==0)for(const c of s)try{const m=c.title.replace(/^\d{3,4}\s*[:\-ââ]\s*/,"").replace(/\(\d{3,4}\)/,"").trim()||c.title,p=await(await fetch("/api/history/search-image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:m})})).json(),A=((a=p.primaryImage)==null?void 0:a.localUrl)||((r=p.primaryImage)==null?void 0:r.sourceUrl)||((u=(i=p.candidates)==null?void 0:i[0])==null?void 0:u.localUrl)||((y=(o=p.candidates)==null?void 0:o[0])==null?void 0:y.sourceUrl);if(p.success&&A){g(L=>L.map(J=>J.id===c.id?{...J,heroImage:A}:J));try{await we(R(T,"historyEvents",c.id),{...c,heroImage:A,updatedAt:new Date().toISOString()},{merge:!0})}catch(L){console.warn("Silent auto-convert setDoc notice:",L)}}}catch(m){console.warn("Silent auto-convert error for:",c.title,m)}},Ga=async t=>{var s,a,r,i,u,o;Fa(t.id);try{const c=await(await fetch("/api/history/search-image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:t.title})})).json(),m=((s=c.primaryImage)==null?void 0:s.localUrl)||((a=c.primaryImage)==null?void 0:a.sourceUrl)||((i=(r=c.candidates)==null?void 0:r[0])==null?void 0:i.localUrl)||((o=(u=c.candidates)==null?void 0:u[0])==null?void 0:o.sourceUrl);
13if(c.success&&m){try{await we(R(T,"historyEvents",t.id),{...t,heroImage:m,updatedAt:new Date().toISOString()},{merge:!0})}catch(b){console.warn("Firestore setDoc notice for quick attach:",b)}g(b=>b.map(p=>p.id===t.id?{...p,heroImage:m}:p)),n(`Attached authentic image to "${t.title}"!`,"success")}else n(`No image found for "${t.title}". Try manual web search.`,"error")}catch(y){console.error("Quick auto attach error:",y),n("Failed to auto-attach image.","error")}finally{Fa(null)}},[Ks,za]=d.useState(!1),[ta,Ka]=d.useState(!1),[Ee,Tt]=d.useState(null),aa=(t,s)=>{Hs(s||null);const a=t||(s?s.title:l.title)||"Ethiopia History";Yt(a),Ta([]),Ma(null),Dt(!0),sa(a)},sa=async t=>{if(!(!t||!t.trim())){$a(!0);try{const a=await(await fetch("/api/history/search-image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:t.trim()})})).json();a.success?(Ta(a.candidates||[]),Ma(a.primaryImage||null)):n(a.error||"Failed to find images.","error")}catch(s){console.error("Image search failed:",s),n("Error searching images from Wikipedia/Internet.","error")}finally{$a(!1)}}},Va=async t=>{const s=t.localUrl||t.sourceUrl;if(s){if(Se)try{await we(R(T,"historyEvents",Se.id),{...Se,heroImage:s,updatedAt:new Date().toISOString()},{merge:!0}),g(a=>a.map(r=>r.id===Se.id?{...r,heroImage:s}:r)),n(`Attached Wikipedia image to "${Se.title}"!`,"success")}catch(a){console.error("Failed to update event image:",a),n("Failed to save image to database.","error")}else D(a=>({...a,heroImage:s})),n("Image attached to historical record!","success");Dt(!1)}},Vs=async()=>{var a,r,i,u,o,y;if(x.length===0)return;Ka(!0);let t=0;const s=x.length;Tt({current:0,total:s,title:"Initializing auto-enrichment...",updated:0});for(let c=0;c<s;c++){const m=x[c],b=m.title.replace(/^\d{3,4}\s*[:\-ââ]\s*/,"").replace(/\(\d{3,4}\)/,"").trim()||m.title;Tt({current:c+1,total:s,title:m.title,updated:t});try{const A=await(await fetch("/api/history/search-image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:b})})).json(),L=((a=A.primaryImage)==null?void 0:a.localUrl)||((r=A.primaryImage)==null?void 0:r.sourceUrl)||((u=(i=A.candidates)==null?void 0:i[0])==null?void 0:u.localUrl)||((y=(o=A.candidates)==null?void 0:o[0])==null?void 0:y.sourceUrl);if(L){try{await we(R(T,"historyEvents",m.id),{...m,heroImage:L,updatedAt:new Date().toISOString()},{merge:!0})}catch(J){console.warn("Firestore setDoc notice during bulk enrich:",J)}g(J=>J.map(Y=>Y.id===m.id?{...Y,heroImage:L}:Y)),t++,Tt({current:c+1,total:s,title:m.title,updated:t})}}catch(p){console.warn(`Bulk enrich skip for ${m.title}:`,p)}}Ka(!1),n(`Successfully auto-enriched ${t} historical records with Wikipedia/Internet images!`,"success"),setTimeout(()=>{Tt(null),za(!1)},1200)},Re=d.useMemo(()=>!l.title.trim()&&!l.summary.trim()&&!l.content.trim()?[]:ca({id:V==null?void 0:V.id,title:l.title,summary:l.summary,content:l.content},x,.5),[l.title,l.summary,l.content,V,x]),$t=(t=Le)=>{La(!0);const s=[],a=new Set;for(let r=0;r<x.length;r++){const i=x[r],u=x.slice(r+1),o=ca({id:i.id,title:i.title,summary:i.summary,content:i.content},u,t);for(const y of o){const c=y.item,m=[i.id,c.id].sort().join("::");a.has(m)||(a.add(m),s.push({pairId:m,primary:i,duplicate:c,match:y}))}}rt(s),La(!1)},ra=async(t,s="primary")=>{var a,r,i,u,o,y,c,m;At(t.pairId);try{const b=s==="primary"?t.primary:t.duplicate,p=s==="primary"?t.duplicate:t.primary,A=((a=b.summary)==null?void 0:a.trim())||"",L=((r=p.summary)==null?void 0:r.trim())||"",J=A?L&&L.length>A.length&&!A.includes(L.slice(0,30))?`${A} (${L})`:A:L,Y=((i=b.content)==null?void 0:i.trim())||"",je=((u=p.content)==null?void 0:u.trim())||"";let Ue=Y;!Y&&je?Ue=je:Y&&je&&je.length>50&&!Y.includes(je.slice(0,40))&&(Ue=`${Y} 14 15--- Additional Context & Record Details --- 16${je}`);let We=((o=b.ethiopianDate)==null?void 0:o.trim())||((y=p.ethiopianDate)==null?void 0:y.trim())||"";const ht=((c=b.gregorianDate)==null?void 0:c.trim())||((m=p.gregorianDate)==null?void 0:m.trim())||"";if(!We&&ht)try{const B=new Date(ht);if(!isNaN(B.getTime())){const ee=ge(B);We=`${ee.monthNameEn} ${ee.day}, ${ee.year} EC (${ee.monthNameAm})`}}catch{}const Ot=b.heroImage&&!b.heroImage.includes("unsplash")?b.heroImage:p.heroImage||b.heroImage||"",re=b.status==="published"||p.status==="published"?"published":b.status||"draft",Ge={title:b.title,summary:J,content:Ue,ethiopianDate:We,gregorianDate:ht,heroImage:Ot,status:re,era:b.era||p.era||"imperial",updatedAt:new Date().toISOString()};let Ae=b.id;
16if(b.id&&!b.id.startsWith("f")&&!b.id.startsWith("hw-"))await we(R(T,"historyEvents",b.id),Ge,{merge:!0});else{const B=R(ze(T,"historyEvents"));Ae=B.id,Ge.createdAt=new Date().toISOString(),await we(B,Ge)}if(p.id&&!p.id.startsWith("f")&&!p.id.startsWith("hw-"))try{await Gt(R(T,"historyEvents",p.id))}catch(B){console.warn("Could not delete loser doc from Firestore:",B)}g(B=>B.filter(ee=>ee.id!==p.id).map(ee=>ee.id===b.id?{...ee,id:Ae,...Ge}:ee)),rt(B=>B.filter(ee=>ee.pairId!==t.pairId)),n(`Merged records! Enhanced "${b.title}" with historical context and removed duplicate.`,"success")}catch(b){console.error("Error merging duplicate events:",b),n("Failed to merge duplicate events.","error")}finally{At(null)}},qs=async t=>{At(t.pairId);try{await qe(R(T,"historyEvents",t.duplicate.id),{status:"draft",updatedAt:Ne()}),g(s=>s.map(a=>a.id===t.duplicate.id?{...a,status:"draft"}:a)),rt(s=>s.filter(a=>a.pairId!==t.pairId)),n(`Set "${t.duplicate.title}" to Draft status.`,"info")}catch(s){console.error("Failed to update duplicate status:",s),n("Error setting status to draft.","error")}finally{At(null)}},Js=t=>{rt(s=>s.filter(a=>a.pairId!==t)),n("Marked as separate unique records.","info")},Ys=async()=>{const t=ue.filter(a=>a.match.combinedSimilarity>=75);if(t.length===0){n("No high-confidence duplicate pairs (>= 75% similarity) found.","info");return}Ra(!0);let s=0;for(const a of t)try{await ra(a,"primary"),s++}catch(r){console.warn("Batch merge pair skip:",r)}Ra(!1),n(`Successfully batch-merged ${s} high-confidence duplicate pairs!`,"success")},Qs=async()=>{Oa(!0);try{const s=await(await fetch("/api/history/deduplicate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threshold:Le})})).json();s.success?(n(`Server Database Cleaned! Scanned ${s.totalScanned} records, merged ${s.mergedCount} duplicate pairs. ${s.remainingTotal} unique records remain.`,"success"),await Z(),rt([])):n(s.error||"Server deduplication failed.","error")}catch(t){console.error("Server deduplication failed:",t),n("Failed to connect to server deduplication endpoint.","error")}finally{Oa(!1)}},Xs=async(t="incomplete_only")=>{Ha(!0),n("Starting batch AI enhancement for history events...","info");try{const a=await(await fetch("/api/history/batch-enhance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:t})})).json();a.success?(n(`Successfully enhanced ${a.successCount} of ${a.processedCount} history database events with Gemini AI!`,"success"),await Z()):n(a.error||"Batch AI enhancement failed.","error")}catch(s){console.error("Batch AI enhancement error:",s),n("Failed to connect to batch AI enhance server endpoint.","error")}finally{Ha(!1)}},Zs=async t=>{Ba(t.id),n(`Enhancing "${t.title}" with Gemini AI...`,"info");try{const a=await(await fetch("/api/history/enhance-event",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({eventId:t.id})})).json();a.success?(n(`Successfully enhanced "${a.enhancedEvent.title}"! Updated dates, summary, content & images.`,"success"),await Z(),V&&V.id===t.id&&D({title:a.enhancedEvent.title||"",ethiopianDate:a.enhancedEvent.ethiopianDate||"",gregorianDate:a.enhancedEvent.gregorianDate||"",summary:a.enhancedEvent.summary||"",content:a.enhancedEvent.content||"",heroImage:a.enhancedEvent.heroImage||z[0].url,era:a.enhancedEvent.era||"imperial",status:a.enhancedEvent.status||"published"})):n(a.error||"Enhancement failed.","error")}catch(s){console.error("Single event enhance error:",s),n("Failed to enhance history event.","error")}finally{Ba(null)}};d.useEffect(()=>{Z()},[]);async function Z(){F(!0);try{let t;try{const a=bs(ze(T,"historyEvents"),vr("createdAt","desc"),ps(1e3));t=await oa(a)}catch{t=await oa(bs(ze(T,"historyEvents"),ps(1e3)))}let s=t.docs.map(a=>({id:a.id,...a.data()}));s.length===0&&(s=us.map(a=>({id:a.id,title:a.title,gregorianDate:a.eventDateGregorian,ethiopianDate:"",summary:a.summary,content:a.detailedBody,heroImage:a.imageUrl,status:a.status,createdAt:new Date().toISOString()}))),g(s),setTimeout(()=>Wa(s),500)}catch(t){console.warn("Firestore history events read notice (Quota or network): falling back to local fallback data",(t==null?void 0:t.message)||t);const s=us.map(a=>({id:a.id,title:a.title,gregorianDate:a.eventDateGregorian,ethiopianDate:"",summary:a.summary,content:a.detailedBody,heroImage:a.imageUrl,status:a.status,createdAt:new Date().toISOString()}));g(s),setTimeout(()=>Wa(s),500)}finally{F(!1)}}const er=async t=>{Da(t.id),n(`Generating article for ${t.title}...`,"info");try{const a=await(await fetch("/api/agents/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentId:"publishing-agent",prompt:`Generate a comprehensive, engaging, and factual news-style historical article about the following Ethiopian historical event. 17Title: ${t.title} 18Date: ${t.ethiopianDate} (${t.gregorianDate}) 19Summary: ${t.summary} 20Details: ${t.content} 21 22Instructions: 231. Write a compelling headline. 242. Structure the article with an introduction, historical context, key figures, and the lasting impact of this event. 253. Use a journalistic, educational tone appropriate for a modern audience. 264. Output ONLY the article text (Markdown formatted), no preamble.`})})).json();if(a.result){const r=await js({headline:`Historical Retrospective: ${t.title}`,title:`Historical Retrospective: ${t.title}`,content:a.result,summary:t.summary,excerpt:t.summary,categoryId:"History",category:"History",status:"draft",sourceUrl:"",imageUrl:t.heroImage||z[0].url,heroImage:t.heroImage||z[0].url,publishedAt:new Date().toISOString()});r.success?n("Draft article generated successfully! Check Content Editor.","success"):n(`Failed to save draft article: ${r.error||"Unknown error"}`,"error")}else n("Failed to generate article.","error")}catch(s){console.error(s),n("Error generating article.","error")}finally{Da(null)}},Mt=(t=!1)=>{ga(null),Nt("write");const s=new Date,a=s.toISOString().split("T")[0],r=ge(s),i=`${r.monthNameEn} ${r.day}, ${r.year} EC (${r.monthNameAm})`;D({title:"",ethiopianDate:t?i:"",gregorianDate:t?a:new Date().toISOString().split("T")[0],summary:"",content:"",heroImage:z[0].url,era:"imperial",status:"published"}),Ze(!0)},qa=t=>{ga(t),Nt("write"),D({title:t.title||"",ethiopianDate:t.ethiopianDate||"",gregorianDate:t.gregorianDate?new Date(t.gregorianDate).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],summary:t.summary||"",content:t.content||"",heroImage:t.heroImage||z[0].url,era:t.era||"imperial",status:t.status||"published"}),Ze(!0)},W=async t=>{if(!l.title&&!l.content&&!l.summary){n("Please provide an event title or draft description before using AI Enhance.","info");return}fa(t);try{const a=await(await fetch("/api/ai/enhance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:t,headline:l.title,content:l.content,category:l.era,text:t==="history_title"?l.title:t==="history_summary"?l.title+` 27`+(l.content||l.summary):l.content||l.summary||l.title})})).json();a.result?t==="history_title"?(D(r=>({...r,title:a.result})),n("⨠Historical event title refined by AI!","success")):t==="history_summary"?(D(r=>({...r,summary:a.result}
27)),n("⨠Concise lead summary generated by AI!","success")):t==="history_expand"?(D(r=>({...r,content:a.result})),n("⨠Historical description expanded with comprehensive academic context!","success")):t==="history_proofread"?(D(r=>({...r,content:a.result})),n("ð Description proofread, formatted, and polished by AI!","success")):t==="history_enhance"?(D(r=>({...r,content:a.result,summary:r.summary||a.result.slice(0,180).replace(/[#*>\n]/g," ").trim()+"..."})),n("⨠Historical description fully enhanced by Gemini AI!","success")):t==="history_citations"?(D(r=>({...r,content:r.content?`${r.content} 28 29${a.result}`:a.result})),n("ð Academic citations appended to description!","success")):t==="history_key_facts"?(D(r=>({...r,content:r.content?`${r.content} 30 31${a.result}`:a.result})),n("â¡ Key facts callout appended to description!","success")):t==="translate_amharic"&&(D(r=>({...r,title:a.result.split(` 32`)[0]||a.result})),n("Translated to Amharic by AI!","success")):n(a.error||"AI enhancement returned no text.","error")}catch(s){console.error("AI history action failed:",s),n("AI enhancement unavailable. Please try again.","error")}finally{fa(null)}},De=t=>{D(s=>{let a=t;return t==="h2"?a=` 33## Historical Significance 34`:t==="h3"?a=` 35### Key Treaties & Figures 36`:t==="bold"?a="**bold text**":t==="italic"?a="*italic text*":t==="quote"?a=` 37> "Imperial Proclamation line..." 38`:t==="bullet"?a=` 39- Key Fact 40- Important Landmark 41`:t==="link"&&(a="[Archival Reference](https://example.com)"),{...s,content:s.content?`${s.content} 42${a}`:a}})},Ja=()=>{if(!l.gregorianDate){n("Please select a European (Gregorian) date first.","info");return}const t=new Date(l.gregorianDate);if(isNaN(t.getTime())){n("Invalid European date.","error");return}const s=ge(t),a=`${s.monthNameEn} ${s.day}, ${s.year} E.C.`;D(r=>({...r,ethiopianDate:a})),n(`Converted to Ethiopian Date: ${a}`,"success")},Ya=async()=>{if(!l.title){n("Please enter an Event Title first before enhancing.","info");return}Ia(!0);try{const t=await Ua(l.title,l.heroImage),r=(await(await fetch("/api/agents/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentId:"publishing-agent",prompt:`Generate a comprehensive, highly engaging, factual, and detailed news-style historical article based on the following Ethiopian archival event: 43Title: ${l.title} 44Ethiopian Date: ${l.ethiopianDate||"Historical Era"} 45European/Gregorian Date: ${l.gregorianDate||"Historical Era"} 46Summary: ${l.summary||""} 47Content Details: ${l.content||""} 48 49Instructions: 501. Write a captivating published-grade headline and engaging lead summary. 512. Structure the article with markdown section headers: 52 ## Historical Context & Prelude 53 ## Major Developments, Decrees & Key Figures 54 ## Historical Significance & Modern Heritage 553. Use a journalistic, educational tone appropriate for EthioExplorer. 564. Output rich Markdown content.`})})).json()).result||l.content||l.summary||`Detailed historical retrospective on ${l.title}.`,i=l.title.toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-")+"-"+Math.random().toString(36).substring(2,7),u={title:l.title,headline:l.title,slug:i,content:r,summary:l.summary||r.replace(/<[^>]+>/g,"").slice(0,180)+"...",excerpt:l.summary||r.replace(/<[^>]+>/g,"").slice(0,180)+"...",category:"History",categoryId:"History",status:"published",authorName:"EthioExplorer Historical Archives",author:"EthioExplorer Historical Archives",imageUrl:t,heroImage:t,featuredImage:t,ethiopianDate:l.ethiopianDate||"",gregorianDate:l.gregorianDate||"",publishedAt:new Date().toISOString()},o=await js(u);if(!o.success)throw new Error(o.error||"Failed to publish article");D(y=>({...y,content:r,heroImage:t})),n("⨠Event enhanced with AI and successfully published as a live historical article!","success")}catch(t){console.error("Enhance and publish article failed:",t),n("Failed to enhance and publish article. Please try again.","error")}finally{Ia(!1)}},tr=async t=>{if(t.preventDefault(),!l.title||!l.summary){alert("Please fill in required fields (Title, Summary)");return}if(!V&&Re.length>0&&Re[0].combinedSimilarity>=65){const s=Re[0];if(!window.confirm(`â ï¸ Potential Duplicate Warning (${s.combinedSimilarity}% Cosine Similarity Match) 57
58This historical record is very similar to an existing record: 59"${s.item.title}" 60 61Reason: ${s.matchReason} 62 63Do you still want to save this historical record?`))return}Sa(!0);try{const s=await Ua(l.title,l.heroImage),a={title:l.title,ethiopianDate:l.ethiopianDate,gregorianDate:l.gregorianDate,summary:l.summary,content:l.content||l.summary,heroImage:s,era:l.era,status:l.status,updatedAt:Ne()};V?(await qe(R(T,"historyEvents",V.id),a),n("Historical entry successfully updated in Firestore!","success")):(await ys(ze(T,"historyEvents"),{...a,createdAt:Ne()}),n("New historical entry saved to Firestore!","success")),Ze(!1),Z()}catch(s){console.error("Error saving historical event:",s),n("Error saving historical event to Firestore.","error")}finally{Sa(!1)}};x.filter(t=>t.status==="published").length,x.filter(t=>t.status!=="published").length;const ar=()=>{Ct(""),fe([]),Vt(null),qt(null),Fe.current=!1,$e(!0)},it=(t,s)=>{t.charCodeAt(0)===65279&&(t=t.slice(1));try{let a=[];if(s==="csv")a=Jr(t);else{let o;try{o=JSON.parse(t)}catch{o=new Function("return "+t.trim())()}Array.isArray(o)?a=o:o&&typeof o=="object"&&(a=o.events||o.history||o.records||o.data||o.items||o.results||[o])}if(!a||a.length===0){n("No historical records found in the provided data.","info"),fe([]);return}const r=new Map;x.forEach(o=>{o.title&&r.set(o.title.toLowerCase().trim(),o)});const i=a.length>80,u=a.map((o,y)=>{const c=String(o.title||o.headline||o.event||o.name||"");let m=String(o.ethiopianDate||o.ethiopiandate||o.ethiopian_date||o.ethdate||"");const b=String(o.gregorianDate||o.gregoriandate||o.gregorian_date||o.date||new Date().toISOString().split("T")[0]);if(!m.trim()&&b)try{const Ae=new Date(b);if(!isNaN(Ae.getTime())){const B=ge(Ae);m=`${B.monthNameEn} ${B.day}, ${B.year} E.C.`}}catch{}const p=String(o.summary||o.lead||o.description||o.excerpt||""),A=String(o.content||o.body||o.text||p||""),L=String(o.era||o.period||"imperial"),J=z[y%z.length].url,Y=String(o.heroImage||o.heroimage||o.hero_image||o.image||J),je=String(o.status||Kt),Ue=!!c.trim();let We;c.trim()||(We="Missing Title");const ht=c.toLowerCase().trim(),Ot=r.get(ht);let re=null;Ot?re={item:Ot,combinedSimilarity:100,matchReason:"Exact Title Match"}:i||(re=ca({title:c,summary:p,content:A},x,.45)[0]||null);const Ge=re&&re.combinedSimilarity>=60;return{id:`imp-${Date.now()}-${y}`,title:c,ethiopianDate:m,gregorianDate:b,summary:p||c,content:A||p||c,era:L,heroImage:Y,status:je,selected:Ue&&!Ge,isValid:Ue,errorMsg:We,duplicateMatch:re?{item:re.item||re,combinedSimilarity:re.combinedSimilarity,matchReason:re.matchReason||"High Similarity"}:void 0}});fe(u)}catch(a){n(`Error parsing ${s.toUpperCase()} content: `+(a.message||"Invalid format"),"error"),fe([])}},sr=t=>{Ct(t),Jt.current&&clearTimeout(Jt.current),t.trim().length>10?Jt.current=setTimeout(()=>{let s=X,a=t.trim();a.startsWith("```")&&(a=a.replace(/^```[a-z]*\n/i,"").replace(/\n```$/,"").trim()),(a.startsWith("[")&&a.endsWith("]")||a.startsWith("{")&&a.endsWith("}"))&&X==="csv"&&(s="json",vt("json")),it(a,s)},300):fe([])},Qa=t=>{t.name.toLowerCase().endsWith(".csv");const a=t.name.toLowerCase().endsWith(".json")?"json":"csv";vt(a);const r=new FileReader;r.onload=i=>{var o;const u=(o=i.target)==null?void 0:o.result;u&&(Ct(u),it(u,a))},r.readAsText(t)},rr=()=>{const t=X==="csv"?Ds:Is;Ct(t),it(t,X)},lr=()=>{const t=X==="csv"?Ds:Is,s=`ethiopian_history_template.${X}`,a=new Blob([t],{type:X==="csv"?"text/csv":"application/json"}),r=URL.createObjectURL(a),i=document.createElement("a");i.href=r,i.download=s,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)},la=t=>{fe(s=>s.map(a=>a.isValid?{...a,selected:t}:a))},nr=t=>{fe(s=>s.map(a=>a.id===t?{...a,selected:!a.selected}:a))},ir=()=>{Fe.current=!0},or=async()=>{const t=q.filter(c=>c.selected&&c.isValid);if(t.length===0){n("Please select at least one valid record to import.","error");return}ja(!0),Fe.current=!1,qt(null);const s=Date.now();Vt({current:0,total:t.length,success:0,fail:0}),ka({startTime:s,rate:0,eta:0,stepLabel:"Initializing parallel ingestion queue..."});let a=0,r=0,i=0;const u=[...t],o=async c=>{if(Fe.current)return!1;try{let m=c.heroImage;return Na&&(m=await zs(c.title,c.heroImage,2e3)),await ys(ze(T,"historyEvents"),{title:c.title,ethiopianDate:c.ethiopianDate,gregorianDate:c.gregorianDate,summary:c.summary,content:c.content,era:c.era,heroImage:m,status:c.status||Kt,createdAt:Ne(),updatedAt:Ne()}),!0}catch(m){return console.error("Failed to import record:",c.title,m),!1}},y=Array.from({length:Math.max(1,Math.min(va||1,u.length))},async()=>{for(;u.length>0&&!Fe.current;){const c=u.shift();if(!c)break;try{await o(c)?a++:r++}catch(m){console.error("Batch import record error:",m),r++}if(i++,i%4===0||i===t.length){const m=Math.max((Date.now()-s)/1e3,.1),b=Math.round(i/m*10)/10,p=t.length-i,A=b>0?Math.ceil(p/b):0;Vt({current:i,total:t.length,success:a,fail:r}),ka({startTime:s,rate:b,eta:A,stepLabel:`Ingesting "${String(c.title).slice(0,30)}..." (${i}/${t.length})`})}}});try{await Promise.all(y)}catch(c){console.error("Parallel import processing error:",c),n(`Import process encountered an error: ${c.message}`,"error")}finally{const c=Math.max((Date.now()-s)/1e3,.1);ja(!1),Fe.current?n(`Import paused by user. ${a} records imported successfully.`,"info"):n(`Import completed! ${a} historical records ingested in ${c.toFixed(1)}s (${(a/c).toFixed(1)} items/sec).`,"success"),qt({total:t.length,success:a,fail:r,elapsedSec:Math.round(c*10)/10}),a>0&&$e(!1),Z()}}
63,[Oe,ot]=d.useState(1),[dt,dr]=d.useState(10),[xe,Xa]=d.useState(!0),Ft=t=>{if(t.ethiopianDate&&t.ethiopianDate.trim())return t.ethiopianDate.trim();if(t.gregorianDate)try{const a=new Date(t.gregorianDate);if(!isNaN(a.getTime())){const r=ge(a);return`${r.monthNameEn} ${r.day}, ${r.year} EC (${r.monthNameAm})`}}catch{}if(t.createdAt)try{const a=t.createdAt.toDate?t.createdAt.toDate():new Date(t.createdAt);if(!isNaN(a.getTime())){const r=ge(a);return`${r.monthNameEn} ${r.day}, ${r.year} EC (${r.monthNameAm})`}}catch{}const s=Ht(new Date);return`${s.monthNameEn} ${s.day}, ${s.year} EC`},Pt=t=>{const s=Ft(t),a=Ht(new Date),r=new Date;if(s.toLowerCase().includes(a.monthNameEn.toLowerCase())||s.includes(a.monthNameAm))return!0;if(t.gregorianDate)try{const i=new Date(t.gregorianDate);if(!isNaN(i.getTime())&&(ge(i).month===a.month||i.getMonth()===r.getMonth()))return!0}catch{}return!1},[G,ct]=d.useState(!1),[He,Za]=d.useState(null);d.useEffect(()=>{ot(1)},[P,te,be,He,dt,xe,G]);const es={ancient:{label:"Ancient & Axum",amharic:"áá³áá / á áá±á",color:"bg-emerald-100/80 text-emerald-900 border-emerald-300"},medieval:{label:"Medieval Era",amharic:"áá«á¨áá ááá",color:"bg-amber-100/80 text-amber-900 border-amber-300"},imperial:{label:"Imperial Era",amharic:"ááá ááá¥áµ",color:"bg-purple-100/80 text-purple-900 border-purple-300"},modern:{label:"Modern Era",amharic:"áááá",color:"bg-blue-100/80 text-blue-900 border-blue-300"},revolution:{label:"Revolution / Derg",amharic:"á á¥á®áµ",color:"bg-rose-100/80 text-rose-900 border-rose-300"},contemporary:{label:"Contemporary",amharic:"áá
á³á",color:"bg-teal-100/80 text-teal-900 border-teal-300"}},na=t=>{const s=(t||"imperial").toLowerCase();return es[s]||{label:t||"Imperial",amharic:"",color:"bg-slate-100 dark:bg-slate-800 text-slate-800 dark:text-slate-200 border-slate-300"}},Lt=d.useMemo(()=>x.filter(t=>t.status==="published").length,[x]),ts=d.useMemo(()=>x.filter(t=>t.status!=="published").length,[x]),_e=Ht(new Date),as=d.useMemo(()=>x.filter(t=>Pt(t)).length,[x]),ss=d.useMemo(()=>x.filter(t=>Ke(t)).length,[x]),rs=d.useMemo(()=>x.filter(t=>t.heroImage&&!t.heroImage.includes("placeholder")).length,[x]),ls=x.filter(t=>{var y,c,m;const s=Ft(t),a=!P||((y=t.title)==null?void 0:y.toLowerCase().includes(P.toLowerCase()))||((c=t.ethiopianDate)==null?void 0:c.toLowerCase().includes(P.toLowerCase()))||s.toLowerCase().includes(P.toLowerCase())||((m=t.summary)==null?void 0:m.toLowerCase().includes(P.toLowerCase())),r=te==="all"||(t.status||"draft")===te,i=be==="all"||(t.era||"imperial").toLowerCase()===be.toLowerCase(),u=!G||Ke(t),o=!He||Ts(t).centuryKey===He;return a&&r&&i&&u&&o}),Ie=[...ls].sort((t,s)=>{const a=Ke(t),r=Ke(s);if(a&&!r)return-1;if(!a&&r)return 1;if(xe){const o=Pt(t),y=Pt(s);if(o&&!y)return-1;if(!o&&y)return 1}const i=new Date(t.gregorianDate||t.createdAt||0).getTime();return new Date(s.gregorianDate||s.createdAt||0).getTime()-i}),Be=Ht(new Date),Rt=Ie.length,xt=Math.ceil(Rt/dt)||1,ia=(Oe-1)*dt,ns=Math.min(ia+dt,Rt),se=Ie.slice(ia,ns),[Q,mt]=d.useState({isOpen:!1,type:"single"}),cr=t=>{de(s=>{const a=new Set(s);return a.has(t)?a.delete(t):a.add(t),a})},xr=()=>{const t=se.map(a=>a.id),s=t.length>0&&t.every(a=>C.has(a));de(s?a=>{const r=new Set(a);return t.forEach(i=>r.delete(i)),r}:a=>{const r=new Set(a);return t.forEach(i=>r.add(i)),r})},mr=()=>{const t=Ie.map(a=>a.id),s=t.length>0&&t.every(a=>C.has(a));de(s?new Set:new Set(t))},hr=async()=>{if(C.size!==0){ce(!0);try{for(const t of C)await qe(R(T,"historyEvents",t),{status:"published",updatedAt:Ne()});n(`Published ${C.size} historical records.`,"success"),de(new Set),Z()}catch{n("Failed to bulk publish items.","error")}finally{ce(!1)}}},br=async()=>{if(C.size!==0){ce(!0);try{for(const t of C)await qe(R(T,"historyEvents",t),{status:"draft",updatedAt:Ne()});n(`Changed ${C.size} records to draft.`,"info"),de(new Set),Z()}catch{n("Failed to bulk draft items.","error")}finally{ce(!1)}}},pr=async()=>{var s,a,r,i,u,o;if(C.size===0)return;ce(!0);let t=0;try{const y=x.filter(c=>C.has(c.id));for(const c of y){const b=await(await fetch("/api/history/search-image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:c.title})})).json(),p=((s=b.primaryImage)==null?void 0:s.localUrl)||((a=b.primaryImage)==null?void 0:a.sourceUrl)||((i=(r=b.candidates)==null?void 0:r[0])==null?void 0:i.localUrl)||((o=(u=b.candidates)==null?void 0:u[0])==null?void 0:o.sourceUrl);p&&(await qe(R(T,"historyEvents",c.id),{heroImage:p,updatedAt:Ne()}),t++)}n(`Auto-attached authentic web/wiki images to ${t} records!`,"success"),Z()}catch{n("Error during bulk image auto-attach.","error")}finally{ce(!1)}}
63,ur=()=>{C.size!==0&&mt({isOpen:!0,type:"bulk"})},gr=(t,s)=>{mt({isOpen:!0,type:"single",targetId:t,targetTitle:s})},fr=async()=>{if(Q.type==="bulk"){if(C.size===0)return;ce(!0);try{const t=Array.from(C);for(const s of t)await Gt(R(T,"historyEvents",s));n(`Permanently deleted ${t.length} historical records from Firestore.`,"success"),de(new Set),mt({isOpen:!1,type:"single"}),Z()}catch(t){console.error("Bulk deletion error:",t),n("Error deleting selected records.","error")}finally{ce(!1)}}else if(Q.type==="single"&&Q.targetId){ce(!0);try{await Gt(R(T,"historyEvents",Q.targetId)),n(`Deleted historical event "${Q.targetTitle||""}".`,"success"),de(t=>{const s=new Set(t);return Q.targetId&&s.delete(Q.targetId),s}),mt({isOpen:!1,type:"single"}),Z()}catch(t){console.error("Delete single event error:",t),n("Error deleting event.","error")}finally{ce(!1)}}},is=async(t,s)=>{try{await qe(R(T,"historyEvents",t),{status:s}),n("Status updated.","success"),Z()}catch(a){console.error("Error updating status:",a),n("Error updating status.","error")}},yr=(t,s)=>{gr(t,s||"Selected Historical Event")},os=l.content.trim()?l.content.trim().split(/\s+/).length:0;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4 border-b border-slate-200 dark:border-slate-700 pb-5",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-xs font-bold uppercase tracking-widest text-amber-900 bg-amber-50 px-2.5 py-0.5 rounded border border-amber-200",children:"Ethio-Gregorian Archives"}),e.jsxs("span",{className:"text-xs text-slate-400 font-medium",children:["⢠",x.length," Events | ",O.length," Figures"]})]}),e.jsx("h1",{className:"text-3xl font-serif font-black text-slate-900 dark:text-slate-100",children:"Historical Knowledge Database"}),e.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400 mt-1",children:"Curate historical milestones, imperial decrees, and historical figures database."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 self-start md:self-auto",children:[e.jsxs(kr,{to:"/admin/archive-sync",className:"bg-emerald-900 text-emerald-100 border border-emerald-700 px-4 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider hover:bg-emerald-800 transition-colors shadow-sm flex items-center gap-2",title:"Open Automated Archival Sync Utility for established Ethiopian digital archives",children:[e.jsx(Ve,{className:"w-4 h-4 text-emerald-300"}),e.jsx("span",{children:"Archive Sync Utility"})]}),e.jsxs("button",{type:"button",onClick:()=>Xs("incomplete_only"),disabled:ea,className:"bg-purple-800 text-white px-4 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider hover:bg-purple-900 transition-colors shadow-sm flex items-center gap-2 disabled:opacity-50",title:"Automatically enhance history database records using Gemini AI",children:[e.jsx($,{className:`w-4 h-4 ${ea?"animate-spin":""}`}),e.jsx("span",{children:ea?"Enhancing Events...":"â¡ AI Enhance Content"})]}),e.jsxs("button",{type:"button",onClick:()=>{Zt(!0),$t(Le)},className:"bg-amber-700 text-white px-4 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider hover:bg-amber-800 transition-colors shadow-sm flex items-center gap-2",children:[e.jsx(gs,{className:"w-4 h-4"}),e.jsx("span",{children:"Merge Duplicates"})]}),e.jsxs("button",{onClick:ar,className:"bg-slate-700 text-white px-4 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider hover:bg-slate-800 transition-colors shadow-sm flex items-center gap-2",children:[e.jsx(Je,{className:"w-4 h-4 text-emerald-400"}),e.jsx("span",{children:"Import Records"})]}),e.jsxs("button",{type:"button",onClick:()=>{w==="figures"?(ne(null),j(!0)):Mt(!1)},className:"bg-emerald-800 hover:bg-emerald-700 text-white px-5 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all shadow-md hover:shadow-lg flex items-center gap-2 border border-emerald-600 ring-2 ring-emerald-500/30",title:w==="figures"?"Add a new historical figure entry":"Manually create and add a new historical event entry to Firestore",children:[e.jsx(Ye,{className:"w-4 h-4 text-emerald-200"}),e.jsx("span",{children:w==="figures"?"Create New Figure":"Create New Entry"})]})]})]}),e.jsxs("div",{id:"admin-history-top-summary",className:"bg-gradient-to-r from-slate-900 via-emerald-950 to-slate-900 text-white p-5 rounded-2xl border border-emerald-800/60 shadow-md relative overflow-hidden",children:[e.jsx("div",{className:"absolute -right-10 -top-10 w-48 h-48 bg-emerald-500/10 rounded-full blur-2xl pointer-events-none"}),e.jsx("div",{className:"absolute -left-10 -bottom-10 w-48 h-48 bg-amber-500/10 rounded-full blur-2xl pointer-events-none"}),e.jsxs("div",{className:"relative z-10 flex flex-col lg:flex-row items-stretch lg:items-center justify-between gap-5",children:[e.jsxs("div",{className:"space-y-1.5 max-w-xl",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"bg-emerald-500/20 text-emerald-300 border border-emerald-500/30 text-[11px] font-bold px-2.5 py-0.5 rounded-full uppercase tracking-wider inline-flex items-center gap-1.5",children:[e.jsx(Ve,{className:"w-3.5 h-3.5 text-emerald-400"}),e.jsx("span",{children:"Firestore Archive Overview"})]}),e.jsxs("span",{className:"bg-amber-500/20 text-amber-300 border border-amber-500/30 text-[11px] font-bold px-2.5 py-0.5 rounded-full inline-flex items-center gap-1",children:[e.jsx(bt,{className:"w-3.5 h-3.5 text-amber-400"}),e.jsxs("span",{children:[_e.monthNameEn," (",_e.monthNameAm,")"]})]})]}),e.jsx("h2",{className:"text-xl sm:text-2xl font-serif font-black text-slate-100 tracking-tight",children:"Historical Knowledge Repository Summary"}),e.jsx("p",{className:"text-xs text-slate-300 leading-relaxed",children:"Real-time synchronization across historical events, royal chronicles, imperial treaties, and active Ethiopian calendar anniversaries."})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3.5 shrink-0 w-full lg:w-auto",children:[e.jsxs("div",{className:"bg-slate-800/80 backdrop-blur-sm border border-emerald-700/40 p-4 rounded-xl flex items-center gap-3.5 min-w-[220px]",children:[e.jsx("div",{className:"p-3 bg-amber-500/20 text-amber-400 rounded-xl border border-amber-500/30 font-bold shrink-0",children:e.jsx(Ve,{className:"w-6 h-6"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-300",children:"Total Historical Events"}),e.jsx("div",{className:"text-3xl font-black font-serif text-amber-400 leading-tight",children:x.length}),e.jsxs("div",{className:"text-[11px] text-slate-300 flex items-center gap-1.5 mt-0.5",children:[e.jsxs("span",{className:"text-emerald-400 font-semibold",children:[Lt," live"]}),e.jsx("span",{children:"â¢"}),e.jsxs("span",{className:"text-slate-400",children:[ts," drafts"]})]})]})]}),e.jsxs("div",{className:"bg-slate-800/80 backdrop-blur-sm border border-emerald-700/40 p-4 rounded-xl flex items-center justify-between gap-3.5 min-w-[220px]",children:[e.jsxs("div",{className:"flex items-center gap-3.5",children:[e.jsx("div",{className:"p-3 bg-emerald-500/20 text-emerald-400 rounded-xl border border-emerald-500/30 font-bold shrink-0",children:e.jsx(bt,{className:"w-6 h-6"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-300",children:"Current Month Events"}),e.jsx("div",{className:"text-3xl font-black font-serif text-emerald-400 leading-tight",children:as}),e.jsxs("div",{className:"text-[11px] text-emerald-300 font-medium mt
63-0.5",children:[_e.monthNameEn," (",_e.monthNameAm,")"]})]})]}),e.jsx("button",{type:"button",onClick:()=>{v("events"),Xa(!xe)},className:`p-2 rounded-lg text-xs font-bold transition-all border shrink-0 ${xe?"bg-amber-500 text-slate-950 border-amber-400 font-black shadow-sm":"bg-slate-700/60 hover:bg-slate-700 text-slate-300 border-slate-600 hover:text-white"}`,title:xe?"Disable current month sorting priority":"Prioritize current month events in table",children:e.jsx(ha,{className:`w-4 h-4 ${xe?"fill-slate-950":""}`})})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 border-b border-slate-200 dark:border-slate-800 pb-2",children:[e.jsxs("button",{onClick:()=>v("events"),className:`flex items-center gap-2 px-5 py-2.5 rounded-xl font-serif text-sm font-bold transition-all ${w==="events"?"bg-amber-900 text-amber-50 shadow-md ring-2 ring-amber-600":"bg-slate-100 dark:bg-slate-800 text-slate-700 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700"}`,children:[e.jsx(Ve,{className:"w-4 h-4 text-amber-400"}),e.jsxs("span",{children:["Historical Events & Milestones (",x.length,")"]})]}),e.jsxs("button",{onClick:()=>v("figures"),className:`flex items-center gap-2 px-5 py-2.5 rounded-xl font-serif text-sm font-bold transition-all ${w==="figures"?"bg-amber-900 text-amber-50 shadow-md ring-2 ring-amber-600":"bg-slate-100 dark:bg-slate-800 text-slate-700 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700"}`,children:[e.jsx(da,{className:"w-4 h-4 text-amber-400"}),e.jsxs("span",{children:["Historical Figures & Role Database (",O.length,")"]})]})]}),w==="figures"&&e.jsxs("div",{className:"space-y-6 animate-fadeIn",children:[e.jsxs("div",{className:"bg-white dark:bg-slate-800 p-5 rounded-2xl border border-slate-200 dark:border-slate-700 shadow-sm space-y-4",children:[e.jsxs("div",{className:"flex flex-col md:flex-row items-start md:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-xl font-serif font-extrabold text-slate-900 dark:text-slate-100 flex items-center gap-2",children:[e.jsx(da,{className:"w-5 h-5 text-amber-600"}),"Historical Figures & Role Filtering System"]}),e.jsxs("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1",children:["Categorize and filter historical leaders by ",e.jsx("strong",{children:"Military Leader"}),", ",e.jsx("strong",{children:"Diplomat"}),", and ",e.jsx("strong",{children:"Political Figure"}),"."]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{type:"button",onClick:oe,disabled:M,className:"px-4 py-2 bg-emerald-800 text-emerald-100 rounded-xl text-xs font-bold flex items-center gap-2 hover:bg-emerald-900 transition-colors shadow-xs disabled:opacity-50",title:"Seed default historical figures into Firestore database",children:[e.jsx(S,{className:`w-4 h-4 ${M?"animate-spin":""}`}),e.jsx("span",{children:M?"Syncing...":"Sync Default Figures"})]}),e.jsxs("button",{onClick:()=>{ne(null),j(!0)},className:"px-4 py-2 bg-amber-800 text-white rounded-xl text-xs font-bold flex items-center gap-2 hover:bg-amber-900 transition-colors shadow-xs",children:[e.jsx(Ye,{className:"w-4 h-4"}),e.jsx("span",{children:"Add New Figure"})]})]})]}),e.jsxs("div",{className:"flex flex-col md:flex-row items-center justify-between gap-4 pt-3 border-t border-slate-100 dark:border-slate-700",children:[e.jsxs("div",{className:"flex items-center gap-2 overflow-x-auto w-full md:w-auto",children:[e.jsxs("span",{className:"text-xs font-bold uppercase text-slate-400 flex items-center gap-1 shrink-0",children:[e.jsx(pa,{className:"w-3.5 h-3.5 text-amber-600"})," Filter:"]}),e.jsxs("button",{onClick:()=>N("all"),className:`px-3 py-1.5 rounded-xl text-xs font-bold transition-all shrink-0 ${f==="all"?"bg-amber-600 text-white shadow-xs":"bg-slate-100 dark:bg-slate-700 text-slate-700 dark:text-slate-200"}`,children:["All Categories (",O.length,")"]}),e.jsx("button",{onClick:()=>N("military"),className:`px-3 py-1.5 rounded-xl text-xs font-bold transition-all shrink-0 flex items-center gap-1.5 ${f==="military"?"bg-amber-700 text-white shadow-xs ring-2 ring-amber-500":"bg-slate-100 dar
63k:bg-slate-700 text-slate-700 dark:text-slate-200 hover:bg-slate-200"}`,children:e.jsx("span",{children:"âï¸ Military Leader"})}),e.jsx("button",{onClick:()=>N("diplomat"),className:`px-3 py-1.5 rounded-xl text-xs font-bold transition-all shrink-0 flex items-center gap-1.5 ${f==="diplomat"?"bg-indigo-700 text-white shadow-xs ring-2 ring-indigo-500":"bg-slate-100 dark:bg-slate-700 text-slate-700 dark:text-slate-200 hover:bg-slate-200"}`,children:e.jsx("span",{children:"ð Diplomat"})}),e.jsx("button",{onClick:()=>N("political"),className:`px-3 py-1.5 rounded-xl text-xs font-bold transition-all shrink-0 flex items-center gap-1.5 ${f==="political"?"bg-emerald-700 text-white shadow-xs ring-2 ring-emerald-500":"bg-slate-100 dark:bg-slate-700 text-slate-700 dark:text-slate-200 hover:bg-slate-200"}`,children:e.jsx("span",{children:"ð Political Figure"})})]}),e.jsxs("div",{className:"relative w-full md:w-72",children:[e.jsx(pt,{className:"w-4 h-4 text-slate-400 absolute left-3 top-1/2 -translate-y-1/2"}),e.jsx("input",{type:"text",placeholder:"Search figure, title, or role...",value:Qe,onChange:t=>h(t.target.value),className:"w-full pl-9 pr-4 py-2 bg-slate-50 dark:bg-slate-900 border border-slate-200 dark:border-slate-700 rounded-xl text-xs text-slate-900 dark:text-slate-100 focus:outline-none focus:ring-2 focus:ring-amber-500"})]})]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:ua.map(t=>{const s=hs(t);return e.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-2xl border border-slate-200 dark:border-slate-700 shadow-sm overflow-hidden flex flex-col justify-between hover:shadow-md transition-shadow",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"relative h-48 bg-slate-900 overflow-hidden",children:[e.jsx("img",{src:t.portraitUrl,alt:t.name,referrerPolicy:"no-referrer",onError:a=>{a.currentTarget.src="https://upload.wikimedia.org/wikipedia/commons/thumb/c/c5/Menelik_II_%28retouched%29.jpg/800px-Menelik_II_%28retouched%29.jpg"},className:"w-full h-full object-cover opacity-90"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-slate-950 via-slate-950/20 to-transparent"}),e.jsx("div",{className:"absolute top-3 left-3 flex flex-wrap gap-1.5",children:s.map(a=>e.jsx("span",{className:`px-2.5 py-0.5 rounded-full text-[10px] font-mono font-extrabold tracking-wider uppercase border shadow-sm ${a==="military"?"bg-amber-950/90 text-amber-300 border-amber-500/50":a==="diplomat"?"bg-indigo-950/90 text-indigo-300 border-indigo-500/50":"bg-emerald-950/90 text-emerald-300 border-emerald-500/50"}`,children:a==="military"?"âï¸ Military":a==="diplomat"?"ð Diplomat":"ð Political"},a))})]}),e.jsxs("div",{className:"p-5 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("h4",{className:"text-lg font-serif font-black text-slate-900 dark:text-slate-100",children:t.name}),t.amharicName&&e.jsx("span",{className:"text-xs font-serif font-bold text-amber-700 dark:text-amber-400",children:t.amharicName})]}),e.jsx("p",{className:"text-xs font-medium text-slate-500 dark:text-slate-400 mt-0.5",children:t.title})]}),e.jsxs("div",{className:"space-y-1.5 text-xs text-slate-600 dark:text-slate-300 bg-slate-50 dark:bg-slate-900/50 p-3 rounded-xl border border-slate-100 dark:border-slate-800",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Role:"})," ",t.role]}),t.armyBranch&&e.jsxs("div",{children:[e.jsx("strong",{children:"Branch:"})," ",t.armyBranch]}),t.forceSize&&e.jsxs("div",{children:[e.jsx("strong",{children:"Force:"})," ",t.forceSize]})]}),e.jsx("p",{className:"text-xs text-slate-600 dark:text-slate-400 line-clamp-3 leading-relaxed",children:t.biography})]})]}),e.jsxs("div",{className:"p-4 bg-slate-50 dark:bg-slate-900/80 border-t border-slate-100 dark:border-slate-700 flex items-center justify-between",children:[e.jsxs("span",{className:"text-[11px] font-mono text-slate-400",children:["ID: ",t.id]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>{ne(t),j(!0)},className:"px-3 py-1.5 bg-amber-100 text-amber-900 dark:bg-amber-900/50 dark:text-amber-200 rounded-lg text-xs font-bold hover:bg-amber-200 transition-colors flex items-center gap-1",children:[e.jsx(ut,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Edit"})]}),e.jsxs("button",{onClick:()=>he(t.id,t.name),className:"px-3 py-1.5 bg-rose-100 text-rose-800 dark:bg-rose-950/80 dark:text-rose-300 rounded-lg text-xs font-bold hover:bg-rose-200 transition-colors flex items-center gap-1",children:[e.jsx(gt,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Delete"})]})]})]})]},t.id)})}),ua.length===0&&e.jsxs("div",{className:"p-12 text-center bg-white dark:bg-slate-800 rounded-2xl border border-slate-200 dark:border-slate-700 space-y-3",children:[e.jsx(da,{className:"w-10 h-10 text-slate-400 mx-auto"}),e.jsx("h4",{className:"text-base font-serif font-bold text-slate-800 dark:text-slate-200",children:"No Historical Figures Found"}),e.jsx("p",{className:"text-xs text-slate-500 max-w-md mx-auto",children:"No figures matched your current search query or category filter. Try clearing filters or adding a new figure."})]})]}),w==="events"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 ga
63p-3.5",children:[e.jsxs("div",{className:"bg-white dark:bg-slate-800 p-4 rounded-xl border border-slate-200 dark:border-slate-700 shadow-xs flex items-center gap-3.5",children:[e.jsx("div",{className:"p-3 bg-amber-50 text-amber-900 rounded-xl border border-amber-200 font-bold shrink-0",children:e.jsx(Ve,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider",children:"Total Records"}),e.jsx("div",{className:"text-2xl font-black font-serif text-slate-900 dark:text-slate-100 mt-0.5",children:x.length}),e.jsx("div",{className:"text-[11px] text-amber-800 font-medium",children:"Historical Repository"})]})]}),e.jsxs("div",{onClick:()=>ct(!G),className:`p-4 rounded-xl border shadow-xs flex items-center gap-3.5 cursor-pointer transition-all ${G?"bg-emerald-900 text-white border-emerald-700 ring-2 ring-emerald-500 shadow-md":"bg-white dark:bg-slate-800 border-emerald-300 dark:border-emerald-800 hover:bg-emerald-50/50 dark:hover:bg-slate-700/60"}`,title:"Click to filter by historical events occurring on today's calendar date",children:[e.jsx("div",{className:`p-3 rounded-xl border font-bold shrink-0 ${G?"bg-emerald-800 text-amber-300 border-emerald-600":"bg-emerald-50 text-emerald-800 border-emerald-200"}`,children:e.jsx($,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`text-xs font-bold uppercase tracking-wider ${G?"text-emerald-200":"text-slate-400"}`,children:"Today's Date"}),e.jsx("span",{className:"text-[9px] bg-amber-400 text-slate-950 font-black px-1 rounded uppercase",children:"Live"})]}),e.jsx("div",{className:`text-2xl font-black font-serif mt-0.5 ${G?"text-white":"text-emerald-800 dark:text-emerald-300"}`,children:ss}),e.jsx("div",{className:`text-[11px] font-medium ${G?"text-emerald-200 font-bold":"text-emerald-700 dark:text-emerald-400"}`,children:G?"â Filter Active":"Matches Today"})]})]}),e.jsxs("div",{className:"bg-white dark:bg-slate-800 p-4 rounded-xl border border-slate-200 dark:border-slate-700 shadow-xs flex items-center gap-3.5",children:[e.jsx("div",{className:"p-3 bg-emerald-50 text-emerald-800 rounded-xl border border-emerald-200 font-bold shrink-0",children:e.jsx(_t,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider",children:"Published"}),e.jsx("div",{className:"text-2xl font-black font-serif text-slate-900 dark:text-slate-100 mt-0.5",children:Lt}),e.jsx("div",{className:"text-[11px] text-emerald-700 font-medium",children:x.length>0?`${Math.round(Lt/x.length*100)}% of total`:"0%"})]})]}),e.jsxs("div",{className:"bg-white dark:bg-slate-800 p-4 rounded-xl border border-slate-200 dark:border-slate-700 shadow-xs flex items-center gap-3.5",children:[e.jsx("div",{className:"p-3 bg-indigo-50 text-indigo-800 rounded-xl border border-indigo-200 font-bold shrink-0",children:e.jsx(bt,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider",children:"Current Month"}),e.jsx("div",{className:"text-2xl font-black font-serif text-slate-900 dark:text-slate-100 mt-0.5",children:as}),e.jsxs("div",{className:"text-[11px] text-indigo-700 font-medium",children:["In ",_e.monthNameEn," (",_e.monthNameAm,")"]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-slate-800 p-4 rounded-xl border border-slate-200 dark:border-slate-700 shadow-xs flex items-center gap-3.5",children:[e.jsx("div",{className:"p-3 bg-teal-50 text-teal-800 rounded-xl border border-teal-200 font-bold shrink-0",children:e.jsx(zt,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider",children:"Media Enriched"}),e.jsx("div",{className:"text-2xl font-black font-serif text-slate-900 dark:text-slate-100 mt-0.5",children:rs}),e.jsx("div",{className:"text-[11px] text-teal-700 font-medium",children:x.length>0?`${Math.round(rs/x.length*100)}% coverage`:"0%"})]})]})]}),e.jsx(qr,{events:x,selectedCentury:He,onSelectCentury:Za}),e.jsxs("div",{className:"bg-amber-900 text-amber-50 p-4 rounded-xl shadow-sm border border-amber-800 flex flex-col md:flex-row items-start md:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2.5 bg-amber-800/80 rounded-xl text-amber-300 font-bold shrink-0",children:e.jsx(bt,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] font-mono uppercase font-bold text-amber-300 bg-amber-950 px-2 py-0.5 rounded border border-amber-800/80",children:"Active Ethiopian Calendar"}),e.jsxs("span",{className:"text-xs font-bold text-amber-200",children:[Be.monthNameAm," (",Be.season,")"]})]}),e.jsxs("h4",{className:"text-base font-serif font-bold text-white mt-0.5",children:["Current Month: ",Be.monthNameEn," ",Be.day,", ",Be.year," EC (",Be.geezYear," á.á)"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2.5 bg-amber-950/70 p-2 rounded-xl border border-amber-800/80 text-xs self-stretch md:self-auto justify-between md:justify-start",children:[e.jsx("span",{className:"text-amber-200 font-medium pl-1",children:"Start from Current Month:"}),e.jsxs("button",{type:"button",onClick:()=>Xa(!xe),className:`px-3 py-1.5 rounded-lg font-bold text-xs transition-colors flex items-center gap-1.5 ${xe?"bg-amber-400 text-slate-950 shadow-sm":"bg-amber-900 text-amber-200 hover:text-white"}`,children:[e.jsx(ha,{className:`w-3.5 h-3.5 ${xe?"fill-slate-950 text-slate-950":"text-amber-300"}`}),e.jsx("span",{children:xe?"Active (At Top)":"Disabled"})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-slate-800 p-3.5 rounded-xl shadow-xs border border-slate-200 dark:border-slate-700 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-bold uppercase tracking-wider text-slate-500 dark:text-slate-400 flex items-center gap-1.5",children:[e.jsx(pa,{className:"w-3.5 h-3.5 text-amber-700"}),e.jsx("span",{children:"Filter by Historical Era / Epoch:"})]}),e.jsxs("span",{className:"text-xs text-slate-400 font-mono",children:["Showing ",ls.length," of ",x.length]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("button",{onClick:()=>ct(!G),className:`px-3 py-1.5 rounded-lg text-xs font-bold transition-all border flex items-center gap-1.5 ${G?"bg-emerald-800 text-white border-emerald-900 shadow-sm ring-2 ring-emerald-500":"bg-emerald-50 text-emerald-900 border-emerald-300 hover:bg-emerald-100"}`,children:[e.jsx($,{className:"w-3 h-3 text-amber-500 fill-amber-500"}),e.jsx("span",{children:"Today in History"}),e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-mono font-bold ${G?"bg-emerald-950 text-emerald-200":"bg-emerald-200 text-emerald-900"}`,children:ss})]}),e.jsxs("button",{onClick:()=>st("all"),className:`px-3 py-1.5 rounded-lg text-xs font-bold transition-colors border flex items-center gap-1.5 ${be==="all"?"bg-amber-900 text-amber-50 border-amber-950 shadow-xs":"bg-slate-50 dark:bg-slate-900 text-slate-700 dark:text-slate-300 border-slate-200 dark:border-slate-700 hover:bg-slate-100 dar
63k:bg-slate-800"}`,children:[e.jsx("span",{children:"All Historical Eras"}),e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-mono ${be==="all"?"bg-amber-800 text-amber-200":"bg-slate-200 text-slate-700 dark:text-slate-300"}`,children:x.length})]}),Object.entries(es).map(([t,s])=>{const a=x.filter(i=>(i.era||"imperial").toLowerCase()===t).length,r=be===t;return e.jsxs("button",{onClick:()=>st(t),className:`px-3 py-1.5 rounded-lg text-xs font-bold transition-colors border flex items-center gap-1.5 ${r?"bg-amber-900 text-amber-50 border-amber-950 shadow-xs":`${s.color} hover:brightness-95`}`,children:[e.jsx("span",{children:s.label}),s.amharic&&e.jsxs("span",{className:"opacity-70 font-serif",children:["(",s.amharic,")"]}),e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-mono ${r?"bg-amber-800 text-amber-200":"bg-white dark:bg-slate-800/80 text-slate-800 dark:text-slate-200"}`,children:a})]},t)}),He&&e.jsxs("div",{className:"flex items-center gap-1.5 bg-amber-500/15 dark:bg-amber-950/60 border border-amber-400 dark:border-amber-700 text-amber-900 dark:text-amber-200 px-3 py-1.5 rounded-lg text-xs font-bold shadow-xs",children:[e.jsx(As,{className:"w-3.5 h-3.5 text-amber-600 dark:text-amber-400"}),e.jsxs("span",{children:["Century: ",e.jsx("span",{className:"underline decoration-amber-500 underline-offset-2",children:He})]}),e.jsx("button",{type:"button",onClick:()=>Za(null),className:"ml-1 hover:bg-amber-200 dark:hover:bg-amber-800/80 p-0.5 rounded text-amber-800 dark:text-amber-300 transition-colors",title:"Clear active century filter",children:e.jsx(ve,{className:"w-3 h-3"})})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-slate-800 p-4 rounded-xl shadow-xs border border-slate-200 dark:border-slate-700 flex flex-col md:flex-row items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 w-full md:w-auto",children:[e.jsxs("div",{className:"relative w-full md:w-80",children:[e.jsx("input",{type:"text",placeholder:"Search event title, ethiopian date, summary...",value:P,onChange:t=>K(t.target.value),className:"w-full pl-9 pr-4 py-2 bg-slate-50 dark:bg-slate-900 border border-slate-200 dark:border-slate-700 rounded-lg text-xs focus:bg-white dark:bg-slate-800 focus:border-amber-600 focus:outline-none font-medium"}),e.jsx(pt,{className:"w-4 h-4 text-slate-400 absolute left-3 top-2.5 pointer-events-none"})]}),e.jsxs("button",{type:"button",onClick:()=>Mt(!1),className:"hidden sm:inline-flex items-center gap-1.5 bg-emerald-800 hover:bg-emerald-700 text-white px-3.5 py-2 rounded-lg text-xs font-bold shrink-0 transition-colors shadow-xs",title:"Create and add a new historical record to Firestore",children:[e.jsx(Ye,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Create Entry"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4 w-full md:w-auto justify-between md:justify-end",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-bold text-slate-400 uppercase",children:"Status:"}),e.jsxs("select",{value:te,onChange:t=>E(t.target.value),className:"px-3 py-1.5 bg-slate-50 dark:bg-slate-900 border border-slate-200 dark:border-slate-700 rounded-lg text-xs font-medium focus:outline-none",children:[e.jsxs("option",{value:"all",children:["All Statuses (",x.length,")"]}),e.jsxs("option",{value:"published",children:["Published (",Lt,")"]}),e.jsxs("option",{value:"draft",children:["Draft (",ts,")"]})]})]}),(P||te!=="all"||be!=="all"||G)&&e.jsxs("button",{onClick:()=>{K(""),E("all"),st("all"),ct(!1)},className:"text-xs font-bold text-amber-700 bg-amber-50 hover:bg-amber-100 border border-amber-200 px-3 py-1.5 rounded-lg transition-colors flex items-center gap-1",children:[e.jsx(ve,{className:"w-3.5 h-3.5"}),"Clear Filters"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-bold text-slate-400 uppercase",children:"Per Page:"}),e.jsxs("select",{value:dt,onChange:t=>dr(Number(t.target.value)),className:"px-3 py-1.5 bg-slate-50 dark:bg-slate-900 border border-slate-200 dark:border-slate-700 rounded-lg text-xs font-medium focus:outline-none",children:[e.jsx("option",{value:5,children:"5"}),e.jsx("option",{value:10,children:"10"}),e.jsx("option",{value:20,children:"20"}),e.jsx("option",{value:50,children:"50"})]})]})]})]}),C.size>0&&e.jsxs("div",{className:"bg-slate-900 text-white p-3.5 rounded-xl shadow-lg border border-slate-800 flex flex-wrap items-center justify-between gap-3 animate-in fade-in duration-200",children:[e.jsxs("div",{className:"flex items-center gap-2.5 flex-wrap",children:[e.jsxs("span",{className:"bg-amber-500 text-slate-950 font-black text-xs px-2.5 py-1 rounded-md font-mono flex items-center gap-1.5",children:[e.jsx(Lr,{className:"w-3.5 h-3.5"}),e.jsxs("span",{children:[C.size," Selected"]})]}),se.length>0&&se.every(t=>C.has(t.id))&&Ie.length>se.length&&e.jsx("button",{type:"button",onClick:mr,className:"text-xs text-amber-300 hover:text-amber-200 underline font-medium cursor-pointer",children:C.size===Ie.length?`All ${Ie.length} filtered records selected`:`Select all ${Ie.length} records in current filter`}),e.jsx("span",{className:"text-xs font-medium text-slate-300 hidden md:inline",children:"Apply batch changes across selected historical records:"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:hr,disabled:ye,className:"px-3 py-1.5 bg-emerald-600 hover:bg-emerald-500 text-white rounded-lg text-xs font-bold disabled:opacity-50 transition-colors flex items-center gap-1 shadow-xs cursor-pointer",title:"Publish selected events",children:[e.jsx(_t,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Bulk Publish"})]}),e.jsxs("button",{type:"button",onClick:br,disabled:ye,className:"px-3 py-1.5 bg-slate-700 hover:bg-slate-600 text-white rounded-lg text-xs font-bold disabled:opacity-50 transition-colors flex items-center gap-1 shadow-xs cursor-pointer",title:"Set selected events to draft",children:[e.jsx(Bt,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Bulk Draft"})]}),e.jsxs("button",{type:"button",onClick:pr,disabled:ye,className:"px-3 py-1.5 bg-amber-600 hover:bg-amber-500 text-slate-950 font-bold rounded-lg text-xs disabled:opacity-50 transition-colors flex items-center gap-1 shadow-xs cursor-pointer",title:"Lookup authentic Wikipedia images for selected events",children:[e.jsx(Te,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"⨠Auto-Image"})]}),e.jsxs("button",{type:"button",onClick:ur,disabled:ye,className:"px-3.5 py-1.5 bg-rose-700 hover:bg-rose-600 active:bg-rose-800 text-white rounded-lg text-xs font-bold disabled:opacity-50 transition-colors flex items-center gap-1.5 shadow-xs cursor-pointer",title:"Delete all selected historical records",children:[e.jsx(gt,{className:"w-3.5 h-3.5"}),e.jsxs("span",{children:["Delete Selected (",C.size,")"]})]}),e.jsx("button",{type:"button",onClick:()=>de(new Set),className:"px-2.5 py-1.5 bg-slate-800 hover:bg-slate-700 text-slate-400 hover:text-white rounded-lg text-xs font-medium transition-colors cursor-pointer",children:"Clear"})]})]}),e.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-xl shadow-xs border border-slate-200 dark:border-slate-700 overflow-hidden",children:[le?e.jsxs("div",{className:"p-16 text-center text-slate-500 dark:text-slate-400 font-serif flex flex-col items-center justify-center gap-3",children:[e.jsx(S,{className:"w-7 h-7 animate-spin text-amber-700 dark:text-amber-500"}),e.jsx("div",{className:"text-sm font-bold text-slate-700 dark:text-slate-300",children:"Loading historical archives from Firestore..."}),e.jsx("p",{className:"text-xs text-slate-400",children:"Synchronizing Ethiopian calendar dates and royal chronicles"})]}):se.length===0?e.jsx("div",{className:"p-8 sm:p-14 text-center",children:x.length===0?e.jsxs("div",{className:"max-w-md mx-auto
63space-y-4",children:[e.jsx("div",{className:"w-16 h-16 bg-gradient-to-br from-emerald-100 to-amber-100 dark:from-emerald-950/60 dark:to-amber-950/60 border border-emerald-300 dark:border-emerald-700/50 rounded-2xl flex items-center justify-center mx-auto shadow-sm",children:e.jsx(fs,{className:"w-8 h-8 text-emerald-800 dark:text-emerald-300"})}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h3",{className:"text-lg font-serif font-black text-slate-900 dark:text-slate-100 tracking-tight",children:"Historical Knowledge Repository is Empty"}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 leading-relaxed",children:"No historical events are currently recorded in the Firestore database. You can create your first archival entry or import our pre-curated Ethiopian history chronicle."})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2.5 pt-2",children:[e.jsxs("button",{type:"button",onClick:()=>Mt(!1),className:"inline-flex items-center gap-1.5 bg-emerald-800 hover:bg-emerald-700 text-white px-4 py-2 rounded-xl text-xs font-bold uppercase tracking-wider transition-colors shadow-xs cursor-pointer",children:[e.jsx(Ye,{className:"w-4 h-4"}),e.jsx("span",{children:"Create First Historical Entry"})]}),e.jsxs("button",{type:"button",onClick:()=>$e(!0),className:"inline-flex items-center gap-1.5 bg-amber-500 hover:bg-amber-400 text-slate-950 px-4 py-2 rounded-xl text-xs font-bold transition-colors shadow-xs cursor-pointer",children:[e.jsx(Je,{className:"w-4 h-4"}),e.jsx("span",{children:"Import Archives (CSV / JSON)"})]})]})]}):e.jsxs("div",{className:"max-w-lg mx-auto space-y-4",children:[e.jsx("div",{className:"w-16 h-16 bg-amber-50 dark:bg-amber-950/40 border border-amber-200 dark:border-amber-800/50 rounded-2xl flex items-center justify-center mx-auto shadow-sm",children:e.jsx(Vr,{className:"w-8 h-8 text-amber-700 dark:text-amber-400"})}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h3",{className:"text-lg font-serif font-black text-slate-900 dark:text-slate-100 tracking-tight",children:"No Historical Events Match Your Criteria"}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 leading-relaxed",children:"We couldn't find any historical events matching your active search keywords or filter configuration."})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2 pt-1",children:[P&&e.jsxs("span",{className:"bg-amber-100 dark:bg-amber-950/80 text-amber-900 dark:text-amber-300 border border-amber-300 dark:border-amber-800 text-[11px] font-bold px-2.5 py-1 rounded-lg inline-flex items-center gap-1.5",children:[e.jsxs("span",{children:['Search: "',P,'"']}),e.jsx("button",{type:"button",onClick:()=>K(""),className:"hover:text-rose-600 transition-colors cursor-pointer",title:"Remove search filter",children:e.jsx(ve,{className:"w-3 h-3"})})]}),te!=="all"&&e.jsxs("span",{className:"bg-slate-100 dark:bg-slate-800 text-slate-800 dark:text-slate-200 border border-slate-300 dark:border-slate-700 text-[11px] font-bold px-2.5 py-1 rounded-lg inline-flex items-center gap-1.5",children:[e.jsxs("span",{children:["Status: ",te]}),e.jsx("button",{type:"button",onClick:()=>E("all"),className:"hover:text-rose-600 transition-colors cursor-pointer",title:"Remove status filter",children:e.jsx(ve,{className:"w-3 h-3"})})]}),be!=="all"&&e.jsxs("span",{className:"bg-slate-100 dark:bg-slate-800 text-slate-800 dark:text-slate-200 border border-slate-300 dark:border-slate-700 text-[11px] font-bold px-2.5 py-1 rounded-lg inline-flex items-center gap-1.5",children:[e.jsxs("span",{children:["Era: ",be]}),e.jsx("button",{type:"button",onClick:()=>st("all"),className:"hover:text-rose-600 transition-colors cursor-pointer",title:"Remove era filter",children:e.jsx(ve,{className:"w-3 h-3"})})]}),G&&e.jsxs("span",{className:"bg-emerald-100 dark:bg-emerald-950 text-emerald-900 dark:text-emerald-300 border border-emerald-300 dark:border-emerald-800 text-[11px] font-bold px-2.5 py-1 rounded-lg inline-flex items-center gap-1.5",children:[e.jsx("span",{children:"Today's Date Only"}),e.jsx("button",{type:"button",onClick:()=>ct(!1),className:"hover:text-rose-600 transition-colors cursor-pointer",title:"Remove today-only filter",children:e.jsx(ve,{className:"w-3 h-3"})})]})]}),e.jsxs("div",{className:"bg-slate-50 dark:bg-slate-900/60 p-3.5 rounded-xl border border-slate-200 dark:border-slate-800 text-left space-y-2",children:[e.jsxs("div",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-400 flex items-center gap-1",children:[e.jsx($,{className:"w-3 h-3 text-amber-500"}),e.jsx("span",{children:"Try searching popular historical topics:"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:["Battle of Adwa","Emperor Menelik II","Axum Obelisk","Lalibela Churches","Haile Selassie","Yekatit 23","Lucy (Dinkinesh)"].map(t=>e.jsx("button",{type:"button",onClick:()=>K(t),className:"text-[11px] font-medium bg-white dark:bg-slate-800 hover:bg-amber-100 dar
63k:hover:bg-amber-950 text-slate-700 dark:text-slate-300 hover:text-amber-900 dark:hover:text-amber-200 border border-slate-200 dark:border-slate-700 px-2.5 py-1 rounded-lg transition-colors cursor-pointer",children:t},t))})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2.5 pt-2",children:[e.jsxs("button",{type:"button",onClick:()=>{K(""),E("all"),st("all"),ct(!1)},className:"inline-flex items-center gap-1.5 bg-slate-800 hover:bg-slate-900 text-white px-4 py-2 rounded-xl text-xs font-bold transition-colors shadow-xs cursor-pointer",children:[e.jsx(Rr,{className:"w-3.5 h-3.5 text-amber-400"}),e.jsx("span",{children:"Reset All Filters"})]}),e.jsxs("button",{type:"button",onClick:()=>Mt(G),className:"inline-flex items-center gap-1.5 bg-emerald-800 hover:bg-emerald-700 text-white px-4 py-2 rounded-xl text-xs font-bold uppercase tracking-wider transition-colors shadow-xs cursor-pointer",children:[e.jsx(Ye,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Create New Event"})]})]})]})}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full divide-y divide-slate-200",children:[e.jsx("thead",{className:"bg-slate-50 dark:bg-slate-900",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"px-4 py-3.5 text-center w-12",children:e.jsx("input",{type:"checkbox",checked:se.length>0&&se.every(t=>C.has(t.id)),ref:t=>{if(t){const s=se.some(r=>C.has(r.id)),a=se.length>0&&se.every(r=>C.has(r.id));t.indeterminate=s&&!a}},onChange:xr,className:"rounded border-slate-300 text-amber-800 focus:ring-amber-800 cursor-pointer w-4 h-4",title:"Select all events on this page"})}),e.jsx("th",{scope:"col",className:"px-6 py-3.5 text-left text-xs font-bold text-slate-600 dark:text-slate-400 uppercase tracking-wider",children:"Historical Event"}),e.jsx("th",{scope:"col",className:"px-6 py-3.5 text-left text-xs font-bold text-slate-600 dark:text-slate-400 uppercase tracking-wider",children:"Ethiopian Date"}),e.jsx("th",{scope:"col",className:"px-6 py-3.5 text-left text-xs font-bold text-slate-600 dark:text-slate-400 uppercase tracking-wider",children:"Gregorian Equivalent"}),e.jsx("th",{scope:"col",className:"px-6 py-3.5 text-left text-xs font-bold text-slate-600 dark:text-slate-400 uppercase tracking-wider",children:"Era / Epoch"}),e.jsx("th",{scope:"col",className:"px-6 py-3.5 text-left text-xs font-bold text-slate-600 dark:text-slate-400 uppercase tracking-wider",children:"Status"}),e.jsx("th",{scope:"col",className:"px-6 py-3.5 text-right text-xs font-bold text-slate-600 dark:text-slate-400 uppercase tracking-wider",children:"Action Controls"})]})}),e.jsx("tbody",{className:"bg-white dark:bg-slate-800 divide-y divide-slate-200",children:se.map(t=>{const s=Ft(t),a=Pt(t),r=Ke(t),i=na(t.era),u=C.has(t.id),o=u?"bg-amber-50/70 dark:bg-amber-950/40 border-l-4 border-amber-700":r?"bg-emerald-500/10 dark:bg-emerald-950/40 border-l-4 border-emerald-600 dark:border-emerald-400 hover:bg-emerald-500/20 ring-1 ring-emerald-500/20":a?"bg-amber-50/30 hover:bg-amber-50/60":"hover:bg-slate-50 dark:bg-slate-900/80";return e.jsxs("tr",{className:`transition-colors ${o}`,children:[e.jsx("td",{className:"px-4 py-4 text-center",children:e.jsx("input",{type:"checkbox",checked:u,onChange:()=>cr(t.id),className:"rounded border-slate-300 text-amber-800 focus:ring-amber-800 cursor-pointer w-4 h-4"})}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-start gap-3.5",children:[t.heroImage?e.jsx("img",{src:t.heroImage||void 0,alt:"",referrerPolicy:"no-referrer",onClick:()=>pe(t),className:`w-14 h-14 rounded-lg object-cover border shrink-0 cursor-pointer hover:opacity-90 shadow-xs transition-opacity ${r?"border-emerald-500 ring-2 ring-emerald-400/40":"border-slate-200 dark:border-slate-700"}`,title:"Click to view full record preview"}):e.jsx("div",{onClick:()=>pe(t),className:`w-14 h-14 rounded-lg flex items-center justify-center shrink-0 font-bold text-xs border cursor-pointer transition-colors ${r?"bg-emerald-100 text-emerald-900 border-emerald-400 font-black ring-2 ring-emerald-400/40":"bg-
63amber-100/80 text-amber-900 border-amber-200 hover:bg-amber-200/80"}`,title:"Click to view full record preview",children:"ARCH"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm font-bold text-slate-900 dark:text-slate-100 font-serif flex items-center gap-2 flex-wrap",children:[e.jsx("button",{onClick:()=>pe(t),className:"hover:text-amber-900 text-left transition-colors font-bold",children:t.title}),r&&e.jsxs("span",{className:"bg-emerald-800 text-emerald-50 text-[9px] font-black px-2 py-0.5 rounded-full inline-flex items-center gap-1 uppercase tracking-wider font-mono shrink-0 shadow-xs border border-emerald-600",children:[e.jsx($,{className:"w-2.5 h-2.5 text-amber-300 fill-amber-300"}),e.jsx("span",{children:"Today's Date"})]}),a&&!r&&e.jsxs("span",{className:"bg-amber-800 text-amber-100 text-[9px] font-bold px-2 py-0.5 rounded-full inline-flex items-center gap-1 uppercase tracking-wider font-mono shrink-0",children:[e.jsx(ha,{className:"w-2.5 h-2.5 text-amber-300 fill-amber-300"}),"Current Month"]})]}),e.jsx("div",{className:"text-xs text-slate-500 dark:text-slate-400 line-clamp-1 max-w-md mt-0.5 font-sans",children:t.summary})]})]})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-xs font-bold",children:r?e.jsxs("span",{className:"bg-emerald-100 dark:bg-emerald-950/80 text-emerald-950 dark:text-emerald-200 border-2 border-emerald-500 px-2.5 py-1 rounded-md inline-flex items-center gap-1.5 font-serif shadow-xs",children:[e.jsx($,{className:"w-3 h-3 text-amber-600 fill-amber-500 shrink-0"}),e.jsxs("span",{children:["ð
",s]})]}):e.jsxs("span",{className:"bg-amber-50 dark:bg-slate-900 text-amber-900 dark:text-amber-200 px-2.5 py-1 rounded-md border border-amber-200 dark:border-slate-700 inline-block font-serif shadow-2xs",children:["ð
",s]})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-xs text-slate-600 dark:text-slate-400 font-medium font-mono",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{children:t.gregorianDate?new Date(t.gregorianDate).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"N/A"}),r&&e.jsx("span",{className:"text-[9px] bg-emerald-700 text-white px-1.5 py-0.5 rounded font-sans uppercase font-black tracking-wider",children:"Today"})]})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("span",{className:`px-2.5 py-1 text-[11px] font-bold rounded-md border ${i.color}`,children:i.label})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`px-2.5 py-0.5 text-[10px] font-bold uppercase rounded-full ${t.status==="published"?"bg-emerald-100 text-emerald-800 border border-emerald-200":"bg-slate-100 dark:bg-slate-800 text-slate-700 dark:text-slate-300 border border-slate-200 dark:border-slate-700"}`,children:t.status||"draft"}),e.jsx("button",{onClick:()=>is(t.id,t.status==="published"?"draft":"published"),className:"text-[10px] text-slate-400 hover:text-slate-700 dark:text-slate-300 underline font-mono",title:"Quick status toggle",children:t.status==="published"?"Unpublish":"Publish"})]})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-right text-xs font-bold",children:e.jsxs("div",{className:"flex items-center justify-end gap-1.5",children:[e.jsxs("button",{onClick:()=>pe(t),className:"bg-sky-50 text-sky-800 hover:bg-sky-100 border border-sky-200 px-2.5 py-1 rounded-md text-[11px] font-bold inline-flex items-center gap-1 transition-colors shadow-2xs",title:"View full record details",children:[e.jsx(Or,{className:"w-3 h-3 text-sky-700"}),e.jsx("span",{children:"View"})]}),e.jsxs("button",{onClick:()=>Ga(t),disabled:Xt===t.id,className:"bg-amber-100/90 hover:bg-amber-200 text-amber-950 border border-amber-300 px-2.5 py-1 rounded-md text-[11px] font-bold disabled:opacity-50 inline-flex items-center gap-1 transition-colors shadow-2xs",title:"1-Click Auto-Attach authentic Wikipedia/Web image via Python Engine",children:[Xt===t.id?e.jsx(S,{className:"w-3 h-3 animate-spin text-amber-900"}):e.jsx(Te,{className:"w-3 h-3 text-amber-900"}),e.jsx("span",{children:"Auto-Image"})]}),e.jsxs("button",{onClick:()=>
63aa(t.title,t),className:"bg-slate-100 dark:bg-slate-800 hover:bg-slate-200 text-slate-800 dark:text-slate-200 border border-slate-300 px-2.5 py-1 rounded-md text-[11px] font-bold inline-flex items-center gap-1 transition-colors shadow-2xs",title:"Manual Search Wikipedia/Internet for historical images",children:[e.jsx(zt,{className:"w-3 h-3 text-slate-700 dark:text-slate-300"}),e.jsx("span",{children:"Browse"})]}),e.jsxs("button",{onClick:()=>er(t),disabled:Ea===t.id,className:"bg-indigo-50 hover:bg-indigo-100 text-indigo-900 border border-indigo-200 px-2.5 py-1 rounded-md text-[11px] font-bold disabled:opacity-50 inline-flex items-center gap-1 transition-colors shadow-2xs",title:"Generate a full front-page news article from this historical event",children:[Ea===t.id?e.jsx(S,{className:"w-3 h-3 animate-spin text-indigo-700"}):e.jsx($,{className:"w-3 h-3 text-indigo-700"}),e.jsx("span",{children:"Gen Article"})]}),e.jsx("button",{onClick:()=>Zs(t),disabled:_a===t.id,className:"p-1.5 text-purple-600 hover:text-purple-800 hover:bg-purple-50 rounded-md transition-colors disabled:opacity-50",title:"AI Enhance Content (Summary, Narrative, Dates & Image)",children:e.jsx($,{className:`w-3.5 h-3.5 ${_a===t.id?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>{const y=`${window.location.origin}/history/${t.id}`;navigator.clipboard.writeText(y),n("Public URL copied to clipboard!","success")},className:"p-1.5 text-blue-600 hover:text-blue-800 hover:bg-blue-50 rounded-md transition-colors",title:"Copy Public URL",children:e.jsx(Hr,{className:"w-3.5 h-3.5"})}),e.jsxs("button",{type:"button",onClick:()=>qa(t),className:"bg-amber-100 hover:bg-amber-200 text-amber-950 dark:bg-amber-950/70 dark:hover:bg-amber-900 dark:text-amber-200 border border-amber-300 dark:border-amber-700 px-2.5 py-1 rounded-md text-[11px] font-bold inline-flex items-center gap-1 transition-colors shadow-2xs cursor-pointer",title:"Edit Historical Record (Title, Description, Dates)",children:[e.jsx(ut,{className:"w-3 h-3 text-amber-900 dark:text-amber-300"}),e.jsx("span",{children:"Edit"})]}),e.jsx("button",{type:"button",onClick:()=>yr(t.id,t.title),className:"p-1.5 text-rose-600 hover:text-rose-800 hover:bg-rose-50 rounded-md transition-colors cursor-pointer",title:`Delete Record: "${t.title}"`,children:e.jsx(gt,{className:"w-3.5 h-3.5"})})]})})]},t.id)})})]})}),Rt>0&&e.jsxs("div",{className:"px-6 py-4 bg-slate-50 dark:bg-slate-900 border-t border-slate-200 dark:border-slate-700 flex flex-col sm:flex-row items-center justify-between gap-4",children:[e.jsxs("div",{className:"text-xs text-slate-600 dark:text-slate-400 font-medium",children:["Showing ",e.jsx("strong",{className:"text-slate-900 dark:text-slate-100",children:ia+1})," to"," ",e.jsx("strong",{className:"text-slate-900 dark:text-slate-100",children:ns})," of"," ",e.jsx("strong",{className:"text-slate-900 dark:text-slate-100",children:Rt})," historical records"]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{onClick:()=>ot(1),disabled:Oe===1,className:"p-1.5 rounded-lg border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-800 text-slate-700 dark:text-slate-300 hover:bg-slate-100 dark:bg-slate-800 disabled:opacity-40 disabled:hover:bg-white dark:bg-slate-800 text-xs font-bold",title:"First Page",children:e.jsx(_r,{className:"w-4 h-4"})}),e.jsxs("button",{onClick:()=>ot(t=>Math.max(1,t-1)),disabled:Oe===1,className:"px-3 py-1.5 rounded-lg border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-800 text-slate-700 dark:text-slate-300 hover:bg-slate-100 dark:bg-slate-800 disabled:opacity-40 disabled:hover:bg-white dark:bg-slate-800 text-xs font-bold flex items-center gap-1",children:[e.jsx(Ur,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Prev"})]}),e.jsxs("div",{className:"px-3 py-1.5 font-mono text-xs text-slate-800 dark:text-slate-200 font-bold bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded-lg",children:["Page ",Oe," of ",xt]}),e.jsxs("button",{onClick:()=>ot(t=>Math.min(xt,t+1)),disabled:Oe===xt,className:"px-3 py-1.5 rounded-lg border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-800 text-slate-700 dark:text-slate-300 hover:bg-slate-100 dar
63k:bg-slate-800 disabled:opacity-40 disabled:hover:bg-white dark:bg-slate-800 text-xs font-bold flex items-center gap-1",children:[e.jsx("span",{children:"Next"}),e.jsx(Cr,{className:"w-3.5 h-3.5"})]}),e.jsx("button",{onClick:()=>ot(xt),disabled:Oe===xt,className:"p-1.5 rounded-lg border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-800 text-slate-700 dark:text-slate-300 hover:bg-slate-100 dark:bg-slate-800 disabled:opacity-40 disabled:hover:bg-white dark:bg-slate-800 text-xs font-bold",title:"Last Page",children:e.jsx(Br,{className:"w-4 h-4"})})]})]})]})]}),jt&&e.jsx(Dr,{isOpen:jt,onClose:()=>{j(!1),ne(null)},itemType:"figures",item:ae,onSave:Xe}),$s&&e.jsx("div",{className:"fixed inset-0 bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4 z-50 overflow-y-auto",children:e.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-2xl shadow-2xl max-w-4xl w-full p-6 my-8 space-y-6 max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between pb-4 border-b border-slate-200 dark:border-slate-700 gap-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:`text-xs font-bold uppercase tracking-widest px-2.5 py-0.5 rounded border ${V?"text-amber-900 bg-amber-50 border-amber-200":"text-emerald-900 bg-emerald-50 border-emerald-300"}`,children:V?"Edit Historical Record":"Create New Historical Entry"}),e.jsx("span",{className:"text-xs text-emerald-800 bg-emerald-100/70 dark:bg-emerald-950/70 dark:text-emerald-300 font-mono px-2 py-0.5 rounded",children:"Firestore: historyEvents"}),e.jsxs("span",{className:"text-xs text-slate-400 font-mono",children:[os," words"]})]}),e.jsx("h2",{className:"text-2xl font-serif font-bold text-slate-900 dark:text-slate-100 mt-1",children:V?"Edit Archival Record":"Create New Historical Event Entry"}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-0.5",children:V?"Update event chronology, archival source notes, summary, and imagery.":"Manually add a new event to the Ethiopian Historical Timeline and Today in History repository."})]}),e.jsx("button",{onClick:()=>Ze(!1),className:"text-slate-400 hover:text-slate-600 dark:text-slate-400 p-2 text-xl font-bold self-end md:self-auto",title:"Close modal",children:"â"})]}),e.jsxs("div",{className:"bg-gradient-to-r from-amber-900 to-slate-900 text-white p-3.5 rounded-xl flex flex-wrap items-center justify-between gap-3 shadow-inner",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-amber-400 text-sm font-bold",children:"ðï¸ AI Scholar Assistant:"}),e.jsx("span",{className:"text-xs text-slate-300 hidden sm:inline",children:"Polish title, summarize event, or enhance into a published article."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",disabled:Et||!l.title,onClick:Ya,className:"bg-gradient-to-r from-emerald-600 to-teal-600 hover:from-emerald-500 hover:to-teal-500 text-white px-3.5 py-1.5 rounded-lg text-xs font-bold disabled:opacity-40 transition-all shadow-md flex items-center gap-1.5 border border-emerald-400/30",title:"Enhance event with AI and publish it directly as a historical article",children:Et?e.jsxs(e.Fragment,{children:[e.jsx(S,{className:"w-3.5 h-3.5 animate-spin"}),e.jsx("span",{children:"Publishing Article..."})]}):e.jsxs(e.Fragment,{children:[e.jsx($,{className:"w-3.5 h-3.5 text-emerald-200"}),e.jsx("span",{children:"Enhance & Publish as Article"})]})}),e.jsx("button",{type:"button",disabled:!!k||!l.title,onClick:()=>W("history_title"),className:"bg-amber-700/80 hover:bg-amber-700 text-white px-3 py-1.5 rounded text-xs font-semibold disabled:opacity-40 transition-colors flex items-center gap-1",children:k==="history_title"?"Polishing...":"⨠Polish Title"}),e.jsx("button",{type:"button",disabled:!!k||!l.title&&!l.content,onClick:()=>W("history_summary"),className:"bg-amber-700/80 hover:bg-amber-700 text-white px-3 py-1.5 rounded text-xs font-semibold disabled:opacity-40 transition-colors flex items-center gap-1",children:k==="history_summary"?"Generating...":"â¡ Auto Lead Summary"}),e.jsx("button",{type:"button",disabled:!!k||!l.title,onClick:()=>W("history_expand"),className:"bg-amber-700/80 hover:bg-amber-700 text-white px-3 py-1.5 rounded text-xs font-semibold disabled:opacity-40 transition-colors flex items-center gap-1",children:k==="history_expand"?"Writing...":"ð AI History Scholar"}),e.jsx("button",{type:"button",disabled:!!k||!l.title,onClick:()=>W("translate_amharic"),className:"bg-emerald-700/80 hover:bg-emerald-700 text-white px-3 py-1.5 rounded text-xs font-semibold disabled:opacity-40 transition-colors flex items-center gap-1",children:k==="translate_amharic"?"Translating...":"ð Translate to Amharic"})]})]}),e.jsxs("form",{onSubmit:tr,className:"space-y-5",children:[Re.length>0&&e.jsxs("div",{className:"bg-amber-50 border-2 border-amber-300 rounded-xl p-4 space-y-3 shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 text-amber-900 font-bold text-sm",children:[e.jsx(ba,{className:"w-5 h-5 text-amber-600 shrink-0"}),e.jsxs("span",{children:["Potential Duplicate Historical Record (",Re[0].combinedSimilarity,"% Cosine Match)"]})]}),e.jsx("span",{className:"text-[10px] uppercase font-mono tracking-wider font-extrabold bg-amber-200 text-amber-900 px-2 py-0.5 rounded",children:"TF-IDF Cosine Similarity"})]}),e.jsx("div",{className:"space-y-2 text-xs text-amber-950",children:Re.slice(0,2).map((t,s)=>e.jsxs("div",{className:"bg-white dark:bg-slate-800/80 p-3 rounded-lg border border-amber-200 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-serif font-bold text-slate-900 dark:text-slate-100 line-clamp-1",children:t.item.title}),e.jsxs("span",{className:"font-mono font-bold text-amber-800 bg-amber-100 px-2 py-0.5 rounded text-[11px] shrink-0",children:[t.combinedSimilarity,"% match"]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-[11px] text-slate-600 dar
63k:text-slate-400 font-medium",children:[e.jsxs("span",{children:["Reason: ",e.jsx("strong",{className:"text-amber-900 font-semibold",children:t.matchReason})]}),e.jsx("span",{children:"â¢"}),e.jsxs("span",{children:["Title Cosine: ",e.jsxs("strong",{className:"font-mono text-slate-800 dark:text-slate-200",children:[t.titleSimilarity,"%"]})]}),e.jsx("span",{children:"â¢"}),e.jsxs("span",{children:["Content Cosine: ",e.jsxs("strong",{className:"font-mono text-slate-800 dark:text-slate-200",children:[t.contentSimilarity,"%"]})]})]})]},s))})]}),e.jsxs("div",{className:"bg-gradient-to-r from-amber-950/20 via-slate-900/10 to-amber-900/20 dark:from-amber-950/40 dark:to-slate-900/40 p-3 rounded-xl border border-amber-300/40 dark:border-amber-700/40",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-bold text-amber-900 dark:text-amber-300",children:[e.jsx($,{className:"w-4 h-4 text-amber-600 dark:text-amber-400"}),e.jsx("span",{children:"Gemini AI Archival Assistant"})]}),e.jsx("span",{className:"text-[11px] text-slate-500 dark:text-slate-400",children:"Auto-expand notes, proofread descriptions, & sync dates"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("button",{type:"button",disabled:!!k||!l.title&&!l.content&&!l.summary,onClick:()=>W("history_enhance"),className:"bg-amber-800 hover:bg-amber-700 text-white text-xs font-bold px-3 py-1.5 rounded-lg flex items-center gap-1.5 transition-colors shadow-2xs disabled:opacity-50",title:"Automatically expand brief notes or proofread detailed description",children:[k==="history_enhance"?e.jsx(S,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx($,{className:"w-3.5 h-3.5 text-amber-300"}),e.jsx("span",{children:"⨠Auto-Enhance Full Record"})]}),e.jsxs("button",{type:"button",disabled:!!k||!l.title&&!l.content,onClick:()=>W("history_expand"),className:"bg-white dark:bg-slate-800 hover:bg-amber-50 dark:hover:bg-slate-700 text-amber-900 dark:text-amber-200 border border-amber-300 dark:border-amber-700 text-xs font-bold px-2.5 py-1.5 rounded-lg flex items-center gap-1.5 transition-colors disabled:opacity-50",title:"Expand draft notes into a structured multi-paragraph historical narrative",children:[k==="history_expand"?e.jsx(S,{className:"w-3.5 h-3.5 animate-spin text-amber-600"}):e.jsx(fs,{className:"w-3.5 h-3.5 text-amber-600"}),e.jsx("span",{children:"ð Expand Narrative"})]}),e.jsxs("button",{type:"button",disabled:!!k||!l.content&&!l.summary,onClick:()=>W("history_proofread"),className:"bg-white dark:bg-slate-800 hover:bg-amber-50 dark:hover:bg-slate-700 text-slate-800 dark:text-slate-200 border border-slate-300 dark:border-slate-700 text-xs font-bold px-2.5 py-1.5 rounded-lg flex items-center gap-1.5 transition-colors disabled:opacity-50",title:"Proofread grammar, academic tone, dates, and historical terminology",children:[k==="history_proofread"?e.jsx(S,{className:"w-3.5 h-3.5 animate-spin text-amber-600"}):e.jsx(ut,{className:"w-3.5 h-3.5 text-indigo-600 dark:text-indigo-400"}),e.jsx("span",{children:"ð Proofread & Polish"})]}),e.jsxs("button",{type:"button",disabled:!!k||!l.title&&!l.content,onClick:()=>W("history_summary"),className:"bg-white dark:bg-slate-800 hover:bg-amber-50 dark:hover:bg-slate-700 text-slate-800 dark:text-slate-200 border border-slate-300 dark:border-slate-700 text-xs font-bold px-2.5 py-1.5 rounded-lg flex items-center gap-1.5 transition-colors disabled:opacity-50",title:"Generate a concise 1-2 sentence lead summary from event details",children:[k==="history_summary"?e.jsx(S,{className:"w-3.5 h-3.5 animate-spin text-amber-600"}):e.jsx(Bt,{className:"w-3.5 h-3.5 text-emerald-600"}),e.jsx("span",{children:"⨠Lead Summary"})]}),e.jsxs("button",{type:"button",disabled:!!k||!l.title,onClick:()=>W("translate_amharic"),className:"bg-white dark:bg-slate-800 hover:bg-amber-50 dark:hover:bg-slate-700 text-slate-800 dark:text-slate-200 border border-slate-300 dark:border-slate-700 text-xs font-bold px-2.5 py-1.5 rounded-lg flex items-center gap-1.5 transition-colors disabled:opacity-50",title:"Translate event title and summary into formal Amharic",children:[k==="translate_amharic"?e.jsx(S,{className:"w-3.5 h-3.5 animate-spin text-amber-600"}):e.jsx(Te,{className:"w-3.5 h-3.5 text-blue-600"}),e.jsx(Sr,{variant:"inline",size:"xs"}),e.jsx("span",{children:"Amharic (á ááá)"})]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("label",{className:"block text-xs font-bold uppercase text-slate-700 dark:text-slate-300",children:"Event Title *"}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("button",{type:"button",disabled:!!k||!l.title,onClick:()=>W("history_title"),className:"text-[11px] font-bold text-amber-800 dark:text-amber-300 hover:underline flex items-center gap-1 disabled:opacity-50",title:"Refine historical title for academic punch and precision",children:[k==="history_title"?e.jsx(S,{className:"w-3 h-3 animate-spin"}):e.jsx($,{className:"w-3 h-3"}),e.jsx("span",{children:"AI Refine Title"})]})})]}),e.jsx("input",{type:"text",value:l.title,onChange:t=>D({...l,title:t.target.value}),required:!0,placeholder:"e.g. Battle of Adwa Defeat of Colonial Forces",className:"w-full px-3.5 py-2.5 border border-slate-300 rounded-lg text-sm font-bold text-slate-900 dark:text-slate-100 font-serif focus:outline-none focus:border-amber-600"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 bg-slate-50 dark:bg-slate-900/60 p-2.5 rounded-lg border border-slate-200 dark:border-slate-700",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(bt,{className:"w-4 h-4 text-amber-700"}),e.jsx("span",{className:"text-xs font-bold text-slate-700 dark:text-slate-300",children:"Chronological Dating & Calendar Sync"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[Ke(l)&&e.jsxs("span",{className:"bg-emerald-100 text-emerald-950 dark:bg-emerald-950 dark:text-emerald-200 border border-emerald-400 text-[11px] font-bold px-2 py-0.5 rounded-full inline-flex items-center gap-1",children:[e.jsx($,{className:"w-3 h-3 text-amber-600 fill-amber-500"}),e.jsx("span",{children:"Matches Today in Ethiopian History"})]}),e.jsxs("button",{type:"button",onClick:()=>{const t=new Date,s=t.toISOString().split("T")[0],a=ge(t),r=`${a.monthNameEn} ${a.day}, ${a.year} EC (${a.monthNameAm})`;D(i=>({...i,gregorianDate:s,ethiopianDate:r})),n(`Date set to Today: ${r}`,"success")},className:"bg-emerald-800 hover:bg-emerald-700 text-white px-2.5 py-1 rounded text-xs font-bold transition-colors inline-flex items-center gap-1 shadow-2xs",title:"Automatically populate today's Ethiopian and European date",children:[e.jsx($,{className:"w-3 h-3 text-amber-300"}),e.jsx("span",{children:"Fill Today's Date"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("label",{className:"block text-xs font-bold uppercase text-slate-700 dark:text-slate-300",children:"Ethiopian Date *"}),l.gregorianDate&&e.jsxs("button",{type:"button",onClick:Ja,className:"text-[11px] font-bold text-amber-800 hover:text-amber-950 flex items-center gap-1 bg-amber-100/80 hover:bg-amber-200 px-2 py-0.5 rounded transition-colors",title:"Convert from European Date",children:[e.jsx(S,{className:"w-3 h-3"}),e.jsx("span",{children:"Auto-Convert"})]})]}),e.jsx("input",{type:"text",value:l.ethiopianDate,onChange:t=>D({...l,ethiopianDate:t.target.value}),placeholder:"e.g. Yekatit 23, 1888 EC",className:"w-full px-3 py-2 border border-slate-300 rounded-lg text-sm font-bold focus:outline-none focus:border-amber-600 font-serif text-amber-900 bg-amber-50/20"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("label",{className:"block text-xs font-bold uppercase text-slate-700 dark:text-slate-300",children:"Gregorian Date Equivalent"}),e.jsx("button",{type:"button",onClick:Ja,className:"text-[11px] font-bold text-amber-800 hover:text-amber-950 flex items-center gap-1 bg-amber-100 hover:bg-amber-200 px-2 py-0.5 rounded transition-colors",children:e.jsx("span",{children:"Convert to Ethiopian"})})]}),e.jsx("input",{type:"date",value:l.gregorianDate,onChange:t=>{const s=t.target.value,a={...l,gregorianDate:s};if(s){const r=new Date(s);if(!isNaN(r.getTime())){const i=ge(r);a.ethiopianDate=`${i.monthNameEn} ${i.day}, ${i.year} E.C.`}}D(a)},className:"w-full px-3 py-2 border border-slate-300 rounded-lg text-sm focus:outline-none focus:border-amber-600"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold uppercase text-slate-700 dark:text-slate-300 mb-1",children:"Status"}),e.jsxs("select",{value:l.status,onChange:t=>D({...l,status:t.target.value}),className:"w-full px-3 py-2 border border-slate-300 rounded-lg text-sm focus:outline-none focus:border-amber-600 font-medium",children:[e.jsx("option",{value:"published",children:"Published (Live in Timeline)"}),e.jsx("option",{value:"draft",children:"Draft (Private Curation)"})]})]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-1",children:[e.jsx("label",{className:"block text-xs font-bold uppercase text-slate-700 dark:text-slate-300",children:"Archival Image / Artifact URL"}),e.jsxs("button",{type:"button",onClick:()=>aa(l.title||"Ethiopia History"),className:"bg-indigo-700 hover:bg-indigo-800 text-white text-xs px-3 py-1 rounded-lg font-bold flex items-center gap-1.5 transition-colors shadow-sm",children:[e.jsx(pt,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Search Web / Wikipedia"})]})]}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("input",{type:"text",value:l.heroImage,onChange:t=>D({...l,heroImage:t.target.value}),placeholder:"https://upload.wikimedia.org/... or /uploads/history/...",className:"w-full px-3 py-2 border border-slate-300 rounded-lg text-sm focus:outline-none focus:border-amber-600"}),l.heroImage&&e.jsx("img",{src:l.heroImage||void 0,alt:"Preview",referrerPolicy:"no-referrer",className:"w-12 h-10 rounded object-cover border border-slate-300 shrink-0"})]}),e.jsxs("div",{className:"flex items-center gap-2 overflow-x-auto pb-1",children:[e.jsx("span",{className:"text-xs font-bold text-slate-400 shrink-0",children:"Presets:"}),z.map((t,s)=>e.jsx("button",{type:"button",onClick:()=>D({...l,heroImage:t.url}),className:`text-[11px] px-2.5 py-1 rounded border font-medium shrink-0 transition-colors ${l.heroImage===t.url?"bg-amber-800 text-white border-amber-900":"bg-slate-100 dar
63k:bg-slate-800 text-slate-700 dark:text-slate-300 border-slate-200 dark:border-slate-700 hover:bg-slate-200"}`,children:t.label},s))]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("label",{className:"block text-xs font-bold uppercase text-slate-700 dark:text-slate-300",children:"Summary / Concise Lead *"}),e.jsxs("button",{type:"button",disabled:!!k||!l.title&&!l.content,onClick:()=>W("history_summary"),className:"text-[11px] font-bold text-amber-800 dark:text-amber-300 hover:underline flex items-center gap-1 disabled:opacity-50",title:"Generate or polish a concise 1-2 sentence lead summary with Gemini AI",children:[k==="history_summary"?e.jsx(S,{className:"w-3 h-3 animate-spin"}):e.jsx($,{className:"w-3 h-3"}),e.jsx("span",{children:"AI Generate Lead"})]})]}),e.jsx("textarea",{rows:2,required:!0,value:l.summary,onChange:t=>D({...l,summary:t.target.value}),placeholder:"Key summary of what transpired on this historical day...",className:"w-full px-3 py-2 border border-slate-300 rounded-lg text-sm focus:outline-none focus:border-amber-600"})]}),e.jsxs("div",{className:"border border-slate-300 rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"bg-slate-100 dark:bg-slate-800 px-4 py-2 border-b border-slate-200 dark:border-slate-700 flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>Nt("write"),className:`px-3 py-1 rounded text-xs font-bold transition-colors ${wt==="write"?"bg-white dark:bg-slate-800 text-amber-900 shadow-sm":"text-slate-600 dark:text-slate-400 hover:text-slate-900 dark:text-slate-100"}`,children:"âï¸ Edit Archival Text"}),e.jsx("button",{type:"button",onClick:()=>Nt("preview"),className:`px-3 py-1 rounded text-xs font-bold transition-colors ${wt==="preview"?"bg-white dark:bg-slate-800 text-amber-900 shadow-sm":"text-slate-600 dark:text-slate-400 hover:text-slate-900 dark:text-slate-100"}`,children:"ðï¸ Archival Preview"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsxs("button",{type:"button",disabled:!!k||!l.title&&!l.content,onClick:()=>W("history_expand"),className:"bg-amber-100 dark:bg-amber-950/60 hover:bg-amber-200 text-amber-900 dark:text-amber-200 border border-amber-300 dark:border-amber-700 px-2 py-1 rounded text-xs font-bold transition-colors flex items-center gap-1 disabled:opacity-50",title:"Use Gemini AI to automatically expand draft notes into a structured historical document",children:[k==="history_expand"?e.jsx(S,{className:"w-3 h-3 animate-spin text-amber-700"}):e.jsx($,{className:"w-3 h-3 text-amber-600"}),e.jsx("span",{children:"AI Expand"})]}),e.jsxs("button",{type:"button",disabled:!!k||!l.content,onClick:()=>W("history_proofread"),className:"bg-indigo-50 dark:bg-indigo-950/50 hover:bg-indigo-100 text-indigo-900 dark:text-indigo-200 border border-indigo-300 dark:border-indigo-700 px-2 py-1 rounded text-xs font-bold transition-colors flex items-center gap-1 disabled:opacity-50",title:"Proofread grammar, dates, academic formatting, and terminology",children:[k==="history_proofread"?e.jsx(S,{className:"w-3 h-3 animate-spin text-indigo-700"}):e.jsx(ut,{className:"w-3 h-3 text-indigo-600"}),e.jsx("span",{children:"AI Proofread"})]}),e.jsxs("button",{type:"button",disabled:!!k||!l.title&&!l.content,onClick:()=>W("history_citations"),className:"bg-white dark:bg-slate-800 hover:bg-slate-50 text-slate-700 dark:text-slate-300 border border-slate-300 dark:border-slate-700 px-2 py-1 rounded text-xs font-medium transition-colors flex items-center gap-1 disabled:opacity-50",title:"Generate APA, MLA, Chicago, and BibTeX academic citations",children:[k==="history_citations"?e.jsx(S,{className:"w-3 h-3 animate-spin"}):e.jsx(Bt,{className:"w-3 h-3 text-slate-500"}),e.jsx("span",{children:"+ Citations"})]}),e.jsxs("button",{type:"button",disabled:!!k||!l.title&&!l.content,onClick:()=>W("history_key_facts"),className:"bg-white dark:bg-slate-800 hover:bg-slate-50 text-slate-700 dark:text-slate-300 border border-slate-300 dark:border-slate-700 px-2 py-1 rounded text-xs font-medium transition-colors flex items-center gap-1 disabled:opacity-50",title:"Extract Key Facts callout table",children:[k==="history_key_facts"?e.jsx(S,{className:"w-3 h-3 animate-spin"}):e.jsx(Ut,{className:"w-3 h-3 text-emerald-600"}),e.jsx("span",{children:"+ Key Facts"})]})]}),wt==="write"&&e.jsxs("div",{className:"flex items-center gap-1 border-l border-slate-300 pl-2",children:[e.jsx("button",{type:"button",onClick:()=>De("bold"),className:"px-2 py-0.5 text-xs font-bold bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded hover:bg-slate-50 dark:bg-slate-900",title:"Bold",children:"B"}),e.jsx("button",{type:"button",onClick:()=>De("italic"),className:"px-2 py-0.5 text-xs italic font-serif bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded hover:bg-slate-50 dark:bg-slate-900",title:"Italic",children:"I"}),e.jsx("button",{type:"button",onClick:()=>De("h2"),className:"px-2 py-0.5 text-xs font-bold bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded hover:bg-slate-50 dark:bg-slate-900",children:"H2"}),e.jsx("button",{type:"button",onClick:()=>De("h3"),className:"px-2 py-0.5 text-xs font-bold bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded hover:bg-slate-50 dark:bg-slate-900",children:"H3"}),e.jsx("button",{type:"button",onClick:()=>De("quote"),className:"px-2 py-0.5 text-xs font-serif bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded hover:bg-slate-50 dark:bg-slate-900",children:"â Decree"}),e.jsx("button",{type:"button",onClick:()=>De("bullet"),className:"px-2 py-0.5 text-xs bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded hover:bg-slate-50 dark:bg-slate-900",children:"⢠List"}),e.jsx("button",{type:"button",onClick:()=>
63De("link"),className:"px-2 py-0.5 text-xs bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded hover:bg-slate-50 dark:bg-slate-900",children:"ð Citation"})]})]}),wt==="write"?e.jsx("textarea",{rows:8,value:l.content,onChange:t=>D({...l,content:t.target.value}),placeholder:"Write detailed historical background, treaties, imperial speeches...",className:"w-full p-4 text-sm font-sans focus:outline-none focus:bg-amber-50/10"}):e.jsxs("div",{className:"p-6 bg-amber-50/30 min-h-[220px] space-y-4",children:[l.heroImage&&e.jsx("img",{src:l.heroImage||void 0,alt:"",referrerPolicy:"no-referrer",className:"w-full aspect-video object-cover rounded-lg mb-4 border border-amber-200 shadow-sm"}),e.jsxs("div",{className:"flex items-center gap-2 text-xs font-bold text-amber-900 bg-amber-100 px-3 py-1 rounded w-fit",children:[e.jsxs("span",{children:["ð
",l.ethiopianDate||"Unknown Date"]}),l.gregorianDate&&e.jsxs("span",{children:["(",new Date(l.gregorianDate).toLocaleDateString(),")"]})]}),e.jsx("h1",{className:"text-2xl font-serif font-bold text-slate-900 dark:text-slate-100",children:l.title||"Untitled Historical Event"}),l.summary&&e.jsx("p",{className:"text-sm italic text-slate-700 dark:text-slate-300 border-l-3 border-amber-800 pl-3 py-1 font-serif bg-white dark:bg-slate-800/60 p-2 rounded",children:l.summary}),e.jsx("div",{className:"prose max-w-none text-sm text-slate-800 dark:text-slate-200 space-y-3 font-serif leading-relaxed whitespace-pre-wrap",children:l.content||e.jsx("span",{className:"text-slate-400 italic font-sans",children:'No detailed content entered. Switch back to "Edit Archival Text" tab.'})})]})]}),e.jsxs("div",{className:"flex justify-between items-center pt-4 border-t border-slate-200 dark:border-slate-700",children:[e.jsxs("span",{className:"text-xs text-slate-500 dark:text-slate-400 font-mono",children:[l.content.length," characters ⢠",os," words"]}),e.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[e.jsx("button",{type:"button",disabled:Et||!l.title,onClick:Ya,className:"px-4 py-2 bg-emerald-800 hover:bg-emerald-900 text-white rounded-lg text-xs font-bold uppercase tracking-wider disabled:opacity-50 transition-colors shadow-sm flex items-center gap-1.5",title:"Enhance event with AI and publish it directly as a historical article",children:Et?e.jsxs(e.Fragment,{children:[e.jsx(S,{className:"w-3.5 h-3.5 animate-spin"}),e.jsx("span",{children:"Publishing Article..."})]}):e.jsxs(e.Fragment,{children:[e.jsx($,{className:"w-3.5 h-3.5 text-emerald-300"}),e.jsx("span",{children:"Enhance & Publish Article"})]})}),e.jsx("button",{type:"button",onClick:()=>Ze(!1),className:"px-4 py-2 border border-slate-300 rounded-lg text-xs font-bold text-slate-600 dark:text-slate-400 hover:bg-slate-50 dark:bg-slate-900",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:Ca,className:"px-6 py-2.5 bg-emerald-800 hover:bg-emerald-700 text-white rounded-lg text-xs font-bold uppercase tracking-wider disabled:opacity-50 transition-all shadow-md flex items-center gap-1.5 border border-emerald-600",children:Ca?e.jsxs(e.Fragment,{children:[e.jsx(S,{className:"w-3.5 h-3.5 animate-spin"}),e.jsx("span",{children:"Saving to Firestore..."})]}):V?e.jsxs(e.Fragment,{children:[e.jsx(Wr,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Update Archival Record"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ye,{className:"w-3.5 h-3.5 text-emerald-200"}),e.jsx("span",{children:"Create Historical Entry"})]})})]})]})]})]})}),Ms&&e.jsx("div",{className:"fixed inset-0 bg-slate-900/70 backdrop-blur-sm flex items-center justify-center p-4 z-50 overflow-y-auto",children:e.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-2xl shadow-2xl max-w-5xl w-full p-6 my-8 space-y-6 max-h-[92vh] overflow-y-auto border border-slate-200 dark:border-slate-700",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between pb-4 border-b border-slate-200 dark:border-slate-700 gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-[10px] font-bold uppercase tracking-widest text-emerald-900 bg-emerald-100 px-2.5 py-0.5 rounded border border-emerald-200 flex items-center gap-1",children:[e.jsx(Je,{className:"w-3 h-3"}
63)," Batch Ingestion Engine"]}),e.jsx("span",{className:"text-xs text-slate-500 dark:text-slate-400 font-mono",children:"Today in Ethiopian History"})]}),e.jsx("h2",{className:"text-2xl font-serif font-black text-slate-900 dark:text-slate-100 mt-1",children:"Import Historical Records (CSV / JSON)"})]}),e.jsx("button",{onClick:()=>$e(!1),className:"text-slate-400 hover:text-slate-600 dark:text-slate-400 p-2 text-xl font-bold self-end sm:self-auto rounded-lg hover:bg-slate-100 dark:bg-slate-800",children:"â"})]}),e.jsxs("div",{className:"bg-slate-50 dark:bg-slate-900 p-4 rounded-xl border border-slate-200 dark:border-slate-700 space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-bold uppercase text-slate-600 dark:text-slate-400",children:"Format:"}),e.jsxs("div",{className:"flex bg-white dark:bg-slate-800 p-1 rounded-lg border border-slate-200 dark:border-slate-700 text-xs font-bold",children:[e.jsxs("button",{type:"button",onClick:()=>{vt("csv"),Me&&it(Me,"csv")},className:`px-3 py-1.5 rounded-md transition-colors flex items-center gap-1.5 ${X==="csv"?"bg-emerald-800 text-white shadow-sm":"text-slate-600 dark:text-slate-400 hover:text-slate-900 dark:text-slate-100"}`,children:[e.jsx(Gr,{className:"w-4 h-4"}),e.jsx("span",{children:"CSV Format"})]}),e.jsxs("button",{type:"button",onClick:()=>{vt("json"),Me&&it(Me,"json")},className:`px-3 py-1.5 rounded-md transition-colors flex items-center gap-1.5 ${X==="json"?"bg-emerald-800 text-white shadow-sm":"text-slate-600 dark:text-slate-400 hover:text-slate-900 dark:text-slate-100"}`,children:[e.jsx(zr,{className:"w-4 h-4"}),e.jsx("span",{children:"JSON Format"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-bold uppercase text-slate-600 dark:text-slate-400",children:"Source:"}),e.jsxs("div",{className:"flex bg-white dark:bg-slate-800 p-1 rounded-lg border border-slate-200 dark:border-slate-700 text-xs font-bold",children:[e.jsxs("button",{type:"button",onClick:()=>ya("file"),className:`px-3 py-1.5 rounded-md transition-colors flex items-center gap-1.5 ${kt==="file"?"bg-slate-800 text-white shadow-sm":"text-slate-600 dark:text-slate-400 hover:text-slate-900 dark:text-slate-100"}`,children:[e.jsx(Je,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Upload File"})]}),e.jsxs("button",{type:"button",onClick:()=>ya("paste"),className:`px-3 py-1.5 rounded-md transition-colors flex items-center gap-1.5 ${kt==="paste"?"bg-slate-800 text-white shadow-sm":"text-slate-600 dark:text-slate-400 hover:text-slate-900 dark:text-slate-100"}`,children:[e.jsx(Bt,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Paste Raw Text"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsxs("button",{type:"button",onClick:rr,className:"bg-amber-100 hover:bg-amber-200 text-amber-900 px-3 py-1.5 rounded-lg text-xs font-bold transition-colors flex items-center gap-1.5 border border-amber-300",children:[e.jsx($,{className:"w-3.5 h-3.5 text-amber-800"}),e.jsx("span",{children:"Load Ethiopian History Sample"})]}),e.jsxs("button",{type:"button",onClick:lr,className:"bg-white dark:bg-slate-800 hover:bg-slate-100 dark:bg-slate-800 text-slate-700 dark:text-slate-300 px-3 py-1.5 rounded-lg text-xs font-bold transition-colors flex items-center gap-1.5 border border-slate-300",children:[e.jsx(Er,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Template"})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-slate-800 p-3 rounded-xl border border-slate-200 dark:border-slate-700 flex flex-wrap items-center justify-between gap-3 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{className:"font-bold text-slate-700 dark:text-slate-300 flex items-center gap-1.5",children:[e.jsx(Ve,{className:"w-3.5 h-3.5 text-emerald-800"}),"Speed Engine:"]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[e.jsx("input",{type:"checkbox",checked:Na,onChange:t=>Ls(t.target.checked),className:"rounded text-emerald-600 focus:ring-emerald-500 w-4 h-4"}),e.jsxs("span",{className:"text-slate-700 dark:text-slate-300 font-medium",children:["Enable Wikipedia Image Lookup ",e.jsx("span",{className:"text-slate-400 text-[10px]",children:"(2s timeout fallback)"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 font-bold text-slate-700 dark:text-slate-300",children:[e.jsx("span",{children:"Parallel Workers:"}),e.jsxs("select",{value:va,onChange:t=>Rs(Number(t.target.value)),className:"px-2 py-1 bg-slate-50 dark:bg-slate-900 border border-slate-300 rounded font-mono text-xs focus:outline-none",children:[e.jsx("option",{value:4,children:"4 Concurrent Workers"}),e.jsx("option",{value:8,children:"8 Concurrent Workers (Fast)"}),e.jsx("option",{value:16,children:"16 Concurrent Workers (Ultra)"})]})]})]}),kt==="file"&&e.jsxs("div",{children:[e.jsx("input",{type:"file",ref:wa,onChange:t=>{t.target.files&&t.target.files[0]&&(Qa(t.target.files[0]),t.target.value="")},accept:".csv, .json, text/csv, application/json",className:"hidden"}),e.jsx("div",{onDragEnter:t=>{t.preventDefault(),St(!0)},onDragOver:t=>{t.preventDefault(),St(!0)},onDragLeave:t=>{t.preventDefault(),St(!1)},onDrop:t=>{t.preventDefault(),St(!1),t.dataTransfer.files&&t.dataTransfer.files[0]&&Qa(t.dataTransfer.files[0])},onClick:()=>{var t;return(t=wa.current)==null?void 0:t.click()},className:`border-2 border-dashed rounded-xl p-6 text-center cursor-pointer transition-all ${Fs?"border-emerald-600 bg-emerald-50 scale-[1.01]":"border-slate-300 bg-white dark:bg-slate-800 hover:border-emerald-500 hover:bg-slate-50 dark:bg-slate-900"}`,children:e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-2",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-emerald-100 text-emerald-800 flex items-center justify-center",children:e.jsx(Je,{className:"w-6 h-6"})}),e.jsxs("div",{className:"text-sm font-bold text-slate-800 dark:text-slate-200",children:["Click to select or drag & drop your ",X.toUpperCase()," file here"]}),e.jsxs("div",{className:"text-xs text-slate-500 dark:text-slate-400",children:["Supports ",e.jsx("span",{className:"font-mono font-bold text-slate-700 dark:text-slate-300",children:".csv"})," and ",e.jsx("span",{className:"font-mono font-bold text-slate-700 dark:text-slate-300",children:".json"})," files containing fields: ",e.jsx("span",{className:"font-mono text-emerald-800",children:"title, ethiopianDate, gregorianDate, summary, content, era"})]})]})})]}),kt==="paste"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs font-bold text-slate-700 dark:text-slate-300",children:[e.jsxs("span",{children:["Paste Raw ",X.toUpperCase()," Code or
63Content"]}),e.jsxs("span",{className:"text-slate-400 font-mono",children:[Me.length," characters"]})]}),e.jsx("textarea",{rows:6,value:Me,onChange:t=>sr(t.target.value),placeholder:X==="csv"?`title,ethiopianDate,gregorianDate,summary,content,era 64"Battle of Adwa","Yekatit 23, 1888 EC","1896-03-01","Victory over colonial forces"...`:`[ 65 { 66 "title": "Battle of Adwa", 67 "ethiopianDate": "Yekatit 23, 1888 EC", 68 "summary": "..." 69 } 70]`,className:"w-full p-3 font-mono text-xs bg-white dark:bg-slate-800 border border-slate-300 rounded-lg focus:outline-none focus:border-emerald-600"})]})]}),q.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 bg-slate-100 dark:bg-slate-800 p-3 rounded-xl border border-slate-200 dark:border-slate-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-xs font-bold text-slate-800 dark:text-slate-200",children:["Parsed Records (",q.length,")"]}),e.jsxs("span",{className:"text-xs bg-emerald-100 text-emerald-800 font-bold px-2 py-0.5 rounded-full flex items-center gap-1",children:[e.jsx(_t,{className:"w-3.5 h-3.5"}),q.filter(t=>t.isValid).length," Valid"]}),q.some(t=>!t.isValid)&&e.jsxs("span",{className:"text-xs bg-rose-100 text-rose-800 font-bold px-2 py-0.5 rounded-full flex items-center gap-1",children:[e.jsx(Es,{className:"w-3.5 h-3.5"}),q.filter(t=>!t.isValid).length," Invalid"]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs font-bold",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-slate-600 dark:text-slate-400",children:"Default Status:"}),e.jsxs("select",{value:Kt,onChange:t=>Ps(t.target.value),className:"px-2 py-1 bg-white dark:bg-slate-800 border border-slate-300 rounded text-xs font-bold focus:outline-none",children:[e.jsx("option",{value:"published",children:"Published (Live)"}),e.jsx("option",{value:"draft",children:"Draft (Private)"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 border-l border-slate-300 pl-3",children:[e.jsx("button",{type:"button",onClick:()=>la(!0),className:"text-emerald-700 hover:underline",children:"Select All Valid"}),e.jsx("span",{className:"text-slate-300",children:"|"}),e.jsx("button",{type:"button",onClick:()=>la(!1),className:"text-slate-600 dark:text-slate-400 hover:underline",children:"Deselect All"}),e.jsx("span",{className:"text-slate-300",children:"|"}),e.jsxs("button",{type:"button",onClick:()=>{fe(t=>t.map(s=>({...s,selected:s.isValid&&!(s.duplicateMatch&&s.duplicateMatch.combinedSimilarity>=55)})))},className:"text-amber-800 hover:underline font-bold flex items-center gap-1",children:[e.jsx(ba,{className:"w-3 h-3 text-amber-600"}),"Deselect High Duplicates"]})]})]})]}),e.jsxs("div",{className:"border border-slate-200 dark:border-slate-700 rounded-xl overflow-hidden max-h-64 overflow-y-auto bg-white dark:bg-slate-800",children:[q.filter(t=>t.selected).length===0&&q.length>0&&e.jsxs("div",{className:"bg-amber-50 text-amber-800 p-3 text-center border-b border-amber-200 text-xs font-bold flex items-center justify-center gap-2",children:[e.jsx(ba,{className:"w-4 h-4"}),"0 records selected. They may have been automatically deselected due to being high-confidence duplicates of existing database records. You can manually check the boxes below to force import them."]}),e.jsxs("table",{className:"min-w-full divide-y divide-slate-200 text-xs",children:[e.jsx("thead",{className:"bg-slate-100 dark:bg-slate-800 sticky top-0 font-bold text-slate-700 dark:text-slate-300 uppercase",children:e.jsxs("tr",{children:[e.jsx("th",{className:"p-3 text-center w-10",children:e.jsx("input",{type:"checkbox",checked:q.length>0&&q.every(t=>t.selected||!t.isValid),onChange:t=>la(t.target.checked),className:"rounded text-emerald-600 focus:ring-emerald-500"})}),e.jsx("th",{className:"p-3 text-left",children:"Title"}),e.jsx("th",{className:"p-3 text-left",children:"Ethiopian Date"}),e.jsx("th",{className:"p-3 text-left",children:"Gregorian Equivalent"}),e.jsx("th",{className:"p-3 text-left",children:"Era"}),e.jsx("th",{className:"p-3 text-left",children:"Summary / Excerpt"}),e.jsx("th",{className:"p-3 text-center",children:"Validation"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-200 bg-white dark:bg-slate-800",children:q.map(t=>e.jsxs("tr",{className:`hover:bg-slate-50 dark:bg-slate-900 transition-colors ${t.isValid?t.selected?"bg-emerald-50/30":"":"bg-rose-50/40"}`,children:[e.jsx("td",{className:"p-3 text-center",children:e.jsx("input",{type:"checkbox",disabled:!t.isValid,checked:t.selected,onChange:()=>nr(t.id),className:"rounded text-emerald-600 focus:ring-emerald-500"})}),e.jsxs("td",{className:"p-3 font-serif font-bold text-slate-900 dark:text-slate-100 max-w-xs",children:[e.jsx("div",{className:"truncate",children:t.title||e.jsx("span",{className:"text-rose-500 italic",children:"[Missing]"})}),t.duplicateMatch&&e.jsxs("div",{className:"text-[10px] font-mono text-amber-800 flex items-center gap-1 mt-0.5 font-sans",children:[e.jsxs("span",{children:["â ï¸ ",t.duplicateMatch.combinedSimilarity,"% match:"]}),e.jsx("span",{className:"italic truncate max-w-[160px]",children:t.duplicateMatch.item.title})]})]}),e.jsx("td",{className:"p-3 font-bold text-amber-900 whitespace-nowrap font-serif",children:t.ethiopianDate||e.jsx("span",{className:"text-rose-500 italic",children:"[Missing]"})}
70),e.jsx("td",{className:"p-3 text-slate-600 dark:text-slate-400 font-mono whitespace-nowrap",children:t.gregorianDate}),e.jsx("td",{className:"p-3 text-slate-700 dark:text-slate-300 capitalize font-medium",children:t.era}),e.jsx("td",{className:"p-3 text-slate-500 dark:text-slate-400 max-w-xs truncate",children:t.summary}),e.jsx("td",{className:"p-3 text-center whitespace-nowrap",children:t.isValid?e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-bold bg-emerald-100 text-emerald-800",children:[e.jsx(Ut,{className:"w-3 h-3"})," Ready"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-bold bg-rose-100 text-rose-800",children:[e.jsx(Es,{className:"w-3 h-3"})," ",t.errorMsg]})})]},t.id))})]})]})]}),et&&ke&&e.jsxs("div",{className:"bg-emerald-950 text-white p-4 rounded-xl shadow-lg space-y-3 border border-emerald-800",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-2 text-xs font-bold",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{className:"w-4 h-4 animate-spin text-emerald-400"}),e.jsx("span",{className:"text-emerald-100 font-mono",children:tt.stepLabel||"Ingesting records into Ethiopian History Database..."})]}),e.jsxs("div",{className:"flex items-center gap-3 text-emerald-300 font-mono text-[11px]",children:[tt.rate>0&&e.jsxs("span",{children:["â¡ ",tt.rate," items/sec"]}),tt.eta>0&&e.jsxs("span",{children:["â±ï¸ ~",tt.eta,"s ETA"]}),e.jsxs("span",{className:"bg-emerald-900 px-2.5 py-1 rounded text-white font-bold",children:[ke.current," / ",ke.total]})]})]}),e.jsx("div",{className:"w-full bg-emerald-900 h-3 rounded-full overflow-hidden p-0.5 border border-emerald-800",children:e.jsx("div",{className:"bg-gradient-to-r from-emerald-500 to-teal-300 h-full rounded-full transition-all duration-200",style:{width:`${Math.round(ke.current/ke.total*100)}%`}})}),e.jsxs("div",{className:"flex items-center justify-between text-[11px] text-emerald-200/80 pt-1",children:[e.jsxs("span",{children:["Success: ",e.jsx("strong",{className:"text-emerald-300",children:ke.success})," ⢠Failed: ",e.jsx("strong",{className:"text-rose-300",children:ke.fail})]}),e.jsxs("button",{type:"button",onClick:ir,className:"text-rose-300 hover:text-white bg-rose-900/60 hover:bg-rose-900 px-2.5 py-1 rounded border border-rose-700/50 font-bold transition-colors flex items-center gap-1",children:[e.jsx(ve,{className:"w-3 h-3"})," Stop / Abort Ingestion"]})]})]}),Ce&&!et&&e.jsxs("div",{className:"bg-emerald-50 p-4 rounded-xl border border-emerald-200 flex flex-col sm:flex-row sm:items-center justify-between gap-3 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-full bg-emerald-100 text-emerald-800 flex items-center justify-center font-bold",children:"â"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-bold text-emerald-950 text-sm",children:"Batch Ingestion Complete"}),e.jsxs("p",{className:"text-emerald-800 text-xs",children:["Successfully ingested ",e.jsx("strong",{children:Ce.success})," records in ",e.jsxs("strong",{children:[Ce.elapsedSec,"s"]})," (avg ",e.jsx("strong",{children:(Ce.success/Math.max(Ce.elapsedSec,.1)).toFixed(1)})," records/sec).",Ce.fail>0&&e.jsxs("span",{className:"text-rose-600 font-bold ml-2",children:["(",Ce.fail," failed)"]})]})]})]}),e.jsx("button",{type:"button",onClick:()=>$e(!1),className:"px-4 py-2 bg-emerald-800 hover:bg-emerald-900 text-white font-bold rounded-lg self-end sm:self-auto",children:"Close Modal"})]}),e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-slate-200 dark:border-slate-700",children:[e.jsxs("div",{className:"text-xs text-slate-500 dark:text-slate-400",children:[q.filter(t=>t.selected&&t.isValid).length," historical events selected for batch creation."]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>$e(!1),disabled:et,className:"px-4 py-2 border border-slate-300 rounded-lg text-xs font-bold text-slate-600 dar
70k:text-slate-400 hover:bg-slate-50 dark:bg-slate-900",children:"Close"}),e.jsx("button",{type:"button",disabled:et||q.filter(t=>t.selected&&t.isValid).length===0,onClick:or,className:"px-6 py-2.5 bg-emerald-800 hover:bg-emerald-900 text-white rounded-lg text-xs font-bold uppercase tracking-wider disabled:opacity-50 transition-colors shadow flex items-center gap-2",children:et?e.jsxs(e.Fragment,{children:[e.jsx(S,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{children:"Ingesting..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(Je,{className:"w-4 h-4"}),e.jsxs("span",{children:["Import ",q.filter(t=>t.selected&&t.isValid).length," Records"]})]})})]})]})]})}),Os&&e.jsx("div",{className:"fixed inset-0 bg-slate-900/75 backdrop-blur-sm flex items-center justify-center p-4 z-50 overflow-y-auto",children:e.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-2xl shadow-2xl max-w-4xl w-full p-6 my-8 space-y-5 border border-slate-200 dark:border-slate-700",children:[e.jsxs("div",{className:"flex items-center justify-between pb-4 border-b border-slate-200 dark:border-slate-700",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"p-2 bg-indigo-100 text-indigo-800 rounded-lg",children:e.jsx(Te,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-serif font-bold text-slate-900 dark:text-slate-100",children:"Search Internet & Wikipedia Images"}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:Se?`Target Post: "${Se.title}"`:"Select an authentic historical photo or artifact for this record"})]})]}),e.jsx("button",{onClick:()=>Dt(!1),className:"text-slate-400 hover:text-slate-600 dark:text-slate-400 p-1.5 rounded-lg hover:bg-slate-100 dark:bg-slate-800 font-bold",children:"â"})]}),e.jsxs("form",{onSubmit:t=>{t.preventDefault(),sa(It)},className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(pt,{className:"w-4 h-4 text-slate-400 absolute left-3 top-3"}),e.jsx("input",{type:"text",value:It,onChange:t=>Yt(t.target.value),placeholder:"e.g. Victory of Adwa, Emperor Menelik, Lalibela Churches...",className:"w-full pl-9 pr-4 py-2 bg-slate-50 dark:bg-slate-900 border border-slate-300 rounded-xl text-sm font-semibold focus:outline-none focus:border-indigo-600 focus:bg-white dark:bg-slate-800"})]}),e.jsxs("button",{type:"submit",disabled:Qt||!It.trim(),className:"px-5 py-2 bg-indigo-700 hover:bg-indigo-800 text-white rounded-xl text-xs font-bold uppercase tracking-wider flex items-center gap-1.5 transition-colors disabled:opacity-50",children:[Qt?e.jsx(S,{className:"w-4 h-4 animate-spin"}):e.jsx(pt,{className:"w-4 h-4"}),e.jsx("span",{children:"Search"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5 items-center bg-slate-50 dark:bg-slate-900 p-2.5 rounded-xl border border-slate-200 dark:border-slate-700 text-xs",children:[e.jsx("span",{className:"font-bold text-slate-700 dark:text-slate-300 text-[11px] uppercase tracking-wider font-mono mr-1",children:"ðï¸ Historical Topics:"}),Gs.map((t,s)=>e.jsx("button",{type:"button",onClick:()=>{Yt(t),sa(t)},className:"px-2.5 py-1 bg-white dark:bg-slate-800 hover:bg-indigo-50 hover:text-indigo-700 border border-slate-200 dark:border-slate-700 rounded-lg text-slate-700 dark:text-slate-300 text-[11px] font-medium transition-colors shadow-2xs",children:t},s))]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-slate-200 dark:border-slate-700 pb-2",children:[e.jsx("div",{className:"flex items-center gap-1",children:[{id:"all",label:"All Sources"},{id:"wikipedia_en",label:"Wikipedia (EN)"},{id:"wikipedia_am",label:"Wikipedia (á ááá)"},{id:"commons",label:"Wikimedia Commons"},{id:"web",label:"Open Web CC"}].map(t=>e.jsx("button",{type:"button",onClick:()=>_s(t.id),className:`px-3 py-1 rounded-lg text-xs font-bold transition-all ${Pe===t.id?"bg-indigo-700 text-white shadow-xs":"text-slate-600 dark:text-slate-400 hover:bg-slate-100 dark:bg-slate-800"}`,children:t.label},t.id))}),e.jsxs("div",{className:"text-[11px] font-mono text-emerald-800 bg-emerald-50 px-2.5 py-1 rounded border border-emerald-200 font-bold flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-500 animate-pulse"}),"Payton Python 2.0 Ingest Engine Active"]})]}),e.jsx("div",{className:"min-h-[280px] max-h-[50vh] overflow-y-auto pr-1",children:Qt?e.jsxs("div",{className:"py-16 text-center space-y-3",children:[e.jsx(S,{className:"w-8 h-8 text-indigo-600 animate-spin mx-auto"}),e.jsx("p",{className:"text-sm font-bold text-slate-700 dark:text-slate-300 font-serif",children:"Querying English & Amharic Wikipedia APIs via Payton Engine..."}),e.jsx("p",{className:"text-xs text-slate-400",children:"Downloading high-resolution historical images & hosting locally in /uploads/history/"})]}):Aa.length===0?e.jsxs("div",{className:"py-16 text-center text-slate-500 dark:text-slate-400 font-serif space-y-2",children:[e.jsx(zt,{className:"w-10 h-10 text-slate-300 mx-auto"}),e.jsxs("p",{children:['No historical images found for "',It,'". Try selecting one of the topic chips above.']})]}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4",children:Aa.filter(t=>{var s,a,r,i;return Pe==="all"?!0:Pe==="wikipedia_en"?(s=t.source)==null?void 0:s.includes("(EN)"):Pe==="wikipedia_am"?((a=t.source)==null?void 0:a.includes("á ááá"))||t.language==="am":Pe==="commons"?(r=t.source)==null?void 0:r.includes("Commons"):Pe==="web"?(i=t.source)==null?void 0:i.includes("Web"):!0}).map((t,s)=>{var a,r;return e.jsxs("div",{className:"group bg-slate-50 dark:bg-slate-900 border border-slate-200 dark:border-slate-700 hover:border-indigo-500 rounded-xl overflow-hidden transition-all shadow-xs hover:shadow-md flex flex-col justify-between",children:[e.jsxs("div",{className:"relative aspect-video bg-slate-900 overflow-hidden cursor-pointer",onClick:()=>at(t),children:[e.jsx("img",{src:t.localUrl||t.sourceUrl||void 0,alt:t.title,referrerPolicy:"no-referrer",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}),e.jsx("span",{className:"absolute top-2 left-2 bg-slate-900/80 backdrop-blur-sm text-white text-[9px] font-mono font-bold px-2 py-0.5 rounded border border-white/20",children:t.source||"Wikipedia"}),((a=t.metadata)==null?void 0:a.qualityGrade)&&e.jsx("span",{className:"absolute bottom-2 left-2 bg-indigo-900/80 text-indigo-200 text-[9px] font-mono font-bold px-1.5 py-0.5 rounded",children:t.metadata.qualityGrade}),t.isHostedLocally&&e.jsx("span",{className:"absolute top-2 right-2 bg-emerald-800 text-white text-[9px] font-mono font-bold px-2 py-0.5 rounded shadow",children:"â Local Storage"})]}),e.jsxs("div",{className:"p-3 space-y-2 flex-1 flex flex-col justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between gap-1",children:[e.jsx("h4",{className:"text-xs font-serif font-bold text-slate-900 dark:text-slate-100 line-clamp-1",children:t.title}),e.jsx("button",{type:"button",onClick:()=>at(t),className:"text-[10px] text-slate-400 hover:text-indigo-600 font-bold shrink-0",children:"ð Zoom"})]}),t.caption&&e.jsx("p",{className:"text-[11px] text-slate-500 dark:text-slate-400 line-clamp-2 mt-0.5",children:t.caption}),((r=t.metadata)==null?void 0:r.license)&&e.jsxs("p",{className:"text-[10px] text-slate-400 font-mono mt-1",children:["ð ",t.metadata.license]})]}),e.jsxs("button",{type:"button",onClick:()=>
70Va(t),className:"w-full mt-2 py-1.5 bg-indigo-50 hover:bg-indigo-600 text-indigo-700 hover:text-white rounded-lg text-xs font-bold transition-colors flex items-center justify-center gap-1 shadow-2xs",children:[e.jsx(Ut,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Attach to Record"})]})]})]},s)})})}),e.jsxs("div",{className:"flex justify-between items-center pt-3 border-t border-slate-200 dark:border-slate-700 text-xs text-slate-500 dark:text-slate-400",children:[e.jsx("span",{children:"Powered by Python Wikipedia & Wikimedia Commons Ingest"}),e.jsx("button",{type:"button",onClick:()=>Dt(!1),className:"px-4 py-2 bg-slate-100 dark:bg-slate-800 hover:bg-slate-200 text-slate-700 dark:text-slate-300 font-bold rounded-lg",children:"Close"})]})]})}),Ks&&e.jsx("div",{className:"fixed inset-0 bg-slate-900/75 backdrop-blur-sm flex items-center justify-center p-4 z-50",children:e.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-2xl shadow-2xl max-w-lg w-full p-6 space-y-5 border border-slate-200 dark:border-slate-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2.5 bg-indigo-100 text-indigo-800 rounded-xl font-bold",children:e.jsx(Te,{className:"w-6 h-6"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-serif font-bold text-slate-900 dark:text-slate-100",children:"Auto-Enrich Historical Images"}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:"Scan database & attach authentic Wikipedia images automatically."})]})]}),e.jsxs("p",{className:"text-sm text-slate-600 dark:text-slate-400 font-sans leading-relaxed",children:["This process will execute the Python image search engine against all ",e.jsx("strong",{children:x.length})," historical records in your database, downloading authentic historical photos/paintings from Wikipedia and Wikimedia Commons to local storage."]}),Ee&&e.jsxs("div",{className:"bg-indigo-50 border border-indigo-200 p-4 rounded-xl space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-xs font-bold text-indigo-950",children:[e.jsxs("span",{className:"line-clamp-1",children:["Processing: ",Ee.title]}),e.jsxs("span",{children:[Ee.current," / ",Ee.total]})]}),e.jsx("div",{className:"w-full bg-indigo-200 h-2.5 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-indigo-600 h-full transition-all duration-300",style:{width:`${Math.round(Ee.current/Ee.total*100)}%`}})}),e.jsxs("p",{className:"text-[11px] text-indigo-800 font-medium",children:[Ee.updated," records updated with new images so far."]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 pt-3 border-t border-slate-200 dark:border-slate-700",children:[e.jsx("button",{type:"button",onClick:()=>za(!1),disabled:ta,className:"px-4 py-2 border border-slate-300 text-slate-600 dark:text-slate-400 hover:bg-slate-50 dark:bg-slate-900 rounded-lg text-xs font-bold",children:"Cancel"}),e.jsx("button",{type:"button",onClick:Vs,disabled:ta,className:"px-5 py-2 bg-indigo-800 hover:bg-indigo-900 text-white rounded-lg text-xs font-bold uppercase tracking-wider disabled:opacity-50 transition-colors shadow flex items-center gap-2",children:ta?e.jsxs(e.Fragment,{children:[e.jsx(S,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{children:"Enriching Database..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(Te,{className:"w-4 h-4"}),e.jsx("span",{children:"Start Auto-Enrichment"})]})})]})]})}),_&&e.jsx("div",{className:"fixed inset-0 bg-slate-950/85 backdrop-blur-md flex items-center justify-center p-4 z-50",children:e.jsxs("div",{className:"bg-slate-900 border border-slate-700 rounded-2xl max-w-2xl w-full p-5 text-white space-y-4 shadow-2xl",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-slate-800 pb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-mono font-bold bg-indigo-900/80 text-indigo-300 px-2 py-0.5 rounded border border-indigo-700",children:_.source||"Wikipedia"}),e.jsx("h4",{className:"text-sm font-serif font-bold text-slate-100 line-clamp-1",children:_.title})]}),e.jsx("button",{onClick:()=>at(null),className:"text-slate-400 hover:text-white font-bold p-1 hover:bg-slate-800 rounded-lg",children:"â"})]}),e.jsx("div",{className:"relative aspect-video bg-black rounded-xl overflow-hidden border border-slate-800 flex items-center justify-center",children:e.jsx("img",{src:_.localUrl||_.sourceUrl||void 0,alt:_.title,referrerPolicy:"no-referrer",className:"max-h-full max-w-full object-contain"})}),e.jsxs("div",{className:"bg-slate-850 p-3 rounded-xl border border-slate-800 space-y-2 text-xs",children:[_.caption&&e.jsx("p",{className:"text-slate-300 italic font-serif",children:_.caption}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 text-[11px] font-mono text-slate-400 pt-1 border-t border-slate-800",children:[e.jsxs("div",{children:["Quality: ",e.jsx("strong",{className:"text-white",children:((ds=_.metadata)==null?void 0:ds.qualityGrade)||"Standard"})]}),e.jsxs("div",{children:["Size: ",e.jsx("strong",{className:"text-white",children:(cs=_.metadata)!=null&&cs.width?`${_.metadata.width}x${_.metadata.height}`:"Original"})]}),e.jsxs("div",{children:["License: ",e.jsx("strong",{className:"text-white",children:((xs=_.metadata)==null?void 0:xs.license)||"Wikimedia Commons"})]}),e.jsxs("div",{children:["Hosted: ",e.jsx("strong",{className:"text-emerald-400",children:_.isHostedLocally?"Local Server":"Remote CDN"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx("a",{href:_.sourceUrl,target:"_blank",rel:"noreferrer",className:"text-xs text-indigo-400 hover:underline flex items-center gap-1 font-mono",children:"ð Original Source URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>at(null),className:"px-4 py-1.5 bg-slate-800 hover:bg-slate-700 text-slate-200 rounded-lg text-xs font-bold",children:"Close"}),e.jsxs("button",{type:"button",onClick:()=>{Va(_),at(null)},className:"px-4 py-1.5 bg-indigo-600 hover:bg-indigo-500 text-white rounded-lg text-xs font-bold flex items-center gap-1",children:[e.jsx(Ut,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Attach to Record"})]})]})]})]})}),I&&e.jsx("div",{className:"fixed inset-0 bg-slate-900/75 backdrop-blur-sm flex items-center justify-center p-4 z-50 overflow-y-auto",children:e.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-2xl shadow-2xl max-w-3xl w-full p-6 my-8 space-y-5 border border-slate-200 dark:border-slate-700 max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-start justify-between border-b border-slate-200 dark:border-slate-700 pb-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:`px-2.5 py-0.5 text-xs font-bold rounded-md border ${na(I.era).color}`,children:na(I.era).label}),e.jsx("span",{className:`px-2.5 py-0.5 text-[10px] font-bold uppercase rounded-full ${I.status==="published"?"bg-emerald-100 text-emerald-800":"bg-slate-100 dar
70k:bg-slate-800 text-slate-700 dark:text-slate-300"}`,children:I.status||"draft"})]}),e.jsx("h2",{className:"text-2xl font-serif font-bold text-slate-900 dark:text-slate-100",children:I.title})]}),e.jsx("button",{onClick:()=>pe(null),className:"text-slate-400 hover:text-slate-600 dark:text-slate-400 p-1.5 rounded-lg hover:bg-slate-100 dark:bg-slate-800 font-bold text-lg",children:"â"})]}),e.jsxs("div",{className:"bg-amber-50 p-3.5 rounded-xl border border-amber-200 flex flex-wrap items-center justify-between gap-3 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2 font-serif font-bold text-amber-950",children:[e.jsx("span",{children:"ð
Ethiopian Calendar:"}),e.jsx("span",{className:"bg-white dark:bg-slate-800 px-2.5 py-1 rounded border border-amber-300",children:Ft(I)})]}),e.jsxs("div",{className:"flex items-center gap-2 font-mono text-slate-700 dark:text-slate-300",children:[e.jsx("span",{children:"Gregorian Equivalent:"}),e.jsx("span",{className:"font-bold text-slate-900 dark:text-slate-100",children:I.gregorianDate?new Date(I.gregorianDate).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}):"N/A"})]})]}),I.heroImage?e.jsx("div",{className:"relative aspect-video rounded-xl overflow-hidden border border-slate-200 dark:border-slate-700 shadow-xs bg-slate-900",children:e.jsx("img",{src:I.heroImage||void 0,alt:I.title,referrerPolicy:"no-referrer",className:"w-full h-full object-cover"})}):e.jsx("div",{className:"p-8 bg-slate-50 dark:bg-slate-900 border border-dashed border-slate-300 rounded-xl text-center text-slate-400 text-xs",children:"No hero image attached yet. Use 1-Click Auto-Attach or Browse to add an image."}),I.summary&&e.jsxs("div",{className:"bg-slate-50 dark:bg-slate-900 p-4 rounded-xl border border-slate-200 dark:border-slate-700",children:[e.jsx("div",{className:"text-[10px] font-mono font-bold uppercase tracking-wider text-slate-400 mb-1",children:"Executive Summary"}),e.jsx("p",{className:"text-sm font-serif italic text-slate-800 dark:text-slate-200 leading-relaxed",children:I.summary})]}),I.content&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[10px] font-mono font-bold uppercase tracking-wider text-slate-400",children:"Full Historical Documentation"}),e.jsx("div",{className:"text-sm text-slate-700 dark:text-slate-300 font-serif leading-relaxed whitespace-pre-wrap bg-white dark:bg-slate-800 p-4 rounded-xl border border-slate-200 dark:border-slate-700 max-h-60 overflow-y-auto",children:I.content})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 pt-4 border-t border-slate-200 dark:border-slate-700",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>{const t=I;pe(null),qa(t)},className:"px-4 py-2 bg-slate-900 hover:bg-slate-800 text-white rounded-lg text-xs font-bold flex items-center gap-1.5 shadow-xs",children:[e.jsx(ut,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Edit Record"})]}),e.jsxs("button",{type:"button",onClick:()=>{Ga(I)},disabled:Xt===I.id,className:"px-3.5 py-2 bg-amber-100 hover:bg-amber-200 text-amber-950 border border-amber-300 rounded-lg text-xs font-bold flex items-center gap-1.5 transition-colors",children:[e.jsx(Te,{className:"w-3.5 h-3.5 text-amber-900"}),e.jsx("span",{children:"⨠Auto-Attach Image"})]}),e.jsxs("button",{type:"button",onClick:()=>{const t=I;pe(null),aa(t.title,t)},className:"px-3.5 py-2 bg-slate-100 dark:bg-slate-800 hover:bg-slate-200 text-slate-800 dark:text-slate-200 border border-slate-300 rounded-lg text-xs font-bold flex items-center gap-1.5",children:[e.jsx(zt,{className:"w-3.5 h-3.5 text-slate-700 dark:text-slate-300"}),e.jsx("span",{children:"Browse Images"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{is(I.id,I.status==="published"?"draft":"published"),pe(t=>t?{...t,status:t.status==="published"?"draft":"published"}:null)},className:"px-4 py-2 bg-emerald-50 hover:bg-emerald-100 text-emerald-900 border border-emerald-300 rounded-lg text-xs font-bold",children:I.status==="published"?"Unpublish to Draft":"Publish Record"}),e.jsx("button",{type:"button",onClick:()=>pe(null),className:"px-4 py-2 border border-slate-300 hover:bg-slate-50 dark:bg-slate-900 text-slate-700 dark:text-slate-300 rounded-lg text-xs font-bold",children:"Close"})]})]})]})}),Bs&&e.jsx("div",{className:"fixed inset-0 bg-slate-900/80 backdrop-blur-sm flex items-center justify-center p-4 z-50 overflow-y-auto",children:e.jsxs("div",{className:"bg-white dark:bg-slate-800 rounded-2xl shadow-2xl max-w-4xl w-full p-6 my-8 space-y-5 border border-slate-200 dark:border-slate-700 max-h-[92vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-start justify-between border-b border-slate-200 dark:border-slate-700 pb-4 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-3 bg-amber-100 text-amber-900 rounded-xl font-bold",children:e.jsx(gs,{className:"w-6 h-6"})}),e.jsxs("div",{children:[e.jsxs("h2",{className:"text-2xl font-serif font-bold text-slate-900 dark:text-slate-100 flex items-center gap-2",children:[e.jsx("span",{children:"Duplicate Detection & Event Enhancer"}),ue.length>0&&e.jsxs("span",{className:"text-xs bg-amber-500 text-slate-950 px-2 py-0.5 rounded-full font-mono font-bold",children:[ue.length," ",ue.length===1?"Pair":"Pairs"]})]}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-0.5",children:"Scan repository using TF-IDF cosine similarity to merge overlapping records, fill missing dates/images, and eliminate duplicates."})]})]}),e.jsx("button",{type:"button",onClick:()=>
70Zt(!1),className:"text-slate-400 hover:text-slate-600 dark:hover:text-slate-200 font-bold p-1 rounded-lg",children:"â"})]}),e.jsxs("div",{className:"bg-slate-50 dark:bg-slate-900 p-3.5 rounded-xl border border-slate-200 dark:border-slate-700 flex flex-wrap items-center justify-between gap-3 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"font-bold text-slate-600 dark:text-slate-300",children:"Similarity Sensitivity:"}),[{label:"40% Loose",val:.4},{label:"50% Medium",val:.5},{label:"65% Strict",val:.65},{label:"80% High",val:.8}].map(t=>e.jsx("button",{type:"button",onClick:()=>{Pa(t.val),$t(t.val)},className:`px-2.5 py-1 rounded-md font-mono text-[11px] font-bold transition-colors ${Le===t.val?"bg-amber-600 text-white shadow-xs":"bg-white dark:bg-slate-800 text-slate-600 dark:text-slate-300 border border-slate-200 dark:border-slate-700 hover:bg-slate-100"}`,children:t.label},t.val))]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap sm:flex-nowrap",children:[e.jsxs("button",{type:"button",onClick:()=>$t(Le),disabled:lt||nt,className:"px-3 py-1.5 bg-slate-200 dark:bg-slate-700 hover:bg-slate-300 text-slate-800 dark:text-slate-200 rounded-lg text-xs font-bold flex items-center gap-1.5 transition-colors",children:[e.jsx(S,{className:`w-3.5 h-3.5 ${lt?"animate-spin":""}`}),e.jsx("span",{children:"Re-scan Client"})]}),e.jsxs("button",{type:"button",onClick:Qs,disabled:nt||lt,className:"px-3 py-1.5 bg-indigo-600 hover:bg-indigo-700 text-white rounded-lg text-xs font-bold flex items-center gap-1.5 transition-colors shadow-xs disabled:opacity-50",title:"Run server-side database cleanup to automatically merge duplicate history records",children:[e.jsx($,{className:`w-3.5 h-3.5 ${nt?"animate-spin":""}`}),e.jsx("span",{children:nt?"Cleaning DB...":"â¡ Server Auto-Merge DB"})]}),ue.filter(t=>t.match.combinedSimilarity>=75).length>0&&e.jsxs("button",{type:"button",onClick:Ys,disabled:Ws||lt||nt,className:"px-3.5 py-1.5 bg-amber-600 hover:bg-amber-700 text-white rounded-lg text-xs font-bold flex items-center gap-1.5 transition-colors shadow-xs",children:[e.jsx($,{className:"w-3.5 h-3.5"}),e.jsxs("span",{children:["Batch Merge High Matches (",ue.filter(t=>t.match.combinedSimilarity>=75).length,")"]})]})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto space-y-4 pr-1",children:lt?e.jsxs("div",{className:"py-16 text-center space-y-3",children:[e.jsx(S,{className:"w-8 h-8 text-amber-600 animate-spin mx-auto"}),e.jsxs("p",{className:"text-sm font-serif font-bold text-slate-700 dark:text-slate-300",children:["Scanning ",x.length," historical events with Cosine Similarity..."]})]}):ue.length===0?e.jsxs("div",{className:"py-16 text-center space-y-3 bg-emerald-50/50 dark:bg-emerald-950/20 border border-emerald-200 dark:border-emerald-800/50 rounded-2xl p-6",children:[e.jsx(_t,{className:"w-12 h-12 text-emerald-600 mx-auto"}),e.jsx("h3",{className:"text-lg font-serif font-bold text-emerald-900 dark:text-emerald-200",children:"No Duplicate Historical Events Found"}),e.jsxs("p",{className:"text-xs text-emerald-700 dark:text-emerald-400 max-w-md mx-auto",children:["All ",x.length," historical records in your database appear unique at the ",Math.round(Le*100),"% similarity threshold."]}),e.jsx("button",{type:"button",onClick:()=>{Pa(.4),$t(.4)},className:"mt-2 px-4 py-2 bg-emerald-600 text-white font-bold text-xs rounded-lg hover:bg-emerald-700",children:"Try 40% Loose Sensitivity Scan"})]}):ue.map(t=>{const{primary:s,duplicate:a,match:r}=t,i=Us===t.pairId;return e.jsxs("div",{className:"bg-white dark:bg-slate-850 border border-slate-200 dark:border-slate-700 rounded-xl overflow-hidden shadow-xs space-y-3 p-4 hover:border-amber-400 transition-colors",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-slate-100 dark:border-slate-800 pb-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:`px-2.5 py-0.5 rounded-full text-xs font-bold font-mono ${r.combinedSimilarity>=80?"bg-rose-100 text-rose-800 border border-rose-300":r.combinedSimilarity>=65?"bg-amber-100 text-amber-900 border border-amber-300":"bg-indigo-100 text-indigo-800 border border-indigo-300"}`,children:["ð¥ ",r.combinedSimilarity,"% Similarity Match"]}),e.jsxs("span",{className:"text-xs text-slate-500 italic",children:["(",r.matchReason,")"]})]}),e.jsxs("span",{className:"text-[11px] font-mono text-slate-400",children:["Title: ",r.titleSimilarity,"% | Body: ",r.contentSimilarity,"%"]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 text-xs",children:[e.jsxs("div",{className:"p-3.5 bg-slate-50 dark:bg-slate-900 rounded-xl border border-slate-200 dark:border-slate-700 space-y-2 relative",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider bg-slate-200 dark:bg-slate-800 px-2 py-0.5 rounded text-slate-700 dark:text-slate-300",children:"Record A (Primary)"}),e.jsx("span",{className:`text-[10px] font-bold px-2 py-0.5 rounded ${s.status==="published"?"bg-emerald-100 text-emerald-800":"bg-slate-200 text-slate-700"}`,children:s.status||"draft"})]}),e.jsx("h4",{className:"font-serif font-bold text-slate-900 dark:text-slate-100 text-sm",children:s.title}),e.jsxs("div",{className:"space-y-1 text-[11px] text-slate-600 dar
70k:text-slate-300 font-mono",children:[e.jsxs("div",{children:["ð
Eth: ",e.jsx("strong",{className:"text-amber-900 dark:text-amber-300",children:s.ethiopianDate||"[Missing]"})]}),e.jsxs("div",{children:["ð Greg: ",s.gregorianDate||"[Missing]"]}),e.jsxs("div",{children:["ðï¸ Era: ",e.jsx("span",{className:"capitalize",children:s.era||"imperial"})]})]}),s.summary&&e.jsxs("p",{className:"text-[11px] text-slate-500 italic line-clamp-2",children:['"',s.summary,'"']}),s.heroImage&&e.jsx("div",{className:"h-16 rounded overflow-hidden bg-slate-900 border border-slate-200 dark:border-slate-700",children:e.jsx("img",{src:s.heroImage||void 0,alt:"",referrerPolicy:"no-referrer",className:"w-full h-full object-cover"})}),e.jsxs("button",{type:"button",onClick:()=>ra(t,"primary"),disabled:i,className:"w-full mt-2 py-1.5 bg-amber-600 hover:bg-amber-700 text-white font-bold rounded-lg text-xs flex items-center justify-center gap-1.5 transition-colors",children:[e.jsx($,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Merge & Enhance (Keep Record A)"})]})]}),e.jsxs("div",{className:"p-3.5 bg-amber-50/50 dark:bg-slate-900/80 rounded-xl border border-amber-200/80 dark:border-slate-700 space-y-2 relative",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider bg-amber-200 dark:bg-amber-900/60 text-amber-900 dark:text-amber-200 px-2 py-0.5 rounded",children:"Record B (Duplicate Candidate)"}),e.jsx("span",{className:`text-[10px] font-bold px-2 py-0.5 rounded ${a.status==="published"?"bg-emerald-100 text-emerald-800":"bg-slate-200 text-slate-700"}`,children:a.status||"draft"})]}),e.jsx("h4",{className:"font-serif font-bold text-slate-900 dark:text-slate-100 text-sm",children:a.title}),e.jsxs("div",{className:"space-y-1 text-[11px] text-slate-600 dark:text-slate-300 font-mono",children:[e.jsxs("div",{children:["ð
Eth: ",e.jsx("strong",{className:"text-amber-900 dark:text-amber-300",children:a.ethiopianDate||"[Missing]"})]}),e.jsxs("div",{children:["ð Greg: ",a.gregorianDate||"[Missing]"]}),e.jsxs("div",{children:["ðï¸ Era: ",e.jsx("span",{className:"capitalize",children:a.era||"imperial"})]})]}),a.summary&&e.jsxs("p",{className:"text-[11px] text-slate-500 italic line-clamp-2",children:['"',a.summary,'"']}),a.heroImage&&e.jsx("div",{className:"h-16 rounded overflow-hidden bg-slate-900 border border-slate-200 dark:border-slate-700",children:e.jsx("img",{src:a.heroImage||void 0,alt:"",referrerPolicy:"no-referrer",className:"w-full h-full object-cover"})}),e.jsxs("button",{type:"button",onClick:()=>ra(t,"duplicate"),disabled:i,className:"w-full mt-2 py-1.5 bg-slate-800 hover:bg-slate-900 text-white font-bold rounded-lg text-xs flex items-center justify-center gap-1.5 transition-colors",children:[e.jsx($,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Merge & Enhance (Keep Record B)"})]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 pt-2 border-t border-slate-100 dark:border-slate-800 text-xs",children:[e.jsx("div",{className:"text-[11px] text-slate-500",children:"ð¡ Merging will combine missing summary/body details into the kept record and delete the duplicate doc."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>qs(t),disabled:i,className:"px-3 py-1 bg-slate-100 dark:bg-slate-800 hover:bg-slate-200 text-slate-700 dark:text-slate-300 rounded font-bold text-[11px]",children:"Set Record B to Draft"}),e.jsx("button",{type:"button",onClick:()=>Js(t.pairId),disabled:i,className:"px-3 py-1 text-slate-500 hover:text-slate-800 dark:hover:text-slate-200 font-bold text-[11px]",children:"Keep Both (Not Duplicate)"})]})]})]},t.pairId)})}),e.jsxs("div",{className:"flex justify-between items-center pt-3 border-t border-slate-200 dark:border-slate-700 shrink-0 text-xs text-slate-500",children:[e.jsxs("span",{children:[ue.length," potential duplicate pair(s) detected."]}),e.jsx("button",{type:"button",onClick:()=>
70Zt(!1),className:"px-4 py-2 bg-slate-100 dark:bg-slate-800 hover:bg-slate-200 text-slate-700 dark:text-slate-300 font-bold rounded-lg",children:"Close"})]})]})}),Q.isOpen&&e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-xs z-50 flex items-center justify-center p-4 animate-in fade-in duration-150",children:e.jsxs("div",{className:"bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-800 rounded-2xl max-w-md w-full shadow-2xl p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3.5",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-rose-100 dark:bg-rose-950/60 border border-rose-200 dark:border-rose-800/60 flex items-center justify-center shrink-0 text-rose-600 dark:text-rose-400",children:e.jsx(gt,{className:"w-5 h-5"})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-base font-bold text-slate-900 dark:text-slate-100 font-serif",children:Q.type==="bulk"?`Delete ${C.size} Historical Events?`:"Delete Historical Event?"}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 leading-relaxed",children:Q.type==="bulk"?`This will permanently delete ${C.size} selected historical entries from your Firestore archive. This action cannot be reversed.`:`Are you sure you want to permanently delete "${Q.targetTitle||"this historical record"}" from Firestore?`})]})]}),Q.type==="bulk"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"text-[11px] font-bold text-slate-400 uppercase tracking-wider",children:"Selected for permanent removal:"}),e.jsxs("div",{className:"max-h-36 overflow-y-auto space-y-1 p-2.5 bg-slate-50 dark:bg-slate-950/60 rounded-xl border border-slate-200 dark:border-slate-800 text-xs text-slate-700 dark:text-slate-300",children:[x.filter(t=>C.has(t.id)).slice(0,10).map((t,s)=>e.jsxs("div",{className:"flex items-center gap-2 truncate text-[11px]",children:[e.jsxs("span",{className:"text-slate-400 font-mono font-bold w-4 shrink-0",children:[s+1,"."]}),e.jsx("span",{className:"font-semibold text-slate-800 dark:text-slate-200 truncate",children:t.title}),t.ethiopianDate&&e.jsxs("span",{className:"text-[10px] text-amber-700 dark:text-amber-400 shrink-0 font-mono",children:["(",t.ethiopianDate,")"]})]},t.id)),C.size>10&&e.jsxs("div",{className:"text-[10px] text-slate-400 italic pt-1 pl-6",children:["...and ",C.size-10," more events selected"]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2.5 pt-2 border-t border-slate-100 dark:border-slate-800",children:[e.jsx("button",{type:"button",disabled:ye,onClick:()=>mt({isOpen:!1,type:"single"}),className:"px-4 py-2 bg-slate-100 dark:bg-slate-800 hover:bg-slate-200 dark:hover:bg-slate-700 text-slate-700 dark:text-slate-300 font-bold rounded-xl text-xs transition-colors cursor-pointer",children:"Cancel"}),e.jsxs("button",{type:"button",disabled:ye,onClick:fr,className:"px-4 py-2 bg-rose-700 hover:bg-rose-600 active:bg-rose-800 text-white font-bold rounded-xl text-xs flex items-center gap-1.5 transition-colors shadow-xs cursor-pointer disabled:opacity-50",children:[ye?e.jsx(S,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(gt,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:ye?"Deleting...":Q.type==="bulk"?`Confirm Delete (${C.size})`:"Confirm Delete"})]})]})]})})]})}export{Dl as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.