@zydon/common 2.9.36 → 2.9.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/dist/{chunk-IFYEQTIR.js → chunk-3RFXFIBL.js} +2 -2
  2. package/dist/chunk-5GXRPVV5.js +9 -0
  3. package/dist/{chunk-XT2AH5G2.js → chunk-5ZMA4N4W.js} +1 -1
  4. package/dist/{chunk-ALVCWIRN.js → chunk-ANH46M6K.js} +3 -3
  5. package/dist/{chunk-A2LPDSRW.js → chunk-BK36QQTT.js} +2 -2
  6. package/dist/chunk-CB4KDKZY.js +6 -0
  7. package/dist/chunk-CB4KDKZY.js.map +1 -0
  8. package/dist/{chunk-CK6Q4FGI.js → chunk-COAGQGZA.js} +2 -2
  9. package/dist/{chunk-5N6Y3FIM.js → chunk-CZ5Y53WA.js} +2 -2
  10. package/dist/{chunk-U2XWJMVE.js → chunk-EICUAMNN.js} +2 -2
  11. package/dist/chunk-H762KDPN.js +11 -0
  12. package/dist/chunk-H762KDPN.js.map +1 -0
  13. package/dist/{chunk-LKX2OZSP.js → chunk-JBYYU67F.js} +3 -3
  14. package/dist/{chunk-FCC5IEAW.js → chunk-JKAMT5TC.js} +2 -2
  15. package/dist/chunk-K34AZXX4.js +8 -0
  16. package/dist/chunk-K34AZXX4.js.map +1 -0
  17. package/dist/{chunk-IWNQZ4DU.js → chunk-KDSM2AIT.js} +2 -2
  18. package/dist/chunk-KJJDGCL4.js +8 -0
  19. package/dist/chunk-KJJDGCL4.js.map +1 -0
  20. package/dist/{chunk-XA36N32L.js → chunk-L6CMWQCC.js} +2 -2
  21. package/dist/{chunk-HPBLOHGU.js → chunk-MJFCJZFD.js} +2 -2
  22. package/dist/chunk-MTJT2RGA.js +8 -0
  23. package/dist/chunk-MTJT2RGA.js.map +1 -0
  24. package/dist/{chunk-W6J37DOS.js → chunk-MY4CZ5PC.js} +2 -2
  25. package/dist/{chunk-XECFL7W6.js → chunk-NJLLYK4S.js} +2 -2
  26. package/dist/{chunk-QZVNKHIE.js → chunk-PMKM67BB.js} +2 -2
  27. package/dist/{chunk-3GERPUNO.js → chunk-PVHLAOT2.js} +5 -5
  28. package/dist/chunk-Q2R3X4EB.js +8 -0
  29. package/dist/chunk-Q2R3X4EB.js.map +1 -0
  30. package/dist/{chunk-C3JTGVAS.js → chunk-R7BNGTUT.js} +2 -2
  31. package/dist/{chunk-K6O5RVKC.js → chunk-TAA5KCEG.js} +3 -3
  32. package/dist/{chunk-772DOKEN.js → chunk-TS7QZPD6.js} +2 -2
  33. package/dist/{chunk-7IHZRIIU.js → chunk-TSEVZMIE.js} +2 -2
  34. package/dist/chunk-UYYDORSQ.js +6 -0
  35. package/dist/chunk-UYYDORSQ.js.map +1 -0
  36. package/dist/{chunk-4FRN4I7H.js → chunk-VELCTMU2.js} +2 -2
  37. package/dist/{chunk-BUDIH7D2.js → chunk-VPZL6AIF.js} +2 -2
  38. package/dist/{chunk-7CMID2IK.js → chunk-W27CC2AQ.js} +5 -5
  39. package/dist/{chunk-ZYFY6BCA.js → chunk-YHOVSR7P.js} +2 -2
  40. package/dist/chunk-YJYS2LQQ.js +12 -0
  41. package/dist/chunk-YJYS2LQQ.js.map +1 -0
  42. package/dist/chunk-Z3HTIXB2.js +6 -0
  43. package/dist/chunk-Z3HTIXB2.js.map +1 -0
  44. package/dist/components/Accordion/index.js +2 -2
  45. package/dist/components/ActionButton/index.js +2 -2
  46. package/dist/components/Analytics/Carts/index.d.ts +29 -0
  47. package/dist/components/Analytics/Carts/index.js +61 -0
  48. package/dist/components/Analytics/Carts/index.js.map +1 -0
  49. package/dist/components/Analytics/OrderProjection/index.d.ts +6 -78
  50. package/dist/components/Analytics/OrderProjection/index.js +29 -29
  51. package/dist/components/Analytics/OrderProjection/index.js.map +1 -1
  52. package/dist/components/Analytics/OverviewAnalytics/index.d.ts +6 -3
  53. package/dist/components/Analytics/OverviewAnalytics/index.js +21 -20
  54. package/dist/components/Analytics/OverviewAnalytics/index.js.map +1 -1
  55. package/dist/components/Analytics/PartnerAnalysis/index.d.ts +9 -6
  56. package/dist/components/Analytics/PartnerAnalysis/index.js +25 -24
  57. package/dist/components/Analytics/PartnerAnalysis/index.js.map +1 -1
  58. package/dist/components/Analytics/index.js +7 -7
  59. package/dist/components/Analytics/index.js.map +1 -1
  60. package/dist/components/Autocomplete/index.js +2 -2
  61. package/dist/components/AvatarButton/index.js +5 -5
  62. package/dist/components/BuilderLayout/index.js +2 -2
  63. package/dist/components/BuilderSidebar/index.js +1 -1
  64. package/dist/components/BulkEditModal/index.js +4 -4
  65. package/dist/components/CardBrand/index.js +1 -1
  66. package/dist/components/ColorPickerInput/index.js +2 -2
  67. package/dist/components/ColumnResizeHandle/index.d.ts +3 -2
  68. package/dist/components/ColumnResizeHandle/index.js +1 -1
  69. package/dist/components/Common/index.js +4 -4
  70. package/dist/components/CopyButton/index.js +2 -2
  71. package/dist/components/DataView/index.js +5 -5
  72. package/dist/components/DataViewMobileItem/index.d.ts +6 -0
  73. package/dist/components/DataViewMobileItem/index.js +2 -0
  74. package/dist/components/DataViewMobileItem/index.js.map +1 -0
  75. package/dist/components/DragButton/index.js +2 -2
  76. package/dist/components/Drawer/index.js +2 -2
  77. package/dist/components/DynamicDataView/index.js +8 -8
  78. package/dist/components/EasyCropModal/index.js +3 -3
  79. package/dist/components/Error/index.js +1 -1
  80. package/dist/components/ExpandableGroup/index.js +1 -1
  81. package/dist/components/FileUpload/index.js +6 -6
  82. package/dist/components/Filters/index.js +4 -4
  83. package/dist/components/FrameSkeleton/index.js +1 -1
  84. package/dist/components/HelpButton/index.js +2 -2
  85. package/dist/components/Icon/index.js +1 -1
  86. package/dist/components/IconButton/index.js +2 -2
  87. package/dist/components/ImageCropModal/index.js +2 -2
  88. package/dist/components/Incrementer/index.js +2 -2
  89. package/dist/components/InfoCircle/index.js +2 -2
  90. package/dist/components/ListBundles/index.js +2 -2
  91. package/dist/components/MenuItem/index.js +2 -10
  92. package/dist/components/MenuItem/index.js.map +1 -1
  93. package/dist/components/Modal/index.js +2 -2
  94. package/dist/components/MoreMenu/index.js +4 -11
  95. package/dist/components/MoreMenu/index.js.map +1 -1
  96. package/dist/components/NotFound/index.js +1 -1
  97. package/dist/components/PasswordRules/index.js +1 -1
  98. package/dist/components/PopoverSelect/index.js +1 -1
  99. package/dist/components/PortalBrandImage/index.js +1 -1
  100. package/dist/components/SearchInput/index.js +2 -2
  101. package/dist/components/SelectList/index.js +4 -4
  102. package/dist/components/SelectableCards/index.js +3 -3
  103. package/dist/components/SeoPreview/index.js +1 -1
  104. package/dist/components/StateDisplay/index.js +2 -2
  105. package/dist/components/StepUpDialog/index.js +1 -1
  106. package/dist/components/Steps/index.js +1 -1
  107. package/dist/components/StyledTab/index.js +1 -1
  108. package/dist/components/SwapList/index.js +2 -2
  109. package/dist/components/ToggleTheme/index.js +3 -3
  110. package/dist/components/WebhookCard/index.js +1 -1
  111. package/dist/components/carousel/index.js +2 -2
  112. package/dist/components/form/Address/index.js +3 -3
  113. package/dist/components/form/Autocomplete/index.js +3 -3
  114. package/dist/components/form/ColorPicker/index.js +2 -2
  115. package/dist/components/form/FileUpload/index.js +6 -6
  116. package/dist/components/form/Incrementer/index.js +2 -2
  117. package/dist/components/form/Password/index.js +1 -1
  118. package/dist/components/form/SelectList/index.js +4 -4
  119. package/dist/components/form/SelectableCards/index.js +3 -3
  120. package/dist/components/form/Webhook/index.js +4 -4
  121. package/dist/components/lightbox/index.js +1 -1
  122. package/dist/components/table/index.js +2 -2
  123. package/dist/hooks/useCartsFilters.d.ts +8 -0
  124. package/dist/hooks/useCartsFilters.js +5 -0
  125. package/dist/hooks/useCartsFilters.js.map +1 -0
  126. package/dist/hooks/useOrderProjectionFilters.d.ts +4 -58
  127. package/dist/hooks/useOrderProjectionFilters.js +3 -3
  128. package/dist/hooks/useResizableColumns.d.ts +1 -1
  129. package/dist/hooks/useResizableColumns.js +1 -1
  130. package/dist/hooks/useThemeToggle.js +3 -3
  131. package/dist/index.js +3 -3
  132. package/dist/theme/theme-provider.js +3 -3
  133. package/dist/types/carts.d.ts +8 -0
  134. package/dist/types/carts.js +2 -0
  135. package/dist/types/carts.js.map +1 -0
  136. package/dist/types/orderProjection.d.ts +3 -2
  137. package/dist/types/partnerAnalysis.d.ts +3 -2
  138. package/dist/useCartsFilters-9eb738ab.d.ts +219 -0
  139. package/dist/useOrderProjectionFilters-5c1162d5.d.ts +297 -0
  140. package/dist/{useResizableColumns.types-6611ee0b.d.ts → useResizableColumns.types-33105448.d.ts} +4 -3
  141. package/dist/utils/buildExportPayload.js +1 -1
  142. package/dist/utils/carts.d.ts +20 -0
  143. package/dist/utils/carts.js +3 -0
  144. package/dist/utils/carts.js.map +1 -0
  145. package/dist/utils/orderProjection.d.ts +2 -1
  146. package/dist/utils/orderProjection.js +1 -1
  147. package/package.json +5 -1
  148. package/dist/chunk-7WUAJEER.js +0 -6
  149. package/dist/chunk-7WUAJEER.js.map +0 -1
  150. package/dist/chunk-OONF23Z2.js +0 -6
  151. package/dist/chunk-OONF23Z2.js.map +0 -1
  152. package/dist/chunk-SRP3UTFW.js +0 -9
  153. package/dist/chunk-TQFKLNTU.js +0 -8
  154. package/dist/chunk-TQFKLNTU.js.map +0 -1
  155. package/dist/orderProjection-c6f4f71e.d.ts +0 -182
  156. /package/dist/{chunk-IFYEQTIR.js.map → chunk-3RFXFIBL.js.map} +0 -0
  157. /package/dist/{chunk-SRP3UTFW.js.map → chunk-5GXRPVV5.js.map} +0 -0
  158. /package/dist/{chunk-XT2AH5G2.js.map → chunk-5ZMA4N4W.js.map} +0 -0
  159. /package/dist/{chunk-ALVCWIRN.js.map → chunk-ANH46M6K.js.map} +0 -0
  160. /package/dist/{chunk-A2LPDSRW.js.map → chunk-BK36QQTT.js.map} +0 -0
  161. /package/dist/{chunk-CK6Q4FGI.js.map → chunk-COAGQGZA.js.map} +0 -0
  162. /package/dist/{chunk-5N6Y3FIM.js.map → chunk-CZ5Y53WA.js.map} +0 -0
  163. /package/dist/{chunk-U2XWJMVE.js.map → chunk-EICUAMNN.js.map} +0 -0
  164. /package/dist/{chunk-LKX2OZSP.js.map → chunk-JBYYU67F.js.map} +0 -0
  165. /package/dist/{chunk-FCC5IEAW.js.map → chunk-JKAMT5TC.js.map} +0 -0
  166. /package/dist/{chunk-IWNQZ4DU.js.map → chunk-KDSM2AIT.js.map} +0 -0
  167. /package/dist/{chunk-XA36N32L.js.map → chunk-L6CMWQCC.js.map} +0 -0
  168. /package/dist/{chunk-HPBLOHGU.js.map → chunk-MJFCJZFD.js.map} +0 -0
  169. /package/dist/{chunk-W6J37DOS.js.map → chunk-MY4CZ5PC.js.map} +0 -0
  170. /package/dist/{chunk-XECFL7W6.js.map → chunk-NJLLYK4S.js.map} +0 -0
  171. /package/dist/{chunk-QZVNKHIE.js.map → chunk-PMKM67BB.js.map} +0 -0
  172. /package/dist/{chunk-3GERPUNO.js.map → chunk-PVHLAOT2.js.map} +0 -0
  173. /package/dist/{chunk-C3JTGVAS.js.map → chunk-R7BNGTUT.js.map} +0 -0
  174. /package/dist/{chunk-K6O5RVKC.js.map → chunk-TAA5KCEG.js.map} +0 -0
  175. /package/dist/{chunk-772DOKEN.js.map → chunk-TS7QZPD6.js.map} +0 -0
  176. /package/dist/{chunk-7IHZRIIU.js.map → chunk-TSEVZMIE.js.map} +0 -0
  177. /package/dist/{chunk-4FRN4I7H.js.map → chunk-VELCTMU2.js.map} +0 -0
  178. /package/dist/{chunk-BUDIH7D2.js.map → chunk-VPZL6AIF.js.map} +0 -0
  179. /package/dist/{chunk-7CMID2IK.js.map → chunk-W27CC2AQ.js.map} +0 -0
  180. /package/dist/{chunk-ZYFY6BCA.js.map → chunk-YHOVSR7P.js.map} +0 -0
