1import{r as l,s as n,j as e,t as o}from"./index-u1voOWyK.js";import{B as m}from"./button-DzDkl-FE.js";import{I as u}from"./input-CA6x9EGC.js";import{L as i}from"./label-DlVZV7qR.js";import{T as I}from"./textarea-KQXqZcbQ.js";import{C as g,a as v}from"./card-Inc_xdUB.js";import{S as T}from"./switch-3m5PLwPJ.js";import{S as E,a as k,b as y,c as L,d as O}from"./select-Cq37j6Dg.js";import{D as A,f as q,a as z,b as B,c as P}from"./dialog-RfK7Hfj8.js";import{S as V}from"./S3MediaPicker-D3Mlc0IY.js";import{L as j}from"./loader-circle-CUqtV-ar.js";import{P as $}from"./plus-C_W2yhbI.js";import{S as N}from"./save-Da0Ic4Zq.js";import{T as f}from"./tag-AkwL6len.js";import{I as F}from"./image-Cm3OwR_i.js";import{T as H}from"./trash-2-5gTi04vr.js";import"./index-BTyM2oEZ.js";import"./index-BdQq_4o_.js";import"./index-BbnJ9368.js";import"./Combination-DJ_CZLQa.js";import"./chevron-down-Rj4olIZD.js";import"./check-CrGuBdTW.js";import"./index-B-BebqpP.js";import"./scroll-area-8DbX1aaz.js";import"./useMediaManager-Dpwz_aGG.js";import"./useCustomStorage-CkdofJjk.js";import"./search-DDA8_SET.js";import"./layout-grid-qauo_NOC.js";import"./list-Bp_c7kJP.js";import"./link-CA7q5ntW.js";import"./upload-YyAV-qAc.js";
1import"./circle-alert-6DUF82vB.js";import"./file-BQYYjE1m.js";import"./file-text-DrIOS0gf.js";const M=[{value:"none",label:"Nenhum"},{value:"users",label:"Usuários (Adultos)"},{value:"baby",label:"Bebê (Infantil)"},{value:"bike",label:"Bicicleta (Aventuras)"},{value:"sparkles",label:"Estrelas (Especial)"}];function we(){const[p,b]=l.useState([]),[C,_]=l.useState(!0),[w,d]=l.useState(!1),[s,t]=l.useState(null),[h,c]=l.useState(!1);l.useEffect(()=>{x()},[]);const x=async()=>{const{data:a,error:r}=await n.from("leisure_categories").select("*").order("sort_order",{ascending:!0});!r&&a&&b(a),_(!1)},S=async()=>{if(!s?.name){o({title:"Nome é obrigatório",variant:"destructive"});return}c(!0);const a={name:s.name,description:s.description,is_active:s.is_active??!0,sort_order:s.sort_order||0,image_url:s.image_url,icon_name:s.icon_name==="none"?null:s.icon_name,tooltip:s.tooltip,updated_at:new Date().toISOString()};if(s.id){const{error:r}=await n.from("leisure_categories").update(a).eq("id",s.id);if(r){o({title:"Erro ao salvar",description:r.message,variant:"destructive"}),c(!1);return}}else{const{error:r}=await n.from("leisure_categories").insert(a);if(r){o({title:"Erro ao salvar",description:r.message,variant:"destructive"}),c(!1);return}}c(!1),d(!1),t(null),x(),o({title:"Categoria salva!"})},D=async a=>{if(!confirm("Tem certeza que deseja excluir esta categoria?"))return;const{error:r}=await n.from("leisure_categories").delete().eq("id",a);if(r){o({title:"Erro ao excluir",description:r.message,variant:"destructive"});return}x(),o({title:"Categoria excluÃda!"})};return C?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(j,{className:"h-8 w-8 animate-spin text-blue-500"})}):e.jsxs("div",{className:"p-6 lg:p-8 space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold text-slate-100",children:"Categorias de Programação"}),e.jsx("p",{className:"text-slate-500 text-sm mt-1",children:"Turmas e categorias para programações de lazer"})]}),e.jsxs(A,{open:w,onOpenChange:d,children:[e.jsx(q,{asChild:!0,children:e.jsxs(m,{onClick:()=>t({is_active:!0,sort_order:0}),className:"bg-blue-600 hover:bg-blue-700 text-white",children:[e.jsx($,{className:"h-4 w-4 mr-2"})," Nova Categoria"]})}),e.jsxs(z,{className:"max-w-lg bg-[#0f1629] border-[#1e2a4a]",children:[e.jsx(B,{children:e.jsxs(P,{className:"text-slate-100",children:[s?.id?"Editar":"Nova"," Categoria"]})}),e.jsxs("div",{className:"space-y-4 max-h-[70vh] overflow-y-auto pr-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{className:"text-slate-300",children:"Nome *"}),e.jsx(u,{value:s?.name||"",onChange:a=>t({...s,name:a.target.value}),placeholder:"Ex: Infantil, Adulto, FamÃlia",className:"bg-[#0a0e1a] border-[#1e2a4a] text-slate-200"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{className:"text-slate-300",children:"Descrição"}),e.jsx(I,{value:s?.description||"",onChange:a=>t({...s,description:a.target.value}),className:"bg-[#0a0e1a] border-[#1e2a4a] text-slate-200",placeholder:"Descrição da categoria"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{className:"text-slate-300",children:"Tooltip (texto ao passar o mouse)"}),e.jsx(u,{value:s?.tooltip||"",onChange:a=>t({...s,tooltip:a.target.value}),placeholder:"Atividades para crianças de 4 a 10 anos",className:"bg-[#0a0e1a] border-[#1e2a4a] text-slate-200"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{className:"text-slate-300",children:"Imagem"}),e.jsx(V,{value:s?.image_url||"",onChange:a=>t({...s,image_url:a}),accept:"image"}),s?.image_url&&e.jsx("img",{src:s.image_url,className:"w-20 h-20 object-cover rounded-full mt-2"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{className:"text-slate-300",children:"Ãcone (se não tiver imagem)"}),e.jsxs(E,{value:s?.icon_name||"none",onValueChange:a=>t({...s,icon_name:a}),children:[e.jsx(k,{className:"bg-[#0a0e1a] border-[#1e2a4a] text-slate-200",children:e.jsx(y,{placeholder:"Selecione um Ãcone"})}),e.jsx(L,{className:"bg-[#0f1629] border-[#1e2a4a]",children:M.map(a=>e.jsx(O,{value:a.value,className:"text-slate-200 focus:bg-[#1a2744]",children:a.label},a.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{className:"text-slate-300",children:"Ordem"}),e.jsx(u,{type:"number",value:s?.sort_order||0,onChange:a=>t({...s,sort_order:parseInt(a.target.value)||0}),className:"bg-[#0a0e1a] border-[#1e2a4a] text-slate-200"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(T,{checked:s?.is_active??!0,onCheckedChange:a=>t({...s,is_active:a})}),e.jsx(i,{className:"text-slate-300",children:"Ativa"})]}),e.jsxs(m,{onClick:S,className:"w-full bg-blue-600 hover:bg-blue-700 text-white",disabled:h,children:[h?e.jsx(j,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(N,{className:"h-4 w-4 mr-2"}),"Salvar"]})]})]})]})]}),p.length===0?e.jsx(g,{className:"rounded-xl bg-[#0f1629] border border-[#1e2a4a]",children:e.jsxs(v,{className:"py-12 text-center",children:[e.jsx(f,{className:"w-12 h-12 mx-auto mb-4 text-slate-600"}),e.jsx("p",{className:"text-slate-400",children:"Nenhuma categoria cadastrada"}),e.jsx("p",{className:"text-sm text-slate-500",children:'Clique em "Nova Categoria" para começar'})]})}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:p.map(a=>e.jsx(g,{className:`rounded-xl bg-[#0f1629] border border-[#1e2a4a] ${a.is_active?"":"opacity-60"}`,children:e.jsx(v,{className:"p-4",children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[a.image_url?e.jsx("img",{src:a.image_url,className:"w-12 h-12 rounded-full object-cover",alt:a.name}):e.jsx("div",{className:`p-2 rounded-lg ${a.is_active?"bg-blue-500/20 text-blue-400":"bg-[#0a0e1a] text-slate-500"}`,children:a.icon_name?e.jsx(F,{className:"w-5 h-5"}):e.jsx(f,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-slate-100",children:a.name}),a.description&&e.jsx("p",{className:"text-sm text-slate-400 line-clamp-2",children:a.description}),a.tooltip&&e.jsx("p",{className:"text-xs text-slate-500 mt-1 italic",children:a.tooltip}),e.jsxs("p",{className:"text-xs text-slate-500 mt-1",children:["Ordem: ",a.sort_order]})]})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(m,{variant:"ghost",size:"icon",onClick:()=>{t(a),d(!0)},className:"text-slate-400 hover:text-slate-200 hover:bg-[#1a2744]",children:e.jsx(N,{className:"h-4 w-4"})}),e.jsx(m,{variant:"ghost",size:"icon",onClick:()=>D(a.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:e.jsx(H,{className:"h-4 w-4"})})]})]})})},a.id))})]})}export{we 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.