"use strict";(globalThis.webpackChunkcomplianz_gdpr=globalThis.webpackChunkcomplianz_gdpr||[]).push([[7660],{95279:(e,t,a)=>{a.r(t),a.d(t,{default:()=>_});var n=a(86087),l=a(59402),d=a(30020),r=a(1806),s=a(31127),o=a(66212),u=a(92998),c=a(20543),i=a(2118),D=a(19312),f=a(17054),m=a(49317),y=a(53039),g=a(81810),p=a(72346),w=a(45111),h=a(27723),b=a(38432);const _=()=>{const[e,t]=(0,n.useState)(null),a=Boolean(e),_=(0,b.default)((e=>e.startDate)),z=(0,b.default)((e=>e.endDate)),M=(0,b.default)((e=>e.setStartDate)),E=(0,b.default)((e=>e.setEndDate)),k=(0,b.default)((e=>e.range)),v=(0,b.default)((e=>e.setRange)),A={startDate:(0,r.A)(_),endDate:(0,r.A)(z),key:"selection"},C=(0,n.useRef)(0),S=["today","yesterday","last-7-days","last-30-days","last-90-days","last-month","last-year","year-to-date"],L={today:{label:(0,h.__)("Today","complianz-gdpr"),range:()=>({startDate:(0,s.default)(new Date),endDate:(0,o.default)(new Date)})},yesterday:{label:(0,h.__)("Yesterday","complianz-gdpr"),range:()=>({startDate:(0,s.default)((0,u.default)(new Date,-1)),endDate:(0,o.default)((0,u.default)(new Date,-1))})},"last-7-days":{label:(0,h.__)("Last 7 days","complianz-gdpr"),range:()=>({startDate:(0,s.default)((0,u.default)(new Date,-7)),endDate:(0,o.default)((0,u.default)(new Date,-1))})},"last-30-days":{label:(0,h.__)("Last 30 days","complianz-gdpr"),range:()=>({startDate:(0,s.default)((0,u.default)(new Date,-30)),endDate:(0,o.default)((0,u.default)(new Date,-1))})},"last-90-days":{label:(0,h.__)("Last 90 days","complianz-gdpr"),range:()=>({startDate:(0,s.default)((0,u.default)(new Date,-90)),endDate:(0,o.default)((0,u.default)(new Date,-1))})},"last-month":{label:(0,h.__)("Last month","complianz-gdpr"),range:()=>({startDate:(0,c.default)((0,i.default)(new Date,-1)),endDate:(0,D.default)((0,i.default)(new Date,-1))})},"year-to-date":{label:(0,h.__)("Year to date","complianz-gdpr"),range:()=>({startDate:(0,f.A)(new Date),endDate:(0,o.default)(new Date)})},"last-year":{label:(0,h.__)("Last year","complianz-gdpr"),range:()=>({startDate:(0,f.A)((0,m.default)(new Date,-1)),endDate:(0,y.A)((0,m.default)(new Date,-1))})}};function O(e){const t=this.range();return(0,g.default)(e.startDate,t.startDate)&&(0,g.default)(e.endDate,t.endDate)}const R=[];for(const[e,t]of Object.entries(S))t&&(R.push(L[t]),R[R.length-1].isSelected=O);const T=e=>{t(null)},j="MMMM d, yyyy",F=_?(0,p.default)(new Date(_),j):(0,p.default)(defaultStart,j),N=z?(0,p.default)(new Date(z),j):(0,p.default)(defaultEnd,j);return(0,n.createElement)("div",{className:"cmplz-date-range-container"},(0,n.createElement)("button",{onClick:e=>{t(e.currentTarget)},id:"cmplz-date-range-picker-open-button"},(0,n.createElement)(w.default,{name:"calendar",size:"18"}),"custom"===k&&F+" - "+N,"custom"!==k&&L[k].label,(0,n.createElement)(w.default,{name:"chevron-down"})),(0,n.createElement)(l.Ay,{anchorEl:e,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},open:a,onClose:T,className:"burst"},(0,n.createElement)("div",{id:"cmplz-date-range-picker-container"},(0,n.createElement)(d.Ur,{ranges:[A],rangeColors:["var(--rsp-brand-primary)"],dateDisplayFormat:j,monthDisplayFormat:"MMMM",onChange:e=>{(e=>{C.current++;let t=(0,p.default)(e.selection.startDate,"yyyy-MM-dd"),a=(0,p.default)(e.selection.endDate,"yyyy-MM-dd"),n="custom";for(const[t,a]of Object.entries(L))a.isSelected(e.selection)&&(n=t);e.selection.startDate,e.selection.endDate,2!==C.current&&t===a&&"custom"===n||(C.current=0,M(t),E(a),v(n),T())})(e)},inputRanges:[],showSelectionPreview:!0,months:2,direction:"horizontal",minDate:new Date(2022,0,1),maxDate:new Date,staticRanges:R}))))}}}]);