import { Component, Input } from '@angular/core';
import dayjs from "dayjs";
import utc from 'dayjs/plugin/utc';
import * as i0 from "@angular/core";
import * as i1 from "@ng-bootstrap/ng-bootstrap";
import * as i2 from "@angular/common";
import * as i3 from "ngx-daterangepicker-material";
dayjs.extend(utc);
export class DatePickerComponent {
    cd;
    activeModal;
    dayjs = dayjs;
    fileType = 'csv';
    isCustomDate = (m) => {
        const isValidDate = m > this.dayjs();
        return isValidDate ? 'invalid-date' : false;
    };
    outputVal = { startDate: '', endDate: '', validated: false };
    constructor(cd, activeModal) {
        this.cd = cd;
        this.activeModal = activeModal;
    }
    onDateChange(event) {
        if (this.fileType === 'pdf') {
            this.isCustomDate = (m) => {
                const isValidDate = m > this.dayjs(event.startDate).add(2, 'day') || m > this.dayjs();
                return isValidDate ? 'invalid-date' : false;
            };
        }
        else if (this.fileType === 'csv') {
            this.isCustomDate = (m) => {
                const isValidDate = m > this.dayjs(event.startDate).add(1, 'month') || m > this.dayjs();
                return isValidDate ? 'invalid-date' : false;
            };
        }
        this.cd.detectChanges();
    }
    onDateUpdated(event) {
        console.log(event);
        if (!event.startDate || !event.endDate)
            return;
        this.outputVal = { startDate: event.startDate.format('YYYY-MM-DD'), endDate: event.endDate.format('YYYY-MM-DD'), validated: true };
        // this.isCustomDate = (m: dayjs.Dayjs) => {
        //   const isValidDate = m > this.dayjs();
        //       return isValidDate ? 'invalid-date' : false;
        // }
    }
    onSubmit() {
        this.activeModal.close(this.outputVal);
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: DatePickerComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i1.NgbActiveModal }], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: DatePickerComponent, selector: "lib-date-picker", inputs: { fileType: "fileType" }, ngImport: i0, template: "<!-- <div class=\"p-4 d-flex justify-content-center\"  >\r\n<ngx-daterangepicker-material [isCustomDate]=\"isCustomDate\">\r\n</ngx-daterangepicker-material>    \r\n</div> -->\r\n\r\n<div class=\"d-flex flex-column justify-content-between h-100\" >\r\n<div>\r\n    <div class=\"header mb-5\" >Export as {{fileType}}</div>\r\n\r\n    <!-- <div class=\"d-flex align-items-center position-relative \">\r\n        <span class=\"svg-icon svg-icon-1 position-absolute ms-3\">\r\n            <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\">\r\n                <path\r\n                    d=\"M13.3333 1.66663V4.99996M6.66667 1.66663V4.99996M2.5 8.33329H17.5M4.16667 3.33329H15.8333C16.7538 3.33329 17.5 4.07948 17.5 4.99996V16.6666C17.5 17.5871 16.7538 18.3333 15.8333 18.3333H4.16667C3.24619 18.3333 2.5 17.5871 2.5 16.6666V4.99996C2.5 4.07948 3.24619 3.33329 4.16667 3.33329Z\"\r\n                    stroke=\"#344054\" stroke-width=\"1.67\" stroke-linecap=\"round\" stroke-linejoin=\"round\" />\r\n            </svg>\r\n        </span>\r\n        <input class=\"fx-date-range form-control ps-14\" style=\"min-width: 100px !important;\"\r\n    type=\"text\" matInput ngxDaterangepickerMd  [drops]=\"'down'\"\r\n    [opens]=\"'right'\" [alwaysShowCalendars]=\"true\" [keepCalendarOpeningWithRange]=\"true\"\r\n    [showCancel]=\"false\" autocomplete=\"off\" [(ngModel)]=\"selectedDateRange\"\r\n    [ngModelOptions]=\"{standalone: true}\" \r\n    [isCustomDate]=\"isCustomDate\" [autoApply]=\"true\"\r\n    [locale]=\"{ format: 'DD-MM-YYYY', firstDay: 1, monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] }\"\r\n     name=\"daterange\" [readonly]=\"true\" (startDateChanged)=\"onDateChange($event)\" (datesUpdated)=\"onDateUpdated($event)\" /> \r\n    </div>  -->\r\n    <ngx-daterangepicker-material [drops]=\"'down'\"\r\n     [opens]=\"'right'\" [alwaysShowCalendars]=\"true\" [keepCalendarOpeningWithRange]=\"true\"\r\n     [showCancel]=\"false\" autocomplete=\"off\" \r\n     [isCustomDate]=\"isCustomDate\" [autoApply]=\"true\"\r\n     [locale]=\"{ format: 'DD-MM-YYYY', firstDay: 1, monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] }\"\r\n      name=\"daterange\"  (startDateChanged)=\"onDateChange($event)\" (datesUpdated)=\"onDateUpdated($event)\">\r\n    </ngx-daterangepicker-material>\r\n    <div *ngIf=\"fileType === 'csv'\" class=\"text-muted mb-5\" >Only one month data can be downloaded</div>\r\n    <div *ngIf=\"fileType === 'pdf'\" class=\"text-muted mb-5\" >Only three days data can be downloaded</div>\r\n\r\n</div>\r\n\r\n<div class=\"row\">\r\n    <div class=\"col-6\" >\r\n        <button (click)=\"activeModal.close()\"  class=\"btn btn-outline w-100\">Cancel</button>\r\n    </div>\r\n\r\n    <div class=\"col-6\">\r\n        <button (click)=\"onSubmit()\" [disabled]=\"!outputVal.startDate || !outputVal.endDate\"  class=\"btn btn-primary w-100\">Download</button>\r\n    </div>\r\n\r\n</div>\r\n \r\n</div>\r\n\r\n\r\n\r\n\r\n", styles: [":host{padding:24px}.header{color:#101828;font-size:18px;font-weight:600;line-height:28px}:host::ng-deep .md-drppicker .btn{line-height:10px!important}:host::ng-deep .daterangepicker-input+.ngx-daterangepicker-material .applyBtn{display:none}:host::ng-deep .md-drppicker.drops-down-right.ltr.show-ranges.shown{top:65px!important}:host::ng-deep .md-drppicker.drops-down-right.ltr.double.show-ranges.shown{top:65px!important;right:-475px!important;left:unset!important;height:400px!important}:host::ng-deep .md-drppicker .btn{border-radius:8px!important;border:1px solid var(--Primary-600, #00A3FF)!important;background:var(--Primary-600, #00A3FF)!important;box-shadow:0 1px 2px #1018280d!important;color:var(--White, #FFF)!important;font-size:14px!important;font-weight:600!important;line-height:20px;text-transform:capitalize}:host::ng-deep .md-drppicker .ranges ul li button{padding:12px 16px;width:160px;color:var(--Gray-700, #344054);font-size:14px;font-weight:400;line-height:20px;background:none;border:none;text-align:left;cursor:pointer}:host::ng-deep .md-drppicker td.active,:host::ng-deep .md-drppicker td.active:hover{background-color:#029cf4!important;border-radius:20px!important;color:var(--White, #FFF)!important;text-align:center!important;font-size:14px!important;font-weight:500!important;line-height:20px}:host::ng-deep .md-drppicker.ltr .ranges{float:left;margin-top:10px!important}:host::ng-deep .md-drppicker td.in-range{background:var(--Primary-50, #EAF8FF)}:host::ng-deep .md-drppicker .ranges ul li button.active{background:var(--Primary-50, #EAF8FF)!important;border-radius:8px!important;color:var(--Primary-700, #009BF3);font-size:14px!important;font-weight:500!important;line-height:20px!important}:host::ng-deep .md-drppicker table th,:host::ng-deep table td{width:40px!important;height:40px!important;padding:10px 8px!important}:host::ng-deep .md-drppicker td.available.prev,:host::ng-deep .md-drppicker th.available.prev{background-image:url(data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgMy43IDYiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDMuNyA2IiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxnPg0KCTxwYXRoIGQ9Ik0zLjcsMC43TDEuNCwzbDIuMywyLjNMMyw2TDAsM2wzLTNMMy43LDAuN3oiLz4NCjwvZz4NCjwvc3ZnPg0K)!important;background-repeat:no-repeat!important;background-size:.5em!important;background-position:center!important}:host::ng-deep .md-drppicker td.available.next,:host::ng-deep .md-drppicker th.available.next{background-image:url(data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgMy43IDYiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDMuNyA2IiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxnPg0KCTxwYXRoIGQ9Ik0zLjcsMC43TDEuNCwzbDIuMywyLjNMMyw2TDAsM2wzLTNMMy43LDAuN3oiLz4NCjwvZz4NCjwvc3ZnPg0K)!important;background-repeat:no-repeat!important;background-size:.5em!important;background-position:center!important}:host::ng-deep .md-drppicker table th{border-bottom:0px solid var(--Gray-200, #EAECF0)!important;background:transparent!important;color:var(--Gray-700, #344054)!important;text-align:center;font-size:16px!important;font-weight:500!important;line-height:24px}:host::ng-deep .md-drppicker .btn.btn-default{border-radius:8px!important;border:1px solid var(--Gray-300, #D0D5DD)!important;background:var(--White, #FFF)!important;box-shadow:0 1px 2px #1018280d!important;color:var(--Gray-700, #344054)!important;font-size:14px!important;font-weight:600!important;line-height:20px;text-transform:capitalize;margin-right:10px!important}:host::ng-deep .md-drppicker td.available.invalid-date{text-decoration:line-through;pointer-events:none;color:#a9a9a9}:host::ng-deep .md-drppicker td.available.today:not(.invalid-date){text-decoration:unset;pointer-events:unset;color:unset}\n"], dependencies: [{ kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.DaterangepickerComponent, selector: "ngx-daterangepicker-material", inputs: ["startDate", "endDate", "dateLimit", "autoApply", "singleDatePicker", "showDropdowns", "showWeekNumbers", "showISOWeekNumbers", "linkedCalendars", "autoUpdateInput", "alwaysShowCalendars", "maxSpan", "lockStartDate", "timePicker", "timePicker24Hour", "timePickerIncrement", "timePickerSeconds", "showClearButton", "firstMonthDayClass", "lastMonthDayClass", "emptyWeekRowClass", "emptyWeekColumnClass", "firstDayOfNextMonthClass", "lastDayOfPreviousMonthClass", "showCustomRangeLabel", "showCancel", "keepCalendarOpeningWithRange", "showRangeLabelOnInput", "customRangeDirection", "drops", "opens", "closeOnAutoApply", "minDate", "locale", "ranges", "maxDate", "isInvalidDate", "isCustomDate", "isTooltipDate"], outputs: ["choosedDate", "rangeClicked", "datesUpdated", "startDateChanged", "endDateChanged", "cancelClicked", "clearClicked"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: DatePickerComponent, decorators: [{
            type: Component,
            args: [{ selector: 'lib-date-picker', template: "<!-- <div class=\"p-4 d-flex justify-content-center\"  >\r\n<ngx-daterangepicker-material [isCustomDate]=\"isCustomDate\">\r\n</ngx-daterangepicker-material>    \r\n</div> -->\r\n\r\n<div class=\"d-flex flex-column justify-content-between h-100\" >\r\n<div>\r\n    <div class=\"header mb-5\" >Export as {{fileType}}</div>\r\n\r\n    <!-- <div class=\"d-flex align-items-center position-relative \">\r\n        <span class=\"svg-icon svg-icon-1 position-absolute ms-3\">\r\n            <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\">\r\n                <path\r\n                    d=\"M13.3333 1.66663V4.99996M6.66667 1.66663V4.99996M2.5 8.33329H17.5M4.16667 3.33329H15.8333C16.7538 3.33329 17.5 4.07948 17.5 4.99996V16.6666C17.5 17.5871 16.7538 18.3333 15.8333 18.3333H4.16667C3.24619 18.3333 2.5 17.5871 2.5 16.6666V4.99996C2.5 4.07948 3.24619 3.33329 4.16667 3.33329Z\"\r\n                    stroke=\"#344054\" stroke-width=\"1.67\" stroke-linecap=\"round\" stroke-linejoin=\"round\" />\r\n            </svg>\r\n        </span>\r\n        <input class=\"fx-date-range form-control ps-14\" style=\"min-width: 100px !important;\"\r\n    type=\"text\" matInput ngxDaterangepickerMd  [drops]=\"'down'\"\r\n    [opens]=\"'right'\" [alwaysShowCalendars]=\"true\" [keepCalendarOpeningWithRange]=\"true\"\r\n    [showCancel]=\"false\" autocomplete=\"off\" [(ngModel)]=\"selectedDateRange\"\r\n    [ngModelOptions]=\"{standalone: true}\" \r\n    [isCustomDate]=\"isCustomDate\" [autoApply]=\"true\"\r\n    [locale]=\"{ format: 'DD-MM-YYYY', firstDay: 1, monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] }\"\r\n     name=\"daterange\" [readonly]=\"true\" (startDateChanged)=\"onDateChange($event)\" (datesUpdated)=\"onDateUpdated($event)\" /> \r\n    </div>  -->\r\n    <ngx-daterangepicker-material [drops]=\"'down'\"\r\n     [opens]=\"'right'\" [alwaysShowCalendars]=\"true\" [keepCalendarOpeningWithRange]=\"true\"\r\n     [showCancel]=\"false\" autocomplete=\"off\" \r\n     [isCustomDate]=\"isCustomDate\" [autoApply]=\"true\"\r\n     [locale]=\"{ format: 'DD-MM-YYYY', firstDay: 1, monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] }\"\r\n      name=\"daterange\"  (startDateChanged)=\"onDateChange($event)\" (datesUpdated)=\"onDateUpdated($event)\">\r\n    </ngx-daterangepicker-material>\r\n    <div *ngIf=\"fileType === 'csv'\" class=\"text-muted mb-5\" >Only one month data can be downloaded</div>\r\n    <div *ngIf=\"fileType === 'pdf'\" class=\"text-muted mb-5\" >Only three days data can be downloaded</div>\r\n\r\n</div>\r\n\r\n<div class=\"row\">\r\n    <div class=\"col-6\" >\r\n        <button (click)=\"activeModal.close()\"  class=\"btn btn-outline w-100\">Cancel</button>\r\n    </div>\r\n\r\n    <div class=\"col-6\">\r\n        <button (click)=\"onSubmit()\" [disabled]=\"!outputVal.startDate || !outputVal.endDate\"  class=\"btn btn-primary w-100\">Download</button>\r\n    </div>\r\n\r\n</div>\r\n \r\n</div>\r\n\r\n\r\n\r\n\r\n", styles: [":host{padding:24px}.header{color:#101828;font-size:18px;font-weight:600;line-height:28px}:host::ng-deep .md-drppicker .btn{line-height:10px!important}:host::ng-deep .daterangepicker-input+.ngx-daterangepicker-material .applyBtn{display:none}:host::ng-deep .md-drppicker.drops-down-right.ltr.show-ranges.shown{top:65px!important}:host::ng-deep .md-drppicker.drops-down-right.ltr.double.show-ranges.shown{top:65px!important;right:-475px!important;left:unset!important;height:400px!important}:host::ng-deep .md-drppicker .btn{border-radius:8px!important;border:1px solid var(--Primary-600, #00A3FF)!important;background:var(--Primary-600, #00A3FF)!important;box-shadow:0 1px 2px #1018280d!important;color:var(--White, #FFF)!important;font-size:14px!important;font-weight:600!important;line-height:20px;text-transform:capitalize}:host::ng-deep .md-drppicker .ranges ul li button{padding:12px 16px;width:160px;color:var(--Gray-700, #344054);font-size:14px;font-weight:400;line-height:20px;background:none;border:none;text-align:left;cursor:pointer}:host::ng-deep .md-drppicker td.active,:host::ng-deep .md-drppicker td.active:hover{background-color:#029cf4!important;border-radius:20px!important;color:var(--White, #FFF)!important;text-align:center!important;font-size:14px!important;font-weight:500!important;line-height:20px}:host::ng-deep .md-drppicker.ltr .ranges{float:left;margin-top:10px!important}:host::ng-deep .md-drppicker td.in-range{background:var(--Primary-50, #EAF8FF)}:host::ng-deep .md-drppicker .ranges ul li button.active{background:var(--Primary-50, #EAF8FF)!important;border-radius:8px!important;color:var(--Primary-700, #009BF3);font-size:14px!important;font-weight:500!important;line-height:20px!important}:host::ng-deep .md-drppicker table th,:host::ng-deep table td{width:40px!important;height:40px!important;padding:10px 8px!important}:host::ng-deep .md-drppicker td.available.prev,:host::ng-deep .md-drppicker th.available.prev{background-image:url(data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgMy43IDYiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDMuNyA2IiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxnPg0KCTxwYXRoIGQ9Ik0zLjcsMC43TDEuNCwzbDIuMywyLjNMMyw2TDAsM2wzLTNMMy43LDAuN3oiLz4NCjwvZz4NCjwvc3ZnPg0K)!important;background-repeat:no-repeat!important;background-size:.5em!important;background-position:center!important}:host::ng-deep .md-drppicker td.available.next,:host::ng-deep .md-drppicker th.available.next{background-image:url(data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgMy43IDYiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDMuNyA2IiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxnPg0KCTxwYXRoIGQ9Ik0zLjcsMC43TDEuNCwzbDIuMywyLjNMMyw2TDAsM2wzLTNMMy43LDAuN3oiLz4NCjwvZz4NCjwvc3ZnPg0K)!important;background-repeat:no-repeat!important;background-size:.5em!important;background-position:center!important}:host::ng-deep .md-drppicker table th{border-bottom:0px solid var(--Gray-200, #EAECF0)!important;background:transparent!important;color:var(--Gray-700, #344054)!important;text-align:center;font-size:16px!important;font-weight:500!important;line-height:24px}:host::ng-deep .md-drppicker .btn.btn-default{border-radius:8px!important;border:1px solid var(--Gray-300, #D0D5DD)!important;background:var(--White, #FFF)!important;box-shadow:0 1px 2px #1018280d!important;color:var(--Gray-700, #344054)!important;font-size:14px!important;font-weight:600!important;line-height:20px;text-transform:capitalize;margin-right:10px!important}:host::ng-deep .md-drppicker td.available.invalid-date{text-decoration:line-through;pointer-events:none;color:#a9a9a9}:host::ng-deep .md-drppicker td.available.today:not(.invalid-date){text-decoration:unset;pointer-events:unset;color:unset}\n"] }]
        }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: i1.NgbActiveModal }], propDecorators: { fileType: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 