PageSourceSearch

https://democrata.org.br/sistema/assets/index-DLO5G8Kz.js

js democrata.org.br collected 2026-10-09 16:59:19 UTC 128,169 bytes, 69 lines download raw bytes

1import{J as q,af as O,bE as St,cB as ra,ag as Y,cC as At,bC as We,cD as la,cE as na,cF as Ct,cG as Rt,cH as ia,cI as oa,cJ as ca,cK as da,r as l,b1 as _t,cL as ua,cM as xa,al as ma,am as we,bu as pa,bn as Mt,bo as ba,bp as ga,br as ha,bG as fa,cN as va,cO as ka,aG as ya,cP as ja,cQ as wa,b$ as Na,_ as Pt,ao as Ue,aq as Sa,b2 as Aa,bt as It,a2 as qe,b4 as Ca,b3 as Ra,au as _a,at as Ma,bg as Pa,aA as Oe,$ as lt,a0 as Et,aB as ke,bv as Ia,aE as Ea,bw as nt,aH as Ta,aI as $a,aJ as Te,aN as Ba,b9 as Oa,aK as La,b8 as za,b6 as it,aQ as Da,j as e,a as F,f as te,L as H,cp as ie,R as se,Y as Tt,g as Ke,x as Fa,b as Wa,co as Ne,cR as Ua,cS as qa,T as Ka,V as Va,W as ot,E as Ga,G as Ja,F as Ve,cA as G,cT as $t,aW as Ha,k as Bt,cv as Qa,cs as Za,ct as X,cu as Ya,cU as ye,I as Xa,aR as es}from"./index-DEXqc8fB.js";import{u as ts,b as as,Q as ss,a as rs}from"./useQuery-CDo_LIsD.js";import{P as J}from"./PageHeader-CrxVp842.js";import{u as Ot}from"./useMutation-IhhvkaR7.js";import{T as V}from"./triangle-alert-CEfUEOmw.js";import{S as Lt}from"./search-CkuHA81f.js";import{F as zt}from"./filter-Cb_a2YFK.js";import{C as re}from"./circle-x-CgGWciRr.js";import{C as ae}from"./circle-check-CVemeniK.js";import{E as ls}from"./ellipsis-vertical-ByJY7O-r.js";import{S as ns}from"./smartphone-BH5BMQil.js";import{Z as oe}from"./zap-D1Y-VWGZ.js";import{S as je}from"./settings-Bahoboo8.js";import{P as Le}from"./play-BCMQX1Sb.js";import{W as is}from"./wifi-DFbrGAH5.js";import{F as os}from"./file-check-BPrOVxBx.js";import{U as cs}from"./user-check-LDGz82WD.js";import{B as ds}from"./banknote-DauPF7Eg.js";import{L as us}from"./link-2-VXYbr9c-.js";import{M as ct}from"./mic-CGT16PNF.js";import{i as xs,j as ms,k as ps,a as bs,s as Dt,d as gs,e as hs,f as fs,l as vs,C as ks,g as ys,u as js,b as ws,c as Ns,P as Ss,h as As}from"./PolarChart-D-cHCpA-.js";/**
2 * @license lucide-react v0.372.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 ce=q("Activity",[["path",{d:"M22 12h-4l-3 9L9 3l-3 9H2",key:"d5dnw9"}]]);/**
7 * @license lucide-react v0.372.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const Se=q("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);/**
12 * @license lucide-react v0.372.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const Cs=q("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]);/**
17 * @license lucide-react v0.372.0 - ISC
18 *
19 * This source code is licensed under the ISC license.
20 * See the LICENSE file in the root directory of this source tree.
21 */const Rs=q("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/**
22 * @license lucide-react v0.372.0 - ISC
23 *
24 * This source code is licensed under the ISC license.
25 * See the LICENSE file in the root directory of this source tree.
26 */const Ft=q("Cog",[["path",{d:"M12 20a8 8 0 1 0 0-16 8 8 0 0 0 0 16Z",key:"sobvz5"}],["path",{d:"M12 14a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z",key:"11i496"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 22v-2",key:"1osdcq"}],["path",{d:"m17 20.66-1-1.73",key:"eq3orb"}],["path",{d:"M11 10.27 7 3.34",key:"16pf9h"}
26],["path",{d:"m20.66 17-1.73-1",key:"sg0v6f"}],["path",{d:"m3.34 7 1.73 1",key:"1ulond"}],["path",{d:"M14 12h8",key:"4f43i9"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"m20.66 7-1.73 1",key:"1ow05n"}],["path",{d:"m3.34 17 1.73-1",key:"nuk764"}],["path",{d:"m17 3.34-1 1.73",key:"2wel8s"}],["path",{d:"m11 13.73-4 6.93",key:"794ttg"}]]);/**
27 * @license lucide-react v0.372.0 - ISC
28 *
29 * This source code is licensed under the ISC license.
30 * See the LICENSE file in the root directory of this source tree.
31 */const _s=q("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);/**
32 * @license lucide-react v0.372.0 - ISC
33 *
34 * This source code is licensed under the ISC license.
35 * See the LICENSE file in the root directory of this source tree.
36 */const Ms=q("MicOff",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M18.89 13.23A7.12 7.12 0 0 0 19 12v-2",key:"80xlxr"}],["path",{d:"M5 10v2a7 7 0 0 0 12 5",key:"p2k8kg"}],["path",{d:"M15 9.34V5a3 3 0 0 0-5.68-1.33",key:"1gzdoj"}],["path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12",key:"r2i35w"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/**
37 * @license lucide-react v0.372.0 - ISC
38 *
39 * This source code is licensed under the ISC license.
40 * See the LICENSE file in the root directory of this source tree.
41 */const Ps=q("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/**
42 * @license lucide-react v0.372.0 - ISC
43 *
44 * This source code is licensed under the ISC license.
45 * See the LICENSE file in the root directory of this source tree.
46 */const Re=q("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);/**
47 * @license lucide-react v0.372.0 - ISC
48 *
49 * This source code is licensed under the ISC license.
50 * See the LICENSE file in the root directory of this source tree.
51 */const Wt=q("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);/**
52 * @license lucide-react v0.372.0 - ISC
53 *
54 * This source code is licensed under the ISC license.
55 * See the LICENSE file in the root directory of this source tree.
56 */const Is=q("Volume2",[["polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5",key:"16drj5"}],["path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07",key:"ltjumu"}],["path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14",key:"1kegas"}]]);/**
57 * @license lucide-react v0.372.0 - ISC
58 *
59 * This source code is licensed under the ISC license.
60 * See the LICENSE file in the root directory of this source tree.
61 */const dt=q("VolumeX",[["polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5",key:"16drj5"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]]);var Ge=(t,a,s)=>{switch(a){case"angleAxis":return Rt(t,s);case"radiusAxis":return Ct(t,s);default:throw new Error("Unexpected axis type: ".concat(a))}},Je=(t,a,s)=>{switch(a){case"angleAxis":return oa(t,s);case"radiusAxis":return ia(t,s);default:throw new Error("Unexpected axis type: ".concat(a))}},_e=O([Ge,St,xs,Je],ra),Ut=O([Y,ps,ca,We],da),qt=O([Y,Ge,St,_e,ms,Je,At,Ut,We],la);O([qt],t=>{if(t){var a=new Map;return t.forEach(s=>{var r=(s.coordinate+360)%360;a.has(r)||a.set(r,s)}),Array.from(a.values())}});var Es=O([Y,Ge,_e,Je,At,Ut,We],na);function ze(){return ze=Object.assign?Object.assign.bind():function(t){for(var a=1;a<arguments.length;a++){var s=arguments[a];for(var r in s)({}).hasOwnProperty.call(s,r)&&(t[r]=s[r])}return t},ze.apply(null,arguments)}function Kt(t){return typeof t=="string"?parseInt(t,10):t}function De(t){return l.createElement(bs,ze({shapeType:"sector"},t))}function ut(t,a){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);a&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),s.push.apply(s,r)}return s}function Ae(t){for(var a=1;a<arguments.length;a++){var s=arguments[a]!=null?arguments[a]:{};
61a%2?ut(Object(s),!0).forEach(function(r){Ts(t,r,s[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):ut(Object(s)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(s,r))})}return t}function Ts(t,a,s){return(a=$s(a))in t?Object.defineProperty(t,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[a]=s,t}function $s(t){var a=Bs(t,"string");return typeof a=="symbol"?a:a+""}function Bs(t,a){if(typeof t!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var r=s.call(t,a);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(t)}var Os=(t,a)=>Ct(t,a),Ls=(t,a)=>_e(t,"radiusAxis",a),Me=O([Os,Ls],(t,a)=>{if(!(t==null||a==null))return Ae(Ae({},t),{},{scale:a})}),He=(t,a,s,r)=>Es(t,"radiusAxis",a,r),zs=(t,a,s)=>Rt(t,s),Ds=(t,a,s)=>_e(t,"angleAxis",s),Pe=O([zs,Ds],(t,a)=>{if(!(t==null||a==null))return Ae(Ae({},t),{},{scale:a})}),Qe=(t,a,s,r)=>qt(t,"angleAxis",s,r),Fs=(t,a,s,r)=>r,Ze=O([Dt,Fs],(t,a)=>{if(t.some(s=>s.type==="radialBar"&&a.dataKey===s.dataKey&&a.stackId===s.stackId))return a}),Vt=O([Y,Me,He,Pe,Qe],(t,a,s,r,o)=>ma(t,"radiusAxis")?we(a,s,!1):we(r,o,!1)),Ws=O([Pe,Me,Y],(t,a,s)=>{var r=s==="radial"?t:a;if(!(r==null||r.scale==null))return pa({numericAxis:r})}),Us=(t,a,s,r,o)=>o,qs=(t,a,s,r,o)=>s,Ks=(t,a,s,r,o)=>a,Gt=(t,a,s,r,o)=>r.maxBarSize,Jt=t=>t.type==="radialBar",Vs=O([Y,Dt,qs,Ks],(t,a,s,r)=>a.filter(o=>t==="centric"?o.angleAxisId===s:o.radiusAxisId===r).filter(o=>o.hide===!1).filter(Jt)),Gs=()=>{},Js=O([Vs,ha,Gs],fs),Hs=O([Y,Mt,Pe,Qe,Me,He,Gt],(t,a,s,r,o,u,m)=>{var v,p,k=ya(m)?a:m;if(t==="centric"){var c,x;return(c=(x=we(s,r,!0))!==null&&x!==void 0?x:k)!==null&&c!==void 0?c:0}return(v=(p=we(o,u,!0))!==null&&p!==void 0?p:k)!==null&&v!==void 0?v:0}),Qs=O([Js,Mt,ba,ga,Hs,Vt,Gt],hs),Zs=O([Qs,Ze],(t,a)=>{if(!(t==null||a==null)){var s=t.find(r=>r.stackId===a.stackId&&a.dataKey!=null&&r.dataKeys.includes(a.dataKey));if(s!=null)return s.position}}),Ht=O([vs],t=>t.filter(Jt).filter(Na)),Ys=O([Ht,_t,ja],wa),xt=O([Ys,Ht,fa,va],ka),Xs=(t,a,s)=>{var r=Y(t);return r==="centric"?xt(t,"radiusAxis",a):xt(t,"angleAxis",s)},er=O([Xs,Ze],gs),tr=O([Pe,Qe,Me,He,ua,Ze,Vt,Y,Ws,xa,Us,Zs,er],(t,a,s,r,o,u,m,v,p,k,c,x,N)=>{var{chartData:g,dataStartIndex:d,dataEndIndex:f}=o;if(u==null||s==null||t==null||g==null||m==null||x==null||v!=="centric"&&v!=="radial"||r==null)return[];var{dataKey:w,minPointSize:h}=u,{cx:b,cy:A,startAngle:i,endAngle:E}=k,S=g.slice(d,f+1),n=v==="centric"?s:t,y=N?n.scale.domain():null;return fr({angleAxis:t,angleAxisTicks:a,bandSize:m,baseValue:p,cells:c,cx:b,cy:A,dataKey:w,dataStartIndex:d,displayedData:S,endAngle:E,layout:v,minPointSize:h,pos:x,radiusAxis:s,radiusAxisTicks:r,stackedData:N,stackedDomain:y,startAngle:i})}),ar=O([_t,(t,a)=>a],(t,a)=>{var{chartData:s,dataStartIndex:r,dataEndIndex:o}=t;if(s==null)return[];var u=s.slice(r,o+1);return u.length===0?[]:u.map(m=>({type:a,value:m.name,color:m.fill,payload:m}))}),sr=["shape","activeShape","cornerRadius","id"],rr=["onMouseEnter","onClick","onMouseLeave"],lr=["value","background"];function de(){return de=Object.assign?Object.assign.bind():function(t){for(var a=1;a<arguments.length;a++){var s=arguments[a];for(var r in s)({}).hasOwnProperty.call(s,r)&&(t[r]=s[r])}return t},de.apply(null,arguments)}function mt(t,a){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);a&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),s.push.apply(s,r)}return s}function z(t){for(var a=1;a<arguments.length;a++){var s=arguments[a]!=null?arguments[a]:{};a%2?mt(Object(s),!0).forEach(function(r){nr(t,r,s[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):mt(Object(s)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(s,r))})}return t}
61function nr(t,a,s){return(a=ir(a))in t?Object.defineProperty(t,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[a]=s,t}function ir(t){var a=or(t,"string");return typeof a=="symbol"?a:a+""}function or(t,a){if(typeof t!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var r=s.call(t,a);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(t)}function Fe(t,a){if(t==null)return{};var s,r,o=cr(t,a);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(t);for(r=0;r<u.length;r++)s=u[r],a.indexOf(s)===-1&&{}.propertyIsEnumerable.call(t,s)&&(o[s]=t[s])}return o}function cr(t,a){if(t==null)return{};var s={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(a.indexOf(r)!==-1)continue;s[r]=t[r]}return s}var Ce=[];function dr(t){var{showLabels:a,sectors:s,children:r}=t,o=s.map(u=>({value:u.value,payload:u.payload,parentViewBox:void 0,clockWise:!1,viewBox:{cx:u.cx,cy:u.cy,innerRadius:u.innerRadius,outerRadius:u.outerRadius,startAngle:u.startAngle,endAngle:u.endAngle,clockWise:!1},fill:u.fill}));return l.createElement(za,{value:a?o:void 0},r)}function ur(t){var{sectors:a,allOtherRadialBarProps:s,showLabels:r}=t,{shape:o,activeShape:u,cornerRadius:m,id:v}=s,p=Fe(s,sr),k=Ba(p),c=qe(Oa),{onMouseEnter:x,onClick:N,onMouseLeave:g}=s,d=Fe(s,rr),f=js(x,s.dataKey,v),w=ws(g),h=Ns(N,s.dataKey,v);return a==null?null:l.createElement(dr,{showLabels:r,sectors:a},a.map((b,A)=>{var i=u&&c===String(A),E=f(b,A),S=w(b,A),n=h(b,A),y=z(z(z(z({},k),{},{cornerRadius:Kt(m)},b),Et(d,b,A)),{},{onMouseEnter:E,onMouseLeave:S,onClick:n,className:"recharts-radial-bar-sector ".concat(b.className),forceCornerRadius:p.forceCornerRadius,cornerIsExternal:p.cornerIsExternal,isActive:i,option:i?u:o});return i?l.createElement(Oe,{zIndex:Ue.activeBar,key:"sector-".concat(b.cx,"-").concat(b.cy,"-").concat(b.innerRadius,"-").concat(b.outerRadius,"-").concat(b.startAngle,"-").concat(b.endAngle,"-").concat(A)},l.createElement(De,y)):l.createElement(De,de({key:"sector-".concat(b.cx,"-").concat(b.cy,"-").concat(b.innerRadius,"-").concat(b.outerRadius,"-").concat(b.startAngle,"-").concat(b.endAngle,"-").concat(A)},y))}),l.createElement(La,{label:s.label}),s.children)}function xr(t){var{props:a,previousSectorsRef:s}=t,{data:r,isAnimationActive:o,animationBegin:u,animationDuration:m,animationEasing:v,onAnimationEnd:p,onAnimationStart:k}=a,c=Ta(a,"recharts-radialbar-"),x=s.current,[N,g]=l.useState(!1),d=l.useCallback(()=>{typeof p=="function"&&p(),g(!1)},[p]),f=l.useCallback(()=>{typeof k=="function"&&k(),g(!0)},[k]);return l.createElement($a,{animationId:c,begin:u,duration:m,isActive:o,easing:v,onAnimationStart:f,onAnimationEnd:d,key:c},w=>{var h=w===1?r:(r??Ce).map((b,A)=>{var i=x&&x[A];if(i)return z(z({},b),{},{startAngle:Te(i.startAngle,b.startAngle,w),endAngle:Te(i.endAngle,b.endAngle,w)});var{endAngle:E,startAngle:S}=b;return z(z({},b),{},{endAngle:Te(S,E,w)})});return w>0&&(s.current=h??null),l.createElement(ke,null,l.createElement(ur,{sectors:h??Ce,allOtherRadialBarProps:a,showLabels:!N}))})}function mr(t){var a=l.useRef(null);return l.createElement(xr,{props:t,previousSectorsRef:a})}function pr(t){var a=qe(s=>ar(s,t.legendType));return l.createElement(Ca,{legendPayload:a??[]})}var br=l.memo(t=>{var{dataKey:a,data:s,stroke:r,strokeWidth:o,name:u,hide:m,fill:v,tooltipType:p,id:k}=t,c={dataDefinedOnItem:s,positions:void 0,settings:{graphicalItemId:k,stroke:r,strokeWidth:o,fill:v,nameKey:void 0,dataKey:a,name:Ma(u,a),hide:m,type:p,color:v,unit:""}};return l.createElement(_a,{tooltipEntrySettings:c})});class gr extends l.PureComponent{renderBackground(a){if(a==null)return null;var{cornerRadius:s}=this.props,r=Pa(this.props.background);return l.createElement(Oe,{zIndex:ys(this.props.background,Ue.barBackground)},a.map((o,u)=>{var{value:m,background:v}=o,p=Fe(o,lr);if(!v)return null;var k=z(z(z(z(z({cornerRadius:Kt(s)},p),{},{fill:"#eee"},v),r),Et(this.props,o,u)),{}
61,{index:u,className:lt("recharts-radial-bar-background-sector",String(r==null?void 0:r.className)),option:v,isActive:!1});return l.createElement(De,de({key:"background-".concat(p.cx,"-").concat(p.cy,"-").concat(p.innerRadius,"-").concat(p.outerRadius,"-").concat(p.startAngle,"-").concat(p.endAngle,"-").concat(u)},k))}))}render(){var{hide:a,data:s,className:r,background:o}=this.props;if(a)return null;var u=lt("recharts-area",r);return l.createElement(Oe,{zIndex:this.props.zIndex},l.createElement(ke,{className:u},o&&l.createElement(ke,{className:"recharts-radial-bar-background"},this.renderBackground(s)),l.createElement(ke,{className:"recharts-radial-bar-sectors"},l.createElement(mr,this.props))))}}function hr(t){var a,s=Ra(t.children,ks),r={data:void 0,hide:!1,id:t.id,dataKey:t.dataKey,minPointSize:t.minPointSize,stackId:It(t.stackId),maxBarSize:t.maxBarSize,barSize:t.barSize,type:"radialBar",angleAxisId:t.angleAxisId,radiusAxisId:t.radiusAxisId},o=(a=qe(u=>tr(u,t.radiusAxisId,t.angleAxisId,r,s)))!==null&&a!==void 0?a:Ce;return l.createElement(l.Fragment,null,l.createElement(br,{dataKey:t.dataKey,data:o,stroke:t.stroke,strokeWidth:t.strokeWidth,name:t.name,hide:t.hide,fill:t.fill,tooltipType:t.tooltipType,id:t.id}),l.createElement(gr,de({},t,{data:o})))}var me={angleAxisId:0,animationBegin:0,animationDuration:1500,animationEasing:"ease",background:!1,cornerIsExternal:!1,cornerRadius:0,data:[],forceCornerRadius:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:0,radiusAxisId:0,zIndex:Ue.bar};function fr(t){var{displayedData:a,stackedData:s,dataStartIndex:r,stackedDomain:o,dataKey:u,baseValue:m,layout:v,radiusAxis:p,radiusAxisTicks:k,bandSize:c,pos:x,angleAxis:N,minPointSize:g,cx:d,cy:f,angleAxisTicks:w,cells:h,startAngle:b,endAngle:A}=t;return w==null||k==null?Ce:(a??[]).map((i,E)=>{var S,n,y,P,M,R;if(s?S=Ia(s[r+E],o):(S=Ea(i,u),Array.isArray(S)||(S=[m,S])),v==="radial"){n=nt({axis:p,ticks:k,bandSize:c,offset:x.offset,entry:i,index:E}),M=N.scale(S[1]),P=N.scale(S[0]),y=(n??0)+x.size;var j=M-P;if(Math.abs(g)>0&&Math.abs(j)<Math.abs(g)){var C=it(j||g)*(Math.abs(g)-Math.abs(j));M+=C}R={background:{cx:d,cy:f,innerRadius:n,outerRadius:y,startAngle:b,endAngle:A}}}else{n=p.scale(S[0]),y=p.scale(S[1]),P=nt({axis:N,ticks:w,bandSize:c,offset:x.offset,entry:i,index:E}),M=(P??0)+x.size;var _=y-n;if(Math.abs(g)>0&&Math.abs(_)<Math.abs(g)){var I=it(_||g)*(Math.abs(g)-Math.abs(_));y+=I}}return z(z(z({},i),R),{},{payload:i,value:s?S:S[1],cx:d,cy:f,innerRadius:n,outerRadius:y,startAngle:P,endAngle:M},h&&h[E]&&h[E].props)})}function Qt(t){var a=Pt(t,me);return l.createElement(Sa,{id:a.id,type:"radialBar"},s=>{var r,o,u;return l.createElement(l.Fragment,null,l.createElement(Aa,{type:"radialBar",id:s,data:void 0,dataKey:a.dataKey,hide:(r=a.hide)!==null&&r!==void 0?r:me.hide,angleAxisId:(o=a.angleAxisId)!==null&&o!==void 0?o:me.angleAxisId,radiusAxisId:(u=a.radiusAxisId)!==null&&u!==void 0?u:me.radiusAxisId,stackId:It(a.stackId),barSize:a.barSize,minPointSize:a.minPointSize,maxBarSize:a.maxBarSize}),l.createElement(pr,a),l.createElement(hr,de({},a,{id:s})))})}Qt.displayName="RadialBar";function pt(t,a){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);a&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),s.push.apply(s,r)}return s}function bt(t){for(var a=1;a<arguments.length;a++){var s=arguments[a]!=null?arguments[a]:{};a%2?pt(Object(s),!0).forEach(function(r){vr(t,r,s[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):pt(Object(s)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(s,r))})}return t}function vr(t,a,s){return(a=kr(a))in t?Object.defineProperty(t,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[a]=s,t}function kr(t){var a=yr(t,"string");return typeof a=="symbol"?a:a+""}function yr(t,a){if(typeof t!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var r=s.call(t,a);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}
61return(a==="string"?String:Number)(t)}var jr=["axis","item"],wr=bt(bt({},As),{},{layout:"radial",startAngle:0,endAngle:360}),Nr=l.forwardRef((t,a)=>{var s=Pt(t,wr);return l.createElement(Ss,{chartName:"RadialBarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:jr,tooltipPayloadSearcher:Da,categoricalChartProps:s,ref:a})});const gt={idle:[0,212,255],thinking:[245,158,11],active:[34,197,94]},Sr={idle:.8,thinking:3,active:1.5},Ar=40;function $e(t,a,s){return t+(a-t)*s}function Cr(t,a,s){return[$e(t[0],a[0],s),$e(t[1],a[1],s),$e(t[2],a[2],s)]}function Rr({state:t="idle",size:a=280}){const s=l.useRef(null),r=l.useRef(0),o=l.useRef([]),u=l.useRef([...gt.idle]),m=l.useRef(t),v=l.useRef(0);l.useEffect(()=>{m.current=t},[t]),l.useEffect(()=>{const k=[];for(let c=0;c<Ar;c++)k.push({angle:Math.random()*Math.PI*2,radius:.35+Math.random()*.55,speed:.2+Math.random()*.6,size:1+Math.random()*2,alpha:Math.random(),alphaSpeed:.3+Math.random()*.7});o.current=k},[]);const p=l.useCallback(()=>{const k=s.current;if(!k)return;const c=k.getContext("2d");if(!c)return;const x=window.devicePixelRatio||1,N=k.width/x,g=k.height/x,d=N/2,f=g/2,w=.016;v.current+=w;const h=v.current,b=gt[m.current],A=u.current,i=.03;u.current=Cr(A,b,i);const[E,S,n]=u.current,y=`${Math.round(E)},${Math.round(S)},${Math.round(n)}`;c.clearRect(0,0,N,g);const P=Sr[m.current],M=1+Math.sin(h*P)*.05,j=Math.min(N,g)*.18*M;c.save(),c.shadowColor=`rgba(${y},0.5)`,c.shadowBlur=m.current==="thinking"?60:35;const C=c.createRadialGradient(d,f,0,d,f,j);C.addColorStop(0,`rgba(${y},0.9)`),C.addColorStop(.5,`rgba(${y},0.3)`),C.addColorStop(1,`rgba(${y},0.05)`),c.beginPath(),c.arc(d,f,j,0,Math.PI*2),c.fillStyle=C,c.fill(),c.restore();const _=c.createRadialGradient(d,f,0,d,f,j*.4);_.addColorStop(0,"rgba(255,255,255,0.7)"),_.addColorStop(1,`rgba(${y},0.0)`),c.beginPath(),c.arc(d,f,j*.4,0,Math.PI*2),c.fillStyle=_,c.fill();for(let T=0;T<3;T++){const $=j*(1.4+T*.35),L=.15+T*.08,K=h*L*(T%2===0?1:-1);c.save(),c.translate(d,f),c.rotate(K),c.beginPath(),c.arc(0,0,$,0,Math.PI*2),c.strokeStyle=`rgba(${y},${.12-T*.03})`,c.lineWidth=1,c.setLineDash([8,12+T*4]),c.stroke(),c.restore()}const I=o.current,B=m.current==="thinking"?2.5:1;for(const T of I){T.angle+=T.speed*B*w,T.alpha+=T.alphaSpeed*w;const $=Math.abs(Math.sin(T.alpha))*.7,L=j*(1.2+T.radius*1.5),K=d+Math.cos(T.angle)*L,Q=f+Math.sin(T.angle)*L;c.beginPath(),c.arc(K,Q,T.size,0,Math.PI*2),c.fillStyle=`rgba(${y},${$})`,c.fill()}for(let T=0;T<I.length;T++){const $=I[T],L=j*(1.2+$.radius*1.5),K=d+Math.cos($.angle)*L,Q=f+Math.sin($.angle)*L;for(let Ie=T+1;Ie<I.length;Ie++){const Ee=I[Ie],Xe=j*(1.2+Ee.radius*1.5),et=d+Math.cos(Ee.angle)*Xe,tt=f+Math.sin(Ee.angle)*Xe,at=K-et,st=Q-tt,rt=Math.sqrt(at*at+st*st);if(rt<70){const sa=(1-rt/70)*.15;c.beginPath(),c.moveTo(K,Q),c.lineTo(et,tt),c.strokeStyle=`rgba(${y},${sa})`,c.lineWidth=.5,c.setLineDash([]),c.stroke()}}}if(m.current==="active")for(let $=0;$<2;$++){const L=(h*.8+$*1.5)%3,K=j*(1+L*.8),Q=Math.max(0,.3-L*.1);c.beginPath(),c.arc(d,f,K,0,Math.PI*2),c.strokeStyle=`rgba(${y},${Q})`,c.lineWidth=1.5,c.setLineDash([]),c.stroke()}r.current=requestAnimationFrame(p)},[]);return l.useEffect(()=>{const k=s.current;if(!k)return;(()=>{const N=window.devicePixelRatio||1;k.width=a*N,k.height=a*N,k.style.width=a+"px",k.style.height=a+"px";const g=k.getContext("2d");g&&g.scale(N,N)})(),r.current=requestAnimationFrame(p);const x=()=>{document.hidden?cancelAnimationFrame(r.current):r.current=requestAnimationFrame(p)};return document.addEventListener("visibilitychange",x),()=>{cancelAnimationFrame(r.current),document.removeEventListener("visibilitychange",x)}},[p,a]),e.jsx("canvas",{ref:s,className:"pointer-events-none"})}const U="/aria-autonoma",Zt="/aria/autonoma";async function _r(t,a=1,s=50){const{gravidade:r,...o}=t??{},{data:u}=await F.get(`${U}/problemas`,{params:{...o,...r?{severidade:r}:{},page:a,per_page:s}}),v=(Array.isArray(u)?u:(u==null?void 0:u.items)??[]).map(p=>({...p,gravidade:p.gravidade??p.severidade,descricao:String(p.descricao??p.titulo??"")}));return Array.isArray(u)?{items:v,total:v.length,page:a,per_page:s}:{items:v,total:Number((u==null?void 0:u.total)??v.length),page:Number((u==null?void 0:u.page)??a),per_page:Number((u==null?void 0:u.per_page)??s)}}async function Mr(t,a){const{data:s}=await F.post(`${U}/problemas/${t}/resolver`,{tipo_acao:"notificar",canal:"interno",descricao:"Resolvido manualmente pelo painel"});return s}async function Pr(t,a){const{data:s}=await F.post(`${U}/problemas/${t}/ignorar`,null,{params:{motivo:a}});return s}async function Ir(t,a=1,s=50){const{data:r}=await F.get(`${U}/acoes`,{params:{...t,page:a,per_page:s}});return Array.isArray(r)?{items:r,total:r.length,page:a,per_page:s}:{items:(r==null?void 0:r.items)??[],total:Number((r==null?void 0:r.total)??0),page:Number((r==null?void 0:r.page)??a),per_page:Number((r==null?void 0:r.per_page)??s)}}async function Er(t,a,s){const r={};a==="positivo"&&(r.foi_util=!0),a==="negativo"&&(r.foi_util=!1),s&&(r.comentario=s);const{data:o}=await F.post(`${U}/acoes/${t}/feedback`,r);return o}async function Tr(){var o;const{data:t}=await F.get(`${U}/aprendizado/estatisticas`),a=(t==null?void 0:t.aprendizado)??{},s={};for(const u of((o=t==null?void 0:t.problemas)==null?void 0:o.por_tipo)??[])u&&typeof u.tipo=="string"&&(s[u.tipo]=u.total);const r=a.confianca_media??0;return{total_solucoes:a.total_solucoes??0,solucoes_ativas:a.solucoes_ativas??0,taxa_sucesso_global:a.taxa_sucesso_global??0,confianca_media:r<=1?Math.round(r*100):r,total_anti_solucoes:a.anti_solucoes??0,top_solucoes:a.top_solucoes??[],problemas_por_tipo:s,evolucao_confianca:[]}}async function $r(t=!0){const{data:a}=await F.get(`${U}/aprendizado/solucoes`,{params:{ativa:t}});return Array.isArray(a)?a:(a==null?void 0:a.items)??[]}async function Br(){const{data:t}=await F.get(`${U}/monitores`);return t}async function Or(){const{data:t}=await F.get(`${U}/scheduler/status`);return t}async function Yt(){const{data:t}=await F.post(`${U}/scheduler/executar-ciclo`);return t}async function Lr(){const{data:t}=await F.get(`${U}/config`);return t}async function zr(t,a){const{data:s}=await F.put(`${U}/config`,{chave:t,valor:a});return s}async function Dr(t){for(const[a,s]of Object.entries(t))await zr(a,s)}async function Xt(){const{data:t}=await F.get(`${Zt}/visao-completa`);return t}async function ea(){const{data:t}=await F.post(`${Zt}/relatorio-diario`);return t}async function Fr(){const{data:t}=await F.get(`${U}/health-score`);return t}const ne={all:["aria"],visao:()=>[...ne.all,"visao-completa"],saude:()=>[...ne.all,"saude-tecnica"],acoes:t=>[...ne.all,"acoes",t],aprendizado:()=>[...ne.all,"aprendizado"]};function Wr(){return ts({queryKey:ne.visao(),queryFn:Xt,refetchInterval:3e4,staleTime:15e3,placeholderData:t=>t})}function Ur(){const t=as();return Ot({mutationFn:Yt,onSuccess:()=>{t.invalidateQueries({queryKey:ne.all})}})}function qr(){return Ot({mutationFn:ea})}const ht=50,Kr=[{value:"todos",label:"Todos"},{value:"aberto",label:"Abertos"},{value:"em_andamento",label:"Em Andamento"},{value:"resolvido",label:"Resolvidos"},{value:"ignorado",label:"Ignorados"}],Vr=[{value:"",label:"Todas"},{value:"critica",label:"Crítica"},{value:"alta",label:"Alta"},{value:"media",label:"Média"},{value:"baixa",label:"Baixa"}];function Gr({status:t}
61){const a={aberto:{bg:"bg-amber-100 dark:bg-amber-900/30",text:"text-amber-700 dark:text-amber-400",icon:V},em_andamento:{bg:"bg-blue-100 dark:bg-blue-900/30",text:"text-blue-700 dark:text-blue-400",icon:Ke},resolvido:{bg:"bg-emerald-100 dark:bg-emerald-900/30",text:"text-emerald-700 dark:text-emerald-400",icon:ae},ignorado:{bg:"bg-slate-100 dark:bg-slate-700",text:"text-slate-600 dark:text-slate-400",icon:re}}[t],s=a.icon;return e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-xs font-medium ${a.bg} ${a.text}`,children:[e.jsx(s,{className:"h-3 w-3"}),t.replace("_"," ")]})}function Jr({gravidade:t}){const a={critica:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400",alta:"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400",media:"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400",baixa:"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400"}[t];return e.jsx("span",{className:`rounded-full px-2.5 py-1 text-xs font-medium ${a}`,children:t})}function Hr({problema:t,onStatusChange:a}){const[s,r]=l.useState(!1),[o,u]=l.useState(!1),m=async v=>{u(!0);try{if(v==="resolver")await Mr(t.id);else if(v==="ignorar"){const p=prompt("Motivo para ignorar este problema:");if(p)await Pr(t.id,p);else{u(!1);return}}a()}catch(p){alert(te(p,"Erro ao atualizar problema")),console.error(p)}finally{u(!1),r(!1)}};return e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:()=>r(!s),disabled:o,className:"rounded-lg p-2 text-slate-400 transition hover:bg-slate-100 hover:text-slate-600 dark:hover:bg-slate-700 dark:hover:text-slate-300",children:e.jsx(ls,{className:"h-4 w-4"})}),s&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>r(!1)}),e.jsxs("div",{className:"absolute right-0 top-full z-20 mt-1 w-48 rounded-xl border border-slate-200 bg-white py-1 shadow-lg dark:border-slate-700 dark:bg-slate-800",children:[e.jsxs("button",{onClick:()=>m("resolver"),disabled:t.status==="resolvido",className:"flex w-full items-center gap-2 px-4 py-2 text-sm text-slate-700 hover:bg-slate-50 disabled:opacity-50 dark:text-slate-300 dark:hover:bg-slate-700",children:[e.jsx(ae,{className:"h-4 w-4 text-emerald-500"}),"Marcar como Resolvido"]}),e.jsxs("button",{onClick:()=>m("ignorar"),disabled:t.status==="ignorado",className:"flex w-full items-center gap-2 px-4 py-2 text-sm text-slate-700 hover:bg-slate-50 disabled:opacity-50 dark:text-slate-300 dark:hover:bg-slate-700",children:[e.jsx(re,{className:"h-4 w-4 text-slate-500"}),"Ignorar Problema"]})]})]})]})}function Qr(){const[t,a]=l.useState([]),[s,r]=l.useState(0),[o,u]=l.useState(1),[m,v]=l.useState(!0),[p,k]=l.useState(null),[c,x]=l.useState({status:"aberto"}),[N,g]=l.useState(!1),[d,f]=l.useState(""),w=Math.max(1,Math.ceil(s/ht)),h=i=>{u(1),x(i)},b=l.useCallback(async()=>{try{v(!0);const i=await _r(c,o,ht);a(i.items),r(i.total),k(null)}catch(i){k(te(i,"Erro ao carregar problemas")),console.error("Erro ao carregar problemas:",i)}finally{v(!1)}},[c,o]);l.useEffect(()=>{b()},[b]);const A=d?t.filter(i=>(i.tipo??"").toLowerCase().includes(d.toLowerCase())||(i.descricao??"").toLowerCase().includes(d.toLowerCase())):t;return e.jsxs("div",{className:"space-y-6",children:[e.jsx(J,{title:"Problemas Detectados",subtitle:p?"Falha ao carregar":`${s.toLocaleString("pt-BR")} problemas — página ${o} de ${w}`,icon:e.jsx(V,{className:"h-6 w-6"}),actions:e.jsxs(H,{to:"/aria-autonoma",className:"flex items-center gap-2 rounded-lg border border-slate-200 px-4 py-2 text-sm font-medium text-slate-700 transition hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800",children:[e.jsx(ie,{className:"h-4 w-4"}),"Voltar"]})}),e.jsxs("div",{className:"rounded-2xl border border-slate-200 bg-white p-4 dark:border-slate-700 dark:bg-slate-800",children:[e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Lt,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"}),e.jsx("input",{type:"text",placeholder:"Filtrar a página atual...",title:"Busca local: filtra apenas os problemas da página carregada. Para buscar no todo, use os filtros.",value:d,onChange:i=>f(i.target.value),className:"w-full rounded-lg border border-slate-200 bg-white py-2 pl-10 pr-4 text-sm text-slate-900 placeholder-slate-400 focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-slate-700 dark:bg-slate-900 dark:text-white dark:placeholder-slate-500"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:()=>g(!N),className:`flex items-center gap-2 rounded-lg border px-4 py-2 text-sm font-medium transition ${N?"border-blue-500 bg-blue-50 text-blue-600 dar
61k:bg-blue-900/20 dark:text-blue-400":"border-slate-200 text-slate-700 hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-700"}`,children:[e.jsx(zt,{className:"h-4 w-4"}),"Filtros"]}),e.jsx("button",{onClick:b,disabled:m,className:"flex items-center gap-2 rounded-lg border border-slate-200 px-4 py-2 text-sm font-medium text-slate-700 transition hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-700",children:e.jsx(se,{className:`h-4 w-4 ${m?"animate-spin":""}`})})]})]}),N&&e.jsxs("div",{className:"mt-4 grid grid-cols-1 gap-4 border-t border-slate-100 pt-4 dark:border-slate-700 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-medium text-slate-600 dark:text-slate-400",children:"Status"}),e.jsx("select",{value:c.status||"todos",onChange:i=>h({...c,status:i.target.value}),className:"w-full rounded-lg border border-slate-200 bg-white px-3 py-2 text-sm text-slate-900 dark:border-slate-700 dark:bg-slate-900 dark:text-white",children:Kr.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-medium text-slate-600 dark:text-slate-400",children:"Gravidade"}),e.jsx("select",{value:c.gravidade||"",onChange:i=>h({...c,gravidade:i.target.value||void 0}),className:"w-full rounded-lg border border-slate-200 bg-white px-3 py-2 text-sm text-slate-900 dark:border-slate-700 dark:bg-slate-900 dark:text-white",children:Vr.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-medium text-slate-600 dark:text-slate-400",children:"Data Início"}),e.jsx("input",{type:"date",value:c.data_inicio||"",onChange:i=>h({...c,data_inicio:i.target.value||void 0}),className:"w-full rounded-lg border border-slate-200 bg-white px-3 py-2 text-sm text-slate-900 dark:border-slate-700 dark:bg-slate-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-medium text-slate-600 dark:text-slate-400",children:"Data Fim"}),e.jsx("input",{type:"date",value:c.data_fim||"",onChange:i=>h({...c,data_fim:i.target.value||void 0}),className:"w-full rounded-lg border border-slate-200 bg-white px-3 py-2 text-sm text-slate-900 dark:border-slate-700 dark:bg-slate-900 dark:text-white"})]})]})]}),e.jsxs("div",{className:"overflow-hidden rounded-2xl border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-800",children:[m&&t.length===0?e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(se,{className:"mx-auto h-8 w-8 animate-spin text-slate-400"}),e.jsx("p",{className:"mt-2 text-sm text-slate-500 dark:text-slate-400",children:"Carregando problemas..."})]}):p?e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(re,{className:"mx-auto h-8 w-8 text-red-400"}),e.jsx("p",{className:"mt-2 text-sm text-red-600 dark:text-red-400",children:"Não foi possível carregar os problemas"}),e.jsx("p",{className:"mt-1 text-xs text-slate-500 dark:text-slate-400",children:p}),e.jsx("button",{onClick:b,className:"mt-4 rounded-lg border border-slate-200 px-4 py-2 text-sm font-medium text-slate-700 transition hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-700",children:"Tentar novamente"})]}):A.length===0?e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(V,{className:"mx-auto h-8 w-8 text-slate-300 dark:text-slate-600"}),e.jsx("p",{className:"mt-2 text-sm text-slate-500 dark:text-slate-400",children:"Nenhum problema encontrado"})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"border-b border-slate-100 bg-slate-50 dark:border-slate-700 dark:bg-slate-800/50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-slate-600 dark:text-slate-400",children:"Tipo"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-slate-600 dar
61k:text-slate-400",children:"Descrição"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-slate-600 dark:text-slate-400",children:"Gravidade"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-slate-600 dark:text-slate-400",children:"Status"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-slate-600 dark:text-slate-400",children:"Detectado"}),e.jsx("th",{className:"px-4 py-3"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-100 dark:divide-slate-700",children:A.map(i=>e.jsxs("tr",{className:"transition hover:bg-slate-50 dark:hover:bg-slate-700/50",children:[e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-sm font-medium text-slate-900 dark:text-white",children:i.tipo.replace(/_/g," ")})}),e.jsxs("td",{className:"max-w-xs px-4 py-3",children:[e.jsx("p",{className:"truncate text-sm text-slate-600 dark:text-slate-400",children:i.descricao}),i.entidade_nome&&e.jsxs("p",{className:"mt-0.5 truncate text-xs text-slate-400 dark:text-slate-500",children:[i.entidade_tipo,": ",i.entidade_nome]})]}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(Jr,{gravidade:i.gravidade})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(Gr,{status:i.status})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:new Date(i.detectado_em).toLocaleDateString("pt-BR")})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(Hr,{problema:i,onStatusChange:b})})]},i.id))})]})}),!p&&s>0&&e.jsxs("div",{className:"flex flex-col items-center justify-between gap-3 border-t border-slate-100 px-4 py-3 dark:border-slate-700 sm:flex-row",children:[e.jsxs("p",{className:"text-sm text-slate-600 dark:text-slate-400",children:["Página ",o," de ",w," (total"," ",s.toLocaleString("pt-BR"),")"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:()=>u(i=>Math.max(1,i-1)),disabled:m||o<=1,className:"flex items-center gap-1 rounded-lg border border-slate-200 px-3 py-1.5 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-700",children:[e.jsx(ie,{className:"h-4 w-4"}),"Anterior"]}),e.jsxs("button",{onClick:()=>u(i=>Math.min(w,i+1)),disabled:m||o>=w,className:"flex items-center gap-1 rounded-lg border border-slate-200 px-3 py-1.5 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-700",children:["Próxima",e.jsx(Tt,{className:"h-4 w-4"})]})]})]})]})]})}const ft=50,Zr=[{value:"",label:"Todos"},{value:"notificar",label:"Notificação"},{value:"corrigir",label:"Correção"},{value:"escalar",label:"Escalação"},{value:"aguardar",label:"Aguardar"},{value:"monitorar",label:"Monitorar"}],Yr=[{value:"",label:"Todos"},{value:"whatsapp",label:"WhatsApp"},{value:"email",label:"Email"},{value:"sistema",label:"Sistema"},{value:"manual",label:"Manual"}];function Xr({canal:t}){const s={whatsapp:ns,email:Wa,sistema:Ps,manual:Fa}[t]||Ne;return e.jsx(s,{className:"h-4 w-4"})}function el({acao:t,onFeedbackSent:a}){const[s,r]=l.useState(!1),[o,u]=l.useState(!1),[m,v]=l.useState(""),p=async k=>{r(!0);try{await Er(t.id,k,m||void 0),a(),u(!1),v("")}catch(c){alert(te(c,"Erro ao enviar feedback")),console.error(c)}finally{r(!1)}};return t.tem_feedback?e.jsxs("span",{className:"flex items-center gap-1 text-xs text-emerald-600 dark:text-emerald-400",children:[e.jsx(Ne,{className:"h-3 w-3"}),"Avaliada"]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>p("positivo"),disabled:s,className:"rounded p-1 text-slate-400 transition hover:bg-emerald-50 hover:text-emerald-600 dark:hover:bg-emerald-900/20 dark:hover:text-emerald-400",title:"Ação foi útil",children:e.jsx(Ua,{className:"h-4 w-4"})}),e.jsx("button",{onClick:()=>p("negativo"),disabled:s,className:"rounded p-1 text-slate-400 transition hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-900/20 dark:hover:text-red-400",title:"Ação não foi útil",children:e.jsx(qa,{className:"h-4 w-4"})}),e.jsx("button",{onClick:()=>u(!o),disabled:s,className:"rounded p-1 text-slate-400 transition hover:bg-slate-100 hover:text-slate-600 dar
61k:hover:bg-slate-700 dark:hover:text-slate-300",title:"Adicionar comentário",children:e.jsx(Ne,{className:"h-4 w-4"})}),o&&e.jsxs("div",{className:"absolute left-0 top-full z-20 mt-2 w-64 rounded-xl border border-slate-200 bg-white p-3 shadow-lg dark:border-slate-700 dark:bg-slate-800",children:[e.jsx("textarea",{value:m,onChange:k=>v(k.target.value),placeholder:"Descreva o problema...",className:"mb-2 w-full rounded-lg border border-slate-200 bg-white p-2 text-sm text-slate-900 placeholder-slate-400 focus:border-blue-500 focus:outline-none dark:border-slate-700 dark:bg-slate-900 dark:text-white",rows:2}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>u(!1),className:"rounded px-2 py-1 text-xs text-slate-500 hover:bg-slate-100 dark:hover:bg-slate-700",children:"Cancelar"}),e.jsx("button",{onClick:()=>p("neutro"),disabled:!m.trim(),className:"rounded bg-blue-600 px-2 py-1 text-xs text-white hover:bg-blue-700 disabled:opacity-50",children:"Enviar"})]})]})]})}function tl(){const[t,a]=l.useState([]),[s,r]=l.useState(0),[o,u]=l.useState(1),[m,v]=l.useState(!0),[p,k]=l.useState(null),[c,x]=l.useState({}),[N,g]=l.useState(!1),[d,f]=l.useState(""),w=Math.max(1,Math.ceil(s/ft)),h=i=>{u(1),x(i)},b=l.useCallback(async()=>{try{v(!0);const i=await Ir(c,o,ft);a(i.items),r(i.total),k(null)}catch(i){k(te(i,"Erro ao carregar ações")),console.error("Erro ao carregar ações:",i)}finally{v(!1)}},[c,o]);l.useEffect(()=>{b()},[b]);const A=d?t.filter(i=>{var E;return(i.tipo_acao??"").toLowerCase().includes(d.toLowerCase())||(i.canal??"").toLowerCase().includes(d.toLowerCase())||((E=i.destinatario)==null?void 0:E.toLowerCase().includes(d.toLowerCase()))}):t;return e.jsxs("div",{className:"space-y-6",children:[e.jsx(J,{title:"Ações Executadas",subtitle:p?"Falha ao carregar":`${s.toLocaleString("pt-BR")} ações — página ${o} de ${w}`,icon:e.jsx(ce,{className:"h-6 w-6"}),actions:e.jsxs(H,{to:"/aria-autonoma",className:"flex items-center gap-2 rounded-lg border border-slate-200 px-4 py-2 text-sm font-medium text-slate-700 transition hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800",children:[e.jsx(ie,{className:"h-4 w-4"}),"Voltar"]})}),e.jsxs("div",{className:"rounded-2xl border border-slate-200 bg-white p-4 dark:border-slate-700 dark:bg-slate-800",children:[e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Lt,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"}),e.jsx("input",{type:"text",placeholder:"Filtrar a página atual...",title:"Busca local: filtra apenas as ações da página carregada. Para buscar no todo, use os filtros.",value:d,onChange:i=>f(i.target.value),className:"w-full rounded-lg border border-slate-200 bg-white py-2 pl-10 pr-4 text-sm text-slate-900 placeholder-slate-400 focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-slate-700 dark:bg-slate-900 dark:text-white dark:placeholder-slate-500"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:()=>g(!N),className:`flex items-center gap-2 rounded-lg border px-4 py-2 text-sm font-medium transition ${N?"border-blue-500 bg-blue-50 text-blue-600 dark:bg-blue-900/20 dark:text-blue-400":"border-slate-200 text-slate-700 hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-700"}`,children:[e.jsx(zt,{className:"h-4 w-4"}),"Filtros"]}),e.jsx("button",{onClick:b,disabled:m,className:"flex items-center gap-2 rounded-lg border border-slate-200 px-4 py-2 text-sm font-medium text-slate-700 transition hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-700",children:e.jsx(se,{className:`h-4 w-4 ${m?"animate-spin":""}`})})]})]}),N&&e.jsxs("div",{className:"mt-4 grid grid-cols-1 gap-4 border-t border-slate-100 pt-4 dark:border-slate-700 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-medium text-slate-600 dar
61k:text-slate-400",children:"Tipo de Ação"}),e.jsx("select",{value:c.tipo_acao||"",onChange:i=>h({...c,tipo_acao:i.target.value||void 0}),className:"w-full rounded-lg border border-slate-200 bg-white px-3 py-2 text-sm text-slate-900 dark:border-slate-700 dark:bg-slate-900 dark:text-white",children:Zr.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-medium text-slate-600 dark:text-slate-400",children:"Canal"}),e.jsx("select",{value:c.canal||"",onChange:i=>h({...c,canal:i.target.value||void 0}),className:"w-full rounded-lg border border-slate-200 bg-white px-3 py-2 text-sm text-slate-900 dark:border-slate-700 dark:bg-slate-900 dark:text-white",children:Yr.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-medium text-slate-600 dark:text-slate-400",children:"Resultado"}),e.jsxs("select",{value:c.sucesso===void 0?"":c.sucesso?"true":"false",onChange:i=>h({...c,sucesso:i.target.value===""?void 0:i.target.value==="true"}),className:"w-full rounded-lg border border-slate-200 bg-white px-3 py-2 text-sm text-slate-900 dark:border-slate-700 dark:bg-slate-900 dark:text-white",children:[e.jsx("option",{value:"",children:"Todos"}),e.jsx("option",{value:"true",children:"Sucesso"}),e.jsx("option",{value:"false",children:"Falha"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-medium text-slate-600 dark:text-slate-400",children:"Data início"}),e.jsx("input",{type:"date",value:c.data_inicio||"",onChange:i=>h({...c,data_inicio:i.target.value||void 0}),className:"w-full rounded-lg border border-slate-200 bg-white px-3 py-2 text-sm text-slate-900 dark:border-slate-700 dark:bg-slate-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-medium text-slate-600 dark:text-slate-400",children:"Data fim"}),e.jsx("input",{type:"date",value:c.data_fim||"",onChange:i=>h({...c,data_fim:i.target.value||void 0}),className:"w-full rounded-lg border border-slate-200 bg-white px-3 py-2 text-sm text-slate-900 dark:border-slate-700 dark:bg-slate-900 dark:text-white"})]})]})]}),e.jsxs("div",{className:"overflow-hidden rounded-2xl border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-800",children:[m&&t.length===0?e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(se,{className:"mx-auto h-8 w-8 animate-spin text-slate-400"}),e.jsx("p",{className:"mt-2 text-sm text-slate-500 dark:text-slate-400",children:"Carregando ações..."})]}):p?e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(re,{className:"mx-auto h-8 w-8 text-red-400"}),e.jsx("p",{className:"mt-2 text-sm text-red-600 dark:text-red-400",children:"Não foi possível carregar as ações"}),e.jsx("p",{className:"mt-1 text-xs text-slate-500 dark:text-slate-400",children:p}),e.jsx("button",{onClick:b,className:"mt-4 rounded-lg border border-slate-200 px-4 py-2 text-sm font-medium text-slate-700 transition hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-700",children:"Tentar novamente"})]}):A.length===0?e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(ce,{className:"mx-auto h-8 w-8 text-slate-300 dark:text-slate-600"}),e.jsx("p",{className:"mt-2 text-sm text-slate-500 dark:text-slate-400",children:"Nenhuma ação encontrada"})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"border-b border-slate-100 bg-slate-50 dark:border-slate-700 dark:bg-slate-800/50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-slate-600 dark:text-slate-400",children:"Tipo"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-slate-600 dark:text-slate-400",children:"Canal"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-slate-600 dark:text-slate-400",children:"Destinatário"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-slate-600 dar
61k:text-slate-400",children:"Resultado"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-slate-600 dark:text-slate-400",children:"Executado"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-slate-600 dark:text-slate-400",children:"Feedback"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-100 dark:divide-slate-700",children:A.map(i=>e.jsxs("tr",{className:"transition hover:bg-slate-50 dark:hover:bg-slate-700/50",children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("span",{className:"text-sm font-medium text-slate-900 dark:text-white",children:i.tipo_acao.replace(/_/g," ")}),e.jsxs("p",{className:"mt-0.5 text-xs text-slate-500 dark:text-slate-400",children:["Problema #",i.problema_id]})]}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("span",{className:"flex items-center gap-2 text-sm text-slate-600 dark:text-slate-400",children:[e.jsx(Xr,{canal:i.canal}),i.canal]})}),e.jsx("td",{className:"max-w-xs px-4 py-3",children:e.jsx("p",{className:"truncate text-sm text-slate-600 dark:text-slate-400",children:i.destinatario||"-"})}),e.jsx("td",{className:"px-4 py-3",children:i.sucesso?e.jsxs("span",{className:"flex items-center gap-1 text-sm text-emerald-600 dark:text-emerald-400",children:[e.jsx(ae,{className:"h-4 w-4"}),"Sucesso"]}):e.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-600 dark:text-red-400",children:[e.jsx(re,{className:"h-4 w-4"}),"Falha"]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{children:[e.jsx("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:new Date(i.executado_em).toLocaleDateString("pt-BR")}),e.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500",children:i.executado_por})]})}),e.jsx("td",{className:"relative px-4 py-3",children:e.jsx(el,{acao:i,onFeedbackSent:b})})]},i.id))})]})}),!p&&s>0&&e.jsxs("div",{className:"flex flex-col items-center justify-between gap-3 border-t border-slate-100 px-4 py-3 dark:border-slate-700 sm:flex-row",children:[e.jsxs("p",{className:"text-sm text-slate-600 dark:text-slate-400",children:["Página ",o," de ",w," (total"," ",s.toLocaleString("pt-BR"),")"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:()=>u(i=>Math.max(1,i-1)),disabled:m||o<=1,className:"flex items-center gap-1 rounded-lg border border-slate-200 px-3 py-1.5 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-700",children:[e.jsx(ie,{className:"h-4 w-4"}),"Anterior"]}),e.jsxs("button",{onClick:()=>u(i=>Math.min(w,i+1)),disabled:m||o>=w,className:"flex items-center gap-1 rounded-lg border border-slate-200 px-3 py-1.5 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-700",children:["Próxima",e.jsx(Tt,{className:"h-4 w-4"})]})]})]})]})]})}function pe({label:t,valor:a,icon:s,color:r}){return e.jsx("div",{className:"rounded-xl border border-slate-200 bg-white p-4 dark:border-slate-700 dark:bg-slate-800",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`rounded-lg p-2 ${r}`,children:e.jsx(s,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold text-slate-900 dark:text-white",children:a}),e.jsx("p",{className:"text-xs text-slate-600 dark:text-slate-400",children:t})]})]})})}function al({solucao:t}){return e.jsxs("div",{className:"rounded-xl border border-slate-200 bg-white p-4 dark:border-slate-700 dark:bg-slate-800",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-slate-900 dark:text-white",children:t.tipo_problema.replace(/_/g," ")}),e.jsx("span",{className:"rounded bg-slate-100 px-1.5 py-0.5 text-xs text-slate-600 dar
61k:bg-slate-700 dark:text-slate-400",children:t.tipo_acao})]}),e.jsxs("p",{className:"mt-1 text-xs text-slate-500 dark:text-slate-400",children:["Canal: ",t.canal]})]}),e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${t.ativa?"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-400":"bg-slate-100 text-slate-500 dark:bg-slate-700 dark:text-slate-400"}`,children:t.ativa?"Ativa":"Inativa"})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"rounded-lg bg-slate-50 p-2 text-center dark:bg-slate-700/50",children:[e.jsxs("p",{className:"text-lg font-bold text-slate-900 dark:text-white",children:[t.confianca,"%"]}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:"Confiança"})]}),e.jsxs("div",{className:"rounded-lg bg-slate-50 p-2 text-center dark:bg-slate-700/50",children:[e.jsx("p",{className:"text-lg font-bold text-slate-900 dark:text-white",children:t.vezes_usada}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:"Usos"})]}),e.jsxs("div",{className:"rounded-lg bg-slate-50 p-2 text-center dark:bg-slate-700/50",children:[e.jsxs("p",{className:"text-lg font-bold text-emerald-600 dark:text-emerald-400",children:[t.taxa_sucesso,"%"]}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:"Sucesso"})]})]}),t.atualizada_em&&e.jsxs("p",{className:"mt-2 text-xs text-slate-400 dark:text-slate-500",children:["Atualizada em ",new Date(t.atualizada_em).toLocaleDateString("pt-BR")]})]})}function sl(){const[t,a]=l.useState(null),[s,r]=l.useState([]),[o,u]=l.useState(!0),[m,v]=l.useState(!1),[p,k]=l.useState(!1),[c,x]=l.useState(!1),N=l.useCallback(async()=>{try{u(!0);const[g,d]=await Promise.allSettled([Tr(),$r(!m)]);g.status==="fulfilled"?a(g.value):console.error("Erro nas estatísticas de aprendizado:",g.reason),d.status==="fulfilled"?r(d.value):console.error("Erro nas soluções aprendidas:",d.reason),k(g.status==="rejected"),x(d.status==="rejected")}finally{u(!1)}},[m]);return l.useEffect(()=>{N()},[N]),o&&!t?e.jsxs("div",{className:"space-y-6",children:[e.jsx(J,{title:"Aprendizado",subtitle:"Carregando...",icon:e.jsx(Se,{className:"h-6 w-6"})}),e.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[...Array(4)].map((g,d)=>e.jsx("div",{className:"h-24 animate-pulse rounded-xl bg-slate-200 dark:bg-slate-700"},d))})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(J,{title:"Aprendizado",subtitle:"Soluções aprendidas e estatísticas do sistema",icon:e.jsx(Se,{className:"h-6 w-6"}),actions:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:N,disabled:o,className:"flex items-center gap-2 rounded-lg border border-slate-200 px-4 py-2 text-sm font-medium text-slate-700 transition hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800",children:e.jsx(se,{className:`h-4 w-4 ${o?"animate-spin":""}`})}),e.jsxs(H,{to:"/aria-autonoma",className:"flex items-center gap-2 rounded-lg border border-slate-200 px-4 py-2 text-sm font-medium text-slate-700 transition hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800",children:[e.jsx(ie,{className:"h-4 w-4"}),"Voltar"]})]})}),(p||c)&&e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-amber-200 bg-amber-50 p-4 dark:border-amber-800 dark:bg-amber-900/20",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-amber-800 dark:text-amber-300",children:[e.jsx(V,{className:"h-4 w-4 shrink-0"}),e.jsxs("span",{children:["Falha ao carregar"," ",[p&&"as estatísticas",c&&"as soluções aprendidas"].filter(Boolean).join(" e ")," — os dados abaixo podem estar incompletos ou desatualizados."]})]}),e.jsx("button",{onClick:N,className:"shrink-0 rounded-lg border border-amber-300 px-3 py-1.5 text-xs font-medium text-amber-800 transition hover:bg-amber-100 dark:border-amber-700 dark:text-amber-300 dark:hover:bg-amber-900/40",children:"Tentar novamente"})]}),t&&e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(pe,{label:"Soluções Ativas",valor:t.solucoes_ativas,icon:oe,color:"bg-purple-100 text-purple-600 dar
61k:bg-purple-900/30 dark:text-purple-400"}),e.jsx(pe,{label:"Taxa de Sucesso Global",valor:`${t.taxa_sucesso_global}%`,icon:ae,color:"bg-emerald-100 text-emerald-600 dark:bg-emerald-900/30 dark:text-emerald-400"}),e.jsx(pe,{label:"Confiança Média",valor:`${t.confianca_media}%`,icon:Ka,color:"bg-blue-100 text-blue-600 dark:bg-blue-900/30 dark:text-blue-400"}),e.jsx(pe,{label:"Anti-Soluções",valor:t.total_anti_solucoes,icon:re,color:"bg-red-100 text-red-600 dark:bg-red-900/30 dark:text-red-400"})]}),t&&Object.keys(t.problemas_por_tipo).length>0&&e.jsxs("div",{className:"rounded-2xl border border-slate-200 bg-white p-6 dark:border-slate-700 dark:bg-slate-800",children:[e.jsx("h3",{className:"mb-4 text-sm font-semibold text-slate-700 dark:text-slate-200",children:"Problemas por Tipo"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(t.problemas_por_tipo).map(([g,d])=>e.jsxs("div",{className:"rounded-lg bg-slate-100 px-3 py-2 dark:bg-slate-700",children:[e.jsx("span",{className:"text-sm font-medium text-slate-900 dark:text-white",children:d}),e.jsx("span",{className:"ml-2 text-xs text-slate-500 dark:text-slate-400",children:g.replace(/_/g," ")})]},g))})]}),e.jsxs("div",{className:"rounded-2xl border border-slate-200 bg-white p-6 dark:border-slate-700 dark:bg-slate-800",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsxs("h3",{className:"flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-slate-200",children:[e.jsx(oe,{className:"h-4 w-4"}),"Soluções Aprendidas"]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-slate-600 dark:text-slate-400",children:[e.jsx("input",{type:"checkbox",checked:m,onChange:g=>v(g.target.checked),className:"rounded border-slate-300 text-blue-600 focus:ring-blue-500 dark:border-slate-600"}),"Mostrar inativas"]})]}),c&&s.length===0?e.jsx("p",{className:"py-8 text-center text-sm text-red-600 dark:text-red-400",children:'Não foi possível carregar as soluções — use "Tentar novamente" acima'}):s.length===0?e.jsxs("p",{className:"py-8 text-center text-sm text-slate-500 dark:text-slate-400",children:["Nenhuma solução ",m?"":"ativa ","encontrada"]}):e.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3",children:s.map(g=>e.jsx(al,{solucao:g},g.id))})]})]})}const rl=[{value:"alertar",label:"Alertar",icon:Ga,desc:"Detecta e avisa, não age sozinha",color:"blue"},{value:"agir",label:"Agir",icon:Ft,desc:"Corrige problemas simples automaticamente",color:"amber"},{value:"total",label:"Total",icon:oe,desc:"Autonomia máxima — use com cautela",color:"red",warning:!0}],ll={pedidos_pendentes:{label:"Pedidos de Filiação",icon:Bt},mandatos_vencendo:{label:"Mandatos Vencendo",icon:Wt},integracoes:{label:"Integrações",icon:us},financeiro:{label:"Financeiro",icon:ds},membros_orgaos:{label:"Membros de Órgãos",icon:cs},pre_candidaturas:{label:"Pré-candidaturas",icon:Ha},filiacao:{label:"Filiação Online",icon:os},erros_500:{label:"Erros HTTP 500",icon:Cs},servicos:{label:"Serviços (systemd)",icon:Re},infra:{label:"Infraestrutura",icon:_s},integracoes_ext:{label:"APIs Externas",icon:is}},nl=[{value:"notificar",label:"Enviar notificações",icon:Ja},{value:"lembrete",label:"Criar lembretes",icon:Ke},{value:"escalonar",label:"Escalar para superior",icon:V},{value:"criar_tarefa",label:"Criar tarefas",icon:Ve},{value:"atualizar_dados",label:"Alterar dados no sistema",icon:Ft,warning:!0}],il=[{value:"critica",label:"Crítica",color:"red"},{value:"alta",label:"Alta",color:"orange"},{value:"media",label:"Média",color:"amber"},{value:"baixa",label:"Baixa",color:"blue"}];function W(t,a,s){return!t||!t[a]?s:t[a].valor}function Z({title:t,icon:a,children:s}){return e.jsxs($t.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},className:"rounded-2xl border border-slate-200 bg-white p-6 dark:border-slate-700 dark:bg-slate-800",children:[e.jsxs("h3",{className:"mb-4 flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-slate-200",children:[e.jsx(a,{className:"h-4 w-4"}),t]}),s]})}function vt({monitor:t}){const a=ll[t.nome]||{label:t.nome,icon:ce},s=a.icon;return e.jsxs("div",{className:"flex items-center gap-3 rounded-xl border border-slate-100 p-3 dark:border-slate-700",children:[e.jsx("div",{className:`rounded-lg p-2 ${t.ativo?"bg-emerald-100 text-emerald-600 dark:bg-emerald-900/30 dark:text-emerald-400":"bg-slate-100 text-slate-400 dark:bg-slate-700"}`,children:e.jsx(s,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-white",children:a.label}),e.jsx("p",{className:"truncate text-xs text-slate-500 dark:text-slate-400",children:t.descricao})]}),e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${t.ativo?"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-400":"bg-slate-100 text-slate-500 dark:bg-slate-700 dark:text-slate-400"}`,children:t.ativo?"Ativo":"Inativo"})]})}function ol(){const[t,a]=l.useState(null),[s,r]=l.useState([]),[o,u]=l.useState(null),[m,v]=l.useState(!0),[p,k]=l.useState(null),[c,x]=l.useState(!1),[N,g]=l.useState(!1),d=l.useCallback(async()=>{try{v(!0);const[n,y,P]=await Promise.all([Lr(),Br(),Or()]);a(n),r(y),u(P),g(!1),k(null)}catch(n){k(te(n,"Erro ao carregar configurações")),console.error(n)}finally{v(!1)}},[]);l.useEffect(()=>{d()},[d]);const f=(n,y)=>{t&&(a({...t,[n]:{...t[n],valor:y}}),g(!0))},w=(n,y)=>{const P=W(t,n,[]),M=P.includes(y)?P.filter(R=>R!==y):[...P,y];f(n,M)},h=async()=>
61{if(t){x(!0);try{const n={};for(const[y,P]of Object.entries(t))n[y]=P.valor;await Dr(n),G.success("Configurações salvas!"),g(!1)}catch(n){G.error(te(n,"Erro ao salvar configurações"))}finally{x(!1)}}},b=async()=>{try{const n=await Yt();G.success(`Ciclo executado: ${n.problemas_detectados} problemas, ${n.acoes_executadas} ações`),d()}catch{G.error("Erro ao executar ciclo")}},A=async()=>{try{await ea(),G.success("Relatório diário gerado e enviado")}catch{G.error("Erro ao gerar relatório")}};if(m&&!t)return e.jsxs("div",{className:"space-y-6",children:[e.jsx(J,{title:"Configurações",subtitle:"Carregando...",icon:e.jsx(je,{className:"h-6 w-6"})}),e.jsx("div",{className:"space-y-4",children:[...Array(4)].map((n,y)=>e.jsx("div",{className:"h-32 animate-pulse rounded-2xl bg-slate-200 dark:bg-slate-700"},y))})]});if(!t)return e.jsxs("div",{className:"space-y-6",children:[e.jsx(J,{title:"Configurações",subtitle:"Falha ao carregar",icon:e.jsx(je,{className:"h-6 w-6"})}),e.jsxs("div",{className:"rounded-2xl border border-slate-200 bg-white p-8 text-center dark:border-slate-700 dark:bg-slate-800",children:[e.jsx(V,{className:"mx-auto h-8 w-8 text-red-500"}),e.jsx("p",{className:"mt-2 text-sm text-red-600 dark:text-red-400",children:"Não foi possível carregar a configuração da ARIA"}),p&&e.jsx("p",{className:"mt-1 text-xs text-slate-500 dark:text-slate-400",children:p}),e.jsx("button",{onClick:d,className:"mt-4 rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white transition hover:bg-blue-700",children:"Tentar novamente"})]})]});const i=W(t,"autonomia_nivel","alertar"),E=W(t,"tipos_acao_permitidos",[]),S=W(t,"severidades_requer_aprovacao",[]);return W(t,"monitores_ativos",[]),e.jsxs("div",{className:"space-y-6",children:[e.jsx(J,{title:"Configurações",subtitle:"Controle completo da ARIA Autônoma",icon:e.jsx(je,{className:"h-6 w-6"}),actions:e.jsxs("div",{className:"flex items-center gap-2",children:[N&&e.jsx("span",{className:"rounded-full bg-amber-100 px-3 py-1 text-xs font-medium text-amber-700 dark:bg-amber-900/30 dark:text-amber-400",children:"Alterações não salvas"}),e.jsxs("button",{onClick:h,disabled:c||!N,className:"flex items-center gap-1.5 rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white transition hover:bg-blue-700 disabled:opacity-40",children:[c?e.jsx(se,{className:"h-4 w-4 animate-spin"}):e.jsx(Va,{className:"h-4 w-4"}),"Salvar"]}),e.jsxs(H,{to:"/aria-autonoma",className:"flex items-center gap-1.5 rounded-lg border border-slate-200 px-3 py-2 text-sm text-slate-700 transition hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800",children:[e.jsx(ie,{className:"h-4 w-4"}),"Voltar"]})]})}),e.jsx(Z,{title:"Nível de Autonomia",icon:ot,children:e.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:rl.map(n=>{const y=i===n.value,P=n.icon,M=n.color==="blue"?"border-blue-500 bg-blue-50 dark:border-blue-400 dark:bg-blue-900/20":n.color==="amber"?"border-amber-500 bg-amber-50 dark:border-amber-400 dark:bg-amber-900/20":"border-red-500 bg-red-50 dark:border-red-400 dark:bg-red-900/20";return e.jsxs("button",{onClick:()=>{n.value==="total"&&i!=="total"&&!confirm("Ativar autonomia TOTAL? A ARIA agirá sem intervenção humana.")||f("autonomia_nivel",n.value)},className:`rounded-xl border-2 p-4 text-left transition ${y?M:"border-slate-200 hover:border-slate-300 dark:border-slate-700 dark:hover:border-slate-600"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(P,{className:`h-5 w-5 ${y?"text-blue-600 dark:text-blue-400":"text-slate-400"}`}),e.jsx("span",{className:`text-sm font-semibold ${y?"text-slate-900 dark:text-white":"text-slate-700 dark:text-slate-300"}`,children:n.label}),y&&e.jsx(ae,{className:"ml-auto h-4 w-4 text-emerald-500"})]}),e.jsx("p",{className:"mt-1.5 text-xs text-slate-500 dark:text-slate-400",children:n.desc}),n.warning&&e.jsx("p",{className:"mt-2 text-xs font-medium text-red-600 dark:text-red-400",children:"Requer supervisão constante"})]},n.value)})})}),e.jsx(Z,{title:"Monitores de Negócio",icon:V,children:e.jsx("div",{className:"grid grid-cols-1 gap-2 md:grid-cols-2",children:s.filter(n=>!["erros_500","servicos","infra","integracoes_ext"].includes(n.nome)).map(n=>e.jsx(vt,{monitor:n},n.nome))})}),e.jsx(Z,{title:"Monitores Técnicos",icon:Re,children:e.jsxs("div",{className:"grid grid-cols-1 gap-2 md:grid-cols-2",children:[s.filter(n=>["erros_500","servicos","infra","integracoes_ext"].includes(n.nome)).map(n=>e.jsx(vt,{monitor:n},n.nome)),s.filter(n=>["erros_500","servicos","infra","integracoes_ext"].includes(n.nome)).length===0&&e.jsx("p",{className:"col-span-2 py-4 text-center text-sm text-slate-500 dark:text-slate-400",children:"Monitores técnicos gerenciados pelo scheduler (cada 2 min)"})]})}),e.jsx(Z,{title:"Ações Permitidas",icon:oe,children:e.jsx("div",{className:"space-y-2",children:nl.map(n=>{const y=E.includes(n.value),P=n.icon;return e.jsxs("label",{className:`flex cursor-pointer items-center gap-3 rounded-lg border p-3 transition ${y?"border-blue-200 bg-blue-50 dark:border-blue-800 dark:bg-blue-900/20":"border-slate-100 dar
61k:border-slate-700"}`,children:[e.jsx("input",{type:"checkbox",checked:y,onChange:()=>{n.value==="atualizar_dados"&&!y&&!confirm("Permitir que a ARIA altere dados no sistema?")||w("tipos_acao_permitidos",n.value)},className:"rounded border-slate-300 text-blue-600 focus:ring-blue-500"}),e.jsx(P,{className:"h-4 w-4 text-slate-500"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("span",{className:"text-sm font-medium text-slate-900 dark:text-white",children:n.label}),n.warning&&y&&e.jsx("span",{className:"ml-2 text-xs text-red-600 dark:text-red-400",children:"Permite alteração de dados"})]})]},n.value)})})}),e.jsxs(Z,{title:"Severidades que Requerem Aprovação",icon:ot,children:[e.jsx("p",{className:"mb-3 text-xs text-slate-500 dark:text-slate-400",children:"Ações nessas severidades sempre pedem confirmação antes de executar."}),e.jsx("div",{className:"flex flex-wrap gap-2",children:il.map(n=>{const y=S.includes(n.value),P={red:y?"border-red-400 bg-red-100 text-red-700 dark:border-red-600 dark:bg-red-900/30 dark:text-red-400":"border-slate-200 text-slate-600 dark:border-slate-700 dark:text-slate-400",orange:y?"border-orange-400 bg-orange-100 text-orange-700 dark:border-orange-600 dark:bg-orange-900/30 dark:text-orange-400":"border-slate-200 text-slate-600 dark:border-slate-700 dark:text-slate-400",amber:y?"border-amber-400 bg-amber-100 text-amber-700 dark:border-amber-600 dark:bg-amber-900/30 dark:text-amber-400":"border-slate-200 text-slate-600 dark:border-slate-700 dark:text-slate-400",blue:y?"border-blue-400 bg-blue-100 text-blue-700 dark:border-blue-600 dark:bg-blue-900/30 dark:text-blue-400":"border-slate-200 text-slate-600 dark:border-slate-700 dark:text-slate-400"};return e.jsxs("button",{onClick:()=>
61w("severidades_requer_aprovacao",n.value),className:`rounded-lg border-2 px-4 py-2 text-sm font-medium transition ${P[n.color]}`,children:[y&&e.jsx(ae,{className:"mr-1 inline h-3.5 w-3.5"}),n.label]},n.value)})})]}),e.jsx(Z,{title:"Limites",icon:ce,children:e.jsxs("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-xs font-medium text-slate-600 dark:text-slate-400",children:"Máximo ações/hora"}),e.jsx("input",{type:"number",min:1,max:500,value:W(t,"max_acoes_hora",200),onChange:n=>f("max_acoes_hora",parseInt(n.target.value)||200),className:"w-full rounded-lg border border-slate-200 bg-white px-3 py-2 text-sm dark:border-slate-700 dark:bg-slate-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-xs font-medium text-slate-600 dark:text-slate-400",children:"Máximo ações/dia"}),e.jsx("input",{type:"number",min:1,max:5e3,value:W(t,"max_acoes_dia",500),onChange:n=>f("max_acoes_dia",parseInt(n.target.value)||500),className:"w-full rounded-lg border border-slate-200 bg-white px-3 py-2 text-sm dark:border-slate-700 dark:bg-slate-900 dark:text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-xs font-medium text-slate-600 dark:text-slate-400",children:"Confiança mínima (0.0 - 1.0)"}),e.jsx("input",{type:"number",min:0,max:1,step:.05,value:W(t,"min_confianca_global",.7),onChange:n=>f("min_confianca_global",parseFloat(n.target.value)||.7),className:"w-full rounded-lg border border-slate-200 bg-white px-3 py-2 text-sm dark:border-slate-700 dark:bg-slate-900 dark:text-white"}),(()=>{const n=W(t,"min_confianca_global",.7);return n<.5?e.jsx("p",{className:"mt-1 text-xs text-red-600",children:"Muito permissivo"}):n<=.7?e.jsx("p",{className:"mt-1 text-xs text-amber-600",children:"Moderado"}):e.jsx("p",{className:"mt-1 text-xs text-emerald-600",children:"Conservador"})})()]})]})}),e.jsxs(Z,{title:"Horário Ativo",icon:Wt,children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs text-slate-500 dark:text-slate-400",children:"Início"}),e.jsx("input",{type:"time",value:W(t,"horario_ativo_inicio","00:00"),onChange:n=>f("horario_ativo_inicio",n.target.value),className:"rounded-lg border border-slate-200 bg-white px-3 py-2 text-sm dark:border-slate-700 dark:bg-slate-900 dark:text-white"})]}),e.jsx("span",{className:"mt-5 text-slate-400",children:"até"}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs text-slate-500 dark:text-slate-400",children:"Fim"}),e.jsx("input",{type:"time",value:W(t,"horario_ativo_fim","23:59"),onChange:n=>f("horario_ativo_fim",n.target.value),className:"rounded-lg border border-slate-200 bg-white px-3 py-2 text-sm dark:border-slate-700 dark:bg-slate-900 dark:text-white"})]})]}),e.jsxs("p",{className:"mt-2 text-xs text-slate-500 dark:text-slate-400",children:["ARIA ativa das ",W(t,"horario_ativo_inicio","00:00")," às"," ",W(t,"horario_ativo_fim","23:59")]})]}),e.jsxs(Z,{title:"Scheduler Automático",icon:oe,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm text-slate-700 dark:text-slate-300",children:["Status:"," ",e.jsx("span",{className:o!=null&&o.running?"font-medium text-emerald-600 dark:text-emerald-400":"font-medium text-red-600 dark:text-red-400",children:o?o.running?"Ativo":"Parado":"desconhecido"})]}),e.jsx("p",{className:"text-xs text-slate-500",children:o?`${o.execution_count||0} ciclos executados`:"sem dado"})]}),e.jsx("span",{className:"text-xs text-slate-400 dark:text-slate-500",children:"Gerenciado pelo servidor"})]}),(o==null?void 0:o.jobs)&&o.jobs.length>0&&e.jsx("div",{className:"mt-4 space-y-1",children:o.jobs.map(n=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-slate-50 px-3 py-2 text-sm dark:bg-slate-700/50",children:[e.jsx("span",{className:"text-slate-700 dark:text-slate-300",children:n.name}),e.jsxs("span",{className:"flex items-center gap-1 text-xs text-slate-500",children:[e.jsx(Ke,{className:"h-3 w-3"}),n.next_run?new Date(n.next_run).toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"}):"-"]})]},n.id))})]}),e.jsx(Z,{title:"Ações Rápidas",icon:Le,children:e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs("button",{onClick:b,className:"flex items-center gap-2 rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white transition hover:bg-blue-700",children:[e.jsx(Le,{className:"h-4 w-4"}),"Forçar Ciclo Completo"]}),e.jsxs("button",{onClick:A,className:"flex items-center gap-2 rounded-lg border border-slate-200 px-4 py-2 text-sm font-medium text-slate-700 transition hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800",children:[e.jsx(Ve,{className:"h-4 w-4"}),"Gerar Relatório Diário"]})]})})]})}const kt=typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window),yt=typeof window<"u"&&"speechSynthesis"in window,cl="";function dl(){const[t,a]=l.useState(!1),[s,r]=l.useState(!1),[o,u]=l.useState(""),[m,v]=l.useState(""),[p,k]=l.useState(null),[c,x]=l.useState(0),N=l.useRef(null),g=l.useRef(null),d=l.useRef(null),f=l.useRef(null),w=l.useRef(null),h=l.useRef(0),b=l.useRef(null),A=l.useCallback(()=>
61{if(!kt){k("Reconhecimento de voz não suportado");return}k(null),u(""),v("");const M=window.SpeechRecognition||window.webkitSpeechRecognition,R=new M;R.lang="pt-BR",R.continuous=!1,R.interimResults=!0,R.maxAlternatives=1,R.onstart=()=>a(!0),R.onresult=j=>{g.current&&clearTimeout(g.current);let C="",_="";for(let I=j.resultIndex;I<j.results.length;I++){const B=j.results[I][0].transcript;j.results[I].isFinal?_+=B:C+=B}_&&u(I=>I+_),v(C),_||(g.current=setTimeout(()=>{N.current&&N.current.stop()},2e3))},R.onerror=j=>{j.error==="not-allowed"?k("Permissão do microfone negada"):j.error==="no-speech"?k("Nenhuma fala detectada"):j.error!=="aborted"&&k("Erro no reconhecimento"),a(!1),S()},R.onend=()=>{a(!1),v(""),g.current&&clearTimeout(g.current),S()},N.current=R,R.start(),E()},[]),i=l.useCallback(()=>{N.current&&(N.current.stop(),N.current=null),g.current&&clearTimeout(g.current),a(!1),v(""),S()},[]),E=l.useCallback(async()=>{try{const M=await navigator.mediaDevices.getUserMedia({audio:!0});w.current=M;const R=new AudioContext;d.current=R;const j=R.createAnalyser();j.fftSize=256,f.current=j,R.createMediaStreamSource(M).connect(j);const _=new Uint8Array(j.frequencyBinCount),I=()=>{if(!f.current)return;j.getByteFrequencyData(_);const B=_.reduce((T,$)=>T+$,0)/_.length/255;x(B),h.current=requestAnimationFrame(I)};I()}catch{}},[]),S=l.useCallback(()=>{h.current&&cancelAnimationFrame(h.current),w.current&&(w.current.getTracks().forEach(M=>M.stop()),w.current=null),d.current&&(d.current.close().catch(()=>{}),d.current=null),f.current=null,x(0)},[]),n=l.useCallback(async M=>{if(!M)return;let R=M.replace(/\*\*(.*?)\*\*/g,"$1").replace(/```[\s\S]*?```/g,"código omitido").replace(/\n- /g,". ").replace(/\n/g,". ").replace(/\|/g,",").replace(/#{1,6}\s/g,"").trim();R.length>1500&&(R=R.slice(0,1500)+"..."),r(!0);try{const j=localStorage.getItem("token"),C=await fetch(`${cl}/api/v1/aria/tts`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${j}`},body:JSON.stringify({text:R})});if(C.ok){const _=await C.blob(),I=URL.createObjectURL(_),B=new Audio(I);b.current=B,B.onended=()=>{URL.revokeObjectURL(I),r(!1),b.current=null},B.onerror=()=>{URL.revokeObjectURL(I),r(!1),b.current=null},await B.play();return}}catch{}if(yt){speechSynthesis.cancel();const j=new SpeechSynthesisUtterance(R.slice(0,500));j.lang="pt-BR",j.rate=1.1;const _=speechSynthesis.getVoices().find(I=>I.lang.startsWith("pt"));_&&(j.voice=_),j.onend=()=>r(!1),j.onerror=()=>r(!1),speechSynthesis.speak(j)}else r(!1)},[]),y=l.useCallback(()=>{b.current&&(b.current.pause(),b.current=null),yt&&speechSynthesis.cancel(),r(!1)},[]);return l.useEffect(()=>{const M=j=>{var _;if(j.code!=="Space"||j.repeat)return;const C=(_=j.target)==null?void 0:_.tagName;C==="INPUT"||C==="TEXTAREA"||C==="SELECT"||(j.preventDefault(),t||A())},R=j=>{var _;if(j.code!=="Space")return;const C=(_=j.target)==null?void 0:_.tagName;C==="INPUT"||C==="TEXTAREA"||C==="SELECT"||t&&i()};return document.addEventListener("keydown",M),document.addEventListener("keyup",R),()=>{document.removeEventListener("keydown",M),document.removeEventListener("keyup",R)}},[t,A,i]),l.useEffect(()=>()=>{S(),g.current&&clearTimeout(g.current)},[S]),{startListening:A,stopListening:i,isListening:t,transcript:o,interimTranscript:m,speak:n,stopSpeaking:y,isSpeaking:s,voiceState:t?"listening":s?"speaking":"idle",volume:c,error:p,supported:{stt:kt,tts:!0}}}function ul(){const[t,a]=l.useState(null),[s,r]=l.useState(!1);l.useEffect(()=>{if(window.matchMedia("(display-mode: standalone)").matches||localStorage.getItem("aria-install-dismissed")||!/Android|iPhone|iPad/i.test(navigator.userAgent))return;const p=c=>{c.preventDefault(),a(c),r(!0)};return window.addEventListener("beforeinstallprompt",p),/iPhone|iPad/.test(navigator.userAgent)&&!window.MSStream&&setTimeout(()=>r(!0),3e3),()=>window.removeEventListener("beforeinstallprompt",p)},[]);const o=async()=>{if(t){t.prompt();const{outcome:m}=await t.userChoice;m==="accepted"&&r(!1),a(null)}else alert("Toque em Compartilhar (icone de seta) e depois em 'Adicionar a Tela de Inicio'")},u=()=>{r(!1),localStorage.setItem("aria-install-dismissed","1")};return s?e.jsxs("div",{style:{position:"fixed",bottom:0,left:0,right:0,zIndex:9999,padding:"12px 16px",background:"linear-gradient(135deg, rgba(6,9,17,0.97), rgba(34,211,238,0.08))",borderTop:"1px solid rgba(34,211,238,0.2)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,backdropFilter:"blur(12px)"},children:[e.jsx("span",{style:{fontSize:12,color:"rgba(255,255,255,0.8)",fontFamily:"'JetBrains Mono', sans-serif"},children:"Instale o app ARIA no celular"}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:u,style:{padding:"6px 12px",fontSize:11,borderRadius:8,border:"1px solid rgba(255,255,255,0.1)",background:"transparent",color:"rgba(255,255,255,0.4)",cursor:"pointer"},children:"Depois"}),e.jsx("button",{onClick:o,style:{padding:"6px 14px",fontSize:11,borderRadius:8,fontWeight:600,border:"1px solid rgba(34,211,238,0.3)",background:"rgba(34,211,238,0.15)",color:"rgba(34,211,238,0.9)",cursor:"pointer"},children:"Instalar"})]})]}):null}const jt=typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window),ta=["aria","area","arya","a ria","ei aria","oi aria","oi area","hey aria","fala aria","e aria","e area"];function aa(t){return t.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").trim()}function xl(t){const a=aa(t);for(const s of ta){const r=a.indexOf(s);if(r>=0){const o=t.slice(r+s.length).trim().replace(/^[,.\s]+/,"").trim();return o.length>2?o:null}}return null}function ml(){try{const t=new AudioContext,a=t.createOscillator(),s=t.createGain();a.connect(s),s.connect(t.destination),a.frequency.value=880,s.gain.value=.15,a.start(),s.gain.exponentialRampToValueAtTime(.001,t.currentTime+.12),a.stop(t.currentTime+.12),setTimeout(()=>t.close(),300)}catch{}}function pl({enabled:t,onActivated:a}){const[s,r]=l.useState(!1),[o,u]=l.useState(""),[m,v]=l.useState(null),p=l.useRef(null),k=l.useRef(null),c=l.useRef(t),x=l.useRef(!1),N=l.useRef(a),g=l.useRef(0);l.useEffect(()=>{c.current=t},[t]),l.useEffect(()=>{N.current=a},[a]);const d=l.useCallback(()=>
61{if(k.current&&(clearTimeout(k.current),k.current=null),p.current){try{p.current.abort()}catch{}p.current=null}r(!1),g.current=0},[]),f=l.useCallback(()=>{if(!jt||!c.current||x.current)return;if(g.current++,g.current>100){v("Mic sem resposta"),console.warn("[WakeWord] Muitos restarts sem resultados — parando.");return}if(p.current)try{p.current.abort()}catch{}const w=window.SpeechRecognition||window.webkitSpeechRecognition,h=new w;h.lang="pt-BR",h.continuous=!0,h.interimResults=!0,h.onstart=()=>{r(!0),v(null)},h.onresult=b=>{g.current=0;for(let A=b.resultIndex;A<b.results.length;A++){const i=b.results[A][0].transcript,E=aa(i);if(u(i),console.log("[WakeWord]",b.results[A].isFinal?"FINAL:":"interim:",i,"→",E),ta.some(S=>E.includes(S))){x.current=!0;try{h.stop()}catch{}p.current=null,r(!1),ml();const S=b.results[A].isFinal?xl(i):null;N.current(S),k.current=setTimeout(()=>{x.current=!1,c.current&&f()},5e3);return}}},h.onerror=b=>{const A=(b==null?void 0:b.error)||"unknown";console.warn("[WakeWord] onerror:",A),A==="not-allowed"||A==="service-not-allowed"?(v("Mic bloqueado"),x.current=!0):A==="audio-capture"?v("Mic indisponível"):A==="network"&&v("Sem rede p/ STT")},h.onend=()=>{r(!1),p.current=null,c.current&&!x.current&&(k.current=setTimeout(f,300))},p.current=h;try{h.start()}catch(b){console.warn("[WakeWord] start() falhou:",b==null?void 0:b.message),v("Start falhou"),k.current=setTimeout(f,2e3)}},[]);return l.useEffect(()=>(t?(x.current=!1,g.current=0,v(null),u(""),f()):d(),d),[t,f,d]),l.useEffect(()=>{const w=()=>{document.hidden?d():c.current&&(g.current=0,setTimeout(f,300))};return document.addEventListener("visibilitychange",w),()=>document.removeEventListener("visibilitychange",w)},[f,d]),{isStandby:s,lastHeard:o,error:m,supported:jt}}const be={idle:{r:34,g:211,b:238},thinking:{r:245,g:158,b:11},active:{r:34,g:197,b:94},listening:{r:168,g:85,b:247},speaking:{r:56,g:189,b:248}};function Be(t,a,s){return t+(a-t)*s}function bl(t,a,s){return{r:Math.round(Be(t.r,a.r,s)),g:Math.round(Be(t.g,a.g,s)),b:Math.round(Be(t.b,a.b,s))}}function wt({state:t="idle",size:a=220,healthScore:s=null,volume:r=0}){const o=l.useRef(null),u=l.useRef(0),m=l.useRef([]),v=l.useRef({...be.idle}),p=l.useRef({...be.idle}),k=l.useRef([]);return l.useEffect(()=>{if(p.current=be[t]||be.idle,t==="active"||t==="speaking")for(let c=0;c<3;c++)k.current.push({radius:a*.15,alpha:.5,speed:1.2+c*.4})},[t,a]),l.useEffect(()=>{const c=o.current;if(!c)return;const x=c.getContext("2d");if(!x)return;const N=window.devicePixelRatio||1;c.width=a*N,c.height=a*N,x.scale(N,N);const g=a/2,d=a/2,f=a*.18;if(!m.current.length)for(let b=0;b<40;b++)m.current.push({angle:Math.random()*Math.PI*2,dist:f*1.4+Math.random()*f*2.2,speed:.002+Math.random()*.005,sz:.6+Math.random()*1.8,aBase:.15+Math.random()*.45,aOff:Math.random()*Math.PI*2});let w=!0;function h(){if(!w)return;u.current++;const b=u.current*.016;v.current=bl(v.current,p.current,.035);const A=v.current,i=`${A.r},${A.g},${A.b}`;x.clearRect(0,0,a,a);const S=1+Math.sin(b*(t==="thinking"?3.5:t==="listening"?2.5:t==="active"||t==="speaking"?2:.7))*.05+r*.12;[1.6,2.1,2.7].forEach((C,_)=>{const I=f*C*S;x.save(),x.translate(g,d),x.rotate(b*(.12-_*.03)*(_%2?-1:1)),x.beginPath(),x.arc(0,0,I,0,Math.PI*2),x.strokeStyle=`rgba(${i},${.07-_*.015})`,x.lineWidth=.8,x.setLineDash([6+_*3,10+_*5]),x.stroke(),x.setLineDash([]),x.restore()});const n=m.current;for(let C=0;C<n.length;C++){const _=n[C],I=g+Math.cos(_.angle)*_.dist,B=d+Math.sin(_.angle)*_.dist;for(let T=C+1;T<n.length;T++){const $=n[T],L=g+Math.cos($.angle)*$.dist,K=d+Math.sin($.angle)*$.dist,Q=Math.hypot(I-L,B-K);Q<55&&(x.beginPath(),x.moveTo(I,B),x.lineTo(L,K),x.strokeStyle=`rgba(${i},${(1-Q/55)*.1})`,x.lineWidth=.4,x.stroke())}}const y=t==="thinking"?2.8:t==="listening"?2:t==="active"||t==="speaking"?1.5:1;for(const C of n){C.angle+=C.speed*y;const _=g+Math.cos(C.angle)*C.dist,I=d+Math.sin(C.angle)*C.dist,B=C.aBase*(.5+.5*Math.sin(b*1.3+C.aOff));x.beginPath(),x.arc(_,I,C.sz,0,Math.PI*2),x.fillStyle=`rgba(${i},${B})`,x.fill()}k.current=k.current.filter(C=>
61(C.radius+=C.speed,C.alpha-=.007,C.alpha<=0?!1:(x.beginPath(),x.arc(g,d,C.radius,0,Math.PI*2),x.strokeStyle=`rgba(${i},${C.alpha})`,x.lineWidth=1.2,x.stroke(),!0)));const P=f*1.8*S,M=x.createRadialGradient(g,d,0,g,d,P);M.addColorStop(0,`rgba(${i},0.12)`),M.addColorStop(1,`rgba(${i},0)`),x.beginPath(),x.arc(g,d,P,0,Math.PI*2),x.fillStyle=M,x.fill();const R=f*S,j=x.createRadialGradient(g-R*.2,d-R*.2,0,g,d,R);j.addColorStop(0,`rgba(${Math.min(A.r+50,255)},${Math.min(A.g+50,255)},${Math.min(A.b+50,255)},0.85)`),j.addColorStop(.7,`rgba(${i},0.6)`),j.addColorStop(1,`rgba(${Math.max(A.r-30,0)},${Math.max(A.g-30,0)},${Math.max(A.b-30,0)},0.4)`),x.beginPath(),x.arc(g,d,R,0,Math.PI*2),x.fillStyle=j,x.shadowColor=`rgba(${i},0.5)`,x.shadowBlur=25+r*30,x.fill(),x.shadowBlur=0,x.fillStyle="rgba(255,255,255,0.85)",x.font=`bold ${Math.round(a*.09)}px 'Orbitron', monospace`,x.textAlign="center",x.textBaseline="middle",x.fillText(s===null?"—":`${s}%`,g,d-2),x.fillStyle="rgba(255,255,255,0.35)",x.font=`${Math.round(a*.035)}px 'JetBrains Mono', monospace`,x.fillText(s===null?"SEM DADO":"SAUDE",g,d+a*.055),requestAnimationFrame(h)}return h(),()=>{w=!1}},[a,t,s]),e.jsx("canvas",{ref:o,style:{width:a,height:a},className:"pointer-events-none"})}function ue({title:t,icon:a,children:s,color:r="cyan",className:o=""}){const u={cyan:{border:"rgba(34,211,238,0.12)",title:"rgba(34,211,238,0.7)",glow:"rgba(34,211,238,0.03)"},amber:{border:"rgba(245,158,11,0.12)",title:"rgba(245,158,11,0.7)",glow:"rgba(245,158,11,0.03)"},green:{border:"rgba(34,197,94,0.12)",title:"rgba(34,197,94,0.7)",glow:"rgba(34,197,94,0.03)"},red:{border:"rgba(239,68,68,0.12)",title:"rgba(239,68,68,0.7)",glow:"rgba(239,68,68,0.03)"},purple:{border:"rgba(168,85,247,0.12)",title:"rgba(168,85,247,0.7)",glow:"rgba(168,85,247,0.03)"}},m=u[r]||u.cyan;return e.jsxs("div",{className:o,style:{background:"rgba(255,255,255,0.02)",border:`1px solid ${m.border}`,borderRadius:14,padding:"14px 16px",backdropFilter:"blur(8px)",boxShadow:`0 0 30px ${m.glow}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:10},children:[e.jsx("span",{style:{fontSize:13},children:a}),e.jsx("span",{style:{fontSize:11,fontWeight:600,color:m.title,fontFamily:"'JetBrains Mono', monospace",letterSpacing:1.5,textTransform:"uppercase"},children:t})]}),s]})}function ge({value:t,max:a,label:s,unit:r="%"}){const o=Math.min(t/a*100,100),u=o<60?"#22c55e":o<80?"#eab308":"#ef4444",m=Number.isInteger(t)?String(t):t.toFixed(1);return e.jsxs("div",{style:{textAlign:"center"},children:[e.jsxs("div",{style:{position:"relative",width:56,height:56,margin:"0 auto"},children:[e.jsxs("svg",{width:"56",height:"56",viewBox:"0 0 56 56",children:[e.jsx("circle",{cx:"28",cy:"28",r:"22",fill:"none",stroke:"rgba(255,255,255,0.06)",strokeWidth:"4"}),e.jsx("circle",{cx:"28",cy:"28",r:"22",fill:"none",stroke:u,strokeWidth:"4",strokeDasharray:`${o*1.382} 138.2`,strokeLinecap:"round",transform:"rotate(-90 28 28)",style:{filter:`drop-shadow(0 0 4px ${u}60)`,transition:"stroke-dasharray 0.8s"}})]}),e.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx("span",{style:{fontSize:12,fontWeight:700,color:"rgba(255,255,255,0.85)",fontFamily:"'Orbitron', monospace"},children:m})})]}),e.jsx("div",{style:{fontSize:9,color:"rgba(255,255,255,0.35)",marginTop:4,fontFamily:"'JetBrains Mono', monospace",letterSpacing:1},children:s})]})}function gl({name:t,ok:a}){return e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:5,padding:"4px 10px",borderRadius:14,background:"rgba(255,255,255,0.02)",border:`1px solid ${a?"rgba(34,197,94,0.15)":"rgba(239,68,68,0.15)"}`},children:[e.jsx("div",{style:{width:5,height:5,borderRadius:"50%",background:a?"#22c55e":"#ef4444",boxShadow:`0 0 6px ${a?"rgba(34,197,94,0.5)":"rgba(239,68,68,0.5)"}`}}),e.jsx("span",{style:{fontSize:10,color:a?"rgba(34,197,94,0.6)":"rgba(239,68,68,0.6)",fontFamily:"'JetBrains Mono', monospace"},children:t})]})}function he({label:t,value:a,total:s,color:r}){const o=s>0?a/s*100:0;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6}
61,children:[e.jsx("span",{style:{fontSize:10,color:"rgba(255,255,255,0.4)",width:48,textAlign:"right",fontFamily:"'JetBrains Mono', monospace"},children:t}),e.jsx("div",{style:{flex:1,height:6,background:"rgba(255,255,255,0.04)",borderRadius:3,overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",width:`${o}%`,background:r,borderRadius:3,boxShadow:`0 0 6px ${r}40`,transition:"width 0.8s"}})}),e.jsx("span",{style:{fontSize:11,fontWeight:700,color:"rgba(255,255,255,0.7)",width:20,fontFamily:"'JetBrains Mono', monospace"},children:a})]})}function hl({tipo:t,dest:a,ok:s,hora:r,quem:o}){const u=o==null?void 0:o.includes("auto");return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 0",borderBottom:"1px solid rgba(255,255,255,0.03)"},children:[e.jsx("div",{style:{width:18,height:18,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",background:s?"rgba(34,197,94,0.15)":"rgba(239,68,68,0.15)",flexShrink:0},children:s?e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"#22c55e",strokeWidth:"3",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"#ef4444",strokeWidth:"3",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[e.jsx("span",{style:{fontSize:11,color:"rgba(255,255,255,0.7)",fontWeight:600},children:t}),u&&e.jsx("span",{style:{fontSize:8,padding:"1px 6px",borderRadius:8,background:"rgba(34,211,238,0.1)",color:"rgba(34,211,238,0.6)",fontFamily:"'JetBrains Mono', monospace"},children:"auto"})]}),e.jsx("div",{style:{fontSize:9,color:"rgba(255,255,255,0.25)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a||"—"})]}),e.jsx("span",{style:{fontSize:9,color:"rgba(255,255,255,0.2)",fontFamily:"'JetBrains Mono', monospace",flexShrink:0},children:r})]})}const Nt="";function fl({onState:t,onVolume:a}){var E;const[s,r]=l.useState([]),[o,u]=l.useState(""),[m,v]=l.useState(!1),[p,k]=l.useState(!1),[c,x]=l.useState(!1),N=l.useRef(null),g=l.useRef(null),d=dl(),f=l.useRef(d);f.current=d;const w=l.useRef(()=>{}),h=l.useCallback(S=>{t("listening"),S?w.current(S):f.current.startListening()},[t]),b=pl({enabled:c,onActivated:h}),A=["Qual a saude do sistema?","Quantos filiados temos?","Problemas abertos?","Onde os processos travam?"];l.useEffect(()=>{d.transcript&&!d.isListening&&i(d.transcript)},[d.transcript,d.isListening]),l.useEffect(()=>{d.isListening?t("listening"):d.isSpeaking&&t("speaking")},[d.isListening,d.isSpeaking,t]),l.useEffect(()=>{a==null||a(d.volume)},[d.volume,a]),l.useEffect(()=>{N.current&&(N.current.scrollTop=N.current.scrollHeight)},[s]);const i=l.useCallback(async S=>{var P;if(!S.trim()||m)return;r(M=>[...M,{r:"u",c:S.trim()}]),u(""),v(!0),t("thinking"),s.length+1,r(M=>[...M,{r:"a",c:"",streaming:!0}]);const n=localStorage.getItem("token");try{const M=await fetch(`${Nt}/api/v1/aria/chat/stream`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({message:S,session_id:g.current})});if(!M.ok)throw new Error(`HTTP ${M.status}`);const R=(P=M.body)==null?void 0:P.getReader();if(!R)throw new Error("No reader");const j=new TextDecoder;for(;;){const{done:C,value:_}=await R.read();if(C)break;for(const I of j.decode(_).split(`
62`))if(I.startsWith("data: "))try{const B=JSON.parse(I.slice(6));B.token!=null&&r(T=>{const $=[...T],L=$[$.length-1];return L&&L.r==="a"&&(L.c=(L.c||"")+String(B.token)),$}),B.done&&(g.current=B.session_id)}catch{}}}catch{try{const M=await fetch(`${Nt}/api/v1/aria/chat`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({message:S,session_id:g.current})});if(!M.ok)throw new Error(`HTTP ${M.status}`);const R=await M.json();g.current=R.session_id,r(j=>{const C=[...j],_=C[C.length-1];return(_==null?void 0:_.r)==="a"&&(_.c=R.answer||"Não consegui responder agora (resposta vazia do servidor). Tente de novo."),C})}catch{r(M=>{const R=[...M],j=R[R.length-1];
62return(j==null?void 0:j.r)==="a"&&!j.c&&(j.c="Não consegui responder (erro de conexão com o servidor). Tente de novo em instantes."),R})}}let y="";if(r(M=>{const R=[...M],j=R[R.length-1];return(j==null?void 0:j.r)==="a"&&(j.streaming=!1,y=j.c),R}),v(!1),p&&y){t("speaking"),d.speak(y);const M=setInterval(()=>{speechSynthesis.speaking||(clearInterval(M),t("idle"),setTimeout(()=>{p&&d.startListening()},500))},200)}else t("active"),setTimeout(()=>t("idle"),3e3)},[m,t,s.length,p,d]);return w.current=i,e.jsxs("div",{style:{width:"100%"},children:[e.jsxs("div",{ref:N,style:{maxHeight:220,overflowY:"auto",marginBottom:8,scrollbarWidth:"thin",scrollbarColor:"rgba(34,211,238,0.15) transparent"},children:[!s.length&&!m&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6,justifyContent:"center",padding:8},children:A.map((S,n)=>e.jsx("button",{onClick:()=>i(S),style:{padding:"6px 12px",fontSize:11,borderRadius:16,border:"1px solid rgba(34,211,238,0.15)",background:"rgba(34,211,238,0.04)",color:"rgba(34,211,238,0.6)",cursor:"pointer",fontFamily:"'JetBrains Mono', monospace"},children:S},n))}),s.map((S,n)=>e.jsx("div",{style:{display:"flex",justifyContent:S.r==="u"?"flex-end":"flex-start",marginBottom:8},children:e.jsxs("div",{style:{maxWidth:"85%",padding:"8px 12px",fontSize:12,lineHeight:1.6,whiteSpace:"pre-wrap",borderRadius:S.r==="u"?"14px 14px 3px 14px":"14px 14px 14px 3px",background:S.r==="u"?"rgba(34,211,238,0.12)":"rgba(255,255,255,0.04)",border:`1px solid ${S.r==="u"?"rgba(34,211,238,0.2)":"rgba(255,255,255,0.06)"}`,color:"rgba(255,255,255,0.8)"},children:[S.c,S.streaming&&e.jsx("span",{style:{display:"inline-block",width:2,height:14,background:"rgba(34,211,238,0.6)",marginLeft:2,animation:"pulse 1s infinite"}})]})},n)),m&&!((E=s[s.length-1])!=null&&E.c)&&e.jsx("div",{style:{padding:"8px 12px",borderRadius:14,background:"rgba(245,158,11,0.08)",border:"1px solid rgba(245,158,11,0.15)",color:"rgba(245,158,11,0.7)",fontSize:11,display:"inline-block"},children:e.jsx("span",{style:{animation:"pulse 1.5s infinite"},children:"ARIA pensando..."})})]}),d.supported.stt&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:6},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[d.isListening&&e.jsx("span",{style:{fontSize:10,color:"rgba(168,85,247,0.7)",fontFamily:"'JetBrains Mono', monospace",animation:"pulse 1.5s infinite"},children:"Ouvindo..."}),d.isSpeaking&&e.jsx("span",{style:{fontSize:10,color:"rgba(56,189,248,0.7)",fontFamily:"'JetBrains Mono', monospace",animation:"pulse 1.5s infinite"},children:"Falando..."}),d.interimTranscript&&e.jsx("span",{style:{fontSize:10,color:"rgba(168,85,247,0.5)",fontStyle:"italic"},children:d.interimTranscript})]}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsxs("button",{onClick:()=>k(!p),style:{display:"flex",alignItems:"center",gap:4,padding:"3px 10px",borderRadius:12,fontSize:9,border:`1px solid ${p?"rgba(168,85,247,0.3)":"rgba(255,255,255,0.08)"}`,background:p?"rgba(168,85,247,0.1)":"transparent",color:p?"rgba(168,85,247,0.7)":"rgba(255,255,255,0.3)",cursor:"pointer",fontFamily:"'JetBrains Mono', monospace"},children:[p?e.jsx(Is,{size:10}):e.jsx(dt,{size:10}),"Voz ",p?"ON":"OFF"]}),d.supported.stt&&e.jsxs("button",{onClick:()=>x(!c),style:{display:"flex",alignItems:"center",gap:4,padding:"3px 10px",borderRadius:12,fontSize:9,border:`1px solid ${c?b.error?"rgba(239,68,68,0.3)":"rgba(34,211,238,0.3)":"rgba(255,255,255,0.08)"}`,background:c?b.error?"rgba(239,68,68,0.1)":"rgba(34,211,238,0.1)":"transparent",color:c?b.error?"rgba(239,68,68,0.7)":"rgba(34,211,238,0.7)":"rgba(255,255,255,0.3)",cursor:"pointer",fontFamily:"'JetBrains Mono', monospace"},children:[e.jsx(ct,{size:10}),c?b.error?b.error:b.isStandby?b.lastHeard?`"${b.lastHeard.slice(-20)}"`:'Esperando "ARIA"...':"Wake ON":"Wake OFF"]})]})]}),e.jsxs("div",{style:{display:"flex",gap:6},children:[d.supported.stt&&e.jsx("button",{onClick:()=>{d.isListening?d.stopListening():(d.startListening(),t("listening"))},disabled:m,style:{width:38,height:38,borderRadius:"50%",border:"none",cursor:"pointer",background:d.isListening?"rgba(168,85,247,0.2)":"rgba(255,255,255,0.02)",display:"flex",alignItems:"center",justifyContent:"center",animation:d.isListening?"pulse 1s infinite":"none"},children:d.isListening?e.jsx(Ms,{size:15,color:"rgba(168,85,247,0.9)"}):e.jsx(ct,{size:15,color:"rgba(255,255,255,0.3)"})}),e.jsx("input",{value:d.isListening?d.interimTranscript||d.transcript||"":o,onChange:S=>u(S.target.value),onKeyDown:S=>{S.key==="Enter"&&!S.shiftKey&&(S.preventDefault(),i(o))},placeholder:d.isListening?"Ouvindo...":"Fale com a ARIA...",disabled:m||d.isListening,style:{flex:1,padding:"10px 14px",fontSize:12,borderRadius:20,background:d.isListening?"rgba(168,85,247,0.05)":"rgba(255,255,255,0.03)",border:`1px solid ${d.isListening?"rgba(168,85,247,0.3)":"rgba(34,211,238,0.15)"}`,color:"rgba(255,255,255,0.85)",outline:"none",fontFamily:"'JetBrains Mono', sans-serif",transition:"all 0.3s"}}),e.jsx("button",{onClick:()=>i(o),disabled:m||!o.trim()||d.isListening,style:{width:38,height:38,borderRadius:"50%",border:"none",cursor:o.trim()&&!m?"pointer":"default",background:o.trim()&&!m?"rgba(34,211,238,0.15)":"rgba(255,255,255,0.02)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:o.trim()&&!m?"rgba(34,211,238,0.8)":"rgba(255,255,255,0.15)",strokeWidth:"2",strokeLinecap:"round",children:[e.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),e.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})}),d.isSpeaking&&e.jsx("button",{onClick:()=>d.stopSpeaking(),style:{width:38,height:38,borderRadius:"50%",border:"none",cursor:"pointer",background:"rgba(239,68,68,0.15)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(dt,{size:15,color:"rgba(239,68,68,0.8)"})})]})]})}function vl(t){if(!t)return"";const a=t.replace(/\D/g,"");return a.length>=10?`***${a.slice(-4)} (WhatsApp)`:t.includes("democrata-")||t.includes("ollama")?t.replace("democrata-",""):t.length>20?t.slice(0,20)+"...":t}function kl(t=768){const[a,s]=l.useState(typeof window<"u"?window.innerWidth:1200);return l.useEffect(()=>{const r=()=>s(window.innerWidth);return window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[]),a<t}function yl(){const[t,a]=l.useState("idle"),[s,r]=l.useState(0),[o,u]=l.useState(new Date),[m,v]=l.useState(null),[p,k]=l.useState(null),[c,x]=l.useState(null),[N,g]=l.useState(!1),d=kl();l.useEffect(()=>{const n=setInterval(()=>u(new Date),1e3);return()=>clearInterval(n)},[]),l.useEffect(()=>{const n=()=>{Xt().then(P=>{v(P),x(null)}
62).catch(()=>{x(P=>P??new Date)})};n();const y=setInterval(n,3e4);return()=>clearInterval(y)},[]),l.useEffect(()=>{const n=()=>{Fr().then(P=>{k(P),g(!1)}).catch(()=>{g(!0)})};n();const y=setInterval(n,3e4);return()=>clearInterval(y)},[]);const f=m==null?void 0:m.tecnico,w=(m==null?void 0:m.problemas)||{total_abertos:0,critica:0,alta:0,media:0,baixa:0},h=m==null?void 0:m.acoes_24h,b=m==null?void 0:m.aprendizado;m==null||m.negocio;const A=(p==null?void 0:p.score)??(m?Math.max(0,Math.round(100-(w.critica*5+w.alta*1.5+w.media*.3+(((f==null?void 0:f.ram.usado_pct)||0)>80?10:0)+(((f==null?void 0:f.cpu.load_5m)||0)>3?10:0)))):null),i={idle:"Monitorando",thinking:"Processando...",active:"Respondendo",listening:"Ouvindo...",speaking:"Falando..."},E={idle:"rgba(34,211,238,0.6)",thinking:"rgba(245,158,11,0.6)",active:"rgba(34,197,94,0.6)",listening:"rgba(168,85,247,0.6)",speaking:"rgba(56,189,248,0.6)"},S={"democrata-backend":"Backend","democrata-celery-worker":"Celery","democrata-celery-beat":"Beat","democrata-wa-bridge":"WA Bridge",ollama:"Ollama"};return e.jsxs("div",{style:{minHeight:"100vh",background:"#060911",color:"#fff",fontFamily:"'Segoe UI', sans-serif",overflow:"hidden"},children:[e.jsx("style",{children:`
63        @import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;700;900&family=JetBrains+Mono:wght@300;400;600&display=swap');
64        @keyframes pulse { 0%,100% { opacity:1 } 50% { opacity:0.4 } }
65        @keyframes fadeUp { from { opacity:0; transform:translateY(10px) } to { opacity:1; transform:translateY(0) } }
66        @keyframes scanline { 0% { top:-2px } 100% { top:100% } }
67        ::-webkit-scrollbar { width:3px }
68        ::-webkit-scrollbar-thumb { background:rgba(34,211,238,0.15); border-radius:2px }
69      `}),e.jsx("div",{style:{position:"fixed",inset:0,pointerEvents:"none",backgroundImage:"linear-gradient(rgba(34,211,238,0.012) 1px, transparent 1px), linear-gradient(90deg, rgba(34,211,238,0.012) 1px, transparent 1px)",backgroundSize:"50px 50px"}}),e.jsx("div",{style:{position:"fixed",inset:0,pointerEvents:"none",overflow:"hidden"},children:e.jsx("div",{style:{position:"absolute",width:"100%",height:1.5,background:"linear-gradient(90deg, transparent, rgba(34,211,238,0.025), transparent)",animation:"scanline 10s linear infinite"}})}),e.jsxs("div",{style:{position:"relative",zIndex:1,maxWidth:1200,margin:"0 auto",padding:d?"10px 12px":"16px 20px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:d?8:12},children:[e.jsx("span",{style:{fontSize:9,color:"rgba(34,211,238,0.25)",fontFamily:"'JetBrains Mono', monospace",letterSpacing:3},children:d?"ARIA v3.0":"SISTEMA DEMOCRATA // ARIA v3.0"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5},children:[e.jsx("div",{style:{width:5,height:5,borderRadius:"50%",background:E[t],boxShadow:`0 0 6px ${E[t]}`,animation:t==="thinking"?"pulse 1s infinite":"none"}}),e.jsx("span",{style:{fontSize:10,color:E[t],fontFamily:"'JetBrains Mono', monospace"},children:i[t]})]}),e.jsx("span",{style:{fontSize:11,color:"rgba(255,255,255,0.3)",fontFamily:"'JetBrains Mono', monospace"},children:o.toLocaleTimeString("pt-BR")})]})]}),(c||N)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:10,padding:"8px 12px",borderRadius:10,border:`1px solid ${c?"rgba(239,68,68,0.35)":"rgba(245,158,11,0.3)"}`,background:c?"rgba(239,68,68,0.08)":"rgba(245,158,11,0.06)",color:c?"rgba(239,68,68,0.85)":"rgba(245,158,11,0.8)",fontSize:11,fontFamily:"'JetBrains Mono', monospace"},children:[e.jsx("span",{children:"⚠"}),e.jsx("span",{children:c?`SEM DADOS desde ${c.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})} — falha ao consultar a API. Os painéis podem estar desatualizados.`:"Health score indisponível — exibindo estimativa calculada localmente."})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:d?"1fr":"1fr 240px 1fr",gap:d?10:16,alignItems:"start"},children:[d&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",paddingTop:4},children:[e.jsx(wt,{state:t,size:150,healthScore:A,volume:s}
69),e.jsx("h1",{style:{fontFamily:"'Orbitron', sans-serif",fontSize:18,fontWeight:900,letterSpacing:8,marginTop:-4,background:"linear-gradient(135deg, #22d3ee, #a78bfa, #22d3ee)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent"},children:"A.R.I.A."}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr 1fr",gap:6,marginTop:8,width:"100%"},children:[{v:m?w.total_abertos:"—",l:"Prob",c:"rgba(239,68,68,0.6)"},{v:h?h.total:"—",l:"Ações",c:"rgba(245,158,11,0.6)"},{v:h&&h.total>0?Math.round(h.sucesso/h.total*100)+"%":"—",l:"OK",c:"rgba(34,197,94,0.6)"},{v:f?`${Object.values(f.servicos).filter(n=>n==="active").length}/${Object.keys(f.servicos).length}`:"—",l:"Svc",c:"rgba(34,211,238,0.6)"}].map((n,y)=>e.jsxs("div",{style:{textAlign:"center",padding:"6px 2px",borderRadius:8,background:"rgba(255,255,255,0.02)",border:"1px solid rgba(255,255,255,0.04)"},children:[e.jsx("div",{style:{fontSize:14,fontWeight:700,color:n.c,fontFamily:"'Orbitron', monospace"},children:n.v}),e.jsx("div",{style:{fontSize:7,color:"rgba(255,255,255,0.25)",fontFamily:"'JetBrains Mono', monospace"},children:n.l})]},y))})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:d?8:12,animation:"fadeUp 0.6s ease"},children:[e.jsx(ue,{title:"Infraestrutura",icon:"⚡",color:"cyan",children:f&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr 1fr",gap:6},children:[e.jsx(ge,{value:f.ram.usado_pct,max:100,label:"RAM"}),e.jsx(ge,{value:f.cpu.load_5m,max:f.cpu.cores,label:"CPU",unit:""}),e.jsx(ge,{value:f.disco.usado_pct,max:100,label:"DISCO"}),e.jsx(ge,{value:f.postgres.ativas,max:f.postgres.max,label:"PG",unit:""})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:10},children:Object.entries(f.servicos).map(([n,y])=>e.jsx(gl,{name:S[n]||n,ok:y==="active"},n))})]})}),e.jsxs(ue,{title:`Problemas (${m?w.total_abertos:"—"})`,icon:"⚠️",color:"red",children:[e.jsx(he,{label:"Critica",value:w.critica,total:w.total_abertos,color:"#ef4444"}),e.jsx(he,{label:"Alta",value:w.alta,total:w.total_abertos,color:"#f97316"}),e.jsx(he,{label:"Media",value:w.media,total:w.total_abertos,color:"#eab308"}),e.jsx(he,{label:"Baixa",value:w.baixa,total:w.total_abertos,color:"#3b82f6"})]}),e.jsx(ue,{title:"Aprendizado",icon:"🧠",color:"purple",children:e.jsx("div",{style:{display:"flex",gap:12,justifyContent:"center"},children:[{v:(b==null?void 0:b.solucoes_ativas)??0,l:"Soluções"},{v:(((b==null?void 0:b.confianca_media)??0)*100).toFixed(0)+"%",l:"Confiança"},{v:(b==null?void 0:b.anti_solucoes)??0,l:"Anti-sol."}].map((n,y)=>e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{fontSize:18,fontWeight:700,color:"rgba(255,255,255,0.8)",fontFamily:"'Orbitron', monospace"},children:n.v}),e.jsx("div",{style:{fontSize:9,color:"rgba(168,85,247,0.5)",fontFamily:"'JetBrains Mono', monospace",letterSpacing:1},children:n.l})]},y))})})]}),!d&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",paddingTop:8},children:[e.jsx(wt,{state:t,size:220,healthScore:A,volume:s}),e.jsx("h1",{style:{fontFamily:"'Orbitron', sans-serif",fontSize:22,fontWeight:900,letterSpacing:10,marginTop:-8,background:"linear-gradient(135deg, #22d3ee, #a78bfa, #22d3ee)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent"},children:"A.R.I.A."}),e.jsx("p",{style:{fontSize:9,color:"rgba(255,255,255,0.2)",letterSpacing:3,fontFamily:"'JetBrains Mono', monospace",marginTop:2},children:"ASSISTENTE AUTONOMA"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8,marginTop:16,width:"100%"},children:[{v:m?w.total_abertos:"—",l:"Problemas",c:"rgba(239,68,68,0.6)"},{v:h?h.total:"—",l:"Ações 24h",c:"rgba(245,158,11,0.6)"},{v:h&&h.total>0?Math.round(h.sucesso/h.total*100)+"%":"—",l:"Sucesso",c:"rgba(34,197,94,0.6)"},{v:f?`${Object.values(f.servicos).filter(n=>n==="active").length}/${Object.keys(f.servicos).length}`:"—",l:"Serviços",c:"rgba(34,211,238,0.6)"}].map((n,y)=>e.jsxs("div",{style:{textAlign:"center",padding:"8px 4px",borderRadius:10,background:"rgba(255,255,255,0.02)",border:"1px solid rgba(255,255,255,0.04)"},children:[e.jsx("div",{style:{fontSize:16,fontWeight:700,color:n.c,fontFamily:"'Orb
69itron', monospace"},children:n.v}),e.jsx("div",{style:{fontSize:8,color:"rgba(255,255,255,0.25)",fontFamily:"'JetBrains Mono', monospace",letterSpacing:1.5},children:n.l})]},y))})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,animation:"fadeUp 0.6s ease 0.15s both"},children:[e.jsx(ue,{title:"Ações Recentes",icon:"⚡",color:"amber",children:h?h.acoes.length===0?e.jsx("div",{style:{fontSize:11,color:"rgba(255,255,255,0.3)",textAlign:"center",padding:12},children:"Nenhuma ação nas últimas 24h"}):h.acoes.slice(0,5).map((n,y)=>e.jsx(hl,{tipo:n.tipo_acao.replace(/_/g," ").replace("autocorrect:",""),dest:vl(n.destinatario),ok:n.sucesso,hora:new Date(n.executado_em).toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"}),quem:n.executado_por},y)):e.jsx("div",{style:{fontSize:11,color:c?"rgba(239,68,68,0.7)":"rgba(255,255,255,0.3)",textAlign:"center",padding:12},children:c?"Falha ao carregar ações (API fora do ar)":"Carregando..."})}),e.jsx(ue,{title:"Chat",icon:"💬",color:"cyan",children:e.jsx(fl,{onState:a,onVolume:r})})]})]}),e.jsx("div",{style:{display:"flex",justifyContent:"center",gap:d?4:8,marginTop:d?10:16,flexWrap:"wrap"},children:[{to:"/aria-autonoma/problemas",label:"Problemas"},{to:"/aria-autonoma/acoes",label:"Ações"},{to:"/aria-autonoma/aprendizado",label:"Aprendizado"},{to:"/aria-autonoma/configuracoes",label:"Configurações"},{to:"/aria-autonoma/classico",label:"Clássico"}].map(({to:n,label:y})=>e.jsx(H,{to:n,style:{padding:"6px 14px",fontSize:10,borderRadius:10,border:"1px solid rgba(34,211,238,0.1)",background:"rgba(34,211,238,0.03)",color:"rgba(34,211,238,0.5)",textDecoration:"none",fontFamily:"'JetBrains Mono', monospace",letterSpacing:1,transition:"all 0.2s"},children:y},n))})]}),e.jsx(ul,{})]})}const le="rounded-2xl border border-slate-200 bg-white p-5 transition dark:border-white/[0.06] dark:bg-white/[0.03] dark:shadow-[0_0_20px_rgba(0,212,255,0.04)] dark:backdrop-blur-sm",xe="mb-4 flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-cyan-300/90",ee="text-slate-900 dark:text-white",D="text-slate-500 dark:text-white/40",Ye="text-xs font-medium text-blue-600 hover:underline dark:text-cyan-400 dark:hover:text-cyan-300";function fe({value:t,max:a=100,label:s,unit:r="%",size:o=110}){const u=Math.min(t/a*100,100),m=u<60?"#10b981":u<80?"#f59e0b":"#ef4444",v=[{value:u,fill:m}];return e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{style:{width:o,height:o},children:e.jsx(es,{children:e.jsx(Nr,{innerRadius:"70%",outerRadius:"100%",data:v,startAngle:180,endAngle:0,barSize:8,children:e.jsx(Qt,{background:!0,dataKey:"value",cornerRadius:5})})})}),e.jsxs("div",{className:"-mt-7 text-center",children:[e.jsxs("span",{className:`text-base font-bold ${ee}`,children:[typeof t=="number"?t.toFixed(1):t,e.jsx("span",{className:`text-[10px] font-normal ${D}`,children:r})]}),e.jsx("p",{className:`text-[10px] ${D}`,children:s})]})]})}function jl({name:t,status:a}){const s=a==="active",r=t.replace("democrata-","").replace("ollama","Ollama").replace("celery-worker","Celery Worker").replace("celery-beat","Celery Beat").replace("wa-bridge","WA Bridge").replace("backend","Backend");return e.jsxs("div",{className:`flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium transition ${s?"border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-500/20 dark:bg-emerald-500/10 dark:text-emerald-400":"border-red-200 bg-red-50 text-red-700 dark:border-red-500/20 dark:bg-red-500/10 dark:text-red-400"}`,children:[e.jsx(Rs,{className:`h-2.5 w-2.5 ${s?"text-emerald-500 dark:text-emerald-400":"text-red-500 dark:text-red-400"}`}),r]})}function ve({label:t,valor:a,icon:s,color:r,darkGlow:o,subtitle:u}){return e.jsx($t.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:`${le} ${o||""}`,children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`rounded-xl p-2.5 ${r}`,children:e.jsx(s,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:`text-2xl font-bold ${ee}
69`,children:typeof a=="number"?a.toLocaleString("pt-BR"):a}),e.jsx("p",{className:`text-sm ${D}`,children:t}),u&&e.jsx("p",{className:"text-[10px] text-slate-400 dark:text-white/30",children:u})]})]})})}function wl({data:t}){const a=t.postgres.max>0?Math.round(t.postgres.ativas/t.postgres.max*100):0;return e.jsxs("div",{className:le,children:[e.jsxs("h3",{className:xe,children:[e.jsx(Re,{className:"h-4 w-4"}),"Saúde Técnica"]}),e.jsxs("div",{className:"mb-4 grid grid-cols-2 gap-3 sm:grid-cols-4",children:[e.jsx(fe,{value:t.ram.usado_pct,label:"RAM"}),e.jsx(fe,{value:t.cpu.load_5m,max:t.cpu.cores,label:"CPU Load",unit:""}),e.jsx(fe,{value:t.disco.usado_pct,label:"Disco"}),e.jsx(fe,{value:a,label:"PostgreSQL"})]}),e.jsxs("div",{className:`mb-3 grid grid-cols-2 gap-2 text-[10px] sm:grid-cols-4 ${D}`,children:[e.jsxs("span",{children:[t.ram.livre_mb.toLocaleString("pt-BR")," MB livres"]}),e.jsxs("span",{children:[t.cpu.load_1m," / ",t.cpu.load_5m," / ",t.cpu.load_15m]}),e.jsxs("span",{children:[t.disco.livre_gb," GB livres"]}),e.jsxs("span",{children:[t.postgres.ativas,"/",t.postgres.max," conn"]})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Object.entries(t.servicos).map(([s,r])=>e.jsx(jl,{name:s,status:r},s))})]})}function Nl({data:t}){const a=[{label:"Crítica",value:t.critica,color:"bg-red-500 dark:bg-red-500/80",bar:"bg-red-500 dark:bg-red-400"},{label:"Alta",value:t.alta,color:"bg-orange-500",bar:"bg-orange-500 dark:bg-orange-400"},{label:"Média",value:t.media,color:"bg-amber-500",bar:"bg-amber-500 dark:bg-amber-400"},{label:"Baixa",value:t.baixa,color:"bg-blue-500",bar:"bg-blue-500 dark:bg-blue-400"}],s=t.total_abertos;return e.jsxs("div",{className:le,children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsxs("h3",{className:xe.replace("mb-4 ",""),children:[e.jsx(V,{className:"h-4 w-4"}),"Problemas (",s,")"]}),e.jsx(H,{to:"/aria-autonoma/problemas",className:Ye,children:"Ver todos"})]}),e.jsx("div",{className:"space-y-2.5",children:a.map(r=>e.jsxs("div",{children:[e.jsxs("div",{className:"mb-0.5 flex items-center justify-between text-xs",children:[e.jsx("span",{className:D,children:r.label}),e.jsx("span",{className:`font-medium ${ee}`,children:r.value})]}),e.jsx("div",{className:"h-1.5 overflow-hidden rounded-full bg-slate-100 dark:bg-white/[0.06]",children:e.jsx("div",{className:`h-full ${r.bar} transition-all duration-500`,style:{width:s>0?`${r.value/s*100}%`:"0%"}})})]},r.label))}),t.mais_antigo&&e.jsxs("p",{className:`mt-3 text-[10px] ${D}`,children:["Mais antigo: ",t.mais_antigo.tipo,"/",t.mais_antigo.subtipo," (",new Date(t.mais_antigo.detectado_em).toLocaleDateString("pt-BR"),")"]})]})}function Sl({data:t}){const a=t.total>0?Math.round(t.sucesso/t.total*100):null;return e.jsxs("div",{className:le,children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsxs("h3",{className:xe.replace("mb-4 ",""),children:[e.jsx(ce,{className:"h-4 w-4"}),"Ações 24h (",t.total,")"]}),e.jsx(H,{to:"/aria-autonoma/acoes",className:Ye,children:"Ver todas"})]}),e.jsxs("div",{className:"mb-3 grid grid-cols-3 gap-2 text-center",children:[e.jsxs("div",{className:"rounded-lg bg-emerald-50 p-1.5 dark:bg-emerald-500/10",children:[e.jsx("p",{className:"text-lg font-bold text-emerald-600 dark:text-emerald-400",children:t.sucesso}),e.jsx("p",{className:"text-[10px] text-emerald-600 dark:text-emerald-400/70",children:"Sucesso"})]}),e.jsxs("div",{className:"rounded-lg bg-red-50 p-1.5 dark:bg-red-500/10",children:[e.jsx("p",{className:"text-lg font-bold text-red-600 dark:text-red-400",children:t.falha}),e.jsx("p",{className:"text-[10px] text-red-600 dark:text-red-400/70",children:"Falha"})]}),e.jsxs("div",{className:"rounded-lg bg-blue-50 p-1.5 dark:bg-cyan-500/10",children:[e.jsx("p",{className:"text-lg font-bold text-blue-600 dark:text-cyan-400",children:a===null?"—":`${a}%`}),e.jsx("p",{className:"text-[10px] text-blue-600 dark:text-cyan-400/70",children:"Taxa"})]})]}),e.jsxs("div",{className:"max-h-56 space-y-1.5 overflow-y-auto",children:[t.acoes.slice(0,8).map((s,r)=>e.jsxs("div",{className:"flex items-center gap-2.5 rounded-lg border border-slate-100 p-2 dark:border-white/[0.05] dark:bg-white/[0.02]",children:[s.sucesso?e.jsx(ae,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500"}):e.jsx(re,{className:"h-3.5 w-3.5 shrink-0 text-red-500"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:`truncate text-xs font-medium ${ee}`,children:s.tipo_acao.replace(/_/g," ").replace("autocorrect:","")}),e.jsxs("p",{className:`truncate text-[10px] ${D}`,children:[s.executado_por==="aria_autocorrect"?"Auto":s.executado_por,s.destinatario?` → ${s.destinatario.slice(-8)}`:""]})]}),e.jsx("span",{className:`shrink-0 text-[10px] ${D}`,children:new Date(s.executado_em).toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})})]},r)),t.total===0&&e.jsx("p",{className:`py-4 text-center text-xs ${D}`,children:"Nenhuma ação nas últimas 24h"})]})]})}function Al({data:t}){return e.jsxs("div",{className:le,children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsxs("h3",{className:xe.replace("mb-4 ",""),children:[e.jsx(Se,{className:"h-4 w-4"}),"Aprendizado"]}),e.jsx(H,{to:"/aria-autonoma/aprendizado",className:Ye,children:"Detalhes"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:`text-xl font-bold ${ee}`,children:t.solucoes_ativas}),e.jsx("p",{className:`text-[10px] ${D}`,children:"Soluções"})]}),e.jsxs("div",{children:[e.jsxs("p",{className:`text-xl font-bold ${ee}`,children:[((t.confianca_media??0)*100).toFixed(0),"%"]}),e.jsx("p",{className:`text-[10px] ${D}`,children:"Confiança"})]}),e.jsxs("div",{children:[e.jsx("p",{className:`text-xl font-bold ${ee}`,children:t.anti_solucoes}),e.jsx("p",{className:`text-[10px] ${D}`,children:"Anti-sol."})]})]}),t.top_solucoes.length>0&&e.jsxs("div",{className:"mt-3 border-t border-slate-100 pt-3 dark:border-white/[0.06]",children:[e.jsx("p",{className:`mb-1.5 text-[10px] font-medium uppercase ${D}`,children:"Top Soluções"}),t.top_solucoes.slice(0,3).map((a,s)=>e.jsxs("div",{className:"flex items-center justify-between py-0.5 text-xs",children:[e.jsxs("span",{className:"text-slate-700 dark:text-white/70",children:[a.tipo_problema," → ",a.tipo_acao]}),e.jsxs("span",{className:`text-[10px] font-medium ${D}`,children:[(a.confianca*100).toFixed(0),"%"]})]},s))]})]})}function Cl({data:t}){return e.jsxs("div",{className:le,children:[e.jsxs("h3",{className:xe,children:[e.jsx(Bt,{className:"h-4 w-4"}),"Negócio (24h)"]}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:[{v:t.novos_filiados_24h,l:"Novos filiados",c:""},{v:t.pedidos_pendentes,l:"Pedidos pendentes",c:""},{v:t.pedidos_aprovados,l:"Aprovados",c:"text-emerald-600 dark:text-emerald-400"},{v:t.pedidos_rejeitados,l:"Rejeitados",c:"text-red-600 dark:text-red-400"}].map((a,s)=>e.jsxs("div",{className:"rounded-lg bg-slate-50 p-2.5 dark:bg-white/[0.03]",children:[e.jsx("p",{className:`text-xl font-bold ${a.c||ee}`,children:a.v}),e.jsx("p",{className:`text-[10px] ${a.c||D}`,children:a.l})]},s))})]})}function Rl(){const{data:t,isLoading:a,isFetching:s,error:r,refetch:o}=Wr(),u=Ur(),m=qr(),v=()=>{u.mutate(void 0,{onSuccess:h=>G.success(`Ciclo executado: ${h.problemas_detectados} problemas, ${h.acoes_executadas} ações`),onError:h=>{var A;const b=(A=h==null?void 0:h.response)==null?void 0:A.status;
69G.error(b===403?"Sem permissão para executar o ciclo (requer administrador)":te(h,"Erro ao executar ciclo"))}})},p=()=>{m.mutate(void 0,{onSuccess:()=>G.success("Relatório diário gerado e enviado"),onError:h=>G.error(te(h,"Erro ao gerar relatório"))})};if(a&&!t)return e.jsxs("div",{className:"space-y-6",children:[e.jsx(J,{title:"A.R.I.A.",subtitle:"Carregando...",icon:e.jsx(ye,{className:"h-6 w-6"})}),e.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-4",children:[...Array(4)].map((h,b)=>e.jsx("div",{className:"h-28 animate-pulse rounded-2xl bg-slate-200 dark:bg-white/[0.05]"},b))})]});if(r||!t)return e.jsxs("div",{className:"space-y-6",children:[e.jsx(J,{title:"A.R.I.A.",subtitle:"Sistema autônomo",icon:e.jsx(ye,{className:"h-6 w-6"})}),e.jsxs("div",{className:`${le} text-center`,children:[e.jsx(V,{className:"mx-auto h-8 w-8 text-red-500"}),e.jsx("p",{className:"mt-2 text-red-700 dark:text-red-400",children:"Erro ao carregar dados"}),e.jsx("button",{onClick:()=>o(),className:"mt-4 rounded-lg bg-red-600 px-4 py-2 text-sm font-medium text-white hover:bg-red-700",children:"Tentar novamente"})]})]});const{tecnico:k,negocio:c,acoes_24h:x,problemas:N,aprendizado:g}=t,d=x.total>0?Math.round(x.sucesso/x.total*100):null,f=Object.values(k.servicos).filter(h=>h==="active").length,w=Object.keys(k.servicos).length;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"hidden dark:block",children:e.jsx(Rr,{state:"idle",size:56})}),e.jsx("div",{className:"flex-1",children:e.jsx(J,{title:"A.R.I.A.",subtitle:"Assistente Autônoma do Sistema Democrata",icon:e.jsx(ye,{className:"h-6 w-6 dark:hidden"}),actions:e.jsxs("div",{className:"flex items-center gap-2",children:[s&&e.jsx("span",{className:`text-[10px] ${D}`,children:"Atualizando..."}),e.jsxs(H,{to:"/aria-autonoma",className:"flex items-center gap-1.5 rounded-lg border border-cyan-200 bg-cyan-50 px-3 py-2 text-sm font-medium text-cyan-700 transition hover:bg-cyan-100 dark:border-cyan-500/20 dark:bg-cyan-500/10 dark:text-cyan-400 dark:hover:bg-cyan-500/20",children:[e.jsx(Xa,{className:"h-4 w-4"}),"Dashboard Principal"]}),e.jsxs("button",{onClick:p,disabled:m.isPending,className:"flex items-center gap-1.5 rounded-lg border border-slate-200 px-3 py-2 text-sm font-medium text-slate-700 transition hover:bg-slate-50 disabled:opacity-50 dark:border-white/10 dark:text-white/70 dark:hover:bg-white/5",children:[e.jsx(Ve,{className:"h-4 w-4"}),"Relatório"]}),e.jsxs("button",{onClick:v,disabled:u.isPending,className:"flex items-center gap-1.5 rounded-lg bg-blue-600 px-3 py-2 text-sm font-medium text-white transition hover:bg-blue-700 disabled:opacity-50 dark:bg-cyan-600 dark:hover:bg-cyan-500",children:[e.jsx(Le,{className:"h-4 w-4"}),u.isPending?"Executando...":"Forçar Ciclo"]}),e.jsx("button",{onClick:()=>o(),className:"rounded-lg border border-slate-200 p-2 text-slate-600 transition hover:bg-slate-50 dark:border-white/10 dark:text-white/50 dark:hover:bg-white/5",children:e.jsx(se,{className:`h-4 w-4 ${s?"animate-spin":""}`})})]})})})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(ve,{label:"Problemas Abertos",valor:N.total_abertos,icon:V,color:"bg-amber-100 text-amber-600 dark:bg-amber-500/10 dark:text-amber-400",subtitle:`${N.critica} críticos, ${N.alta} altos`}),e.jsx(ve,{label:"Ações Hoje",valor:x.total,icon:oe,color:"bg-blue-100 text-blue-600 dark:bg-cyan-500/10 dark:text-cyan-400",subtitle:`${x.automaticas} auto, ${x.via_chat} chat`}),e.jsx(ve,{label:"Taxa Sucesso",valor:d===null?"—":`${d}%`,icon:ae,color:"bg-emerald-100 text-emerald-600 dark:bg-emerald-500/10 dark:text-emerald-400",subtitle:d===null?"sem ações no período":`${x.sucesso} ok, ${x.falha} falha`}),e.jsx(ve,{label:"Serviços",valor:`${f}/${w}`,icon:Re,color:f===w?"bg-emerald-100 text-emerald-600 dark:bg-emerald-500/10 dark:text-emerald-400":"bg-red-100 text-red-600 dark:bg-red-500/10 dark:text-red-400",subtitle:f===w?"Todos ativos":"Serviço(s) caído(s)"})]}),e.jsx(wl,{data:k}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-3",children:[e.jsx(Nl,{data:N}),e.jsx(Sl,{data:x}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(Al,{data:g}),e.jsx(Cl,{data:c})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2 border-t border-slate-200 pt-6 dark:border-white/[0.06]",children:[{to:"/aria-autonoma/chat",label:"Chat",icon:Ne},{to:"/aria-autonoma/problemas",label:"Problemas",icon:V},{to:"/aria-autonoma/acoes",label:"Ações",icon:ce},{to:"/aria-autonoma/aprendizado",label:"Aprendizado",icon:Se},{to:"/aria-autonoma/configuracoes",label:"Configurações",icon:je}].map(({to:h,label:b,icon:A})=>e.jsxs(H,{to:h,className:"flex items-center gap-2 rounded-lg border border-slate-200 px-4 py-2.5 text-sm font-medium text-slate-700 transition hover:bg-slate-50 dark:border-white/[0.08] dark:text-white/60 dark:hover:bg-white/5 dark:hover:text-white/90",children:[e.jsx(A,{className:"h-4 w-4"}),b]},h))})]})}const _l=new rs({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}});function Ml(){return e.jsx("div",{className:"flex h-[60vh] items-center justify-center text-slate-500 dark:text-white/40",children:e.jsxs("div",{className:"text-center",children:[e.jsx(ye,{className:"mx-auto mb-3 h-12 w-12 text-blue-500 dark:text-cyan-400"}),e.jsx("p",{className:"text-lg font-medium text-slate-700 dark:text-white/70",children:"Chat com a ARIA"}),e.jsx("p",{className:"mt-1 text-sm",children:"Use o botão flutuante no canto inferior direito"})]})})}function Yl(){return e.jsx(Qa,{roles:["admin"],fallbackMessage:"Acesso restrito à administração.",children:e.jsx(ss,{client:_l,children:e.jsxs(Za,{children:[e.jsx(X,{index:!0,element:e.jsx(yl,{})}),e.jsx(X,{path:"classico",element:e.jsx(Rl,{})}),e.jsx(X,{path:"chat",element:e.jsx(Ml,{})}),e.jsx(X,{path:"problemas",element:e.jsx(Qr,{})}),e.jsx(X,{path:"acoes",element:e.jsx(tl,{})}),e.jsx(X,{path:"aprendizado",element:e.jsx(sl,{})}),e.jsx(X,{path:"configuracoes",element:e.jsx(ol,{})}),e.jsx(X,{path:"*",element:e.jsx(Ya,{to:"/aria-autonoma",replace:!0})})]})})})}export{Yl 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.