1import{h as E,j as e,r as x}from"./index-Dv5_VdR4.js";import{a3 as G,u as R,P as U,a as b}from"./DashboardLayout-BoiYKGPL.js";import{E as O}from"./Button-BBxVbTY4.js";import"./checkbox-rfv9N2pr.js";import{S as $,a as W,b as _,c as q,d as N}from"./select-BwBh6j7s.js";import{B as C}from"./button-BNq5u0IO.js";import"./separator-C06W94ZU.js";import{D as X,a as J,b as K,c as Q}from"./dialog-vd3RPwcc.js";import{I as Y}from"./input-DyzflNfw.js";import"./label-kfdxHPTk.js";import"./tabs-DfGFDO4E.js";import{P as Z,a as ee,b as se}from"./popover-Cv42vBRm.js";import"./radio-group-CQ_jeFsA.js";import"./video-DM_orobI.js";import"./schema-BqAfI-VN.js";import{C as ae}from"./create-action-button-CKwfNdJS.js";import{T as te,a as re,b as v,c as d,d as ie,e as m}from"./table-CPf_WPBi.js";import"./alert-dialog-BokM4nZS.js";import"./pagination-DN03aN_5.js";import"./rich-content-DsJiU72S.js";import"./InputField-DDU_WnMn.js";import{S as le}from"./StatusBadge-Bayl2ZAx.js";import{B as j}from"./badge-BPL0OLa4.js";import{T as oe}from"./TruncatedWithTooltip-QC8sn_RV.js";import{D as ne}from"./DeleteConfirmationModal-BDVu0VNe.js";import{i as ce,g as V,a as D}from"./publicationUtils-BsFlRUrC.js";import{I as me}from"./Combination-DXGo4Ofw.js";import{G as de}from"./GenericPagination-9QDAeBCH.js";import{u as xe}from"./useVideos-C9g7GcqH.js";import{u as ue}from"./useVideosMutations-CchLtLEw.js";import{u as he}from"./useDebounce-mBvd2nnI.js";import"./textarea-Yx1VMO03.js";import"./command-zSd6lJY5.js";import{f as ge}from"./format-CF7xCLk1.js";import{p as pe}from"./pt-BR-B-RBtcJQ.js";import"./house-D9xc_JPh.js";import"./index-BlG7SVE_.js";import"./datetime-BadLwWuy.js";import"./types-BeuqWv6e.js";import"./storage-limits-B1zJFB2s.js";import"./Label-B3MFjgEp.js";import"./useMutation-BpEjbdkF.js";const y=()=>{const t=E();return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Lista de videos"}),e.jsx("p",{className:"mt-1 text-gray-600",children:"Gerencie videos, status e publicacoes"})]}),e.jsx(ae,{onClick:()=>t("/publicacao/videos/novo"),children:"Novo video"})]})},je=({searchTerm:t,onSearchChange:n,statusFilter:c,onStatusFilterChange:l})=>e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 mb-6",children:[e.jsx("div",{className:"flex-1",children:e.jsx(Y,{placeholder:"Buscar por tÃtulo do vÃdeo...",value:t,onChange:o=>n(o.target.value),className:"w-full"})}),e.jsxs($,{value:c,onValueChange:l,children:[e.jsx(W,{className:"w-full sm:w-[180px]",children:e.jsx(_,{placeholder:"Status"})}),e.jsxs(q,{children:[e.jsx(N,{value:"all",children:"Todos"}),e.jsx(N,{value:"Ativo",children:"Ativo"}),e.jsx(N,{value:"Inativo",children:"Inativo"})]})]})]}),I=3,fe=({src:t,alt:n,onClick:c})=>{const[l,o]=x.useState(!1);return!t||l?e.jsx("div",{className:"w-10 h-10 rounded-full overflow-hidden bg-gray-100 flex items-center justify-center",children:e.jsx(me,{size:20,className:"text-gray-400"})}):e.jsx("button",{onClick:c,className:"w-10 h-10 rounded-full overflow-hidden bg-gray-100 flex items-center justify-center cursor-pointer hover:ring-2 hover:ring-primary hover:ring-offset-2 transition-all",title:"Clique para ver a imagem",children:e.jsx("img",{src:t,alt:n,className:"w-full h-full object-cover",onError:()=>o(!0)})})},be=({categorias:t})=>{if(!t||t.length===0)return e.jsx("span",{className:"text-gray-400 text-sm",children:"â"});const n=t.slice(0,I),c=t.slice(I),l=c.length>0;return e.jsxs("div",{className:"flex flex-wrap gap-1 items-center",children:[n.map((o,r)=>e.jsx(j,{variant:"secondary",className:"text-xs whitespace-nowrap",children:o},r)),l&&e.jsxs(Z,{children:[e.jsx(ee,{asChild:!0,children:e.jsxs("button",{className:"text-xs text-gray-500 hover:text-gray-700 hover:underline cursor-pointer font-medium whitespace-nowrap",children:["+",c.length," mais"]})}),e.jsx(se,{className:"w-72 p-3",align:"start",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium text-sm text-gray-900",children:"Todas as categorias"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:t.map((o,r)=>
1e.jsx(j,{variant:"secondary",className:"text-xs",children:o},r))})]})})]})]})},Ne=({videos:t,onView:n,onEdit:c,onDelete:l,isDeleting:o=!1})=>{const[r,h]=x.useState(null);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded-lg border border-gray-200 overflow-hidden animate-fade-in",children:e.jsxs(te,{children:[e.jsx(re,{children:e.jsxs(v,{className:"bg-gray-50",children:[e.jsx(d,{className:"font-semibold w-20",children:"ID"}),e.jsx(d,{className:"font-semibold w-14",children:"Thumbnail"}),e.jsx(d,{className:"font-semibold min-w-[200px]",children:"TÃtulo"}),e.jsx(d,{className:"font-semibold w-56",children:"Categorias"}),e.jsx(d,{className:"font-semibold w-36",children:"Data/Horário"}),e.jsx(d,{className:"font-semibold w-28",children:"Autor"}),e.jsx(d,{className:"font-semibold w-20",children:"Status"}),e.jsx(d,{className:"font-semibold w-36",children:"Status Publicação"}),e.jsx(d,{className:"text-right font-semibold w-24",children:"Ações"})]})}),e.jsx(ie,{children:t.length===0?e.jsx(v,{children:e.jsx(m,{colSpan:9,className:"text-center py-8 text-gray-500",children:"Nenhum vÃdeo encontrado"})}):t.map(s=>e.jsxs(v,{className:"hover:bg-gray-50 transition-colors duration-200",children:[e.jsx(m,{className:"font-medium text-gray-600",children:s.realId?e.jsx(oe,{value:s.realId,max:8}):s.id.toString().padStart(3,"0")}),e.jsx(m,{children:e.jsx(fe,{src:s.thumbnailUrl,alt:`Thumbnail de ${s.titulo}`,onClick:()=>s.thumbnailUrl&&h({url:s.thumbnailUrl,title:s.titulo})})}),e.jsx(m,{className:"font-medium min-w-[200px]",children:e.jsx("div",{className:"line-clamp-2 break-words",children:s.titulo})}),e.jsx(m,{children:e.jsx(be,{categorias:s.categorias||[]})}),e.jsx(m,{className:"text-gray-600 whitespace-nowrap text-sm",children:s.dataHoraPublicacao||"â"}),e.jsx(m,{className:"text-gray-600",children:s.autor||"Não informado"}),e.jsx(m,{children:e.jsx(le,{status:s.status})}),e.jsx(m,{children:ce(s.dataPublicacao)?e.jsxs(j,{variant:D(s.dataPublicacao),className:"flex items-center gap-1 w-fit",children:[e.jsx(G,{size:12}),V(s.dataPublicacao)]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(j,{variant:D(s.dataPublicacao),className:"flex items-center gap-1 w-fit",children:[e.jsx(R,{size:12}),V(s.dataPublicacao)]}),e.jsx("span",{className:"text-sm text-gray-500",children:new Date(s.dataPublicacao).toLocaleDateString("pt-BR")})]})}),e.jsx(m,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>n(s.id),className:"h-8 w-8 p-0 hover:bg-gray-100",title:"Visualizar vÃdeo",children:e.jsx(O,{size:16,className:"text-gray-500"})}),e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>c(s.id),className:"h-8 w-8 p-0 hover:bg-gray-100",title:"Editar vÃdeo",children:e.jsx(U,{size:16,className:"text-gray-500"})}),e.jsx(ne,{itemTitle:s.titulo,itemType:"vÃdeo",onConfirm:()=>l(s.id),isLoading:o})]})})]},s.id))})]})}),e.jsx(X,{open:!!r,onOpenChange:()=>h(null),children:e.jsxs(J,{className:"max-w-3xl",children:[e.jsx(K,{children:e.jsx(Q,{className:"line-clamp-1",children:r==null?void 0:r.title})}),e.jsx("div",{className:"flex items-center justify-center",children:r&&e.jsx("img",{src:r.url,alt:r.title,className:"max-h-[70vh] w-auto object-contain rounded-lg"})})]})})]})},ve=t=>ge(new Date(t),"dd/MM/yyyy 'à s' HH:mm",{locale:pe}),ye=()=>{const t=E(),[n,c]=x.useState(""),[l,o]=x.useState("all"),[r,h]=x.useState(1),[s,we]=x.useState(10),w=he(n,500),B=x.useMemo(()=>({page:r,limit:s,title:w||void 0,status:l==="all"?void 0:l}),[r,s,w,l]),{data:g,isLoading:A,error:f}=xe(B),S=ue(),p=(g==null?void 0:g.data)??[],L=x.useMemo(()=>p.map((a,u)=>{var i,T;return{id:(r-1)*s+u+1,realId:a.id,titulo:a.title,descricao:a.description||a.summary||"",autor:(i=a.author)==null?void 0:i.name,status:a.status,dataPublicacao:new Date(a.publicationDate).toISOString(),thumbnailUrl:a.thumbnailUrl||a.imageLink||a.imageUrl,summary:a.summary,categorias:((T=a.tags)==null?void 0:T.map(F=>F.name))||[],dataHoraPublicacao:ve(a.publicationDate)}}),[p,r,s]),P=(g==null?void 0:g.total)??0,k=Math.max(1,Math.ceil(P/s)),M=a=>{const u=a-(r-1)*s-1,i=p[u];i!=null&&i.id&&t(`/publicacao/videos/view/${i.id}`)},H=a=>{const u=a-(r-1)*s-1,i=p[u];i!=null&&i.id&&t(`/publicacao/videos/editar/${i.id}`)},z=a=>{const u=a-(r-1)*s-1,i=p[u];i!=null&&i.id&&S.mutate(i.id)};return A?e.jsx(b,{headerTitle:"VÃdeos",headerSubtitle:"Gerencie os vÃdeos do sistema",children:e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsx(y,{}),e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-[#27A697] mx-auto"}),e.jsx("p",{className:"mt-2 text-gray-600",children:"Carregando vÃdeos..."})]})})]})}):f?e.jsx(b,{headerTitle:"VÃdeos",headerSubtitle:"Gerencie os vÃdeos do sistema",children:e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsx(y,{}),e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-red-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx("svg",{className:"w-8 h-8 text-red-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"})})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"Erro ao carregar vÃdeos"}),e.jsx("p",{className:"text-sm text-gray-600 mb-4",children:f instanceof Error?f.message:"Erro desconhecido"}),e.jsx("button",{onClick:()=>window.location.reload(),className:"inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-[#27A697] hover:bg-[#1E8A7A] focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-[#27A697]",children:"Tentar novamente"})]})})]})}):e.jsx(b,{headerTitle:"VÃdeos",headerSubtitle:"Gerencie os vÃdeos do sistema",children:e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsx(y,{}),e.jsx(je,{searchTerm:n,onSearchChange:a=>{c(a),h(1)},statusFilter:String(l),onStatusFilterChange:a=>{o(a),h(1)}}),e.jsx(Ne,{videos:L,onView:M,onEdit:H,onDelete:z,isDeleting:S.isPending}),e.jsx("div",{className:"mt-6",children:e.jsx(de,{currentPage:r,totalPages:k,onPageChange:h,totalItems:P,itemsPerPage:s,itemLabel:"vÃdeos"})})]})})};console.log("Videos.tsx: Loading Videos page component");const xs=()=>(console.log("Videos.tsx: Rendering Videos component"),e.jsx(ye,{}));export{xs 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.