PageSourceSearch

https://7maravilhas.pt/build/assets/category-DdMIS7nG.js

js 7maravilhas.pt collected 2026-09-24 23:51:04 UTC 11,113 bytes, 6 lines download raw bytes

1import{r as f,a as R,j as e,Y as N,m as G}from"./app-Ce8cAmW-.js";import{M as L,X as _}from"./main-layout-C-X_DRHS.js";import{A as P}from"./arrow-left-LRlQ-iPB.js";import{C as W}from"./chevron-left-DLtF4d4Z.js";import{C as k}from"./chevron-right-Cn40fT_Z.js";import{C as Y}from"./circle-alert-By6rAmmI.js";import{I as q}from"./info-CxJPxxjS.js";import{T as z}from"./triangle-alert-rYQvvzhB.js";import{C as J}from"./check-DhGwiBDQ.js";import{c as X}from"./primary-button-hvRD1VpQ.js";/* empty css            */import"./index-skiHflQy.js";import"./index-BLDRET_f.js";/**
2 * @license lucide-react v0.475.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const B=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],H=X("GripVertical",B);function K({monument:l,isSelected:h,liveRank:u,selectedCount:c,maxVotes:m,onToggle:x,onViewDetails:t,isLocked:g,isToggling:i}){const s=c<m||h,v=u?8-u:null;return e.jsxs("div",{className:`bg-card overflow-hidden rounded-lg border-2 transition-all ${h?"border-primary shadow-md":"border-border hover:border-primary/30"}`,children:[e.jsxs("div",{className:"relative cursor-pointer",onClick:t,children:[l.image_url?e.jsx("img",{src:l.image_url,alt:l.name,className:"h-28 w-full object-cover"}):e.jsx("div",{className:"bg-muted flex h-28 w-full items-center justify-center",children:e.jsx("span",{className:"text-muted-foreground text-xs",children:"Sem imagem"})}),h&&u&&e.jsxs("div",{className:"absolute top-2 left-2 flex items-center gap-1",children:[e.jsx("div",{className:"bg-primary text-primary-foreground flex h-6 w-6 items-center justify-center rounded-full text-xs font-bold shadow-lg",children:u}),e.jsxs("div",{className:"rounded-full bg-black/60 px-1.5 py-0.5 text-[10px] font-semibold text-white shadow",children:[v,"pts"]})]})]}),e.jsxs("div",{className:"p-3",children:[e.jsx("h4",{className:"text-foreground hover:text-primary mb-1 line-clamp-1 cursor-pointer text-sm font-medium",onClick:t,children:l.name}),e.jsx("p",{className:"text-muted-foreground mb-3 text-xs",children:l.municipality}),!g&&(h?e.jsxs("button",{onClick:x,disabled:i,className:"text-destructive border-destructive/30 hover:bg-destructive/10 flex w-full items-center justify-center gap-1 rounded-lg border px-3 py-1.5 text-sm font-medium transition-colors disabled:opacity-50",children:[e.jsx(_,{className:"h-4 w-4"}),"Remover"]}):e.jsxs("button",{onClick:x,disabled:i||!s,className:"text-primary border-primary/30 hover:bg-primary/10 flex w-full items-center justify-center gap-1 rounded-lg border px-3 py-1.5 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(J,{className:"h-4 w-4"}),"Selecionar"]}))]})]})}function Q({items:l,onReorder:h,onRemove:u,isLocked:c,maxVotes:m}){const[x,t]=f.useState(null),[g,i]=f.useState(null),s=(a,n)=>{c||(t(n),a.dataTransfer.effectAllowed="move")},v=(a,n)=>{a.preventDefault(),!(c||x===null)&&i(n)},y=()=>{if(c||x===null||g===null){t(null),i(null);return}if(x!==g){const a=[...l],[n]=a.splice(x,1);a.splice(g,0,n),h(a)}t(null),i(null)};return l.length===0?e.jsxs("div",{className:"text-muted-foreground py-6 text-center",children:[e.jsx("p",{className:"text-sm",children:"Ainda não selecionou nenhum monumento."}),e.jsxs("p",{className:"mt-1 text-xs",children:["Selecione ",m," monumentos da lista."]})]}):e.jsx("div",{className:"space-y-1.5",children:l.map((a,n)=>e.jsxs("div",{draggable:!c,onDragStart:b=>s(b,n),onDragOver:b=>v(b,n),onDragEnd:y,className:`bg-card border-border flex items-center gap-2 rounded-lg border p-2 transition-all ${c?"":"cursor-grab active:cursor-grabbing"} ${g===n?"border-primary bg-primary/5":""} ${x===n?"opacity-50":""}`,children:[!c&&e.jsx(H,{className:"text-muted-foreground h-3 w-3 shrink-0"}),e.jsx("div",{className:"bg-primary text-primary-foreground flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-xs font-bold",children:n+1}),a.image_url&&e.jsx("img",{src:a.image_url,alt:a.name,className:"h-8 w-8 shrink-0 rounded object-cover"}),e.jsx("div",{className:"min-w-0 flex-grow",children:e.jsx("p",{className:"text-foreground truncate text-xs font-medium",children:a.name})}),e.jsxs("span",{className:"text-primary bg-primary/10 shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-semibold",children:[8-(n+1),"pts"]}),!c&&e.jsx("button",{onClick:()=>u(a.id),className:"text-muted-foreground hover:text-destructive p-1 transition-colors",children:e.jsx(_,{className:"h-3 w-3"})})]},a.id))})}function ce({category:l,specialist:h,monuments:u,selectedMonuments:c,isLocked:m,phase:x,maxVotes:t,prevCategory:g,nextCategory:i}){const[s,v]=f.useState(c),[y,a]=f.useState(!1),[n,b]=f.useState(null),[D,T]=f.useState(null),[I,C]=f.useState(!1),w=f.useRef(null),j=u.length>0,M=h.district?`Não existem monumentos no distrito de ${h.district} para a categoria ${l.shortLabel}.`:`Não existem monumentos disponíveis para a categoria ${l.shortLabel}.`,$=async r=>{if(m||D)return;const o=s.some(d=>d.id===r.id);if(!o&&s.length>=t){C(!0),setTimeout(()=>C(!1),3e3);return}T(r.id);try{if((await R.post(route("voting.toggle"),{monument_id:r.id,selected:!o})).status===200){if(o){const p=s.filter(S=>S.id!==r.id);v(p.map((S,F)=>({...S,rank:F+1})))}else v([...s,{...r,rank:s.length+1}]);b(new Date().toLocaleTimeString("pt-PT"))}}finally{T(null)}},A=f.useCallback(r=>{const o=r.map((d,p)=>({...d,rank:p+1}));v(o),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{a(!0),R.post(route("voting.autosave"),{category:l.slug,votes:o.map((d,p)=>({monument_id:d.id,rank:p+1}))}).then(({data:d})=>{d.saved_at&&b(new Date(d.saved_at).toLocaleTimeString("pt-PT"))}).finally(()=>a(!1))},300)},[l.slug]),O=r=>{const o=s.find(d=>d.id===r);o&&$(o)},E=r=>{G.visit(route("voting.monument",{monument:r.slug}))};return e.jsx(L,{title:`Votação - ${l.shortLabel}`,children:e.jsx("div",{className:"bg-background min-h-screen py-4",children:e.jsxs("div",{className:"container mx-auto max-w-7xl px-4",children:[e.jsxs("div",{className:"mt-6 mb-4 flex items-center justify-between",children:[e.jsxs(N,{href:route("voting.dashboard"),
6className:"text-primary hover:text-primary/80 inline-flex items-center gap-1 text-sm",children:[e.jsx(P,{className:"h-4 w-4"}),"Voltar ao Início"]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(N,{href:route("voting.rules"),className:"text-muted-foreground hover:text-primary text-xs transition-colors",children:"Ver Regras"}),e.jsx("div",{className:"text-muted-foreground text-xs",children:y?e.jsx("span",{className:"text-primary",children:"A guardar..."}):n?e.jsxs("span",{children:["Guardado às ",n]}):null})]})]}),e.jsxs("div",{className:"mb-4 flex items-center justify-center gap-4",children:[g?e.jsxs(N,{href:route("voting.category",{slug:g.slug}),className:"text-muted-foreground hover:text-primary flex items-center gap-1 text-sm",children:[e.jsx(W,{className:"h-4 w-4"}),g.shortLabel]}):e.jsx("div",{className:"w-24"}),e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-foreground text-xl font-bold",children:l.shortLabel}),e.jsx("p",{className:"text-muted-foreground text-xs",children:j?`Fase ${x} • Selecione ${t} monumentos`:`Fase ${x} • Sem monumentos disponíveis para votação`})]}),i?e.jsxs(N,{href:route("voting.category",{slug:i.slug}),className:"text-muted-foreground hover:text-primary flex items-center gap-1 text-sm",children:[i.shortLabel,e.jsx(k,{className:"h-4 w-4"})]}):e.jsx("div",{className:"w-24"})]}),I&&e.jsxs("div",{className:"bg-destructive/10 border-destructive/20 mb-4 flex items-center gap-2 rounded-lg border p-3",children:[e.jsx(Y,{className:"text-destructive h-4 w-4 shrink-0"}),e.jsxs("p",{className:"text-destructive text-sm",children:["Já selecionou ",t," monumentos. Remova um para adicionar outro."]})]}),m&&e.jsxs("div",{className:"bg-primary/10 border-primary/20 mb-4 flex items-center gap-2 rounded-lg border p-3",children:[e.jsx(q,{className:"text-primary h-4 w-4 shrink-0"}),e.jsx("p",{className:"text-foreground text-sm",children:"Os votos foram submetidos e não podem ser alterados."})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-3",children:[e.jsxs("div",{className:j?"lg:col-span-2":"lg:col-span-3",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsxs("h2",{className:"text-foreground text-sm font-semibold",children:["Monumentos (",u.length,")"]}),j&&e.jsxs("span",{className:`text-sm font-medium ${s.length===t?"text-green-600":"text-muted-foreground"}`,children:[s.length,"/",t," selecionados"]})]}),j?e.jsx("div",{className:"grid grid-cols-2 gap-2 overflow-y-auto pr-1 md:grid-cols-3",children:u.map(r=>(()=>{const o=s.find(p=>p.id===r.id),d=(o==null?void 0:o.rank)??null;return e.jsx(K,{monument:r,isSelected:s.some(p=>p.id===r.id),liveRank:d,selectedCount:s.length,maxVotes:t,onToggle:()=>$(r),onViewDetails:()=>E(r),isLocked:m,isToggling:D===r.id},r.id)})())}):e.jsxs("div",{className:"border-border bg-muted/20 rounded-lg border border-dashed p-10 text-center",children:[e.jsx("p",{className:"text-foreground text-sm font-medium",children:"Sem monumentos nesta categoria"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:M})]})]}),j&&e.jsxs("div",{children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("h2",{className:"text-foreground text-sm font-semibold",children:"Ordenação"}),!m&&s.length>0&&e.jsx("span",{className:"text-muted-foreground text-[10px]",children:"Arraste para ordenar"})]}),e.jsxs("p",{className:"text-muted-foreground mb-2 text-[10px] leading-snug",children:["Coloque em ",e.jsx("strong",{children:"1.º lugar"})," o património mais relevante. O ",e.jsx("strong",{children:"último lugar"})," deve corresponder ao menos relevante entre os selecionados."]}),e.jsx("div",{className:"bg-muted/30 min-h-[350px] rounded-lg p-3",children:e.jsx(Q,{items:s,onReorder:A,onRemove:O,isLocked:m,maxVotes:t})}),j&&s.length<t&&!m&&e.jsxs("div",{className:"text-muted-foreground mt-3 flex items-start gap-2 text-xs",children:[e.jsx(z,{className:"mt-0.5 h-3 w-3 shrink-0"}),e.jsxs("p",{children:["Faltam ",t-s.length," patrimónios(s)."]})]})]})]}),(j&&s.length===t||!j)&&!m&&e.jsx("div",{className:"mt-4 text-center",children:i?e.jsxs(N,{href:route("voting.category",{slug:i.slug}),className:"bg-primary hover:bg-primary/90 text-primary-foreground inline-flex items-center gap-1 rounded-lg px-4 py-2 text-sm font-medium transition-colors",children:["Próxima: ",i.shortL
6abel,e.jsx(k,{className:"h-4 w-4"})]}):e.jsxs(N,{href:route("voting.summary"),className:"bg-primary hover:bg-primary/90 text-primary-foreground inline-flex items-center gap-1 rounded-lg px-4 py-2 text-sm font-medium transition-colors",children:["Ver Resumo",e.jsx(k,{className:"h-4 w-4"})]})})]})})})}export{ce 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.