@zydon/common 2.9.34 → 2.9.36

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.
@@ -0,0 +1,6 @@
1
+ import i from 'dayjs';
2
+
3
+ var A=(o=>(o.DAILY="DAILY",o.WEEKLY="WEEKLY",o.MONTHLY="MONTHLY",o.CUSTOM="CUSTOM",o))(A||{}),E=(d=>(d.SUNDAY="SUNDAY",d.MONDAY="MONDAY",d.TUESDAY="TUESDAY",d.WEDNESDAY="WEDNESDAY",d.THURSDAY="THURSDAY",d.FRIDAY="FRIDAY",d.SATURDAY="SATURDAY",d))(E||{}),s=(a=>(a.FIXED_DAY="FIXED_DAY",a.SPECIFIC_DAY="SPECIFIC_DAY",a))(s||{}),g=(r=>(r.DAYS="DAYS",r.WEEKS="WEEKS",r.MONTHS="MONTHS",r))(g||{}),c=(t=>(t.ORDER_PLACED="ORDER_PLACED",t.ORDER_UNPLANNED="ORDER_UNPLANNED",t.ORDER_PLANNED="ORDER_PLANNED",t.SHOPPING_CART_ACTIVE="SHOPPING_CART_ACTIVE",t.SHOPPING_CART_ABANDONED="SHOPPING_CART_ABANDONED",t))(c||{}),P=(o=>(o.SALE="SALE",o.ORDER="ORDER",o.SHOPPING_CART="SHOPPING_CART",o.ORDER_PROJECTION="ORDER_PROJECTION",o))(P||{}),F=(r=>(r.PAST="PAST",r.TODAY="TODAY",r.FUTURE="FUTURE",r))(F||{}),R=(a=>(a.DAY="DAY",a.WEEK="WEEK",a))(R||{}),l="YYYY-MM-DD",T=350,_=2,u=3,O="partner",S=216,Y=170,p=160,C=e=>`day-${e}`,I=(e,n)=>{if(n===7){let D=e.startOf("week"),d=D.add(6,"day");return {period:"OTHER",start_date:D.format(l),end_date:d.format(l)}}let a=Math.floor((n-1)/2),r=Math.ceil((n-1)/2),o=e.subtract(a,"day"),t=e.add(r,"day");return {period:"OTHER",start_date:o.format(l),end_date:t.format(l)}},f=(e,n)=>{let a=i(e),r=i(n),o=[],t=a;for(;t.isBefore(r)||t.isSame(r,"day");)o.push(t),t=t.add(1,"day");return o},b={["SUNDAY"]:"Domingo",["MONDAY"]:"Segunda",["TUESDAY"]:"Ter\xE7a",["WEDNESDAY"]:"Quarta",["THURSDAY"]:"Quinta",["FRIDAY"]:"Sexta",["SATURDAY"]:"S\xE1bado"},L=e=>{if(!e)return "N\xE3o definida";let{frequency:n,days_of_week:a}=e;switch(n){case"DAILY":return "Diariamente";case"WEEKLY":{if(!a||a.length===0)return "Semanalmente";let r=a.map(D=>b[D]);if(r.length===1)return r[0];let o=r[r.length-1];return `${r.slice(0,-1).join(", ")} e ${o}`}case"MONTHLY":return "Mensalmente";case"CUSTOM":return "Personalizada";default:return "N\xE3o definida"}},m=e=>{let n=i(e).startOf("day"),a=i().startOf("day");return n.isBefore(a)?{period:"PAST"}:n.isSame(a)?{period:"TODAY"}:{period:"FUTURE"}},H=(e,n)=>e==="ORDER_PLACED"?{label:"Pedido realizado",labelPlural:"Pedidos realizados",background:"linear-gradient(0deg, rgba(34, 197, 94, 0.08) 0%, rgba(34, 197, 94, 0.08) 100%), #FFF",color:"#065E49",backgroundHover:"linear-gradient(0deg, rgba(34, 197, 94, 0.20) 0%, rgba(34, 197, 94, 0.20) 100%), #FFF"}:e==="ORDER_UNPLANNED"?{label:"Pedido fora do padr\xE3o",labelPlural:"Pedidos fora do padr\xE3o",background:"linear-gradient(0deg, rgba(0, 184, 217, 0.12) 0%, rgba(0, 184, 217, 0.12) 100%), #FFF",color:"#003768",backgroundHover:"linear-gradient(0deg, rgba(0, 184, 217, 0.24) 0%, rgba(0, 184, 217, 0.24) 100%), #FFF"}:e==="SHOPPING_CART_ACTIVE"?{label:"Pedido em andamento",labelPlural:"Pedidos em andamento",background:"linear-gradient(0deg, rgba(255, 171, 0, 0.12) 0%, rgba(255, 171, 0, 0.12) 100%), #FFF",color:"#7A4100",backgroundHover:"linear-gradient(0deg, rgba(255, 171, 0, 0.20) 0%, rgba(255, 171, 0, 0.20) 100%), #FFF",iconBadgeColor:"#FFAB00"}:e==="SHOPPING_CART_ABANDONED"?{label:"Carrinho abandonado",labelPlural:"Carrinhos abandonados",background:"linear-gradient(0deg, rgba(255, 86, 48, 0.12) 0%, rgba(255, 86, 48, 0.12) 100%), #FFF",color:"#7A0916",backgroundHover:"linear-gradient(0deg, rgba(255, 86, 48, 0.24) 0%, rgba(255, 86, 48, 0.24) 100%), #FFF",iconBadgeColor:"#FF5630"}:e==="ORDER_PLANNED"?n==="PAST"?{label:"Pedido n\xE3o realizado",labelPlural:"Pedidos n\xE3o realizados",background:"linear-gradient(0deg, rgba(255, 86, 48, 0.12) 0%, rgba(255, 86, 48, 0.12) 100%), #FFF",color:"#7A0916",backgroundHover:"linear-gradient(0deg, rgba(255, 86, 48, 0.24) 0%, rgba(255, 86, 48, 0.24) 100%), #FFF",iconBadgeColor:"#FF5630"}:n==="TODAY"?{label:"Pedido previsto para hoje",labelPlural:"Pedidos previstos para hoje",background:"linear-gradient(0deg, rgba(255, 171, 0, 0.12) 0%, rgba(255, 171, 0, 0.12) 100%), #FFF",color:"#7A4100",backgroundHover:"linear-gradient(0deg, rgba(255, 171, 0, 0.20) 0%, rgba(255, 171, 0, 0.20) 100%), #FFF",iconBadgeColor:"#FFAB00"}:{label:"Pedido previsto",labelPlural:"Pedidos previstos",background:"linear-gradient(0deg, rgba(145, 158, 171, 0.08) 0%, rgba(145, 158, 171, 0.08) 100%), #FFF",color:"#1C252E",backgroundHover:"linear-gradient(0deg, #C4CDD5 0%, #C4CDD5 100%), #FFF"}:{label:"Desconhecido",labelPlural:"Desconhecidos",background:"#FFF",color:"#000",backgroundHover:"#FFF"},y={["ORDER_PLACED"]:{label:"Pedido realizado",color:"#22C55E"},["ORDER_UNPLANNED"]:{label:"Pedido fora do padr\xE3o",color:"#00B8D9"},["ORDER_PLANNED"]:{label:"Pedido previsto",color:"#C4CDD5"},["SHOPPING_CART_ACTIVE"]:{label:"Pedido em andamento",color:"#FFAB00"},["SHOPPING_CART_ABANDONED"]:{label:"Carrinho abandonado",color:"#FF5630"}};
4
+
5
+ export { A as a, E as b, s as c, g as d, c as e, P as f, F as g, R as h, T as i, _ as j, u as k, O as l, S as m, Y as n, p as o, C as p, I as q, f as r, L as s, m as t, H as u, y as v };
6
+ //# sourceMappingURL=chunk-OONF23Z2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/orderProjection.ts"],"names":["dayjs","Frequency","DayOfWeek","MontlhyStrategy","CustomUnit","EventType","ExternalOrigin","Period","ViewMode","DATE_FORMAT","SCROLL_END_THRESHOLD","MAX_INDIVIDUAL_EVENTS","MAX_VISIBLE_TOOLTIP_EVENTS","PARTNER_COLUMN_KEY","PARTNER_COLUMN_DEFAULT_WIDTH","PARTNER_COLUMN_MIN_WIDTH","DAY_COLUMN_MIN_WIDTH","getDayColumnKey","index","getDateRange","referenceDate","daysCount","start","end","daysBefore","daysAfter","getDaysInRange","startDate","endDate","days","current","DAY_LABELS","getRecurrenceLabel","recurrence","frequency","days_of_week","selectedDays","day","lastDay","getPeriodInfo","refDate","today","getEventStyles","type","period","EVENT_TYPE_OPTIONS"],"mappings":"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,uFACJ,EAGEA,IAAS,kBACJ,CACL,MAAO,2BACP,YAAa,4BACb,WACE,wFACF,MAAO,UACP,gBACE,uFACJ,EAGEA,IAAS,uBACJ,CACL,MAAO,sBACP,YAAa,uBACb,WACE,wFACF,MAAO,UACP,gBACE,wFACF,eAAgB,SAClB,EAGEA,IAAS,0BACJ,CACL,MAAO,sBACP,YAAa,wBACb,WACE,wFACF,MAAO,UACP,gBACE,wFACF,eAAgB,SAClB,EAGEA,IAAS,gBACPC,IAAW,OACN,CACL,MAAO,0BACP,YAAa,4BACb,WACE,wFACF,MAAO,UACP,gBACE,wFACF,eAAgB,SAClB,EAGEA,IAAW,QACN,CACL,MAAO,4BACP,YAAa,8BACb,WACE,wFACF,MAAO,UACP,gBACE,wFACF,eAAgB,SAClB,EAGK,CACL,MAAO,kBACP,YAAa,oBACb,WACE,4FACF,MAAO,UACP,gBAAiB,uDACnB,EAGK,CACL,MAAO,eACP,YAAa,gBACb,WAAY,OACZ,MAAO,OACP,gBAAiB,MACnB,EAGWC,EAGT,CACF,CAAC,cAAsB,EAAG,CACxB,MAAO,mBACP,MAAO,SACT,EACA,CAAC,iBAAyB,EAAG,CAC3B,MAAO,2BACP,MAAO,SACT,EACA,CAAC,eAAuB,EAAG,CACzB,MAAO,kBACP,MAAO,SACT,EACA,CAAC,sBAA8B,EAAG,CAChC,MAAO,sBACP,MAAO,SACT,EACA,CAAC,yBAAiC,EAAG,CACnC,MAAO,sBACP,MAAO,SACT,CACF","sourcesContent":["import dayjs from 'dayjs';\n\nimport { FilterDateState } from 'types/analytics';\nimport { EventStyles, Recurrence } from 'types/orderProjection';\nimport { FilterPeriod } from 'utils/analytics';\n\nexport enum Frequency {\n DAILY = 'DAILY',\n WEEKLY = 'WEEKLY',\n MONTHLY = 'MONTHLY',\n CUSTOM = 'CUSTOM',\n}\n\nexport enum DayOfWeek {\n SUNDAY = 'SUNDAY',\n MONDAY = 'MONDAY',\n TUESDAY = 'TUESDAY',\n WEDNESDAY = 'WEDNESDAY',\n THURSDAY = 'THURSDAY',\n FRIDAY = 'FRIDAY',\n SATURDAY = 'SATURDAY',\n}\n\nexport enum MontlhyStrategy {\n FIXED_DAY = 'FIXED_DAY',\n SPECIFIC_DAY = 'SPECIFIC_DAY',\n}\n\nexport enum CustomUnit {\n DAYS = 'DAYS',\n WEEKS = 'WEEKS',\n MONTHS = 'MONTHS',\n}\n\nexport enum EventType {\n ORDER_PLACED = 'ORDER_PLACED',\n ORDER_UNPLANNED = 'ORDER_UNPLANNED',\n ORDER_PLANNED = 'ORDER_PLANNED',\n SHOPPING_CART_ACTIVE = 'SHOPPING_CART_ACTIVE',\n SHOPPING_CART_ABANDONED = 'SHOPPING_CART_ABANDONED',\n}\n\nexport enum ExternalOrigin {\n SALE = 'SALE',\n ORDER = 'ORDER',\n SHOPPING_CART = 'SHOPPING_CART',\n ORDER_PROJECTION = 'ORDER_PROJECTION',\n}\n\nexport enum Period {\n PAST = 'PAST',\n TODAY = 'TODAY',\n FUTURE = 'FUTURE',\n}\n\nexport enum ViewMode {\n DAY = 'DAY',\n WEEK = 'WEEK',\n}\n\nconst DATE_FORMAT = 'YYYY-MM-DD';\n\nexport const SCROLL_END_THRESHOLD = 350;\n\nexport const MAX_INDIVIDUAL_EVENTS = 2;\n\nexport const MAX_VISIBLE_TOOLTIP_EVENTS = 3;\n\nexport const PARTNER_COLUMN_KEY = 'partner';\n\nexport const PARTNER_COLUMN_DEFAULT_WIDTH = 216;\n\nexport const PARTNER_COLUMN_MIN_WIDTH = 170;\n\nexport const DAY_COLUMN_MIN_WIDTH = 160;\n\nexport const getDayColumnKey = (index: number): string => `day-${index}`;\n\nexport const getDateRange = (\n referenceDate: dayjs.Dayjs,\n daysCount: number,\n): FilterDateState => {\n if (daysCount === 7) {\n const start = referenceDate.startOf('week');\n const end = start.add(6, 'day');\n\n return {\n period: FilterPeriod.OTHER,\n start_date: start.format(DATE_FORMAT),\n end_date: end.format(DATE_FORMAT),\n };\n }\n\n const daysBefore = Math.floor((daysCount - 1) / 2);\n const daysAfter = Math.ceil((daysCount - 1) / 2);\n\n const start = referenceDate.subtract(daysBefore, 'day');\n const end = referenceDate.add(daysAfter, 'day');\n\n return {\n period: FilterPeriod.OTHER,\n start_date: start.format(DATE_FORMAT),\n end_date: end.format(DATE_FORMAT),\n };\n};\n\nexport const getDaysInRange = (\n startDate: string,\n endDate: string,\n): dayjs.Dayjs[] => {\n const start = dayjs(startDate);\n const end = dayjs(endDate);\n const days: dayjs.Dayjs[] = [];\n\n let current = start;\n\n while (current.isBefore(end) || current.isSame(end, 'day')) {\n days.push(current);\n current = current.add(1, 'day');\n }\n\n return days;\n};\n\nconst DAY_LABELS: Record<DayOfWeek, string> = {\n [DayOfWeek.SUNDAY]: 'Domingo',\n [DayOfWeek.MONDAY]: 'Segunda',\n [DayOfWeek.TUESDAY]: 'Terça',\n [DayOfWeek.WEDNESDAY]: 'Quarta',\n [DayOfWeek.THURSDAY]: 'Quinta',\n [DayOfWeek.FRIDAY]: 'Sexta',\n [DayOfWeek.SATURDAY]: 'Sábado',\n};\n\nexport const getRecurrenceLabel = (recurrence?: Recurrence): string => {\n if (!recurrence) return 'Não definida';\n\n const { frequency, days_of_week } = recurrence;\n\n switch (frequency) {\n case Frequency.DAILY:\n return 'Diariamente';\n\n case Frequency.WEEKLY: {\n if (!days_of_week || days_of_week.length === 0) {\n return 'Semanalmente';\n }\n\n const selectedDays = days_of_week.map(day => DAY_LABELS[day]);\n\n if (selectedDays.length === 1) {\n return selectedDays[0];\n }\n\n const lastDay = selectedDays[selectedDays.length - 1];\n const otherDays = selectedDays.slice(0, -1).join(', ');\n return `${otherDays} e ${lastDay}`;\n }\n\n case Frequency.MONTHLY:\n return 'Mensalmente';\n\n case Frequency.CUSTOM:\n return 'Personalizada';\n\n default:\n return 'Não definida';\n }\n};\n\nexport const getPeriodInfo = (referenceDate: Date): { period: Period } => {\n const refDate = dayjs(referenceDate).startOf('day');\n const today = dayjs().startOf('day');\n\n if (refDate.isBefore(today)) return { period: Period.PAST };\n if (refDate.isSame(today)) return { period: Period.TODAY };\n\n return { period: Period.FUTURE };\n};\n\nexport const getEventStyles = (\n type?: EventType,\n period?: Period,\n): EventStyles => {\n if (type === EventType.ORDER_PLACED) {\n return {\n label: 'Pedido realizado',\n labelPlural: 'Pedidos realizados',\n background:\n 'linear-gradient(0deg, rgba(34, 197, 94, 0.08) 0%, rgba(34, 197, 94, 0.08) 100%), #FFF',\n color: '#065E49',\n backgroundHover:\n 'linear-gradient(0deg, rgba(34, 197, 94, 0.20) 0%, rgba(34, 197, 94, 0.20) 100%), #FFF',\n };\n }\n\n if (type === EventType.ORDER_UNPLANNED) {\n return {\n label: 'Pedido fora do padrão',\n labelPlural: 'Pedidos fora do padrão',\n background:\n 'linear-gradient(0deg, rgba(0, 184, 217, 0.12) 0%, rgba(0, 184, 217, 0.12) 100%), #FFF',\n color: '#003768',\n backgroundHover:\n 'linear-gradient(0deg, rgba(0, 184, 217, 0.24) 0%, rgba(0, 184, 217, 0.24) 100%), #FFF',\n };\n }\n\n if (type === EventType.SHOPPING_CART_ACTIVE) {\n return {\n label: 'Pedido em andamento',\n labelPlural: 'Pedidos em andamento',\n background:\n 'linear-gradient(0deg, rgba(255, 171, 0, 0.12) 0%, rgba(255, 171, 0, 0.12) 100%), #FFF',\n color: '#7A4100',\n backgroundHover:\n 'linear-gradient(0deg, rgba(255, 171, 0, 0.20) 0%, rgba(255, 171, 0, 0.20) 100%), #FFF',\n iconBadgeColor: '#FFAB00',\n };\n }\n\n if (type === EventType.SHOPPING_CART_ABANDONED) {\n return {\n label: 'Carrinho abandonado',\n labelPlural: 'Carrinhos abandonados',\n background:\n 'linear-gradient(0deg, rgba(255, 86, 48, 0.12) 0%, rgba(255, 86, 48, 0.12) 100%), #FFF',\n color: '#7A0916',\n backgroundHover:\n 'linear-gradient(0deg, rgba(255, 86, 48, 0.24) 0%, rgba(255, 86, 48, 0.24) 100%), #FFF',\n iconBadgeColor: '#FF5630',\n };\n }\n\n if (type === EventType.ORDER_PLANNED) {\n if (period === Period.PAST) {\n return {\n label: 'Pedido não realizado',\n labelPlural: 'Pedidos não realizados',\n background:\n 'linear-gradient(0deg, rgba(255, 86, 48, 0.12) 0%, rgba(255, 86, 48, 0.12) 100%), #FFF',\n color: '#7A0916',\n backgroundHover:\n 'linear-gradient(0deg, rgba(255, 86, 48, 0.24) 0%, rgba(255, 86, 48, 0.24) 100%), #FFF',\n iconBadgeColor: '#FF5630',\n };\n }\n\n if (period === Period.TODAY) {\n return {\n label: 'Pedido previsto para hoje',\n labelPlural: 'Pedidos previstos para hoje',\n background:\n 'linear-gradient(0deg, rgba(255, 171, 0, 0.12) 0%, rgba(255, 171, 0, 0.12) 100%), #FFF',\n color: '#7A4100',\n backgroundHover:\n 'linear-gradient(0deg, rgba(255, 171, 0, 0.20) 0%, rgba(255, 171, 0, 0.20) 100%), #FFF',\n iconBadgeColor: '#FFAB00',\n };\n }\n\n return {\n label: 'Pedido previsto',\n labelPlural: 'Pedidos previstos',\n background:\n 'linear-gradient(0deg, rgba(145, 158, 171, 0.08) 0%, rgba(145, 158, 171, 0.08) 100%), #FFF',\n color: '#1C252E',\n backgroundHover: 'linear-gradient(0deg, #C4CDD5 0%, #C4CDD5 100%), #FFF',\n };\n }\n\n return {\n label: 'Desconhecido',\n labelPlural: 'Desconhecidos',\n background: '#FFF',\n color: '#000',\n backgroundHover: '#FFF',\n };\n};\n\nexport const EVENT_TYPE_OPTIONS: Record<\n EventType,\n { label: string; color: string }\n> = {\n [EventType.ORDER_PLACED]: {\n label: 'Pedido realizado',\n color: '#22C55E',\n },\n [EventType.ORDER_UNPLANNED]: {\n label: 'Pedido fora do padrão',\n color: '#00B8D9',\n },\n [EventType.ORDER_PLANNED]: {\n label: 'Pedido previsto',\n color: '#C4CDD5',\n },\n [EventType.SHOPPING_CART_ACTIVE]: {\n label: 'Pedido em andamento',\n color: '#FFAB00',\n },\n [EventType.SHOPPING_CART_ABANDONED]: {\n label: 'Carrinho abandonado',\n color: '#FF5630',\n },\n};\n"]}
@@ -0,0 +1,9 @@
1
+ import { q } from './chunk-OONF23Z2.js';
2
+ import { b } from './chunk-TXJ45CNA.js';
3
+ import { useRef, useState, useMemo, useCallback } from 'react';
4
+ import D from 'dayjs';
5
+
6
+ var L=()=>{let u=b("down","sm"),P=b("down","md"),v=b("down","lg"),O=b("down","xl"),m=useRef(null),[g,f]=useState(()=>D()),[h,R]=useState([]),[S,T]=useState([]),[o,j]=useState([]),[r,w]=useState([]),[y,M]=useState(!0),[b$1,F]=useState("WEEK"),i=useMemo(()=>h.map(t=>t.id),[h]),l=useMemo(()=>S.map(t=>t.id),[S]),_=u?"DAY":b$1,a=useMemo(()=>u||_==="DAY"?1:P?3:v?4:O?5:7,[u,P,v,O,_]),n=useMemo(()=>q(g,a),[g,a]),E=useMemo(()=>({start_date:n.start_date,end_date:n.end_date,...i.length>0?{partner_ids:i}:{},...o.length>0?{event_types:o}:{},...l.length>0?{profile_ids:l}:{},...r.length>0?{classifications:r}:{},ascending:y}),[n.start_date,n.end_date,i,o,l,r,y]),k=useMemo(()=>({start_date:n.start_date,end_date:n.end_date,...i.length>0?{partner_ids:i}:{},...l.length>0?{profile_ids:l}:{},...o.length>0?{event_types:o}:{},...r.length>0?{classifications:r}:{}}),[n.start_date,n.end_date,i,l,o,r]),e=useCallback(()=>{m.current&&(m.current.scrollTop=0);},[]),A=useCallback(t=>{f(t),e();},[e]),q$1=useCallback(()=>{f(t=>t.subtract(a,"day")),e();},[e,a]),x=useCallback(()=>{f(t=>t.add(a,"day")),e();},[e,a]),V=useCallback(()=>{f(D()),e();},[e]),W=useCallback(t=>{R(t),e();},[e]),B=useCallback(t=>{j(t),e();},[e]),I=useCallback(t=>{T(t),e();},[e]),Y=useCallback(t=>{w(t),e();},[e]),H=useCallback(t=>{M(t),e();},[e]);return {scrollRef:m,baseDate:g,dateRange:n,visibleDays:a,handleBaseDateChange:A,handlePreviousWeek:q$1,handleNextWeek:x,handleToday:V,selectedPartners:h,setSelectedPartners:W,selectedEventTypes:o,setSelectedEventTypes:B,selectedProfiles:S,setSelectedProfiles:I,selectedClassifications:r,setSelectedClassifications:Y,ascending:y,setAscending:H,viewMode:_,setViewMode:F,params:E,summaryParams:k,scrollToTop:e}},J=L;
7
+
8
+ export { J as a };
9
+ //# sourceMappingURL=chunk-SRP3UTFW.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/useOrderProjectionFilters.ts"],"names":["useCallback","useMemo","useRef","useState","dayjs","useOrderProjectionFilters","isMobile","useResponsive_default","isTablet","isSmallDesktop","isDesktop","scrollRef","baseDate","setBaseDate","selectedPartners","setSelectedPartners","selectedProfiles","setSelectedProfiles","selectedEventTypes","setSelectedEventTypes","selectedClassifications","setSelectedClassifications","ascending","setAscending","viewMode","setViewMode","partnerIds","p","profileIds","effectiveViewMode","visibleDays","dateRange","getDateRange","params","summaryParams","scrollToTop","handleBaseDateChange","date","handlePreviousWeek","prev","handleNextWeek","handleToday","handleSelectedPartnersChange","value","handleSelectedEventTypesChange","handleSelectedProfilesChange","handleSelectedClassificationsChange","handleAscendingChange","useOrderProjectionFilters_default"],"mappings":"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","sourcesContent":["import { useCallback, useMemo, useRef, useState } from 'react';\nimport dayjs from 'dayjs';\n\nimport {\n OrderProjectionRequest,\n OrderProjectionSummaryRequest,\n SelectedFilterOption,\n} from 'hooks/useOrderProjectionFilters.types';\nimport useResponsive from 'hooks/useResponsive';\nimport { ViewMode } from 'types/orderProjection';\nimport { getDateRange } from 'utils/orderProjection';\n\nconst useOrderProjectionFilters = () => {\n const isMobile = useResponsive('down', 'sm');\n const isTablet = useResponsive('down', 'md');\n const isSmallDesktop = useResponsive('down', 'lg');\n const isDesktop = useResponsive('down', 'xl');\n const scrollRef = useRef<HTMLDivElement>(null);\n\n const [baseDate, setBaseDate] = useState(() => dayjs());\n const [selectedPartners, setSelectedPartners] = useState<SelectedFilterOption[]>(\n [],\n );\n const [selectedProfiles, setSelectedProfiles] = useState<SelectedFilterOption[]>(\n [],\n );\n const [selectedEventTypes, setSelectedEventTypes] = useState<string[]>([]);\n const [selectedClassifications, setSelectedClassifications] = useState<\n string[]\n >([]);\n\n const [ascending, setAscending] = useState<boolean>(true);\n const [viewMode, setViewMode] = useState<ViewMode>(ViewMode.WEEK);\n\n const partnerIds = useMemo(\n () => selectedPartners.map(p => p.id),\n [selectedPartners],\n );\n\n const profileIds = useMemo(\n () => selectedProfiles.map(p => p.id),\n [selectedProfiles],\n );\n\n const effectiveViewMode = isMobile ? ViewMode.DAY : viewMode;\n\n const visibleDays = useMemo(() => {\n if (isMobile || effectiveViewMode === ViewMode.DAY) return 1;\n if (isTablet) return 3;\n if (isSmallDesktop) return 4;\n if (isDesktop) return 5;\n return 7;\n }, [isMobile, isTablet, isSmallDesktop, isDesktop, effectiveViewMode]);\n\n const dateRange = useMemo(\n () => getDateRange(baseDate, visibleDays),\n [baseDate, visibleDays],\n );\n\n const params = useMemo<OrderProjectionRequest>(\n () => ({\n start_date: dateRange.start_date,\n end_date: dateRange.end_date,\n ...(partnerIds.length > 0 ? { partner_ids: partnerIds } : {}),\n ...(selectedEventTypes.length > 0\n ? { event_types: selectedEventTypes }\n : {}),\n ...(profileIds.length > 0 ? { profile_ids: profileIds } : {}),\n ...(selectedClassifications.length > 0\n ? { classifications: selectedClassifications }\n : {}),\n ascending,\n }),\n [\n dateRange.start_date,\n dateRange.end_date,\n partnerIds,\n selectedEventTypes,\n profileIds,\n selectedClassifications,\n ascending,\n ],\n );\n\n const summaryParams = useMemo<OrderProjectionSummaryRequest>(\n () => ({\n start_date: dateRange.start_date,\n end_date: dateRange.end_date,\n ...(partnerIds.length > 0 ? { partner_ids: partnerIds } : {}),\n ...(profileIds.length > 0 ? { profile_ids: profileIds } : {}),\n ...(selectedEventTypes.length > 0\n ? { event_types: selectedEventTypes }\n : {}),\n ...(selectedClassifications.length > 0\n ? { classifications: selectedClassifications }\n : {}),\n }),\n [\n dateRange.start_date,\n dateRange.end_date,\n partnerIds,\n profileIds,\n selectedEventTypes,\n selectedClassifications,\n ],\n );\n\n const scrollToTop = useCallback(() => {\n if (scrollRef.current) {\n scrollRef.current.scrollTop = 0;\n }\n }, []);\n\n const handleBaseDateChange = useCallback(\n (date: dayjs.Dayjs) => {\n setBaseDate(date);\n scrollToTop();\n },\n [scrollToTop],\n );\n\n const handlePreviousWeek = useCallback(() => {\n setBaseDate(prev => prev.subtract(visibleDays, 'day'));\n scrollToTop();\n }, [scrollToTop, visibleDays]);\n\n const handleNextWeek = useCallback(() => {\n setBaseDate(prev => prev.add(visibleDays, 'day'));\n scrollToTop();\n }, [scrollToTop, visibleDays]);\n\n const handleToday = useCallback(() => {\n setBaseDate(dayjs());\n scrollToTop();\n }, [scrollToTop]);\n\n const handleSelectedPartnersChange = useCallback(\n (value: SelectedFilterOption[]) => {\n setSelectedPartners(value);\n scrollToTop();\n },\n [scrollToTop],\n );\n\n const handleSelectedEventTypesChange = useCallback(\n (value: string[]) => {\n setSelectedEventTypes(value);\n scrollToTop();\n },\n [scrollToTop],\n );\n\n const handleSelectedProfilesChange = useCallback(\n (value: SelectedFilterOption[]) => {\n setSelectedProfiles(value);\n scrollToTop();\n },\n [scrollToTop],\n );\n\n const handleSelectedClassificationsChange = useCallback(\n (value: string[]) => {\n setSelectedClassifications(value);\n scrollToTop();\n },\n [scrollToTop],\n );\n\n const handleAscendingChange = useCallback(\n (value: boolean) => {\n setAscending(value);\n scrollToTop();\n },\n [scrollToTop],\n );\n\n return {\n scrollRef,\n\n baseDate,\n dateRange,\n visibleDays,\n handleBaseDateChange,\n handlePreviousWeek,\n handleNextWeek,\n handleToday,\n\n selectedPartners,\n setSelectedPartners: handleSelectedPartnersChange,\n\n selectedEventTypes,\n setSelectedEventTypes: handleSelectedEventTypesChange,\n\n selectedProfiles,\n setSelectedProfiles: handleSelectedProfilesChange,\n\n selectedClassifications,\n setSelectedClassifications: handleSelectedClassificationsChange,\n\n ascending,\n setAscending: handleAscendingChange,\n\n viewMode: effectiveViewMode,\n setViewMode,\n\n params,\n summaryParams,\n\n scrollToTop,\n };\n};\n\nexport type UseOrderProjectionFiltersReturn = ReturnType<\n typeof useOrderProjectionFilters\n>;\n\nexport default useOrderProjectionFilters;\n"]}
1
+ {"version":3,"sources":["../src/hooks/useOrderProjectionFilters.ts"],"names":["useCallback","useMemo","useRef","useState","dayjs","useOrderProjectionFilters","isMobile","useResponsive_default","isTablet","isSmallDesktop","isDesktop","scrollRef","baseDate","setBaseDate","selectedPartners","setSelectedPartners","selectedProfiles","setSelectedProfiles","selectedEventTypes","setSelectedEventTypes","selectedClassifications","setSelectedClassifications","ascending","setAscending","viewMode","setViewMode","partnerIds","p","profileIds","effectiveViewMode","visibleDays","dateRange","getDateRange","params","summaryParams","scrollToTop","handleBaseDateChange","date","handlePreviousWeek","prev","handleNextWeek","handleToday","handleSelectedPartnersChange","value","handleSelectedEventTypesChange","handleSelectedProfilesChange","handleSelectedClassificationsChange","handleAscendingChange","useOrderProjectionFilters_default"],"mappings":"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","sourcesContent":["import { useCallback, useMemo, useRef, useState } from 'react';\nimport dayjs from 'dayjs';\n\nimport {\n OrderProjectionRequest,\n OrderProjectionSummaryRequest,\n SelectedFilterOption,\n} from 'hooks/useOrderProjectionFilters.types';\nimport useResponsive from 'hooks/useResponsive';\nimport { ViewMode } from 'utils/orderProjection';\nimport { getDateRange } from 'utils/orderProjection';\n\nconst useOrderProjectionFilters = () => {\n const isMobile = useResponsive('down', 'sm');\n const isTablet = useResponsive('down', 'md');\n const isSmallDesktop = useResponsive('down', 'lg');\n const isDesktop = useResponsive('down', 'xl');\n const scrollRef = useRef<HTMLDivElement>(null);\n\n const [baseDate, setBaseDate] = useState(() => dayjs());\n const [selectedPartners, setSelectedPartners] = useState<SelectedFilterOption[]>(\n [],\n );\n const [selectedProfiles, setSelectedProfiles] = useState<SelectedFilterOption[]>(\n [],\n );\n const [selectedEventTypes, setSelectedEventTypes] = useState<string[]>([]);\n const [selectedClassifications, setSelectedClassifications] = useState<\n string[]\n >([]);\n\n const [ascending, setAscending] = useState<boolean>(true);\n const [viewMode, setViewMode] = useState<ViewMode>(ViewMode.WEEK);\n\n const partnerIds = useMemo(\n () => selectedPartners.map(p => p.id),\n [selectedPartners],\n );\n\n const profileIds = useMemo(\n () => selectedProfiles.map(p => p.id),\n [selectedProfiles],\n );\n\n const effectiveViewMode = isMobile ? ViewMode.DAY : viewMode;\n\n const visibleDays = useMemo(() => {\n if (isMobile || effectiveViewMode === ViewMode.DAY) return 1;\n if (isTablet) return 3;\n if (isSmallDesktop) return 4;\n if (isDesktop) return 5;\n return 7;\n }, [isMobile, isTablet, isSmallDesktop, isDesktop, effectiveViewMode]);\n\n const dateRange = useMemo(\n () => getDateRange(baseDate, visibleDays),\n [baseDate, visibleDays],\n );\n\n const params = useMemo<OrderProjectionRequest>(\n () => ({\n start_date: dateRange.start_date,\n end_date: dateRange.end_date,\n ...(partnerIds.length > 0 ? { partner_ids: partnerIds } : {}),\n ...(selectedEventTypes.length > 0\n ? { event_types: selectedEventTypes }\n : {}),\n ...(profileIds.length > 0 ? { profile_ids: profileIds } : {}),\n ...(selectedClassifications.length > 0\n ? { classifications: selectedClassifications }\n : {}),\n ascending,\n }),\n [\n dateRange.start_date,\n dateRange.end_date,\n partnerIds,\n selectedEventTypes,\n profileIds,\n selectedClassifications,\n ascending,\n ],\n );\n\n const summaryParams = useMemo<OrderProjectionSummaryRequest>(\n () => ({\n start_date: dateRange.start_date,\n end_date: dateRange.end_date,\n ...(partnerIds.length > 0 ? { partner_ids: partnerIds } : {}),\n ...(profileIds.length > 0 ? { profile_ids: profileIds } : {}),\n ...(selectedEventTypes.length > 0\n ? { event_types: selectedEventTypes }\n : {}),\n ...(selectedClassifications.length > 0\n ? { classifications: selectedClassifications }\n : {}),\n }),\n [\n dateRange.start_date,\n dateRange.end_date,\n partnerIds,\n profileIds,\n selectedEventTypes,\n selectedClassifications,\n ],\n );\n\n const scrollToTop = useCallback(() => {\n if (scrollRef.current) {\n scrollRef.current.scrollTop = 0;\n }\n }, []);\n\n const handleBaseDateChange = useCallback(\n (date: dayjs.Dayjs) => {\n setBaseDate(date);\n scrollToTop();\n },\n [scrollToTop],\n );\n\n const handlePreviousWeek = useCallback(() => {\n setBaseDate(prev => prev.subtract(visibleDays, 'day'));\n scrollToTop();\n }, [scrollToTop, visibleDays]);\n\n const handleNextWeek = useCallback(() => {\n setBaseDate(prev => prev.add(visibleDays, 'day'));\n scrollToTop();\n }, [scrollToTop, visibleDays]);\n\n const handleToday = useCallback(() => {\n setBaseDate(dayjs());\n scrollToTop();\n }, [scrollToTop]);\n\n const handleSelectedPartnersChange = useCallback(\n (value: SelectedFilterOption[]) => {\n setSelectedPartners(value);\n scrollToTop();\n },\n [scrollToTop],\n );\n\n const handleSelectedEventTypesChange = useCallback(\n (value: string[]) => {\n setSelectedEventTypes(value);\n scrollToTop();\n },\n [scrollToTop],\n );\n\n const handleSelectedProfilesChange = useCallback(\n (value: SelectedFilterOption[]) => {\n setSelectedProfiles(value);\n scrollToTop();\n },\n [scrollToTop],\n );\n\n const handleSelectedClassificationsChange = useCallback(\n (value: string[]) => {\n setSelectedClassifications(value);\n scrollToTop();\n },\n [scrollToTop],\n );\n\n const handleAscendingChange = useCallback(\n (value: boolean) => {\n setAscending(value);\n scrollToTop();\n },\n [scrollToTop],\n );\n\n return {\n scrollRef,\n\n baseDate,\n dateRange,\n visibleDays,\n handleBaseDateChange,\n handlePreviousWeek,\n handleNextWeek,\n handleToday,\n\n selectedPartners,\n setSelectedPartners: handleSelectedPartnersChange,\n\n selectedEventTypes,\n setSelectedEventTypes: handleSelectedEventTypesChange,\n\n selectedProfiles,\n setSelectedProfiles: handleSelectedProfilesChange,\n\n selectedClassifications,\n setSelectedClassifications: handleSelectedClassificationsChange,\n\n ascending,\n setAscending: handleAscendingChange,\n\n viewMode: effectiveViewMode,\n setViewMode,\n\n params,\n summaryParams,\n\n scrollToTop,\n };\n};\n\nexport type UseOrderProjectionFiltersReturn = ReturnType<\n typeof useOrderProjectionFilters\n>;\n\nexport default useOrderProjectionFilters;\n"]}
@@ -1,12 +1,12 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { Partner, OrderProjectionSummary, OrderProjectionEvent, PartnerDetails, PartnerOrder, PartnerSaleSummary, Event, PartnerAddress } from '../../../types/orderProjection.js';
2
+ import { P as Partner, O as OrderProjectionSummary, a as OrderProjectionEvent, b as PartnerDetails, c as PartnerOrder, d as PartnerSaleSummary, E as Event, e as PartnerAddress } from '../../../orderProjection-c6f4f71e.js';
3
3
  import { UseOrderProjectionFiltersReturn } from '../../../hooks/useOrderProjectionFilters.js';
