1import{j as e,u as je,aQ as ve,aM as we,N as ye,aR as ae,aS as ke,aT as Ne,aU as Me,aV as Ce}from"./index-QRiPE925.js";import{r as u,k as Se,d as $e}from"./vendor-react-C2vrxknb.js";import{r as Le,s as Ae}from"./slugify-CO7LaGPz.js";import{M as De}from"./index-IFimuDji.js";const A=({onAction:s,isActive:o,disabled:w,children:C,title:d})=>e.jsx("button",{type:"button",onMouseDown:D=>{D.preventDefault(),w||s()},className:`p-1.5 rounded-md transition-colors duration-150 ${o?"bg-indigo-500/15 text-indigo-400":"text-gray-500 hover:text-gray-300 hover:bg-white/[0.04]"} ${w?"opacity-40 cursor-not-allowed":""}`,title:d,tabIndex:-1,children:C}),Z=()=>e.jsx("div",{className:"w-px h-4 bg-white/[0.06] mx-0.5"}),Be=({value:s,onChange:o,onImageUpload:w,uploadingImage:C,placeholder:d="Write your article..."})=>{const D=u.useRef(null),g=m=>{const M=D.current;if(!M)return;const a=M.selectionStart,k=M.selectionEnd,y=s.substring(a,k),p=s.substring(0,a),x=s.substring(k);let v,n,f;switch(m){case"bold":{const l=y||"bold text";v=`${p}**${l}**${x}`,n=a+2,f=a+2+l.length;break}case"italic":{const l=y||"italic text";v=`${p}*${l}*${x}`,n=a+1,f=a+1+l.length;break}case"strike":{const l=y||"strikethrough";v=`${p}~~${l}~~${x}`,n=a+2,f=a+2+l.length;break}case"h1":{const l=p.lastIndexOf(` 2`)+1,N=s.substring(0,l),B=y||s.substring(l,k)||"Heading";v=`${N}# ${B}${x}`,n=l+2,f=l+2+B.length;break}case"h2":{const l=p.lastIndexOf(` 3`)+1,N=s.substring(0,l),B=y||s.substring(l,k)||"Heading";v=`${N}## ${B}${x}`,n=l+3,f=l+3+B.length;break}case"h3":{const l=p.lastIndexOf(` 4`)+1,N=s.substring(0,l),B=y||s.substring(l,k)||"Heading";v=`${N}### ${B}${x}`,n=l+4,f=l+4+B.length;break}case"bullet":{const l=y||"list item";v=`${p}- ${l}${x}`,n=a+2,f=a+2+l.length;break}case"numbered":{const l=y||"list item";v=`${p}1. ${l}${x}`,n=a+3,f=a+3+l.length;break}case"link":{const l=y||"link text";v=`${p}[${l}](url)${x}`,n=a+l.length+3,f=a+l.length+6;break}case"quote":{const l=y||"quote";v=`${p}> ${l}${x}`,n=a+2,f=a+2+l.length;break}case"code":{const l=y||"code";v=`${p}\`${l}\`${x}`,n=a+1,f=a+1+l.length;break}case"codeblock":{const l=y||"code here";v=`${p} 5\`\`\` 6${l} 7\`\`\` 8${x}`,n=a+5,f=a+5+l.length;break}case"hr":{v=`${p} 9--- 10${x}`,n=a+5,f=a+5;break}case"align-left":case"align-center":case"align-right":{const l=m.replace("align-",""),N=p.lastIndexOf(` 11`)+1,B=s.indexOf(` 12`,k),O=B===-1?s.length:B,_=s.substring(N,O),U=_.match(/^(!\[)([^\]]*)(\]\([^)]+\))$/);if(U){let I=U[2];const S=I.match(/\|(small|medium)/),H=S?S[1]:null;I=I.replace(/\|(small|medium|left|center|right)/g,""),H&&(I+=`|${H}`),l!=="left"&&(I+=`|${l}`);const Y=`${U[1]}${I}${U[3]}`;v=s.substring(0,N)+Y+s.substring(O),n=N,f=N+Y.length}else{const I=_.replace(/^\{(center|right)\}/,""),S=l==="left"?"":`{${l}}`,H=S+I;v=s.substring(0,N)+H+s.substring(O),n=N+S.length,f=N+H.length}break}default:return}o(v),requestAnimationFrame(()=>{M.selectionStart=n,M.selectionEnd=f})},Q=()=>{if(!w)return;const m=document.createElement("input");m.type="file",m.accept="image/jpeg,image/png,image/gif,image/webp,video/mp4,video/webm,video/quicktime",m.onchange=async M=>{const a=M.target.files?.[0];if(!a)return;const k=await w(a);if(k){const y=D.current,p=y?y.selectionStart:s.length,x=s.substring(0,p),v=s.substring(p),n=``;o(`${x} 13${n} 14${v}`)}},m.click()};return e.jsxs("div",{className:"flex flex-col flex-1 min-h-0 border border-white/[0.06] rounded-xl overflow-hidden",children:[e.jsx("div",{className:"flex items-center px-2 py-1.5 border-b border-white/[0.06] flex-shrink-0",children:e.jsxs("div",{className:"flex items-center gap-0.5 flex-wrap",children:[e.jsx(A,{onAction:()=>g("bold"),title:"Bold",children:e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z"})})}),e.jsx(A,{onAction:()=>g("italic"),title:"Italic",children:e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"
14currentColor",children:e.jsx("path",{d:"M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z"})})}),e.jsx(A,{onAction:()=>g("strike"),title:"Strikethrough",children:e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M10 19h4v-3h-4v3zM5 4v3h5v3h4V7h5V4H5zM3 14h18v-2H3v2z"})})}),e.jsx(Z,{}),e.jsx(A,{onAction:()=>g("h1"),title:"Heading 1",children:e.jsx("span",{className:"flex items-center justify-center w-3.5 h-3.5 text-[11px] font-bold leading-none",children:"H1"})}),e.jsx(A,{onAction:()=>g("h2"),title:"Heading 2",children:e.jsx("span",{className:"flex items-center justify-center w-3.5 h-3.5 text-[11px] font-bold leading-none",children:"H2"})}),e.jsx(A,{onAction:()=>g("h3"),title:"Heading 3",children:e.jsx("span",{className:"flex items-center justify-center w-3.5 h-3.5 text-[11px] font-bold leading-none",children:"H3"})}),e.jsx(Z,{}),e.jsx(A,{onAction:()=>g("bullet"),title:"Bullet list",children:e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z"})})}),e.jsx(A,{onAction:()=>g("numbered"),title:"Numbered list",children:e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z"})})}),e.jsx(Z,{}),e.jsx(A,{onAction:()=>g("link"),title:"Link",children:e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"})})}),e.jsx(A,{onAction:()=>g("quote"),title:"Quote",children:e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"})})}),e.jsx(A,{onAction:()=>g("code"),title:"Inline code",children:e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"})})}),e.jsx(A,{onAction:()=>g("codeblock"),title:"Code block",children:e.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[e.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),e.jsx("path",{d:"M9 10l-2 2 2 2M15 10l2 2-2 2"})]})}),e.jsx(Z,{}),e.jsx(A,{onAction:()=>g("align-left"),title:"Align left",children:e.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"currentColor",children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"2",rx:"0.5"}),e.jsx("rect",{x:"3",y:"11",width:"12",height:"2",rx:"0.5"}),e.jsx("rect",{x:"3",y:"18",width:"15",height:"2",rx:"0.5"})]})}),e.jsx(A,{onAction:()=>g("align-center"),title:"Align center",children:e.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"currentColor",children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"2",rx:"0.5"}),e.jsx("rect",{x:"6",y:"11",width:"12",height:"2",rx:"0.5"}),e.jsx("rect",{x:"4.5",y:"18",width:"15",height:"2",rx:"0.5"})]})}),e.jsx(A,{onAction:()=>g("align-right"),title:"Align right",children:e.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"currentColor",children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"2",rx:"0.5"}),e.jsx("rect",{x:"9",y:"11",width:"12",height:"2",rx:"0.5"}),e.jsx("rect",{x:"6",y:"18",width:"15",height:"2",rx:"0.5"})]})}),e.jsx(Z,{}),e.jsx(A,{onAction:()=>g("hr"),title:"Horizontal rule",children:e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("rect",{x:"2",y:"11",width:"20",height:"2",rx:"1"})})}),e.jsx(A,{onAction:Q,disabled:C,title:"Upload image or video",children:C?e.jsxs("svg",{className:"w-3.5 h-3.5 animate-spin",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}):e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 15.75l5.159-5.159a2.25 2.25 0 013.182 0l5.159 5.159m-1.5-1.5l1.409-1.409a2.25 2.25 0 013.182 0l2.909 2.909M3.75 21h16.5A2.25 2.25 0 0022.5 18.75V5.25A2.25 2.25 0 0020.25 3H3.75A2.25 2.25 0 001.5 5.25v13.5A2.25 2.25 0 003.75 21z"})})})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto custom-scrollbar min-h-0",children:e.jsx("textarea",{ref:D,value:s,onChange:m=>o(m.target.value),className:"w-full h-full bg-transparent px-3.5 py-3 text-base sm:text-sm text-gray-300 placeholder-gray-600 focus:outline-none focus:ring-0 resize-none font-mono leading-relaxed",placeholder:d,style:{minHeight:"280px"}})})]})},ze=({value:s,onChange:o,placeholder:w="Select date & time"})=>{const C=s?new Date(s):null,[d,D]=u.useState(!1),[g,Q]=u.useState(C||new Date),[m,M]=u.useState(C),[a,k]=u.useState(C?String(C.getHours()).padStart(2,"0"):"12"),[y,p]=u.useState(C?String(C.getMinutes()).padStart(2,"0"):"00"),[x,v]=u.useState({top:0,left:0}),n=u.useRef(null),f=u.useRef(null);u.useEffect(()=>{if(!d)if(s){const r=new Date(s);M(r),k(String(r.getHours()).padStart(2,"0")),p(String(r.getMinutes()).padStart(2,"0"))}else M(null)},[s,d]),u.useEffect(()=>{const r=c=>{n.current&&!n.current.contains(c.target)&&f.current&&!f.current.contains(c.target)&&D(!1)};if(d)return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[d]),u.useEffect(()=>{if(d&&n.current){const r=n.current.getBoundingClientRect(),c=280,b=380,z=window.innerWidth,E=window.innerHeight-r.bottom<b&&r.top>b,P=z<640;let V;P?V=(z-c)/2:V=z-r.left<c?r.right-c:r.left;const J=8;V=Math.max(J,Math.min(V,z-c-J)),v({top:E?r.top-b-8:r.bottom+8,left:V,showAbove:E})}},[d]),u.useEffect(()=>{const r=c=>{d&&f.current&&!f.current.contains(c.target)&&D(!1)};if(d)return window.addEventListener("scroll",r,!0),()=>window.removeEventListener("scroll",r,!0)},[d]);const l=r=>{const c=r.getFullYear(),b=r.getMonth(),z=new Date(c,b+1,0).getDate(),q=new Date(c,b,1).getDay(),E=[];for(let P=0;P<q;P++)E.push(null);for(let P=1;P<=z;P++)E.push(new Date(c,b,P));return E},N=(r,c,b)=>{if(!r)return;const z=r.getFullYear(),q=String(r.getMonth()+1).padStart(2,"0"),E=String(r.getDate()).padStart(2,"0");o(`${z}-${q}-${E}T${c}:${b}`)},B=r=>{if(!r)return;M(r);const c=String(Math.max(0,Math.min(23,parseInt(a)||0))).padStart(2,"0"),b=String(Math.max(0,Math.min(59,parseInt(y)||0))).padStart(2,"0");N(r,c,b)},O=r=>{const c=r.replace(/\D/g,"").slice(0,2);if(k(c),m){const b=String(Math.max(0,Math.min(23,parseInt(c)||0))).padStart(2,"0"),z=String(Math.max(0,Math.min(59,parseInt(y)||0))).padStart(2,"0");N(m,b,z)}},_=()=>{const r=String(Math.max(0,Math.min(23,parseInt(a)||0))).padStart(2,"0");k(r)},U=r=>{const c=r.replace(/\D/g,"").slice(0,2);if(p(c),m){const b=String(Math.max(0,Math.min(23,parseInt(a)||0))).padStart(2,"0"),z=String(Math.max(0,Math.min(59,parseInt(c)||0))).padStart(2,"0");N(m,b,z)}},I=()=>{const r=String(Math.max(0,Math.min(59,parseInt(y)||0))).padStart(2,"0");p(r)},S=r=>{if(!r)return!1;const c=new Date;return r.getDate()===c.getDate()&&r.getMonth()===c.getMonth()&&r.getFullYear()===c.getFullYear()},H=r=>!r||!m?!1:r.getDate()===m.getDate()&&r.getMonth()===m.getMonth()&&r.getFullYear()===m.getFullYear(),Y=["January","February","March","April","May","June","July","August","September","October","November","December"],se=["Su","Mo","Tu","We","Th","Fr","Sa"],K=()=>
14{if(!m)return null;const r=String(m.getDate()).padStart(2,"0"),c=String(m.getMonth()+1).padStart(2,"0"),b=m.getFullYear();return`${r}.${c}.${b} ${a}:${y}`},G=r=>{r.stopPropagation(),M(null),k("12"),p("00"),o(""),D(!1)};return e.jsxs(e.Fragment,{children:[e.jsxs("button",{ref:n,type:"button",onClick:()=>D(!d),className:`w-full flex items-center gap-2 bg-input-bg border border-border-default/30 rounded-lg px-2.5 py-1.5 text-xs transition-colors focus:outline-none focus:border-indigo-500/50 ${m?"text-white":"text-gray-600"}`,children:[e.jsx("svg",{className:"w-3.5 h-3.5 shrink-0 text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}),e.jsx("span",{className:"flex-1 text-left truncate",children:K()||w}),m&&e.jsx("button",{onClick:G,className:"p-0.5 hover:bg-white/[0.06] rounded transition-colors shrink-0 text-gray-500 hover:text-gray-300",title:"Clear",children:e.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),d&&Se.createPortal(e.jsxs("div",{ref:f,className:"fixed z-[9999] w-[280px] rounded-xl bg-panel-bg border border-border-emphasis/50 animate-fadeIn p-3",style:{top:`${x.top}px`,left:`${x.left}
14px`,transformOrigin:x.showAbove?"bottom center":"top center"},children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("button",{type:"button",onClick:()=>Q(new Date(g.getFullYear(),g.getMonth()-1,1)),className:"p-1.5 hover:bg-input-bg rounded-lg transition-colors text-gray-400 hover:text-white",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})})}),e.jsxs("span",{className:"text-sm font-medium text-white",children:[Y[g.getMonth()]," ",g.getFullYear()]}),e.jsx("button",{type:"button",onClick:()=>Q(new Date(g.getFullYear(),g.getMonth()+1,1)),className:"p-1.5 hover:bg-input-bg rounded-lg transition-colors text-gray-400 hover:text-white",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})})]}),e.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:se.map(r=>e.jsx("div",{className:"text-center text-xs text-gray-500 font-medium py-1",children:r},r))}),e.jsx("div",{className:"grid grid-cols-7 gap-1",children:l(g).map((r,c)=>e.jsx("button",{type:"button",onClick:()=>B(r),disabled:!r,className:` 15 aspect-square flex items-center justify-center text-xs rounded-lg transition-colors 16 ${r?"hover:bg-input-bg cursor-pointer":"invisible"} 17 ${H(r)?"bg-indigo-500 text-white hover:bg-indigo-600":""} 18 ${S(r)&&!H(r)?"ring-1 ring-indigo-500/50 text-indigo-400":""} 19 ${!H(r)&&!S(r)&&r?"text-gray-300":""} 20 `,children:r?.getDate()},c))}),e.jsx("div",{className:"mt-3 pt-3 border-t border-border-emphasis/30",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[11px] text-gray-500 uppercase tracking-wider font-medium",children:"Time"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{type:"text",inputMode:"numeric",maxLength:2,value:a,onChange:r=>O(r.target.value),onBlur:_,className:"w-9 text-center bg-input-bg border border-border-default/30 rounded-lg py-1 text-xs text-white focus:outline-none focus:border-indigo-500/50 transition-colors"}),e.jsx("span",{className:"text-gray-500 text-sm font-medium",children:":"}),e.jsx("input",{type:"text",inputMode:"numeric",maxLength:2,value:y,onChange:r=>U(r.target.value),onBlur:I,className:"w-9 text-center bg-input-bg border border-border-default/30 rounded-lg py-1 text-xs text-white focus:outline-none focus:border-indigo-500/50 transition-colors"})]})]})}),e.jsxs("div",{className:"mt-3 pt-3 border-t border-border-emphasis/30 flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{const r=new Date;M(r),Q(r);const c=String(r.getHours()).padStart(2,"0"),b=String(r.getMinutes()).padStart(2,"0");k(c),p(b),N(r,c,b)},className:"flex-1 px-2 py-1.5 text-xs text-gray-300 hover:text-white hover:bg-input-bg rounded-lg transition-colors",children:"Now"}),m&&e.jsx("button",{type:"button",onClick:G,className:"flex-1 px-2 py-1.5 text-xs text-red-400 hover:text-red-300 hover:bg-red-500/10 rounded-lg transition-colors",children:"Clear"})]})]}),document.body)]})},ce=s=>{if(!s)return!1;const o=s.split("?")[0].split("#")[0].split(".").pop()?.toLowerCase();return["mp4","webm","mov"].includes(o)},ee=s=>{let o="left",w=s;const C=d=>typeof d!="string"?null:d.startsWith("{center}")?{align:"center",rest:d.slice(8)}:d.startsWith("{right}")?{align:"right",rest:d.slice(7)}:null;if(Array.isArray(s)&&s.length>0){const d=C(s[0]);d&&(o=d.align,w=d.rest?[d.rest,...s.slice(1)]:s.slice(1))}else{const d=C(s);d&&(o=d.align,w=d.rest)}return{align:o,children:w}},te=s=>s==="center"?"text-center":s==="right"?"text-right":"",He=s=>s&&s.replace(/\n{3,}/g,o=>{const w=o.length-2;return` 21 22`+`Â 23 24`.repeat(w)}),Ie={h1:({children:s})=>{const o=ee(s);return e.jsx("h1",{className:`text-base font-bold text-gray-200 mt-5 mb-2 ${te(o.align)}`,children:o.children})},h2:({children:s})=>{const o=ee(s);return e.jsx("h2",{className:`text-sm font-semibold text-gray-200 mt-4 mb-2 ${te(o.align)}`,children:o.children})},h3:({children:s})=>{const o=ee(s);return e.jsx("h3",{className:`text-sm font-semibold text-gray-300 mt-3 mb-1.5 ${te(o.align)}`,children:o.children})},p:({children:s})=>{const o=ee(s);return e.jsx("p",{className:`text-gray-400 text-sm mb-2.5 leading-relaxed ${te(o.align)}`,children:o.children})},ul:({children:s})=>e.jsx("ul",{className:"list-disc list-inside text-gray-400 text-sm mb-2.5 space-y-0.5",children:s}),ol:({children:s})=>e.jsx("ol",{className:"list-decimal list-inside text-gray-400 text-sm mb-2.5 space-y-0.5",children:s}),li:({children:s})=>e.jsx("li",{className:"text-gray-400 text-sm",children:s}),strong:({children:s})=>e.jsx("strong",{className:"text-gray-200 font-semibold",children:s}),em:({children:s})=>e.jsx("em",{className:"italic",children:s}),a:({href:s,children:o})=>e.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"text-indigo-400 hover:text-indigo-300 hover:underline transition-colors font-medium",children:o}),code:({inline:s,children:o})=>s?e.jsx("code",{className:"bg-input-bg text-cyan-400 px-1 py-0.5 rounded text-xs font-mono",children:o}):e.jsx("code",{className:"block bg-app-bg text-cyan-400 p-2.5 rounded-lg text-xs font-mono overflow-x-auto mb-2.5",children:o}),blockquote:({children:s})=>e.jsx("blockquote",{className:"border-l-2 border-indigo-500/50 pl-3 italic text-gray-500 my-2.5 text-sm",children:s}),hr:()=>e.jsx("hr",{className:"border-border-default/30 my-3"}),img:({src:s,alt:o})=>{let w=o||"";const C=w.match(/\|(small|medium)/),d=C?C[1]==="small"?"max-w-[30%]":"max-w-[50%]":"max-w-full",D=w.match(/\|(left|center|right)/),g=D?D[1]==="center"?"mx-auto":D[1]==="right"?"ml-auto":"":"";return w=w.replace(/\|(small|medium|left|center|right)/g,""),ce(s)?e.jsx("video",{src:s,autoPlay:!0,loop:!0,muted:!0,playsInl
24ine:!0,className:`rounded-lg h-auto my-2.5 block ${d} ${g}`}):e.jsx("img",{src:s,alt:w,className:`rounded-lg h-auto my-2.5 block ${d} ${g}`,loading:"lazy"})},table:({children:s})=>e.jsx("div",{className:"overflow-x-auto mb-2.5",children:e.jsx("table",{className:"min-w-full text-xs text-gray-400 border-collapse",children:s})}),th:({children:s})=>e.jsx("th",{className:"border border-border-default/30 px-2 py-1 bg-input-bg/50 text-gray-300 font-medium text-left",children:s}),td:({children:s})=>e.jsx("td",{className:"border border-border-default/30 px-2 py-1",children:s})},Ve=({initialArticleId:s})=>{const{user:o}=je(),w=$e(),[C,d]=u.useState([]),[D,g]=u.useState(!0),[Q,m]=u.useState(0),[M,a]=u.useState(0),[k,y]=u.useState(""),p=20,[x,v]=u.useState(null),[n,f]=u.useState({title:"",shortDescription:"",content:"",imageUrl:"",isPublished:!0,publishedAt:"",author:"AI Edit Team",tags:"",slug:""}),[l,N]=u.useState(!1),[B,O]=u.useState(!1),[_,U]=u.useState(!1),[I,S]=u.useState(null),[H,Y]=u.useState(null),[se,K]=u.useState(!1),[G,r]=u.useState(!1),[c,b]=u.useState(null),[z,q]=u.useState(null),[E,P]=u.useState(!1),V=u.useRef(null),J=!!o?.isEditor,re=u.useCallback(async()=>{g(!0);const t=await ve({limit:p,skip:M*p,search:k});t.success&&(d(t.articles),m(t.pagination.total)),g(!1)},[M,k]);u.useEffect(()=>{J&&!x&&re()},[re,x,J]),u.useEffect(()=>{if(H){const t=setTimeout(()=>Y(null),3e3);return()=>clearTimeout(t)}},[H]);const ne=()=>{f({title:"",shortDescription:"",content:"",imageUrl:"",isPublished:!0,publishedAt:"",author:"AI Edit Team",tags:"",slug:""}),v({}),b(null),S(null),r(!1)},le=t=>
24{f({title:t.title||"",shortDescription:t.shortDescription||"",content:t.content||"",imageUrl:t.imageUrl||"",isPublished:t.isPublished||!1,publishedAt:t.publishedAt?(()=>{const i=new Date(t.publishedAt);return`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,"0")}-${String(i.getDate()).padStart(2,"0")}T${String(i.getHours()).padStart(2,"0")}:${String(i.getMinutes()).padStart(2,"0")}`})():"",author:t.author||"AI Edit Team",tags:(t.tags||[]).join(", "),slug:t.slug||""}),v(t),b(null),S(null),r(!1)},de=t=>{le(t),t.id&&w(`/news-editor/${t.id}`)};u.useEffect(()=>{J&&s&&!x?.id&&(async()=>{const t=await we(s);t.success&&t.article&&le(t.article)})()},[s,J]);const ie=async t=>{N(!0),S(null);let i=n.imageUrl||null;if(c){const $=await ae(c);if(!$.success){S($.error||"Failed to upload cover image"),N(!1);return}i=$.publicUrl,b(null)}const h={title:n.title,shortDescription:n.shortDescription,content:n.content,imageUrl:i,isPublished:t,author:n.author,tags:n.tags.split(",").map($=>$.trim()).filter(Boolean),slug:n.slug||void 0};if(t){if(n.publishedAt){const $=new Date(n.publishedAt);h.publishedAt=$<=new Date?$.toISOString():new Date().toISOString()}}else h.publishedAt=null;let j;if(x.id?j=await ke(x.id,h):j=await Ne(h),N(!1),j.success){const $=t?x.id?"Article updated":"Article published":"Draft saved";Y($),v(null),w("/news-editor")}else S(j.error||"Failed to save article")},xe=async()=>{if(!x?.id)return;O(!0),S(null);const t=await Ce(x.id);O(!1),U(!1),t.success?(Y("Article deleted"),v(null),w("/news-editor")):S(t.error||"Failed to delete article")},he=t=>{const i=t.target.files?.[0];if(!i)return;const h=URL.createObjectURL(i);b(i),f(j=>({...j,imageUrl:h})),V.current&&(V.current.value="")},ue=async t=>{K(!0),S(null);const i=await ae(t);return K(!1),i.success?i.publicUrl:(S(i.error||"Failed to upload image"),null)},W=(t,i)=>{f(h=>{const j={...h,[t]:i};return t==="title"&&!x?.id&&(j.slug=Ae(i)),j})},ge=()=>{if(!n.content)return[];const t=[],i=/!\[([^\]]*)\]\(([^)]+)\)/g;let h;for(;(h=i.exec(n.content))!==null;){const j=h[1],$=h[2],F=j.match(/\|(small|medium)/),R=F?F[1]:"large",T=j.match(/\|(left|center|right)/),L=T?T[1]:"left";t.push({url:$,alt:j,size:R,align:L,isVideo:ce($)})}return t},oe=(t,i,h)=>{let j=t.replace(/\|(small|medium|left|center|right)/g,"");return i!=="large"&&(j+=`|${i}`),h!=="left"&&(j+=`|${h}`),j},me=(t,i)=>{const h=/!\[([^\]]*)\]\(([^)]+)\)/g,j=n.content.replace(h,($,F,R)=>
24{if(R!==t)return $;const T=F.match(/\|(left|center|right)/),L=T?T[1]:"left";return``});W("content",j)},pe=(t,i)=>{const h=/!\[([^\]]*)\]\(([^)]+)\)/g,j=n.content.replace(h,($,F,R)=>{if(R!==t)return $;const T=F.match(/\|(small|medium)/),L=T?T[1]:"large";return``});W("content",j)},fe=async(t,i)=>{if(q(t),!t.startsWith("blob:")){const h=await Me(t);if(!h.success){S(h.error||"Failed to delete image"),q(null);return}}if(i)b(null),W("imageUrl","");else{const h=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),j=new RegExp(`!\\[[^\\]]*\\]\\(${h}\\)\\n?`,"g");W("content",n.content.replace(j,""))}q(null)},be=t=>t?new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"-",X=Math.ceil(Q/p);return J?x!==null?e.jsxs("div",{className:"flex-1 bg-panel-bg rounded-lg xs:rounded-xl sm:rounded-2xl flex flex-col min-h-0 h-full overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 xs:px-4 py-2.5 border-b border-border-default/20 flex-shrink-0 gap-1.5",children:[e.jsxs("button",{onClick:()=>{v(null),w("/news-editor")},className:"flex items-center gap-1 text-gray-400 hover:text-white transition-colors duration-150 text-sm group flex-shrink-0",children:[e.jsx("svg",{className:"w-4 h-4 transition-transform duration-150 group-hover:-translate-x-0.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})}),e.jsx("span",{className:"hidden sm:inline",children:"Articles"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex lg:hidden rounded-lg border border-white/[0.06] overflow-hidden flex-shrink-0 h-[30px]",children:[e.jsx("button",{onClick:()=>P(!1),className:`px-2.5 h-full text-xs font-medium transition-colors ${E?"text-gray-500 hover:text-gray-300":"bg-indigo-500/15 text-indigo-400"}`,children:"Edit"}),e.jsx("button",{onClick:()=>P(!0),className:`px-2.5 h-full text-xs font-medium transition-colors ${E?"bg-indigo-500/15 text-indigo-400":"text-gray-500 hover:text-gray-300"}`,children:"Preview"})]}),e.jsx("button",{onClick:()=>r(!G),className:`w-[30px] h-[30px] flex items-center justify-center rounded-lg transition-colors duration-150 flex-shrink-0 ${G?"bg-indigo-500/15 text-indigo-400":"text-gray-500 hover:text-gray-300 hover:bg-input-bg"}`,title:"Article settings",children:e.jsxs("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.325.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 011.37.49l1.296 2.247a1.125 1.125 0 01-.26 1.431l-1.003.827c-.293.241-.438.613-.43.992a7.723 7.723 0 010 .255c-.008.378.137.75.43.991l1.004.827c.424.35.534.955.26 1.43l-1.298 2.247a1.125 1.125 0 01-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.47 6.47 0 01-.22.128c-.331.183-.581.495-.644.869l-.213 1.281c-.09.543-.56.941-1.11.941h-2.594c-.55 0-1.019-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 01-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 01-1.369-.49l-1.297-2.247a1.125 1.125 0 01.26-1.431l1.004-.827c.292-.24.437-.613.43-.991a6.932 6.932 0 010-.255c.007-.38-.138-.751-.43-.992l-1.004-.827a1.125 1.125 0 01-.26-1.43l1.297-2.247a1.125 1.125 0 011.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.086.22-.128.332-.183.582-.495.644-.869l.214-1.28z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}),x.id&&e.jsx("button",{onClick:()=>U(!0),className:"w-[30px] h-[30px] flex items-center justify-center rounded-lg text-gray-500 hover:text-red-400 hover:bg-red-500/10 transition-colors duration-150 flex-shrink-0",title:"Delete article",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"})})}),e.jsx("button",{onClick:()=>ie(!1),disabled:l||!n.title,className:"h-[30px] px-3 text-xs font-medium rounded-lg text-gray-400 hover:text-white bg-white/[0.04] hover:bg-white/[0.08] border border-white/[0.06] transition-all duration-150 disabled:opacity-40 disabled:cursor-not-allowed whitespace-nowrap flex-shrink-0",children:"Draft"}),e.jsxs("button",{onClick:()=>ie(!0),disabled:l||!n.title||!n.shortDescription||!n.content,className:"relative h-[30px] px-3 text-xs font-medium rounded-lg text-white transition-all duration-200 disabled:opacity-40 disabled:cursor-not-allowed overflow-hidden group flex-shrink-0",children:[e.jsx("span",{className:"absolute inset-0 rounded-lg bg-gradient-to-r from-indigo-500 to-purple-600 opacity-90 group-hover:opacity-100 transition-opacity"}),e.jsxs("span",{className:"relative flex items-center gap-1.5 whitespace-nowrap",children:[l&&e.jsxs("svg",{className:"w-3 h-3 animate-spin",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),l?"Saving...":x.id&&x.isPublished?"Update":"Publish"]})]})]})]}),I&&e.jsxs("div",{className:"mx-3 xs:mx-4 mt-2 flex items-center gap-2 p-2.5 bg-red-500/10 border border-red-500/20 rounded-lg animate-fadeIn",children:[e.jsx("svg",{className:"w-4 h-4 text-red-400 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m9-.75
24a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z"})}),e.jsx("span",{className:"text-red-400 text-xs flex-1",children:I}),e.jsx("button",{onClick:()=>S(null),className:"text-red-400/60 hover:text-red-400 transition-colors",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),G&&e.jsxs("div",{className:"mx-3 xs:mx-4 mt-2 p-3 bg-input-bg/50 border border-border-default/20 rounded-xl animate-fadeIn",children:[e.jsxs("div",{className:"grid grid-cols-1 xs:grid-cols-2 sm:grid-cols-3 gap-2.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-medium text-gray-500 mb-1 uppercase tracking-wider",children:"Author"}),e.jsx("input",{type:"text",value:n.author,onChange:t=>W("author",t.target.value),className:"w-full bg-input-bg border border-border-default/30 rounded-lg px-2.5 py-1.5 text-xs text-white placeholder-gray-600 focus:outline-none focus:border-indigo-500/50 transition-colors",placeholder:"Author"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-medium text-gray-500 mb-1 uppercase tracking-wider",children:"Tags"}),e.jsx("input",{type:"text",value:n.tags,onChange:t=>W("tags",t.target.value),className:"w-full bg-input-bg border border-border-default/30 rounded-lg px-2.5 py-1.5 text-xs text-white placeholder-gray-600 focus:outline-none focus:border-indigo-500/50 transition-colors",placeholder:"tag1, tag2"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-medium text-gray-500 mb-1 uppercase tracking-wider",children:"Publish Date"}),e.jsx(ze,{value:n.publishedAt,onChange:t=>W("publishedAt",t)})]})]}),e.jsxs("div",{className:"mt-2.5",children:[e.jsx("label",{className:"block text-[11px] font-medium text-gray-500 mb-1 uppercase tracking-wider",children:"URL Slug"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-gray-500 flex-shrink-0",children:"/news/"}),e.jsx("input",{type:"text",value:n.slug,onChange:t=>W("slug",t.target.value.toLowerCase().replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-")),className:"flex-1 bg-input-bg border border-border-default/30 rounded-lg px-2.5 py-1.5 text-xs text-white placeholder-gray-600 focus:outline-none focus:border-indigo-500/50 transition-colors font-mono",placeholder:"auto-generated-from-title"})]}),e.jsx("p",{className:"text-[10px] text-gray-600 mt-1",children:"Leave empty to auto-generate from title. Changing this will change the article URL."})]})]}),e.jsxs("div",{className:"flex-1 flex min-h-0",children:[e.jsxs("div",{className:`flex-1 flex flex-col overflow-y-auto px-3 xs:px-4 py-3 space-y-3 custom-scrollbar min-w-0 ${E?"hidden lg:flex":""}`,children:[e.jsx("input",{type:"text",value:n.title,onChange:t=>W("title",t.target.value),className:"w-full bg-transparent text-lg sm:text-xl font-semibold text-white placeholder-gray-600 focus:outline-none",placeholder:"Article title...",maxLength:200}),e.jsx("textarea",{value:n.shortDescription,onChange:t=>W("shortDescription",t.target.value),className:"w-full bg-transparent text-base sm:text-sm text-gray-300 placeholder-gray-600 focus:outline-none focus:ring-0 resize-none leading-relaxed",placeholder:"Short description for the article preview...",rows:2,maxLength:500}),e.jsxs("div",{children:[n.imageUrl?e.jsxs("div",{className:"relative group w-fit",children:[e.jsx("img",{src:n.imageUrl,alt:"Cover",className:"h-28 sm:h-36 max-w-[240px] sm:max-w-[320px] rounded-lg object-contain bg-input-bg/30 cursor-pointer",onClick:()=>V.current?.click()}),e.jsx("button",{onClick:()=>{b(null),W("imageUrl","")},className:"absolute top-1.5 right-1.5 w-6 h-6 flex items-center justify-center rounded-full bg-black/70 text-gray-400 hover:text-white hover:bg-red-500/80 opacity-0 group-hover:opacity-100 transition-all duration-150",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}):e.jsxs("button",{onClick:()=>V.current?.click(),className:"flex items-center gap-2 px-3 py-2 text-xs text-gray-500 hover:text-gray-400 bg-input-bg/30 hover:bg-input-bg/50 border border-border-default/20 rounded-lg transition-all duration-150",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 15.75l5.159-5.159a2.25 2.25 0 013.182 0l5.159 5.159m-1.5-1.5l1.409-1.409a2.25 2.25 0 013.182 0l2.909 2.909M3.75 21h16.5A2.25 2.25 0 0022.5 18.75V5.25A2.25 2.25 0 0020.25 3H3.75A2.25 2.25 0 001.5 5.25v13.5A2.25 2.25 0 003.75 21z"})}),e.jsx("span",{children:"Add cover image"})]}),e.jsx("input",{ref:V,type:"file",accept:"image/jpeg,image/png,image/gif,image/webp",onChange:he,className:"hidden"})]}),e.jsx("div",{className:"h-px bg-border-default/20"}),e.jsx(Be,{value:n.content,onChange:t=>W("content",t),onImageUpload:ue,uploadingImage:se,placeholder:"Write your article content..."},x?.id||"new"),(()=>{const t=ge(),i=[];return n.imageUrl&&i.push({url:n.imageUrl,isCover:!0,size:"large",align:"left",isVideo:!1}),t.forEach(h=>i.push({...h,isCover:!1})),i.length===0?null:e.jsxs("div",{children:[e.jsxs("div",{className:"text-[11px] font-medium text-gray-500 uppercase tracking-wider mb-2",children:["Media (",i.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-3",children:i.map(({url:h,isCover:j,size:$,align:F,isVideo:R},T)=>e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsxs("div",{className:"relative group",children:[R?e.jsxs("div",{className:"w-16 h-16 rounded-lg bg-input-bg/30 overflow-hidden relative",children:[e.jsx("video",{src:h,className:"w-full h-full object-cover",preload:"metadata",muted:!0}
24),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/30",children:e.jsx("svg",{className:"w-5 h-5 text-white/80",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M8 5v14l11-7z"})})})]}):e.jsx("img",{src:h,alt:"",className:"w-16 h-16 rounded-lg object-cover bg-input-bg/30"}),j&&e.jsx("span",{className:"absolute bottom-0.5 left-0.5 px-1 py-0.5 text-[9px] font-medium bg-black/70 text-gray-300 rounded",children:"Cover"}),e.jsx("button",{onClick:()=>fe(h,j),disabled:z===h,className:"absolute -top-1 -right-1 w-5 h-5 flex items-center justify-center rounded-full bg-black/80 text-gray-400 hover:text-white hover:bg-red-500/90 opacity-0 group-hover:opacity-100 transition-all duration-150 disabled:opacity-50",title:R?"Delete video":"Delete image",children:z===h?e.jsxs("svg",{className:"w-2.5 h-2.5 animate-spin",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}):e.jsx("svg",{className:"w-2.5 h-2.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"3",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),!j&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"flex gap-px rounded-md overflow-hidden border border-white/[0.06]",children:[{key:"small",label:"S"},{key:"medium",label:"M"},{key:"large",label:"L"}].map(L=>e.jsx("button",{onClick:()=>me(h,L.key),className:`px-1.5 py-0.5 text-[10px] font-medium transition-colors ${$===L.key?"bg-indigo-500/20 text-indigo-400":"text-gray-600 hover:text-gray-400 hover:bg-white/[0.04]"}`,title:L.key==="small"?"30% width":L.key==="medium"?"50% width":"Full width",children:L.label},L.key))}),e.jsx("div",{className:"flex gap-px rounded-md overflow-hidden border border-white/[0.06]",children:[{key:"left",icon:e.jsxs("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 12 12",fill:"currentColor",children:[e.jsx("rect",{x:"0",y:"1",width:"12",height:"1.5",rx:"0.5"}),e.jsx("rect",{x:"0",y:"5.25",width:"8",height:"1.5",rx:"0.5"}),e.jsx("rect",{x:"0",y:"9.5",width:"10",height:"1.5",rx:"0.5"})]})},{key:"center",icon:e.jsxs("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 12 12",fill:"currentColor",children:[e.jsx("rect",{x:"0",y:"1",width:"12",height:"1.5",rx:"0.5"}),e.jsx("rect",{x:"2",y:"5.25",width:"8",height:"1.5",rx:"0.5"}),e.jsx("rect",{x:"1",y:"9.5",width:"10",height:"1.5",rx:"0.5"})]})},{key:"right",icon:e.jsxs("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 12 12",fill:"currentColor",children:[e.jsx("rect",{x:"0",y:"1",width:"12",height:"1.5",rx:"0.5"}),e.jsx("rect",{x:"4",y:"5.25",width:"8",height:"1.5",rx:"0.5"}),e.jsx("rect",{x:"2",y:"9.5",width:"10",height:"1.5",rx:"0.5"})]})}].map(L=>e.jsx("button",{onClick:()=>pe(h,L.key),className:`px-1.5 py-0.5 transition-colors ${F===L.key?"bg-indigo-500/20 text-indigo-400":"text-gray-600 hover:text-gray-400 hover:bg-white/[0.04]"}`,title:`Align ${L.key}`,children:L.icon},L.key))})]})]},`${h}-${T}`))})]})})()]}),e.jsx("div",{className:"hidden lg:block w-px bg-border-default/20 flex-shrink-0"}),e.jsxs("div",{className:`${E?"flex":"hidden"} lg:flex flex-col flex-1 min-w-0 min-h-0`,children:[e.jsx("div",{className:"px-3 py-2 border-b border-border-default/20 flex-shrink-0",children:e.jsx("span",{className:"text-[11px] font-medium text-gray-500 uppercase tracking-wider",children:"Preview"})}),e.jsxs("div",{className:"flex-1 overflow-y-auto custom-scrollbar px-4 py-4",children:[n.imageUrl&&e.jsx("div",{className:"mb-4 flex justify-center",children:e.jsx("img",{src:n.imageUrl,alt:n.title,className:"max-w-[70%] max-h-[40vh] w-auto h-auto object-contain rounded-lg"})}),n.title?e.jsx("h1",{className:"text-base font-bold text-gray-200 mb-2",children:n.title}):e.jsx("h1",{className:"text-base font-bold text-gray-600 italic mb-2",children:"Untitled"}),e.jsx("div",{className:"text-xs text-gray-500 mb-4",children:"Just now"}),e.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-sm",children:n.content?e.jsx(De,{remarkPlugins:[Le],components:Ie,children:He(n.content)}):e.jsx("p",{className:"text-gray-600 text-sm italic",children:"Start writing to see the preview..."})}),n.tags&&n.tags.split(",").filter(t=>t.trim()).length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-6 pt-4 border-t border-border-default/30",children:n.tags.split(",").map(t=>
24t.trim()).filter(Boolean).map((t,i)=>e.jsx("span",{className:"px-2 py-1 text-xs bg-input-bg text-gray-400 rounded-md",children:t},i))})]})]})]}),_&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",onClick:()=>U(!1),children:e.jsxs("div",{className:"bg-panel-bg border border-border-default/30 rounded-2xl p-5 max-w-sm w-full animate-fadeIn",onClick:t=>t.stopPropagation(),children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-red-500/10 flex items-center justify-center mb-3",children:e.jsx("svg",{className:"w-5 h-5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"})})}),e.jsx("h3",{className:"text-base font-semibold text-white mb-1.5",children:"Delete Article"}),e.jsxs("p",{className:"text-sm text-gray-400 mb-5 leading-relaxed",children:["Are you sure you want to delete â",x.title||"this article","â? This action cannot be undone."]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>U(!1),className:"flex-1 px-3 py-2 text-sm font-medium text-gray-300 hover:text-white bg-input-bg hover:bg-hover-bg rounded-xl transition-colors duration-150",children:"Cancel"}),e.jsx("button",{onClick:xe,disabled:B,className:"flex-1 px-3 py-2 text-sm font-medium bg-red-600 hover:bg-red-500 disabled:bg-gray-700 disabled:text-gray-500 text-white rounded-xl transition-colors duration-150",children:B?"Deleting...":"Delete"})]})]})})]}):e.jsxs("div",{className:"flex-1 bg-panel-bg rounded-lg xs:rounded-xl sm:rounded-2xl flex flex-col min-h-0 h-full overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 xs:px-4 py-2.5 xs:py-3 border-b border-border-default/20 flex-shrink-0",children:[e.jsx("div",{}),e.jsx("button",{onClick:ne,className:"w-8 h-8 flex items-center justify-center rounded-lg bg-indigo-500/15 hover:bg-indigo-500/25 text-indigo-400 hover:text-indigo-300 transition-all duration-150",title:"New Article",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})})]}),e.jsx("div",{className:"px-3 xs:px-4 py-2 flex-shrink-0",children:e.jsxs("div",{className:"relative",children:[e.jsx("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-gray-500 pointer-events-none",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"})}),e.jsx("input",{type:"text",value:k,onChange:t=>{y(t.target.value),a(0)},className:"w-full bg-input-bg/50 border border-border-default/20 rounded-xl pl-8.5 pr-3 py-2 text-sm text-white placeholder-gray-600 focus:outline-none focus:border-indigo-500/30 transition-colors",placeholder:"Search articles...",style:{paddingLeft:"2.25rem"}}),k&&e.jsx("button",{onClick:()=>{y(""),a(0)},className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-gray-600 hover:text-gray-400 transition-colors",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}),H&&e.jsxs("div",{className:"mx-3 xs:mx-4 mb-1 flex items-center gap-2 p-2.5 bg-emerald-500/10 border border-emerald-500/20 rounded-xl animate-fadeIn",children:[e.jsx("svg",{className:"w-4 h-4 text-emerald-400 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("span",{className:"text-emerald-400 text-xs",children:H})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-3 xs:px-4 py-1 custom-scrollbar",children:D?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-2 border-indigo-500/30 border-t-indigo-400"}),e.jsx("span",{className:"text-xs text-gray-500",children:"Loading articles..."})]}):C.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-input-bg flex items-center justify-center mb-3",children:e.jsx("svg",{className:"w-6 h-6 text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})})}),e.jsx("p",{className:"text-sm text-gray-400 font-medium mb-1",children:k?"No results found":"No articles yet"}),e.jsx("p",{className:"text-xs text-gray-600",children:k?"Try a different search term":"Create your first article to get started"})]}):e.jsx("div",{className:"space-y-2",children:C.map(t=>e.jsx(ye,{to:`/news-editor/${t.id}`,onClick:()=>de(t),className:"w-full text-left bg-white/[0.02] hover:bg-white/[0.05] border border-white/[0.06] hover:border-white/[0.12] rounded-xl p-3 sm:p-4 transition-all duration-200 group block",children:e.jsxs("div",{className:"flex items-start gap-3.5",children:[t.imageUrl?e.jsx("img",{src:t.imageUrl,alt:"",className:"w-16 h-16 sm:w-20 sm:h-20 rounded-xl object-cover flex-shrink-0"}):e.jsx("div",{className:"w-16 h-16 sm:w-20 sm:h-20 rounded-xl bg-gradient-to-br from-indigo-500/10 to-purple-500/10 flex items-center justify-center flex-shrink-0",children:e.jsx("svg",{className:"w-6 h-6 text-indigo-500/40",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})})}),e.jsxs("div",{className:"flex-1 min-w-0 py-0.5",children:[e.jsx("h3",{className:"text-[15px] font-medium text-gray-200 group-hover:text-white transition-colors truncate mb-1",children:t.title}),e.jsx("p",{className:"text-sm text-gray-500 line-clamp-2 mb-2 leading-relaxed",children:t.shortDe
24scription}),e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 text-[11px] font-medium rounded-md ${t.isPublished?"bg-emerald-500/10 text-emerald-400":"bg-amber-500/10 text-amber-400"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${t.isPublished?"bg-emerald-400":"bg-amber-400"}`}),t.isPublished?"Published":"Draft"]}),e.jsx("span",{className:"text-xs text-gray-600",children:be(t.publishedAt||t.createdAt)})]})]})]})},t.id))})}),X>1&&e.jsxs("div",{className:"flex items-center justify-between px-3 xs:px-4 py-2 border-t border-border-default/20 flex-shrink-0",children:[e.jsxs("span",{className:"text-[11px] text-gray-600",children:["Page ",M+1," of ",X]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>a(Math.max(0,M-1)),disabled:M===0,className:"p-1.5 rounded-lg text-gray-500 hover:text-white hover:bg-input-bg disabled:text-gray-700 disabled:hover:bg-transparent transition-colors",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})})}),e.jsx("button",{onClick:()=>a(Math.min(X-1,M+1)),disabled:M>=X-1,className:"p-1.5 rounded-lg text-gray-500 hover:text-white hover:bg-input-bg disabled:text-gray-700 disabled:hover:bg-transparent transition-colors",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})})})]})]})]}):e.jsxs("div",{className:"flex-1 bg-panel-bg rounded-lg xs:rounded-xl sm:rounded-2xl flex flex-col items-center justify-center min-h-0 h-full p-4",children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-input-bg flex items-center justify-center mb-4",children:e.jsx("svg",{className:"w-7 h-7 text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.5 10.5V6.75a4.5 4.5 0 10-9 0v3.75m-.75 11.25h10.5a2.25 2.25 0 002.25-2.25v-6.75a2.25 2.25 0 00-2.25-2.25H6.75a2.25 2.25 0 00-2.25 2.25v6.75a2.25 2.25 0 002.25 2.25z"})})}),e.jsx("h2",{className:"text-lg font-semibold text-gray-200 mb-1.5",children:"Access Denied"}),e.jsx("p",{className:"text-sm text-gray-500 text-center max-w-xs",children:"You need editor permissions to access this panel."})]})};export{Ve 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.