@@ -7,12 +7,13 @@ import '../../../types/entityMetadata.js';
7
7
 
8
8
  interface OrdersByTypeProps {
9
9
  data: QuotationDashboardSeriesItem[];
10
+ isFetching?: boolean;
10
11
  viewMode: ViewMode;
11
12
  selectedYear: number;
12
13
  DetailComponent?: ComponentType<OverviewDetailBaseProps>;
13
14
  }
14
15
 
15
- declare const OrdersByType: ({ data, viewMode, selectedYear, DetailComponent, }: OrdersByTypeProps) => react_jsx_runtime.JSX.Element;
16
+ declare const OrdersByType: ({ data, isFetching, viewMode, selectedYear, DetailComponent, }: OrdersByTypeProps) => react_jsx_runtime.JSX.Element;
16
17
 
17
18
  declare const OverviewDetail: ({ open, onClose, title, viewMode, selectedYear, totalValue, periodLabel, suffix, rows, total, isLoading, isFetching, page, perPage, onSearch, onPaginationChange, buildPartnerLink, mobileItemSlot, }: OverviewDetailProps) => react_jsx_runtime.JSX.Element;
18
19
 
@@ -36,19 +37,21 @@ declare const getPeriodSuffix: (viewMode: ViewMode) => string;
36
37
  interface SalesEvolutionProps {
37
38
  data: RevenueGoalDashboardSeriesItem[];
38
39
  kpis?: RevenueGoalDashboardKpis;
40
+ isFetching?: boolean;
39
41
  viewMode: ViewMode;
40
42
  selectedYear: number;
41
43
  editGoalAction?: ReactNode;
42
44
  DetailComponent?: ComponentType<OverviewDetailBaseProps>;
43
45
  }
44
46
 
45
- declare const SalesEvolution: ({ data, kpis, viewMode, selectedYear, editGoalAction, DetailComponent, }: SalesEvolutionProps) => react_jsx_runtime.JSX.Element;
47
+ declare const SalesEvolution: ({ data, isFetching, kpis, viewMode, selectedYear, editGoalAction, DetailComponent, }: SalesEvolutionProps) => react_jsx_runtime.JSX.Element;
46
48
 
47
49
  interface SalesForecastProps {
48
50
  data: SalesForecastDashboardSeriesItem[];
51
+ isFetching?: boolean;
49
52
  viewMode: ViewMode;
50
53
  }
51
54
 
52
- declare const SalesForecast: ({ data, viewMode }: SalesForecastProps) => react_jsx_runtime.JSX.Element;
55
+ declare const SalesForecast: ({ data, viewMode, isFetching }: SalesForecastProps) => react_jsx_runtime.JSX.Element;
53
56
 
54
57
  export { OrdersByType, OrdersByTypeProps, OverviewDetail, OverviewDetailBaseProps, OverviewDetailProps, SalesEvolution, SalesEvolutionProps, SalesForecast, SalesForecastProps, getDateRange, getPeriodLabel, getPeriodSuffix, useOverviewDetailState };
@@ -1,14 +1,15 @@
1
1
  import { b, c, d as d$3 } from '../../../chunk-FYG3YWFZ.js';
2
- import { a, m, c as c$1, n } from '../../../chunk-4FRN4I7H.js';
3
- import { a as a$7 } from '../../../chunk-DRGARBKB.js';
4
- import { a as a$6 } from '../../../chunk-QZVNKHIE.js';
5
- import { a as a$4 } from '../../../chunk-7IHZRIIU.js';
6
- import { a as a$3 } from '../../../chunk-5N6Y3FIM.js';
2
+ import { a, m, c as c$1, n } from '../../../chunk-VELCTMU2.js';
3
+ import { a as a$2 } from '../../../chunk-Q2R3X4EB.js';
4
+ import { a as a$8 } from '../../../chunk-DRGARBKB.js';
5
+ import { a as a$7 } from '../../../chunk-PMKM67BB.js';
6
+ import { a as a$5 } from '../../../chunk-TSEVZMIE.js';
7
+ import { a as a$4 } from '../../../chunk-CZ5Y53WA.js';
7
8
  import { d as d$2 } from '../../../chunk-2W5FGLTC.js';
8
9
  import { h, d as d$1, c as c$2 } from '../../../chunk-OF6623HG.js';
9
10
  import '../../../chunk-5J35UAV6.js';
10
- import { d } from '../../../chunk-7CMID2IK.js';
11
- import { a as a$2 } from '../../../chunk-C3JTGVAS.js';
11
+ import { d } from '../../../chunk-W27CC2AQ.js';
12
+ import { a as a$3 } from '../../../chunk-R7BNGTUT.js';
12
13
  import { a as a$1 } from '../../../chunk-4F2NKGF6.js';
13
14
  import '../../../chunk-PRWQQJDL.js';
14
15
  import '../../../chunk-SB7J43ND.js';
@@ -18,30 +19,30 @@ import '../../../chunk-NIQW2J3M.js';
18
19
  import '../../../chunk-XUDTPZHF.js';
19
20
  import '../../../chunk-UVPQR2Q2.js';
20
21
  import '../../../chunk-RBTYTONM.js';
22
+ import '../../../chunk-I4PPSW36.js';
21
23
  import '../../../chunk-CO2KQFUN.js';
22
- import '../../../chunk-XT2AH5G2.js';
24
+ import '../../../chunk-5ZMA4N4W.js';
23
25
  import '../../../chunk-Z6YXPKWP.js';
24
26
  import '../../../chunk-F65ZXAGV.js';
25
- import '../../../chunk-I4PPSW36.js';
27
+ import { b as b$1 } from '../../../chunk-TXJ45CNA.js';
26
28
  import { b as b$2 } from '../../../chunk-ERLI5GAP.js';
27
29
  import '../../../chunk-LQRRMVFN.js';
28
- import { b as b$1 } from '../../../chunk-TXJ45CNA.js';
29
30
  import '../../../chunk-Y66XXBB3.js';
30
- import { a as a$5 } from '../../../chunk-HFDGIEZC.js';
31
+ import { a as a$6 } from '../../../chunk-HFDGIEZC.js';
31
32
  import { useState, useCallback, useMemo, useRef } from 'react';
32
- import mt from '@mui/material/CardContent';
33
- import dt from '@mui/material/CardHeader';
34
- import D from '@mui/material/Stack';
33
+ import ft from '@mui/material/CardContent';
34
+ import ut from '@mui/material/CardHeader';
35
+ import L from '@mui/material/Stack';
35
36
  import { ResponsiveContainer, BarChart, CartesianGrid, XAxis, YAxis, Tooltip, Bar, ComposedChart, Line } from 'recharts';
36
37
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
37
- import ue from '@mui/material/Divider';
38
+ import ye from '@mui/material/Divider';
38
39
  import M from '@mui/material/Typography';
39
- import He from '@mui/material/Checkbox';
40
- import Ke from '@mui/material/FormControlLabel';
41
- import xt from '@mui/material/Link';
40
+ import Qe from '@mui/material/Checkbox';
41
+ import Ue from '@mui/material/FormControlLabel';
42
+ import kt from '@mui/material/Link';
42
43
  import { styled, alpha } from '@mui/material/styles';
43
44
 