4
4
  import { ReactNode } from 'react';
5
5
  import { GridQuery } from '../../../types/filter.js';
6
- import '../../../utils/partnerAnalysis.js';
6
+ import 'dayjs';
7
7
  import '../../../types/analytics.js';
8
8
  import '../../../utils/analytics.js';
9
- import 'dayjs';
9
+ import '../../../utils/partnerAnalysis.js';
10
10
  import '../../../types/entityMetadata.js';
11
11
 
12
12
  interface CalendarProps$1 {
@@ -1,33 +1,32 @@
1
- import { i, h as h$2 } from '../../../chunk-BBVOF2BY.js';
2
- import { a as a$e } from '../../../chunk-TQFKLNTU.js';
3
- import { d, e as e$2 } from '../../../chunk-K2PWIYEM.js';
4
- import { a as a$h, b as b$2, c as c$1 } from '../../../chunk-U2XWJMVE.js';
1
+ import { i as i$1, h as h$1 } from '../../../chunk-BBVOF2BY.js';
2
+ import { a as a$d } from '../../../chunk-TQFKLNTU.js';
3
+ import { d, e as e$1 } from '../../../chunk-K2PWIYEM.js';
4
+ import { a as a$g, b as b$1, c as c$1 } from '../../../chunk-U2XWJMVE.js';
5
5
  import { a as a$5 } from '../../../chunk-DRGARBKB.js';
6
6
  import '../../../chunk-55XSPNSX.js';
7
- import { a as a$8 } from '../../../chunk-RUABKHIV.js';
8
- import { a as a$d } from '../../../chunk-772DOKEN.js';
9
- import { a as a$c } from '../../../chunk-5N6Y3FIM.js';
10
- import { d as d$1, g as g$1 } from '../../../chunk-2W5FGLTC.js';
7
+ import { a as a$7 } from '../../../chunk-RUABKHIV.js';
8
+ import { a as a$c } from '../../../chunk-772DOKEN.js';
9
+ import { a as a$b } from '../../../chunk-5N6Y3FIM.js';
10
+ import { d as d$1, g } from '../../../chunk-2W5FGLTC.js';
11
11
  import { h } from '../../../chunk-OF6623HG.js';
12
12
  import { a as a$3 } from '../../../chunk-HE2LUROB.js';
13
- import { a as a$g } from '../../../chunk-5J35UAV6.js';
14
- import { a as a$f } from '../../../chunk-4F2NKGF6.js';
13
+ import { a as a$f } from '../../../chunk-5J35UAV6.js';
14
+ import { a as a$e } from '../../../chunk-4F2NKGF6.js';
15
15
  import { a } from '../../../chunk-AZJ3VCNL.js';
16
- import { a as a$j } from '../../../chunk-ZYFY6BCA.js';
17
- import { a as a$b } from '../../../chunk-CO2KQFUN.js';
16
+ import { a as a$i } from '../../../chunk-ZYFY6BCA.js';
17
+ import { a as a$a } from '../../../chunk-CO2KQFUN.js';
18
18
  import { a as a$1 } from '../../../chunk-XT2AH5G2.js';
19
19
  import '../../../chunk-Z6YXPKWP.js';
20
20
  import '../../../chunk-F65ZXAGV.js';
21
- import { a as a$a } from '../../../chunk-E3R7W7GK.js';
22
- import { a as a$4 } from '../../../chunk-HLJGNOJN.js';
23
- import { m, j, d as d$2, f, e as e$1, h as h$1, g, a as a$7, b as b$1, l, k, n, c as c$2 } from '../../../chunk-PTIGK5PS.js';
24
- import { e } from '../../../chunk-QGXT2AUD.js';
21
+ import { a as a$9 } from '../../../chunk-E3R7W7GK.js';
22
+ import { a as a$4 } from '../../../chunk-SRP3UTFW.js';
23
+ import { u, e, r, l, n, m, p, o, i, j, t, s, v, k } from '../../../chunk-OONF23Z2.js';
25
24
  import '../../../chunk-ERLI5GAP.js';
26
- import { a as a$9 } from '../../../chunk-LQRRMVFN.js';
25
+ import { a as a$8 } from '../../../chunk-LQRRMVFN.js';
27
26
  import { a as a$6 } from '../../../chunk-7WUAJEER.js';
28
27
  import { b } from '../../../chunk-TXJ45CNA.js';
29
28
  import { a as a$2 } from '../../../chunk-LFHA3YUV.js';
30
- import { a as a$i } from '../../../chunk-GGJJ3II3.js';
29
+ import { a as a$h } from '../../../chunk-GGJJ3II3.js';
31
30
  import { createContext, memo, useMemo, useContext, useCallback, useRef, useState } from 'react';
32
31
  import vl from '@mui/material/CircularProgress';
33
32
  import Ne from '@mui/material/TableCell';
@@ -55,8 +54,8 @@ import Td from '@mui/material/Checkbox';
55
54
  import bd from '@mui/material/FormControlLabel';
56
55
  import { PickersDay } from '@mui/x-date-pickers/PickersDay';
57
56
 
58
- var wo=styled(Ne,{shouldForwardProp:o=>o!=="cellAlign"})(({theme:o,cellAlign:r="top"})=>({position:"sticky",left:0,zIndex:1,verticalAlign:r,backgroundColor:o.palette.background.paper,[o.breakpoints.down("sm")]:{width:"50%",minWidth:"50%"}})),io=styled(Ne,{shouldForwardProp:o=>o!=="isToday"})(({theme:o,isToday:r})=>({width:"auto",minWidth:"auto",overflow:"hidden",backgroundColor:`${r?o.palette.grey[200]:o.palette.common.white} !important`,verticalAlign:"top"})),Ir=styled(gn)(({theme:o})=>({"& .MuiTableCell-root":{padding:o.spacing(1,2),borderBottom:`1px solid ${o.palette.divider} !important`,borderRight:`1px solid ${o.palette.divider} !important`,"&:last-child":{borderRight:"none !important"}}}));var Me=createContext(null),Tn=({adapters:o,slots:r,children:e})=>{let t=a$4(),a=useMemo(()=>({adapters:o,slots:r,filters:t}),[o,r,t]);return jsx(Me.Provider,{value:a,children:e})},c=()=>{let o=useContext(Me);if(!o)throw new Error("useOrderProjectionContext must be used within an OrderProjectionProvider");return o},x=()=>c().filters;var Fe=styled(a,{shouldForwardProp:o=>o!=="isToday"})(({theme:o,isToday:r})=>({color:r?o.palette.primary.main:o.palette.text.secondary,backgroundColor:r?alpha(o.palette.primary.main,.15):alpha(o.palette.grey[500],.15),cursor:"pointer"}));var Pn=({day:o,summary:r})=>{let e=useMemo(()=>fe().startOf("day"),[]),t=o.isAfter(e,"day"),a=useMemo(()=>{let i=o.format("YYYY-MM-DD"),n=r?.days.find(l=>l.date===i);return {shopping_cart_active:n?.shopping_cart_active??0,order_placed:n?.order_placed??0,order_unplanned:n?.order_unplanned??0,order_planned:n?.order_planned??0,shopping_cart_abandoned:n?.shopping_cart_abandoned??0}},[o,r]);return jsxs(co,{gap:1.5,children:[jsxs(co,{direction:"row",alignItems:"center",gap:1,children:[jsx(a$1,{icon:"CALENDAR_TODAY",color:"grey.400"}),jsx(W,{variant:"caption",fontWeight:"bold",children:"Pedidos"})]}),jsxs(co,{gap:.5,children:[!t&&jsxs(Fragment,{children:[jsxs(W,{variant:"caption",children:["Pedidos em andamento:"," ",jsx("strong",{children:a.shopping_cart_active})]}),jsxs(W,{variant:"caption",children:["Pedidos realizados: ",jsx("strong",{children:a.order_placed})]}),jsxs(W,{variant:"caption",children:["Pedidos fora do padr\xE3o: ",jsx("strong",{children:a.order_unplanned})]})]}),jsxs(W,{variant:"caption",children:["Pedidos previstos: ",jsx("strong",{children:a.order_planned})]}),!t&&jsxs(W,{variant:"caption",children:["Carrinhos abandonados:"," ",jsx("strong",{children:a.shopping_cart_abandoned})]})]})]})},We=Pn;var _n=({day:o,summary:r,isFetchingSummary:e})=>{let t=o.isSame(fe(),"day"),{ordersPlacedCount:a,ordersExpectedCount:i}=useMemo(()=>{let n=o.format("YYYY-MM-DD"),l=r?.days.find(u=>u.date===n),d=l?.order_placed??0,y=l?.order_unplanned??0,f=l?.order_planned??0;return {ordersPlacedCount:d+y,ordersExpectedCount:d+y+f}},[o,r]);return jsx(a$f,{isLoading:e,loading:jsx(Dn,{width:50,height:24}),children:jsx(a$g,{title:jsx(We,{day:o,summary:r}),arrow:!0,children:jsx("span",{children:jsxs(Fe,{variant:"filled",backgroundColor:"#919EAB29",color:"text.secondary",isToday:t,children:[a," de ",i]})})})})},Ge=_n;var An=["Dom.","Seg.","Ter.","Qua.","Qui.","Sex.","S\xE1b."],On=({day:o,index:r,summary:e,isFetchingSummary:t,resize:a})=>{let i=o.isSame(fe(),"day");return jsxs(io,{isToday:i,"data-testid":`day-cell-${r}`,children:[jsxs(co,{direction:"row",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:1,children:[jsxs(co,{children:[jsx(W,{variant:"subtitle2",color:i?"primary.main":"text.secondary",children:o.date()}),jsx(W,{variant:"body2",fontSize:13,color:i?"primary.main":"text.secondary",children:An[o.day()]})]}),jsx(Ge,{day:o,summary:e,isFetchingSummary:t})]}),a&&jsx(a$e,{label:`Redimensionar coluna ${o.format("DD/MM")}`,...a})]})},ze=On;var Nt=styled(wn,{shouldForwardProp:o=>o!=="active"})(({theme:o,active:r})=>({justifyContent:"flex-start",color:r?o.palette.primary.main:o.palette.text.secondary,fontWeight:r?800:400,"&:hover":{background:o.palette.action.hover}}));var Nn=({summary:o})=>jsxs(co,{gap:1.5,children:[jsxs(co,{direction:"row",alignItems:"center",gap:1,children:[jsx(a$1,{icon:"USER_GROUP",color:"grey.400"}),jsx(W,{variant:"caption",fontWeight:"bold",children:"Clientes"})]}),jsx(co,{gap:.5,children:jsxs(W,{variant:"caption",children:["Total de clientes: ",jsx("strong",{children:o?.partner_count??0})]})})]}),Ue=Nn;var Fn=({summary:o,isFetchingSummary:r,resize:e})=>{let{open:t,onClose:a$1,onOpen:i}=a$9(),{ascending:n,setAscending:l}=x(),d=useCallback(y=>{l(y),a$1();},[a$1,l]);return jsxs(Fragment,{children:[jsxs(wo,{cellAlign:"center",children:[jsxs(co,{direction:"row",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:1,children:[jsxs(co,{direction:"row",alignItems:"center",gap:1,children:[jsx(W,{variant:"caption",color:"text.primary",children:"Clientes"}),jsx(a$f,{isLoading:r,loading:jsx(a$8,{width:26,height:24}),children:jsx(a$g,{title:jsx(Ue,{summary:o}),arrow:!0,children:jsx("span",{children:jsx(a,{variant:"filled",backgroundColor:"#919EAB29",color:"text.secondary",sx:{cursor:"pointer"},children:o?.partner_count??0})})})})]}),jsx(a$d,{label:"Selecionar ordena\xE7\xE3o",icon:"SORTING_AZ_02",color:"text.secondary",size:"small",onClick:i})]}),e&&jsx(a$e,{label:"Redimensionar coluna Clientes",...e})]}),jsxs(a$b,{open:t,onClose:a$1,disabledArrow:!0,sx:{width:180,p:1},children:[jsx(Nt,{variant:"text",onClick:()=>d(!0),active:n,fullWidth:!0,children:"De A \xE0 Z"}),jsx(Nt,{variant:"text",onClick:()=>d(!1),active:!n,fullWidth:!0,children:"De Z \xE0 A"})]})]})},qe=Fn;var Qe=styled(Gn)(({theme:o})=>({"& .MuiTableCell-root":{padding:o.spacing(1,2),borderTop:`1px solid ${o.palette.divider} !important`,borderBottom:`1px solid ${o.palette.divider} !important`,borderRight:`1px solid ${o.palette.divider} !important`,background:o.palette.common.white,"&:last-child":{borderRight:"none !important"}},"& .MuiTableCell-root:first-of-type":{zIndex:3}}));var Vn=({days:o,summary:r,isFetchingSummary:e,getColumnResizeProps:t})=>jsx(Qe,{children:jsxs(gn,{children:[jsx(qe,{summary:r,isFetchingSummary:e,resize:t(d$2)}),o.map((a,i)=>jsx(ze,{index:i,day:a,summary:r,isFetchingSummary:e,resize:t(h$1(i))},i))]})}),Xe=Vn;var $n={["PAST"]:{icon:jsx(a$1,{icon:"HEXAGON_WARNING",color:"#FF5630",width:24}),message:jsxs(Fragment,{children:["O cliente deveria ter feito pedido, conforme sua frequ\xEAncia de compra, mas nenhum pedido foi registrado. Esse comportamento pode indicar"," ",jsx("strong",{children:"queda de engajamento"})," ou"," ",jsx("strong",{children:"risco de inativa\xE7\xE3o"}),"."]})},["TODAY"]:{icon:jsx(a$1,{icon:"WARNING_TRIANGLE_SOLID",color:"#FFAB00",width:24}),message:jsx(Fragment,{children:"Conforme a frequ\xEAncia de compra deste cliente, um pedido era esperado hoje, mas nenhum registro foi feito at\xE9 o momento."})},["FUTURE"]:{icon:jsx(a$1,{icon:"INFO",color:"common.black",width:24}),message:jsxs(Fragment,{children:["Baseado na rotina de compras identificada."," ",jsx("strong",{children:"Nenhuma a\xE7\xE3o \xE9 necess\xE1ria no momento"}),"."]})}},Ke={["ORDER_UNPLANNED"]:()=>{let o=m("ORDER_UNPLANNED");return {icon:jsx(a$1,{icon:"INFO",color:"#00B8D9",width:24}),message:jsxs(Fragment,{children:["O cliente realizou um pedido em um dia diferente da sua rotina habitual. Isso pode indicar uma"," ",jsx("strong",{children:"mudan\xE7a de comportamento de compra"})," ou uma"," ",jsx("strong",{children:"demanda excepcional"}),"."]}),background:o.background,color:o.color}},["ORDER_PLANNED"]:({referenceDate:o})=>{let{period:r}=l(o||new Date),e=m("ORDER_PLANNED",r),{icon:t,message:a}=$n[r];return {icon:t,message:a,background:e.background,color:e.color}},["SHOPPING_CART_ACTIVE"]:()=>{let o=m("SHOPPING_CART_ACTIVE");return {icon:jsx(a$1,{icon:"WARNING_TRIANGLE_SOLID",color:"#FFAB00",width:24}),message:jsx(Fragment,{children:"O cliente est\xE1 atualizando o carrinho neste momento."}),background:o.background,color:o.color}},["SHOPPING_CART_ABANDONED"]:({referenceDate:o})=>{let r=m("SHOPPING_CART_ABANDONED");return {icon:jsx(a$1,{icon:"HEXAGON_WARNING",color:"#FF5630",width:24}),message:jsxs(Fragment,{children:["Carrinho est\xE1 abandonado h\xE1 ",jsx("strong",{children:g$1(o)}),"."]}),background:r.background,color:r.color}}};var Je=styled(Un,{shouldForwardProp:o=>o!=="customBackground"&&o!=="customColor"})(({theme:o,customBackground:r,customColor:e})=>({padding:o.spacing(1.5,2),borderRadius:0,borderBottom:`1px solid ${o.palette.divider}`,background:r,color:e}));var qn=({origin:o,referenceDate:r})=>{let e=Ke[o];if(!e)return null;let t=e({origin:o,referenceDate:r});return t?jsx(Je,{icon:t.icon,customBackground:t.background,customColor:t.color,children:t.message}):null},Ze=qn;var Zn=({message:o,onRetry:r,isFetching:e})=>jsxs(co,{alignItems:"center",justifyContent:"center",p:3,gap:.5,children:[jsx(W,{variant:"body2",color:"text.secondary",children:o}),jsx(Xn,{variant:"text",startIcon:jsx(a$1,{icon:"REFRESH_CHANGE"}),size:"small",onClick:r,loading:e,children:"Tentar novamente"})]}),no=Zn;var rp=()=>jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Resumo do pedido"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"ID"}),jsx(a$8,{width:"20%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Data e hora"}),jsx(a$8,{width:"30%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Valor do pedido"}),jsx(a$8,{width:"20%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{gap:.5,children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Status do pedido"}),jsx(a$8,{width:"30%",height:22})]})]}),jsxs(co,{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"},gap:1.5,children:[jsx(a$8,{width:"100%",height:30}),jsx(a$8,{width:"100%",height:30})]})]}),oa=rp;var ep=({eventId:o})=>{let{adapters:r,slots:e}=c(),{useEventDetails:t}=r,{renderEventStatus:a,renderEventActions:i}=e,{data:n,isLoading:l,isFetching:d,isError:y,refetch:f}=t(o,{skip:!o}),u=n?.detail?.sale_external_id||n?.detail?.external_id,_=l||d,D=n?.external_origin==="SALE";return jsx(a$f,{isLoading:_,loading:jsx(oa,{}),anError:y,error:jsx(no,{message:"N\xE3o foi poss\xEDvel carregar os detalhes do pedido realizado!",onRetry:f,isFetching:d}),children:jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Resumo do pedido"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"ID"}),jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:u?`#${u}`:"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Data e hora"}),jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:d$1(n?.detail?.created_at,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Valor do pedido"}),jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:h(n?.detail?.total_value??n?.amount_value)})]}),n&&a?.(n)]}),jsxs(co,{gap:1.5,children:[n&&i?.(n),!D&&jsx(Un,{severity:"warning",children:"Este pedido foi importado do ERP. Para visualizar detalhes ou realizar a\xE7\xF5es, acesse o sistema ERP."})]})]})})},ta=ep;var ap=({period:o})=>{let r=o==="PAST",e=o==="FUTURE";return jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:e?"Comportamento de compra":"Resumo"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Data prevista"}),jsx(a$8,{width:"20%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Frequ\xEAncia de compras"}),jsx(a$8,{width:"30%",height:22})]}),r&&jsxs(Fragment,{children:[jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Per\xEDodo desde o \xFAltimo pedido"}),jsx(a$8,{width:"20%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"\xDAltimo pedido"}),jsx(a$8,{width:"50%",height:22})]})]})]}),jsxs(co,{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"},gap:1,children:[jsx(a$8,{width:"100%",height:30}),jsx(a$8,{width:"100%",height:30})]})]})},ea=ap;var np=({eventId:o})=>{let{adapters:r,slots:e}=c(),{useEventDetails:t}=r,{renderEventActions:a,renderSaleLink:i}=e,{data:n,isLoading:l$1,isFetching:d,isError:y,refetch:f}=t(o,{skip:!o}),{period:u}=l(n?.reference_date??new Date),_=u==="PAST",D=u==="FUTURE",E=n?.partner?.sale_analysis?.last_sale_sale_external_id||n?.partner?.sale_analysis?.last_sale_external_id,J=n?.partner?.sale_analysis?.last_sale_negotiation_date;return jsx(a$f,{isLoading:l$1,loading:jsx(ea,{period:u}),anError:y,error:jsx(no,{message:"N\xE3o foi poss\xEDvel carregar os detalhes do pedido previsto!",onRetry:f,isFetching:d}),children:jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:D?"Comportamento de compra":"Resumo"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Data prevista"}),jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:d$1(n?.reference_date,"DD/MM/YYYY")})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Frequ\xEAncia de compras"}),jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:k(n?.partner?.recurrence)})]}),_&&jsxs(Fragment,{children:[jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Per\xEDodo desde o \xFAltimo pedido"}),jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:J?g$1(J):"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"\xDAltimo pedido"}),E?jsxs(co,{direction:"row",alignItems:"center",gap:.5,children:[i?.(E),jsxs(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:["em ",d$1(J,"DD/MM/YYYY [\xE0s] HH:mm")]})]}):jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:"-"})]})]})]}),n&&a?.(n)]})})},aa=np;var sp=()=>jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Resumo do pedido"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"ID"}),jsx(a$8,{width:"30%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Data e hora"}),jsx(a$8,{width:"25%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Valor do pedido"}),jsx(a$8,{width:"20%",height:22})]})]}),jsx(Xo,{sx:{mx:-3}}),jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Comportamento de compra"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Frequ\xEAncia de compras"}),jsx(a$8,{width:"35%",height:22})]})]}),jsxs(co,{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"},gap:1,children:[jsx(a$8,{width:"100%",height:30}),jsx(a$8,{width:"100%",height:30})]})]}),ia=sp;var dp=({eventId:o})=>{let{adapters:r,slots:e}=c(),{useEventDetails:t}=r,{renderEventActions:a}=e,{data:i,isLoading:n,isFetching:l,isError:d,refetch:y}=t(o,{skip:!o}),f=i?.detail?.sale_external_id||i?.detail?.external_id;return jsx(a$f,{isLoading:n,loading:jsx(ia,{}),anError:d,error:jsx(no,{message:"N\xE3o foi poss\xEDvel carregar os detalhes do pedido!",onRetry:y,isFetching:l}),children:jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Resumo do pedido"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"ID"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:f?`#${f}`:"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Data e hora"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:d$1(i?.reference_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Valor do pedido"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:h(i?.amount_value)})]})]}),jsx(Xo,{sx:{mx:-3}}),jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Comportamento de compra"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Frequ\xEAncia de compras"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:k(i?.partner?.recurrence)})]})]}),i&&a?.(i)]})})},na=dp;var lp=()=>jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Informa\xE7\xF5es do carrinho"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Tempo decorrido desde o abandono"}),jsx(a$8,{width:"30%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Modelo de pedido"}),jsx(a$8,{width:"40%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Forma de pagamento"}),jsx(a$8,{width:"40%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Valor do carrinho"}),jsx(a$8,{width:"20%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Endere\xE7o"}),jsx(a$8,{width:"80%",height:22})]})]}),jsx(a$8,{width:"100%",height:30})]}),pa=lp;var yp=({eventId:o})=>{let{adapters:r,slots:e}=c(),{useEventDetails:t}=r,{formatAddress:a}=e,{data:i,isLoading:n,isFetching:l,isError:d,refetch:y}=t(o,{skip:!o});return jsx(a$f,{isLoading:n,loading:jsx(pa,{}),anError:d,error:jsx(no,{message:"N\xE3o foi poss\xEDvel carregar os detalhes do carrinho abandonado!",onRetry:y,isFetching:l}),children:jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Informa\xE7\xF5es do carrinho"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Tempo decorrido desde o abandono"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:d$1(i?.detail?.abandoned_at,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Modelo de pedido"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:i?.detail?.new_order?.name??"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Forma de pagamento"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:i?.detail?.payment_method?.name??"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Valor do carrinho"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:h(i?.detail?.total??i?.amount_value)})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Endere\xE7o"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:a(i?.detail?.address)})]})]}),jsx(wn,{component:si,href:`https://wa.me/${i?.partner?.phone}`,target:"_blank",rel:"noopener noreferrer",variant:"outlined",startIcon:jsx(a$1,{icon:"WHATSAPP",color:"success.main"}),color:"inherit",size:"small",disabled:!i?.partner?.phone,children:"Enviar mensagem"})]})})},sa=yp;var fp=()=>jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Resumo do carrinho"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Modelo de pedido"}),jsx(a$8,{width:"40%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Forma de pagamento"}),jsx(a$8,{width:"30%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Valor do carrinho"}),jsx(a$8,{width:"20%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Endere\xE7o"}),jsx(a$8,{width:"80%",height:22})]})]}),jsx(a$8,{width:"100%",height:30})]}),da=fp;var hp=({eventId:o})=>{let{adapters:r,slots:e}=c(),{useEventDetails:t}=r,{formatAddress:a}=e,{data:i,isLoading:n,isFetching:l,isError:d,refetch:y}=t(o,{skip:!o});return jsx(a$f,{isLoading:n,loading:jsx(da,{}),anError:d,error:jsx(no,{message:"N\xE3o foi poss\xEDvel carregar os detalhes do carrinho!",onRetry:y,isFetching:l}),children:jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Resumo do carrinho"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Modelo de pedido"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:i?.detail?.new_order?.name??"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Forma de pagamento"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:i?.detail?.payment_method?.name??"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Valor do carrinho"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:h(i?.detail?.total??i?.amount_value)})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Endere\xE7o"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:a(i?.detail?.address)})]})]}),jsx(wn,{component:si,href:`https://wa.me/${i?.partner?.phone}`,target:"_blank",rel:"noopener noreferrer",variant:"outlined",startIcon:jsx(a$1,{icon:"WHATSAPP",color:"success.main"}),color:"inherit",size:"small",disabled:!i?.partner?.phone,children:"Enviar mensagem"})]})})},la=hp;var Sp={["ORDER_PLACED"]:ta,["ORDER_UNPLANNED"]:na,["ORDER_PLANNED"]:aa,["SHOPPING_CART_ACTIVE"]:la,["SHOPPING_CART_ABANDONED"]:sa},Tp=({origin:o,eventId:r})=>{let e=Sp[o];return e?jsx(e,{eventId:r}):null},jt=Tp;var vp=({events:o})=>{let{getEventCode:r}=c().slots;if(o.length<=1){let e=o[0];return e?jsx(jt,{origin:e.type,eventId:e.id}):null}return jsx(Fragment,{children:o.map(e=>jsxs(a$h,{slotProps:{transition:{unmountOnExit:!0}},children:[jsx(b$2,{children:jsxs(W,{variant:"overline",color:"text.secondary",children:["Pedido:\u2002",jsxs(W,{component:"span",variant:"body2",fontWeight:600,color:"text.primary",children:["#",r(e)]})]})}),jsx(c$1,{sx:{p:0,mt:-2},children:jsx(jt,{origin:e.type,eventId:e.id})})]},e.id))})},ma=vp;var xp=()=>jsxs(co,{p:3,gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Informa\xE7\xF5es do cliente"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Nome"}),jsx(a$8,{width:"40%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"CPF/CNPJ"}),jsx(a$8,{width:"30%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,children:[jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Telefone"}),jsx(a$8,{width:"100%",height:22})]}),jsx(wn,{variant:"text",startIcon:jsx(a$1,{icon:"PENCIL_EDIT"}),color:"inherit",size:"small",disabled:!0,children:"Editar"})]})]}),fa=xp;var Dp=({partner:o,isLoading:r,onPhoneUpdated:e})=>{let{renderPartnerLink:t,renderPhoneEditor:a}=c().slots;return jsx(a$f,{isLoading:r,loading:jsx(fa,{}),children:jsxs(co,{p:3,gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Informa\xE7\xF5es do cliente"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Nome"}),t?t(o):jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:o?.name||"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"CPF/CNPJ"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:o?.tax_id?i(o.tax_id):"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,children:[jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Telefone"}),o?.phone?jsx(si,{href:`https://wa.me/${o.phone}`,target:"_blank",rel:"noopener noreferrer",color:"#22C55E",children:jsxs(co,{direction:"row",alignItems:"center",gap:1,children:[jsx(a$1,{icon:"WHATSAPP",color:"#22C55E"}),jsx(W,{variant:"subtitle2",color:"success.main",children:h$2(o.phone)})]})}):jsx(W,{variant:"subtitle2",color:"text.primary",children:"-"})]}),a?.(o?.external_id??"",e??(()=>{}))]})]})})},ua=Dp;var ha=styled(co,{shouldForwardProp:o=>o!=="customBackground"&&o!=="customColor"})(({theme:o,customBackground:r,customColor:e})=>({padding:o.spacing(.5,1),borderRadius:4,background:r,color:e}));var Lp=({open:o,onClose:r,events:e})=>{let t=e[0],[a,i]=useState(),{useEventDetails:n}=c().adapters,{data:l$1,isLoading:d,refetch:y}=n(t?.id??"",{skip:!o||!t?.id}),{period:f}=l(t?.reference_date??new Date),u=m(t?.type,f),_=useCallback(D=>{i(D),y();},[y]);return jsxs(a$c,{open:o,onClose:r,headerTitle:jsxs(Fragment,{children:["Detalhes"," ",jsx(ha,{customBackground:u.background,customColor:u.color,children:jsx(W,{variant:"subtitle2",fontSize:13,noWrap:!0,children:u.label})})]}),headerProps:{direction:"row-reverse"},contentProps:{p:0},maxWidth:520,children:[jsx(co,{position:"sticky",top:0,zIndex:9,children:jsx(Ze,{origin:t?.type,referenceDate:t?.reference_date})}),jsx(ua,{partner:l$1?.partner?{...l$1.partner,phone:a??l$1.partner.phone}:void 0,isLoading:d,onPhoneUpdated:_}),jsx(Xo,{}),jsx(ma,{events:e})]})},yt=Lp;var Mp=({icon:o,title:r,description:e,details:t,footer:a})=>jsxs(co,{gap:1,children:[jsxs(co,{direction:"row",alignItems:"center",gap:.5,children:[o,jsx(W,{variant:"caption",fontWeight:"bold",children:r})]}),jsx(W,{variant:"caption",children:e}),t&&jsxs(Fragment,{children:[jsx(Xo,{sx:{borderStyle:"dashed"}}),jsx(co,{children:t})]}),a&&jsxs(Fragment,{children:[jsx(Xo,{sx:{borderStyle:"dashed"}}),a]})]}),X=Mp;var Bp=({event:o})=>{let{getEventCode:r}=c().slots;return jsx(X,{icon:jsx(a$1,{icon:"CHECK_CIRCLE",color:"#22C55E"}),title:"Pedido realizado",description:"Pedido realizado com sucesso!",details:jsxs(Fragment,{children:[jsxs(W,{variant:"caption",children:["ID:"," ",jsx("strong",{children:r(o)?`#${r(o)}`:"-"})]}),jsxs(W,{variant:"caption",children:["Data e hora:"," ",jsx("strong",{children:d$1(o.reference_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsxs(W,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(o.amount_value)})]})]})})},Ca=Bp;var Yp=({event:o})=>{let{period:r}=l(o.reference_date);return r==="PAST"?jsx(X,{icon:jsx(a$1,{icon:"HEXAGON_WARNING",color:"#FF5630"}),title:"Pedido n\xE3o realizado",description:"Cliente n\xE3o realizou o pedido previsto na data esperada.",details:jsxs(W,{variant:"caption",children:["Data prevista:"," ",jsx("strong",{children:d$1(o.reference_date,"DD/MM/YYYY")})]})}):r==="TODAY"?jsx(X,{icon:jsx(a$1,{icon:"WARNING_TRIANGLE_SOLID",color:"#FFAB00"}),title:"Pedido previsto para hoje",description:"Nenhum pedido registrado at\xE9 o momento.",details:jsxs(W,{variant:"caption",children:["Valor previsto: ",jsx("strong",{children:h(o.amount_value)})]})}):jsx(X,{icon:jsx(a$1,{icon:"CALENDAR_TODAY",color:"#C4CDD5"}),title:"Pedido previsto",description:"Pr\xF3ximo pedido estimado conforme padr\xE3o de frequ\xEAncia.",details:jsxs(W,{variant:"caption",children:["Data prevista:"," ",jsx("strong",{children:d$1(o.reference_date,"DD/MM/YYYY")})]})})},Pa=Yp;var Wp=({event:o})=>{let{getEventCode:r}=c().slots;return jsx(X,{icon:jsx(a$1,{icon:"INFO",color:"#00B8D9"}),title:"Pedido fora do padr\xE3o",description:"Pedido feito em dia n\xE3o previsto pela frequ\xEAncia.",details:jsxs(Fragment,{children:[jsxs(W,{variant:"caption",children:["ID:"," ",jsx("strong",{children:r(o)?`#${r(o)}`:"-"})]}),jsxs(W,{variant:"caption",children:["Data e hora:"," ",jsx("strong",{children:d$1(o.reference_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsxs(W,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(o.amount_value)})]})]})})},xa=Wp;var Hp=({event:o})=>jsx(X,{icon:jsx(a$1,{icon:"CANCEL_CIRCLE_SOLID",color:"#FF5630"}),title:"Carrinho abandonado",description:jsxs(Fragment,{children:["Carrinho inativo h\xE1 ",jsx("strong",{children:g$1(o.reference_date)})," \u2014 valor estimado: ",jsx("strong",{children:h(o.amount_value)}),"."]}),details:jsxs(Fragment,{children:[jsxs(W,{variant:"caption",children:["ID:"," ",jsx("strong",{children:o.external_id?`#${o.external_id}`:"-"})]}),jsxs(W,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(o.amount_value)})]})]})}),Ea=Hp;var zp=({event:o})=>jsx(X,{icon:jsx(a$1,{icon:"WARNING_TRIANGLE_SOLID",color:"#FFAB00"}),title:"Pedido em andamento",description:"Cliente est\xE1 atualizando o carrinho neste momento.",details:jsxs(W,{variant:"caption",children:["Valor parcial: ",jsx("strong",{children:h(o.amount_value)})]})}),_a=zp;var re={color:"common.white",width:16,height:16,sx:{flexShrink:0}},Ia={["ORDER_PLACED"]:{getIcon:()=>null,getTitle:()=>"Pedido realizado",getDescription:()=>"Pedido confirmado com sucesso!",getTooltip:o=>jsx(Ca,{event:o})},["ORDER_UNPLANNED"]:{getIcon:()=>null,getTitle:()=>"Pedido fora do padr\xE3o",getDescription:()=>"Pedido feito fora do dia habitual.",getTooltip:o=>jsx(xa,{event:o})},["ORDER_PLANNED"]:{getIcon:o=>{let{period:r}=l(o.reference_date);return r==="PAST"?jsx(a$1,{icon:"HEXAGON_WARNING",...re}):r==="TODAY"?jsx(a$1,{icon:"WARNING_TRIANGLE_SOLID",...re}):null},getTitle:o=>{let{period:r}=l(o.reference_date);return r==="PAST"?"Pedido n\xE3o realizado":r==="TODAY"?"Pedido previsto para hoje":"Pedido previsto"},getDescription:o=>{let{period:r}=l(o.reference_date);return r==="PAST"?"Cliente n\xE3o realizou o pedido previsto na data esperada.":r==="TODAY"?"Nenhum pedido registrado at\xE9 o momento.":"Pr\xF3ximo pedido estimado conforme padr\xE3o de frequ\xEAncia."},getTooltip:o=>jsx(Pa,{event:o})},["SHOPPING_CART_ACTIVE"]:{getIcon:()=>null,getTitle:()=>"Pedido em andamento",getDescription:()=>"Cliente est\xE1 atualizando o carrinho neste momento.",getTooltip:o=>jsx(_a,{event:o})},["SHOPPING_CART_ABANDONED"]:{getIcon:()=>jsx(a$1,{icon:"CANCEL_CIRCLE_SOLID",...re}),getTitle:()=>"Carrinho abandonado",getDescription:o=>`Carrinho inativo h\xE1 ${g$1(o.reference_date)} \u2014 valor estimado: ${h(o.amount_value)}.`,getTooltip:o=>jsx(Ea,{event:o})}};var Oa=styled(co,{shouldForwardProp:o=>o!=="eventType"&&o!=="period"})(({theme:o,eventType:r,period:e})=>{let t=m(r,e);return {position:"relative",padding:o.spacing(.5,1),borderRadius:4,background:t.background,color:t.color,cursor:"pointer","&:hover":{background:t.backgroundHover}}}),wa=styled(co,{shouldForwardProp:o=>o!=="eventType"&&o!=="period"})(({theme:o,eventType:r,period:e})=>({position:"absolute",top:-5,right:-5,width:20,height:20,alignItems:"center",justifyContent:"center",borderRadius:"50%",background:m(r,e).iconBadgeColor,boxShadow:`0 0 0 2px ${o.palette.common.white}`}));var Up=({event:o,index:r})=>{let[e,t]=a$a(),a=Ia[o.type];if(!a)return null;let{period:i}=l(o.reference_date),n=a.getIcon(o);return jsxs(Fragment,{children:[jsx(a$g,{title:a.getTooltip(o),arrow:!0,children:jsxs(Oa,{"data-testid":`event-${r}`,eventType:o.type,period:i,onClick:t,children:[n&&jsx(wa,{eventType:o.type,period:i,children:n}),jsx(W,{variant:"subtitle2",fontSize:13,noWrap:!0,children:a.getTitle(o)}),jsx(W,{variant:"caption",noWrap:!0,children:a.getDescription(o)})]})}),jsx(yt,{open:e,onClose:t,events:[o]})]})},Ma=Up;var Qp=({icon:o,title:r,description:e,children:t})=>jsxs(co,{gap:1,children:[jsxs(co,{direction:"row",alignItems:"center",gap:.5,children:[o,jsx(W,{variant:"caption",fontWeight:"bold",children:r})]}),jsx(W,{variant:"caption",children:e}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsx(co,{gap:1,children:t})]}),lo=Qp;var Kp=({events:o})=>{let{getEventCode:r}=c().slots,e=o.slice(0,c$2),t=o.length-c$2;return jsxs(lo,{icon:jsx(a$1,{icon:"CHECK_CIRCLE",color:"#22C55E"}),title:"Pedidos realizados",description:"Pedidos realizados com sucesso!",children:[e.map((a,i)=>jsxs(co,{children:[i>0&&jsx(Xo,{sx:{borderStyle:"dashed",mb:1}}),jsxs(W,{variant:"caption",children:["ID:"," ",jsx("strong",{children:r(a)?`#${r(a)}`:"-"})]}),jsxs(W,{variant:"caption",children:["Data/Hora:"," ",jsx("strong",{children:d$1(a.reference_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsxs(W,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(a.amount_value)})]})]},a.id)),t>0&&jsxs(Fragment,{children:[jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(W,{variant:"caption",children:["e mais ",t," pedido",t>1?"s":""]})]})]})},Wa=Kp;var os={["PAST"]:jsx(a$1,{icon:"HEXAGON_WARNING",color:"#FF5630"}),["TODAY"]:jsx(a$1,{icon:"WARNING_TRIANGLE_SOLID",color:"#FFAB00"}),["FUTURE"]:jsx(a$1,{icon:"CALENDAR_TODAY",color:"#C4CDD5"})},rs={["PAST"]:"Pedidos n\xE3o realizados",["TODAY"]:"Pedidos previstos para hoje",["FUTURE"]:"Pedidos previstos"},ts={["PAST"]:"Clientes n\xE3o realizaram os pedidos previstos na data esperada.",["TODAY"]:"Nenhum pedido registrado at\xE9 o momento.",["FUTURE"]:"Pr\xF3ximos pedidos estimados conforme padr\xE3o de frequ\xEAncia."},es=({events:o})=>{let{period:r}=l(o[0]?.reference_date),e=o.slice(0,c$2),t=o.length-c$2;return jsxs(lo,{icon:os[r],title:rs[r],description:ts[r],children:[e.map((a,i)=>jsxs(co,{children:[i>0&&jsx(Xo,{sx:{borderStyle:"dashed",mb:1}}),jsxs(W,{variant:"caption",children:["Data prevista:"," ",jsx("strong",{children:d$1(a.reference_date,"DD/MM/YYYY")})]})]},a.id)),t>0&&jsxs(Fragment,{children:[jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(W,{variant:"caption",children:["e mais ",t," pedido",t>1?"s":""]})]})]})},Va=es;var ns=({events:o})=>{let{getEventCode:r}=c().slots,e=o.slice(0,c$2),t=o.length-c$2;return jsxs(lo,{icon:jsx(a$1,{icon:"INFO",color:"#00B8D9"}),title:"Pedidos fora do padr\xE3o",description:"Pedidos feitos em dias n\xE3o previstos pela frequ\xEAncia.",children:[e.map((a,i)=>jsxs(co,{children:[i>0&&jsx(Xo,{sx:{borderStyle:"dashed",mb:1}}),jsxs(W,{variant:"caption",children:["ID:"," ",jsx("strong",{children:r(a)?`#${r(a)}`:"-"})]}),jsxs(W,{variant:"caption",children:["Data/Hora:"," ",jsx("strong",{children:d$1(a.reference_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsxs(W,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(a.amount_value)})]})]},a.id)),t>0&&jsxs(Fragment,{children:[jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(W,{variant:"caption",children:["e mais ",t," pedido",t>1?"s":""]})]})]})},$a=ns;var ds=({events:o})=>{let r=o.slice(0,c$2),e=o.length-c$2;return jsxs(lo,{icon:jsx(a$1,{icon:"CANCEL_CIRCLE_SOLID",color:"#FF5630"}),title:"Carrinhos abandonados",description:"Carrinhos inativos h\xE1 algum tempo.",children:[r.map((t,a)=>jsxs(co,{children:[a>0&&jsx(Xo,{sx:{borderStyle:"dashed",mb:1}}),jsxs(W,{variant:"caption",children:["ID:"," ",jsx("strong",{children:t.external_id?`#${t.external_id}`:"-"})]}),jsxs(W,{variant:"caption",children:["Inativo h\xE1: ",jsx("strong",{children:g$1(t.reference_date)})]}),jsxs(W,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(t.amount_value)})]})]},t.id)),e>0&&jsxs(Fragment,{children:[jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(W,{variant:"caption",children:["e mais ",e," carrinho",e>1?"s":""]})]})]})},ja=ds;var ms=({events:o})=>{let r=o.slice(0,c$2),e=o.length-c$2;return jsxs(lo,{icon:jsx(a$1,{icon:"WARNING_TRIANGLE_SOLID",color:"#FFAB00"}),title:"Pedidos em andamento",description:"Clientes est\xE3o atualizando seus carrinhos neste momento.",children:[r.map((t,a)=>jsxs(co,{children:[a>0&&jsx(Xo,{sx:{borderStyle:"dashed",mb:1}}),jsxs(W,{variant:"caption",children:["ID:"," ",jsx("strong",{children:t.external_id?`#${t.external_id}`:"-"})]}),jsxs(W,{variant:"caption",children:["Valor parcial: ",jsx("strong",{children:h(t.amount_value)})]})]},t.id)),e>0&&jsxs(Fragment,{children:[jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(W,{variant:"caption",children:["e mais ",e," carrinho",e>1?"s":""]})]})]})},Qa=ms;var Xa={["ORDER_PLACED"]:Wa,["ORDER_UNPLANNED"]:$a,["ORDER_PLANNED"]:Va,["SHOPPING_CART_ACTIVE"]:Qa,["SHOPPING_CART_ABANDONED"]:ja};var Ka=styled(co,{shouldForwardProp:o=>o!=="customBackground"&&o!=="customColor"&&o!=="customHoverBackground"})(({theme:o,customBackground:r,customColor:e,customHoverBackground:t})=>({padding:o.spacing(.5,1),borderRadius:4,background:r,color:e,cursor:"pointer","&:hover":{background:t}}));var hs=({group:o,index:r})=>{let[e,t]=a$a(),{config:a,count:i,events:n}=o,l=i>1?a.labelPlural:a.label,d=Xa[n[0].type];return jsxs(Fragment,{children:[jsx(a$g,{title:jsx(d,{events:n}),arrow:!0,children:jsx(Ka,{"data-testid":`grouped-events-${r}`,customBackground:a.background,customColor:a.color,customHoverBackground:a.backgroundHover,onClick:t,children:jsxs(W,{variant:"subtitle2",fontSize:13,title:`${i} ${l}`,noWrap:!0,children:[jsx("strong",{children:i})," ",l]})})}),jsx(yt,{open:e,onClose:t,events:n})]})},Za=hs;var bs=({events:o})=>{let r=useMemo(()=>{let e={};return o.forEach(t=>{let a=t.type==="ORDER_PLANNED"?m(t.type,l(t.reference_date).period):m(t.type);e[a.label]||(e[a.label]={count:0,config:a,events:[]}),e[a.label].count+=1,e[a.label].events.push(t);}),Object.values(e)},[o]);return jsx(Fragment,{children:r.map((e,t)=>jsx(Za,{index:t,group:e},t))})},ri=bs;var ti=styled(co)({gap:4});var ks=({events:o,day:r,index:e})=>{let t=r.isSame(fe(),"day");if(o.length===0)return jsx(io,{isToday:t,"data-testid":`day-column-${e}`});let a=o.length>b$1;return jsx(io,{isToday:t,"data-testid":`day-column-${e}`,children:jsx(ti,{children:a?jsx(ri,{events:o}):o.map((i,n)=>jsx(Ma,{index:n,event:i},n))})})},ei=ks;var Es=({day:o,index:r,events:e,isFetching:t})=>{let a=o.isSame(fe(),"day");return t?jsx(io,{isToday:a,"data-testid":`day-column-${r}`,children:jsx(a$8,{width:"100%",height:"100%",sx:{maxHeight:46.42}})}):jsx(ei,{events:e,day:o,index:r})},ai=Es;var ii=styled(_s)(()=>({width:6,height:6,borderRadius:"50%",flexShrink:0}));var Os=({status:o,variant:r="body2",color:e="text.primary"})=>{let t=e$2[o];if(!t)return null;let{label:a,color:i}=t;return jsxs(co,{direction:"row",alignItems:"center",gap:1,children:[jsx(ii,{bgcolor:i}),jsx(W,{variant:r,color:e,noWrap:!0,children:a})]})},Ct=Os;var Ns=()=>jsxs(co,{mt:-1,px:1,gap:1,children:[jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Nome"}),jsx(a$8,{width:"40%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"CPF/CNPJ"}),jsx(a$8,{width:"30%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"E-mail"}),jsx(a$8,{width:"35%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Status do cliente"}),jsx(a$8,{width:"20%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{gap:.5,children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Segmento"}),jsx(a$8,{width:"35%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,children:[jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Telefone"}),jsx(a$8,{width:"100%",height:22})]}),jsx(wn,{variant:"text",startIcon:jsx(a$1,{icon:"PENCIL_EDIT"}),color:"inherit",size:"small",disabled:!0,children:"Editar"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Telefone"}),jsx(a$8,{width:"20%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Vendedor preferencial"}),jsx(a$8,{width:"40%",height:22})]})]}),pi=Ns;var Ys=({partner:o,onPhoneUpdated:r})=>{let[e,t]=a$a(!0),{adapters:a,slots:i$1}=c(),{renderPartnerLink:n,renderPhoneEditor:l}=i$1,{data:d,isLoading:y,refetch:f}=a.usePartnerDetails(o.external_id,{skip:!o.external_id||!e}),u=d?.mobile??d?.phone,_=useMemo(()=>d?.fiscal_registration_number?i(d?.fiscal_registration_number):"-",[d?.fiscal_registration_number]),D=useCallback(E=>{f(),r?.(E);},[f,r]);return jsxs(a$h,{expanded:e,onChange:t,defaultExpanded:!0,children:[jsx(b$2,{children:jsx(W,{variant:"overline",color:"text.secondary",children:"Informa\xE7\xF5es"})}),jsx(c$1,{children:jsx(a$f,{isLoading:y,loading:jsx(pi,{}),children:jsxs(co,{mt:-1,px:1,gap:1,children:[jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Nome"}),n?n(d):jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:o?.name||"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"CPF/CNPJ"}),jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:_})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"E-mail"}),jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:d?.email||"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Status do cliente"}),o.classification?jsx(Ct,{status:o.classification,variant:"subtitle2",color:"text.primary"}):jsx(W,{variant:"subtitle2",color:"text.primary",children:"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{gap:.5,children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Segmento"}),d?.profile?.name?jsx(Fs,{variant:"outlined",label:d.profile.name,size:"small",color:"default",sx:{width:"fit-content"}}):jsx(W,{variant:"subtitle2",color:"text.primary",children:"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,children:[jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Telefone"}),u?jsxs(co,{direction:"row",alignItems:"center",gap:.5,children:[jsx(a$1,{icon:"WHATSAPP",color:"success.main",sx:{flexShrink:0}}),jsx(si,{component:si,href:`https://wa.me/${u}`,target:"_blank",rel:"noopener noreferrer",variant:"subtitle2",color:"success.main",noWrap:!0,children:h$2(u)})]}):jsx(W,{variant:"subtitle2",color:"text.primary",children:"-"})]}),l?.(o.external_id,D)]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Vendedor preferencial"}),jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:d?.main_seller?.name||"-"})]})]})})})]})},di=Ys;var Hs=({order:o})=>{let{renderSaleLink:r}=c().slots;return jsxs(a$5,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,p:1.5,sx:{borderRadius:1},children:[jsxs(co,{overflow:"hidden",children:[o?.id?r?.(o.id):jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:"-"}),jsx(W,{variant:"caption",color:"text.secondary",children:d$1(o?.negotiation_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsx(W,{variant:"subtitle2",color:"text.primary",children:h(o?.total_value)})]})},ci=memo(Hs,a$2);var zs=()=>jsxs(co,{gap:1.5,children:[jsx(a$8,{width:"100%",height:66}),jsx(a$8,{width:"100%",height:66}),jsx(a$8,{width:"100%",height:66}),jsx(a$8,{width:"100%",height:66}),jsx(a$8,{width:"100%",height:66})]}),mi=zs;var js=({partner:o})=>{let[r,e]=a$a(!1),t=useMemo(()=>o?.external_id?{perPage:5,sort:{fieldName:"negotiationDate",sortType:"DESC"},filter:{operator:"AND",groups:[{operator:"AND",conditionals:[{fieldName:"partnerId",conditional:"EQUALS",value:[o.external_id]}]}]}}:null,[o?.external_id]),{usePartnerOrders:a}=c().adapters,{data:{items:i=[]}={},isLoading:n}=a(t,{skip:!t});return jsxs(a$h,{expanded:r,onChange:e,children:[jsx(b$2,{children:jsx(W,{variant:"overline",color:"text.secondary",children:"\xDAltimos pedidos"})}),jsx(c$1,{children:jsx(co,{mt:-1,px:1,children:jsx(a$f,{isLoading:n,loading:jsx(mi,{}),isEmpty:i?.length===0,empty:jsx(co,{alignItems:"center",justifyContent:"center",gap:1.5,p:2,children:jsx(W,{variant:"body2",color:"text.secondary",children:"Este cliente ainda n\xE3o possui pedidos realizados."})}),children:jsx(co,{gap:1.5,children:i?.map((l,d)=>jsx(ci,{order:l,"data-testid":`last-order-${d}`},l.id))})})})})]})},fi=js;var Ks=({partner:o})=>{let{renderSaleLink:r}=c().slots,[e,t]=a$a(!1),a=useMemo(()=>k(o?.recurrence),[o?.recurrence]),i=o?.sale_analysis?.last_sale_sale_external_id||o?.sale_analysis?.last_sale_external_id,n=o?.sale_analysis?.last_sale_negotiation_date;return jsxs(a$h,{expanded:e,onChange:t,children:[jsx(b$2,{children:jsx(W,{variant:"overline",color:"text.secondary",children:"Comportamento de compra"})}),jsx(c$1,{children:jsxs(co,{mt:-1,px:1,gap:1,children:[jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Frequ\xEAncia de compras"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:a})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"\xDAltimo pedido"}),i?jsxs(co,{direction:"row",alignItems:"center",gap:.5,children:[r?.(i),jsxs(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:["em ",d$1(n,"DD/MM/YYYY [\xE0s] HH:mm")]})]}):jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:"-"})]})]})})]})},gi=Ks;var se=styled(Xo)(({theme:o})=>({height:30,alignSelf:"center",borderStyle:"dashed",[o.breakpoints.down("sm")]:{display:"none"}}));var od=()=>jsxs(co,{direction:{xs:"column",sm:"row"},justifyContent:{xs:"flex-start",sm:"center"},gap:3,children:[jsxs(co,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(W,{variant:"body2",children:"Qtd. de pedidos"}),jsx(a$8,{width:30,height:22})]}),jsx(se,{orientation:"vertical",flexItem:!0}),jsxs(co,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(W,{variant:"body2",children:"Valor total"}),jsx(a$8,{width:92,height:22})]}),jsx(se,{orientation:"vertical",flexItem:!0}),jsxs(co,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(W,{variant:"body2",children:"Ticket m\xE9dio"}),jsx(a$8,{width:71,height:22})]})]}),ui=od;var rd=({partner:o})=>{let[r,e]=a$a(!1),{usePartnerSaleSummary:t}=c().adapters,{data:a,isLoading:i}=t(o.external_id,{skip:!o.external_id||!r});return jsxs(a$h,{expanded:r,onChange:e,children:[jsx(b$2,{children:jsx(W,{variant:"overline",color:"text.secondary",children:"Indicadores de vendas"})}),jsx(c$1,{children:jsx(co,{mt:-1,px:1,children:jsx(a$f,{isLoading:i,loading:jsx(ui,{}),children:jsxs(co,{direction:{xs:"column",sm:"row"},justifyContent:{xs:"flex-start",sm:"center"},gap:3,children:[jsxs(co,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(W,{variant:"body2",children:"Qtd. de pedidos"}),jsx(W,{variant:"subtitle2",children:a?.order_quantity||0})]}),jsx(Xo,{orientation:"vertical",flexItem:!0}),jsxs(co,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(W,{variant:"body2",children:"Valor total"}),jsx(W,{variant:"subtitle2",children:h(a?.total_value)})]}),jsx(Xo,{orientation:"vertical",flexItem:!0}),jsxs(co,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(W,{variant:"body2",children:"Ticket m\xE9dio"}),jsx(W,{variant:"subtitle2",children:h(a?.average_ticket)})]})]})})})})]})},Si=rd;var td=({partner:o,onPhoneUpdated:r})=>jsxs(Fragment,{children:[jsx(di,{partner:o,onPhoneUpdated:r}),jsx(Si,{partner:o}),jsx(gi,{partner:o}),jsx(fi,{partner:o})]}),Ti=td;var vi=styled(co)(({theme:o})=>({minHeight:47.42,flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:o.spacing(1.5)})),le=styled(wn)(({theme:o})=>({justifyContent:"flex-start",color:o.palette.text.primary,fontWeight:400,"&:hover":{background:o.palette.action.hover}}));var ld=({partner:o})=>{let{open:r,onClose:e,setOpen:t}=a$9(),a=useRef(null),[i,n]=a$a(!1),[l,d]=useState(o.phone),y=l?.replace(/\D/g,""),f=!!y,u=useCallback(L=>{d(L);},[]),_=o.sale_analysis.sale_count,D=useMemo(()=>`${_} pedido${_===0||_>1?"s":""}`,[_]),E=useMemo(()=>{let Ro=[e$2[o.classification]?.label,D].filter(Boolean).join(" \u2022 ");return `${o.name}
59
- ${Ro}`},[o.classification,o.name,D]),J=useCallback(()=>{a.current&&t(a.current);},[t]),P=useCallback(()=>{e(),n();},[e,n]);return jsxs(Fragment,{children:[jsx(wo,{title:E,onClick:J,sx:{cursor:"pointer"},children:jsxs(vi,{children:[jsxs(co,{overflow:"hidden",children:[jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:o.name}),jsxs(co,{direction:"row",alignItems:"center",gap:.5,children:[jsx(Ct,{status:o.classification,variant:"caption",color:"text.disabled"}),jsxs(W,{variant:"caption",color:"text.disabled",noWrap:!0,children:[o.classification&&jsx(Fragment,{children:"\u2022"})," ",D]})]})]}),jsx("span",{ref:a,children:jsx(a$1,{icon:"ARROW_DOWN_SIMPLE",color:"text.secondary"})})]})}),jsxs(a$b,{open:r,onClose:e,disabledArrow:!0,sx:{width:180,p:1},children:[jsx(le,{component:si,href:`https://wa.me/${y}`,target:"_blank",rel:"noopener noreferrer",variant:"text",startIcon:jsx(a$1,{icon:"WHATSAPP"}),disabled:!f,fullWidth:!0,children:"Enviar mensagem"}),jsx(le,{variant:"text",startIcon:jsx(a$1,{icon:"INFORMATIONS"}),onClick:P,fullWidth:!0,children:"Ver detalhes"})]}),jsx(a$c,{open:i,onClose:n,headerTitle:"Detalhes do cliente",headerProps:{direction:"row-reverse"},maxWidth:520,contentProps:{p:0},children:jsx(Ti,{partner:o,onPhoneUpdated:u})})]})},Di=ld;var yd=({partner:o,index:r,days:e,isFetching:t})=>{let a=useMemo(()=>{let i=new Map;return o.events.forEach(n=>{let l=new Date(n.reference_date).toISOString().slice(0,10),d=i.get(l)??[];d.push(n),i.set(l,d);}),i},[o.events]);return jsxs(Ir,{"data-testid":`partner-${r}`,children:[jsx(Di,{partner:o}),e.map((i,n)=>jsx(ai,{index:n,day:i,events:a.get(i.format("YYYY-MM-DD"))??[],isFetching:t},n))]})},_i=memo(yd);var Ii=styled(gd)({display:"flex",flexDirection:"column",width:"100%",height:"calc(100vh - 300px)",boxShadow:"none",overflow:"hidden"}),Ri=styled(Sd)({flex:1}),Ai=styled(ud,{shouldForwardProp:o=>o!=="totalWidth"&&o!=="isResizing"})(({totalWidth:o,isResizing:r})=>({tableLayout:"fixed",borderCollapse:"separate",borderSpacing:0,height:"100%",...o>0&&{width:o},...r&&{userSelect:"none",cursor:"col-resize"}})),Oi=styled(hd)(({theme:o})=>({"& .MuiTableRow-root":{backgroundColor:o.palette.background.paper},"& .MuiTableRow-root:last-child .MuiTableCell-root":{height:"100%"}}));var vd=({classification:o,checked:r,onToggle:e})=>{let{label:t,color:a}=e$2[o];return jsx(bd,{control:jsx(Td,{name:`classification-${o}`,checked:r,onChange:e}),label:jsxs(co,{direction:"row",alignItems:"center",gap:1,children:[jsx(co,{width:6,height:16,bgcolor:a,borderRadius:1})," ",t]})})},Li=vd;var Dd=Object.values(d),Ed=()=>{let{selectedClassifications:o,setSelectedClassifications:r}=x(),[e,t]=a$a(!!o.length),a=useCallback(i=>{r(o.includes(i)?o.filter(n=>n!==i):[...o,i]);},[r,o]);return jsxs(a$h,{expanded:e,onChange:t,children:[jsx(b$2,{children:jsx(W,{variant:"body2",fontWeight:"bold",color:"text.primary",children:"Classifica\xE7\xF5es"})}),jsx(c$1,{children:jsx(co,{mt:-1,children:Dd.map(i=>jsx(Li,{classification:i,checked:o.includes(i),onToggle:()=>a(i)},i))})})]})},Ni=Ed;var ye=(o,r,e="40%")=>({position:"relative",backgroundColor:"transparent","&::before":{content:'""',position:"absolute",inset:3,backgroundColor:o,borderRadius:e,zIndex:-1},"&:hover, &:focus":{backgroundColor:"transparent","&::before":{backgroundColor:r}}}),Bi=styled(a$3)(()=>({"&.MuiDateCalendar-root":{margin:-24},"& .MuiPickersCalendarHeader-label":{textTransform:"capitalize"}})),Fi=styled(PickersDay,{shouldForwardProp:o=>o!=="isDaily"&&o!=="isInRange"&&o!=="isStart"&&o!=="isEnd"})(({theme:o,isInRange:r,isStart:e,isEnd:t,isDaily:a})=>({borderRadius:0,"&:not(.Mui-selected):not(.MuiPickersDay-today)":{"&:hover, &:focus":{backgroundColor:o.palette.action.hover,borderRadius:"40%"}},...!r&&{"&.MuiPickersDay-today:not(.Mui-selected)":{color:o.palette.common.white,border:"none !important",...ye(o.palette.common.black,alpha(o.palette.common.black,.8))}},"&.Mui-selected":{color:`${o.palette.primary.contrastText} !important`,...ye(o.palette.primary.main,o.palette.primary.dark)},...r&&a&&{color:o.palette.primary.contrastText,...ye(o.palette.primary.main,o.palette.primary.dark,6)},...r&&!a&&{backgroundColor:"transparent",borderTop:`1px solid ${o.palette.divider}`,borderBottom:`1px solid ${o.palette.divider}`,borderLeft:e?`1px solid ${o.palette.divider}`:"none",borderRight:t?`1px solid ${o.palette.divider}`:"none",...e&&{borderTopLeftRadius:8,borderBottomLeftRadius:8},...t&&{borderTopRightRadius:8,borderBottomRightRadius:8},"&.MuiPickersDay-today:not(.Mui-selected)":{borderTop:`1px solid ${o.palette.divider} !important`,borderBottom:`1px solid ${o.palette.divider} !important`,borderLeft:"none !important",borderRight:"none !important"}}}));var Od=["D","S","T","Q","Q","S","S"],It=(o,r)=>o.getFullYear()===r.getFullYear()&&o.getMonth()===r.getMonth()&&o.getDate()===r.getDate(),wd=()=>{let{baseDate:o,dateRange:r,viewMode:e,handleBaseDateChange:t}=x(),a=fe(r.start_date).toDate(),i=fe(r.end_date).toDate(),n=useCallback(f=>It(f,a)||It(f,i)||f>a&&f<i,[a,i]),l=useCallback(f=>It(f,a),[a]),d=useCallback(f=>It(f,i),[i]),y=useCallback(f=>{f&&t(fe(f));},[t]);return jsxs(co,{p:2,pb:3,gap:2,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Calend\xE1rio"}),jsx(co,{alignItems:"center",children:jsx(Bi,{value:o.toDate(),onChange:y,showDaysOutsideCurrentMonth:!0,slots:{day:Fi},slotProps:{day:f=>{let u=f.day.toDate();return {isInRange:n(u),isStart:l(u),isEnd:d(u),isDaily:e==="DAY",disableMargin:!0}}},dayOfWeekFormatter:f=>Od[f.day()],fixedWeekNumber:6})})]})},Wi=wd;var Yd=()=>{let{selectedPartners:o,setSelectedPartners:r}=x(),[e,t]=a$a(!0),[a,i]=useState(""),{buildOptions:n,finishSearch:l,onSearch:d,onSelectValue:y,search:f,searching:u}=a$i(),{usePartnerOptions:_}=c().adapters,{items:D,isFetching:E,isLoading:J}=_({search:f,skip:!e}),P=useMemo(()=>u||E?[]:n(D.map(({id:m,name:b})=>({value:m,label:b||""})),E),[n,E,D,u]),L=o.length>0,Ro=useCallback(m=>{y(P,m);let b=typeof m=="string"?m:String(m?.value||""),At=P.find(Ao=>String(Ao.value)===b)?.label||(typeof m=="string"?m:String(m?.label||""));b&&!o.some(Ao=>Ao.id===b)&&r([...o,{id:b,name:At}]),i("");},[r,y,P,o]),_r=useCallback(m=>{r(o.filter(b=>b.id!==m.id));},[r,o]);return jsxs(a$h,{expanded:e,onChange:t,children:[jsx(b$2,{children:jsx(W,{variant:"body2",fontWeight:"bold",color:"text.primary",children:"Clientes"})}),jsx(c$1,{children:jsxs(co,{gap:1,children:[jsx(a$j,{name:"partners",label:"Clientes",placeholder:"Digite para buscar um cliente...",size:"small",options:P,loading:J,inputValue:a,onInputChange:(m,b)=>i(b),onSearch:d,onBlur:l,onChange:Ro,filterOptions:m=>m,noOptionsText:u||E?"Carregando...":void 0,InputLabelProps:{shrink:!0},fullWidth:!0}),jsx(a$5,{direction:"row",alignItems:"center",flexWrap:"wrap",overflow:"auto",maxHeight:148,p:1.5,sx:{bgcolor:"grey.50"},children:jsx(a$f,{isEmpty:!L,empty:jsx(W,{variant:"body2",color:"text.secondary",children:"Nenhum cliente selecionado"}),children:o.map((m,b)=>jsx(Fs,{variant:"outlined",label:m.name,color:"default",onDelete:()=>_r(m),"data-testid":`filter-partner-${b}`},m.id))})})]})})]})},zi=Yd;var zd=()=>{let{selectedProfiles:o,setSelectedProfiles:r}=x(),[e,t]=a$a(!!o.length),[a,i]=useState(""),{buildOptions:n,finishSearch:l,onSearch:d,onSelectValue:y,search:f,searching:u}=a$i(),{useProfileOptions:_}=c().adapters,{items:D,isFetching:E,isLoading:J}=_({search:f,skip:!e}),P=useMemo(()=>u||E?[]:n(D.map(({id:m,name:b})=>({value:m,label:b||""})),E),[n,E,D,u]),L=o.length>0,Ro=useCallback(m=>{y(P,m);let b=typeof m=="string"?m:String(m?.value||""),At=P.find(Ao=>String(Ao.value)===b)?.label||(typeof m=="string"?m:String(m?.label||""));b&&!o.some(Ao=>Ao.id===b)&&r([...o,{id:b,name:At}]),i("");},[r,y,P,o]),_r=useCallback(m=>{r(o.filter(b=>b.id!==m.id));},[r,o]);return jsxs(a$h,{expanded:e,onChange:t,children:[jsx(b$2,{children:jsx(W,{variant:"body2",fontWeight:"bold",color:"text.primary",children:"Segmentos"})}),jsx(c$1,{children:jsxs(co,{gap:1,children:[jsx(a$j,{name:"profiles",label:"Segmentos",placeholder:"Digite para buscar um segmento...",size:"small",options:P,loading:J,inputValue:a,onInputChange:(m,b)=>i(b),onSearch:d,onBlur:l,onChange:Ro,filterOptions:m=>m,noOptionsText:u||E?"Carregando...":void 0,InputLabelProps:{shrink:!0},fullWidth:!0}),jsx(a$5,{direction:"row",alignItems:"center",flexWrap:"wrap",overflow:"auto",maxHeight:148,p:1.5,sx:{bgcolor:"grey.50"},children:jsx(a$f,{isEmpty:!L,empty:jsx(W,{variant:"body2",color:"text.secondary",children:"Nenhum segmento selecionado"}),children:o.map((m,b)=>jsx(Fs,{variant:"outlined",label:m.name,color:"default",onDelete:()=>_r(m),"data-testid":`filter-profile-${b}`},m.id))})})]})})]})},qi=zd;var jd=({status:o,checked:r,onToggle:e})=>{let{label:t,color:a}=n[o];return jsx(bd,{control:jsx(Td,{name:`status-${o}`,checked:r,onChange:e}),label:jsxs(co,{direction:"row",alignItems:"center",gap:1,children:[jsx(co,{width:6,height:16,bgcolor:a,borderRadius:1})," ",t]})})},Xi=jd;var Jd=Object.values(e),Zd=()=>{let{selectedEventTypes:o,setSelectedEventTypes:r}=x(),[e,t]=a$a(!!o.length),a=useCallback(i=>{r(o.includes(i)?o.filter(n=>n!==i):[...o,i]);},[r,o]);return jsxs(a$h,{expanded:e,onChange:t,children:[jsx(b$2,{children:jsx(W,{variant:"body2",fontWeight:"bold",color:"text.primary",children:"Status de eventos"})}),jsx(c$1,{children:jsx(co,{mt:-1,children:Jd.map(i=>jsx(Xi,{status:i,checked:o.includes(i),onToggle:()=>a(i)},i))})})]})},Ki=Zd;var rl=()=>jsxs(Fragment,{children:[jsx(Wi,{}),jsx(zi,{}),jsx(qi,{}),jsx(Ki,{}),jsx(Ni,{})]}),Ji=rl;var on=styled(co)(({theme:o})=>({flexDirection:"row",alignItems:"center",padding:o.spacing(2.5),gap:o.spacing(1)})),rn=styled(co)(({theme:o})=>({flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:o.spacing(2.5),gap:o.spacing(1)})),he=styled(_s)({flex:1,display:"flex",alignItems:"center",minWidth:0}),tn=styled(he)({justifyContent:"flex-start"}),en=styled(he)({justifyContent:"center"}),an=styled(he)({justifyContent:"flex-end"});var nn={["DAY"]:"Dia",["WEEK"]:"Semana"},pn={["DAY"]:"CALENDAR_TODAY",["WEEK"]:"COLUMNS"};var Se=styled(wn,{shouldForwardProp:o=>o!=="active"})(({theme:o,active:r})=>({justifyContent:"flex-start",color:r?o.palette.primary.main:o.palette.text.secondary,fontWeight:r?800:400,"&:hover":{background:o.palette.action.hover}}));var dl=()=>{let{open:o,onClose:r,onOpen:e}=a$9(),{viewMode:t,setViewMode:a}=x(),i=useCallback(n=>{a(n),r();},[r,a]);return jsxs(Fragment,{children:[jsx(wn,{variant:"text",startIcon:jsx(a$1,{icon:pn[t]}),endIcon:jsx(a$1,{icon:"ARROW_DOWN_SIMPLE"}),color:"inherit",size:"small",onClick:e,children:nn[t]}),jsxs(a$b,{open:o,onClose:r,disabledArrow:!0,sx:{width:180,p:1},children:[jsx(Se,{variant:"text",startIcon:jsx(a$1,{icon:"CALENDAR_TODAY"}),onClick:()=>i("DAY"),active:t==="DAY",fullWidth:!0,children:"Dia"}),jsx(Se,{variant:"text",startIcon:jsx(a$1,{icon:"COLUMNS"}),onClick:()=>i("WEEK"),active:t==="WEEK",fullWidth:!0,children:"Semana"})]})]})},dn=dl;var fl=()=>{let{visibleDays:o,dateRange:r,handlePreviousWeek:e,handleNextWeek:t}=x(),a=useMemo(()=>{let i=fe(r.start_date),n=fe(r.end_date);if(o===1)return d$1(i.toDate(),"DD [de] MMM [de] YYYY");let l=i.month()===n.month(),d=i.year()===n.year();return l&&d?`${i.format("DD")} - ${d$1(n.toDate(),"DD [de] MMM [de] YYYY")}`:d?`${d$1(i.toDate(),"DD [de] MMM")} - ${d$1(n.toDate(),"DD [de] MMM")}`:`${d$1(i.toDate(),"DD MMM YYYY")} - ${d$1(n.toDate(),"DD MMM YYYY")}`},[r,o]);return jsxs(co,{direction:"row",alignItems:"center",gap:1,children:[jsx(a$d,{label:"Semana anterior",icon:"CHEVRON_LEFT",color:"inherit",size:"small",onClick:e}),jsx(W,{variant:"subtitle1",color:"text.primary",noWrap:!0,children:a}),jsx(a$d,{label:"Pr\xF3xima semana",icon:"CHEVRON_RIGHT",color:"inherit",size:"small",onClick:t})]})},be=fl;var Sl=()=>{let o=b("down","sm"),{selectedPartners:r,selectedProfiles:e,selectedEventTypes:t}=x(),a=useMemo(()=>r.length+e.length+t.length,[r.length,e.length,t.length]),[i,n]=a$a();return jsxs(Fragment,{children:[o?jsxs(rn,{children:[jsx(be,{}),jsx(cn,{badgeContent:a,invisible:a===0,color:"primary",children:jsx(a$d,{label:"Filtrar",icon:"FILTER_LIST",color:"inherit",size:"small",onClick:n})})]}):jsxs(on,{children:[jsx(tn,{children:jsx(dn,{})}),jsx(en,{children:jsx(be,{})}),jsx(an,{children:jsx(cn,{badgeContent:a,invisible:a===0,color:"primary",children:jsx(wn,{variant:"text",startIcon:jsx(a$1,{icon:"FILTER_LIST"}),endIcon:jsx(a$1,{icon:"ARROW_DOWN_SIMPLE"}),color:"inherit",size:"small",onClick:n,children:"Filtrar"})})})]}),jsx(a$c,{open:i,onClose:n,headerTitle:"Filtros",headerProps:{direction:"row-reverse"},contentProps:{p:0},maxWidth:320,children:jsx(Ji,{})})]})},mn=Sl;var kl=({partners:o,summary:r,isFetching:e,isFetchingSummary:t,onRowsScrollEnd:a,isFetchingNextPage:i})=>{let{dateRange:n,scrollRef:l}=x(),d=b("down","sm"),y=useMemo(()=>j(n.start_date,n.end_date),[n.start_date,n.end_date]),f$1=useMemo(()=>[{key:d$2,minWidth:f,defaultWidth:e$1},...y.map((P,L)=>({key:h$1(L),minWidth:g}))],[y]),{columnWidths:u,totalWidth:_,isResizing:D,getColumnResizeProps:E}=a$6({columns:f$1,containerRef:l,enabled:!d}),J=useCallback(()=>{let P=l.current;if(!P||i)return;let{scrollTop:L,scrollHeight:Ro,clientHeight:_r}=P;Ro-L-_r<=a$7&&a();},[l,a,i]);return jsxs(Ii,{variant:"outlined",children:[jsx(mn,{}),jsx(Ri,{ref:l,onScroll:J,children:jsxs(Ai,{stickyHeader:!0,totalWidth:_,isResizing:D,children:[!!u.length&&jsx("colgroup",{children:u.map((P,L)=>jsx("col",{style:{width:P.width}},L))}),jsx(Xe,{days:y,summary:r,isFetchingSummary:t,getColumnResizeProps:E}),jsxs(Oi,{children:[!o.length&&jsxs(Ir,{children:[jsx(wo,{}),y.map((P,L)=>jsx(io,{isToday:P.isSame(fe(),"day")},L))]}),o.map((P,L)=>jsx(_i,{index:L,partner:P,days:y,isFetching:e},P.external_id)),i&&jsx(gn,{children:jsx(Ne,{colSpan:y.length+1,align:"center",sx:{py:2,border:"none"},children:jsx(vl,{size:24})})})]})]})})]})},Dl=kl;
57
+ var wo=styled(Ne,{shouldForwardProp:o=>o!=="cellAlign"})(({theme:o,cellAlign:r="top"})=>({position:"sticky",left:0,zIndex:1,verticalAlign:r,backgroundColor:o.palette.background.paper,[o.breakpoints.down("sm")]:{width:"50%",minWidth:"50%"}})),io=styled(Ne,{shouldForwardProp:o=>o!=="isToday"})(({theme:o,isToday:r})=>({width:"auto",minWidth:"auto",overflow:"hidden",backgroundColor:`${r?o.palette.grey[200]:o.palette.common.white} !important`,verticalAlign:"top"})),Ir=styled(gn)(({theme:o})=>({"& .MuiTableCell-root":{padding:o.spacing(1,2),borderBottom:`1px solid ${o.palette.divider} !important`,borderRight:`1px solid ${o.palette.divider} !important`,"&:last-child":{borderRight:"none !important"}}}));var Me=createContext(null),Tn=({adapters:o,slots:r,children:e})=>{let t=a$4(),a=useMemo(()=>({adapters:o,slots:r,filters:t}),[o,r,t]);return jsx(Me.Provider,{value:a,children:e})},c=()=>{let o=useContext(Me);if(!o)throw new Error("useOrderProjectionContext must be used within an OrderProjectionProvider");return o},x=()=>c().filters;var Fe=styled(a,{shouldForwardProp:o=>o!=="isToday"})(({theme:o,isToday:r})=>({color:r?o.palette.primary.main:o.palette.text.secondary,backgroundColor:r?alpha(o.palette.primary.main,.15):alpha(o.palette.grey[500],.15),cursor:"pointer"}));var Pn=({day:o,summary:r})=>{let e=useMemo(()=>fe().startOf("day"),[]),t=o.isAfter(e,"day"),a=useMemo(()=>{let i=o.format("YYYY-MM-DD"),n=r?.days.find(l=>l.date===i);return {shopping_cart_active:n?.shopping_cart_active??0,order_placed:n?.order_placed??0,order_unplanned:n?.order_unplanned??0,order_planned:n?.order_planned??0,shopping_cart_abandoned:n?.shopping_cart_abandoned??0}},[o,r]);return jsxs(co,{gap:1.5,children:[jsxs(co,{direction:"row",alignItems:"center",gap:1,children:[jsx(a$1,{icon:"CALENDAR_TODAY",color:"grey.400"}),jsx(W,{variant:"caption",fontWeight:"bold",children:"Pedidos"})]}),jsxs(co,{gap:.5,children:[!t&&jsxs(Fragment,{children:[jsxs(W,{variant:"caption",children:["Pedidos em andamento:"," ",jsx("strong",{children:a.shopping_cart_active})]}),jsxs(W,{variant:"caption",children:["Pedidos realizados: ",jsx("strong",{children:a.order_placed})]}),jsxs(W,{variant:"caption",children:["Pedidos fora do padr\xE3o: ",jsx("strong",{children:a.order_unplanned})]})]}),jsxs(W,{variant:"caption",children:["Pedidos previstos: ",jsx("strong",{children:a.order_planned})]}),!t&&jsxs(W,{variant:"caption",children:["Carrinhos abandonados:"," ",jsx("strong",{children:a.shopping_cart_abandoned})]})]})]})},We=Pn;var _n=({day:o,summary:r,isFetchingSummary:e})=>{let t=o.isSame(fe(),"day"),{ordersPlacedCount:a,ordersExpectedCount:i}=useMemo(()=>{let n=o.format("YYYY-MM-DD"),l=r?.days.find(u=>u.date===n),d=l?.order_placed??0,y=l?.order_unplanned??0,f=l?.order_planned??0;return {ordersPlacedCount:d+y,ordersExpectedCount:d+y+f}},[o,r]);return jsx(a$e,{isLoading:e,loading:jsx(Dn,{width:50,height:24}),children:jsx(a$f,{title:jsx(We,{day:o,summary:r}),arrow:!0,children:jsx("span",{children:jsxs(Fe,{variant:"filled",backgroundColor:"#919EAB29",color:"text.secondary",isToday:t,children:[a," de ",i]})})})})},Ge=_n;var An=["Dom.","Seg.","Ter.","Qua.","Qui.","Sex.","S\xE1b."],On=({day:o,index:r,summary:e,isFetchingSummary:t,resize:a})=>{let i=o.isSame(fe(),"day");return jsxs(io,{isToday:i,"data-testid":`day-cell-${r}`,children:[jsxs(co,{direction:"row",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:1,children:[jsxs(co,{children:[jsx(W,{variant:"subtitle2",color:i?"primary.main":"text.secondary",children:o.date()}),jsx(W,{variant:"body2",fontSize:13,color:i?"primary.main":"text.secondary",children:An[o.day()]})]}),jsx(Ge,{day:o,summary:e,isFetchingSummary:t})]}),a&&jsx(a$d,{label:`Redimensionar coluna ${o.format("DD/MM")}`,...a})]})},ze=On;var Nt=styled(wn,{shouldForwardProp:o=>o!=="active"})(({theme:o,active:r})=>({justifyContent:"flex-start",color:r?o.palette.primary.main:o.palette.text.secondary,fontWeight:r?800:400,"&:hover":{background:o.palette.action.hover}}));var Nn=({summary:o})=>jsxs(co,{gap:1.5,children:[jsxs(co,{direction:"row",alignItems:"center",gap:1,children:[jsx(a$1,{icon:"USER_GROUP",color:"grey.400"}),jsx(W,{variant:"caption",fontWeight:"bold",children:"Clientes"})]}),jsx(co,{gap:.5,children:jsxs(W,{variant:"caption",children:["Total de clientes: ",jsx("strong",{children:o?.partner_count??0})]})})]}),Ue=Nn;var Fn=({summary:o,isFetchingSummary:r,resize:e})=>{let{open:t,onClose:a$1,onOpen:i}=a$8(),{ascending:n,setAscending:l}=x(),d=useCallback(y=>{l(y),a$1();},[a$1,l]);return jsxs(Fragment,{children:[jsxs(wo,{cellAlign:"center",children:[jsxs(co,{direction:"row",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:1,children:[jsxs(co,{direction:"row",alignItems:"center",gap:1,children:[jsx(W,{variant:"caption",color:"text.primary",children:"Clientes"}),jsx(a$e,{isLoading:r,loading:jsx(a$7,{width:26,height:24}),children:jsx(a$f,{title:jsx(Ue,{summary:o}),arrow:!0,children:jsx("span",{children:jsx(a,{variant:"filled",backgroundColor:"#919EAB29",color:"text.secondary",sx:{cursor:"pointer"},children:o?.partner_count??0})})})})]}),jsx(a$c,{label:"Selecionar ordena\xE7\xE3o",icon:"SORTING_AZ_02",color:"text.secondary",size:"small",onClick:i})]}),e&&jsx(a$d,{label:"Redimensionar coluna Clientes",...e})]}),jsxs(a$a,{open:t,onClose:a$1,disabledArrow:!0,sx:{width:180,p:1},children:[jsx(Nt,{variant:"text",onClick:()=>d(!0),active:n,fullWidth:!0,children:"De A \xE0 Z"}),jsx(Nt,{variant:"text",onClick:()=>d(!1),active:!n,fullWidth:!0,children:"De Z \xE0 A"})]})]})},qe=Fn;var Qe=styled(Gn)(({theme:o})=>({"& .MuiTableCell-root":{padding:o.spacing(1,2),borderTop:`1px solid ${o.palette.divider} !important`,borderBottom:`1px solid ${o.palette.divider} !important`,borderRight:`1px solid ${o.palette.divider} !important`,background:o.palette.common.white,"&:last-child":{borderRight:"none !important"}},"& .MuiTableCell-root:first-of-type":{zIndex:3}}));var Vn=({days:o,summary:r,isFetchingSummary:e,getColumnResizeProps:t})=>jsx(Qe,{children:jsxs(gn,{children:[jsx(qe,{summary:r,isFetchingSummary:e,resize:t(l)}),o.map((a,i)=>jsx(ze,{index:i,day:a,summary:r,isFetchingSummary:e,resize:t(p(i))},i))]})}),Xe=Vn;var $n={["PAST"]:{icon:jsx(a$1,{icon:"HEXAGON_WARNING",color:"#FF5630",width:24}),message:jsxs(Fragment,{children:["O cliente deveria ter feito pedido, conforme sua frequ\xEAncia de compra, mas nenhum pedido foi registrado. Esse comportamento pode indicar"," ",jsx("strong",{children:"queda de engajamento"})," ou"," ",jsx("strong",{children:"risco de inativa\xE7\xE3o"}),"."]})},["TODAY"]:{icon:jsx(a$1,{icon:"WARNING_TRIANGLE_SOLID",color:"#FFAB00",width:24}),message:jsx(Fragment,{children:"Conforme a frequ\xEAncia de compra deste cliente, um pedido era esperado hoje, mas nenhum registro foi feito at\xE9 o momento."})},["FUTURE"]:{icon:jsx(a$1,{icon:"INFO",color:"common.black",width:24}),message:jsxs(Fragment,{children:["Baseado na rotina de compras identificada."," ",jsx("strong",{children:"Nenhuma a\xE7\xE3o \xE9 necess\xE1ria no momento"}),"."]})}},Ke={["ORDER_UNPLANNED"]:()=>{let o=u("ORDER_UNPLANNED");return {icon:jsx(a$1,{icon:"INFO",color:"#00B8D9",width:24}),message:jsxs(Fragment,{children:["O cliente realizou um pedido em um dia diferente da sua rotina habitual. Isso pode indicar uma"," ",jsx("strong",{children:"mudan\xE7a de comportamento de compra"})," ou uma"," ",jsx("strong",{children:"demanda excepcional"}),"."]}),background:o.background,color:o.color}},["ORDER_PLANNED"]:({referenceDate:o})=>{let{period:r}=t(o||new Date),e=u("ORDER_PLANNED",r),{icon:t$1,message:a}=$n[r];return {icon:t$1,message:a,background:e.background,color:e.color}},["SHOPPING_CART_ACTIVE"]:()=>{let o=u("SHOPPING_CART_ACTIVE");return {icon:jsx(a$1,{icon:"WARNING_TRIANGLE_SOLID",color:"#FFAB00",width:24}),message:jsx(Fragment,{children:"O cliente est\xE1 atualizando o carrinho neste momento."}),background:o.background,color:o.color}},["SHOPPING_CART_ABANDONED"]:({referenceDate:o})=>{let r=u("SHOPPING_CART_ABANDONED");return {icon:jsx(a$1,{icon:"HEXAGON_WARNING",color:"#FF5630",width:24}),message:jsxs(Fragment,{children:["Carrinho est\xE1 abandonado h\xE1 ",jsx("strong",{children:g(o)}),"."]}),background:r.background,color:r.color}}};var Je=styled(Un,{shouldForwardProp:o=>o!=="customBackground"&&o!=="customColor"})(({theme:o,customBackground:r,customColor:e})=>({padding:o.spacing(1.5,2),borderRadius:0,borderBottom:`1px solid ${o.palette.divider}`,background:r,color:e}));var qn=({origin:o,referenceDate:r})=>{let e=Ke[o];if(!e)return null;let t=e({origin:o,referenceDate:r});return t?jsx(Je,{icon:t.icon,customBackground:t.background,customColor:t.color,children:t.message}):null},Ze=qn;var Zn=({message:o,onRetry:r,isFetching:e})=>jsxs(co,{alignItems:"center",justifyContent:"center",p:3,gap:.5,children:[jsx(W,{variant:"body2",color:"text.secondary",children:o}),jsx(Xn,{variant:"text",startIcon:jsx(a$1,{icon:"REFRESH_CHANGE"}),size:"small",onClick:r,loading:e,children:"Tentar novamente"})]}),no=Zn;var rp=()=>jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Resumo do pedido"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"ID"}),jsx(a$7,{width:"20%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Data e hora"}),jsx(a$7,{width:"30%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Valor do pedido"}),jsx(a$7,{width:"20%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{gap:.5,children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Status do pedido"}),jsx(a$7,{width:"30%",height:22})]})]}),jsxs(co,{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"},gap:1.5,children:[jsx(a$7,{width:"100%",height:30}),jsx(a$7,{width:"100%",height:30})]})]}),oa=rp;var ep=({eventId:o})=>{let{adapters:r,slots:e}=c(),{useEventDetails:t}=r,{renderEventStatus:a,renderEventActions:i}=e,{data:n,isLoading:l,isFetching:d,isError:y,refetch:f}=t(o,{skip:!o}),u=n?.detail?.sale_external_id||n?.detail?.external_id,_=l||d,D=n?.external_origin==="SALE";return jsx(a$e,{isLoading:_,loading:jsx(oa,{}),anError:y,error:jsx(no,{message:"N\xE3o foi poss\xEDvel carregar os detalhes do pedido realizado!",onRetry:f,isFetching:d}),children:jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Resumo do pedido"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"ID"}),jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:u?`#${u}`:"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Data e hora"}),jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:d$1(n?.detail?.created_at,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Valor do pedido"}),jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:h(n?.detail?.total_value??n?.amount_value)})]}),n&&a?.(n)]}),jsxs(co,{gap:1.5,children:[n&&i?.(n),!D&&jsx(Un,{severity:"warning",children:"Este pedido foi importado do ERP. Para visualizar detalhes ou realizar a\xE7\xF5es, acesse o sistema ERP."})]})]})})},ta=ep;var ap=({period:o})=>{let r=o==="PAST",e=o==="FUTURE";return jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:e?"Comportamento de compra":"Resumo"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Data prevista"}),jsx(a$7,{width:"20%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Frequ\xEAncia de compras"}),jsx(a$7,{width:"30%",height:22})]}),r&&jsxs(Fragment,{children:[jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Per\xEDodo desde o \xFAltimo pedido"}),jsx(a$7,{width:"20%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"\xDAltimo pedido"}),jsx(a$7,{width:"50%",height:22})]})]})]}),jsxs(co,{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"},gap:1,children:[jsx(a$7,{width:"100%",height:30}),jsx(a$7,{width:"100%",height:30})]})]})},ea=ap;var np=({eventId:o})=>{let{adapters:r,slots:e}=c(),{useEventDetails:t$1}=r,{renderEventActions:a,renderSaleLink:i}=e,{data:n,isLoading:l,isFetching:d,isError:y,refetch:f}=t$1(o,{skip:!o}),{period:u}=t(n?.reference_date??new Date),_=u==="PAST",D=u==="FUTURE",E=n?.partner?.sale_analysis?.last_sale_sale_external_id||n?.partner?.sale_analysis?.last_sale_external_id,J=n?.partner?.sale_analysis?.last_sale_negotiation_date;return jsx(a$e,{isLoading:l,loading:jsx(ea,{period:u}),anError:y,error:jsx(no,{message:"N\xE3o foi poss\xEDvel carregar os detalhes do pedido previsto!",onRetry:f,isFetching:d}),children:jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:D?"Comportamento de compra":"Resumo"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Data prevista"}),jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:d$1(n?.reference_date,"DD/MM/YYYY")})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Frequ\xEAncia de compras"}),jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:s(n?.partner?.recurrence)})]}),_&&jsxs(Fragment,{children:[jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Per\xEDodo desde o \xFAltimo pedido"}),jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:J?g(J):"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"\xDAltimo pedido"}),E?jsxs(co,{direction:"row",alignItems:"center",gap:.5,children:[i?.(E),jsxs(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:["em ",d$1(J,"DD/MM/YYYY [\xE0s] HH:mm")]})]}):jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:"-"})]})]})]}),n&&a?.(n)]})})},aa=np;var sp=()=>jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Resumo do pedido"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"ID"}),jsx(a$7,{width:"30%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Data e hora"}),jsx(a$7,{width:"25%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Valor do pedido"}),jsx(a$7,{width:"20%",height:22})]})]}),jsx(Xo,{sx:{mx:-3}}),jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Comportamento de compra"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Frequ\xEAncia de compras"}),jsx(a$7,{width:"35%",height:22})]})]}),jsxs(co,{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"},gap:1,children:[jsx(a$7,{width:"100%",height:30}),jsx(a$7,{width:"100%",height:30})]})]}),ia=sp;var dp=({eventId:o})=>{let{adapters:r,slots:e}=c(),{useEventDetails:t}=r,{renderEventActions:a}=e,{data:i,isLoading:n,isFetching:l,isError:d,refetch:y}=t(o,{skip:!o}),f=i?.detail?.sale_external_id||i?.detail?.external_id;return jsx(a$e,{isLoading:n,loading:jsx(ia,{}),anError:d,error:jsx(no,{message:"N\xE3o foi poss\xEDvel carregar os detalhes do pedido!",onRetry:y,isFetching:l}),children:jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Resumo do pedido"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"ID"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:f?`#${f}`:"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Data e hora"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:d$1(i?.reference_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Valor do pedido"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:h(i?.amount_value)})]})]}),jsx(Xo,{sx:{mx:-3}}),jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Comportamento de compra"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Frequ\xEAncia de compras"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:s(i?.partner?.recurrence)})]})]}),i&&a?.(i)]})})},na=dp;var lp=()=>jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Informa\xE7\xF5es do carrinho"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Tempo decorrido desde o abandono"}),jsx(a$7,{width:"30%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Modelo de pedido"}),jsx(a$7,{width:"40%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Forma de pagamento"}),jsx(a$7,{width:"40%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Valor do carrinho"}),jsx(a$7,{width:"20%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Endere\xE7o"}),jsx(a$7,{width:"80%",height:22})]})]}),jsx(a$7,{width:"100%",height:30})]}),pa=lp;var yp=({eventId:o})=>{let{adapters:r,slots:e}=c(),{useEventDetails:t}=r,{formatAddress:a}=e,{data:i,isLoading:n,isFetching:l,isError:d,refetch:y}=t(o,{skip:!o});return jsx(a$e,{isLoading:n,loading:jsx(pa,{}),anError:d,error:jsx(no,{message:"N\xE3o foi poss\xEDvel carregar os detalhes do carrinho abandonado!",onRetry:y,isFetching:l}),children:jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Informa\xE7\xF5es do carrinho"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Tempo decorrido desde o abandono"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:d$1(i?.detail?.abandoned_at,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Modelo de pedido"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:i?.detail?.new_order?.name??"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Forma de pagamento"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:i?.detail?.payment_method?.name??"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Valor do carrinho"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:h(i?.detail?.total??i?.amount_value)})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Endere\xE7o"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:a(i?.detail?.address)})]})]}),jsx(wn,{component:si,href:`https://wa.me/${i?.partner?.phone}`,target:"_blank",rel:"noopener noreferrer",variant:"outlined",startIcon:jsx(a$1,{icon:"WHATSAPP",color:"success.main"}),color:"inherit",size:"small",disabled:!i?.partner?.phone,children:"Enviar mensagem"})]})})},sa=yp;var fp=()=>jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Resumo do carrinho"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Modelo de pedido"}),jsx(a$7,{width:"40%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Forma de pagamento"}),jsx(a$7,{width:"30%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Valor do carrinho"}),jsx(a$7,{width:"20%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Endere\xE7o"}),jsx(a$7,{width:"80%",height:22})]})]}),jsx(a$7,{width:"100%",height:30})]}),da=fp;var hp=({eventId:o})=>{let{adapters:r,slots:e}=c(),{useEventDetails:t}=r,{formatAddress:a}=e,{data:i,isLoading:n,isFetching:l,isError:d,refetch:y}=t(o,{skip:!o});return jsx(a$e,{isLoading:n,loading:jsx(da,{}),anError:d,error:jsx(no,{message:"N\xE3o foi poss\xEDvel carregar os detalhes do carrinho!",onRetry:y,isFetching:l}),children:jsxs(co,{gap:3,p:3,children:[jsxs(co,{gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Resumo do carrinho"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Modelo de pedido"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:i?.detail?.new_order?.name??"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Forma de pagamento"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:i?.detail?.payment_method?.name??"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Valor do carrinho"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:h(i?.detail?.total??i?.amount_value)})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Endere\xE7o"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:a(i?.detail?.address)})]})]}),jsx(wn,{component:si,href:`https://wa.me/${i?.partner?.phone}`,target:"_blank",rel:"noopener noreferrer",variant:"outlined",startIcon:jsx(a$1,{icon:"WHATSAPP",color:"success.main"}),color:"inherit",size:"small",disabled:!i?.partner?.phone,children:"Enviar mensagem"})]})})},la=hp;var Sp={["ORDER_PLACED"]:ta,["ORDER_UNPLANNED"]:na,["ORDER_PLANNED"]:aa,["SHOPPING_CART_ACTIVE"]:la,["SHOPPING_CART_ABANDONED"]:sa},Tp=({origin:o,eventId:r})=>{let e=Sp[o];return e?jsx(e,{eventId:r}):null},jt=Tp;var vp=({events:o})=>{let{getEventCode:r}=c().slots;if(o.length<=1){let e=o[0];return e?jsx(jt,{origin:e.type,eventId:e.id}):null}return jsx(Fragment,{children:o.map(e=>jsxs(a$g,{slotProps:{transition:{unmountOnExit:!0}},children:[jsx(b$1,{children:jsxs(W,{variant:"overline",color:"text.secondary",children:["Pedido:\u2002",jsxs(W,{component:"span",variant:"body2",fontWeight:600,color:"text.primary",children:["#",r(e)]})]})}),jsx(c$1,{sx:{p:0,mt:-2},children:jsx(jt,{origin:e.type,eventId:e.id})})]},e.id))})},ma=vp;var xp=()=>jsxs(co,{p:3,gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Informa\xE7\xF5es do cliente"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Nome"}),jsx(a$7,{width:"40%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"CPF/CNPJ"}),jsx(a$7,{width:"30%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,children:[jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Telefone"}),jsx(a$7,{width:"100%",height:22})]}),jsx(wn,{variant:"text",startIcon:jsx(a$1,{icon:"PENCIL_EDIT"}),color:"inherit",size:"small",disabled:!0,children:"Editar"})]})]}),fa=xp;var Dp=({partner:o,isLoading:r,onPhoneUpdated:e})=>{let{renderPartnerLink:t,renderPhoneEditor:a}=c().slots;return jsx(a$e,{isLoading:r,loading:jsx(fa,{}),children:jsxs(co,{p:3,gap:1,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Informa\xE7\xF5es do cliente"}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Nome"}),t?t(o):jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:o?.name||"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"CPF/CNPJ"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:o?.tax_id?i$1(o.tax_id):"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,children:[jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Telefone"}),o?.phone?jsx(si,{href:`https://wa.me/${o.phone}`,target:"_blank",rel:"noopener noreferrer",color:"#22C55E",children:jsxs(co,{direction:"row",alignItems:"center",gap:1,children:[jsx(a$1,{icon:"WHATSAPP",color:"#22C55E"}),jsx(W,{variant:"subtitle2",color:"success.main",children:h$1(o.phone)})]})}):jsx(W,{variant:"subtitle2",color:"text.primary",children:"-"})]}),a?.(o?.external_id??"",e??(()=>{}))]})]})})},ua=Dp;var ha=styled(co,{shouldForwardProp:o=>o!=="customBackground"&&o!=="customColor"})(({theme:o,customBackground:r,customColor:e})=>({padding:o.spacing(.5,1),borderRadius:4,background:r,color:e}));var Lp=({open:o,onClose:r,events:e})=>{let t$1=e[0],[a,i]=useState(),{useEventDetails:n}=c().adapters,{data:l,isLoading:d,refetch:y}=n(t$1?.id??"",{skip:!o||!t$1?.id}),{period:f}=t(t$1?.reference_date??new Date),u$1=u(t$1?.type,f),_=useCallback(D=>{i(D),y();},[y]);return jsxs(a$b,{open:o,onClose:r,headerTitle:jsxs(Fragment,{children:["Detalhes"," ",jsx(ha,{customBackground:u$1.background,customColor:u$1.color,children:jsx(W,{variant:"subtitle2",fontSize:13,noWrap:!0,children:u$1.label})})]}),headerProps:{direction:"row-reverse"},contentProps:{p:0},maxWidth:520,children:[jsx(co,{position:"sticky",top:0,zIndex:9,children:jsx(Ze,{origin:t$1?.type,referenceDate:t$1?.reference_date})}),jsx(ua,{partner:l?.partner?{...l.partner,phone:a??l.partner.phone}:void 0,isLoading:d,onPhoneUpdated:_}),jsx(Xo,{}),jsx(ma,{events:e})]})},yt=Lp;var Mp=({icon:o,title:r,description:e,details:t,footer:a})=>jsxs(co,{gap:1,children:[jsxs(co,{direction:"row",alignItems:"center",gap:.5,children:[o,jsx(W,{variant:"caption",fontWeight:"bold",children:r})]}),jsx(W,{variant:"caption",children:e}),t&&jsxs(Fragment,{children:[jsx(Xo,{sx:{borderStyle:"dashed"}}),jsx(co,{children:t})]}),a&&jsxs(Fragment,{children:[jsx(Xo,{sx:{borderStyle:"dashed"}}),a]})]}),X=Mp;var Bp=({event:o})=>{let{getEventCode:r}=c().slots;return jsx(X,{icon:jsx(a$1,{icon:"CHECK_CIRCLE",color:"#22C55E"}),title:"Pedido realizado",description:"Pedido realizado com sucesso!",details:jsxs(Fragment,{children:[jsxs(W,{variant:"caption",children:["ID:"," ",jsx("strong",{children:r(o)?`#${r(o)}`:"-"})]}),jsxs(W,{variant:"caption",children:["Data e hora:"," ",jsx("strong",{children:d$1(o.reference_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsxs(W,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(o.amount_value)})]})]})})},Ca=Bp;var Yp=({event:o})=>{let{period:r}=t(o.reference_date);return r==="PAST"?jsx(X,{icon:jsx(a$1,{icon:"HEXAGON_WARNING",color:"#FF5630"}),title:"Pedido n\xE3o realizado",description:"Cliente n\xE3o realizou o pedido previsto na data esperada.",details:jsxs(W,{variant:"caption",children:["Data prevista:"," ",jsx("strong",{children:d$1(o.reference_date,"DD/MM/YYYY")})]})}):r==="TODAY"?jsx(X,{icon:jsx(a$1,{icon:"WARNING_TRIANGLE_SOLID",color:"#FFAB00"}),title:"Pedido previsto para hoje",description:"Nenhum pedido registrado at\xE9 o momento.",details:jsxs(W,{variant:"caption",children:["Valor previsto: ",jsx("strong",{children:h(o.amount_value)})]})}):jsx(X,{icon:jsx(a$1,{icon:"CALENDAR_TODAY",color:"#C4CDD5"}),title:"Pedido previsto",description:"Pr\xF3ximo pedido estimado conforme padr\xE3o de frequ\xEAncia.",details:jsxs(W,{variant:"caption",children:["Data prevista:"," ",jsx("strong",{children:d$1(o.reference_date,"DD/MM/YYYY")})]})})},Pa=Yp;var Wp=({event:o})=>{let{getEventCode:r}=c().slots;return jsx(X,{icon:jsx(a$1,{icon:"INFO",color:"#00B8D9"}),title:"Pedido fora do padr\xE3o",description:"Pedido feito em dia n\xE3o previsto pela frequ\xEAncia.",details:jsxs(Fragment,{children:[jsxs(W,{variant:"caption",children:["ID:"," ",jsx("strong",{children:r(o)?`#${r(o)}`:"-"})]}),jsxs(W,{variant:"caption",children:["Data e hora:"," ",jsx("strong",{children:d$1(o.reference_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsxs(W,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(o.amount_value)})]})]})})},xa=Wp;var Hp=({event:o})=>jsx(X,{icon:jsx(a$1,{icon:"CANCEL_CIRCLE_SOLID",color:"#FF5630"}),title:"Carrinho abandonado",description:jsxs(Fragment,{children:["Carrinho inativo h\xE1 ",jsx("strong",{children:g(o.reference_date)})," \u2014 valor estimado: ",jsx("strong",{children:h(o.amount_value)}),"."]}),details:jsxs(Fragment,{children:[jsxs(W,{variant:"caption",children:["ID:"," ",jsx("strong",{children:o.external_id?`#${o.external_id}`:"-"})]}),jsxs(W,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(o.amount_value)})]})]})}),Ea=Hp;var zp=({event:o})=>jsx(X,{icon:jsx(a$1,{icon:"WARNING_TRIANGLE_SOLID",color:"#FFAB00"}),title:"Pedido em andamento",description:"Cliente est\xE1 atualizando o carrinho neste momento.",details:jsxs(W,{variant:"caption",children:["Valor parcial: ",jsx("strong",{children:h(o.amount_value)})]})}),_a=zp;var re={color:"common.white",width:16,height:16,sx:{flexShrink:0}},Ia={["ORDER_PLACED"]:{getIcon:()=>null,getTitle:()=>"Pedido realizado",getDescription:()=>"Pedido confirmado com sucesso!",getTooltip:o=>jsx(Ca,{event:o})},["ORDER_UNPLANNED"]:{getIcon:()=>null,getTitle:()=>"Pedido fora do padr\xE3o",getDescription:()=>"Pedido feito fora do dia habitual.",getTooltip:o=>jsx(xa,{event:o})},["ORDER_PLANNED"]:{getIcon:o=>{let{period:r}=t(o.reference_date);return r==="PAST"?jsx(a$1,{icon:"HEXAGON_WARNING",...re}):r==="TODAY"?jsx(a$1,{icon:"WARNING_TRIANGLE_SOLID",...re}):null},getTitle:o=>{let{period:r}=t(o.reference_date);return r==="PAST"?"Pedido n\xE3o realizado":r==="TODAY"?"Pedido previsto para hoje":"Pedido previsto"},getDescription:o=>{let{period:r}=t(o.reference_date);return r==="PAST"?"Cliente n\xE3o realizou o pedido previsto na data esperada.":r==="TODAY"?"Nenhum pedido registrado at\xE9 o momento.":"Pr\xF3ximo pedido estimado conforme padr\xE3o de frequ\xEAncia."},getTooltip:o=>jsx(Pa,{event:o})},["SHOPPING_CART_ACTIVE"]:{getIcon:()=>null,getTitle:()=>"Pedido em andamento",getDescription:()=>"Cliente est\xE1 atualizando o carrinho neste momento.",getTooltip:o=>jsx(_a,{event:o})},["SHOPPING_CART_ABANDONED"]:{getIcon:()=>jsx(a$1,{icon:"CANCEL_CIRCLE_SOLID",...re}),getTitle:()=>"Carrinho abandonado",getDescription:o=>`Carrinho inativo h\xE1 ${g(o.reference_date)} \u2014 valor estimado: ${h(o.amount_value)}.`,getTooltip:o=>jsx(Ea,{event:o})}};var Oa=styled(co,{shouldForwardProp:o=>o!=="eventType"&&o!=="period"})(({theme:o,eventType:r,period:e})=>{let t=u(r,e);return {position:"relative",padding:o.spacing(.5,1),borderRadius:4,background:t.background,color:t.color,cursor:"pointer","&:hover":{background:t.backgroundHover}}}),wa=styled(co,{shouldForwardProp:o=>o!=="eventType"&&o!=="period"})(({theme:o,eventType:r,period:e})=>({position:"absolute",top:-5,right:-5,width:20,height:20,alignItems:"center",justifyContent:"center",borderRadius:"50%",background:u(r,e).iconBadgeColor,boxShadow:`0 0 0 2px ${o.palette.common.white}`}));var Up=({event:o,index:r})=>{let[e,t$1]=a$9(),a=Ia[o.type];if(!a)return null;let{period:i}=t(o.reference_date),n=a.getIcon(o);return jsxs(Fragment,{children:[jsx(a$f,{title:a.getTooltip(o),arrow:!0,children:jsxs(Oa,{"data-testid":`event-${r}`,eventType:o.type,period:i,onClick:t$1,children:[n&&jsx(wa,{eventType:o.type,period:i,children:n}),jsx(W,{variant:"subtitle2",fontSize:13,noWrap:!0,children:a.getTitle(o)}),jsx(W,{variant:"caption",noWrap:!0,children:a.getDescription(o)})]})}),jsx(yt,{open:e,onClose:t$1,events:[o]})]})},Ma=Up;var Qp=({icon:o,title:r,description:e,children:t})=>jsxs(co,{gap:1,children:[jsxs(co,{direction:"row",alignItems:"center",gap:.5,children:[o,jsx(W,{variant:"caption",fontWeight:"bold",children:r})]}),jsx(W,{variant:"caption",children:e}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsx(co,{gap:1,children:t})]}),lo=Qp;var Kp=({events:o})=>{let{getEventCode:r}=c().slots,e=o.slice(0,k),t=o.length-k;return jsxs(lo,{icon:jsx(a$1,{icon:"CHECK_CIRCLE",color:"#22C55E"}),title:"Pedidos realizados",description:"Pedidos realizados com sucesso!",children:[e.map((a,i)=>jsxs(co,{children:[i>0&&jsx(Xo,{sx:{borderStyle:"dashed",mb:1}}),jsxs(W,{variant:"caption",children:["ID:"," ",jsx("strong",{children:r(a)?`#${r(a)}`:"-"})]}),jsxs(W,{variant:"caption",children:["Data/Hora:"," ",jsx("strong",{children:d$1(a.reference_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsxs(W,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(a.amount_value)})]})]},a.id)),t>0&&jsxs(Fragment,{children:[jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(W,{variant:"caption",children:["e mais ",t," pedido",t>1?"s":""]})]})]})},Wa=Kp;var os={["PAST"]:jsx(a$1,{icon:"HEXAGON_WARNING",color:"#FF5630"}),["TODAY"]:jsx(a$1,{icon:"WARNING_TRIANGLE_SOLID",color:"#FFAB00"}),["FUTURE"]:jsx(a$1,{icon:"CALENDAR_TODAY",color:"#C4CDD5"})},rs={["PAST"]:"Pedidos n\xE3o realizados",["TODAY"]:"Pedidos previstos para hoje",["FUTURE"]:"Pedidos previstos"},ts={["PAST"]:"Clientes n\xE3o realizaram os pedidos previstos na data esperada.",["TODAY"]:"Nenhum pedido registrado at\xE9 o momento.",["FUTURE"]:"Pr\xF3ximos pedidos estimados conforme padr\xE3o de frequ\xEAncia."},es=({events:o})=>{let{period:r}=t(o[0]?.reference_date),e=o.slice(0,k),t$1=o.length-k;return jsxs(lo,{icon:os[r],title:rs[r],description:ts[r],children:[e.map((a,i)=>jsxs(co,{children:[i>0&&jsx(Xo,{sx:{borderStyle:"dashed",mb:1}}),jsxs(W,{variant:"caption",children:["Data prevista:"," ",jsx("strong",{children:d$1(a.reference_date,"DD/MM/YYYY")})]})]},a.id)),t$1>0&&jsxs(Fragment,{children:[jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(W,{variant:"caption",children:["e mais ",t$1," pedido",t$1>1?"s":""]})]})]})},Va=es;var ns=({events:o})=>{let{getEventCode:r}=c().slots,e=o.slice(0,k),t=o.length-k;return jsxs(lo,{icon:jsx(a$1,{icon:"INFO",color:"#00B8D9"}),title:"Pedidos fora do padr\xE3o",description:"Pedidos feitos em dias n\xE3o previstos pela frequ\xEAncia.",children:[e.map((a,i)=>jsxs(co,{children:[i>0&&jsx(Xo,{sx:{borderStyle:"dashed",mb:1}}),jsxs(W,{variant:"caption",children:["ID:"," ",jsx("strong",{children:r(a)?`#${r(a)}`:"-"})]}),jsxs(W,{variant:"caption",children:["Data/Hora:"," ",jsx("strong",{children:d$1(a.reference_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsxs(W,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(a.amount_value)})]})]},a.id)),t>0&&jsxs(Fragment,{children:[jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(W,{variant:"caption",children:["e mais ",t," pedido",t>1?"s":""]})]})]})},$a=ns;var ds=({events:o})=>{let r=o.slice(0,k),e=o.length-k;return jsxs(lo,{icon:jsx(a$1,{icon:"CANCEL_CIRCLE_SOLID",color:"#FF5630"}),title:"Carrinhos abandonados",description:"Carrinhos inativos h\xE1 algum tempo.",children:[r.map((t,a)=>jsxs(co,{children:[a>0&&jsx(Xo,{sx:{borderStyle:"dashed",mb:1}}),jsxs(W,{variant:"caption",children:["ID:"," ",jsx("strong",{children:t.external_id?`#${t.external_id}`:"-"})]}),jsxs(W,{variant:"caption",children:["Inativo h\xE1: ",jsx("strong",{children:g(t.reference_date)})]}),jsxs(W,{variant:"caption",children:["Valor: ",jsx("strong",{children:h(t.amount_value)})]})]},t.id)),e>0&&jsxs(Fragment,{children:[jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(W,{variant:"caption",children:["e mais ",e," carrinho",e>1?"s":""]})]})]})},ja=ds;var ms=({events:o})=>{let r=o.slice(0,k),e=o.length-k;return jsxs(lo,{icon:jsx(a$1,{icon:"WARNING_TRIANGLE_SOLID",color:"#FFAB00"}),title:"Pedidos em andamento",description:"Clientes est\xE3o atualizando seus carrinhos neste momento.",children:[r.map((t,a)=>jsxs(co,{children:[a>0&&jsx(Xo,{sx:{borderStyle:"dashed",mb:1}}),jsxs(W,{variant:"caption",children:["ID:"," ",jsx("strong",{children:t.external_id?`#${t.external_id}`:"-"})]}),jsxs(W,{variant:"caption",children:["Valor parcial: ",jsx("strong",{children:h(t.amount_value)})]})]},t.id)),e>0&&jsxs(Fragment,{children:[jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(W,{variant:"caption",children:["e mais ",e," carrinho",e>1?"s":""]})]})]})},Qa=ms;var Xa={["ORDER_PLACED"]:Wa,["ORDER_UNPLANNED"]:$a,["ORDER_PLANNED"]:Va,["SHOPPING_CART_ACTIVE"]:Qa,["SHOPPING_CART_ABANDONED"]:ja};var Ka=styled(co,{shouldForwardProp:o=>o!=="customBackground"&&o!=="customColor"&&o!=="customHoverBackground"})(({theme:o,customBackground:r,customColor:e,customHoverBackground:t})=>({padding:o.spacing(.5,1),borderRadius:4,background:r,color:e,cursor:"pointer","&:hover":{background:t}}));var hs=({group:o,index:r})=>{let[e,t]=a$9(),{config:a,count:i,events:n}=o,l=i>1?a.labelPlural:a.label,d=Xa[n[0].type];return jsxs(Fragment,{children:[jsx(a$f,{title:jsx(d,{events:n}),arrow:!0,children:jsx(Ka,{"data-testid":`grouped-events-${r}`,customBackground:a.background,customColor:a.color,customHoverBackground:a.backgroundHover,onClick:t,children:jsxs(W,{variant:"subtitle2",fontSize:13,title:`${i} ${l}`,noWrap:!0,children:[jsx("strong",{children:i})," ",l]})})}),jsx(yt,{open:e,onClose:t,events:n})]})},Za=hs;var bs=({events:o})=>{let r=useMemo(()=>{let e={};return o.forEach(t$1=>{let a=t$1.type==="ORDER_PLANNED"?u(t$1.type,t(t$1.reference_date).period):u(t$1.type);e[a.label]||(e[a.label]={count:0,config:a,events:[]}),e[a.label].count+=1,e[a.label].events.push(t$1);}),Object.values(e)},[o]);return jsx(Fragment,{children:r.map((e,t)=>jsx(Za,{index:t,group:e},t))})},ri=bs;var ti=styled(co)({gap:4});var ks=({events:o,day:r,index:e})=>{let t=r.isSame(fe(),"day");if(o.length===0)return jsx(io,{isToday:t,"data-testid":`day-column-${e}`});let a=o.length>j;return jsx(io,{isToday:t,"data-testid":`day-column-${e}`,children:jsx(ti,{children:a?jsx(ri,{events:o}):o.map((i,n)=>jsx(Ma,{index:n,event:i},n))})})},ei=ks;var Es=({day:o,index:r,events:e,isFetching:t})=>{let a=o.isSame(fe(),"day");return t?jsx(io,{isToday:a,"data-testid":`day-column-${r}`,children:jsx(a$7,{width:"100%",height:"100%",sx:{maxHeight:46.42}})}):jsx(ei,{events:e,day:o,index:r})},ai=Es;var ii=styled(_s)(()=>({width:6,height:6,borderRadius:"50%",flexShrink:0}));var Os=({status:o,variant:r="body2",color:e="text.primary"})=>{let t=e$1[o];if(!t)return null;let{label:a,color:i}=t;return jsxs(co,{direction:"row",alignItems:"center",gap:1,children:[jsx(ii,{bgcolor:i}),jsx(W,{variant:r,color:e,noWrap:!0,children:a})]})},Ct=Os;var Ns=()=>jsxs(co,{mt:-1,px:1,gap:1,children:[jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Nome"}),jsx(a$7,{width:"40%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"CPF/CNPJ"}),jsx(a$7,{width:"30%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"E-mail"}),jsx(a$7,{width:"35%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Status do cliente"}),jsx(a$7,{width:"20%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{gap:.5,children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Segmento"}),jsx(a$7,{width:"35%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,children:[jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Telefone"}),jsx(a$7,{width:"100%",height:22})]}),jsx(wn,{variant:"text",startIcon:jsx(a$1,{icon:"PENCIL_EDIT"}),color:"inherit",size:"small",disabled:!0,children:"Editar"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Telefone"}),jsx(a$7,{width:"20%",height:22})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Vendedor preferencial"}),jsx(a$7,{width:"40%",height:22})]})]}),pi=Ns;var Ys=({partner:o,onPhoneUpdated:r})=>{let[e,t]=a$9(!0),{adapters:a,slots:i}=c(),{renderPartnerLink:n,renderPhoneEditor:l}=i,{data:d,isLoading:y,refetch:f}=a.usePartnerDetails(o.external_id,{skip:!o.external_id||!e}),u=d?.mobile??d?.phone,_=useMemo(()=>d?.fiscal_registration_number?i$1(d?.fiscal_registration_number):"-",[d?.fiscal_registration_number]),D=useCallback(E=>{f(),r?.(E);},[f,r]);return jsxs(a$g,{expanded:e,onChange:t,defaultExpanded:!0,children:[jsx(b$1,{children:jsx(W,{variant:"overline",color:"text.secondary",children:"Informa\xE7\xF5es"})}),jsx(c$1,{children:jsx(a$e,{isLoading:y,loading:jsx(pi,{}),children:jsxs(co,{mt:-1,px:1,gap:1,children:[jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Nome"}),n?n(d):jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:o?.name||"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"CPF/CNPJ"}),jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:_})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"E-mail"}),jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:d?.email||"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Status do cliente"}),o.classification?jsx(Ct,{status:o.classification,variant:"subtitle2",color:"text.primary"}):jsx(W,{variant:"subtitle2",color:"text.primary",children:"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{gap:.5,children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Segmento"}),d?.profile?.name?jsx(Fs,{variant:"outlined",label:d.profile.name,size:"small",color:"default",sx:{width:"fit-content"}}):jsx(W,{variant:"subtitle2",color:"text.primary",children:"-"})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,children:[jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Telefone"}),u?jsxs(co,{direction:"row",alignItems:"center",gap:.5,children:[jsx(a$1,{icon:"WHATSAPP",color:"success.main",sx:{flexShrink:0}}),jsx(si,{component:si,href:`https://wa.me/${u}`,target:"_blank",rel:"noopener noreferrer",variant:"subtitle2",color:"success.main",noWrap:!0,children:h$1(u)})]}):jsx(W,{variant:"subtitle2",color:"text.primary",children:"-"})]}),l?.(o.external_id,D)]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Vendedor preferencial"}),jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:d?.main_seller?.name||"-"})]})]})})})]})},di=Ys;var Hs=({order:o})=>{let{renderSaleLink:r}=c().slots;return jsxs(a$5,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:3,p:1.5,sx:{borderRadius:1},children:[jsxs(co,{overflow:"hidden",children:[o?.id?r?.(o.id):jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:"-"}),jsx(W,{variant:"caption",color:"text.secondary",children:d$1(o?.negotiation_date,"DD/MM/YYYY [\xE0s] HH:mm")})]}),jsx(W,{variant:"subtitle2",color:"text.primary",children:h(o?.total_value)})]})},ci=memo(Hs,a$2);var zs=()=>jsxs(co,{gap:1.5,children:[jsx(a$7,{width:"100%",height:66}),jsx(a$7,{width:"100%",height:66}),jsx(a$7,{width:"100%",height:66}),jsx(a$7,{width:"100%",height:66}),jsx(a$7,{width:"100%",height:66})]}),mi=zs;var js=({partner:o})=>{let[r,e]=a$9(!1),t=useMemo(()=>o?.external_id?{perPage:5,sort:{fieldName:"negotiationDate",sortType:"DESC"},filter:{operator:"AND",groups:[{operator:"AND",conditionals:[{fieldName:"partnerId",conditional:"EQUALS",value:[o.external_id]}]}]}}:null,[o?.external_id]),{usePartnerOrders:a}=c().adapters,{data:{items:i=[]}={},isLoading:n}=a(t,{skip:!t});return jsxs(a$g,{expanded:r,onChange:e,children:[jsx(b$1,{children:jsx(W,{variant:"overline",color:"text.secondary",children:"\xDAltimos pedidos"})}),jsx(c$1,{children:jsx(co,{mt:-1,px:1,children:jsx(a$e,{isLoading:n,loading:jsx(mi,{}),isEmpty:i?.length===0,empty:jsx(co,{alignItems:"center",justifyContent:"center",gap:1.5,p:2,children:jsx(W,{variant:"body2",color:"text.secondary",children:"Este cliente ainda n\xE3o possui pedidos realizados."})}),children:jsx(co,{gap:1.5,children:i?.map((l,d)=>jsx(ci,{order:l,"data-testid":`last-order-${d}`},l.id))})})})})]})},fi=js;var Ks=({partner:o})=>{let{renderSaleLink:r}=c().slots,[e,t]=a$9(!1),a=useMemo(()=>s(o?.recurrence),[o?.recurrence]),i=o?.sale_analysis?.last_sale_sale_external_id||o?.sale_analysis?.last_sale_external_id,n=o?.sale_analysis?.last_sale_negotiation_date;return jsxs(a$g,{expanded:e,onChange:t,children:[jsx(b$1,{children:jsx(W,{variant:"overline",color:"text.secondary",children:"Comportamento de compra"})}),jsx(c$1,{children:jsxs(co,{mt:-1,px:1,gap:1,children:[jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"Frequ\xEAncia de compras"}),jsx(W,{variant:"subtitle2",color:"text.primary",children:a})]}),jsx(Xo,{sx:{borderStyle:"dashed"}}),jsxs(co,{children:[jsx(W,{variant:"body2",color:"text.secondary",children:"\xDAltimo pedido"}),i?jsxs(co,{direction:"row",alignItems:"center",gap:.5,children:[r?.(i),jsxs(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:["em ",d$1(n,"DD/MM/YYYY [\xE0s] HH:mm")]})]}):jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:"-"})]})]})})]})},gi=Ks;var se=styled(Xo)(({theme:o})=>({height:30,alignSelf:"center",borderStyle:"dashed",[o.breakpoints.down("sm")]:{display:"none"}}));var od=()=>jsxs(co,{direction:{xs:"column",sm:"row"},justifyContent:{xs:"flex-start",sm:"center"},gap:3,children:[jsxs(co,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(W,{variant:"body2",children:"Qtd. de pedidos"}),jsx(a$7,{width:30,height:22})]}),jsx(se,{orientation:"vertical",flexItem:!0}),jsxs(co,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(W,{variant:"body2",children:"Valor total"}),jsx(a$7,{width:92,height:22})]}),jsx(se,{orientation:"vertical",flexItem:!0}),jsxs(co,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(W,{variant:"body2",children:"Ticket m\xE9dio"}),jsx(a$7,{width:71,height:22})]})]}),ui=od;var rd=({partner:o})=>{let[r,e]=a$9(!1),{usePartnerSaleSummary:t}=c().adapters,{data:a,isLoading:i}=t(o.external_id,{skip:!o.external_id||!r});return jsxs(a$g,{expanded:r,onChange:e,children:[jsx(b$1,{children:jsx(W,{variant:"overline",color:"text.secondary",children:"Indicadores de vendas"})}),jsx(c$1,{children:jsx(co,{mt:-1,px:1,children:jsx(a$e,{isLoading:i,loading:jsx(ui,{}),children:jsxs(co,{direction:{xs:"column",sm:"row"},justifyContent:{xs:"flex-start",sm:"center"},gap:3,children:[jsxs(co,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(W,{variant:"body2",children:"Qtd. de pedidos"}),jsx(W,{variant:"subtitle2",children:a?.order_quantity||0})]}),jsx(Xo,{orientation:"vertical",flexItem:!0}),jsxs(co,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(W,{variant:"body2",children:"Valor total"}),jsx(W,{variant:"subtitle2",children:h(a?.total_value)})]}),jsx(Xo,{orientation:"vertical",flexItem:!0}),jsxs(co,{alignItems:{xs:"flex-start",sm:"center"},children:[jsx(W,{variant:"body2",children:"Ticket m\xE9dio"}),jsx(W,{variant:"subtitle2",children:h(a?.average_ticket)})]})]})})})})]})},Si=rd;var td=({partner:o,onPhoneUpdated:r})=>jsxs(Fragment,{children:[jsx(di,{partner:o,onPhoneUpdated:r}),jsx(Si,{partner:o}),jsx(gi,{partner:o}),jsx(fi,{partner:o})]}),Ti=td;var vi=styled(co)(({theme:o})=>({minHeight:47.42,flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:o.spacing(1.5)})),le=styled(wn)(({theme:o})=>({justifyContent:"flex-start",color:o.palette.text.primary,fontWeight:400,"&:hover":{background:o.palette.action.hover}}));var ld=({partner:o})=>{let{open:r,onClose:e,setOpen:t}=a$8(),a=useRef(null),[i,n]=a$9(!1),[l,d]=useState(o.phone),y=l?.replace(/\D/g,""),f=!!y,u=useCallback(L=>{d(L);},[]),_=o.sale_analysis.sale_count,D=useMemo(()=>`${_} pedido${_===0||_>1?"s":""}`,[_]),E=useMemo(()=>{let Ro=[e$1[o.classification]?.label,D].filter(Boolean).join(" \u2022 ");return `${o.name}
58
+ ${Ro}`},[o.classification,o.name,D]),J=useCallback(()=>{a.current&&t(a.current);},[t]),P=useCallback(()=>{e(),n();},[e,n]);return jsxs(Fragment,{children:[jsx(wo,{title:E,onClick:J,sx:{cursor:"pointer"},children:jsxs(vi,{children:[jsxs(co,{overflow:"hidden",children:[jsx(W,{variant:"subtitle2",color:"text.primary",noWrap:!0,children:o.name}),jsxs(co,{direction:"row",alignItems:"center",gap:.5,children:[jsx(Ct,{status:o.classification,variant:"caption",color:"text.disabled"}),jsxs(W,{variant:"caption",color:"text.disabled",noWrap:!0,children:[o.classification&&jsx(Fragment,{children:"\u2022"})," ",D]})]})]}),jsx("span",{ref:a,children:jsx(a$1,{icon:"ARROW_DOWN_SIMPLE",color:"text.secondary"})})]})}),jsxs(a$a,{open:r,onClose:e,disabledArrow:!0,sx:{width:180,p:1},children:[jsx(le,{component:si,href:`https://wa.me/${y}`,target:"_blank",rel:"noopener noreferrer",variant:"text",startIcon:jsx(a$1,{icon:"WHATSAPP"}),disabled:!f,fullWidth:!0,children:"Enviar mensagem"}),jsx(le,{variant:"text",startIcon:jsx(a$1,{icon:"INFORMATIONS"}),onClick:P,fullWidth:!0,children:"Ver detalhes"})]}),jsx(a$b,{open:i,onClose:n,headerTitle:"Detalhes do cliente",headerProps:{direction:"row-reverse"},maxWidth:520,contentProps:{p:0},children:jsx(Ti,{partner:o,onPhoneUpdated:u})})]})},Di=ld;var yd=({partner:o,index:r,days:e,isFetching:t})=>{let a=useMemo(()=>{let i=new Map;return o.events.forEach(n=>{let l=new Date(n.reference_date).toISOString().slice(0,10),d=i.get(l)??[];d.push(n),i.set(l,d);}),i},[o.events]);return jsxs(Ir,{"data-testid":`partner-${r}`,children:[jsx(Di,{partner:o}),e.map((i,n)=>jsx(ai,{index:n,day:i,events:a.get(i.format("YYYY-MM-DD"))??[],isFetching:t},n))]})},_i=memo(yd);var Ii=styled(gd)({display:"flex",flexDirection:"column",width:"100%",height:"calc(100vh - 300px)",boxShadow:"none",overflow:"hidden"}),Ri=styled(Sd)({flex:1}),Ai=styled(ud,{shouldForwardProp:o=>o!=="totalWidth"&&o!=="isResizing"})(({totalWidth:o,isResizing:r})=>({tableLayout:"fixed",borderCollapse:"separate",borderSpacing:0,height:"100%",...o>0&&{width:o},...r&&{userSelect:"none",cursor:"col-resize"}})),Oi=styled(hd)(({theme:o})=>({"& .MuiTableRow-root":{backgroundColor:o.palette.background.paper},"& .MuiTableRow-root:last-child .MuiTableCell-root":{height:"100%"}}));var vd=({classification:o,checked:r,onToggle:e})=>{let{label:t,color:a}=e$1[o];return jsx(bd,{control:jsx(Td,{name:`classification-${o}`,checked:r,onChange:e}),label:jsxs(co,{direction:"row",alignItems:"center",gap:1,children:[jsx(co,{width:6,height:16,bgcolor:a,borderRadius:1})," ",t]})})},Li=vd;var Dd=Object.values(d),Ed=()=>{let{selectedClassifications:o,setSelectedClassifications:r}=x(),[e,t]=a$9(!!o.length),a=useCallback(i=>{r(o.includes(i)?o.filter(n=>n!==i):[...o,i]);},[r,o]);return jsxs(a$g,{expanded:e,onChange:t,children:[jsx(b$1,{children:jsx(W,{variant:"body2",fontWeight:"bold",color:"text.primary",children:"Classifica\xE7\xF5es"})}),jsx(c$1,{children:jsx(co,{mt:-1,children:Dd.map(i=>jsx(Li,{classification:i,checked:o.includes(i),onToggle:()=>a(i)},i))})})]})},Ni=Ed;var ye=(o,r,e="40%")=>({position:"relative",backgroundColor:"transparent","&::before":{content:'""',position:"absolute",inset:3,backgroundColor:o,borderRadius:e,zIndex:-1},"&:hover, &:focus":{backgroundColor:"transparent","&::before":{backgroundColor:r}}}),Bi=styled(a$3)(()=>({"&.MuiDateCalendar-root":{margin:-24},"& .MuiPickersCalendarHeader-label":{textTransform:"capitalize"}})),Fi=styled(PickersDay,{shouldForwardProp:o=>o!=="isDaily"&&o!=="isInRange"&&o!=="isStart"&&o!=="isEnd"})(({theme:o,isInRange:r,isStart:e,isEnd:t,isDaily:a})=>({borderRadius:0,"&:not(.Mui-selected):not(.MuiPickersDay-today)":{"&:hover, &:focus":{backgroundColor:o.palette.action.hover,borderRadius:"40%"}},...!r&&{"&.MuiPickersDay-today:not(.Mui-selected)":{color:o.palette.common.white,border:"none !important",...ye(o.palette.common.black,alpha(o.palette.common.black,.8))}},"&.Mui-selected":{color:`${o.palette.primary.contrastText} !important`,...ye(o.palette.primary.main,o.palette.primary.dark)},...r&&a&&{color:o.palette.primary.contrastText,...ye(o.palette.primary.main,o.palette.primary.dark,6)},...r&&!a&&{backgroundColor:"transparent",borderTop:`1px solid ${o.palette.divider}`,borderBottom:`1px solid ${o.palette.divider}`,borderLeft:e?`1px solid ${o.palette.divider}`:"none",borderRight:t?`1px solid ${o.palette.divider}`:"none",...e&&{borderTopLeftRadius:8,borderBottomLeftRadius:8},...t&&{borderTopRightRadius:8,borderBottomRightRadius:8},"&.MuiPickersDay-today:not(.Mui-selected)":{borderTop:`1px solid ${o.palette.divider} !important`,borderBottom:`1px solid ${o.palette.divider} !important`,borderLeft:"none !important",borderRight:"none !important"}}}));var Od=["D","S","T","Q","Q","S","S"],It=(o,r)=>o.getFullYear()===r.getFullYear()&&o.getMonth()===r.getMonth()&&o.getDate()===r.getDate(),wd=()=>{let{baseDate:o,dateRange:r,viewMode:e,handleBaseDateChange:t}=x(),a=fe(r.start_date).toDate(),i=fe(r.end_date).toDate(),n=useCallback(f=>It(f,a)||It(f,i)||f>a&&f<i,[a,i]),l=useCallback(f=>It(f,a),[a]),d=useCallback(f=>It(f,i),[i]),y=useCallback(f=>{f&&t(fe(f));},[t]);return jsxs(co,{p:2,pb:3,gap:2,children:[jsx(W,{variant:"overline",color:"text.secondary",children:"Calend\xE1rio"}),jsx(co,{alignItems:"center",children:jsx(Bi,{value:o.toDate(),onChange:y,showDaysOutsideCurrentMonth:!0,slots:{day:Fi},slotProps:{day:f=>{let u=f.day.toDate();return {isInRange:n(u),isStart:l(u),isEnd:d(u),isDaily:e==="DAY",disableMargin:!0}}},dayOfWeekFormatter:f=>Od[f.day()],fixedWeekNumber:6})})]})},Wi=wd;var Yd=()=>{let{selectedPartners:o,setSelectedPartners:r}=x(),[e,t]=a$9(!0),[a,i]=useState(""),{buildOptions:n,finishSearch:l,onSearch:d,onSelectValue:y,search:f,searching:u}=a$h(),{usePartnerOptions:_}=c().adapters,{items:D,isFetching:E,isLoading:J}=_({search:f,skip:!e}),P=useMemo(()=>u||E?[]:n(D.map(({id:m,name:b})=>({value:m,label:b||""})),E),[n,E,D,u]),L=o.length>0,Ro=useCallback(m=>{y(P,m);let b=typeof m=="string"?m:String(m?.value||""),At=P.find(Ao=>String(Ao.value)===b)?.label||(typeof m=="string"?m:String(m?.label||""));b&&!o.some(Ao=>Ao.id===b)&&r([...o,{id:b,name:At}]),i("");},[r,y,P,o]),_r=useCallback(m=>{r(o.filter(b=>b.id!==m.id));},[r,o]);return jsxs(a$g,{expanded:e,onChange:t,children:[jsx(b$1,{children:jsx(W,{variant:"body2",fontWeight:"bold",color:"text.primary",children:"Clientes"})}),jsx(c$1,{children:jsxs(co,{gap:1,children:[jsx(a$i,{name:"partners",label:"Clientes",placeholder:"Digite para buscar um cliente...",size:"small",options:P,loading:J,inputValue:a,onInputChange:(m,b)=>i(b),onSearch:d,onBlur:l,onChange:Ro,filterOptions:m=>m,noOptionsText:u||E?"Carregando...":void 0,InputLabelProps:{shrink:!0},fullWidth:!0}),jsx(a$5,{direction:"row",alignItems:"center",flexWrap:"wrap",overflow:"auto",maxHeight:148,p:1.5,sx:{bgcolor:"grey.50"},children:jsx(a$e,{isEmpty:!L,empty:jsx(W,{variant:"body2",color:"text.secondary",children:"Nenhum cliente selecionado"}),children:o.map((m,b)=>jsx(Fs,{variant:"outlined",label:m.name,color:"default",onDelete:()=>_r(m),"data-testid":`filter-partner-${b}`},m.id))})})]})})]})},zi=Yd;var zd=()=>{let{selectedProfiles:o,setSelectedProfiles:r}=x(),[e,t]=a$9(!!o.length),[a,i]=useState(""),{buildOptions:n,finishSearch:l,onSearch:d,onSelectValue:y,search:f,searching:u}=a$h(),{useProfileOptions:_}=c().adapters,{items:D,isFetching:E,isLoading:J}=_({search:f,skip:!e}),P=useMemo(()=>u||E?[]:n(D.map(({id:m,name:b})=>({value:m,label:b||""})),E),[n,E,D,u]),L=o.length>0,Ro=useCallback(m=>{y(P,m);let b=typeof m=="string"?m:String(m?.value||""),At=P.find(Ao=>String(Ao.value)===b)?.label||(typeof m=="string"?m:String(m?.label||""));b&&!o.some(Ao=>Ao.id===b)&&r([...o,{id:b,name:At}]),i("");},[r,y,P,o]),_r=useCallback(m=>{r(o.filter(b=>b.id!==m.id));},[r,o]);return jsxs(a$g,{expanded:e,onChange:t,children:[jsx(b$1,{children:jsx(W,{variant:"body2",fontWeight:"bold",color:"text.primary",children:"Segmentos"})}),jsx(c$1,{children:jsxs(co,{gap:1,children:[jsx(a$i,{name:"profiles",label:"Segmentos",placeholder:"Digite para buscar um segmento...",size:"small",options:P,loading:J,inputValue:a,onInputChange:(m,b)=>i(b),onSearch:d,onBlur:l,onChange:Ro,filterOptions:m=>m,noOptionsText:u||E?"Carregando...":void 0,InputLabelProps:{shrink:!0},fullWidth:!0}),jsx(a$5,{direction:"row",alignItems:"center",flexWrap:"wrap",overflow:"auto",maxHeight:148,p:1.5,sx:{bgcolor:"grey.50"},children:jsx(a$e,{isEmpty:!L,empty:jsx(W,{variant:"body2",color:"text.secondary",children:"Nenhum segmento selecionado"}),children:o.map((m,b)=>jsx(Fs,{variant:"outlined",label:m.name,color:"default",onDelete:()=>_r(m),"data-testid":`filter-profile-${b}`},m.id))})})]})})]})},qi=zd;var jd=({status:o,checked:r,onToggle:e})=>{let{label:t,color:a}=v[o];return jsx(bd,{control:jsx(Td,{name:`status-${o}`,checked:r,onChange:e}),label:jsxs(co,{direction:"row",alignItems:"center",gap:1,children:[jsx(co,{width:6,height:16,bgcolor:a,borderRadius:1})," ",t]})})},Xi=jd;var Jd=Object.values(e),Zd=()=>{let{selectedEventTypes:o,setSelectedEventTypes:r}=x(),[e,t]=a$9(!!o.length),a=useCallback(i=>{r(o.includes(i)?o.filter(n=>n!==i):[...o,i]);},[r,o]);return jsxs(a$g,{expanded:e,onChange:t,children:[jsx(b$1,{children:jsx(W,{variant:"body2",fontWeight:"bold",color:"text.primary",children:"Status de eventos"})}),jsx(c$1,{children:jsx(co,{mt:-1,children:Jd.map(i=>jsx(Xi,{status:i,checked:o.includes(i),onToggle:()=>a(i)},i))})})]})},Ki=Zd;var rl=()=>jsxs(Fragment,{children:[jsx(Wi,{}),jsx(zi,{}),jsx(qi,{}),jsx(Ki,{}),jsx(Ni,{})]}),Ji=rl;var on=styled(co)(({theme:o})=>({flexDirection:"row",alignItems:"center",padding:o.spacing(2.5),gap:o.spacing(1)})),rn=styled(co)(({theme:o})=>({flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:o.spacing(2.5),gap:o.spacing(1)})),he=styled(_s)({flex:1,display:"flex",alignItems:"center",minWidth:0}),tn=styled(he)({justifyContent:"flex-start"}),en=styled(he)({justifyContent:"center"}),an=styled(he)({justifyContent:"flex-end"});var nn={["DAY"]:"Dia",["WEEK"]:"Semana"},pn={["DAY"]:"CALENDAR_TODAY",["WEEK"]:"COLUMNS"};var Se=styled(wn,{shouldForwardProp:o=>o!=="active"})(({theme:o,active:r})=>({justifyContent:"flex-start",color:r?o.palette.primary.main:o.palette.text.secondary,fontWeight:r?800:400,"&:hover":{background:o.palette.action.hover}}));var dl=()=>{let{open:o,onClose:r,onOpen:e}=a$8(),{viewMode:t,setViewMode:a}=x(),i=useCallback(n=>{a(n),r();},[r,a]);return jsxs(Fragment,{children:[jsx(wn,{variant:"text",startIcon:jsx(a$1,{icon:pn[t]}),endIcon:jsx(a$1,{icon:"ARROW_DOWN_SIMPLE"}),color:"inherit",size:"small",onClick:e,children:nn[t]}),jsxs(a$a,{open:o,onClose:r,disabledArrow:!0,sx:{width:180,p:1},children:[jsx(Se,{variant:"text",startIcon:jsx(a$1,{icon:"CALENDAR_TODAY"}),onClick:()=>i("DAY"),active:t==="DAY",fullWidth:!0,children:"Dia"}),jsx(Se,{variant:"text",startIcon:jsx(a$1,{icon:"COLUMNS"}),onClick:()=>i("WEEK"),active:t==="WEEK",fullWidth:!0,children:"Semana"})]})]})},dn=dl;var fl=()=>{let{visibleDays:o,dateRange:r,handlePreviousWeek:e,handleNextWeek:t}=x(),a=useMemo(()=>{let i=fe(r.start_date),n=fe(r.end_date);if(o===1)return d$1(i.toDate(),"DD [de] MMM [de] YYYY");let l=i.month()===n.month(),d=i.year()===n.year();return l&&d?`${i.format("DD")} - ${d$1(n.toDate(),"DD [de] MMM [de] YYYY")}`:d?`${d$1(i.toDate(),"DD [de] MMM")} - ${d$1(n.toDate(),"DD [de] MMM")}`:`${d$1(i.toDate(),"DD MMM YYYY")} - ${d$1(n.toDate(),"DD MMM YYYY")}`},[r,o]);return jsxs(co,{direction:"row",alignItems:"center",gap:1,children:[jsx(a$c,{label:"Semana anterior",icon:"CHEVRON_LEFT",color:"inherit",size:"small",onClick:e}),jsx(W,{variant:"subtitle1",color:"text.primary",noWrap:!0,children:a}),jsx(a$c,{label:"Pr\xF3xima semana",icon:"CHEVRON_RIGHT",color:"inherit",size:"small",onClick:t})]})},be=fl;var Sl=()=>{let o=b("down","sm"),{selectedPartners:r,selectedProfiles:e,selectedEventTypes:t}=x(),a=useMemo(()=>r.length+e.length+t.length,[r.length,e.length,t.length]),[i,n]=a$9();return jsxs(Fragment,{children:[o?jsxs(rn,{children:[jsx(be,{}),jsx(cn,{badgeContent:a,invisible:a===0,color:"primary",children:jsx(a$c,{label:"Filtrar",icon:"FILTER_LIST",color:"inherit",size:"small",onClick:n})})]}):jsxs(on,{children:[jsx(tn,{children:jsx(dn,{})}),jsx(en,{children:jsx(be,{})}),jsx(an,{children:jsx(cn,{badgeContent:a,invisible:a===0,color:"primary",children:jsx(wn,{variant:"text",startIcon:jsx(a$1,{icon:"FILTER_LIST"}),endIcon:jsx(a$1,{icon:"ARROW_DOWN_SIMPLE"}),color:"inherit",size:"small",onClick:n,children:"Filtrar"})})})]}),jsx(a$b,{open:i,onClose:n,headerTitle:"Filtros",headerProps:{direction:"row-reverse"},contentProps:{p:0},maxWidth:320,children:jsx(Ji,{})})]})},mn=Sl;var kl=({partners:o$1,summary:r$1,isFetching:e,isFetchingSummary:t,onRowsScrollEnd:a,isFetchingNextPage:i$1})=>{let{dateRange:n$1,scrollRef:l$1}=x(),d=b("down","sm"),y=useMemo(()=>r(n$1.start_date,n$1.end_date),[n$1.start_date,n$1.end_date]),f=useMemo(()=>[{key:l,minWidth:n,defaultWidth:m},...y.map((P,L)=>({key:p(L),minWidth:o}))],[y]),{columnWidths:u,totalWidth:_,isResizing:D,getColumnResizeProps:E}=a$6({columns:f,containerRef:l$1,enabled:!d}),J=useCallback(()=>{let P=l$1.current;if(!P||i$1)return;let{scrollTop:L,scrollHeight:Ro,clientHeight:_r}=P;Ro-L-_r<=i&&a();},[l$1,a,i$1]);return jsxs(Ii,{variant:"outlined",children:[jsx(mn,{}),jsx(Ri,{ref:l$1,onScroll:J,children:jsxs(Ai,{stickyHeader:!0,totalWidth:_,isResizing:D,children:[!!u.length&&jsx("colgroup",{children:u.map((P,L)=>jsx("col",{style:{width:P.width}},L))}),jsx(Xe,{days:y,summary:r$1,isFetchingSummary:t,getColumnResizeProps:E}),jsxs(Oi,{children:[!o$1.length&&jsxs(Ir,{children:[jsx(wo,{}),y.map((P,L)=>jsx(io,{isToday:P.isSame(fe(),"day")},L))]}),o$1.map((P,L)=>jsx(_i,{index:L,partner:P,days:y,isFetching:e},P.external_id)),i$1&&jsx(gn,{children:jsx(Ne,{colSpan:y.length+1,align:"center",sx:{py:2,border:"none"},children:jsx(vl,{size:24})})})]})]})})]})},Dl=kl;
60
59
 
61
60
  export { Dl as Calendar, Tn as OrderProjectionProvider, c as useOrderProjectionContext, x as useOrderProjectionFilterContext };
62
61
  //# sourceMappingURL=index.js.map