vendor: 10,287 bytes, line 1
1var we=s=>{throw TypeError(s)};var ie=(s,e,r)=>e.has(s)||we("Cannot "+r);var t=(s,e,r)=>(ie(s,e,"read from private field"),r?r.call(s):e.get(s)),y=(s,e,r)=>e.has(s)?we("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,r),u=(s,e,r,i)=>(ie(s,e,"write to private field"),i?i.call(s,r):e.set(s,r),r),x=(s,e,r)=>(ie(s,e,"access private method"),r);import{d as Qe,p as Ne,r as T,s as re,e as te,n as $e,i as oe,f as Ce,t as Ke,g as qe,h as Be,k as Re,l as ae,m as Se,o as He,u as Me,c as ge,j as a,X as ze,q as Ee,v as Oe}from"./index-BxoQIv5-.js";import{r as f,u as Ve,L as ne}from"./react-DcuNND5j.js";import{T as We,D as Ge,E as Xe}from"./AdminModal-B2frKStn.js";import{U as Je}from"./users-CqD1NWvT.js";import{L as Ye}from"./loader-circle-B0ECQrlj.js";import{K as Ze}from"./key-round-C7xyKw5d.js";import"./swiper-4o4E_2QE.js";var C,d,J,N,A,H,P,U,Y,z,V,_,$,Q,W,m,X,le,ce,de,he,ue,me,xe,Le,Ie,et=(Ie=class extends Qe{constructor(e,r){super();y(this,m);y(this,C);y(this,d);y(this,J);y(this,N);y(this,A);y(this,H);y(this,P);y(this,U);y(this,Y);y(this,z);y(this,V);y(this,_);y(this,$);y(this,Q);y(this,W,new Set);this.options=r,u(this,C,e),u(this,U,null),u(this,P,Ne()),this.options.experimental_prefetchInRender||t(this,P).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(t(this,d).addObserver(this),ke(t(this,d),this.options)?x(this,m,X).call(this):this.updateResult(),x(this,m,he).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return fe(t(this,d),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return fe(t(this,d),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,x(this,m,ue).call(this),x(this,m,me).call(this),t(this,d).removeObserver(this)}setOptions(e,r){const i=this.options,l=t(this,d);if(this.options=t(this,C).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof T(this.options.enabled,t(this,d))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");x(this,m,xe).call(this),t(this,d).setOptions(this.options),i._defaulted&&!re(this.options,i)&&t(this,C).getQueryCache().notify({type:"observerOptionsUpdated",query:t(this,d),observer:this});const c=this.hasListeners();c&&Ue(t(this,d),l,this.options,i)&&x(this,m,X).call(this),this.updateResult(r),c&&(t(this,d)!==l||T(this.options.enabled,t(this,d))!==T(i.enabled,t(this,d))||te(this.options.staleTime,t(this,d))!==te(i.staleTime,t(this,d)))&&x(this,m,le).call(this);const o=x(this,m,ce).call(this);c&&(t(this,d)!==l||T(this.options.enabled,t(this,d))!==T(i.enabled,t(this,d))||o!==t(this,Q))&&x(this,m,de).call(this,o)}getOptimisticResult(e){const r=t(this,C).getQueryCache().build(t(this,C),e),i=this.createResult(r,e);return st(this,i)&&(u(this,N,i),u(this,H,this.options),u(this,A,t(this,d).state)),i}getCurrentResult(){return t(this,N)}trackResult(e,r){const i={};return Object.keys(e).forEach(l=>{Object.defineProperty(i,l,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(l),r==null||r(l),e[l])})}),i}trackProp(e){t(this,W).add(e)}getCurrentQuery(){return t(this,d)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const r=t(this,C).defaultQueryOptions(e),i=t(this,C).getQueryCache().build(t(this,C),r);return i.fetch().then(()=>this.createResult(i,r))}fetch(e){return x(this,m,X).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),t(this,N)))}createResult(e,r){var je;const i=t(this,d),l=this.options,c=t(this,N),o=t(this,A),v=t(this,H),g=e!==i?e.state:t(this,J),{state:b}=e;let n={...b},S=!1,j;if(r._optimisticResults){const w=this.hasListeners(),q=!w&&ke(e,r),B=w&&Ue(e,i,r,l);(q||B)&&(n={...n,...Be(b.data,e.options)}),r._optimisticResults==="isRestoring"&&(n.fetchStatus="idle")}let{error:F,errorUpdatedAt:O,status:E}=n;if(r.select&&n.data!==void 0)if(c&&n.data===(o==null?void 0:o.data)&&r.select===t(this,Y))j=t(this,z);else try{u(this,Y,r.select),j=r.select(n.data),j=Re(c==null?void 0:c.data,j,r),u(this,z,j),u(this,U,null)}catch(w){u(this,U,w)}else j=n.data;if(r.placeholderData!==void 0&&j===void 0&&E==="pending"){let w;if(c!=null&&c.isPlaceholderData&&r.placeholderData===(v==null?void 0:v.placeholderData))w=c.data;else if(w=typeof r.placeholderData=="function"?r.placeholderData((je=t(this,V))==null?void 0:je.state.data,t(this,V)):r.placeholderData,r.select&&w!==void 0)try{w=r.select(w),u(this,U,null)}catch(q){u(this,U,q)}w!==void 0&&(E="success",j=Re(c==null?void 0:c.data,w,r),S=!0)}t(this,U)&&(F=t(this,U),j=t(this,z),O=Date.now(),E="error");const h=n.fetchStatus==="fetching",K=E==="pending",G=E==="error",Z=K&&h,ve=j!==void 0,k={status:E,fetchStatus:n.fetchStatus,isPending:K,isSuccess:E==="success",isError:G,isInitialLoading:Z,isLoading:Z,data:j,dataUpdatedAt:n.dataUpdatedAt,error:F,errorUpdatedAt:O,failureCount:n.fetchFailureCount,failureReason:n.fetchFailureReason,errorUpdateCount:n.errorUpdateCount,isFetched:n.dataUpdateCount>0||n.errorUpdateCount>0,isFetchedAfterMount:n.dataUpdateCount>g.dataUpdateCount||n.errorUpdateCount>g.errorUpdateCount,isFetching:h,isRefetching:h&&!K,isLoadingError:G&&!ve,isPaused:n.fetchStatus==="paused",isPlaceholderData:S,isRefetchError:G&&ve,isStale:ye(e,r),refetch:this.refetch,promise:t(this,P)};if(this.options.experimental_prefetchInRender){const w=ee=>{k.status==="error"?ee.reject(k.error):k.data!==void 0&&ee.resolve(k.data)},q=()=>{const ee=u(this,P,k.promise=Ne());w(ee)},B=t(this,P);switch(B.status){case"pending":e.queryHash===i.queryHash&&w(B);break;case"fulfilled":(k.status==="error"||k.data!==B.value)&&q();break;case"rejected":(k.status!=="error"||k.error!==B.reason)&&q();break}}return k}updateResult(e){const r=t(this,N),i=this.createResult(t(this,d),this.options);if(u(this,A,t(this,d).state),u(this,H,this.options),t(this,A).data!==void 0&&u(this,V,t(this,d)),re(i,r))return;u(this,N,i);const l={},c=()=>{if(!r)return!0;const{notifyOnChangeProps:o}=this.options,v=typeof o=="function"?o():o;if(v==="all"||!v&&!t(this,W).size)return!0;const p=new Set(v??t(this,W));return this.options.throwOnError&&p.add("error"),Object.keys(t(this,N)).some(g=>{const b=g;return t(this,N)[b]!==r[b]&&p.has(b)})};(e==null?void 0:e.listeners)!==!1&&c()&&(l.listeners=!0),x(this,m,Le).call(this,{...l,...e})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&x(this,m,he).call(this)}},C=new WeakMap,d=new WeakMap,J=new WeakMap,N=new WeakMap,A=new WeakMap,H=new WeakMap,P=new WeakMap,U=new WeakMap,Y=new WeakMap,z=new WeakMap,V=new WeakMap,_=new WeakMap,$=new WeakMap,Q=new WeakMap,W=new WeakMap,m=new WeakSet,X=function(e){x(this,m,xe).call(this);let r=t(this,d).fetch(this.options,e);return e!=null&&e.throwOnError||(r=r.catch($e)),r},le=function(){x(this,m,ue).call(this);const e=te(this.options.staleTime,t(this,d));if(oe||t(this,N).isStale||!Ce(e))return;const i=Ke(t(this,N).dataUpdatedAt,e)+1;u(this,_,setTimeout(()=>{t(this,N).isStale||this.updateResult()},i))},ce=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(t(this,d)):this.options.refetchInterval)??!1},de=function(e){x(this,m,me).call(this),u(this,Q,e),!(oe||T(this.options.enabled,t(this,d))===!1||!Ce(t(this,Q))||t(this,Q)===0)&&u(this,$,setInterval(()=>{(this.options.refetchIntervalInBackground||qe.isFocused())&&x(this,m,X).call(this)},t(this,Q)))},he=function(){x(this,m,le).call(this),x(this,m,de).call(this,x(this,m,ce).call(this))},ue=function(){t(this,_)&&(clearTimeout(t(this,_)),u(this,_,void 0))},me=function(){t(this,$)&&(clearInterval(t(this,$)),u(this,$,void 0))},xe=function(){const e=t(this,C).getQueryCache().build(t(this,C),this.options);if(e===t(this,d))return;const r=t(this,d);u(this,d,e),u(this,J,e.state),this.hasListeners()&&(r==null||r.removeObserver(this),e.addObserver(this))},Le=function(e){ae.batch(()=>{e.listeners&&this.listeners.forEach(r=>{r(t(this,N))}),t(this,C).getQueryCache().notify({query:t(this,d),type:"observerResultsUpdated"})})},Ie);function tt(s,e){return T(e.enabled,s)!==!1&&s.state.data===void 0&&!(s.state.status==="error"&&e.retryOnMount===!1)}function ke(s,e){return tt(s,e)||s.state.data!==void 0&&fe(s,e,e.refetchOnMount)}function fe(s,e,r){if(T(e.enabled,s)!==!1){const i=typeof r=="function"?r(s):r;return i==="always"||i!==!1&&ye(s,e)}return!1}function Ue(s,e,r,i){return(s!==e||T(i.enabled,s)===!1)&&(!r.suspense||s.state.status!=="error")&&ye(s,r)}function ye(s,e){return T(e.enabled,s)!==!1&&s.isStaleByTime(te(e.staleTime,s))}function st(s,e){return!re(s.getCurrentResult(),e)}var M,L,R,D,I,se,pe,Pe,rt=(Pe=class extends Qe{constructor(e,r){super();y(this,I);y(this,M);y(this,L);y(this,R);y(this,D);u(this,M,e),this.setOptions(r),this.bindMethods(),x(this,I,se).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){var i;const r=this.options;this.options=t(this,M).defaultMutationOptions(e),re(this.options,r)||t(this,M).getMutationCache().notify({type:"observerOptionsUpdated",mutation:t(this,R),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&Se(r.mutationKey)!==Se(this.options.mutationKey)?this.reset():((i=t(this,R))==null?void 0:i.state.status)==="pending"&&t(this,R).setOptions(this.options)}onUnsubscribe(){var e;this.hasListeners()||(e=t(this,R))==null||e.removeObserver(this)}onMutationUpdate(e){x(this,I,se).call(this),x(this,I,pe).call(this,e)}getCurrentResult(){return t(this,L)}reset(){var e;(e=t(this,R))==null||e.removeObserver(this),u(this,R,void 0),x(this,I,se).call(this),x(this,I,pe).call(this)}mutate(e,r){var i;return u(this,D,r),(i=t(this,R))==null||i.removeObserver(this),u(this,R,t(this,M).getMutationCache().build(t(this,M),this.options)),t(this,R).addObserver(this),t(this,R).execute(e)}},M=new WeakMap,L=new WeakMap,R=new WeakMap,D=new WeakMap,I=new WeakSet,se=function(){var r;const e=((r=t(this,R))==null?void 0:r.state)??He();u(this,L,{...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset})}
1,pe=function(e){ae.batch(()=>{var r,i,l,c,o,v,p,g;if(t(this,D)&&this.hasListeners()){const b=t(this,L).variables,n=t(this,L).context;(e==null?void 0:e.type)==="success"?((i=(r=t(this,D)).onSuccess)==null||i.call(r,e.data,b,n),(c=(l=t(this,D)).onSettled)==null||c.call(l,e.data,null,b,n)):(e==null?void 0:e.type)==="error"&&((v=(o=t(this,D)).onError)==null||v.call(o,e.error,b,n),(g=(p=t(this,D)).onSettled)==null||g.call(p,void 0,e.error,b,n))}this.listeners.forEach(b=>{b(t(this,L))})})},Pe),Fe=f.createContext(!1),at=()=>f.useContext(Fe);Fe.Provider;function it(){let s=!1;return{clearReset:()=>{s=!1},reset:()=>{s=!0},isReset:()=>s}}var nt=f.createContext(it()),ot=()=>f.useContext(nt);function Ae(s,e){return typeof s=="function"?s(...e):!!s}function be(){}var lt=(s,e)=>{(s.suspense||s.throwOnError||s.experimental_prefetchInRender)&&(e.isReset()||(s.retryOnMount=!1))},ct=s=>{f.useEffect(()=>{s.clearReset()},[s])},dt=({result:s,errorResetBoundary:e,throwOnError:r,query:i})=>s.isError&&!e.isReset()&&!s.isFetching&&i&&Ae(r,[s.error,i]),ht=s=>{s.suspense&&(s.staleTime===void 0&&(s.staleTime=1e3),typeof s.gcTime=="number"&&(s.gcTime=Math.max(s.gcTime,1e3)))},ut=(s,e)=>s.isLoading&&s.isFetching&&!e,mt=(s,e)=>(s==null?void 0:s.suspense)&&e.isPending,Te=(s,e,r)=>e.fetchOptimistic(s).catch(()=>{r.clearReset()});function xt(s,e,r){var b,n,S,j,F;const i=Me(),l=at(),c=ot(),o=i.defaultQueryOptions(s);(n=(b=i.getDefaultOptions().queries)==null?void 0:b._experimental_beforeQuery)==null||n.call(b,o),o._optimisticResults=l?"isRestoring":"optimistic",ht(o),lt(o,c),ct(c);const v=!i.getQueryCache().get(o.queryHash),[p]=f.useState(()=>new e(i,o)),g=p.getOptimisticResult(o);if(f.useSyncExternalStore(f.useCallback(O=>{const E=l?be:p.subscribe(ae.batchCalls(O));return p.updateResult(),E},[p,l]),()=>p.getCurrentResult(),()=>p.getCurrentResult()),f.useEffect(()=>{p.setOptions(o,{listeners:!1})},[o,p]),mt(o,g))throw Te(o,p,c);if(dt({result:g,errorResetBoundary:c,throwOnError:o.throwOnError,query:i.getQueryCache().get(o.queryHash)}))throw g.error;if((j=(S=i.getDefaultOptions().queries)==null?void 0:S._experimental_afterQuery)==null||j.call(S,o,g),o.experimental_prefetchInRender&&!oe&&ut(g,l)){const O=v?Te(o,p,c):(F=i.getQueryCache().get(o.queryHash))==null?void 0:F.promise;O==null||O.catch(be).finally(()=>{p.updateResult()})}return o.notifyOnChangeProps?g:p.trackResult(g)}function ft(s,e){return xt(s,et)}function De(s,e){const r=Me(),[i]=f.useState(()=>new rt(r,s));f.useEffect(()=>{i.setOptions(s)},[i,s]);const l=f.useSyncExternalStore(f.useCallback(o=>i.subscribe(ae.batchCalls(o)),[i]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),c=f.useCallback((o,v)=>{i.mutate(o,v).catch(be)},[i]);if(l.error&&Ae(i.options.throwOnError,[l.error]))throw l.error;return{...l,mutate:c,mutateAsync:l.mutate}}const pt=ge("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const bt=ge("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const gt=ge("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]),_e="#1bbca3";function yt({username:s,password:e,onDone:r}){const[i,l]=f.useState(!1),c=async()=>{try{await navigator.clipboard.writeText(`Usuario: ${s} 2Contraseña: ${e}`),l(!0),setTimeout(()=>l(!1),2e3)}catch{}};return a.jsxs("div",{className:"p-6","data-testid":"panel-new-credential",children:[a.jsx("div",{className:"mx-auto mb-5 w-14 h-14 rounded-full bg-[#1bbca3]/10 flex items-center justify-center",children:a.jsx(Ze,{className:"w-7 h-7 text-[#1bbca3]"})}),a.jsx("h3",{className:"text-lg font-bold text-gray-800 text-center mb-2",children:"Usuario creado"}),a.jsxs("p",{className:"text-sm text-gray-500 text-center mb-5",children:["Entrega estos datos a ",a.jsx("span",{className:"font-medium text-gray-700",children:s}),". La contraseña es de un solo uso y se le pedirá cambiarla al entrar."]}),a.jsxs("div",{className:"rounded-xl border border-gray-200 bg-gray-50 divide-y divide-gray-200 mb-4",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[a.jsx("span",{className:"text-xs uppercase tracking-wide text-gray-400",children:"Usuario"}),a.jsx("span",{className:"font-mono text-sm text-gray-800",children:s})]}),a.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[a.jsx("span",{className:"text-xs uppercase tracking-wide text-gray-400",children:"Contraseña"}),a.jsx("span",{className:"font-mono text-sm font-semibold text-gray-800 tracking-wider","data-testid":"text-one-time-password",children:e})]})]}),a.jsx("p",{className:"text-xs text-amber-700 bg-amber-50 border border-amber-200 rounded-lg px-3 py-2 mb-5",children:"Guárdala ahora: por seguridad no volverá a mostrarse."}),a.jsxs("div",{className:"flex gap-3",children:[a.jsxs("button",{onClick:c,className:"flex-1 py-2.5 text-sm font-semibold text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-100 inline-flex items-center justify-center gap-2","data-testid":"button-copy-credential",children:[i?a.jsx(pt,{className:"w-4 h-4 text-[#1bbca3]"}):a.jsx(bt,{className:"w-4 h-4"}),i?"Copiado":"Copiar"]}),a.jsx("button",{onClick:r,style:{backgroundColor:_e},className:"flex-1 py-2.5 text-sm font-semibold text-white rounded-lg hover:opacity-90","data-testid":"button-credential-done",children:"Listo"})]})]})}function vt({onClose:s}){const[e,r]=f.useState(""),[i,l]=f.useState(""),[c,o]=f.useState(null),{data:v=[],isLoading:p}=ft({queryKey:["/api/admin/users"],queryFn:()=>fetch("/api/admin/users",{credentials:"include"}).then(n=>n.json())}),g=De({mutationFn:async n=>(await Oe("POST","/api/admin/users",{username:n})).json(),onSuccess:n=>{o({username:n.username,password:n.oneTimePassword}),r(""),l(""),Ee.invalidateQueries({queryKey:["/api/admin/users"]})},onError:async n=>{var S;l(((S=n==null?void 0:n.message)==null?void 0:S.replace(/^\d+:\s*/,""))||"No se pudo crear el usuario.")}}),b=De({mutationFn:n=>Oe("DELETE",`/api/admin/users?username=${encodeURIComponent(n)}`),onSuccess:()=>Ee.invalidateQueries({queryKey:["/api/admin/users"]}),onError:()=>l("No se pudo eliminar el usuario.")});return a.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-gray-900/50 backdrop-blur-sm px-4 animate-in fade-in duration-200",role:"dialog","aria-modal":"true",onClick:s,"data-testid":"modal-users",children:a.jsx("div",{className:"w-full max-w-lg rounded-2xl bg-white shadow-2xl overflow-hidden animate-in zoom-in-95 slide-in-from-bottom-2 duration-200",onClick:n=>n.stopPropagation(),children:c?a.jsx(yt,{username:c.username,password:c.password,onDone:()=>o(null)}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-100",children:[a.jsxs("div",{className:"flex items-center gap-2.5",children:[a.jsx(Je,{className:"w-5 h-5 text-[#1bbca3]"}),a.jsx("h3",{className:"font-bold text-gray-800",children:"Usuarios del blog"})]}),a.jsx("button",{onClick:s,className:"text-gray-400 hover:text-gray-600 p-1 rounded-md hover:bg-gray-100","aria-label":"Cerrar","data-testid":"button-close-users",children:a.jsx(ze,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"px-6 py-5",children:[a.jsxs("form",{onSubmit:n=>{n.preventDefault(),e.trim()&&g.mutate(e.trim())},className:"flex gap-2 mb-5",children:[a.jsx("input",{value:e,onCh
2ange:n=>r(n.target.value),placeholder:"Nombre del nuevo editor",className:"flex-1 px-3 py-2 text-sm border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#1bbca3]/40 focus:border-[#1bbca3]","data-testid":"input-new-username"}),a.jsxs("button",{type:"submit",disabled:!e.trim()||g.isPending,style:{backgroundColor:_e},className:"px-4 py-2 text-sm font-semibold text-white rounded-lg hover:opacity-90 disabled:opacity-40 inline-flex items-center gap-2 whitespace-nowrap","data-testid":"button-create-user",children:[g.isPending?a.jsx(Ye,{className:"w-4 h-4 animate-spin"}):a.jsx(gt,{className:"w-4 h-4"}),"Crear"]})]}),i&&a.jsx("p",{className:"mb-4 text-sm text-red-600 bg-red-50 border border-red-200 rounded-lg px-3 py-2","data-testid":"text-users-error",children:i}),p?a.jsx("p",{className:"text-sm text-gray-400 py-6 text-center",children:"Cargando usuarios..."}):v.length===0?a.jsxs("div",{className:"text-center py-8",children:[a.jsx("p",{className:"text-sm text-gray-500",children:"TodavÃa no hay otros editores."}),a.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Crea uno y entrégale la clave de un solo uso."})]}):a.jsx("ul",{className:"divide-y divide-gray-100 border border-gray-200 rounded-xl overflow-hidden",children:v.map(n=>a.jsxs("li",{className:"flex items-center justify-between px-4 py-3 bg-white",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"font-medium text-gray-800 truncate",children:n.username}),a.jsx("p",{className:"text-xs text-gray-400",children:n.mustChangePassword?"Pendiente de su primer ingreso":"Activo"})]}),a.jsx("button",{onClick:()=>b.mutate(n.username),disabled:b.isPending,className:"p-2 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded-md disabled:opacity-40","aria-label":`Eliminar ${n.username}`,"data-testid":`button-delete-user-${n.username}`,children:a.jsx(We,{className:"w-4 h-4"})})]},n.username))})]})]})})})}function Ut(){Ve();const[s,e]=f.useState([]),[r,i]=f.useState(!0),[l,c]=f.useState(null),[o,v]=f.useState(null),[p,g]=f.useState(null),[b,n]=f.useState(!1);async function S(){(await fetch("/api/admin/me",{credentials:"include"})).ok||window.location.assign("/news")}async function j(){i(!0);const h=await fetch("/api/admin/articles",{credentials:"include"});h.ok&&e(await h.json()),i(!1)}
2function F(h,K){v({slug:h,title:K})}async function O(){if(!o)return;const{slug:h}=o;c(h),(await fetch(`/api/admin/articles?slug=${encodeURIComponent(h)}`,{method:"DELETE",credentials:"include"})).ok?e(G=>G.filter(Z=>Z.slug!==h)):g("No se pudo eliminar el artÃculo. Reintenta en unos segundos."),c(null),v(null)}async function E(){await fetch("/api/admin/logout",{method:"POST",credentials:"include"}),window.location.assign("/news")}return f.useEffect(()=>{S().then(j)},[]),a.jsxs("div",{className:"min-h-screen bg-gray-50",children:[a.jsxs("header",{className:"bg-white border-b border-gray-100 px-4 py-3 flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-7 h-7 bg-[#1bbca3] rounded-md flex items-center justify-center",children:a.jsx("span",{className:"text-white font-bold text-xs",children:"N"})}),a.jsx("span",{className:"font-semibold text-gray-800 text-sm",children:"NeuroUP Noticias"})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("a",{href:"/",className:"text-xs text-gray-400 hover:text-gray-600 transition-colors",children:"Ver sitio"}),a.jsx("button",{onClick:()=>n(!0),className:"text-xs text-gray-500 hover:text-[#1bbca3] transition-colors","data-testid":"button-open-users",children:"Usuarios"}),a.jsx("button",{onClick:E,className:"text-xs text-gray-500 hover:text-red-500 transition-colors","data-testid":"button-logout",children:"Cerrar sesión"})]})]}),a.jsxs("main",{className:"max-w-5xl mx-auto px-4 py-8",children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-xl font-bold text-gray-900",children:"ArtÃculos del blog"}),a.jsxs("p",{className:"text-sm text-gray-500 mt-0.5",children:[s.length," artÃculo",s.length!==1?"s":""," en total"]})]}),a.jsx(ne,{href:"/news/nueva",children:a.jsxs("button",{className:"bg-[#1bbca3] hover:bg-[#17a892] text-white text-sm font-medium px-4 py-2 rounded-lg transition-colors flex items-center gap-2","data-testid":"button-new-article",children:[a.jsx("span",{children:"ï¼"})," Nuevo artÃculo"]})})]}),r?a.jsx("div",{className:"text-center py-16 text-gray-400 text-sm",children:"Cargando artÃculos..."}):s.length===0?a.jsxs("div",{className:"text-center py-16 bg-white rounded-xl border border-gray-100",children:[a.jsx("p",{className:"text-gray-400 text-sm",children:"No hay artÃculos aún."}),a.jsx(ne,{href:"/news/nueva",children:a.jsx("button",{className:"mt-3 text-[#1bbca3] text-sm font-medium hover:underline",children:"Crear el primero"})})]}):a.jsx("div",{className:"bg-white rounded-xl border border-gray-100 overflow-hidden",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-gray-100 text-left",children:[a.jsx("th",{className:"px-4 py-3 text-xs font-semibold text-gray-500 uppercase tracking-wide",children:"TÃtulo"}),a.jsx("th",{className:"px-4 py-3 text-xs font-semibold text-gray-500 uppercase tracking-wide hidden md:table-cell",children:"CategorÃa"}),a.jsx("th",{className:"px-4 py-3 text-xs font-semibold text-gray-500 uppercase tracking-wide hidden sm:table-cell",children:"Autor"}),a.jsx("th",{className:"px-4 py-3 text-xs font-semibold text-gray-500 uppercase tracking-wide hidden lg:table-cell",children:"Fecha"}),a.jsx("th",{className:"px-4 py-3 text-xs font-semibold text-gray-500 uppercase tracking-wide",children:"Estado"}),a.jsx("th",{className:"px-4 py-3"})]})}),a.jsx("tbody",{children:s.map(h=>a.jsxs("tr",{className:"border-b border-gray-50 last:border-0 hover:bg-gray-50 transition-colors",children:[a.jsx("td",{className:"px-4 py-3 font-medium text-gray-800 max-w-xs truncate","data-testid":`text-article-title-${h.slug}`,children:h.title}),a.jsx("td",{className:"px-4 py-3 text-gray-500 hidden md:table-cell",children:h.category||"â"}),a.jsx("td",{className:"px-4 py-3 text-gray-500 hidden sm:table-cell",children:h.author||"â"}),a.jsx("td",{className:"px-4 py-3 text-gray-400 text-xs hidden lg:table-cell",children:h.date||"â"}),a.jsx("td",{className:"px-4 py-3",children:a.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${h.published?"bg-green-50 text-green-600":"bg-yellow-50 text-yellow-600"}`,"data-testid":`status-article-${h.slug}`,children:h.published?"Publicado":"Borrador"})}),a.jsx("td",{className:"px-4 py-3",children:a.jsxs("div",{className:"flex items-center gap-3 justify-end",children:[a.jsx(ne,{href:`/news/editar/${h.slug}`,children:a.jsx("button",{className:"text-[#1bbca3] hover:underline text-xs font-medium","data-testid":`button-edit-${h.slug}`,children:"Editar"})}),a.jsx("button",{onClick:()=>F(h.slug,h.title),disabled:l===h.slug,className:"text-red-400 hover:text-red-600 text-xs font-medium disabled:opacity-50","data-testid":`button-delete-${h.slug}`,children:l===h.slug?"...":"Eliminar"})]})})]},h.slug))})]})})]}),o&&a.jsx(Ge,{title:o.title,deleting:!!l,onConfirm:O,onCancel:()=>v(null)}),b&&a.jsx(vt,{onClose:()=>n(!1)}),p&&a.jsx(Xe,{message:p,onClose:()=>g(null)})]})}export{Ut 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.