PageSourceSearch

https://www.visitecamposdojordao.org.br/assets/RoteirosTematicosList-CZ7L1ocx.js

js visitecamposdojordao.org.br collected 2026-10-02 22:27:07 UTC 28,526 bytes, 1 lines download raw bytes

1import{r as i,j as e}from"./vendor-react-CoH7wDUq.js";import{E as be,m as Z,am as fe,an as ve,ao as Ne,ap as je,aq as ye,ar as we,p as Ce}from"./AdminApp-DKqxBNNv.js";import{p as Ee,B as ke}from"./index-DarzfxaQ.js";import{R as Se}from"./RoteiroImageCarousel-DmmxoWPM.js";import{A as Le,a as Ie,b as Ue,c as U}from"./AdminCard-TGEFBssE.js";import"./vendor-pdf-DNjb9-t8.js";const F=()=>({ativo:!0,localId:null,titulo:"",textoDetalhe:"",imagemEtapaUrl:"",etapaSite:"",etapaInstagram:"",etapaFacebook:"",etapaLat:"",etapaLng:""}),ee=()=>({slug:"",titulo:"",resumo:"",ordem:"0",tag:"",sugeridoCidade:!0,ativo:!0}),ae=()=>({title:"",slug:"",category:"Lazer",description:"",address:"",phone:"",website:"",imageUrl:"",isActive:!0});function G({ativo:u,variant:o,onSetAtivo:d}){const b=o==="compact"?"px-2 py-1 text-[10px]":"px-2.5 py-1.5 text-xs";return e.jsxs("div",{className:"inline-flex shrink-0 overflow-hidden rounded-lg border border-slate-200 bg-white shadow-sm",role:"group","aria-label":"Visibilidade no site",children:[e.jsx("button",{type:"button",onClick:()=>d(!0),className:`font-bold ${b} border-r border-slate-200 transition-colors ${u?"bg-emerald-600 text-white":"text-slate-600 hover:bg-emerald-50"}`,children:"Ativar"}),e.jsx("button",{type:"button",onClick:()=>d(!1),className:`font-bold ${b} transition-colors ${u?"text-slate-600 hover:bg-amber-50":"bg-amber-700 text-white"}`,children:"Desativar"})]})}function te(u){const o=String(u||"").trim();if(!o)return null;const d=/^https?:\/\//i.test(o)?o:Ee(o.replace(/^\//,""));return ke(d)?d:null}function Fe(u){var b;const o=new Set,d=[];for(const h of u.etapas??[]){if(h.ativo===!1)continue;let n=null;for(const C of[h.imagemEtapaUrl,(b=h.local)==null?void 0:b.imagem_url]){const j=te(C);if(j){n=j;break}}!n||o.has(n)||(o.add(n),d.push(n))}if(d.length===0){const h=te(u.imagemCapa);h&&d.push(h)}return d}function se(u){const o=String(u||"").trim();if(!o)return null;const d=parseFloat(o.replace(",","."));return Number.isFinite(d)?d:null}function Ae(u){return u.map((o,d)=>({titulo:o.titulo.trim()||(o.localId&&o.localNomeCurto?o.localNomeCurto.trim():"")||`Etapa ${d+1}`,ativo:o.ativo!==!1,textoDetalhe:o.textoDetalhe.trim()?o.textoDetalhe:null,ordem:d,localId:o.localId&&o.localId>0?o.localId:null,imagemEtapaUrl:o.imagemEtapaUrl.trim()?o.imagemEtapaUrl.trim():null,etapaSite:o.etapaSite.trim()?o.etapaSite.trim():null,etapaInstagram:o.etapaInstagram.trim()?o.etapaInstagram.trim():null,etapaFacebook:o.etapaFacebook.trim()?o.etapaFacebook.trim():null,etapaLat:se(o.etapaLat),etapaLng:se(o.etapaLng)}))}function Ge(){const[u,o]=i.useState([]),[d,b]=i.useState(!0),[h,n]=i.useState(""),[C,j]=i.useState(null),[A,R]=i.useState(!1),[m,f]=i.useState(ee),[y,v]=i.useState([F()]),[P,z]=i.useState(!1),[E,k]=i.useState(null),[S,w]=i.useState(""),[M,D]=i.useState([]),[le,B]=i.useState(!1),[_,T]=i.useState(!1),[c,g]=i.useState(ae),[q,H]=i.useState(!1),[oe,N]=i.useState(null),[O,J]=i.useState(null),[Q,W]=i.useState(!1),[V,K]=i.useState(null),$=async()=>{b(!0),n("");try{const a=await fe();o(a)}catch(a){n(a instanceof Error?a.message:"Erro ao carregar roteiros")}finally{b(!1)}};i.useEffect(()=>{$()},[]),i.useEffect(()=>{A||(k(null),w(""),D([]),T(!1),N(null))},[A]),i.useEffect(()=>{if(E===null)return;const a=setTimeout(()=>{B(!0),be({q:S,limit:120}).then(D).catch(()=>D([])).finally(()=>B(!1))},S.trim()?280:0);return()=>clearTimeout(a)},[S,E]);const re=()=>{j(null),f(ee()),v([F()]),N(0),R(!0)},L=()=>{R(!1),j(null),N(null)},ie=async a=>{try{const t=await ve(String(a.id)),l=[...Array.isArray(t.etapas)?t.etapas:[]].sort((s,p)=>(Number.isFinite(s.ordem)?s.ordem:0)-(Number.isFinite(p.ordem)?p.ordem:0));j(t.id),f({slug:t.slug,titulo:t.titulo,resumo:t.resumo??"",ordem:String(t.ordem??0),tag:t.tag??"",sugeridoCidade:t.sugeridoCidade!==!1,ativo:t.ativo!==!1}),v(l.length?l.map(s=>{var p;return{ativo:s.ativo!==!1,localId:s.localId??null,titulo:s.titulo??"",textoDetalhe:s.textoDetalhe??"",imagemEtapaUrl:s.imagemEtapaUrl??"",etapaSite:s.etapaSite??"",etapaInstagram:s.etapaInstagram??"",etapaFacebook:s.etapaFacebook??"",etapaLat:s.etapaLat!=null&&Number.isFinite(Number(s.etapaLat))?String(s.etapaLat):"",etapaLng:s.etapaLng!=null&&Number.isFinite(Number(s.etapaLng))?String(s.etapaLng):"",localNomeCurto:(p=s.local)==null?void 0:p.nome,localAtivo:s.local?s.local.ativo!==!1:void 0}}):[F()]),N(0),R(!0)}catch(t){n(t instanceof Error?t.message:"Erro ao abrir roteiro")}},ne=()=>
1{v(a=>{const t=[...a,F()];return queueMicrotask(()=>N(t.length-1)),t})},ce=a=>{v(t=>t.length<=1?t:t.filter((r,l)=>l!==a)),N(t=>t===null?null:t===a?Math.max(0,a-1):t>a?t-1:t)},X=(a,t)=>{const r=a+t;v(l=>{if(r<0||r>=l.length)return l;const s=[...l];return[s[a],s[r]]=[s[r],s[a]],s})},x=i.useCallback((a,t)=>{v(r=>r.map((l,s)=>s===a?{...l,...t}:l))},[]),de=(a,t)=>{v(r=>r.map((l,s)=>{if(s!==a)return l;const p=l.titulo.trim();return{...l,localId:t.id,localNomeCurto:t.nome,titulo:p?l.titulo:t.nome}})),k(null),w("")},me=a=>{x(a,{localId:null,localNomeCurto:void 0})},ue=async a=>{var r;const t=y[a];if(!(!(t!=null&&t.localId)||t.localId<=0)){J(a),n("");try{const l=await Ne(t.localId),s=t.imagemEtapaUrl.trim(),p={etapaSite:(l.site??"").trim(),etapaInstagram:(l.instagram??"").trim(),etapaFacebook:(l.facebook??"").trim(),etapaLat:l.lat!=null&&Number.isFinite(Number(l.lat))?String(l.lat):"",etapaLng:l.lng!=null&&Number.isFinite(Number(l.lng))?String(l.lng):""};!s&&((r=l.imagem_url)!=null&&r.trim())&&(p.imagemEtapaUrl=l.imagem_url.trim()),x(a,p)}catch(l){n(l instanceof Error?l.message:"Erro ao carregar ficha do local")}finally{J(null)}}},xe=async a=>{a.preventDefault(),z(!0),n("");const t=Ae(y),r={slug:m.slug.trim(),titulo:m.titulo.trim(),resumo:m.resumo,ordem:Number(m.ordem)||0,tag:m.tag.trim()||null,sugeridoCidade:m.sugeridoCidade,ativo:m.ativo,etapas:t};try{C!=null?await je(String(C),r):await ye(r),L(),await $()}catch(l){n(l instanceof Error?l.message:"Erro ao guardar")}finally{z(!1)}}
1,pe=async a=>{if(confirm("Eliminar este roteiro temático?"))try{await we(String(a)),await $()}catch(t){n(t instanceof Error?t.message:"Erro ao eliminar")}},ge=async()=>{if(!c.title.trim()){n("Indique o nome do local.");return}H(!0),n("");try{const a={title:c.title.trim(),slug:c.slug.trim()||void 0,category:c.category,description:c.description.trim()||void 0,address:c.address.trim()||void 0,phone:c.phone.trim()||void 0,website:c.website.trim()||void 0,imageUrl:c.imageUrl.trim()||void 0,isActive:c.isActive},t=await Ce(a),r=t.title??c.title.trim(),l=y.length;v(s=>[...s,{ativo:!0,localId:t.id,titulo:r,textoDetalhe:"",imagemEtapaUrl:"",etapaSite:"",etapaInstagram:"",etapaFacebook:"",etapaLat:"",etapaLng:"",localNomeCurto:r}]),N(l),g(ae()),T(!1)}catch(a){n(a instanceof Error?a.message:"Erro ao criar local")}finally{H(!1)}};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:justify-between sm:items-center gap-3 mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl md:text-2xl font-bold text-slate-800",style:{fontFamily:"'Poppins', sans-serif"},children:"Roteiros temáticos"}),e.jsx("p",{className:"text-sm text-slate-500 mt-1",children:'Conteúdo da página "Roteiros". Use a opção "Sugerir na aba A cidade" para incluir ou excluir cada roteiro do planeador da secção A cidade.'})]}),e.jsx("button",{type:"button",onClick:re,className:"px-4 py-2.5 bg-blue-600 text-white rounded-lg hover:bg-blue-700 font-medium touch-manipulation w-full sm:w-auto",children:"Novo roteiro"})]}),h&&e.jsx("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-lg text-red-700 text-sm",children:h}),A&&e.jsx("div",{className:"fixed inset-0 z-[200] flex items-end sm:items-center justify-center bg-slate-900/50 p-0 sm:p-4",role:"dialog","aria-modal":"true","aria-labelledby":"roteiro-admin-titulo",onClick:L,children:e.jsxs("div",{className:"flex h-[min(92dvh,900px)] w-full max-w-2xl flex-col overflow-hidden rounded-t-2xl border border-slate-200 bg-white shadow-2xl sm:rounded-2xl sm:max-h-[90vh]",onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-slate-200 bg-slate-50 px-4 py-3",children:[e.jsx("h3",{id:"roteiro-admin-titulo",className:"text-base font-bold text-slate-800 truncate pr-2",children:C!=null?"Editar roteiro":"Novo roteiro"}),e.jsx("button",{type:"button",onClick:L,className:"shrink-0 rounded-lg border border-slate-200 bg-white px-3 py-2 text-sm font-medium text-slate-700 hover:bg-slate-100",children:"Fechar"})]}),e.jsxs("form",{onSubmit:xe,className:"flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-4 space-y-5",children:[e.jsxs("details",{open:!0,className:"rounded-xl border border-slate-200 bg-white",children:[e.jsx("summary",{className:"cursor-pointer select-none px-3 py-2.5 text-sm font-bold text-slate-800 hover:bg-slate-50 rounded-t-xl",children:"Dados gerais"}),e.jsxs("div",{className:"space-y-3 border-t border-slate-100 p-3",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs font-medium text-slate-700",children:"Slug (URL)"}),e.jsx("input",{required:!0,value:m.slug,onChange:a=>f(t=>({...t,slug:a.target.value})),className:"w-full px-3 py-2 border rounded-lg text-sm",placeholder:"ex: capivari"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs font-medium text-slate-700",children:"Ordem"}),e.jsx("input",{type:"number",value:m.ordem,onChange:a=>f(t=>({...t,ordem:a.target.value})),className:"w-full px-3 py-2 border rounded-lg text-sm"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs font-medium text-slate-700",children:"Título"}),e.jsx("input",{required:!0,value:m.titulo,onChange:a=>f(t=>({...t,titulo:a.target.value})),className:"w-full px-3 py-2 border rounded-lg text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs font-medium text-slate-700",children:"Resumo"}),e.jsx("textarea",{value:m.resumo,onChange:a=>f(t=>({...t,resumo:a.target.value})),className:"w-full px-3 py-2 border rounded-lg text-sm",rows:3})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs font-medium text-slate-700",children:"Tag (opcional, máx. 80 caracteres)"}),e.jsx("input",{value:m.tag,maxLength:80,onChange:a=>f(t=>({...t,tag:a.target.value})),className:"w-full px-3 py-2 border rounded-lg text-sm",placeholder:"Ex.: região; tema; público-alvo"}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-relaxed",children:["Usada no site como etiqueta curta (filtros futuros, consistência). O assistente de IA responde sobre roteiros principalmente pela ",e.jsx("strong",{children:"base de conhecimento"}),' (categoria "roteiro", pack importado em IA, perguntas/respostas por etapa) — não depende deste campo.']})]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:m.sugeridoCidade,onChange:a=>f(t=>({...t,sugeridoCidade:a.target.checked}))}),"Sugerir na aba A cidade (planeador de roteiros)"]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-relaxed -mt-1",children:["Se desmarcado, o roteiro continua na página ",e.jsx("strong",{children:"Roteiros"}),', mas não entra na rotação de sugestões do bloco "A cidade".']}),e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:m.ativo,onChange:a=>f(t=>({...t,ativo:a.target.checked}))}),"Ativo no site"]}),e.jsxs("p",{className:"text-[11px] text-slate-500 leading-relaxed",children:["O carrossel de imagens na home usa as fotos dos locais ligados e a ",e.jsx("strong",{children:"URL da imagem"}
1)," de cada etapa (obrigatória quando não há local na base)."]})]})]}),e.jsxs("div",{className:"space-y-4 border-t border-slate-200 pt-4",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-slate-800",children:"Etapas"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-0.5 max-w-md",children:"Expanda uma etapa de cada vez. Ligue um local ou indique URL da imagem para pontos só editoriais."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:ne,className:"px-3 py-2 text-xs rounded-lg bg-slate-800 text-white font-semibold hover:bg-slate-900",children:"+ Etapa"}),e.jsx("button",{type:"button",onClick:()=>T(a=>!a),className:"px-3 py-2 text-xs rounded-lg bg-amber-50 text-amber-900 border border-amber-200 font-semibold hover:bg-amber-100",children:_?"Fechar novo local":"+ Novo local (atração)"})]})]}),_?e.jsxs("div",{className:"p-3 rounded-lg border border-amber-200 bg-amber-50/50 space-y-2",children:[e.jsxs("p",{className:"text-xs text-amber-900 font-medium",children:["Cria uma entrada em ",e.jsx("strong",{children:"Atrações"})," (categoria no mapa: lazer, natureza, etc.) e adiciona uma etapa já ligada a esse local — útil quando o ponto ainda não existe na base."]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[e.jsxs("div",{className:"sm:col-span-2 space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-slate-700",children:"Nome *"}),e.jsx("input",{value:c.title,onChange:a=>g(t=>({...t,title:a.target.value})),className:"w-full px-2 py-1.5 border rounded text-sm",placeholder:"Ex.: Parque da Cerejeira"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-slate-700",children:"Slug (opcional)"}),e.jsx("input",{value:c.slug,onChange:a=>g(t=>({...t,slug:a.target.value})),className:"w-full px-2 py-1.5 border rounded text-sm",placeholder:"gerado automaticamente se vazio"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-slate-700",children:"Subcategoria (mapa)"}),e.jsx("input",{value:c.category,onChange:a=>g(t=>({...t,category:a.target.value})),className:"w-full px-2 py-1.5 border rounded text-sm",placeholder:"Lazer"})]}),e.jsxs("div",{className:"sm:col-span-2 space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-slate-700",children:"Descrição"}),e.jsx("textarea",{value:c.description,onChange:a=>g(t=>({...t,description:a.target.value})),className:"w-full px-2 py-1.5 border rounded text-sm",rows:3})]}),e.jsxs("div",{className:"sm:col-span-2 space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-slate-700",children:"Endereço"}),e.jsx("input",{value:c.address,onChange:a=>g(t=>({...t,address:a.target.value})),className:"w-full px-2 py-1.5 border rounded text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-slate-700",children:"Telefone"}),e.jsx("input",{value:c.phone,onChange:a=>g(t=>({...t,phone:a.target.value})),className:"w-full px-2 py-1.5 border rounded text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-slate-700",children:"Site"}),e.jsx("input",{value:c.website,onChange:a=>g(t=>({...t,website:a.target.value})),className:"w-full px-2 py-1.5 border rounded text-sm"})]}),e.jsxs("div",{className:"sm:col-span-2 space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-slate-700",children:"URL da imagem"}),e.jsx("input",{value:c.imageUrl,onChange:a=>g(t=>({...t,imageUrl:a.target.value})),className:"w-full px-2 py-1.5 border rounded text-sm",placeholder:"https://…"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-0.5",children:[e.jsxs("label",{className:"inline-flex items-center gap-2 text-xs text-slate-700 cursor-pointer",children:[e.jsx("span",{className:"px-2 py-1.5 bg-slate-200 rounded-md hover:bg-slate-300",children:Q?"A enviar…":"Carregar imagem do PC"}),e.jsx("input",{type:"file",accept:"image/jpeg,image/png,image/webp,image/gif",className:"sr-only",disabled:Q||q,onChange:async a=>{var r;const t=(r=a.target.files)==null?void 0:r[0];if(a.target.value="",!!t){if(!c.title.trim()){n("Preencha o nome do local antes de carregar a imagem (usamos o nome no ficheiro).");return}n(""),W(!0);try{const{url:l}=await Z(t,c.title);g(s=>({...s,imageUrl:l}))}catch(l){n(l instanceof Error?l.message:"Erro no upload da imagem")}finally{W(!1)}}}})]}),e.jsx("span",{className:"text-[11px] text-slate-500",children:"JPG, PNG, WebP ou GIF"})]})]}),e.jsxs("label",{className:"sm:col-span-2 flex items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:c.isActive,onChange:a=>g(t=>({...t,isActive:a.target.checked}))}),"Local ativo no site"]}),e.jsx("div",{className:"sm:col-span-2 flex gap-2",children:e.jsx("button",{type:"button",disabled:q,onClick:()=>void ge(),className:"px-4 py-2 bg-amber-700 text-white rounded-lg text-sm font-semibold disabled:opacity-50",children:q?"A criar…":"Criar local e adicionar etapa"})})]})]}):null,E!==null?e.jsxs("div",{className:"p-3 rounded-lg border border-indigo-200 bg-indigo-50/60 space-y-2",children:[e.jsxs("p",{className:"text-xs font-semibold text-indigo-900",children:["Escolher local para a etapa ",E+1]}),e.jsx("input",{type:"search",value:S,onChange:a=>w(a.target.value),placeholder:"Pesquisar por nome…",className:"w-full px-3 py-2 border rounded-lg text-sm",autoFocus:!0}),e.jsx("div",{className:"max-h-48 overflow-y-auto rounded border border-indigo-100 bg-white text-sm",children:le?e.jsx("p",{className:"p-2 text-slate-500 text-xs",children:"A pesquisar…"}):M.length===0?e.jsx("p",{className:"p-2 text-slate-500 text-xs",children:"Nenhum resultado. Tente outro termo."}):e.jsx("ul",{className:"divide-y divide-slate-100",children:M.map(a=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"w-full text-left px-3 py-2 hover:bg-indigo-50 text-slate-800",onClick:()=>de(E,a),children:[e.jsx("span",{className:"font-medium",children:a.nome}),e.jsxs("span",{className:"text-slate-500 text-xs ml-2",children:[a.categoria,a.ativo?"":" · inativo"]})]})},a.id))})}),e.jsx("button",{type:"button",className:"text-xs text-indigo-800 underline",onClick:()=>{k(null),w("")},children:"Cancelar escolha"})]}):null,e.jsx("ul",{className:"space-y-2",children:y.map((a,t)=>{const r=oe===t,l=a.titulo.trim()||a.localNomeCurto||`Etapa ${t+1}`;return e.jsxs("li",{className:"rounded-xl border border-slate-200 bg-white overflow-hidden shadow-sm",children:[e.jsxs("div",{className:"flex items-stretch gap-0 border-b border-slate-100/80",children:[e.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center justify-between gap-2 px-3 py-2.5 text-left hover:bg-slate-50",onClick:()=>N(r?null:t),children:[e.jsxs("span",{className:"text-sm font-semibold text-slate-800 min-w-0 truncate",children:[e.jsxs("span",{className:"text-slate-500 font-bold mr-1",children:[t+1,"."]}),l,a.localId?e.jsx("span",{className:"ml-2 text-[10px] font-normal uppercase text-emerald-700",children:"· com local"}):null,a.ativo?null:e.jsx("span",{className:"ml-2 text-[10px] font-semibold uppercase text-amber-800",children:"· invisível"})]}),e.jsx("span",{className:"text-xs text-slate-500 shrink-0",children:r?"▲":"▼"})]}),e.jsx("div",{className:"flex shrink-0 items-center border-l border-slate-200 bg-slate-50/50 px-1.5 py-1",children:e.jsx(G,{variant:"compact",ativo:a.ativo,onSetAtivo:s=>x(t,{ativo:s})})})]}),r?e.jsxs("div",{className:"space-y-3 border-t border-slate-100 bg-slate-50/40 px-3 py-3",children:[e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsx("button",{type:"button",className:"px-2 py-1 text-xs rounded border border-slate-200 bg-white",onClick:()=>X(t,-1),disabled:t===0,children:"↑"}),e.jsx("button",{type:"button",className:"px-2 py-1 text-xs rounded border border-slate-200 bg-white",onClick:()=>X(t,1),disabled:t===y.length-1,children:"↓"}),e.jsx("button",{type:"button",className:"px-2 py-1 text-xs rounded bg-red-50 text-red-800 border border-red-100",onClick:()=>ce(t),disabled:y.length<=1,children:"Remover"})]}),a.localId?e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center sm:justify-between text-sm",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded-lg bg-emerald-100 text-emerald-900 text-xs font-semibold",children:["Ligado: ",a.localNomeCurto??`ID ${a.localId}`]}),a.localAtivo===!1?e.jsx("span",{className:"inline-flex items-center rounded-lg bg-amber-100 px-2 py-1 text-[11px] font-medium text-amber-950",children:"Local inativo nas listagens do site — a parada do circuito continua visível se a etapa estiver ativa."}):null,e.jsx(G,{variant:"inline",ativo:a.ativo,onSetAtivo:s=>x(t,{ativo:s})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",className:"text-xs text-slate-600 underline",onClick:()=>me(t),children:"Remover ligação"}),e.jsx("button",{type:"button",className:"text-xs text-indigo-700 underline font-medium",onClick:()=>{k(t),w("")},children:"Trocar local"}),e.jsx("button",{type:"button",disabled:O===t,className:"text-xs font-semibold rounded-md border border-emerald-200 bg-emerald-50 text-emerald-900 px-2 py-1 hover:bg-emerald-100 disabled:opacity-50",onClick:()=>void ue(t),children:O===t?"A carregar…":"Preencher a partir do mapa"})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("button",{type:"button",className:"text-sm px-3 py-2 rounded-lg bg-indigo-600 text-white font-medium hover:bg-indigo-700 w-full sm:w-auto",onClick:()=>{k(t),w("")},children:"Escolher local na base"}),e.jsxs("div",{className:"flex flex-col gap-2 rounded-lg border border-slate-200 bg-white px-3 py-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("p",{className:"text-xs text-slate-600",children:[e.jsx("span",{className:"font-semibold text-slate-800",children:"Sem local na base:"})," use Ativar / Desativar para ocultar esta paragem no site até voltar a ativar."]}),e.jsx(G,{variant:"inline",ativo:a.ativo,onSetAtivo:s=>x(t,{ativo:s})})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-slate-700",children:"Título (no site)"}),e.jsx("input",{value:a.titulo,onChange:s=>x(t,{titulo:s.target.value}),className:"w-full px-3 py-2 border rounded-lg text-sm bg-white",placeholder:"Nome curto da paragem"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"text-xs font-medium text-slate-700",children:["URL da imagem (carrossel)"," ",a.localId?null:e.jsx("span",{className:"text-amber-700 font-semibold",children:"· recomendado sem local"})]}),e.jsx("input",{value:a.imagemEtapaUrl,onChange:s=>x(t,{imagemEtapaUrl:s.target.value}),className:"w-full px-3 py-2 border rounded-lg text-sm bg-white",placeholder:"https://…"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-0.5",children:[e.jsxs("label",{className:"inline-flex items-center gap-2 text-xs text-slate-700 cursor-pointer",children:[e.jsx("span",{className:"px-2 py-1.5 bg-slate-200 rounded-md hover:bg-slate-300",children:V===t?"A enviar…":"Carregar imagem do PC"}),e.jsx("input",{type:"file",accept:"image/jpeg,image/png,image/webp,image/gif",className:"sr-only",disabled:V!==null||P,onChange:async s=>{var Y;const p=(Y=s.target.files)==null?void 0:Y[0];if(s.target.value="",!p)return;const he=a.titulo.trim()||a.localNomeCurto&&a.localNomeCurto.trim()||m.t
1itulo.trim()||`etapa-${t+1}`;n(""),K(t);try{const{url:I}=await Z(p,he);x(t,{imagemEtapaUrl:I})}catch(I){n(I instanceof Error?I.message:"Erro no upload da imagem")}finally{K(null)}}})]}),e.jsx("span",{className:"text-[11px] text-slate-500",children:"JPG, PNG, WebP ou GIF"})]})]}),e.jsx("p",{className:"text-[11px] text-slate-500 leading-snug -mt-1",children:"Site, redes e coordenadas abaixo são opcionais. Se preencher, aparecem no card público em substituição dos dados do local ligado. Use «Preencher a partir do mapa» para copiar do cadastro."}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-slate-700",children:"Site (URL)"}),e.jsx("input",{value:a.etapaSite,onChange:s=>x(t,{etapaSite:s.target.value}),className:"w-full px-3 py-2 border rounded-lg text-sm bg-white",placeholder:"https://…"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-slate-700",children:"Instagram (URL ou @conta)"}),e.jsx("input",{value:a.etapaInstagram,onChange:s=>x(t,{etapaInstagram:s.target.value}),className:"w-full px-3 py-2 border rounded-lg text-sm bg-white",placeholder:"https://instagram.com/… ou @conta"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-slate-700",children:"Facebook (URL)"}),e.jsx("input",{value:a.etapaFacebook,onChange:s=>x(t,{etapaFacebook:s.target.value}),className:"w-full px-3 py-2 border rounded-lg text-sm bg-white",placeholder:"https://facebook.com/…"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-slate-700",children:"Latitude"}),e.jsx("input",{inputMode:"decimal",value:a.etapaLat,onChange:s=>x(t,{etapaLat:s.target.value}),className:"w-full px-3 py-2 border rounded-lg text-sm bg-white",placeholder:"ex: -22,74"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-slate-700",children:"Longitude"}),e.jsx("input",{inputMode:"decimal",value:a.etapaLng,onChange:s=>x(t,{etapaLng:s.target.value}),className:"w-full px-3 py-2 border rounded-lg text-sm bg-white",placeholder:"ex: -45,59"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-slate-700",children:"Detalhes do roteiro (opcional)"}),e.jsx("textarea",{value:a.textoDetalhe,onChange:s=>x(t,{textoDetalhe:s.target.value}),className:"w-full px-3 py-2 border rounded-lg text-sm bg-white",rows:4,placeholder:"Horários, valores… Aparece abaixo da ficha do local."})]})]}):null]},t)})})]})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2 border-t border-slate-200 bg-slate-50 px-4 py-3",children:[e.jsx("button",{type:"submit",disabled:P,className:"px-5 py-2.5 bg-blue-600 text-white rounded-lg text-sm font-semibold disabled:opacity-50",children:P?"A guardar…":"Guardar"}),e.jsx("button",{type:"button",onClick:L,className:"px-5 py-2.5 bg-white border border-slate-200 rounded-lg text-sm font-medium",children:"Cancelar"})]})]})]})}),d?e.jsx("p",{className:"text-slate-500",children:"A carregar…"}):e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:u.map(a=>{var r;const t=Fe(a);return e.jsxs("div",{className:"rounded-2xl border border-slate-200/90 bg-white shadow-sm overflow-hidden",children:[e.jsx("div",{className:"h-36 bg-gradient-to-br from-slate-100 to-slate-200 relative",children:t.length>0?e.jsx(Se,{images:t,alt:"",className:"h-full w-full",intervalMs:4200}):e.jsx("div",{className:"h-full w-full flex items-center justify-center text-slate-400 text-sm font-medium",children:"Sem imagens (adicione URL por etapa ou ligue um local com foto)"})}),e.jsx(Le,{title:a.titulo,subtitle:`${a.slug} · ordem ${a.ordem}${a.sugeridoCidade===!1?" · só página Roteiros":""}`,status:a.ativo?"active":"inactive",preview:e.jsx("span",{className:"text-slate-600 line-clamp-2",children:a.resumo||"—"}),details:e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(U,{label:"A cidade:",value:a.sugeridoCidade===!1?"Não sugerido":"Incluído nos sugeridos",empty:"—"}),e.jsx(U,{label:"Tag:",value:a.tag,empty:"—"}),e.jsx(U,{label:"Capa (legado):",value:a.imagemCapa,empty:"—"}),e.jsx(U,{label:"Etapas:",value:String(((r=a.etapas)==null?void 0:r.length)??0),empty:"0"})]}),actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>void ie(a),className:Ie,children:"Editar"}),e.jsx("button",{type:"button",onClick:()=>void pe(a.id),className:Ue,children:"Excluir"})]}),className:"border-0 shadow-none rounded-none"})]},a.id)})}),!d&&!u.length&&e.jsx("p",{className:"p-8 text-slate-500 text-center bg-white rounded-2xl border border-slate-200",children:"Nenhum roteiro cadastrado. Use o seed ou crie aqui."})]})}
1export{Ge 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.