44
- var ee={orders:"#22C55E",quotations:"#0EA5E9"};var Yo=({x:e=0,y:o=0,width:t=0,height:r=0,index:a,activeBarIndex:i})=>i!==a?null:jsx("rect",{x:e-6,y:o,width:t+12,height:r+6,fill:"#919EAB",opacity:.16,rx:6}),Oe=Yo;var qo=({x:e=0,y:o=0,width:t=0,index:r=0,data:a,visibleSeries:i,isMonthly:n,shouldRotateLabels:l})=>{if(!n||l)return null;let c=a[r];if(!c)return null;let s=0;return i.orders&&(s+=c.order_count??0),i.quotations&&(s+=c.quotation_count??0),s?jsx("text",{x:e+t/2,y:o-8,textAnchor:"middle",fontSize:11,fill:"#212B36",children:s}):null},Ie=qo;var Qo=({active:e,payload:o,label:t,viewMode:r})=>{if(!e||!o?.length)return null;let a=r==="DAILY",i=String(t),n=i.split("-");if(n.length>=2){let s=parseInt(n[1],10)-1,p=b[s];a&&n.length===3?i=`${parseInt(n[2],10)} de ${p} de ${n[0]}`:a||(i=`${p} de ${n[0]}`);}let l=o[0].payload,c=[{name:"Vendas",count:l.order_count??0,value:l.order_value??0,color:o.find(s=>s.dataKey==="order_count")?.color??"#22C55E"},{name:"Or\xE7amentos",count:l.quotation_count??0,value:l.quotation_value??0,color:o.find(s=>s.dataKey==="quotation_count")?.color??"#0EA5E9"}];return jsxs(a$7,{minWidth:{xs:"auto",sm:300},p:1,gap:1,children:[jsx(M,{variant:"body2",color:"text.secondary",children:i}),jsx(ue,{}),jsx(D,{children:c.map((s,p)=>jsxs(D,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:2,"data-testid":`tooltip-item-${p}`,children:[jsxs(D,{direction:"row",alignItems:"center",gap:1,children:[jsx(D,{width:6,height:6,borderRadius:"50%",bgcolor:s.color}),jsx(M,{variant:"body2",noWrap:!0,children:s.name})]}),jsxs(M,{variant:"body2",color:"text.disabled",noWrap:!0,children:[s.count," ",s.count===1?"pedido":"pedidos","\u2002",jsx(M,{component:"span",variant:"body2",color:"text.primary",children:h(s.value)})]})]},s.name))})]})},mo=Qo;var at=({data:e,viewMode:o,visibleSeries:t,activeBarIndex:r,onMouseMove:a,onMouseLeave:i,onBarClick:n$1})=>{let l=o==="MONTHLY",[c$2,s]=useState(0),p=useRef(null),m=useCallback(d=>{p.current&&(p.current.disconnect(),p.current=null),d&&(s(d.clientWidth),p.current=new ResizeObserver(()=>s(d.clientWidth)),p.current.observe(d));},[]),h=useMemo(()=>!l||c$2===0||e.length===0?!1:(c$2-60)/e.length<80,[l,c$2,e.length]),C=useMemo(()=>e.some(d=>(d.order_count??0)>0),[e]),y=useMemo(()=>e.some(d=>(d.quotation_count??0)>0),[e]),S=useMemo(()=>{if(!e.length)return [0,1];let d=Math.max(...e.map(f=>(f.order_count??0)+(f.quotation_count??0)));return [0,d>0?d*1.15:1]},[e]),T=useMemo(()=>{let[,d]=S,f=d/6;return [...new Set(Array.from({length:7},(x,L)=>Math.round(f*L)))]},[S]),g=t.quotations&&y,v=t.orders&&C&&!g,P=useMemo(()=>l?c:d$3,[l]);return jsx(c$1,{ref:m,children:jsx(ResponsiveContainer,{width:"100%",height:250,children:jsxs(BarChart,{data:e,margin:{top:20,right:10,bottom:h?-90:0,left:20},barCategoryGap:"20%",style:{cursor:"pointer"},onMouseMove:a,onMouseLeave:i,onClick:d=>{d?.activeTooltipIndex!=null&&n$1?.(Number(d.activeTooltipIndex));},children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,...h&&{interval:0,height:120},tick:h?jsx(n,{}):{fontSize:12,fill:"#637381"},tickFormatter:P}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:d=>d$1(d),domain:S,ticks:T}),jsx(Tooltip,{content:jsx(mo,{viewMode:o}),cursor:!1}),jsx(Bar,{dataKey:"order_count",name:"Vendas",fill:ee.orders,stackId:"orders",maxBarSize:48,isAnimationActive:!1,hide:!t.orders,background:jsx(Oe,{activeBarIndex:r}),radius:v?[4,4,0,0]:void 0,...v&&{label:{position:"top",fontSize:11,fill:"#212B36",content:jsx(Ie,{data:e,visibleSeries:t,isMonthly:l,shouldRotateLabels:h})}}}),jsx(Bar,{dataKey:"quotation_count",name:"Or\xE7amentos",fill:ee.quotations,stackId:"orders",maxBarSize:48,isAnimationActive:!1,hide:!t.quotations,radius:g?[4,4,0,0]:void 0,...!t.orders&&{background:jsx(Oe,{activeBarIndex:r})},...g&&{label:{position:"top",fontSize:11,fill:"#212B36",content:jsx(Ie,{data:e,visibleSeries:t,isMonthly:l,shouldRotateLabels:h})}}})]})})})},uo=at;var st=({visibleSeries:e,onToggleSerie:o})=>jsxs(D,{direction:"row",justifyContent:"center",flexWrap:"wrap",gap:1,children:[jsx(Ke,{control:jsx(He,{checked:e.orders,onChange:()=>o("orders"),sx:{"&.Mui-checked":{color:ee.orders}}}),label:"Vendas"}),jsx(Ke,{control:jsx(He,{checked:e.quotations,onChange:()=>o("quotations"),sx:{"&.Mui-checked":{color:ee.quotations}}}),label:"Or\xE7amentos"})]}),go=st;var ct=({ordersTotal:e,quotationsTotal:o,isMonthly:t})=>{let r=b$1("down","md");return jsxs(D,{direction:{xs:"column",md:"row"},alignItems:{xs:"flex-start",md:"center"},flexWrap:"wrap",gap:3,children:[r&&jsx(ue,{orientation:"horizontal",flexItem:!0,sx:{borderStyle:"dashed",mx:-3}}),jsxs(D,{children:[jsx(M,{variant:"body2",color:"text.secondary",children:t?"Vendas no ano":"Vendas no m\xEAs"}),jsxs(M,{variant:"subtitle2",children:[e," vendas"]})]}),jsx(ue,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),jsxs(D,{children:[jsx(M,{variant:"body2",color:"text.secondary",children:t?"Or\xE7amentos no ano":"Or\xE7amentos no m\xEAs"}),jsxs(M,{variant:"subtitle2",children:[o," or\xE7amentos"]})]})]})},Ae=ct;var ft=({data:e,viewMode:o,selectedYear:t,DetailComponent:r})=>{let a$2=o==="MONTHLY",[i,n]=useState({orders:!0,quotations:!0}),[l,c]=useState(null),[s,p]=useState(!1),[m$1,h]=useState(""),[C,y]=useState(0),S=useCallback(f=>{n(x=>({...x,[f]:!x[f]}));},[]),T=useCallback(f=>{f?.activeTooltipIndex!=null&&c(Number(f.activeTooltipIndex));},[]),g=useCallback(()=>c(null),[]),v=useCallback(f=>{let x=e[f];x&&(h(x.label),y(x.order_value),p(!0));},[e]),P=useCallback(()=>{p(!1);},[]),d=useMemo(()=>{let f=e.reduce((L,N)=>L+(N.order_count??0),0),x=e.reduce((L,N)=>L+(N.quotation_count??0),0);return {ordersTotal:f,quotationsTotal:x}},[e]);return jsxs(Fragment,{children:[jsxs(a,{children:[jsx(dt,{title:"Quantidade de pedidos por tipo"}),jsx(mt,{children:jsx(a$1,{isEmpty:e.length===0,empty:jsx(m,{}),children:jsxs(D,{gap:3,children:[jsx(D,{display:{xs:"none",md:"block"},children:jsx(Ae,{isMonthly:a$2,ordersTotal:d.ordersTotal,quotationsTotal:d.quotationsTotal})}),jsx(uo,{data:e,viewMode:o,visibleSeries:i,activeBarIndex:l,onMouseMove:T,onMouseLeave:g,onBarClick:v}),jsx(go,{visibleSeries:i,onToggleSerie:S}),jsx(D,{display:{xs:"block",md:"none"},children:jsx(Ae,{isMonthly:a$2,ordersTotal:d.ordersTotal,quotationsTotal:d.quotationsTotal})})]})})})]}),m$1&&r&&jsx(r,{open:s,onClose:P,label:m$1,viewMode:o,selectedYear:t,totalValue:C})]})},ut=ft;var yt=({title:e,viewMode:o,selectedYear:t,periodLabel:r})=>jsxs(D,{width:"100%",minWidth:0,overflow:"hidden",children:[jsx(M,{variant:"subtitle1",noWrap:!0,children:"Detalhes do relat\xF3rio"}),jsxs(D,{direction:"row",alignItems:"center",columnGap:1.5,rowGap:0,flexWrap:"wrap",children:[jsx(M,{variant:"body2",color:"text.secondary",flexShrink:0,children:e}),"\u2022",jsx(M,{variant:"body2",flexShrink:0,children:b$2[o]}),"\u2022",jsx(M,{variant:"body2",flexShrink:0,children:t}),"\u2022",jsx(M,{variant:"body2",color:"text.secondary",noWrap:!0,children:r})]})]}),xo=yt;var ko=styled(ue)(()=>({height:30,alignSelf:"center",borderStyle:"dashed"})),To=styled(D)(({theme:e})=>({position:"relative",display:"flex",flexDirection:"column",padding:e.spacing(2),gap:e.spacing(1),color:e.palette.text.primary,"& a":{textDecoration:"none"},"&+div":{borderTop:`1px dashed ${alpha(e.palette.grey[500],.2)}`}}));var Ct=e=>jsx(D,{justifyContent:"center",height:1,children:jsx(M,{variant:"body2",color:"text.primary",children:e.id})}),kt=(e,o)=>jsx(D,{justifyContent:"center",height:1,children:e?.partner?.id&&o?jsx(xt,{component:"a",href:o(e.partner.id),target:"_blank",rel:"noopener noreferrer",variant:"subtitle2",sx:{textDecoration:"underline"},noWrap:!0,children:e.partner?.name||"-"}):jsx(M,{variant:"body2",color:"text.primary",noWrap:!0,children:e.partner?.name||"-"})}),Tt=e=>jsx(D,{justifyContent:"center",height:1,children:jsx(M,{variant:"body2",color:"text.primary",children:h(e.total_value)})}),Mt=e=>jsx(D,{justifyContent:"center",height:1,children:e.negotiation_date?jsx(M,{variant:"body2",color:"text.primary",children:d$2(e.negotiation_date,"DD/MM/YYYY")}):"-"}),Lt=e=>jsx(D,{justifyContent:"center",height:1,children:e.status||"-"}),Dt=e=>jsx(To,{children:jsxs(D,{gap:1,children:[jsxs(D,{children:[jsx(M,{variant:"body2",color:"text.secondary",children:"Pedido"}),jsx(M,{variant:"subtitle2",color:"text.primary",children:e.id})]}),jsxs(D,{children:[jsx(M,{variant:"body2",color:"text.secondary",children:"Cliente"}),jsx(M,{variant:"subtitle2",color:"primary.main",children:e.partner?.name||"-"})]}),jsxs(D,{direction:"row",alignItems:"center",gap:1,children:[jsxs(D,{flex:1,overflow:"hidden",children:[jsx(M,{variant:"body2",color:"text.secondary",noWrap:!0,children:"Valor do pedido"}),jsx(M,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:h(e.total_value)})]}),jsx(ue,{orientation:"vertical",flexItem:!0,sx:{borderStyle:"dashed",mx:3}}),jsxs(D,{flex:1,overflow:"hidden",children:[jsx(M,{variant:"body2",color:"text.secondary",noWrap:!0,children:"Data"}),jsx(M,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:e.negotiation_date?d$2(e.negotiation_date,"DD/MM/YYYY"):"-"})]})]}),jsxs(D,{gap:.5,children:[jsx(M,{variant:"body2",color:"text.secondary",children:"Status"}),jsx(M,{variant:"subtitle2",color:"text.primary",children:e.status||"-"})]})]})},e.id),wt=({open:e,onClose:o,title:t,viewMode:r,selectedYear:a,totalValue:i,periodLabel:n,suffix:l,rows:c,total:s,isLoading:p,isFetching:m,page:h$1,perPage:C,onSearch:y,onPaginationChange:S,buildPartnerLink:T,mobileItemSlot:g})=>{let v=b$1("down","sm"),P=jsxs(D,{gap:3,children:[jsxs(D,{direction:{xs:"column",sm:"row"},justifyContent:"space-between",gap:2,children:[jsxs(D,{minWidth:0,direction:"row",alignItems:"center",gap:3,flexWrap:"wrap",children:[jsxs(D,{children:[jsxs(M,{variant:"body2",color:"text.secondary",children:["Vendas ",l]}),jsx(M,{variant:"subtitle2",color:"text.primary",children:h(i)})]}),jsx(ko,{orientation:"vertical",flexItem:!0}),jsxs(D,{children:[jsxs(M,{variant:"body2",color:"text.secondary",children:["Qtd. de pedidos ",l]}),jsx(M,{variant:"subtitle2",color:"text.primary",children:s})]})]}),jsx(a$2,{size:"small",placeholder:"Buscar",onSearch:y,trigger:"change",iconPosition:"start",sx:{minWidth:200}})]}),jsx(d,{title:"Pedidos",header:jsx(Fragment,{}),headerProps:{p:0},columns:[{field:"external_id",headerName:"Pedido",flex:1,renderCell:({row:f})=>Ct(f)},{field:"partner_name",headerName:"Cliente",flex:1,renderCell:({row:f})=>kt(f,T)},{field:"total_value",headerName:"Valor do pedido",flex:1,renderCell:({row:f})=>Tt(f)},{field:"created_at",headerName:"Data",flex:1,renderCell:({row:f})=>Mt(f)},{field:"last_status",headerName:"Status",flex:1,renderCell:({row:f})=>Lt(f)}],rows:c,rowCount:s,mobileRender:f=>g?g(f):Dt(f),loading:p,fetching:m,paginationModel:{page:h$1,pageSize:C},onPaginationChange:S,paginationMode:"server",disableRowSelectionOnClick:!0,disableColumnMenu:!0,containerProps:{height:400}})]}),d$1=jsx(xo,{title:t,viewMode:r,selectedYear:a,periodLabel:n});return v?jsx(a$3,{open:e,onClose:o,headerTitle:d$1,headerProps:{direction:"row-reverse",sx:{"& > :last-child":{minWidth:0,overflow:"hidden"}}},children:P}):jsx(a$4,{open:e,onClose:o,maxWidth:"lg",dialogTitle:d$1,dialogTitleProps:{sx:{flex:1,overflow:"hidden"}},fullWidth:!0,children:P})},Bt=wt;var We=(e,o)=>{let t=e.split("-");if(o==="DAILY"&&t.length===3){let n=`${t[0]}-${t[1]}-${t[2]}`;return {startDate:n,endDate:n}}let r=parseInt(t[0],10),a=parseInt(t[1],10),i=new Date(r,a,0).getDate();return {startDate:`${t[0]}-${t[1]}-01`,endDate:`${t[0]}-${t[1]}-${String(i).padStart(2,"0")}`}},_e=(e,o)=>{let t=e.split("-"),r=parseInt(t[1],10)-1,a=b[r]??"";if(o==="DAILY"&&t.length===3){let i=parseInt(t[2],10);return `${a} - Dia ${i}`}return a},Ee=e=>e==="MONTHLY"?"no m\xEAs":"no dia";var Ot=(e,o)=>{let{page:t,perPage:r,search:a,handlePaginationModelChange:i,handleSearch:n}=a$5(),{startDate:l,endDate:c}=useMemo(()=>We(e,o),[e,o]),s=useMemo(()=>_e(e,o),[e,o]),p=Ee(o),m=useMemo(()=>({page:t,perPage:r,...a?{search:a}:{},filter:{operator:"AND",groups:[{operator:"AND",conditionals:[{fieldName:"negotiationDate",conditional:"GREATER_THAN_OR_EQUAL",value:[`${l}T00:00:00`]},{fieldName:"negotiationDate",conditional:"LESS_THAN_OR_EQUAL",value:[`${c}T23:59:59`]}]}]}}),[c,t,r,a,l]),h=useCallback((C,y)=>{i({page:C,pageSize:y});},[i]);return {page:t,perPage:r,periodLabel:s,suffix:p,queryParams:m,handleSearch:n,handlePaginationChange:h}},It=Ot;var k={sales:"#22C55E",forecast:"#F59E0B",goal:"#212B36"};var zt=({x:e=0,y:o=0,width:t=0,height:r=0,index:a,activeBarIndex:i})=>i!==a?null:jsx("rect",{x:e-6,y:o,width:t+6*2,height:r+6,fill:k.sales,opacity:.16,rx:6}),ke=zt;var Vt=({active:e,payload:o,label:t,viewMode:r})=>{if(!e||!o?.length)return null;let a=r==="DAILY",i=o[0].payload,n=Number(i.realized)||0,l=Number(i.forecast)||0,c=Number(i.goal)||0,s=c>0?n/c*100:0,p=c>n?c-n:0,m=a?"no dia":"no m\xEAs",h$1=a?"di\xE1ria":"mensal",C=String(t),y=C.split("-");if(y.length>=2){let T=parseInt(y[1],10)-1,g=b[T];a&&y.length===3?C=`${parseInt(y[2],10)} de ${g} de ${y[0]}`:a||(C=`${g} de ${y[0]}`);}let S=[{name:`Realizado ${m}`,value:h(n),color:k.sales},{name:`Previsto ${m}`,value:h(l),color:k.forecast},{name:`Meta ${h$1}`,value:h(c),color:k.goal},{name:"Atingimento",value:`${s.toFixed(0)}%`,color:"#00B8D9"},{name:`GAP ${m}`,value:h(p),color:"#FF5630"}];return jsxs(a$7,{minWidth:{xs:"auto",sm:400},p:1,gap:1,children:[jsx(M,{variant:"body2",color:"text.secondary",children:C}),jsx(ue,{}),jsx(D,{children:S.map((T,g)=>jsxs(D,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,"data-testid":`tooltip-item-${g}`,children:[jsxs(D,{direction:"row",alignItems:"center",gap:1,children:[jsx(D,{width:6,height:6,borderRadius:"50%",bgcolor:T.color}),jsx(M,{variant:"body2",noWrap:!0,children:T.name})]}),jsx(M,{variant:"body2",children:T.value})]},g))})]})},Me=Vt;var Ht=({data:e,visibleSeries:o,yDomain:t,yTicks:r,viewMode:a,activeBarIndex:i,onMouseMove:n,onMouseLeave:l,onBarClick:c})=>{let s=useCallback(p=>d$1(p),[]);return jsx(ResponsiveContainer,{width:"100%",height:350,children:jsxs(ComposedChart,{data:e,margin:{top:20,right:10,bottom:0,left:20},style:{cursor:"pointer"},onMouseMove:n,onMouseLeave:l,onClick:p=>{p?.activeTooltipIndex!=null&&c?.(Number(p.activeTooltipIndex));},children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:d$3}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:s,domain:t,ticks:r}),jsx(Tooltip,{content:jsx(Me,{viewMode:a})}),jsx(Bar,{dataKey:"realized",fill:"transparent",isAnimationActive:!1,background:jsx(ke,{activeBarIndex:i})}),o.goal&&jsx(Line,{dataKey:"goal",name:"Meta",stroke:k.goal,strokeWidth:2,strokeDasharray:"8 4",dot:!1,isAnimationActive:!1}),o.realized&&jsx(Line,{dataKey:"realized",name:"Vendas",stroke:k.sales,strokeWidth:2,dot:{fill:k.sales,r:4,strokeWidth:0},isAnimationActive:!1}),o.forecast&&jsx(Line,{dataKey:"forecast",name:"Previsto",stroke:k.forecast,strokeWidth:2,strokeDasharray:"6 3",dot:{fill:k.forecast,r:4,strokeWidth:0},isAnimationActive:!1})]})})},Mo=Ht;var tr=({data:e,visibleSeries:o,yDomain:t,yTicks:r,shouldRotateLabels:a,activeBarIndex:i,onMouseMove:n$1,onMouseLeave:l,onBarClick:c$1,viewMode:s})=>{let p=useMemo(()=>a?!1:{position:"top",fontSize:12,fill:"#212B36",formatter:m=>h(Number(m))},[a]);return jsx(ResponsiveContainer,{width:"100%",height:300,children:jsxs(ComposedChart,{data:e,margin:{top:20,right:10,bottom:a?-90:0,left:20},barCategoryGap:"20%",style:{cursor:"pointer"},onMouseMove:n$1,onMouseLeave:l,onClick:m=>{m?.activeTooltipIndex!=null&&c$1?.(Number(m.activeTooltipIndex));},children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,...a&&{interval:0,height:120},tick:a?jsx(n,{}):{fontSize:12,fill:"#637381"},tickFormatter:c}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:m=>d$1(m),domain:t,ticks:r}),jsx(Tooltip,{content:jsx(Me,{viewMode:s})}),o.goal&&jsx(Line,{dataKey:"goal",name:"Meta",stroke:k.goal,strokeWidth:2,strokeDasharray:"8 4",dot:!1,isAnimationActive:!1}),o.realized&&jsx(Bar,{dataKey:"realized",name:"Vendas",fill:k.sales,maxBarSize:48,isAnimationActive:!1,radius:[4,4,0,0],background:jsx(ke,{activeBarIndex:i}),label:p}),o.forecast&&jsx(Line,{dataKey:"forecast",name:"Previsto",stroke:k.forecast,strokeWidth:2,strokeDasharray:"6 3",dot:{fill:k.forecast,r:4,strokeWidth:0},isAnimationActive:!1})]})})},Do=tr;var nr=({data:e,viewMode:o,visibleSeries:t,yDomain:r,yTicks:a,formatYAxis:i,onBarClick:n})=>{let[l,c]=useState(null),[s,p]=useState(0),m=useRef(null),h=o==="MONTHLY",C=useMemo(()=>!h||s===0||e.length===0?!1:(s-60)/e.length<60,[s,e.length,h]),y=useCallback(()=>c(null),[]),S=useCallback(g=>{g?.activeTooltipIndex!=null&&c(Number(g.activeTooltipIndex));},[]),T=useCallback(g=>{m.current&&(m.current.disconnect(),m.current=null),g&&(p(g.clientWidth),m.current=new ResizeObserver(()=>p(g.clientWidth)),m.current.observe(g));},[]);return h?jsx(c$1,{ref:T,children:jsx(Do,{data:e,visibleSeries:t,yDomain:r,yTicks:a,formatYAxis:i,shouldRotateLabels:C,activeBarIndex:l,onMouseMove:S,onMouseLeave:y,onBarClick:n,viewMode:o})}):jsx(c$1,{ref:T,children:jsx(Mo,{data:e,visibleSeries:t,yDomain:r,yTicks:a,formatYAxis:i,viewMode:o,activeBarIndex:l,onMouseMove:S,onMouseLeave:y,onBarClick:n})})},Bo=nr;var lr=({visibleSeries:e,onToggleSerie:o})=>jsxs(D,{direction:"row",justifyContent:"center",flexWrap:"wrap",gap:1,children:[jsx(Ke,{control:jsx(He,{checked:e.realized,onChange:()=>o("realized"),sx:{"&.Mui-checked":{color:k.sales}}}),label:"Vendas"}),jsx(Ke,{control:jsx(He,{checked:e.forecast,onChange:()=>o("forecast"),sx:{"&.Mui-checked":{color:k.forecast}}}),label:"Previsto"}),jsx(Ke,{control:jsx(He,{checked:e.goal,onChange:()=>o("goal"),sx:{"&.Mui-checked":{color:k.goal}}}),label:"Meta"})]}),Po=lr;var pr=({kpis:e,isMonthly:o,editGoalAction:t})=>{let r=b$1("down","md");return jsxs(D,{direction:{xs:"column",md:"row"},alignItems:{xs:"flex-start",md:"center"},flexWrap:"wrap",gap:3,children:[r&&jsx(ue,{orientation:"horizontal",flexItem:!0,sx:{borderStyle:"dashed",mx:-3}}),jsxs(D,{children:[jsxs(M,{variant:"body2",color:"text.secondary",children:["Previsto no ",o?"ano":"m\xEAs"]}),jsx(M,{variant:"subtitle2",children:h(e?.forecast)})]}),jsx(ue,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),jsxs(D,{children:[jsxs(M,{variant:"body2",color:"text.secondary",children:["Realizado no ",o?"ano":"m\xEAs"]}),jsx(M,{variant:"subtitle2",children:h(e?.realized)})]}),jsx(ue,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),jsxs(D,{children:[jsxs(D,{direction:"row",alignItems:"center",gap:3,children:[jsxs(M,{variant:"body2",color:"text.secondary",children:["Meta ",o?"anual":"mensal"]}),t]}),jsx(M,{variant:"subtitle2",children:h(e?.goal)})]}),jsx(ue,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),jsxs(D,{children:[jsx(M,{variant:"body2",color:"text.secondary",children:"Atingimento"}),jsx(M,{variant:"subtitle2",children:c$2(e?.achievement??0,{maximumFractionDigits:2,minimumFractionDigits:2})})]}),jsx(ue,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),jsxs(D,{children:[jsxs(D,{direction:"row",gap:.5,children:[jsxs(M,{variant:"body2",color:"text.secondary",children:["GAP do ",o?"ano":"m\xEAs"]}),jsx(a$6,{text:"Diferen\xE7a entre o valor realizado e a meta. Um GAP significa que as vendas ainda est\xE3o abaixo do objetivo definido para o per\xEDodo.",width:18,arrow:!0,sx:{mt:-.1}})]}),jsx(M,{variant:"subtitle2",children:h(e?.gap)})]})]})},Qe=pr;var fr=({data:e,kpis:o,viewMode:t,selectedYear:r,editGoalAction:a$2,DetailComponent:i})=>{let[n,l]=useState({realized:!0,forecast:!0,goal:!0}),[c,s]=useState(!1),[p,m$1]=useState(""),[h,C]=useState(0),y=t==="MONTHLY",S=useMemo(()=>{if(!e.length)return [0,1];let x=e.flatMap(N=>[Number(N.realized)||0,Number(N.forecast)||0,Number(N.goal)||0]),L=Math.max(...x);return [0,L>0?L*1.15:1]},[e]),T=useMemo(()=>{let[,x]=S,L=x/6,N=Array.from({length:7},($r,$o)=>Math.round(L*$o));return [...new Set(N)]},[S]),g=useCallback(x=>{l(L=>({...L,[x]:!L[x]}));},[]),v=useCallback(x=>g(x),[g]),P=useCallback(x=>{let L=e[x];L&&(m$1(L.label),C(L.realized),s(!0));},[e]),d=useCallback(()=>{s(!1);},[]),f=useCallback(x=>d$1(x),[]);return jsxs(Fragment,{children:[jsxs(a,{children:[jsx(dt,{title:"Evolu\xE7\xE3o de vendas"}),jsx(mt,{children:jsx(a$1,{isEmpty:e.length===0,empty:jsx(m,{}),children:jsxs(D,{gap:3,children:[jsx(D,{display:{xs:"none",md:"block"},children:jsx(Qe,{kpis:o,isMonthly:y,editGoalAction:a$2})}),jsx(Bo,{data:e,viewMode:t,visibleSeries:n,yDomain:S,yTicks:T,formatYAxis:f,onBarClick:P}),jsx(Po,{visibleSeries:n,onToggleSerie:v}),jsx(D,{display:{xs:"block",md:"none"},children:jsx(Qe,{kpis:o,isMonthly:y,editGoalAction:a$2})})]})})})]}),p&&i&&jsx(i,{open:c,onClose:d,label:p,viewMode:t,selectedYear:r,totalValue:h})]})},ur=fr;var ie={realized:"#22C55E",forecast:"#F59E0B"};var yr=({x:e=0,y:o=0,width:t=0,height:r=0,index:a,activeBarIndex:i})=>i!==a?null:jsx("rect",{x:e-6,y:o,width:t+12,height:r+6,fill:"#919EAB",opacity:.16,rx:6}),Oo=yr;var vr=({x:e=0,y:o=0,width:t=0,height:r=0,index:a,activeBarIndex:i,bothRendered:n})=>i!==a?null:jsx("rect",{x:e-6,y:o,width:n?t*2+4+12:t+12,height:r+6,fill:"#919EAB",opacity:.16,rx:6}),Io=vr;var xr=({active:e,payload:o,label:t,viewMode:r})=>{if(!e||!o?.length)return null;let a=r==="DAILY",i=String(t),n=i.split("-");if(n.length>=2){let l=parseInt(n[1],10)-1,c=b[l];a&&n.length===3?i=`${parseInt(n[2],10)} de ${c} de ${n[0]}`:a||(i=`${c} de ${n[0]}`);}return jsxs(a$7,{minWidth:{xs:"auto",sm:200},p:1,gap:1,children:[jsx(M,{variant:"body2",color:"text.secondary",children:i}),jsx(ue,{}),jsx(D,{children:o.map((l,c)=>jsxs(D,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,"data-testid":`tooltip-item-${c}`,children:[jsxs(D,{direction:"row",alignItems:"center",gap:1,children:[jsx(D,{width:6,height:6,borderRadius:"50%",bgcolor:l.color}),jsx(M,{variant:"body2",noWrap:!0,children:l.name})]}),jsx(M,{variant:"body2",children:h(l.value)})]},l.name))})]})},zo=xr;var Rr=({data:e,viewMode:o,visibleSeries:t,activeBarIndex:r,onMouseMove:a,onMouseLeave:i})=>{let n$1=o==="MONTHLY",[l,c$2]=useState(0),s=useRef(null),p=useCallback(v=>{s.current&&(s.current.disconnect(),s.current=null),v&&(c$2(v.clientWidth),s.current=new ResizeObserver(()=>c$2(v.clientWidth)),s.current.observe(v));},[]),m=useMemo(()=>!n$1||l===0||e.length===0?!1:(l-60)/e.length<80,[n$1,l,e.length]),h=useMemo(()=>e.some(v=>v.realized_value>0),[e]),C=useMemo(()=>e.some(v=>v.forecast_value>0),[e]),y=useMemo(()=>{if(!e.length)return [0,1];let v=e.flatMap(d=>[d.realized_value,d.forecast_value]),P=Math.max(...v);return [0,P>0?P*1.15:1]},[e]),S=useMemo(()=>{let[,v]=y,P=v/6;return [...new Set(Array.from({length:7},(d,f)=>Math.round(P*f)))]},[y]),T=useMemo(()=>n$1?c:d$3,[n$1]),g=t.realized&&h&&t.forecast&&C;return jsx(c$1,{ref:p,children:jsx(ResponsiveContainer,{width:"100%",height:250,children:jsxs(BarChart,{data:e,margin:{top:20,right:10,bottom:m?-90:0,left:20},barCategoryGap:"20%",barGap:4,onMouseMove:a,onMouseLeave:i,children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,...m&&{interval:0,height:120},tick:m?jsx(n,{}):{fontSize:12,fill:"#637381"},tickFormatter:T}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:v=>d$1(v),domain:y,ticks:S}),jsx(Tooltip,{content:jsx(zo,{viewMode:o}),cursor:!1}),t.realized&&h&&jsx(Bar,{dataKey:"realized_value",name:"Realizado",fill:ie.realized,maxBarSize:32,isAnimationActive:!1,radius:[4,4,0,0],background:jsx(Io,{activeBarIndex:r,bothRendered:g})}),t.forecast&&C&&jsx(Bar,{dataKey:"forecast_value",name:"Previsto",fill:ie.forecast,maxBarSize:32,isAnimationActive:!1,radius:[4,4,0,0],...!t.realized&&{background:jsx(Oo,{activeBarIndex:r})}})]})})})},Fo=Rr;var zr=({visibleSeries:e,onToggleSerie:o})=>jsxs(D,{direction:"row",justifyContent:"center",flexWrap:"wrap",gap:1,children:[jsx(Ke,{control:jsx(He,{checked:e.realized,onChange:()=>o("realized"),sx:{"&.Mui-checked":{color:ie.realized}}}),label:"Realizado"}),jsx(Ke,{control:jsx(He,{checked:e.forecast,onChange:()=>o("forecast"),sx:{"&.Mui-checked":{color:ie.forecast}}}),label:"Previsto"})]}),_o=zr;var Fr=({totalForecast:e,totalRealized:o,percentage:t,isMonthly:r})=>{let a=b$1("down","md");return jsxs(D,{direction:{xs:"column",md:"row"},alignItems:{xs:"flex-start",md:"center"},flexWrap:"wrap",gap:3,children:[a&&jsx(ue,{orientation:"horizontal",flexItem:!0,sx:{borderStyle:"dashed",mx:-3}}),jsxs(D,{children:[jsx(M,{variant:"body2",color:"text.secondary",children:r?"Total previsto no ano":"Total previsto no m\xEAs"}),jsx(M,{variant:"subtitle2",children:h(e)})]}),jsx(ue,{orientation:a?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:a?"solid":"dashed"}}),jsxs(D,{children:[jsx(M,{variant:"body2",color:"text.secondary",children:r?"Total realizado no ano":"Total realizado no m\xEAs"}),jsx(M,{variant:"subtitle2",children:h(o)})]}),jsx(ue,{orientation:a?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:a?"solid":"dashed"}}),jsxs(D,{children:[jsx(M,{variant:"body2",color:"text.secondary",children:"Atingimento"}),jsxs(M,{variant:"subtitle2",children:[t,"%"]})]})]})},eo=Fr;var Er=({data:e,viewMode:o})=>{let t=o==="MONTHLY",[r,a$2]=useState({realized:!0,forecast:!0}),[i,n]=useState(null),l=useCallback(m=>{a$2(h=>({...h,[m]:!h[m]}));},[]),c=useCallback(m=>{m?.activeTooltipIndex!=null&&n(Number(m.activeTooltipIndex));},[]),s=useCallback(()=>n(null),[]),p=useMemo(()=>{let m=e.reduce((y,S)=>y+(S.realized_value??0),0),h=e.reduce((y,S)=>y+(S.forecast_value??0),0),C=h>0?Math.round(m/h*100):0;return {totalRealized:m,totalForecast:h,percentage:C}},[e]);return jsxs(a,{children:[jsx(dt,{title:"Previsto vs. Realizado (Positiva\xE7\xE3o)"}),jsx(mt,{children:jsx(a$1,{isEmpty:e.length===0,empty:jsx(m,{}),children:jsxs(D,{gap:3,children:[jsx(D,{display:{xs:"none",md:"block"},children:jsx(eo,{totalForecast:p.totalForecast,totalRealized:p.totalRealized,percentage:p.percentage,isMonthly:t})}),jsx(Fo,{data:e,viewMode:o,visibleSeries:r,activeBarIndex:i,onMouseMove:c,onMouseLeave:s}),jsx(_o,{visibleSeries:r,onToggleSerie:l}),jsx(D,{display:{xs:"block",md:"none"},children:jsx(eo,{totalForecast:p.totalForecast,totalRealized:p.totalRealized,percentage:p.percentage,isMonthly:t})})]})})})]})},Nr=Er;
45
+ var te={orders:"#22C55E",quotations:"#0EA5E9"};var qo=({x:e=0,y:o=0,width:t=0,height:r=0,index:a,activeBarIndex:i})=>i!==a?null:jsx("rect",{x:e-6,y:o,width:t+12,height:r+6,fill:"#919EAB",opacity:.16,rx:6}),ze=qo;var Ko=({x:e=0,y:o=0,width:t=0,index:r=0,data:a,visibleSeries:i,isMonthly:n,shouldRotateLabels:l})=>{if(!n||l)return null;let c=a[r];if(!c)return null;let s=0;return i.orders&&(s+=c.order_count??0),i.quotations&&(s+=c.quotation_count??0),s?jsx("text",{x:e+t/2,y:o-8,textAnchor:"middle",fontSize:11,fill:"#212B36",children:s}):null},Fe=Ko;var Xo=({active:e,payload:o,label:t,viewMode:r})=>{if(!e||!o?.length)return null;let a=r==="DAILY",i=String(t),n=i.split("-");if(n.length>=2){let s=parseInt(n[1],10)-1,m=b[s];a&&n.length===3?i=`${parseInt(n[2],10)} de ${m} de ${n[0]}`:a||(i=`${m} de ${n[0]}`);}let l=o[0].payload,c=[{name:"Vendas",count:l.order_count??0,value:l.order_value??0,color:o.find(s=>s.dataKey==="order_count")?.color??"#22C55E"},{name:"Or\xE7amentos",count:l.quotation_count??0,value:l.quotation_value??0,color:o.find(s=>s.dataKey==="quotation_count")?.color??"#0EA5E9"}];return jsxs(a$8,{minWidth:{xs:"auto",sm:300},p:1,gap:1,children:[jsx(M,{variant:"body2",color:"text.secondary",children:i}),jsx(ye,{}),jsx(L,{children:c.map((s,m)=>jsxs(L,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:2,"data-testid":`tooltip-item-${m}`,children:[jsxs(L,{direction:"row",alignItems:"center",gap:1,children:[jsx(L,{width:6,height:6,borderRadius:"50%",bgcolor:s.color}),jsx(M,{variant:"body2",noWrap:!0,children:s.name})]}),jsxs(M,{variant:"body2",color:"text.disabled",noWrap:!0,children:[s.count," ",s.count===1?"pedido":"pedidos","\u2002",jsx(M,{component:"span",variant:"body2",color:"text.primary",children:h(s.value)})]})]},s.name))})]})},uo=Xo;var nt=({data:e,viewMode:o,visibleSeries:t,activeBarIndex:r,onMouseMove:a,onMouseLeave:i,onBarClick:n$1})=>{let l=o==="MONTHLY",[c$2,s]=useState(0),m=useRef(null),p=useCallback(u=>{m.current&&(m.current.disconnect(),m.current=null),u&&(s(u.clientWidth),m.current=new ResizeObserver(()=>s(u.clientWidth)),m.current.observe(u));},[]),d=useMemo(()=>!l||c$2===0||e.length===0?!1:(c$2-60)/e.length<80,[l,c$2,e.length]),y=useMemo(()=>e.some(u=>(u.order_count??0)>0),[e]),v=useMemo(()=>e.some(u=>(u.quotation_count??0)>0),[e]),k=useMemo(()=>{if(!e.length)return [0,1];let u=Math.max(...e.map(g=>(g.order_count??0)+(g.quotation_count??0)));return [0,u>0?u*1.15:1]},[e]),S=useMemo(()=>{let[,u]=k,g=u/6;return [...new Set(Array.from({length:7},(R,x)=>Math.round(g*x)))]},[k]),h=t.quotations&&v,b=t.orders&&y&&!h,P=useMemo(()=>l?c:d$3,[l]);return jsx(c$1,{ref:p,children:jsx(ResponsiveContainer,{width:"100%",height:250,children:jsxs(BarChart,{data:e,margin:{top:20,right:10,bottom:d?-90:0,left:20},barCategoryGap:"20%",style:{cursor:"pointer"},onMouseMove:a,onMouseLeave:i,onClick:u=>{u?.activeTooltipIndex!=null&&n$1?.(Number(u.activeTooltipIndex));},children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,...d&&{interval:0,height:120},tick:d?jsx(n,{}):{fontSize:12,fill:"#637381"},tickFormatter:P}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:u=>d$1(u),domain:k,ticks:S}),jsx(Tooltip,{content:jsx(uo,{viewMode:o}),cursor:!1}),jsx(Bar,{dataKey:"order_count",name:"Vendas",fill:te.orders,stackId:"orders",maxBarSize:48,isAnimationActive:!1,hide:!t.orders,background:jsx(ze,{activeBarIndex:r}),radius:b?[4,4,0,0]:void 0,...b&&{label:{position:"top",fontSize:11,fill:"#212B36",content:jsx(Fe,{data:e,visibleSeries:t,isMonthly:l,shouldRotateLabels:d})}}}),jsx(Bar,{dataKey:"quotation_count",name:"Or\xE7amentos",fill:te.quotations,stackId:"orders",maxBarSize:48,isAnimationActive:!1,hide:!t.quotations,radius:h?[4,4,0,0]:void 0,...!t.orders&&{background:jsx(ze,{activeBarIndex:r})},...h&&{label:{position:"top",fontSize:11,fill:"#212B36",content:jsx(Fe,{data:e,visibleSeries:t,isMonthly:l,shouldRotateLabels:d})}}})]})})})},yo=nt;var ct=({visibleSeries:e,onToggleSerie:o})=>jsxs(L,{direction:"row",justifyContent:"center",flexWrap:"wrap",gap:1,children:[jsx(Ue,{control:jsx(Qe,{checked:e.orders,onChange:()=>o("orders"),sx:{"&.Mui-checked":{color:te.orders}}}),label:"Vendas"}),jsx(Ue,{control:jsx(Qe,{checked:e.quotations,onChange:()=>o("quotations"),sx:{"&.Mui-checked":{color:te.quotations}}}),label:"Or\xE7amentos"})]}),bo=ct;var mt=({ordersTotal:e,quotationsTotal:o,isMonthly:t})=>{let r=b$1("down","md");return jsxs(L,{direction:{xs:"column",md:"row"},alignItems:{xs:"flex-start",md:"center"},flexWrap:"wrap",gap:3,children:[r&&jsx(ye,{orientation:"horizontal",flexItem:!0,sx:{borderStyle:"dashed",mx:-3}}),jsxs(L,{children:[jsx(M,{variant:"body2",color:"text.secondary",children:t?"Vendas no ano":"Vendas no m\xEAs"}),jsxs(M,{variant:"subtitle2",children:[e," vendas"]})]}),jsx(ye,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),jsxs(L,{children:[jsx(M,{variant:"body2",color:"text.secondary",children:t?"Or\xE7amentos no ano":"Or\xE7amentos no m\xEAs"}),jsxs(M,{variant:"subtitle2",children:[o," or\xE7amentos"]})]})]})},Ve=mt;var ht=({data:e,isFetching:o,viewMode:t,selectedYear:r,DetailComponent:a$3})=>{let i=t==="MONTHLY",[n,l]=useState({orders:!0,quotations:!0}),[c,s]=useState(null),[m$1,p]=useState(!1),[d,y]=useState(""),[v,k]=useState(0),S=useCallback(R=>{l(x=>({...x,[R]:!x[R]}));},[]),h=useCallback(R=>{R?.activeTooltipIndex!=null&&s(Number(R.activeTooltipIndex));},[]),b=useCallback(()=>s(null),[]),P=useCallback(R=>{let x=e[R];x&&(y(x.label),k(x.order_value),p(!0));},[e]),u=useCallback(()=>{p(!1);},[]),g=useMemo(()=>{let R=e.reduce((D,$)=>D+($.order_count??0),0),x=e.reduce((D,$)=>D+($.quotation_count??0),0);return {ordersTotal:R,quotationsTotal:x}},[e]);return jsxs(Fragment,{children:[jsxs(a,{children:[jsx(ut,{title:"Quantidade de pedidos por tipo"}),jsx(ft,{children:jsx(a$1,{isEmpty:e.length===0,empty:jsx(m,{}),children:jsxs(L,{gap:3,children:[jsx(L,{display:{xs:"none",md:"block"},children:jsx(Ve,{isMonthly:i,ordersTotal:g.ordersTotal,quotationsTotal:g.quotationsTotal})}),jsx(a$2,{active:o,children:jsx(yo,{data:e,viewMode:t,visibleSeries:n,activeBarIndex:c,onMouseMove:h,onMouseLeave:b,onBarClick:P})}),jsx(bo,{visibleSeries:n,onToggleSerie:S}),jsx(L,{display:{xs:"block",md:"none"},children:jsx(Ve,{isMonthly:i,ordersTotal:g.ordersTotal,quotationsTotal:g.quotationsTotal})})]})})})]}),d&&a$3&&jsx(a$3,{open:m$1,onClose:u,label:d,viewMode:t,selectedYear:r,totalValue:v})]})},yt=ht;var vt=({title:e,viewMode:o,selectedYear:t,periodLabel:r})=>jsxs(L,{width:"100%",minWidth:0,overflow:"hidden",children:[jsx(M,{variant:"subtitle1",noWrap:!0,children:"Detalhes do relat\xF3rio"}),jsxs(L,{direction:"row",alignItems:"center",columnGap:1.5,rowGap:0,flexWrap:"wrap",children:[jsx(M,{variant:"body2",color:"text.secondary",flexShrink:0,children:e}),"\u2022",jsx(M,{variant:"body2",flexShrink:0,children:b$2[o]}),"\u2022",jsx(M,{variant:"body2",flexShrink:0,children:t}),"\u2022",jsx(M,{variant:"body2",color:"text.secondary",noWrap:!0,children:r})]})]}),ko=vt;var Mo=styled(ye)(()=>({height:30,alignSelf:"center",borderStyle:"dashed"})),Lo=styled(L)(({theme:e})=>({position:"relative",display:"flex",flexDirection:"column",padding:e.spacing(2),gap:e.spacing(1),color:e.palette.text.primary,"& a":{textDecoration:"none"},"&+div":{borderTop:`1px dashed ${alpha(e.palette.grey[500],.2)}`}}));var Tt=e=>jsx(L,{justifyContent:"center",height:1,children:jsx(M,{variant:"body2",color:"text.primary",children:e.id})}),Mt=(e,o)=>jsx(L,{justifyContent:"center",height:1,children:e?.partner?.id&&o?jsx(kt,{component:"a",href:o(e.partner.id),target:"_blank",rel:"noopener noreferrer",variant:"subtitle2",sx:{textDecoration:"underline"},noWrap:!0,children:e.partner?.name||"-"}):jsx(M,{variant:"body2",color:"text.primary",noWrap:!0,children:e.partner?.name||"-"})}),Lt=e=>jsx(L,{justifyContent:"center",height:1,children:jsx(M,{variant:"body2",color:"text.primary",children:h(e.total_value)})}),Dt=e=>jsx(L,{justifyContent:"center",height:1,children:e.negotiation_date?jsx(M,{variant:"body2",color:"text.primary",children:d$2(e.negotiation_date,"DD/MM/YYYY")}):"-"}),wt=e=>jsx(L,{justifyContent:"center",height:1,children:e.status||"-"}),Bt=e=>jsx(Lo,{children:jsxs(L,{gap:1,children:[jsxs(L,{children:[jsx(M,{variant:"body2",color:"text.secondary",children:"Pedido"}),jsx(M,{variant:"subtitle2",color:"text.primary",children:e.id})]}),jsxs(L,{children:[jsx(M,{variant:"body2",color:"text.secondary",children:"Cliente"}),jsx(M,{variant:"subtitle2",color:"primary.main",children:e.partner?.name||"-"})]}),jsxs(L,{direction:"row",alignItems:"center",gap:1,children:[jsxs(L,{flex:1,overflow:"hidden",children:[jsx(M,{variant:"body2",color:"text.secondary",noWrap:!0,children:"Valor do pedido"}),jsx(M,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:h(e.total_value)})]}),jsx(ye,{orientation:"vertical",flexItem:!0,sx:{borderStyle:"dashed",mx:3}}),jsxs(L,{flex:1,overflow:"hidden",children:[jsx(M,{variant:"body2",color:"text.secondary",noWrap:!0,children:"Data"}),jsx(M,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:e.negotiation_date?d$2(e.negotiation_date,"DD/MM/YYYY"):"-"})]})]}),jsxs(L,{gap:.5,children:[jsx(M,{variant:"body2",color:"text.secondary",children:"Status"}),jsx(M,{variant:"subtitle2",color:"text.primary",children:e.status||"-"})]})]})},e.id),Pt=({open:e,onClose:o,title:t,viewMode:r,selectedYear:a,totalValue:i,periodLabel:n,suffix:l,rows:c,total:s,isLoading:m,isFetching:p,page:d$1,perPage:y,onSearch:v,onPaginationChange:k,buildPartnerLink:S,mobileItemSlot:h$1})=>{let b=b$1("down","sm"),P=jsxs(L,{gap:3,children:[jsxs(L,{direction:{xs:"column",sm:"row"},justifyContent:"space-between",gap:2,children:[jsxs(L,{minWidth:0,direction:"row",alignItems:"center",gap:3,flexWrap:"wrap",children:[jsxs(L,{children:[jsxs(M,{variant:"body2",color:"text.secondary",children:["Vendas ",l]}),jsx(M,{variant:"subtitle2",color:"text.primary",children:h(i)})]}),jsx(Mo,{orientation:"vertical",flexItem:!0}),jsxs(L,{children:[jsxs(M,{variant:"body2",color:"text.secondary",children:["Qtd. de pedidos ",l]}),jsx(M,{variant:"subtitle2",color:"text.primary",children:s})]})]}),jsx(a$3,{size:"small",placeholder:"Buscar",onSearch:v,trigger:"change",iconPosition:"start",sx:{minWidth:200}})]}),jsx(d,{title:"Pedidos",header:jsx(Fragment,{}),headerProps:{p:0},columns:[{field:"external_id",headerName:"Pedido",flex:1,renderCell:({row:g})=>Tt(g)},{field:"partner_name",headerName:"Cliente",flex:1,renderCell:({row:g})=>Mt(g,S)},{field:"total_value",headerName:"Valor do pedido",flex:1,renderCell:({row:g})=>Lt(g)},{field:"created_at",headerName:"Data",flex:1,renderCell:({row:g})=>Dt(g)},{field:"last_status",headerName:"Status",flex:1,renderCell:({row:g})=>wt(g)}],rows:c,rowCount:s,mobileRender:g=>h$1?h$1(g):Bt(g),loading:m,fetching:p,paginationModel:{page:d$1,pageSize:y},onPaginationChange:k,paginationMode:"server",disableRowSelectionOnClick:!0,disableColumnMenu:!0,containerProps:{height:400}})]}),u=jsx(ko,{title:t,viewMode:r,selectedYear:a,periodLabel:n});return b?jsx(a$4,{open:e,onClose:o,headerTitle:u,headerProps:{direction:"row-reverse",sx:{"& > :last-child":{minWidth:0,overflow:"hidden"}}},children:P}):jsx(a$5,{open:e,onClose:o,maxWidth:"lg",dialogTitle:u,dialogTitleProps:{sx:{flex:1,overflow:"hidden"}},fullWidth:!0,children:P})},Rt=Pt;var Ee=(e,o)=>{let t=e.split("-");if(o==="DAILY"&&t.length===3){let n=`${t[0]}-${t[1]}-${t[2]}`;return {startDate:n,endDate:n}}let r=parseInt(t[0],10),a=parseInt(t[1],10),i=new Date(r,a,0).getDate();return {startDate:`${t[0]}-${t[1]}-01`,endDate:`${t[0]}-${t[1]}-${String(i).padStart(2,"0")}`}},Ne=(e,o)=>{let t=e.split("-"),r=parseInt(t[1],10)-1,a=b[r]??"";if(o==="DAILY"&&t.length===3){let i=parseInt(t[2],10);return `${a} - Dia ${i}`}return a},$e=e=>e==="MONTHLY"?"no m\xEAs":"no dia";var zt=(e,o)=>{let{page:t,perPage:r,search:a,handlePaginationModelChange:i,handleSearch:n}=a$6(),{startDate:l,endDate:c}=useMemo(()=>Ee(e,o),[e,o]),s=useMemo(()=>Ne(e,o),[e,o]),m=$e(o),p=useMemo(()=>({page:t,perPage:r,...a?{search:a}:{},filter:{operator:"AND",groups:[{operator:"AND",conditionals:[{fieldName:"negotiationDate",conditional:"GREATER_THAN_OR_EQUAL",value:[`${l}T00:00:00`]},{fieldName:"negotiationDate",conditional:"LESS_THAN_OR_EQUAL",value:[`${c}T23:59:59`]}]}]}}),[c,t,r,a,l]),d=useCallback((y,v)=>{i({page:y,pageSize:v});},[i]);return {page:t,perPage:r,periodLabel:s,suffix:m,queryParams:p,handleSearch:n,handlePaginationChange:d}},Ft=zt;var T={sales:"#22C55E",forecast:"#F59E0B",goal:"#212B36"};var At=({x:e=0,y:o=0,width:t=0,height:r=0,index:a,activeBarIndex:i})=>i!==a?null:jsx("rect",{x:e-6,y:o,width:t+6*2,height:r+6,fill:T.sales,opacity:.16,rx:6}),Me=At;var _t=({active:e,payload:o,label:t,viewMode:r})=>{if(!e||!o?.length)return null;let a=r==="DAILY",i=o[0].payload,n=Number(i.realized)||0,l=Number(i.forecast)||0,c=Number(i.goal)||0,s=c>0?n/c*100:0,m=c>n?c-n:0,p=a?"no dia":"no m\xEAs",d=a?"di\xE1ria":"mensal",y=String(t),v=y.split("-");if(v.length>=2){let S=parseInt(v[1],10)-1,h=b[S];a&&v.length===3?y=`${parseInt(v[2],10)} de ${h} de ${v[0]}`:a||(y=`${h} de ${v[0]}`);}let k=[{name:`Realizado ${p}`,value:h(n),color:T.sales},{name:`Previsto ${p}`,value:h(l),color:T.forecast},{name:`Meta ${d}`,value:h(c),color:T.goal},{name:"Atingimento",value:`${s.toFixed(0)}%`,color:"#00B8D9"},{name:`GAP ${p}`,value:h(m),color:"#FF5630"}];return jsxs(a$8,{minWidth:{xs:"auto",sm:400},p:1,gap:1,children:[jsx(M,{variant:"body2",color:"text.secondary",children:y}),jsx(ye,{}),jsx(L,{children:k.map((S,h)=>jsxs(L,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,"data-testid":`tooltip-item-${h}`,children:[jsxs(L,{direction:"row",alignItems:"center",gap:1,children:[jsx(L,{width:6,height:6,borderRadius:"50%",bgcolor:S.color}),jsx(M,{variant:"body2",noWrap:!0,children:S.name})]}),jsx(M,{variant:"body2",children:S.value})]},h))})]})},De=_t;var Qt=({data:e,visibleSeries:o,yDomain:t,yTicks:r,viewMode:a,activeBarIndex:i,onMouseMove:n,onMouseLeave:l,onBarClick:c})=>{let s=useCallback(m=>d$1(m),[]);return jsx(ResponsiveContainer,{width:"100%",height:350,children:jsxs(ComposedChart,{data:e,margin:{top:20,right:10,bottom:0,left:20},style:{cursor:"pointer"},onMouseMove:n,onMouseLeave:l,onClick:m=>{m?.activeTooltipIndex!=null&&c?.(Number(m.activeTooltipIndex));},children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:d$3}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:s,domain:t,ticks:r}),jsx(Tooltip,{content:jsx(De,{viewMode:a})}),jsx(Bar,{dataKey:"realized",fill:"transparent",isAnimationActive:!1,background:jsx(Me,{activeBarIndex:i})}),o.goal&&jsx(Line,{dataKey:"goal",name:"Meta",stroke:T.goal,strokeWidth:2,strokeDasharray:"8 4",dot:!1,isAnimationActive:!1}),o.realized&&jsx(Line,{dataKey:"realized",name:"Vendas",stroke:T.sales,strokeWidth:2,dot:{fill:T.sales,r:4,strokeWidth:0},isAnimationActive:!1}),o.forecast&&jsx(Line,{dataKey:"forecast",name:"Previsto",stroke:T.forecast,strokeWidth:2,strokeDasharray:"6 3",dot:{fill:T.forecast,r:4,strokeWidth:0},isAnimationActive:!1})]})})},Do=Qt;var ar=({data:e,visibleSeries:o,yDomain:t,yTicks:r,shouldRotateLabels:a,activeBarIndex:i,onMouseMove:n$1,onMouseLeave:l,onBarClick:c$1,viewMode:s})=>{let m=useMemo(()=>a?!1:{position:"top",fontSize:12,fill:"#212B36",formatter:p=>h(Number(p))},[a]);return jsx(ResponsiveContainer,{width:"100%",height:300,children:jsxs(ComposedChart,{data:e,margin:{top:20,right:10,bottom:a?-90:0,left:20},barCategoryGap:"20%",style:{cursor:"pointer"},onMouseMove:n$1,onMouseLeave:l,onClick:p=>{p?.activeTooltipIndex!=null&&c$1?.(Number(p.activeTooltipIndex));},children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,...a&&{interval:0,height:120},tick:a?jsx(n,{}):{fontSize:12,fill:"#637381"},tickFormatter:c}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:p=>d$1(p),domain:t,ticks:r}),jsx(Tooltip,{content:jsx(De,{viewMode:s})}),o.goal&&jsx(Line,{dataKey:"goal",name:"Meta",stroke:T.goal,strokeWidth:2,strokeDasharray:"8 4",dot:!1,isAnimationActive:!1}),o.realized&&jsx(Bar,{dataKey:"realized",name:"Vendas",fill:T.sales,maxBarSize:48,isAnimationActive:!1,radius:[4,4,0,0],background:jsx(Me,{activeBarIndex:i}),label:m}),o.forecast&&jsx(Line,{dataKey:"forecast",name:"Previsto",stroke:T.forecast,strokeWidth:2,strokeDasharray:"6 3",dot:{fill:T.forecast,r:4,strokeWidth:0},isAnimationActive:!1})]})})},Bo=ar;var lr=({data:e,viewMode:o,visibleSeries:t,yDomain:r,yTicks:a,formatYAxis:i,onBarClick:n})=>{let[l,c]=useState(null),[s,m]=useState(0),p=useRef(null),d=o==="MONTHLY",y=useMemo(()=>!d||s===0||e.length===0?!1:(s-60)/e.length<60,[s,e.length,d]),v=useCallback(()=>c(null),[]),k=useCallback(h=>{h?.activeTooltipIndex!=null&&c(Number(h.activeTooltipIndex));},[]),S=useCallback(h=>{p.current&&(p.current.disconnect(),p.current=null),h&&(m(h.clientWidth),p.current=new ResizeObserver(()=>m(h.clientWidth)),p.current.observe(h));},[]);return d?jsx(c$1,{ref:S,children:jsx(Bo,{data:e,visibleSeries:t,yDomain:r,yTicks:a,formatYAxis:i,shouldRotateLabels:y,activeBarIndex:l,onMouseMove:k,onMouseLeave:v,onBarClick:n,viewMode:o})}):jsx(c$1,{ref:S,children:jsx(Do,{data:e,visibleSeries:t,yDomain:r,yTicks:a,formatYAxis:i,viewMode:o,activeBarIndex:l,onMouseMove:k,onMouseLeave:v,onBarClick:n})})},Ro=lr;var pr=({visibleSeries:e,onToggleSerie:o})=>jsxs(L,{direction:"row",justifyContent:"center",flexWrap:"wrap",gap:1,children:[jsx(Ue,{control:jsx(Qe,{checked:e.realized,onChange:()=>o("realized"),sx:{"&.Mui-checked":{color:T.sales}}}),label:"Vendas"}),jsx(Ue,{control:jsx(Qe,{checked:e.forecast,onChange:()=>o("forecast"),sx:{"&.Mui-checked":{color:T.forecast}}}),label:"Previsto"}),jsx(Ue,{control:jsx(Qe,{checked:e.goal,onChange:()=>o("goal"),sx:{"&.Mui-checked":{color:T.goal}}}),label:"Meta"})]}),Oo=pr;var dr=({kpis:e,isMonthly:o,editGoalAction:t})=>{let r=b$1("down","md");return jsxs(L,{direction:{xs:"column",md:"row"},alignItems:{xs:"flex-start",md:"center"},flexWrap:"wrap",gap:3,children:[r&&jsx(ye,{orientation:"horizontal",flexItem:!0,sx:{borderStyle:"dashed",mx:-3}}),jsxs(L,{children:[jsxs(M,{variant:"body2",color:"text.secondary",children:["Previsto no ",o?"ano":"m\xEAs"]}),jsx(M,{variant:"subtitle2",children:h(e?.forecast)})]}),jsx(ye,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),jsxs(L,{children:[jsxs(M,{variant:"body2",color:"text.secondary",children:["Realizado no ",o?"ano":"m\xEAs"]}),jsx(M,{variant:"subtitle2",children:h(e?.realized)})]}),jsx(ye,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),jsxs(L,{children:[jsxs(L,{direction:"row",alignItems:"center",gap:3,children:[jsxs(M,{variant:"body2",color:"text.secondary",children:["Meta ",o?"anual":"mensal"]}),t]}),jsx(M,{variant:"subtitle2",children:h(e?.goal)})]}),jsx(ye,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),jsxs(L,{children:[jsx(M,{variant:"body2",color:"text.secondary",children:"Atingimento"}),jsx(M,{variant:"subtitle2",children:c$2(e?.achievement??0,{maximumFractionDigits:2,minimumFractionDigits:2})})]}),jsx(ye,{orientation:r?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:r?"solid":"dashed"}}),jsxs(L,{children:[jsxs(L,{direction:"row",gap:.5,children:[jsxs(M,{variant:"body2",color:"text.secondary",children:["GAP do ",o?"ano":"m\xEAs"]}),jsx(a$7,{text:"Diferen\xE7a entre o valor realizado e a meta. Um GAP significa que as vendas ainda est\xE3o abaixo do objetivo definido para o per\xEDodo.",width:18,arrow:!0,sx:{mt:-.1}})]}),jsx(M,{variant:"subtitle2",children:h(e?.gap)})]})]})},Xe=dr;var hr=({data:e,isFetching:o,kpis:t,viewMode:r,selectedYear:a$3,editGoalAction:i,DetailComponent:n})=>{let[l,c]=useState({realized:!0,forecast:!0,goal:!0}),[s,m$1]=useState(!1),[p,d]=useState(""),[y,v]=useState(0),k=r==="MONTHLY",S=useMemo(()=>{if(!e.length)return [0,1];let x=e.flatMap($=>[Number($.realized)||0,Number($.forecast)||0,Number($.goal)||0]),D=Math.max(...x);return [0,D>0?D*1.15:1]},[e]),h=useMemo(()=>{let[,x]=S,D=x/6,$=Array.from({length:7},(Gr,Go)=>Math.round(D*Go));return [...new Set($)]},[S]),b=useCallback(x=>{c(D=>({...D,[x]:!D[x]}));},[]),P=useCallback(x=>b(x),[b]),u=useCallback(x=>{let D=e[x];D&&(d(D.label),v(D.realized),m$1(!0));},[e]),g=useCallback(()=>{m$1(!1);},[]),R=useCallback(x=>d$1(x),[]);return jsxs(Fragment,{children:[jsxs(a,{children:[jsx(ut,{title:"Evolu\xE7\xE3o de vendas"}),jsx(ft,{children:jsx(a$1,{isEmpty:e.length===0,empty:jsx(m,{}),children:jsxs(L,{gap:3,children:[jsx(L,{display:{xs:"none",md:"block"},children:jsx(Xe,{kpis:t,isMonthly:k,editGoalAction:i})}),jsx(a$2,{active:o,children:jsx(Ro,{data:e,viewMode:r,visibleSeries:l,yDomain:S,yTicks:h,formatYAxis:R,onBarClick:u})}),jsx(Oo,{visibleSeries:l,onToggleSerie:P}),jsx(L,{display:{xs:"block",md:"none"},children:jsx(Xe,{kpis:t,isMonthly:k,editGoalAction:i})})]})})})]}),p&&n&&jsx(n,{open:s,onClose:g,label:p,viewMode:r,selectedYear:a$3,totalValue:y})]})},yr=hr;var se={realized:"#22C55E",forecast:"#F59E0B"};var vr=({x:e=0,y:o=0,width:t=0,height:r=0,index:a,activeBarIndex:i})=>i!==a?null:jsx("rect",{x:e-6,y:o,width:t+12,height:r+6,fill:"#919EAB",opacity:.16,rx:6}),zo=vr;var Sr=({x:e=0,y:o=0,width:t=0,height:r=0,index:a,activeBarIndex:i,bothRendered:n})=>i!==a?null:jsx("rect",{x:e-6,y:o,width:n?t*2+4+12:t+12,height:r+6,fill:"#919EAB",opacity:.16,rx:6}),Fo=Sr;var kr=({active:e,payload:o,label:t,viewMode:r})=>{if(!e||!o?.length)return null;let a=r==="DAILY",i=String(t),n=i.split("-");if(n.length>=2){let l=parseInt(n[1],10)-1,c=b[l];a&&n.length===3?i=`${parseInt(n[2],10)} de ${c} de ${n[0]}`:a||(i=`${c} de ${n[0]}`);}return jsxs(a$8,{minWidth:{xs:"auto",sm:200},p:1,gap:1,children:[jsx(M,{variant:"body2",color:"text.secondary",children:i}),jsx(ye,{}),jsx(L,{children:o.map((l,c)=>jsxs(L,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,"data-testid":`tooltip-item-${c}`,children:[jsxs(L,{direction:"row",alignItems:"center",gap:1,children:[jsx(L,{width:6,height:6,borderRadius:"50%",bgcolor:l.color}),jsx(M,{variant:"body2",noWrap:!0,children:l.name})]}),jsx(M,{variant:"body2",children:h(l.value)})]},l.name))})]})},Ao=kr;var Ir=({data:e,viewMode:o,visibleSeries:t,activeBarIndex:r,onMouseMove:a,onMouseLeave:i})=>{let n$1=o==="MONTHLY",[l,c$2]=useState(0),s=useRef(null),m=useCallback(b=>{s.current&&(s.current.disconnect(),s.current=null),b&&(c$2(b.clientWidth),s.current=new ResizeObserver(()=>c$2(b.clientWidth)),s.current.observe(b));},[]),p=useMemo(()=>!n$1||l===0||e.length===0?!1:(l-60)/e.length<80,[n$1,l,e.length]),d=useMemo(()=>e.some(b=>b.realized_value>0),[e]),y=useMemo(()=>e.some(b=>b.forecast_value>0),[e]),v=useMemo(()=>{if(!e.length)return [0,1];let b=e.flatMap(u=>[u.realized_value,u.forecast_value]),P=Math.max(...b);return [0,P>0?P*1.15:1]},[e]),k=useMemo(()=>{let[,b]=v,P=b/6;return [...new Set(Array.from({length:7},(u,g)=>Math.round(P*g)))]},[v]),S=useMemo(()=>n$1?c:d$3,[n$1]),h=t.realized&&d&&t.forecast&&y;return jsx(c$1,{ref:m,children:jsx(ResponsiveContainer,{width:"100%",height:250,children:jsxs(BarChart,{data:e,margin:{top:20,right:10,bottom:p?-90:0,left:20},barCategoryGap:"20%",barGap:4,onMouseMove:a,onMouseLeave:i,children:[jsx(CartesianGrid,{vertical:!1,strokeDasharray:"3 3",stroke:"#F4F6F8"}),jsx(XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,...p&&{interval:0,height:120},tick:p?jsx(n,{}):{fontSize:12,fill:"#637381"},tickFormatter:S}),jsx(YAxis,{axisLine:!1,tickLine:!1,tick:{fontSize:12,fill:"#637381"},tickFormatter:b=>d$1(b),domain:v,ticks:k}),jsx(Tooltip,{content:jsx(Ao,{viewMode:o}),cursor:!1}),t.realized&&d&&jsx(Bar,{dataKey:"realized_value",name:"Realizado",fill:se.realized,maxBarSize:32,isAnimationActive:!1,radius:[4,4,0,0],background:jsx(Fo,{activeBarIndex:r,bothRendered:h})}),t.forecast&&y&&jsx(Bar,{dataKey:"forecast_value",name:"Previsto",fill:se.forecast,maxBarSize:32,isAnimationActive:!1,radius:[4,4,0,0],...!t.realized&&{background:jsx(zo,{activeBarIndex:r})}})]})})})},Wo=Ir;var Ar=({visibleSeries:e,onToggleSerie:o})=>jsxs(L,{direction:"row",justifyContent:"center",flexWrap:"wrap",gap:1,children:[jsx(Ue,{control:jsx(Qe,{checked:e.realized,onChange:()=>o("realized"),sx:{"&.Mui-checked":{color:se.realized}}}),label:"Realizado"}),jsx(Ue,{control:jsx(Qe,{checked:e.forecast,onChange:()=>o("forecast"),sx:{"&.Mui-checked":{color:se.forecast}}}),label:"Previsto"})]}),No=Ar;var Wr=({totalForecast:e,totalRealized:o,percentage:t,isMonthly:r})=>{let a=b$1("down","md");return jsxs(L,{direction:{xs:"column",md:"row"},alignItems:{xs:"flex-start",md:"center"},flexWrap:"wrap",gap:3,children:[a&&jsx(ye,{orientation:"horizontal",flexItem:!0,sx:{borderStyle:"dashed",mx:-3}}),jsxs(L,{children:[jsx(M,{variant:"body2",color:"text.secondary",children:r?"Total previsto no ano":"Total previsto no m\xEAs"}),jsx(M,{variant:"subtitle2",children:h(e)})]}),jsx(ye,{orientation:a?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:a?"solid":"dashed"}}),jsxs(L,{children:[jsx(M,{variant:"body2",color:"text.secondary",children:r?"Total realizado no ano":"Total realizado no m\xEAs"}),jsx(M,{variant:"subtitle2",children:h(o)})]}),jsx(ye,{orientation:a?"horizontal":"vertical",flexItem:!0,sx:{borderStyle:a?"solid":"dashed"}}),jsxs(L,{children:[jsx(M,{variant:"body2",color:"text.secondary",children:"Atingimento"}),jsxs(M,{variant:"subtitle2",children:[t,"%"]})]})]})},to=Wr;var $r=({data:e,viewMode:o,isFetching:t})=>{let r=o==="MONTHLY",[a$3,i]=useState({realized:!0,forecast:!0}),[n,l]=useState(null),c=useCallback(d=>{i(y=>({...y,[d]:!y[d]}));},[]),s=useCallback(d=>{d?.activeTooltipIndex!=null&&l(Number(d.activeTooltipIndex));},[]),m$1=useCallback(()=>l(null),[]),p=useMemo(()=>{let d=e.reduce((k,S)=>k+(S.realized_value??0),0),y=e.reduce((k,S)=>k+(S.forecast_value??0),0),v=y>0?Math.round(d/y*100):0;return {totalRealized:d,totalForecast:y,percentage:v}},[e]);return jsxs(a,{children:[jsx(ut,{title:"Previsto vs. Realizado (Positiva\xE7\xE3o)"}),jsx(ft,{children:jsx(a$1,{isEmpty:e.length===0,empty:jsx(m,{}),children:jsxs(L,{gap:3,children:[jsx(L,{display:{xs:"none",md:"block"},children:jsx(to,{totalForecast:p.totalForecast,totalRealized:p.totalRealized,percentage:p.percentage,isMonthly:r})}),jsx(a$2,{active:t,children:jsx(Wo,{data:e,viewMode:o,visibleSeries:a$3,activeBarIndex:n,onMouseMove:s,onMouseLeave:m$1})}),jsx(No,{visibleSeries:a$3,onToggleSerie:c}),jsx(L,{display:{xs:"block",md:"none"},children:jsx(to,{totalForecast:p.totalForecast,totalRealized:p.totalRealized,percentage:p.percentage,isMonthly:r})})]})})})]})},Yr=$r;
45
46
 
46
- export { ut as OrdersByType, Bt as OverviewDetail, ur as SalesEvolution, Nr as SalesForecast, We as getDateRange, _e as getPeriodLabel, Ee as getPeriodSuffix, It as useOverviewDetailState };
47
+ export { yt as OrdersByType, Rt as OverviewDetail, yr as SalesEvolution, Yr as SalesForecast, Ee as getDateRange, Ne as getPeriodLabel, $e as getPeriodSuffix, Ft as useOverviewDetailState };
47
48
  //# sourceMappingURL=index.js.map