"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    useExactDateVariable: ()=>useExactDateVariable,
    useExactDateVariableContext: ()=>useExactDateVariableContext
});
const external_react_namespaceObject = require("react");
const external_react_i18next_namespaceObject = require("react-i18next");
const operators_js_namespaceObject = require("../../../collection-manager/interfaces/properties/operators.js");
const index_js_namespaceObject = require("../../../flag-provider/index.js");
const util_js_namespaceObject = require("../../../schema-component/antd/date-picker/util.js");
const useExactDateVariableContext = ()=>{
    const exactDateTimeCtx = (0, external_react_namespaceObject.useMemo)(()=>(0, util_js_namespaceObject.getDateExact)(), []);
    return {
        exactDateTimeCtx
    };
};
const useExactDateVariable = function() {
    let { schema, targetFieldSchema } = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
    var _collectionField_uiSchema;
    const { collectionField } = (0, index_js_namespaceObject.useFlag)();
    const { dateOnly, utc, accuracy, picker } = (null == collectionField ? void 0 : null == (_collectionField_uiSchema = collectionField.uiSchema) ? void 0 : _collectionField_uiSchema['x-component-props']) || {};
    const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
    const exactDateTimeSettings = (0, external_react_namespaceObject.useMemo)(()=>{
        const getDateKeys = (key)=>{
            if (!picker) {
                if ('now' === key) return 'nowLocal';
                if ('today' === key) return 'todayDate';
                if ('yesterday' === key) return 'yesterdayDate';
                if ('tomorrow' === key) return 'tomorrowDate';
            }
            if (dateOnly) {
                if ('now' === key) return null;
                return "".concat(key, "Date");
            }
            return "".concat(key).concat(utc || accuracy ? 'Utc' : 'Local');
        };
        const dateOptions = [
            {
                key: 'now',
                value: getDateKeys('now'),
                label: t('Now'),
                operators: operators_js_namespaceObject.datetime
            },
            {
                key: 'today',
                value: getDateKeys('today'),
                label: t('Today'),
                operators: operators_js_namespaceObject.datetime
            },
            {
                key: 'yesterday',
                value: getDateKeys('yesterday'),
                label: t('Yesterday'),
                operators: operators_js_namespaceObject.datetime
            },
            {
                key: 'tomorrow',
                value: getDateKeys('tomorrow'),
                label: t('Tomorrow'),
                operators: operators_js_namespaceObject.datetime
            }
        ].filter((v)=>v.value);
        return {
            label: t('Date variables'),
            value: '$nExactDate',
            key: '$nExactDate',
            children: dateOptions
        };
    }, [
        null == schema ? void 0 : schema['x-component'],
        targetFieldSchema
    ]);
    const { exactDateTimeCtx } = useExactDateVariableContext();
    return {
        exactDateTimeSettings,
        exactDateTimeCtx,
        shouldDisplayExactDate: !!collectionField
    };
};
exports.useExactDateVariable = __webpack_exports__.useExactDateVariable;
exports.useExactDateVariableContext = __webpack_exports__.useExactDateVariableContext;
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
    "useExactDateVariable",
    "useExactDateVariableContext"
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
Object.defineProperty(exports, '__esModule', {
    value: true
});
