"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),a=require("moment"),n=require("classnames"),r=require("../../Text/Text.js"),i=require("../utils.js"),o=require("./CalendarGrid.scss.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=s(a),d=s(n),l=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];exports.CalendarGrid=function(a){var n=a.activeStartDate,s=a.setHoveredDate,c=a.minDate,m=a.maxDate,f=a.tileDisabled,g=a.onChange,v=a.view,h=void 0===v?"month":v,T=a.rangeStartDate,D=a.rangeEndDate,y=a.rangeHoveredDate,M=a.selected,x=a.getTileClassName,b=a.className,j=a.testId,p="month"===h,S=u.default().startOf(p?"day":"month").toDate(),q=t.useMemo((function(){if(p){var e=u.default(n).startOf("month"),t=0===e.day()?e.subtract(6,"days"):e.startOf("week").add(1,"days");return new Array(42).fill(void 0).map((function(e,a){return t.clone().add(a,"days").toDate()}))}var a=u.default(n).startOf("year");return new Array(12).fill(void 0).map((function(e,t){return a.clone().add(t,"months").toDate()}))}),[n,p]),C=t.useCallback((function(){return null==s?void 0:s(void 0)}),[s]);return e.jsxs("div",{className:d.default(o.root,!p&&o.yearView,b),onMouseLeave:C,"data-testid":j,children:[p&&l.map((function(t){return e.jsx(r.Text,{size:14,className:o.dow,children:t},t)})),q.map((function(t){var a=p?i.isSameDay:i.isSameMonth,r={activeStartDate:n,date:t},u=c&&t.getTime()<(null==c?void 0:c.getTime())||m&&t.getTime()>(null==m?void 0:m.getTime())||!(null==f||!f(r)),l=!!p&&t.getMonth()!==n.getMonth(),v=a(S,t),b=a(t,M)||a(t,T)||a(t,D),j=i.getMaxDate(D||y,T),q=i.getMinDate(D||y,T),C=a(q,t),w=a(j,t),N=q&&j&&q.getTime()<t.getTime()&&j.getTime()>t.getTime(),O=C||w||N;return e.jsx("button",{className:d.default(o.button,!p&&o.monthButton,u&&o.disabled,l&&o.neighbourMonth,v&&o.today,b&&o.selected,O&&o.range,C&&o.rangeStart,w&&o.rangeEnd,null==x?void 0:x(r)),disabled:u,onClick:function(){return g(t)},onMouseEnter:s?function(){return s(t)}:void 0,children:e.jsx("span",{className:o.buttonContent,children:"month"===h?t.getDate():i.MonthOptions[t.getMonth()].fullTitle})},"".concat(n.getTime(),"-").concat(t.getTime()))}))]})};
//# sourceMappingURL=CalendarGrid.js.map
