// Generated by purs version 0.14.5
"use strict";
var Control_Applicative = require("../Control.Applicative/index.js");
var Control_Bind = require("../Control.Bind/index.js");
var Control_Monad_Gen_Class = require("../Control.Monad.Gen.Class/index.js");
var Data_Bounded = require("../Data.Bounded/index.js");
var Data_Date = require("../Data.Date/index.js");
var Data_Date_Component = require("../Data.Date.Component/index.js");
var Data_Date_Component_Gen = require("../Data.Date.Component.Gen/index.js");
var Data_Functor = require("../Data.Functor/index.js");
var Data_Int = require("../Data.Int/index.js");
var Data_Maybe = require("../Data.Maybe/index.js");
var Data_Time_Duration = require("../Data.Time.Duration/index.js");
var genDate = function (dictMonadGen) {
    return Control_Bind.bind((dictMonadGen.Monad0()).Bind1())(Data_Date_Component_Gen.genYear(dictMonadGen))(function (year) {
        var maxDays = (function () {
            var $2 = Data_Date.isLeapYear(year);
            if ($2) {
                return 365;
            };
            return 364;
        })();
        return Control_Bind.bind((dictMonadGen.Monad0()).Bind1())(Data_Functor.map((((dictMonadGen.Monad0()).Bind1()).Apply0()).Functor0())(function ($3) {
            return Data_Time_Duration.Days(Data_Int.toNumber($3));
        })(Control_Monad_Gen_Class.chooseInt(dictMonadGen)(0)(maxDays)))(function (days) {
            return Control_Applicative.pure((dictMonadGen.Monad0()).Applicative0())(Data_Maybe.fromJust()(Control_Bind.bind(Data_Maybe.bindMaybe)(Data_Date.exactDate(year)(Data_Bounded.bottom(Data_Date_Component.boundedMonth))(Data_Bounded.bottom(Data_Date_Component.boundedDay)))(function (janFirst) {
                return Data_Date.adjust(days)(janFirst);
            })));
        });
    });
};
module.exports = {
    genDate: genDate,
    genDay: Data_Date_Component_Gen.genDay,
    genMonth: Data_Date_Component_Gen.genMonth,
    genWeekday: Data_Date_Component_Gen.genWeekday,
    genYear: Data_Date_Component_Gen.genYear
};
