PageSourceSearch

https://radreport.com.br/assets/FrasesPage-D3rdxdSB.js

js radreport.com.br collected 2026-09-24 14:36:05 UTC 33,015 bytes, 8 lines download raw bytes

1import{j as e,a as Ge,u as je,k as Ue}from"./vendor-query-skQMsM6X.js";import{r as n}from"./vendor-react-DyYvSSk1.js";import{c as v,p as h,ab as C,aQ as Je,aq as d,aL as le,I as N,r as Q,v as K,x as X,y as Y,z as M,a6 as Qe,a8 as Ke,a9 as Xe,bj as Ye,aR as We,aJ as Ze,am as ve,an as Ne,ao as fe,ap as be,aM as ea,aN as aa,aO as $,aP as H,as as sa,b as P,X as te}from"./index-BGwtrXIa.js";import{C as ye,a as Ce,b as we}from"./collapsible-CSslgSh4.js";import{n as ta,i as re,b as Se,a as Te}from"./templateVariableProcessor-BxWBf8HQ.js";import{a as Re,O as Ve,bO as _e,ae as Ee,F as ra,bt as oa,ak as ia,b1 as De,aH as la,bx as ca,aa as na,ag as da,Y as xa,o as ma,L as ke,t as ua,X as ha,u as ga,br as pa,bg as ja,bH as va}from"./vendor-ui-CCmu0bzQ.js";import{p as Na}from"./parse-CtdOddQZ.js";import{p as Me}from"./pt-BR-0bEujIJO.js";import{T as oe}from"./textarea-ChvLdc2s.js";import{T as fa,a as ba,b as ie,c as k,d as ya,e as S}from"./table-DnRDtd-j.js";import{C as Ca}from"./ConfirmDeleteDialog-rGyCVXaJ.js";import{u as wa}from"./useDebounce-kVyuRpVJ.js";import{R as Sa,a as Ta,b as Va,c as _a}from"./RevisionHistoryTab-IjPlKLlA.js";import"./vendor-supabase-BfoV2C50.js";function Ea({formData:c}){const[m,E]=n.useState({}),[g,W]=n.useState({}),[R,ce]=n.useState(!0),[D,ne]=n.useState(!0),p=n.useMemo(()=>{if(!c.variaveis)return[];try{const l=JSON.parse(c.variaveis);return ta(l)}catch{return[]}},[c.variaveis]),Z=p.length>0,q=n.useMemo(()=>p.filter(l=>{if(re(l)){const i=g[l.nome];return i?i.useDirectVolume?i.directVolume>0:i.x>0||i.y>0||i.z>0:!1}const t=m[l.nome];return t!=null&&t!==""}).length,[p,m,g]),L=p.filter(l=>l.obrigatorio).length,T=p.filter(l=>{if(!l.obrigatorio)return!0;if(re(l)){const i=g[l.nome];return i?i.useDirectVolume?i.directVolume>0:i.x>0||i.y>0||i.z>0:!1}const t=m[l.nome];return t!=null&&t!==""}).length,O=n.useMemo(()=>{const l={...m};return Object.entries(g).forEach(([t,i])=>{i.useDirectVolume?l[t]=i.directVolume:i.x>0&&i.y>0&&i.z>0&&(l[t]=Se(i.x,i.y,i.z))}),l},[m,g]),G=n.useMemo(()=>c.texto?Te(c.texto,O):"",[c.texto,O]),de=n.useMemo(()=>c.conclusao?Te(c.conclusao,O):"",[c.conclusao,O]),V=n.useCallback((l,t)=>{E(i=>({...i,[l]:t}))},[]),z=n.useCallback((l,t,i)=>{W(u=>({...u,[l]:{...u[l]||{x:0,y:0,z:0,directVolume:0,useDirectVolume:!1},[t]:i}}))},[]),ee=n.useCallback(()=>{E({}),W({}),v.info("Valores resetados")},[]),j=n.useCallback(()=>{const l=p.filter(t=>{if(!t.obrigatorio)return!1;if(re(t)){const u=g[t.nome];return u?u.useDirectVolume?u.directVolume<=0:u.x<=0&&u.y<=0&&u.z<=0:!0}const i=m[t.nome];return i==null||i===""});if(l.length>0){v.error(`Campos obrigatórios pendentes: ${l.map(t=>t.descricao||t.nome).join(", ")}`);return}v.success("Frase funcionando corretamente! Variáveis processadas com sucesso.")},[p,m,g]),ae=l=>l.descricao||l.nome.replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase()),x=l=>{const{nome:t,tipo:i,unidade:u,opcoes:I,obrigatorio:_}=l,o=ae(l);if(re(l)){const r=g[t]||{x:0,y:0,z:0,directVolume:0,useDirectVolume:!1},f=r.x>0&&r.y>0&&r.z>0?Se(r.x,r.y,r.z):0;return e.jsxs("div",{className:"space-y-2 p-3 border border-border/50 rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(d,{className:"text-sm font-medium",children:[o," ",_&&e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:r.useDirectVolume?"Direto":"Calcular"}),e.jsx(le,{checked:r.useDirectVolume,onCheckedChange:w=>z(t,"useDirectVolume",w)})]})]}),r.useDirectVolume?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(la,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(N,{type:"number",step:"0.1",min:"0",placeholder:"Volume",value:r.directVolume||"",onChange:w=>z(t,"directVolume",parseFloat(w.target.value)||0),className:"flex-1"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:u||"cm³"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ca,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 flex-1",children:[e.jsx(N,{type:"number",step:"0.1",min:"0",placeholder:"X",value:r.x||"",onChange:w=>z(t,"x",parseFloat(w.target.value)||0)}),e.jsx(N,{type:"number",step:"0.1",min:"0",placeholder:"Y",value:r.y||"",onChange:w=>z(t,"y",parseFloat(w.target.value)||0)}),e.jsx(N,{type:"number",step:"0.1",min:"0",placeholder:"Z",value:r.z||"",onChange:w=>z(t,"z",parseFloat(w.target.value)||0)})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"cm"})]}),f>0&&e.jsxs("p",{className:"text-xs text-muted-foreground pl-6",children:["Volume calculado: ",f.toLocaleStr
1ing("pt-BR",{minimumFractionDigits:1,maximumFractionDigits:1})," ",u||"cm³"]})]})]},t)}if(i==="select"&&I&&I.length>0)return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(d,{className:"text-sm",children:[o," ",_&&e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs(Q,{value:m[t]||"",onValueChange:r=>V(t,r),children:[e.jsx(K,{children:e.jsx(X,{placeholder:"Selecione..."})}),e.jsx(Y,{children:I.map(r=>e.jsx(M,{value:r,children:r},r))})]})]},t);if(i==="boolean"||i==="booleano")return e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs(d,{className:"text-sm",children:[o," ",_&&e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(le,{checked:m[t]||!1,onCheckedChange:r=>V(t,r)})]},t);if(i==="data"){const r=m[t]?Na(m[t],"dd/MM/yyyy",new Date):void 0;return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(d,{className:"text-sm",children:[o," ",_&&e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs(Qe,{children:[e.jsx(Ke,{asChild:!0,children:e.jsxs(h,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e.jsx(na,{className:"mr-2 h-4 w-4"}),m[t]||"Selecione uma data"]})}),e.jsx(Xe,{className:"w-auto p-0",align:"start",children:e.jsx(Ye,{mode:"single",selected:r,onSelect:f=>{f&&V(t,We(f,"dd/MM/yyyy",{locale:Me}))},locale:Me,initialFocus:!0})})]})]},t)}return i==="numero"?e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(d,{className:"text-sm",children:[o," ",_&&e.jsx("span",{className:"text-destructive",children:"*"}),u&&e.jsxs("span",{className:"text-muted-foreground ml-1",children:["(",u,")"]})]}),e.jsx(N,{type:"number",step:"0.1",placeholder:`Digite ${o.toLowerCase()}`,value:m[t]||"",onChange:r=>V(t,parseFloat(r.target.value)||"")})]},t):e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(d,{className:"text-sm",children:[o," ",_&&e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(N,{type:"text",placeholder:`Digite ${o.toLowerCase()}`,value:m[t]||"",onChange:r=>V(t,r.target.value)})]},t)};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-amber-500/10 border border-amber-500/30 rounded-lg p-3",children:e.jsxs("p",{className:"text-sm text-amber-600 dark:text-amber-400 flex items-center gap-2",children:[e.jsx(Re,{className:"h-4 w-4"}),e.jsx("strong",{children:"Modo Simulação:"})," Exatamente como o radiologista verá ao selecionar esta frase."]})}),Z&&e.jsxs(ye,{open:R,onOpenChange:ce,children:[e.jsx(Ce,{asChild:!0,children:e.jsxs(h,{variant:"ghost",className:"w-full justify-between p-3 h-auto",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ve,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:"Variáveis"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(C,{variant:"outline",className:"text-xs",children:[q,"/",p.length," preenchidas"]}),L>0&&T<L&&e.jsxs(C,{variant:"destructive",className:"text-xs",children:[L-T," obrigatórias"]}),R?e.jsx(_e,{className:"h-4 w-4"}):e.jsx(Ee,{className:"h-4 w-4"})]})]})}),e.jsx(we,{children:e.jsx(Je,{className:"max-h-[300px] pr-4",children:e.jsx("div",{className:"space-y-4 p-3 border border-border/50 rounded-lg bg-muted/20",children:p.map(x)})})})]}),e.jsxs(ye,{open:D,onOpenChange:ne,children:[e.jsx(Ce,{asChild:!0,children:e.jsxs(h,{variant:"ghost",className:"w-full justify-between p-3 h-auto",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ra,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:"Preview do Texto"})]}),D?e.jsx(_e,{className:"h-4 w-4"}):e.jsx(Ee,{className:"h-4 w-4"})]})}),e.jsx(we,{children:e.jsxs("div",{className:"space-y-4 p-3 border border-border/50 rounded-lg bg-muted/20",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{className:"text-xs text-muted-foreground uppercase tracking-wider",children:"Texto (Achados)"}),e.jsx("div",{className:"p-3 bg-background rounded border border-border/50 min-h-[60px]",children:G||e.jsx("span",{className:"text-muted-foreground italic",children:"Sem texto definido"})})]}),c.conclusao&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(d,{className:"text-xs text-muted-foreground uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(oa,{className:"h-3 w-3"}),"Conclusão (Impressão)"]}),e.jsx("div",{className:"p-3 bg-blue-500/5 border border-blue-500/20 rounded min-h-[40px]",children:de||e.jsx("span",{className:"text-muted-foreground italic",children:"Sem conclusão definida"})})]}),c.tecnica&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{className:"text-xs text-muted-foreground uppercase tracking-wider",children:"Técnica"}),e.jsx("div",{className:"p-3 bg-muted/50 rounded border border-border/50 text-sm",children:c.tecnica})]}),c.observacao&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{className:"text-xs text-muted-foreground uppercase tracking-wider",children:"Observação"}),e.jsx("div",{className:"p-3 bg-amber-500/5 border border-amber-500/20 rounded text-sm",children:c.observacao})]})]})})]}),!Z&&e.jsxs("div",{className:"text-center py-6 text-muted-foreground",children:[e.jsx(Ve,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"Esta frase não possui variáveis configuradas."}),e.jsx("p",{className:"text-xs mt-1",children:"O texto será inserido exatamente como está definido."})]}),e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-border/50",children:[e.jsxs(h,{variant:"outline",size:"sm",onClick:ee,className:"gap-1.5",children:[e.jsx(ia,{className:"h-3.5 w-3.5"}),"Reset"]}),e.jsxs(h,{size:"sm",onClick:j,className:"gap-1.5",children:[e.jsx(De,{className:"h-3.5 w-3.5"}),"Testar Aplicação"]})]})]})}const Oe=["US","TC","RM","RX","MM"],J=15,ka='id, codigo, titulo, texto, modalidade_codigo, categoria, variaveis, "sinônimos", tags, ativa, conclusao, tecnica, observacao, atalho, created_at, updated_at, version',F=c=>
1c?c.replace(/\\n\\n/g,`
2
3`).replace(/\\n/g,`
4`):null,Fe=(c,m)=>{if(c&&typeof c=="object"){const E=c;if(E.code==="PGRST116")return"Não foi possível confirmar o salvamento. Recarregue a página e tente novamente.";const g=[E.message,E.details,E.hint].filter(Boolean);if(g.length>0)return g.join(" — ")}return c instanceof Error?c.message:m},Ga=()=>{const c=Ge(),[m,E]=n.useState(""),[g,W]=n.useState(null),[R,ce]=n.useState(null),[D,ne]=n.useState(null),[p,Z]=n.useState("all"),[q,L]=n.useState("updated"),[T,O]=n.useState(1),G=wa(m,300),[de,V]=n.useState(!1),[z,ee]=n.useState(!1),[j,ae]=n.useState(null),[x,l]=n.useState(null),[t,i]=n.useState(null),[u,I]=n.useState(!1),_=n.useRef(!1),[o,r]=n.useState({codigo:"",titulo:"",texto:"",modalidade_codigo:"",categoria:"",conclusao:"",tecnica:"",observacao:"",ativa:!0,variaveis:"[]",sinonimos:"",tags:"",atalho:""}),{data:f}=je({queryKey:["admin-frases-meta"],queryFn:async()=>{const{data:a,error:s}=await P.rpc("admin_get_frases_meta");if(s)throw console.error("[FrasesPage] admin_get_frases_meta:",s.message),new Error(s.message);const b=a??{};return{categories:b.categories??[],activeCount:Number(b.activeCount??0)}},staleTime:5*6e4,refetchOnWindowFocus:!1}),w=(f==null?void 0:f.categories)??[],ze=(f==null?void 0:f.activeCount)??0,{data:B,isLoading:Ae,refetch:xe}=je({queryKey:["admin-frases",T,G,g,R,D,p,q],queryFn:async()=>{let a=P.from("frases_modelo").select(ka,{count:"exact"});if(G){const U=`%${G}%`;a=a.or(`codigo.ilike.${U},texto.ilike.${U},titulo.ilike.${U}`)}if(g&&(a=a.eq("modalidade_codigo",g)),R&&(a=a.eq("categoria",R)),D&&(a=a.eq("ativa",D==="ativa")),p!=="all"){const U=p==="today"?1:7,He=new Date(Date.now()-U*864e5).toISOString();a=a.gte("updated_at",He)}const s=(T-1)*J,b=s+J-1,y=q==="updated"?a.order("updated_at",{ascending:!1}):a.order("codigo"),{data:A,count:$e,error:pe}=await y.range(s,b);if(pe)throw pe;return{frases:A||[],totalCount:$e||0}},staleTime:3e4,placeholderData:Ue}),ue=(B==null?void 0:B.frases)??[],se=(B==null?void 0:B.totalCount)??0,me=Math.ceil(se/J),he=a=>{const s=a.match(/\{\{[^}]+\}\}/g);return s?s.length:0},ge=a=>{a?(ae(a),r({codigo:a.codigo,titulo:a.titulo||"",texto:a.texto,modalidade_codigo:a.modalidade_codigo||"",categoria:a.categoria||"",conclusao:a.conclusao||"",tecnica:a.tecnica||"",observacao:a.observacao||"",ativa:a.ativa??!0,variaveis:JSON.stringify(a.variaveis||[],null,2),sinonimos:Array.isArray(a.sinônimos)?a.sinônimos.join(", "):"",tags:Array.isArray(a.tags)?a.tags.join(", "):"",atalho:a.atalho||""})):(ae(null),r({codigo:"",titulo:"",texto:"",modalidade_codigo:"",categoria:"",conclusao:"",tecnica:"",observacao:"",ativa:!0,variaveis:"[]",sinonimos:"",tags:"",atalho:""})),V(!0)},Pe=async()=>{var a;if(!_.current){if(!o.codigo||!o.texto){v.error("Código e texto são obrigatórios");return}_.current=!0,I(!0);try{let s=[];try{s=JSON.parse(o.variaveis)}catch{v.error("JSON de variáveis inválido");return}const b={codigo:o.codigo,titulo:o.titulo||o.categoria||null,texto:F(o.texto)||"",modalidade_codigo:o.modalidade_codigo||null,categoria:o.categoria||null,conclusao:F(o.conclusao),tecnica:F(o.tecnica),observacao:F(o.observacao),ativa:o.ativa,variaveis:s,sinônimos:o.sinonimos?o.sinonimos.split(",").map(y=>y.trim()).filter(Boolean):null,tags:o.tags?o.tags.split(",").map(y=>y.trim()).filter(Boolean):null,atalho:((a=o.atalho)==null?void 0:a.toLowerCase().replace(/[^a-z0-9]/g,""))||null};if(j){const{data:y,error:A}=await P.from("frases_modelo").update(b).eq("id",j.id).select("id, updated_at").maybeSingle();if(A)throw A;if(!y)throw{code:"PGRST116"};v.success("Frase atualizada com sucesso")}else{const{data:y,error:A}=await P.from("frases_modelo").insert(b).select("id, updated_at").maybeSingle();if(A)throw A;if(!y)throw{code:"PGRST116"};v.success("Frase criada com sucesso")}V(!1),xe(),c.invalidateQueries({queryKey:["admin-frases-meta"]})}catch(s){te.error("Erro ao salvar frase:",s),v.error(Fe(s,"Erro ao salvar frase."))}finally{_.current=!1,I(!1)}}},qe=a=>{i(a)},Le=async()=>{if(t)try{const{error:a}=await P.from("frases_modelo").delete().eq("id",t.id);if(a)throw a;v.success("Frase excluída"),i(null),xe(),c.invalidateQueries({queryKey:["admin-frases-meta"]})}catch(a){te.error("Erro ao excluir frase:",a),v.error("Erro ao excluir. Tente novamente.")}},Ie=async a=>{const s={codigo:`${a.codigo}_COPY`,texto:F(a.texto)||"",modalidade_codigo:a.modalidade_codigo,categoria:a.categoria,conclusao:F(a.conclusao),tecnica:F(a.tecnica),observacao:F(a.observacao),ativa:a.ativa,variaveis:a.variaveis,sinônimos:a.sinônimos,tags:a.tags};try{const{data:b,error:y}=await P.from("frases_modelo").insert(s).select("id, updated_at").maybeSingle();if(y)throw y;if(!b)throw{code:"PGRST116"};v.success("Frase duplicada"),xe()}catch(b){te.error("Erro ao duplicar frase:",b),v.error(Fe(b,"Erro ao duplicar frase."))}},Be=async a=>{try{const{error:s}=await P.from("frases_modelo").update({ativa:!a.ativa}).eq("id",a.id);if(s)throw s;c.invalidateQueries({queryKey:["admin-frases"]}
4),c.invalidateQueries({queryKey:["admin-frases-meta"]}),v.success(a.ativa?"Frase desativada":"Frase ativada")}catch(s){te.error("Erro ao alterar status:",s),v.error("Erro ao alterar status. Tente novamente.")}};return e.jsxs(Ze,{children:[e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Frases Modelo"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[se.toLocaleString("pt-BR")," frases encontradas • ",ze.toLocaleString("pt-BR")," ativas"]})]}),e.jsxs(h,{onClick:()=>ge(),className:"gap-2",children:[e.jsx(da,{className:"h-4 w-4"}),"Nova Frase"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(xa,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(N,{placeholder:"Buscar por código, texto ou título...",value:m,onChange:a=>E(a.target.value),className:"pl-9"})]}),e.jsxs(Q,{value:g||"all",onValueChange:a=>W(a==="all"?null:a),children:[e.jsx(K,{className:"w-[140px]",children:e.jsx(X,{placeholder:"Modalidade"})}),e.jsxs(Y,{children:[e.jsx(M,{value:"all",children:"Todas"}),Oe.map(a=>e.jsx(M,{value:a,children:a},a))]})]}),e.jsxs(Q,{value:R||"all",onValueChange:a=>ce(a==="all"?null:a),children:[e.jsx(K,{className:"w-[180px]",children:e.jsx(X,{placeholder:"Categoria"})}),e.jsxs(Y,{className:"max-h-[300px]",children:[e.jsx(M,{value:"all",children:"Todas"}),w.map(a=>e.jsx(M,{value:a,children:a},a))]})]}),e.jsxs(Q,{value:D||"all",onValueChange:a=>ne(a==="all"?null:a),children:[e.jsx(K,{className:"w-[120px]",children:e.jsx(X,{placeholder:"Status"})}),e.jsxs(Y,{children:[e.jsx(M,{value:"all",children:"Todas"}),e.jsx(M,{value:"ativa",children:"Ativas"}),e.jsx(M,{value:"inativa",children:"Inativas"})]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground mr-1",children:"Recência:"}),[{v:"all",label:"Todas"},{v:"today",label:"Editadas hoje"},{v:"week",label:"Esta semana"}].map(a=>e.jsx(h,{size:"sm",variant:p===a.v?"default":"outline",className:"h-7 px-3 text-xs",onClick:()=>{Z(a.v),O(1)},children:a.label},a.v)),e.jsx("span",{className:"mx-2 h-4 w-px bg-border"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Ordenar por:"}),e.jsxs(h,{size:"sm",variant:q==="updated"?"default":"outline",className:"h-7 px-3 text-xs gap-1",onClick:()=>L("updated"),children:[e.jsx(ma,{className:"h-3 w-3"})," Recentes"]}),e.jsx(h,{size:"sm",variant:q==="codigo"?"default":"outline",className:"h-7 px-3 text-xs",onClick:()=>L("codigo"),children:"Código"})]}),e.jsx("div",{className:"border rounded-lg overflow-x-auto",children:e.jsxs(fa,{className:"min-w-[900px]",children:[e.jsx(ba,{children:e.jsxs(ie,{children:[e.jsx(k,{className:"w-[200px]",children:"Código"}),e.jsx(k,{children:"Texto"}),e.jsx(k,{className:"w-[90px]",children:"Atalho"}),e.jsx(k,{className:"w-[120px]",children:"Categoria"}),e.jsx(k,{className:"w-[80px]",children:"Mod."}),e.jsx(k,{className:"w-[60px] text-center",children:"Vars"}),e.jsx(k,{className:"w-[120px]",children:"Atualizado"}),e.jsx(k,{className:"w-[80px] text-center",children:"Status"}),e.jsx(k,{className:"w-[140px] text-right",children:"Ações"})]})}),e.jsx(ya,{children:Ae?e.jsx(ie,{children:e.jsx(S,{colSpan:9,className:"text-center py-10",children:e.jsx(ke,{className:"h-6 w-6 animate-spin mx-auto text-muted-foreground"})})}):ue.length===0?e.jsx(ie,{children:e.jsx(S,{colSpan:9,className:"text-center py-10 text-muted-foreground",children:"Nenhuma frase encontrada"})}):ue.map(a=>e.jsxs(ie,{className:"relative",children:[e.jsxs(S,{className:"font-mono text-xs relative",children:[e.jsx(Sa,{date:a.updated_at}),a.codigo]}),e.jsx(S,{className:"max-w-[300px] truncate text-sm",children:a.texto}),e.jsx(S,{children:a.atalho&&e.jsx(C,{variant:"secondary",className:"font-mono text-xs bg-primary/10 text-primary",children:a.atalho})}),e.jsx(S,{children:a.categoria&&e.jsx(C,{variant:"outline",className:"text-xs truncate max-w-[100px]",children:a.categoria})}),e.jsx(S,{children:a.modalidade_codigo&&e.jsx(C,{variant:"secondary",className:"text-xs",children:a.modalidade_codigo})}),e.jsx(S,{className:"text-center tabular-nums",children:he(a.texto)>0&&e.jsx(C,{className:"bg-blue-500/20 text-blue-400 text-xs",children:he(a.texto)})}),e.jsx(S,{children:e.jsx(Ta,{date:a.updated_at,compact:!0})}),e.jsx(S,{className:"text-center",children:e.jsx(le,{checked:a.ativa??!0,onCheckedChange:()=>Be(a)})}),e.jsx(S,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(h,{variant:"ghost",size:"icon",onClick:()=>{l(a),ee(!0)},children:e.jsx(Re,{className:"h-4 w-4"})}),e.jsx(h,{variant:"ghost",size:"icon",onClick:()=>ge(a),children:e.jsx(ua,{className:"h-4 w-4"})}),e.jsx(h,{variant:"ghost",size:"icon",onClick:()=>Ie(a),children:e.jsx(ha,{className:"h-4 w-4"})}),e.jsx(h,{variant:"ghost",size:"icon",onClick:()=>qe(a),children:e.jsx(ga,{className:"h-4 w-4 text-destructive"})})]})})]},a.id))})]})}),me>1&&e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground tabular-nums",children:["Mostrando ",(T-1)*J+1,"-",Math.min(T*J,se)," de ",se.toLocaleStr
4ing("pt-BR")]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{variant:"outline",size:"sm",disabled:T===1,onClick:()=>O(a=>a-1),children:e.jsx(pa,{className:"h-4 w-4"})}),e.jsxs("span",{className:"text-sm",children:[T," / ",me]}),e.jsx(h,{variant:"outline",size:"sm",disabled:T===me,onClick:()=>O(a=>a+1),children:e.jsx(ja,{className:"h-4 w-4"})})]})]})]}),e.jsx(ve,{open:de,onOpenChange:a=>!u&&V(a),children:e.jsxs(Ne,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(fe,{children:e.jsx(be,{children:j?"Editar Frase":"Nova Frase"})}),j&&e.jsx(Va,{createdAt:j.created_at,updatedAt:j.updated_at,version:j.version}),e.jsxs(ea,{defaultValue:"basico",className:"mt-4",children:[e.jsxs(aa,{className:`flex w-full overflow-x-auto sm:grid ${j?"sm:grid-cols-6":"sm:grid-cols-5"}`,children:[e.jsx($,{value:"basico",children:"Básico"}),e.jsx($,{value:"conteudo",children:"Conteúdo"}),e.jsx($,{value:"variaveis",children:"Variáveis"}),e.jsx($,{value:"sinonimos",children:"Sinônimos"}),e.jsxs($,{value:"preview",className:"gap-1.5",children:[e.jsx(De,{className:"h-3.5 w-3.5"}),"Preview"]}),j&&e.jsxs($,{value:"historico",className:"gap-1.5",children:[e.jsx(va,{className:"h-3.5 w-3.5"}),"Histórico"]})]}),e.jsxs(H,{value:"basico",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Código *"}),e.jsx(N,{value:o.codigo,onChange:a=>r(s=>({...s,codigo:a.target.value})),placeholder:"US_ABD_FIGADO_ESTEATOSE_LEVE"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Dica: Formato: MODALIDADE_REGIÃO_ORGÃO_DESCRIÇÃO (maiúsculas, underscores)."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Título (busca por voz)"}),e.jsx(N,{value:o.titulo,onChange:a=>r(s=>({...s,titulo:a.target.value})),placeholder:"Ex: Esteatose Hepática Leve"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Dica: Nome descritivo para busca por voz. Se vazio, usa Categoria."})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Modalidade"}),e.jsxs(Q,{value:o.modalidade_codigo,onValueChange:a=>r(s=>({...s,modalidade_codigo:a})),children:[e.jsx(K,{children:e.jsx(X,{placeholder:"Selecione"})}),e.jsx(Y,{children:Oe.map(a=>e.jsx(M,{value:a,children:a},a))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Dica: US=Ultrassom | TC=Tomografia | RM=Ressonância | RX=Radiografia | MM=Mamografia"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Categoria"}),e.jsx(N,{value:o.categoria,onChange:a=>r(s=>({...s,categoria:a.target.value})),placeholder:"Ex: Fígado, Tireoide, Pulmão"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Dica: Órgão ou região anatômica principal. Agrupa frases similares."})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Tags (separadas por vírgula)"}),e.jsx(N,{value:o.tags,onChange:a=>r(s=>({...s,tags:a.target.value})),placeholder:"esteatose, hepatomegalia, grau I"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Dica: Palavras-chave para busca rápida. Ex: esteatose, cisto, nódulo, calcificação, normal"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Atalho Rápido"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground font-mono text-lg",children:";"}),e.jsx(N,{value:o.atalho,onChange:a=>r(s=>({...s,atalho:a.target.value.toLowerCase().replace(/[^a-z0-9]/g,"").slice(0,15)})),placeholder:"estleve",className:"font-mono",maxLength:15})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Dica: Digite ",e.jsx("code",{className:"bg-muted px-1 rounded",children:o.atalho||"atalho"})," no editor e prima ",e.jsx("strong",{children:"Espaço"})," ou ",e.jsx("strong",{children:"Enter"})," para inserir automaticamente."]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-4",children:[e.jsx(le,{checked:o.ativa,onCheckedChange:a=>r(s=>({...s,ativa:a}))}),e.jsx(d,{children:"Frase ativa"})]})]}
4),e.jsxs(H,{value:"conteudo",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Texto * (Achados)"}),e.jsx(oe,{value:o.texto,onChange:a=>r(s=>({...s,texto:a.target.value})),placeholder:"Fígado com dimensões {{medida_longitudinal}} x {{medida_ap}} cm, contornos regulares, ecotextura homogênea, sem lesões focais.",rows:4}),e.jsxs("details",{className:"text-xs text-muted-foreground",children:[e.jsxs("summary",{className:"cursor-pointer hover:text-foreground",children:["Dica: Use ","{{variavel}}"," para campos dinâmicos"]}),e.jsxs("div",{className:"mt-1 pl-3 border-l-2 border-muted",children:["• ","{{medida}}"," → valores numéricos",e.jsx("br",{}),"• ","{{lado}}"," → direito/esquerdo",e.jsx("br",{}),"• ","{{descricao}}"," → texto livre",e.jsx("br",{}),"Ex: Nódulo ","{{ecogenicidade}}"," no ","{{lobo}}",", medindo ","{{mx}}"," x ","{{my}}"," x ","{{mz}}"," cm."]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Conclusão (Impressão)"}),e.jsx(oe,{value:o.conclusao,onChange:a=>r(s=>({...s,conclusao:a.target.value})),placeholder:"Sinais de esteatose hepática {{grau}}.",rows:2}),e.jsxs("details",{className:"text-xs text-muted-foreground",children:[e.jsx("summary",{className:"cursor-pointer hover:text-foreground",children:"Dica: Texto para IMPRESSÃO DIAGNÓSTICA"}),e.jsxs("div",{className:"mt-1 pl-3 border-l-2 border-muted",children:["• Seja conclusivo e sintético",e.jsx("br",{}),'• Omita medidas específicas (use "aumentado", "reduzido")',e.jsx("br",{}),'• Padrões: "Sinais de...", "Sugestivo de...", "Compatível com..."']})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Técnica"}),e.jsx(N,{value:o.tecnica,onChange:a=>r(s=>({...s,tecnica:a.target.value})),placeholder:"Transdutor convexo de 3,5 MHz"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Opcional. Ex: Transdutor convexo 3,5 MHz"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Observação"}),e.jsx(N,{value:o.observacao,onChange:a=>r(s=>({...s,observacao:a.target.value})),placeholder:"Correlacionar com dados clínicos"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Opcional. Ex: Correlacionar clinicamente."})]})]})]}),e.jsx(H,{value:"variaveis",className:"space-y-4 mt-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Variáveis (JSON)"}),e.jsx(oe,{value:o.variaveis,onChange:a=>r(s=>({...s,variaveis:a.target.value})),placeholder:`[
5  {"nome": "medida", "tipo": "numero", "unidade": "cm", "minimo": 0.1, "maximo": 30},
6  {"nome": "lado", "tipo": "select", "opcoes": ["direito", "esquerdo", "bilateral"]},
7  {"nome": "descricao", "tipo": "texto", "obrigatorio": false}
8]`,rows:12,className:"font-mono text-xs"}),e.jsxs("details",{className:"text-xs text-muted-foreground",children:[e.jsx("summary",{className:"cursor-pointer hover:text-foreground font-medium",children:"Dica: Como definir variáveis"}),e.jsxs("div",{className:"mt-2 p-3 bg-muted/50 rounded-md space-y-1",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Tipos:"})," numero | texto | select | boolean"]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Campos:"})," unidade, minimo/maximo, obrigatorio, valor_padrao"]}),e.jsx("p",{className:"font-mono bg-background/50 p-1 rounded text-[11px]",children:'Ex: {"nome": "ecogenicidade", "tipo": "select", "opcoes": ["hipo", "iso", "hiper"]}'})]})]})]})}),e.jsx(H,{value:"sinonimos",className:"space-y-4 mt-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Sinônimos (separados por vírgula)"}),e.jsx(oe,{value:o.sinonimos,onChange:a=>r(s=>({...s,sinonimos:a.target.value})),placeholder:"fígado normal, parênquima hepático preservado, hepatico sem alterações, fígado ok",rows:4}),e.jsxs("details",{className:"text-xs text-muted-foreground",children:[e.jsx("summary",{className:"cursor-pointer hover:text-foreground font-medium",children:"Dica: Dicas para sinônimos"}),e.jsxs("div",{className:"mt-2 p-3 bg-muted/50 rounded-md space-y-1",children:[e.jsxs("p",{children:["• ",e.jsx("strong",{children:"Abreviações:"}),' "tirads 2", "birads 1"']}),e.jsxs("p",{children:["• ",e.jsx("strong",{children:"Sinônimos médicos:"}),' "hepatomegalia", "fígado aumentado"']}),e.jsxs("p",{children:["• ",e.jsx("strong",{children:"Variações coloquiais:"}),' "normal", "ok", "sem alterações"']}),e.jsxs("p",{children:["• ",e.jsx("strong",{children:"Erros de ditado:"}),' "figado" (sem acento), "nodulo"']})]})]})]})}),e.jsx(H,{value:"preview",className:"mt-4",children:e.jsx(Ea,{formData:o})}),j&&e.jsx(H,{value:"historico",className:"mt-4",children:e.jsx(_a,{sourceTable:"frases_modelo",sourceId:j.id,onRestore:a=>{r(s=>({...s,titulo:a.titulo??s.titulo,texto:a.texto??s.texto,conclusao:a.conclusao??s.conclusao,tecnica:a.te
8cnica??s.tecnica,observacao:a.observacao??s.observacao,categoria:a.categoria??s.categoria,variaveis:a.variaveis?JSON.stringify(a.variaveis,null,2):s.variaveis,tags:Array.isArray(a.tags)?a.tags.join(", "):s.tags}))}})})]}),e.jsxs(sa,{className:"mt-6",children:[e.jsx(h,{variant:"outline",onClick:()=>V(!1),disabled:u,children:"Cancelar"}),e.jsxs(h,{onClick:Pe,disabled:u,children:[u&&e.jsx(ke,{className:"h-4 w-4 mr-2 animate-spin"}),j?"Salvar":"Criar"]})]})]})}),e.jsx(ve,{open:z,onOpenChange:ee,children:e.jsxs(Ne,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsx(fe,{children:e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-sm",children:x==null?void 0:x.codigo}),x!=null&&x.ativa?e.jsx(C,{variant:"default",className:"text-xs",children:"Ativa"}):e.jsx(C,{variant:"secondary",className:"text-xs",children:"Inativa"})]})}),x&&e.jsxs("div",{className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex gap-2",children:[x.modalidade_codigo&&e.jsx(C,{variant:"outline",children:x.modalidade_codigo}),x.categoria&&e.jsx(C,{variant:"secondary",children:x.categoria})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{className:"text-muted-foreground",children:"Texto"}),e.jsx("div",{className:"p-3 bg-muted rounded-md text-sm whitespace-pre-wrap",children:x.texto.split(/(\{\{[^}]+\}\})/g).map((a,s)=>a.match(/\{\{[^}]+\}\}/)?e.jsx("span",{className:"bg-blue-500/20 text-blue-400 px-1 rounded",children:a},s):a)})]}),x.conclusao&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{className:"text-muted-foreground",children:"Conclusão"}),e.jsx("div",{className:"p-3 bg-muted rounded-md text-sm",children:x.conclusao})]}),Array.isArray(x.variaveis)&&x.variaveis.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(d,{className:"text-muted-foreground",children:["Variáveis (",x.variaveis.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:x.variaveis.map((a,s)=>e.jsxs(C,{variant:"outline",className:"text-xs",children:[a.nome||a,": ",a.tipo||"texto",a.unidade&&` (${a.unidade})`]},s))})]}),Array.isArray(x.tags)&&x.tags.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{className:"text-muted-foreground",children:"Tags"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:x.tags.map((a,s)=>e.jsx(C,{variant:"secondary",className:"text-xs",children:String(a)},s))})]})]})]})}),e.jsx(Ca,{open:!!t,onOpenChange:a=>!a&&i(null),onConfirm:Le,description:`Excluir frase "${t==null?void 0:t.codigo}"? Esta ação não pode ser desfeita.`})]})};export{Ga 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.