antd-date-picker-nepali
Version:
This is a antd component for nepali datepicker.
22,733 lines • 864 kB
JavaScript
import * as React from "react";
import React__default, { createContext, useContext, useEffect, version as version$2, isValidElement, useRef, useLayoutEffect as useLayoutEffect$1, useState, useMemo as useMemo$1, useCallback, forwardRef, Children, createRef, useImperativeHandle } from "react";
import { DatePicker } from "antd";
import classNames from "classnames";
import * as ReactDOM from "react-dom";
import ReactDOM__default, { createPortal, unstable_batchedUpdates } from "react-dom";
import dayjs from "dayjs";
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
function getDefaultExportFromCjs(x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
}
var jsxRuntime = { exports: {} };
var reactJsxRuntime_production_min = {};
/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var hasRequiredReactJsxRuntime_production_min;
function requireReactJsxRuntime_production_min() {
if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min;
hasRequiredReactJsxRuntime_production_min = 1;
var f = React__default, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
function q(c, a, g) {
var b, d = {}, e = null, h = null;
void 0 !== g && (e = "" + g);
void 0 !== a.key && (e = "" + a.key);
void 0 !== a.ref && (h = a.ref);
for (b in a) m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
if (c && c.defaultProps) for (b in a = c.defaultProps, a) void 0 === d[b] && (d[b] = a[b]);
return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
}
reactJsxRuntime_production_min.Fragment = l;
reactJsxRuntime_production_min.jsx = q;
reactJsxRuntime_production_min.jsxs = q;
return reactJsxRuntime_production_min;
}
var reactJsxRuntime_development = {};
/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var hasRequiredReactJsxRuntime_development;
function requireReactJsxRuntime_development() {
if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
hasRequiredReactJsxRuntime_development = 1;
if (process.env.NODE_ENV !== "production") {
(function() {
var React2 = React__default;
var REACT_ELEMENT_TYPE = Symbol.for("react.element");
var REACT_PORTAL_TYPE = Symbol.for("react.portal");
var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
var REACT_PROVIDER_TYPE = Symbol.for("react.provider");
var REACT_CONTEXT_TYPE = Symbol.for("react.context");
var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list");
var REACT_MEMO_TYPE = Symbol.for("react.memo");
var REACT_LAZY_TYPE = Symbol.for("react.lazy");
var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
var FAUX_ITERATOR_SYMBOL = "@@iterator";
function getIteratorFn(maybeIterable) {
if (maybeIterable === null || typeof maybeIterable !== "object") {
return null;
}
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
if (typeof maybeIterator === "function") {
return maybeIterator;
}
return null;
}
var ReactSharedInternals = React2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
function error(format2) {
{
{
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
args[_key2 - 1] = arguments[_key2];
}
printWarning("error", format2, args);
}
}
}
function printWarning(level, format2, args) {
{
var ReactDebugCurrentFrame2 = ReactSharedInternals.ReactDebugCurrentFrame;
var stack = ReactDebugCurrentFrame2.getStackAddendum();
if (stack !== "") {
format2 += "%s";
args = args.concat([stack]);
}
var argsWithFormat = args.map(function(item) {
return String(item);
});
argsWithFormat.unshift("Warning: " + format2);
Function.prototype.apply.call(console[level], console, argsWithFormat);
}
}
var enableScopeAPI = false;
var enableCacheElement = false;
var enableTransitionTracing = false;
var enableLegacyHidden = false;
var enableDebugTracing = false;
var REACT_MODULE_REFERENCE;
{
REACT_MODULE_REFERENCE = Symbol.for("react.module.reference");
}
function isValidElementType(type4) {
if (typeof type4 === "string" || typeof type4 === "function") {
return true;
}
if (type4 === REACT_FRAGMENT_TYPE || type4 === REACT_PROFILER_TYPE || enableDebugTracing || type4 === REACT_STRICT_MODE_TYPE || type4 === REACT_SUSPENSE_TYPE || type4 === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type4 === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing) {
return true;
}
if (typeof type4 === "object" && type4 !== null) {
if (type4.$$typeof === REACT_LAZY_TYPE || type4.$$typeof === REACT_MEMO_TYPE || type4.$$typeof === REACT_PROVIDER_TYPE || type4.$$typeof === REACT_CONTEXT_TYPE || type4.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
// types supported by any Flight configuration anywhere since
// we don't know which Flight build this will end up being used
// with.
type4.$$typeof === REACT_MODULE_REFERENCE || type4.getModuleId !== void 0) {
return true;
}
}
return false;
}
function getWrappedName(outerType, innerType, wrapperName) {
var displayName = outerType.displayName;
if (displayName) {
return displayName;
}
var functionName = innerType.displayName || innerType.name || "";
return functionName !== "" ? wrapperName + "(" + functionName + ")" : wrapperName;
}
function getContextName(type4) {
return type4.displayName || "Context";
}
function getComponentNameFromType(type4) {
if (type4 == null) {
return null;
}
{
if (typeof type4.tag === "number") {
error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.");
}
}
if (typeof type4 === "function") {
return type4.displayName || type4.name || null;
}
if (typeof type4 === "string") {
return type4;
}
switch (type4) {
case REACT_FRAGMENT_TYPE:
return "Fragment";
case REACT_PORTAL_TYPE:
return "Portal";
case REACT_PROFILER_TYPE:
return "Profiler";
case REACT_STRICT_MODE_TYPE:
return "StrictMode";
case REACT_SUSPENSE_TYPE:
return "Suspense";
case REACT_SUSPENSE_LIST_TYPE:
return "SuspenseList";
}
if (typeof type4 === "object") {
switch (type4.$$typeof) {
case REACT_CONTEXT_TYPE:
var context = type4;
return getContextName(context) + ".Consumer";
case REACT_PROVIDER_TYPE:
var provider = type4;
return getContextName(provider._context) + ".Provider";
case REACT_FORWARD_REF_TYPE:
return getWrappedName(type4, type4.render, "ForwardRef");
case REACT_MEMO_TYPE:
var outerName = type4.displayName || null;
if (outerName !== null) {
return outerName;
}
return getComponentNameFromType(type4.type) || "Memo";
case REACT_LAZY_TYPE: {
var lazyComponent = type4;
var payload = lazyComponent._payload;
var init = lazyComponent._init;
try {
return getComponentNameFromType(init(payload));
} catch (x) {
return null;
}
}
}
}
return null;
}
var assign = Object.assign;
var disabledDepth = 0;
var prevLog;
var prevInfo;
var prevWarn;
var prevError;
var prevGroup;
var prevGroupCollapsed;
var prevGroupEnd;
function disabledLog() {
}
disabledLog.__reactDisabledLog = true;
function disableLogs() {
{
if (disabledDepth === 0) {
prevLog = console.log;
prevInfo = console.info;
prevWarn = console.warn;
prevError = console.error;
prevGroup = console.group;
prevGroupCollapsed = console.groupCollapsed;
prevGroupEnd = console.groupEnd;
var props = {
configurable: true,
enumerable: true,
value: disabledLog,
writable: true
};
Object.defineProperties(console, {
info: props,
log: props,
warn: props,
error: props,
group: props,
groupCollapsed: props,
groupEnd: props
});
}
disabledDepth++;
}
}
function reenableLogs() {
{
disabledDepth--;
if (disabledDepth === 0) {
var props = {
configurable: true,
enumerable: true,
writable: true
};
Object.defineProperties(console, {
log: assign({}, props, {
value: prevLog
}),
info: assign({}, props, {
value: prevInfo
}),
warn: assign({}, props, {
value: prevWarn
}),
error: assign({}, props, {
value: prevError
}),
group: assign({}, props, {
value: prevGroup
}),
groupCollapsed: assign({}, props, {
value: prevGroupCollapsed
}),
groupEnd: assign({}, props, {
value: prevGroupEnd
})
});
}
if (disabledDepth < 0) {
error("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
}
}
}
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
var prefix;
function describeBuiltInComponentFrame(name, source, ownerFn) {
{
if (prefix === void 0) {
try {
throw Error();
} catch (x) {
var match2 = x.stack.trim().match(/\n( *(at )?)/);
prefix = match2 && match2[1] || "";
}
}
return "\n" + prefix + name;
}
}
var reentry = false;
var componentFrameCache;
{
var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map;
componentFrameCache = new PossiblyWeakMap();
}
function describeNativeComponentFrame(fn, construct) {
if (!fn || reentry) {
return "";
}
{
var frame = componentFrameCache.get(fn);
if (frame !== void 0) {
return frame;
}
}
var control;
reentry = true;
var previousPrepareStackTrace = Error.prepareStackTrace;
Error.prepareStackTrace = void 0;
var previousDispatcher;
{
previousDispatcher = ReactCurrentDispatcher.current;
ReactCurrentDispatcher.current = null;
disableLogs();
}
try {
if (construct) {
var Fake = function() {
throw Error();
};
Object.defineProperty(Fake.prototype, "props", {
set: function() {
throw Error();
}
});
if (typeof Reflect === "object" && Reflect.construct) {
try {
Reflect.construct(Fake, []);
} catch (x) {
control = x;
}
Reflect.construct(fn, [], Fake);
} else {
try {
Fake.call();
} catch (x) {
control = x;
}
fn.call(Fake.prototype);
}
} else {
try {
throw Error();
} catch (x) {
control = x;
}
fn();
}
} catch (sample) {
if (sample && control && typeof sample.stack === "string") {
var sampleLines = sample.stack.split("\n");
var controlLines = control.stack.split("\n");
var s = sampleLines.length - 1;
var c = controlLines.length - 1;
while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
c--;
}
for (; s >= 1 && c >= 0; s--, c--) {
if (sampleLines[s] !== controlLines[c]) {
if (s !== 1 || c !== 1) {
do {
s--;
c--;
if (c < 0 || sampleLines[s] !== controlLines[c]) {
var _frame = "\n" + sampleLines[s].replace(" at new ", " at ");
if (fn.displayName && _frame.includes("<anonymous>")) {
_frame = _frame.replace("<anonymous>", fn.displayName);
}
{
if (typeof fn === "function") {
componentFrameCache.set(fn, _frame);
}
}
return _frame;
}
} while (s >= 1 && c >= 0);
}
break;
}
}
}
} finally {
reentry = false;
{
ReactCurrentDispatcher.current = previousDispatcher;
reenableLogs();
}
Error.prepareStackTrace = previousPrepareStackTrace;
}
var name = fn ? fn.displayName || fn.name : "";
var syntheticFrame = name ? describeBuiltInComponentFrame(name) : "";
{
if (typeof fn === "function") {
componentFrameCache.set(fn, syntheticFrame);
}
}
return syntheticFrame;
}
function describeFunctionComponentFrame(fn, source, ownerFn) {
{
return describeNativeComponentFrame(fn, false);
}
}
function shouldConstruct(Component) {
var prototype = Component.prototype;
return !!(prototype && prototype.isReactComponent);
}
function describeUnknownElementTypeFrameInDEV(type4, source, ownerFn) {
if (type4 == null) {
return "";
}
if (typeof type4 === "function") {
{
return describeNativeComponentFrame(type4, shouldConstruct(type4));
}
}
if (typeof type4 === "string") {
return describeBuiltInComponentFrame(type4);
}
switch (type4) {
case REACT_SUSPENSE_TYPE:
return describeBuiltInComponentFrame("Suspense");
case REACT_SUSPENSE_LIST_TYPE:
return describeBuiltInComponentFrame("SuspenseList");
}
if (typeof type4 === "object") {
switch (type4.$$typeof) {
case REACT_FORWARD_REF_TYPE:
return describeFunctionComponentFrame(type4.render);
case REACT_MEMO_TYPE:
return describeUnknownElementTypeFrameInDEV(type4.type, source, ownerFn);
case REACT_LAZY_TYPE: {
var lazyComponent = type4;
var payload = lazyComponent._payload;
var init = lazyComponent._init;
try {
return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
} catch (x) {
}
}
}
}
return "";
}
var hasOwnProperty = Object.prototype.hasOwnProperty;
var loggedTypeFailures = {};
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
function setCurrentlyValidatingElement(element) {
{
if (element) {
var owner = element._owner;
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
ReactDebugCurrentFrame.setExtraStackFrame(stack);
} else {
ReactDebugCurrentFrame.setExtraStackFrame(null);
}
}
}
function checkPropTypes(typeSpecs, values, location, componentName, element) {
{
var has = Function.call.bind(hasOwnProperty);
for (var typeSpecName in typeSpecs) {
if (has(typeSpecs, typeSpecName)) {
var error$1 = void 0;
try {
if (typeof typeSpecs[typeSpecName] !== "function") {
var err = Error((componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
err.name = "Invariant Violation";
throw err;
}
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
} catch (ex) {
error$1 = ex;
}
if (error$1 && !(error$1 instanceof Error)) {
setCurrentlyValidatingElement(element);
error("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", componentName || "React class", location, typeSpecName, typeof error$1);
setCurrentlyValidatingElement(null);
}
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
loggedTypeFailures[error$1.message] = true;
setCurrentlyValidatingElement(element);
error("Failed %s type: %s", location, error$1.message);
setCurrentlyValidatingElement(null);
}
}
}
}
}
var isArrayImpl = Array.isArray;
function isArray(a) {
return isArrayImpl(a);
}
function typeName(value) {
{
var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag;
var type4 = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
return type4;
}
}
function willCoercionThrow(value) {
{
try {
testStringCoercion(value);
return false;
} catch (e) {
return true;
}
}
}
function testStringCoercion(value) {
return "" + value;
}
function checkKeyStringCoercion(value) {
{
if (willCoercionThrow(value)) {
error("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", typeName(value));
return testStringCoercion(value);
}
}
}
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
var RESERVED_PROPS = {
key: true,
ref: true,
__self: true,
__source: true
};
var specialPropKeyWarningShown;
var specialPropRefWarningShown;
var didWarnAboutStringRefs;
{
didWarnAboutStringRefs = {};
}
function hasValidRef(config) {
{
if (hasOwnProperty.call(config, "ref")) {
var getter = Object.getOwnPropertyDescriptor(config, "ref").get;
if (getter && getter.isReactWarning) {
return false;
}
}
}
return config.ref !== void 0;
}
function hasValidKey(config) {
{
if (hasOwnProperty.call(config, "key")) {
var getter = Object.getOwnPropertyDescriptor(config, "key").get;
if (getter && getter.isReactWarning) {
return false;
}
}
}
return config.key !== void 0;
}
function warnIfStringRefCannotBeAutoConverted(config, self2) {
{
if (typeof config.ref === "string" && ReactCurrentOwner.current && self2 && ReactCurrentOwner.current.stateNode !== self2) {
var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);
if (!didWarnAboutStringRefs[componentName]) {
error('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', getComponentNameFromType(ReactCurrentOwner.current.type), config.ref);
didWarnAboutStringRefs[componentName] = true;
}
}
}
}
function defineKeyPropWarningGetter(props, displayName) {
{
var warnAboutAccessingKey = function() {
if (!specialPropKeyWarningShown) {
specialPropKeyWarningShown = true;
error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName);
}
};
warnAboutAccessingKey.isReactWarning = true;
Object.defineProperty(props, "key", {
get: warnAboutAccessingKey,
configurable: true
});
}
}
function defineRefPropWarningGetter(props, displayName) {
{
var warnAboutAccessingRef = function() {
if (!specialPropRefWarningShown) {
specialPropRefWarningShown = true;
error("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName);
}
};
warnAboutAccessingRef.isReactWarning = true;
Object.defineProperty(props, "ref", {
get: warnAboutAccessingRef,
configurable: true
});
}
}
var ReactElement = function(type4, key, ref, self2, source, owner, props) {
var element = {
// This tag allows us to uniquely identify this as a React Element
$$typeof: REACT_ELEMENT_TYPE,
// Built-in properties that belong on the element
type: type4,
key,
ref,
props,
// Record the component responsible for creating this element.
_owner: owner
};
{
element._store = {};
Object.defineProperty(element._store, "validated", {
configurable: false,
enumerable: false,
writable: true,
value: false
});
Object.defineProperty(element, "_self", {
configurable: false,
enumerable: false,
writable: false,
value: self2
});
Object.defineProperty(element, "_source", {
configurable: false,
enumerable: false,
writable: false,
value: source
});
if (Object.freeze) {
Object.freeze(element.props);
Object.freeze(element);
}
}
return element;
};
function jsxDEV(type4, config, maybeKey, source, self2) {
{
var propName;
var props = {};
var key = null;
var ref = null;
if (maybeKey !== void 0) {
{
checkKeyStringCoercion(maybeKey);
}
key = "" + maybeKey;
}
if (hasValidKey(config)) {
{
checkKeyStringCoercion(config.key);
}
key = "" + config.key;
}
if (hasValidRef(config)) {
ref = config.ref;
warnIfStringRefCannotBeAutoConverted(config, self2);
}
for (propName in config) {
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
props[propName] = config[propName];
}
}
if (type4 && type4.defaultProps) {
var defaultProps = type4.defaultProps;
for (propName in defaultProps) {
if (props[propName] === void 0) {
props[propName] = defaultProps[propName];
}
}
}
if (key || ref) {
var displayName = typeof type4 === "function" ? type4.displayName || type4.name || "Unknown" : type4;
if (key) {
defineKeyPropWarningGetter(props, displayName);
}
if (ref) {
defineRefPropWarningGetter(props, displayName);
}
}
return ReactElement(type4, key, ref, self2, source, ReactCurrentOwner.current, props);
}
}
var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
function setCurrentlyValidatingElement$1(element) {
{
if (element) {
var owner = element._owner;
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
} else {
ReactDebugCurrentFrame$1.setExtraStackFrame(null);
}
}
}
var propTypesMisspellWarningShown;
{
propTypesMisspellWarningShown = false;
}
function isValidElement2(object4) {
{
return typeof object4 === "object" && object4 !== null && object4.$$typeof === REACT_ELEMENT_TYPE;
}
}
function getDeclarationErrorAddendum() {
{
if (ReactCurrentOwner$1.current) {
var name = getComponentNameFromType(ReactCurrentOwner$1.current.type);
if (name) {
return "\n\nCheck the render method of `" + name + "`.";
}
}
return "";
}
}
function getSourceInfoErrorAddendum(source) {
{
return "";
}
}
var ownerHasKeyUseWarning = {};
function getCurrentComponentErrorInfo(parentType) {
{
var info = getDeclarationErrorAddendum();
if (!info) {
var parentName = typeof parentType === "string" ? parentType : parentType.displayName || parentType.name;
if (parentName) {
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
}
}
return info;
}
}
function validateExplicitKey(element, parentType) {
{
if (!element._store || element._store.validated || element.key != null) {
return;
}
element._store.validated = true;
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
return;
}
ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
var childOwner = "";
if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
}
setCurrentlyValidatingElement$1(element);
error('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
setCurrentlyValidatingElement$1(null);
}
}
function validateChildKeys(node2, parentType) {
{
if (typeof node2 !== "object") {
return;
}
if (isArray(node2)) {
for (var i = 0; i < node2.length; i++) {
var child = node2[i];
if (isValidElement2(child)) {
validateExplicitKey(child, parentType);
}
}
} else if (isValidElement2(node2)) {
if (node2._store) {
node2._store.validated = true;
}
} else if (node2) {
var iteratorFn = getIteratorFn(node2);
if (typeof iteratorFn === "function") {
if (iteratorFn !== node2.entries) {
var iterator = iteratorFn.call(node2);
var step;
while (!(step = iterator.next()).done) {
if (isValidElement2(step.value)) {
validateExplicitKey(step.value, parentType);
}
}
}
}
}
}
}
function validatePropTypes(element) {
{
var type4 = element.type;
if (type4 === null || type4 === void 0 || typeof type4 === "string") {
return;
}
var propTypes;
if (typeof type4 === "function") {
propTypes = type4.propTypes;
} else if (typeof type4 === "object" && (type4.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
// Inner props are checked in the reconciler.
type4.$$typeof === REACT_MEMO_TYPE)) {
propTypes = type4.propTypes;
} else {
return;
}
if (propTypes) {
var name = getComponentNameFromType(type4);
checkPropTypes(propTypes, element.props, "prop", name, element);
} else if (type4.PropTypes !== void 0 && !propTypesMisspellWarningShown) {
propTypesMisspellWarningShown = true;
var _name = getComponentNameFromType(type4);
error("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", _name || "Unknown");
}
if (typeof type4.getDefaultProps === "function" && !type4.getDefaultProps.isReactClassApproved) {
error("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
}
}
}
function validateFragmentProps(fragment) {
{
var keys2 = Object.keys(fragment.props);
for (var i = 0; i < keys2.length; i++) {
var key = keys2[i];
if (key !== "children" && key !== "key") {
setCurrentlyValidatingElement$1(fragment);
error("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", key);
setCurrentlyValidatingElement$1(null);
break;
}
}
if (fragment.ref !== null) {
setCurrentlyValidatingElement$1(fragment);
error("Invalid attribute `ref` supplied to `React.Fragment`.");
setCurrentlyValidatingElement$1(null);
}
}
}
var didWarnAboutKeySpread = {};
function jsxWithValidation(type4, props, key, isStaticChildren, source, self2) {
{
var validType = isValidElementType(type4);
if (!validType) {
var info = "";
if (type4 === void 0 || typeof type4 === "object" && type4 !== null && Object.keys(type4).length === 0) {
info += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.";
}
var sourceInfo = getSourceInfoErrorAddendum();
if (sourceInfo) {
info += sourceInfo;
} else {
info += getDeclarationErrorAddendum();
}
var typeString;
if (type4 === null) {
typeString = "null";
} else if (isArray(type4)) {
typeString = "array";
} else if (type4 !== void 0 && type4.$$typeof === REACT_ELEMENT_TYPE) {
typeString = "<" + (getComponentNameFromType(type4.type) || "Unknown") + " />";
info = " Did you accidentally export a JSX literal instead of a component?";
} else {
typeString = typeof type4;
}
error("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", typeString, info);
}
var element = jsxDEV(type4, props, key, source, self2);
if (element == null) {
return element;
}
if (validType) {
var children = props.children;
if (children !== void 0) {
if (isStaticChildren) {
if (isArray(children)) {
for (var i = 0; i < children.length; i++) {
validateChildKeys(children[i], type4);
}
if (Object.freeze) {
Object.freeze(children);
}
} else {
error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
}
} else {
validateChildKeys(children, type4);
}
}
}
{
if (hasOwnProperty.call(props, "key")) {
var componentName = getComponentNameFromType(type4);
var keys2 = Object.keys(props).filter(function(k) {
return k !== "key";
});
var beforeExample = keys2.length > 0 ? "{key: someKey, " + keys2.join(": ..., ") + ": ...}" : "{key: someKey}";
if (!didWarnAboutKeySpread[componentName + beforeExample]) {
var afterExample = keys2.length > 0 ? "{" + keys2.join(": ..., ") + ": ...}" : "{}";
error('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />', beforeExample, componentName, afterExample, componentName);
didWarnAboutKeySpread[componentName + beforeExample] = true;
}
}
}
if (type4 === REACT_FRAGMENT_TYPE) {
validateFragmentProps(element);
} else {
validatePropTypes(element);
}
return element;
}
}
function jsxWithValidationStatic(type4, props, key) {
{
return jsxWithValidation(type4, props, key, true);
}
}
function jsxWithValidationDynamic(type4, props, key) {
{
return jsxWithValidation(type4, props, key, false);
}
}
var jsx = jsxWithValidationDynamic;
var jsxs = jsxWithValidationStatic;
reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
reactJsxRuntime_development.jsx = jsx;
reactJsxRuntime_development.jsxs = jsxs;
})();
}
return reactJsxRuntime_development;
}
if (process.env.NODE_ENV === "production") {
jsxRuntime.exports = requireReactJsxRuntime_production_min();
} else {
jsxRuntime.exports = requireReactJsxRuntime_development();
}
var jsxRuntimeExports = jsxRuntime.exports;
function _extends() {
return _extends = Object.assign ? Object.assign.bind() : function(n) {
for (var e = 1; e < arguments.length; e++) {
var t = arguments[e];
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
}
return n;
}, _extends.apply(null, arguments);
}
var CalendarOutlined$1 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M880 184H712v-64c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v64H384v-64c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v64H144c-17.7 0-32 14.3-32 32v664c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V216c0-17.7-14.3-32-32-32zm-40 656H184V460h656v380zM184 392V256h128v48c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8v-48h256v48c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8v-48h128v136H184z" } }] }, "name": "calendar", "theme": "outlined" };
function _arrayWithHoles(r) {
if (Array.isArray(r)) return r;
}
function _iterableToArrayLimit(r, l) {
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (null != t) {
var e, n, i, u, a = [], f = true, o = false;
try {
if (i = (t = t.call(r)).next, 0 === l) {
if (Object(t) !== t) return;
f = false;
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ;
} catch (r2) {
o = true, n = r2;
} finally {
try {
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
} finally {
if (o) throw n;
}
}
return a;
}
}
function _arrayLikeToArray(r, a) {
(null == a || a > r.length) && (a = r.length);
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
return n;
}
function _unsupportedIterableToArray(r, a) {
if (r) {
if ("string" == typeof r) return _arrayLikeToArray(r, a);
var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
}
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _slicedToArray(r, e) {
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
}
function _typeof(o) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
return typeof o2;
} : function(o2) {
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
}, _typeof(o);
}
function toPrimitive(t, r) {
if ("object" != _typeof(t) || !t) return t;
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r || "default");
if ("object" != _typeof(i)) return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return ("string" === r ? String : Number)(t);
}
function toPropertyKey(t) {
var i = toPrimitive(t, "string");
return "symbol" == _typeof(i) ? i : i + "";
}
function _defineProperty(e, r, t) {
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
value: t,
enumerable: true,
configurable: true,
writable: true
}) : e[r] = t, e;
}
function _objectWithoutPropertiesLoose(r, e) {
if (null == r) return {};
var t = {};
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
if (e.includes(n)) continue;
t[n] = r[n];
}
return t;
}
function _objectWithoutProperties(e, t) {
if (null == e) return {};
var o, r, i = _objectWithoutPropertiesLoose(e, t);
if (Object.getOwnPropertySymbols) {
var s = Object.getOwnPropertySymbols(e);
for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
}
return i;
}
function bound01(n, max) {
if (isOnePointZero(n)) {
n = "100%";
}
var isPercent = isPercentage(n);
n = max === 360 ? n : Math.min(max, Math.max(0, parseFloat(n)));
if (isPercent) {
n = parseInt(String(n * max), 10) / 100;
}
if (Math.abs(n - max) < 1e-6) {
return 1;
}
if (max === 360) {
n = (n < 0 ? n % max + max : n % max) / parseFloat(String(max));
} else {
n = n % max / parseFloat(String(max));
}
return n;
}
function clamp01(val) {
return Math.min(1, Math.max(0, val));
}
function isOnePointZero(n) {
return typeof n === "string" && n.indexOf(".") !== -1 && parseFloat(n) === 1;
}
function isPercentage(n) {
return typeof n === "string" && n.indexOf("%") !== -1;
}
function boundAlpha(a) {
a = parseFloat(a);
if (isNaN(a) || a < 0 || a > 1) {
a = 1;
}
return a;
}
function convertToPercentage(n) {
if (n <= 1) {
return "".concat(Number(n) * 100, "%");
}
return n;
}
function pad2(c) {
return c.length === 1 ? "0" + c : String(c);
}
function rgbToRgb(r, g, b) {
return {
r: bound01(r, 255) * 255,
g: bound01(g, 255) * 255,
b: bound01(b, 255) * 255
};
}
function rgbToHsl(r, g, b) {
r = bound01(r, 255);
g = bound01(g, 255);
b = bound01(b, 255);
var max = Math.max(r, g, b);
var min = Math.min(r, g, b);
var h = 0;
var s = 0;
var l = (max + min) / 2;
if (max === min) {
s = 0;
h = 0;
} else {
var d = max - min;
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
switch (max) {
case r:
h = (g - b) / d + (g < b ? 6 : 0);
break;
case g:
h = (b - r) / d + 2;
break;
case b:
h = (r - g) / d + 4;
break;
}
h /= 6;
}
return { h, s, l };
}
function hue2rgb(p, q, t) {
if (t < 0) {
t += 1;
}
if (t > 1) {
t -= 1;
}
if (t < 1 / 6) {
return p + (q - p) * (6 * t);
}
if (t < 1 / 2) {
return q;
}
if (t < 2 / 3) {
return p + (q - p) * (2 / 3 - t) * 6;
}
return p;
}
function hslToRgb(h, s, l) {
var r;
var g;
var b;
h = bound01(h, 360);
s = bound01(s, 100);
l = bound01(l, 100);
if (s === 0) {
g = l;
b = l;
r = l;
} else {
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
var p = 2 * l - q;
r = hue2rgb(p, q, h + 1 / 3);
g = hue2rgb(p, q, h);
b = hue2rgb(p, q, h - 1 / 3);
}
return { r: r * 255, g: g * 255, b: b * 255 };
}
function rgbToHsv(r, g, b) {
r = bound01(r, 255);
g = bound01(g, 255);
b = bound01(b, 255);
var max = Math.max(r, g, b);
var min = Math.min(r, g, b);
var h = 0;
var v = max;
var d = max - min;
var s = max === 0 ? 0 : d / max;
if (max === min) {
h = 0;
} else {
switch (max) {
case r:
h = (g - b) / d + (g < b ? 6 : 0);
break;
case g:
h = (b - r) / d + 2;
break;
case b:
h = (r - g) / d + 4;
break;
}
h /= 6;
}
return { h, s, v };
}
function hsvToRgb(h, s, v) {
h = bound01(h, 360) * 6;
s = bound01(s, 100);
v = bound01(v, 100);
var i = Math.floor(h);
var f = h - i;
var p = v * (1 - s);
var q = v * (1 - f * s);
var t = v * (1 - (1 - f) * s);
var mod = i % 6;
var r = [v, q, p, p, t, v][mod];
var g = [t, v, v, q, p, p][mod];
var b = [p, p, t, v, v, q][mod];
return { r: r * 255, g: g * 255, b: b * 255 };
}
function rgbToHex(r, g, b, allow3Char) {
var hex2 = [
pad2(Math.round(r).toString(16)),
pad2(Math.round(g).toString(16)),
pad2(Math.round(b).toString(16))
];
if (allow3Char && hex2[0].startsWith(hex2[0].charAt(1)) && hex2[1].startsWith(hex2[1].charAt(1)) && hex2[2].startsWith(hex2[2].charAt(1))) {
return hex2[0].charAt(0) + hex2[1].charAt(0) + hex2[2].charAt(0);
}
return hex2.join("");
}
function rgbaToHex(r, g, b, a, allow4Char) {
var hex2 = [
pad2(Math.round(r).toString(16)),
pad2(Math.round(g).toString(16)),
pad2(Math.round(b).toString(16)),
pad2(convertDecimalToHex(a))
];
if (allow4Char && hex2[0].startsWith(hex2[0].charAt(1)) && hex2[1].startsWith(hex2[1].charAt(1)) && hex2[2].startsWith(hex2[2].charAt(1)) && hex2[3].startsWith(hex2[3].charAt(1))) {
return hex2[0].charAt(0) + hex2[1].charAt(0) + hex2[2].charAt(0) + hex2[3].charAt(0);
}
return hex2.join("");
}
function convertDecimalToHex(d) {
return Math.round(parseFloat(d) * 255).toString(16);
}
function convertHexToDecimal(h) {
return parseIntFromHex(h) / 255;
}
function parseIntFromHex(val) {
return parseInt(val, 16);
}
function numberInputToObject(color) {
return {
r: color >> 16,
g: (color & 65280) >> 8,
b: color & 255
};
}
var names = {
aliceblue: "#f0f8ff",
antiquewhite: "#faebd7",
aqua: "#00ffff",
aquamarine: "#7fffd4",
azure: "#f0ffff",
beige: "#f5f5dc",
bisque: "#ffe4c4",
black: "#000000",
blanchedalmond: "#ffebcd",
blue: "#0000ff",
blueviolet: "#8a2be2",
brown: "#a52a2a",
burlywood: "#deb887",
cadetblue: "#5f9ea0",
chartreuse: "#7fff00",
chocolate: "#d2691e",
coral: "#ff7f50",
cornflowerblue: "#6495ed",
cornsilk: "#fff8dc",
crimson: "#dc143c",
cyan: "#00ffff",
darkblue: "#00008b",
darkcyan: "#008b8b",
darkgoldenrod: "#b8860b",
darkgray: "#a9a9a9",
darkgreen: "#006400",
darkgrey: "#a9a9a9",
darkkhaki: "#bdb76b",
darkmagenta: "#8b008b",
darkolivegreen: "#556b2f",
darkorange: "#ff8c00",
darkorchid: "#9932cc",
darkred: "#8b0000",
darksalmon: "#e9967a",
darkseagreen: "#8fbc8f",
darkslateblue: "#483d8b",
darkslategray: "#2f4f4f",
darkslategrey: "#2f4f4f",
darkturquoise: "#00ced1",
darkviolet: "#9400d3",
deeppink: "#ff1493",
deepskyblue: "#00bfff",
dimgray: "#696969",
dimgrey: "#696969",
dodgerblue: "#1e90ff",
firebrick: "#b22222",
floralwhite: "#fffaf0",
forestgreen: "#228b22",
fuchsia: "#ff00ff",
gainsboro: "#dcdcdc",
ghostwhite: "#f8f8ff",
goldenrod: "#daa520",
gold: "#ffd700",
gray: "#808080",
green: "#008000",
greenyellow: "#adff2f",
grey: "#808080",
honeydew: "#f0fff0",
hotpink: "#ff69b4",
indianred: "#cd5c5c",
indigo: "#4b0082",
ivory: "#fffff0",
khaki: "#f0e68c",
lavenderblush: "#fff0f5",
lavender: "#e6e6fa",
lawngreen: "#7cfc00",
lemonchiffon: "#fffacd",
lightblue: "#add8e6",
lightcoral: "#f08080",
lightcyan: "#e0ffff",
lightgoldenrodyellow: "#fafad2",
lightgray: "#d3d3d3",
lightgreen: "#90ee90",
lightgrey: "#d3d3d3",
lightpink: "#ffb6c1",
lightsalmon: "#ffa07a",
lightseagreen: "#20b2aa",
lightskyblue: "#87cefa",
lightslategray: "#778899",
lightslategrey: "#778899",
lightsteelblue: "#b0c4de",
lightyellow: "#ffffe0",
lime: "#00ff00",
limegreen: "#32cd32",
linen: "#faf0e6",
magenta: "#ff00ff",
maroon: "#800000",
mediumaquamarine: "#66cdaa",
mediumblue: "#0000cd",
mediumorchid: "#ba55d3",
mediumpurple: "#9370db",
mediumseagreen: "#3cb371",
mediumslateblue: "#7b68ee",
mediumspringgreen: "#00fa9a",
mediumturquoise: "#48d1cc",
mediumvioletred: "#c71585",
midnightblue: "#191970",
mintcream: "#f5fffa",
mistyrose: "#ffe4e1",
moccasin: "#ffe4b5",
navajowhite: "#ffdead",
navy: "#000080",
oldlace: "#fdf5e6",
olive: "#808000",
olivedrab: "#6b8e23",
orange: "#ffa500",
orangered: "#ff4500",
orchid: "#da70d6",
palegoldenrod: "#eee8aa",
palegreen: "#98fb98",
paleturquoise: "#afeeee",
palevioletred: "#db7093",
papayawhip: "#ffefd5",
peachpuff: "#ffdab9",
peru: "#cd853f",
pink: "#ffc0cb",
plum: "#dda0dd",
powderblue: "#b0e0e6",
purple: "#800080",
rebeccapurple: "#663399",
red: "#ff0000",
rosybrown: "#bc8f8f",
royalblue: "#4169e1",
saddlebrown: "#8b4513",
salmon: "#fa8072",
sandybrown: "#f4a460",
seagreen: "#2e8b57",
seashell: "#fff5ee",
sienna: "#a0522d",
silver: "#c0c0c0",
skyblue: "#87ceeb",
slateblue: "#6a5acd",
slategray: "#708090",
slategrey: "#708090",
snow: "#fffafa",
springgreen: "#00ff7f",
steelblue: "#4682b4",
tan: "#d2b48c",
teal: "#008080",
thistle: "#d8bfd8",
tomato: "#ff6347",
turquoise: "#40e0d0",
violet: "#ee82ee",
wheat: "#f5deb3",
white: "#ffffff",
whitesmoke: "#f5f5f5",
yellow: "#ffff00",
yellowgreen: "#9acd32"
};
function inputToRGB(color) {
var rgb = { r: 0, g: 0, b: 0 };
var a = 1;
var s = null;
var v = null;
var l = null;
var ok = false;
var format2 = false;
if (typeof color === "string") {
color = stringInputToObject(color);
}
if (typeof color === "object") {
if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
rgb = rgbToRgb(color.r, color.g, color.b);
ok = true;
format2 = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
} else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
s = convertToPercentage(color.s);
v = convertToPercentage(color.v);
rgb = hsvToRgb(color.h, s, v);
ok = true;
format2 = "hsv";
} else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
s = convertToPercentage(color.s);
l = convertToPercentage(color.l);
rgb = hslToRgb(color.h, s, l);
ok = true;
format2 = "hsl";
}
if (Object.prototype.hasOwnProperty.call(color, "a")) {
a = color.a;
}
}
a = boundAlpha(a);
return {
ok,
format: color.format || format2,
r: Math.min(255, Math.max(rgb.r, 0)),
g: Math.min(255, Math.max(rgb.g, 0)),
b: Math.min(255, Math.max(rgb.b, 0)),
a
};
}
var CSS_INTEGER = "[-\\+]?\\d+%?";
var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
var CSS_UNIT = "(?:".concat(CSS_NUMBER, ")|(?:").concat(CSS_INTEGER, ")");
var PERMISSIVE_MATCH3 = "[\\s|\\(]+(".concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")\\s*\\)?");
var PERMISSIVE_MATCH4 = "[\\s|\\(]+(".concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")\\s*\\)?");
var matchers = {
CSS_UNIT: new RegExp(CSS_UNIT),
rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
};
function stringInputToObject(color) {
color = color.trim().toLowerCase();
if (color.length === 0) {
return false;
}
var named = false;
if (names[color]) {
color = names[color];
named = true;
} else if (color === "transparent") {
return { r: 0, g: 0, b: 0, a: 0, format: "name" };
}
var match2 = matchers.rgb.exec(color);
if (match2) {
return { r: match2[1], g: match2[2], b: match2[3] };
}
match2 = matchers.rgba.exec(color);
if (match2) {
return { r: match2[1], g: match2[2], b: match2[3], a: match2[4] };
}
match2 = matchers.hsl.exec(color);
if (match2) {
return { h: match2[1], s: match2[2], l: match2[3] };
}
match2 = matchers.hsla.exec(color);
if (match2) {
return { h: match2[1], s: match2[2], l: match2[3], a: match2[4] };
}
match2 = matchers.hsv.exec(color);
if (match2) {
return { h: match2[1], s: match2[2], v: match2[3] };
}
match2 = matchers.hsva.exec(color);
if (match2) {
return { h: match2[1], s: match2[2], v: match2[3], a: match2[4] };
}
match2 = matchers.hex8.exec(color);
if (match2) {
return {
r: parseIntFromHex(match2[1]),
g: parseIntFromHex(match2[2]),
b: parseIntFromHex(match2[3]),
a: convertHexToDecimal(match2[4]),
format: named ? "name" : "hex8"
};
}
match2 = matchers.hex6.exec(color);
if (match2) {
return {
r: parseIntFromHex(match2[1]),
g: parseIntFromHex(match2[2]),
b: parseIntFromHex(match2[3]),
format: named ? "name" : "hex"
};
}
match2 = matchers.hex4.exec(color);
if (match2) {
return {
r: parseIntFromHex(match2[1] + match2[1]),
g: parseIntFromHex(match2[2] + match2[2]),
b: parseIntFromHex(match2[3] + match2[3]),
a: convertHexToDecimal(match2[4] + match2[4]),
format: named ? "name" : "hex8"
};
}
match2 = matchers.hex3.exec(color);
if (match2) {
return {
r: parseIntFromHex(match2[1] + match2[1]),
g: parseIntFromHex(match2[2] + match2[2]),
b: parseIntFromHex(match2[3] + match2[3]),
format: named ? "name" : "hex"
};
}
return false;
}
function isValidCSSUnit(color) {
return Boolean(matchers.CSS_UNIT.exec(String(color)));
}
var TinyColor = (
/** @class */
function() {
function TinyColor2(color, opts) {
if (color === void 0) {
color = "";
}
if (opts === void 0) {
opts = {};
}
var _a;
if (color instanceof TinyColor2) {
return color;
}
if (typeof color === "number") {
color = numberInputToObject(color);
}
this.originalInput = color;
var rgb = inputToRGB(color);
this.originalInput = color;
this.r = rgb.r;
this.g = rgb.g;
this.b = rgb.b;
this.a = rgb.a;
this.roundA = Math.round(100 * this.a) / 100;
this.format = (_a = opts.format) !== null && _a !== void 0 ? _a : rgb.format;
this.gradientType = opts.gradientType;
if (this.r < 1) {
this.r = Math.round(this.r);
}
if (this.g < 1) {
this.g = Math.round(this.g);
}
if (this.b < 1) {
this.b = Math.round(this.b);
}
this.isValid = rgb.ok;
}
TinyColor2.prototype.isDark = function() {
return this.getBrightness() < 128;
};
TinyColor2.prototype.isLight = function() {
return !this.isDark();
};
TinyColor2.prototype.getBrightness = function() {
var rgb = this.toRgb();
return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1e3;
};
TinyColor2.prototype.getLuminance = function() {
var rgb = this.toRgb();
var R;
var G;
var B;
var RsRGB = rgb.r / 255;
var GsRGB = rgb.g / 255;
var BsRGB = rgb.b / 255;
if (RsRGB <= 0.03928) {
R = RsRGB / 12.92;
} else {
R = Math.pow((RsRGB + 0.055) / 1.055, 2.4);
}
if (GsRGB <= 0.03928) {
G = GsRGB / 12.92;
} else {
G = Math.pow((GsRGB + 0.055) / 1.055, 2.4);
}
if (BsRGB <= 0.03928) {
B = BsRGB / 12.92;
} else {
B = Math.pow((BsRGB + 0.055) / 1.055, 2.4);
}
return 0.2126 * R + 0.7152 * G + 0.0722 * B;
};
TinyColor2.prototype.getAlpha = function() {
return this.a;
};
TinyColor2.prototype.setAlpha = function(alpha) {
this.a = boundAlpha(alpha);
this.roundA = Math.round(100 * this.a) / 100;
return this;
};
TinyColor2.prototype.isMonochrome = function() {
var s = this.toHsl().s;
return s === 0;
};
TinyColor2.prototype.toHsv = function() {
var hsv = rgbToHsv(this.r, this.g, this.b);
return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this.a };
};
TinyColor2.prototype.toHsvString = function() {
var hsv = rgbToHsv(this.r, this.g, this.b);
var h = Math.round(hsv.h * 360);
var s = Math.round(hsv.s * 100);
var v = Math.round(hsv.v * 100);
return this.a === 1 ? "hsv(".concat(h, ", ").concat(s, "%, ").concat(v, "%)") : "hsva(".concat(h, ", ").concat(s, "%, ").concat(v, "%, ").concat(this.roundA, ")");
};
TinyColor2.prototype.toHsl = function() {
var hsl = rgbToHsl(this.r, this.g, this.b);
return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this.a };
};
TinyColor2.prototype.toHslString = function() {
var hsl = rgbToHsl(this.r, this.g, this.b);
var h = Math.round(hsl.h * 360);
var s = Math.round(hsl.s * 100);
var l = Math.round(hsl.l * 100);
return this.a === 1 ? "hsl(".concat(h, ", ").concat(s, "%, ").concat(l, "%)") : "hsla(".concat(h, ", ").concat(s, "%, ").concat(l, "%, ").concat(this.roundA, ")");
};
TinyColor2.prototype.toHex = function(allow3Char) {
if (allow3Char === void 0) {
allow3Char = false;
}
return rgbToHex(this.r, this.g, this.b, allow3Char);
};
TinyColor2.prototype.toHexString = function(allow3Char) {
if (allow3Char === void 0) {
allow3Char = false;
}
return "#" + this.toHex(allow3Char);
};
TinyColor2.prototype.toHex8 = function(allow4Char) {
if (allow4Char === void 0) {
allow4Char = false;
}
return rgbaToHex(this.r, this.g, this.b, this.a, allow4Char);
};
TinyColor2.prototype.toHex8String = function(allow4Char) {
if (allow4Char === void 0) {
allow4Char = false;
}
return "#" + this.toHex8(allow4Char);
};
TinyColor2.prototype.toHexShortString = function(allowShortChar) {
if (allowShortChar === void 0) {
allowShortChar = false;
}
return this.a === 1 ? this.toHexString(allowShortChar) : this.toHex8String(allowShortChar);
};
TinyColor2.prototype.toRgb = function() {
return {
r: Math.round(this.r),
g: Math.round(this.g),
b: Math.round(this.b),
a: this.a
};
};
TinyColor2.prototype.toRgbString = function() {
var r = Math.round(this.r);
var g = Math.round(this.g);
var b = Math.round(this.b);
return this.a === 1 ? "rgb(".concat(r, ", ").concat(g, ", ").concat(b, ")") : "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(this.roundA, ")");
};
TinyColor2.prototype.toPercentageRgb = function() {
var fmt = function(x) {
return "".concat(Math.round(bound01(x, 255) * 100), "%");
};
return {
r: fmt(this.r),
g: fmt(this.g),
b: fmt(this.b),
a: this.a
};
};
TinyColor2.prototype.toPercentageRgbString = function() {
var rnd = function(x) {
return Math.round(bound01(x, 255) * 100);
};
return this.a === 1 ? "rgb(".concat(rnd(this.r), "%, ").concat(rnd(this.g), "%, ").concat(rnd(this.b), "%)") : "rgba(".concat(rnd(this.r), "%, ").concat(rnd(this.g), "%, ").concat(rnd(this.b), "%, ").concat(this.roundA, ")");
};
TinyColor2.prototype.toName = function() {
if (this.a === 0) {
return "transparent";
}
if (this.a < 1) {
return false;
}
var hex2 = "#" + rgbToHex(this.r, this.g, this.b, false);
for (var _i = 0, _a = Object.entries(names); _i < _a.length; _i++) {
var _b = _a[_i], key = _b[0], value = _b[1];
if (hex2 === value) {
return key;
}
}
return false;
};
TinyColor2.prototype.toString = function(format2) {
var formatSet = Boolean(format2);
format2 = format2 !== null && format2 !== void 0 ? format2 : this.format;
var formattedString = false;
var hasAlpha = this.a < 1 && this.a >= 0;
var needsAlphaFormat = !formatSet && hasAlpha && (format2.startsWith("hex") || format2 === "name");
if (needsAlphaFormat) {
if (format2 === "name" && this.a === 0) {
return this.toName();
}
return this.toRgbString();
}
if (format2 === "rgb") {
formattedString = this.toRgbString();
}
if (format2 === "prgb") {
formattedString = this.toPercentageRgbString();
}
if (format2 === "hex" || format2 === "hex6") {
formattedString = this.toHexString();
}
if (format2 === "hex3") {
formattedString = this.toHexString(true);
}
if (format2 === "hex4") {
formattedString = this.toHex8String(true);
}
if (format2 === "hex8") {
formattedString = this.toHex8String();
}
if (format2 === "name") {
formattedString = this.toName();
}
if (format2 === "hsl") {
formattedString = this.toHslString();
}
if (format2 === "hsv") {
formattedString = this.toHsvString();
}
return formattedString || this.toHexString();
};
TinyColor2.prototype.toNumber = function() {
return (Math.round(this.r) << 16) + (Math.round(this.g) << 8) + Math.round(this.b);
};
TinyColor2.prototype.clone = function() {
return new TinyColor2(this.toString());
};
TinyColor2.prototype.lighten = function(amount) {
if (amount === void 0) {
amount = 10;
}
var hsl = this.toHsl();
hsl.l += amount / 100;
hsl.l = clamp01(hsl.l);
return new TinyColor2(hsl);
};
TinyColor2.prototype.brighten = function(amount) {
if (amount === void 0) {
amount = 10;
}
var rgb = this.toRgb();
rgb.r = Math.max(0, Math.min(255, rgb.r - Math.round(255 * -(amount / 100))));
rgb.g = Math.max(0, Math.min(255, rgb.g - Math.round(255 * -(amount / 100))));
rgb.b = Math.max(0, Math.min(255, rgb.b - Math.round(255 * -(amount / 100))));
return new TinyColor2(rgb);
};
TinyColor2.prototype.darken = function(amount) {
if (amount === void 0) {
amount = 10;
}
var hsl = this.toHsl();
hsl.l -= amount / 100;
hsl.l = clamp01(hsl.l);
return new TinyColor2(hsl);
};
TinyColor2.prototype.tint = function(amount) {
if (amount === void 0) {
amount = 10;
}
return this.mix("white", amount);
};
TinyColor2.prototype.shade = function(amount) {
if (amount === void 0) {
amount = 10;
}
return this.mix("black", amount);
};
TinyColor2.prototype.desaturate = function(amount) {
if (amount === void 0) {
amount = 10;
}
var hsl = this.toHsl();
hsl.s -= amount / 100;
hsl.s = clamp01(hsl.s);
return new TinyColor2(hsl);
};
TinyColor2.prototype.saturate = function(amount) {
if (amount === void 0) {
amount = 10;
}
var hsl = this.toHsl();
hsl.s += amount / 100;
hsl.s = clamp01(hsl.s);
return new TinyColor2(hsl);
};
TinyColor2.prototype.greyscale = function() {
return this.desaturate(100);
};
TinyColor2.prototype.spin = function(amount) {
var hsl = this.toHsl();
var hue = (hsl.h + amount) % 360;
hsl.h = hue < 0 ? 360 + hue : hue;
return new TinyColor2(hsl);
};
TinyColor2.prototype.mix = function(color, amount) {
if (amount === void 0) {
amount = 50;
}
var rgb1 = this.toRgb();
var rgb2 = new TinyColor2(color).toRgb();
var p = amount / 100;
var rgba = {
r: (rgb2.r - rgb1.r) * p + rgb1.r,
g: (rgb2.g - rgb1.g) * p + rgb1.g,
b: (rgb2.b - rgb1.b) * p + rgb1.b,
a: (rgb2.a - rgb1.a) * p + rgb1.a
};
return new TinyColor2(rgba);
};
TinyColor2.prototype.analogous = function(results, slices) {
if (results === void 0) {
results = 6;
}
if (slices === void 0) {
slices = 30;
}
var hsl = this.toHsl();
var part = 360 / slices;
var ret = [this];
for (hsl.h = (hsl.h - (part * results >> 1) + 720) % 360; --results; ) {
hsl.h = (hsl.h + part) % 360;
ret.push(new TinyColor2(hsl));
}
return ret;
};
TinyColor2.prototype.complement = function() {
var hsl = this.toHsl();
hsl.h = (hsl.h + 180) % 360;
return new TinyColor2(hsl);
};
TinyColor2.prototype.monochromatic = function(results) {
if (results === void 0) {
results = 6;
}
var hsv = this.toHsv();
var h = hsv.h;
var s = hsv.s;
var v = hsv.v;
var res = [];
var modification = 1 / results;
while (results--) {
res.push(new TinyColor2({ h, s, v }));
v = (v + modification) % 1;
}
return res;
};
TinyColor2.prototype.splitcomplement = function() {
var hsl = this.toHsl();
var h = hsl.h;
return [
this,
new TinyColor2({ h: (h + 72) % 360, s: hsl.s, l: hsl.l }),
new TinyColor2({ h: (h + 216) % 360, s: hsl.s, l: hsl.l })
];
};
TinyColor2.prototype.onBackground = function(background) {
var fg = this.toRgb();
var bg = new TinyColor2(background).toRgb();
var alpha = fg.a + bg.a * (1 - fg.a);
return new TinyColor2({
r: (fg.r * fg.a + bg.r * bg.a * (1 - fg.a)) / alpha,
g: (fg.g * fg.a + bg.g * bg.a * (1 - fg.a)) / alpha,
b: (fg.b * fg.a + bg.b * bg.a * (1 - fg.a)) / alpha,
a: alpha
});
};
TinyColor2.prototype.triad = function() {
return this.polyad(3);
};
TinyColor2.prototype.tetrad = function() {
return this.polyad(4);
};
TinyColor2.prototype.polyad = function(n) {
var hsl = this.toHsl();
var h = hsl.h;
var result = [this];
var increment = 360 / n;
for (var i = 1; i < n; i++) {
result.push(new TinyColor2({ h: (h + i * increment) % 360, s: hsl.s, l: hsl.l }));
}
return result;
};
TinyColor2.prototype.equals = function(color) {
return this.toRgbString() === new TinyColor2(color).toRgbString();
};
return TinyColor2;
}()
);
var hueStep = 2;
var saturationStep = 0.16;
var saturationStep2 = 0.05;
var brightnessStep1 = 0.05;
var brightnessStep2 = 0.15;
var lightColorCount = 5;
var darkColorCount = 4;
var darkColorMap = [{
index: 7,
opacity: 0.15
}, {
index: 6,
opacity: 0.25
}, {
index: 5,
opacity: 0.3
}, {
index: 5,
opacity: 0.45
}, {
index: 5,
opacity: 0.65
}, {
index: 5,
opacity: 0.85
}, {
index: 4,
opacity: 0.9
}, {
index: 3,
opacity: 0.95
}, {
index: 2,
opacity: 0.97
}, {
index: 1,
opacity: 0.98
}];
function toHsv(_ref) {
var r = _ref.r, g = _ref.g, b = _ref.b;
var hsv = rgbToHsv(r, g, b);
return {
h: hsv.h * 360,
s: hsv.s,
v: hsv.v
};
}
function toHex(_ref2) {
var r = _ref2.r, g = _ref2.g, b = _ref2.b;
return "#".concat(rgbToHex(r, g, b, false));
}
function mix(rgb1, rgb2, amount) {
var p = amount / 100;
var rgb = {
r: (rgb2.r - rgb1.r) * p + rgb1.r,
g: (rgb2.g - rgb1.g) * p + rgb1.g,
b: (rgb2.b - rgb1.b) * p + rgb1.b
};
return rgb;
}
function getHue(hsv, i, light) {
var hue;
if (Math.round(hsv.h) >= 60 && Math.round(hsv.h) <= 240) {
hue = light ? Math.round(hsv.h) - hueStep * i : Math.round(hsv.h) + hueStep * i;
} else {
hue = light ? Math.round(hsv.h) + hueStep * i : Math.round(hsv.h) - hueStep * i;
}
if (hue < 0) {
hue += 360;
} else if (hue >= 360) {
hue -= 360;
}
return hue;
}
function getSaturation(hsv, i, light) {
if (hsv.h === 0 && hsv.s === 0) {
return hsv.s;
}
var saturation;
if (light) {
saturation = hsv.s - saturationStep * i;
} else if (i === darkColorCount) {
saturation = hsv.s + saturationStep;
} else {
saturation = hsv.s + saturationStep2 * i;
}
if (saturation > 1) {
saturation = 1;
}
if (light && i === lightColorCount && saturation > 0.1) {
saturation = 0.1;
}
if (saturation < 0.06) {
saturation = 0.06;
}
return Number(saturation.toFixed(2));
}
function getValue$1(hsv, i, light) {
var value;
if (light) {
value = hsv.v + brightnessStep1 * i;
} else {
value = hsv.v - brightnessStep2 * i;
}
if (value > 1) {
value = 1;
}
return Number(value.toFixed(2));
}
function generate$1(color) {
var opts = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
var patterns = [];
var pColor = inputToRGB(color);
for (var i = lightColorCount; i > 0; i -= 1) {
var hsv = toHsv(pColor);
var colorString = toHex(inputToRGB({
h: getHue(hsv, i, true),
s: getSaturation(hsv, i, true),
v: getValue$1(hsv, i, true)
}));
patterns.push(colorString);
}
patterns.push(toHex(pColor));
for (var _i = 1; _i <= darkColorCount; _i += 1) {
var _hsv = toHsv(pColor);
var _colorString = toHex(inputToRGB({
h: getHue(_hsv, _i),
s: getSaturation(_hsv, _i),
v: getValue$1(_hsv, _i)
}));
patterns.push(_colorString);
}
if (opts.theme === "dark") {
return darkColorMap.map(function(_ref3) {
var index2 = _ref3.index, opacity = _ref3.opacity;
var darkColorString = toHex(mix(inputToRGB(opts.backgroundColor || "#141414"), inputToRGB(patterns[index2]), opacity * 100));
return darkColorString;
});
}
return patterns;
}
var presetPrimaryColors = {
"red": "#F5222D",
"volcano": "#FA541C",
"orange": "#FA8C16",
"gold": "#FAAD14",
"yellow": "#FADB14",
"lime": "#A0D911",
"green": "#52C41A",
"cyan": "#13C2C2",
"blue": "#1677FF",
"geekblue": "#2F54EB",
"purple": "#722ED1",
"magenta": "#EB2F96",
"grey": "#666666"
};
var red = ["#fff1f0", "#ffccc7", "#ffa39e", "#ff7875", "#ff4d4f", "#f5222d", "#cf1322", "#a8071a", "#820014", "#5c0011"];
red.primary = red[5];
var volcano = ["#fff2e8", "#ffd8bf", "#ffbb96", "#ff9c6e", "#ff7a45", "#fa541c", "#d4380d", "#ad2102", "#871400", "#610b00"];
volcano.primary = volcano[5];
var orange = ["#fff7e6", "#ffe7ba", "#ffd591", "#ffc069", "#ffa940", "#fa8c16", "#d46b08", "#ad4e00", "#873800", "#612500"];
orange.primary = orange[5];
var gold = ["#fffbe6", "#fff1b8", "#ffe58f", "#ffd666", "#ffc53d", "#faad14", "#d48806", "#ad6800", "#874d00", "#613400"];
gold.primary = gold[5];
var yellow = ["#feffe6", "#ffffb8", "#fffb8f", "#fff566", "#ffec3d", "#fadb14", "#d4b106", "#ad8b00", "#876800", "#614700"];
yellow.primary = yellow[5];
var lime = ["#fcffe6", "#f4ffb8", "#eaff8f", "#d3f261", "#bae637", "#a0d911", "#7cb305", "#5b8c00", "#3f6600", "#254000"];
lime.primary = lime[5];
var green = ["#f6ffed", "#d9f7be", "#b7eb8f", "#95de64", "#73d13d", "#52c41a", "#389e0d", "#237804", "#135200", "#092b00"];
green.primary = green[5];
var cyan = ["#e6fffb", "#b5f5ec", "#87e8de", "#5cdbd3", "#36cfc9", "#13c2c2", "#08979c", "#006d75", "#00474f", "#002329"];
cyan.primary = cyan[5];
var blue = ["#e6f4ff", "#bae0ff", "#91caff", "#69b1ff", "#4096ff", "#1677ff", "#0958d9", "#003eb3", "#002c8c", "#001d66"];
blue.primary = blue[5];
var geekblue = ["#f0f5ff", "#d6e4ff", "#adc6ff", "#85a5ff", "#597ef7", "#2f54eb", "#1d39c4", "#10239e", "#061178", "#030852"];
geekblue.primary = geekblue[5];
var purple = ["#f9f0ff", "#efdbff", "#d3adf7", "#b37feb", "#9254de", "#722ed1", "#531dab", "#391085", "#22075e", "#120338"];
purple.primary = purple[5];
var magenta = ["#fff0f6", "#ffd6e7", "#ffadd2", "#ff85c0", "#f759ab", "#eb2f96", "#c41d7f", "#9e1068", "#780650", "#520339"];
magenta.primary = magenta[5];
var grey = ["#a6a6a6", "#999999", "#8c8c8c", "#808080", "#737373", "#666666", "#404040", "#1a1a1a", "#000000", "#000000"];
grey.primary = grey[5];
var presetPalettes = {
red,
volcano,
orange,
gold,
yellow,
lime,
green,
cyan,
blue,
geekblue,
purple,
magenta,
grey
};
var IconContext = /* @__PURE__ */ createContext({});
function ownKeys(e, r) {
var t = Object.keys(e);
if (Object.getOwnPropertySymbols) {
var o = Object.getOwnPropertySymbols(e);
r && (o = o.filter(function(r2) {
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
})), t.push.apply(t, o);
}
return t;
}
function _objectSpread2(e) {
for (var r = 1; r < arguments.length; r++) {
var t = null != arguments[r] ? arguments[r] : {};
r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
_defineProperty(e, r2, t[r2]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
});
}
return e;
}
function canUseDom() {
return !!(typeof window !== "undefined" && window.document && window.document.createElement);
}
function contains(root, n) {
if (!root) {
return false;
}
if (root.contains) {
return root.contains(n);
}
var node2 = n;
while (node2) {
if (node2 === root) {
return true;
}
node2 = node2.parentNode;
}
return false;
}
var APPEND_ORDER = "data-rc-order";
var APPEND_PRIORITY = "data-rc-priority";
var MARK_KEY = "rc-util-key";
var containerCache = /* @__PURE__ */ new Map();
function getMark() {
var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, mark = _ref.mark;
if (mark) {
return mark.startsWith("data-") ? mark : "data-".concat(mark);
}
return MARK_KEY;
}
function getContainer(option) {
if (option.attachTo) {
return option.attachTo;
}
var head = document.querySelector("head");
return head || document.body;
}
function getOrder(prepend) {
if (prepend === "queue") {
return "prependQueue";
}
return prepend ? "prepend" : "append";
}
function findStyles(container) {
return Array.from((containerCache.get(container) || container).children).filter(function(node2) {
return node2.tagName === "STYLE";
});
}
function injectCSS(css) {
var option = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
if (!canUseDom()) {
return null;
}
var csp = option.csp, prepend = option.prepend, _option$priority = option.priority, priority = _option$priority === void 0 ? 0 : _option$priority;
var mergedOrder = getOrder(prepend);
var isPrependQueue = mergedOrder === "prependQueue";
var styleNode = document.createElement("style");
styleNode.setAttribute(APPEND_ORDER, mergedOrder);
if (isPrependQueue && priority) {
styleNode.setAttribute(APPEND_PRIORITY, "".concat(priority));
}
if (csp !== null && csp !== void 0 && csp.nonce) {
styleNode.nonce = csp === null || csp === void 0 ? void 0 : csp.nonce;
}
styleNode.innerHTML = css;
var container = getContainer(option);
var firstChild = container.firstChild;
if (prepend) {
if (isPrependQueue) {
var existStyle = (option.styles || findStyles(container)).filter(function(node2) {
if (!["prepend", "prependQueue"].includes(node2.getAttribute(APPEND_ORDER))) {
return false;
}
var nodePriority = Number(node2.getAttribute(APPEND_PRIORITY) || 0);
return priority >= nodePriority;
});
if (existStyle.length) {
container.insertBefore(styleNode, existStyle[existStyle.length - 1].nextSibling);
return styleNode;
}
}
container.insertBefore(styleNode, firstChild);
} else {
container.appendChild(styleNode);
}
return styleNode;
}
function findExistNode(key) {
var option = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
var container = getContainer(option);
return (option.styles || findStyles(container)).find(function(node2) {
return node2.getAttribute(getMark(option)) === key;
});
}
function removeCSS(key) {
var option = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
var existNode = findExistNode(key, option);
if (existNode) {
var container = getContainer(option);
container.removeChild(existNode);
}
}
function syncRealContainer(container, option) {
var cachedRealContainer = containerCache.get(container);
if (!cachedRealContainer || !contains(document, cachedRealContainer)) {
var placeholderStyle = injectCSS("", option);
var parentNode = placeholderStyle.parentNode;
containerCache.set(container, parentNode);
container.removeChild(placeholderStyle);
}
}
function updateCSS(css, key) {
var originOption = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
var container = getContainer(originOption);
var styles = findStyles(container);
var option = _objectSpread2(_objectSpread2({}, originOption), {}, {
styles
});
syncRealContainer(container, option);
var existNode = findExistNode(key, option);
if (existNode) {
var _option$csp, _option$csp2;
if ((_option$csp = option.csp) !== null && _option$csp !== void 0 && _option$csp.nonce && existNode.nonce !== ((_option$csp2 = option.csp) === null || _option$csp2 === void 0 ? void 0 : _option$csp2.nonce)) {
var _option$csp3;
existNode.nonce = (_option$csp3 = option.csp) === null || _option$csp3 === void 0 ? void 0 : _option$csp3.nonce;
}
if (existNode.innerHTML !== css) {
existNode.innerHTML = css;
}
return existNode;
}
var newNode = injectCSS(css, option);
newNode.setAttribute(getMark(option), key);
return newNode;
}
function getRoot(ele) {
var _ele$getRootNode;
return ele === null || ele === void 0 || (_ele$getRootNode = ele.getRootNode) === null || _ele$getRootNode === void 0 ? void 0 : _ele$getRootNode.call(ele);
}
function inShadow(ele) {
return getRoot(ele) instanceof ShadowRoot;
}
function getShadowRoot(ele) {
return inShadow(ele) ? getRoot(ele) : null;
}
var warned = {};
var preWarningFns = [];
var preMessage = function preMessage2(fn) {
preWarningFns.push(fn);
};
function warning$4(valid, message) {
if (process.env.NODE_ENV !== "production" && !valid && console !== void 0) {
var finalMessage = preWarningFns.reduce(function(msg, preMessageFn) {
return preMessageFn(msg !== null && msg !== void 0 ? msg : "", "warning");
}, message);
if (finalMessage) {
console.error("Warning: ".concat(finalMessage));
}
}
}
function note(valid, message) {
if (process.env.NODE_ENV !== "production" && !valid && console !== void 0) {
var finalMessage = preWarningFns.reduce(function(msg, preMessageFn) {
return preMessageFn(msg !== null && msg !== void 0 ? msg : "", "note");
}, message);
if (finalMessage) {
console.warn("Note: ".concat(finalMessage));
}
}
}
function resetWarned$1() {
warned = {};
}
function call(method4, valid, message) {
if (!valid && !warned[message]) {
method4(false, message);
warned[message] = true;
}
}
function warningOnce(valid, message) {
call(warning$4, valid, message);
}
function noteOnce(valid, message) {
call(note, valid, message);
}
warningOnce.preMessage = preMessage;
warningOnce.resetWarned = resetWarned$1;
warningOnce.noteOnce = noteOnce;
function camelCase(input) {
return input.replace(/-(.)/g, function(match2, g) {
return g.toUpperCase();
});
}
function warning$3(valid, message) {
warningOnce(valid, "[@ant-design/icons] ".concat(message));
}
function isIconDefinition(target) {
return _typeof(target) === "object" && typeof target.name === "string" && typeof target.theme === "string" && (_typeof(target.icon) === "object" || typeof target.icon === "function");
}
function normalizeAttrs() {
var attrs = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
return Object.keys(attrs).reduce(function(acc, key) {
var val = attrs[key];
switch (key) {
case "class":
acc.className = val;
delete acc.class;
break;
default:
delete acc[key];
acc[camelCase(key)] = val;
}
return acc;
}, {});
}
function generate(node2, key, rootProps) {
if (!rootProps) {
return /* @__PURE__ */ React__default.createElement(node2.tag, _objectSpread2({
key
}, normalizeAttrs(node2.attrs)), (node2.children || []).map(function(child, index2) {
return generate(child, "".concat(key, "-").concat(node2.tag, "-").concat(index2));
}));
}
return /* @__PURE__ */ React__default.createElement(node2.tag, _objectSpread2(_objectSpread2({
key
}, normalizeAttrs(node2.attrs)), rootProps), (node2.children || []).map(function(child, index2) {
return generate(child, "".concat(key, "-").concat(node2.tag, "-").concat(index2));
}));
}
function getSecondaryColor(primaryColor) {
return generate$1(primaryColor)[0];
}
function normalizeTwoToneColors(twoToneColor) {
if (!twoToneColor) {
return [];
}
return Array.isArray(twoToneColor) ? twoToneColor : [twoToneColor];
}
var iconStyles = "\n.anticon {\n display: inline-flex;\n align-items: center;\n color: inherit;\n font-style: normal;\n line-height: 0;\n text-align: center;\n text-transform: none;\n vertical-align: -0.125em;\n text-rendering: optimizeLegibility;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\n.anticon > * {\n line-height: 1;\n}\n\n.anticon svg {\n display: inline-block;\n}\n\n.anticon::before {\n display: none;\n}\n\n.anticon .anticon-icon {\n display: block;\n}\n\n.anticon[tabindex] {\n cursor: pointer;\n}\n\n.anticon-spin::before,\n.anticon-spin {\n display: inline-block;\n -webkit-animation: loadingCircle 1s infinite linear;\n animation: loadingCircle 1s infinite linear;\n}\n\n@-webkit-keyframes loadingCircle {\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n\n@keyframes loadingCircle {\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n";
var useInsertStyles = function useInsertStyles2(eleRef) {
var _useContext = useContext(IconContext), csp = _useContext.csp, prefixCls = _useContext.prefixCls;
var mergedStyleStr = iconStyles;
if (prefixCls) {
mergedStyleStr = mergedStyleStr.replace(/anticon/g, prefixCls);
}
useEffect(function() {
var ele = eleRef.current;
var shadowRoot = getShadowRoot(ele);
updateCSS(mergedStyleStr, "@ant-design-icons", {
prepend: true,
csp,
attachTo: shadowRoot
});
}, []);
};
var _excluded$e = ["icon", "className", "onClick", "style", "primaryColor", "secondaryColor"];
var twoToneColorPalette = {
primaryColor: "#333",
secondaryColor: "#E6E6E6",
calculated: false
};
function setTwoToneColors(_ref) {
var primaryColor = _ref.primaryColor, secondaryColor = _ref.secondaryColor;
twoToneColorPalette.primaryColor = primaryColor;
twoToneColorPalette.secondaryColor = secondaryColor || getSecondaryColor(primaryColor);
twoToneColorPalette.calculated = !!secondaryColor;
}
function getTwoToneColors() {
return _objectSpread2({}, twoToneColorPalette);
}
var IconBase = function IconBase2(props) {
var icon = props.icon, className = props.className, onClick = props.onClick, style2 = props.style, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, restProps = _objectWithoutProperties(props, _excluded$e);
var svgRef = React.useRef();
var colors = twoToneColorPalette;
if (primaryColor) {
colors = {
primaryColor,
secondaryColor: secondaryColor || getSecondaryColor(primaryColor)
};
}
useInsertStyles(svgRef);
warning$3(isIconDefinition(icon), "icon should be icon definiton, but got ".concat(icon));
if (!isIconDefinition(icon)) {
return null;
}
var target = icon;
if (target && typeof target.icon === "function") {
target = _objectSpread2(_objectSpread2({}, target), {}, {
icon: target.icon(colors.primaryColor, colors.secondaryColor)
});
}
return generate(target.icon, "svg-".concat(target.name), _objectSpread2(_objectSpread2({
className,
onClick,
style: style2,
"data-icon": target.name,
width: "1em",
height: "1em",
fill: "currentColor",
"aria-hidden": "true"
}, restProps), {}, {
ref: svgRef
}));
};
IconBase.displayName = "IconReact";
IconBase.getTwoToneColors = getTwoToneColors;
IconBase.setTwoToneColors = setTwoToneColors;
function setTwoToneColor(twoToneColor) {
var _normalizeTwoToneColo = normalizeTwoToneColors(twoToneColor), _normalizeTwoToneColo2 = _slicedToArray(_normalizeTwoToneColo, 2), primaryColor = _normalizeTwoToneColo2[0], secondaryColor = _normalizeTwoToneColo2[1];
return IconBase.setTwoToneColors({
primaryColor,
secondaryColor
});
}
function getTwoToneColor() {
var colors = IconBase.getTwoToneColors();
if (!colors.calculated) {
return colors.primaryColor;
}
return [colors.primaryColor, colors.secondaryColor];
}
var _excluded$d = ["className", "icon", "spin", "rotate", "tabIndex", "onClick", "twoToneColor"];
setTwoToneColor(blue.primary);
var Icon$1 = /* @__PURE__ */ React.forwardRef(function(props, ref) {
var className = props.className, icon = props.icon, spin = props.spin, rotate = props.rotate, tabIndex = props.tabIndex, onClick = props.onClick, twoToneColor = props.twoToneColor, restProps = _objectWithoutProperties(props, _excluded$d);
var _React$useContext = React.useContext(IconContext), _React$useContext$pre = _React$useContext.prefixCls, prefixCls = _React$useContext$pre === void 0 ? "anticon" : _React$useContext$pre, rootClassName = _React$useContext.rootClassName;
var classString = classNames(rootClassName, prefixCls, _defineProperty(_defineProperty({}, "".concat(prefixCls, "-").concat(icon.name), !!icon.name), "".concat(prefixCls, "-spin"), !!spin || icon.name === "loading"), className);
var iconTabIndex = tabIndex;
if (iconTabIndex === void 0 && onClick) {
iconTabIndex = -1;
}
var svgStyle = rotate ? {
msTransform: "rotate(".concat(rotate, "deg)"),
transform: "rotate(".concat(rotate, "deg)")
} : void 0;
var _normalizeTwoToneColo = normalizeTwoToneColors(twoToneColor), _normalizeTwoToneColo2 = _slicedToArray(_normalizeTwoToneColo, 2), primaryColor = _normalizeTwoToneColo2[0], secondaryColor = _normalizeTwoToneColo2[1];
return /* @__PURE__ */ React.createElement("span", _extends({
role: "img",
"aria-label": icon.name
}, restProps, {
ref,
tabIndex: iconTabIndex,
onClick,
className: classString
}), /* @__PURE__ */ React.createElement(IconBase, {
icon,
primaryColor,
secondaryColor,
style: svgStyle
}));
});
Icon$1.displayName = "AntdIcon";
Icon$1.getTwoToneColor = getTwoToneColor;
Icon$1.setTwoToneColor = setTwoToneColor;
var CalendarOutlined = function CalendarOutlined2(props, ref) {
return /* @__PURE__ */ React.createElement(Icon$1, _extends({}, props, {
ref,
icon: CalendarOutlined$1
}));
};
var RefIcon$8 = /* @__PURE__ */ React.forwardRef(CalendarOutlined);
if (process.env.NODE_ENV !== "production") {
RefIcon$8.displayName = "CalendarOutlined";
}
var ClockCircleOutlined$1 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z" } }, { "tag": "path", "attrs": { "d": "M686.7 638.6L544.1 535.5V288c0-4.4-3.6-8-8-8H488c-4.4 0-8 3.6-8 8v275.4c0 2.6 1.2 5 3.3 6.5l165.4 120.6c3.6 2.6 8.6 1.8 11.2-1.7l28.6-39c2.6-3.7 1.8-8.7-1.8-11.2z" } }] }, "name": "clock-circle", "theme": "outlined" };
var ClockCircleOutlined = function ClockCircleOutlined2(props, ref) {
return /* @__PURE__ */ React.createElement(Icon$1, _extends({}, props, {
ref,
icon: ClockCircleOutlined$1
}));
};
var RefIcon$7 = /* @__PURE__ */ React.forwardRef(ClockCircleOutlined);
if (process.env.NODE_ENV !== "production") {
RefIcon$7.displayName = "ClockCircleOutlined";
}
var SwapRightOutlined$1 = { "icon": { "tag": "svg", "attrs": { "viewBox": "0 0 1024 1024", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M873.1 596.2l-164-208A32 32 0 00684 376h-64.8c-6.7 0-10.4 7.7-6.3 13l144.3 183H152c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h695.9c26.8 0 41.7-30.8 25.2-51.8z" } }] }, "name": "swap-right", "theme": "outlined" };
var SwapRightOutlined = function SwapRightOutlined2(props, ref) {
return /* @__PURE__ */ React.createElement(Icon$1, _extends({}, props, {
ref,
icon: SwapRightOutlined$1
}));
};
var RefIcon$6 = /* @__PURE__ */ React.forwardRef(SwapRightOutlined);
if (process.env.NODE_ENV !== "production") {
RefIcon$6.displayName = "SwapRightOutlined";
}
function _arrayWithoutHoles(r) {
if (Array.isArray(r)) return _arrayLikeToArray(r);
}
function _iterableToArray(r) {
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _toConsumableArray(r) {
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
}
function useEvent(callback) {
var fnRef = React.useRef();
fnRef.current = callback;
var memoFn = React.useCallback(function() {
var _fnRef$current;
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return (_fnRef$current = fnRef.current) === null || _fnRef$current === void 0 ? void 0 : _fnRef$current.call.apply(_fnRef$current, [fnRef].concat(args));
}, []);
return memoFn;
}
var useInternalLayoutEffect = process.env.NODE_ENV !== "test" && canUseDom() ? React.useLayoutEffect : React.useEffect;
var useLayoutEffect = function useLayoutEffect2(callback, deps) {
var firstMountRef = React.useRef(true);
useInternalLayoutEffect(function() {
return callback(firstMountRef.current);
}, deps);
useInternalLayoutEffect(function() {
firstMountRef.current = false;
return function() {
firstMountRef.current = true;
};
}, []);
};
var useLayoutUpdateEffect = function useLayoutUpdateEffect2(callback, deps) {
useLayoutEffect(function(firstMount) {
if (!firstMount) {
return callback();
}
}, deps);
};
function useSafeState(defaultValue) {
var destroyRef = React.useRef(false);
var _React$useState = React.useState(defaultValue), _React$useState2 = _slicedToArray(_React$useState, 2), value = _React$useState2[0], setValue = _React$useState2[1];
React.useEffect(function() {
destroyRef.current = false;
return function() {
destroyRef.current = true;
};
}, []);
function safeSetState(updater, ignoreDestroy) {
if (ignoreDestroy && destroyRef.current) {
return;
}
setValue(updater);
}
return [value, safeSetState];
}
function hasValue(value) {
return value !== void 0;
}
function useMergedState(defaultStateValue, option) {
var _ref = option || {}, defaultValue = _ref.defaultValue, value = _ref.value, onChange = _ref.onChange, postState = _ref.postState;
var _useState = useSafeState(function() {
if (hasValue(value)) {
return value;
} else if (hasValue(defaultValue)) {
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
} else {
return typeof defaultStateValue === "function" ? defaultStateValue() : defaultStateValue;
}
}), _useState2 = _slicedToArray(_useState, 2), innerValue = _useState2[0], setInnerValue = _useState2[1];
var mergedValue = value !== void 0 ? value : innerValue;
var postMergedValue = postState ? postState(mergedValue) : mergedValue;
var onChangeFn = useEvent(onChange);
var _useState3 = useSafeState([mergedValue]), _useState4 = _slicedToArray(_useState3, 2), prevValue = _useState4[0], setPrevValue = _useState4[1];
useLayoutUpdateEffect(function() {
var prev2 = prevValue[0];
if (innerValue !== prev2) {
onChangeFn(innerValue, prev2);
}
}, [prevValue]);
useLayoutUpdateEffect(function() {
if (!hasValue(value)) {
setInnerValue(value);
}
}, [value]);
var triggerChange = useEvent(function(updater, ignoreDestroy) {
setInnerValue(updater, ignoreDestroy);
setPrevValue([mergedValue], ignoreDestroy);
});
return [postMergedValue, triggerChange];
}
var reactIs = { exports: {} };
var reactIs_production_min = {};
/**
* @license React
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var hasRequiredReactIs_production_min;
function requireReactIs_production_min() {
if (hasRequiredReactIs_production_min) return reactIs_production_min;
hasRequiredReactIs_production_min = 1;
var b = Symbol.for("react.element"), c = Symbol.for("react.portal"), d = Symbol.for("react.fragment"), e = Symbol.for("react.strict_mode"), f = Symbol.for("react.profiler"), g = Symbol.for("react.provider"), h = Symbol.for("react.context"), k = Symbol.for("react.server_context"), l = Symbol.for("react.forward_ref"), m = Symbol.for("react.suspense"), n = Symbol.for("react.suspense_list"), p = Symbol.for("react.memo"), q = Symbol.for("react.lazy"), t = Symbol.for("react.offscreen"), u;
u = Symbol.for("react.module.reference");
function v(a) {
if ("object" === typeof a && null !== a) {
var r = a.$$typeof;
switch (r) {
case b:
switch (a = a.type, a) {
case d:
case f:
case e:
case m:
case n:
return a;
default:
switch (a = a && a.$$typeof, a) {
case k:
case h:
case l:
case q:
case p:
case g:
return a;
default:
return r;
}
}
case c:
return r;
}
}
}
reactIs_production_min.ContextConsumer = h;
reactIs_production_min.ContextProvider = g;
reactIs_production_min.Element = b;
reactIs_production_min.ForwardRef = l;
reactIs_production_min.Fragment = d;
reactIs_production_min.Lazy = q;
reactIs_production_min.Memo = p;
reactIs_production_min.Portal = c;
reactIs_production_min.Profiler = f;
reactIs_production_min.StrictMode = e;
reactIs_production_min.Suspense = m;
reactIs_production_min.SuspenseList = n;
reactIs_production_min.isAsyncMode = function() {
return false;
};
reactIs_production_min.isConcurrentMode = function() {
return false;
};
reactIs_production_min.isContextConsumer = function(a) {
return v(a) === h;
};
reactIs_production_min.isContextProvider = function(a) {
return v(a) === g;
};
reactIs_production_min.isElement = function(a) {
return "object" === typeof a && null !== a && a.$$typeof === b;
};
reactIs_production_min.isForwardRef = function(a) {
return v(a) === l;
};
reactIs_production_min.isFragment = function(a) {
return v(a) === d;
};
reactIs_production_min.isLazy = function(a) {
return v(a) === q;
};
reactIs_production_min.isMemo = function(a) {
return v(a) === p;
};
reactIs_production_min.isPortal = function(a) {
return v(a) === c;
};
reactIs_production_min.isProfiler = function(a) {
return v(a) === f;
};
reactIs_production_min.isStrictMode = function(a) {
return v(a) === e;
};
reactIs_production_min.isSuspense = function(a) {
return v(a) === m;
};
reactIs_production_min.isSuspenseList = function(a) {
return v(a) === n;
};
reactIs_production_min.isValidElementType = function(a) {
return "string" === typeof a || "function" === typeof a || a === d || a === f || a === e || a === m || a === n || a === t || "object" === typeof a && null !== a && (a.$$typeof === q || a.$$typeof === p || a.$$typeof === g || a.$$typeof === h || a.$$typeof === l || a.$$typeof === u || void 0 !== a.getModuleId) ? true : false;
};
reactIs_production_min.typeOf = v;
return reactIs_production_min;
}
var reactIs_development = {};
/**
* @license React
* react-is.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var hasRequiredReactIs_development;
function requireReactIs_development() {
if (hasRequiredReactIs_development) return reactIs_development;
hasRequiredReactIs_development = 1;
if (process.env.NODE_ENV !== "production") {
(function() {
var REACT_ELEMENT_TYPE = Symbol.for("react.element");
var REACT_PORTAL_TYPE = Symbol.for("react.portal");
var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
var REACT_PROVIDER_TYPE = Symbol.for("react.provider");
var REACT_CONTEXT_TYPE = Symbol.for("react.context");
var REACT_SERVER_CONTEXT_TYPE = Symbol.for("react.server_context");
var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list");
var REACT_MEMO_TYPE = Symbol.for("react.memo");
var REACT_LAZY_TYPE = Symbol.for("react.lazy");
var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
var enableScopeAPI = false;
var enableCacheElement = false;
var enableTransitionTracing = false;
var enableLegacyHidden = false;
var enableDebugTracing = false;
var REACT_MODULE_REFERENCE;
{
REACT_MODULE_REFERENCE = Symbol.for("react.module.reference");
}
function isValidElementType(type4) {
if (typeof type4 === "string" || typeof type4 === "function") {
return true;
}
if (type4 === REACT_FRAGMENT_TYPE || type4 === REACT_PROFILER_TYPE || enableDebugTracing || type4 === REACT_STRICT_MODE_TYPE || type4 === REACT_SUSPENSE_TYPE || type4 === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type4 === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing) {
return true;
}
if (typeof type4 === "object" && type4 !== null) {
if (type4.$$typeof === REACT_LAZY_TYPE || type4.$$typeof === REACT_MEMO_TYPE || type4.$$typeof === REACT_PROVIDER_TYPE || type4.$$typeof === REACT_CONTEXT_TYPE || type4.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
// types supported by any Flight configuration anywhere since
// we don't know which Flight build this will end up being used
// with.
type4.$$typeof === REACT_MODULE_REFERENCE || type4.getModuleId !== void 0) {
return true;
}
}
return false;
}
function typeOf(object4) {
if (typeof object4 === "object" && object4 !== null) {
var $$typeof = object4.$$typeof;
switch ($$typeof) {
case REACT_ELEMENT_TYPE:
var type4 = object4.type;
switch (type4) {
case REACT_FRAGMENT_TYPE:
case REACT_PROFILER_TYPE:
case REACT_STRICT_MODE_TYPE:
case REACT_SUSPENSE_TYPE:
case REACT_SUSPENSE_LIST_TYPE:
return type4;
default:
var $$typeofType = type4 && type4.$$typeof;
switch ($$typeofType) {
case REACT_SERVER_CONTEXT_TYPE:
case REACT_CONTEXT_TYPE:
case REACT_FORWARD_REF_TYPE:
case REACT_LAZY_TYPE:
case REACT_MEMO_TYPE:
case REACT_PROVIDER_TYPE:
return $$typeofType;
default:
return $$typeof;
}
}
case REACT_PORTAL_TYPE:
return $$typeof;
}
}
return void 0;
}
var ContextConsumer = REACT_CONTEXT_TYPE;
var ContextProvider = REACT_PROVIDER_TYPE;
var Element2 = REACT_ELEMENT_TYPE;
var ForwardRef = REACT_FORWARD_REF_TYPE;
var Fragment = REACT_FRAGMENT_TYPE;
var Lazy = REACT_LAZY_TYPE;
var Memo = REACT_MEMO_TYPE;
var Portal2 = REACT_PORTAL_TYPE;
var Profiler = REACT_PROFILER_TYPE;
var StrictMode = REACT_STRICT_MODE_TYPE;
var Suspense = REACT_SUSPENSE_TYPE;
var SuspenseList = REACT_SUSPENSE_LIST_TYPE;
var hasWarnedAboutDeprecatedIsAsyncMode = false;
var hasWarnedAboutDeprecatedIsConcurrentMode = false;
function isAsyncMode(object4) {
{
if (!hasWarnedAboutDeprecatedIsAsyncMode) {
hasWarnedAboutDeprecatedIsAsyncMode = true;
console["warn"]("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 18+.");
}
}
return false;
}
function isConcurrentMode(object4) {
{
if (!hasWarnedAboutDeprecatedIsConcurrentMode) {
hasWarnedAboutDeprecatedIsConcurrentMode = true;
console["warn"]("The ReactIs.isConcurrentMode() alias has been deprecated, and will be removed in React 18+.");
}
}
return false;
}
function isContextConsumer(object4) {
return typeOf(object4) === REACT_CONTEXT_TYPE;
}
function isContextProvider(object4) {
return typeOf(object4) === REACT_PROVIDER_TYPE;
}
function isElement(object4) {
return typeof object4 === "object" && object4 !== null && object4.$$typeof === REACT_ELEMENT_TYPE;
}
function isForwardRef(object4) {
return typeOf(object4) === REACT_FORWARD_REF_TYPE;
}
function isFragment2(object4) {
return typeOf(object4) === REACT_FRAGMENT_TYPE;
}
function isLazy(object4) {
return typeOf(object4) === REACT_LAZY_TYPE;
}
function isMemo(object4) {
return typeOf(object4) === REACT_MEMO_TYPE;
}
function isPortal(object4) {
return typeOf(object4) === REACT_PORTAL_TYPE;
}
function isProfiler(object4) {
return typeOf(object4) === REACT_PROFILER_TYPE;
}
function isStrictMode(object4) {
return typeOf(object4) === REACT_STRICT_MODE_TYPE;
}
function isSuspense(object4) {
return typeOf(object4) === REACT_SUSPENSE_TYPE;
}
function isSuspenseList(object4) {
return typeOf(object4) === REACT_SUSPENSE_LIST_TYPE;
}
reactIs_development.ContextConsumer = ContextConsumer;
reactIs_development.ContextProvider = ContextProvider;
reactIs_development.Element = Element2;
reactIs_development.ForwardRef = ForwardRef;
reactIs_development.Fragment = Fragment;
reactIs_development.Lazy = Lazy;
reactIs_development.Memo = Memo;
reactIs_development.Portal = Portal2;
reactIs_development.Profiler = Profiler;
reactIs_development.StrictMode = StrictMode;
reactIs_development.Suspense = Suspense;
reactIs_development.SuspenseList = SuspenseList;
reactIs_development.isAsyncMode = isAsyncMode;
reactIs_development.isConcurrentMode = isConcurrentMode;
reactIs_development.isContextConsumer = isContextConsumer;
reactIs_development.isContextProvider = isContextProvider;
reactIs_development.isElement = isElement;
reactIs_development.isForwardRef = isForwardRef;
reactIs_development.isFragment = isFragment2;
reactIs_development.isLazy = isLazy;
reactIs_development.isMemo = isMemo;
reactIs_development.isPortal = isPortal;
reactIs_development.isProfiler = isProfiler;
reactIs_development.isStrictMode = isStrictMode;
reactIs_development.isSuspense = isSuspense;
reactIs_development.isSuspenseList = isSuspenseList;
reactIs_development.isValidElementType = isValidElementType;
reactIs_development.typeOf = typeOf;
})();
}
return reactIs_development;
}
if (process.env.NODE_ENV === "production") {
reactIs.exports = requireReactIs_production_min();
} else {
reactIs.exports = requireReactIs_development();
}
var reactIsExports = reactIs.exports;
function useMemo(getValue2, condition, shouldUpdate) {
var cacheRef = React.useRef({});
if (!("value" in cacheRef.current) || shouldUpdate(cacheRef.current.condition, condition)) {
cacheRef.current.value = getValue2();
cacheRef.current.condition = condition;
}
return cacheRef.current.value;
}
var fillRef = function fillRef2(ref, node2) {
if (typeof ref === "function") {
ref(node2);
} else if (_typeof(ref) === "object" && ref && "current" in ref) {
ref.current = node2;
}
};
var composeRef = function composeRef2() {
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
refs[_key] = arguments[_key];
}
var refList = refs.filter(Boolean);
if (refList.length <= 1) {
return refList[0];
}
return function(node2) {
refs.forEach(function(ref) {
fillRef(ref, node2);
});
};
};
var useComposeRef = function useComposeRef2() {
for (var _len2 = arguments.length, refs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
refs[_key2] = arguments[_key2];
}
return useMemo(function() {
return composeRef.apply(void 0, refs);
}, refs, function(prev2, next2) {
return prev2.length !== next2.length || prev2.every(function(ref, i) {
return ref !== next2[i];
});
});
};
var supportRef = function supportRef2(nodeOrComponent) {
var _type$prototype, _nodeOrComponent$prot;
var type4 = reactIsExports.isMemo(nodeOrComponent) ? nodeOrComponent.type.type : nodeOrComponent.type;
if (typeof type4 === "function" && !((_type$prototype = type4.prototype) !== null && _type$prototype !== void 0 && _type$prototype.render) && type4.$$typeof !== reactIsExports.ForwardRef) {
return false;
}
if (typeof nodeOrComponent === "function" && !((_nodeOrComponent$prot = nodeOrComponent.prototype) !== null && _nodeOrComponent$prot !== void 0 && _nodeOrComponent$prot.render) && nodeOrComponent.$$typeof !== reactIsExports.ForwardRef) {
return false;
}
return true;
};
function isReactElement(node2) {
return /* @__PURE__ */ isValidElement(node2) && !reactIsExports.isFragment(node2);
}
Number(version$2.split(".")[0]) >= 19 ? (
// >= React 19
function(node2) {
if (isReactElement(node2)) {
return node2.props.ref;
}
return null;
}
) : (
// < React 19
function(node2) {
if (isReactElement(node2)) {
return node2.ref;
}
return null;
}
);
function get(entity, path) {
var current = entity;
for (var i = 0; i < path.length; i += 1) {
if (current === null || current === void 0) {
return void 0;
}
current = current[path[i]];
}
return current;
}
function _toArray(r) {
return _arrayWithHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableRest();
}
function internalSet(entity, paths, value, removeIfUndefined) {
if (!paths.length) {
return value;
}
var _paths = _toArray(paths), path = _paths[0], restPath = _paths.slice(1);
var clone;
if (!entity && typeof path === "number") {
clone = [];
} else if (Array.isArray(entity)) {
clone = _toConsumableArray(entity);
} else {
clone = _objectSpread2({}, entity);
}
if (removeIfUndefined && value === void 0 && restPath.length === 1) {
delete clone[path][restPath[0]];
} else {
clone[path] = internalSet(clone[path], restPath, value, removeIfUndefined);
}
return clone;
}
function set(entity, paths, value) {
var removeIfUndefined = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false;
if (paths.length && removeIfUndefined && value === void 0 && !get(entity, paths.slice(0, -1))) {
return entity;
}
return internalSet(entity, paths, value, removeIfUndefined);
}
function isObject(obj) {
return _typeof(obj) === "object" && obj !== null && Object.getPrototypeOf(obj) === Object.prototype;
}
function createEmpty(source) {
return Array.isArray(source) ? [] : {};
}
var keys = typeof Reflect === "undefined" ? Object.keys : Reflect.ownKeys;
function merge$1() {
for (var _len = arguments.length, sources = new Array(_len), _key = 0; _key < _len; _key++) {
sources[_key] = arguments[_key];
}
var clone = createEmpty(sources[0]);
sources.forEach(function(src) {
function internalMerge(path, parentLoopSet) {
var loopSet = new Set(parentLoopSet);
var value = get(src, path);
var isArr = Array.isArray(value);
if (isArr || isObject(value)) {
if (!loopSet.has(value)) {
loopSet.add(value);
var originValue = get(clone, path);
if (isArr) {
clone = set(clone, path, []);
} else if (!originValue || _typeof(originValue) !== "object") {
clone = set(clone, path, createEmpty(value));
}
keys(value).forEach(function(key) {
internalMerge([].concat(_toConsumableArray(path), [key]), loopSet);
});
}
} else {
clone = set(clone, path, value);
}
}
internalMerge([]);
});
return clone;
}
function omit(obj, fields) {
var clone = Object.assign({}, obj);
if (Array.isArray(fields)) {
fields.forEach(function(key) {
delete clone[key];
});
}
return clone;
}
var attributes = "accept acceptCharset accessKey action allowFullScreen allowTransparency\n alt async autoComplete autoFocus autoPlay capture cellPadding cellSpacing challenge\n charSet checked classID className colSpan cols content contentEditable contextMenu\n controls coords crossOrigin data dateTime default defer dir disabled download draggable\n encType form formAction formEncType formMethod formNoValidate formTarget frameBorder\n headers height hidden high href hrefLang htmlFor httpEquiv icon id inputMode integrity\n is keyParams keyType kind label lang list loop low manifest marginHeight marginWidth max maxLength media\n mediaGroup method min minLength multiple muted name noValidate nonce open\n optimum pattern placeholder poster preload radioGroup readOnly rel required\n reversed role rowSpan rows sandbox scope scoped scrolling seamless selected\n shape size sizes span spellCheck src srcDoc srcLang srcSet start step style\n summary tabIndex target title type useMap value width wmode wrap";
var eventsName = "onCopy onCut onPaste onCompositionEnd onCompositionStart onCompositionUpdate onKeyDown\n onKeyPress onKeyUp onFocus onBlur onChange onInput onSubmit onClick onContextMenu onDoubleClick\n onDrag onDragEnd onDragEnter onDragExit onDragLeave onDragOver onDragStart onDrop onMouseDown\n onMouseEnter onMouseLeave onMouseMove onMouseOut onMouseOver onMouseUp onSelect onTouchCancel\n onTouchEnd onTouchMove onTouchStart onScroll onWheel onAbort onCanPlay onCanPlayThrough\n onDurationChange onEmptied onEncrypted onEnded onError onLoadedData onLoadedMetadata\n onLoadStart onPause onPlay onPlaying onProgress onRateChange onSeeked onSeeking onStalled onSuspend onTimeUpdate onVolumeChange onWaiting onLoad onError";
var propList = "".concat(attributes, " ").concat(eventsName).split(/[\s\n]+/);
var ariaPrefix = "aria-";
var dataPrefix = "data-";
function match(key, prefix) {
return key.indexOf(prefix) === 0;
}
function pickAttrs(props) {
var ariaOnly = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
var mergedConfig;
if (ariaOnly === false) {
mergedConfig = {
aria: true,
data: true,
attr: true
};
} else if (ariaOnly === true) {
mergedConfig = {
aria: true
};
} else {
mergedConfig = _objectSpread2({}, ariaOnly);
}
var attrs = {};
Object.keys(props).forEach(function(key) {
if (
// Aria
mergedConfig.aria && (key === "role" || match(key, ariaPrefix)) || // Data
mergedConfig.data && match(key, dataPrefix) || // Attr
mergedConfig.attr && propList.includes(key)
) {
attrs[key] = props[key];
}
});
return attrs;
}
var OrderContext = /* @__PURE__ */ React.createContext(null);
var EMPTY_LIST$1 = [];
function useDom(render2, debug) {
var _React$useState = React.useState(function() {
if (!canUseDom()) {
return null;
}
var defaultEle = document.createElement("div");
if (process.env.NODE_ENV !== "production" && debug) {
defaultEle.setAttribute("data-debug", debug);
}
return defaultEle;
}), _React$useState2 = _slicedToArray(_React$useState, 1), ele = _React$useState2[0];
var appendedRef = React.useRef(false);
var queueCreate = React.useContext(OrderContext);
var _React$useState3 = React.useState(EMPTY_LIST$1), _React$useState4 = _slicedToArray(_React$useState3, 2), queue = _React$useState4[0], setQueue = _React$useState4[1];
var mergedQueueCreate = queueCreate || (appendedRef.current ? void 0 : function(appendFn) {
setQueue(function(origin) {
var newQueue = [appendFn].concat(_toConsumableArray(origin));
return newQueue;
});
});
function append2() {
if (!ele.parentElement) {
document.body.appendChild(ele);
}
appendedRef.current = true;
}
function cleanup2() {
var _ele$parentElement;
(_ele$parentElement = ele.parentElement) === null || _ele$parentElement === void 0 ? void 0 : _ele$parentElement.removeChild(ele);
appendedRef.current = false;
}
useLayoutEffect(function() {
if (render2) {
if (queueCreate) {
queueCreate(append2);
} else {
append2();
}
} else {
cleanup2();
}
return cleanup2;
}, [render2]);
useLayoutEffect(function() {
if (queue.length) {
queue.forEach(function(appendFn) {
return appendFn();
});
setQueue(EMPTY_LIST$1);
}
}, [queue]);
return [ele, mergedQueueCreate];
}
function measureScrollbarSize(ele) {
var randomId = "rc-scrollbar-measure-".concat(Math.random().toString(36).substring(7));
var measureEle = document.createElement("div");
measureEle.id = randomId;
var measureStyle = measureEle.style;
measureStyle.position = "absolute";
measureStyle.left = "0";
measureStyle.top = "0";
measureStyle.width = "100px";
measureStyle.height = "100px";
measureStyle.overflow = "scroll";
var fallbackWidth;
var fallbackHeight;
if (ele) {
var targetStyle = getComputedStyle(ele);
measureStyle.scrollbarColor = targetStyle.scrollbarColor;
measureStyle.scrollbarWidth = targetStyle.scrollbarWidth;
var webkitScrollbarStyle = getComputedStyle(ele, "::-webkit-scrollbar");
var width = parseInt(webkitScrollbarStyle.width, 10);
var height = parseInt(webkitScrollbarStyle.height, 10);
try {
var widthStyle = width ? "width: ".concat(webkitScrollbarStyle.width, ";") : "";
var heightStyle = height ? "height: ".concat(webkitScrollbarStyle.height, ";") : "";
updateCSS("\n#".concat(randomId, "::-webkit-scrollbar {\n").concat(widthStyle, "\n").concat(heightStyle, "\n}"), randomId);
} catch (e) {
console.error(e);
fallbackWidth = width;
fallbackHeight = height;
}
}
document.body.appendChild(measureEle);
var scrollWidth = ele && fallbackWidth && !isNaN(fallbackWidth) ? fallbackWidth : measureEle.offsetWidth - measureEle.clientWidth;
var scrollHeight = ele && fallbackHeight && !isNaN(fallbackHeight) ? fallbackHeight : measureEle.offsetHeight - measureEle.clientHeight;
document.body.removeChild(measureEle);
removeCSS(randomId);
return {
width: scrollWidth,
height: scrollHeight
};
}
function getTargetScrollBarSize(target) {
if (typeof document === "undefined" || !target || !(target instanceof Element)) {
return {
width: 0,
height: 0
};
}
return measureScrollbarSize(target);
}
function isBodyOverflowing() {
return document.body.scrollHeight > (window.innerHeight || document.documentElement.clientHeight) && window.innerWidth > document.body.offsetWidth;
}
var UNIQUE_ID = "rc-util-locker-".concat(Date.now());
var uuid$2 = 0;
function useScrollLocker(lock) {
var mergedLock = !!lock;
var _React$useState = React.useState(function() {
uuid$2 += 1;
return "".concat(UNIQUE_ID, "_").concat(uuid$2);
}), _React$useState2 = _slicedToArray(_React$useState, 1), id = _React$useState2[0];
useLayoutEffect(function() {
if (mergedLock) {
var scrollbarSize = getTargetScrollBarSize(document.body).width;
var isOverflow = isBodyOverflowing();
updateCSS("\nhtml body {\n overflow-y: hidden;\n ".concat(isOverflow ? "width: calc(100% - ".concat(scrollbarSize, "px);") : "", "\n}"), id);
} else {
removeCSS(id);
}
return function() {
removeCSS(id);
};
}, [mergedLock, id]);
}
var inline = false;
function inlineMock(nextInline) {
return inline;
}
var getPortalContainer = function getPortalContainer2(getContainer2) {
if (getContainer2 === false) {
return false;
}
if (!canUseDom() || !getContainer2) {
return null;
}
if (typeof getContainer2 === "string") {
return document.querySelector(getContainer2);
}
if (typeof getContainer2 === "function") {
return getContainer2();
}
return getContainer2;
};
var Portal = /* @__PURE__ */ React.forwardRef(function(props, ref) {
var open = props.open, autoLock = props.autoLock, getContainer2 = props.getContainer, debug = props.debug, _props$autoDestroy = props.autoDestroy, autoDestroy = _props$autoDestroy === void 0 ? true : _props$autoDestroy, children = props.children;
var _React$useState = React.useState(open), _React$useState2 = _slicedToArray(_React$useState, 2), shouldRender = _React$useState2[0], setShouldRender = _React$useState2[1];
var mergedRender = shouldRender || open;
if (process.env.NODE_ENV !== "production") {
warningOnce(canUseDom() || !open, "Portal only work in client side. Please call 'useEffect' to show Portal instead default render in SSR.");
}
React.useEffect(function() {
if (autoDestroy || open) {
setShouldRender(open);
}
}, [open, autoDestroy]);
var _React$useState3 = React.useState(function() {
return getPortalContainer(getContainer2);
}), _React$useState4 = _slicedToArray(_React$useState3, 2), innerContainer = _React$useState4[0], setInnerContainer = _React$useState4[1];
React.useEffect(function() {
var customizeContainer = getPortalContainer(getContainer2);
setInnerContainer(customizeContainer !== null && customizeContainer !== void 0 ? customizeContainer : null);
});
var _useDom = useDom(mergedRender && !innerContainer, debug), _useDom2 = _slicedToArray(_useDom, 2), defaultContainer = _useDom2[0], queueCreate = _useDom2[1];
var mergedContainer = innerContainer !== null && innerContainer !== void 0 ? innerContainer : defaultContainer;
useScrollLocker(autoLock && open && canUseDom() && (mergedContainer === defaultContainer || mergedContainer === document.body));
var childRef = null;
if (children && supportRef(children) && ref) {
var _ref = children;
childRef = _ref.ref;
}
var mergedRef = useComposeRef(childRef, ref);
if (!mergedRender || !canUseDom() || innerContainer === void 0) {
return null;
}
var renderInline = mergedContainer === false || inlineMock();
var reffedChildren = children;
if (ref) {
reffedChildren = /* @__PURE__ */ React.cloneElement(children, {
ref: mergedRef
});
}
return /* @__PURE__ */ React.createElement(OrderContext.Provider, {
value: queueCreate
}, renderInline ? reffedChildren : /* @__PURE__ */ createPortal(reffedChildren, mergedContainer));
});
if (process.env.NODE_ENV !== "production") {
Portal.displayName = "Portal";
}
function toArray$3(children) {
var option = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
var ret = [];
React__default.Children.forEach(children, function(child) {
if ((child === void 0 || child === null) && !option.keepEmpty) {
return;
}
if (Array.isArray(child)) {
ret = ret.concat(toArray$3(child));
} else if (reactIsExports.isFragment(child) && child.props) {
ret = ret.concat(toArray$3(child.props.children, option));
} else {
ret.push(child);
}
});
return ret;
}
function isDOM(node2) {
return node2 instanceof HTMLElement || node2 instanceof SVGElement;
}
function getDOM(node2) {
if (node2 && _typeof(node2) === "object" && isDOM(node2.nativeElement)) {
return node2.nativeElement;
}
if (isDOM(node2)) {
return node2;
}
return null;
}
function findDOMNode(node2) {
var domNode = getDOM(node2);
if (domNode) {
return domNode;
}
if (node2 instanceof React__default.Component) {
var _ReactDOM$findDOMNode;
return (_ReactDOM$findDOMNode = ReactDOM__default.findDOMNode) === null || _ReactDOM$findDOMNode === void 0 ? void 0 : _ReactDOM$findDOMNode.call(ReactDOM__default, node2);
}
return null;
}
var CollectionContext = /* @__PURE__ */ React.createContext(null);
function Collection(_ref) {
var children = _ref.children, onBatchResize = _ref.onBatchResize;
var resizeIdRef = React.useRef(0);
var resizeInfosRef = React.useRef([]);
var onCollectionResize = React.useContext(CollectionContext);
var onResize2 = React.useCallback(function(size, element, data) {
resizeIdRef.current += 1;
var currentId = resizeIdRef.current;
resizeInfosRef.current.push({
size,
element,
data
});
Promise.resolve().then(function() {
if (currentId === resizeIdRef.current) {
onBatchResize === null || onBatchResize === void 0 || onBatchResize(resizeInfosRef.current);
resizeInfosRef.current = [];
}
});
onCollectionResize === null || onCollectionResize === void 0 || onCollectionResize(size, element, data);
}, [onBatchResize, onCollectionResize]);
return /* @__PURE__ */ React.createElement(CollectionContext.Provider, {
value: onResize2
}, children);
}
var MapShim = function() {
if (typeof Map !== "undefined") {
return Map;
}
function getIndex(arr, key) {
var result = -1;
arr.some(function(entry, index2) {
if (entry[0] === key) {
result = index2;
return true;
}
return false;
});
return result;
}
return (
/** @class */
function() {
function class_1() {
this.__entries__ = [];
}
Object.defineProperty(class_1.prototype, "size", {
/**
* @returns {boolean}
*/
get: function() {
return this.__entries__.length;
},
enumerable: true,
configurable: true
});
class_1.prototype.get = function(key) {
var index2 = getIndex(this.__entries__, key);
var entry = this.__entries__[index2];
return entry && entry[1];
};
class_1.prototype.set = function(key, value) {
var index2 = getIndex(this.__entries__, key);
if (~index2) {
this.__entries__[index2][1] = value;
} else {
this.__entries__.push([key, value]);
}
};
class_1.prototype.delete = function(key) {
var entries = this.__entries__;
var index2 = getIndex(entries, key);
if (~index2) {
entries.splice(index2, 1);
}
};
class_1.prototype.has = function(key) {
return !!~getIndex(this.__entries__, key);
};
class_1.prototype.clear = function() {
this.__entries__.splice(0);
};
class_1.prototype.forEach = function(callback, ctx) {
if (ctx === void 0) {
ctx = null;
}
for (var _i = 0, _a = this.__entries__; _i < _a.length; _i++) {
var entry = _a[_i];
callback.call(ctx, entry[1], entry[0]);
}
};
return class_1;
}()
);
}();
var isBrowser = typeof window !== "undefined" && typeof document !== "undefined" && window.document === document;
var global$1 = function() {
if (typeof global !== "undefined" && global.Math === Math) {
return global;
}
if (typeof self !== "undefined" && self.Math === Math) {
return self;
}
if (typeof window !== "undefined" && window.Math === Math) {
return window;
}
return Function("return this")();
}();
var requestAnimationFrame$1 = function() {
if (typeof requestAnimationFrame === "function") {
return requestAnimationFrame.bind(global$1);
}
return function(callback) {
return setTimeout(function() {
return callback(Date.now());
}, 1e3 / 60);
};
}();
var trailingTimeout = 2;
function throttle(callback, delay) {
var leadingCall = false, trailingCall = false, lastCallTime = 0;
function resolvePending() {
if (leadingCall) {
leadingCall = false;
callback();
}
if (trailingCall) {
proxy();
}
}
function timeoutCallback() {
requestAnimationFrame$1(resolvePending);
}
function proxy() {
var timeStamp = Date.now();
if (leadingCall) {
if (timeStamp - lastCallTime < trailingTimeout) {
return;
}
trailingCall = true;
} else {
leadingCall = true;
trailingCall = false;
setTimeout(timeoutCallback, delay);
}
lastCallTime = timeStamp;
}
return proxy;
}
var REFRESH_DELAY = 20;
var transitionKeys = ["top", "right", "bottom", "left", "width", "height", "size", "weight"];
var mutationObserverSupported = typeof MutationObserver !== "undefined";
var ResizeObserverController = (
/** @class */
function() {
function ResizeObserverController2() {
this.connected_ = false;
this.mutationEventsAdded_ = false;
this.mutationsObserver_ = null;
this.observers_ = [];
this.onTransitionEnd_ = this.onTransitionEnd_.bind(this);
this.refresh = throttle(this.refresh.bind(this), REFRESH_DELAY);
}
ResizeObserverController2.prototype.addObserver = function(observer) {
if (!~this.observers_.indexOf(observer)) {
this.observers_.push(observer);
}
if (!this.connected_) {
this.connect_();
}
};
ResizeObserverController2.prototype.removeObserver = function(observer) {
var observers2 = this.observers_;
var index2 = observers2.indexOf(observer);
if (~index2) {
observers2.splice(index2, 1);
}
if (!observers2.length && this.connected_) {
this.disconnect_();
}
};
ResizeObserverController2.prototype.refresh = function() {
var changesDetected = this.updateObservers_();
if (changesDetected) {
this.refresh();
}
};
ResizeObserverController2.prototype.updateObservers_ = function() {
var activeObservers = this.observers_.filter(function(observer) {
return observer.gatherActive(), observer.hasActive();
});
activeObservers.forEach(function(observer) {
return observer.broadcastActive();
});
return activeObservers.length > 0;
};
ResizeObserverController2.prototype.connect_ = function() {
if (!isBrowser || this.connected_) {
return;
}
document.addEventListener("transitionend", this.onTransitionEnd_);
window.addEventListener("resize", this.refresh);
if (mutationObserverSupported) {
this.mutationsObserver_ = new MutationObserver(this.refresh);
this.mutationsObserver_.observe(document, {
attributes: true,
childList: true,
characterData: true,
subtree: true
});
} else {
document.addEventListener("DOMSubtreeModified", this.refresh);
this.mutationEventsAdded_ = true;
}
this.connected_ = true;
};
ResizeObserverController2.prototype.disconnect_ = function() {
if (!isBrowser || !this.connected_) {
return;
}
document.removeEventListener("transitionend", this.onTransitionEnd_);
window.removeEventListener("resize", this.refresh);
if (this.mutationsObserver_) {
this.mutationsObserver_.disconnect();
}
if (this.mutationEventsAdded_) {
document.removeEventListener("DOMSubtreeModified", this.refresh);
}
this.mutationsObserver_ = null;
this.mutationEventsAdded_ = false;
this.connected_ = false;
};
ResizeObserverController2.prototype.onTransitionEnd_ = function(_a) {
var _b = _a.propertyName, propertyName = _b === void 0 ? "" : _b;
var isReflowProperty = transitionKeys.some(function(key) {
return !!~propertyName.indexOf(key);
});
if (isReflowProperty) {
this.refresh();
}
};
ResizeObserverController2.getInstance = function() {
if (!this.instance_) {
this.instance_ = new ResizeObserverController2();
}
return this.instance_;
};
ResizeObserverController2.instance_ = null;
return ResizeObserverController2;
}()
);
var defineConfigurable = function(target, props) {
for (var _i = 0, _a = Object.keys(props); _i < _a.length; _i++) {
var key = _a[_i];
Object.defineProperty(target, key, {
value: props[key],
enumerable: false,
writable: false,
configurable: true
});
}
return target;
};
var getWindowOf = function(target) {
var ownerGlobal = target && target.ownerDocument && target.ownerDocument.defaultView;
return ownerGlobal || global$1;
};
var emptyRect = createRectInit(0, 0, 0, 0);
function toFloat(value) {
return parseFloat(value) || 0;
}
function getBordersSize(styles) {
var positions = [];
for (var _i = 1; _i < arguments.length; _i++) {
positions[_i - 1] = arguments[_i];
}
return positions.reduce(function(size, position2) {
var value = styles["border-" + position2 + "-width"];
return size + toFloat(value);
}, 0);
}
function getPaddings(styles) {
var positions = ["top", "right", "bottom", "left"];
var paddings = {};
for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
var position2 = positions_1[_i];
var value = styles["padding-" + position2];
paddings[position2] = toFloat(value);
}
return paddings;
}
function getSVGContentRect(target) {
var bbox = target.getBBox();
return createRectInit(0, 0, bbox.width, bbox.height);
}
function getHTMLElementContentRect(target) {
var clientWidth = target.clientWidth, clientHeight = target.clientHeight;
if (!clientWidth && !clientHeight) {
return emptyRect;
}
var styles = getWindowOf(target).getComputedStyle(target);
var paddings = getPaddings(styles);
var horizPad = paddings.left + paddings.right;
var vertPad = paddings.top + paddings.bottom;
var width = toFloat(styles.width), height = toFloat(styles.height);
if (styles.boxSizing === "border-box") {
if (Math.round(width + horizPad) !== clientWidth) {
width -= getBordersSize(styles, "left", "right") + horizPad;
}
if (Math.round(height + vertPad) !== clientHeight) {
height -= getBordersSize(styles, "top", "bottom") + vertPad;
}
}
if (!isDocumentElement(target)) {
var vertScrollbar = Math.round(width + horizPad) - clientWidth;
var horizScrollbar = Math.round(height + vertPad) - clientHeight;
if (Math.abs(vertScrollbar) !== 1) {
width -= vertScrollbar;
}
if (Math.abs(horizScrollbar) !== 1) {
height -= horizScrollbar;
}
}
return createRectInit(paddings.left, paddings.top, width, height);
}
var isSVGGraphicsElement = function() {
if (typeof SVGGraphicsElement !== "undefined") {
return function(target) {
return target instanceof getWindowOf(target).SVGGraphicsElement;
};
}
return function(target) {
return target instanceof getWindowOf(target).SVGElement && typeof target.getBBox === "function";
};
}();
function isDocumentElement(target) {
return target === getWindowOf(target).document.documentElement;
}
function getContentRect(target) {
if (!isBrowser) {
return emptyRect;
}
if (isSVGGraphicsElement(target)) {
return getSVGContentRect(target);
}
return getHTMLElementContentRect(target);
}
function createReadOnlyRect(_a) {
var x = _a.x, y = _a.y, width = _a.width, height = _a.height;
var Constr = typeof DOMRectReadOnly !== "undefined" ? DOMRectReadOnly : Object;
var rect = Object.create(Constr.prototype);
defineConfigurable(rect, {
x,
y,
width,
height,
top: y,
right: x + width,
bottom: height + y,
left: x
});
return rect;
}
function createRectInit(x, y, width, height) {
return { x, y, width, height };
}
var ResizeObservation = (
/** @class */
function() {
function ResizeObservation2(target) {
this.broadcastWidth = 0;
this.broadcastHeight = 0;
this.contentRect_ = createRectInit(0, 0, 0, 0);
this.target = target;
}
ResizeObservation2.prototype.isActive = function() {
var rect = getContentRect(this.target);
this.contentRect_ = rect;
return rect.width !== this.broadcastWidth || rect.height !== this.broadcastHeight;
};
ResizeObservation2.prototype.broadcastRect = function() {
var rect = this.contentRect_;
this.broadcastWidth = rect.width;
this.broadcastHeight = rect.height;
return rect;
};
return ResizeObservation2;
}()
);
var ResizeObserverEntry = (
/** @class */
/* @__PURE__ */ function() {
function ResizeObserverEntry2(target, rectInit) {
var contentRect = createReadOnlyRect(rectInit);
defineConfigurable(this, { target, contentRect });
}
return ResizeObserverEntry2;
}()
);
var ResizeObserverSPI = (
/** @class */
function() {
function ResizeObserverSPI2(callback, controller, callbackCtx) {
this.activeObservations_ = [];
this.observations_ = new MapShim();
if (typeof callback !== "function") {
throw new TypeError("The callback provided as parameter 1 is not a function.");
}
this.callback_ = callback;
this.controller_ = controller;
this.callbackCtx_ = callbackCtx;
}
ResizeObserverSPI2.prototype.observe = function(target) {
if (!arguments.length) {
throw new TypeError("1 argument required, but only 0 present.");
}
if (typeof Element === "undefined" || !(Element instanceof Object)) {
return;
}
if (!(target instanceof getWindowOf(target).Element)) {
throw new TypeError('parameter 1 is not of type "Element".');
}
var observations = this.observations_;
if (observations.has(target)) {
return;
}
observations.set(target, new ResizeObservation(target));
this.controller_.addObserver(this);
this.controller_.refresh();
};
ResizeObserverSPI2.prototype.unobserve = function(target) {
if (!arguments.length) {
throw new TypeError("1 argument required, but only 0 present.");
}
if (typeof Element === "undefined" || !(Element instanceof Object)) {
return;
}
if (!(target instanceof getWindowOf(target).Element)) {
throw new TypeError('parameter 1 is not of type "Element".');
}
var observations = this.observations_;
if (!observations.has(target)) {
return;
}
observations.delete(target);
if (!observations.size) {
this.controller_.removeObserver(this);
}
};
ResizeObserverSPI2.prototype.disconnect = function() {
this.clearActive();
this.observations_.clear();
this.controller_.removeObserver(this);
};
ResizeObserverSPI2.prototype.gatherActive = function() {
var _this = this;
this.clearActive();
this.observations_.forEach(function(observation) {
if (observation.isActive()) {
_this.activeObservations_.push(observation);
}
});
};
ResizeObserverSPI2.prototype.broadcastActive = function() {
if (!this.hasActive()) {
return;
}
var ctx = this.callbackCtx_;
var entries = this.activeObservations_.map(function(observation) {
return new ResizeObserverEntry(observation.target, observation.broadcastRect());
});
this.callback_.call(ctx, entries, ctx);
this.clearActive();
};
ResizeObserverSPI2.prototype.clearActive = function() {
this.activeObservations_.splice(0);
};
ResizeObserverSPI2.prototype.hasActive = function() {
return this.activeObservations_.length > 0;
};
return ResizeObserverSPI2;
}()
);
var observers = typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : new MapShim();
var ResizeObserver$2 = (
/** @class */
/* @__PURE__ */ function() {
function ResizeObserver2(callback) {
if (!(this instanceof ResizeObserver2)) {
throw new TypeError("Cannot call a class as a function.");
}
if (!arguments.length) {
throw new TypeError("1 argument required, but only 0 present.");
}
var controller = ResizeObserverController.getInstance();
var observer = new ResizeObserverSPI(callback, controller, this);
observers.set(this, observer);
}
return ResizeObserver2;
}()
);
[
"observe",
"unobserve",
"disconnect"
].forEach(function(method4) {
ResizeObserver$2.prototype[method4] = function() {
var _a;
return (_a = observers.get(this))[method4].apply(_a, arguments);
};
});
var index = function() {
if (typeof global$1.ResizeObserver !== "undefined") {
return global$1.ResizeObserver;
}
return ResizeObserver$2;
}();
var elementListeners = /* @__PURE__ */ new Map();
function onResize(entities) {
entities.forEach(function(entity) {
var _elementListeners$get;
var target = entity.target;
(_elementListeners$get = elementListeners.get(target)) === null || _elementListeners$get === void 0 || _elementListeners$get.forEach(function(listener) {
return listener(target);
});
});
}
var resizeObserver = new index(onResize);
process.env.NODE_ENV !== "production" ? elementListeners : null;
process.env.NODE_ENV !== "production" ? onResize : null;
function observe(element, callback) {
if (!elementListeners.has(element)) {
elementListeners.set(element, /* @__PURE__ */ new Set());
resizeObserver.observe(element);
}
elementListeners.get(element).add(callback);
}
function unobserve(element, callback) {
if (elementListeners.has(element)) {
elementListeners.get(element).delete(callback);
if (!elementListeners.get(element).size) {
resizeObserver.unobserve(element);
elementListeners.delete(element);
}
}
}
function _classCallCheck(a, n) {
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
}
function _defineProperties(e, r) {
for (var t = 0; t < r.length; t++) {
var o = r[t];
o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, toPropertyKey(o.key), o);
}
}
function _createClass(e, r, t) {
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
writable: false
}), e;
}
function _setPrototypeOf(t, e) {
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t2, e2) {
return t2.__proto__ = e2, t2;
}, _setPrototypeOf(t, e);
}
function _inherits(t, e) {
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
t.prototype = Object.create(e && e.prototype, {
constructor: {
value: t,
writable: true,
configurable: true
}
}), Object.defineProperty(t, "prototype", {
writable: false
}), e && _setPrototypeOf(t, e);
}
function _getPrototypeOf(t) {
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(t2) {
return t2.__proto__ || Object.getPrototypeOf(t2);
}, _getPrototypeOf(t);
}
function _isNativeReflectConstruct() {
try {
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
}));
} catch (t2) {
}
return (_isNativeReflectConstruct = function _isNativeReflectConstruct2() {
return !!t;
})();
}
function _assertThisInitialized(e) {
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return e;
}
function _possibleConstructorReturn(t, e) {
if (e && ("object" == _typeof(e) || "function" == typeof e)) return e;
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
return _assertThisInitialized(t);
}
function _createSuper(t) {
var r = _isNativeReflectConstruct();
return function() {
var e, o = _getPrototypeOf(t);
if (r) {
var s = _getPrototypeOf(this).constructor;
e = Reflect.construct(o, arguments, s);
} else e = o.apply(this, arguments);
return _possibleConstructorReturn(this, e);
};
}
var DomWrapper$1 = /* @__PURE__ */ function(_React$Component) {
_inherits(DomWrapper2, _React$Component);
var _super = _createSuper(DomWrapper2);
function DomWrapper2() {
_classCallCheck(this, DomWrapper2);
return _super.apply(this, arguments);
}
_createClass(DomWrapper2, [{
key: "render",
value: function render2() {
return this.props.children;
}
}]);
return DomWrapper2;
}(React.Component);
function SingleObserver(props, ref) {
var children = props.children, disabled = props.disabled;
var elementRef = React.useRef(null);
var wrapperRef = React.useRef(null);
var onCollectionResize = React.useContext(CollectionContext);
var isRenderProps = typeof children === "function";
var mergedChildren = isRenderProps ? children(elementRef) : children;
var sizeRef = React.useRef({
width: -1,
height: -1,
offsetWidth: -1,
offsetHeight: -1
});
var canRef = !isRenderProps && /* @__PURE__ */ React.isValidElement(mergedChildren) && supportRef(mergedChildren);
var originRef = canRef ? mergedChildren.ref : null;
var mergedRef = useComposeRef(originRef, elementRef);
var getDom = function getDom2() {
var _elementRef$current;
return findDOMNode(elementRef.current) || // Support `nativeElement` format
(elementRef.current && _typeof(elementRef.current) === "object" ? findDOMNode((_elementRef$current = elementRef.current) === null || _elementRef$current === void 0 ? void 0 : _elementRef$current.nativeElement) : null) || findDOMNode(wrapperRef.current);
};
React.useImperativeHandle(ref, function() {
return getDom();
});
var propsRef = React.useRef(props);
propsRef.current = props;
var onInternalResize = React.useCallback(function(target) {
var _propsRef$current = propsRef.current, onResize2 = _propsRef$current.onResize, data = _propsRef$current.data;
var _target$getBoundingCl = target.getBoundingClientRect(), width = _target$getBoundingCl.width, height = _target$getBoundingCl.height;
var offsetWidth = target.offsetWidth, offsetHeight = target.offsetHeight;
var fixedWidth = Math.floor(width);
var fixedHeight = Math.floor(height);
if (sizeRef.current.width !== fixedWidth || sizeRef.current.height !== fixedHeight || sizeRef.current.offsetWidth !== offsetWidth || sizeRef.current.offsetHeight !== offsetHeight) {
var size = {
width: fixedWidth,
height: fixedHeight,
offsetWidth,
offsetHeight
};
sizeRef.current = size;
var mergedOffsetWidth = offsetWidth === Math.round(width) ? width : offsetWidth;
var mergedOffsetHeight = offsetHeight === Math.round(height) ? height : offsetHeight;
var sizeInfo = _objectSpread2(_objectSpread2({}, size), {}, {
offsetWidth: mergedOffsetWidth,
offsetHeight: mergedOffsetHeight
});
onCollectionResize === null || onCollectionResize === void 0 || onCollectionResize(sizeInfo, target, data);
if (onResize2) {
Promise.resolve().then(function() {
onResize2(sizeInfo, target);
});
}
}
}, []);
React.useEffect(function() {
var currentElement = getDom();
if (currentElement && !disabled) {
observe(currentElement, onInternalResize);
}
return function() {
return unobserve(currentElement, onInternalResize);
};
}, [elementRef.current, disabled]);
return /* @__PURE__ */ React.createElement(DomWrapper$1, {
ref: wrapperRef
}, canRef ? /* @__PURE__ */ React.cloneElement(mergedChildren, {
ref: mergedRef
}) : mergedChildren);
}
var RefSingleObserver = /* @__PURE__ */ React.forwardRef(SingleObserver);
if (process.env.NODE_ENV !== "production") {
RefSingleObserver.displayName = "SingleObserver";
}
var INTERNAL_PREFIX_KEY = "rc-observer-key";
function ResizeObserver$1(props, ref) {
var children = props.children;
var childNodes = typeof children === "function" ? [children] : toArray$3(children);
if (process.env.NODE_ENV !== "production") {
if (childNodes.length > 1) {
warning$4(false, "Find more than one child node with `children` in ResizeObserver. Please use ResizeObserver.Collection instead.");
} else if (childNodes.length === 0) {
warning$4(false, "`children` of ResizeObserver is empty. Nothing is in observe.");
}
}
return childNodes.map(function(child, index2) {
var key = (child === null || child === void 0 ? void 0 : child.key) || "".concat(INTERNAL_PREFIX_KEY, "-").concat(index2);
return /* @__PURE__ */ React.createElement(RefSingleObserver, _extends({}, props, {
key,
ref: index2 === 0 ? ref : void 0
}), child);
});
}
var RefResizeObserver = /* @__PURE__ */ React.forwardRef(ResizeObserver$1);
if (process.env.NODE_ENV !== "production") {
RefResizeObserver.displayName = "ResizeObserver";
}
RefResizeObserver.Collection = Collection;
function getUseId() {
var fullClone2 = _objectSpread2({}, React);
return fullClone2.useId;
}
var uuid$1 = 0;
var useOriginId = getUseId();
const useId$1 = useOriginId ? (
// Use React `useId`
function useId(id) {
var reactId = useOriginId();
if (id) {
return id;
}
if (process.env.NODE_ENV === "test") {
return "test-id";
}
return reactId;
}
) : (
// Use compatible of `useId`
function useCompatId(id) {
var _React$useState = React.useState("ssr-id"), _React$useState2 = _slicedToArray(_React$useState, 2), innerId = _React$useState2[0], setInnerId = _React$useState2[1];
React.useEffect(function() {
var nextId = uuid$1;
uuid$1 += 1;
setInnerId("rc_unique_".concat(nextId));
}, []);
if (id) {
return id;
}
if (process.env.NODE_ENV === "test") {
return "test-id";
}
return innerId;
}
);
const isMobile = function() {
if (typeof navigator === "undefined" || typeof window === "undefined") {
return false;
}
var agent = navigator.userAgent || navigator.vendor || window.opera;
return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(agent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(agent === null || agent === void 0 ? void 0 : agent.substr(0, 4));
};
var _excluded$c = ["children"];
var Context$1 = /* @__PURE__ */ React.createContext({});
function MotionProvider(_ref) {
var children = _ref.children, props = _objectWithoutProperties(_ref, _excluded$c);
return /* @__PURE__ */ React.createElement(Context$1.Provider, {
value: props
}, children);
}
var DomWrapper = /* @__PURE__ */ function(_React$Component) {
_inherits(DomWrapper2, _React$Component);
var _super = _createSuper(DomWrapper2);
function DomWrapper2() {
_classCallCheck(this, DomWrapper2);
return _super.apply(this, arguments);
}
_createClass(DomWrapper2, [{
key: "render",
value: function render2() {
return this.props.children;
}
}]);
return DomWrapper2;
}(React.Component);
function useSyncState$1(defaultValue) {
var _React$useReducer = React.useReducer(function(x) {
return x + 1;
}, 0), _React$useReducer2 = _slicedToArray(_React$useReducer, 2), forceUpdate = _React$useReducer2[1];
var currentValueRef = React.useRef(defaultValue);
var getValue2 = useEvent(function() {
return currentValueRef.current;
});
var setValue = useEvent(function(updater) {
currentValueRef.current = typeof updater === "function" ? updater(currentValueRef.current) : updater;
forceUpdate();
});
return [getValue2, setValue];
}
var STATUS_NONE = "none";
var STATUS_APPEAR = "appear";
var STATUS_ENTER = "enter";
var STATUS_LEAVE = "leave";
var STEP_NONE = "none";
var STEP_PREPARE = "prepare";
var STEP_START = "start";
var STEP_ACTIVE = "active";
var STEP_ACTIVATED = "end";
var STEP_PREPARED = "prepared";
function makePrefixMap(styleProp, eventName) {
var prefixes = {};
prefixes[styleProp.toLowerCase()] = eventName.toLowerCase();
prefixes["Webkit".concat(styleProp)] = "webkit".concat(eventName);
prefixes["Moz".concat(styleProp)] = "moz".concat(eventName);
prefixes["ms".concat(styleProp)] = "MS".concat(eventName);
prefixes["O".concat(styleProp)] = "o".concat(eventName.toLowerCase());
return prefixes;
}
function getVendorPrefixes(domSupport, win) {
var prefixes = {
animationend: makePrefixMap("Animation", "AnimationEnd"),
transitionend: makePrefixMap("Transition", "TransitionEnd")
};
if (domSupport) {
if (!("AnimationEvent" in win)) {
delete prefixes.animationend.animation;
}
if (!("TransitionEvent" in win)) {
delete prefixes.transitionend.transition;
}
}
return prefixes;
}
var vendorPrefixes = getVendorPrefixes(canUseDom(), typeof window !== "undefined" ? window : {});
var style = {};
if (canUseDom()) {
var _document$createEleme = document.createElement("div");
style = _document$createEleme.style;
}
var prefixedEventNames = {};
function getVendorPrefixedEventName(eventName) {
if (prefixedEventNames[eventName]) {
return prefixedEventNames[eventName];
}
var prefixMap = vendorPrefixes[eventName];
if (prefixMap) {
var stylePropList = Object.keys(prefixMap);
var len = stylePropList.length;
for (var i = 0; i < len; i += 1) {
var styleProp = stylePropList[i];
if (Object.prototype.hasOwnProperty.call(prefixMap, styleProp) && styleProp in style) {
prefixedEventNames[eventName] = prefixMap[styleProp];
return prefixedEventNames[eventName];
}
}
}
return "";
}
var internalAnimationEndName = getVendorPrefixedEventName("animationend");
var internalTransitionEndName = getVendorPrefixedEventName("transitionend");
var supportTransition = !!(internalAnimationEndName && internalTransitionEndName);
var animationEndName = internalAnimationEndName || "animationend";
var transitionEndName = internalTransitionEndName || "transitionend";
function getTransitionName(transitionName, transitionType) {
if (!transitionName) return null;
if (_typeof(transitionName) === "object") {
var type4 = transitionType.replace(/-\w/g, function(match2) {
return match2[1].toUpperCase();
});
return transitionName[type4];
}
return "".concat(transitionName, "-").concat(transitionType);
}
const useDomMotionEvents = function(onInternalMotionEnd) {
var cacheElementRef = useRef();
function removeMotionEvents(element) {
if (element) {
element.removeEventListener(transitionEndName, onInternalMotionEnd);
element.removeEventListener(animationEndName, onInternalMotionEnd);
}
}
function patchMotionEvents(element) {
if (cacheElementRef.current && cacheElementRef.current !== element) {
removeMotionEvents(cacheElementRef.current);
}
if (element && element !== cacheElementRef.current) {
element.addEventListener(transitionEndName, onInternalMotionEnd);
element.addEventListener(animationEndName, onInternalMotionEnd);
cacheElementRef.current = element;
}
}
React.useEffect(function() {
return function() {
removeMotionEvents(cacheElementRef.current);
};
}, []);
return [patchMotionEvents, removeMotionEvents];
};
var useIsomorphicLayoutEffect = canUseDom() ? useLayoutEffect$1 : useEffect;
var raf = function raf2(callback) {
return +setTimeout(callback, 16);
};
var caf = function caf2(num) {
return clearTimeout(num);
};
if (typeof window !== "undefined" && "requestAnimationFrame" in window) {
raf = function raf3(callback) {
return window.requestAnimationFrame(callback);
};
caf = function caf3(handle) {
return window.cancelAnimationFrame(handle);
};
}
var rafUUID = 0;
var rafIds = /* @__PURE__ */ new Map();
function cleanup(id) {
rafIds.delete(id);
}
var wrapperRaf = function wrapperRaf2(callback) {
var times = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1;
rafUUID += 1;
var id = rafUUID;
function callRef(leftTimes) {
if (leftTimes === 0) {
cleanup(id);
callback();
} else {
var realId = raf(function() {
callRef(leftTimes - 1);
});
rafIds.set(id, realId);
}
}
callRef(times);
return id;
};
wrapperRaf.cancel = function(id) {
var realId = rafIds.get(id);
cleanup(id);
return caf(realId);
};
if (process.env.NODE_ENV !== "production") {
wrapperRaf.ids = function() {
return rafIds;
};
}
const useNextFrame = function() {
var nextFrameRef = React.useRef(null);
function cancelNextFrame() {
wrapperRaf.cancel(nextFrameRef.current);
}
function nextFrame(callback) {
var delay = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 2;
cancelNextFrame();
var nextFrameId = wrapperRaf(function() {
if (delay <= 1) {
callback({
isCanceled: function isCanceled() {
return nextFrameId !== nextFrameRef.current;
}
});
} else {
nextFrame(callback, delay - 1);
}
});
nextFrameRef.current = nextFrameId;
}
React.useEffect(function() {
return function() {
cancelNextFrame();
};
}, []);
return [nextFrame, cancelNextFrame];
};
var FULL_STEP_QUEUE = [STEP_PREPARE, STEP_START, STEP_ACTIVE, STEP_ACTIVATED];
var SIMPLE_STEP_QUEUE = [STEP_PREPARE, STEP_PREPARED];
var SkipStep = false;
var DoStep = true;
function isActive(step) {
return step === STEP_ACTIVE || step === STEP_ACTIVATED;
}
const useStepQueue = function(status, prepareOnly, callback) {
var _useState = useSafeState(STEP_NONE), _useState2 = _slicedToArray(_useState, 2), step = _useState2[0], setStep = _useState2[1];
var _useNextFrame = useNextFrame(), _useNextFrame2 = _slicedToArray(_useNextFrame, 2), nextFrame = _useNextFrame2[0], cancelNextFrame = _useNextFrame2[1];
function startQueue() {
setStep(STEP_PREPARE, true);
}
var STEP_QUEUE = prepareOnly ? SIMPLE_STEP_QUEUE : FULL_STEP_QUEUE;
useIsomorphicLayoutEffect(function() {
if (step !== STEP_NONE && step !== STEP_ACTIVATED) {
var index2 = STEP_QUEUE.indexOf(step);
var nextStep = STEP_QUEUE[index2 + 1];
var result = callback(step);
if (result === SkipStep) {
setStep(nextStep, true);
} else if (nextStep) {
nextFrame(function(info) {
function doNext() {
if (info.isCanceled()) return;
setStep(nextStep, true);
}
if (result === true) {
doNext();
} else {
Promise.resolve(result).then(doNext);
}
});
}
}
}, [status, step]);
React.useEffect(function() {
return function() {
cancelNextFrame();
};
}, []);
return [startQueue, step];
};
function useStatus(supportMotion, visible, getElement, _ref) {
var _ref$motionEnter = _ref.motionEnter, motionEnter = _ref$motionEnter === void 0 ? true : _ref$motionEnter, _ref$motionAppear = _ref.motionAppear, motionAppear = _ref$motionAppear === void 0 ? true : _ref$motionAppear, _ref$motionLeave = _ref.motionLeave, motionLeave = _ref$motionLeave === void 0 ? true : _ref$motionLeave, motionDeadline = _ref.motionDeadline, motionLeaveImmediately = _ref.motionLeaveImmediately, onAppearPrepare = _ref.onAppearPrepare, onEnterPrepare = _ref.onEnterPrepare, onLeavePrepare = _ref.onLeavePrepare, onAppearStart = _ref.onAppearStart, onEnterStart = _ref.onEnterStart, onLeaveStart = _ref.onLeaveStart, onAppearActive = _ref.onAppearActive, onEnterActive = _ref.onEnterActive, onLeaveActive = _ref.onLeaveActive, onAppearEnd = _ref.onAppearEnd, onEnterEnd = _ref.onEnterEnd, onLeaveEnd = _ref.onLeaveEnd, onVisibleChanged = _ref.onVisibleChanged;
var _useState = useSafeState(), _useState2 = _slicedToArray(_useState, 2), asyncVisible = _useState2[0], setAsyncVisible = _useState2[1];
var _useSyncState = useSyncState$1(STATUS_NONE), _useSyncState2 = _slicedToArray(_useSyncState, 2), getStatus = _useSyncState2[0], setStatus = _useSyncState2[1];
var _useState3 = useSafeState(null), _useState4 = _slicedToArray(_useState3, 2), style2 = _useState4[0], setStyle = _useState4[1];
var currentStatus = getStatus();
var mountedRef = useRef(false);
var deadlineRef = useRef(null);
function getDomElement() {
return getElement();
}
var activeRef = useRef(false);
function updateMotionEndStatus() {
setStatus(STATUS_NONE);
setStyle(null, true);
}
var onInternalMotionEnd = useEvent(function(event) {
var status = getStatus();
if (status === STATUS_NONE) {
return;
}
var element = getDomElement();
if (event && !event.deadline && event.target !== element) {
return;
}
var currentActive = activeRef.current;
var canEnd;
if (status === STATUS_APPEAR && currentActive) {
canEnd = onAppearEnd === null || onAppearEnd === void 0 ? void 0 : onAppearEnd(element, event);
} else if (status === STATUS_ENTER && currentActive) {
canEnd = onEnterEnd === null || onEnterEnd === void 0 ? void 0 : onEnterEnd(element, event);
} else if (status === STATUS_LEAVE && currentActive) {
canEnd = onLeaveEnd === null || onLeaveEnd === void 0 ? void 0 : onLeaveEnd(element, event);
}
if (currentActive && canEnd !== false) {
updateMotionEndStatus();
}
});
var _useDomMotionEvents = useDomMotionEvents(onInternalMotionEnd), _useDomMotionEvents2 = _slicedToArray(_useDomMotionEvents, 1), patchMotionEvents = _useDomMotionEvents2[0];
var getEventHandlers = function getEventHandlers2(targetStatus) {
switch (targetStatus) {
case STATUS_APPEAR:
return _defineProperty(_defineProperty(_defineProperty({}, STEP_PREPARE, onAppearPrepare), STEP_START, onAppearStart), STEP_ACTIVE, onAppearActive);
case STATUS_ENTER:
return _defineProperty(_defineProperty(_defineProperty({}, STEP_PREPARE, onEnterPrepare), STEP_START, onEnterStart), STEP_ACTIVE, onEnterActive);
case STATUS_LEAVE:
return _defineProperty(_defineProperty(_defineProperty({}, STEP_PREPARE, onLeavePrepare), STEP_START, onLeaveStart), STEP_ACTIVE, onLeaveActive);
default:
return {};
}
};
var eventHandlers = React.useMemo(function() {
return getEventHandlers(currentStatus);
}, [currentStatus]);
var _useStepQueue = useStepQueue(currentStatus, !supportMotion, function(newStep) {
if (newStep === STEP_PREPARE) {
var onPrepare = eventHandlers[STEP_PREPARE];
if (!onPrepare) {
return SkipStep;
}
return onPrepare(getDomElement());
}
if (step in eventHandlers) {
var _eventHandlers$step;
setStyle(((_eventHandlers$step = eventHandlers[step]) === null || _eventHandlers$step === void 0 ? void 0 : _eventHandlers$step.call(eventHandlers, getDomElement(), null)) || null);
}
if (step === STEP_ACTIVE && currentStatus !== STATUS_NONE) {
patchMotionEvents(getDomElement());
if (motionDeadline > 0) {
clearTimeout(deadlineRef.current);
deadlineRef.current = setTimeout(function() {
onInternalMotionEnd({
deadline: true
});
}, motionDeadline);
}
}
if (step === STEP_PREPARED) {
updateMotionEndStatus();
}
return DoStep;
}), _useStepQueue2 = _slicedToArray(_useStepQueue, 2), startStep = _useStepQueue2[0], step = _useStepQueue2[1];
var active = isActive(step);
activeRef.current = active;
useIsomorphicLayoutEffect(function() {
setAsyncVisible(visible);
var isMounted = mountedRef.current;
mountedRef.current = true;
var nextStatus;
if (!isMounted && visible && motionAppear) {
nextStatus = STATUS_APPEAR;
}
if (isMounted && visible && motionEnter) {
nextStatus = STATUS_ENTER;
}
if (isMounted && !visible && motionLeave || !isMounted && motionLeaveImmediately && !visible && motionLeave) {
nextStatus = STATUS_LEAVE;
}
var nextEventHandlers = getEventHandlers(nextStatus);
if (nextStatus && (supportMotion || nextEventHandlers[STEP_PREPARE])) {
setStatus(nextStatus);
startStep();
} else {
setStatus(STATUS_NONE);
}
}, [visible]);
useEffect(function() {
if (
// Cancel appear
currentStatus === STATUS_APPEAR && !motionAppear || // Cancel enter
currentStatus === STATUS_ENTER && !motionEnter || // Cancel leave
currentStatus === STATUS_LEAVE && !motionLeave
) {
setStatus(STATUS_NONE);
}
}, [motionAppear, motionEnter, motionLeave]);
useEffect(function() {
return function() {
mountedRef.current = false;
clearTimeout(deadlineRef.current);
};
}, []);
var firstMountChangeRef = React.useRef(false);
useEffect(function() {
if (asyncVisible) {
firstMountChangeRef.current = true;
}
if (asyncVisible !== void 0 && currentStatus === STATUS_NONE) {
if (firstMountChangeRef.current || asyncVisible) {
onVisibleChanged === null || onVisibleChanged === void 0 || onVisibleChanged(asyncVisible);
}
firstMountChangeRef.current = true;
}
}, [asyncVisible, currentStatus]);
var mergedStyle = style2;
if (eventHandlers[STEP_PREPARE] && step === STEP_START) {
mergedStyle = _objectSpread2({
transition: "none"
}, mergedStyle);
}
return [currentStatus, step, mergedStyle, asyncVisible !== null && asyncVisible !== void 0 ? asyncVisible : visible];
}
function genCSSMotion(config) {
var transitionSupport = config;
if (_typeof(config) === "object") {
transitionSupport = config.transitionSupport;
}
function isSupportTransition(props, contextMotion) {
return !!(props.motionName && transitionSupport && contextMotion !== false);
}
var CSSMotion2 = /* @__PURE__ */ React.forwardRef(function(props, ref) {
var _props$visible = props.visible, visible = _props$visible === void 0 ? true : _props$visible, _props$removeOnLeave = props.removeOnLeave, removeOnLeave = _props$removeOnLeave === void 0 ? true : _props$removeOnLeave, forceRender = props.forceRender, children = props.children, motionName = props.motionName, leavedClassName = props.leavedClassName, eventProps = props.eventProps;
var _React$useContext = React.useContext(Context$1), contextMotion = _React$useContext.motion;
var supportMotion = isSupportTransition(props, contextMotion);
var nodeRef = useRef();
var wrapperNodeRef = useRef();
function getDomElement() {
try {
return nodeRef.current instanceof HTMLElement ? nodeRef.current : findDOMNode(wrapperNodeRef.current);
} catch (e) {
return null;
}
}
var _useStatus = useStatus(supportMotion, visible, getDomElement, props), _useStatus2 = _slicedToArray(_useStatus, 4), status = _useStatus2[0], statusStep = _useStatus2[1], statusStyle = _useStatus2[2], mergedVisible = _useStatus2[3];
var renderedRef = React.useRef(mergedVisible);
if (mergedVisible) {
renderedRef.current = true;
}
var setNodeRef = React.useCallback(function(node2) {
nodeRef.current = node2;
fillRef(ref, node2);
}, [ref]);
var motionChildren;
var mergedProps = _objectSpread2(_objectSpread2({}, eventProps), {}, {
visible
});
if (!children) {
motionChildren = null;
} else if (status === STATUS_NONE) {
if (mergedVisible) {
motionChildren = children(_objectSpread2({}, mergedProps), setNodeRef);
} else if (!removeOnLeave && renderedRef.current && leavedClassName) {
motionChildren = children(_objectSpread2(_objectSpread2({}, mergedProps), {}, {
className: leavedClassName
}), setNodeRef);
} else if (forceRender || !removeOnLeave && !leavedClassName) {
motionChildren = children(_objectSpread2(_objectSpread2({}, mergedProps), {}, {
style: {
display: "none"
}
}), setNodeRef);
} else {
motionChildren = null;
}
} else {
var statusSuffix;
if (statusStep === STEP_PREPARE) {
statusSuffix = "prepare";
} else if (isActive(statusStep)) {
statusSuffix = "active";
} else if (statusStep === STEP_START) {
statusSuffix = "start";
}
var motionCls = getTransitionName(motionName, "".concat(status, "-").concat(statusSuffix));
motionChildren = children(_objectSpread2(_objectSpread2({}, mergedProps), {}, {
className: classNames(getTransitionName(motionName, status), _defineProperty(_defineProperty({}, motionCls, motionCls && statusSuffix), motionName, typeof motionName === "string")),
style: statusStyle
}), setNodeRef);
}
if (/* @__PURE__ */ React.isValidElement(motionChildren) && supportRef(motionChildren)) {
var _ref = motionChildren, originNodeRef = _ref.ref;
if (!originNodeRef) {
motionChildren = /* @__PURE__ */ React.cloneElement(motionChildren, {
ref: setNodeRef
});
}
}
return /* @__PURE__ */ React.createElement(DomWrapper, {
ref: wrapperNodeRef
}, motionChildren);
});
CSSMotion2.displayName = "CSSMotion";
return CSSMotion2;
}
const CSSMotion = genCSSMotion(supportTransition);
var STATUS_ADD = "add";
var STATUS_KEEP = "keep";
var STATUS_REMOVE = "remove";
var STATUS_REMOVED = "removed";
function wrapKeyToObject(key) {
var keyObj;
if (key && _typeof(key) === "object" && "key" in key) {
keyObj = key;
} else {
keyObj = {
key
};
}
return _objectSpread2(_objectSpread2({}, keyObj), {}, {
key: String(keyObj.key)
});
}
function parseKeys() {
var keys2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
return keys2.map(wrapKeyToObject);
}
function diffKeys() {
var prevKeys = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
var currentKeys = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
var list = [];
var currentIndex = 0;
var currentLen = currentKeys.length;
var prevKeyObjects = parseKeys(prevKeys);
var currentKeyObjects = parseKeys(currentKeys);
prevKeyObjects.forEach(function(keyObj) {
var hit = false;
for (var i = currentIndex; i < currentLen; i += 1) {
var currentKeyObj = currentKeyObjects[i];
if (currentKeyObj.key === keyObj.key) {
if (currentIndex < i) {
list = list.concat(currentKeyObjects.slice(currentIndex, i).map(function(obj) {
return _objectSpread2(_objectSpread2({}, obj), {}, {
status: STATUS_ADD
});
}));
currentIndex = i;
}
list.push(_objectSpread2(_objectSpread2({}, currentKeyObj), {}, {
status: STATUS_KEEP
}));
currentIndex += 1;
hit = true;
break;
}
}
if (!hit) {
list.push(_objectSpread2(_objectSpread2({}, keyObj), {}, {
status: STATUS_REMOVE
}));
}
});
if (currentIndex < currentLen) {
list = list.concat(currentKeyObjects.slice(currentIndex).map(function(obj) {
return _objectSpread2(_objectSpread2({}, obj), {}, {
status: STATUS_ADD
});
}));
}
var keys2 = {};
list.forEach(function(_ref) {
var key = _ref.key;
keys2[key] = (keys2[key] || 0) + 1;
});
var duplicatedKeys = Object.keys(keys2).filter(function(key) {
return keys2[key] > 1;
});
duplicatedKeys.forEach(function(matchKey) {
list = list.filter(function(_ref2) {
var key = _ref2.key, status = _ref2.status;
return key !== matchKey || status !== STATUS_REMOVE;
});
list.forEach(function(node2) {
if (node2.key === matchKey) {
node2.status = STATUS_KEEP;
}
});
});
return list;
}
var _excluded$b = ["component", "children", "onVisibleChanged", "onAllRemoved"], _excluded2$3 = ["status"];
var MOTION_PROP_NAMES = ["eventProps", "visible", "children", "motionName", "motionAppear", "motionEnter", "motionLeave", "motionLeaveImmediately", "motionDeadline", "removeOnLeave", "leavedClassName", "onAppearPrepare", "onAppearStart", "onAppearActive", "onAppearEnd", "onEnterStart", "onEnterActive", "onEnterEnd", "onLeaveStart", "onLeaveActive", "onLeaveEnd"];
function genCSSMotionList(transitionSupport) {
var CSSMotion$1 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : CSSMotion;
var CSSMotionList = /* @__PURE__ */ function(_React$Component) {
_inherits(CSSMotionList2, _React$Component);
var _super = _createSuper(CSSMotionList2);
function CSSMotionList2() {
var _this;
_classCallCheck(this, CSSMotionList2);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _super.call.apply(_super, [this].concat(args));
_defineProperty(_assertThisInitialized(_this), "state", {
keyEntities: []
});
_defineProperty(_assertThisInitialized(_this), "removeKey", function(removeKey) {
var keyEntities = _this.state.keyEntities;
var nextKeyEntities = keyEntities.map(function(entity) {
if (entity.key !== removeKey) return entity;
return _objectSpread2(_objectSpread2({}, entity), {}, {
status: STATUS_REMOVED
});
});
_this.setState({
keyEntities: nextKeyEntities
});
return nextKeyEntities.filter(function(_ref) {
var status = _ref.status;
return status !== STATUS_REMOVED;
}).length;
});
return _this;
}
_createClass(CSSMotionList2, [{
key: "render",
value: function render2() {
var _this2 = this;
var keyEntities = this.state.keyEntities;
var _this$props = this.props, component = _this$props.component, children = _this$props.children, _onVisibleChanged = _this$props.onVisibleChanged, onAllRemoved = _this$props.onAllRemoved, restProps = _objectWithoutProperties(_this$props, _excluded$b);
var Component = component || React.Fragment;
var motionProps = {};
MOTION_PROP_NAMES.forEach(function(prop) {
motionProps[prop] = restProps[prop];
delete restProps[prop];
});
delete restProps.keys;
return /* @__PURE__ */ React.createElement(Component, restProps, keyEntities.map(function(_ref2, index2) {
var status = _ref2.status, eventProps = _objectWithoutProperties(_ref2, _excluded2$3);
var visible = status === STATUS_ADD || status === STATUS_KEEP;
return /* @__PURE__ */ React.createElement(CSSMotion$1, _extends({}, motionProps, {
key: eventProps.key,
visible,
eventProps,
onVisibleChanged: function onVisibleChanged(changedVisible) {
_onVisibleChanged === null || _onVisibleChanged === void 0 || _onVisibleChanged(changedVisible, {
key: eventProps.key
});
if (!changedVisible) {
var restKeysCount = _this2.removeKey(eventProps.key);
if (restKeysCount === 0 && onAllRemoved) {
onAllRemoved();
}
}
}
}), function(props, ref) {
return children(_objectSpread2(_objectSpread2({}, props), {}, {
index: index2
}), ref);
});
}));
}
}], [{
key: "getDerivedStateFromProps",
value: function getDerivedStateFromProps(_ref3, _ref4) {
var keys2 = _ref3.keys;
var keyEntities = _ref4.keyEntities;
var parsedKeyObjects = parseKeys(keys2);
var mixedKeyEntities = diffKeys(keyEntities, parsedKeyObjects);
return {
keyEntities: mixedKeyEntities.filter(function(entity) {
var prevEntity = keyEntities.find(function(_ref5) {
var key = _ref5.key;
return entity.key === key;
});
if (prevEntity && prevEntity.status === STATUS_REMOVED && entity.status === STATUS_REMOVE) {
return false;
}
return true;
})
};
}
}]);
return CSSMotionList2;
}(React.Component);
_defineProperty(CSSMotionList, "defaultProps", {
component: "div"
});
return CSSMotionList;
}
genCSSMotionList(supportTransition);
function Arrow(props) {
var prefixCls = props.prefixCls, align = props.align, arrow = props.arrow, arrowPos = props.arrowPos;
var _ref = arrow || {}, className = _ref.className, content = _ref.content;
var _arrowPos$x = arrowPos.x, x = _arrowPos$x === void 0 ? 0 : _arrowPos$x, _arrowPos$y = arrowPos.y, y = _arrowPos$y === void 0 ? 0 : _arrowPos$y;
var arrowRef = React.useRef();
if (!align || !align.points) {
return null;
}
var alignStyle = {
position: "absolute"
};
if (align.autoArrow !== false) {
var popupPoints = align.points[0];
var targetPoints = align.points[1];
var popupTB = popupPoints[0];
var popupLR = popupPoints[1];
var targetTB = targetPoints[0];
var targetLR = targetPoints[1];
if (popupTB === targetTB || !["t", "b"].includes(popupTB)) {
alignStyle.top = y;
} else if (popupTB === "t") {
alignStyle.top = 0;
} else {
alignStyle.bottom = 0;
}
if (popupLR === targetLR || !["l", "r"].includes(popupLR)) {
alignStyle.left = x;
} else if (popupLR === "l") {
alignStyle.left = 0;
} else {
alignStyle.right = 0;
}
}
return /* @__PURE__ */ React.createElement("div", {
ref: arrowRef,
className: classNames("".concat(prefixCls, "-arrow"), className),
style: alignStyle
}, content);
}
function Mask(props) {
var prefixCls = props.prefixCls, open = props.open, zIndex = props.zIndex, mask = props.mask, motion = props.motion;
if (!mask) {
return null;
}
return /* @__PURE__ */ React.createElement(CSSMotion, _extends({}, motion, {
motionAppear: true,
visible: open,
removeOnLeave: true
}), function(_ref) {
var className = _ref.className;
return /* @__PURE__ */ React.createElement("div", {
style: {
zIndex
},
className: classNames("".concat(prefixCls, "-mask"), className)
});
});
}
var PopupContent = /* @__PURE__ */ React.memo(function(_ref) {
var children = _ref.children;
return children;
}, function(_, next2) {
return next2.cache;
});
if (process.env.NODE_ENV !== "production") {
PopupContent.displayName = "PopupContent";
}
var Popup$1 = /* @__PURE__ */ React.forwardRef(function(props, ref) {
var popup = props.popup, className = props.className, prefixCls = props.prefixCls, style2 = props.style, target = props.target, _onVisibleChanged = props.onVisibleChanged, open = props.open, keepDom = props.keepDom, fresh = props.fresh, onClick = props.onClick, mask = props.mask, arrow = props.arrow, arrowPos = props.arrowPos, align = props.align, motion = props.motion, maskMotion = props.maskMotion, forceRender = props.forceRender, getPopupContainer = props.getPopupContainer, autoDestroy = props.autoDestroy, Portal2 = props.portal, zIndex = props.zIndex, onMouseEnter = props.onMouseEnter, onMouseLeave = props.onMouseLeave, onPointerEnter = props.onPointerEnter, ready = props.ready, offsetX = props.offsetX, offsetY = props.offsetY, offsetR = props.offsetR, offsetB = props.offsetB, onAlign = props.onAlign, onPrepare = props.onPrepare, stretch = props.stretch, targetWidth = props.targetWidth, targetHeight = props.targetHeight;
var childNode = typeof popup === "function" ? popup() : popup;
var isNodeVisible = open || keepDom;
var getPopupContainerNeedParams = (getPopupContainer === null || getPopupContainer === void 0 ? void 0 : getPopupContainer.length) > 0;
var _React$useState = React.useState(!getPopupContainer || !getPopupContainerNeedParams), _React$useState2 = _slicedToArray(_React$useState, 2), show = _React$useState2[0], setShow = _React$useState2[1];
useLayoutEffect(function() {
if (!show && getPopupContainerNeedParams && target) {
setShow(true);
}
}, [show, getPopupContainerNeedParams, target]);
if (!show) {
return null;
}
var AUTO = "auto";
var offsetStyle = {
left: "-1000vw",
top: "-1000vh",
right: AUTO,
bottom: AUTO
};
if (ready || !open) {
var _experimental;
var points = align.points;
var dynamicInset = align.dynamicInset || ((_experimental = align._experimental) === null || _experimental === void 0 ? void 0 : _experimental.dynamicInset);
var alignRight = dynamicInset && points[0][1] === "r";
var alignBottom = dynamicInset && points[0][0] === "b";
if (alignRight) {
offsetStyle.right = offsetR;
offsetStyle.left = AUTO;
} else {
offsetStyle.left = offsetX;
offsetStyle.right = AUTO;
}
if (alignBottom) {
offsetStyle.bottom = offsetB;
offsetStyle.top = AUTO;
} else {
offsetStyle.top = offsetY;
offsetStyle.bottom = AUTO;
}
}
var miscStyle = {};
if (stretch) {
if (stretch.includes("height") && targetHeight) {
miscStyle.height = targetHeight;
} else if (stretch.includes("minHeight") && targetHeight) {
miscStyle.minHeight = targetHeight;
}
if (stretch.includes("width") && targetWidth) {
miscStyle.width = targetWidth;
} else if (stretch.includes("minWidth") && targetWidth) {
miscStyle.minWidth = targetWidth;
}
}
if (!open) {
miscStyle.pointerEvents = "none";
}
return /* @__PURE__ */ React.createElement(Portal2, {
open: forceRender || isNodeVisible,
getContainer: getPopupContainer && function() {
return getPopupContainer(target);
},
autoDestroy
}, /* @__PURE__ */ React.createElement(Mask, {
prefixCls,
open,
zIndex,
mask,
motion: maskMotion
}), /* @__PURE__ */ React.createElement(RefResizeObserver, {
onResize: onAlign,
disabled: !open
}, function(resizeObserverRef) {
return /* @__PURE__ */ React.createElement(CSSMotion, _extends({
motionAppear: true,
motionEnter: true,
motionLeave: true,
removeOnLeave: false,
forceRender,
leavedClassName: "".concat(prefixCls, "-hidden")
}, motion, {
onAppearPrepare: onPrepare,
onEnterPrepare: onPrepare,
visible: open,
onVisibleChanged: function onVisibleChanged(nextVisible) {
var _motion$onVisibleChan;
motion === null || motion === void 0 || (_motion$onVisibleChan = motion.onVisibleChanged) === null || _motion$onVisibleChan === void 0 || _motion$onVisibleChan.call(motion, nextVisible);
_onVisibleChanged(nextVisible);
}
}), function(_ref, motionRef) {
var motionClassName = _ref.className, motionStyle = _ref.style;
var cls = classNames(prefixCls, motionClassName, className);
return /* @__PURE__ */ React.createElement("div", {
ref: composeRef(resizeObserverRef, ref, motionRef),
className: cls,
style: _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
"--arrow-x": "".concat(arrowPos.x || 0, "px"),
"--arrow-y": "".concat(arrowPos.y || 0, "px")
}, offsetStyle), miscStyle), motionStyle), {}, {
boxSizing: "border-box",
zIndex
}, style2),
onMouseEnter,
onMouseLeave,
onPointerEnter,
onClick
}, arrow && /* @__PURE__ */ React.createElement(Arrow, {
prefixCls,
arrow,
arrowPos,
align
}), /* @__PURE__ */ React.createElement(PopupContent, {
cache: !open && !fresh
}, childNode));
});
}));
});
if (process.env.NODE_ENV !== "production") {
Popup$1.displayName = "Popup";
}
var TriggerWrapper = /* @__PURE__ */ React.forwardRef(function(props, ref) {
var children = props.children, getTriggerDOMNode = props.getTriggerDOMNode;
var canUseRef = supportRef(children);
var setRef = React.useCallback(function(node2) {
fillRef(ref, getTriggerDOMNode ? getTriggerDOMNode(node2) : node2);
}, [getTriggerDOMNode]);
var mergedRef = useComposeRef(setRef, children.ref);
return canUseRef ? /* @__PURE__ */ React.cloneElement(children, {
ref: mergedRef
}) : children;
});
if (process.env.NODE_ENV !== "production") {
TriggerWrapper.displayName = "TriggerWrapper";
}
var TriggerContext = /* @__PURE__ */ React.createContext(null);
function toArray$2(val) {
return val ? Array.isArray(val) ? val : [val] : [];
}
function useAction(mobile, action, showAction, hideAction) {
return React.useMemo(function() {
var mergedShowAction = toArray$2(showAction !== null && showAction !== void 0 ? showAction : action);
var mergedHideAction = toArray$2(hideAction !== null && hideAction !== void 0 ? hideAction : action);
var showActionSet = new Set(mergedShowAction);
var hideActionSet = new Set(mergedHideAction);
if (mobile) {
if (showActionSet.has("hover")) {
showActionSet.delete("hover");
showActionSet.add("click");
}
if (hideActionSet.has("hover")) {
hideActionSet.delete("hover");
hideActionSet.add("click");
}
}
return [showActionSet, hideActionSet];
}, [mobile, action, showAction, hideAction]);
}
const isVisible = function(element) {
if (!element) {
return false;
}
if (element instanceof Element) {
if (element.offsetParent) {
return true;
}
if (element.getBBox) {
var _getBBox = element.getBBox(), width = _getBBox.width, height = _getBBox.height;
if (width || height) {
return true;
}
}
if (element.getBoundingClientRect) {
var _element$getBoundingC = element.getBoundingClientRect(), _width = _element$getBoundingC.width, _height = _element$getBoundingC.height;
if (_width || _height) {
return true;
}
}
}
return false;
};
function isPointsEq() {
var a1 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
var a2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
var isAlignPoint = arguments.length > 2 ? arguments[2] : void 0;
if (isAlignPoint) {
return a1[0] === a2[0];
}
return a1[0] === a2[0] && a1[1] === a2[1];
}
function getAlignPopupClassName(builtinPlacements, prefixCls, align, isAlignPoint) {
var points = align.points;
var placements = Object.keys(builtinPlacements);
for (var i = 0; i < placements.length; i += 1) {
var _builtinPlacements$pl;
var placement = placements[i];
if (isPointsEq((_builtinPlacements$pl = builtinPlacements[placement]) === null || _builtinPlacements$pl === void 0 ? void 0 : _builtinPlacements$pl.points, points, isAlignPoint)) {
return "".concat(prefixCls, "-placement-").concat(placement);
}
}
return "";
}
function getMotion(prefixCls, motion, animation, transitionName) {
if (motion) {
return motion;
}
if (animation) {
return {
motionName: "".concat(prefixCls, "-").concat(animation)
};
}
if (transitionName) {
return {
motionName: transitionName
};
}
return null;
}
function getWin(ele) {
return ele.ownerDocument.defaultView;
}
function collectScroller(ele) {
var scrollerList = [];
var current = ele === null || ele === void 0 ? void 0 : ele.parentElement;
var scrollStyle = ["hidden", "scroll", "clip", "auto"];
while (current) {
var _getWin$getComputedSt = getWin(current).getComputedStyle(current), overflowX = _getWin$getComputedSt.overflowX, overflowY = _getWin$getComputedSt.overflowY, overflow = _getWin$getComputedSt.overflow;
if ([overflowX, overflowY, overflow].some(function(o) {
return scrollStyle.includes(o);
})) {
scrollerList.push(current);
}
current = current.parentElement;
}
return scrollerList;
}
function toNum(num) {
var defaultValue = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1;
return Number.isNaN(num) ? defaultValue : num;
}
function getPxValue(val) {
return toNum(parseFloat(val), 0);
}
function getVisibleArea(initArea, scrollerList) {
var visibleArea = _objectSpread2({}, initArea);
(scrollerList || []).forEach(function(ele) {
if (ele instanceof HTMLBodyElement || ele instanceof HTMLHtmlElement) {
return;
}
var _getWin$getComputedSt2 = getWin(ele).getComputedStyle(ele), overflow = _getWin$getComputedSt2.overflow, overflowClipMargin = _getWin$getComputedSt2.overflowClipMargin, borderTopWidth = _getWin$getComputedSt2.borderTopWidth, borderBottomWidth = _getWin$getComputedSt2.borderBottomWidth, borderLeftWidth = _getWin$getComputedSt2.borderLeftWidth, borderRightWidth = _getWin$getComputedSt2.borderRightWidth;
var eleRect = ele.getBoundingClientRect();
var eleOutHeight = ele.offsetHeight, eleInnerHeight = ele.clientHeight, eleOutWidth = ele.offsetWidth, eleInnerWidth = ele.clientWidth;
var borderTopNum = getPxValue(borderTopWidth);
var borderBottomNum = getPxValue(borderBottomWidth);
var borderLeftNum = getPxValue(borderLeftWidth);
var borderRightNum = getPxValue(borderRightWidth);
var scaleX = toNum(Math.round(eleRect.width / eleOutWidth * 1e3) / 1e3);
var scaleY = toNum(Math.round(eleRect.height / eleOutHeight * 1e3) / 1e3);
var eleScrollWidth = (eleOutWidth - eleInnerWidth - borderLeftNum - borderRightNum) * scaleX;
var eleScrollHeight = (eleOutHeight - eleInnerHeight - borderTopNum - borderBottomNum) * scaleY;
var scaledBorderTopWidth = borderTopNum * scaleY;
var scaledBorderBottomWidth = borderBottomNum * scaleY;
var scaledBorderLeftWidth = borderLeftNum * scaleX;
var scaledBorderRightWidth = borderRightNum * scaleX;
var clipMarginWidth = 0;
var clipMarginHeight = 0;
if (overflow === "clip") {
var clipNum = getPxValue(overflowClipMargin);
clipMarginWidth = clipNum * scaleX;
clipMarginHeight = clipNum * scaleY;
}
var eleLeft = eleRect.x + scaledBorderLeftWidth - clipMarginWidth;
var eleTop = eleRect.y + scaledBorderTopWidth - clipMarginHeight;
var eleRight = eleLeft + eleRect.width + 2 * clipMarginWidth - scaledBorderLeftWidth - scaledBorderRightWidth - eleScrollWidth;
var eleBottom = eleTop + eleRect.height + 2 * clipMarginHeight - scaledBorderTopWidth - scaledBorderBottomWidth - eleScrollHeight;
visibleArea.left = Math.max(visibleArea.left, eleLeft);
visibleArea.top = Math.max(visibleArea.top, eleTop);
visibleArea.right = Math.min(visibleArea.right, eleRight);
visibleArea.bottom = Math.min(visibleArea.bottom, eleBottom);
});
return visibleArea;
}
function getUnitOffset(size) {
var offset = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
var offsetStr = "".concat(offset);
var cells = offsetStr.match(/^(.*)\%$/);
if (cells) {
return size * (parseFloat(cells[1]) / 100);
}
return parseFloat(offsetStr);
}
function getNumberOffset(rect, offset) {
var _ref = offset || [], _ref2 = _slicedToArray(_ref, 2), offsetX = _ref2[0], offsetY = _ref2[1];
return [getUnitOffset(rect.width, offsetX), getUnitOffset(rect.height, offsetY)];
}
function splitPoints() {
var points = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "";
return [points[0], points[1]];
}
function getAlignPoint(rect, points) {
var topBottom = points[0];
var leftRight = points[1];
var x;
var y;
if (topBottom === "t") {
y = rect.y;
} else if (topBottom === "b") {
y = rect.y + rect.height;
} else {
y = rect.y + rect.height / 2;
}
if (leftRight === "l") {
x = rect.x;
} else if (leftRight === "r") {
x = rect.x + rect.width;
} else {
x = rect.x + rect.width / 2;
}
return {
x,
y
};
}
function reversePoints(points, index2) {
var reverseMap = {
t: "b",
b: "t",
l: "r",
r: "l"
};
return points.map(function(point, i) {
if (i === index2) {
return reverseMap[point] || "c";
}
return point;
}).join("");
}
function useAlign(open, popupEle, target, placement, builtinPlacements, popupAlign, onPopupAlign) {
var _React$useState = React.useState({
ready: false,
offsetX: 0,
offsetY: 0,
offsetR: 0,
offsetB: 0,
arrowX: 0,
arrowY: 0,
scaleX: 1,
scaleY: 1,
align: builtinPlacements[placement] || {}
}), _React$useState2 = _slicedToArray(_React$useState, 2), offsetInfo = _React$useState2[0], setOffsetInfo = _React$useState2[1];
var alignCountRef = React.useRef(0);
var scrollerList = React.useMemo(function() {
if (!popupEle) {
return [];
}
return collectScroller(popupEle);
}, [popupEle]);
var prevFlipRef = React.useRef({});
var resetFlipCache = function resetFlipCache2() {
prevFlipRef.current = {};
};
if (!open) {
resetFlipCache();
}
var onAlign = useEvent(function() {
if (popupEle && target && open) {
let getIntersectionVisibleArea = function(offsetX, offsetY) {
var area = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : visibleArea;
var l = popupRect.x + offsetX;
var t = popupRect.y + offsetY;
var r = l + popupWidth;
var b = t + popupHeight;
var visibleL = Math.max(l, area.left);
var visibleT = Math.max(t, area.top);
var visibleR = Math.min(r, area.right);
var visibleB = Math.min(b, area.bottom);
return Math.max(0, (visibleR - visibleL) * (visibleB - visibleT));
}, syncNextPopupPosition = function() {
nextPopupY = popupRect.y + nextOffsetY;
nextPopupBottom = nextPopupY + popupHeight;
nextPopupX = popupRect.x + nextOffsetX;
nextPopupRight = nextPopupX + popupWidth;
};
var _popupElement$parentE, _popupElement$parentE2;
var popupElement = popupEle;
var doc = popupElement.ownerDocument;
var win = getWin(popupElement);
var _win$getComputedStyle = win.getComputedStyle(popupElement), width = _win$getComputedStyle.width, height = _win$getComputedStyle.height, popupPosition = _win$getComputedStyle.position;
var originLeft = popupElement.style.left;
var originTop = popupElement.style.top;
var originRight = popupElement.style.right;
var originBottom = popupElement.style.bottom;
var originOverflow = popupElement.style.overflow;
var placementInfo = _objectSpread2(_objectSpread2({}, builtinPlacements[placement]), popupAlign);
var placeholderElement = doc.createElement("div");
(_popupElement$parentE = popupElement.parentElement) === null || _popupElement$parentE === void 0 || _popupElement$parentE.appendChild(placeholderElement);
placeholderElement.style.left = "".concat(popupElement.offsetLeft, "px");
placeholderElement.style.top = "".concat(popupElement.offsetTop, "px");
placeholderElement.style.position = popupPosition;
placeholderElement.style.height = "".concat(popupElement.offsetHeight, "px");
placeholderElement.style.width = "".concat(popupElement.offsetWidth, "px");
popupElement.style.left = "0";
popupElement.style.top = "0";
popupElement.style.right = "auto";
popupElement.style.bottom = "auto";
popupElement.style.overflow = "hidden";
var targetRect;
if (Array.isArray(target)) {
targetRect = {
x: target[0],
y: target[1],
width: 0,
height: 0
};
} else {
var rect = target.getBoundingClientRect();
targetRect = {
x: rect.x,
y: rect.y,
width: rect.width,
height: rect.height
};
}
var popupRect = popupElement.getBoundingClientRect();
var _doc$documentElement = doc.documentElement, clientWidth = _doc$documentElement.clientWidth, clientHeight = _doc$documentElement.clientHeight, scrollWidth = _doc$documentElement.scrollWidth, scrollHeight = _doc$documentElement.scrollHeight, scrollTop = _doc$documentElement.scrollTop, scrollLeft = _doc$documentElement.scrollLeft;
var popupHeight = popupRect.height;
var popupWidth = popupRect.width;
var targetHeight = targetRect.height;
var targetWidth = targetRect.width;
var visibleRegion = {
left: 0,
top: 0,
right: clientWidth,
bottom: clientHeight
};
var scrollRegion = {
left: -scrollLeft,
top: -scrollTop,
right: scrollWidth - scrollLeft,
bottom: scrollHeight - scrollTop
};
var htmlRegion = placementInfo.htmlRegion;
var VISIBLE = "visible";
var VISIBLE_FIRST = "visibleFirst";
if (htmlRegion !== "scroll" && htmlRegion !== VISIBLE_FIRST) {
htmlRegion = VISIBLE;
}
var isVisibleFirst = htmlRegion === VISIBLE_FIRST;
var scrollRegionArea = getVisibleArea(scrollRegion, scrollerList);
var visibleRegionArea = getVisibleArea(visibleRegion, scrollerList);
var visibleArea = htmlRegion === VISIBLE ? visibleRegionArea : scrollRegionArea;
var adjustCheckVisibleArea = isVisibleFirst ? visibleRegionArea : visibleArea;
popupElement.style.left = "auto";
popupElement.style.top = "auto";
popupElement.style.right = "0";
popupElement.style.bottom = "0";
var popupMirrorRect = popupElement.getBoundingClientRect();
popupElement.style.left = originLeft;
popupElement.style.top = originTop;
popupElement.style.right = originRight;
popupElement.style.bottom = originBottom;
popupElement.style.overflow = originOverflow;
(_popupElement$parentE2 = popupElement.parentElement) === null || _popupElement$parentE2 === void 0 || _popupElement$parentE2.removeChild(placeholderElement);
var _scaleX = toNum(Math.round(popupWidth / parseFloat(width) * 1e3) / 1e3);
var _scaleY = toNum(Math.round(popupHeight / parseFloat(height) * 1e3) / 1e3);
if (_scaleX === 0 || _scaleY === 0 || isDOM(target) && !isVisible(target)) {
return;
}
var offset = placementInfo.offset, targetOffset = placementInfo.targetOffset;
var _getNumberOffset = getNumberOffset(popupRect, offset), _getNumberOffset2 = _slicedToArray(_getNumberOffset, 2), popupOffsetX = _getNumberOffset2[0], popupOffsetY = _getNumberOffset2[1];
var _getNumberOffset3 = getNumberOffset(targetRect, targetOffset), _getNumberOffset4 = _slicedToArray(_getNumberOffset3, 2), targetOffsetX = _getNumberOffset4[0], targetOffsetY = _getNumberOffset4[1];
targetRect.x -= targetOffsetX;
targetRect.y -= targetOffsetY;
var _ref3 = placementInfo.points || [], _ref4 = _slicedToArray(_ref3, 2), popupPoint = _ref4[0], targetPoint = _ref4[1];
var targetPoints = splitPoints(targetPoint);
var popupPoints = splitPoints(popupPoint);
var targetAlignPoint = getAlignPoint(targetRect, targetPoints);
var popupAlignPoint = getAlignPoint(popupRect, popupPoints);
var nextAlignInfo = _objectSpread2({}, placementInfo);
var nextOffsetX = targetAlignPoint.x - popupAlignPoint.x + popupOffsetX;
var nextOffsetY = targetAlignPoint.y - popupAlignPoint.y + popupOffsetY;
var originIntersectionVisibleArea = getIntersectionVisibleArea(nextOffsetX, nextOffsetY);
var originIntersectionRecommendArea = getIntersectionVisibleArea(nextOffsetX, nextOffsetY, visibleRegionArea);
var targetAlignPointTL = getAlignPoint(targetRect, ["t", "l"]);
var popupAlignPointTL = getAlignPoint(popupRect, ["t", "l"]);
var targetAlignPointBR = getAlignPoint(targetRect, ["b", "r"]);
var popupAlignPointBR = getAlignPoint(popupRect, ["b", "r"]);
var overflow = placementInfo.overflow || {};
var adjustX = overflow.adjustX, adjustY = overflow.adjustY, shiftX = overflow.shiftX, shiftY = overflow.shiftY;
var supportAdjust = function supportAdjust2(val) {
if (typeof val === "boolean") {
return val;
}
return val >= 0;
};
var nextPopupY;
var nextPopupBottom;
var nextPopupX;
var nextPopupRight;
syncNextPopupPosition();
var needAdjustY = supportAdjust(adjustY);
var sameTB = popupPoints[0] === targetPoints[0];
if (needAdjustY && popupPoints[0] === "t" && (nextPopupBottom > adjustCheckVisibleArea.bottom || prevFlipRef.current.bt)) {
var tmpNextOffsetY = nextOffsetY;
if (sameTB) {
tmpNextOffsetY -= popupHeight - targetHeight;
} else {
tmpNextOffsetY = targetAlignPointTL.y - popupAlignPointBR.y - popupOffsetY;
}
var newVisibleArea = getIntersectionVisibleArea(nextOffsetX, tmpNextOffsetY);
var newVisibleRecommendArea = getIntersectionVisibleArea(nextOffsetX, tmpNextOffsetY, visibleRegionArea);
if (
// Of course use larger one
newVisibleArea > originIntersectionVisibleArea || newVisibleArea === originIntersectionVisibleArea && (!isVisibleFirst || // Choose recommend one
newVisibleRecommendArea >= originIntersectionRecommendArea)
) {
prevFlipRef.current.bt = true;
nextOffsetY = tmpNextOffsetY;
popupOffsetY = -popupOffsetY;
nextAlignInfo.points = [reversePoints(popupPoints, 0), reversePoints(targetPoints, 0)];
} else {
prevFlipRef.current.bt = false;
}
}
if (needAdjustY && popupPoints[0] === "b" && (nextPopupY < adjustCheckVisibleArea.top || prevFlipRef.current.tb)) {
var _tmpNextOffsetY = nextOffsetY;
if (sameTB) {
_tmpNextOffsetY += popupHeight - targetHeight;
} else {
_tmpNextOffsetY = targetAlignPointBR.y - popupAlignPointTL.y - popupOffsetY;
}
var _newVisibleArea = getIntersectionVisibleArea(nextOffsetX, _tmpNextOffsetY);
var _newVisibleRecommendArea = getIntersectionVisibleArea(nextOffsetX, _tmpNextOffsetY, visibleRegionArea);
if (
// Of course use larger one
_newVisibleArea > originIntersectionVisibleArea || _newVisibleArea === originIntersectionVisibleArea && (!isVisibleFirst || // Choose recommend one
_newVisibleRecommendArea >= originIntersectionRecommendArea)
) {
prevFlipRef.current.tb = true;
nextOffsetY = _tmpNextOffsetY;
popupOffsetY = -popupOffsetY;
nextAlignInfo.points = [reversePoints(popupPoints, 0), reversePoints(targetPoints, 0)];
} else {
prevFlipRef.current.tb = false;
}
}
var needAdjustX = supportAdjust(adjustX);
var sameLR = popupPoints[1] === targetPoints[1];
if (needAdjustX && popupPoints[1] === "l" && (nextPopupRight > adjustCheckVisibleArea.right || prevFlipRef.current.rl)) {
var tmpNextOffsetX = nextOffsetX;
if (sameLR) {
tmpNextOffsetX -= popupWidth - targetWidth;
} else {
tmpNextOffsetX = targetAlignPointTL.x - popupAlignPointBR.x - popupOffsetX;
}
var _newVisibleArea2 = getIntersectionVisibleArea(tmpNextOffsetX, nextOffsetY);
var _newVisibleRecommendArea2 = getIntersectionVisibleArea(tmpNextOffsetX, nextOffsetY, visibleRegionArea);
if (
// Of course use larger one
_newVisibleArea2 > originIntersectionVisibleArea || _newVisibleArea2 === originIntersectionVisibleArea && (!isVisibleFirst || // Choose recommend one
_newVisibleRecommendArea2 >= originIntersectionRecommendArea)
) {
prevFlipRef.current.rl = true;
nextOffsetX = tmpNextOffsetX;
popupOffsetX = -popupOffsetX;
nextAlignInfo.points = [reversePoints(popupPoints, 1), reversePoints(targetPoints, 1)];
} else {
prevFlipRef.current.rl = false;
}
}
if (needAdjustX && popupPoints[1] === "r" && (nextPopupX < adjustCheckVisibleArea.left || prevFlipRef.current.lr)) {
var _tmpNextOffsetX = nextOffsetX;
if (sameLR) {
_tmpNextOffsetX += popupWidth - targetWidth;
} else {
_tmpNextOffsetX = targetAlignPointBR.x - popupAlignPointTL.x - popupOffsetX;
}
var _newVisibleArea3 = getIntersectionVisibleArea(_tmpNextOffsetX, nextOffsetY);
var _newVisibleRecommendArea3 = getIntersectionVisibleArea(_tmpNextOffsetX, nextOffsetY, visibleRegionArea);
if (
// Of course use larger one
_newVisibleArea3 > originIntersectionVisibleArea || _newVisibleArea3 === originIntersectionVisibleArea && (!isVisibleFirst || // Choose recommend one
_newVisibleRecommendArea3 >= originIntersectionRecommendArea)
) {
prevFlipRef.current.lr = true;
nextOffsetX = _tmpNextOffsetX;
popupOffsetX = -popupOffsetX;
nextAlignInfo.points = [reversePoints(popupPoints, 1), reversePoints(targetPoints, 1)];
} else {
prevFlipRef.current.lr = false;
}
}
syncNextPopupPosition();
var numShiftX = shiftX === true ? 0 : shiftX;
if (typeof numShiftX === "number") {
if (nextPopupX < visibleRegionArea.left) {
nextOffsetX -= nextPopupX - visibleRegionArea.left - popupOffsetX;
if (targetRect.x + targetWidth < visibleRegionArea.left + numShiftX) {
nextOffsetX += targetRect.x - visibleRegionArea.left + targetWidth - numShiftX;
}
}
if (nextPopupRight > visibleRegionArea.right) {
nextOffsetX -= nextPopupRight - visibleRegionArea.right - popupOffsetX;
if (targetRect.x > visibleRegionArea.right - numShiftX) {
nextOffsetX += targetRect.x - visibleRegionArea.right + numShiftX;
}
}
}
var numShiftY = shiftY === true ? 0 : shiftY;
if (typeof numShiftY === "number") {
if (nextPopupY < visibleRegionArea.top) {
nextOffsetY -= nextPopupY - visibleRegionArea.top - popupOffsetY;
if (targetRect.y + targetHeight < visibleRegionArea.top + numShiftY) {
nextOffsetY += targetRect.y - visibleRegionArea.top + targetHeight - numShiftY;
}
}
if (nextPopupBottom > visibleRegionArea.bottom) {
nextOffsetY -= nextPopupBottom - visibleRegionArea.bottom - popupOffsetY;
if (targetRect.y > visibleRegionArea.bottom - numShiftY) {
nextOffsetY += targetRect.y - visibleRegionArea.bottom + numShiftY;
}
}
}
var popupLeft = popupRect.x + nextOffsetX;
var popupRight = popupLeft + popupWidth;
var popupTop = popupRect.y + nextOffsetY;
var popupBottom = popupTop + popupHeight;
var targetLeft = targetRect.x;
var targetRight = targetLeft + targetWidth;
var targetTop = targetRect.y;
var targetBottom = targetTop + targetHeight;
var maxLeft = Math.max(popupLeft, targetLeft);
var minRight = Math.min(popupRight, targetRight);
var xCenter = (maxLeft + minRight) / 2;
var nextArrowX = xCenter - popupLeft;
var maxTop = Math.max(popupTop, targetTop);
var minBottom = Math.min(popupBottom, targetBottom);
var yCenter = (maxTop + minBottom) / 2;
var nextArrowY = yCenter - popupTop;
onPopupAlign === null || onPopupAlign === void 0 || onPopupAlign(popupEle, nextAlignInfo);
var offsetX4Right = popupMirrorRect.right - popupRect.x - (nextOffsetX + popupRect.width);
var offsetY4Bottom = popupMirrorRect.bottom - popupRect.y - (nextOffsetY + popupRect.height);
if (_scaleX === 1) {
nextOffsetX = Math.round(nextOffsetX);
offsetX4Right = Math.round(offsetX4Right);
}
if (_scaleY === 1) {
nextOffsetY = Math.round(nextOffsetY);
offsetY4Bottom = Math.round(offsetY4Bottom);
}
var nextOffsetInfo = {
ready: true,
offsetX: nextOffsetX / _scaleX,
offsetY: nextOffsetY / _scaleY,
offsetR: offsetX4Right / _scaleX,
offsetB: offsetY4Bottom / _scaleY,
arrowX: nextArrowX / _scaleX,
arrowY: nextArrowY / _scaleY,
scaleX: _scaleX,
scaleY: _scaleY,
align: nextAlignInfo
};
setOffsetInfo(nextOffsetInfo);
}
});
var triggerAlign = function triggerAlign2() {
alignCountRef.current += 1;
var id = alignCountRef.current;
Promise.resolve().then(function() {
if (alignCountRef.current === id) {
onAlign();
}
});
};
var resetReady = function resetReady2() {
setOffsetInfo(function(ori) {
return _objectSpread2(_objectSpread2({}, ori), {}, {
ready: false
});
});
};
useLayoutEffect(resetReady, [placement]);
useLayoutEffect(function() {
if (!open) {
resetReady();
}
}, [open]);
return [offsetInfo.ready, offsetInfo.offsetX, offsetInfo.offsetY, offsetInfo.offsetR, offsetInfo.offsetB, offsetInfo.arrowX, offsetInfo.arrowY, offsetInfo.scaleX, offsetInfo.scaleY, offsetInfo.align, triggerAlign];
}
function useWatch$1(open, target, popup, onAlign, onScroll) {
useLayoutEffect(function() {
if (open && target && popup) {
let notifyScroll = function() {
onAlign();
onScroll();
};
var targetElement = target;
var popupElement = popup;
var targetScrollList = collectScroller(targetElement);
var popupScrollList = collectScroller(popupElement);
var win = getWin(popupElement);
var mergedList = new Set([win].concat(_toConsumableArray(targetScrollList), _toConsumableArray(popupScrollList)));
mergedList.forEach(function(scroller) {
scroller.addEventListener("scroll", notifyScroll, {
passive: true
});
});
win.addEventListener("resize", notifyScroll, {
passive: true
});
onAlign();
return function() {
mergedList.forEach(function(scroller) {
scroller.removeEventListener("scroll", notifyScroll);
win.removeEventListener("resize", notifyScroll);
});
};
}
}, [open, target, popup]);
}
function useWinClick(open, clickToHide, targetEle, popupEle, mask, maskClosable, inPopupOrChild, triggerOpen) {
var openRef = React.useRef(open);
openRef.current = open;
React.useEffect(function() {
if (clickToHide && popupEle && (!mask || maskClosable)) {
var onTriggerClose = function onTriggerClose2(_ref) {
var target = _ref.target;
if (openRef.current && !inPopupOrChild(target)) {
triggerOpen(false);
}
};
var win = getWin(popupEle);
win.addEventListener("mousedown", onTriggerClose, true);
win.addEventListener("contextmenu", onTriggerClose, true);
var targetShadowRoot = getShadowRoot(targetEle);
if (targetShadowRoot) {
targetShadowRoot.addEventListener("mousedown", onTriggerClose, true);
targetShadowRoot.addEventListener("contextmenu", onTriggerClose, true);
}
if (process.env.NODE_ENV !== "production") {
var _targetEle$getRootNod, _popupEle$getRootNode;
var targetRoot = targetEle === null || targetEle === void 0 || (_targetEle$getRootNod = targetEle.getRootNode) === null || _targetEle$getRootNod === void 0 ? void 0 : _targetEle$getRootNod.call(targetEle);
var popupRoot = (_popupEle$getRootNode = popupEle.getRootNode) === null || _popupEle$getRootNode === void 0 ? void 0 : _popupEle$getRootNode.call(popupEle);
warning$4(targetRoot === popupRoot, "trigger element and popup element should in same shadow root.");
}
return function() {
win.removeEventListener("mousedown", onTriggerClose, true);
win.removeEventListener("contextmenu", onTriggerClose, true);
if (targetShadowRoot) {
targetShadowRoot.removeEventListener("mousedown", onTriggerClose, true);
targetShadowRoot.removeEventListener("contextmenu", onTriggerClose, true);
}
};
}
}, [clickToHide, targetEle, popupEle, mask, maskClosable]);
}
var _excluded$a = ["prefixCls", "children", "action", "showAction", "hideAction", "popupVisible", "defaultPopupVisible", "onPopupVisibleChange", "afterPopupVisibleChange", "mouseEnterDelay", "mouseLeaveDelay", "focusDelay", "blurDelay", "mask", "maskClosable", "getPopupContainer", "forceRender", "autoDestroy", "destroyPopupOnHide", "popup", "popupClassName", "popupStyle", "popupPlacement", "builtinPlacements", "popupAlign", "zIndex", "stretch", "getPopupClassNameFromAlign", "fresh", "alignPoint", "onPopupClick", "onPopupAlign", "arrow", "popupMotion", "maskMotion", "popupTransitionName", "popupAnimation", "maskTransitionName", "maskAnimation", "className", "getTriggerDOMNode"];
function generateTrigger() {
var PortalComponent = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : Portal;
var Trigger2 = /* @__PURE__ */ React.forwardRef(function(props, ref) {
var _props$prefixCls = props.prefixCls, prefixCls = _props$prefixCls === void 0 ? "rc-trigger-popup" : _props$prefixCls, children = props.children, _props$action = props.action, action = _props$action === void 0 ? "hover" : _props$action, showAction = props.showAction, hideAction = props.hideAction, popupVisible = props.popupVisible, defaultPopupVisible = props.defaultPopupVisible, onPopupVisibleChange = props.onPopupVisibleChange, afterPopupVisibleChange = props.afterPopupVisibleChange, mouseEnterDelay = props.mouseEnterDelay, _props$mouseLeaveDela = props.mouseLeaveDelay, mouseLeaveDelay = _props$mouseLeaveDela === void 0 ? 0.1 : _props$mouseLeaveDela, focusDelay = props.focusDelay, blurDelay = props.blurDelay, mask = props.mask, _props$maskClosable = props.maskClosable, maskClosable = _props$maskClosable === void 0 ? true : _props$maskClosable, getPopupContainer = props.getPopupContainer, forceRender = props.forceRender, autoDestroy = props.autoDestroy, destroyPopupOnHide = props.destroyPopupOnHide, popup = props.popup, popupClassName = props.popupClassName, popupStyle = props.popupStyle, popupPlacement = props.popupPlacement, _props$builtinPlaceme = props.builtinPlacements, builtinPlacements = _props$builtinPlaceme === void 0 ? {} : _props$builtinPlaceme, popupAlign = props.popupAlign, zIndex = props.zIndex, stretch = props.stretch, getPopupClassNameFromAlign = props.getPopupClassNameFromAlign, fresh = props.fresh, alignPoint = props.alignPoint, onPopupClick = props.onPopupClick, onPopupAlign = props.onPopupAlign, arrow = props.arrow, popupMotion = props.popupMotion, maskMotion = props.maskMotion, popupTransitionName = props.popupTransitionName, popupAnimation = props.popupAnimation, maskTransitionName = props.maskTransitionName, maskAnimation = props.maskAnimation, className = props.className, getTriggerDOMNode = props.getTriggerDOMNode, restProps = _objectWithoutProperties(props, _excluded$a);
var mergedAutoDestroy = autoDestroy || destroyPopupOnHide || false;
var _React$useState = React.useState(false), _React$useState2 = _slicedToArray(_React$useState, 2), mobile = _React$useState2[0], setMobile = _React$useState2[1];
useLayoutEffect(function() {
setMobile(isMobile());
}, []);
var subPopupElements = React.useRef({});
var parentContext = React.useContext(TriggerContext);
var context = React.useMemo(function() {
return {
registerSubPopup: function registerSubPopup(id2, subPopupEle) {
subPopupElements.current[id2] = subPopupEle;
parentContext === null || parentContext === void 0 || parentContext.registerSubPopup(id2, subPopupEle);
}
};
}, [parentContext]);
var id = useId$1();
var _React$useState3 = React.useState(null), _React$useState4 = _slicedToArray(_React$useState3, 2), popupEle = _React$useState4[0], setPopupEle = _React$useState4[1];
var externalPopupRef = React.useRef(null);
var setPopupRef = useEvent(function(node2) {
externalPopupRef.current = node2;
if (isDOM(node2) && popupEle !== node2) {
setPopupEle(node2);
}
parentContext === null || parentContext === void 0 || parentContext.registerSubPopup(id, node2);
});
var _React$useState5 = React.useState(null), _React$useState6 = _slicedToArray(_React$useState5, 2), targetEle = _React$useState6[0], setTargetEle = _React$useState6[1];
var externalForwardRef = React.useRef(null);
var setTargetRef = useEvent(function(node2) {
if (isDOM(node2) && targetEle !== node2) {
setTargetEle(node2);
externalForwardRef.current = node2;
}
});
var child = React.Children.only(children);
var originChildProps = (child === null || child === void 0 ? void 0 : child.props) || {};
var cloneProps = {};
var inPopupOrChild = useEvent(function(ele) {
var _getShadowRoot, _getShadowRoot2;
var childDOM = targetEle;
return (childDOM === null || childDOM === void 0 ? void 0 : childDOM.contains(ele)) || ((_getShadowRoot = getShadowRoot(childDOM)) === null || _getShadowRoot === void 0 ? void 0 : _getShadowRoot.host) === ele || ele === childDOM || (popupEle === null || popupEle === void 0 ? void 0 : popupEle.contains(ele)) || ((_getShadowRoot2 = getShadowRoot(popupEle)) === null || _getShadowRoot2 === void 0 ? void 0 : _getShadowRoot2.host) === ele || ele === popupEle || Object.values(subPopupElements.current).some(function(subPopupEle) {
return (subPopupEle === null || subPopupEle === void 0 ? void 0 : subPopupEle.contains(ele)) || ele === subPopupEle;
});
});
var mergePopupMotion = getMotion(prefixCls, popupMotion, popupAnimation, popupTransitionName);
var mergeMaskMotion = getMotion(prefixCls, maskMotion, maskAnimation, maskTransitionName);
var _React$useState7 = React.useState(defaultPopupVisible || false), _React$useState8 = _slicedToArray(_React$useState7, 2), internalOpen = _React$useState8[0], setInternalOpen = _React$useState8[1];
var mergedOpen = popupVisible !== null && popupVisible !== void 0 ? popupVisible : internalOpen;
var setMergedOpen = useEvent(function(nextOpen) {
if (popupVisible === void 0) {
setInternalOpen(nextOpen);
}
});
useLayoutEffect(function() {
setInternalOpen(popupVisible || false);
}, [popupVisible]);
var openRef = React.useRef(mergedOpen);
openRef.current = mergedOpen;
var lastTriggerRef = React.useRef([]);
lastTriggerRef.current = [];
var internalTriggerOpen = useEvent(function(nextOpen) {
var _lastTriggerRef$curre;
setMergedOpen(nextOpen);
if (((_lastTriggerRef$curre = lastTriggerRef.current[lastTriggerRef.current.length - 1]) !== null && _lastTriggerRef$curre !== void 0 ? _lastTriggerRef$curre : mergedOpen) !== nextOpen) {
lastTriggerRef.current.push(nextOpen);
onPopupVisibleChange === null || onPopupVisibleChange === void 0 || onPopupVisibleChange(nextOpen);
}
});
var delayRef = React.useRef();
var clearDelay = function clearDelay2() {
clearTimeout(delayRef.current);
};
var triggerOpen = function triggerOpen2(nextOpen) {
var delay = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
clearDelay();
if (delay === 0) {
internalTriggerOpen(nextOpen);
} else {
delayRef.current = setTimeout(function() {
internalTriggerOpen(nextOpen);
}, delay * 1e3);
}
};
React.useEffect(function() {
return clearDelay;
}, []);
var _React$useState9 = React.useState(false), _React$useState10 = _slicedToArray(_React$useState9, 2), inMotion = _React$useState10[0], setInMotion = _React$useState10[1];
useLayoutEffect(function(firstMount) {
if (!firstMount || mergedOpen) {
setInMotion(true);
}
}, [mergedOpen]);
var _React$useState11 = React.useState(null), _React$useState12 = _slicedToArray(_React$useState11, 2), motionPrepareResolve = _React$useState12[0], setMotionPrepareResolve = _React$useState12[1];
var _React$useState13 = React.useState([0, 0]), _React$useState14 = _slicedToArray(_React$useState13, 2), mousePos = _React$useState14[0], setMousePos = _React$useState14[1];
var setMousePosByEvent = function setMousePosByEvent2(event) {
setMousePos([event.clientX, event.clientY]);
};
var _useAlign = useAlign(mergedOpen, popupEle, alignPoint ? mousePos : targetEle, popupPlacement, builtinPlacements, popupAlign, onPopupAlign), _useAlign2 = _slicedToArray(_useAlign, 11), ready = _useAlign2[0], offsetX = _useAlign2[1], offsetY = _useAlign2[2], offsetR = _useAlign2[3], offsetB = _useAlign2[4], arrowX = _useAlign2[5], arrowY = _useAlign2[6], scaleX = _useAlign2[7], scaleY = _useAlign2[8], alignInfo = _useAlign2[9], onAlign = _useAlign2[10];
var _useAction = useAction(mobile, action, showAction, hideAction), _useAction2 = _slicedToArray(_useAction, 2), showActions = _useAction2[0], hideActions = _useAction2[1];
var clickToShow = showActions.has("click");
var clickToHide = hideActions.has("click") || hideActions.has("contextMenu");
var triggerAlign = useEvent(function() {
if (!inMotion) {
onAlign();
}
});
var onScroll = function onScroll2() {
if (openRef.current && alignPoint && clickToHide) {
triggerOpen(false);
}
};
useWatch$1(mergedOpen, targetEle, popupEle, triggerAlign, onScroll);
useLayoutEffect(function() {
triggerAlign();
}, [mousePos, popupPlacement]);
useLayoutEffect(function() {
if (mergedOpen && !(builtinPlacements !== null && builtinPlacements !== void 0 && builtinPlacements[popupPlacement])) {
triggerAlign();
}
}, [JSON.stringify(popupAlign)]);
var alignedClassName = React.useMemo(function() {
var baseClassName = getAlignPopupClassName(builtinPlacements, prefixCls, alignInfo, alignPoint);
return classNames(baseClassName, getPopupClassNameFromAlign === null || getPopupClassNameFromAlign === void 0 ? void 0 : getPopupClassNameFromAlign(alignInfo));
}, [alignInfo, getPopupClassNameFromAlign, builtinPlacements, prefixCls, alignPoint]);
React.useImperativeHandle(ref, function() {
return {
nativeElement: externalForwardRef.current,
popupElement: externalPopupRef.current,
forceAlign: triggerAlign
};
});
var _React$useState15 = React.useState(0), _React$useState16 = _slicedToArray(_React$useState15, 2), targetWidth = _React$useState16[0], setTargetWidth = _React$useState16[1];
var _React$useState17 = React.useState(0), _React$useState18 = _slicedToArray(_React$useState17, 2), targetHeight = _React$useState18[0], setTargetHeight = _React$useState18[1];
var syncTargetSize = function syncTargetSize2() {
if (stretch && targetEle) {
var rect = targetEle.getBoundingClientRect();
setTargetWidth(rect.width);
setTargetHeight(rect.height);
}
};
var onTargetResize = function onTargetResize2() {
syncTargetSize();
triggerAlign();
};
var onVisibleChanged = function onVisibleChanged2(visible) {
setInMotion(false);
onAlign();
afterPopupVisibleChange === null || afterPopupVisibleChange === void 0 || afterPopupVisibleChange(visible);
};
var onPrepare = function onPrepare2() {
return new Promise(function(resolve) {
syncTargetSize();
setMotionPrepareResolve(function() {
return resolve;
});
});
};
useLayoutEffect(function() {
if (motionPrepareResolve) {
onAlign();
motionPrepareResolve();
setMotionPrepareResolve(null);
}
}, [motionPrepareResolve]);
function wrapperAction(eventName, nextOpen, delay, preEvent) {
cloneProps[eventName] = function(event) {
var _originChildProps$eve;
preEvent === null || preEvent === void 0 || preEvent(event);
triggerOpen(nextOpen, delay);
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
(_originChildProps$eve = originChildProps[eventName]) === null || _originChildProps$eve === void 0 || _originChildProps$eve.call.apply(_originChildProps$eve, [originChildProps, event].concat(args));
};
}
if (clickToShow || clickToHide) {
cloneProps.onClick = function(event) {
var _originChildProps$onC;
if (openRef.current && clickToHide) {
triggerOpen(false);
} else if (!openRef.current && clickToShow) {
setMousePosByEvent(event);
triggerOpen(true);
}
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
args[_key2 - 1] = arguments[_key2];
}
(_originChildProps$onC = originChildProps.onClick) === null || _originChildProps$onC === void 0 || _originChildProps$onC.call.apply(_originChildProps$onC, [originChildProps, event].concat(args));
};
}
useWinClick(mergedOpen, clickToHide, targetEle, popupEle, mask, maskClosable, inPopupOrChild, triggerOpen);
var hoverToShow = showActions.has("hover");
var hoverToHide = hideActions.has("hover");
var onPopupMouseEnter;
var onPopupMouseLeave;
if (hoverToShow) {
wrapperAction("onMouseEnter", true, mouseEnterDelay, function(event) {
setMousePosByEvent(event);
});
wrapperAction("onPointerEnter", true, mouseEnterDelay, function(event) {
setMousePosByEvent(event);
});
onPopupMouseEnter = function onPopupMouseEnter2(event) {
if ((mergedOpen || inMotion) && popupEle !== null && popupEle !== void 0 && popupEle.contains(event.target)) {
triggerOpen(true, mouseEnterDelay);
}
};
if (alignPoint) {
cloneProps.onMouseMove = function(event) {
var _originChildProps$onM;
(_originChildProps$onM = originChildProps.onMouseMove) === null || _originChildProps$onM === void 0 || _originChildProps$onM.call(originChildProps, event);
};
}
}
if (hoverToHide) {
wrapperAction("onMouseLeave", false, mouseLeaveDelay);
wrapperAction("onPointerLeave", false, mouseLeaveDelay);
onPopupMouseLeave = function onPopupMouseLeave2() {
triggerOpen(false, mouseLeaveDelay);
};
}
if (showActions.has("focus")) {
wrapperAction("onFocus", true, focusDelay);
}
if (hideActions.has("focus")) {
wrapperAction("onBlur", false, blurDelay);
}
if (showActions.has("contextMenu")) {
cloneProps.onContextMenu = function(event) {
var _originChildProps$onC2;
if (openRef.current && hideActions.has("contextMenu")) {
triggerOpen(false);
} else {
setMousePosByEvent(event);
triggerOpen(true);
}
event.preventDefault();
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
args[_key3 - 1] = arguments[_key3];
}
(_originChildProps$onC2 = originChildProps.onContextMenu) === null || _originChildProps$onC2 === void 0 || _originChildProps$onC2.call.apply(_originChildProps$onC2, [originChildProps, event].concat(args));
};
}
if (className) {
cloneProps.className = classNames(originChildProps.className, className);
}
var mergedChildrenProps = _objectSpread2(_objectSpread2({}, originChildProps), cloneProps);
var passedProps = {};
var passedEventList = ["onContextMenu", "onClick", "onMouseDown", "onTouchStart", "onMouseEnter", "onMouseLeave", "onFocus", "onBlur"];
passedEventList.forEach(function(eventName) {
if (restProps[eventName]) {
passedProps[eventName] = function() {
var _mergedChildrenProps$;
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
args[_key4] = arguments[_key4];
}
(_mergedChildrenProps$ = mergedChildrenProps[eventName]) === null || _mergedChildrenProps$ === void 0 || _mergedChildrenProps$.call.apply(_mergedChildrenProps$, [mergedChildrenProps].concat(args));
restProps[eventName].apply(restProps, args);
};
}
});
var triggerNode = /* @__PURE__ */ React.cloneElement(child, _objectSpread2(_objectSpread2({}, mergedChildrenProps), passedProps));
var arrowPos = {
x: arrowX,
y: arrowY
};
var innerArrow = arrow ? _objectSpread2({}, arrow !== true ? arrow : {}) : null;
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(RefResizeObserver, {
disabled: !mergedOpen,
ref: setTargetRef,
onResize: onTargetResize
}, /* @__PURE__ */ React.createElement(TriggerWrapper, {
getTriggerDOMNode
}, triggerNode)), /* @__PURE__ */ React.createElement(TriggerContext.Provider, {
value: context
}, /* @__PURE__ */ React.createElement(Popup$1, {
portal: PortalComponent,
ref: setPopupRef,
prefixCls,
popup,
className: classNames(popupClassName, alignedClassName),
style: popupStyle,
target: targetEle,
onMouseEnter: onPopupMouseEnter,
onMouseLeave: onPopupMouseLeave,
onPointerEnter: onPopupMouseEnter,
zIndex,
open: mergedOpen,
keepDom: inMotion,
fresh,
onClick: onPopupClick,
mask,
motion: mergePopupMotion,
maskMotion: mergeMaskMotion,
onVisibleChanged,
onPrepare,
forceRender,
autoDestroy: mergedAutoDestroy,
getPopupContainer,
align: alignInfo,
arrow: innerArrow,
arrowPos,
ready,
offsetX,
offsetY,
offsetR,
offsetB,
onAlign: triggerAlign,
stretch,
targetWidth: targetWidth / scaleX,
targetHeight: targetHeight / scaleY
})));
});
if (process.env.NODE_ENV !== "production") {
Trigger2.displayName = "Trigger";
}
return Trigger2;
}
const Trigger = generateTrigger(Portal);
function getRealPlacement(placement, rtl) {
if (placement !== void 0) {
return placement;
}
return rtl ? "bottomRight" : "bottomLeft";
}
function getoffsetUnit(placement, rtl) {
var realPlacement = getRealPlacement(placement, rtl);
var placementRight = realPlacement === null || realPlacement === void 0 ? void 0 : realPlacement.toLowerCase().endsWith("right");
var offsetUnit = placementRight ? "insetInlineEnd" : "insetInlineStart";
if (rtl) {
offsetUnit = ["insetInlineStart", "insetInlineEnd"].find(function(unit2) {
return unit2 !== offsetUnit;
});
}
return offsetUnit;
}
var PickerContext = /* @__PURE__ */ React.createContext(null);
var BUILT_IN_PLACEMENTS = {
bottomLeft: {
points: ["tl", "bl"],
offset: [0, 4],
overflow: {
adjustX: 1,
adjustY: 1
}
},
bottomRight: {
points: ["tr", "br"],
offset: [0, 4],
overflow: {
adjustX: 1,
adjustY: 1
}
},
topLeft: {
points: ["bl", "tl"],
offset: [0, -4],
overflow: {
adjustX: 0,
adjustY: 1
}
},
topRight: {
points: ["br", "tr"],
offset: [0, -4],
overflow: {
adjustX: 0,
adjustY: 1
}
}
};
function PickerTrigger(_ref) {
var popupElement = _ref.popupElement, popupStyle = _ref.popupStyle, popupClassName = _ref.popupClassName, popupAlign = _ref.popupAlign, transitionName = _ref.transitionName, getPopupContainer = _ref.getPopupContainer, children = _ref.children, range3 = _ref.range, placement = _ref.placement, _ref$builtinPlacement = _ref.builtinPlacements, builtinPlacements = _ref$builtinPlacement === void 0 ? BUILT_IN_PLACEMENTS : _ref$builtinPlacement, direction = _ref.direction, visible = _ref.visible, onClose = _ref.onClose;
var _React$useContext = React.useContext(PickerContext), prefixCls = _React$useContext.prefixCls;
var dropdownPrefixCls = "".concat(prefixCls, "-dropdown");
var realPlacement = getRealPlacement(placement, direction === "rtl");
return /* @__PURE__ */ React.createElement(Trigger, {
showAction: [],
hideAction: ["click"],
popupPlacement: realPlacement,
builtinPlacements,
prefixCls: dropdownPrefixCls,
popupTransitionName: transitionName,
popup: popupElement,
popupAlign,
popupVisible: visible,
popupClassName: classNames(popupClassName, _defineProperty(_defineProperty({}, "".concat(dropdownPrefixCls, "-range"), range3), "".concat(dropdownPrefixCls, "-rtl"), direction === "rtl")),
popupStyle,
stretch: "minWidth",
getPopupContainer,
onPopupVisibleChange: function onPopupVisibleChange(nextVisible) {
if (!nextVisible) {
onClose();
}
}
}, children);
}
function leftPad(str, length2) {
var fill = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "0";
var current = String(str);
while (current.length < length2) {
current = "".concat(fill).concat(current);
}
return current;
}
function toArray$1(val) {
if (val === null || val === void 0) {
return [];
}
return Array.isArray(val) ? val : [val];
}
function fillIndex(ori, index2, value) {
var clone = _toConsumableArray(ori);
clone[index2] = value;
return clone;
}
function pickProps(props, keys2) {
var clone = {};
var mergedKeys = keys2 || Object.keys(props);
mergedKeys.forEach(function(key) {
if (props[key] !== void 0) {
clone[key] = props[key];
}
});
return clone;
}
function getRowFormat(picker, locale2, format2) {
if (format2) {
return format2;
}
switch (picker) {
case "time":
return locale2.fieldTimeFormat;
case "datetime":
return locale2.fieldDateTimeFormat;
case "month":
return locale2.fieldMonthFormat;
case "year":
return locale2.fieldYearFormat;
case "quarter":
return locale2.fieldQuarterFormat;
case "week":
return locale2.fieldWeekFormat;
default:
return locale2.fieldDateFormat;
}
}
function getFromDate(calendarValues, activeIndexList, activeIndex) {
var mergedActiveIndex = activeIndex !== void 0 ? activeIndex : activeIndexList[activeIndexList.length - 1];
var firstValuedIndex = activeIndexList.find(function(index2) {
return calendarValues[index2];
});
return mergedActiveIndex !== firstValuedIndex ? calendarValues[firstValuedIndex] : void 0;
}
function pickTriggerProps(props) {
return pickProps(props, ["placement", "builtinPlacements", "popupAlign", "getPopupContainer", "transitionName", "direction"]);
}
function useCellRender(cellRender, dateRender, monthCellRender, range3) {
if (process.env.NODE_ENV !== "production") {
warningOnce(!dateRender, "'dateRender' is deprecated. Please use 'cellRender' instead.");
warningOnce(!monthCellRender, "'monthCellRender' is deprecated. Please use 'cellRender' instead.");
}
var mergedCellRender = React.useMemo(function() {
if (cellRender) {
return cellRender;
}
return function(current, info) {
var date4 = current;
if (dateRender && info.type === "date") {
return dateRender(date4, info.today);
}
if (monthCellRender && info.type === "month") {
return monthCellRender(date4, info.locale);
}
return info.originNode;
};
}, [cellRender, monthCellRender, dateRender]);
var onInternalCellRender = React.useCallback(function(date4, info) {
return mergedCellRender(date4, _objectSpread2(_objectSpread2({}, info), {}, {
range: range3
}));
}, [mergedCellRender, range3]);
return onInternalCellRender;
}
function useFieldsInvalidate(calendarValue, isInvalidateDate) {
var allowEmpty = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [];
var _React$useState = React.useState([false, false]), _React$useState2 = _slicedToArray(_React$useState, 2), fieldsInvalidates = _React$useState2[0], setFieldsInvalidates = _React$useState2[1];
var onSelectorInvalid = function onSelectorInvalid2(invalid, index2) {
setFieldsInvalidates(function(ori) {
return fillIndex(ori, index2, invalid);
});
};
var submitInvalidates = React.useMemo(function() {
return fieldsInvalidates.map(function(invalid, index2) {
if (invalid) {
return true;
}
var current = calendarValue[index2];
if (!current) {
return false;
}
if (!allowEmpty[index2] && !current) {
return true;
}
if (current && isInvalidateDate(current, {
activeIndex: index2
})) {
return true;
}
return false;
});
}, [calendarValue, fieldsInvalidates, isInvalidateDate, allowEmpty]);
return [submitInvalidates, onSelectorInvalid];
}
function fillTimeFormat(showHour, showMinute, showSecond, showMillisecond, showMeridiem) {
var timeFormat = "";
var cells = [];
if (showHour) {
cells.push(showMeridiem ? "hh" : "HH");
}
if (showMinute) {
cells.push("mm");
}
if (showSecond) {
cells.push("ss");
}
timeFormat = cells.join(":");
if (showMillisecond) {
timeFormat += ".SSS";
}
if (showMeridiem) {
timeFormat += " A";
}
return timeFormat;
}
function fillLocale(locale2, showHour, showMinute, showSecond, showMillisecond, use12Hours) {
var fieldDateTimeFormat = locale2.fieldDateTimeFormat, fieldDateFormat = locale2.fieldDateFormat, fieldTimeFormat = locale2.fieldTimeFormat, fieldMonthFormat = locale2.fieldMonthFormat, fieldYearFormat = locale2.fieldYearFormat, fieldWeekFormat = locale2.fieldWeekFormat, fieldQuarterFormat = locale2.fieldQuarterFormat, yearFormat = locale2.yearFormat, cellYearFormat = locale2.cellYearFormat, cellQuarterFormat = locale2.cellQuarterFormat, dayFormat = locale2.dayFormat, cellDateFormat = locale2.cellDateFormat;
var timeFormat = fillTimeFormat(showHour, showMinute, showSecond, showMillisecond, use12Hours);
return _objectSpread2(_objectSpread2({}, locale2), {}, {
fieldDateTimeFormat: fieldDateTimeFormat || "YYYY-MM-DD ".concat(timeFormat),
fieldDateFormat: fieldDateFormat || "YYYY-MM-DD",
fieldTimeFormat: fieldTimeFormat || timeFormat,
fieldMonthFormat: fieldMonthFormat || "YYYY-MM",
fieldYearFormat: fieldYearFormat || "YYYY",
fieldWeekFormat: fieldWeekFormat || "gggg-wo",
fieldQuarterFormat: fieldQuarterFormat || "YYYY-[Q]Q",
yearFormat: yearFormat || "YYYY",
cellYearFormat: cellYearFormat || "YYYY",
cellQuarterFormat: cellQuarterFormat || "[Q]Q",
cellDateFormat: cellDateFormat || dayFormat || "D"
});
}
function useLocale$1(locale2, showProps) {
var showHour = showProps.showHour, showMinute = showProps.showMinute, showSecond = showProps.showSecond, showMillisecond = showProps.showMillisecond, use12Hours = showProps.use12Hours;
return React__default.useMemo(function() {
return fillLocale(locale2, showHour, showMinute, showSecond, showMillisecond, use12Hours);
}, [locale2, showHour, showMinute, showSecond, showMillisecond, use12Hours]);
}
function checkShow(format2, keywords, show) {
return show !== null && show !== void 0 ? show : keywords.some(function(keyword) {
return format2.includes(keyword);
});
}
var showTimeKeys = [
// 'format',
"showNow",
"showHour",
"showMinute",
"showSecond",
"showMillisecond",
"use12Hours",
"hourStep",
"minuteStep",
"secondStep",
"millisecondStep",
"hideDisabledOptions",
"defaultValue",
"disabledHours",
"disabledMinutes",
"disabledSeconds",
"disabledMilliseconds",
"disabledTime",
"changeOnScroll",
"defaultOpenValue"
];
function pickTimeProps(props) {
var timeProps = pickProps(props, showTimeKeys);
var format2 = props.format, picker = props.picker;
var propFormat = null;
if (format2) {
propFormat = format2;
if (Array.isArray(propFormat)) {
propFormat = propFormat[0];
}
propFormat = _typeof(propFormat) === "object" ? propFormat.format : propFormat;
}
if (picker === "time") {
timeProps.format = propFormat;
}
return [timeProps, propFormat];
}
function isStringFormat(format2) {
return format2 && typeof format2 === "string";
}
function existShowConfig(showHour, showMinute, showSecond, showMillisecond) {
return [showHour, showMinute, showSecond, showMillisecond].some(function(show) {
return show !== void 0;
});
}
function fillShowConfig(hasShowConfig, showHour, showMinute, showSecond, showMillisecond) {
var parsedShowHour = showHour;
var parsedShowMinute = showMinute;
var parsedShowSecond = showSecond;
if (!hasShowConfig && !parsedShowHour && !parsedShowMinute && !parsedShowSecond && !showMillisecond) {
parsedShowHour = true;
parsedShowMinute = true;
parsedShowSecond = true;
} else if (hasShowConfig) {
var _parsedShowHour, _parsedShowMinute, _parsedShowSecond;
var existFalse = [parsedShowHour, parsedShowMinute, parsedShowSecond].some(function(show) {
return show === false;
});
var existTrue = [parsedShowHour, parsedShowMinute, parsedShowSecond].some(function(show) {
return show === true;
});
var defaultShow = existFalse ? true : !existTrue;
parsedShowHour = (_parsedShowHour = parsedShowHour) !== null && _parsedShowHour !== void 0 ? _parsedShowHour : defaultShow;
parsedShowMinute = (_parsedShowMinute = parsedShowMinute) !== null && _parsedShowMinute !== void 0 ? _parsedShowMinute : defaultShow;
parsedShowSecond = (_parsedShowSecond = parsedShowSecond) !== null && _parsedShowSecond !== void 0 ? _parsedShowSecond : defaultShow;
}
return [parsedShowHour, parsedShowMinute, parsedShowSecond, showMillisecond];
}
function getTimeProps(componentProps) {
var showTime = componentProps.showTime;
var _pickTimeProps = pickTimeProps(componentProps), _pickTimeProps2 = _slicedToArray(_pickTimeProps, 2), pickedProps = _pickTimeProps2[0], propFormat = _pickTimeProps2[1];
var showTimeConfig = showTime && _typeof(showTime) === "object" ? showTime : {};
var timeConfig = _objectSpread2(_objectSpread2({
defaultOpenValue: showTimeConfig.defaultOpenValue || showTimeConfig.defaultValue
}, pickedProps), showTimeConfig);
var showMillisecond = timeConfig.showMillisecond;
var showHour = timeConfig.showHour, showMinute = timeConfig.showMinute, showSecond = timeConfig.showSecond;
var hasShowConfig = existShowConfig(showHour, showMinute, showSecond, showMillisecond);
var _fillShowConfig = fillShowConfig(hasShowConfig, showHour, showMinute, showSecond, showMillisecond);
var _fillShowConfig2 = _slicedToArray(_fillShowConfig, 3);
showHour = _fillShowConfig2[0];
showMinute = _fillShowConfig2[1];
showSecond = _fillShowConfig2[2];
return [timeConfig, _objectSpread2(_objectSpread2({}, timeConfig), {}, {
showHour,
showMinute,
showSecond,
showMillisecond
}), timeConfig.format, propFormat];
}
function fillShowTimeConfig(picker, showTimeFormat, propFormat, timeConfig, locale2) {
var isTimePicker = picker === "time";
if (picker === "datetime" || isTimePicker) {
var pickedProps = timeConfig;
var defaultLocaleFormat = getRowFormat(picker, locale2, null);
var baselineFormat = defaultLocaleFormat;
var formatList = [showTimeFormat, propFormat];
for (var i = 0; i < formatList.length; i += 1) {
var format2 = toArray$1(formatList[i])[0];
if (isStringFormat(format2)) {
baselineFormat = format2;
break;
}
}
var showHour = pickedProps.showHour, showMinute = pickedProps.showMinute, showSecond = pickedProps.showSecond, showMillisecond = pickedProps.showMillisecond;
var use12Hours = pickedProps.use12Hours;
var showMeridiem = checkShow(baselineFormat, ["a", "A", "LT", "LLL", "LTS"], use12Hours);
var hasShowConfig = existShowConfig(showHour, showMinute, showSecond, showMillisecond);
if (!hasShowConfig) {
showHour = checkShow(baselineFormat, ["H", "h", "k", "LT", "LLL"]);
showMinute = checkShow(baselineFormat, ["m", "LT", "LLL"]);
showSecond = checkShow(baselineFormat, ["s", "LTS"]);
showMillisecond = checkShow(baselineFormat, ["SSS"]);
}
var _fillShowConfig3 = fillShowConfig(hasShowConfig, showHour, showMinute, showSecond, showMillisecond);
var _fillShowConfig4 = _slicedToArray(_fillShowConfig3, 3);
showHour = _fillShowConfig4[0];
showMinute = _fillShowConfig4[1];
showSecond = _fillShowConfig4[2];
var timeFormat = showTimeFormat || fillTimeFormat(showHour, showMinute, showSecond, showMillisecond, showMeridiem);
return _objectSpread2(_objectSpread2({}, pickedProps), {}, {
// Format
format: timeFormat,
// Show Config
showHour,
showMinute,
showSecond,
showMillisecond,
use12Hours: showMeridiem
});
}
return null;
}
function fillClearIcon(prefixCls, allowClear, clearIcon) {
if (process.env.NODE_ENV !== "production" && clearIcon) {
warningOnce(false, "`clearIcon` will be removed in future. Please use `allowClear` instead.");
}
if (allowClear === false) {
return null;
}
var config = allowClear && _typeof(allowClear) === "object" ? allowClear : {};
return config.clearIcon || clearIcon || /* @__PURE__ */ React.createElement("span", {
className: "".concat(prefixCls, "-clear-btn")
});
}
var WEEK_DAY_COUNT = 7;
function nullableCompare(value1, value2, oriCompareFn) {
if (!value1 && !value2 || value1 === value2) {
return true;
}
if (!value1 || !value2) {
return false;
}
return oriCompareFn();
}
function isSameDecade(generateConfig, decade1, decade2) {
return nullableCompare(decade1, decade2, function() {
var num1 = Math.floor(generateConfig.getYear(decade1) / 10);
var num2 = Math.floor(generateConfig.getYear(decade2) / 10);
return num1 === num2;
});
}
function isSameYear(generateConfig, year1, year2) {
return nullableCompare(year1, year2, function() {
return generateConfig.getYear(year1) === generateConfig.getYear(year2);
});
}
function getQuarter(generateConfig, date4) {
var quota = Math.floor(generateConfig.getMonth(date4) / 3);
return quota + 1;
}
function isSameQuarter(generateConfig, quarter1, quarter2) {
return nullableCompare(quarter1, quarter2, function() {
return isSameYear(generateConfig, quarter1, quarter2) && getQuarter(generateConfig, quarter1) === getQuarter(generateConfig, quarter2);
});
}
function isSameMonth(generateConfig, month1, month2) {
return nullableCompare(month1, month2, function() {
return isSameYear(generateConfig, month1, month2) && generateConfig.getMonth(month1) === generateConfig.getMonth(month2);
});
}
function isSameDate(generateConfig, date1, date22) {
return nullableCompare(date1, date22, function() {
return isSameYear(generateConfig, date1, date22) && isSameMonth(generateConfig, date1, date22) && generateConfig.getDate(date1) === generateConfig.getDate(date22);
});
}
function isSameTime(generateConfig, time1, time2) {
return nullableCompare(time1, time2, function() {
return generateConfig.getHour(time1) === generateConfig.getHour(time2) && generateConfig.getMinute(time1) === generateConfig.getMinute(time2) && generateConfig.getSecond(time1) === generateConfig.getSecond(time2);
});
}
function isSameTimestamp(generateConfig, time1, time2) {
return nullableCompare(time1, time2, function() {
return isSameDate(generateConfig, time1, time2) && isSameTime(generateConfig, time1, time2) && generateConfig.getMillisecond(time1) === generateConfig.getMillisecond(time2);
});
}
function isSameWeek(generateConfig, locale2, date1, date22) {
return nullableCompare(date1, date22, function() {
var weekStartDate1 = generateConfig.locale.getWeekFirstDate(locale2, date1);
var weekStartDate2 = generateConfig.locale.getWeekFirstDate(locale2, date22);
return isSameYear(generateConfig, weekStartDate1, weekStartDate2) && generateConfig.locale.getWeek(locale2, date1) === generateConfig.locale.getWeek(locale2, date22);
});
}
function isSame(generateConfig, locale2, source, target, type4) {
switch (type4) {
case "date":
return isSameDate(generateConfig, source, target);
case "week":
return isSameWeek(generateConfig, locale2.locale, source, target);
case "month":
return isSameMonth(generateConfig, source, target);
case "quarter":
return isSameQuarter(generateConfig, source, target);
case "year":
return isSameYear(generateConfig, source, target);
case "decade":
return isSameDecade(generateConfig, source, target);
case "time":
return isSameTime(generateConfig, source, target);
default:
return isSameTimestamp(generateConfig, source, target);
}
}
function isInRange(generateConfig, startDate, endDate, current) {
if (!startDate || !endDate || !current) {
return false;
}
return generateConfig.isAfter(current, startDate) && generateConfig.isAfter(endDate, current);
}
function isSameOrAfter(generateConfig, locale2, date1, date22, type4) {
if (isSame(generateConfig, locale2, date1, date22, type4)) {
return true;
}
return generateConfig.isAfter(date1, date22);
}
function getWeekStartDate(locale2, generateConfig, value) {
var weekFirstDay = generateConfig.locale.getWeekFirstDay(locale2);
var monthStartDate = generateConfig.setDate(value, 1);
var startDateWeekDay = generateConfig.getWeekDay(monthStartDate);
var alignStartDate = generateConfig.addDate(monthStartDate, weekFirstDay - startDateWeekDay);
if (generateConfig.getMonth(alignStartDate) === generateConfig.getMonth(value) && generateConfig.getDate(alignStartDate) > 1) {
alignStartDate = generateConfig.addDate(alignStartDate, -7);
}
return alignStartDate;
}
function formatValue(value, _ref) {
var generateConfig = _ref.generateConfig, locale2 = _ref.locale, format2 = _ref.format;
if (!value) {
return "";
}
return typeof format2 === "function" ? format2(value) : generateConfig.locale.format(locale2.locale, value, format2);
}
function fillTime(generateConfig, date4, time) {
var tmpDate = date4;
var getFn = ["getHour", "getMinute", "getSecond", "getMillisecond"];
var setFn = ["setHour", "setMinute", "setSecond", "setMillisecond"];
setFn.forEach(function(fn, index2) {
if (time) {
tmpDate = generateConfig[fn](tmpDate, generateConfig[getFn[index2]](time));
} else {
tmpDate = generateConfig[fn](tmpDate, 0);
}
});
return tmpDate;
}
function useDisabledBoundary(generateConfig, locale2, disabledDate, minDate, maxDate) {
var mergedDisabledDate = useEvent(function(date4, info) {
if (disabledDate && disabledDate(date4, info)) {
return true;
}
if (minDate && generateConfig.isAfter(minDate, date4) && !isSame(generateConfig, locale2, minDate, date4, info.type)) {
return true;
}
if (maxDate && generateConfig.isAfter(date4, maxDate) && !isSame(generateConfig, locale2, maxDate, date4, info.type)) {
return true;
}
return false;
});
return mergedDisabledDate;
}
function useFieldFormat(picker, locale2, format2) {
return React.useMemo(function() {
var rawFormat = getRowFormat(picker, locale2, format2);
var formatList = toArray$1(rawFormat);
var firstFormat = formatList[0];
var maskFormat = _typeof(firstFormat) === "object" && firstFormat.type === "mask" ? firstFormat.format : null;
return [
// Format list
formatList.map(function(config) {
return typeof config === "string" || typeof config === "function" ? config : config.format;
}),
// Mask Format
maskFormat
];
}, [picker, locale2, format2]);
}
function useInputReadOnly(formatList, inputReadOnly, multiple) {
if (typeof formatList[0] === "function" || multiple) {
return true;
}
return inputReadOnly;
}
function useInvalidate(generateConfig, picker, disabledDate, showTime) {
var isInvalidate = useEvent(function(date4, info) {
var outsideInfo = _objectSpread2({
type: picker
}, info);
delete outsideInfo.activeIndex;
if (
// Date object is invalid
!generateConfig.isValidate(date4) || // Date is disabled by `disabledDate`
disabledDate && disabledDate(date4, outsideInfo)
) {
return true;
}
if ((picker === "date" || picker === "time") && showTime) {
var _showTime$disabledTim;
var range3 = info && info.activeIndex === 1 ? "end" : "start";
var _ref = ((_showTime$disabledTim = showTime.disabledTime) === null || _showTime$disabledTim === void 0 ? void 0 : _showTime$disabledTim.call(showTime, date4, range3, {
from: outsideInfo.from
})) || {}, disabledHours = _ref.disabledHours, disabledMinutes = _ref.disabledMinutes, disabledSeconds = _ref.disabledSeconds, disabledMilliseconds = _ref.disabledMilliseconds;
var legacyDisabledHours = showTime.disabledHours, legacyDisabledMinutes = showTime.disabledMinutes, legacyDisabledSeconds = showTime.disabledSeconds;
var mergedDisabledHours = disabledHours || legacyDisabledHours;
var mergedDisabledMinutes = disabledMinutes || legacyDisabledMinutes;
var mergedDisabledSeconds = disabledSeconds || legacyDisabledSeconds;
var hour = generateConfig.getHour(date4);
var minute = generateConfig.getMinute(date4);
var second = generateConfig.getSecond(date4);
var millisecond = generateConfig.getMillisecond(date4);
if (mergedDisabledHours && mergedDisabledHours().includes(hour)) {
return true;
}
if (mergedDisabledMinutes && mergedDisabledMinutes(hour).includes(minute)) {
return true;
}
if (mergedDisabledSeconds && mergedDisabledSeconds(hour, minute).includes(second)) {
return true;
}
if (disabledMilliseconds && disabledMilliseconds(hour, minute, second).includes(millisecond)) {
return true;
}
}
return false;
});
return isInvalidate;
}
function useList(value) {
var fillMode = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
var values = React.useMemo(function() {
var list = value ? toArray$1(value) : value;
if (fillMode && list) {
list[1] = list[1] || list[0];
}
return list;
}, [value, fillMode]);
return values;
}
function useFilledProps(props, updater) {
var generateConfig = props.generateConfig, locale2 = props.locale, _props$picker = props.picker, picker = _props$picker === void 0 ? "date" : _props$picker, _props$prefixCls = props.prefixCls, prefixCls = _props$prefixCls === void 0 ? "rc-picker" : _props$prefixCls, _props$styles = props.styles, styles = _props$styles === void 0 ? {} : _props$styles, _props$classNames = props.classNames, classNames2 = _props$classNames === void 0 ? {} : _props$classNames, _props$order = props.order, order = _props$order === void 0 ? true : _props$order, _props$components = props.components, components = _props$components === void 0 ? {} : _props$components, inputRender = props.inputRender, allowClear = props.allowClear, clearIcon = props.clearIcon, needConfirm = props.needConfirm, multiple = props.multiple, format2 = props.format, inputReadOnly = props.inputReadOnly, disabledDate = props.disabledDate, minDate = props.minDate, maxDate = props.maxDate, showTime = props.showTime, value = props.value, defaultValue = props.defaultValue, pickerValue = props.pickerValue, defaultPickerValue = props.defaultPickerValue;
var values = useList(value);
var defaultValues = useList(defaultValue);
var pickerValues = useList(pickerValue);
var defaultPickerValues = useList(defaultPickerValue);
var internalPicker = picker === "date" && showTime ? "datetime" : picker;
var multipleInteractivePicker = internalPicker === "time" || internalPicker === "datetime";
var complexPicker = multipleInteractivePicker || multiple;
var mergedNeedConfirm = needConfirm !== null && needConfirm !== void 0 ? needConfirm : multipleInteractivePicker;
var _getTimeProps = getTimeProps(props), _getTimeProps2 = _slicedToArray(_getTimeProps, 4), timeProps = _getTimeProps2[0], localeTimeProps = _getTimeProps2[1], showTimeFormat = _getTimeProps2[2], propFormat = _getTimeProps2[3];
var mergedLocale = useLocale$1(locale2, localeTimeProps);
var mergedShowTime = React.useMemo(function() {
return fillShowTimeConfig(internalPicker, showTimeFormat, propFormat, timeProps, mergedLocale);
}, [internalPicker, showTimeFormat, propFormat, timeProps, mergedLocale]);
if (process.env.NODE_ENV !== "production" && picker === "time") {
if (["disabledHours", "disabledMinutes", "disabledSeconds"].some(function(key) {
return props[key];
})) {
warningOnce(false, "'disabledHours', 'disabledMinutes', 'disabledSeconds' will be removed in the next major version, please use 'disabledTime' instead.");
}
}
var filledProps = React.useMemo(function() {
return _objectSpread2(_objectSpread2({}, props), {}, {
prefixCls,
locale: mergedLocale,
picker,
styles,
classNames: classNames2,
order,
components: _objectSpread2({
input: inputRender
}, components),
clearIcon: fillClearIcon(prefixCls, allowClear, clearIcon),
showTime: mergedShowTime,
value: values,
defaultValue: defaultValues,
pickerValue: pickerValues,
defaultPickerValue: defaultPickerValues
}, updater === null || updater === void 0 ? void 0 : updater());
}, [props]);
var _useFieldFormat = useFieldFormat(internalPicker, mergedLocale, format2), _useFieldFormat2 = _slicedToArray(_useFieldFormat, 2), formatList = _useFieldFormat2[0], maskFormat = _useFieldFormat2[1];
var mergedInputReadOnly = useInputReadOnly(formatList, inputReadOnly, multiple);
var disabledBoundaryDate = useDisabledBoundary(generateConfig, locale2, disabledDate, minDate, maxDate);
var isInvalidateDate = useInvalidate(generateConfig, picker, disabledBoundaryDate, mergedShowTime);
var mergedProps = React.useMemo(function() {
return _objectSpread2(_objectSpread2({}, filledProps), {}, {
needConfirm: mergedNeedConfirm,
inputReadOnly: mergedInputReadOnly,
disabledDate: disabledBoundaryDate
});
}, [filledProps, mergedNeedConfirm, mergedInputReadOnly, disabledBoundaryDate]);
return [mergedProps, internalPicker, complexPicker, formatList, maskFormat, isInvalidateDate];
}
function useDelayState(value, defaultValue, onChange) {
var _useMergedState = useMergedState(defaultValue, {
value
}), _useMergedState2 = _slicedToArray(_useMergedState, 2), state = _useMergedState2[0], setState = _useMergedState2[1];
var nextValueRef = React__default.useRef(value);
var rafRef = React__default.useRef();
var cancelRaf = function cancelRaf2() {
wrapperRaf.cancel(rafRef.current);
};
var doUpdate = useEvent(function() {
setState(nextValueRef.current);
if (onChange && state !== nextValueRef.current) {
onChange(nextValueRef.current);
}
});
var updateValue = useEvent(function(next2, immediately) {
cancelRaf();
nextValueRef.current = next2;
if (next2 || immediately) {
doUpdate();
} else {
rafRef.current = wrapperRaf(doUpdate);
}
});
React__default.useEffect(function() {
return cancelRaf;
}, []);
return [state, updateValue];
}
function useOpen(open, defaultOpen) {
var disabledList = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [];
var onOpenChange = arguments.length > 3 ? arguments[3] : void 0;
var mergedOpen = disabledList.every(function(disabled) {
return disabled;
}) ? false : open;
var _useDelayState = useDelayState(mergedOpen, defaultOpen || false, onOpenChange), _useDelayState2 = _slicedToArray(_useDelayState, 2), rafOpen = _useDelayState2[0], setRafOpen = _useDelayState2[1];
function setOpen(next2) {
var config = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
if (!config.inherit || rafOpen) {
setRafOpen(next2, config.force);
}
}
return [rafOpen, setOpen];
}
function usePickerRef(ref) {
var selectorRef = React.useRef();
React.useImperativeHandle(ref, function() {
var _selectorRef$current;
return {
nativeElement: (_selectorRef$current = selectorRef.current) === null || _selectorRef$current === void 0 ? void 0 : _selectorRef$current.nativeElement,
focus: function focus(options) {
var _selectorRef$current2;
(_selectorRef$current2 = selectorRef.current) === null || _selectorRef$current2 === void 0 || _selectorRef$current2.focus(options);
},
blur: function blur() {
var _selectorRef$current3;
(_selectorRef$current3 = selectorRef.current) === null || _selectorRef$current3 === void 0 || _selectorRef$current3.blur();
}
};
});
return selectorRef;
}
function usePresets(presets, legacyRanges) {
return React.useMemo(function() {
if (presets) {
return presets;
}
if (legacyRanges) {
warningOnce(false, "`ranges` is deprecated. Please use `presets` instead.");
return Object.entries(legacyRanges).map(function(_ref) {
var _ref2 = _slicedToArray(_ref, 2), label = _ref2[0], value = _ref2[1];
return {
label,
value
};
});
}
return [];
}, [presets, legacyRanges]);
}
function useLockEffect(condition, callback) {
var delayFrames = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1;
var callbackRef = React.useRef(callback);
callbackRef.current = callback;
useLayoutUpdateEffect(function() {
if (condition) {
callbackRef.current(condition);
} else {
var id = wrapperRaf(function() {
callbackRef.current(condition);
}, delayFrames);
return function() {
wrapperRaf.cancel(id);
};
}
}, [condition]);
}
function useRangeActive(disabled) {
var empty = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
var mergedOpen = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
var _React$useState = React.useState(0), _React$useState2 = _slicedToArray(_React$useState, 2), activeIndex = _React$useState2[0], setActiveIndex = _React$useState2[1];
var _React$useState3 = React.useState(false), _React$useState4 = _slicedToArray(_React$useState3, 2), focused = _React$useState4[0], setFocused = _React$useState4[1];
var activeListRef = React.useRef([]);
var lastOperationRef = React.useRef(null);
var triggerFocus = function triggerFocus2(nextFocus) {
setFocused(nextFocus);
};
var lastOperation = function lastOperation2(type4) {
if (type4) {
lastOperationRef.current = type4;
}
return lastOperationRef.current;
};
var nextActiveIndex = function nextActiveIndex2(nextValue) {
var list = activeListRef.current;
var filledActiveSet = new Set(list.filter(function(index2) {
return nextValue[index2] || empty[index2];
}));
var nextIndex = list[list.length - 1] === 0 ? 1 : 0;
if (filledActiveSet.size >= 2 || disabled[nextIndex]) {
return null;
}
return nextIndex;
};
useLockEffect(focused || mergedOpen, function() {
if (!focused) {
activeListRef.current = [];
}
});
React.useEffect(function() {
if (focused) {
activeListRef.current.push(activeIndex);
}
}, [focused, activeIndex]);
return [focused, triggerFocus, lastOperation, activeIndex, setActiveIndex, nextActiveIndex, activeListRef.current];
}
function useRangeDisabledDate(values, disabled, activeIndexList, generateConfig, locale2, disabledDate) {
var activeIndex = activeIndexList[activeIndexList.length - 1];
var rangeDisabledDate = function rangeDisabledDate2(date4, info) {
var _values = _slicedToArray(values, 2), start = _values[0], end = _values[1];
var mergedInfo = _objectSpread2(_objectSpread2({}, info), {}, {
from: getFromDate(values, activeIndexList)
});
if (activeIndex === 1 && disabled[0] && start && // Same date isOK
!isSame(generateConfig, locale2, start, date4, mergedInfo.type) && // Before start date
generateConfig.isAfter(start, date4)) {
return true;
}
if (activeIndex === 0 && disabled[1] && end && // Same date isOK
!isSame(generateConfig, locale2, end, date4, mergedInfo.type) && // After end date
generateConfig.isAfter(date4, end)) {
return true;
}
return disabledDate === null || disabledDate === void 0 ? void 0 : disabledDate(date4, mergedInfo);
};
return rangeDisabledDate;
}
function offsetPanelDate(generateConfig, picker, date4, offset) {
switch (picker) {
case "date":
case "week":
return generateConfig.addMonth(date4, offset);
case "month":
case "quarter":
return generateConfig.addYear(date4, offset);
case "year":
return generateConfig.addYear(date4, offset * 10);
case "decade":
return generateConfig.addYear(date4, offset * 100);
default:
return date4;
}
}
var EMPTY_LIST = [];
function useRangePickerValue(generateConfig, locale2, calendarValue, modes, open, activeIndex, pickerMode, multiplePanel) {
var defaultPickerValue = arguments.length > 8 && arguments[8] !== void 0 ? arguments[8] : EMPTY_LIST;
var pickerValue = arguments.length > 9 && arguments[9] !== void 0 ? arguments[9] : EMPTY_LIST;
var timeDefaultValue = arguments.length > 10 && arguments[10] !== void 0 ? arguments[10] : EMPTY_LIST;
var onPickerValueChange = arguments.length > 11 ? arguments[11] : void 0;
var minDate = arguments.length > 12 ? arguments[12] : void 0;
var maxDate = arguments.length > 13 ? arguments[13] : void 0;
var isTimePicker = pickerMode === "time";
var mergedActiveIndex = activeIndex || 0;
var getDefaultPickerValue = function getDefaultPickerValue2(index2) {
var now = generateConfig.getNow();
if (isTimePicker) {
now = fillTime(generateConfig, now);
}
return defaultPickerValue[index2] || calendarValue[index2] || now;
};
var _pickerValue = _slicedToArray(pickerValue, 2), startPickerValue = _pickerValue[0], endPickerValue = _pickerValue[1];
var _useMergedState = useMergedState(function() {
return getDefaultPickerValue(0);
}, {
value: startPickerValue
}), _useMergedState2 = _slicedToArray(_useMergedState, 2), mergedStartPickerValue = _useMergedState2[0], setStartPickerValue = _useMergedState2[1];
var _useMergedState3 = useMergedState(function() {
return getDefaultPickerValue(1);
}, {
value: endPickerValue
}), _useMergedState4 = _slicedToArray(_useMergedState3, 2), mergedEndPickerValue = _useMergedState4[0], setEndPickerValue = _useMergedState4[1];
var currentPickerValue = React.useMemo(function() {
var current = [mergedStartPickerValue, mergedEndPickerValue][mergedActiveIndex];
return isTimePicker ? current : fillTime(generateConfig, current, timeDefaultValue[mergedActiveIndex]);
}, [isTimePicker, mergedStartPickerValue, mergedEndPickerValue, mergedActiveIndex, generateConfig, timeDefaultValue]);
var setCurrentPickerValue = function setCurrentPickerValue2(nextPickerValue) {
var source = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "panel";
var updater = [setStartPickerValue, setEndPickerValue][mergedActiveIndex];
updater(nextPickerValue);
var clone = [mergedStartPickerValue, mergedEndPickerValue];
clone[mergedActiveIndex] = nextPickerValue;
if (onPickerValueChange && (!isSame(generateConfig, locale2, mergedStartPickerValue, clone[0], pickerMode) || !isSame(generateConfig, locale2, mergedEndPickerValue, clone[1], pickerMode))) {
onPickerValueChange(clone, {
source,
range: mergedActiveIndex === 1 ? "end" : "start",
mode: modes
});
}
};
var getEndDatePickerValue = function getEndDatePickerValue2(startDate, endDate) {
if (multiplePanel) {
var SAME_CHECKER = {
date: "month",
week: "month",
month: "year",
quarter: "year"
};
var mode = SAME_CHECKER[pickerMode];
if (mode && !isSame(generateConfig, locale2, startDate, endDate, mode)) {
return offsetPanelDate(generateConfig, pickerMode, endDate, -1);
}
if (pickerMode === "year" && startDate) {
var srcYear = Math.floor(generateConfig.getYear(startDate) / 10);
var tgtYear = Math.floor(generateConfig.getYear(endDate) / 10);
if (srcYear !== tgtYear) {
return offsetPanelDate(generateConfig, pickerMode, endDate, -1);
}
}
}
return endDate;
};
var prevActiveIndexRef = React.useRef(null);
useLayoutEffect(function() {
if (open) {
if (!defaultPickerValue[mergedActiveIndex]) {
var nextPickerValue = isTimePicker ? null : generateConfig.getNow();
if (prevActiveIndexRef.current !== null && prevActiveIndexRef.current !== mergedActiveIndex) {
nextPickerValue = [mergedStartPickerValue, mergedEndPickerValue][mergedActiveIndex ^ 1];
} else if (calendarValue[mergedActiveIndex]) {
nextPickerValue = mergedActiveIndex === 0 ? calendarValue[0] : getEndDatePickerValue(calendarValue[0], calendarValue[1]);
} else if (calendarValue[mergedActiveIndex ^ 1]) {
nextPickerValue = calendarValue[mergedActiveIndex ^ 1];
}
if (nextPickerValue) {
if (minDate && generateConfig.isAfter(minDate, nextPickerValue)) {
nextPickerValue = minDate;
}
var offsetPickerValue = multiplePanel ? offsetPanelDate(generateConfig, pickerMode, nextPickerValue, 1) : nextPickerValue;
if (maxDate && generateConfig.isAfter(offsetPickerValue, maxDate)) {
nextPickerValue = multiplePanel ? offsetPanelDate(generateConfig, pickerMode, maxDate, -1) : maxDate;
}
setCurrentPickerValue(nextPickerValue, "reset");
}
}
}
}, [open, mergedActiveIndex, calendarValue[mergedActiveIndex]]);
React.useEffect(function() {
if (open) {
prevActiveIndexRef.current = mergedActiveIndex;
} else {
prevActiveIndexRef.current = null;
}
}, [open, mergedActiveIndex]);
useLayoutEffect(function() {
if (open && defaultPickerValue) {
if (defaultPickerValue[mergedActiveIndex]) {
setCurrentPickerValue(defaultPickerValue[mergedActiveIndex], "reset");
}
}
}, [open, mergedActiveIndex]);
return [currentPickerValue, setCurrentPickerValue];
}
function useSyncState(defaultValue, controlledValue) {
var valueRef = React.useRef(defaultValue);
var _React$useState = React.useState({}), _React$useState2 = _slicedToArray(_React$useState, 2), forceUpdate = _React$useState2[1];
var getter = function getter2(useControlledValueFirst) {
return useControlledValueFirst && controlledValue !== void 0 ? controlledValue : valueRef.current;
};
var setter = function setter2(nextValue) {
valueRef.current = nextValue;
forceUpdate({});
};
return [getter, setter, getter(true)];
}
var EMPTY_VALUE = [];
function useUtil(generateConfig, locale2, formatList) {
var getDateTexts = function getDateTexts2(dates) {
return dates.map(function(date4) {
return formatValue(date4, {
generateConfig,
locale: locale2,
format: formatList[0]
});
});
};
var isSameDates = function isSameDates2(source, target) {
var maxLen = Math.max(source.length, target.length);
var diffIndex = -1;
for (var i = 0; i < maxLen; i += 1) {
var prev2 = source[i] || null;
var next2 = target[i] || null;
if (prev2 !== next2 && !isSameTimestamp(generateConfig, prev2, next2)) {
diffIndex = i;
break;
}
}
return [diffIndex < 0, diffIndex !== 0];
};
return [getDateTexts, isSameDates];
}
function orderDates(dates, generateConfig) {
return _toConsumableArray(dates).sort(function(a, b) {
return generateConfig.isAfter(a, b) ? 1 : -1;
});
}
function useCalendarValue(mergedValue) {
var _useSyncState = useSyncState(mergedValue), _useSyncState2 = _slicedToArray(_useSyncState, 2), calendarValue = _useSyncState2[0], setCalendarValue = _useSyncState2[1];
var syncWithValue = useEvent(function() {
setCalendarValue(mergedValue);
});
React.useEffect(function() {
syncWithValue();
}, [mergedValue]);
return [calendarValue, setCalendarValue];
}
function useInnerValue(generateConfig, locale2, formatList, rangeValue, order, defaultValue, value, onCalendarChange, onOk) {
var _useMergedState = useMergedState(defaultValue, {
value
}), _useMergedState2 = _slicedToArray(_useMergedState, 2), innerValue = _useMergedState2[0], setInnerValue = _useMergedState2[1];
var mergedValue = innerValue || EMPTY_VALUE;
var _useCalendarValue = useCalendarValue(mergedValue), _useCalendarValue2 = _slicedToArray(_useCalendarValue, 2), calendarValue = _useCalendarValue2[0], setCalendarValue = _useCalendarValue2[1];
var _useUtil = useUtil(generateConfig, locale2, formatList), _useUtil2 = _slicedToArray(_useUtil, 2), getDateTexts = _useUtil2[0], isSameDates = _useUtil2[1];
var triggerCalendarChange = useEvent(function(nextCalendarValues) {
var clone = _toConsumableArray(nextCalendarValues);
if (rangeValue) {
for (var i = 0; i < 2; i += 1) {
clone[i] = clone[i] || null;
}
} else if (order) {
clone = orderDates(clone.filter(function(date4) {
return date4;
}), generateConfig);
}
var _isSameDates = isSameDates(calendarValue(), clone), _isSameDates2 = _slicedToArray(_isSameDates, 2), isSameMergedDates = _isSameDates2[0], isSameStart = _isSameDates2[1];
if (!isSameMergedDates) {
setCalendarValue(clone);
if (onCalendarChange) {
var cellTexts = getDateTexts(clone);
onCalendarChange(clone, cellTexts, {
range: isSameStart ? "end" : "start"
});
}
}
});
var triggerOk = function triggerOk2() {
if (onOk) {
onOk(calendarValue());
}
};
return [mergedValue, setInnerValue, calendarValue, triggerCalendarChange, triggerOk];
}
function useRangeValue(info, mergedValue, setInnerValue, getCalendarValue, triggerCalendarChange, disabled, formatList, focused, open, isInvalidateDate) {
var generateConfig = info.generateConfig, locale2 = info.locale, picker = info.picker, onChange = info.onChange, allowEmpty = info.allowEmpty, order = info.order;
var orderOnChange = disabled.some(function(d) {
return d;
}) ? false : order;
var _useUtil3 = useUtil(generateConfig, locale2, formatList), _useUtil4 = _slicedToArray(_useUtil3, 2), getDateTexts = _useUtil4[0], isSameDates = _useUtil4[1];
var _useSyncState3 = useSyncState(mergedValue), _useSyncState4 = _slicedToArray(_useSyncState3, 2), submitValue = _useSyncState4[0], setSubmitValue = _useSyncState4[1];
var syncWithValue = useEvent(function() {
setSubmitValue(mergedValue);
});
React.useEffect(function() {
syncWithValue();
}, [mergedValue]);
var triggerSubmit = useEvent(function(nextValue) {
var isNullValue = nextValue === null;
var clone = _toConsumableArray(nextValue || submitValue());
if (isNullValue) {
var maxLen = Math.max(disabled.length, clone.length);
for (var i = 0; i < maxLen; i += 1) {
if (!disabled[i]) {
clone[i] = null;
}
}
}
if (orderOnChange && clone[0] && clone[1]) {
clone = orderDates(clone, generateConfig);
}
triggerCalendarChange(clone);
var _clone = clone, _clone2 = _slicedToArray(_clone, 2), start = _clone2[0], end = _clone2[1];
var startEmpty = !start;
var endEmpty = !end;
var validateEmptyDateRange = allowEmpty ? (
// Validate empty start
(!startEmpty || allowEmpty[0]) && // Validate empty end
(!endEmpty || allowEmpty[1])
) : true;
var validateOrder = !order || startEmpty || endEmpty || isSame(generateConfig, locale2, start, end, picker) || generateConfig.isAfter(end, start);
var validateDates = (
// Validate start
(!start || !isInvalidateDate(start, {
activeIndex: 0
})) && // Validate end
(!end || !isInvalidateDate(end, {
from: start,
activeIndex: 1
}))
);
var allPassed = (
// Null value is from clear button
isNullValue || // Normal check
validateEmptyDateRange && validateOrder && validateDates
);
if (allPassed) {
setInnerValue(clone);
var _isSameDates3 = isSameDates(clone, mergedValue), _isSameDates4 = _slicedToArray(_isSameDates3, 1), isSameMergedDates = _isSameDates4[0];
if (onChange && !isSameMergedDates) {
onChange(
// Return null directly if all date are empty
isNullValue && clone.every(function(val) {
return !val;
}) ? null : clone,
getDateTexts(clone)
);
}
}
return allPassed;
});
var flushSubmit = useEvent(function(index2, needTriggerChange) {
var nextSubmitValue = fillIndex(submitValue(), index2, getCalendarValue()[index2]);
setSubmitValue(nextSubmitValue);
if (needTriggerChange) {
triggerSubmit();
}
});
var interactiveFinished = !focused && !open;
useLockEffect(!interactiveFinished, function() {
if (interactiveFinished) {
triggerSubmit();
triggerCalendarChange(mergedValue);
syncWithValue();
}
}, 2);
return [flushSubmit, triggerSubmit];
}
function useShowNow(picker, mode, showNow, showToday, rangePicker) {
if (mode !== "date" && mode !== "time") {
return false;
}
if (showNow !== void 0) {
return showNow;
}
if (showToday !== void 0) {
return showToday;
}
return !rangePicker && (picker === "date" || picker === "time");
}
function findValidateTime(date4, getHourUnits, getMinuteUnits, getSecondUnits, getMillisecondUnits, generateConfig) {
var nextDate = date4;
function alignValidate(getUnitValue, setUnitValue, units) {
var nextValue = generateConfig[getUnitValue](nextDate);
var nextUnit = units.find(function(unit2) {
return unit2.value === nextValue;
});
if (!nextUnit || nextUnit.disabled) {
var validateUnits = units.filter(function(unit2) {
return !unit2.disabled;
});
var reverseEnabledUnits = _toConsumableArray(validateUnits).reverse();
var validateUnit = reverseEnabledUnits.find(function(unit2) {
return unit2.value <= nextValue;
}) || validateUnits[0];
if (validateUnit) {
nextValue = validateUnit.value;
nextDate = generateConfig[setUnitValue](nextDate, nextValue);
}
}
return nextValue;
}
var nextHour = alignValidate("getHour", "setHour", getHourUnits());
var nextMinute = alignValidate("getMinute", "setMinute", getMinuteUnits(nextHour));
var nextSecond = alignValidate("getSecond", "setSecond", getSecondUnits(nextHour, nextMinute));
alignValidate("getMillisecond", "setMillisecond", getMillisecondUnits(nextHour, nextMinute, nextSecond));
return nextDate;
}
function emptyDisabled() {
return [];
}
function generateUnits(start, end) {
var step = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1;
var hideDisabledOptions = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false;
var disabledUnits = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : [];
var pad = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : 2;
var units = [];
var integerStep = step >= 1 ? step | 0 : 1;
for (var i = start; i <= end; i += integerStep) {
var disabled = disabledUnits.includes(i);
if (!disabled || !hideDisabledOptions) {
units.push({
label: leftPad(i, pad),
value: i,
disabled
});
}
}
return units;
}
function useTimeInfo(generateConfig) {
var props = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
var date4 = arguments.length > 2 ? arguments[2] : void 0;
var _ref = props || {}, use12Hours = _ref.use12Hours, _ref$hourStep = _ref.hourStep, hourStep = _ref$hourStep === void 0 ? 1 : _ref$hourStep, _ref$minuteStep = _ref.minuteStep, minuteStep = _ref$minuteStep === void 0 ? 1 : _ref$minuteStep, _ref$secondStep = _ref.secondStep, secondStep = _ref$secondStep === void 0 ? 1 : _ref$secondStep, _ref$millisecondStep = _ref.millisecondStep, millisecondStep = _ref$millisecondStep === void 0 ? 100 : _ref$millisecondStep, hideDisabledOptions = _ref.hideDisabledOptions, disabledTime = _ref.disabledTime, disabledHours = _ref.disabledHours, disabledMinutes = _ref.disabledMinutes, disabledSeconds = _ref.disabledSeconds;
var mergedDate = React.useMemo(function() {
return date4 || generateConfig.getNow();
}, [date4, generateConfig]);
if (process.env.NODE_ENV !== "production") {
var isHourStepValid = 24 % hourStep === 0;
var isMinuteStepValid = 60 % minuteStep === 0;
var isSecondStepValid = 60 % secondStep === 0;
warningOnce(isHourStepValid, "`hourStep` ".concat(hourStep, " is invalid. It should be a factor of 24."));
warningOnce(isMinuteStepValid, "`minuteStep` ".concat(minuteStep, " is invalid. It should be a factor of 60."));
warningOnce(isSecondStepValid, "`secondStep` ".concat(secondStep, " is invalid. It should be a factor of 60."));
}
var getDisabledTimes = React.useCallback(function(targetDate) {
var disabledConfig = (disabledTime === null || disabledTime === void 0 ? void 0 : disabledTime(targetDate)) || {};
return [disabledConfig.disabledHours || disabledHours || emptyDisabled, disabledConfig.disabledMinutes || disabledMinutes || emptyDisabled, disabledConfig.disabledSeconds || disabledSeconds || emptyDisabled, disabledConfig.disabledMilliseconds || emptyDisabled];
}, [disabledTime, disabledHours, disabledMinutes, disabledSeconds]);
var _React$useMemo = React.useMemo(function() {
return getDisabledTimes(mergedDate);
}, [mergedDate, getDisabledTimes]), _React$useMemo2 = _slicedToArray(_React$useMemo, 4), mergedDisabledHours = _React$useMemo2[0], mergedDisabledMinutes = _React$useMemo2[1], mergedDisabledSeconds = _React$useMemo2[2], mergedDisabledMilliseconds = _React$useMemo2[3];
var getAllUnits = React.useCallback(function(getDisabledHours, getDisabledMinutes, getDisabledSeconds, getDisabledMilliseconds) {
var hours = generateUnits(0, 23, hourStep, hideDisabledOptions, getDisabledHours());
var rowHourUnits2 = use12Hours ? hours.map(function(unit2) {
return _objectSpread2(_objectSpread2({}, unit2), {}, {
label: leftPad(unit2.value % 12 || 12, 2)
});
}) : hours;
var getMinuteUnits2 = function getMinuteUnits3(nextHour) {
return generateUnits(0, 59, minuteStep, hideDisabledOptions, getDisabledMinutes(nextHour));
};
var getSecondUnits2 = function getSecondUnits3(nextHour, nextMinute) {
return generateUnits(0, 59, secondStep, hideDisabledOptions, getDisabledSeconds(nextHour, nextMinute));
};
var getMillisecondUnits2 = function getMillisecondUnits3(nextHour, nextMinute, nextSecond) {
return generateUnits(0, 999, millisecondStep, hideDisabledOptions, getDisabledMilliseconds(nextHour, nextMinute, nextSecond), 3);
};
return [rowHourUnits2, getMinuteUnits2, getSecondUnits2, getMillisecondUnits2];
}, [hideDisabledOptions, hourStep, use12Hours, millisecondStep, minuteStep, secondStep]);
var _React$useMemo3 = React.useMemo(function() {
return getAllUnits(mergedDisabledHours, mergedDisabledMinutes, mergedDisabledSeconds, mergedDisabledMilliseconds);
}, [getAllUnits, mergedDisabledHours, mergedDisabledMinutes, mergedDisabledSeconds, mergedDisabledMilliseconds]), _React$useMemo4 = _slicedToArray(_React$useMemo3, 4), rowHourUnits = _React$useMemo4[0], getMinuteUnits = _React$useMemo4[1], getSecondUnits = _React$useMemo4[2], getMillisecondUnits = _React$useMemo4[3];
var getValidTime = function getValidTime2(nextTime, certainDate) {
var getCheckHourUnits = function getCheckHourUnits2() {
return rowHourUnits;
};
var getCheckMinuteUnits = getMinuteUnits;
var getCheckSecondUnits = getSecondUnits;
var getCheckMillisecondUnits = getMillisecondUnits;
if (certainDate) {
var _getDisabledTimes = getDisabledTimes(certainDate), _getDisabledTimes2 = _slicedToArray(_getDisabledTimes, 4), targetDisabledHours = _getDisabledTimes2[0], targetDisabledMinutes = _getDisabledTimes2[1], targetDisabledSeconds = _getDisabledTimes2[2], targetDisabledMilliseconds = _getDisabledTimes2[3];
var _getAllUnits = getAllUnits(targetDisabledHours, targetDisabledMinutes, targetDisabledSeconds, targetDisabledMilliseconds), _getAllUnits2 = _slicedToArray(_getAllUnits, 4), targetRowHourUnits = _getAllUnits2[0], targetGetMinuteUnits = _getAllUnits2[1], targetGetSecondUnits = _getAllUnits2[2], targetGetMillisecondUnits = _getAllUnits2[3];
getCheckHourUnits = function getCheckHourUnits2() {
return targetRowHourUnits;
};
getCheckMinuteUnits = targetGetMinuteUnits;
getCheckSecondUnits = targetGetSecondUnits;
getCheckMillisecondUnits = targetGetMillisecondUnits;
}
var validateDate = findValidateTime(nextTime, getCheckHourUnits, getCheckMinuteUnits, getCheckSecondUnits, getCheckMillisecondUnits, generateConfig);
return validateDate;
};
return [
// getValidTime
getValidTime,
// Units
rowHourUnits,
getMinuteUnits,
getSecondUnits,
getMillisecondUnits
];
}
function Footer(props) {
var mode = props.mode, internalMode = props.internalMode, renderExtraFooter = props.renderExtraFooter, showNow = props.showNow, showTime = props.showTime, onSubmit = props.onSubmit, onNow = props.onNow, invalid = props.invalid, needConfirm = props.needConfirm, generateConfig = props.generateConfig, disabledDate = props.disabledDate;
var _React$useContext = React.useContext(PickerContext), prefixCls = _React$useContext.prefixCls, locale2 = _React$useContext.locale, _React$useContext$but = _React$useContext.button, Button2 = _React$useContext$but === void 0 ? "button" : _React$useContext$but;
var now = generateConfig.getNow();
var _useTimeInfo = useTimeInfo(generateConfig, showTime, now), _useTimeInfo2 = _slicedToArray(_useTimeInfo, 1), getValidTime = _useTimeInfo2[0];
var extraNode = renderExtraFooter === null || renderExtraFooter === void 0 ? void 0 : renderExtraFooter(mode);
var nowDisabled = disabledDate(now, {
type: mode
});
var onInternalNow = function onInternalNow2() {
if (!nowDisabled) {
var validateNow = getValidTime(now);
onNow(validateNow);
}
};
var nowPrefixCls = "".concat(prefixCls, "-now");
var nowBtnPrefixCls = "".concat(nowPrefixCls, "-btn");
var presetNode = showNow && /* @__PURE__ */ React.createElement("li", {
className: nowPrefixCls
}, /* @__PURE__ */ React.createElement("a", {
className: classNames(nowBtnPrefixCls, nowDisabled && "".concat(nowBtnPrefixCls, "-disabled")),
"aria-disabled": nowDisabled,
onClick: onInternalNow
}, internalMode === "date" ? locale2.today : locale2.now));
var okNode = needConfirm && /* @__PURE__ */ React.createElement("li", {
className: "".concat(prefixCls, "-ok")
}, /* @__PURE__ */ React.createElement(Button2, {
disabled: invalid,
onClick: onSubmit
}, locale2.ok));
var rangeNode = (presetNode || okNode) && /* @__PURE__ */ React.createElement("ul", {
className: "".concat(prefixCls, "-ranges")
}, presetNode, okNode);
if (!extraNode && !rangeNode) {
return null;
}
return /* @__PURE__ */ React.createElement("div", {
className: "".concat(prefixCls, "-footer")
}, extraNode && /* @__PURE__ */ React.createElement("div", {
className: "".concat(prefixCls, "-footer-extra")
}, extraNode), rangeNode);
}
function useToggleDates(generateConfig, locale2, panelMode) {
function toggleDates(list, target) {
var index2 = list.findIndex(function(date4) {
return isSame(generateConfig, locale2, date4, target, panelMode);
});
if (index2 === -1) {
return [].concat(_toConsumableArray(list), [target]);
}
var sliceList = _toConsumableArray(list);
sliceList.splice(index2, 1);
return sliceList;
}
return toggleDates;
}
var PanelContext = /* @__PURE__ */ React.createContext(null);
function usePanelContext() {
return React.useContext(PanelContext);
}
function useInfo(props, panelType) {
var prefixCls = props.prefixCls, generateConfig = props.generateConfig, locale2 = props.locale, disabledDate = props.disabledDate, minDate = props.minDate, maxDate = props.maxDate, cellRender = props.cellRender, hoverValue = props.hoverValue, hoverRangeValue = props.hoverRangeValue, onHover = props.onHover, values = props.values, pickerValue = props.pickerValue, onSelect = props.onSelect, prevIcon = props.prevIcon, nextIcon = props.nextIcon, superPrevIcon = props.superPrevIcon, superNextIcon = props.superNextIcon;
var now = generateConfig.getNow();
var info = {
now,
values,
pickerValue,
prefixCls,
disabledDate,
minDate,
maxDate,
cellRender,
hoverValue,
hoverRangeValue,
onHover,
locale: locale2,
generateConfig,
onSelect,
panelType,
// Icons
prevIcon,
nextIcon,
superPrevIcon,
superNextIcon
};
return [info, now];
}
var PickerHackContext = /* @__PURE__ */ React.createContext({});
if (process.env.NODE_ENV !== "production") {
PickerHackContext.displayName = "PickerHackContext";
}
function PanelBody(props) {
var rowNum = props.rowNum, colNum = props.colNum, baseDate = props.baseDate, getCellDate = props.getCellDate, prefixColumn = props.prefixColumn, rowClassName = props.rowClassName, titleFormat = props.titleFormat, getCellText = props.getCellText, getCellClassName = props.getCellClassName, headerCells = props.headerCells, _props$cellSelection = props.cellSelection, cellSelection = _props$cellSelection === void 0 ? true : _props$cellSelection, disabledDate = props.disabledDate;
var _usePanelContext = usePanelContext(), prefixCls = _usePanelContext.prefixCls, type4 = _usePanelContext.panelType, now = _usePanelContext.now, contextDisabledDate = _usePanelContext.disabledDate, cellRender = _usePanelContext.cellRender, onHover = _usePanelContext.onHover, hoverValue = _usePanelContext.hoverValue, hoverRangeValue = _usePanelContext.hoverRangeValue, generateConfig = _usePanelContext.generateConfig, values = _usePanelContext.values, locale2 = _usePanelContext.locale, onSelect = _usePanelContext.onSelect;
var mergedDisabledDate = disabledDate || contextDisabledDate;
var cellPrefixCls = "".concat(prefixCls, "-cell");
var _React$useContext = React.useContext(PickerHackContext), onCellDblClick = _React$useContext.onCellDblClick;
var matchValues = function matchValues2(date4) {
return values.some(function(singleValue) {
return singleValue && isSame(generateConfig, locale2, date4, singleValue, type4);
});
};
var rows = [];
for (var row = 0; row < rowNum; row += 1) {
var rowNode = [];
var rowStartDate = void 0;
var _loop = function _loop2() {
var offset = row * colNum + col;
var currentDate = getCellDate(baseDate, offset);
var disabled = mergedDisabledDate === null || mergedDisabledDate === void 0 ? void 0 : mergedDisabledDate(currentDate, {
type: type4
});
if (col === 0) {
rowStartDate = currentDate;
if (prefixColumn) {
rowNode.push(prefixColumn(rowStartDate));
}
}
var inRange = false;
var rangeStart = false;
var rangeEnd = false;
if (cellSelection && hoverRangeValue) {
var _hoverRangeValue = _slicedToArray(hoverRangeValue, 2), hoverStart = _hoverRangeValue[0], hoverEnd = _hoverRangeValue[1];
inRange = isInRange(generateConfig, hoverStart, hoverEnd, currentDate);
rangeStart = isSame(generateConfig, locale2, currentDate, hoverStart, type4);
rangeEnd = isSame(generateConfig, locale2, currentDate, hoverEnd, type4);
}
var title = titleFormat ? formatValue(currentDate, {
locale: locale2,
format: titleFormat,
generateConfig
}) : void 0;
var inner = /* @__PURE__ */ React.createElement("div", {
className: "".concat(cellPrefixCls, "-inner")
}, getCellText(currentDate));
rowNode.push(/* @__PURE__ */ React.createElement("td", {
key: col,
title,
className: classNames(cellPrefixCls, _objectSpread2(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(cellPrefixCls, "-disabled"), disabled), "".concat(cellPrefixCls, "-hover"), (hoverValue || []).some(function(date4) {
return isSame(generateConfig, locale2, currentDate, date4, type4);
})), "".concat(cellPrefixCls, "-in-range"), inRange && !rangeStart && !rangeEnd), "".concat(cellPrefixCls, "-range-start"), rangeStart), "".concat(cellPrefixCls, "-range-end"), rangeEnd), "".concat(prefixCls, "-cell-selected"), !hoverRangeValue && // WeekPicker use row instead
type4 !== "week" && matchValues(currentDate)), getCellClassName(currentDate))),
onClick: function onClick() {
if (!disabled) {
onSelect(currentDate);
}
},
onDoubleClick: function onDoubleClick() {
if (!disabled && onCellDblClick) {
onCellDblClick();
}
},
onMouseEnter: function onMouseEnter() {
if (!disabled) {
onHover === null || onHover === void 0 || onHover(currentDate);
}
},
onMouseLeave: function onMouseLeave() {
if (!disabled) {
onHover === null || onHover === void 0 || onHover(null);
}
}
}, cellRender ? cellRender(currentDate, {
prefixCls,
originNode: inner,
today: now,
type: type4,
locale: locale2
}) : inner));
};
for (var col = 0; col < colNum; col += 1) {
_loop();
}
rows.push(/* @__PURE__ */ React.createElement("tr", {
key: row,
className: rowClassName === null || rowClassName === void 0 ? void 0 : rowClassName(rowStartDate)
}, rowNode));
}
return /* @__PURE__ */ React.createElement("div", {
className: "".concat(prefixCls, "-body")
}, /* @__PURE__ */ React.createElement("table", {
className: "".concat(prefixCls, "-content")
}, headerCells && /* @__PURE__ */ React.createElement("thead", null, /* @__PURE__ */ React.createElement("tr", null, headerCells)), /* @__PURE__ */ React.createElement("tbody", null, rows)));
}
var HIDDEN_STYLE = {
visibility: "hidden"
};
function PanelHeader(props) {
var offset = props.offset, superOffset = props.superOffset, onChange = props.onChange, getStart = props.getStart, getEnd = props.getEnd, children = props.children;
var _usePanelContext = usePanelContext(), prefixCls = _usePanelContext.prefixCls, _usePanelContext$prev = _usePanelContext.prevIcon, prevIcon = _usePanelContext$prev === void 0 ? "‹" : _usePanelContext$prev, _usePanelContext$next = _usePanelContext.nextIcon, nextIcon = _usePanelContext$next === void 0 ? "›" : _usePanelContext$next, _usePanelContext$supe = _usePanelContext.superPrevIcon, superPrevIcon = _usePanelContext$supe === void 0 ? "«" : _usePanelContext$supe, _usePanelContext$supe2 = _usePanelContext.superNextIcon, superNextIcon = _usePanelContext$supe2 === void 0 ? "»" : _usePanelContext$supe2, minDate = _usePanelContext.minDate, maxDate = _usePanelContext.maxDate, generateConfig = _usePanelContext.generateConfig, locale2 = _usePanelContext.locale, pickerValue = _usePanelContext.pickerValue, type4 = _usePanelContext.panelType;
var headerPrefixCls = "".concat(prefixCls, "-header");
var _React$useContext = React.useContext(PickerHackContext), hidePrev = _React$useContext.hidePrev, hideNext = _React$useContext.hideNext, hideHeader = _React$useContext.hideHeader;
var disabledOffsetPrev = React.useMemo(function() {
if (!minDate || !offset || !getEnd) {
return false;
}
var prevPanelLimitDate = getEnd(offset(-1, pickerValue));
return !isSameOrAfter(generateConfig, locale2, prevPanelLimitDate, minDate, type4);
}, [minDate, offset, pickerValue, getEnd, generateConfig, locale2, type4]);
var disabledSuperOffsetPrev = React.useMemo(function() {
if (!minDate || !superOffset || !getEnd) {
return false;
}
var prevPanelLimitDate = getEnd(superOffset(-1, pickerValue));
return !isSameOrAfter(generateConfig, locale2, prevPanelLimitDate, minDate, type4);
}, [minDate, superOffset, pickerValue, getEnd, generateConfig, locale2, type4]);
var disabledOffsetNext = React.useMemo(function() {
if (!maxDate || !offset || !getStart) {
return false;
}
var nextPanelLimitDate = getStart(offset(1, pickerValue));
return !isSameOrAfter(generateConfig, locale2, maxDate, nextPanelLimitDate, type4);
}, [maxDate, offset, pickerValue, getStart, generateConfig, locale2, type4]);
var disabledSuperOffsetNext = React.useMemo(function() {
if (!maxDate || !superOffset || !getStart) {
return false;
}
var nextPanelLimitDate = getStart(superOffset(1, pickerValue));
return !isSameOrAfter(generateConfig, locale2, maxDate, nextPanelLimitDate, type4);
}, [maxDate, superOffset, pickerValue, getStart, generateConfig, locale2, type4]);
var onOffset = function onOffset2(distance) {
if (offset) {
onChange(offset(distance, pickerValue));
}
};
var onSuperOffset = function onSuperOffset2(distance) {
if (superOffset) {
onChange(superOffset(distance, pickerValue));
}
};
if (hideHeader) {
return null;
}
var prevBtnCls = "".concat(headerPrefixCls, "-prev-btn");
var nextBtnCls = "".concat(headerPrefixCls, "-next-btn");
var superPrevBtnCls = "".concat(headerPrefixCls, "-super-prev-btn");
var superNextBtnCls = "".concat(headerPrefixCls, "-super-next-btn");
return /* @__PURE__ */ React.createElement("div", {
className: headerPrefixCls
}, superOffset && /* @__PURE__ */ React.createElement("button", {
type: "button",
"aria-label": "super-prev-year",
onClick: function onClick() {
return onSuperOffset(-1);
},
tabIndex: -1,
className: classNames(superPrevBtnCls, disabledSuperOffsetPrev && "".concat(superPrevBtnCls, "-disabled")),
disabled: disabledSuperOffsetPrev,
style: hidePrev ? HIDDEN_STYLE : {}
}, superPrevIcon), offset && /* @__PURE__ */ React.createElement("button", {
type: "button",
"aria-label": "prev-year",
onClick: function onClick() {
return onOffset(-1);
},
tabIndex: -1,
className: classNames(prevBtnCls, disabledOffsetPrev && "".concat(prevBtnCls, "-disabled")),
disabled: disabledOffsetPrev,
style: hidePrev ? HIDDEN_STYLE : {}
}, prevIcon), /* @__PURE__ */ React.createElement("div", {
className: "".concat(headerPrefixCls, "-view")
}, children), offset && /* @__PURE__ */ React.createElement("button", {
type: "button",
"aria-label": "next-year",
onClick: function onClick() {
return onOffset(1);
},
tabIndex: -1,
className: classNames(nextBtnCls, disabledOffsetNext && "".concat(nextBtnCls, "-disabled")),
disabled: disabledOffsetNext,
style: hideNext ? HIDDEN_STYLE : {}
}, nextIcon), superOffset && /* @__PURE__ */ React.createElement("button", {
type: "button",
"aria-label": "super-next-year",
onClick: function onClick() {
return onSuperOffset(1);
},
tabIndex: -1,
className: classNames(superNextBtnCls, disabledSuperOffsetNext && "".concat(superNextBtnCls, "-disabled")),
disabled: disabledSuperOffsetNext,
style: hideNext ? HIDDEN_STYLE : {}
}, superNextIcon));
}
function DatePanel(props) {
var prefixCls = props.prefixCls, _props$panelName = props.panelName, panelName = _props$panelName === void 0 ? "date" : _props$panelName, locale2 = props.locale, generateConfig = props.generateConfig, pickerValue = props.pickerValue, onPickerValueChange = props.onPickerValueChange, onModeChange = props.onModeChange, _props$mode = props.mode, mode = _props$mode === void 0 ? "date" : _props$mode, disabledDate = props.disabledDate, onSelect = props.onSelect, onHover = props.onHover, showWeek = props.showWeek;
var panelPrefixCls = "".concat(prefixCls, "-").concat(panelName, "-panel");
var cellPrefixCls = "".concat(prefixCls, "-cell");
var isWeek = mode === "week";
var _useInfo = useInfo(props, mode), _useInfo2 = _slicedToArray(_useInfo, 2), info = _useInfo2[0], now = _useInfo2[1];
var weekFirstDay = generateConfig.locale.getWeekFirstDay(locale2.locale);
var monthStartDate = generateConfig.setDate(pickerValue, 1);
var baseDate = getWeekStartDate(locale2.locale, generateConfig, monthStartDate);
var month = generateConfig.getMonth(pickerValue);
var prefixColumn = isWeek || showWeek ? function(date4) {
var disabled = disabledDate === null || disabledDate === void 0 ? void 0 : disabledDate(date4, {
type: "week"
});
return /* @__PURE__ */ React.createElement("td", {
key: "week",
className: classNames(cellPrefixCls, "".concat(cellPrefixCls, "-week"), _defineProperty({}, "".concat(cellPrefixCls, "-disabled"), disabled)),
onClick: function onClick() {
if (!disabled) {
onSelect(date4);
}
},
onMouseEnter: function onMouseEnter() {
if (!disabled) {
onHover === null || onHover === void 0 || onHover(date4);
}
},
onMouseLeave: function onMouseLeave() {
if (!disabled) {
onHover === null || onHover === void 0 || onHover(null);
}
}
}, /* @__PURE__ */ React.createElement("div", {
className: "".concat(cellPrefixCls, "-inner")
}, generateConfig.locale.getWeek(locale2.locale, date4)));
} : null;
var headerCells = [];
var weekDaysLocale = locale2.shortWeekDays || (generateConfig.locale.getShortWeekDays ? generateConfig.locale.getShortWeekDays(locale2.locale) : []);
if (prefixColumn) {
headerCells.push(/* @__PURE__ */ React.createElement("th", {
key: "empty",
"aria-label": "empty cell"
}));
}
for (var i = 0; i < WEEK_DAY_COUNT; i += 1) {
headerCells.push(/* @__PURE__ */ React.createElement("th", {
key: i
}, weekDaysLocale[(i + weekFirstDay) % WEEK_DAY_COUNT]));
}
var getCellDate = function getCellDate2(date4, offset) {
return generateConfig.addDate(date4, offset);
};
var getCellText = function getCellText2(date4) {
return formatValue(date4, {
locale: locale2,
format: locale2.cellDateFormat,
generateConfig
});
};
var getCellClassName = function getCellClassName2(date4) {
var classObj = _defineProperty(_defineProperty({}, "".concat(prefixCls, "-cell-in-view"), isSameMonth(generateConfig, date4, pickerValue)), "".concat(prefixCls, "-cell-today"), isSameDate(generateConfig, date4, now));
return classObj;
};
var monthsLocale = locale2.shortMonths || (generateConfig.locale.getShortMonths ? generateConfig.locale.getShortMonths(locale2.locale) : []);
var yearNode = /* @__PURE__ */ React.createElement("button", {
type: "button",
"aria-label": "year panel",
key: "year",
onClick: function onClick() {
onModeChange("year", pickerValue);
},
tabIndex: -1,
className: "".concat(prefixCls, "-year-btn")
}, formatValue(pickerValue, {
locale: locale2,
format: locale2.yearFormat,
generateConfig
}));
var monthNode = /* @__PURE__ */ React.createElement("button", {
type: "button",
"aria-label": "month panel",
key: "month",
onClick: function onClick() {
onModeChange("month", pickerValue);
},
tabIndex: -1,
className: "".concat(prefixCls, "-month-btn")
}, locale2.monthFormat ? formatValue(pickerValue, {
locale: locale2,
format: locale2.monthFormat,
generateConfig
}) : monthsLocale[month]);
var monthYearNodes = locale2.monthBeforeYear ? [monthNode, yearNode] : [yearNode, monthNode];
return /* @__PURE__ */ React.createElement(PanelContext.Provider, {
value: info
}, /* @__PURE__ */ React.createElement("div", {
className: classNames(panelPrefixCls, showWeek && "".concat(panelPrefixCls, "-show-week"))
}, /* @__PURE__ */ React.createElement(PanelHeader, {
offset: function offset(distance) {
return generateConfig.addMonth(pickerValue, distance);
},
superOffset: function superOffset(distance) {
return generateConfig.addYear(pickerValue, distance);
},
onChange: onPickerValueChange,
getStart: function getStart(date4) {
return generateConfig.setDate(date4, 1);
},
getEnd: function getEnd(date4) {
var clone = generateConfig.setDate(date4, 1);
clone = generateConfig.addMonth(clone, 1);
return generateConfig.addDate(clone, -1);
}
}, monthYearNodes), /* @__PURE__ */ React.createElement(PanelBody, _extends({
titleFormat: locale2.fieldDateFormat
}, props, {
colNum: WEEK_DAY_COUNT,
rowNum: 6,
baseDate,
headerCells,
getCellDate,
getCellText,
getCellClassName,
prefixColumn,
cellSelection: !isWeek
}))));
}
var SPEED_PTG = 1 / 3;
function useScrollTo(ulRef, value) {
var scrollingRef = React.useRef(false);
var scrollRafRef = React.useRef(null);
var scrollDistRef = React.useRef(null);
var isScrolling = function isScrolling2() {
return scrollingRef.current;
};
var stopScroll = function stopScroll2() {
wrapperRaf.cancel(scrollRafRef.current);
scrollingRef.current = false;
};
var scrollRafTimesRef = React.useRef();
var startScroll = function startScroll2() {
var ul = ulRef.current;
scrollDistRef.current = null;
scrollRafTimesRef.current = 0;
if (ul) {
var targetLi = ul.querySelector('[data-value="'.concat(value, '"]'));
var firstLi = ul.querySelector("li");
var doScroll = function doScroll2() {
stopScroll();
scrollingRef.current = true;
scrollRafTimesRef.current += 1;
var currentTop = ul.scrollTop;
var firstLiTop = firstLi.offsetTop;
var targetLiTop = targetLi.offsetTop;
var targetTop = targetLiTop - firstLiTop;
if (targetLiTop === 0 && targetLi !== firstLi || !isVisible(ul)) {
if (scrollRafTimesRef.current <= 5) {
scrollRafRef.current = wrapperRaf(doScroll2);
}
return;
}
var nextTop = currentTop + (targetTop - currentTop) * SPEED_PTG;
var dist = Math.abs(targetTop - nextTop);
if (scrollDistRef.current !== null && scrollDistRef.current < dist) {
stopScroll();
return;
}
scrollDistRef.current = dist;
if (dist <= 1) {
ul.scrollTop = targetTop;
stopScroll();
return;
}
ul.scrollTop = nextTop;
scrollRafRef.current = wrapperRaf(doScroll2);
};
if (targetLi && firstLi) {
doScroll();
}
}
};
var syncScroll = useEvent(startScroll);
return [syncScroll, stopScroll, isScrolling];
}
var SCROLL_DELAY = 300;
function TimeColumn(props) {
var units = props.units, value = props.value, optionalValue = props.optionalValue, type4 = props.type, onChange = props.onChange, onDblClick = props.onDblClick, changeOnScroll = props.changeOnScroll;
var _usePanelContext = usePanelContext(), prefixCls = _usePanelContext.prefixCls, cellRender = _usePanelContext.cellRender, now = _usePanelContext.now, locale2 = _usePanelContext.locale;
var panelPrefixCls = "".concat(prefixCls, "-time-panel");
var cellPrefixCls = "".concat(prefixCls, "-time-panel-cell");
var ulRef = React.useRef(null);
var checkDelayRef = React.useRef();
var clearDelayCheck = function clearDelayCheck2() {
clearTimeout(checkDelayRef.current);
};
var _useScrollTo = useScrollTo(ulRef, value !== null && value !== void 0 ? value : optionalValue), _useScrollTo2 = _slicedToArray(_useScrollTo, 3), syncScroll = _useScrollTo2[0], stopScroll = _useScrollTo2[1], isScrolling = _useScrollTo2[2];
useLayoutEffect(function() {
syncScroll();
clearDelayCheck();
return function() {
stopScroll();
clearDelayCheck();
};
}, [value, optionalValue, units]);
var onInternalScroll = function onInternalScroll2(event) {
clearDelayCheck();
var target = event.target;
if (!isScrolling() && changeOnScroll) {
checkDelayRef.current = setTimeout(function() {
var ul = ulRef.current;
var firstLiTop = ul.querySelector("li").offsetTop;
var liList = Array.from(ul.querySelectorAll("li"));
var liTopList = liList.map(function(li) {
return li.offsetTop - firstLiTop;
});
var liDistList = liTopList.map(function(top, index2) {
if (units[index2].disabled) {
return Number.MAX_SAFE_INTEGER;
}
return Math.abs(top - target.scrollTop);
});
var minDist = Math.min.apply(Math, _toConsumableArray(liDistList));
var minDistIndex = liDistList.findIndex(function(dist) {
return dist === minDist;
});
var targetUnit = units[minDistIndex];
if (targetUnit && !targetUnit.disabled) {
onChange(targetUnit.value);
}
}, SCROLL_DELAY);
}
};
var columnPrefixCls = "".concat(panelPrefixCls, "-column");
return /* @__PURE__ */ React.createElement("ul", {
className: columnPrefixCls,
ref: ulRef,
"data-type": type4,
onScroll: onInternalScroll
}, units.map(function(_ref) {
var label = _ref.label, unitValue = _ref.value, disabled = _ref.disabled;
var inner = /* @__PURE__ */ React.createElement("div", {
className: "".concat(cellPrefixCls, "-inner")
}, label);
return /* @__PURE__ */ React.createElement("li", {
key: unitValue,
className: classNames(cellPrefixCls, _defineProperty(_defineProperty({}, "".concat(cellPrefixCls, "-selected"), value === unitValue), "".concat(cellPrefixCls, "-disabled"), disabled)),
onClick: function onClick() {
if (!disabled) {
onChange(unitValue);
}
},
onDoubleClick: function onDoubleClick() {
if (!disabled && onDblClick) {
onDblClick();
}
},
"data-value": unitValue
}, cellRender ? cellRender(unitValue, {
prefixCls,
originNode: inner,
today: now,
type: "time",
subType: type4,
locale: locale2
}) : inner);
}));
}
function isAM(hour) {
return hour < 12;
}
function TimePanelBody(props) {
var showHour = props.showHour, showMinute = props.showMinute, showSecond = props.showSecond, showMillisecond = props.showMillisecond, showMeridiem = props.use12Hours, changeOnScroll = props.changeOnScroll;
var _usePanelContext = usePanelContext(), prefixCls = _usePanelContext.prefixCls, values = _usePanelContext.values, generateConfig = _usePanelContext.generateConfig, locale2 = _usePanelContext.locale, onSelect = _usePanelContext.onSelect, pickerValue = _usePanelContext.pickerValue;
var value = (values === null || values === void 0 ? void 0 : values[0]) || null;
var _React$useContext = React.useContext(PickerHackContext), onCellDblClick = _React$useContext.onCellDblClick;
var _useTimeInfo = useTimeInfo(generateConfig, props, value), _useTimeInfo2 = _slicedToArray(_useTimeInfo, 5), getValidTime = _useTimeInfo2[0], rowHourUnits = _useTimeInfo2[1], getMinuteUnits = _useTimeInfo2[2], getSecondUnits = _useTimeInfo2[3], getMillisecondUnits = _useTimeInfo2[4];
var getUnitValue = function getUnitValue2(func) {
var valueUnitVal = value && generateConfig[func](value);
var pickerUnitValue = pickerValue && generateConfig[func](pickerValue);
return [valueUnitVal, pickerUnitValue];
};
var _getUnitValue = getUnitValue("getHour"), _getUnitValue2 = _slicedToArray(_getUnitValue, 2), hour = _getUnitValue2[0], pickerHour = _getUnitValue2[1];
var _getUnitValue3 = getUnitValue("getMinute"), _getUnitValue4 = _slicedToArray(_getUnitValue3, 2), minute = _getUnitValue4[0], pickerMinute = _getUnitValue4[1];
var _getUnitValue5 = getUnitValue("getSecond"), _getUnitValue6 = _slicedToArray(_getUnitValue5, 2), second = _getUnitValue6[0], pickerSecond = _getUnitValue6[1];
var _getUnitValue7 = getUnitValue("getMillisecond"), _getUnitValue8 = _slicedToArray(_getUnitValue7, 2), millisecond = _getUnitValue8[0], pickerMillisecond = _getUnitValue8[1];
var meridiem = hour === null ? null : isAM(hour) ? "am" : "pm";
var hourUnits = React.useMemo(function() {
if (!showMeridiem) {
return rowHourUnits;
}
return isAM(hour) ? rowHourUnits.filter(function(h) {
return isAM(h.value);
}) : rowHourUnits.filter(function(h) {
return !isAM(h.value);
});
}, [hour, rowHourUnits, showMeridiem]);
var getEnabled = function getEnabled2(units, val) {
var _enabledUnits$;
var enabledUnits = units.filter(function(unit2) {
return !unit2.disabled;
});
return val !== null && val !== void 0 ? val : (
// Fallback to enabled value
enabledUnits === null || enabledUnits === void 0 || (_enabledUnits$ = enabledUnits[0]) === null || _enabledUnits$ === void 0 ? void 0 : _enabledUnits$.value
);
};
var validHour = getEnabled(rowHourUnits, hour);
var minuteUnits = React.useMemo(function() {
return getMinuteUnits(validHour);
}, [getMinuteUnits, validHour]);
var validMinute = getEnabled(minuteUnits, minute);
var secondUnits = React.useMemo(function() {
return getSecondUnits(validHour, validMinute);
}, [getSecondUnits, validHour, validMinute]);
var validSecond = getEnabled(secondUnits, second);
var millisecondUnits = React.useMemo(function() {
return getMillisecondUnits(validHour, validMinute, validSecond);
}, [getMillisecondUnits, validHour, validMinute, validSecond]);
var validMillisecond = getEnabled(millisecondUnits, millisecond);
var meridiemUnits = React.useMemo(function() {
if (!showMeridiem) {
return [];
}
var base = generateConfig.getNow();
var amDate = generateConfig.setHour(base, 6);
var pmDate = generateConfig.setHour(base, 18);
var formatMeridiem = function formatMeridiem2(date4, defaultLabel) {
var cellMeridiemFormat = locale2.cellMeridiemFormat;
return cellMeridiemFormat ? formatValue(date4, {
generateConfig,
locale: locale2,
format: cellMeridiemFormat
}) : defaultLabel;
};
return [{
label: formatMeridiem(amDate, "AM"),
value: "am",
disabled: rowHourUnits.every(function(h) {
return h.disabled || !isAM(h.value);
})
}, {
label: formatMeridiem(pmDate, "PM"),
value: "pm",
disabled: rowHourUnits.every(function(h) {
return h.disabled || isAM(h.value);
})
}];
}, [rowHourUnits, showMeridiem, generateConfig, locale2]);
var triggerChange = function triggerChange2(nextDate) {
var validateDate = getValidTime(nextDate);
onSelect(validateDate);
};
var triggerDateTmpl = React.useMemo(function() {
var tmpl = value || pickerValue || generateConfig.getNow();
var isNotNull = function isNotNull2(num) {
return num !== null && num !== void 0;
};
if (isNotNull(hour)) {
tmpl = generateConfig.setHour(tmpl, hour);
tmpl = generateConfig.setMinute(tmpl, minute);
tmpl = generateConfig.setSecond(tmpl, second);
tmpl = generateConfig.setMillisecond(tmpl, millisecond);
} else if (isNotNull(pickerHour)) {
tmpl = generateConfig.setHour(tmpl, pickerHour);
tmpl = generateConfig.setMinute(tmpl, pickerMinute);
tmpl = generateConfig.setSecond(tmpl, pickerSecond);
tmpl = generateConfig.setMillisecond(tmpl, pickerMillisecond);
} else if (isNotNull(validHour)) {
tmpl = generateConfig.setHour(tmpl, validHour);
tmpl = generateConfig.setMinute(tmpl, validMinute);
tmpl = generateConfig.setSecond(tmpl, validSecond);
tmpl = generateConfig.setMillisecond(tmpl, validMillisecond);
}
return tmpl;
}, [value, pickerValue, hour, minute, second, millisecond, validHour, validMinute, validSecond, validMillisecond, pickerHour, pickerMinute, pickerSecond, pickerMillisecond, generateConfig]);
var onHourChange = function onHourChange2(val) {
triggerChange(generateConfig.setHour(triggerDateTmpl, val));
};
var onMinuteChange = function onMinuteChange2(val) {
triggerChange(generateConfig.setMinute(triggerDateTmpl, val));
};
var onSecondChange = function onSecondChange2(val) {
triggerChange(generateConfig.setSecond(triggerDateTmpl, val));
};
var onMillisecondChange = function onMillisecondChange2(val) {
triggerChange(generateConfig.setMillisecond(triggerDateTmpl, val));
};
var onMeridiemChange = function onMeridiemChange2(val) {
if (val === "am" && !isAM(hour)) {
triggerChange(generateConfig.setHour(triggerDateTmpl, hour - 12));
} else if (val === "pm" && isAM(hour)) {
triggerChange(generateConfig.setHour(triggerDateTmpl, hour + 12));
}
};
var sharedColumnProps = {
onDblClick: onCellDblClick,
changeOnScroll
};
return /* @__PURE__ */ React.createElement("div", {
className: "".concat(prefixCls, "-content")
}, showHour && /* @__PURE__ */ React.createElement(TimeColumn, _extends({
units: hourUnits,
value: hour,
optionalValue: pickerHour,
type: "hour",
onChange: onHourChange
}, sharedColumnProps)), showMinute && /* @__PURE__ */ React.createElement(TimeColumn, _extends({
units: minuteUnits,
value: minute,
optionalValue: pickerMinute,
type: "minute",
onChange: onMinuteChange
}, sharedColumnProps)), showSecond && /* @__PURE__ */ React.createElement(TimeColumn, _extends({
units: secondUnits,
value: second,
optionalValue: pickerSecond,
type: "second",
onChange: onSecondChange
}, sharedColumnProps)), showMillisecond && /* @__PURE__ */ React.createElement(TimeColumn, _extends({
units: millisecondUnits,
value: millisecond,
optionalValue: pickerMillisecond,
type: "millisecond",
onChange: onMillisecondChange
}, sharedColumnProps)), showMeridiem && /* @__PURE__ */ React.createElement(TimeColumn, _extends({
units: meridiemUnits,
value: meridiem,
type: "meridiem",
onChange: onMeridiemChange
}, sharedColumnProps)));
}
function TimePanel(props) {
var prefixCls = props.prefixCls, value = props.value, locale2 = props.locale, generateConfig = props.generateConfig, showTime = props.showTime;
var _ref = showTime || {}, format2 = _ref.format;
var panelPrefixCls = "".concat(prefixCls, "-time-panel");
var _useInfo = useInfo(props, "time"), _useInfo2 = _slicedToArray(_useInfo, 1), info = _useInfo2[0];
return /* @__PURE__ */ React.createElement(PanelContext.Provider, {
value: info
}, /* @__PURE__ */ React.createElement("div", {
className: classNames(panelPrefixCls)
}, /* @__PURE__ */ React.createElement(PanelHeader, null, value ? formatValue(value, {
locale: locale2,
format: format2,
generateConfig
}) : " "), /* @__PURE__ */ React.createElement(TimePanelBody, showTime)));
}
function DateTimePanel(props) {
var prefixCls = props.prefixCls, generateConfig = props.generateConfig, showTime = props.showTime, onSelect = props.onSelect, value = props.value, pickerValue = props.pickerValue, onHover = props.onHover;
var panelPrefixCls = "".concat(prefixCls, "-datetime-panel");
var _useTimeInfo = useTimeInfo(generateConfig, showTime), _useTimeInfo2 = _slicedToArray(_useTimeInfo, 1), getValidTime = _useTimeInfo2[0];
var mergeTime = function mergeTime2(date4) {
if (value) {
return fillTime(generateConfig, date4, value);
}
return fillTime(generateConfig, date4, pickerValue);
};
var onDateHover = function onDateHover2(date4) {
onHover === null || onHover === void 0 || onHover(date4 ? mergeTime(date4) : date4);
};
var onDateSelect = function onDateSelect2(date4) {
var cloneDate = mergeTime(date4);
onSelect(getValidTime(cloneDate, cloneDate));
};
return /* @__PURE__ */ React.createElement("div", {
className: panelPrefixCls
}, /* @__PURE__ */ React.createElement(DatePanel, _extends({}, props, {
onSelect: onDateSelect,
onHover: onDateHover
})), /* @__PURE__ */ React.createElement(TimePanel, props));
}
function DecadePanel(props) {
var prefixCls = props.prefixCls, locale2 = props.locale, generateConfig = props.generateConfig, pickerValue = props.pickerValue, disabledDate = props.disabledDate, onPickerValueChange = props.onPickerValueChange;
var panelPrefixCls = "".concat(prefixCls, "-decade-panel");
var _useInfo = useInfo(props, "decade"), _useInfo2 = _slicedToArray(_useInfo, 1), info = _useInfo2[0];
var getStartYear = function getStartYear2(date4) {
var startYear = Math.floor(generateConfig.getYear(pickerValue) / 100) * 100;
return generateConfig.setYear(date4, startYear);
};
var getEndYear = function getEndYear2(date4) {
var startYear = getStartYear(date4);
return generateConfig.addYear(startYear, 99);
};
var startYearDate = getStartYear(pickerValue);
var endYearDate = getEndYear(pickerValue);
var baseDate = generateConfig.addYear(startYearDate, -10);
var getCellDate = function getCellDate2(date4, offset) {
return generateConfig.addYear(date4, offset * 10);
};
var getCellText = function getCellText2(date4) {
var cellYearFormat = locale2.cellYearFormat;
var startYearStr = formatValue(date4, {
locale: locale2,
format: cellYearFormat,
generateConfig
});
var endYearStr = formatValue(generateConfig.addYear(date4, 9), {
locale: locale2,
format: cellYearFormat,
generateConfig
});
return "".concat(startYearStr, "-").concat(endYearStr);
};
var getCellClassName = function getCellClassName2(date4) {
return _defineProperty({}, "".concat(prefixCls, "-cell-in-view"), isSameDecade(generateConfig, date4, startYearDate) || isSameDecade(generateConfig, date4, endYearDate) || isInRange(generateConfig, startYearDate, endYearDate, date4));
};
var mergedDisabledDate = disabledDate ? function(currentDate, disabledInfo) {
var baseStartDate = generateConfig.setDate(currentDate, 1);
var baseStartMonth = generateConfig.setMonth(baseStartDate, 0);
var baseStartYear = generateConfig.setYear(baseStartMonth, Math.floor(generateConfig.getYear(baseStartMonth) / 10) * 10);
var baseEndYear = generateConfig.addYear(baseStartYear, 10);
var baseEndDate = generateConfig.addDate(baseEndYear, -1);
return disabledDate(baseStartYear, disabledInfo) && disabledDate(baseEndDate, disabledInfo);
} : null;
var yearNode = "".concat(formatValue(startYearDate, {
locale: locale2,
format: locale2.yearFormat,
generateConfig
}), "-").concat(formatValue(endYearDate, {
locale: locale2,
format: locale2.yearFormat,
generateConfig
}));
return /* @__PURE__ */ React.createElement(PanelContext.Provider, {
value: info
}, /* @__PURE__ */ React.createElement("div", {
className: panelPrefixCls
}, /* @__PURE__ */ React.createElement(PanelHeader, {
superOffset: function superOffset(distance) {
return generateConfig.addYear(pickerValue, distance * 100);
},
onChange: onPickerValueChange,
getStart: getStartYear,
getEnd: getEndYear
}, yearNode), /* @__PURE__ */ React.createElement(PanelBody, _extends({}, props, {
disabledDate: mergedDisabledDate,
colNum: 3,
rowNum: 4,
baseDate,
getCellDate,
getCellText,
getCellClassName
}))));
}
function MonthPanel(props) {
var prefixCls = props.prefixCls, locale2 = props.locale, generateConfig = props.generateConfig, pickerValue = props.pickerValue, disabledDate = props.disabledDate, onPickerValueChange = props.onPickerValueChange, onModeChange = props.onModeChange;
var panelPrefixCls = "".concat(prefixCls, "-month-panel");
var _useInfo = useInfo(props, "month"), _useInfo2 = _slicedToArray(_useInfo, 1), info = _useInfo2[0];
var baseDate = generateConfig.setMonth(pickerValue, 0);
var monthsLocale = locale2.shortMonths || (generateConfig.locale.getShortMonths ? generateConfig.locale.getShortMonths(locale2.locale) : []);
var getCellDate = function getCellDate2(date4, offset) {
return generateConfig.addMonth(date4, offset);
};
var getCellText = function getCellText2(date4) {
var month = generateConfig.getMonth(date4);
return locale2.monthFormat ? formatValue(date4, {
locale: locale2,
format: locale2.monthFormat,
generateConfig
}) : monthsLocale[month];
};
var getCellClassName = function getCellClassName2() {
return _defineProperty({}, "".concat(prefixCls, "-cell-in-view"), true);
};
var mergedDisabledDate = disabledDate ? function(currentDate, disabledInfo) {
var startDate = generateConfig.setDate(currentDate, 1);
var nextMonthStartDate = generateConfig.setMonth(startDate, generateConfig.getMonth(startDate) + 1);
var endDate = generateConfig.addDate(nextMonthStartDate, -1);
return disabledDate(startDate, disabledInfo) && disabledDate(endDate, disabledInfo);
} : null;
var yearNode = /* @__PURE__ */ React.createElement("button", {
type: "button",
key: "year",
"aria-label": "year panel",
onClick: function onClick() {
onModeChange("year");
},
tabIndex: -1,
className: "".concat(prefixCls, "-year-btn")
}, formatValue(pickerValue, {
locale: locale2,
format: locale2.yearFormat,
generateConfig
}));
return /* @__PURE__ */ React.createElement(PanelContext.Provider, {
value: info
}, /* @__PURE__ */ React.createElement("div", {
className: panelPrefixCls
}, /* @__PURE__ */ React.createElement(PanelHeader, {
superOffset: function superOffset(distance) {
return generateConfig.addYear(pickerValue, distance);
},
onChange: onPickerValueChange,
getStart: function getStart(date4) {
return generateConfig.setMonth(date4, 0);
},
getEnd: function getEnd(date4) {
return generateConfig.setMonth(date4, 11);
}
}, yearNode), /* @__PURE__ */ React.createElement(PanelBody, _extends({}, props, {
disabledDate: mergedDisabledDate,
titleFormat: locale2.fieldMonthFormat,
colNum: 3,
rowNum: 4,
baseDate,
getCellDate,
getCellText,
getCellClassName
}))));
}
function QuarterPanel(props) {
var prefixCls = props.prefixCls, locale2 = props.locale, generateConfig = props.generateConfig, pickerValue = props.pickerValue, onPickerValueChange = props.onPickerValueChange, onModeChange = props.onModeChange;
var panelPrefixCls = "".concat(prefixCls, "-quarter-panel");
var _useInfo = useInfo(props, "quarter"), _useInfo2 = _slicedToArray(_useInfo, 1), info = _useInfo2[0];
var baseDate = generateConfig.setMonth(pickerValue, 0);
var getCellDate = function getCellDate2(date4, offset) {
return generateConfig.addMonth(date4, offset * 3);
};
var getCellText = function getCellText2(date4) {
return formatValue(date4, {
locale: locale2,
format: locale2.cellQuarterFormat,
generateConfig
});
};
var getCellClassName = function getCellClassName2() {
return _defineProperty({}, "".concat(prefixCls, "-cell-in-view"), true);
};
var yearNode = /* @__PURE__ */ React.createElement("button", {
type: "button",
key: "year",
"aria-label": "year panel",
onClick: function onClick() {
onModeChange("year");
},
tabIndex: -1,
className: "".concat(prefixCls, "-year-btn")
}, formatValue(pickerValue, {
locale: locale2,
format: locale2.yearFormat,
generateConfig
}));
return /* @__PURE__ */ React.createElement(PanelContext.Provider, {
value: info
}, /* @__PURE__ */ React.createElement("div", {
className: panelPrefixCls
}, /* @__PURE__ */ React.createElement(PanelHeader, {
superOffset: function superOffset(distance) {
return generateConfig.addYear(pickerValue, distance);
},
onChange: onPickerValueChange,
getStart: function getStart(date4) {
return generateConfig.setMonth(date4, 0);
},
getEnd: function getEnd(date4) {
return generateConfig.setMonth(date4, 11);
}
}, yearNode), /* @__PURE__ */ React.createElement(PanelBody, _extends({}, props, {
titleFormat: locale2.fieldQuarterFormat,
colNum: 4,
rowNum: 1,
baseDate,
getCellDate,
getCellText,
getCellClassName
}))));
}
function WeekPanel(props) {
var prefixCls = props.prefixCls, generateConfig = props.generateConfig, locale2 = props.locale, value = props.value, hoverValue = props.hoverValue, hoverRangeValue = props.hoverRangeValue;
var localeName = locale2.locale;
var rowPrefixCls = "".concat(prefixCls, "-week-panel-row");
var rowClassName = function rowClassName2(currentDate) {
var rangeCls = {};
if (hoverRangeValue) {
var _hoverRangeValue = _slicedToArray(hoverRangeValue, 2), rangeStart = _hoverRangeValue[0], rangeEnd = _hoverRangeValue[1];
var isRangeStart = isSameWeek(generateConfig, localeName, rangeStart, currentDate);
var isRangeEnd = isSameWeek(generateConfig, localeName, rangeEnd, currentDate);
rangeCls["".concat(rowPrefixCls, "-range-start")] = isRangeStart;
rangeCls["".concat(rowPrefixCls, "-range-end")] = isRangeEnd;
rangeCls["".concat(rowPrefixCls, "-range-hover")] = !isRangeStart && !isRangeEnd && isInRange(generateConfig, rangeStart, rangeEnd, currentDate);
}
if (hoverValue) {
rangeCls["".concat(rowPrefixCls, "-hover")] = hoverValue.some(function(date4) {
return isSameWeek(generateConfig, localeName, currentDate, date4);
});
}
return classNames(
rowPrefixCls,
_defineProperty({}, "".concat(rowPrefixCls, "-selected"), !hoverRangeValue && isSameWeek(generateConfig, localeName, value, currentDate)),
// Patch for hover range
rangeCls
);
};
return /* @__PURE__ */ React.createElement(DatePanel, _extends({}, props, {
mode: "week",
panelName: "week",
rowClassName
}));
}
function YearPanel(props) {
var prefixCls = props.prefixCls, locale2 = props.locale, generateConfig = props.generateConfig, pickerValue = props.pickerValue, disabledDate = props.disabledDate, onPickerValueChange = props.onPickerValueChange, onModeChange = props.onModeChange;
var panelPrefixCls = "".concat(prefixCls, "-year-panel");
var _useInfo = useInfo(props, "year"), _useInfo2 = _slicedToArray(_useInfo, 1), info = _useInfo2[0];
var getStartYear = function getStartYear2(date4) {
var startYear = Math.floor(generateConfig.getYear(pickerValue) / 10) * 10;
return generateConfig.setYear(date4, startYear);
};
var getEndYear = function getEndYear2(date4) {
var startYear = getStartYear(date4);
return generateConfig.addYear(startYear, 9);
};
var startYearDate = getStartYear(pickerValue);
var endYearDate = getEndYear(pickerValue);
var baseDate = generateConfig.addYear(startYearDate, -1);
var getCellDate = function getCellDate2(date4, offset) {
return generateConfig.addYear(date4, offset);
};
var getCellText = function getCellText2(date4) {
return formatValue(date4, {
locale: locale2,
format: locale2.cellYearFormat,
generateConfig
});
};
var getCellClassName = function getCellClassName2(date4) {
return _defineProperty({}, "".concat(prefixCls, "-cell-in-view"), isSameYear(generateConfig, date4, startYearDate) || isSameYear(generateConfig, date4, endYearDate) || isInRange(generateConfig, startYearDate, endYearDate, date4));
};
var mergedDisabledDate = disabledDate ? function(currentDate, disabledInfo) {
var startMonth = generateConfig.setMonth(currentDate, 0);
var startDate = generateConfig.setDate(startMonth, 1);
var endMonth = generateConfig.setMonth(currentDate, generateConfig.getMonth(currentDate) + 1);
var enDate = generateConfig.addDate(endMonth, -1);
return disabledDate(startDate, disabledInfo) && disabledDate(enDate, disabledInfo);
} : null;
var yearNode = /* @__PURE__ */ React.createElement("button", {
type: "button",
key: "decade",
"aria-label": "decade panel",
onClick: function onClick() {
onModeChange("decade");
},
tabIndex: -1,
className: "".concat(prefixCls, "-decade-btn")
}, formatValue(startYearDate, {
locale: locale2,
format: locale2.yearFormat,
generateConfig
}), "-", formatValue(endYearDate, {
locale: locale2,
format: locale2.yearFormat,
generateConfig
}));
return /* @__PURE__ */ React.createElement(PanelContext.Provider, {
value: info
}, /* @__PURE__ */ React.createElement("div", {
className: panelPrefixCls
}, /* @__PURE__ */ React.createElement(PanelHeader, {
superOffset: function superOffset(distance) {
return generateConfig.addYear(pickerValue, distance * 10);
},
onChange: onPickerValueChange,
getStart: getStartYear,
getEnd: getEndYear
}, yearNode), /* @__PURE__ */ React.createElement(PanelBody, _extends({}, props, {
disabledDate: mergedDisabledDate,
titleFormat: locale2.fieldYearFormat,
colNum: 3,
rowNum: 4,
baseDate,
getCellDate,
getCellText,
getCellClassName
}))));
}
var DefaultComponents = {
date: DatePanel,
datetime: DateTimePanel,
week: WeekPanel,
month: MonthPanel,
quarter: QuarterPanel,
year: YearPanel,
decade: DecadePanel,
time: TimePanel
};
function PickerPanel(props, ref) {
var _React$useContext;
var locale2 = props.locale, generateConfig = props.generateConfig, direction = props.direction, prefixCls = props.prefixCls, _props$tabIndex = props.tabIndex, tabIndex = _props$tabIndex === void 0 ? 0 : _props$tabIndex, multiple = props.multiple, defaultValue = props.defaultValue, value = props.value, onChange = props.onChange, onSelect = props.onSelect, defaultPickerValue = props.defaultPickerValue, pickerValue = props.pickerValue, onPickerValueChange = props.onPickerValueChange, mode = props.mode, onPanelChange = props.onPanelChange, _props$picker = props.picker, picker = _props$picker === void 0 ? "date" : _props$picker, showTime = props.showTime, hoverValue = props.hoverValue, hoverRangeValue = props.hoverRangeValue, cellRender = props.cellRender, dateRender = props.dateRender, monthCellRender = props.monthCellRender, _props$components = props.components, components = _props$components === void 0 ? {} : _props$components, hideHeader = props.hideHeader;
var mergedPrefixCls = ((_React$useContext = React.useContext(PickerContext)) === null || _React$useContext === void 0 ? void 0 : _React$useContext.prefixCls) || prefixCls || "rc-picker";
var rootRef = React.useRef();
React.useImperativeHandle(ref, function() {
return {
nativeElement: rootRef.current
};
});
var _getTimeProps = getTimeProps(props), _getTimeProps2 = _slicedToArray(_getTimeProps, 4), timeProps = _getTimeProps2[0], localeTimeProps = _getTimeProps2[1], showTimeFormat = _getTimeProps2[2], propFormat = _getTimeProps2[3];
var filledLocale = useLocale$1(locale2, localeTimeProps);
var internalPicker = picker === "date" && showTime ? "datetime" : picker;
var mergedShowTime = React.useMemo(function() {
return fillShowTimeConfig(internalPicker, showTimeFormat, propFormat, timeProps, filledLocale);
}, [internalPicker, showTimeFormat, propFormat, timeProps, filledLocale]);
var now = generateConfig.getNow();
var _useMergedState = useMergedState(picker, {
value: mode,
postState: function postState(val) {
return val || "date";
}
}), _useMergedState2 = _slicedToArray(_useMergedState, 2), mergedMode = _useMergedState2[0], setMergedMode = _useMergedState2[1];
var internalMode = mergedMode === "date" && mergedShowTime ? "datetime" : mergedMode;
var toggleDates = useToggleDates(generateConfig, locale2, internalPicker);
var _useMergedState3 = useMergedState(defaultValue, {
value
}), _useMergedState4 = _slicedToArray(_useMergedState3, 2), innerValue = _useMergedState4[0], setMergedValue = _useMergedState4[1];
var mergedValue = React.useMemo(function() {
var values = toArray$1(innerValue).filter(function(val) {
return val;
});
return multiple ? values : values.slice(0, 1);
}, [innerValue, multiple]);
var triggerChange = useEvent(function(nextValue) {
setMergedValue(nextValue);
if (onChange && (nextValue === null || mergedValue.length !== nextValue.length || mergedValue.some(function(ori, index2) {
return !isSame(generateConfig, locale2, ori, nextValue[index2], internalPicker);
}))) {
onChange === null || onChange === void 0 || onChange(multiple ? nextValue : nextValue[0]);
}
});
var onInternalSelect = useEvent(function(newDate) {
onSelect === null || onSelect === void 0 || onSelect(newDate);
if (mergedMode === picker) {
var nextValues = multiple ? toggleDates(mergedValue, newDate) : [newDate];
triggerChange(nextValues);
}
});
var _useMergedState5 = useMergedState(defaultPickerValue || mergedValue[0] || now, {
value: pickerValue
}), _useMergedState6 = _slicedToArray(_useMergedState5, 2), mergedPickerValue = _useMergedState6[0], setInternalPickerValue = _useMergedState6[1];
React.useEffect(function() {
if (mergedValue[0] && !pickerValue) {
setInternalPickerValue(mergedValue[0]);
}
}, [mergedValue[0]]);
var triggerPanelChange = function triggerPanelChange2(viewDate, nextMode) {
onPanelChange === null || onPanelChange === void 0 || onPanelChange(viewDate || pickerValue, nextMode || mergedMode);
};
var setPickerValue = function setPickerValue2(nextPickerValue) {
var triggerPanelEvent = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
setInternalPickerValue(nextPickerValue);
onPickerValueChange === null || onPickerValueChange === void 0 || onPickerValueChange(nextPickerValue);
if (triggerPanelEvent) {
triggerPanelChange(nextPickerValue);
}
};
var triggerModeChange = function triggerModeChange2(nextMode, viewDate) {
setMergedMode(nextMode);
if (viewDate) {
setPickerValue(viewDate);
}
triggerPanelChange(viewDate, nextMode);
};
var onPanelValueSelect = function onPanelValueSelect2(nextValue) {
onInternalSelect(nextValue);
setPickerValue(nextValue);
if (mergedMode !== picker) {
var decadeYearQueue = ["decade", "year"];
var decadeYearMonthQueue = [].concat(decadeYearQueue, ["month"]);
var pickerQueue = {
quarter: [].concat(decadeYearQueue, ["quarter"]),
week: [].concat(_toConsumableArray(decadeYearMonthQueue), ["week"]),
date: [].concat(_toConsumableArray(decadeYearMonthQueue), ["date"])
};
var queue = pickerQueue[picker] || decadeYearMonthQueue;
var index2 = queue.indexOf(mergedMode);
var nextMode = queue[index2 + 1];
if (nextMode) {
triggerModeChange(nextMode, nextValue);
}
}
};
var hoverRangeDate = React.useMemo(function() {
var start;
var end;
if (Array.isArray(hoverRangeValue)) {
var _hoverRangeValue = _slicedToArray(hoverRangeValue, 2);
start = _hoverRangeValue[0];
end = _hoverRangeValue[1];
} else {
start = hoverRangeValue;
}
if (!start && !end) {
return null;
}
start = start || end;
end = end || start;
return generateConfig.isAfter(start, end) ? [end, start] : [start, end];
}, [hoverRangeValue, generateConfig]);
var onInternalCellRender = useCellRender(cellRender, dateRender, monthCellRender);
var PanelComponent = components[internalMode] || DefaultComponents[internalMode] || DatePanel;
var parentHackContext = React.useContext(PickerHackContext);
var pickerPanelContext = React.useMemo(function() {
return _objectSpread2(_objectSpread2({}, parentHackContext), {}, {
hideHeader
});
}, [parentHackContext, hideHeader]);
if (process.env.NODE_ENV !== "production") {
warningOnce(!mergedValue || mergedValue.every(function(val) {
return generateConfig.isValidate(val);
}), "Invalidate date pass to `value` or `defaultValue`.");
}
var panelCls = "".concat(mergedPrefixCls, "-panel");
var panelProps = pickProps(props, [
// Week
"showWeek",
// Icons
"prevIcon",
"nextIcon",
"superPrevIcon",
"superNextIcon",
// Disabled
"disabledDate",
"minDate",
"maxDate",
// Hover
"onHover"
]);
return /* @__PURE__ */ React.createElement(PickerHackContext.Provider, {
value: pickerPanelContext
}, /* @__PURE__ */ React.createElement("div", {
ref: rootRef,
tabIndex,
className: classNames(panelCls, _defineProperty({}, "".concat(panelCls, "-rtl"), direction === "rtl"))
}, /* @__PURE__ */ React.createElement(PanelComponent, _extends({}, panelProps, {
// Time
showTime: mergedShowTime,
prefixCls: mergedPrefixCls,
locale: filledLocale,
generateConfig,
onModeChange: triggerModeChange,
pickerValue: mergedPickerValue,
onPickerValueChange: function onPickerValueChange2(nextPickerValue) {
setPickerValue(nextPickerValue, true);
},
value: mergedValue[0],
onSelect: onPanelValueSelect,
values: mergedValue,
cellRender: onInternalCellRender,
hoverRangeValue: hoverRangeDate,
hoverValue
}))));
}
var RefPanelPicker = /* @__PURE__ */ React.memo(/* @__PURE__ */ React.forwardRef(PickerPanel));
if (process.env.NODE_ENV !== "production") {
RefPanelPicker.displayName = "PanelPicker";
}
function PopupPanel(props) {
var picker = props.picker, multiplePanel = props.multiplePanel, pickerValue = props.pickerValue, onPickerValueChange = props.onPickerValueChange, needConfirm = props.needConfirm, onSubmit = props.onSubmit, range3 = props.range, hoverValue = props.hoverValue;
var _React$useContext = React.useContext(PickerContext), prefixCls = _React$useContext.prefixCls, generateConfig = _React$useContext.generateConfig;
var internalOffsetDate = React.useCallback(function(date4, offset) {
return offsetPanelDate(generateConfig, picker, date4, offset);
}, [generateConfig, picker]);
var nextPickerValue = React.useMemo(function() {
return internalOffsetDate(pickerValue, 1);
}, [pickerValue, internalOffsetDate]);
var onSecondPickerValueChange = function onSecondPickerValueChange2(nextDate) {
onPickerValueChange(internalOffsetDate(nextDate, -1));
};
var sharedContext = {
onCellDblClick: function onCellDblClick() {
if (needConfirm) {
onSubmit();
}
}
};
var hideHeader = picker === "time";
var pickerProps = _objectSpread2(_objectSpread2({}, props), {}, {
hoverValue: null,
hoverRangeValue: null,
hideHeader
});
if (range3) {
pickerProps.hoverRangeValue = hoverValue;
} else {
pickerProps.hoverValue = hoverValue;
}
if (multiplePanel) {
return /* @__PURE__ */ React.createElement("div", {
className: "".concat(prefixCls, "-panels")
}, /* @__PURE__ */ React.createElement(PickerHackContext.Provider, {
value: _objectSpread2(_objectSpread2({}, sharedContext), {}, {
hideNext: true
})
}, /* @__PURE__ */ React.createElement(RefPanelPicker, pickerProps)), /* @__PURE__ */ React.createElement(PickerHackContext.Provider, {
value: _objectSpread2(_objectSpread2({}, sharedContext), {}, {
hidePrev: true
})
}, /* @__PURE__ */ React.createElement(RefPanelPicker, _extends({}, pickerProps, {
pickerValue: nextPickerValue,
onPickerValueChange: onSecondPickerValueChange
}))));
}
return /* @__PURE__ */ React.createElement(PickerHackContext.Provider, {
value: _objectSpread2({}, sharedContext)
}, /* @__PURE__ */ React.createElement(RefPanelPicker, pickerProps));
}
function executeValue(value) {
return typeof value === "function" ? value() : value;
}
function PresetPanel(props) {
var prefixCls = props.prefixCls, presets = props.presets, _onClick = props.onClick, onHover = props.onHover;
if (!presets.length) {
return null;
}
return /* @__PURE__ */ React.createElement("div", {
className: "".concat(prefixCls, "-presets")
}, /* @__PURE__ */ React.createElement("ul", null, presets.map(function(_ref, index2) {
var label = _ref.label, value = _ref.value;
return /* @__PURE__ */ React.createElement("li", {
key: index2,
onClick: function onClick() {
_onClick(executeValue(value));
},
onMouseEnter: function onMouseEnter() {
onHover(executeValue(value));
},
onMouseLeave: function onMouseLeave() {
onHover(null);
}
}, label);
})));
}
function Popup(props) {
var panelRender = props.panelRender, internalMode = props.internalMode, picker = props.picker, showNow = props.showNow, range3 = props.range, multiple = props.multiple, _props$activeOffset = props.activeOffset, activeOffset = _props$activeOffset === void 0 ? 0 : _props$activeOffset, placement = props.placement, presets = props.presets, onPresetHover = props.onPresetHover, onPresetSubmit = props.onPresetSubmit, onFocus = props.onFocus, onBlur = props.onBlur, onPanelMouseDown = props.onPanelMouseDown, direction = props.direction, value = props.value, onSelect = props.onSelect, isInvalid = props.isInvalid, defaultOpenValue = props.defaultOpenValue, onOk = props.onOk, onSubmit = props.onSubmit;
var _React$useContext = React.useContext(PickerContext), prefixCls = _React$useContext.prefixCls;
var panelPrefixCls = "".concat(prefixCls, "-panel");
var rtl = direction === "rtl";
var arrowRef = React.useRef(null);
var wrapperRef = React.useRef(null);
var _React$useState = React.useState(0), _React$useState2 = _slicedToArray(_React$useState, 2), containerWidth = _React$useState2[0], setContainerWidth = _React$useState2[1];
var _React$useState3 = React.useState(0), _React$useState4 = _slicedToArray(_React$useState3, 2), containerOffset = _React$useState4[0], setContainerOffset = _React$useState4[1];
var onResize2 = function onResize3(info) {
if (info.offsetWidth) {
setContainerWidth(info.offsetWidth);
}
};
React.useEffect(function() {
if (range3) {
var _arrowRef$current;
var arrowWidth = ((_arrowRef$current = arrowRef.current) === null || _arrowRef$current === void 0 ? void 0 : _arrowRef$current.offsetWidth) || 0;
var maxOffset = containerWidth - arrowWidth;
if (activeOffset <= maxOffset) {
setContainerOffset(0);
} else {
setContainerOffset(activeOffset + arrowWidth - containerWidth);
}
}
}, [containerWidth, activeOffset, range3]);
function filterEmpty(list) {
return list.filter(function(item) {
return item;
});
}
var valueList = React.useMemo(function() {
return filterEmpty(toArray$1(value));
}, [value]);
var isTimePickerEmptyValue = picker === "time" && !valueList.length;
var footerSubmitValue = React.useMemo(function() {
if (isTimePickerEmptyValue) {
return filterEmpty([defaultOpenValue]);
}
return valueList;
}, [isTimePickerEmptyValue, valueList, defaultOpenValue]);
var popupPanelValue = isTimePickerEmptyValue ? defaultOpenValue : valueList;
var disableSubmit = React.useMemo(function() {
if (!footerSubmitValue.length) {
return true;
}
return footerSubmitValue.some(function(val) {
return isInvalid(val);
});
}, [footerSubmitValue, isInvalid]);
var onFooterSubmit = function onFooterSubmit2() {
if (isTimePickerEmptyValue) {
onSelect(defaultOpenValue);
}
onOk();
onSubmit();
};
var mergedNodes = /* @__PURE__ */ React.createElement("div", {
className: "".concat(prefixCls, "-panel-layout")
}, /* @__PURE__ */ React.createElement(PresetPanel, {
prefixCls,
presets,
onClick: onPresetSubmit,
onHover: onPresetHover
}), /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(PopupPanel, _extends({}, props, {
value: popupPanelValue
})), /* @__PURE__ */ React.createElement(Footer, _extends({}, props, {
showNow: multiple ? false : showNow,
invalid: disableSubmit,
onSubmit: onFooterSubmit
}))));
if (panelRender) {
mergedNodes = panelRender(mergedNodes);
}
var containerPrefixCls = "".concat(panelPrefixCls, "-container");
var marginLeft = "marginLeft";
var marginRight = "marginRight";
var renderNode = /* @__PURE__ */ React.createElement("div", {
onMouseDown: onPanelMouseDown,
tabIndex: -1,
className: classNames(
containerPrefixCls,
// Used for Today Button style, safe to remove if no need
"".concat(prefixCls, "-").concat(internalMode, "-panel-container")
),
style: _defineProperty(_defineProperty({}, rtl ? marginRight : marginLeft, containerOffset), rtl ? marginLeft : marginRight, "auto"),
onFocus,
onBlur
}, mergedNodes);
if (range3) {
var realPlacement = getRealPlacement(placement, rtl);
var offsetUnit = getoffsetUnit(realPlacement, rtl);
renderNode = /* @__PURE__ */ React.createElement("div", {
onMouseDown: onPanelMouseDown,
ref: wrapperRef,
className: classNames("".concat(prefixCls, "-range-wrapper"), "".concat(prefixCls, "-").concat(picker, "-range-wrapper"))
}, /* @__PURE__ */ React.createElement("div", {
ref: arrowRef,
className: "".concat(prefixCls, "-range-arrow"),
style: _defineProperty({}, offsetUnit, activeOffset)
}), /* @__PURE__ */ React.createElement(RefResizeObserver, {
onResize: onResize2
}, renderNode));
}
return renderNode;
}
function useInputProps(props, postProps) {
var format2 = props.format, maskFormat = props.maskFormat, generateConfig = props.generateConfig, locale2 = props.locale, preserveInvalidOnBlur = props.preserveInvalidOnBlur, inputReadOnly = props.inputReadOnly, required4 = props.required, ariaRequired = props["aria-required"], onSubmit = props.onSubmit, _onFocus = props.onFocus, _onBlur = props.onBlur, onInputChange = props.onInputChange, onInvalid = props.onInvalid, open = props.open, onOpenChange = props.onOpenChange, _onKeyDown = props.onKeyDown, _onChange = props.onChange, activeHelp = props.activeHelp, name = props.name, autoComplete = props.autoComplete, id = props.id, value = props.value, invalid = props.invalid, placeholder = props.placeholder, disabled = props.disabled, activeIndex = props.activeIndex, allHelp = props.allHelp, picker = props.picker;
var parseDate = function parseDate2(str, formatStr) {
var parsed = generateConfig.locale.parse(locale2.locale, str, [formatStr]);
return parsed && generateConfig.isValidate(parsed) ? parsed : null;
};
var firstFormat = format2[0];
var getText = React.useCallback(function(date4) {
return formatValue(date4, {
locale: locale2,
format: firstFormat,
generateConfig
});
}, [locale2, generateConfig, firstFormat]);
var valueTexts = React.useMemo(function() {
return value.map(getText);
}, [value, getText]);
var size = React.useMemo(function() {
var defaultSize = picker === "time" ? 8 : 10;
var length2 = typeof firstFormat === "function" ? firstFormat(generateConfig.getNow()).length : firstFormat.length;
return Math.max(defaultSize, length2) + 2;
}, [firstFormat, picker, generateConfig]);
var _validateFormat = function validateFormat(text) {
for (var i = 0; i < format2.length; i += 1) {
var singleFormat = format2[i];
if (typeof singleFormat === "string") {
var parsed = parseDate(text, singleFormat);
if (parsed) {
return parsed;
}
}
}
return false;
};
var getInputProps = function getInputProps2(index2) {
function getProp(propValue) {
return index2 !== void 0 ? propValue[index2] : propValue;
}
var pickedAttrs = pickAttrs(props, {
aria: true,
data: true
});
var inputProps = _objectSpread2(_objectSpread2({}, pickedAttrs), {}, {
// ============== Shared ==============
format: maskFormat,
validateFormat: function validateFormat(text) {
return !!_validateFormat(text);
},
preserveInvalidOnBlur,
readOnly: inputReadOnly,
required: required4,
"aria-required": ariaRequired,
name,
autoComplete,
size,
// ============= By Index =============
id: getProp(id),
value: getProp(valueTexts) || "",
invalid: getProp(invalid),
placeholder: getProp(placeholder),
active: activeIndex === index2,
helped: allHelp || activeHelp && activeIndex === index2,
disabled: getProp(disabled),
onFocus: function onFocus(event) {
_onFocus(event, index2);
},
onBlur: function onBlur(event) {
_onBlur(event, index2);
},
onSubmit,
// Get validate text value
onChange: function onChange(text) {
onInputChange();
var parsed = _validateFormat(text);
if (parsed) {
onInvalid(false, index2);
_onChange(parsed, index2);
return;
}
onInvalid(!!text, index2);
},
onHelp: function onHelp() {
onOpenChange(true, {
index: index2
});
},
onKeyDown: function onKeyDown(event) {
var prevented = false;
_onKeyDown === null || _onKeyDown === void 0 || _onKeyDown(event, function() {
if (process.env.NODE_ENV !== "production") {
warningOnce(false, "`preventDefault` callback is deprecated. Please call `event.preventDefault` directly.");
}
prevented = true;
});
if (!event.defaultPrevented && !prevented) {
switch (event.key) {
case "Escape":
onOpenChange(false, {
index: index2
});
break;
case "Enter":
if (!open) {
onOpenChange(true);
}
break;
}
}
}
}, postProps === null || postProps === void 0 ? void 0 : postProps({
valueTexts
}));
Object.keys(inputProps).forEach(function(key) {
if (inputProps[key] === void 0) {
delete inputProps[key];
}
});
return inputProps;
};
return [getInputProps, getText];
}
var propNames = ["onMouseEnter", "onMouseLeave"];
function useRootProps(props) {
return React.useMemo(function() {
return pickProps(props, propNames);
}, [props]);
}
var _excluded$9 = ["icon", "type"], _excluded2$2 = ["onClear"];
function Icon(props) {
var icon = props.icon, type4 = props.type, restProps = _objectWithoutProperties(props, _excluded$9);
var _React$useContext = React.useContext(PickerContext), prefixCls = _React$useContext.prefixCls;
return icon ? /* @__PURE__ */ React.createElement("span", _extends({
className: "".concat(prefixCls, "-").concat(type4)
}, restProps), icon) : null;
}
function ClearIcon(_ref) {
var onClear = _ref.onClear, restProps = _objectWithoutProperties(_ref, _excluded2$2);
return /* @__PURE__ */ React.createElement(Icon, _extends({}, restProps, {
type: "clear",
role: "button",
onMouseDown: function onMouseDown(e) {
e.preventDefault();
},
onClick: function onClick(e) {
e.stopPropagation();
onClear();
}
}));
}
var FORMAT_KEYS = ["YYYY", "MM", "DD", "HH", "mm", "ss", "SSS"];
var REPLACE_KEY = "顧";
var MaskFormat = /* @__PURE__ */ function() {
function MaskFormat2(format2) {
_classCallCheck(this, MaskFormat2);
_defineProperty(this, "format", void 0);
_defineProperty(this, "maskFormat", void 0);
_defineProperty(this, "cells", void 0);
_defineProperty(this, "maskCells", void 0);
this.format = format2;
var replaceKeys = FORMAT_KEYS.map(function(key) {
return "(".concat(key, ")");
}).join("|");
var replaceReg = new RegExp(replaceKeys, "g");
this.maskFormat = format2.replace(
replaceReg,
// Use Chinese character to avoid user use it in format
function(key) {
return REPLACE_KEY.repeat(key.length);
}
);
var cellReg = new RegExp("(".concat(FORMAT_KEYS.join("|"), ")"));
var strCells = (format2.split(cellReg) || []).filter(function(str) {
return str;
});
var offset = 0;
this.cells = strCells.map(function(text) {
var mask = FORMAT_KEYS.includes(text);
var start = offset;
var end = offset + text.length;
offset = end;
return {
text,
mask,
start,
end
};
});
this.maskCells = this.cells.filter(function(cell) {
return cell.mask;
});
}
_createClass(MaskFormat2, [{
key: "getSelection",
value: function getSelection(maskCellIndex) {
var _ref = this.maskCells[maskCellIndex] || {}, start = _ref.start, end = _ref.end;
return [start || 0, end || 0];
}
/** Check given text match format */
}, {
key: "match",
value: function match2(text) {
for (var i = 0; i < this.maskFormat.length; i += 1) {
var maskChar = this.maskFormat[i];
var textChar = text[i];
if (!textChar || maskChar !== REPLACE_KEY && maskChar !== textChar) {
return false;
}
}
return true;
}
/** Get mask cell count */
}, {
key: "size",
value: function size() {
return this.maskCells.length;
}
}, {
key: "getMaskCellIndex",
value: function getMaskCellIndex(anchorIndex) {
var closetDist = Number.MAX_SAFE_INTEGER;
var closetIndex = 0;
for (var i = 0; i < this.maskCells.length; i += 1) {
var _this$maskCells$i = this.maskCells[i], start = _this$maskCells$i.start, end = _this$maskCells$i.end;
if (anchorIndex >= start && anchorIndex <= end) {
return i;
}
var dist = Math.min(Math.abs(anchorIndex - start), Math.abs(anchorIndex - end));
if (dist < closetDist) {
closetDist = dist;
closetIndex = i;
}
}
return closetIndex;
}
}]);
return MaskFormat2;
}();
function getMaskRange(key) {
var PresetRange = {
YYYY: [0, 9999, (/* @__PURE__ */ new Date()).getFullYear()],
MM: [1, 12],
DD: [1, 31],
HH: [0, 23],
mm: [0, 59],
ss: [0, 59],
SSS: [0, 999]
};
return PresetRange[key];
}
var _excluded$8 = ["active", "showActiveCls", "suffixIcon", "format", "validateFormat", "onChange", "onInput", "helped", "onHelp", "onSubmit", "onKeyDown", "preserveInvalidOnBlur", "invalid", "clearIcon"];
var Input = /* @__PURE__ */ React.forwardRef(function(props, ref) {
var active = props.active, _props$showActiveCls = props.showActiveCls, showActiveCls = _props$showActiveCls === void 0 ? true : _props$showActiveCls, suffixIcon = props.suffixIcon, format2 = props.format, validateFormat = props.validateFormat, onChange = props.onChange;
props.onInput;
var helped = props.helped, onHelp = props.onHelp, onSubmit = props.onSubmit, onKeyDown = props.onKeyDown, _props$preserveInvali = props.preserveInvalidOnBlur, preserveInvalidOnBlur = _props$preserveInvali === void 0 ? false : _props$preserveInvali, invalid = props.invalid, clearIcon = props.clearIcon, restProps = _objectWithoutProperties(props, _excluded$8);
var value = props.value, onFocus = props.onFocus, onBlur = props.onBlur, onMouseUp = props.onMouseUp;
var _React$useContext = React.useContext(PickerContext), prefixCls = _React$useContext.prefixCls, _React$useContext$inp = _React$useContext.input, Component = _React$useContext$inp === void 0 ? "input" : _React$useContext$inp;
var inputPrefixCls = "".concat(prefixCls, "-input");
var _React$useState = React.useState(false), _React$useState2 = _slicedToArray(_React$useState, 2), focused = _React$useState2[0], setFocused = _React$useState2[1];
var _React$useState3 = React.useState(value), _React$useState4 = _slicedToArray(_React$useState3, 2), internalInputValue = _React$useState4[0], setInputValue = _React$useState4[1];
var _React$useState5 = React.useState(""), _React$useState6 = _slicedToArray(_React$useState5, 2), focusCellText = _React$useState6[0], setFocusCellText = _React$useState6[1];
var _React$useState7 = React.useState(null), _React$useState8 = _slicedToArray(_React$useState7, 2), focusCellIndex = _React$useState8[0], setFocusCellIndex = _React$useState8[1];
var _React$useState9 = React.useState(null), _React$useState10 = _slicedToArray(_React$useState9, 2), forceSelectionSyncMark = _React$useState10[0], forceSelectionSync = _React$useState10[1];
var inputValue = internalInputValue || "";
React.useEffect(function() {
setInputValue(value);
}, [value]);
var holderRef = React.useRef();
var inputRef = React.useRef();
React.useImperativeHandle(ref, function() {
return {
nativeElement: holderRef.current,
inputElement: inputRef.current,
focus: function focus(options) {
inputRef.current.focus(options);
},
blur: function blur() {
inputRef.current.blur();
}
};
});
var maskFormat = React.useMemo(function() {
return new MaskFormat(format2 || "");
}, [format2]);
var _React$useMemo = React.useMemo(function() {
if (helped) {
return [0, 0];
}
return maskFormat.getSelection(focusCellIndex);
}, [maskFormat, focusCellIndex, helped]), _React$useMemo2 = _slicedToArray(_React$useMemo, 2), selectionStart = _React$useMemo2[0], selectionEnd = _React$useMemo2[1];
var onModify = function onModify2(text) {
if (text && text !== format2 && text !== value) {
onHelp();
}
};
var triggerInputChange = useEvent(function(text) {
if (validateFormat(text)) {
onChange(text);
}
setInputValue(text);
onModify(text);
});
var onInternalChange = function onInternalChange2(event) {
if (!format2) {
var text = event.target.value;
onModify(text);
setInputValue(text);
onChange(text);
}
};
var onFormatPaste = function onFormatPaste2(event) {
var pasteText = event.clipboardData.getData("text");
if (validateFormat(pasteText)) {
triggerInputChange(pasteText);
}
};
var mouseDownRef = React.useRef(false);
var onFormatMouseDown = function onFormatMouseDown2() {
mouseDownRef.current = true;
};
var onFormatMouseUp = function onFormatMouseUp2(event) {
var _ref = event.target, start = _ref.selectionStart;
var closeMaskIndex = maskFormat.getMaskCellIndex(start);
setFocusCellIndex(closeMaskIndex);
forceSelectionSync({});
onMouseUp === null || onMouseUp === void 0 || onMouseUp(event);
mouseDownRef.current = false;
};
var onFormatFocus = function onFormatFocus2(event) {
setFocused(true);
setFocusCellIndex(0);
setFocusCellText("");
onFocus(event);
};
var onSharedBlur = function onSharedBlur2(event) {
onBlur(event);
};
var onFormatBlur = function onFormatBlur2(event) {
setFocused(false);
onSharedBlur(event);
};
useLockEffect(active, function() {
if (!active && !preserveInvalidOnBlur) {
setInputValue(value);
}
});
var onSharedKeyDown = function onSharedKeyDown2(event) {
if (event.key === "Enter" && validateFormat(inputValue)) {
onSubmit();
}
onKeyDown === null || onKeyDown === void 0 || onKeyDown(event);
};
var onFormatKeyDown = function onFormatKeyDown2(event) {
onSharedKeyDown(event);
var key = event.key;
var nextCellText = null;
var nextFillText = null;
var maskCellLen = selectionEnd - selectionStart;
var cellFormat = format2.slice(selectionStart, selectionEnd);
var offsetCellIndex = function offsetCellIndex2(offset) {
setFocusCellIndex(function(idx) {
var nextIndex = idx + offset;
nextIndex = Math.max(nextIndex, 0);
nextIndex = Math.min(nextIndex, maskFormat.size() - 1);
return nextIndex;
});
};
var offsetCellValue = function offsetCellValue2(offset) {
var _getMaskRange = getMaskRange(cellFormat), _getMaskRange2 = _slicedToArray(_getMaskRange, 3), rangeStart = _getMaskRange2[0], rangeEnd = _getMaskRange2[1], rangeDefault = _getMaskRange2[2];
var currentText = inputValue.slice(selectionStart, selectionEnd);
var currentTextNum = Number(currentText);
if (isNaN(currentTextNum)) {
return String(rangeDefault ? rangeDefault : offset > 0 ? rangeStart : rangeEnd);
}
var num = currentTextNum + offset;
var range3 = rangeEnd - rangeStart + 1;
return String(rangeStart + (range3 + num - rangeStart) % range3);
};
switch (key) {
case "Backspace":
case "Delete":
nextCellText = "";
nextFillText = cellFormat;
break;
case "ArrowLeft":
nextCellText = "";
offsetCellIndex(-1);
break;
case "ArrowRight":
nextCellText = "";
offsetCellIndex(1);
break;
case "ArrowUp":
nextCellText = "";
nextFillText = offsetCellValue(1);
break;
case "ArrowDown":
nextCellText = "";
nextFillText = offsetCellValue(-1);
break;
default:
if (!isNaN(Number(key))) {
nextCellText = focusCellText + key;
nextFillText = nextCellText;
}
break;
}
if (nextCellText !== null) {
setFocusCellText(nextCellText);
if (nextCellText.length >= maskCellLen) {
offsetCellIndex(1);
setFocusCellText("");
}
}
if (nextFillText !== null) {
var nextFocusValue = (
// before
inputValue.slice(0, selectionStart) + // replace
leftPad(nextFillText, maskCellLen) + // after
inputValue.slice(selectionEnd)
);
triggerInputChange(nextFocusValue.slice(0, format2.length));
}
forceSelectionSync({});
};
var rafRef = React.useRef();
useLayoutEffect(function() {
if (!focused || !format2 || mouseDownRef.current) {
return;
}
if (!maskFormat.match(inputValue)) {
triggerInputChange(format2);
return;
}
inputRef.current.setSelectionRange(selectionStart, selectionEnd);
rafRef.current = wrapperRaf(function() {
inputRef.current.setSelectionRange(selectionStart, selectionEnd);
});
return function() {
wrapperRaf.cancel(rafRef.current);
};
}, [maskFormat, format2, focused, inputValue, focusCellIndex, selectionStart, selectionEnd, forceSelectionSyncMark, triggerInputChange]);
var inputProps = format2 ? {
onFocus: onFormatFocus,
onBlur: onFormatBlur,
onKeyDown: onFormatKeyDown,
onMouseDown: onFormatMouseDown,
onMouseUp: onFormatMouseUp,
onPaste: onFormatPaste
} : {};
return /* @__PURE__ */ React.createElement("div", {
ref: holderRef,
className: classNames(inputPrefixCls, _defineProperty(_defineProperty({}, "".concat(inputPrefixCls, "-active"), active && showActiveCls), "".concat(inputPrefixCls, "-placeholder"), helped))
}, /* @__PURE__ */ React.createElement(Component, _extends({
ref: inputRef,
"aria-invalid": invalid,
autoComplete: "off"
}, restProps, {
onKeyDown: onSharedKeyDown,
onBlur: onSharedBlur
// Replace with format
}, inputProps, {
// Value
value: inputValue,
onChange: onInternalChange
})), /* @__PURE__ */ React.createElement(Icon, {
type: "suffix",
icon: suffixIcon
}), clearIcon);
});
if (process.env.NODE_ENV !== "production") {
Input.displayName = "Input";
}
var _excluded$7 = ["id", "clearIcon", "suffixIcon", "separator", "activeIndex", "activeHelp", "allHelp", "focused", "onFocus", "onBlur", "onKeyDown", "locale", "generateConfig", "placeholder", "className", "style", "onClick", "onClear", "value", "onChange", "onSubmit", "onInputChange", "format", "maskFormat", "preserveInvalidOnBlur", "onInvalid", "disabled", "invalid", "inputReadOnly", "direction", "onOpenChange", "onActiveOffset", "placement", "onMouseDown", "required", "aria-required", "autoFocus"], _excluded2$1 = ["index"];
function RangeSelector(props, ref) {
var id = props.id, clearIcon = props.clearIcon, suffixIcon = props.suffixIcon, _props$separator = props.separator, separator = _props$separator === void 0 ? "~" : _props$separator, activeIndex = props.activeIndex;
props.activeHelp;
props.allHelp;
var focused = props.focused;
props.onFocus;
props.onBlur;
props.onKeyDown;
props.locale;
props.generateConfig;
var placeholder = props.placeholder, className = props.className, style2 = props.style, onClick = props.onClick, onClear = props.onClear, value = props.value;
props.onChange;
props.onSubmit;
props.onInputChange;
props.format;
props.maskFormat;
props.preserveInvalidOnBlur;
props.onInvalid;
var disabled = props.disabled, invalid = props.invalid;
props.inputReadOnly;
var direction = props.direction;
props.onOpenChange;
var onActiveOffset = props.onActiveOffset, placement = props.placement, _onMouseDown = props.onMouseDown;
props.required;
props["aria-required"];
var autoFocus = props.autoFocus, restProps = _objectWithoutProperties(props, _excluded$7);
var rtl = direction === "rtl";
var _React$useContext = React.useContext(PickerContext), prefixCls = _React$useContext.prefixCls;
var ids = React.useMemo(function() {
if (typeof id === "string") {
return [id];
}
var mergedId = id || {};
return [mergedId.start, mergedId.end];
}, [id]);
var rootRef = React.useRef();
var inputStartRef = React.useRef();
var inputEndRef = React.useRef();
var getInput = function getInput2(index2) {
var _index;
return (_index = [inputStartRef, inputEndRef][index2]) === null || _index === void 0 ? void 0 : _index.current;
};
React.useImperativeHandle(ref, function() {
return {
nativeElement: rootRef.current,
focus: function focus(options) {
if (_typeof(options) === "object") {
var _getInput;
var _ref = options || {}, _ref$index = _ref.index, _index2 = _ref$index === void 0 ? 0 : _ref$index, rest = _objectWithoutProperties(_ref, _excluded2$1);
(_getInput = getInput(_index2)) === null || _getInput === void 0 || _getInput.focus(rest);
} else {
var _getInput2;
(_getInput2 = getInput(options !== null && options !== void 0 ? options : 0)) === null || _getInput2 === void 0 || _getInput2.focus();
}
},
blur: function blur() {
var _getInput3, _getInput4;
(_getInput3 = getInput(0)) === null || _getInput3 === void 0 || _getInput3.blur();
(_getInput4 = getInput(1)) === null || _getInput4 === void 0 || _getInput4.blur();
}
};
});
var rootProps = useRootProps(restProps);
var mergedPlaceholder = React.useMemo(function() {
return Array.isArray(placeholder) ? placeholder : [placeholder, placeholder];
}, [placeholder]);
var _useInputProps = useInputProps(_objectSpread2(_objectSpread2({}, props), {}, {
id: ids,
placeholder: mergedPlaceholder
})), _useInputProps2 = _slicedToArray(_useInputProps, 1), getInputProps = _useInputProps2[0];
var realPlacement = getRealPlacement(placement, rtl);
var offsetUnit = getoffsetUnit(realPlacement, rtl);
var placementRight = realPlacement === null || realPlacement === void 0 ? void 0 : realPlacement.toLowerCase().endsWith("right");
var _React$useState = React.useState({
position: "absolute",
width: 0
}), _React$useState2 = _slicedToArray(_React$useState, 2), activeBarStyle = _React$useState2[0], setActiveBarStyle = _React$useState2[1];
var syncActiveOffset = useEvent(function() {
var input = getInput(activeIndex);
if (input) {
var _input$nativeElement = input.nativeElement, offsetWidth = _input$nativeElement.offsetWidth, offsetLeft = _input$nativeElement.offsetLeft, offsetParent = _input$nativeElement.offsetParent;
var parentWidth = (offsetParent === null || offsetParent === void 0 ? void 0 : offsetParent.offsetWidth) || 0;
var activeOffset = placementRight ? parentWidth - offsetWidth - offsetLeft : offsetLeft;
setActiveBarStyle(function(ori) {
return _objectSpread2(_objectSpread2({}, ori), {}, _defineProperty({
width: offsetWidth
}, offsetUnit, activeOffset));
});
onActiveOffset(activeOffset);
}
});
React.useEffect(function() {
syncActiveOffset();
}, [activeIndex]);
var showClear = clearIcon && (value[0] && !disabled[0] || value[1] && !disabled[1]);
var startAutoFocus = autoFocus && !disabled[0];
var endAutoFocus = autoFocus && !startAutoFocus && !disabled[1];
return /* @__PURE__ */ React.createElement(RefResizeObserver, {
onResize: syncActiveOffset
}, /* @__PURE__ */ React.createElement("div", _extends({}, rootProps, {
className: classNames(prefixCls, "".concat(prefixCls, "-range"), _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-focused"), focused), "".concat(prefixCls, "-disabled"), disabled.every(function(i) {
return i;
})), "".concat(prefixCls, "-invalid"), invalid.some(function(i) {
return i;
})), "".concat(prefixCls, "-rtl"), rtl), className),
style: style2,
ref: rootRef,
onClick,
onMouseDown: function onMouseDown(e) {
var target = e.target;
if (target !== inputStartRef.current.inputElement && target !== inputEndRef.current.inputElement) {
e.preventDefault();
}
_onMouseDown === null || _onMouseDown === void 0 || _onMouseDown(e);
}
}), /* @__PURE__ */ React.createElement(Input, _extends({
ref: inputStartRef
}, getInputProps(0), {
autoFocus: startAutoFocus,
"date-range": "start"
})), /* @__PURE__ */ React.createElement("div", {
className: "".concat(prefixCls, "-range-separator")
}, separator), /* @__PURE__ */ React.createElement(Input, _extends({
ref: inputEndRef
}, getInputProps(1), {
autoFocus: endAutoFocus,
"date-range": "end"
})), /* @__PURE__ */ React.createElement("div", {
className: "".concat(prefixCls, "-active-bar"),
style: activeBarStyle
}), /* @__PURE__ */ React.createElement(Icon, {
type: "suffix",
icon: suffixIcon
}), showClear && /* @__PURE__ */ React.createElement(ClearIcon, {
icon: clearIcon,
onClear
})));
}
var RefRangeSelector = /* @__PURE__ */ React.forwardRef(RangeSelector);
if (process.env.NODE_ENV !== "production") {
RefRangeSelector.displayName = "RangeSelector";
}
function separateConfig(config, defaultConfig2) {
var singleConfig = config !== null && config !== void 0 ? config : defaultConfig2;
if (Array.isArray(singleConfig)) {
return singleConfig;
}
return [singleConfig, singleConfig];
}
function getActiveRange(activeIndex) {
return activeIndex === 1 ? "end" : "start";
}
function RangePicker(props, ref) {
var _useFilledProps = useFilledProps(props, function() {
var disabled2 = props.disabled, allowEmpty2 = props.allowEmpty;
var mergedDisabled = separateConfig(disabled2, false);
var mergedAllowEmpty = separateConfig(allowEmpty2, false);
return {
disabled: mergedDisabled,
allowEmpty: mergedAllowEmpty
};
}), _useFilledProps2 = _slicedToArray(_useFilledProps, 6), filledProps = _useFilledProps2[0], internalPicker = _useFilledProps2[1], complexPicker = _useFilledProps2[2], formatList = _useFilledProps2[3], maskFormat = _useFilledProps2[4], isInvalidateDate = _useFilledProps2[5];
var prefixCls = filledProps.prefixCls, styles = filledProps.styles, classNames2 = filledProps.classNames, placement = filledProps.placement, defaultValue = filledProps.defaultValue, value = filledProps.value, needConfirm = filledProps.needConfirm, onKeyDown = filledProps.onKeyDown, disabled = filledProps.disabled, allowEmpty = filledProps.allowEmpty, disabledDate = filledProps.disabledDate, minDate = filledProps.minDate, maxDate = filledProps.maxDate, defaultOpen = filledProps.defaultOpen, open = filledProps.open, onOpenChange = filledProps.onOpenChange, locale2 = filledProps.locale, generateConfig = filledProps.generateConfig, picker = filledProps.picker, showNow = filledProps.showNow, showToday = filledProps.showToday, showTime = filledProps.showTime, mode = filledProps.mode, onPanelChange = filledProps.onPanelChange, onCalendarChange = filledProps.onCalendarChange, onOk = filledProps.onOk, defaultPickerValue = filledProps.defaultPickerValue, pickerValue = filledProps.pickerValue, onPickerValueChange = filledProps.onPickerValueChange, inputReadOnly = filledProps.inputReadOnly, suffixIcon = filledProps.suffixIcon, onFocus = filledProps.onFocus, onBlur = filledProps.onBlur, presets = filledProps.presets, ranges = filledProps.ranges, components = filledProps.components, cellRender = filledProps.cellRender, dateRender = filledProps.dateRender, monthCellRender = filledProps.monthCellRender, onClick = filledProps.onClick;
var selectorRef = usePickerRef(ref);
var _useOpen = useOpen(open, defaultOpen, disabled, onOpenChange), _useOpen2 = _slicedToArray(_useOpen, 2), mergedOpen = _useOpen2[0], setMergeOpen = _useOpen2[1];
var triggerOpen = function triggerOpen2(nextOpen, config) {
if (disabled.some(function(fieldDisabled) {
return !fieldDisabled;
}) || !nextOpen) {
setMergeOpen(nextOpen, config);
}
};
var _useInnerValue = useInnerValue(generateConfig, locale2, formatList, true, false, defaultValue, value, onCalendarChange, onOk), _useInnerValue2 = _slicedToArray(_useInnerValue, 5), mergedValue = _useInnerValue2[0], setInnerValue = _useInnerValue2[1], getCalendarValue = _useInnerValue2[2], triggerCalendarChange = _useInnerValue2[3], triggerOk = _useInnerValue2[4];
var calendarValue = getCalendarValue();
var _useRangeActive = useRangeActive(disabled, allowEmpty, mergedOpen), _useRangeActive2 = _slicedToArray(_useRangeActive, 7), focused = _useRangeActive2[0], triggerFocus = _useRangeActive2[1], lastOperation = _useRangeActive2[2], activeIndex = _useRangeActive2[3], setActiveIndex = _useRangeActive2[4], nextActiveIndex = _useRangeActive2[5], activeIndexList = _useRangeActive2[6];
var onSharedFocus = function onSharedFocus2(event, index2) {
triggerFocus(true);
onFocus === null || onFocus === void 0 || onFocus(event, {
range: getActiveRange(index2 !== null && index2 !== void 0 ? index2 : activeIndex)
});
};
var onSharedBlur = function onSharedBlur2(event, index2) {
triggerFocus(false);
onBlur === null || onBlur === void 0 || onBlur(event, {
range: getActiveRange(index2 !== null && index2 !== void 0 ? index2 : activeIndex)
});
};
var mergedShowTime = React.useMemo(function() {
if (!showTime) {
return null;
}
var disabledTime = showTime.disabledTime;
var proxyDisabledTime = disabledTime ? function(date4) {
var range3 = getActiveRange(activeIndex);
var fromDate = getFromDate(calendarValue, activeIndexList, activeIndex);
return disabledTime(date4, range3, {
from: fromDate
});
} : void 0;
return _objectSpread2(_objectSpread2({}, showTime), {}, {
disabledTime: proxyDisabledTime
});
}, [showTime, activeIndex, calendarValue, activeIndexList]);
var _useMergedState = useMergedState([picker, picker], {
value: mode
}), _useMergedState2 = _slicedToArray(_useMergedState, 2), modes = _useMergedState2[0], setModes = _useMergedState2[1];
var mergedMode = modes[activeIndex] || picker;
var internalMode = mergedMode === "date" && mergedShowTime ? "datetime" : mergedMode;
var multiplePanel = internalMode === picker && internalMode !== "time";
var mergedShowNow = useShowNow(picker, mergedMode, showNow, showToday, true);
var _useRangeValue = useRangeValue(filledProps, mergedValue, setInnerValue, getCalendarValue, triggerCalendarChange, disabled, formatList, focused, mergedOpen, isInvalidateDate), _useRangeValue2 = _slicedToArray(_useRangeValue, 2), flushSubmit = _useRangeValue2[0], triggerSubmitChange = _useRangeValue2[1];
var mergedDisabledDate = useRangeDisabledDate(calendarValue, disabled, activeIndexList, generateConfig, locale2, disabledDate);
var _useFieldsInvalidate = useFieldsInvalidate(calendarValue, isInvalidateDate, allowEmpty), _useFieldsInvalidate2 = _slicedToArray(_useFieldsInvalidate, 2), submitInvalidates = _useFieldsInvalidate2[0], onSelectorInvalid = _useFieldsInvalidate2[1];
var _useRangePickerValue = useRangePickerValue(generateConfig, locale2, calendarValue, modes, mergedOpen, activeIndex, internalPicker, multiplePanel, defaultPickerValue, pickerValue, mergedShowTime === null || mergedShowTime === void 0 ? void 0 : mergedShowTime.defaultOpenValue, onPickerValueChange, minDate, maxDate), _useRangePickerValue2 = _slicedToArray(_useRangePickerValue, 2), currentPickerValue = _useRangePickerValue2[0], setCurrentPickerValue = _useRangePickerValue2[1];
var triggerModeChange = useEvent(function(nextPickerValue, nextMode, triggerEvent) {
var clone = fillIndex(modes, activeIndex, nextMode);
if (clone[0] !== modes[0] || clone[1] !== modes[1]) {
setModes(clone);
}
if (onPanelChange && triggerEvent !== false) {
var clonePickerValue = _toConsumableArray(calendarValue);
if (nextPickerValue) {
clonePickerValue[activeIndex] = nextPickerValue;
}
onPanelChange(clonePickerValue, clone);
}
});
var fillCalendarValue = function fillCalendarValue2(date4, index2) {
return (
// Trigger change only when date changed
fillIndex(calendarValue, index2, date4)
);
};
var triggerPartConfirm = function triggerPartConfirm2(date4, skipFocus) {
var nextValue = calendarValue;
if (date4) {
nextValue = fillCalendarValue(date4, activeIndex);
}
var nextIndex = nextActiveIndex(nextValue);
triggerCalendarChange(nextValue);
flushSubmit(activeIndex, nextIndex === null);
if (nextIndex === null) {
triggerOpen(false, {
force: true
});
} else if (!skipFocus) {
selectorRef.current.focus({
index: nextIndex
});
}
};
var onSelectorClick = function onSelectorClick2(event) {
if (!selectorRef.current.nativeElement.contains(document.activeElement)) {
var enabledIndex = disabled.findIndex(function(d) {
return !d;
});
if (enabledIndex >= 0) {
selectorRef.current.focus({
index: enabledIndex
});
}
}
triggerOpen(true);
onClick === null || onClick === void 0 || onClick(event);
};
var onSelectorClear = function onSelectorClear2() {
triggerSubmitChange(null);
triggerOpen(false, {
force: true
});
};
var _React$useState = React.useState(null), _React$useState2 = _slicedToArray(_React$useState, 2), hoverSource = _React$useState2[0], setHoverSource = _React$useState2[1];
var _React$useState3 = React.useState(null), _React$useState4 = _slicedToArray(_React$useState3, 2), internalHoverValues = _React$useState4[0], setInternalHoverValues = _React$useState4[1];
var hoverValues = React.useMemo(function() {
return internalHoverValues || calendarValue;
}, [calendarValue, internalHoverValues]);
React.useEffect(function() {
if (!mergedOpen) {
setInternalHoverValues(null);
}
}, [mergedOpen]);
var _React$useState5 = React.useState(0), _React$useState6 = _slicedToArray(_React$useState5, 2), activeOffset = _React$useState6[0], setActiveOffset = _React$useState6[1];
var presetList = usePresets(presets, ranges);
var onPresetHover = function onPresetHover2(nextValues) {
setInternalHoverValues(nextValues);
setHoverSource("preset");
};
var onPresetSubmit = function onPresetSubmit2(nextValues) {
var passed = triggerSubmitChange(nextValues);
if (passed) {
triggerOpen(false, {
force: true
});
}
};
var onNow = function onNow2(now) {
triggerPartConfirm(now);
};
var onPanelHover = function onPanelHover2(date4) {
setInternalHoverValues(date4 ? fillCalendarValue(date4, activeIndex) : null);
setHoverSource("cell");
};
var onPanelFocus = function onPanelFocus2(event) {
triggerOpen(true);
onSharedFocus(event);
};
var onPanelMouseDown = function onPanelMouseDown2() {
lastOperation("panel");
};
var onPanelSelect = function onPanelSelect2(date4) {
var clone = fillIndex(calendarValue, activeIndex, date4);
triggerCalendarChange(clone);
if (!needConfirm && !complexPicker && internalPicker === internalMode) {
triggerPartConfirm(date4);
}
};
var onPopupClose = function onPopupClose2() {
triggerOpen(false);
};
var onInternalCellRender = useCellRender(cellRender, dateRender, monthCellRender, getActiveRange(activeIndex));
var panelValue = calendarValue[activeIndex] || null;
var isPopupInvalidateDate = useEvent(function(date4) {
return isInvalidateDate(date4, {
activeIndex
});
});
var panelProps = React.useMemo(function() {
var domProps = pickAttrs(filledProps, false);
var restProps = omit(filledProps, [].concat(_toConsumableArray(Object.keys(domProps)), ["onChange", "onCalendarChange", "style", "className", "onPanelChange", "disabledTime"]));
return restProps;
}, [filledProps]);
var panel = /* @__PURE__ */ React.createElement(Popup, _extends({}, panelProps, {
showNow: mergedShowNow,
showTime: mergedShowTime,
range: true,
multiplePanel,
activeOffset,
placement,
disabledDate: mergedDisabledDate,
onFocus: onPanelFocus,
onBlur: onSharedBlur,
onPanelMouseDown,
picker,
mode: mergedMode,
internalMode,
onPanelChange: triggerModeChange,
format: maskFormat,
value: panelValue,
isInvalid: isPopupInvalidateDate,
onChange: null,
onSelect: onPanelSelect,
pickerValue: currentPickerValue,
defaultOpenValue: toArray$1(showTime === null || showTime === void 0 ? void 0 : showTime.defaultOpenValue)[activeIndex],
onPickerValueChange: setCurrentPickerValue,
hoverValue: hoverValues,
onHover: onPanelHover,
needConfirm,
onSubmit: triggerPartConfirm,
onOk: triggerOk,
presets: presetList,
onPresetHover,
onPresetSubmit,
onNow,
cellRender: onInternalCellRender
}));
var onSelectorChange = function onSelectorChange2(date4, index2) {
var clone = fillCalendarValue(date4, index2);
triggerCalendarChange(clone);
};
var onSelectorInputChange = function onSelectorInputChange2() {
lastOperation("input");
};
var onSelectorFocus = function onSelectorFocus2(event, index2) {
lastOperation("input");
triggerOpen(true, {
inherit: true
});
if (activeIndex !== index2 && mergedOpen && !needConfirm && complexPicker) {
triggerPartConfirm(null, true);
}
setActiveIndex(index2);
onSharedFocus(event, index2);
};
var onSelectorBlur = function onSelectorBlur2(event, index2) {
triggerOpen(false);
if (!needConfirm && lastOperation() === "input") {
var nextIndex = nextActiveIndex(calendarValue);
flushSubmit(activeIndex, nextIndex === null);
}
onSharedBlur(event, index2);
};
var onSelectorKeyDown = function onSelectorKeyDown2(event, preventDefault) {
if (event.key === "Tab") {
triggerPartConfirm(null, true);
}
onKeyDown === null || onKeyDown === void 0 || onKeyDown(event, preventDefault);
};
var context = React.useMemo(function() {
return {
prefixCls,
locale: locale2,
generateConfig,
button: components.button,
input: components.input
};
}, [prefixCls, locale2, generateConfig, components.button, components.input]);
useLayoutEffect(function() {
if (mergedOpen && activeIndex !== void 0) {
triggerModeChange(null, picker, false);
}
}, [mergedOpen, activeIndex, picker]);
useLayoutEffect(function() {
var lastOp = lastOperation();
if (!mergedOpen && lastOp === "input") {
triggerOpen(false);
triggerPartConfirm(null, true);
}
if (!mergedOpen && complexPicker && !needConfirm && lastOp === "panel") {
triggerOpen(true);
triggerPartConfirm();
}
}, [mergedOpen]);
if (process.env.NODE_ENV !== "production") {
var isIndexEmpty = function isIndexEmpty2(index2) {
return (
// Value is empty
!(value !== null && value !== void 0 && value[index2]) && // DefaultValue is empty
!(defaultValue !== null && defaultValue !== void 0 && defaultValue[index2])
);
};
if (disabled.some(function(fieldDisabled, index2) {
return fieldDisabled && isIndexEmpty(index2) && !allowEmpty[index2];
})) {
warningOnce(false, "`disabled` should not set with empty `value`. You should set `allowEmpty` or `value` instead.");
}
}
return /* @__PURE__ */ React.createElement(PickerContext.Provider, {
value: context
}, /* @__PURE__ */ React.createElement(PickerTrigger, _extends({}, pickTriggerProps(filledProps), {
popupElement: panel,
popupStyle: styles.popup,
popupClassName: classNames2.popup,
visible: mergedOpen,
onClose: onPopupClose,
range: true
}), /* @__PURE__ */ React.createElement(
RefRangeSelector,
_extends({}, filledProps, {
// Ref
ref: selectorRef,
suffixIcon,
activeIndex: focused || mergedOpen ? activeIndex : null,
activeHelp: !!internalHoverValues,
allHelp: !!internalHoverValues && hoverSource === "preset",
focused,
onFocus: onSelectorFocus,
onBlur: onSelectorBlur,
onKeyDown: onSelectorKeyDown,
onSubmit: triggerPartConfirm,
value: hoverValues,
maskFormat,
onChange: onSelectorChange,
onInputChange: onSelectorInputChange,
format: formatList,
inputReadOnly,
disabled,
open: mergedOpen,
onOpenChange: triggerOpen,
onClick: onSelectorClick,
onClear: onSelectorClear,
invalid: submitInvalidates,
onInvalid: onSelectorInvalid,
onActiveOffset: setActiveOffset
})
)));
}
var RefRangePicker = /* @__PURE__ */ React.forwardRef(RangePicker);
if (process.env.NODE_ENV !== "production") {
RefRangePicker.displayName = "RefRangePicker";
}
var _excluded$6 = ["prefixCls", "invalidate", "item", "renderItem", "responsive", "responsiveDisabled", "registerSize", "itemKey", "className", "style", "children", "display", "order", "component"];
var UNDEFINED = void 0;
function InternalItem(props, ref) {
var prefixCls = props.prefixCls, invalidate = props.invalidate, item = props.item, renderItem = props.renderItem, responsive = props.responsive, responsiveDisabled = props.responsiveDisabled, registerSize = props.registerSize, itemKey = props.itemKey, className = props.className, style2 = props.style, children = props.children, display = props.display, order = props.order, _props$component = props.component, Component = _props$component === void 0 ? "div" : _props$component, restProps = _objectWithoutProperties(props, _excluded$6);
var mergedHidden = responsive && !display;
function internalRegisterSize(width) {
registerSize(itemKey, width);
}
React.useEffect(function() {
return function() {
internalRegisterSize(null);
};
}, []);
var childNode = renderItem && item !== UNDEFINED ? renderItem(item) : children;
var overflowStyle;
if (!invalidate) {
overflowStyle = {
opacity: mergedHidden ? 0 : 1,
height: mergedHidden ? 0 : UNDEFINED,
overflowY: mergedHidden ? "hidden" : UNDEFINED,
order: responsive ? order : UNDEFINED,
pointerEvents: mergedHidden ? "none" : UNDEFINED,
position: mergedHidden ? "absolute" : UNDEFINED
};
}
var overflowProps = {};
if (mergedHidden) {
overflowProps["aria-hidden"] = true;
}
var itemNode = /* @__PURE__ */ React.createElement(Component, _extends({
className: classNames(!invalidate && prefixCls, className),
style: _objectSpread2(_objectSpread2({}, overflowStyle), style2)
}, overflowProps, restProps, {
ref
}), childNode);
if (responsive) {
itemNode = /* @__PURE__ */ React.createElement(RefResizeObserver, {
onResize: function onResize2(_ref) {
var offsetWidth = _ref.offsetWidth;
internalRegisterSize(offsetWidth);
},
disabled: responsiveDisabled
}, itemNode);
}
return itemNode;
}
var Item = /* @__PURE__ */ React.forwardRef(InternalItem);
Item.displayName = "Item";
function channelUpdate(callback) {
if (typeof MessageChannel === "undefined") {
wrapperRaf(callback);
} else {
var channel = new MessageChannel();
channel.port1.onmessage = function() {
return callback();
};
channel.port2.postMessage(void 0);
}
}
function useBatcher() {
var updateFuncRef = React.useRef(null);
var notifyEffectUpdate = function notifyEffectUpdate2(callback) {
if (!updateFuncRef.current) {
updateFuncRef.current = [];
channelUpdate(function() {
unstable_batchedUpdates(function() {
updateFuncRef.current.forEach(function(fn) {
fn();
});
updateFuncRef.current = null;
});
});
}
updateFuncRef.current.push(callback);
};
return notifyEffectUpdate;
}
function useEffectState(notifyEffectUpdate, defaultValue) {
var _React$useState = React.useState(defaultValue), _React$useState2 = _slicedToArray(_React$useState, 2), stateValue = _React$useState2[0], setStateValue = _React$useState2[1];
var setEffectVal = useEvent(function(nextValue) {
notifyEffectUpdate(function() {
setStateValue(nextValue);
});
});
return [stateValue, setEffectVal];
}
var OverflowContext = /* @__PURE__ */ React__default.createContext(null);
var _excluded$5 = ["component"], _excluded2 = ["className"], _excluded3 = ["className"];
var InternalRawItem = function InternalRawItem2(props, ref) {
var context = React.useContext(OverflowContext);
if (!context) {
var _props$component = props.component, Component = _props$component === void 0 ? "div" : _props$component, _restProps = _objectWithoutProperties(props, _excluded$5);
return /* @__PURE__ */ React.createElement(Component, _extends({}, _restProps, {
ref
}));
}
var contextClassName = context.className, restContext = _objectWithoutProperties(context, _excluded2);
var className = props.className, restProps = _objectWithoutProperties(props, _excluded3);
return /* @__PURE__ */ React.createElement(OverflowContext.Provider, {
value: null
}, /* @__PURE__ */ React.createElement(Item, _extends({
ref,
className: classNames(contextClassName, className)
}, restContext, restProps)));
};
var RawItem = /* @__PURE__ */ React.forwardRef(InternalRawItem);
RawItem.displayName = "RawItem";
var _excluded$4 = ["prefixCls", "data", "renderItem", "renderRawItem", "itemKey", "itemWidth", "ssr", "style", "className", "maxCount", "renderRest", "renderRawRest", "suffix", "component", "itemComponent", "onVisibleChange"];
var RESPONSIVE = "responsive";
var INVALIDATE = "invalidate";
function defaultRenderRest(omittedItems) {
return "+ ".concat(omittedItems.length, " ...");
}
function Overflow(props, ref) {
var _props$prefixCls = props.prefixCls, prefixCls = _props$prefixCls === void 0 ? "rc-overflow" : _props$prefixCls, _props$data = props.data, data = _props$data === void 0 ? [] : _props$data, renderItem = props.renderItem, renderRawItem = props.renderRawItem, itemKey = props.itemKey, _props$itemWidth = props.itemWidth, itemWidth = _props$itemWidth === void 0 ? 10 : _props$itemWidth, ssr = props.ssr, style2 = props.style, className = props.className, maxCount = props.maxCount, renderRest = props.renderRest, renderRawRest = props.renderRawRest, suffix = props.suffix, _props$component = props.component, Component = _props$component === void 0 ? "div" : _props$component, itemComponent = props.itemComponent, onVisibleChange = props.onVisibleChange, restProps = _objectWithoutProperties(props, _excluded$4);
var fullySSR = ssr === "full";
var notifyEffectUpdate = useBatcher();
var _useEffectState = useEffectState(notifyEffectUpdate, null), _useEffectState2 = _slicedToArray(_useEffectState, 2), containerWidth = _useEffectState2[0], setContainerWidth = _useEffectState2[1];
var mergedContainerWidth = containerWidth || 0;
var _useEffectState3 = useEffectState(notifyEffectUpdate, /* @__PURE__ */ new Map()), _useEffectState4 = _slicedToArray(_useEffectState3, 2), itemWidths = _useEffectState4[0], setItemWidths = _useEffectState4[1];
var _useEffectState5 = useEffectState(notifyEffectUpdate, 0), _useEffectState6 = _slicedToArray(_useEffectState5, 2), prevRestWidth = _useEffectState6[0], setPrevRestWidth = _useEffectState6[1];
var _useEffectState7 = useEffectState(notifyEffectUpdate, 0), _useEffectState8 = _slicedToArray(_useEffectState7, 2), restWidth = _useEffectState8[0], setRestWidth = _useEffectState8[1];
var _useEffectState9 = useEffectState(notifyEffectUpdate, 0), _useEffectState10 = _slicedToArray(_useEffectState9, 2), suffixWidth = _useEffectState10[0], setSuffixWidth = _useEffectState10[1];
var _useState = useState(null), _useState2 = _slicedToArray(_useState, 2), suffixFixedStart = _useState2[0], setSuffixFixedStart = _useState2[1];
var _useState3 = useState(null), _useState4 = _slicedToArray(_useState3, 2), displayCount = _useState4[0], setDisplayCount = _useState4[1];
var mergedDisplayCount = React.useMemo(function() {
if (displayCount === null && fullySSR) {
return Number.MAX_SAFE_INTEGER;
}
return displayCount || 0;
}, [displayCount, containerWidth]);
var _useState5 = useState(false), _useState6 = _slicedToArray(_useState5, 2), restReady = _useState6[0], setRestReady = _useState6[1];
var itemPrefixCls = "".concat(prefixCls, "-item");
var mergedRestWidth = Math.max(prevRestWidth, restWidth);
var isResponsive = maxCount === RESPONSIVE;
var shouldResponsive = data.length && isResponsive;
var invalidate = maxCount === INVALIDATE;
var showRest = shouldResponsive || typeof maxCount === "number" && data.length > maxCount;
var mergedData = useMemo$1(function() {
var items = data;
if (shouldResponsive) {
if (containerWidth === null && fullySSR) {
items = data;
} else {
items = data.slice(0, Math.min(data.length, mergedContainerWidth / itemWidth));
}
} else if (typeof maxCount === "number") {
items = data.slice(0, maxCount);
}
return items;
}, [data, itemWidth, containerWidth, maxCount, shouldResponsive]);
var omittedItems = useMemo$1(function() {
if (shouldResponsive) {
return data.slice(mergedDisplayCount + 1);
}
return data.slice(mergedData.length);
}, [data, mergedData, shouldResponsive, mergedDisplayCount]);
var getKey = useCallback(function(item, index2) {
var _ref;
if (typeof itemKey === "function") {
return itemKey(item);
}
return (_ref = itemKey && (item === null || item === void 0 ? void 0 : item[itemKey])) !== null && _ref !== void 0 ? _ref : index2;
}, [itemKey]);
var mergedRenderItem = useCallback(renderItem || function(item) {
return item;
}, [renderItem]);
function updateDisplayCount(count, suffixFixedStartVal, notReady) {
if (displayCount === count && (suffixFixedStartVal === void 0 || suffixFixedStartVal === suffixFixedStart)) {
return;
}
setDisplayCount(count);
if (!notReady) {
setRestReady(count < data.length - 1);
onVisibleChange === null || onVisibleChange === void 0 ? void 0 : onVisibleChange(count);
}
if (suffixFixedStartVal !== void 0) {
setSuffixFixedStart(suffixFixedStartVal);
}
}
function onOverflowResize(_, element) {
setContainerWidth(element.clientWidth);
}
function registerSize(key, width) {
setItemWidths(function(origin) {
var clone = new Map(origin);
if (width === null) {
clone.delete(key);
} else {
clone.set(key, width);
}
return clone;
});
}
function registerOverflowSize(_, width) {
setRestWidth(width);
setPrevRestWidth(restWidth);
}
function registerSuffixSize(_, width) {
setSuffixWidth(width);
}
function getItemWidth(index2) {
return itemWidths.get(getKey(mergedData[index2], index2));
}
useLayoutEffect(function() {
if (mergedContainerWidth && typeof mergedRestWidth === "number" && mergedData) {
var totalWidth = suffixWidth;
var len = mergedData.length;
var lastIndex = len - 1;
if (!len) {
updateDisplayCount(0, null);
return;
}
for (var i = 0; i < len; i += 1) {
var currentItemWidth = getItemWidth(i);
if (fullySSR) {
currentItemWidth = currentItemWidth || 0;
}
if (currentItemWidth === void 0) {
updateDisplayCount(i - 1, void 0, true);
break;
}
totalWidth += currentItemWidth;
if (
// Only one means `totalWidth` is the final width
lastIndex === 0 && totalWidth <= mergedContainerWidth || // Last two width will be the final width
i === lastIndex - 1 && totalWidth + getItemWidth(lastIndex) <= mergedContainerWidth
) {
updateDisplayCount(lastIndex, null);
break;
} else if (totalWidth + mergedRestWidth > mergedContainerWidth) {
updateDisplayCount(i - 1, totalWidth - currentItemWidth - suffixWidth + restWidth);
break;
}
}
if (suffix && getItemWidth(0) + suffixWidth > mergedContainerWidth) {
setSuffixFixedStart(null);
}
}
}, [mergedContainerWidth, itemWidths, restWidth, suffixWidth, getKey, mergedData]);
var displayRest = restReady && !!omittedItems.length;
var suffixStyle = {};
if (suffixFixedStart !== null && shouldResponsive) {
suffixStyle = {
position: "absolute",
left: suffixFixedStart,
top: 0
};
}
var itemSharedProps = {
prefixCls: itemPrefixCls,
responsive: shouldResponsive,
component: itemComponent,
invalidate
};
var internalRenderItemNode = renderRawItem ? function(item, index2) {
var key = getKey(item, index2);
return /* @__PURE__ */ React.createElement(OverflowContext.Provider, {
key,
value: _objectSpread2(_objectSpread2({}, itemSharedProps), {}, {
order: index2,
item,
itemKey: key,
registerSize,
display: index2 <= mergedDisplayCount
})
}, renderRawItem(item, index2));
} : function(item, index2) {
var key = getKey(item, index2);
return /* @__PURE__ */ React.createElement(Item, _extends({}, itemSharedProps, {
order: index2,
key,
item,
renderItem: mergedRenderItem,
itemKey: key,
registerSize,
display: index2 <= mergedDisplayCount
}));
};
var restNode;
var restContextProps = {
order: displayRest ? mergedDisplayCount : Number.MAX_SAFE_INTEGER,
className: "".concat(itemPrefixCls, "-rest"),
registerSize: registerOverflowSize,
display: displayRest
};
if (!renderRawRest) {
var mergedRenderRest = renderRest || defaultRenderRest;
restNode = /* @__PURE__ */ React.createElement(Item, _extends({}, itemSharedProps, restContextProps), typeof mergedRenderRest === "function" ? mergedRenderRest(omittedItems) : mergedRenderRest);
} else if (renderRawRest) {
restNode = /* @__PURE__ */ React.createElement(OverflowContext.Provider, {
value: _objectSpread2(_objectSpread2({}, itemSharedProps), restContextProps)
}, renderRawRest(omittedItems));
}
var overflowNode = /* @__PURE__ */ React.createElement(Component, _extends({
className: classNames(!invalidate && prefixCls, className),
style: style2,
ref
}, restProps), mergedData.map(internalRenderItemNode), showRest ? restNode : null, suffix && /* @__PURE__ */ React.createElement(Item, _extends({}, itemSharedProps, {
responsive: isResponsive,
responsiveDisabled: !shouldResponsive,
order: mergedDisplayCount,
className: "".concat(itemPrefixCls, "-suffix"),
registerSize: registerSuffixSize,
display: true,
style: suffixStyle
}), suffix));
if (isResponsive) {
overflowNode = /* @__PURE__ */ React.createElement(RefResizeObserver, {
onResize: onOverflowResize,
disabled: !shouldResponsive
}, overflowNode);
}
return overflowNode;
}
var ForwardOverflow = /* @__PURE__ */ React.forwardRef(Overflow);
ForwardOverflow.displayName = "Overflow";
ForwardOverflow.Item = RawItem;
ForwardOverflow.RESPONSIVE = RESPONSIVE;
ForwardOverflow.INVALIDATE = INVALIDATE;
function MultipleDates(props) {
var prefixCls = props.prefixCls, value = props.value, onRemove = props.onRemove, _props$removeIcon = props.removeIcon, removeIcon = _props$removeIcon === void 0 ? "×" : _props$removeIcon, formatDate = props.formatDate, disabled = props.disabled, maxTagCount = props.maxTagCount, placeholder = props.placeholder;
var selectorCls = "".concat(prefixCls, "-selector");
var selectionCls = "".concat(prefixCls, "-selection");
var overflowCls = "".concat(selectionCls, "-overflow");
function renderSelector(content, onClose) {
return /* @__PURE__ */ React.createElement("span", {
className: classNames("".concat(selectionCls, "-item")),
title: typeof content === "string" ? content : null
}, /* @__PURE__ */ React.createElement("span", {
className: "".concat(selectionCls, "-item-content")
}, content), !disabled && onClose && /* @__PURE__ */ React.createElement("span", {
onMouseDown: function onMouseDown(e) {
e.preventDefault();
},
onClick: onClose,
className: "".concat(selectionCls, "-item-remove")
}, removeIcon));
}
function renderItem(date4) {
var displayLabel = formatDate(date4);
var onClose = function onClose2(event) {
if (event) event.stopPropagation();
onRemove(date4);
};
return renderSelector(displayLabel, onClose);
}
function renderRest(omittedValues) {
var content = "+ ".concat(omittedValues.length, " ...");
return renderSelector(content);
}
return /* @__PURE__ */ React.createElement("div", {
className: selectorCls
}, /* @__PURE__ */ React.createElement(ForwardOverflow, {
prefixCls: overflowCls,
data: value,
renderItem,
renderRest,
itemKey: function itemKey(date4) {
return formatDate(date4);
},
maxCount: maxTagCount
}), !value.length && /* @__PURE__ */ React.createElement("span", {
className: "".concat(prefixCls, "-selection-placeholder")
}, placeholder));
}
var _excluded$3 = ["id", "open", "clearIcon", "suffixIcon", "activeHelp", "allHelp", "focused", "onFocus", "onBlur", "onKeyDown", "locale", "generateConfig", "placeholder", "className", "style", "onClick", "onClear", "internalPicker", "value", "onChange", "onSubmit", "onInputChange", "multiple", "maxTagCount", "format", "maskFormat", "preserveInvalidOnBlur", "onInvalid", "disabled", "invalid", "inputReadOnly", "direction", "onOpenChange", "onMouseDown", "required", "aria-required", "autoFocus", "removeIcon"];
function SingleSelector(props, ref) {
props.id;
var open = props.open, clearIcon = props.clearIcon, suffixIcon = props.suffixIcon;
props.activeHelp;
props.allHelp;
var focused = props.focused;
props.onFocus;
props.onBlur;
props.onKeyDown;
var locale2 = props.locale, generateConfig = props.generateConfig, placeholder = props.placeholder, className = props.className, style2 = props.style, onClick = props.onClick, onClear = props.onClear, internalPicker = props.internalPicker, value = props.value, onChange = props.onChange, onSubmit = props.onSubmit;
props.onInputChange;
var multiple = props.multiple, maxTagCount = props.maxTagCount;
props.format;
props.maskFormat;
props.preserveInvalidOnBlur;
props.onInvalid;
var disabled = props.disabled, invalid = props.invalid;
props.inputReadOnly;
var direction = props.direction;
props.onOpenChange;
var _onMouseDown = props.onMouseDown;
props.required;
props["aria-required"];
var autoFocus = props.autoFocus, removeIcon = props.removeIcon, restProps = _objectWithoutProperties(props, _excluded$3);
var rtl = direction === "rtl";
var _React$useContext = React.useContext(PickerContext), prefixCls = _React$useContext.prefixCls;
var rootRef = React.useRef();
var inputRef = React.useRef();
React.useImperativeHandle(ref, function() {
return {
nativeElement: rootRef.current,
focus: function focus(options) {
var _inputRef$current;
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus(options);
},
blur: function blur() {
var _inputRef$current2;
(_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 || _inputRef$current2.blur();
}
};
});
var rootProps = useRootProps(restProps);
var onSingleChange = function onSingleChange2(date4) {
onChange([date4]);
};
var onMultipleRemove = function onMultipleRemove2(date4) {
var nextValues = value.filter(function(oriDate) {
return oriDate && !isSame(generateConfig, locale2, oriDate, date4, internalPicker);
});
onChange(nextValues);
if (!open) {
onSubmit();
}
};
var _useInputProps = useInputProps(_objectSpread2(_objectSpread2({}, props), {}, {
onChange: onSingleChange
}), function(_ref) {
var valueTexts = _ref.valueTexts;
return {
value: valueTexts[0] || "",
active: focused
};
}), _useInputProps2 = _slicedToArray(_useInputProps, 2), getInputProps = _useInputProps2[0], getText = _useInputProps2[1];
var showClear = !!(clearIcon && value.length && !disabled);
var selectorNode = multiple ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(MultipleDates, {
prefixCls,
value,
onRemove: onMultipleRemove,
formatDate: getText,
maxTagCount,
disabled,
removeIcon,
placeholder
}), /* @__PURE__ */ React.createElement("input", {
className: "".concat(prefixCls, "-multiple-input"),
value: value.map(getText).join(","),
ref: inputRef,
readOnly: true,
autoFocus
}), /* @__PURE__ */ React.createElement(Icon, {
type: "suffix",
icon: suffixIcon
}), showClear && /* @__PURE__ */ React.createElement(ClearIcon, {
icon: clearIcon,
onClear
})) : /* @__PURE__ */ React.createElement(Input, _extends({
ref: inputRef
}, getInputProps(), {
autoFocus,
suffixIcon,
clearIcon: showClear && /* @__PURE__ */ React.createElement(ClearIcon, {
icon: clearIcon,
onClear
}),
showActiveCls: false
}));
return /* @__PURE__ */ React.createElement("div", _extends({}, rootProps, {
className: classNames(prefixCls, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-multiple"), multiple), "".concat(prefixCls, "-focused"), focused), "".concat(prefixCls, "-disabled"), disabled), "".concat(prefixCls, "-invalid"), invalid), "".concat(prefixCls, "-rtl"), rtl), className),
style: style2,
ref: rootRef,
onClick,
onMouseDown: function onMouseDown(e) {
var _inputRef$current3;
var target = e.target;
if (target !== ((_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.inputElement)) {
e.preventDefault();
}
_onMouseDown === null || _onMouseDown === void 0 || _onMouseDown(e);
}
}), selectorNode);
}
var RefSingleSelector = /* @__PURE__ */ React.forwardRef(SingleSelector);
if (process.env.NODE_ENV !== "production") {
RefSingleSelector.displayName = "SingleSelector";
}
function Picker(props, ref) {
var _useFilledProps = useFilledProps(props), _useFilledProps2 = _slicedToArray(_useFilledProps, 6), filledProps = _useFilledProps2[0], internalPicker = _useFilledProps2[1], complexPicker = _useFilledProps2[2], formatList = _useFilledProps2[3], maskFormat = _useFilledProps2[4], isInvalidateDate = _useFilledProps2[5];
var _ref = filledProps, prefixCls = _ref.prefixCls, styles = _ref.styles, classNames2 = _ref.classNames, order = _ref.order, defaultValue = _ref.defaultValue, value = _ref.value, needConfirm = _ref.needConfirm, onChange = _ref.onChange, onKeyDown = _ref.onKeyDown, disabled = _ref.disabled, disabledDate = _ref.disabledDate, minDate = _ref.minDate, maxDate = _ref.maxDate, defaultOpen = _ref.defaultOpen, open = _ref.open, onOpenChange = _ref.onOpenChange, locale2 = _ref.locale, generateConfig = _ref.generateConfig, picker = _ref.picker, showNow = _ref.showNow, showToday = _ref.showToday, showTime = _ref.showTime, mode = _ref.mode, onPanelChange = _ref.onPanelChange, onCalendarChange = _ref.onCalendarChange, onOk = _ref.onOk, multiple = _ref.multiple, defaultPickerValue = _ref.defaultPickerValue, pickerValue = _ref.pickerValue, onPickerValueChange = _ref.onPickerValueChange, inputReadOnly = _ref.inputReadOnly, suffixIcon = _ref.suffixIcon, removeIcon = _ref.removeIcon, onFocus = _ref.onFocus, onBlur = _ref.onBlur, presets = _ref.presets, components = _ref.components, cellRender = _ref.cellRender, dateRender = _ref.dateRender, monthCellRender = _ref.monthCellRender, onClick = _ref.onClick;
var selectorRef = usePickerRef(ref);
function pickerParam(values) {
if (values === null) {
return null;
}
return multiple ? values : values[0];
}
var toggleDates = useToggleDates(generateConfig, locale2, internalPicker);
var _useOpen = useOpen(open, defaultOpen, [disabled], onOpenChange), _useOpen2 = _slicedToArray(_useOpen, 2), mergedOpen = _useOpen2[0], triggerOpen = _useOpen2[1];
var onInternalCalendarChange = function onInternalCalendarChange2(dates, dateStrings, info) {
if (onCalendarChange) {
var filteredInfo = _objectSpread2({}, info);
delete filteredInfo.range;
onCalendarChange(pickerParam(dates), pickerParam(dateStrings), filteredInfo);
}
};
var onInternalOk = function onInternalOk2(dates) {
onOk === null || onOk === void 0 || onOk(pickerParam(dates));
};
var _useInnerValue = useInnerValue(generateConfig, locale2, formatList, false, order, defaultValue, value, onInternalCalendarChange, onInternalOk), _useInnerValue2 = _slicedToArray(_useInnerValue, 5), mergedValue = _useInnerValue2[0], setInnerValue = _useInnerValue2[1], getCalendarValue = _useInnerValue2[2], triggerCalendarChange = _useInnerValue2[3], triggerOk = _useInnerValue2[4];
var calendarValue = getCalendarValue();
var _useRangeActive = useRangeActive([disabled]), _useRangeActive2 = _slicedToArray(_useRangeActive, 4), focused = _useRangeActive2[0], triggerFocus = _useRangeActive2[1], lastOperation = _useRangeActive2[2], activeIndex = _useRangeActive2[3];
var onSharedFocus = function onSharedFocus2(event) {
triggerFocus(true);
onFocus === null || onFocus === void 0 || onFocus(event, {});
};
var onSharedBlur = function onSharedBlur2(event) {
triggerFocus(false);
onBlur === null || onBlur === void 0 || onBlur(event, {});
};
var _useMergedState = useMergedState(picker, {
value: mode
}), _useMergedState2 = _slicedToArray(_useMergedState, 2), mergedMode = _useMergedState2[0], setMode = _useMergedState2[1];
var internalMode = mergedMode === "date" && showTime ? "datetime" : mergedMode;
var mergedShowNow = useShowNow(picker, mergedMode, showNow, showToday);
var onInternalChange = onChange && function(dates, dateStrings) {
onChange(pickerParam(dates), pickerParam(dateStrings));
};
var _useRangeValue = useRangeValue(
_objectSpread2(_objectSpread2({}, filledProps), {}, {
onChange: onInternalChange
}),
mergedValue,
setInnerValue,
getCalendarValue,
triggerCalendarChange,
[],
//disabled,
formatList,
focused,
mergedOpen,
isInvalidateDate
), _useRangeValue2 = _slicedToArray(_useRangeValue, 2), triggerSubmitChange = _useRangeValue2[1];
var _useFieldsInvalidate = useFieldsInvalidate(calendarValue, isInvalidateDate), _useFieldsInvalidate2 = _slicedToArray(_useFieldsInvalidate, 2), submitInvalidates = _useFieldsInvalidate2[0], onSelectorInvalid = _useFieldsInvalidate2[1];
var submitInvalidate = React.useMemo(function() {
return submitInvalidates.some(function(invalidated) {
return invalidated;
});
}, [submitInvalidates]);
var onInternalPickerValueChange = function onInternalPickerValueChange2(dates, info) {
if (onPickerValueChange) {
var cleanInfo = _objectSpread2(_objectSpread2({}, info), {}, {
mode: info.mode[0]
});
delete cleanInfo.range;
onPickerValueChange(dates[0], cleanInfo);
}
};
var _useRangePickerValue = useRangePickerValue(
generateConfig,
locale2,
calendarValue,
[mergedMode],
mergedOpen,
activeIndex,
internalPicker,
false,
// multiplePanel,
defaultPickerValue,
pickerValue,
toArray$1(showTime === null || showTime === void 0 ? void 0 : showTime.defaultOpenValue),
onInternalPickerValueChange,
minDate,
maxDate
), _useRangePickerValue2 = _slicedToArray(_useRangePickerValue, 2), currentPickerValue = _useRangePickerValue2[0], setCurrentPickerValue = _useRangePickerValue2[1];
var triggerModeChange = useEvent(function(nextPickerValue, nextMode, triggerEvent) {
setMode(nextMode);
if (onPanelChange && triggerEvent !== false) {
var lastPickerValue = nextPickerValue || calendarValue[calendarValue.length - 1];
onPanelChange(lastPickerValue, nextMode);
}
});
var triggerConfirm = function triggerConfirm2() {
triggerSubmitChange(getCalendarValue());
triggerOpen(false, {
force: true
});
};
var onSelectorClick = function onSelectorClick2(event) {
if (!disabled && !selectorRef.current.nativeElement.contains(document.activeElement)) {
selectorRef.current.focus();
}
triggerOpen(true);
onClick === null || onClick === void 0 || onClick(event);
};
var onSelectorClear = function onSelectorClear2() {
triggerSubmitChange(null);
triggerOpen(false, {
force: true
});
};
var _React$useState = React.useState(null), _React$useState2 = _slicedToArray(_React$useState, 2), hoverSource = _React$useState2[0], setHoverSource = _React$useState2[1];
var _React$useState3 = React.useState(null), _React$useState4 = _slicedToArray(_React$useState3, 2), internalHoverValue = _React$useState4[0], setInternalHoverValue = _React$useState4[1];
var hoverValues = React.useMemo(function() {
var values = [internalHoverValue].concat(_toConsumableArray(calendarValue)).filter(function(date4) {
return date4;
});
return multiple ? values : values.slice(0, 1);
}, [calendarValue, internalHoverValue, multiple]);
var selectorValues = React.useMemo(function() {
if (!multiple && internalHoverValue) {
return [internalHoverValue];
}
return calendarValue.filter(function(date4) {
return date4;
});
}, [calendarValue, internalHoverValue, multiple]);
React.useEffect(function() {
if (!mergedOpen) {
setInternalHoverValue(null);
}
}, [mergedOpen]);
var presetList = usePresets(presets);
var onPresetHover = function onPresetHover2(nextValue) {
setInternalHoverValue(nextValue);
setHoverSource("preset");
};
var onPresetSubmit = function onPresetSubmit2(nextValue) {
var nextCalendarValues = multiple ? toggleDates(getCalendarValue(), nextValue) : [nextValue];
var passed = triggerSubmitChange(nextCalendarValues);
if (passed && !multiple) {
triggerOpen(false, {
force: true
});
}
};
var onNow = function onNow2(now) {
onPresetSubmit(now);
};
var onPanelHover = function onPanelHover2(date4) {
setInternalHoverValue(date4);
setHoverSource("cell");
};
var onPanelFocus = function onPanelFocus2(event) {
triggerOpen(true);
onSharedFocus(event);
};
var onPanelSelect = function onPanelSelect2(date4) {
lastOperation("panel");
var nextValues = multiple ? toggleDates(getCalendarValue(), date4) : [date4];
triggerCalendarChange(nextValues);
if (!needConfirm && !complexPicker && internalPicker === internalMode) {
triggerConfirm();
}
};
var onPopupClose = function onPopupClose2() {
triggerOpen(false);
};
var onInternalCellRender = useCellRender(cellRender, dateRender, monthCellRender);
var panelProps = React.useMemo(function() {
var domProps = pickAttrs(filledProps, false);
var restProps = omit(filledProps, [].concat(_toConsumableArray(Object.keys(domProps)), ["onChange", "onCalendarChange", "style", "className", "onPanelChange"]));
return _objectSpread2(_objectSpread2({}, restProps), {}, {
multiple: filledProps.multiple
});
}, [filledProps]);
var panel = /* @__PURE__ */ React.createElement(Popup, _extends({}, panelProps, {
showNow: mergedShowNow,
showTime,
disabledDate,
onFocus: onPanelFocus,
onBlur: onSharedBlur,
picker,
mode: mergedMode,
internalMode,
onPanelChange: triggerModeChange,
format: maskFormat,
value: calendarValue,
isInvalid: isInvalidateDate,
onChange: null,
onSelect: onPanelSelect,
pickerValue: currentPickerValue,
defaultOpenValue: showTime === null || showTime === void 0 ? void 0 : showTime.defaultOpenValue,
onPickerValueChange: setCurrentPickerValue,
hoverValue: hoverValues,
onHover: onPanelHover,
needConfirm,
onSubmit: triggerConfirm,
onOk: triggerOk,
presets: presetList,
onPresetHover,
onPresetSubmit,
onNow,
cellRender: onInternalCellRender
}));
var onSelectorChange = function onSelectorChange2(date4) {
triggerCalendarChange(date4);
};
var onSelectorInputChange = function onSelectorInputChange2() {
lastOperation("input");
};
var onSelectorFocus = function onSelectorFocus2(event) {
lastOperation("input");
triggerOpen(true, {
inherit: true
});
onSharedFocus(event);
};
var onSelectorBlur = function onSelectorBlur2(event) {
triggerOpen(false);
onSharedBlur(event);
};
var onSelectorKeyDown = function onSelectorKeyDown2(event, preventDefault) {
if (event.key === "Tab") {
triggerConfirm();
}
onKeyDown === null || onKeyDown === void 0 || onKeyDown(event, preventDefault);
};
var context = React.useMemo(function() {
return {
prefixCls,
locale: locale2,
generateConfig,
button: components.button,
input: components.input
};
}, [prefixCls, locale2, generateConfig, components.button, components.input]);
useLayoutEffect(function() {
if (mergedOpen && activeIndex !== void 0) {
triggerModeChange(null, picker, false);
}
}, [mergedOpen, activeIndex, picker]);
useLayoutEffect(function() {
var lastOp = lastOperation();
if (!mergedOpen && lastOp === "input") {
triggerOpen(false);
triggerConfirm();
}
if (!mergedOpen && complexPicker && !needConfirm && lastOp === "panel") {
triggerOpen(true);
triggerConfirm();
}
}, [mergedOpen]);
return /* @__PURE__ */ React.createElement(PickerContext.Provider, {
value: context
}, /* @__PURE__ */ React.createElement(PickerTrigger, _extends({}, pickTriggerProps(filledProps), {
popupElement: panel,
popupStyle: styles.popup,
popupClassName: classNames2.popup,
visible: mergedOpen,
onClose: onPopupClose
}), /* @__PURE__ */ React.createElement(
RefSingleSelector,
_extends({}, filledProps, {
// Ref
ref: selectorRef,
suffixIcon,
removeIcon,
activeHelp: !!internalHoverValue,
allHelp: !!internalHoverValue && hoverSource === "preset",
focused,
onFocus: onSelectorFocus,
onBlur: onSelectorBlur,
onKeyDown: onSelectorKeyDown,
onSubmit: triggerConfirm,
value: selectorValues,
maskFormat,
onChange: onSelectorChange,
onInputChange: onSelectorInputChange,
internalPicker,
format: formatList,
inputReadOnly,
disabled,
open: mergedOpen,
onOpenChange: triggerOpen,
onClick: onSelectorClick,
onClear: onSelectorClear,
invalid: submitInvalidate,
onInvalid: function onInvalid(invalid) {
onSelectorInvalid(invalid, 0);
}
})
)));
}
var RefPicker = /* @__PURE__ */ React.forwardRef(Picker);
if (process.env.NODE_ENV !== "production") {
RefPicker.displayName = "RefPicker";
}
function _regeneratorRuntime() {
_regeneratorRuntime = function _regeneratorRuntime2() {
return e;
};
var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function(t2, e2, r2) {
t2[e2] = r2.value;
}, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag";
function define(t2, e2, r2) {
return Object.defineProperty(t2, e2, {
value: r2,
enumerable: true,
configurable: true,
writable: true
}), t2[e2];
}
try {
define({}, "");
} catch (t2) {
define = function define2(t3, e2, r2) {
return t3[e2] = r2;
};
}
function wrap(t2, e2, r2, n2) {
var i2 = e2 && e2.prototype instanceof Generator ? e2 : Generator, a2 = Object.create(i2.prototype), c2 = new Context2(n2 || []);
return o(a2, "_invoke", {
value: makeInvokeMethod(t2, r2, c2)
}), a2;
}
function tryCatch(t2, e2, r2) {
try {
return {
type: "normal",
arg: t2.call(e2, r2)
};
} catch (t3) {
return {
type: "throw",
arg: t3
};
}
}
e.wrap = wrap;
var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {};
function Generator() {
}
function GeneratorFunction() {
}
function GeneratorFunctionPrototype() {
}
var p = {};
define(p, a, function() {
return this;
});
var d = Object.getPrototypeOf, v = d && d(d(values([])));
v && v !== r && n.call(v, a) && (p = v);
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
function defineIteratorMethods(t2) {
["next", "throw", "return"].forEach(function(e2) {
define(t2, e2, function(t3) {
return this._invoke(e2, t3);
});
});
}
function AsyncIterator(t2, e2) {
function invoke(r3, o2, i2, a2) {
var c2 = tryCatch(t2[r3], t2, o2);
if ("throw" !== c2.type) {
var u2 = c2.arg, h2 = u2.value;
return h2 && "object" == _typeof(h2) && n.call(h2, "__await") ? e2.resolve(h2.__await).then(function(t3) {
invoke("next", t3, i2, a2);
}, function(t3) {
invoke("throw", t3, i2, a2);
}) : e2.resolve(h2).then(function(t3) {
u2.value = t3, i2(u2);
}, function(t3) {
return invoke("throw", t3, i2, a2);
});
}
a2(c2.arg);
}
var r2;
o(this, "_invoke", {
value: function value(t3, n2) {
function callInvokeWithMethodAndArg() {
return new e2(function(e3, r3) {
invoke(t3, n2, e3, r3);
});
}
return r2 = r2 ? r2.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
}
});
}
function makeInvokeMethod(e2, r2, n2) {
var o2 = h;
return function(i2, a2) {
if (o2 === f) throw Error("Generator is already running");
if (o2 === s) {
if ("throw" === i2) throw a2;
return {
value: t,
done: true
};
}
for (n2.method = i2, n2.arg = a2; ; ) {
var c2 = n2.delegate;
if (c2) {
var u2 = maybeInvokeDelegate(c2, n2);
if (u2) {
if (u2 === y) continue;
return u2;
}
}
if ("next" === n2.method) n2.sent = n2._sent = n2.arg;
else if ("throw" === n2.method) {
if (o2 === h) throw o2 = s, n2.arg;
n2.dispatchException(n2.arg);
} else "return" === n2.method && n2.abrupt("return", n2.arg);
o2 = f;
var p2 = tryCatch(e2, r2, n2);
if ("normal" === p2.type) {
if (o2 = n2.done ? s : l, p2.arg === y) continue;
return {
value: p2.arg,
done: n2.done
};
}
"throw" === p2.type && (o2 = s, n2.method = "throw", n2.arg = p2.arg);
}
};
}
function maybeInvokeDelegate(e2, r2) {
var n2 = r2.method, o2 = e2.iterator[n2];
if (o2 === t) return r2.delegate = null, "throw" === n2 && e2.iterator["return"] && (r2.method = "return", r2.arg = t, maybeInvokeDelegate(e2, r2), "throw" === r2.method) || "return" !== n2 && (r2.method = "throw", r2.arg = new TypeError("The iterator does not provide a '" + n2 + "' method")), y;
var i2 = tryCatch(o2, e2.iterator, r2.arg);
if ("throw" === i2.type) return r2.method = "throw", r2.arg = i2.arg, r2.delegate = null, y;
var a2 = i2.arg;
return a2 ? a2.done ? (r2[e2.resultName] = a2.value, r2.next = e2.nextLoc, "return" !== r2.method && (r2.method = "next", r2.arg = t), r2.delegate = null, y) : a2 : (r2.method = "throw", r2.arg = new TypeError("iterator result is not an object"), r2.delegate = null, y);
}
function pushTryEntry(t2) {
var e2 = {
tryLoc: t2[0]
};
1 in t2 && (e2.catchLoc = t2[1]), 2 in t2 && (e2.finallyLoc = t2[2], e2.afterLoc = t2[3]), this.tryEntries.push(e2);
}
function resetTryEntry(t2) {
var e2 = t2.completion || {};
e2.type = "normal", delete e2.arg, t2.completion = e2;
}
function Context2(t2) {
this.tryEntries = [{
tryLoc: "root"
}], t2.forEach(pushTryEntry, this), this.reset(true);
}
function values(e2) {
if (e2 || "" === e2) {
var r2 = e2[a];
if (r2) return r2.call(e2);
if ("function" == typeof e2.next) return e2;
if (!isNaN(e2.length)) {
var o2 = -1, i2 = function next2() {
for (; ++o2 < e2.length; ) if (n.call(e2, o2)) return next2.value = e2[o2], next2.done = false, next2;
return next2.value = t, next2.done = true, next2;
};
return i2.next = i2;
}
}
throw new TypeError(_typeof(e2) + " is not iterable");
}
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
value: GeneratorFunctionPrototype,
configurable: true
}), o(GeneratorFunctionPrototype, "constructor", {
value: GeneratorFunction,
configurable: true
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function(t2) {
var e2 = "function" == typeof t2 && t2.constructor;
return !!e2 && (e2 === GeneratorFunction || "GeneratorFunction" === (e2.displayName || e2.name));
}, e.mark = function(t2) {
return Object.setPrototypeOf ? Object.setPrototypeOf(t2, GeneratorFunctionPrototype) : (t2.__proto__ = GeneratorFunctionPrototype, define(t2, u, "GeneratorFunction")), t2.prototype = Object.create(g), t2;
}, e.awrap = function(t2) {
return {
__await: t2
};
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function() {
return this;
}), e.AsyncIterator = AsyncIterator, e.async = function(t2, r2, n2, o2, i2) {
void 0 === i2 && (i2 = Promise);
var a2 = new AsyncIterator(wrap(t2, r2, n2, o2), i2);
return e.isGeneratorFunction(r2) ? a2 : a2.next().then(function(t3) {
return t3.done ? t3.value : a2.next();
});
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function() {
return this;
}), define(g, "toString", function() {
return "[object Generator]";
}), e.keys = function(t2) {
var e2 = Object(t2), r2 = [];
for (var n2 in e2) r2.push(n2);
return r2.reverse(), function next2() {
for (; r2.length; ) {
var t3 = r2.pop();
if (t3 in e2) return next2.value = t3, next2.done = false, next2;
}
return next2.done = true, next2;
};
}, e.values = values, Context2.prototype = {
constructor: Context2,
reset: function reset(e2) {
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = false, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e2) for (var r2 in this) "t" === r2.charAt(0) && n.call(this, r2) && !isNaN(+r2.slice(1)) && (this[r2] = t);
},
stop: function stop() {
this.done = true;
var t2 = this.tryEntries[0].completion;
if ("throw" === t2.type) throw t2.arg;
return this.rval;
},
dispatchException: function dispatchException(e2) {
if (this.done) throw e2;
var r2 = this;
function handle(n2, o3) {
return a2.type = "throw", a2.arg = e2, r2.next = n2, o3 && (r2.method = "next", r2.arg = t), !!o3;
}
for (var o2 = this.tryEntries.length - 1; o2 >= 0; --o2) {
var i2 = this.tryEntries[o2], a2 = i2.completion;
if ("root" === i2.tryLoc) return handle("end");
if (i2.tryLoc <= this.prev) {
var c2 = n.call(i2, "catchLoc"), u2 = n.call(i2, "finallyLoc");
if (c2 && u2) {
if (this.prev < i2.catchLoc) return handle(i2.catchLoc, true);
if (this.prev < i2.finallyLoc) return handle(i2.finallyLoc);
} else if (c2) {
if (this.prev < i2.catchLoc) return handle(i2.catchLoc, true);
} else {
if (!u2) throw Error("try statement without catch or finally");
if (this.prev < i2.finallyLoc) return handle(i2.finallyLoc);
}
}
}
},
abrupt: function abrupt(t2, e2) {
for (var r2 = this.tryEntries.length - 1; r2 >= 0; --r2) {
var o2 = this.tryEntries[r2];
if (o2.tryLoc <= this.prev && n.call(o2, "finallyLoc") && this.prev < o2.finallyLoc) {
var i2 = o2;
break;
}
}
i2 && ("break" === t2 || "continue" === t2) && i2.tryLoc <= e2 && e2 <= i2.finallyLoc && (i2 = null);
var a2 = i2 ? i2.completion : {};
return a2.type = t2, a2.arg = e2, i2 ? (this.method = "next", this.next = i2.finallyLoc, y) : this.complete(a2);
},
complete: function complete(t2, e2) {
if ("throw" === t2.type) throw t2.arg;
return "break" === t2.type || "continue" === t2.type ? this.next = t2.arg : "return" === t2.type ? (this.rval = this.arg = t2.arg, this.method = "return", this.next = "end") : "normal" === t2.type && e2 && (this.next = e2), y;
},
finish: function finish(t2) {
for (var e2 = this.tryEntries.length - 1; e2 >= 0; --e2) {
var r2 = this.tryEntries[e2];
if (r2.finallyLoc === t2) return this.complete(r2.completion, r2.afterLoc), resetTryEntry(r2), y;
}
},
"catch": function _catch(t2) {
for (var e2 = this.tryEntries.length - 1; e2 >= 0; --e2) {
var r2 = this.tryEntries[e2];
if (r2.tryLoc === t2) {
var n2 = r2.completion;
if ("throw" === n2.type) {
var o2 = n2.arg;
resetTryEntry(r2);
}
return o2;
}
}
throw Error("illegal catch attempt");
},
delegateYield: function delegateYield(e2, r2, n2) {
return this.delegate = {
iterator: values(e2),
resultName: r2,
nextLoc: n2
}, "next" === this.method && (this.arg = t), y;
}
}, e;
}
function asyncGeneratorStep(n, t, e, r, o, a, c) {
try {
var i = n[a](c), u = i.value;
} catch (n2) {
return void e(n2);
}
i.done ? t(u) : Promise.resolve(u).then(r, o);
}
function _asyncToGenerator(n) {
return function() {
var t = this, e = arguments;
return new Promise(function(r, o) {
var a = n.apply(t, e);
function _next(n2) {
asyncGeneratorStep(a, r, o, _next, _throw, "next", n2);
}
function _throw(n2) {
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n2);
}
_next(void 0);
});
};
}
function isEqual(obj1, obj2) {
var shallow = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
var refSet = /* @__PURE__ */ new Set();
function deepEqual(a, b) {
var level = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1;
var circular = refSet.has(a);
warningOnce(!circular, "Warning: There may be circular references");
if (circular) {
return false;
}
if (a === b) {
return true;
}
if (shallow && level > 1) {
return false;
}
refSet.add(a);
var newLevel = level + 1;
if (Array.isArray(a)) {
if (!Array.isArray(b) || a.length !== b.length) {
return false;
}
for (var i = 0; i < a.length; i++) {
if (!deepEqual(a[i], b[i], newLevel)) {
return false;
}
}
return true;
}
if (a && b && _typeof(a) === "object" && _typeof(b) === "object") {
var keys2 = Object.keys(a);
if (keys2.length !== Object.keys(b).length) {
return false;
}
return keys2.every(function(key) {
return deepEqual(a[key], b[key], newLevel);
});
}
return false;
}
return deepEqual(obj1, obj2);
}
var HOOK_MARK = "RC_FORM_INTERNAL_HOOKS";
var warningFunc = function warningFunc2() {
warningOnce(false, "Can not find FormContext. Please make sure you wrap Field under Form.");
};
var Context = /* @__PURE__ */ React.createContext({
getFieldValue: warningFunc,
getFieldsValue: warningFunc,
getFieldError: warningFunc,
getFieldWarning: warningFunc,
getFieldsError: warningFunc,
isFieldsTouched: warningFunc,
isFieldTouched: warningFunc,
isFieldValidating: warningFunc,
isFieldsValidating: warningFunc,
resetFields: warningFunc,
setFields: warningFunc,
setFieldValue: warningFunc,
setFieldsValue: warningFunc,
validateFields: warningFunc,
submit: warningFunc,
getInternalHooks: function getInternalHooks() {
warningFunc();
return {
dispatch: warningFunc,
initEntityValue: warningFunc,
registerField: warningFunc,
useSubscribe: warningFunc,
setInitialValues: warningFunc,
destroyForm: warningFunc,
setCallbacks: warningFunc,
registerWatch: warningFunc,
getFields: warningFunc,
setValidateMessages: warningFunc,
setPreserve: warningFunc,
getInitialValue: warningFunc
};
}
});
var ListContext = /* @__PURE__ */ React.createContext(null);
function toArray(value) {
if (value === void 0 || value === null) {
return [];
}
return Array.isArray(value) ? value : [value];
}
function isFormInstance(form) {
return form && !!form._init;
}
function newMessages() {
return {
default: "Validation error on field %s",
required: "%s is required",
enum: "%s must be one of %s",
whitespace: "%s cannot be empty",
date: {
format: "%s date %s is invalid for format %s",
parse: "%s date could not be parsed, %s is invalid ",
invalid: "%s date %s is invalid"
},
types: {
string: "%s is not a %s",
method: "%s is not a %s (function)",
array: "%s is not an %s",
object: "%s is not an %s",
number: "%s is not a %s",
date: "%s is not a %s",
boolean: "%s is not a %s",
integer: "%s is not an %s",
float: "%s is not a %s",
regexp: "%s is not a valid %s",
email: "%s is not a valid %s",
url: "%s is not a valid %s",
hex: "%s is not a valid %s"
},
string: {
len: "%s must be exactly %s characters",
min: "%s must be at least %s characters",
max: "%s cannot be longer than %s characters",
range: "%s must be between %s and %s characters"
},
number: {
len: "%s must equal %s",
min: "%s cannot be less than %s",
max: "%s cannot be greater than %s",
range: "%s must be between %s and %s"
},
array: {
len: "%s must be exactly %s in length",
min: "%s cannot be less than %s in length",
max: "%s cannot be greater than %s in length",
range: "%s must be between %s and %s in length"
},
pattern: {
mismatch: "%s value %s does not match pattern %s"
},
clone: function clone() {
var cloned = JSON.parse(JSON.stringify(this));
cloned.clone = this.clone;
return cloned;
}
};
}
var messages = newMessages();
function _isNativeFunction(t) {
try {
return -1 !== Function.toString.call(t).indexOf("[native code]");
} catch (n) {
return "function" == typeof t;
}
}
function _construct(t, e, r) {
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
var o = [null];
o.push.apply(o, e);
var p = new (t.bind.apply(t, o))();
return r && _setPrototypeOf(p, r.prototype), p;
}
function _wrapNativeSuper(t) {
var r = "function" == typeof Map ? /* @__PURE__ */ new Map() : void 0;
return _wrapNativeSuper = function _wrapNativeSuper2(t2) {
if (null === t2 || !_isNativeFunction(t2)) return t2;
if ("function" != typeof t2) throw new TypeError("Super expression must either be null or a function");
if (void 0 !== r) {
if (r.has(t2)) return r.get(t2);
r.set(t2, Wrapper);
}
function Wrapper() {
return _construct(t2, arguments, _getPrototypeOf(this).constructor);
}
return Wrapper.prototype = Object.create(t2.prototype, {
constructor: {
value: Wrapper,
enumerable: false,
writable: true,
configurable: true
}
}), _setPrototypeOf(Wrapper, t2);
}, _wrapNativeSuper(t);
}
var formatRegExp = /%[sdj%]/g;
var warning$2 = function warning() {
};
if (typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production" && typeof window !== "undefined" && typeof document !== "undefined") {
warning$2 = function warning3(type4, errors) {
if (typeof console !== "undefined" && console.warn && typeof ASYNC_VALIDATOR_NO_WARNING === "undefined") {
if (errors.every(function(e) {
return typeof e === "string";
})) {
console.warn(type4, errors);
}
}
};
}
function convertFieldsError(errors) {
if (!errors || !errors.length) return null;
var fields = {};
errors.forEach(function(error) {
var field = error.field;
fields[field] = fields[field] || [];
fields[field].push(error);
});
return fields;
}
function format(template) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
var i = 0;
var len = args.length;
if (typeof template === "function") {
return template.apply(null, args);
}
if (typeof template === "string") {
var str = template.replace(formatRegExp, function(x) {
if (x === "%%") {
return "%";
}
if (i >= len) {
return x;
}
switch (x) {
case "%s":
return String(args[i++]);
case "%d":
return Number(args[i++]);
case "%j":
try {
return JSON.stringify(args[i++]);
} catch (_) {
return "[Circular]";
}
break;
default:
return x;
}
});
return str;
}
return template;
}
function isNativeStringType(type4) {
return type4 === "string" || type4 === "url" || type4 === "hex" || type4 === "email" || type4 === "date" || type4 === "pattern";
}
function isEmptyValue(value, type4) {
if (value === void 0 || value === null) {
return true;
}
if (type4 === "array" && Array.isArray(value) && !value.length) {
return true;
}
if (isNativeStringType(type4) && typeof value === "string" && !value) {
return true;
}
return false;
}
function asyncParallelArray(arr, func, callback) {
var results = [];
var total = 0;
var arrLength = arr.length;
function count(errors) {
results.push.apply(results, _toConsumableArray(errors || []));
total++;
if (total === arrLength) {
callback(results);
}
}
arr.forEach(function(a) {
func(a, count);
});
}
function asyncSerialArray(arr, func, callback) {
var index2 = 0;
var arrLength = arr.length;
function next2(errors) {
if (errors && errors.length) {
callback(errors);
return;
}
var original = index2;
index2 = index2 + 1;
if (original < arrLength) {
func(arr[original], next2);
} else {
callback([]);
}
}
next2([]);
}
function flattenObjArr(objArr) {
var ret = [];
Object.keys(objArr).forEach(function(k) {
ret.push.apply(ret, _toConsumableArray(objArr[k] || []));
});
return ret;
}
var AsyncValidationError = /* @__PURE__ */ function(_Error) {
_inherits(AsyncValidationError2, _Error);
var _super = _createSuper(AsyncValidationError2);
function AsyncValidationError2(errors, fields) {
var _this;
_classCallCheck(this, AsyncValidationError2);
_this = _super.call(this, "Async Validation Error");
_defineProperty(_assertThisInitialized(_this), "errors", void 0);
_defineProperty(_assertThisInitialized(_this), "fields", void 0);
_this.errors = errors;
_this.fields = fields;
return _this;
}
return _createClass(AsyncValidationError2);
}(/* @__PURE__ */ _wrapNativeSuper(Error));
function asyncMap(objArr, option, func, callback, source) {
if (option.first) {
var _pending = new Promise(function(resolve, reject) {
var next2 = function next3(errors) {
callback(errors);
return errors.length ? reject(new AsyncValidationError(errors, convertFieldsError(errors))) : resolve(source);
};
var flattenArr = flattenObjArr(objArr);
asyncSerialArray(flattenArr, func, next2);
});
_pending.catch(function(e) {
return e;
});
return _pending;
}
var firstFields = option.firstFields === true ? Object.keys(objArr) : option.firstFields || [];
var objArrKeys = Object.keys(objArr);
var objArrLength = objArrKeys.length;
var total = 0;
var results = [];
var pending = new Promise(function(resolve, reject) {
var next2 = function next3(errors) {
results.push.apply(results, errors);
total++;
if (total === objArrLength) {
callback(results);
return results.length ? reject(new AsyncValidationError(results, convertFieldsError(results))) : resolve(source);
}
};
if (!objArrKeys.length) {
callback(results);
resolve(source);
}
objArrKeys.forEach(function(key) {
var arr = objArr[key];
if (firstFields.indexOf(key) !== -1) {
asyncSerialArray(arr, func, next2);
} else {
asyncParallelArray(arr, func, next2);
}
});
});
pending.catch(function(e) {
return e;
});
return pending;
}
function isErrorObj(obj) {
return !!(obj && obj.message !== void 0);
}
function getValue(value, path) {
var v = value;
for (var i = 0; i < path.length; i++) {
if (v == void 0) {
return v;
}
v = v[path[i]];
}
return v;
}
function complementError(rule, source) {
return function(oe) {
var fieldValue;
if (rule.fullFields) {
fieldValue = getValue(source, rule.fullFields);
} else {
fieldValue = source[oe.field || rule.fullField];
}
if (isErrorObj(oe)) {
oe.field = oe.field || rule.fullField;
oe.fieldValue = fieldValue;
return oe;
}
return {
message: typeof oe === "function" ? oe() : oe,
fieldValue,
field: oe.field || rule.fullField
};
};
}
function deepMerge(target, source) {
if (source) {
for (var s in source) {
if (source.hasOwnProperty(s)) {
var value = source[s];
if (_typeof(value) === "object" && _typeof(target[s]) === "object") {
target[s] = _objectSpread2(_objectSpread2({}, target[s]), value);
} else {
target[s] = value;
}
}
}
}
return target;
}
var ENUM$1 = "enum";
var enumerable$1 = function enumerable(rule, value, source, errors, options) {
rule[ENUM$1] = Array.isArray(rule[ENUM$1]) ? rule[ENUM$1] : [];
if (rule[ENUM$1].indexOf(value) === -1) {
errors.push(format(options.messages[ENUM$1], rule.fullField, rule[ENUM$1].join(", ")));
}
};
var pattern$2 = function pattern(rule, value, source, errors, options) {
if (rule.pattern) {
if (rule.pattern instanceof RegExp) {
rule.pattern.lastIndex = 0;
if (!rule.pattern.test(value)) {
errors.push(format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern));
}
} else if (typeof rule.pattern === "string") {
var _pattern = new RegExp(rule.pattern);
if (!_pattern.test(value)) {
errors.push(format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern));
}
}
}
};
var range = function range2(rule, value, source, errors, options) {
var len = typeof rule.len === "number";
var min = typeof rule.min === "number";
var max = typeof rule.max === "number";
var spRegexp = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
var val = value;
var key = null;
var num = typeof value === "number";
var str = typeof value === "string";
var arr = Array.isArray(value);
if (num) {
key = "number";
} else if (str) {
key = "string";
} else if (arr) {
key = "array";
}
if (!key) {
return false;
}
if (arr) {
val = value.length;
}
if (str) {
val = value.replace(spRegexp, "_").length;
}
if (len) {
if (val !== rule.len) {
errors.push(format(options.messages[key].len, rule.fullField, rule.len));
}
} else if (min && !max && val < rule.min) {
errors.push(format(options.messages[key].min, rule.fullField, rule.min));
} else if (max && !min && val > rule.max) {
errors.push(format(options.messages[key].max, rule.fullField, rule.max));
} else if (min && max && (val < rule.min || val > rule.max)) {
errors.push(format(options.messages[key].range, rule.fullField, rule.min, rule.max));
}
};
var required$1 = function required(rule, value, source, errors, options, type4) {
if (rule.required && (!source.hasOwnProperty(rule.field) || isEmptyValue(value, type4 || rule.type))) {
errors.push(format(options.messages.required, rule.fullField));
}
};
var urlReg;
const getUrlRegex = function() {
if (urlReg) {
return urlReg;
}
var word = "[a-fA-F\\d:]";
var b = function b2(options) {
return options && options.includeBoundaries ? "(?:(?<=\\s|^)(?=".concat(word, ")|(?<=").concat(word, ")(?=\\s|$))") : "";
};
var v4 = "(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}";
var v6seg = "[a-fA-F\\d]{1,4}";
var v6List = [
"(?:".concat(v6seg, ":){7}(?:").concat(v6seg, "|:)"),
// 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
"(?:".concat(v6seg, ":){6}(?:").concat(v4, "|:").concat(v6seg, "|:)"),
// 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::
"(?:".concat(v6seg, ":){5}(?::").concat(v4, "|(?::").concat(v6seg, "){1,2}|:)"),
// 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::
"(?:".concat(v6seg, ":){4}(?:(?::").concat(v6seg, "){0,1}:").concat(v4, "|(?::").concat(v6seg, "){1,3}|:)"),
// 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::
"(?:".concat(v6seg, ":){3}(?:(?::").concat(v6seg, "){0,2}:").concat(v4, "|(?::").concat(v6seg, "){1,4}|:)"),
// 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::
"(?:".concat(v6seg, ":){2}(?:(?::").concat(v6seg, "){0,3}:").concat(v4, "|(?::").concat(v6seg, "){1,5}|:)"),
// 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::
"(?:".concat(v6seg, ":){1}(?:(?::").concat(v6seg, "){0,4}:").concat(v4, "|(?::").concat(v6seg, "){1,6}|:)"),
// 1:: 1::3:4:5:6:7:8 1::8 1::
"(?::(?:(?::".concat(v6seg, "){0,5}:").concat(v4, "|(?::").concat(v6seg, "){1,7}|:))")
// ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::
];
var v6Eth0 = "(?:%[0-9a-zA-Z]{1,})?";
var v6 = "(?:".concat(v6List.join("|"), ")").concat(v6Eth0);
var v46Exact = new RegExp("(?:^".concat(v4, "$)|(?:^").concat(v6, "$)"));
var v4exact = new RegExp("^".concat(v4, "$"));
var v6exact = new RegExp("^".concat(v6, "$"));
var ip = function ip2(options) {
return options && options.exact ? v46Exact : new RegExp("(?:".concat(b(options)).concat(v4).concat(b(options), ")|(?:").concat(b(options)).concat(v6).concat(b(options), ")"), "g");
};
ip.v4 = function(options) {
return options && options.exact ? v4exact : new RegExp("".concat(b(options)).concat(v4).concat(b(options)), "g");
};
ip.v6 = function(options) {
return options && options.exact ? v6exact : new RegExp("".concat(b(options)).concat(v6).concat(b(options)), "g");
};
var protocol = "(?:(?:[a-z]+:)?//)";
var auth = "(?:\\S+(?::\\S*)?@)?";
var ipv4 = ip.v4().source;
var ipv6 = ip.v6().source;
var host = "(?:(?:[a-z\\u00a1-\\uffff0-9][-_]*)*[a-z\\u00a1-\\uffff0-9]+)";
var domain = "(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*";
var tld = "(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))";
var port = "(?::\\d{2,5})?";
var path = '(?:[/?#][^\\s"]*)?';
var regex = "(?:".concat(protocol, "|www\\.)").concat(auth, "(?:localhost|").concat(ipv4, "|").concat(ipv6, "|").concat(host).concat(domain).concat(tld, ")").concat(port).concat(path);
urlReg = new RegExp("(?:^".concat(regex, "$)"), "i");
return urlReg;
};
var pattern$1 = {
// http://emailregex.com/
email: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/,
// url: new RegExp(
// '^(?!mailto:)(?:(?:http|https|ftp)://|//)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$',
// 'i',
// ),
hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i
};
var types = {
integer: function integer(value) {
return types.number(value) && parseInt(value, 10) === value;
},
float: function float(value) {
return types.number(value) && !types.integer(value);
},
array: function array(value) {
return Array.isArray(value);
},
regexp: function regexp(value) {
if (value instanceof RegExp) {
return true;
}
try {
return !!new RegExp(value);
} catch (e) {
return false;
}
},
date: function date(value) {
return typeof value.getTime === "function" && typeof value.getMonth === "function" && typeof value.getYear === "function" && !isNaN(value.getTime());
},
number: function number(value) {
if (isNaN(value)) {
return false;
}
return typeof value === "number";
},
object: function object(value) {
return _typeof(value) === "object" && !types.array(value);
},
method: function method(value) {
return typeof value === "function";
},
email: function email(value) {
return typeof value === "string" && value.length <= 320 && !!value.match(pattern$1.email);
},
url: function url(value) {
return typeof value === "string" && value.length <= 2048 && !!value.match(getUrlRegex());
},
hex: function hex(value) {
return typeof value === "string" && !!value.match(pattern$1.hex);
}
};
var type$1 = function type(rule, value, source, errors, options) {
if (rule.required && value === void 0) {
required$1(rule, value, source, errors, options);
return;
}
var custom = ["integer", "float", "array", "regexp", "object", "method", "email", "number", "date", "url", "hex"];
var ruleType = rule.type;
if (custom.indexOf(ruleType) > -1) {
if (!types[ruleType](value)) {
errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type));
}
} else if (ruleType && _typeof(value) !== rule.type) {
errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type));
}
};
var whitespace$1 = function whitespace(rule, value, source, errors, options) {
if (/^\s+$/.test(value) || value === "") {
errors.push(format(options.messages.whitespace, rule.fullField));
}
};
const rules = {
required: required$1,
whitespace: whitespace$1,
type: type$1,
range,
enum: enumerable$1,
pattern: pattern$2
};
var any = function any2(rule, value, callback, source, options) {
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if (isEmptyValue(value) && !rule.required) {
return callback();
}
rules.required(rule, value, source, errors, options);
}
callback(errors);
};
var array2 = function array3(rule, value, callback, source, options) {
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if ((value === void 0 || value === null) && !rule.required) {
return callback();
}
rules.required(rule, value, source, errors, options, "array");
if (value !== void 0 && value !== null) {
rules.type(rule, value, source, errors, options);
rules.range(rule, value, source, errors, options);
}
}
callback(errors);
};
var boolean = function boolean2(rule, value, callback, source, options) {
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if (isEmptyValue(value) && !rule.required) {
return callback();
}
rules.required(rule, value, source, errors, options);
if (value !== void 0) {
rules.type(rule, value, source, errors, options);
}
}
callback(errors);
};
var date2 = function date3(rule, value, callback, source, options) {
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if (isEmptyValue(value, "date") && !rule.required) {
return callback();
}
rules.required(rule, value, source, errors, options);
if (!isEmptyValue(value, "date")) {
var dateObject;
if (value instanceof Date) {
dateObject = value;
} else {
dateObject = new Date(value);
}
rules.type(rule, dateObject, source, errors, options);
if (dateObject) {
rules.range(rule, dateObject.getTime(), source, errors, options);
}
}
}
callback(errors);
};
var ENUM = "enum";
var enumerable2 = function enumerable3(rule, value, callback, source, options) {
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if (isEmptyValue(value) && !rule.required) {
return callback();
}
rules.required(rule, value, source, errors, options);
if (value !== void 0) {
rules[ENUM](rule, value, source, errors, options);
}
}
callback(errors);
};
var floatFn = function floatFn2(rule, value, callback, source, options) {
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if (isEmptyValue(value) && !rule.required) {
return callback();
}
rules.required(rule, value, source, errors, options);
if (value !== void 0) {
rules.type(rule, value, source, errors, options);
rules.range(rule, value, source, errors, options);
}
}
callback(errors);
};
var integer2 = function integer3(rule, value, callback, source, options) {
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if (isEmptyValue(value) && !rule.required) {
return callback();
}
rules.required(rule, value, source, errors, options);
if (value !== void 0) {
rules.type(rule, value, source, errors, options);
rules.range(rule, value, source, errors, options);
}
}
callback(errors);
};
var method2 = function method3(rule, value, callback, source, options) {
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if (isEmptyValue(value) && !rule.required) {
return callback();
}
rules.required(rule, value, source, errors, options);
if (value !== void 0) {
rules.type(rule, value, source, errors, options);
}
}
callback(errors);
};
var number2 = function number3(rule, value, callback, source, options) {
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if (value === "") {
value = void 0;
}
if (isEmptyValue(value) && !rule.required) {
return callback();
}
rules.required(rule, value, source, errors, options);
if (value !== void 0) {
rules.type(rule, value, source, errors, options);
rules.range(rule, value, source, errors, options);
}
}
callback(errors);
};
var object2 = function object3(rule, value, callback, source, options) {
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if (isEmptyValue(value) && !rule.required) {
return callback();
}
rules.required(rule, value, source, errors, options);
if (value !== void 0) {
rules.type(rule, value, source, errors, options);
}
}
callback(errors);
};
var pattern2 = function pattern3(rule, value, callback, source, options) {
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if (isEmptyValue(value, "string") && !rule.required) {
return callback();
}
rules.required(rule, value, source, errors, options);
if (!isEmptyValue(value, "string")) {
rules.pattern(rule, value, source, errors, options);
}
}
callback(errors);
};
var regexp$1 = function regexp2(rule, value, callback, source, options) {
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if (isEmptyValue(value) && !rule.required) {
return callback();
}
rules.required(rule, value, source, errors, options);
if (!isEmptyValue(value)) {
rules.type(rule, value, source, errors, options);
}
}
callback(errors);
};
var required2 = function required3(rule, value, callback, source, options) {
var errors = [];
var type4 = Array.isArray(value) ? "array" : _typeof(value);
rules.required(rule, value, source, errors, options, type4);
callback(errors);
};
var string = function string2(rule, value, callback, source, options) {
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if (isEmptyValue(value, "string") && !rule.required) {
return callback();
}
rules.required(rule, value, source, errors, options, "string");
if (!isEmptyValue(value, "string")) {
rules.type(rule, value, source, errors, options);
rules.range(rule, value, source, errors, options);
rules.pattern(rule, value, source, errors, options);
if (rule.whitespace === true) {
rules.whitespace(rule, value, source, errors, options);
}
}
}
callback(errors);
};
var type2 = function type3(rule, value, callback, source, options) {
var ruleType = rule.type;
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if (isEmptyValue(value, ruleType) && !rule.required) {
return callback();
}
rules.required(rule, value, source, errors, options, ruleType);
if (!isEmptyValue(value, ruleType)) {
rules.type(rule, value, source, errors, options);
}
}
callback(errors);
};
const validators = {
string,
method: method2,
number: number2,
boolean,
regexp: regexp$1,
integer: integer2,
float: floatFn,
array: array2,
object: object2,
enum: enumerable2,
pattern: pattern2,
date: date2,
url: type2,
hex: type2,
email: type2,
required: required2,
any
};
var Schema = /* @__PURE__ */ function() {
function Schema2(descriptor) {
_classCallCheck(this, Schema2);
_defineProperty(this, "rules", null);
_defineProperty(this, "_messages", messages);
this.define(descriptor);
}
_createClass(Schema2, [{
key: "define",
value: function define(rules2) {
var _this = this;
if (!rules2) {
throw new Error("Cannot configure a schema with no rules");
}
if (_typeof(rules2) !== "object" || Array.isArray(rules2)) {
throw new Error("Rules must be an object");
}
this.rules = {};
Object.keys(rules2).forEach(function(name) {
var item = rules2[name];
_this.rules[name] = Array.isArray(item) ? item : [item];
});
}
}, {
key: "messages",
value: function messages2(_messages) {
if (_messages) {
this._messages = deepMerge(newMessages(), _messages);
}
return this._messages;
}
}, {
key: "validate",
value: function validate(source_) {
var _this2 = this;
var o = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
var oc = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : function() {
};
var source = source_;
var options = o;
var callback = oc;
if (typeof options === "function") {
callback = options;
options = {};
}
if (!this.rules || Object.keys(this.rules).length === 0) {
if (callback) {
callback(null, source);
}
return Promise.resolve(source);
}
function complete(results) {
var errors = [];
var fields = {};
function add(e) {
if (Array.isArray(e)) {
var _errors;
errors = (_errors = errors).concat.apply(_errors, _toConsumableArray(e));
} else {
errors.push(e);
}
}
for (var i = 0; i < results.length; i++) {
add(results[i]);
}
if (!errors.length) {
callback(null, source);
} else {
fields = convertFieldsError(errors);
callback(errors, fields);
}
}
if (options.messages) {
var messages$1 = this.messages();
if (messages$1 === messages) {
messages$1 = newMessages();
}
deepMerge(messages$1, options.messages);
options.messages = messages$1;
} else {
options.messages = this.messages();
}
var series = {};
var keys2 = options.keys || Object.keys(this.rules);
keys2.forEach(function(z) {
var arr = _this2.rules[z];
var value = source[z];
arr.forEach(function(r) {
var rule = r;
if (typeof rule.transform === "function") {
if (source === source_) {
source = _objectSpread2({}, source);
}
value = source[z] = rule.transform(value);
if (value !== void 0 && value !== null) {
rule.type = rule.type || (Array.isArray(value) ? "array" : _typeof(value));
}
}
if (typeof rule === "function") {
rule = {
validator: rule
};
} else {
rule = _objectSpread2({}, rule);
}
rule.validator = _this2.getValidationMethod(rule);
if (!rule.validator) {
return;
}
rule.field = z;
rule.fullField = rule.fullField || z;
rule.type = _this2.getType(rule);
series[z] = series[z] || [];
series[z].push({
rule,
value,
source,
field: z
});
});
});
var errorFields = {};
return asyncMap(series, options, function(data, doIt) {
var rule = data.rule;
var deep = (rule.type === "object" || rule.type === "array") && (_typeof(rule.fields) === "object" || _typeof(rule.defaultField) === "object");
deep = deep && (rule.required || !rule.required && data.value);
rule.field = data.field;
function addFullField(key, schema) {
return _objectSpread2(_objectSpread2({}, schema), {}, {
fullField: "".concat(rule.fullField, ".").concat(key),
fullFields: rule.fullFields ? [].concat(_toConsumableArray(rule.fullFields), [key]) : [key]
});
}
function cb() {
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
var errorList = Array.isArray(e) ? e : [e];
if (!options.suppressWarning && errorList.length) {
Schema2.warning("async-validator:", errorList);
}
if (errorList.length && rule.message !== void 0) {
errorList = [].concat(rule.message);
}
var filledErrors = errorList.map(complementError(rule, source));
if (options.first && filledErrors.length) {
errorFields[rule.field] = 1;
return doIt(filledErrors);
}
if (!deep) {
doIt(filledErrors);
} else {
if (rule.required && !data.value) {
if (rule.message !== void 0) {
filledErrors = [].concat(rule.message).map(complementError(rule, source));
} else if (options.error) {
filledErrors = [options.error(rule, format(options.messages.required, rule.field))];
}
return doIt(filledErrors);
}
var fieldsSchema = {};
if (rule.defaultField) {
Object.keys(data.value).map(function(key) {
fieldsSchema[key] = rule.defaultField;
});
}
fieldsSchema = _objectSpread2(_objectSpread2({}, fieldsSchema), data.rule.fields);
var paredFieldsSchema = {};
Object.keys(fieldsSchema).forEach(function(field) {
var fieldSchema = fieldsSchema[field];
var fieldSchemaList = Array.isArray(fieldSchema) ? fieldSchema : [fieldSchema];
paredFieldsSchema[field] = fieldSchemaList.map(addFullField.bind(null, field));
});
var schema = new Schema2(paredFieldsSchema);
schema.messages(options.messages);
if (data.rule.options) {
data.rule.options.messages = options.messages;
data.rule.options.error = options.error;
}
schema.validate(data.value, data.rule.options || options, function(errs) {
var finalErrors = [];
if (filledErrors && filledErrors.length) {
finalErrors.push.apply(finalErrors, _toConsumableArray(filledErrors));
}
if (errs && errs.length) {
finalErrors.push.apply(finalErrors, _toConsumableArray(errs));
}
doIt(finalErrors.length ? finalErrors : null);
});
}
}
var res;
if (rule.asyncValidator) {
res = rule.asyncValidator(rule, data.value, cb, data.source, options);
} else if (rule.validator) {
try {
res = rule.validator(rule, data.value, cb, data.source, options);
} catch (error) {
var _console$error, _console;
(_console$error = (_console = console).error) === null || _console$error === void 0 || _console$error.call(_console, error);
if (!options.suppressValidatorError) {
setTimeout(function() {
throw error;
}, 0);
}
cb(error.message);
}
if (res === true) {
cb();
} else if (res === false) {
cb(typeof rule.message === "function" ? rule.message(rule.fullField || rule.field) : rule.message || "".concat(rule.fullField || rule.field, " fails"));
} else if (res instanceof Array) {
cb(res);
} else if (res instanceof Error) {
cb(res.message);
}
}
if (res && res.then) {
res.then(function() {
return cb();
}, function(e) {
return cb(e);
});
}
}, function(results) {
complete(results);
}, source);
}
}, {
key: "getType",
value: function getType(rule) {
if (rule.type === void 0 && rule.pattern instanceof RegExp) {
rule.type = "pattern";
}
if (typeof rule.validator !== "function" && rule.type && !validators.hasOwnProperty(rule.type)) {
throw new Error(format("Unknown rule type %s", rule.type));
}
return rule.type || "string";
}
}, {
key: "getValidationMethod",
value: function getValidationMethod(rule) {
if (typeof rule.validator === "function") {
return rule.validator;
}
var keys2 = Object.keys(rule);
var messageIndex = keys2.indexOf("message");
if (messageIndex !== -1) {
keys2.splice(messageIndex, 1);
}
if (keys2.length === 1 && keys2[0] === "required") {
return validators.required;
}
return validators[this.getType(rule)] || void 0;
}
}]);
return Schema2;
}();
_defineProperty(Schema, "register", function register(type4, validator) {
if (typeof validator !== "function") {
throw new Error("Cannot register a validator by type, validator is not a function");
}
validators[type4] = validator;
});
_defineProperty(Schema, "warning", warning$2);
_defineProperty(Schema, "messages", messages);
_defineProperty(Schema, "validators", validators);
var typeTemplate$1 = "'${name}' is not a valid ${type}";
var defaultValidateMessages = {
default: "Validation error on field '${name}'",
required: "'${name}' is required",
enum: "'${name}' must be one of [${enum}]",
whitespace: "'${name}' cannot be empty",
date: {
format: "'${name}' is invalid for format date",
parse: "'${name}' could not be parsed as date",
invalid: "'${name}' is invalid date"
},
types: {
string: typeTemplate$1,
method: typeTemplate$1,
array: typeTemplate$1,
object: typeTemplate$1,
number: typeTemplate$1,
date: typeTemplate$1,
boolean: typeTemplate$1,
integer: typeTemplate$1,
float: typeTemplate$1,
regexp: typeTemplate$1,
email: typeTemplate$1,
url: typeTemplate$1,
hex: typeTemplate$1
},
string: {
len: "'${name}' must be exactly ${len} characters",
min: "'${name}' must be at least ${min} characters",
max: "'${name}' cannot be longer than ${max} characters",
range: "'${name}' must be between ${min} and ${max} characters"
},
number: {
len: "'${name}' must equal ${len}",
min: "'${name}' cannot be less than ${min}",
max: "'${name}' cannot be greater than ${max}",
range: "'${name}' must be between ${min} and ${max}"
},
array: {
len: "'${name}' must be exactly ${len} in length",
min: "'${name}' cannot be less than ${min} in length",
max: "'${name}' cannot be greater than ${max} in length",
range: "'${name}' must be between ${min} and ${max} in length"
},
pattern: {
mismatch: "'${name}' does not match pattern ${pattern}"
}
};
var AsyncValidator = Schema;
function replaceMessage(template, kv) {
return template.replace(/\$\{\w+\}/g, function(str) {
var key = str.slice(2, -1);
return kv[key];
});
}
var CODE_LOGIC_ERROR = "CODE_LOGIC_ERROR";
function validateRule(_x, _x2, _x3, _x4, _x5) {
return _validateRule.apply(this, arguments);
}
function _validateRule() {
_validateRule = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee2(name, value, rule, options, messageVariables) {
var cloneRule, originValidator, subRuleField, validator, messages2, result, subResults, kv, fillVariableResult;
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
cloneRule = _objectSpread2({}, rule);
delete cloneRule.ruleIndex;
AsyncValidator.warning = function() {
return void 0;
};
if (cloneRule.validator) {
originValidator = cloneRule.validator;
cloneRule.validator = function() {
try {
return originValidator.apply(void 0, arguments);
} catch (error) {
console.error(error);
return Promise.reject(CODE_LOGIC_ERROR);
}
};
}
subRuleField = null;
if (cloneRule && cloneRule.type === "array" && cloneRule.defaultField) {
subRuleField = cloneRule.defaultField;
delete cloneRule.defaultField;
}
validator = new AsyncValidator(_defineProperty({}, name, [cloneRule]));
messages2 = merge$1(defaultValidateMessages, options.validateMessages);
validator.messages(messages2);
result = [];
_context2.prev = 10;
_context2.next = 13;
return Promise.resolve(validator.validate(_defineProperty({}, name, value), _objectSpread2({}, options)));
case 13:
_context2.next = 18;
break;
case 15:
_context2.prev = 15;
_context2.t0 = _context2["catch"](10);
if (_context2.t0.errors) {
result = _context2.t0.errors.map(function(_ref4, index2) {
var message = _ref4.message;
var mergedMessage = message === CODE_LOGIC_ERROR ? messages2.default : message;
return /* @__PURE__ */ React.isValidElement(mergedMessage) ? (
// Wrap ReactNode with `key`
/* @__PURE__ */ React.cloneElement(mergedMessage, {
key: "error_".concat(index2)
})
) : mergedMessage;
});
}
case 18:
if (!(!result.length && subRuleField)) {
_context2.next = 23;
break;
}
_context2.next = 21;
return Promise.all(value.map(function(subValue, i) {
return validateRule("".concat(name, ".").concat(i), subValue, subRuleField, options, messageVariables);
}));
case 21:
subResults = _context2.sent;
return _context2.abrupt("return", subResults.reduce(function(prev2, errors) {
return [].concat(_toConsumableArray(prev2), _toConsumableArray(errors));
}, []));
case 23:
kv = _objectSpread2(_objectSpread2({}, rule), {}, {
name,
enum: (rule.enum || []).join(", ")
}, messageVariables);
fillVariableResult = result.map(function(error) {
if (typeof error === "string") {
return replaceMessage(error, kv);
}
return error;
});
return _context2.abrupt("return", fillVariableResult);
case 26:
case "end":
return _context2.stop();
}
}, _callee2, null, [[10, 15]]);
}));
return _validateRule.apply(this, arguments);
}
function validateRules(namePath, value, rules2, options, validateFirst, messageVariables) {
var name = namePath.join(".");
var filledRules = rules2.map(function(currentRule, ruleIndex) {
var originValidatorFunc = currentRule.validator;
var cloneRule = _objectSpread2(_objectSpread2({}, currentRule), {}, {
ruleIndex
});
if (originValidatorFunc) {
cloneRule.validator = function(rule, val, callback) {
var hasPromise = false;
var wrappedCallback = function wrappedCallback2() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
Promise.resolve().then(function() {
warningOnce(!hasPromise, "Your validator function has already return a promise. `callback` will be ignored.");
if (!hasPromise) {
callback.apply(void 0, args);
}
});
};
var promise = originValidatorFunc(rule, val, wrappedCallback);
hasPromise = promise && typeof promise.then === "function" && typeof promise.catch === "function";
warningOnce(hasPromise, "`callback` is deprecated. Please return a promise instead.");
if (hasPromise) {
promise.then(function() {
callback();
}).catch(function(err) {
callback(err || " ");
});
}
};
}
return cloneRule;
}).sort(function(_ref, _ref2) {
var w1 = _ref.warningOnly, i1 = _ref.ruleIndex;
var w2 = _ref2.warningOnly, i2 = _ref2.ruleIndex;
if (!!w1 === !!w2) {
return i1 - i2;
}
if (w1) {
return 1;
}
return -1;
});
var summaryPromise;
if (validateFirst === true) {
summaryPromise = new Promise(/* @__PURE__ */ function() {
var _ref3 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee(resolve, reject) {
var i, rule, errors;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
i = 0;
case 1:
if (!(i < filledRules.length)) {
_context.next = 12;
break;
}
rule = filledRules[i];
_context.next = 5;
return validateRule(name, value, rule, options, messageVariables);
case 5:
errors = _context.sent;
if (!errors.length) {
_context.next = 9;
break;
}
reject([{
errors,
rule
}]);
return _context.abrupt("return");
case 9:
i += 1;
_context.next = 1;
break;
case 12:
resolve([]);
case 13:
case "end":
return _context.stop();
}
}, _callee);
}));
return function(_x6, _x7) {
return _ref3.apply(this, arguments);
};
}());
} else {
var rulePromises = filledRules.map(function(rule) {
return validateRule(name, value, rule, options, messageVariables).then(function(errors) {
return {
errors,
rule
};
});
});
summaryPromise = (validateFirst ? finishOnFirstFailed(rulePromises) : finishOnAllFailed(rulePromises)).then(function(errors) {
return Promise.reject(errors);
});
}
summaryPromise.catch(function(e) {
return e;
});
return summaryPromise;
}
function finishOnAllFailed(_x8) {
return _finishOnAllFailed.apply(this, arguments);
}
function _finishOnAllFailed() {
_finishOnAllFailed = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee3(rulePromises) {
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
return _context3.abrupt("return", Promise.all(rulePromises).then(function(errorsList) {
var _ref5;
var errors = (_ref5 = []).concat.apply(_ref5, _toConsumableArray(errorsList));
return errors;
}));
case 1:
case "end":
return _context3.stop();
}
}, _callee3);
}));
return _finishOnAllFailed.apply(this, arguments);
}
function finishOnFirstFailed(_x9) {
return _finishOnFirstFailed.apply(this, arguments);
}
function _finishOnFirstFailed() {
_finishOnFirstFailed = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee4(rulePromises) {
var count;
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
while (1) switch (_context4.prev = _context4.next) {
case 0:
count = 0;
return _context4.abrupt("return", new Promise(function(resolve) {
rulePromises.forEach(function(promise) {
promise.then(function(ruleError) {
if (ruleError.errors.length) {
resolve([ruleError]);
}
count += 1;
if (count === rulePromises.length) {
resolve([]);
}
});
});
}));
case 2:
case "end":
return _context4.stop();
}
}, _callee4);
}));
return _finishOnFirstFailed.apply(this, arguments);
}
function getNamePath(path) {
return toArray(path);
}
function cloneByNamePathList(store, namePathList) {
var newStore = {};
namePathList.forEach(function(namePath) {
var value = get(store, namePath);
newStore = set(newStore, namePath, value);
});
return newStore;
}
function containsNamePath(namePathList, namePath) {
var partialMatch = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
return namePathList && namePathList.some(function(path) {
return matchNamePath(namePath, path, partialMatch);
});
}
function matchNamePath(namePath, subNamePath) {
var partialMatch = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
if (!namePath || !subNamePath) {
return false;
}
if (!partialMatch && namePath.length !== subNamePath.length) {
return false;
}
return subNamePath.every(function(nameUnit, i) {
return namePath[i] === nameUnit;
});
}
function isSimilar(source, target) {
if (source === target) {
return true;
}
if (!source && target || source && !target) {
return false;
}
if (!source || !target || _typeof(source) !== "object" || _typeof(target) !== "object") {
return false;
}
var sourceKeys = Object.keys(source);
var targetKeys = Object.keys(target);
var keys2 = new Set([].concat(sourceKeys, targetKeys));
return _toConsumableArray(keys2).every(function(key) {
var sourceValue = source[key];
var targetValue = target[key];
if (typeof sourceValue === "function" && typeof targetValue === "function") {
return true;
}
return sourceValue === targetValue;
});
}
function defaultGetValueFromEvent(valuePropName) {
var event = arguments.length <= 1 ? void 0 : arguments[1];
if (event && event.target && _typeof(event.target) === "object" && valuePropName in event.target) {
return event.target[valuePropName];
}
return event;
}
function move(array4, moveIndex, toIndex) {
var length2 = array4.length;
if (moveIndex < 0 || moveIndex >= length2 || toIndex < 0 || toIndex >= length2) {
return array4;
}
var item = array4[moveIndex];
var diff = moveIndex - toIndex;
if (diff > 0) {
return [].concat(_toConsumableArray(array4.slice(0, toIndex)), [item], _toConsumableArray(array4.slice(toIndex, moveIndex)), _toConsumableArray(array4.slice(moveIndex + 1, length2)));
}
if (diff < 0) {
return [].concat(_toConsumableArray(array4.slice(0, moveIndex)), _toConsumableArray(array4.slice(moveIndex + 1, toIndex + 1)), [item], _toConsumableArray(array4.slice(toIndex + 1, length2)));
}
return array4;
}
var _excluded$2 = ["name"];
var EMPTY_ERRORS = [];
function requireUpdate(shouldUpdate, prev2, next2, prevValue, nextValue, info) {
if (typeof shouldUpdate === "function") {
return shouldUpdate(prev2, next2, "source" in info ? {
source: info.source
} : {});
}
return prevValue !== nextValue;
}
var Field = /* @__PURE__ */ function(_React$Component) {
_inherits(Field2, _React$Component);
var _super = _createSuper(Field2);
function Field2(props) {
var _this;
_classCallCheck(this, Field2);
_this = _super.call(this, props);
_defineProperty(_assertThisInitialized(_this), "state", {
resetCount: 0
});
_defineProperty(_assertThisInitialized(_this), "cancelRegisterFunc", null);
_defineProperty(_assertThisInitialized(_this), "mounted", false);
_defineProperty(_assertThisInitialized(_this), "touched", false);
_defineProperty(_assertThisInitialized(_this), "dirty", false);
_defineProperty(_assertThisInitialized(_this), "validatePromise", void 0);
_defineProperty(_assertThisInitialized(_this), "prevValidating", void 0);
_defineProperty(_assertThisInitialized(_this), "errors", EMPTY_ERRORS);
_defineProperty(_assertThisInitialized(_this), "warnings", EMPTY_ERRORS);
_defineProperty(_assertThisInitialized(_this), "cancelRegister", function() {
var _this$props = _this.props, preserve2 = _this$props.preserve, isListField = _this$props.isListField, name = _this$props.name;
if (_this.cancelRegisterFunc) {
_this.cancelRegisterFunc(isListField, preserve2, getNamePath(name));
}
_this.cancelRegisterFunc = null;
});
_defineProperty(_assertThisInitialized(_this), "getNamePath", function() {
var _this$props2 = _this.props, name = _this$props2.name, fieldContext = _this$props2.fieldContext;
var _fieldContext$prefixN = fieldContext.prefixName, prefixName = _fieldContext$prefixN === void 0 ? [] : _fieldContext$prefixN;
return name !== void 0 ? [].concat(_toConsumableArray(prefixName), _toConsumableArray(name)) : [];
});
_defineProperty(_assertThisInitialized(_this), "getRules", function() {
var _this$props3 = _this.props, _this$props3$rules = _this$props3.rules, rules2 = _this$props3$rules === void 0 ? [] : _this$props3$rules, fieldContext = _this$props3.fieldContext;
return rules2.map(function(rule) {
if (typeof rule === "function") {
return rule(fieldContext);
}
return rule;
});
});
_defineProperty(_assertThisInitialized(_this), "refresh", function() {
if (!_this.mounted) return;
_this.setState(function(_ref) {
var resetCount = _ref.resetCount;
return {
resetCount: resetCount + 1
};
});
});
_defineProperty(_assertThisInitialized(_this), "metaCache", null);
_defineProperty(_assertThisInitialized(_this), "triggerMetaEvent", function(destroy) {
var onMetaChange = _this.props.onMetaChange;
if (onMetaChange) {
var _meta = _objectSpread2(_objectSpread2({}, _this.getMeta()), {}, {
destroy
});
if (!isEqual(_this.metaCache, _meta)) {
onMetaChange(_meta);
}
_this.metaCache = _meta;
} else {
_this.metaCache = null;
}
});
_defineProperty(_assertThisInitialized(_this), "onStoreChange", function(prevStore, namePathList, info) {
var _this$props4 = _this.props, shouldUpdate = _this$props4.shouldUpdate, _this$props4$dependen = _this$props4.dependencies, dependencies = _this$props4$dependen === void 0 ? [] : _this$props4$dependen, onReset = _this$props4.onReset;
var store = info.store;
var namePath = _this.getNamePath();
var prevValue = _this.getValue(prevStore);
var curValue = _this.getValue(store);
var namePathMatch = namePathList && containsNamePath(namePathList, namePath);
if (info.type === "valueUpdate" && info.source === "external" && !isEqual(prevValue, curValue)) {
_this.touched = true;
_this.dirty = true;
_this.validatePromise = null;
_this.errors = EMPTY_ERRORS;
_this.warnings = EMPTY_ERRORS;
_this.triggerMetaEvent();
}
switch (info.type) {
case "reset":
if (!namePathList || namePathMatch) {
_this.touched = false;
_this.dirty = false;
_this.validatePromise = void 0;
_this.errors = EMPTY_ERRORS;
_this.warnings = EMPTY_ERRORS;
_this.triggerMetaEvent();
onReset === null || onReset === void 0 || onReset();
_this.refresh();
return;
}
break;
case "remove": {
if (shouldUpdate) {
_this.reRender();
return;
}
break;
}
case "setField": {
var data = info.data;
if (namePathMatch) {
if ("touched" in data) {
_this.touched = data.touched;
}
if ("validating" in data && !("originRCField" in data)) {
_this.validatePromise = data.validating ? Promise.resolve([]) : null;
}
if ("errors" in data) {
_this.errors = data.errors || EMPTY_ERRORS;
}
if ("warnings" in data) {
_this.warnings = data.warnings || EMPTY_ERRORS;
}
_this.dirty = true;
_this.triggerMetaEvent();
_this.reRender();
return;
} else if ("value" in data && containsNamePath(namePathList, namePath, true)) {
_this.reRender();
return;
}
if (shouldUpdate && !namePath.length && requireUpdate(shouldUpdate, prevStore, store, prevValue, curValue, info)) {
_this.reRender();
return;
}
break;
}
case "dependenciesUpdate": {
var dependencyList = dependencies.map(getNamePath);
if (dependencyList.some(function(dependency) {
return containsNamePath(info.relatedFields, dependency);
})) {
_this.reRender();
return;
}
break;
}
default:
if (namePathMatch || (!dependencies.length || namePath.length || shouldUpdate) && requireUpdate(shouldUpdate, prevStore, store, prevValue, curValue, info)) {
_this.reRender();
return;
}
break;
}
if (shouldUpdate === true) {
_this.reRender();
}
});
_defineProperty(_assertThisInitialized(_this), "validateRules", function(options) {
var namePath = _this.getNamePath();
var currentValue = _this.getValue();
var _ref2 = options || {}, triggerName = _ref2.triggerName, _ref2$validateOnly = _ref2.validateOnly, validateOnly = _ref2$validateOnly === void 0 ? false : _ref2$validateOnly;
var rootPromise = Promise.resolve().then(/* @__PURE__ */ _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee() {
var _this$props5, _this$props5$validate, validateFirst, messageVariables, validateDebounce, filteredRules, promise;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
if (_this.mounted) {
_context.next = 2;
break;
}
return _context.abrupt("return", []);
case 2:
_this$props5 = _this.props, _this$props5$validate = _this$props5.validateFirst, validateFirst = _this$props5$validate === void 0 ? false : _this$props5$validate, messageVariables = _this$props5.messageVariables, validateDebounce = _this$props5.validateDebounce;
filteredRules = _this.getRules();
if (triggerName) {
filteredRules = filteredRules.filter(function(rule) {
return rule;
}).filter(function(rule) {
var validateTrigger = rule.validateTrigger;
if (!validateTrigger) {
return true;
}
var triggerList = toArray(validateTrigger);
return triggerList.includes(triggerName);
});
}
if (!(validateDebounce && triggerName)) {
_context.next = 10;
break;
}
_context.next = 8;
return new Promise(function(resolve) {
setTimeout(resolve, validateDebounce);
});
case 8:
if (!(_this.validatePromise !== rootPromise)) {
_context.next = 10;
break;
}
return _context.abrupt("return", []);
case 10:
promise = validateRules(namePath, currentValue, filteredRules, options, validateFirst, messageVariables);
promise.catch(function(e) {
return e;
}).then(function() {
var ruleErrors = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : EMPTY_ERRORS;
if (_this.validatePromise === rootPromise) {
var _ruleErrors$forEach;
_this.validatePromise = null;
var nextErrors = [];
var nextWarnings = [];
(_ruleErrors$forEach = ruleErrors.forEach) === null || _ruleErrors$forEach === void 0 || _ruleErrors$forEach.call(ruleErrors, function(_ref4) {
var warningOnly = _ref4.rule.warningOnly, _ref4$errors = _ref4.errors, errors = _ref4$errors === void 0 ? EMPTY_ERRORS : _ref4$errors;
if (warningOnly) {
nextWarnings.push.apply(nextWarnings, _toConsumableArray(errors));
} else {
nextErrors.push.apply(nextErrors, _toConsumableArray(errors));
}
});
_this.errors = nextErrors;
_this.warnings = nextWarnings;
_this.triggerMetaEvent();
_this.reRender();
}
});
return _context.abrupt("return", promise);
case 13:
case "end":
return _context.stop();
}
}, _callee);
})));
if (validateOnly) {
return rootPromise;
}
_this.validatePromise = rootPromise;
_this.dirty = true;
_this.errors = EMPTY_ERRORS;
_this.warnings = EMPTY_ERRORS;
_this.triggerMetaEvent();
_this.reRender();
return rootPromise;
});
_defineProperty(_assertThisInitialized(_this), "isFieldValidating", function() {
return !!_this.validatePromise;
});
_defineProperty(_assertThisInitialized(_this), "isFieldTouched", function() {
return _this.touched;
});
_defineProperty(_assertThisInitialized(_this), "isFieldDirty", function() {
if (_this.dirty || _this.props.initialValue !== void 0) {
return true;
}
var fieldContext = _this.props.fieldContext;
var _fieldContext$getInte = fieldContext.getInternalHooks(HOOK_MARK), getInitialValue = _fieldContext$getInte.getInitialValue;
if (getInitialValue(_this.getNamePath()) !== void 0) {
return true;
}
return false;
});
_defineProperty(_assertThisInitialized(_this), "getErrors", function() {
return _this.errors;
});
_defineProperty(_assertThisInitialized(_this), "getWarnings", function() {
return _this.warnings;
});
_defineProperty(_assertThisInitialized(_this), "isListField", function() {
return _this.props.isListField;
});
_defineProperty(_assertThisInitialized(_this), "isList", function() {
return _this.props.isList;
});
_defineProperty(_assertThisInitialized(_this), "isPreserve", function() {
return _this.props.preserve;
});
_defineProperty(_assertThisInitialized(_this), "getMeta", function() {
_this.prevValidating = _this.isFieldValidating();
var meta = {
touched: _this.isFieldTouched(),
validating: _this.prevValidating,
errors: _this.errors,
warnings: _this.warnings,
name: _this.getNamePath(),
validated: _this.validatePromise === null
};
return meta;
});
_defineProperty(_assertThisInitialized(_this), "getOnlyChild", function(children) {
if (typeof children === "function") {
var _meta2 = _this.getMeta();
return _objectSpread2(_objectSpread2({}, _this.getOnlyChild(children(_this.getControlled(), _meta2, _this.props.fieldContext))), {}, {
isFunction: true
});
}
var childList = toArray$3(children);
if (childList.length !== 1 || !/* @__PURE__ */ React.isValidElement(childList[0])) {
return {
child: childList,
isFunction: false
};
}
return {
child: childList[0],
isFunction: false
};
});
_defineProperty(_assertThisInitialized(_this), "getValue", function(store) {
var getFieldsValue = _this.props.fieldContext.getFieldsValue;
var namePath = _this.getNamePath();
return get(store || getFieldsValue(true), namePath);
});
_defineProperty(_assertThisInitialized(_this), "getControlled", function() {
var childProps = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
var _this$props6 = _this.props, name = _this$props6.name, trigger = _this$props6.trigger, validateTrigger = _this$props6.validateTrigger, getValueFromEvent = _this$props6.getValueFromEvent, normalize2 = _this$props6.normalize, valuePropName = _this$props6.valuePropName, getValueProps = _this$props6.getValueProps, fieldContext = _this$props6.fieldContext;
var mergedValidateTrigger = validateTrigger !== void 0 ? validateTrigger : fieldContext.validateTrigger;
var namePath = _this.getNamePath();
var getInternalHooks3 = fieldContext.getInternalHooks, getFieldsValue = fieldContext.getFieldsValue;
var _getInternalHooks = getInternalHooks3(HOOK_MARK), dispatch = _getInternalHooks.dispatch;
var value = _this.getValue();
var mergedGetValueProps = getValueProps || function(val) {
return _defineProperty({}, valuePropName, val);
};
var originTriggerFunc = childProps[trigger];
var valueProps = name !== void 0 ? mergedGetValueProps(value) : {};
if (process.env.NODE_ENV !== "production" && valueProps) {
Object.keys(valueProps).forEach(function(key) {
warningOnce(typeof valueProps[key] !== "function", "It's not recommended to generate dynamic function prop by `getValueProps`. Please pass it to child component directly (prop: ".concat(key, ")"));
});
}
var control = _objectSpread2(_objectSpread2({}, childProps), valueProps);
control[trigger] = function() {
_this.touched = true;
_this.dirty = true;
_this.triggerMetaEvent();
var newValue;
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
if (getValueFromEvent) {
newValue = getValueFromEvent.apply(void 0, args);
} else {
newValue = defaultGetValueFromEvent.apply(void 0, [valuePropName].concat(args));
}
if (normalize2) {
newValue = normalize2(newValue, value, getFieldsValue(true));
}
dispatch({
type: "updateValue",
namePath,
value: newValue
});
if (originTriggerFunc) {
originTriggerFunc.apply(void 0, args);
}
};
var validateTriggerList = toArray(mergedValidateTrigger || []);
validateTriggerList.forEach(function(triggerName) {
var originTrigger = control[triggerName];
control[triggerName] = function() {
if (originTrigger) {
originTrigger.apply(void 0, arguments);
}
var rules2 = _this.props.rules;
if (rules2 && rules2.length) {
dispatch({
type: "validateField",
namePath,
triggerName
});
}
};
});
return control;
});
if (props.fieldContext) {
var getInternalHooks2 = props.fieldContext.getInternalHooks;
var _getInternalHooks2 = getInternalHooks2(HOOK_MARK), initEntityValue = _getInternalHooks2.initEntityValue;
initEntityValue(_assertThisInitialized(_this));
}
return _this;
}
_createClass(Field2, [{
key: "componentDidMount",
value: function componentDidMount() {
var _this$props7 = this.props, shouldUpdate = _this$props7.shouldUpdate, fieldContext = _this$props7.fieldContext;
this.mounted = true;
if (fieldContext) {
var getInternalHooks2 = fieldContext.getInternalHooks;
var _getInternalHooks3 = getInternalHooks2(HOOK_MARK), registerField = _getInternalHooks3.registerField;
this.cancelRegisterFunc = registerField(this);
}
if (shouldUpdate === true) {
this.reRender();
}
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
this.cancelRegister();
this.triggerMetaEvent(true);
this.mounted = false;
}
}, {
key: "reRender",
value: function reRender() {
if (!this.mounted) return;
this.forceUpdate();
}
}, {
key: "render",
value: function render2() {
var resetCount = this.state.resetCount;
var children = this.props.children;
var _this$getOnlyChild = this.getOnlyChild(children), child = _this$getOnlyChild.child, isFunction = _this$getOnlyChild.isFunction;
var returnChildNode;
if (isFunction) {
returnChildNode = child;
} else if (/* @__PURE__ */ React.isValidElement(child)) {
returnChildNode = /* @__PURE__ */ React.cloneElement(child, this.getControlled(child.props));
} else {
warningOnce(!child, "`children` of Field is not validate ReactElement.");
returnChildNode = child;
}
return /* @__PURE__ */ React.createElement(React.Fragment, {
key: resetCount
}, returnChildNode);
}
}]);
return Field2;
}(React.Component);
_defineProperty(Field, "contextType", Context);
_defineProperty(Field, "defaultProps", {
trigger: "onChange",
valuePropName: "value"
});
function WrapperField(_ref6) {
var name = _ref6.name, restProps = _objectWithoutProperties(_ref6, _excluded$2);
var fieldContext = React.useContext(Context);
var listContext = React.useContext(ListContext);
var namePath = name !== void 0 ? getNamePath(name) : void 0;
var key = "keep";
if (!restProps.isListField) {
key = "_".concat((namePath || []).join("_"));
}
if (process.env.NODE_ENV !== "production" && restProps.preserve === false && restProps.isListField && namePath.length <= 1) {
warningOnce(false, "`preserve` should not apply on Form.List fields.");
}
return /* @__PURE__ */ React.createElement(Field, _extends({
key,
name: namePath,
isListField: !!listContext
}, restProps, {
fieldContext
}));
}
function List(_ref) {
var name = _ref.name, initialValue = _ref.initialValue, children = _ref.children, rules2 = _ref.rules, validateTrigger = _ref.validateTrigger, isListField = _ref.isListField;
var context = React.useContext(Context);
var wrapperListContext = React.useContext(ListContext);
var keyRef = React.useRef({
keys: [],
id: 0
});
var keyManager = keyRef.current;
var prefixName = React.useMemo(function() {
var parentPrefixName = getNamePath(context.prefixName) || [];
return [].concat(_toConsumableArray(parentPrefixName), _toConsumableArray(getNamePath(name)));
}, [context.prefixName, name]);
var fieldContext = React.useMemo(function() {
return _objectSpread2(_objectSpread2({}, context), {}, {
prefixName
});
}, [context, prefixName]);
var listContext = React.useMemo(function() {
return {
getKey: function getKey(namePath) {
var len = prefixName.length;
var pathName = namePath[len];
return [keyManager.keys[pathName], namePath.slice(len + 1)];
}
};
}, [prefixName]);
if (typeof children !== "function") {
warningOnce(false, "Form.List only accepts function as children.");
return null;
}
var shouldUpdate = function shouldUpdate2(prevValue, nextValue, _ref2) {
var source = _ref2.source;
if (source === "internal") {
return false;
}
return prevValue !== nextValue;
};
return /* @__PURE__ */ React.createElement(ListContext.Provider, {
value: listContext
}, /* @__PURE__ */ React.createElement(Context.Provider, {
value: fieldContext
}, /* @__PURE__ */ React.createElement(WrapperField, {
name: [],
shouldUpdate,
rules: rules2,
validateTrigger,
initialValue,
isList: true,
isListField: isListField !== null && isListField !== void 0 ? isListField : !!wrapperListContext
}, function(_ref3, meta) {
var _ref3$value = _ref3.value, value = _ref3$value === void 0 ? [] : _ref3$value, onChange = _ref3.onChange;
var getFieldValue = context.getFieldValue;
var getNewValue = function getNewValue2() {
var values = getFieldValue(prefixName || []);
return values || [];
};
var operations = {
add: function add(defaultValue, index2) {
var newValue = getNewValue();
if (index2 >= 0 && index2 <= newValue.length) {
keyManager.keys = [].concat(_toConsumableArray(keyManager.keys.slice(0, index2)), [keyManager.id], _toConsumableArray(keyManager.keys.slice(index2)));
onChange([].concat(_toConsumableArray(newValue.slice(0, index2)), [defaultValue], _toConsumableArray(newValue.slice(index2))));
} else {
if (process.env.NODE_ENV !== "production" && (index2 < 0 || index2 > newValue.length)) {
warningOnce(false, "The second parameter of the add function should be a valid positive number.");
}
keyManager.keys = [].concat(_toConsumableArray(keyManager.keys), [keyManager.id]);
onChange([].concat(_toConsumableArray(newValue), [defaultValue]));
}
keyManager.id += 1;
},
remove: function remove(index2) {
var newValue = getNewValue();
var indexSet = new Set(Array.isArray(index2) ? index2 : [index2]);
if (indexSet.size <= 0) {
return;
}
keyManager.keys = keyManager.keys.filter(function(_, keysIndex) {
return !indexSet.has(keysIndex);
});
onChange(newValue.filter(function(_, valueIndex) {
return !indexSet.has(valueIndex);
}));
},
move: function move$1(from2, to) {
if (from2 === to) {
return;
}
var newValue = getNewValue();
if (from2 < 0 || from2 >= newValue.length || to < 0 || to >= newValue.length) {
return;
}
keyManager.keys = move(keyManager.keys, from2, to);
onChange(move(newValue, from2, to));
}
};
var listValue = value || [];
if (!Array.isArray(listValue)) {
listValue = [];
if (process.env.NODE_ENV !== "production") {
warningOnce(false, "Current value of '".concat(prefixName.join(" > "), "' is not an array type."));
}
}
return children(listValue.map(function(__, index2) {
var key = keyManager.keys[index2];
if (key === void 0) {
keyManager.keys[index2] = keyManager.id;
key = keyManager.keys[index2];
keyManager.id += 1;
}
return {
name: index2,
key,
isListField: true
};
}), operations, meta);
})));
}
function allPromiseFinish(promiseList) {
var hasError = false;
var count = promiseList.length;
var results = [];
if (!promiseList.length) {
return Promise.resolve([]);
}
return new Promise(function(resolve, reject) {
promiseList.forEach(function(promise, index2) {
promise.catch(function(e) {
hasError = true;
return e;
}).then(function(result) {
count -= 1;
results[index2] = result;
if (count > 0) {
return;
}
if (hasError) {
reject(results);
}
resolve(results);
});
});
});
}
var SPLIT$1 = "__@field_split__";
function normalize(namePath) {
return namePath.map(function(cell) {
return "".concat(_typeof(cell), ":").concat(cell);
}).join(SPLIT$1);
}
var NameMap = /* @__PURE__ */ function() {
function NameMap2() {
_classCallCheck(this, NameMap2);
_defineProperty(this, "kvs", /* @__PURE__ */ new Map());
}
_createClass(NameMap2, [{
key: "set",
value: function set2(key, value) {
this.kvs.set(normalize(key), value);
}
}, {
key: "get",
value: function get2(key) {
return this.kvs.get(normalize(key));
}
}, {
key: "update",
value: function update(key, updater) {
var origin = this.get(key);
var next2 = updater(origin);
if (!next2) {
this.delete(key);
} else {
this.set(key, next2);
}
}
}, {
key: "delete",
value: function _delete(key) {
this.kvs.delete(normalize(key));
}
// Since we only use this in test, let simply realize this
}, {
key: "map",
value: function map(callback) {
return _toConsumableArray(this.kvs.entries()).map(function(_ref) {
var _ref2 = _slicedToArray(_ref, 2), key = _ref2[0], value = _ref2[1];
var cells = key.split(SPLIT$1);
return callback({
key: cells.map(function(cell) {
var _cell$match = cell.match(/^([^:]*):(.*)$/), _cell$match2 = _slicedToArray(_cell$match, 3), type4 = _cell$match2[1], unit2 = _cell$match2[2];
return type4 === "number" ? Number(unit2) : unit2;
}),
value
});
});
}
}, {
key: "toJSON",
value: function toJSON() {
var json = {};
this.map(function(_ref3) {
var key = _ref3.key, value = _ref3.value;
json[key.join(".")] = value;
return null;
});
return json;
}
}]);
return NameMap2;
}();
var _excluded$1 = ["name"];
var FormStore = /* @__PURE__ */ _createClass(function FormStore2(forceRootUpdate) {
var _this = this;
_classCallCheck(this, FormStore2);
_defineProperty(this, "formHooked", false);
_defineProperty(this, "forceRootUpdate", void 0);
_defineProperty(this, "subscribable", true);
_defineProperty(this, "store", {});
_defineProperty(this, "fieldEntities", []);
_defineProperty(this, "initialValues", {});
_defineProperty(this, "callbacks", {});
_defineProperty(this, "validateMessages", null);
_defineProperty(this, "preserve", null);
_defineProperty(this, "lastValidatePromise", null);
_defineProperty(this, "getForm", function() {
return {
getFieldValue: _this.getFieldValue,
getFieldsValue: _this.getFieldsValue,
getFieldError: _this.getFieldError,
getFieldWarning: _this.getFieldWarning,
getFieldsError: _this.getFieldsError,
isFieldsTouched: _this.isFieldsTouched,
isFieldTouched: _this.isFieldTouched,
isFieldValidating: _this.isFieldValidating,
isFieldsValidating: _this.isFieldsValidating,
resetFields: _this.resetFields,
setFields: _this.setFields,
setFieldValue: _this.setFieldValue,
setFieldsValue: _this.setFieldsValue,
validateFields: _this.validateFields,
submit: _this.submit,
_init: true,
getInternalHooks: _this.getInternalHooks
};
});
_defineProperty(this, "getInternalHooks", function(key) {
if (key === HOOK_MARK) {
_this.formHooked = true;
return {
dispatch: _this.dispatch,
initEntityValue: _this.initEntityValue,
registerField: _this.registerField,
useSubscribe: _this.useSubscribe,
setInitialValues: _this.setInitialValues,
destroyForm: _this.destroyForm,
setCallbacks: _this.setCallbacks,
setValidateMessages: _this.setValidateMessages,
getFields: _this.getFields,
setPreserve: _this.setPreserve,
getInitialValue: _this.getInitialValue,
registerWatch: _this.registerWatch
};
}
warningOnce(false, "`getInternalHooks` is internal usage. Should not call directly.");
return null;
});
_defineProperty(this, "useSubscribe", function(subscribable) {
_this.subscribable = subscribable;
});
_defineProperty(this, "prevWithoutPreserves", null);
_defineProperty(this, "setInitialValues", function(initialValues, init) {
_this.initialValues = initialValues || {};
if (init) {
var _this$prevWithoutPres;
var nextStore = merge$1(initialValues, _this.store);
(_this$prevWithoutPres = _this.prevWithoutPreserves) === null || _this$prevWithoutPres === void 0 || _this$prevWithoutPres.map(function(_ref) {
var namePath = _ref.key;
nextStore = set(nextStore, namePath, get(initialValues, namePath));
});
_this.prevWithoutPreserves = null;
_this.updateStore(nextStore);
}
});
_defineProperty(this, "destroyForm", function(clearOnDestroy) {
if (clearOnDestroy) {
_this.updateStore({});
} else {
var prevWithoutPreserves = new NameMap();
_this.getFieldEntities(true).forEach(function(entity) {
if (!_this.isMergedPreserve(entity.isPreserve())) {
prevWithoutPreserves.set(entity.getNamePath(), true);
}
});
_this.prevWithoutPreserves = prevWithoutPreserves;
}
});
_defineProperty(this, "getInitialValue", function(namePath) {
var initValue = get(_this.initialValues, namePath);
return namePath.length ? merge$1(initValue) : initValue;
});
_defineProperty(this, "setCallbacks", function(callbacks) {
_this.callbacks = callbacks;
});
_defineProperty(this, "setValidateMessages", function(validateMessages) {
_this.validateMessages = validateMessages;
});
_defineProperty(this, "setPreserve", function(preserve2) {
_this.preserve = preserve2;
});
_defineProperty(this, "watchList", []);
_defineProperty(this, "registerWatch", function(callback) {
_this.watchList.push(callback);
return function() {
_this.watchList = _this.watchList.filter(function(fn) {
return fn !== callback;
});
};
});
_defineProperty(this, "notifyWatch", function() {
var namePath = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
if (_this.watchList.length) {
var values = _this.getFieldsValue();
var allValues = _this.getFieldsValue(true);
_this.watchList.forEach(function(callback) {
callback(values, allValues, namePath);
});
}
});
_defineProperty(this, "timeoutId", null);
_defineProperty(this, "warningUnhooked", function() {
if (process.env.NODE_ENV !== "production" && !_this.timeoutId && typeof window !== "undefined") {
_this.timeoutId = setTimeout(function() {
_this.timeoutId = null;
if (!_this.formHooked) {
warningOnce(false, "Instance created by `useForm` is not connected to any Form element. Forget to pass `form` prop?");
}
});
}
});
_defineProperty(this, "updateStore", function(nextStore) {
_this.store = nextStore;
});
_defineProperty(this, "getFieldEntities", function() {
var pure = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
if (!pure) {
return _this.fieldEntities;
}
return _this.fieldEntities.filter(function(field) {
return field.getNamePath().length;
});
});
_defineProperty(this, "getFieldsMap", function() {
var pure = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
var cache = new NameMap();
_this.getFieldEntities(pure).forEach(function(field) {
var namePath = field.getNamePath();
cache.set(namePath, field);
});
return cache;
});
_defineProperty(this, "getFieldEntitiesForNamePathList", function(nameList) {
if (!nameList) {
return _this.getFieldEntities(true);
}
var cache = _this.getFieldsMap(true);
return nameList.map(function(name) {
var namePath = getNamePath(name);
return cache.get(namePath) || {
INVALIDATE_NAME_PATH: getNamePath(name)
};
});
});
_defineProperty(this, "getFieldsValue", function(nameList, filterFunc) {
_this.warningUnhooked();
var mergedNameList;
var mergedFilterFunc;
var mergedStrict;
if (nameList === true || Array.isArray(nameList)) {
mergedNameList = nameList;
mergedFilterFunc = filterFunc;
} else if (nameList && _typeof(nameList) === "object") {
mergedStrict = nameList.strict;
mergedFilterFunc = nameList.filter;
}
if (mergedNameList === true && !mergedFilterFunc) {
return _this.store;
}
var fieldEntities = _this.getFieldEntitiesForNamePathList(Array.isArray(mergedNameList) ? mergedNameList : null);
var filteredNameList = [];
fieldEntities.forEach(function(entity) {
var _isListField, _ref3;
var namePath = "INVALIDATE_NAME_PATH" in entity ? entity.INVALIDATE_NAME_PATH : entity.getNamePath();
if (mergedStrict) {
var _isList, _ref2;
if ((_isList = (_ref2 = entity).isList) !== null && _isList !== void 0 && _isList.call(_ref2)) {
return;
}
} else if (!mergedNameList && (_isListField = (_ref3 = entity).isListField) !== null && _isListField !== void 0 && _isListField.call(_ref3)) {
return;
}
if (!mergedFilterFunc) {
filteredNameList.push(namePath);
} else {
var meta = "getMeta" in entity ? entity.getMeta() : null;
if (mergedFilterFunc(meta)) {
filteredNameList.push(namePath);
}
}
});
return cloneByNamePathList(_this.store, filteredNameList.map(getNamePath));
});
_defineProperty(this, "getFieldValue", function(name) {
_this.warningUnhooked();
var namePath = getNamePath(name);
return get(_this.store, namePath);
});
_defineProperty(this, "getFieldsError", function(nameList) {
_this.warningUnhooked();
var fieldEntities = _this.getFieldEntitiesForNamePathList(nameList);
return fieldEntities.map(function(entity, index2) {
if (entity && !("INVALIDATE_NAME_PATH" in entity)) {
return {
name: entity.getNamePath(),
errors: entity.getErrors(),
warnings: entity.getWarnings()
};
}
return {
name: getNamePath(nameList[index2]),
errors: [],
warnings: []
};
});
});
_defineProperty(this, "getFieldError", function(name) {
_this.warningUnhooked();
var namePath = getNamePath(name);
var fieldError = _this.getFieldsError([namePath])[0];
return fieldError.errors;
});
_defineProperty(this, "getFieldWarning", function(name) {
_this.warningUnhooked();
var namePath = getNamePath(name);
var fieldError = _this.getFieldsError([namePath])[0];
return fieldError.warnings;
});
_defineProperty(this, "isFieldsTouched", function() {
_this.warningUnhooked();
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var arg0 = args[0], arg1 = args[1];
var namePathList;
var isAllFieldsTouched = false;
if (args.length === 0) {
namePathList = null;
} else if (args.length === 1) {
if (Array.isArray(arg0)) {
namePathList = arg0.map(getNamePath);
isAllFieldsTouched = false;
} else {
namePathList = null;
isAllFieldsTouched = arg0;
}
} else {
namePathList = arg0.map(getNamePath);
isAllFieldsTouched = arg1;
}
var fieldEntities = _this.getFieldEntities(true);
var isFieldTouched = function isFieldTouched2(field) {
return field.isFieldTouched();
};
if (!namePathList) {
return isAllFieldsTouched ? fieldEntities.every(function(entity) {
return isFieldTouched(entity) || entity.isList();
}) : fieldEntities.some(isFieldTouched);
}
var map = new NameMap();
namePathList.forEach(function(shortNamePath) {
map.set(shortNamePath, []);
});
fieldEntities.forEach(function(field) {
var fieldNamePath = field.getNamePath();
namePathList.forEach(function(shortNamePath) {
if (shortNamePath.every(function(nameUnit, i) {
return fieldNamePath[i] === nameUnit;
})) {
map.update(shortNamePath, function(list) {
return [].concat(_toConsumableArray(list), [field]);
});
}
});
});
var isNamePathListTouched = function isNamePathListTouched2(entities) {
return entities.some(isFieldTouched);
};
var namePathListEntities = map.map(function(_ref4) {
var value = _ref4.value;
return value;
});
return isAllFieldsTouched ? namePathListEntities.every(isNamePathListTouched) : namePathListEntities.some(isNamePathListTouched);
});
_defineProperty(this, "isFieldTouched", function(name) {
_this.warningUnhooked();
return _this.isFieldsTouched([name]);
});
_defineProperty(this, "isFieldsValidating", function(nameList) {
_this.warningUnhooked();
var fieldEntities = _this.getFieldEntities();
if (!nameList) {
return fieldEntities.some(function(testField) {
return testField.isFieldValidating();
});
}
var namePathList = nameList.map(getNamePath);
return fieldEntities.some(function(testField) {
var fieldNamePath = testField.getNamePath();
return containsNamePath(namePathList, fieldNamePath) && testField.isFieldValidating();
});
});
_defineProperty(this, "isFieldValidating", function(name) {
_this.warningUnhooked();
return _this.isFieldsValidating([name]);
});
_defineProperty(this, "resetWithFieldInitialValue", function() {
var info = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
var cache = new NameMap();
var fieldEntities = _this.getFieldEntities(true);
fieldEntities.forEach(function(field) {
var initialValue = field.props.initialValue;
var namePath = field.getNamePath();
if (initialValue !== void 0) {
var records = cache.get(namePath) || /* @__PURE__ */ new Set();
records.add({
entity: field,
value: initialValue
});
cache.set(namePath, records);
}
});
var resetWithFields = function resetWithFields2(entities) {
entities.forEach(function(field) {
var initialValue = field.props.initialValue;
if (initialValue !== void 0) {
var namePath = field.getNamePath();
var formInitialValue = _this.getInitialValue(namePath);
if (formInitialValue !== void 0) {
warningOnce(false, "Form already set 'initialValues' with path '".concat(namePath.join("."), "'. Field can not overwrite it."));
} else {
var records = cache.get(namePath);
if (records && records.size > 1) {
warningOnce(false, "Multiple Field with path '".concat(namePath.join("."), "' set 'initialValue'. Can not decide which one to pick."));
} else if (records) {
var originValue = _this.getFieldValue(namePath);
var isListField = field.isListField();
if (!isListField && (!info.skipExist || originValue === void 0)) {
_this.updateStore(set(_this.store, namePath, _toConsumableArray(records)[0].value));
}
}
}
}
});
};
var requiredFieldEntities;
if (info.entities) {
requiredFieldEntities = info.entities;
} else if (info.namePathList) {
requiredFieldEntities = [];
info.namePathList.forEach(function(namePath) {
var records = cache.get(namePath);
if (records) {
var _requiredFieldEntitie;
(_requiredFieldEntitie = requiredFieldEntities).push.apply(_requiredFieldEntitie, _toConsumableArray(_toConsumableArray(records).map(function(r) {
return r.entity;
})));
}
});
} else {
requiredFieldEntities = fieldEntities;
}
resetWithFields(requiredFieldEntities);
});
_defineProperty(this, "resetFields", function(nameList) {
_this.warningUnhooked();
var prevStore = _this.store;
if (!nameList) {
_this.updateStore(merge$1(_this.initialValues));
_this.resetWithFieldInitialValue();
_this.notifyObservers(prevStore, null, {
type: "reset"
});
_this.notifyWatch();
return;
}
var namePathList = nameList.map(getNamePath);
namePathList.forEach(function(namePath) {
var initialValue = _this.getInitialValue(namePath);
_this.updateStore(set(_this.store, namePath, initialValue));
});
_this.resetWithFieldInitialValue({
namePathList
});
_this.notifyObservers(prevStore, namePathList, {
type: "reset"
});
_this.notifyWatch(namePathList);
});
_defineProperty(this, "setFields", function(fields) {
_this.warningUnhooked();
var prevStore = _this.store;
var namePathList = [];
fields.forEach(function(fieldData) {
var name = fieldData.name, data = _objectWithoutProperties(fieldData, _excluded$1);
var namePath = getNamePath(name);
namePathList.push(namePath);
if ("value" in data) {
_this.updateStore(set(_this.store, namePath, data.value));
}
_this.notifyObservers(prevStore, [namePath], {
type: "setField",
data: fieldData
});
});
_this.notifyWatch(namePathList);
});
_defineProperty(this, "getFields", function() {
var entities = _this.getFieldEntities(true);
var fields = entities.map(function(field) {
var namePath = field.getNamePath();
var meta = field.getMeta();
var fieldData = _objectSpread2(_objectSpread2({}, meta), {}, {
name: namePath,
value: _this.getFieldValue(namePath)
});
Object.defineProperty(fieldData, "originRCField", {
value: true
});
return fieldData;
});
return fields;
});
_defineProperty(this, "initEntityValue", function(entity) {
var initialValue = entity.props.initialValue;
if (initialValue !== void 0) {
var namePath = entity.getNamePath();
var prevValue = get(_this.store, namePath);
if (prevValue === void 0) {
_this.updateStore(set(_this.store, namePath, initialValue));
}
}
});
_defineProperty(this, "isMergedPreserve", function(fieldPreserve) {
var mergedPreserve = fieldPreserve !== void 0 ? fieldPreserve : _this.preserve;
return mergedPreserve !== null && mergedPreserve !== void 0 ? mergedPreserve : true;
});
_defineProperty(this, "registerField", function(entity) {
_this.fieldEntities.push(entity);
var namePath = entity.getNamePath();
_this.notifyWatch([namePath]);
if (entity.props.initialValue !== void 0) {
var prevStore = _this.store;
_this.resetWithFieldInitialValue({
entities: [entity],
skipExist: true
});
_this.notifyObservers(prevStore, [entity.getNamePath()], {
type: "valueUpdate",
source: "internal"
});
}
return function(isListField, preserve2) {
var subNamePath = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [];
_this.fieldEntities = _this.fieldEntities.filter(function(item) {
return item !== entity;
});
if (!_this.isMergedPreserve(preserve2) && (!isListField || subNamePath.length > 1)) {
var defaultValue = isListField ? void 0 : _this.getInitialValue(namePath);
if (namePath.length && _this.getFieldValue(namePath) !== defaultValue && _this.fieldEntities.every(function(field) {
return (
// Only reset when no namePath exist
!matchNamePath(field.getNamePath(), namePath)
);
})) {
var _prevStore = _this.store;
_this.updateStore(set(_prevStore, namePath, defaultValue, true));
_this.notifyObservers(_prevStore, [namePath], {
type: "remove"
});
_this.triggerDependenciesUpdate(_prevStore, namePath);
}
}
_this.notifyWatch([namePath]);
};
});
_defineProperty(this, "dispatch", function(action) {
switch (action.type) {
case "updateValue": {
var namePath = action.namePath, value = action.value;
_this.updateValue(namePath, value);
break;
}
case "validateField": {
var _namePath = action.namePath, triggerName = action.triggerName;
_this.validateFields([_namePath], {
triggerName
});
break;
}
}
});
_defineProperty(this, "notifyObservers", function(prevStore, namePathList, info) {
if (_this.subscribable) {
var mergedInfo = _objectSpread2(_objectSpread2({}, info), {}, {
store: _this.getFieldsValue(true)
});
_this.getFieldEntities().forEach(function(_ref5) {
var onStoreChange = _ref5.onStoreChange;
onStoreChange(prevStore, namePathList, mergedInfo);
});
} else {
_this.forceRootUpdate();
}
});
_defineProperty(this, "triggerDependenciesUpdate", function(prevStore, namePath) {
var childrenFields = _this.getDependencyChildrenFields(namePath);
if (childrenFields.length) {
_this.validateFields(childrenFields);
}
_this.notifyObservers(prevStore, childrenFields, {
type: "dependenciesUpdate",
relatedFields: [namePath].concat(_toConsumableArray(childrenFields))
});
return childrenFields;
});
_defineProperty(this, "updateValue", function(name, value) {
var namePath = getNamePath(name);
var prevStore = _this.store;
_this.updateStore(set(_this.store, namePath, value));
_this.notifyObservers(prevStore, [namePath], {
type: "valueUpdate",
source: "internal"
});
_this.notifyWatch([namePath]);
var childrenFields = _this.triggerDependenciesUpdate(prevStore, namePath);
var onValuesChange = _this.callbacks.onValuesChange;
if (onValuesChange) {
var changedValues = cloneByNamePathList(_this.store, [namePath]);
onValuesChange(changedValues, _this.getFieldsValue());
}
_this.triggerOnFieldsChange([namePath].concat(_toConsumableArray(childrenFields)));
});
_defineProperty(this, "setFieldsValue", function(store) {
_this.warningUnhooked();
var prevStore = _this.store;
if (store) {
var nextStore = merge$1(_this.store, store);
_this.updateStore(nextStore);
}
_this.notifyObservers(prevStore, null, {
type: "valueUpdate",
source: "external"
});
_this.notifyWatch();
});
_defineProperty(this, "setFieldValue", function(name, value) {
_this.setFields([{
name,
value
}]);
});
_defineProperty(this, "getDependencyChildrenFields", function(rootNamePath) {
var children = /* @__PURE__ */ new Set();
var childrenFields = [];
var dependencies2fields = new NameMap();
_this.getFieldEntities().forEach(function(field) {
var dependencies = field.props.dependencies;
(dependencies || []).forEach(function(dependency) {
var dependencyNamePath = getNamePath(dependency);
dependencies2fields.update(dependencyNamePath, function() {
var fields = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : /* @__PURE__ */ new Set();
fields.add(field);
return fields;
});
});
});
var fillChildren = function fillChildren2(namePath) {
var fields = dependencies2fields.get(namePath) || /* @__PURE__ */ new Set();
fields.forEach(function(field) {
if (!children.has(field)) {
children.add(field);
var fieldNamePath = field.getNamePath();
if (field.isFieldDirty() && fieldNamePath.length) {
childrenFields.push(fieldNamePath);
fillChildren2(fieldNamePath);
}
}
});
};
fillChildren(rootNamePath);
return childrenFields;
});
_defineProperty(this, "triggerOnFieldsChange", function(namePathList, filedErrors) {
var onFieldsChange = _this.callbacks.onFieldsChange;
if (onFieldsChange) {
var fields = _this.getFields();
if (filedErrors) {
var cache = new NameMap();
filedErrors.forEach(function(_ref6) {
var name = _ref6.name, errors = _ref6.errors;
cache.set(name, errors);
});
fields.forEach(function(field) {
field.errors = cache.get(field.name) || field.errors;
});
}
var changedFields = fields.filter(function(_ref7) {
var fieldName = _ref7.name;
return containsNamePath(namePathList, fieldName);
});
if (changedFields.length) {
onFieldsChange(changedFields, fields);
}
}
});
_defineProperty(this, "validateFields", function(arg1, arg2) {
_this.warningUnhooked();
var nameList;
var options;
if (Array.isArray(arg1) || typeof arg1 === "string" || typeof arg2 === "string") {
nameList = arg1;
options = arg2;
} else {
options = arg1;
}
var provideNameList = !!nameList;
var namePathList = provideNameList ? nameList.map(getNamePath) : [];
var promiseList = [];
var TMP_SPLIT = String(Date.now());
var validateNamePathList = /* @__PURE__ */ new Set();
var _ref8 = options || {}, recursive = _ref8.recursive, dirty = _ref8.dirty;
_this.getFieldEntities(true).forEach(function(field) {
if (!provideNameList) {
namePathList.push(field.getNamePath());
}
if (!field.props.rules || !field.props.rules.length) {
return;
}
if (dirty && !field.isFieldDirty()) {
return;
}
var fieldNamePath = field.getNamePath();
validateNamePathList.add(fieldNamePath.join(TMP_SPLIT));
if (!provideNameList || containsNamePath(namePathList, fieldNamePath, recursive)) {
var promise = field.validateRules(_objectSpread2({
validateMessages: _objectSpread2(_objectSpread2({}, defaultValidateMessages), _this.validateMessages)
}, options));
promiseList.push(promise.then(function() {
return {
name: fieldNamePath,
errors: [],
warnings: []
};
}).catch(function(ruleErrors) {
var _ruleErrors$forEach;
var mergedErrors = [];
var mergedWarnings = [];
(_ruleErrors$forEach = ruleErrors.forEach) === null || _ruleErrors$forEach === void 0 || _ruleErrors$forEach.call(ruleErrors, function(_ref9) {
var warningOnly = _ref9.rule.warningOnly, errors = _ref9.errors;
if (warningOnly) {
mergedWarnings.push.apply(mergedWarnings, _toConsumableArray(errors));
} else {
mergedErrors.push.apply(mergedErrors, _toConsumableArray(errors));
}
});
if (mergedErrors.length) {
return Promise.reject({
name: fieldNamePath,
errors: mergedErrors,
warnings: mergedWarnings
});
}
return {
name: fieldNamePath,
errors: mergedErrors,
warnings: mergedWarnings
};
}));
}
});
var summaryPromise = allPromiseFinish(promiseList);
_this.lastValidatePromise = summaryPromise;
summaryPromise.catch(function(results) {
return results;
}).then(function(results) {
var resultNamePathList = results.map(function(_ref10) {
var name = _ref10.name;
return name;
});
_this.notifyObservers(_this.store, resultNamePathList, {
type: "validateFinish"
});
_this.triggerOnFieldsChange(resultNamePathList, results);
});
var returnPromise = summaryPromise.then(function() {
if (_this.lastValidatePromise === summaryPromise) {
return Promise.resolve(_this.getFieldsValue(namePathList));
}
return Promise.reject([]);
}).catch(function(results) {
var errorList = results.filter(function(result) {
return result && result.errors.length;
});
return Promise.reject({
values: _this.getFieldsValue(namePathList),
errorFields: errorList,
outOfDate: _this.lastValidatePromise !== summaryPromise
});
});
returnPromise.catch(function(e) {
return e;
});
var triggerNamePathList = namePathList.filter(function(namePath) {
return validateNamePathList.has(namePath.join(TMP_SPLIT));
});
_this.triggerOnFieldsChange(triggerNamePathList);
return returnPromise;
});
_defineProperty(this, "submit", function() {
_this.warningUnhooked();
_this.validateFields().then(function(values) {
var onFinish = _this.callbacks.onFinish;
if (onFinish) {
try {
onFinish(values);
} catch (err) {
console.error(err);
}
}
}).catch(function(e) {
var onFinishFailed = _this.callbacks.onFinishFailed;
if (onFinishFailed) {
onFinishFailed(e);
}
});
});
this.forceRootUpdate = forceRootUpdate;
});
function useForm(form) {
var formRef = React.useRef();
var _React$useState = React.useState({}), _React$useState2 = _slicedToArray(_React$useState, 2), forceUpdate = _React$useState2[1];
if (!formRef.current) {
if (form) {
formRef.current = form;
} else {
var forceReRender = function forceReRender2() {
forceUpdate({});
};
var formStore = new FormStore(forceReRender);
formRef.current = formStore.getForm();
}
}
return [formRef.current];
}
var FormContext = /* @__PURE__ */ React.createContext({
triggerFormChange: function triggerFormChange() {
},
triggerFormFinish: function triggerFormFinish() {
},
registerForm: function registerForm() {
},
unregisterForm: function unregisterForm() {
}
});
var FormProvider = function FormProvider2(_ref) {
var validateMessages = _ref.validateMessages, onFormChange = _ref.onFormChange, onFormFinish = _ref.onFormFinish, children = _ref.children;
var formContext = React.useContext(FormContext);
var formsRef = React.useRef({});
return /* @__PURE__ */ React.createElement(FormContext.Provider, {
value: _objectSpread2(_objectSpread2({}, formContext), {}, {
validateMessages: _objectSpread2(_objectSpread2({}, formContext.validateMessages), validateMessages),
// =========================================================
// = Global Form Control =
// =========================================================
triggerFormChange: function triggerFormChange2(name, changedFields) {
if (onFormChange) {
onFormChange(name, {
changedFields,
forms: formsRef.current
});
}
formContext.triggerFormChange(name, changedFields);
},
triggerFormFinish: function triggerFormFinish2(name, values) {
if (onFormFinish) {
onFormFinish(name, {
values,
forms: formsRef.current
});
}
formContext.triggerFormFinish(name, values);
},
registerForm: function registerForm2(name, form) {
if (name) {
formsRef.current = _objectSpread2(_objectSpread2({}, formsRef.current), {}, _defineProperty({}, name, form));
}
formContext.registerForm(name, form);
},
unregisterForm: function unregisterForm2(name) {
var newForms = _objectSpread2({}, formsRef.current);
delete newForms[name];
formsRef.current = newForms;
formContext.unregisterForm(name);
}
})
}, children);
};
var _excluded = ["name", "initialValues", "fields", "form", "preserve", "children", "component", "validateMessages", "validateTrigger", "onValuesChange", "onFieldsChange", "onFinish", "onFinishFailed", "clearOnDestroy"];
var Form = function Form2(_ref, ref) {
var name = _ref.name, initialValues = _ref.initialValues, fields = _ref.fields, form = _ref.form, preserve2 = _ref.preserve, children = _ref.children, _ref$component = _ref.component, Component = _ref$component === void 0 ? "form" : _ref$component, validateMessages = _ref.validateMessages, _ref$validateTrigger = _ref.validateTrigger, validateTrigger = _ref$validateTrigger === void 0 ? "onChange" : _ref$validateTrigger, onValuesChange = _ref.onValuesChange, _onFieldsChange = _ref.onFieldsChange, _onFinish = _ref.onFinish, onFinishFailed = _ref.onFinishFailed, clearOnDestroy = _ref.clearOnDestroy, restProps = _objectWithoutProperties(_ref, _excluded);
var nativeElementRef = React.useRef(null);
var formContext = React.useContext(FormContext);
var _useForm = useForm(form), _useForm2 = _slicedToArray(_useForm, 1), formInstance = _useForm2[0];
var _getInternalHooks = formInstance.getInternalHooks(HOOK_MARK), useSubscribe = _getInternalHooks.useSubscribe, setInitialValues = _getInternalHooks.setInitialValues, setCallbacks = _getInternalHooks.setCallbacks, setValidateMessages = _getInternalHooks.setValidateMessages, setPreserve = _getInternalHooks.setPreserve, destroyForm = _getInternalHooks.destroyForm;
React.useImperativeHandle(ref, function() {
return _objectSpread2(_objectSpread2({}, formInstance), {}, {
nativeElement: nativeElementRef.current
});
});
React.useEffect(function() {
formContext.registerForm(name, formInstance);
return function() {
formContext.unregisterForm(name);
};
}, [formContext, formInstance, name]);
setValidateMessages(_objectSpread2(_objectSpread2({}, formContext.validateMessages), validateMessages));
setCallbacks({
onValuesChange,
onFieldsChange: function onFieldsChange(changedFields) {
formContext.triggerFormChange(name, changedFields);
if (_onFieldsChange) {
for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
rest[_key - 1] = arguments[_key];
}
_onFieldsChange.apply(void 0, [changedFields].concat(rest));
}
},
onFinish: function onFinish(values) {
formContext.triggerFormFinish(name, values);
if (_onFinish) {
_onFinish(values);
}
},
onFinishFailed
});
setPreserve(preserve2);
var mountRef = React.useRef(null);
setInitialValues(initialValues, !mountRef.current);
if (!mountRef.current) {
mountRef.current = true;
}
React.useEffect(
function() {
return function() {
return destroyForm(clearOnDestroy);
};
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[]
);
var childrenNode;
var childrenRenderProps = typeof children === "function";
if (childrenRenderProps) {
var _values = formInstance.getFieldsValue(true);
childrenNode = children(_values, formInstance);
} else {
childrenNode = children;
}
useSubscribe(!childrenRenderProps);
var prevFieldsRef = React.useRef();
React.useEffect(function() {
if (!isSimilar(prevFieldsRef.current || [], fields || [])) {
formInstance.setFields(fields || []);
}
prevFieldsRef.current = fields;
}, [fields, formInstance]);
var formContextValue = React.useMemo(function() {
return _objectSpread2(_objectSpread2({}, formInstance), {}, {
validateTrigger
});
}, [formInstance, validateTrigger]);
var wrapperNode = /* @__PURE__ */ React.createElement(ListContext.Provider, {
value: null
}, /* @__PURE__ */ React.createElement(Context.Provider, {
value: formContextValue
}, childrenNode));
if (Component === false) {
return wrapperNode;
}
return /* @__PURE__ */ React.createElement(Component, _extends({}, restProps, {
ref: nativeElementRef,
onSubmit: function onSubmit(event) {
event.preventDefault();
event.stopPropagation();
formInstance.submit();
},
onReset: function onReset(event) {
var _restProps$onReset;
event.preventDefault();
formInstance.resetFields();
(_restProps$onReset = restProps.onReset) === null || _restProps$onReset === void 0 || _restProps$onReset.call(restProps, event);
}
}), wrapperNode);
};
function stringify$1(value) {
try {
return JSON.stringify(value);
} catch (err) {
return Math.random();
}
}
var useWatchWarning = process.env.NODE_ENV !== "production" ? function(namePath) {
var fullyStr = namePath.join("__RC_FIELD_FORM_SPLIT__");
var nameStrRef = useRef(fullyStr);
warningOnce(nameStrRef.current === fullyStr, "`useWatch` is not support dynamic `namePath`. Please provide static instead.");
} : function() {
};
function useWatch() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var dependencies = args[0], _args$ = args[1], _form = _args$ === void 0 ? {} : _args$;
var options = isFormInstance(_form) ? {
form: _form
} : _form;
var form = options.form;
var _useState = useState(), _useState2 = _slicedToArray(_useState, 2), value = _useState2[0], setValue = _useState2[1];
var valueStr = useMemo$1(function() {
return stringify$1(value);
}, [value]);
var valueStrRef = useRef(valueStr);
valueStrRef.current = valueStr;
var fieldContext = useContext(Context);
var formInstance = form || fieldContext;
var isValidForm = formInstance && formInstance._init;
if (process.env.NODE_ENV !== "production") {
warningOnce(args.length === 2 ? form ? isValidForm : true : isValidForm, "useWatch requires a form instance since it can not auto detect from context.");
}
var namePath = getNamePath(dependencies);
var namePathRef = useRef(namePath);
namePathRef.current = namePath;
useWatchWarning(namePath);
useEffect(
function() {
if (!isValidForm) {
return;
}
var getFieldsValue = formInstance.getFieldsValue, getInternalHooks2 = formInstance.getInternalHooks;
var _getInternalHooks = getInternalHooks2(HOOK_MARK), registerWatch = _getInternalHooks.registerWatch;
var getWatchValue = function getWatchValue2(values, allValues) {
var watchValue = options.preserve ? allValues : values;
return typeof dependencies === "function" ? dependencies(watchValue) : get(watchValue, namePathRef.current);
};
var cancelRegister = registerWatch(function(values, allValues) {
var newValue = getWatchValue(values, allValues);
var nextValueStr = stringify$1(newValue);
if (valueStrRef.current !== nextValueStr) {
valueStrRef.current = nextValueStr;
setValue(newValue);
}
});
var initialValue = getWatchValue(getFieldsValue(), getFieldsValue(true));
if (value !== initialValue) {
setValue(initialValue);
}
return cancelRegister;
},
// We do not need re-register since namePath content is the same
// eslint-disable-next-line react-hooks/exhaustive-deps
[isValidForm]
);
return value;
}
var InternalForm = /* @__PURE__ */ React.forwardRef(Form);
var RefForm = InternalForm;
RefForm.FormProvider = FormProvider;
RefForm.Field = WrapperField;
RefForm.List = List;
RefForm.useForm = useForm;
RefForm.useWatch = useWatch;
const FormItemInputContext = /* @__PURE__ */ React.createContext({});
if (process.env.NODE_ENV !== "production") {
FormItemInputContext.displayName = "FormItemInputContext";
}
const NoFormStyle = (_ref) => {
let {
children,
status,
override
} = _ref;
const formItemInputContext = useContext(FormItemInputContext);
const newFormItemInputContext = useMemo$1(() => {
const newContext = Object.assign({}, formItemInputContext);
if (override) {
delete newContext.isFormItemInput;
}
if (status) {
delete newContext.status;
delete newContext.hasFeedback;
delete newContext.feedbackIcon;
}
return newContext;
}, [status, override, formItemInputContext]);
return /* @__PURE__ */ React.createElement(FormItemInputContext.Provider, {
value: newFormItemInputContext
}, children);
};
const VariantContext = /* @__PURE__ */ createContext(void 0);
function murmur2(str) {
var h = 0;
var k, i = 0, len = str.length;
for (; len >= 4; ++i, len -= 4) {
k = str.charCodeAt(i) & 255 | (str.charCodeAt(++i) & 255) << 8 | (str.charCodeAt(++i) & 255) << 16 | (str.charCodeAt(++i) & 255) << 24;
k = /* Math.imul(k, m): */
(k & 65535) * 1540483477 + ((k >>> 16) * 59797 << 16);
k ^= /* k >>> r: */
k >>> 24;
h = /* Math.imul(k, m): */
(k & 65535) * 1540483477 + ((k >>> 16) * 59797 << 16) ^ /* Math.imul(h, m): */
(h & 65535) * 1540483477 + ((h >>> 16) * 59797 << 16);
}
switch (len) {
case 3:
h ^= (str.charCodeAt(i + 2) & 255) << 16;
case 2:
h ^= (str.charCodeAt(i + 1) & 255) << 8;
case 1:
h ^= str.charCodeAt(i) & 255;
h = /* Math.imul(h, m): */
(h & 65535) * 1540483477 + ((h >>> 16) * 59797 << 16);
}
h ^= h >>> 13;
h = /* Math.imul(h, m): */
(h & 65535) * 1540483477 + ((h >>> 16) * 59797 << 16);
return ((h ^ h >>> 15) >>> 0).toString(36);
}
var SPLIT = "%";
function pathKey(keys2) {
return keys2.join(SPLIT);
}
var Entity = /* @__PURE__ */ function() {
function Entity2(instanceId) {
_classCallCheck(this, Entity2);
_defineProperty(this, "instanceId", void 0);
_defineProperty(this, "cache", /* @__PURE__ */ new Map());
this.instanceId = instanceId;
}
_createClass(Entity2, [{
key: "get",
value: function get2(keys2) {
return this.opGet(pathKey(keys2));
}
/** A fast get cache with `get` concat. */
}, {
key: "opGet",
value: function opGet(keyPathStr) {
return this.cache.get(keyPathStr) || null;
}
}, {
key: "update",
value: function update(keys2, valueFn) {
return this.opUpdate(pathKey(keys2), valueFn);
}
/** A fast get cache with `get` concat. */
}, {
key: "opUpdate",
value: function opUpdate(keyPathStr, valueFn) {
var prevValue = this.cache.get(keyPathStr);
var nextValue = valueFn(prevValue);
if (nextValue === null) {
this.cache.delete(keyPathStr);
} else {
this.cache.set(keyPathStr, nextValue);
}
}
}]);
return Entity2;
}();
var ATTR_TOKEN = "data-token-hash";
var ATTR_MARK = "data-css-hash";
var ATTR_CACHE_PATH = "data-cache-path";
var CSS_IN_JS_INSTANCE = "__cssinjs_instance__";
function createCache() {
var cssinjsInstanceId = Math.random().toString(12).slice(2);
if (typeof document !== "undefined" && document.head && document.body) {
var styles = document.body.querySelectorAll("style[".concat(ATTR_MARK, "]")) || [];
var firstChild = document.head.firstChild;
Array.from(styles).forEach(function(style2) {
style2[CSS_IN_JS_INSTANCE] = style2[CSS_IN_JS_INSTANCE] || cssinjsInstanceId;
if (style2[CSS_IN_JS_INSTANCE] === cssinjsInstanceId) {
document.head.insertBefore(style2, firstChild);
}
});
var styleHash = {};
Array.from(document.querySelectorAll("style[".concat(ATTR_MARK, "]"))).forEach(function(style2) {
var hash = style2.getAttribute(ATTR_MARK);
if (styleHash[hash]) {
if (style2[CSS_IN_JS_INSTANCE] === cssinjsInstanceId) {
var _style$parentNode;
(_style$parentNode = style2.parentNode) === null || _style$parentNode === void 0 || _style$parentNode.removeChild(style2);
}
} else {
styleHash[hash] = true;
}
});
}
return new Entity(cssinjsInstanceId);
}
var StyleContext = /* @__PURE__ */ React.createContext({
hashPriority: "low",
cache: createCache(),
defaultCache: true
});
var AbstractCalculator = /* @__PURE__ */ _createClass(function AbstractCalculator2() {
_classCallCheck(this, AbstractCalculator2);
});
var CALC_UNIT = "CALC_UNIT";
var regexp3 = new RegExp(CALC_UNIT, "g");
function unit$1(value) {
if (typeof value === "number") {
return "".concat(value).concat(CALC_UNIT);
}
return value;
}
var CSSCalculator = /* @__PURE__ */ function(_AbstractCalculator) {
_inherits(CSSCalculator2, _AbstractCalculator);
var _super = _createSuper(CSSCalculator2);
function CSSCalculator2(num, unitlessCssVar) {
var _this;
_classCallCheck(this, CSSCalculator2);
_this = _super.call(this);
_defineProperty(_assertThisInitialized(_this), "result", "");
_defineProperty(_assertThisInitialized(_this), "unitlessCssVar", void 0);
_defineProperty(_assertThisInitialized(_this), "lowPriority", void 0);
var numType = _typeof(num);
_this.unitlessCssVar = unitlessCssVar;
if (num instanceof CSSCalculator2) {
_this.result = "(".concat(num.result, ")");
} else if (numType === "number") {
_this.result = unit$1(num);
} else if (numType === "string") {
_this.result = num;
}
return _this;
}
_createClass(CSSCalculator2, [{
key: "add",
value: function add(num) {
if (num instanceof CSSCalculator2) {
this.result = "".concat(this.result, " + ").concat(num.getResult());
} else if (typeof num === "number" || typeof num === "string") {
this.result = "".concat(this.result, " + ").concat(unit$1(num));
}
this.lowPriority = true;
return this;
}
}, {
key: "sub",
value: function sub(num) {
if (num instanceof CSSCalculator2) {
this.result = "".concat(this.result, " - ").concat(num.getResult());
} else if (typeof num === "number" || typeof num === "string") {
this.result = "".concat(this.result, " - ").concat(unit$1(num));
}
this.lowPriority = true;
return this;
}
}, {
key: "mul",
value: function mul(num) {
if (this.lowPriority) {
this.result = "(".concat(this.result, ")");
}
if (num instanceof CSSCalculator2) {
this.result = "".concat(this.result, " * ").concat(num.getResult(true));
} else if (typeof num === "number" || typeof num === "string") {
this.result = "".concat(this.result, " * ").concat(num);
}
this.lowPriority = false;
return this;
}
}, {
key: "div",
value: function div(num) {
if (this.lowPriority) {
this.result = "(".concat(this.result, ")");
}
if (num instanceof CSSCalculator2) {
this.result = "".concat(this.result, " / ").concat(num.getResult(true));
} else if (typeof num === "number" || typeof num === "string") {
this.result = "".concat(this.result, " / ").concat(num);
}
this.lowPriority = false;
return this;
}
}, {
key: "getResult",
value: function getResult(force) {
return this.lowPriority || force ? "(".concat(this.result, ")") : this.result;
}
}, {
key: "equal",
value: function equal(options) {
var _this2 = this;
var _ref = options || {}, cssUnit = _ref.unit;
var mergedUnit = true;
if (typeof cssUnit === "boolean") {
mergedUnit = cssUnit;
} else if (Array.from(this.unitlessCssVar).some(function(cssVar) {
return _this2.result.includes(cssVar);
})) {
mergedUnit = false;
}
this.result = this.result.replace(regexp3, mergedUnit ? "px" : "");
if (typeof this.lowPriority !== "undefined") {
return "calc(".concat(this.result, ")");
}
return this.result;
}
}]);
return CSSCalculator2;
}(AbstractCalculator);
var NumCalculator = /* @__PURE__ */ function(_AbstractCalculator) {
_inherits(NumCalculator2, _AbstractCalculator);
var _super = _createSuper(NumCalculator2);
function NumCalculator2(num) {
var _this;
_classCallCheck(this, NumCalculator2);
_this = _super.call(this);
_defineProperty(_assertThisInitialized(_this), "result", 0);
if (num instanceof NumCalculator2) {
_this.result = num.result;
} else if (typeof num === "number") {
_this.result = num;
}
return _this;
}
_createClass(NumCalculator2, [{
key: "add",
value: function add(num) {
if (num instanceof NumCalculator2) {
this.result += num.result;
} else if (typeof num === "number") {
this.result += num;
}
return this;
}
}, {
key: "sub",
value: function sub(num) {
if (num instanceof NumCalculator2) {
this.result -= num.result;
} else if (typeof num === "number") {
this.result -= num;
}
return this;
}
}, {
key: "mul",
value: function mul(num) {
if (num instanceof NumCalculator2) {
this.result *= num.result;
} else if (typeof num === "number") {
this.result *= num;
}
return this;
}
}, {
key: "div",
value: function div(num) {
if (num instanceof NumCalculator2) {
this.result /= num.result;
} else if (typeof num === "number") {
this.result /= num;
}
return this;
}
}, {
key: "equal",
value: function equal() {
return this.result;
}
}]);
return NumCalculator2;
}(AbstractCalculator);
var genCalc = function genCalc2(type4, unitlessCssVar) {
var Calculator = type4 === "css" ? CSSCalculator : NumCalculator;
return function(num) {
return new Calculator(num, unitlessCssVar);
};
};
function sameDerivativeOption(left, right) {
if (left.length !== right.length) {
return false;
}
for (var i = 0; i < left.length; i++) {
if (left[i] !== right[i]) {
return false;
}
}
return true;
}
var ThemeCache = /* @__PURE__ */ function() {
function ThemeCache2() {
_classCallCheck(this, ThemeCache2);
_defineProperty(this, "cache", void 0);
_defineProperty(this, "keys", void 0);
_defineProperty(this, "cacheCallTimes", void 0);
this.cache = /* @__PURE__ */ new Map();
this.keys = [];
this.cacheCallTimes = 0;
}
_createClass(ThemeCache2, [{
key: "size",
value: function size() {
return this.keys.length;
}
}, {
key: "internalGet",
value: function internalGet(derivativeOption) {
var _cache2, _cache3;
var updateCallTimes = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
var cache = {
map: this.cache
};
derivativeOption.forEach(function(derivative2) {
if (!cache) {
cache = void 0;
} else {
var _cache;
cache = (_cache = cache) === null || _cache === void 0 || (_cache = _cache.map) === null || _cache === void 0 ? void 0 : _cache.get(derivative2);
}
});
if ((_cache2 = cache) !== null && _cache2 !== void 0 && _cache2.value && updateCallTimes) {
cache.value[1] = this.cacheCallTimes++;
}
return (_cache3 = cache) === null || _cache3 === void 0 ? void 0 : _cache3.value;
}
}, {
key: "get",
value: function get2(derivativeOption) {
var _this$internalGet;
return (_this$internalGet = this.internalGet(derivativeOption, true)) === null || _this$internalGet === void 0 ? void 0 : _this$internalGet[0];
}
}, {
key: "has",
value: function has(derivativeOption) {
return !!this.internalGet(derivativeOption);
}
}, {
key: "set",
value: function set2(derivativeOption, value) {
var _this = this;
if (!this.has(derivativeOption)) {
if (this.size() + 1 > ThemeCache2.MAX_CACHE_SIZE + ThemeCache2.MAX_CACHE_OFFSET) {
var _this$keys$reduce = this.keys.reduce(function(result, key) {
var _result = _slicedToArray(result, 2), callTimes = _result[1];
if (_this.internalGet(key)[1] < callTimes) {
return [key, _this.internalGet(key)[1]];
}
return result;
}, [this.keys[0], this.cacheCallTimes]), _this$keys$reduce2 = _slicedToArray(_this$keys$reduce, 1), targetKey = _this$keys$reduce2[0];
this.delete(targetKey);
}
this.keys.push(derivativeOption);
}
var cache = this.cache;
derivativeOption.forEach(function(derivative2, index2) {
if (index2 === derivativeOption.length - 1) {
cache.set(derivative2, {
value: [value, _this.cacheCallTimes++]
});
} else {
var cacheValue = cache.get(derivative2);
if (!cacheValue) {
cache.set(derivative2, {
map: /* @__PURE__ */ new Map()
});
} else if (!cacheValue.map) {
cacheValue.map = /* @__PURE__ */ new Map();
}
cache = cache.get(derivative2).map;
}
});
}
}, {
key: "deleteByPath",
value: function deleteByPath(currentCache, derivatives) {
var cache = currentCache.get(derivatives[0]);
if (derivatives.length === 1) {
var _cache$value;
if (!cache.map) {
currentCache.delete(derivatives[0]);
} else {
currentCache.set(derivatives[0], {
map: cache.map
});
}
return (_cache$value = cache.value) === null || _cache$value === void 0 ? void 0 : _cache$value[0];
}
var result = this.deleteByPath(cache.map, derivatives.slice(1));
if ((!cache.map || cache.map.size === 0) && !cache.value) {
currentCache.delete(derivatives[0]);
}
return result;
}
}, {
key: "delete",
value: function _delete(derivativeOption) {
if (this.has(derivativeOption)) {
this.keys = this.keys.filter(function(item) {
return !sameDerivativeOption(item, derivativeOption);
});
return this.deleteByPath(this.cache, derivativeOption);
}
return void 0;
}
}]);
return ThemeCache2;
}();
_defineProperty(ThemeCache, "MAX_CACHE_SIZE", 20);
_defineProperty(ThemeCache, "MAX_CACHE_OFFSET", 5);
var uuid = 0;
var Theme = /* @__PURE__ */ function() {
function Theme2(derivatives) {
_classCallCheck(this, Theme2);
_defineProperty(this, "derivatives", void 0);
_defineProperty(this, "id", void 0);
this.derivatives = Array.isArray(derivatives) ? derivatives : [derivatives];
this.id = uuid;
if (derivatives.length === 0) {
warning$4(derivatives.length > 0, "[Ant Design CSS-in-JS] Theme should have at least one derivative function.");
}
uuid += 1;
}
_createClass(Theme2, [{
key: "getDerivativeToken",
value: function getDerivativeToken(token2) {
return this.derivatives.reduce(function(result, derivative2) {
return derivative2(token2, result);
}, void 0);
}
}]);
return Theme2;
}();
var cacheThemes = new ThemeCache();
function createTheme(derivatives) {
var derivativeArr = Array.isArray(derivatives) ? derivatives : [derivatives];
if (!cacheThemes.has(derivativeArr)) {
cacheThemes.set(derivativeArr, new Theme(derivativeArr));
}
return cacheThemes.get(derivativeArr);
}
var resultCache = /* @__PURE__ */ new WeakMap();
var RESULT_VALUE = {};
function memoResult(callback, deps) {
var current = resultCache;
for (var i = 0; i < deps.length; i += 1) {
var dep = deps[i];
if (!current.has(dep)) {
current.set(dep, /* @__PURE__ */ new WeakMap());
}
current = current.get(dep);
}
if (!current.has(RESULT_VALUE)) {
current.set(RESULT_VALUE, callback());
}
return current.get(RESULT_VALUE);
}
var flattenTokenCache = /* @__PURE__ */ new WeakMap();
function flattenToken(token2) {
var hashed = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
var str = flattenTokenCache.get(token2) || "";
if (!str) {
Object.keys(token2).forEach(function(key) {
var value = token2[key];
str += key;
if (value instanceof Theme) {
str += value.id;
} else if (value && _typeof(value) === "object") {
str += flattenToken(value, hashed);
} else {
str += value;
}
});
if (hashed) {
str = murmur2(str);
}
flattenTokenCache.set(token2, str);
}
return str;
}
function token2key(token2, salt) {
return murmur2("".concat(salt, "_").concat(flattenToken(token2, true)));
}
var isClientSide = canUseDom();
function unit(num) {
if (typeof num === "number") {
return "".concat(num, "px");
}
return num;
}
function toStyleStr(style2, tokenKey, styleId) {
var customizeAttrs = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
var plain = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : false;
if (plain) {
return style2;
}
var attrs = _objectSpread2(_objectSpread2({}, customizeAttrs), {}, _defineProperty(_defineProperty({}, ATTR_TOKEN, tokenKey), ATTR_MARK, styleId));
var attrStr = Object.keys(attrs).map(function(attr) {
var val = attrs[attr];
return val ? "".concat(attr, '="').concat(val, '"') : null;
}).filter(function(v) {
return v;
}).join(" ");
return "<style ".concat(attrStr, ">").concat(style2, "</style>");
}
var token2CSSVar = function token2CSSVar2(token2) {
var prefix = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
return "--".concat(prefix ? "".concat(prefix, "-") : "").concat(token2).replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/([A-Z]+)([A-Z][a-z0-9]+)/g, "$1-$2").replace(/([a-z])([A-Z0-9])/g, "$1-$2").toLowerCase();
};
var serializeCSSVar = function serializeCSSVar2(cssVars, hashId, options) {
if (!Object.keys(cssVars).length) {
return "";
}
return ".".concat(hashId).concat(options !== null && options !== void 0 && options.scope ? ".".concat(options.scope) : "", "{").concat(Object.entries(cssVars).map(function(_ref) {
var _ref2 = _slicedToArray(_ref, 2), key = _ref2[0], value = _ref2[1];
return "".concat(key, ":").concat(value, ";");
}).join(""), "}");
};
var transformToken = function transformToken2(token2, themeKey, config) {
var cssVars = {};
var result = {};
Object.entries(token2).forEach(function(_ref3) {
var _config$preserve, _config$ignore;
var _ref4 = _slicedToArray(_ref3, 2), key = _ref4[0], value = _ref4[1];
if (config !== null && config !== void 0 && (_config$preserve = config.preserve) !== null && _config$preserve !== void 0 && _config$preserve[key]) {
result[key] = value;
} else if ((typeof value === "string" || typeof value === "number") && !(config !== null && config !== void 0 && (_config$ignore = config.ignore) !== null && _config$ignore !== void 0 && _config$ignore[key])) {
var _config$unitless;
var cssVar = token2CSSVar(key, config === null || config === void 0 ? void 0 : config.prefix);
cssVars[cssVar] = typeof value === "number" && !(config !== null && config !== void 0 && (_config$unitless = config.unitless) !== null && _config$unitless !== void 0 && _config$unitless[key]) ? "".concat(value, "px") : String(value);
result[key] = "var(".concat(cssVar, ")");
}
});
return [result, serializeCSSVar(cssVars, themeKey, {
scope: config === null || config === void 0 ? void 0 : config.scope
})];
};
var fullClone$3 = _objectSpread2({}, React);
var useInsertionEffect$1 = fullClone$3.useInsertionEffect;
var useInsertionEffectPolyfill = function useInsertionEffectPolyfill2(renderEffect, effect, deps) {
React.useMemo(renderEffect, deps);
useLayoutEffect(function() {
return effect(true);
}, deps);
};
var useCompatibleInsertionEffect = useInsertionEffect$1 ? function(renderEffect, effect, deps) {
return useInsertionEffect$1(function() {
renderEffect();
return effect();
}, deps);
} : useInsertionEffectPolyfill;
var fullClone$2 = _objectSpread2({}, React);
var useInsertionEffect = fullClone$2.useInsertionEffect;
var useCleanupRegister = function useCleanupRegister2(deps) {
var effectCleanups = [];
var cleanupFlag = false;
function register2(fn) {
if (cleanupFlag) {
if (process.env.NODE_ENV !== "production") {
warning$4(false, "[Ant Design CSS-in-JS] You are registering a cleanup function after unmount, which will not have any effect.");
}
return;
}
effectCleanups.push(fn);
}
React.useEffect(function() {
cleanupFlag = false;
return function() {
cleanupFlag = true;
if (effectCleanups.length) {
effectCleanups.forEach(function(fn) {
return fn();
});
}
};
}, deps);
return register2;
};
var useRun = function useRun2() {
return function(fn) {
fn();
};
};
var useEffectCleanupRegister = typeof useInsertionEffect !== "undefined" ? useCleanupRegister : useRun;
function useProdHMR() {
return false;
}
var webpackHMR = false;
function useDevHMR() {
return webpackHMR;
}
const useHMR = process.env.NODE_ENV === "production" ? useProdHMR : useDevHMR;
if (process.env.NODE_ENV !== "production" && typeof module !== "undefined" && module && module.hot && typeof window !== "undefined") {
var win = window;
if (typeof win.webpackHotUpdate === "function") {
var originWebpackHotUpdate = win.webpackHotUpdate;
win.webpackHotUpdate = function() {
webpackHMR = true;
setTimeout(function() {
webpackHMR = false;
}, 0);
return originWebpackHotUpdate.apply(void 0, arguments);
};
}
}
function useGlobalCache(prefix, keyPath, cacheFn, onCacheRemove, onCacheEffect) {
var _React$useContext = React.useContext(StyleContext), globalCache = _React$useContext.cache;
var fullPath = [prefix].concat(_toConsumableArray(keyPath));
var fullPathStr = pathKey(fullPath);
var register2 = useEffectCleanupRegister([fullPathStr]);
var HMRUpdate = useHMR();
var buildCache = function buildCache2(updater) {
globalCache.opUpdate(fullPathStr, function(prevCache) {
var _ref = prevCache || [void 0, void 0], _ref2 = _slicedToArray(_ref, 2), _ref2$ = _ref2[0], times = _ref2$ === void 0 ? 0 : _ref2$, cache = _ref2[1];
var tmpCache = cache;
if (process.env.NODE_ENV !== "production" && cache && HMRUpdate) {
onCacheRemove === null || onCacheRemove === void 0 || onCacheRemove(tmpCache, HMRUpdate);
tmpCache = null;
}
var mergedCache = tmpCache || cacheFn();
var data = [times, mergedCache];
return updater ? updater(data) : data;
});
};
React.useMemo(
function() {
buildCache();
},
/* eslint-disable react-hooks/exhaustive-deps */
[fullPathStr]
/* eslint-enable */
);
var cacheEntity = globalCache.opGet(fullPathStr);
if (process.env.NODE_ENV !== "production" && !cacheEntity) {
buildCache();
cacheEntity = globalCache.opGet(fullPathStr);
}
var cacheContent = cacheEntity[1];
useCompatibleInsertionEffect(function() {
onCacheEffect === null || onCacheEffect === void 0 || onCacheEffect(cacheContent);
}, function(polyfill) {
buildCache(function(_ref3) {
var _ref4 = _slicedToArray(_ref3, 2), times = _ref4[0], cache = _ref4[1];
if (polyfill && times === 0) {
onCacheEffect === null || onCacheEffect === void 0 || onCacheEffect(cacheContent);
}
return [times + 1, cache];
});
return function() {
globalCache.opUpdate(fullPathStr, function(prevCache) {
var _ref5 = prevCache || [], _ref6 = _slicedToArray(_ref5, 2), _ref6$ = _ref6[0], times = _ref6$ === void 0 ? 0 : _ref6$, cache = _ref6[1];
var nextCount = times - 1;
if (nextCount === 0) {
register2(function() {
if (polyfill || !globalCache.opGet(fullPathStr)) {
onCacheRemove === null || onCacheRemove === void 0 || onCacheRemove(cache, false);
}
});
return null;
}
return [times - 1, cache];
});
};
}, [fullPathStr]);
return cacheContent;
}
var EMPTY_OVERRIDE = {};
var hashPrefix = process.env.NODE_ENV !== "production" ? "css-dev-only-do-not-override" : "css";
var tokenKeys = /* @__PURE__ */ new Map();
function recordCleanToken(tokenKey) {
tokenKeys.set(tokenKey, (tokenKeys.get(tokenKey) || 0) + 1);
}
function removeStyleTags(key, instanceId) {
if (typeof document !== "undefined") {
var styles = document.querySelectorAll("style[".concat(ATTR_TOKEN, '="').concat(key, '"]'));
styles.forEach(function(style2) {
if (style2[CSS_IN_JS_INSTANCE] === instanceId) {
var _style$parentNode;
(_style$parentNode = style2.parentNode) === null || _style$parentNode === void 0 || _style$parentNode.removeChild(style2);
}
});
}
}
var TOKEN_THRESHOLD = 0;
function cleanTokenStyle(tokenKey, instanceId) {
tokenKeys.set(tokenKey, (tokenKeys.get(tokenKey) || 0) - 1);
var tokenKeyList = Array.from(tokenKeys.keys());
var cleanableKeyList = tokenKeyList.filter(function(key) {
var count = tokenKeys.get(key) || 0;
return count <= 0;
});
if (tokenKeyList.length - cleanableKeyList.length > TOKEN_THRESHOLD) {
cleanableKeyList.forEach(function(key) {
removeStyleTags(key, instanceId);
tokenKeys.delete(key);
});
}
}
var getComputedToken$1 = function getComputedToken(originToken, overrideToken, theme, format2) {
var derivativeToken = theme.getDerivativeToken(originToken);
var mergedDerivativeToken = _objectSpread2(_objectSpread2({}, derivativeToken), overrideToken);
if (format2) {
mergedDerivativeToken = format2(mergedDerivativeToken);
}
return mergedDerivativeToken;
};
var TOKEN_PREFIX = "token";
function useCacheToken(theme, tokens) {
var option = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
var _useContext = useContext(StyleContext), instanceId = _useContext.cache.instanceId, container = _useContext.container;
var _option$salt = option.salt, salt = _option$salt === void 0 ? "" : _option$salt, _option$override = option.override, override = _option$override === void 0 ? EMPTY_OVERRIDE : _option$override, formatToken2 = option.formatToken, compute = option.getComputedToken, cssVar = option.cssVar;
var mergedToken = memoResult(function() {
return Object.assign.apply(Object, [{}].concat(_toConsumableArray(tokens)));
}, tokens);
var tokenStr = flattenToken(mergedToken);
var overrideTokenStr = flattenToken(override);
var cssVarStr = cssVar ? flattenToken(cssVar) : "";
var cachedToken = useGlobalCache(TOKEN_PREFIX, [salt, theme.id, tokenStr, overrideTokenStr, cssVarStr], function() {
var _cssVar$key;
var mergedDerivativeToken = compute ? compute(mergedToken, override, theme) : getComputedToken$1(mergedToken, override, theme, formatToken2);
var actualToken = _objectSpread2({}, mergedDerivativeToken);
var cssVarsStr = "";
if (!!cssVar) {
var _transformToken = transformToken(mergedDerivativeToken, cssVar.key, {
prefix: cssVar.prefix,
ignore: cssVar.ignore,
unitless: cssVar.unitless,
preserve: cssVar.preserve
});
var _transformToken2 = _slicedToArray(_transformToken, 2);
mergedDerivativeToken = _transformToken2[0];
cssVarsStr = _transformToken2[1];
}
var tokenKey = token2key(mergedDerivativeToken, salt);
mergedDerivativeToken._tokenKey = tokenKey;
actualToken._tokenKey = token2key(actualToken, salt);
var themeKey = (_cssVar$key = cssVar === null || cssVar === void 0 ? void 0 : cssVar.key) !== null && _cssVar$key !== void 0 ? _cssVar$key : tokenKey;
mergedDerivativeToken._themeKey = themeKey;
recordCleanToken(themeKey);
var hashId = "".concat(hashPrefix, "-").concat(murmur2(tokenKey));
mergedDerivativeToken._hashId = hashId;
return [mergedDerivativeToken, hashId, actualToken, cssVarsStr, (cssVar === null || cssVar === void 0 ? void 0 : cssVar.key) || ""];
}, function(cache) {
cleanTokenStyle(cache[0]._themeKey, instanceId);
}, function(_ref) {
var _ref2 = _slicedToArray(_ref, 4), token2 = _ref2[0], cssVarsStr = _ref2[3];
if (cssVar && cssVarsStr) {
var style2 = updateCSS(cssVarsStr, murmur2("css-variables-".concat(token2._themeKey)), {
mark: ATTR_MARK,
prepend: "queue",
attachTo: container,
priority: -999
});
style2[CSS_IN_JS_INSTANCE] = instanceId;
style2.setAttribute(ATTR_TOKEN, token2._themeKey);
}
});
return cachedToken;
}
var extract$2 = function extract(cache, effectStyles, options) {
var _cache = _slicedToArray(cache, 5), realToken = _cache[2], styleStr = _cache[3], cssVarKey = _cache[4];
var _ref3 = options || {}, plain = _ref3.plain;
if (!styleStr) {
return null;
}
var styleId = realToken._tokenKey;
var order = -999;
var sharedAttrs = {
"data-rc-order": "prependQueue",
"data-rc-priority": "".concat(order)
};
var styleText = toStyleStr(styleStr, cssVarKey, styleId, sharedAttrs, plain);
return [order, styleId, styleText];
};
var unitlessKeys = {
animationIterationCount: 1,
borderImageOutset: 1,
borderImageSlice: 1,
borderImageWidth: 1,
boxFlex: 1,
boxFlexGroup: 1,
boxOrdinalGroup: 1,
columnCount: 1,
columns: 1,
flex: 1,
flexGrow: 1,
flexPositive: 1,
flexShrink: 1,
flexNegative: 1,
flexOrder: 1,
gridRow: 1,
gridRowEnd: 1,
gridRowSpan: 1,
gridRowStart: 1,
gridColumn: 1,
gridColumnEnd: 1,
gridColumnSpan: 1,
gridColumnStart: 1,
msGridRow: 1,
msGridRowSpan: 1,
msGridColumn: 1,
msGridColumnSpan: 1,
fontWeight: 1,
lineHeight: 1,
opacity: 1,
order: 1,
orphans: 1,
tabSize: 1,
widows: 1,
zIndex: 1,
zoom: 1,
WebkitLineClamp: 1,
// SVG-related properties
fillOpacity: 1,
floodOpacity: 1,
stopOpacity: 1,
strokeDasharray: 1,
strokeDashoffset: 1,
strokeMiterlimit: 1,
strokeOpacity: 1,
strokeWidth: 1
};
var COMMENT = "comm";
var RULESET = "rule";
var DECLARATION = "decl";
var IMPORT = "@import";
var KEYFRAMES = "@keyframes";
var LAYER = "@layer";
var abs = Math.abs;
var from = String.fromCharCode;
function trim(value) {
return value.trim();
}
function replace(value, pattern4, replacement) {
return value.replace(pattern4, replacement);
}
function indexof(value, search, position2) {
return value.indexOf(search, position2);
}
function charat(value, index2) {
return value.charCodeAt(index2) | 0;
}
function substr(value, begin, end) {
return value.slice(begin, end);
}
function strlen(value) {
return value.length;
}
function sizeof(value) {
return value.length;
}
function append(value, array4) {
return array4.push(value), value;
}
var line = 1;
var column = 1;
var length = 0;
var position = 0;
var character = 0;
var characters = "";
function node(value, root, parent, type4, props, children, length2, siblings) {
return { value, root, parent, type: type4, props, children, line, column, length: length2, return: "", siblings };
}
function char() {
return character;
}
function prev() {
character = position > 0 ? charat(characters, --position) : 0;
if (column--, character === 10)
column = 1, line--;
return character;
}
function next() {
character = position < length ? charat(characters, position++) : 0;
if (column++, character === 10)
column = 1, line++;
return character;
}
function peek() {
return charat(characters, position);
}
function caret() {
return position;
}
function slice(begin, end) {
return substr(characters, begin, end);
}
function token(type4) {
switch (type4) {
case 0:
case 9:
case 10:
case 13:
case 32:
return 5;
case 33:
case 43:
case 44:
case 47:
case 62:
case 64:
case 126:
case 59:
case 123:
case 125:
return 4;
case 58:
return 3;
case 34:
case 39:
case 40:
case 91:
return 2;
case 41:
case 93:
return 1;
}
return 0;
}
function alloc(value) {
return line = column = 1, length = strlen(characters = value), position = 0, [];
}
function dealloc(value) {
return characters = "", value;
}
function delimit(type4) {
return trim(slice(position - 1, delimiter(type4 === 91 ? type4 + 2 : type4 === 40 ? type4 + 1 : type4)));
}
function whitespace2(type4) {
while (character = peek())
if (character < 33)
next();
else
break;
return token(type4) > 2 || token(character) > 3 ? "" : " ";
}
function escaping(index2, count) {
while (--count && next())
if (character < 48 || character > 102 || character > 57 && character < 65 || character > 70 && character < 97)
break;
return slice(index2, caret() + (count < 6 && peek() == 32 && next() == 32));
}
function delimiter(type4) {
while (next())
switch (character) {
case type4:
return position;
case 34:
case 39:
if (type4 !== 34 && type4 !== 39)
delimiter(character);
break;
case 40:
if (type4 === 41)
delimiter(type4);
break;
case 92:
next();
break;
}
return position;
}
function commenter(type4, index2) {
while (next())
if (type4 + character === 47 + 10)
break;
else if (type4 + character === 42 + 42 && peek() === 47)
break;
return "/*" + slice(index2, position - 1) + "*" + from(type4 === 47 ? type4 : next());
}
function identifier(index2) {
while (!token(peek()))
next();
return slice(index2, position);
}
function compile(value) {
return dealloc(parse("", null, null, null, [""], value = alloc(value), 0, [0], value));
}
function parse(value, root, parent, rule, rules2, rulesets, pseudo, points, declarations) {
var index2 = 0;
var offset = 0;
var length2 = pseudo;
var atrule = 0;
var property = 0;
var previous = 0;
var variable = 1;
var scanning = 1;
var ampersand = 1;
var character2 = 0;
var type4 = "";
var props = rules2;
var children = rulesets;
var reference = rule;
var characters2 = type4;
while (scanning)
switch (previous = character2, character2 = next()) {
case 40:
if (previous != 108 && charat(characters2, length2 - 1) == 58) {
if (indexof(characters2 += replace(delimit(character2), "&", "&\f"), "&\f", abs(index2 ? points[index2 - 1] : 0)) != -1)
ampersand = -1;
break;
}
case 34:
case 39:
case 91:
characters2 += delimit(character2);
break;
case 9:
case 10:
case 13:
case 32:
characters2 += whitespace2(previous);
break;
case 92:
characters2 += escaping(caret() - 1, 7);
continue;
case 47:
switch (peek()) {
case 42:
case 47:
append(comment(commenter(next(), caret()), root, parent, declarations), declarations);
break;
default:
characters2 += "/";
}
break;
case 123 * variable:
points[index2++] = strlen(characters2) * ampersand;
case 125 * variable:
case 59:
case 0:
switch (character2) {
case 0:
case 125:
scanning = 0;
case 59 + offset:
if (ampersand == -1) characters2 = replace(characters2, /\f/g, "");
if (property > 0 && strlen(characters2) - length2)
append(property > 32 ? declaration(characters2 + ";", rule, parent, length2 - 1, declarations) : declaration(replace(characters2, " ", "") + ";", rule, parent, length2 - 2, declarations), declarations);
break;
case 59:
characters2 += ";";
default:
append(reference = ruleset(characters2, root, parent, index2, offset, rules2, points, type4, props = [], children = [], length2, rulesets), rulesets);
if (character2 === 123)
if (offset === 0)
parse(characters2, root, reference, reference, props, rulesets, length2, points, children);
else
switch (atrule === 99 && charat(characters2, 3) === 110 ? 100 : atrule) {
case 100:
case 108:
case 109:
case 115:
parse(value, reference, reference, rule && append(ruleset(value, reference, reference, 0, 0, rules2, points, type4, rules2, props = [], length2, children), children), rules2, children, length2, points, rule ? props : children);
break;
default:
parse(characters2, reference, reference, reference, [""], children, 0, points, children);
}
}
index2 = offset = property = 0, variable = ampersand = 1, type4 = characters2 = "", length2 = pseudo;
break;
case 58:
length2 = 1 + strlen(characters2), property = previous;
default:
if (variable < 1) {
if (character2 == 123)
--variable;
else if (character2 == 125 && variable++ == 0 && prev() == 125)
continue;
}
switch (characters2 += from(character2), character2 * variable) {
case 38:
ampersand = offset > 0 ? 1 : (characters2 += "\f", -1);
break;
case 44:
points[index2++] = (strlen(characters2) - 1) * ampersand, ampersand = 1;
break;
case 64:
if (peek() === 45)
characters2 += delimit(next());
atrule = peek(), offset = length2 = strlen(type4 = characters2 += identifier(caret())), character2++;
break;
case 45:
if (previous === 45 && strlen(characters2) == 2)
variable = 0;
}
}
return rulesets;
}
function ruleset(value, root, parent, index2, offset, rules2, points, type4, props, children, length2, siblings) {
var post = offset - 1;
var rule = offset === 0 ? rules2 : [""];
var size = sizeof(rule);
for (var i = 0, j = 0, k = 0; i < index2; ++i)
for (var x = 0, y = substr(value, post + 1, post = abs(j = points[i])), z = value; x < size; ++x)
if (z = trim(j > 0 ? rule[x] + " " + y : replace(y, /&\f/g, rule[x])))
props[k++] = z;
return node(value, root, parent, offset === 0 ? RULESET : type4, props, children, length2, siblings);
}
function comment(value, root, parent, siblings) {
return node(value, root, parent, COMMENT, from(char()), substr(value, 2, -2), 0, siblings);
}
function declaration(value, root, parent, length2, siblings) {
return node(value, root, parent, DECLARATION, substr(value, 0, length2), substr(value, length2 + 1, -1), length2, siblings);
}
function serialize(children, callback) {
var output = "";
for (var i = 0; i < children.length; i++)
output += callback(children[i], i, children, callback) || "";
return output;
}
function stringify(element, index2, children, callback) {
switch (element.type) {
case LAYER:
if (element.children.length) break;
case IMPORT:
case DECLARATION:
return element.return = element.return || element.value;
case COMMENT:
return "";
case KEYFRAMES:
return element.return = element.value + "{" + serialize(element.children, callback) + "}";
case RULESET:
if (!strlen(element.value = element.props.join(","))) return "";
}
return strlen(children = serialize(element.children, callback)) ? element.return = element.value + "{" + children + "}" : "";
}
function lintWarning(message, info) {
var path = info.path, parentSelectors = info.parentSelectors;
warningOnce(false, "[Ant Design CSS-in-JS] ".concat(path ? "Error in ".concat(path, ": ") : "").concat(message).concat(parentSelectors.length ? " Selector: ".concat(parentSelectors.join(" | ")) : ""));
}
var linter$1 = function linter(key, value, info) {
if (key === "content") {
var contentValuePattern = /(attr|counters?|url|(((repeating-)?(linear|radial))|conic)-gradient)\(|(no-)?(open|close)-quote/;
var contentValues = ["normal", "none", "initial", "inherit", "unset"];
if (typeof value !== "string" || contentValues.indexOf(value) === -1 && !contentValuePattern.test(value) && (value.charAt(0) !== value.charAt(value.length - 1) || value.charAt(0) !== '"' && value.charAt(0) !== "'")) {
lintWarning("You seem to be using a value for 'content' without quotes, try replacing it with `content: '\"".concat(value, "\"'`."), info);
}
}
};
var linter2 = function linter3(key, value, info) {
if (key === "animation") {
if (info.hashId && value !== "none") {
lintWarning("You seem to be using hashed animation '".concat(value, "', in which case 'animationName' with Keyframe as value is recommended."), info);
}
}
};
var ATTR_CACHE_MAP = "data-ant-cssinjs-cache-path";
var CSS_FILE_STYLE = "_FILE_STYLE__";
var cachePathMap;
var fromCSSFile = true;
function prepare() {
if (!cachePathMap) {
cachePathMap = {};
if (canUseDom()) {
var div = document.createElement("div");
div.className = ATTR_CACHE_MAP;
div.style.position = "fixed";
div.style.visibility = "hidden";
div.style.top = "-9999px";
document.body.appendChild(div);
var content = getComputedStyle(div).content || "";
content = content.replace(/^"/, "").replace(/"$/, "");
content.split(";").forEach(function(item) {
var _item$split = item.split(":"), _item$split2 = _slicedToArray(_item$split, 2), path = _item$split2[0], hash = _item$split2[1];
cachePathMap[path] = hash;
});
var inlineMapStyle = document.querySelector("style[".concat(ATTR_CACHE_MAP, "]"));
if (inlineMapStyle) {
var _inlineMapStyle$paren;
fromCSSFile = false;
(_inlineMapStyle$paren = inlineMapStyle.parentNode) === null || _inlineMapStyle$paren === void 0 || _inlineMapStyle$paren.removeChild(inlineMapStyle);
}
document.body.removeChild(div);
}
}
}
function existPath(path) {
prepare();
return !!cachePathMap[path];
}
function getStyleAndHash(path) {
var hash = cachePathMap[path];
var styleStr = null;
if (hash && canUseDom()) {
if (fromCSSFile) {
styleStr = CSS_FILE_STYLE;
} else {
var _style = document.querySelector("style[".concat(ATTR_MARK, '="').concat(cachePathMap[path], '"]'));
if (_style) {
styleStr = _style.innerHTML;
} else {
delete cachePathMap[path];
}
}
}
return [styleStr, hash];
}
var SKIP_CHECK = "_skip_check_";
var MULTI_VALUE = "_multi_value_";
function normalizeStyle(styleStr) {
var serialized = serialize(compile(styleStr), stringify);
return serialized.replace(/\{%%%\:[^;];}/g, ";");
}
function isCompoundCSSProperty(value) {
return _typeof(value) === "object" && value && (SKIP_CHECK in value || MULTI_VALUE in value);
}
function injectSelectorHash(key, hashId, hashPriority) {
if (!hashId) {
return key;
}
var hashClassName = ".".concat(hashId);
var hashSelector = hashPriority === "low" ? ":where(".concat(hashClassName, ")") : hashClassName;
var keys2 = key.split(",").map(function(k) {
var _firstPath$match;
var fullPath = k.trim().split(/\s+/);
var firstPath = fullPath[0] || "";
var htmlElement = ((_firstPath$match = firstPath.match(/^\w+/)) === null || _firstPath$match === void 0 ? void 0 : _firstPath$match[0]) || "";
firstPath = "".concat(htmlElement).concat(hashSelector).concat(firstPath.slice(htmlElement.length));
return [firstPath].concat(_toConsumableArray(fullPath.slice(1))).join(" ");
});
return keys2.join(",");
}
var parseStyle = function parseStyle2(interpolation) {
var config = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
var _ref = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
root: true,
parentSelectors: []
}, root = _ref.root, injectHash = _ref.injectHash, parentSelectors = _ref.parentSelectors;
var hashId = config.hashId, layer = config.layer, path = config.path, hashPriority = config.hashPriority, _config$transformers = config.transformers, transformers = _config$transformers === void 0 ? [] : _config$transformers, _config$linters = config.linters, linters = _config$linters === void 0 ? [] : _config$linters;
var styleStr = "";
var effectStyle = {};
function parseKeyframes(keyframes) {
var animationName = keyframes.getName(hashId);
if (!effectStyle[animationName]) {
var _parseStyle = parseStyle2(keyframes.style, config, {
root: false,
parentSelectors
}), _parseStyle2 = _slicedToArray(_parseStyle, 1), _parsedStr = _parseStyle2[0];
effectStyle[animationName] = "@keyframes ".concat(keyframes.getName(hashId)).concat(_parsedStr);
}
}
function flattenList(list) {
var fullList = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
list.forEach(function(item) {
if (Array.isArray(item)) {
flattenList(item, fullList);
} else if (item) {
fullList.push(item);
}
});
return fullList;
}
var flattenStyleList = flattenList(Array.isArray(interpolation) ? interpolation : [interpolation]);
flattenStyleList.forEach(function(originStyle) {
var style2 = typeof originStyle === "string" && !root ? {} : originStyle;
if (typeof style2 === "string") {
styleStr += "".concat(style2, "\n");
} else if (style2._keyframe) {
parseKeyframes(style2);
} else {
var mergedStyle = transformers.reduce(function(prev2, trans) {
var _trans$visit;
return (trans === null || trans === void 0 || (_trans$visit = trans.visit) === null || _trans$visit === void 0 ? void 0 : _trans$visit.call(trans, prev2)) || prev2;
}, style2);
Object.keys(mergedStyle).forEach(function(key) {
var value = mergedStyle[key];
if (_typeof(value) === "object" && value && (key !== "animationName" || !value._keyframe) && !isCompoundCSSProperty(value)) {
var subInjectHash = false;
var mergedKey = key.trim();
var nextRoot = false;
if ((root || injectHash) && hashId) {
if (mergedKey.startsWith("@")) {
subInjectHash = true;
} else {
mergedKey = injectSelectorHash(key, hashId, hashPriority);
}
} else if (root && !hashId && (mergedKey === "&" || mergedKey === "")) {
mergedKey = "";
nextRoot = true;
}
var _parseStyle3 = parseStyle2(value, config, {
root: nextRoot,
injectHash: subInjectHash,
parentSelectors: [].concat(_toConsumableArray(parentSelectors), [mergedKey])
}), _parseStyle4 = _slicedToArray(_parseStyle3, 2), _parsedStr2 = _parseStyle4[0], childEffectStyle = _parseStyle4[1];
effectStyle = _objectSpread2(_objectSpread2({}, effectStyle), childEffectStyle);
styleStr += "".concat(mergedKey).concat(_parsedStr2);
} else {
let appendStyle = function(cssKey, cssValue) {
if (process.env.NODE_ENV !== "production" && (_typeof(value) !== "object" || !(value !== null && value !== void 0 && value[SKIP_CHECK]))) {
[linter$1, linter2].concat(_toConsumableArray(linters)).forEach(function(linter4) {
return linter4(cssKey, cssValue, {
path,
hashId,
parentSelectors
});
});
}
var styleName = cssKey.replace(/[A-Z]/g, function(match2) {
return "-".concat(match2.toLowerCase());
});
var formatValue2 = cssValue;
if (!unitlessKeys[cssKey] && typeof formatValue2 === "number" && formatValue2 !== 0) {
formatValue2 = "".concat(formatValue2, "px");
}
if (cssKey === "animationName" && cssValue !== null && cssValue !== void 0 && cssValue._keyframe) {
parseKeyframes(cssValue);
formatValue2 = cssValue.getName(hashId);
}
styleStr += "".concat(styleName, ":").concat(formatValue2, ";");
};
var _value;
var actualValue = (_value = value === null || value === void 0 ? void 0 : value.value) !== null && _value !== void 0 ? _value : value;
if (_typeof(value) === "object" && value !== null && value !== void 0 && value[MULTI_VALUE] && Array.isArray(actualValue)) {
actualValue.forEach(function(item) {
appendStyle(key, item);
});
} else {
appendStyle(key, actualValue);
}
}
});
}
});
if (!root) {
styleStr = "{".concat(styleStr, "}");
} else if (layer) {
styleStr = "@layer ".concat(layer.name, " {").concat(styleStr, "}");
if (layer.dependencies) {
effectStyle["@layer ".concat(layer.name)] = layer.dependencies.map(function(deps) {
return "@layer ".concat(deps, ", ").concat(layer.name, ";");
}).join("\n");
}
}
return [styleStr, effectStyle];
};
function uniqueHash(path, styleStr) {
return murmur2("".concat(path.join("%")).concat(styleStr));
}
function Empty() {
return null;
}
var STYLE_PREFIX = "style";
function useStyleRegister(info, styleFn) {
var token2 = info.token, path = info.path, hashId = info.hashId, layer = info.layer, nonce = info.nonce, clientOnly = info.clientOnly, _info$order = info.order, order = _info$order === void 0 ? 0 : _info$order;
var _React$useContext = React.useContext(StyleContext), autoClear = _React$useContext.autoClear, mock = _React$useContext.mock, defaultCache = _React$useContext.defaultCache, hashPriority = _React$useContext.hashPriority, container = _React$useContext.container, ssrInline = _React$useContext.ssrInline, transformers = _React$useContext.transformers, linters = _React$useContext.linters, cache = _React$useContext.cache, enableLayer = _React$useContext.layer;
var tokenKey = token2._tokenKey;
var fullPath = [tokenKey];
if (enableLayer) {
fullPath.push("layer");
}
fullPath.push.apply(fullPath, _toConsumableArray(path));
var isMergedClientSide = isClientSide;
if (process.env.NODE_ENV !== "production" && mock !== void 0) {
isMergedClientSide = mock === "client";
}
var _useGlobalCache = useGlobalCache(
STYLE_PREFIX,
fullPath,
// Create cache if needed
function() {
var cachePath = fullPath.join("|");
if (existPath(cachePath)) {
var _getStyleAndHash = getStyleAndHash(cachePath), _getStyleAndHash2 = _slicedToArray(_getStyleAndHash, 2), inlineCacheStyleStr = _getStyleAndHash2[0], styleHash = _getStyleAndHash2[1];
if (inlineCacheStyleStr) {
return [inlineCacheStyleStr, tokenKey, styleHash, {}, clientOnly, order];
}
}
var styleObj = styleFn();
var _parseStyle5 = parseStyle(styleObj, {
hashId,
hashPriority,
layer: enableLayer ? layer : void 0,
path: path.join("-"),
transformers,
linters
}), _parseStyle6 = _slicedToArray(_parseStyle5, 2), parsedStyle = _parseStyle6[0], effectStyle = _parseStyle6[1];
var styleStr = normalizeStyle(parsedStyle);
var styleId = uniqueHash(fullPath, styleStr);
return [styleStr, tokenKey, styleId, effectStyle, clientOnly, order];
},
// Remove cache if no need
function(_ref2, fromHMR) {
var _ref3 = _slicedToArray(_ref2, 3), styleId = _ref3[2];
if ((fromHMR || autoClear) && isClientSide) {
removeCSS(styleId, {
mark: ATTR_MARK
});
}
},
// Effect: Inject style here
function(_ref4) {
var _ref5 = _slicedToArray(_ref4, 4), styleStr = _ref5[0];
_ref5[1];
var styleId = _ref5[2], effectStyle = _ref5[3];
if (isMergedClientSide && styleStr !== CSS_FILE_STYLE) {
var mergedCSSConfig = {
mark: ATTR_MARK,
prepend: enableLayer ? false : "queue",
attachTo: container,
priority: order
};
var nonceStr = typeof nonce === "function" ? nonce() : nonce;
if (nonceStr) {
mergedCSSConfig.csp = {
nonce: nonceStr
};
}
var effectLayerKeys = [];
var effectRestKeys = [];
Object.keys(effectStyle).forEach(function(key) {
if (key.startsWith("@layer")) {
effectLayerKeys.push(key);
} else {
effectRestKeys.push(key);
}
});
effectLayerKeys.forEach(function(effectKey) {
updateCSS(normalizeStyle(effectStyle[effectKey]), "_layer-".concat(effectKey), _objectSpread2(_objectSpread2({}, mergedCSSConfig), {}, {
prepend: true
}));
});
var style2 = updateCSS(styleStr, styleId, mergedCSSConfig);
style2[CSS_IN_JS_INSTANCE] = cache.instanceId;
style2.setAttribute(ATTR_TOKEN, tokenKey);
if (process.env.NODE_ENV !== "production") {
style2.setAttribute(ATTR_CACHE_PATH, fullPath.join("|"));
}
effectRestKeys.forEach(function(effectKey) {
updateCSS(normalizeStyle(effectStyle[effectKey]), "_effect-".concat(effectKey), mergedCSSConfig);
});
}
}
), _useGlobalCache2 = _slicedToArray(_useGlobalCache, 3), cachedStyleStr = _useGlobalCache2[0], cachedTokenKey = _useGlobalCache2[1], cachedStyleId = _useGlobalCache2[2];
return function(node2) {
var styleNode;
if (!ssrInline || isMergedClientSide || !defaultCache) {
styleNode = /* @__PURE__ */ React.createElement(Empty, null);
} else {
styleNode = /* @__PURE__ */ React.createElement("style", _extends({}, _defineProperty(_defineProperty({}, ATTR_TOKEN, cachedTokenKey), ATTR_MARK, cachedStyleId), {
dangerouslySetInnerHTML: {
__html: cachedStyleStr
}
}));
}
return /* @__PURE__ */ React.createElement(React.Fragment, null, styleNode, node2);
};
}
var extract$1 = function extract2(cache, effectStyles, options) {
var _cache = _slicedToArray(cache, 6), styleStr = _cache[0], tokenKey = _cache[1], styleId = _cache[2], effectStyle = _cache[3], clientOnly = _cache[4], order = _cache[5];
var _ref7 = options || {}, plain = _ref7.plain;
if (clientOnly) {
return null;
}
var keyStyleText = styleStr;
var sharedAttrs = {
"data-rc-order": "prependQueue",
"data-rc-priority": "".concat(order)
};
keyStyleText = toStyleStr(styleStr, tokenKey, styleId, sharedAttrs, plain);
if (effectStyle) {
Object.keys(effectStyle).forEach(function(effectKey) {
if (!effectStyles[effectKey]) {
effectStyles[effectKey] = true;
var effectStyleStr = normalizeStyle(effectStyle[effectKey]);
var effectStyleHTML = toStyleStr(effectStyleStr, tokenKey, "_effect-".concat(effectKey), sharedAttrs, plain);
if (effectKey.startsWith("@layer")) {
keyStyleText = effectStyleHTML + keyStyleText;
} else {
keyStyleText += effectStyleHTML;
}
}
});
}
return [order, styleId, keyStyleText];
};
var CSS_VAR_PREFIX = "cssVar";
var useCSSVarRegister = function useCSSVarRegister2(config, fn) {
var key = config.key, prefix = config.prefix, unitless2 = config.unitless, ignore2 = config.ignore, token2 = config.token, _config$scope = config.scope, scope = _config$scope === void 0 ? "" : _config$scope;
var _useContext = useContext(StyleContext), instanceId = _useContext.cache.instanceId, container = _useContext.container;
var tokenKey = token2._tokenKey;
var stylePath = [].concat(_toConsumableArray(config.path), [key, scope, tokenKey]);
var cache = useGlobalCache(CSS_VAR_PREFIX, stylePath, function() {
var originToken = fn();
var _transformToken = transformToken(originToken, key, {
prefix,
unitless: unitless2,
ignore: ignore2,
scope
}), _transformToken2 = _slicedToArray(_transformToken, 2), mergedToken = _transformToken2[0], cssVarsStr = _transformToken2[1];
var styleId = uniqueHash(stylePath, cssVarsStr);
return [mergedToken, cssVarsStr, styleId, key];
}, function(_ref) {
var _ref2 = _slicedToArray(_ref, 3), styleId = _ref2[2];
if (isClientSide) {
removeCSS(styleId, {
mark: ATTR_MARK
});
}
}, function(_ref3) {
var _ref4 = _slicedToArray(_ref3, 3), cssVarsStr = _ref4[1], styleId = _ref4[2];
if (!cssVarsStr) {
return;
}
var style2 = updateCSS(cssVarsStr, styleId, {
mark: ATTR_MARK,
prepend: "queue",
attachTo: container,
priority: -999
});
style2[CSS_IN_JS_INSTANCE] = instanceId;
style2.setAttribute(ATTR_TOKEN, key);
});
return cache;
};
var extract3 = function extract4(cache, effectStyles, options) {
var _cache = _slicedToArray(cache, 4), styleStr = _cache[1], styleId = _cache[2], cssVarKey = _cache[3];
var _ref5 = options || {}, plain = _ref5.plain;
if (!styleStr) {
return null;
}
var order = -999;
var sharedAttrs = {
"data-rc-order": "prependQueue",
"data-rc-priority": "".concat(order)
};
var styleText = toStyleStr(styleStr, cssVarKey, styleId, sharedAttrs, plain);
return [order, styleId, styleText];
};
_defineProperty(_defineProperty(_defineProperty({}, STYLE_PREFIX, extract$1), TOKEN_PREFIX, extract$2), CSS_VAR_PREFIX, extract3);
var Keyframe = /* @__PURE__ */ function() {
function Keyframe2(name, style2) {
_classCallCheck(this, Keyframe2);
_defineProperty(this, "name", void 0);
_defineProperty(this, "style", void 0);
_defineProperty(this, "_keyframe", true);
this.name = name;
this.style = style2;
}
_createClass(Keyframe2, [{
key: "getName",
value: function getName() {
var hashId = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "";
return hashId ? "".concat(hashId, "-").concat(this.name) : this.name;
}
}]);
return Keyframe2;
}();
function noSplit(list) {
list.notSplit = true;
return list;
}
({
// Inset
inset: ["top", "right", "bottom", "left"],
insetBlock: ["top", "bottom"],
insetBlockStart: ["top"],
insetBlockEnd: ["bottom"],
insetInline: ["left", "right"],
insetInlineStart: ["left"],
insetInlineEnd: ["right"],
// Margin
marginBlock: ["marginTop", "marginBottom"],
marginBlockStart: ["marginTop"],
marginBlockEnd: ["marginBottom"],
marginInline: ["marginLeft", "marginRight"],
marginInlineStart: ["marginLeft"],
marginInlineEnd: ["marginRight"],
// Padding
paddingBlock: ["paddingTop", "paddingBottom"],
paddingBlockStart: ["paddingTop"],
paddingBlockEnd: ["paddingBottom"],
paddingInline: ["paddingLeft", "paddingRight"],
paddingInlineStart: ["paddingLeft"],
paddingInlineEnd: ["paddingRight"],
// Border
borderBlock: noSplit(["borderTop", "borderBottom"]),
borderBlockStart: noSplit(["borderTop"]),
borderBlockEnd: noSplit(["borderBottom"]),
borderInline: noSplit(["borderLeft", "borderRight"]),
borderInlineStart: noSplit(["borderLeft"]),
borderInlineEnd: noSplit(["borderRight"]),
// Border width
borderBlockWidth: ["borderTopWidth", "borderBottomWidth"],
borderBlockStartWidth: ["borderTopWidth"],
borderBlockEndWidth: ["borderBottomWidth"],
borderInlineWidth: ["borderLeftWidth", "borderRightWidth"],
borderInlineStartWidth: ["borderLeftWidth"],
borderInlineEndWidth: ["borderRightWidth"],
// Border style
borderBlockStyle: ["borderTopStyle", "borderBottomStyle"],
borderBlockStartStyle: ["borderTopStyle"],
borderBlockEndStyle: ["borderBottomStyle"],
borderInlineStyle: ["borderLeftStyle", "borderRightStyle"],
borderInlineStartStyle: ["borderLeftStyle"],
borderInlineEndStyle: ["borderRightStyle"],
// Border color
borderBlockColor: ["borderTopColor", "borderBottomColor"],
borderBlockStartColor: ["borderTopColor"],
borderBlockEndColor: ["borderBottomColor"],
borderInlineColor: ["borderLeftColor", "borderRightColor"],
borderInlineStartColor: ["borderLeftColor"],
borderInlineEndColor: ["borderRightColor"],
// Border radius
borderStartStartRadius: ["borderTopLeftRadius"],
borderStartEndRadius: ["borderTopRightRadius"],
borderEndStartRadius: ["borderBottomLeftRadius"],
borderEndEndRadius: ["borderBottomRightRadius"]
});
function noop$1() {
}
let deprecatedWarnList = null;
function resetWarned() {
deprecatedWarnList = null;
resetWarned$1();
}
let warning2 = noop$1;
if (process.env.NODE_ENV !== "production") {
warning2 = (valid, component, message) => {
warningOnce(valid, `[antd: ${component}] ${message}`);
if (process.env.NODE_ENV === "test") {
resetWarned();
}
};
}
const WarningContext = /* @__PURE__ */ React.createContext({});
const devUseWarning = process.env.NODE_ENV !== "production" ? (component) => {
const {
strict
} = React.useContext(WarningContext);
const typeWarning = (valid, type4, message) => {
if (!valid) {
if (strict === false && type4 === "deprecated") {
const existWarning = deprecatedWarnList;
if (!deprecatedWarnList) {
deprecatedWarnList = {};
}
deprecatedWarnList[component] = deprecatedWarnList[component] || [];
if (!deprecatedWarnList[component].includes(message || "")) {
deprecatedWarnList[component].push(message || "");
}
if (!existWarning) {
console.warn("[antd] There exists deprecated usage in your code:", deprecatedWarnList);
}
} else {
process.env.NODE_ENV !== "production" ? warning2(valid, component, message) : void 0;
}
}
};
typeWarning.deprecated = (valid, oldProp, newProp, message) => {
typeWarning(valid, "deprecated", `\`${oldProp}\` is deprecated. Please use \`${newProp}\` instead.${message ? ` ${message}` : ""}`);
};
return typeWarning;
} : () => {
const noopWarning = () => {
};
noopWarning.deprecated = noop$1;
return noopWarning;
};
const warning$1 = warning2;
const ValidateMessagesContext = /* @__PURE__ */ createContext(void 0);
var locale$3 = {
// Options
items_per_page: "/ page",
jump_to: "Go to",
jump_to_confirm: "confirm",
page: "Page",
// Pagination
prev_page: "Previous Page",
next_page: "Next Page",
prev_5: "Previous 5 Pages",
next_5: "Next 5 Pages",
prev_3: "Previous 3 Pages",
next_3: "Next 3 Pages",
page_size: "Page Size"
};
var commonLocale = {
yearFormat: "YYYY",
dayFormat: "D",
cellMeridiemFormat: "A",
monthBeforeYear: true
};
var locale$2 = _objectSpread2(_objectSpread2({}, commonLocale), {}, {
locale: "en_US",
today: "Today",
now: "Now",
backToToday: "Back to today",
ok: "OK",
clear: "Clear",
month: "Month",
year: "Year",
timeSelect: "select time",
dateSelect: "select date",
weekSelect: "Choose a week",
monthSelect: "Choose a month",
yearSelect: "Choose a year",
decadeSelect: "Choose a decade",
dateFormat: "M/D/YYYY",
dateTimeFormat: "M/D/YYYY HH:mm:ss",
previousMonth: "Previous month (PageUp)",
nextMonth: "Next month (PageDown)",
previousYear: "Last year (Control + left)",
nextYear: "Next year (Control + right)",
previousDecade: "Last decade",
nextDecade: "Next decade",
previousCentury: "Last century",
nextCentury: "Next century"
});
const locale$1 = {
placeholder: "Select time",
rangePlaceholder: ["Start time", "End time"]
};
const locale = {
lang: Object.assign({
placeholder: "Select date",
yearPlaceholder: "Select year",
quarterPlaceholder: "Select quarter",
monthPlaceholder: "Select month",
weekPlaceholder: "Select week",
rangePlaceholder: ["Start date", "End date"],
rangeYearPlaceholder: ["Start year", "End year"],
rangeQuarterPlaceholder: ["Start quarter", "End quarter"],
rangeMonthPlaceholder: ["Start month", "End month"],
rangeWeekPlaceholder: ["Start week", "End week"]
}, locale$2),
timePickerLocale: Object.assign({}, locale$1)
};
const typeTemplate = "${label} is not a valid ${type}";
const localeValues = {
locale: "en",
Pagination: locale$3,
DatePicker: locale,
TimePicker: locale$1,
Calendar: locale,
global: {
placeholder: "Please select"
},
Table: {
filterTitle: "Filter menu",
filterConfirm: "OK",
filterReset: "Reset",
filterEmptyText: "No filters",
filterCheckall: "Select all items",
filterSearchPlaceholder: "Search in filters",
emptyText: "No data",
selectAll: "Select current page",
selectInvert: "Invert current page",
selectNone: "Clear all data",
selectionAll: "Select all data",
sortTitle: "Sort",
expand: "Expand row",
collapse: "Collapse row",
triggerDesc: "Click to sort descending",
triggerAsc: "Click to sort ascending",
cancelSort: "Click to cancel sorting"
},
Tour: {
Next: "Next",
Previous: "Previous",
Finish: "Finish"
},
Modal: {
okText: "OK",
cancelText: "Cancel",
justOkText: "OK"
},
Popconfirm: {
okText: "OK",
cancelText: "Cancel"
},
Transfer: {
titles: ["", ""],
searchPlaceholder: "Search here",
itemUnit: "item",
itemsUnit: "items",
remove: "Remove",
selectCurrent: "Select current page",
removeCurrent: "Remove current page",
selectAll: "Select all data",
deselectAll: "Deselect all data",
removeAll: "Remove all data",
selectInvert: "Invert current page"
},
Upload: {
uploading: "Uploading...",
removeFile: "Remove file",
uploadError: "Upload error",
previewFile: "Preview file",
downloadFile: "Download file"
},
Empty: {
description: "No data"
},
Icon: {
icon: "icon"
},
Text: {
edit: "Edit",
copy: "Copy",
copied: "Copied",
expand: "Expand",
collapse: "Collapse"
},
Form: {
optional: "(optional)",
defaultValidateMessages: {
default: "Field validation error for ${label}",
required: "Please enter ${label}",
enum: "${label} must be one of [${enum}]",
whitespace: "${label} cannot be a blank character",
date: {
format: "${label} date format is invalid",
parse: "${label} cannot be converted to a date",
invalid: "${label} is an invalid date"
},
types: {
string: typeTemplate,
method: typeTemplate,
array: typeTemplate,
object: typeTemplate,
number: typeTemplate,
date: typeTemplate,
boolean: typeTemplate,
integer: typeTemplate,
float: typeTemplate,
regexp: typeTemplate,
email: typeTemplate,
url: typeTemplate,
hex: typeTemplate
},
string: {
len: "${label} must be ${len} characters",
min: "${label} must be at least ${min} characters",
max: "${label} must be up to ${max} characters",
range: "${label} must be between ${min}-${max} characters"
},
number: {
len: "${label} must be equal to ${len}",
min: "${label} must be minimum ${min}",
max: "${label} must be maximum ${max}",
range: "${label} must be between ${min}-${max}"
},
array: {
len: "Must be ${len} ${label}",
min: "At least ${min} ${label}",
max: "At most ${max} ${label}",
range: "The amount of ${label} must be between ${min}-${max}"
},
pattern: {
mismatch: "${label} does not match the pattern ${pattern}"
}
}
},
Image: {
preview: "Preview"
},
QRCode: {
expired: "QR code expired",
refresh: "Refresh",
scanned: "Scanned"
},
ColorPicker: {
presetEmpty: "Empty"
}
};
Object.assign({}, localeValues.Modal);
let localeList = [];
const generateLocale = () => localeList.reduce((merged, locale2) => Object.assign(Object.assign({}, merged), locale2), localeValues.Modal);
function changeConfirmLocale(newLocale) {
if (newLocale) {
const cloneLocale = Object.assign({}, newLocale);
localeList.push(cloneLocale);
generateLocale();
return () => {
localeList = localeList.filter((locale2) => locale2 !== cloneLocale);
generateLocale();
};
}
Object.assign({}, localeValues.Modal);
}
const LocaleContext = /* @__PURE__ */ createContext(void 0);
const useLocale = (componentName, defaultLocale) => {
const fullLocale = React.useContext(LocaleContext);
const getLocale = React.useMemo(() => {
var _a;
const locale2 = defaultLocale || localeValues[componentName];
const localeFromContext = (_a = fullLocale === null || fullLocale === void 0 ? void 0 : fullLocale[componentName]) !== null && _a !== void 0 ? _a : {};
return Object.assign(Object.assign({}, typeof locale2 === "function" ? locale2() : locale2), localeFromContext || {});
}, [componentName, defaultLocale, fullLocale]);
const getLocaleCode = React.useMemo(() => {
const localeCode = fullLocale === null || fullLocale === void 0 ? void 0 : fullLocale.locale;
if ((fullLocale === null || fullLocale === void 0 ? void 0 : fullLocale.exist) && !localeCode) {
return localeValues.locale;
}
return localeCode;
}, [fullLocale]);
return [getLocale, getLocaleCode];
};
const ANT_MARK = "internalMark";
const LocaleProvider = (props) => {
const {
locale: locale2 = {},
children,
_ANT_MARK__
} = props;
if (process.env.NODE_ENV !== "production") {
const warning3 = devUseWarning("LocaleProvider");
process.env.NODE_ENV !== "production" ? warning3(_ANT_MARK__ === ANT_MARK, "deprecated", "`LocaleProvider` is deprecated. Please use `locale` with `ConfigProvider` instead: http://u.ant.design/locale") : void 0;
}
React.useEffect(() => {
const clearLocale = changeConfirmLocale(locale2 === null || locale2 === void 0 ? void 0 : locale2.Modal);
return clearLocale;
}, [locale2]);
const getMemoizedContextValue = React.useMemo(() => Object.assign(Object.assign({}, locale2), {
exist: true
}), [locale2]);
return /* @__PURE__ */ React.createElement(LocaleContext.Provider, {
value: getMemoizedContextValue
}, children);
};
if (process.env.NODE_ENV !== "production") {
LocaleProvider.displayName = "LocaleProvider";
}
const defaultPresetColors = {
blue: "#1677FF",
purple: "#722ED1",
cyan: "#13C2C2",
green: "#52C41A",
magenta: "#EB2F96",
/**
* @deprecated Use magenta instead
*/
pink: "#EB2F96",
red: "#F5222D",
orange: "#FA8C16",
yellow: "#FADB14",
volcano: "#FA541C",
geekblue: "#2F54EB",
gold: "#FAAD14",
lime: "#A0D911"
};
const seedToken = Object.assign(Object.assign({}, defaultPresetColors), {
// Color
colorPrimary: "#1677ff",
colorSuccess: "#52c41a",
colorWarning: "#faad14",
colorError: "#ff4d4f",
colorInfo: "#1677ff",
colorLink: "",
colorTextBase: "",
colorBgBase: "",
// Font
fontFamily: `-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
'Noto Color Emoji'`,
fontFamilyCode: `'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace`,
fontSize: 14,
// Line
lineWidth: 1,
lineType: "solid",
// Motion
motionUnit: 0.1,
motionBase: 0,
motionEaseOutCirc: "cubic-bezier(0.08, 0.82, 0.17, 1)",
motionEaseInOutCirc: "cubic-bezier(0.78, 0.14, 0.15, 0.86)",
motionEaseOut: "cubic-bezier(0.215, 0.61, 0.355, 1)",
motionEaseInOut: "cubic-bezier(0.645, 0.045, 0.355, 1)",
motionEaseOutBack: "cubic-bezier(0.12, 0.4, 0.29, 1.46)",
motionEaseInBack: "cubic-bezier(0.71, -0.46, 0.88, 0.6)",
motionEaseInQuint: "cubic-bezier(0.755, 0.05, 0.855, 0.06)",
motionEaseOutQuint: "cubic-bezier(0.23, 1, 0.32, 1)",
// Radius
borderRadius: 6,
// Size
sizeUnit: 4,
sizeStep: 4,
sizePopupArrow: 16,
// Control Base
controlHeight: 32,
// zIndex
zIndexBase: 0,
zIndexPopupBase: 1e3,
// Image
opacityImage: 1,
// Wireframe
wireframe: false,
// Motion
motion: true
});
function genColorMapToken(seed, _ref) {
let {
generateColorPalettes: generateColorPalettes2,
generateNeutralColorPalettes: generateNeutralColorPalettes2
} = _ref;
const {
colorSuccess: colorSuccessBase,
colorWarning: colorWarningBase,
colorError: colorErrorBase,
colorInfo: colorInfoBase,
colorPrimary: colorPrimaryBase,
colorBgBase,
colorTextBase
} = seed;
const primaryColors = generateColorPalettes2(colorPrimaryBase);
const successColors = generateColorPalettes2(colorSuccessBase);
const warningColors = generateColorPalettes2(colorWarningBase);
const errorColors = generateColorPalettes2(colorErrorBase);
const infoColors = generateColorPalettes2(colorInfoBase);
const neutralColors = generateNeutralColorPalettes2(colorBgBase, colorTextBase);
const colorLink = seed.colorLink || seed.colorInfo;
const linkColors = generateColorPalettes2(colorLink);
return Object.assign(Object.assign({}, neutralColors), {
colorPrimaryBg: primaryColors[1],
colorPrimaryBgHover: primaryColors[2],
colorPrimaryBorder: primaryColors[3],
colorPrimaryBorderHover: primaryColors[4],
colorPrimaryHover: primaryColors[5],
colorPrimary: primaryColors[6],
colorPrimaryActive: primaryColors[7],
colorPrimaryTextHover: primaryColors[8],
colorPrimaryText: primaryColors[9],
colorPrimaryTextActive: primaryColors[10],
colorSuccessBg: successColors[1],
colorSuccessBgHover: successColors[2],
colorSuccessBorder: successColors[3],
colorSuccessBorderHover: successColors[4],
colorSuccessHover: successColors[4],
colorSuccess: successColors[6],
colorSuccessActive: successColors[7],
colorSuccessTextHover: successColors[8],
colorSuccessText: successColors[9],
colorSuccessTextActive: successColors[10],
colorErrorBg: errorColors[1],
colorErrorBgHover: errorColors[2],
colorErrorBgActive: errorColors[3],
colorErrorBorder: errorColors[3],
colorErrorBorderHover: errorColors[4],
colorErrorHover: errorColors[5],
colorError: errorColors[6],
colorErrorActive: errorColors[7],
colorErrorTextHover: errorColors[8],
colorErrorText: errorColors[9],
colorErrorTextActive: errorColors[10],
colorWarningBg: warningColors[1],
colorWarningBgHover: warningColors[2],
colorWarningBorder: warningColors[3],
colorWarningBorderHover: warningColors[4],
colorWarningHover: warningColors[4],
colorWarning: warningColors[6],
colorWarningActive: warningColors[7],
colorWarningTextHover: warningColors[8],
colorWarningText: warningColors[9],
colorWarningTextActive: warningColors[10],
colorInfoBg: infoColors[1],
colorInfoBgHover: infoColors[2],
colorInfoBorder: infoColors[3],
colorInfoBorderHover: infoColors[4],
colorInfoHover: infoColors[4],
colorInfo: infoColors[6],
colorInfoActive: infoColors[7],
colorInfoTextHover: infoColors[8],
colorInfoText: infoColors[9],
colorInfoTextActive: infoColors[10],
colorLinkHover: linkColors[4],
colorLink: linkColors[6],
colorLinkActive: linkColors[7],
colorBgMask: new TinyColor("#000").setAlpha(0.45).toRgbString(),
colorWhite: "#fff"
});
}
const genRadius = (radiusBase) => {
let radiusLG = radiusBase;
let radiusSM = radiusBase;
let radiusXS = radiusBase;
let radiusOuter = radiusBase;
if (radiusBase < 6 && radiusBase >= 5) {
radiusLG = radiusBase + 1;
} else if (radiusBase < 16 && radiusBase >= 6) {
radiusLG = radiusBase + 2;
} else if (radiusBase >= 16) {
radiusLG = 16;
}
if (radiusBase < 7 && radiusBase >= 5) {
radiusSM = 4;
} else if (radiusBase < 8 && radiusBase >= 7) {
radiusSM = 5;
} else if (radiusBase < 14 && radiusBase >= 8) {
radiusSM = 6;
} else if (radiusBase < 16 && radiusBase >= 14) {
radiusSM = 7;
} else if (radiusBase >= 16) {
radiusSM = 8;
}
if (radiusBase < 6 && radiusBase >= 2) {
radiusXS = 1;
} else if (radiusBase >= 6) {
radiusXS = 2;
}
if (radiusBase > 4 && radiusBase < 8) {
radiusOuter = 4;
} else if (radiusBase >= 8) {
radiusOuter = 6;
}
return {
borderRadius: radiusBase,
borderRadiusXS: radiusXS,
borderRadiusSM: radiusSM,
borderRadiusLG: radiusLG,
borderRadiusOuter: radiusOuter
};
};
function genCommonMapToken(token2) {
const {
motionUnit,
motionBase,
borderRadius,
lineWidth
} = token2;
return Object.assign({
// motion
motionDurationFast: `${(motionBase + motionUnit).toFixed(1)}s`,
motionDurationMid: `${(motionBase + motionUnit * 2).toFixed(1)}s`,
motionDurationSlow: `${(motionBase + motionUnit * 3).toFixed(1)}s`,
// line
lineWidthBold: lineWidth + 1
}, genRadius(borderRadius));
}
const genControlHeight = (token2) => {
const {
controlHeight
} = token2;
return {
controlHeightSM: controlHeight * 0.75,
controlHeightXS: controlHeight * 0.5,
controlHeightLG: controlHeight * 1.25
};
};
function getLineHeight(fontSize) {
return (fontSize + 8) / fontSize;
}
function getFontSizes(base) {
const fontSizes = new Array(10).fill(null).map((_, index2) => {
const i = index2 - 1;
const baseSize = base * Math.pow(Math.E, i / 5);
const intSize = index2 > 1 ? Math.floor(baseSize) : Math.ceil(baseSize);
return Math.floor(intSize / 2) * 2;
});
fontSizes[1] = base;
return fontSizes.map((size) => ({
size,
lineHeight: getLineHeight(size)
}));
}
const genFontMapToken = (fontSize) => {
const fontSizePairs = getFontSizes(fontSize);
const fontSizes = fontSizePairs.map((pair) => pair.size);
const lineHeights = fontSizePairs.map((pair) => pair.lineHeight);
const fontSizeMD = fontSizes[1];
const fontSizeSM = fontSizes[0];
const fontSizeLG = fontSizes[2];
const lineHeight = lineHeights[1];
const lineHeightSM = lineHeights[0];
const lineHeightLG = lineHeights[2];
return {
fontSizeSM,
fontSize: fontSizeMD,
fontSizeLG,
fontSizeXL: fontSizes[3],
fontSizeHeading1: fontSizes[6],
fontSizeHeading2: fontSizes[5],
fontSizeHeading3: fontSizes[4],
fontSizeHeading4: fontSizes[3],
fontSizeHeading5: fontSizes[2],
lineHeight,
lineHeightLG,
lineHeightSM,
fontHeight: Math.round(lineHeight * fontSizeMD),
fontHeightLG: Math.round(lineHeightLG * fontSizeLG),
fontHeightSM: Math.round(lineHeightSM * fontSizeSM),
lineHeightHeading1: lineHeights[6],
lineHeightHeading2: lineHeights[5],
lineHeightHeading3: lineHeights[4],
lineHeightHeading4: lineHeights[3],
lineHeightHeading5: lineHeights[2]
};
};
function genSizeMapToken(token2) {
const {
sizeUnit,
sizeStep
} = token2;
return {
sizeXXL: sizeUnit * (sizeStep + 8),
// 48
sizeXL: sizeUnit * (sizeStep + 4),
// 32
sizeLG: sizeUnit * (sizeStep + 2),
// 24
sizeMD: sizeUnit * (sizeStep + 1),
// 20
sizeMS: sizeUnit * sizeStep,
// 16
size: sizeUnit * sizeStep,
// 16
sizeSM: sizeUnit * (sizeStep - 1),
// 12
sizeXS: sizeUnit * (sizeStep - 2),
// 8
sizeXXS: sizeUnit * (sizeStep - 3)
// 4
};
}
const getAlphaColor$1 = (baseColor, alpha) => new TinyColor(baseColor).setAlpha(alpha).toRgbString();
const getSolidColor = (baseColor, brightness) => {
const instance = new TinyColor(baseColor);
return instance.darken(brightness).toHexString();
};
const generateColorPalettes = (baseColor) => {
const colors = generate$1(baseColor);
return {
1: colors[0],
2: colors[1],
3: colors[2],
4: colors[3],
5: colors[4],
6: colors[5],
7: colors[6],
8: colors[4],
9: colors[5],
10: colors[6]
// 8: colors[7],
// 9: colors[8],
// 10: colors[9],
};
};
const generateNeutralColorPalettes = (bgBaseColor, textBaseColor) => {
const colorBgBase = bgBaseColor || "#fff";
const colorTextBase = textBaseColor || "#000";
return {
colorBgBase,
colorTextBase,
colorText: getAlphaColor$1(colorTextBase, 0.88),
colorTextSecondary: getAlphaColor$1(colorTextBase, 0.65),
colorTextTertiary: getAlphaColor$1(colorTextBase, 0.45),
colorTextQuaternary: getAlphaColor$1(colorTextBase, 0.25),
colorFill: getAlphaColor$1(colorTextBase, 0.15),
colorFillSecondary: getAlphaColor$1(colorTextBase, 0.06),
colorFillTertiary: getAlphaColor$1(colorTextBase, 0.04),
colorFillQuaternary: getAlphaColor$1(colorTextBase, 0.02),
colorBgLayout: getSolidColor(colorBgBase, 4),
colorBgContainer: getSolidColor(colorBgBase, 0),
colorBgElevated: getSolidColor(colorBgBase, 0),
colorBgSpotlight: getAlphaColor$1(colorTextBase, 0.85),
colorBgBlur: "transparent",
colorBorder: getSolidColor(colorBgBase, 15),
colorBorderSecondary: getSolidColor(colorBgBase, 6)
};
};
function derivative(token2) {
presetPrimaryColors.pink = presetPrimaryColors.magenta;
presetPalettes.pink = presetPalettes.magenta;
const colorPalettes = Object.keys(defaultPresetColors).map((colorKey) => {
const colors = token2[colorKey] === presetPrimaryColors[colorKey] ? presetPalettes[colorKey] : generate$1(token2[colorKey]);
return new Array(10).fill(1).reduce((prev2, _, i) => {
prev2[`${colorKey}-${i + 1}`] = colors[i];
prev2[`${colorKey}${i + 1}`] = colors[i];
return prev2;
}, {});
}).reduce((prev2, cur) => {
prev2 = Object.assign(Object.assign({}, prev2), cur);
return prev2;
}, {});
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, token2), colorPalettes), genColorMapToken(token2, {
generateColorPalettes,
generateNeutralColorPalettes
})), genFontMapToken(token2.fontSize)), genSizeMapToken(token2)), genControlHeight(token2)), genCommonMapToken(token2));
}
const defaultTheme = createTheme(derivative);
const defaultConfig = {
token: seedToken,
override: {
override: seedToken
},
hashed: true
};
const DesignTokenContext = /* @__PURE__ */ React__default.createContext(defaultConfig);
const defaultIconPrefixCls = "anticon";
const Variants = ["outlined", "borderless", "filled"];
const defaultGetPrefixCls = (suffixCls, customizePrefixCls) => {
if (customizePrefixCls) {
return customizePrefixCls;
}
return suffixCls ? `ant-${suffixCls}` : "ant";
};
const ConfigContext = /* @__PURE__ */ React.createContext({
// We provide a default function for Context without provider
getPrefixCls: defaultGetPrefixCls,
iconPrefixCls: defaultIconPrefixCls
});
const dynamicStyleMark = `-ant-${Date.now()}-${Math.random()}`;
function getStyle(globalPrefixCls2, theme) {
const variables = {};
const formatColor = (color, updater) => {
let clone = color.clone();
clone = (updater === null || updater === void 0 ? void 0 : updater(clone)) || clone;
return clone.toRgbString();
};
const fillColor = (colorVal, type4) => {
const baseColor = new TinyColor(colorVal);
const colorPalettes = generate$1(baseColor.toRgbString());
variables[`${type4}-color`] = formatColor(baseColor);
variables[`${type4}-color-disabled`] = colorPalettes[1];
variables[`${type4}-color-hover`] = colorPalettes[4];
variables[`${type4}-color-active`] = colorPalettes[6];
variables[`${type4}-color-outline`] = baseColor.clone().setAlpha(0.2).toRgbString();
variables[`${type4}-color-deprecated-bg`] = colorPalettes[0];
variables[`${type4}-color-deprecated-border`] = colorPalettes[2];
};
if (theme.primaryColor) {
fillColor(theme.primaryColor, "primary");
const primaryColor = new TinyColor(theme.primaryColor);
const primaryColors = generate$1(primaryColor.toRgbString());
primaryColors.forEach((color, index2) => {
variables[`primary-${index2 + 1}`] = color;
});
variables["primary-color-deprecated-l-35"] = formatColor(primaryColor, (c) => c.lighten(35));
variables["primary-color-deprecated-l-20"] = formatColor(primaryColor, (c) => c.lighten(20));
variables["primary-color-deprecated-t-20"] = formatColor(primaryColor, (c) => c.tint(20));
variables["primary-color-deprecated-t-50"] = formatColor(primaryColor, (c) => c.tint(50));
variables["primary-color-deprecated-f-12"] = formatColor(primaryColor, (c) => c.setAlpha(c.getAlpha() * 0.12));
const primaryActiveColor = new TinyColor(primaryColors[0]);
variables["primary-color-active-deprecated-f-30"] = formatColor(primaryActiveColor, (c) => c.setAlpha(c.getAlpha() * 0.3));
variables["primary-color-active-deprecated-d-02"] = formatColor(primaryActiveColor, (c) => c.darken(2));
}
if (theme.successColor) {
fillColor(theme.successColor, "success");
}
if (theme.warningColor) {
fillColor(theme.warningColor, "warning");
}
if (theme.errorColor) {
fillColor(theme.errorColor, "error");
}
if (theme.infoColor) {
fillColor(theme.infoColor, "info");
}
const cssList = Object.keys(variables).map((key) => `--${globalPrefixCls2}-${key}: ${variables[key]};`);
return `
:root {
${cssList.join("\n")}
}
`.trim();
}
function registerTheme(globalPrefixCls2, theme) {
const style2 = getStyle(globalPrefixCls2, theme);
if (canUseDom()) {
updateCSS(style2, `${dynamicStyleMark}-dynamic-theme`);
} else {
process.env.NODE_ENV !== "production" ? warning$1(false, "ConfigProvider", "SSR do not support dynamic theme with css variables.") : void 0;
}
}
const DisabledContext = /* @__PURE__ */ React.createContext(false);
const DisabledContextProvider = (_ref) => {
let {
children,
disabled
} = _ref;
const originDisabled = React.useContext(DisabledContext);
return /* @__PURE__ */ React.createElement(DisabledContext.Provider, {
value: disabled !== null && disabled !== void 0 ? disabled : originDisabled
}, children);
};
const SizeContext = /* @__PURE__ */ React.createContext(void 0);
const SizeContextProvider = (_ref) => {
let {
children,
size
} = _ref;
const originSize = React.useContext(SizeContext);
return /* @__PURE__ */ React.createElement(SizeContext.Provider, {
value: size || originSize
}, children);
};
function useConfig() {
const componentDisabled = useContext(DisabledContext);
const componentSize = useContext(SizeContext);
return {
componentDisabled,
componentSize
};
}
const version$1 = "5.19.1";
function isStableColor(color) {
return color >= 0 && color <= 255;
}
function getAlphaColor(frontColor, backgroundColor) {
const {
r: fR,
g: fG,
b: fB,
a: originAlpha
} = new TinyColor(frontColor).toRgb();
if (originAlpha < 1) {
return frontColor;
}
const {
r: bR,
g: bG,
b: bB
} = new TinyColor(backgroundColor).toRgb();
for (let fA = 0.01; fA <= 1; fA += 0.01) {
const r = Math.round((fR - bR * (1 - fA)) / fA);
const g = Math.round((fG - bG * (1 - fA)) / fA);
const b = Math.round((fB - bB * (1 - fA)) / fA);
if (isStableColor(r) && isStableColor(g) && isStableColor(b)) {
return new TinyColor({
r,
g,
b,
a: Math.round(fA * 100) / 100
}).toRgbString();
}
}
return new TinyColor({
r: fR,
g: fG,
b: fB,
a: 1
}).toRgbString();
}
var __rest$6 = function(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
}
return t;
};
function formatToken(derivativeToken) {
const {
override
} = derivativeToken, restToken = __rest$6(derivativeToken, ["override"]);
const overrideTokens = Object.assign({}, override);
Object.keys(seedToken).forEach((token2) => {
delete overrideTokens[token2];
});
const mergedToken = Object.assign(Object.assign({}, restToken), overrideTokens);
const screenXS = 480;
const screenSM = 576;
const screenMD = 768;
const screenLG = 992;
const screenXL = 1200;
const screenXXL = 1600;
if (mergedToken.motion === false) {
const fastDuration = "0s";
mergedToken.motionDurationFast = fastDuration;
mergedToken.motionDurationMid = fastDuration;
mergedToken.motionDurationSlow = fastDuration;
}
const aliasToken = Object.assign(Object.assign(Object.assign({}, mergedToken), {
// ============== Background ============== //
colorFillContent: mergedToken.colorFillSecondary,
colorFillContentHover: mergedToken.colorFill,
colorFillAlter: mergedToken.colorFillQuaternary,
colorBgContainerDisabled: mergedToken.colorFillTertiary,
// ============== Split ============== //
colorBorderBg: mergedToken.colorBgContainer,
colorSplit: getAlphaColor(mergedToken.colorBorderSecondary, mergedToken.colorBgContainer),
// ============== Text ============== //
colorTextPlaceholder: mergedToken.colorTextQuaternary,
colorTextDisabled: mergedToken.colorTextQuaternary,
colorTextHeading: mergedToken.colorText,
colorTextLabel: mergedToken.colorTextSecondary,
colorTextDescription: mergedToken.colorTextTertiary,
colorTextLightSolid: mergedToken.colorWhite,
colorHighlight: mergedToken.colorError,
colorBgTextHover: mergedToken.colorFillSecondary,
colorBgTextActive: mergedToken.colorFill,
colorIcon: mergedToken.colorTextTertiary,
colorIconHover: mergedToken.colorText,
colorErrorOutline: getAlphaColor(mergedToken.colorErrorBg, mergedToken.colorBgContainer),
colorWarningOutline: getAlphaColor(mergedToken.colorWarningBg, mergedToken.colorBgContainer),
// Font
fontSizeIcon: mergedToken.fontSizeSM,
// Line
lineWidthFocus: mergedToken.lineWidth * 4,
// Control
lineWidth: mergedToken.lineWidth,
controlOutlineWidth: mergedToken.lineWidth * 2,
// Checkbox size and expand icon size
controlInteractiveSize: mergedToken.controlHeight / 2,
controlItemBgHover: mergedToken.colorFillTertiary,
controlItemBgActive: mergedToken.colorPrimaryBg,
controlItemBgActiveHover: mergedToken.colorPrimaryBgHover,
controlItemBgActiveDisabled: mergedToken.colorFill,
controlTmpOutline: mergedToken.colorFillQuaternary,
controlOutline: getAlphaColor(mergedToken.colorPrimaryBg, mergedToken.colorBgContainer),
lineType: mergedToken.lineType,
borderRadius: mergedToken.borderRadius,
borderRadiusXS: mergedToken.borderRadiusXS,
borderRadiusSM: mergedToken.borderRadiusSM,
borderRadiusLG: mergedToken.borderRadiusLG,
fontWeightStrong: 600,
opacityLoading: 0.65,
linkDecoration: "none",
linkHoverDecoration: "none",
linkFocusDecoration: "none",
controlPaddingHorizontal: 12,
controlPaddingHorizontalSM: 8,
paddingXXS: mergedToken.sizeXXS,
paddingXS: mergedToken.sizeXS,
paddingSM: mergedToken.sizeSM,
padding: mergedToken.size,
paddingMD: mergedToken.sizeMD,
paddingLG: mergedToken.sizeLG,
paddingXL: mergedToken.sizeXL,
paddingContentHorizontalLG: mergedToken.sizeLG,
paddingContentVerticalLG: mergedToken.sizeMS,
paddingContentHorizontal: mergedToken.sizeMS,
paddingContentVertical: mergedToken.sizeSM,
paddingContentHorizontalSM: mergedToken.size,
paddingContentVerticalSM: mergedToken.sizeXS,
marginXXS: mergedToken.sizeXXS,
marginXS: mergedToken.sizeXS,
marginSM: mergedToken.sizeSM,
margin: mergedToken.size,
marginMD: mergedToken.sizeMD,
marginLG: mergedToken.sizeLG,
marginXL: mergedToken.sizeXL,
marginXXL: mergedToken.sizeXXL,
boxShadow: `
0 6px 16px 0 rgba(0, 0, 0, 0.08),
0 3px 6px -4px rgba(0, 0, 0, 0.12),
0 9px 28px 8px rgba(0, 0, 0, 0.05)
`,
boxShadowSecondary: `
0 6px 16px 0 rgba(0, 0, 0, 0.08),
0 3px 6px -4px rgba(0, 0, 0, 0.12),
0 9px 28px 8px rgba(0, 0, 0, 0.05)
`,
boxShadowTertiary: `
0 1px 2px 0 rgba(0, 0, 0, 0.03),
0 1px 6px -1px rgba(0, 0, 0, 0.02),
0 2px 4px 0 rgba(0, 0, 0, 0.02)
`,
screenXS,
screenXSMin: screenXS,
screenXSMax: screenSM - 1,
screenSM,
screenSMMin: screenSM,
screenSMMax: screenMD - 1,
screenMD,
screenMDMin: screenMD,
screenMDMax: screenLG - 1,
screenLG,
screenLGMin: screenLG,
screenLGMax: screenXL - 1,
screenXL,
screenXLMin: screenXL,
screenXLMax: screenXXL - 1,
screenXXL,
screenXXLMin: screenXXL,
boxShadowPopoverArrow: "2px 2px 5px rgba(0, 0, 0, 0.05)",
boxShadowCard: `
0 1px 2px -2px ${new TinyColor("rgba(0, 0, 0, 0.16)").toRgbString()},
0 3px 6px 0 ${new TinyColor("rgba(0, 0, 0, 0.12)").toRgbString()},
0 5px 12px 4px ${new TinyColor("rgba(0, 0, 0, 0.09)").toRgbString()}
`,
boxShadowDrawerRight: `
-6px 0 16px 0 rgba(0, 0, 0, 0.08),
-3px 0 6px -4px rgba(0, 0, 0, 0.12),
-9px 0 28px 8px rgba(0, 0, 0, 0.05)
`,
boxShadowDrawerLeft: `
6px 0 16px 0 rgba(0, 0, 0, 0.08),
3px 0 6px -4px rgba(0, 0, 0, 0.12),
9px 0 28px 8px rgba(0, 0, 0, 0.05)
`,
boxShadowDrawerUp: `
0 6px 16px 0 rgba(0, 0, 0, 0.08),
0 3px 6px -4px rgba(0, 0, 0, 0.12),
0 9px 28px 8px rgba(0, 0, 0, 0.05)
`,
boxShadowDrawerDown: `
0 -6px 16px 0 rgba(0, 0, 0, 0.08),
0 -3px 6px -4px rgba(0, 0, 0, 0.12),
0 -9px 28px 8px rgba(0, 0, 0, 0.05)
`,
boxShadowTabsOverflowLeft: "inset 10px 0 8px -8px rgba(0, 0, 0, 0.08)",
boxShadowTabsOverflowRight: "inset -10px 0 8px -8px rgba(0, 0, 0, 0.08)",
boxShadowTabsOverflowTop: "inset 0 10px 8px -8px rgba(0, 0, 0, 0.08)",
boxShadowTabsOverflowBottom: "inset 0 -10px 8px -8px rgba(0, 0, 0, 0.08)"
}), overrideTokens);
return aliasToken;
}
var __rest$5 = function(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
}
return t;
};
const unitless = {
lineHeight: true,
lineHeightSM: true,
lineHeightLG: true,
lineHeightHeading1: true,
lineHeightHeading2: true,
lineHeightHeading3: true,
lineHeightHeading4: true,
lineHeightHeading5: true,
opacityLoading: true,
fontWeightStrong: true,
zIndexPopupBase: true,
zIndexBase: true
};
const ignore = {
size: true,
sizeSM: true,
sizeLG: true,
sizeMD: true,
sizeXS: true,
sizeXXS: true,
sizeMS: true,
sizeXL: true,
sizeXXL: true,
sizeUnit: true,
sizeStep: true,
motionBase: true,
motionUnit: true
};
const preserve = {
screenXS: true,
screenXSMin: true,
screenXSMax: true,
screenSM: true,
screenSMMin: true,
screenSMMax: true,
screenMD: true,
screenMDMin: true,
screenMDMax: true,
screenLG: true,
screenLGMin: true,
screenLGMax: true,
screenXL: true,
screenXLMin: true,
screenXLMax: true,
screenXXL: true,
screenXXLMin: true
};
const getComputedToken2 = (originToken, overrideToken, theme) => {
const derivativeToken = theme.getDerivativeToken(originToken);
const {
override
} = overrideToken, components = __rest$5(overrideToken, ["override"]);
let mergedDerivativeToken = Object.assign(Object.assign({}, derivativeToken), {
override
});
mergedDerivativeToken = formatToken(mergedDerivativeToken);
if (components) {
Object.entries(components).forEach((_ref) => {
let [key, value] = _ref;
const {
theme: componentTheme
} = value, componentTokens = __rest$5(value, ["theme"]);
let mergedComponentToken = componentTokens;
if (componentTheme) {
mergedComponentToken = getComputedToken2(Object.assign(Object.assign({}, mergedDerivativeToken), componentTokens), {
override: componentTokens
}, componentTheme);
}
mergedDerivativeToken[key] = mergedComponentToken;
});
}
return mergedDerivativeToken;
};
function useToken() {
const {
token: rootDesignToken,
hashed,
theme,
override,
cssVar
} = React__default.useContext(DesignTokenContext);
const salt = `${version$1}-${hashed || ""}`;
const mergedTheme = theme || defaultTheme;
const [token2, hashId, realToken] = useCacheToken(mergedTheme, [seedToken, rootDesignToken], {
salt,
override,
getComputedToken: getComputedToken2,
// formatToken will not be consumed after 1.15.0 with getComputedToken.
// But token will break if @ant-design/cssinjs is under 1.15.0 without it
formatToken,
cssVar: cssVar && {
prefix: cssVar.prefix,
key: cssVar.key,
unitless,
ignore,
preserve
}
});
return [mergedTheme, realToken, hashed ? hashId : "", token2, cssVar];
}
const BEAT_LIMIT = 1e3 * 60 * 10;
let ArrayKeyMap = /* @__PURE__ */ function() {
function ArrayKeyMap2() {
_classCallCheck(this, ArrayKeyMap2);
this.map = /* @__PURE__ */ new Map();
this.objectIDMap = /* @__PURE__ */ new WeakMap();
this.nextID = 0;
this.lastAccessBeat = /* @__PURE__ */ new Map();
this.accessBeat = 0;
}
return _createClass(ArrayKeyMap2, [{
key: "set",
value: function set2(keys2, value) {
this.clear();
const compositeKey = this.getCompositeKey(keys2);
this.map.set(compositeKey, value);
this.lastAccessBeat.set(compositeKey, Date.now());
}
}, {
key: "get",
value: function get2(keys2) {
const compositeKey = this.getCompositeKey(keys2);
const cache = this.map.get(compositeKey);
this.lastAccessBeat.set(compositeKey, Date.now());
this.accessBeat += 1;
return cache;
}
}, {
key: "getCompositeKey",
value: function getCompositeKey(keys2) {
const ids = keys2.map((key) => {
if (key && typeof key === "object") {
return `obj_${this.getObjectID(key)}`;
}
return `${typeof key}_${key}`;
});
return ids.join("|");
}
}, {
key: "getObjectID",
value: function getObjectID(obj) {
if (this.objectIDMap.has(obj)) {
return this.objectIDMap.get(obj);
}
const id = this.nextID;
this.objectIDMap.set(obj, id);
this.nextID += 1;
return id;
}
}, {
key: "clear",
value: function clear() {
if (this.accessBeat > 1e4) {
const now = Date.now();
this.lastAccessBeat.forEach((beat, key) => {
if (now - beat > BEAT_LIMIT) {
this.map.delete(key);
this.lastAccessBeat.delete(key);
}
});
this.accessBeat = 0;
}
}
}]);
}();
const uniqueMap = new ArrayKeyMap();
function useUniqueMemo(memoFn, deps) {
return React__default.useMemo(() => {
const cachedValue = uniqueMap.get(deps);
if (cachedValue) {
return cachedValue;
}
const newValue = memoFn();
uniqueMap.set(deps, newValue);
return newValue;
}, deps);
}
const textEllipsis = {
overflow: "hidden",
whiteSpace: "nowrap",
textOverflow: "ellipsis"
};
const resetComponent = function(token2) {
let needInheritFontFamily = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
return {
boxSizing: "border-box",
margin: 0,
padding: 0,
color: token2.colorText,
fontSize: token2.fontSize,
// font-variant: @font-variant-base;
lineHeight: token2.lineHeight,
listStyle: "none",
// font-feature-settings: @font-feature-settings-base;
fontFamily: needInheritFontFamily ? "inherit" : token2.fontFamily
};
};
const resetIcon = () => ({
display: "inline-flex",
alignItems: "center",
color: "inherit",
fontStyle: "normal",
lineHeight: 0,
textAlign: "center",
textTransform: "none",
// for SVG icon, see https://blog.prototypr.io/align-svg-icons-to-text-and-say-goodbye-to-font-icons-d44b3d7b26b4
verticalAlign: "-0.125em",
textRendering: "optimizeLegibility",
"-webkit-font-smoothing": "antialiased",
"-moz-osx-font-smoothing": "grayscale",
"> *": {
lineHeight: 1
},
svg: {
display: "inline-block"
}
});
const clearFix = () => ({
// https://github.com/ant-design/ant-design/issues/21301#issuecomment-583955229
"&::before": {
display: "table",
content: '""'
},
"&::after": {
// https://github.com/ant-design/ant-design/issues/21864
display: "table",
clear: "both",
content: '""'
}
});
const genLinkStyle = (token2) => ({
a: {
color: token2.colorLink,
textDecoration: token2.linkDecoration,
backgroundColor: "transparent",
// remove the gray background on active links in IE 10.
outline: "none",
cursor: "pointer",
transition: `color ${token2.motionDurationSlow}`,
"-webkit-text-decoration-skip": "objects",
// remove gaps in links underline in iOS 8+ and Safari 8+.
"&:hover": {
color: token2.colorLinkHover
},
"&:active": {
color: token2.colorLinkActive
},
"&:active, &:hover": {
textDecoration: token2.linkHoverDecoration,
outline: 0
},
// https://github.com/ant-design/ant-design/issues/22503
"&:focus": {
textDecoration: token2.linkFocusDecoration,
outline: 0
},
"&[disabled]": {
color: token2.colorTextDisabled,
cursor: "not-allowed"
}
}
});
const genCommonStyle = (token2, componentPrefixCls, rootCls, resetFont) => {
const prefixSelector = `[class^="${componentPrefixCls}"], [class*=" ${componentPrefixCls}"]`;
const rootPrefixSelector = rootCls ? `.${rootCls}` : prefixSelector;
const resetStyle = {
boxSizing: "border-box",
"&::before, &::after": {
boxSizing: "border-box"
}
};
let resetFontStyle = {};
if (resetFont !== false) {
resetFontStyle = {
fontFamily: token2.fontFamily,
fontSize: token2.fontSize
};
}
return {
[rootPrefixSelector]: Object.assign(Object.assign(Object.assign({}, resetFontStyle), resetStyle), {
[prefixSelector]: resetStyle
})
};
};
const genFocusOutline = (token2) => ({
outline: `${unit(token2.lineWidthFocus)} solid ${token2.colorPrimaryBorder}`,
outlineOffset: 1,
transition: "outline-offset 0s, outline 0s"
});
const genFocusStyle = (token2) => ({
"&:focus-visible": Object.assign({}, genFocusOutline(token2))
});
function genMaxMin(type4) {
if (type4 === "js") {
return {
max: Math.max,
min: Math.min
};
}
return {
max: function() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return `max(${args.map((value) => unit(value)).join(",")})`;
},
min: function() {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
return `min(${args.map((value) => unit(value)).join(",")})`;
}
};
}
const enableStatistic = process.env.NODE_ENV !== "production" || typeof CSSINJS_STATISTIC !== "undefined";
let recording = true;
function merge() {
for (var _len = arguments.length, objs = new Array(_len), _key = 0; _key < _len; _key++) {
objs[_key] = arguments[_key];
}
if (!enableStatistic) {
return Object.assign.apply(Object, [{}].concat(objs));
}
recording = false;
const ret = {};
objs.forEach((obj) => {
const keys2 = Object.keys(obj);
keys2.forEach((key) => {
Object.defineProperty(ret, key, {
configurable: true,
enumerable: true,
get: () => obj[key]
});
});
});
recording = true;
return ret;
}
const statistic = {};
function noop() {
}
const statisticToken = (token2) => {
let tokenKeys2;
let proxy = token2;
let flush = noop;
if (enableStatistic && typeof Proxy !== "undefined") {
tokenKeys2 = /* @__PURE__ */ new Set();
proxy = new Proxy(token2, {
get(obj, prop) {
if (recording) {
tokenKeys2.add(prop);
}
return obj[prop];
}
});
flush = (componentName, componentToken) => {
var _a;
statistic[componentName] = {
global: Array.from(tokenKeys2),
component: Object.assign(Object.assign({}, (_a = statistic[componentName]) === null || _a === void 0 ? void 0 : _a.component), componentToken)
};
};
}
return {
token: proxy,
keys: tokenKeys2,
flush
};
};
const useResetIconStyle = (iconPrefixCls, csp) => {
const [theme, token2] = useToken();
return useStyleRegister({
theme,
token: token2,
hashId: "",
path: ["ant-design-icons", iconPrefixCls],
nonce: () => csp === null || csp === void 0 ? void 0 : csp.nonce,
layer: {
name: "antd"
}
}, () => [{
[`.${iconPrefixCls}`]: Object.assign(Object.assign({}, resetIcon()), {
[`.${iconPrefixCls} .${iconPrefixCls}-icon`]: {
display: "block"
}
})
}]);
};
const getDefaultComponentToken = (component, token2, getDefaultToken) => {
var _a;
if (typeof getDefaultToken === "function") {
return getDefaultToken(merge(token2, (_a = token2[component]) !== null && _a !== void 0 ? _a : {}));
}
return getDefaultToken !== null && getDefaultToken !== void 0 ? getDefaultToken : {};
};
const getComponentToken = (component, token2, defaultToken, options) => {
const customToken = Object.assign({}, token2[component]);
if (options === null || options === void 0 ? void 0 : options.deprecatedTokens) {
const {
deprecatedTokens
} = options;
deprecatedTokens.forEach((_ref) => {
let [oldTokenKey, newTokenKey] = _ref;
var _a;
if (process.env.NODE_ENV !== "production") {
process.env.NODE_ENV !== "production" ? warningOnce(!(customToken === null || customToken === void 0 ? void 0 : customToken[oldTokenKey]), `Component Token \`${String(oldTokenKey)}\` of ${component} is deprecated. Please use \`${String(newTokenKey)}\` instead.`) : void 0;
}
if ((customToken === null || customToken === void 0 ? void 0 : customToken[oldTokenKey]) || (customToken === null || customToken === void 0 ? void 0 : customToken[newTokenKey])) {
(_a = customToken[newTokenKey]) !== null && _a !== void 0 ? _a : customToken[newTokenKey] = customToken === null || customToken === void 0 ? void 0 : customToken[oldTokenKey];
}
});
}
const mergedToken = Object.assign(Object.assign({}, defaultToken), customToken);
Object.keys(mergedToken).forEach((key) => {
if (mergedToken[key] === token2[key]) {
delete mergedToken[key];
}
});
return mergedToken;
};
const getCompVarPrefix = (component, prefix) => `${[prefix, component.replace(/([A-Z]+)([A-Z][a-z]+)/g, "$1-$2").replace(/([a-z])([A-Z])/g, "$1-$2")].filter(Boolean).join("-")}`;
function genComponentStyleHook(componentName, styleFn, getDefaultToken) {
let options = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
const cells = Array.isArray(componentName) ? componentName : [componentName, componentName];
const [component] = cells;
const concatComponent = cells.join("-");
return function(prefixCls) {
let rootCls = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : prefixCls;
const [theme, realToken, hashId, token2, cssVar] = useToken();
const {
getPrefixCls,
iconPrefixCls,
csp
} = useContext(ConfigContext);
const rootPrefixCls = getPrefixCls();
const type4 = cssVar ? "css" : "js";
const calc = useUniqueMemo(() => {
const unitlessCssVar = /* @__PURE__ */ new Set();
if (cssVar) {
Object.keys(options.unitless || {}).forEach((key) => {
unitlessCssVar.add(token2CSSVar(key, cssVar.prefix));
unitlessCssVar.add(token2CSSVar(key, getCompVarPrefix(component, cssVar.prefix)));
});
}
return genCalc(type4, unitlessCssVar);
}, [type4, component, cssVar === null || cssVar === void 0 ? void 0 : cssVar.prefix]);
const {
max,
min
} = genMaxMin(type4);
const sharedConfig = {
theme,
token: token2,
hashId,
nonce: () => csp === null || csp === void 0 ? void 0 : csp.nonce,
clientOnly: options.clientOnly,
layer: {
name: "antd"
},
// antd is always at top of styles
order: options.order || -999
};
useStyleRegister(Object.assign(Object.assign({}, sharedConfig), {
clientOnly: false,
path: ["Shared", rootPrefixCls]
}), () => [{
// Link
"&": genLinkStyle(token2)
}]);
useResetIconStyle(iconPrefixCls, csp);
const wrapSSR = useStyleRegister(Object.assign(Object.assign({}, sharedConfig), {
path: [concatComponent, prefixCls, iconPrefixCls]
}), () => {
if (options.injectStyle === false) {
return [];
}
const {
token: proxyToken,
flush
} = statisticToken(token2);
const defaultComponentToken = getDefaultComponentToken(component, realToken, getDefaultToken);
const componentCls = `.${prefixCls}`;
const componentToken = getComponentToken(component, realToken, defaultComponentToken, {
deprecatedTokens: options.deprecatedTokens
});
if (cssVar) {
Object.keys(defaultComponentToken).forEach((key) => {
defaultComponentToken[key] = `var(${token2CSSVar(key, getCompVarPrefix(component, cssVar.prefix))})`;
});
}
const mergedToken = merge(proxyToken, {
componentCls,
prefixCls,
iconCls: `.${iconPrefixCls}`,
antCls: `.${rootPrefixCls}`,
calc,
// @ts-ignore
max,
// @ts-ignore
min
}, cssVar ? defaultComponentToken : componentToken);
const styleInterpolation = styleFn(mergedToken, {
hashId,
prefixCls,
rootPrefixCls,
iconPrefixCls
});
flush(component, componentToken);
return [options.resetStyle === false ? null : genCommonStyle(mergedToken, prefixCls, rootCls, options.resetFont), styleInterpolation];
});
return [wrapSSR, hashId];
};
}
const genSubStyleComponent = (componentName, styleFn, getDefaultToken, options) => {
const useStyle2 = genComponentStyleHook(componentName, styleFn, getDefaultToken, Object.assign({
resetStyle: false,
// Sub Style should default after root one
order: -998
}, options));
const StyledComponent = (_ref2) => {
let {
prefixCls,
rootCls = prefixCls
} = _ref2;
useStyle2(prefixCls, rootCls);
return null;
};
if (process.env.NODE_ENV !== "production") {
StyledComponent.displayName = `SubStyle_${Array.isArray(componentName) ? componentName.join(".") : componentName}`;
}
return StyledComponent;
};
const genCSSVarRegister = (component, getDefaultToken, options) => {
const {
unitless: compUnitless,
injectStyle = true,
prefixToken
} = options;
const CSSVarRegister = (_ref3) => {
let {
rootCls,
cssVar
} = _ref3;
const [, realToken] = useToken();
useCSSVarRegister({
path: [component],
prefix: cssVar.prefix,
key: cssVar === null || cssVar === void 0 ? void 0 : cssVar.key,
unitless: compUnitless,
ignore,
token: realToken,
scope: rootCls
}, () => {
const defaultToken = getDefaultComponentToken(component, realToken, getDefaultToken);
const componentToken = getComponentToken(component, realToken, defaultToken, {
deprecatedTokens: options === null || options === void 0 ? void 0 : options.deprecatedTokens
});
Object.keys(defaultToken).forEach((key) => {
componentToken[prefixToken(key)] = componentToken[key];
delete componentToken[key];
});
return componentToken;
});
return null;
};
const useCSSVar = (rootCls) => {
const [, , , , cssVar] = useToken();
return [(node2) => injectStyle && cssVar ? /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(CSSVarRegister, {
rootCls,
cssVar,
component
}), node2) : node2, cssVar === null || cssVar === void 0 ? void 0 : cssVar.key];
};
return useCSSVar;
};
const genStyleHooks = (component, styleFn, getDefaultToken, options) => {
const componentName = Array.isArray(component) ? component[0] : component;
function prefixToken(key) {
return `${componentName}${key.slice(0, 1).toUpperCase()}${key.slice(1)}`;
}
const originUnitless = (options === null || options === void 0 ? void 0 : options.unitless) || {};
const compUnitless = Object.assign(Object.assign({}, unitless), {
[prefixToken("zIndexPopup")]: true
});
Object.keys(originUnitless).forEach((key) => {
compUnitless[prefixToken(key)] = originUnitless[key];
});
const mergedOptions = Object.assign(Object.assign({}, options), {
unitless: compUnitless,
prefixToken
});
const useStyle2 = genComponentStyleHook(component, styleFn, getDefaultToken, mergedOptions);
const useCSSVar = genCSSVarRegister(componentName, getDefaultToken, mergedOptions);
return function(prefixCls) {
let rootCls = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : prefixCls;
const [, hashId] = useStyle2(prefixCls, rootCls);
const [wrapCSSVar, cssVarCls] = useCSSVar(rootCls);
return [wrapCSSVar, hashId, cssVarCls];
};
};
const fullClone$1 = Object.assign({}, React);
const {
useId: useId2
} = fullClone$1;
const useEmptyId = () => "";
const useThemeKey = typeof useId2 === "undefined" ? useEmptyId : useId2;
function useTheme(theme, parentTheme, config) {
var _a, _b;
const warning3 = devUseWarning("ConfigProvider");
const themeConfig = theme || {};
const parentThemeConfig = themeConfig.inherit === false || !parentTheme ? Object.assign(Object.assign({}, defaultConfig), {
hashed: (_a = parentTheme === null || parentTheme === void 0 ? void 0 : parentTheme.hashed) !== null && _a !== void 0 ? _a : defaultConfig.hashed,
cssVar: parentTheme === null || parentTheme === void 0 ? void 0 : parentTheme.cssVar
}) : parentTheme;
const themeKey = useThemeKey();
if (process.env.NODE_ENV !== "production") {
const cssVarEnabled = themeConfig.cssVar || parentThemeConfig.cssVar;
const validKey = !!(typeof themeConfig.cssVar === "object" && ((_b = themeConfig.cssVar) === null || _b === void 0 ? void 0 : _b.key) || themeKey);
process.env.NODE_ENV !== "production" ? warning3(!cssVarEnabled || validKey, "breaking", "Missing key in `cssVar` config. Please upgrade to React 18 or set `cssVar.key` manually in each ConfigProvider inside `cssVar` enabled ConfigProvider.") : void 0;
}
return useMemo(() => {
var _a2, _b2;
if (!theme) {
return parentTheme;
}
const mergedComponents = Object.assign({}, parentThemeConfig.components);
Object.keys(theme.components || {}).forEach((componentName) => {
mergedComponents[componentName] = Object.assign(Object.assign({}, mergedComponents[componentName]), theme.components[componentName]);
});
const cssVarKey = `css-var-${themeKey.replace(/:/g, "")}`;
const mergedCssVar = ((_a2 = themeConfig.cssVar) !== null && _a2 !== void 0 ? _a2 : parentThemeConfig.cssVar) && Object.assign(Object.assign(Object.assign({
prefix: config === null || config === void 0 ? void 0 : config.prefixCls
}, typeof parentThemeConfig.cssVar === "object" ? parentThemeConfig.cssVar : {}), typeof themeConfig.cssVar === "object" ? themeConfig.cssVar : {}), {
key: typeof themeConfig.cssVar === "object" && ((_b2 = themeConfig.cssVar) === null || _b2 === void 0 ? void 0 : _b2.key) || cssVarKey
});
return Object.assign(Object.assign(Object.assign({}, parentThemeConfig), themeConfig), {
token: Object.assign(Object.assign({}, parentThemeConfig.token), themeConfig.token),
components: mergedComponents,
cssVar: mergedCssVar
});
}, [themeConfig, parentThemeConfig], (prev2, next2) => prev2.some((prevTheme, index2) => {
const nextTheme = next2[index2];
return !isEqual(prevTheme, nextTheme, true);
}));
}
function MotionWrapper(props) {
const {
children
} = props;
const [, token2] = useToken();
const {
motion
} = token2;
const needWrapMotionProviderRef = React.useRef(false);
needWrapMotionProviderRef.current = needWrapMotionProviderRef.current || motion === false;
if (needWrapMotionProviderRef.current) {
return /* @__PURE__ */ React.createElement(MotionProvider, {
motion
}, children);
}
return children;
}
const PropWarning = /* @__PURE__ */ React.memo((_ref) => {
let {
dropdownMatchSelectWidth
} = _ref;
const warning3 = devUseWarning("ConfigProvider");
warning3.deprecated(dropdownMatchSelectWidth === void 0, "dropdownMatchSelectWidth", "popupMatchSelectWidth");
return null;
});
if (process.env.NODE_ENV !== "production") {
PropWarning.displayName = "PropWarning";
}
const PropWarning$1 = process.env.NODE_ENV !== "production" ? PropWarning : () => null;
var __rest$4 = function(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
}
return t;
};
let existThemeConfig = false;
process.env.NODE_ENV !== "production" ? (componentName) => {
process.env.NODE_ENV !== "production" ? warning$1(!existThemeConfig, componentName, `Static function can not consume context like dynamic theme. Please use 'App' component instead.`) : void 0;
} : (
/* istanbul ignore next */
null
);
const PASSED_PROPS = ["getTargetContainer", "getPopupContainer", "renderEmpty", "input", "pagination", "form", "select", "button"];
const defaultPrefixCls = "ant";
let globalPrefixCls;
function getGlobalPrefixCls() {
return globalPrefixCls || defaultPrefixCls;
}
function isLegacyTheme(theme) {
return Object.keys(theme).some((key) => key.endsWith("Color"));
}
const setGlobalConfig = (props) => {
const {
prefixCls,
iconPrefixCls,
theme,
holderRender
} = props;
if (prefixCls !== void 0) {
globalPrefixCls = prefixCls;
}
if (theme) {
if (isLegacyTheme(theme)) {
process.env.NODE_ENV !== "production" ? warning$1(false, "ConfigProvider", "`config` of css variable theme is not work in v5. Please use new `theme` config instead.") : void 0;
registerTheme(getGlobalPrefixCls(), theme);
}
}
};
const ProviderChildren = (props) => {
const {
children,
csp: customCsp,
autoInsertSpaceInButton,
alert,
anchor,
form,
locale: locale2,
componentSize,
direction,
space,
virtual,
dropdownMatchSelectWidth,
popupMatchSelectWidth,
popupOverflow,
legacyLocale,
parentContext,
iconPrefixCls: customIconPrefixCls,
theme,
componentDisabled,
segmented,
statistic: statistic2,
spin,
calendar,
carousel,
cascader,
collapse,
typography,
checkbox,
descriptions,
divider,
drawer,
skeleton,
steps,
image,
layout,
list,
mentions,
modal,
progress,
result,
slider,
breadcrumb,
menu,
pagination,
input,
textArea,
empty,
badge,
radio,
rate,
switch: SWITCH,
transfer,
avatar,
message,
tag,
table,
card,
tabs,
timeline,
timePicker,
upload,
notification,
tree,
colorPicker,
datePicker,
rangePicker,
flex,
wave,
dropdown,
warning: warningConfig,
tour,
floatButtonGroup,
variant,
inputNumber,
treeSelect
} = props;
const getPrefixCls = React.useCallback((suffixCls, customizePrefixCls) => {
const {
prefixCls
} = props;
if (customizePrefixCls) {
return customizePrefixCls;
}
const mergedPrefixCls = prefixCls || parentContext.getPrefixCls("");
return suffixCls ? `${mergedPrefixCls}-${suffixCls}` : mergedPrefixCls;
}, [parentContext.getPrefixCls, props.prefixCls]);
const iconPrefixCls = customIconPrefixCls || parentContext.iconPrefixCls || defaultIconPrefixCls;
const csp = customCsp || parentContext.csp;
useResetIconStyle(iconPrefixCls, csp);
const mergedTheme = useTheme(theme, parentContext.theme, {
prefixCls: getPrefixCls("")
});
if (process.env.NODE_ENV !== "production") {
existThemeConfig = existThemeConfig || !!mergedTheme;
}
const baseConfig = {
csp,
autoInsertSpaceInButton,
alert,
anchor,
locale: locale2 || legacyLocale,
direction,
space,
virtual,
popupMatchSelectWidth: popupMatchSelectWidth !== null && popupMatchSelectWidth !== void 0 ? popupMatchSelectWidth : dropdownMatchSelectWidth,
popupOverflow,
getPrefixCls,
iconPrefixCls,
theme: mergedTheme,
segmented,
statistic: statistic2,
spin,
calendar,
carousel,
cascader,
collapse,
typography,
checkbox,
descriptions,
divider,
drawer,
skeleton,
steps,
image,
input,
textArea,
layout,
list,
mentions,
modal,
progress,
result,
slider,
breadcrumb,
menu,
pagination,
empty,
badge,
radio,
rate,
switch: SWITCH,
transfer,
avatar,
message,
tag,
table,
card,
tabs,
timeline,
timePicker,
upload,
notification,
tree,
colorPicker,
datePicker,
rangePicker,
flex,
wave,
dropdown,
warning: warningConfig,
tour,
floatButtonGroup,
variant,
inputNumber,
treeSelect
};
if (process.env.NODE_ENV !== "production") {
const warningFn = devUseWarning("ConfigProvider");
warningFn(!("autoInsertSpaceInButton" in props), "deprecated", "`autoInsertSpaceInButton` is deprecated. Please use `{ button: { autoInsertSpace: boolean }}` instead.");
}
const config = Object.assign({}, parentContext);
Object.keys(baseConfig).forEach((key) => {
if (baseConfig[key] !== void 0) {
config[key] = baseConfig[key];
}
});
PASSED_PROPS.forEach((propName) => {
const propValue = props[propName];
if (propValue) {
config[propName] = propValue;
}
});
if (typeof autoInsertSpaceInButton !== "undefined") {
config.button = Object.assign({
autoInsertSpace: autoInsertSpaceInButton
}, config.button);
}
const memoedConfig = useMemo(() => config, config, (prevConfig, currentConfig) => {
const prevKeys = Object.keys(prevConfig);
const currentKeys = Object.keys(currentConfig);
return prevKeys.length !== currentKeys.length || prevKeys.some((key) => prevConfig[key] !== currentConfig[key]);
});
const memoIconContextValue = React.useMemo(() => ({
prefixCls: iconPrefixCls,
csp
}), [iconPrefixCls, csp]);
let childNode = /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(PropWarning$1, {
dropdownMatchSelectWidth
}), children);
const validateMessages = React.useMemo(() => {
var _a, _b, _c, _d;
return merge$1(((_a = localeValues.Form) === null || _a === void 0 ? void 0 : _a.defaultValidateMessages) || {}, ((_c = (_b = memoedConfig.locale) === null || _b === void 0 ? void 0 : _b.Form) === null || _c === void 0 ? void 0 : _c.defaultValidateMessages) || {}, ((_d = memoedConfig.form) === null || _d === void 0 ? void 0 : _d.validateMessages) || {}, (form === null || form === void 0 ? void 0 : form.validateMessages) || {});
}, [memoedConfig, form === null || form === void 0 ? void 0 : form.validateMessages]);
if (Object.keys(validateMessages).length > 0) {
childNode = /* @__PURE__ */ React.createElement(ValidateMessagesContext.Provider, {
value: validateMessages
}, childNode);
}
if (locale2) {
childNode = /* @__PURE__ */ React.createElement(LocaleProvider, {
locale: locale2,
_ANT_MARK__: ANT_MARK
}, childNode);
}
if (iconPrefixCls || csp) {
childNode = /* @__PURE__ */ React.createElement(IconContext.Provider, {
value: memoIconContextValue
}, childNode);
}
if (componentSize) {
childNode = /* @__PURE__ */ React.createElement(SizeContextProvider, {
size: componentSize
}, childNode);
}
childNode = /* @__PURE__ */ React.createElement(MotionWrapper, null, childNode);
const memoTheme = React.useMemo(() => {
const _a = mergedTheme || {}, {
algorithm,
token: token2,
components,
cssVar
} = _a, rest = __rest$4(_a, ["algorithm", "token", "components", "cssVar"]);
const themeObj = algorithm && (!Array.isArray(algorithm) || algorithm.length > 0) ? createTheme(algorithm) : defaultTheme;
const parsedComponents = {};
Object.entries(components || {}).forEach((_ref) => {
let [componentName, componentToken] = _ref;
const parsedToken = Object.assign({}, componentToken);
if ("algorithm" in parsedToken) {
if (parsedToken.algorithm === true) {
parsedToken.theme = themeObj;
} else if (Array.isArray(parsedToken.algorithm) || typeof parsedToken.algorithm === "function") {
parsedToken.theme = createTheme(parsedToken.algorithm);
}
delete parsedToken.algorithm;
}
parsedComponents[componentName] = parsedToken;
});
const mergedToken = Object.assign(Object.assign({}, seedToken), token2);
return Object.assign(Object.assign({}, rest), {
theme: themeObj,
token: mergedToken,
components: parsedComponents,
override: Object.assign({
override: mergedToken
}, parsedComponents),
cssVar
});
}, [mergedTheme]);
if (theme) {
childNode = /* @__PURE__ */ React.createElement(DesignTokenContext.Provider, {
value: memoTheme
}, childNode);
}
if (memoedConfig.warning) {
childNode = /* @__PURE__ */ React.createElement(WarningContext.Provider, {
value: memoedConfig.warning
}, childNode);
}
if (componentDisabled !== void 0) {
childNode = /* @__PURE__ */ React.createElement(DisabledContextProvider, {
disabled: componentDisabled
}, childNode);
}
return /* @__PURE__ */ React.createElement(ConfigContext.Provider, {
value: memoedConfig
}, childNode);
};
const ConfigProvider = (props) => {
const context = React.useContext(ConfigContext);
const antLocale = React.useContext(LocaleContext);
return /* @__PURE__ */ React.createElement(ProviderChildren, Object.assign({
parentContext: context,
legacyLocale: antLocale
}, props));
};
ConfigProvider.ConfigContext = ConfigContext;
ConfigProvider.SizeContext = SizeContext;
ConfigProvider.config = setGlobalConfig;
ConfigProvider.useConfig = useConfig;
Object.defineProperty(ConfigProvider, "SizeContext", {
get: () => {
process.env.NODE_ENV !== "production" ? warning$1(false, "ConfigProvider", "ConfigProvider.SizeContext is deprecated. Please use `ConfigProvider.useConfig().componentSize` instead.") : void 0;
return SizeContext;
}
});
if (process.env.NODE_ENV !== "production") {
ConfigProvider.displayName = "ConfigProvider";
}
const useSize = (customSize) => {
const size = React__default.useContext(SizeContext);
const mergedSize = React__default.useMemo(() => {
if (!customSize) {
return size;
}
if (typeof customSize === "string") {
return customSize !== null && customSize !== void 0 ? customSize : size;
}
if (customSize instanceof Function) {
return customSize(size);
}
return size;
}, [customSize, size]);
return mergedSize;
};
(function(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
}
return t;
});
const SpaceCompactItemContext = /* @__PURE__ */ React.createContext(null);
const useCompactItemContext = (prefixCls, direction) => {
const compactItemContext = React.useContext(SpaceCompactItemContext);
const compactItemClassnames = React.useMemo(() => {
if (!compactItemContext) {
return "";
}
const {
compactDirection,
isFirstItem,
isLastItem
} = compactItemContext;
const separator = compactDirection === "vertical" ? "-vertical-" : "-";
return classNames(`${prefixCls}-compact${separator}item`, {
[`${prefixCls}-compact${separator}first-item`]: isFirstItem,
[`${prefixCls}-compact${separator}last-item`]: isLastItem,
[`${prefixCls}-compact${separator}item-rtl`]: direction === "rtl"
});
}, [prefixCls, direction, compactItemContext]);
return {
compactSize: compactItemContext === null || compactItemContext === void 0 ? void 0 : compactItemContext.compactSize,
compactDirection: compactItemContext === null || compactItemContext === void 0 ? void 0 : compactItemContext.compactDirection,
compactItemClassnames
};
};
const NoCompactStyle = (_ref) => {
let {
children
} = _ref;
return /* @__PURE__ */ React.createElement(SpaceCompactItemContext.Provider, {
value: null
}, children);
};
const ContextIsolator = (props) => {
const {
space,
form,
children
} = props;
if (children === void 0 || children === null) {
return null;
}
let result = children;
if (form) {
result = /* @__PURE__ */ React__default.createElement(NoFormStyle, {
override: true,
status: true
}, result);
}
if (space) {
result = /* @__PURE__ */ React__default.createElement(NoCompactStyle, null, result);
}
return result;
};
const zIndexContext = /* @__PURE__ */ React__default.createContext(void 0);
if (process.env.NODE_ENV !== "production") {
zIndexContext.displayName = "zIndexContext";
}
const CONTAINER_OFFSET = 100;
const CONTAINER_OFFSET_MAX_COUNT = 10;
const CONTAINER_MAX_OFFSET = CONTAINER_OFFSET * CONTAINER_OFFSET_MAX_COUNT;
const containerBaseZIndexOffset = {
Modal: CONTAINER_OFFSET,
Drawer: CONTAINER_OFFSET,
Popover: CONTAINER_OFFSET,
Popconfirm: CONTAINER_OFFSET,
Tooltip: CONTAINER_OFFSET,
Tour: CONTAINER_OFFSET
};
const consumerBaseZIndexOffset = {
SelectLike: 50,
Dropdown: 50,
DatePicker: 50,
Menu: 50,
ImagePreview: 1
};
function isContainerType(type4) {
return type4 in containerBaseZIndexOffset;
}
function useZIndex(componentType, customZIndex) {
const [, token2] = useToken();
const parentZIndex = React__default.useContext(zIndexContext);
const isContainer = isContainerType(componentType);
let result;
if (customZIndex !== void 0) {
result = [customZIndex, customZIndex];
} else {
let zIndex = parentZIndex !== null && parentZIndex !== void 0 ? parentZIndex : 0;
if (isContainer) {
zIndex += // Use preset token zIndex by default but not stack when has parent container
(parentZIndex ? 0 : token2.zIndexPopupBase) + // Container offset
containerBaseZIndexOffset[componentType];
} else {
zIndex += consumerBaseZIndexOffset[componentType];
}
result = [parentZIndex === void 0 ? customZIndex : zIndex, zIndex];
}
if (process.env.NODE_ENV !== "production") {
const warning3 = devUseWarning(componentType);
const maxZIndex = token2.zIndexPopupBase + CONTAINER_MAX_OFFSET;
const currentZIndex = result[0] || 0;
process.env.NODE_ENV !== "production" ? warning3(customZIndex !== void 0 || currentZIndex <= maxZIndex, "usage", "`zIndex` is over design token `zIndexPopupBase` too much. It may cause unexpected override.") : void 0;
}
return result;
}
function getStatusClassNames(prefixCls, status, hasFeedback) {
return classNames({
[`${prefixCls}-status-success`]: status === "success",
[`${prefixCls}-status-warning`]: status === "warning",
[`${prefixCls}-status-error`]: status === "error",
[`${prefixCls}-status-validating`]: status === "validating",
[`${prefixCls}-has-feedback`]: hasFeedback
});
}
const getMergedStatus = (contextStatus, customStatus) => customStatus || contextStatus;
const useCSSVarCls = (prefixCls) => {
const [, , , , cssVar] = useToken();
return cssVar ? `${prefixCls}-css-var` : "";
};
const useVariant = function(component, variant) {
let legacyBordered = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : void 0;
var _a, _b;
const {
variant: configVariant,
[component]: componentConfig
} = useContext(ConfigContext);
const ctxVariant = useContext(VariantContext);
const configComponentVariant = componentConfig === null || componentConfig === void 0 ? void 0 : componentConfig.variant;
let mergedVariant;
if (typeof variant !== "undefined") {
mergedVariant = variant;
} else if (legacyBordered === false) {
mergedVariant = "borderless";
} else {
mergedVariant = (_b = (_a = ctxVariant !== null && ctxVariant !== void 0 ? ctxVariant : configComponentVariant) !== null && _a !== void 0 ? _a : configVariant) !== null && _b !== void 0 ? _b : "outlined";
}
const enableVariantCls = Variants.includes(mergedVariant);
return [mergedVariant, enableVariantCls];
};
function compactItemBorder(token2, parentCls, options) {
const {
focusElCls,
focus,
borderElCls
} = options;
const childCombinator = borderElCls ? "> *" : "";
const hoverEffects = ["hover", focus ? "focus" : null, "active"].filter(Boolean).map((n) => `&:${n} ${childCombinator}`).join(",");
return {
[`&-item:not(${parentCls}-last-item)`]: {
marginInlineEnd: token2.calc(token2.lineWidth).mul(-1).equal()
},
"&-item": Object.assign(Object.assign({
[hoverEffects]: {
zIndex: 2
}
}, focusElCls ? {
[`&${focusElCls}`]: {
zIndex: 2
}
} : {}), {
[`&[disabled] ${childCombinator}`]: {
zIndex: 0
}
})
};
}
function compactItemBorderRadius(prefixCls, parentCls, options) {
const {
borderElCls
} = options;
const childCombinator = borderElCls ? `> ${borderElCls}` : "";
return {
[`&-item:not(${parentCls}-first-item):not(${parentCls}-last-item) ${childCombinator}`]: {
borderRadius: 0
},
[`&-item:not(${parentCls}-last-item)${parentCls}-first-item`]: {
[`& ${childCombinator}, &${prefixCls}-sm ${childCombinator}, &${prefixCls}-lg ${childCombinator}`]: {
borderStartEndRadius: 0,
borderEndEndRadius: 0
}
},
[`&-item:not(${parentCls}-first-item)${parentCls}-last-item`]: {
[`& ${childCombinator}, &${prefixCls}-sm ${childCombinator}, &${prefixCls}-lg ${childCombinator}`]: {
borderStartStartRadius: 0,
borderEndStartRadius: 0
}
}
};
}
function genCompactItemStyle(token2) {
let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
focus: true
};
const {
componentCls
} = token2;
const compactCls = `${componentCls}-compact`;
return {
[compactCls]: Object.assign(Object.assign({}, compactItemBorder(token2, compactCls, options)), compactItemBorderRadius(componentCls, compactCls, options))
};
}
function initInputToken(token2) {
return merge(token2, {
inputAffixPadding: token2.paddingXXS
});
}
const initComponentToken = (token2) => {
const {
controlHeight,
fontSize,
lineHeight,
lineWidth,
controlHeightSM,
controlHeightLG,
fontSizeLG,
lineHeightLG,
paddingSM,
controlPaddingHorizontalSM,
controlPaddingHorizontal,
colorFillAlter,
colorPrimaryHover,
colorPrimary,
controlOutlineWidth,
controlOutline,
colorErrorOutline,
colorWarningOutline,
colorBgContainer
} = token2;
return {
paddingBlock: Math.max(Math.round((controlHeight - fontSize * lineHeight) / 2 * 10) / 10 - lineWidth, 0),
paddingBlockSM: Math.max(Math.round((controlHeightSM - fontSize * lineHeight) / 2 * 10) / 10 - lineWidth, 0),
paddingBlockLG: Math.ceil((controlHeightLG - fontSizeLG * lineHeightLG) / 2 * 10) / 10 - lineWidth,
paddingInline: paddingSM - lineWidth,
paddingInlineSM: controlPaddingHorizontalSM - lineWidth,
paddingInlineLG: controlPaddingHorizontal - lineWidth,
addonBg: colorFillAlter,
activeBorderColor: colorPrimary,
hoverBorderColor: colorPrimaryHover,
activeShadow: `0 0 0 ${controlOutlineWidth}px ${controlOutline}`,
errorActiveShadow: `0 0 0 ${controlOutlineWidth}px ${colorErrorOutline}`,
warningActiveShadow: `0 0 0 ${controlOutlineWidth}px ${colorWarningOutline}`,
hoverBg: colorBgContainer,
activeBg: colorBgContainer,
inputFontSize: fontSize,
inputFontSizeLG: fontSizeLG,
inputFontSizeSM: fontSize
};
};
const genHoverStyle = (token2) => ({
borderColor: token2.hoverBorderColor,
backgroundColor: token2.hoverBg
});
const genDisabledStyle$1 = (token2) => ({
color: token2.colorTextDisabled,
backgroundColor: token2.colorBgContainerDisabled,
borderColor: token2.colorBorder,
boxShadow: "none",
cursor: "not-allowed",
opacity: 1,
"input[disabled], textarea[disabled]": {
cursor: "not-allowed"
},
"&:hover:not([disabled])": Object.assign({}, genHoverStyle(merge(token2, {
hoverBorderColor: token2.colorBorder,
hoverBg: token2.colorBgContainerDisabled
})))
});
const genBaseOutlinedStyle = (token2, options) => ({
background: token2.colorBgContainer,
borderWidth: token2.lineWidth,
borderStyle: token2.lineType,
borderColor: options.borderColor,
"&:hover": {
borderColor: options.hoverBorderColor,
backgroundColor: token2.hoverBg
},
"&:focus, &:focus-within": {
borderColor: options.activeBorderColor,
boxShadow: options.activeShadow,
outline: 0,
backgroundColor: token2.activeBg
}
});
const genOutlinedStatusStyle = (token2, options) => ({
[`&${token2.componentCls}-status-${options.status}:not(${token2.componentCls}-disabled)`]: Object.assign(Object.assign({}, genBaseOutlinedStyle(token2, options)), {
[`${token2.componentCls}-prefix, ${token2.componentCls}-suffix`]: {
color: options.affixColor
}
}),
[`&${token2.componentCls}-status-${options.status}${token2.componentCls}-disabled`]: {
borderColor: options.borderColor
}
});
const genOutlinedStyle = (token2, extraStyles) => ({
"&-outlined": Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, genBaseOutlinedStyle(token2, {
borderColor: token2.colorBorder,
hoverBorderColor: token2.hoverBorderColor,
activeBorderColor: token2.activeBorderColor,
activeShadow: token2.activeShadow
})), {
[`&${token2.componentCls}-disabled, &[disabled]`]: Object.assign({}, genDisabledStyle$1(token2))
}), genOutlinedStatusStyle(token2, {
status: "error",
borderColor: token2.colorError,
hoverBorderColor: token2.colorErrorBorderHover,
activeBorderColor: token2.colorError,
activeShadow: token2.errorActiveShadow,
affixColor: token2.colorError
})), genOutlinedStatusStyle(token2, {
status: "warning",
borderColor: token2.colorWarning,
hoverBorderColor: token2.colorWarningBorderHover,
activeBorderColor: token2.colorWarning,
activeShadow: token2.warningActiveShadow,
affixColor: token2.colorWarning
})), extraStyles)
});
const genOutlinedGroupStatusStyle = (token2, options) => ({
[`&${token2.componentCls}-group-wrapper-status-${options.status}`]: {
[`${token2.componentCls}-group-addon`]: {
borderColor: options.addonBorderColor,
color: options.addonColor
}
}
});
const genOutlinedGroupStyle = (token2) => ({
"&-outlined": Object.assign(Object.assign(Object.assign({
[`${token2.componentCls}-group`]: {
"&-addon": {
background: token2.addonBg,
border: `${unit(token2.lineWidth)} ${token2.lineType} ${token2.colorBorder}`
},
"&-addon:first-child": {
borderInlineEnd: 0
},
"&-addon:last-child": {
borderInlineStart: 0
}
}
}, genOutlinedGroupStatusStyle(token2, {
status: "error",
addonBorderColor: token2.colorError,
addonColor: token2.colorErrorText
})), genOutlinedGroupStatusStyle(token2, {
status: "warning",
addonBorderColor: token2.colorWarning,
addonColor: token2.colorWarningText
})), {
[`&${token2.componentCls}-group-wrapper-disabled`]: {
[`${token2.componentCls}-group-addon`]: Object.assign({}, genDisabledStyle$1(token2))
}
})
});
const genBorderlessStyle = (token2, extraStyles) => {
const {
componentCls
} = token2;
return {
"&-borderless": Object.assign({
background: "transparent",
border: "none",
"&:focus, &:focus-within": {
outline: "none"
},
// >>>>> Disabled
[`&${componentCls}-disabled, &[disabled]`]: {
color: token2.colorTextDisabled
},
// >>>>> Status
[`&${componentCls}-status-error`]: {
"&, & input, & textarea": {
color: token2.colorError
}
},
[`&${componentCls}-status-warning`]: {
"&, & input, & textarea": {
color: token2.colorWarning
}
}
}, extraStyles)
};
};
const genBaseFilledStyle = (token2, options) => ({
background: options.bg,
borderWidth: token2.lineWidth,
borderStyle: token2.lineType,
borderColor: "transparent",
"input&, & input, textarea&, & textarea": {
color: options === null || options === void 0 ? void 0 : options.inputColor
},
"&:hover": {
background: options.hoverBg
},
"&:focus, &:focus-within": {
outline: 0,
borderColor: options.activeBorderColor,
backgroundColor: token2.activeBg
}
});
const genFilledStatusStyle = (token2, options) => ({
[`&${token2.componentCls}-status-${options.status}:not(${token2.componentCls}-disabled)`]: Object.assign(Object.assign({}, genBaseFilledStyle(token2, options)), {
[`${token2.componentCls}-prefix, ${token2.componentCls}-suffix`]: {
color: options.affixColor
}
})
});
const genFilledStyle = (token2, extraStyles) => ({
"&-filled": Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, genBaseFilledStyle(token2, {
bg: token2.colorFillTertiary,
hoverBg: token2.colorFillSecondary,
activeBorderColor: token2.activeBorderColor
})), {
[`&${token2.componentCls}-disabled, &[disabled]`]: Object.assign({}, genDisabledStyle$1(token2))
}), genFilledStatusStyle(token2, {
status: "error",
bg: token2.colorErrorBg,
hoverBg: token2.colorErrorBgHover,
activeBorderColor: token2.colorError,
inputColor: token2.colorErrorText,
affixColor: token2.colorError
})), genFilledStatusStyle(token2, {
status: "warning",
bg: token2.colorWarningBg,
hoverBg: token2.colorWarningBgHover,
activeBorderColor: token2.colorWarning,
inputColor: token2.colorWarningText,
affixColor: token2.colorWarning
})), extraStyles)
});
const genFilledGroupStatusStyle = (token2, options) => ({
[`&${token2.componentCls}-group-wrapper-status-${options.status}`]: {
[`${token2.componentCls}-group-addon`]: {
background: options.addonBg,
color: options.addonColor
}
}
});
const genFilledGroupStyle = (token2) => ({
"&-filled": Object.assign(Object.assign(Object.assign({
[`${token2.componentCls}-group`]: {
"&-addon": {
background: token2.colorFillTertiary
},
[`${token2.componentCls}-filled:not(:focus):not(:focus-within)`]: {
"&:not(:first-child)": {
borderInlineStart: `${unit(token2.lineWidth)} ${token2.lineType} ${token2.colorSplit}`
},
"&:not(:last-child)": {
borderInlineEnd: `${unit(token2.lineWidth)} ${token2.lineType} ${token2.colorSplit}`
}
}
}
}, genFilledGroupStatusStyle(token2, {
status: "error",
addonBg: token2.colorErrorBg,
addonColor: token2.colorErrorText
})), genFilledGroupStatusStyle(token2, {
status: "warning",
addonBg: token2.colorWarningBg,
addonColor: token2.colorWarningText
})), {
[`&${token2.componentCls}-group-wrapper-disabled`]: {
[`${token2.componentCls}-group`]: {
"&-addon": {
background: token2.colorFillTertiary,
color: token2.colorTextDisabled
},
"&-addon:first-child": {
borderInlineStart: `${unit(token2.lineWidth)} ${token2.lineType} ${token2.colorBorder}`,
borderTop: `${unit(token2.lineWidth)} ${token2.lineType} ${token2.colorBorder}`,
borderBottom: `${unit(token2.lineWidth)} ${token2.lineType} ${token2.colorBorder}`
},
"&-addon:last-child": {
borderInlineEnd: `${unit(token2.lineWidth)} ${token2.lineType} ${token2.colorBorder}`,
borderTop: `${unit(token2.lineWidth)} ${token2.lineType} ${token2.colorBorder}`,
borderBottom: `${unit(token2.lineWidth)} ${token2.lineType} ${token2.colorBorder}`
}
}
}
})
});
const genPlaceholderStyle = (color) => ({
// Firefox
"&::-moz-placeholder": {
opacity: 1
},
"&::placeholder": {
color,
userSelect: "none"
// https://github.com/ant-design/ant-design/pull/32639
},
"&:placeholder-shown": {
textOverflow: "ellipsis"
}
});
const genInputLargeStyle = (token2) => {
const {
paddingBlockLG,
lineHeightLG,
borderRadiusLG,
paddingInlineLG
} = token2;
return {
padding: `${unit(paddingBlockLG)} ${unit(paddingInlineLG)}`,
fontSize: token2.inputFontSizeLG,
lineHeight: lineHeightLG,
borderRadius: borderRadiusLG
};
};
const genInputSmallStyle = (token2) => ({
padding: `${unit(token2.paddingBlockSM)} ${unit(token2.paddingInlineSM)}`,
fontSize: token2.inputFontSizeSM,
borderRadius: token2.borderRadiusSM
});
const genBasicInputStyle = (token2) => Object.assign(Object.assign({
position: "relative",
display: "inline-block",
width: "100%",
minWidth: 0,
padding: `${unit(token2.paddingBlock)} ${unit(token2.paddingInline)}`,
color: token2.colorText,
fontSize: token2.inputFontSize,
lineHeight: token2.lineHeight,
borderRadius: token2.borderRadius,
transition: `all ${token2.motionDurationMid}`
}, genPlaceholderStyle(token2.colorTextPlaceholder)), {
// Reset height for `textarea`s
"textarea&": {
maxWidth: "100%",
// prevent textarea resize from coming out of its container
height: "auto",
minHeight: token2.controlHeight,
lineHeight: token2.lineHeight,
verticalAlign: "bottom",
transition: `all ${token2.motionDurationSlow}, height 0s`,
resize: "vertical"
},
// Size
"&-lg": Object.assign({}, genInputLargeStyle(token2)),
"&-sm": Object.assign({}, genInputSmallStyle(token2)),
// RTL
"&-rtl, &-textarea-rtl": {
direction: "rtl"
}
});
const genInputGroupStyle = (token2) => {
const {
componentCls,
antCls
} = token2;
return {
position: "relative",
display: "table",
width: "100%",
borderCollapse: "separate",
borderSpacing: 0,
// Undo padding and float of grid classes
"&[class*='col-']": {
paddingInlineEnd: token2.paddingXS,
"&:last-child": {
paddingInlineEnd: 0
}
},
// Sizing options
[`&-lg ${componentCls}, &-lg > ${componentCls}-group-addon`]: Object.assign({}, genInputLargeStyle(token2)),
[`&-sm ${componentCls}, &-sm > ${componentCls}-group-addon`]: Object.assign({}, genInputSmallStyle(token2)),
// Fix https://github.com/ant-design/ant-design/issues/5754
[`&-lg ${antCls}-select-single ${antCls}-select-selector`]: {
height: token2.controlHeightLG
},
[`&-sm ${antCls}-select-single ${antCls}-select-selector`]: {
height: token2.controlHeightSM
},
[`> ${componentCls}`]: {
display: "table-cell",
"&:not(:first-child):not(:last-child)": {
borderRadius: 0
}
},
[`${componentCls}-group`]: {
"&-addon, &-wrap": {
display: "table-cell",
width: 1,
whiteSpace: "nowrap",
verticalAlign: "middle",
"&:not(:first-child):not(:last-child)": {
borderRadius: 0
}
},
"&-wrap > *": {
display: "block !important"
},
"&-addon": {
position: "relative",
padding: `0 ${unit(token2.paddingInline)}`,
color: token2.colorText,
fontWeight: "normal",
fontSize: token2.inputFontSize,
textAlign: "center",
borderRadius: token2.borderRadius,
transition: `all ${token2.motionDurationSlow}`,
lineHeight: 1,
// Reset Select's style in addon
[`${antCls}-select`]: {
margin: `${unit(token2.calc(token2.paddingBlock).add(1).mul(-1).equal())} ${unit(token2.calc(token2.paddingInline).mul(-1).equal())}`,
[`&${antCls}-select-single:not(${antCls}-select-customize-input):not(${antCls}-pagination-size-changer)`]: {
[`${antCls}-select-selector`]: {
backgroundColor: "inherit",
border: `${unit(token2.lineWidth)} ${token2.lineType} transparent`,
boxShadow: "none"
}
},
"&-open, &-focused": {
[`${antCls}-select-selector`]: {
color: token2.colorPrimary
}
}
},
// https://github.com/ant-design/ant-design/issues/31333
[`${antCls}-cascader-picker`]: {
margin: `-9px ${unit(token2.calc(token2.paddingInline).mul(-1).equal())}`,
backgroundColor: "transparent",
[`${antCls}-cascader-input`]: {
textAlign: "start",
border: 0,
boxShadow: "none"
}
}
}
},
[`${componentCls}`]: {
width: "100%",
marginBottom: 0,
textAlign: "inherit",
"&:focus": {
zIndex: 1,
// Fix https://gw.alipayobjects.com/zos/rmsportal/DHNpoqfMXSfrSnlZvhsJ.png
borderInlineEndWidth: 1
},
"&:hover": {
zIndex: 1,
borderInlineEndWidth: 1,
[`${componentCls}-search-with-button &`]: {
zIndex: 0
}
}
},
// Reset rounded corners
[`> ${componentCls}:first-child, ${componentCls}-group-addon:first-child`]: {
borderStartEndRadius: 0,
borderEndEndRadius: 0,
// Reset Select's style in addon
[`${antCls}-select ${antCls}-select-selector`]: {
borderStartEndRadius: 0,
borderEndEndRadius: 0
}
},
[`> ${componentCls}-affix-wrapper`]: {
[`&:not(:first-child) ${componentCls}`]: {
borderStartStartRadius: 0,
borderEndStartRadius: 0
},
[`&:not(:last-child) ${componentCls}`]: {
borderStartEndRadius: 0,
borderEndEndRadius: 0
}
},
[`> ${componentCls}:last-child, ${componentCls}-group-addon:last-child`]: {
borderStartStartRadius: 0,
borderEndStartRadius: 0,
// Reset Select's style in addon
[`${antCls}-select ${antCls}-select-selector`]: {
borderStartStartRadius: 0,
borderEndStartRadius: 0
}
},
[`${componentCls}-affix-wrapper`]: {
"&:not(:last-child)": {
borderStartEndRadius: 0,
borderEndEndRadius: 0,
[`${componentCls}-search &`]: {
borderStartStartRadius: token2.borderRadius,
borderEndStartRadius: token2.borderRadius
}
},
[`&:not(:first-child), ${componentCls}-search &:not(:first-child)`]: {
borderStartStartRadius: 0,
borderEndStartRadius: 0
}
},
[`&${componentCls}-group-compact`]: Object.assign(Object.assign({
display: "block"
}, clearFix()), {
[`${componentCls}-group-addon, ${componentCls}-group-wrap, > ${componentCls}`]: {
"&:not(:first-child):not(:last-child)": {
borderInlineEndWidth: token2.lineWidth,
"&:hover, &:focus": {
zIndex: 1
}
}
},
"& > *": {
display: "inline-flex",
float: "none",
verticalAlign: "top",
// https://github.com/ant-design/ant-design-pro/issues/139
borderRadius: 0
},
[`
& > ${componentCls}-affix-wrapper,
& > ${componentCls}-number-affix-wrapper,
& > ${antCls}-picker-range
`]: {
display: "inline-flex"
},
"& > *:not(:last-child)": {
marginInlineEnd: token2.calc(token2.lineWidth).mul(-1).equal(),
borderInlineEndWidth: token2.lineWidth
},
// Undo float for .ant-input-group .ant-input
[`${componentCls}`]: {
float: "none"
},
// reset border for Select, DatePicker, AutoComplete, Cascader, Mention, TimePicker, Input
[`& > ${antCls}-select > ${antCls}-select-selector,
& > ${antCls}-select-auto-complete ${componentCls},
& > ${antCls}-cascader-picker ${componentCls},
& > ${componentCls}-group-wrapper ${componentCls}`]: {
borderInlineEndWidth: token2.lineWidth,
borderRadius: 0,
"&:hover, &:focus": {
zIndex: 1
}
},
[`& > ${antCls}-select-focused`]: {
zIndex: 1
},
// update z-index for arrow icon
[`& > ${antCls}-select > ${antCls}-select-arrow`]: {
zIndex: 1
// https://github.com/ant-design/ant-design/issues/20371
},
[`& > *:first-child,
& > ${antCls}-select:first-child > ${antCls}-select-selector,
& > ${antCls}-select-auto-complete:first-child ${componentCls},
& > ${antCls}-cascader-picker:first-child ${componentCls}`]: {
borderStartStartRadius: token2.borderRadius,
borderEndStartRadius: token2.borderRadius
},
[`& > *:last-child,
& > ${antCls}-select:last-child > ${antCls}-select-selector,
& > ${antCls}-cascader-picker:last-child ${componentCls},
& > ${antCls}-cascader-picker-focused:last-child ${componentCls}`]: {
borderInlineEndWidth: token2.lineWidth,
borderStartEndRadius: token2.borderRadius,
borderEndEndRadius: token2.borderRadius
},
// https://github.com/ant-design/ant-design/issues/12493
[`& > ${antCls}-select-auto-complete ${componentCls}`]: {
verticalAlign: "top"
},
[`${componentCls}-group-wrapper + ${componentCls}-group-wrapper`]: {
marginInlineStart: token2.calc(token2.lineWidth).mul(-1).equal(),
[`${componentCls}-affix-wrapper`]: {
borderRadius: 0
}
},
[`${componentCls}-group-wrapper:not(:last-child)`]: {
[`&${componentCls}-search > ${componentCls}-group`]: {
[`& > ${componentCls}-group-addon > ${componentCls}-search-button`]: {
borderRadius: 0
},
[`& > ${componentCls}`]: {
borderStartStartRadius: token2.borderRadius,
borderStartEndRadius: 0,
borderEndEndRadius: 0,
borderEndStartRadius: token2.borderRadius
}
}
}
})
};
};
const genInputStyle = (token2) => {
const {
componentCls,
controlHeightSM,
lineWidth,
calc
} = token2;
const FIXED_CHROME_COLOR_HEIGHT = 16;
const colorSmallPadding = calc(controlHeightSM).sub(calc(lineWidth).mul(2)).sub(FIXED_CHROME_COLOR_HEIGHT).div(2).equal();
return {
[componentCls]: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, resetComponent(token2)), genBasicInputStyle(token2)), genOutlinedStyle(token2)), genFilledStyle(token2)), genBorderlessStyle(token2)), {
'&[type="color"]': {
height: token2.controlHeight,
[`&${componentCls}-lg`]: {
height: token2.controlHeightLG
},
[`&${componentCls}-sm`]: {
height: controlHeightSM,
paddingTop: colorSmallPadding,
paddingBottom: colorSmallPadding
}
},
'&[type="search"]::-webkit-search-cancel-button, &[type="search"]::-webkit-search-decoration': {
"-webkit-appearance": "none"
}
})
};
};
const genAllowClearStyle = (token2) => {
const {
componentCls
} = token2;
return {
// ========================= Input =========================
[`${componentCls}-clear-icon`]: {
margin: 0,
color: token2.colorTextQuaternary,
fontSize: token2.fontSizeIcon,
verticalAlign: -1,
// https://github.com/ant-design/ant-design/pull/18151
// https://codesandbox.io/s/wizardly-sun-u10br
cursor: "pointer",
transition: `color ${token2.motionDurationSlow}`,
"&:hover": {
color: token2.colorTextTertiary
},
"&:active": {
color: token2.colorText
},
"&-hidden": {
visibility: "hidden"
},
"&-has-suffix": {
margin: `0 ${unit(token2.inputAffixPadding)}`
}
}
};
};
const genAffixStyle = (token2) => {
const {
componentCls,
inputAffixPadding,
colorTextDescription,
motionDurationSlow,
colorIcon,
colorIconHover,
iconCls
} = token2;
const affixCls = `${componentCls}-affix-wrapper`;
return {
[affixCls]: Object.assign(Object.assign(Object.assign(Object.assign({}, genBasicInputStyle(token2)), {
display: "inline-flex",
[`&:not(${componentCls}-disabled):hover`]: {
zIndex: 1,
[`${componentCls}-search-with-button &`]: {
zIndex: 0
}
},
"&-focused, &:focus": {
zIndex: 1
},
[`> input${componentCls}`]: {
padding: 0
},
[`> input${componentCls}, > textarea${componentCls}`]: {
fontSize: "inherit",
border: "none",
borderRadius: 0,
outline: "none",
background: "transparent",
color: "inherit",
"&::-ms-reveal": {
display: "none"
},
"&:focus": {
boxShadow: "none !important"
}
},
"&::before": {
display: "inline-block",
width: 0,
visibility: "hidden",
content: '"\\a0"'
},
[`${componentCls}`]: {
"&-prefix, &-suffix": {
display: "flex",
flex: "none",
alignItems: "center",
"> *:not(:last-child)": {
marginInlineEnd: token2.paddingXS
}
},
"&-show-count-suffix": {
color: colorTextDescription
},
"&-show-count-has-suffix": {
marginInlineEnd: token2.paddingXXS
},
"&-prefix": {
marginInlineEnd: inputAffixPadding
},
"&-suffix": {
marginInlineStart: inputAffixPadding
}
}
}), genAllowClearStyle(token2)), {
// password
[`${iconCls}${componentCls}-password-icon`]: {
color: colorIcon,
cursor: "pointer",
transition: `all ${motionDurationSlow}`,
"&:hover": {
color: colorIconHover
}
}
})
};
};
const genGroupStyle$1 = (token2) => {
const {
componentCls,
borderRadiusLG,
borderRadiusSM
} = token2;
return {
[`${componentCls}-group`]: Object.assign(Object.assign(Object.assign({}, resetComponent(token2)), genInputGroupStyle(token2)), {
"&-rtl": {
direction: "rtl"
},
"&-wrapper": Object.assign(Object.assign(Object.assign({
display: "inline-block",
width: "100%",
textAlign: "start",
verticalAlign: "top",
"&-rtl": {
direction: "rtl"
},
// Size
"&-lg": {
[`${componentCls}-group-addon`]: {
borderRadius: borderRadiusLG,
fontSize: token2.inputFontSizeLG
}
},
"&-sm": {
[`${componentCls}-group-addon`]: {
borderRadius: borderRadiusSM
}
}
}, genOutlinedGroupStyle(token2)), genFilledGroupStyle(token2)), {
// '&-disabled': {
// [`${componentCls}-group-addon`]: {
// ...genDisabledStyle(token),
// },
// },
// Fix the issue of using icons in Space Compact mode
// https://github.com/ant-design/ant-design/issues/42122
[`&:not(${componentCls}-compact-first-item):not(${componentCls}-compact-last-item)${componentCls}-compact-item`]: {
[`${componentCls}, ${componentCls}-group-addon`]: {
borderRadius: 0
}
},
[`&:not(${componentCls}-compact-last-item)${componentCls}-compact-first-item`]: {
[`${componentCls}, ${componentCls}-group-addon`]: {
borderStartEndRadius: 0,
borderEndEndRadius: 0
}
},
[`&:not(${componentCls}-compact-first-item)${componentCls}-compact-last-item`]: {
[`${componentCls}, ${componentCls}-group-addon`]: {
borderStartStartRadius: 0,
borderEndStartRadius: 0
}
},
// Fix the issue of input use show-count param in space compact mode
// https://github.com/ant-design/ant-design/issues/46872
[`&:not(${componentCls}-compact-last-item)${componentCls}-compact-item`]: {
[`${componentCls}-affix-wrapper`]: {
borderStartEndRadius: 0,
borderEndEndRadius: 0
}
}
})
})
};
};
const genSearchInputStyle = (token2) => {
const {
componentCls,
antCls
} = token2;
const searchPrefixCls = `${componentCls}-search`;
return {
[searchPrefixCls]: {
[`${componentCls}`]: {
"&:hover, &:focus": {
borderColor: token2.colorPrimaryHover,
[`+ ${componentCls}-group-addon ${searchPrefixCls}-button:not(${antCls}-btn-primary)`]: {
borderInlineStartColor: token2.colorPrimaryHover
}
}
},
[`${componentCls}-affix-wrapper`]: {
borderRadius: 0
},
// fix slight height diff in Firefox:
// https://ant.design/components/auto-complete-cn/#components-auto-complete-demo-certain-category
[`${componentCls}-lg`]: {
lineHeight: token2.calc(token2.lineHeightLG).sub(2e-4).equal()
},
[`> ${componentCls}-group`]: {
[`> ${componentCls}-group-addon:last-child`]: {
insetInlineStart: -1,
padding: 0,
border: 0,
[`${searchPrefixCls}-button`]: {
// Fix https://github.com/ant-design/ant-design/issues/47150
marginInlineEnd: -1,
paddingTop: 0,
paddingBottom: 0,
borderStartStartRadius: 0,
borderStartEndRadius: token2.borderRadius,
borderEndEndRadius: token2.borderRadius,
borderEndStartRadius: 0,
boxShadow: "none"
},
[`${searchPrefixCls}-button:not(${antCls}-btn-primary)`]: {
color: token2.colorTextDescription,
"&:hover": {
color: token2.colorPrimaryHover
},
"&:active": {
color: token2.colorPrimaryActive
},
[`&${antCls}-btn-loading::before`]: {
insetInlineStart: 0,
insetInlineEnd: 0,
insetBlockStart: 0,
insetBlockEnd: 0
}
}
}
},
[`${searchPrefixCls}-button`]: {
height: token2.controlHeight,
"&:hover, &:focus": {
zIndex: 1
}
},
[`&-large ${searchPrefixCls}-button`]: {
height: token2.controlHeightLG
},
[`&-small ${searchPrefixCls}-button`]: {
height: token2.controlHeightSM
},
"&-rtl": {
direction: "rtl"
},
// ===================== Compact Item Customized Styles =====================
[`&${componentCls}-compact-item`]: {
[`&:not(${componentCls}-compact-last-item)`]: {
[`${componentCls}-group-addon`]: {
[`${componentCls}-search-button`]: {
marginInlineEnd: token2.calc(token2.lineWidth).mul(-1).equal(),
borderRadius: 0
}
}
},
[`&:not(${componentCls}-compact-first-item)`]: {
[`${componentCls},${componentCls}-affix-wrapper`]: {
borderRadius: 0
}
},
[`> ${componentCls}-group-addon ${componentCls}-search-button,
> ${componentCls},
${componentCls}-affix-wrapper`]: {
"&:hover, &:focus, &:active": {
zIndex: 2
}
},
[`> ${componentCls}-affix-wrapper-focused`]: {
zIndex: 2
}
}
}
};
};
const genTextAreaStyle = (token2) => {
const {
componentCls,
paddingLG
} = token2;
const textareaPrefixCls = `${componentCls}-textarea`;
return {
[textareaPrefixCls]: {
position: "relative",
"&-show-count": {
// https://github.com/ant-design/ant-design/issues/33049
[`> ${componentCls}`]: {
height: "100%"
},
[`${componentCls}-data-count`]: {
position: "absolute",
bottom: token2.calc(token2.fontSize).mul(token2.lineHeight).mul(-1).equal(),
insetInlineEnd: 0,
color: token2.colorTextDescription,
whiteSpace: "nowrap",
pointerEvents: "none"
}
},
[`
&-allow-clear > ${componentCls},
&-affix-wrapper${textareaPrefixCls}-has-feedback ${componentCls}
`]: {
paddingInlineEnd: paddingLG
},
[`&-affix-wrapper${componentCls}-affix-wrapper`]: {
padding: 0,
[`> textarea${componentCls}`]: {
fontSize: "inherit",
border: "none",
outline: "none",
background: "transparent",
"&:focus": {
boxShadow: "none !important"
}
},
[`${componentCls}-suffix`]: {
margin: 0,
"> *:not(:last-child)": {
marginInline: 0
},
// Clear Icon
[`${componentCls}-clear-icon`]: {
position: "absolute",
insetInlineEnd: token2.paddingInline,
insetBlockStart: token2.paddingXS
},
// Feedback Icon
[`${textareaPrefixCls}-suffix`]: {
position: "absolute",
top: 0,
insetInlineEnd: token2.paddingInline,
bottom: 0,
zIndex: 1,
display: "inline-flex",
alignItems: "center",
margin: "auto",
pointerEvents: "none"
}
}
},
[`&-affix-wrapper${componentCls}-affix-wrapper-sm`]: {
[`${componentCls}-suffix`]: {
[`${componentCls}-clear-icon`]: {
insetInlineEnd: token2.paddingInlineSM
}
}
}
}
};
};
const genRangeStyle = (token2) => {
const {
componentCls
} = token2;
return {
[`${componentCls}-out-of-range`]: {
[`&, & input, & textarea, ${componentCls}-show-count-suffix, ${componentCls}-data-count`]: {
color: token2.colorError
}
}
};
};
genStyleHooks("Input", (token2) => {
const inputToken = merge(token2, initInputToken(token2));
return [
genInputStyle(inputToken),
genTextAreaStyle(inputToken),
genAffixStyle(inputToken),
genGroupStyle$1(inputToken),
genSearchInputStyle(inputToken),
genRangeStyle(inputToken),
// =====================================================
// == Space Compact ==
// =====================================================
genCompactItemStyle(inputToken)
];
}, initComponentToken, {
resetFont: false
});
const initMotionCommon = (duration) => ({
animationDuration: duration,
animationFillMode: "both"
});
const initMotionCommonLeave = (duration) => ({
animationDuration: duration,
animationFillMode: "both"
});
const initMotion = function(motionCls, inKeyframes, outKeyframes, duration) {
let sameLevel = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : false;
const sameLevelPrefix = sameLevel ? "&" : "";
return {
[`
${sameLevelPrefix}${motionCls}-enter,
${sameLevelPrefix}${motionCls}-appear
`]: Object.assign(Object.assign({}, initMotionCommon(duration)), {
animationPlayState: "paused"
}),
[`${sameLevelPrefix}${motionCls}-leave`]: Object.assign(Object.assign({}, initMotionCommonLeave(duration)), {
animationPlayState: "paused"
}),
[`
${sameLevelPrefix}${motionCls}-enter${motionCls}-enter-active,
${sameLevelPrefix}${motionCls}-appear${motionCls}-appear-active
`]: {
animationName: inKeyframes,
animationPlayState: "running"
},
[`${sameLevelPrefix}${motionCls}-leave${motionCls}-leave-active`]: {
animationName: outKeyframes,
animationPlayState: "running",
pointerEvents: "none"
}
};
};
const moveDownIn = new Keyframe("antMoveDownIn", {
"0%": {
transform: "translate3d(0, 100%, 0)",
transformOrigin: "0 0",
opacity: 0
},
"100%": {
transform: "translate3d(0, 0, 0)",
transformOrigin: "0 0",
opacity: 1
}
});
const moveDownOut = new Keyframe("antMoveDownOut", {
"0%": {
transform: "translate3d(0, 0, 0)",
transformOrigin: "0 0",
opacity: 1
},
"100%": {
transform: "translate3d(0, 100%, 0)",
transformOrigin: "0 0",
opacity: 0
}
});
const moveLeftIn = new Keyframe("antMoveLeftIn", {
"0%": {
transform: "translate3d(-100%, 0, 0)",
transformOrigin: "0 0",
opacity: 0
},
"100%": {
transform: "translate3d(0, 0, 0)",
transformOrigin: "0 0",
opacity: 1
}
});
const moveLeftOut = new Keyframe("antMoveLeftOut", {
"0%": {
transform: "translate3d(0, 0, 0)",
transformOrigin: "0 0",
opacity: 1
},
"100%": {
transform: "translate3d(-100%, 0, 0)",
transformOrigin: "0 0",
opacity: 0
}
});
const moveRightIn = new Keyframe("antMoveRightIn", {
"0%": {
transform: "translate3d(100%, 0, 0)",
transformOrigin: "0 0",
opacity: 0
},
"100%": {
transform: "translate3d(0, 0, 0)",
transformOrigin: "0 0",
opacity: 1
}
});
const moveRightOut = new Keyframe("antMoveRightOut", {
"0%": {
transform: "translate3d(0, 0, 0)",
transformOrigin: "0 0",
opacity: 1
},
"100%": {
transform: "translate3d(100%, 0, 0)",
transformOrigin: "0 0",
opacity: 0
}
});
const moveUpIn = new Keyframe("antMoveUpIn", {
"0%": {
transform: "translate3d(0, -100%, 0)",
transformOrigin: "0 0",
opacity: 0
},
"100%": {
transform: "translate3d(0, 0, 0)",
transformOrigin: "0 0",
opacity: 1
}
});
const moveUpOut = new Keyframe("antMoveUpOut", {
"0%": {
transform: "translate3d(0, 0, 0)",
transformOrigin: "0 0",
opacity: 1
},
"100%": {
transform: "translate3d(0, -100%, 0)",
transformOrigin: "0 0",
opacity: 0
}
});
const moveMotion = {
"move-up": {
inKeyframes: moveUpIn,
outKeyframes: moveUpOut
},
"move-down": {
inKeyframes: moveDownIn,
outKeyframes: moveDownOut
},
"move-left": {
inKeyframes: moveLeftIn,
outKeyframes: moveLeftOut
},
"move-right": {
inKeyframes: moveRightIn,
outKeyframes: moveRightOut
}
};
const initMoveMotion = (token2, motionName) => {
const {
antCls
} = token2;
const motionCls = `${antCls}-${motionName}`;
const {
inKeyframes,
outKeyframes
} = moveMotion[motionName];
return [initMotion(motionCls, inKeyframes, outKeyframes, token2.motionDurationMid), {
[`
${motionCls}-enter,
${motionCls}-appear
`]: {
opacity: 0,
animationTimingFunction: token2.motionEaseOutCirc
},
[`${motionCls}-leave`]: {
animationTimingFunction: token2.motionEaseInOutCirc
}
}];
};
const slideUpIn = new Keyframe("antSlideUpIn", {
"0%": {
transform: "scaleY(0.8)",
transformOrigin: "0% 0%",
opacity: 0
},
"100%": {
transform: "scaleY(1)",
transformOrigin: "0% 0%",
opacity: 1
}
});
const slideUpOut = new Keyframe("antSlideUpOut", {
"0%": {
transform: "scaleY(1)",
transformOrigin: "0% 0%",
opacity: 1
},
"100%": {
transform: "scaleY(0.8)",
transformOrigin: "0% 0%",
opacity: 0
}
});
const slideDownIn = new Keyframe("antSlideDownIn", {
"0%": {
transform: "scaleY(0.8)",
transformOrigin: "100% 100%",
opacity: 0
},
"100%": {
transform: "scaleY(1)",
transformOrigin: "100% 100%",
opacity: 1
}
});
const slideDownOut = new Keyframe("antSlideDownOut", {
"0%": {
transform: "scaleY(1)",
transformOrigin: "100% 100%",
opacity: 1
},
"100%": {
transform: "scaleY(0.8)",
transformOrigin: "100% 100%",
opacity: 0
}
});
const slideLeftIn = new Keyframe("antSlideLeftIn", {
"0%": {
transform: "scaleX(0.8)",
transformOrigin: "0% 0%",
opacity: 0
},
"100%": {
transform: "scaleX(1)",
transformOrigin: "0% 0%",
opacity: 1
}
});
const slideLeftOut = new Keyframe("antSlideLeftOut", {
"0%": {
transform: "scaleX(1)",
transformOrigin: "0% 0%",
opacity: 1
},
"100%": {
transform: "scaleX(0.8)",
transformOrigin: "0% 0%",
opacity: 0
}
});
const slideRightIn = new Keyframe("antSlideRightIn", {
"0%": {
transform: "scaleX(0.8)",
transformOrigin: "100% 0%",
opacity: 0
},
"100%": {
transform: "scaleX(1)",
transformOrigin: "100% 0%",
opacity: 1
}
});
const slideRightOut = new Keyframe("antSlideRightOut", {
"0%": {
transform: "scaleX(1)",
transformOrigin: "100% 0%",
opacity: 1
},
"100%": {
transform: "scaleX(0.8)",
transformOrigin: "100% 0%",
opacity: 0
}
});
const slideMotion = {
"slide-up": {
inKeyframes: slideUpIn,
outKeyframes: slideUpOut
},
"slide-down": {
inKeyframes: slideDownIn,
outKeyframes: slideDownOut
},
"slide-left": {
inKeyframes: slideLeftIn,
outKeyframes: slideLeftOut
},
"slide-right": {
inKeyframes: slideRightIn,
outKeyframes: slideRightOut
}
};
const initSlideMotion = (token2, motionName) => {
const {
antCls
} = token2;
const motionCls = `${antCls}-${motionName}`;
const {
inKeyframes,
outKeyframes
} = slideMotion[motionName];
return [initMotion(motionCls, inKeyframes, outKeyframes, token2.motionDurationMid), {
[`
${motionCls}-enter,
${motionCls}-appear
`]: {
transform: "scale(0)",
transformOrigin: "0% 0%",
opacity: 0,
animationTimingFunction: token2.motionEaseOutQuint,
"&-prepare": {
transform: "scale(1)"
}
},
[`${motionCls}-leave`]: {
animationTimingFunction: token2.motionEaseInQuint
}
}];
};
function getArrowToken(token2) {
const {
sizePopupArrow,
borderRadiusXS,
borderRadiusOuter
} = token2;
const unitWidth = sizePopupArrow / 2;
const ax = 0;
const ay = unitWidth;
const bx = borderRadiusOuter * 1 / Math.sqrt(2);
const by = unitWidth - borderRadiusOuter * (1 - 1 / Math.sqrt(2));
const cx = unitWidth - borderRadiusXS * (1 / Math.sqrt(2));
const cy = borderRadiusOuter * (Math.sqrt(2) - 1) + borderRadiusXS * (1 / Math.sqrt(2));
const dx = 2 * unitWidth - cx;
const dy = cy;
const ex = 2 * unitWidth - bx;
const ey = by;
const fx = 2 * unitWidth - ax;
const fy = ay;
const shadowWidth = unitWidth * Math.sqrt(2) + borderRadiusOuter * (Math.sqrt(2) - 2);
const polygonOffset = borderRadiusOuter * (Math.sqrt(2) - 1);
const arrowPolygon = `polygon(${polygonOffset}px 100%, 50% ${polygonOffset}px, ${2 * unitWidth - polygonOffset}px 100%, ${polygonOffset}px 100%)`;
const arrowPath = `path('M ${ax} ${ay} A ${borderRadiusOuter} ${borderRadiusOuter} 0 0 0 ${bx} ${by} L ${cx} ${cy} A ${borderRadiusXS} ${borderRadiusXS} 0 0 1 ${dx} ${dy} L ${ex} ${ey} A ${borderRadiusOuter} ${borderRadiusOuter} 0 0 0 ${fx} ${fy} Z')`;
return {
arrowShadowWidth: shadowWidth,
arrowPath,
arrowPolygon
};
}
const genRoundedArrow = (token2, bgColor, boxShadow) => {
const {
sizePopupArrow,
arrowPolygon,
arrowPath,
arrowShadowWidth,
borderRadiusXS,
calc
} = token2;
return {
pointerEvents: "none",
width: sizePopupArrow,
height: sizePopupArrow,
overflow: "hidden",
"&::before": {
position: "absolute",
bottom: 0,
insetInlineStart: 0,
width: sizePopupArrow,
height: calc(sizePopupArrow).div(2).equal(),
background: bgColor,
clipPath: {
_multi_value_: true,
value: [arrowPolygon, arrowPath]
},
content: '""'
},
"&::after": {
content: '""',
position: "absolute",
width: arrowShadowWidth,
height: arrowShadowWidth,
bottom: 0,
insetInline: 0,
margin: "auto",
borderRadius: {
_skip_check_: true,
value: `0 0 ${unit(borderRadiusXS)} 0`
},
transform: "translateY(50%) rotate(-135deg)",
boxShadow,
zIndex: 0,
background: "transparent"
}
};
};
const getMultipleSelectorUnit = (token2) => {
const {
multipleSelectItemHeight,
paddingXXS,
lineWidth,
INTERNAL_FIXED_ITEM_MARGIN
} = token2;
const basePadding = token2.max(token2.calc(paddingXXS).sub(lineWidth).equal(), 0);
const containerPadding = token2.max(token2.calc(basePadding).sub(INTERNAL_FIXED_ITEM_MARGIN).equal(), 0);
return {
basePadding,
containerPadding,
itemHeight: unit(multipleSelectItemHeight),
itemLineHeight: unit(token2.calc(multipleSelectItemHeight).sub(token2.calc(token2.lineWidth).mul(2)).equal())
};
};
const genOverflowStyle = (token2) => {
const {
componentCls,
iconCls,
borderRadiusSM,
motionDurationSlow,
paddingXS,
multipleItemColorDisabled,
multipleItemBorderColorDisabled,
colorIcon,
colorIconHover,
INTERNAL_FIXED_ITEM_MARGIN
} = token2;
const selectOverflowPrefixCls = `${componentCls}-selection-overflow`;
return {
/**
* Do not merge `height` & `line-height` under style with `selection` & `search`, since chrome
* may update to redesign with its align logic.
*/
// =========================== Overflow ===========================
[selectOverflowPrefixCls]: {
position: "relative",
display: "flex",
flex: "auto",
flexWrap: "wrap",
maxWidth: "100%",
"&-item": {
flex: "none",
alignSelf: "center",
maxWidth: "100%",
display: "inline-flex"
},
// ======================== Selections ==========================
[`${componentCls}-selection-item`]: {
display: "flex",
alignSelf: "center",
flex: "none",
boxSizing: "border-box",
maxWidth: "100%",
marginBlock: INTERNAL_FIXED_ITEM_MARGIN,
borderRadius: borderRadiusSM,
cursor: "default",
transition: `font-size ${motionDurationSlow}, line-height ${motionDurationSlow}, height ${motionDurationSlow}`,
marginInlineEnd: token2.calc(INTERNAL_FIXED_ITEM_MARGIN).mul(2).equal(),
paddingInlineStart: paddingXS,
paddingInlineEnd: token2.calc(paddingXS).div(2).equal(),
[`${componentCls}-disabled&`]: {
color: multipleItemColorDisabled,
borderColor: multipleItemBorderColorDisabled,
cursor: "not-allowed"
},
// It's ok not to do this, but 24px makes bottom narrow in view should adjust
"&-content": {
display: "inline-block",
marginInlineEnd: token2.calc(paddingXS).div(2).equal(),
overflow: "hidden",
whiteSpace: "pre",
// fix whitespace wrapping. custom tags display all whitespace within.
textOverflow: "ellipsis"
},
"&-remove": Object.assign(Object.assign({}, resetIcon()), {
display: "inline-flex",
alignItems: "center",
color: colorIcon,
fontWeight: "bold",
fontSize: 10,
lineHeight: "inherit",
cursor: "pointer",
[`> ${iconCls}`]: {
verticalAlign: "-0.2em"
},
"&:hover": {
color: colorIconHover
}
})
}
}
};
};
const genSize = (token2, suffix) => {
const {
componentCls,
controlHeight
} = token2;
const suffixCls = suffix ? `${componentCls}-${suffix}` : "";
const multipleSelectorUnit = getMultipleSelectorUnit(token2);
return [
// genSelectionStyle(token, suffix),
{
[`${componentCls}-multiple${suffixCls}`]: {
paddingBlock: multipleSelectorUnit.containerPadding,
paddingInlineStart: multipleSelectorUnit.basePadding,
minHeight: controlHeight,
// ======================== Selections ========================
[`${componentCls}-selection-item`]: {
height: multipleSelectorUnit.itemHeight,
lineHeight: unit(multipleSelectorUnit.itemLineHeight)
}
}
}
];
};
const genPickerMultipleStyle = (token2) => {
const {
componentCls,
calc,
lineWidth
} = token2;
const smallToken = merge(token2, {
fontHeight: token2.fontSize,
selectHeight: token2.controlHeightSM,
multipleSelectItemHeight: token2.multipleItemHeightSM,
borderRadius: token2.borderRadiusSM,
borderRadiusSM: token2.borderRadiusXS,
controlHeight: token2.controlHeightSM
});
const largeToken = merge(token2, {
fontHeight: calc(token2.multipleItemHeightLG).sub(calc(lineWidth).mul(2).equal()).equal(),
fontSize: token2.fontSizeLG,
selectHeight: token2.controlHeightLG,
multipleSelectItemHeight: token2.multipleItemHeightLG,
borderRadius: token2.borderRadiusLG,
borderRadiusSM: token2.borderRadius,
controlHeight: token2.controlHeightLG
});
return [
// ======================== Size ========================
genSize(smallToken, "small"),
genSize(token2),
genSize(largeToken, "large"),
// ====================== Selection ======================
{
[`${componentCls}${componentCls}-multiple`]: Object.assign(Object.assign({
width: "100%",
cursor: "text",
// ==================== Selector =====================
[`${componentCls}-selector`]: {
flex: "auto",
padding: 0,
position: "relative",
"&:after": {
margin: 0
},
// ================== placeholder ==================
[`${componentCls}-selection-placeholder`]: {
position: "absolute",
top: "50%",
insetInlineStart: token2.inputPaddingHorizontalBase,
insetInlineEnd: 0,
transform: "translateY(-50%)",
transition: `all ${token2.motionDurationSlow}`,
overflow: "hidden",
whiteSpace: "nowrap",
textOverflow: "ellipsis",
flex: 1,
color: token2.colorTextPlaceholder,
pointerEvents: "none"
}
}
}, genOverflowStyle(token2)), {
// ====================== Input ======================
// Input is `readonly`, which is used for a11y only
[`${componentCls}-multiple-input`]: {
width: 0,
height: 0,
border: 0,
visibility: "hidden",
position: "absolute",
zIndex: -1
}
})
}
];
};
const genPickerCellInnerStyle = (token2) => {
const {
pickerCellCls,
pickerCellInnerCls,
cellHeight,
borderRadiusSM,
motionDurationMid,
cellHoverBg,
lineWidth,
lineType,
colorPrimary,
cellActiveWithRangeBg,
colorTextLightSolid,
colorTextDisabled,
cellBgDisabled,
colorFillSecondary
} = token2;
return {
"&::before": {
position: "absolute",
top: "50%",
insetInlineStart: 0,
insetInlineEnd: 0,
zIndex: 1,
height: cellHeight,
transform: "translateY(-50%)",
content: '""'
},
// >>> Default
[pickerCellInnerCls]: {
position: "relative",
zIndex: 2,
display: "inline-block",
minWidth: cellHeight,
height: cellHeight,
lineHeight: unit(cellHeight),
borderRadius: borderRadiusSM,
transition: `background ${motionDurationMid}`
},
// >>> Hover
[`&:hover:not(${pickerCellCls}-in-view),
&:hover:not(${pickerCellCls}-selected):not(${pickerCellCls}-range-start):not(${pickerCellCls}-range-end)`]: {
[pickerCellInnerCls]: {
background: cellHoverBg
}
},
// >>> Today
[`&-in-view${pickerCellCls}-today ${pickerCellInnerCls}`]: {
"&::before": {
position: "absolute",
top: 0,
insetInlineEnd: 0,
bottom: 0,
insetInlineStart: 0,
zIndex: 1,
border: `${unit(lineWidth)} ${lineType} ${colorPrimary}`,
borderRadius: borderRadiusSM,
content: '""'
}
},
// >>> In Range
[`&-in-view${pickerCellCls}-in-range,
&-in-view${pickerCellCls}-range-start,
&-in-view${pickerCellCls}-range-end`]: {
position: "relative",
[`&:not(${pickerCellCls}-disabled):before`]: {
background: cellActiveWithRangeBg
}
},
// >>> Selected
[`&-in-view${pickerCellCls}-selected,
&-in-view${pickerCellCls}-range-start,
&-in-view${pickerCellCls}-range-end`]: {
[`&:not(${pickerCellCls}-disabled) ${pickerCellInnerCls}`]: {
color: colorTextLightSolid,
background: colorPrimary
},
[`&${pickerCellCls}-disabled ${pickerCellInnerCls}`]: {
background: colorFillSecondary
}
},
[`&-in-view${pickerCellCls}-range-start:not(${pickerCellCls}-disabled):before`]: {
insetInlineStart: "50%"
},
[`&-in-view${pickerCellCls}-range-end:not(${pickerCellCls}-disabled):before`]: {
insetInlineEnd: "50%"
},
// range start border-radius
[`&-in-view${pickerCellCls}-range-start:not(${pickerCellCls}-range-end) ${pickerCellInnerCls}`]: {
borderStartStartRadius: borderRadiusSM,
borderEndStartRadius: borderRadiusSM,
borderStartEndRadius: 0,
borderEndEndRadius: 0
},
// range end border-radius
[`&-in-view${pickerCellCls}-range-end:not(${pickerCellCls}-range-start) ${pickerCellInnerCls}`]: {
borderStartStartRadius: 0,
borderEndStartRadius: 0,
borderStartEndRadius: borderRadiusSM,
borderEndEndRadius: borderRadiusSM
},
// >>> Disabled
"&-disabled": {
color: colorTextDisabled,
pointerEvents: "none",
[pickerCellInnerCls]: {
background: "transparent"
},
"&::before": {
background: cellBgDisabled
}
},
[`&-disabled${pickerCellCls}-today ${pickerCellInnerCls}::before`]: {
borderColor: colorTextDisabled
}
};
};
const genPanelStyle = (token2) => {
const {
componentCls,
pickerCellCls,
pickerCellInnerCls,
pickerYearMonthCellWidth,
pickerControlIconSize,
cellWidth,
paddingSM,
paddingXS,
paddingXXS,
colorBgContainer,
lineWidth,
lineType,
borderRadiusLG,
colorPrimary,
colorTextHeading,
colorSplit,
pickerControlIconBorderWidth,
colorIcon,
textHeight,
motionDurationMid,
colorIconHover,
fontWeightStrong,
cellHeight,
pickerCellPaddingVertical,
colorTextDisabled,
colorText,
fontSize,
motionDurationSlow,
withoutTimeCellHeight,
pickerQuarterPanelContentHeight,
borderRadiusSM,
colorTextLightSolid,
cellHoverBg,
timeColumnHeight,
timeColumnWidth,
timeCellHeight,
controlItemBgActive,
marginXXS,
pickerDatePanelPaddingHorizontal,
pickerControlIconMargin
} = token2;
const pickerPanelWidth = token2.calc(cellWidth).mul(7).add(token2.calc(pickerDatePanelPaddingHorizontal).mul(2)).equal();
return {
[componentCls]: {
"&-panel": {
display: "inline-flex",
flexDirection: "column",
textAlign: "center",
background: colorBgContainer,
borderRadius: borderRadiusLG,
outline: "none",
"&-focused": {
borderColor: colorPrimary
},
"&-rtl": {
[`${componentCls}-prev-icon,
${componentCls}-super-prev-icon`]: {
transform: "rotate(45deg)"
},
[`${componentCls}-next-icon,
${componentCls}-super-next-icon`]: {
transform: "rotate(-135deg)"
}
}
},
// ========================================================
// = Shared Panel =
// ========================================================
[`&-decade-panel,
&-year-panel,
&-quarter-panel,
&-month-panel,
&-week-panel,
&-date-panel,
&-time-panel`]: {
display: "flex",
flexDirection: "column",
width: pickerPanelWidth
},
// ======================= Header =======================
"&-header": {
display: "flex",
padding: `0 ${unit(paddingXS)}`,
color: colorTextHeading,
borderBottom: `${unit(lineWidth)} ${lineType} ${colorSplit}`,
"> *": {
flex: "none"
},
button: {
padding: 0,
color: colorIcon,
lineHeight: unit(textHeight),
background: "transparent",
border: 0,
cursor: "pointer",
transition: `color ${motionDurationMid}`,
fontSize: "inherit",
display: "inline-flex",
alignItems: "center",
justifyContent: "center"
},
"> button": {
minWidth: "1.6em",
fontSize,
"&:hover": {
color: colorIconHover
},
"&:disabled": {
opacity: 0.25,
pointerEvents: "none"
}
},
"&-view": {
flex: "auto",
fontWeight: fontWeightStrong,
lineHeight: unit(textHeight),
"> button": {
color: "inherit",
fontWeight: "inherit",
"&:not(:first-child)": {
marginInlineStart: paddingXS
},
"&:hover": {
color: colorPrimary
}
}
}
},
// Arrow button
[`&-prev-icon,
&-next-icon,
&-super-prev-icon,
&-super-next-icon`]: {
position: "relative",
width: pickerControlIconSize,
height: pickerControlIconSize,
"&::before": {
position: "absolute",
top: 0,
insetInlineStart: 0,
width: pickerControlIconSize,
height: pickerControlIconSize,
border: `0 solid currentcolor`,
borderBlockWidth: `${unit(pickerControlIconBorderWidth)} 0`,
borderInlineWidth: `${unit(pickerControlIconBorderWidth)} 0`,
content: '""'
}
},
[`&-super-prev-icon,
&-super-next-icon`]: {
"&::after": {
position: "absolute",
top: pickerControlIconMargin,
insetInlineStart: pickerControlIconMargin,
display: "inline-block",
width: pickerControlIconSize,
height: pickerControlIconSize,
border: "0 solid currentcolor",
borderBlockWidth: `${unit(pickerControlIconBorderWidth)} 0`,
borderInlineWidth: `${unit(pickerControlIconBorderWidth)} 0`,
content: '""'
}
},
"&-prev-icon, &-super-prev-icon": {
transform: "rotate(-45deg)"
},
"&-next-icon, &-super-next-icon": {
transform: "rotate(135deg)"
},
// ======================== Body ========================
"&-content": {
width: "100%",
tableLayout: "fixed",
borderCollapse: "collapse",
"th, td": {
position: "relative",
minWidth: cellHeight,
fontWeight: "normal"
},
th: {
height: token2.calc(cellHeight).add(token2.calc(pickerCellPaddingVertical).mul(2)).equal(),
color: colorText,
verticalAlign: "middle"
}
},
"&-cell": Object.assign({
padding: `${unit(pickerCellPaddingVertical)} 0`,
color: colorTextDisabled,
cursor: "pointer",
// In view
"&-in-view": {
color: colorText
}
}, genPickerCellInnerStyle(token2)),
[`&-decade-panel,
&-year-panel,
&-quarter-panel,
&-month-panel`]: {
[`${componentCls}-content`]: {
height: token2.calc(withoutTimeCellHeight).mul(4).equal()
},
[pickerCellInnerCls]: {
padding: `0 ${unit(paddingXS)}`
}
},
"&-quarter-panel": {
[`${componentCls}-content`]: {
height: pickerQuarterPanelContentHeight
}
},
// ========================================================
// = Special =
// ========================================================
// ===================== Decade Panel =====================
"&-decade-panel": {
[pickerCellInnerCls]: {
padding: `0 ${unit(token2.calc(paddingXS).div(2).equal())}`
},
[`${componentCls}-cell::before`]: {
display: "none"
}
},
// ============= Year & Quarter & Month Panel =============
[`&-year-panel,
&-quarter-panel,
&-month-panel`]: {
[`${componentCls}-body`]: {
padding: `0 ${unit(paddingXS)}`
},
[pickerCellInnerCls]: {
width: pickerYearMonthCellWidth
}
},
// ====================== Date Panel ======================
"&-date-panel": {
[`${componentCls}-body`]: {
padding: `${unit(paddingXS)} ${unit(pickerDatePanelPaddingHorizontal)}`
},
[`${componentCls}-content th`]: {
boxSizing: "border-box",
padding: 0
}
},
// ====================== Week Panel ======================
"&-week-panel": {
// Clear cell style
[`${componentCls}-cell`]: {
[`&:hover ${pickerCellInnerCls},
&-selected ${pickerCellInnerCls},
${pickerCellInnerCls}`]: {
background: "transparent !important"
}
},
"&-row": {
td: {
"&:before": {
transition: `background ${motionDurationMid}`
},
"&:first-child:before": {
borderStartStartRadius: borderRadiusSM,
borderEndStartRadius: borderRadiusSM
},
"&:last-child:before": {
borderStartEndRadius: borderRadiusSM,
borderEndEndRadius: borderRadiusSM
}
},
"&:hover td": {
"&:before": {
background: cellHoverBg
}
},
"&-range-start td, &-range-end td, &-selected td, &-hover td": {
// Rise priority to override hover style
[`&${pickerCellCls}`]: {
"&:before": {
background: colorPrimary
},
[`&${componentCls}-cell-week`]: {
color: new TinyColor(colorTextLightSolid).setAlpha(0.5).toHexString()
},
[pickerCellInnerCls]: {
color: colorTextLightSolid
}
}
},
"&-range-hover td:before": {
background: controlItemBgActive
}
}
},
// >>> ShowWeek
"&-week-panel, &-date-panel-show-week": {
[`${componentCls}-body`]: {
padding: `${unit(paddingXS)} ${unit(paddingSM)}`
},
[`${componentCls}-content th`]: {
width: "auto"
}
},
// ==================== Datetime Panel ====================
"&-datetime-panel": {
display: "flex",
[`${componentCls}-time-panel`]: {
borderInlineStart: `${unit(lineWidth)} ${lineType} ${colorSplit}`
},
[`${componentCls}-date-panel,
${componentCls}-time-panel`]: {
transition: `opacity ${motionDurationSlow}`
},
// Keyboard
"&-active": {
[`${componentCls}-date-panel,
${componentCls}-time-panel`]: {
opacity: 0.3,
"&-active": {
opacity: 1
}
}
}
},
// ====================== Time Panel ======================
"&-time-panel": {
width: "auto",
minWidth: "auto",
[`${componentCls}-content`]: {
display: "flex",
flex: "auto",
height: timeColumnHeight
},
"&-column": {
flex: "1 0 auto",
width: timeColumnWidth,
margin: `${unit(paddingXXS)} 0`,
padding: 0,
overflowY: "hidden",
textAlign: "start",
listStyle: "none",
transition: `background ${motionDurationMid}`,
overflowX: "hidden",
"&::-webkit-scrollbar": {
width: 8,
backgroundColor: "transparent"
},
"&::-webkit-scrollbar-thumb": {
backgroundColor: token2.colorTextTertiary,
borderRadius: token2.borderRadiusSM
},
// For Firefox
"&": {
scrollbarWidth: "thin",
scrollbarColor: `${token2.colorTextTertiary} transparent`
},
"&::after": {
display: "block",
height: token2.calc("100%").sub(timeCellHeight).equal(),
content: '""'
},
"&:not(:first-child)": {
borderInlineStart: `${unit(lineWidth)} ${lineType} ${colorSplit}`
},
"&-active": {
background: new TinyColor(controlItemBgActive).setAlpha(0.2).toHexString()
},
"&:hover": {
overflowY: "auto"
},
"> li": {
margin: 0,
padding: 0,
[`&${componentCls}-time-panel-cell`]: {
marginInline: marginXXS,
[`${componentCls}-time-panel-cell-inner`]: {
display: "block",
width: token2.calc(timeColumnWidth).sub(token2.calc(marginXXS).mul(2)).equal(),
height: timeCellHeight,
margin: 0,
paddingBlock: 0,
paddingInlineEnd: 0,
paddingInlineStart: token2.calc(timeColumnWidth).sub(timeCellHeight).div(2).equal(),
color: colorText,
lineHeight: unit(timeCellHeight),
borderRadius: borderRadiusSM,
cursor: "pointer",
transition: `background ${motionDurationMid}`,
"&:hover": {
background: cellHoverBg
}
},
"&-selected": {
[`${componentCls}-time-panel-cell-inner`]: {
background: controlItemBgActive
}
},
"&-disabled": {
[`${componentCls}-time-panel-cell-inner`]: {
color: colorTextDisabled,
background: "transparent",
cursor: "not-allowed"
}
}
}
}
}
}
}
};
};
const genPickerPanelStyle = (token2) => {
const {
componentCls,
textHeight,
lineWidth,
paddingSM,
antCls,
colorPrimary,
cellActiveWithRangeBg,
colorPrimaryBorder,
lineType,
colorSplit
} = token2;
return {
[`${componentCls}-dropdown`]: {
// ======================== Footer ========================
[`${componentCls}-footer`]: {
borderTop: `${unit(lineWidth)} ${lineType} ${colorSplit}`,
"&-extra": {
padding: `0 ${unit(paddingSM)}`,
lineHeight: unit(token2.calc(textHeight).sub(token2.calc(lineWidth).mul(2)).equal()),
textAlign: "start",
"&:not(:last-child)": {
borderBottom: `${unit(lineWidth)} ${lineType} ${colorSplit}`
}
}
},
// ==================== Footer > Ranges ===================
[`${componentCls}-panels + ${componentCls}-footer ${componentCls}-ranges`]: {
justifyContent: "space-between"
},
[`${componentCls}-ranges`]: {
marginBlock: 0,
paddingInline: unit(paddingSM),
overflow: "hidden",
textAlign: "start",
listStyle: "none",
display: "flex",
justifyContent: "center",
alignItems: "center",
"> li": {
lineHeight: unit(token2.calc(textHeight).sub(token2.calc(lineWidth).mul(2)).equal()),
display: "inline-block"
},
[`${componentCls}-now-btn-disabled`]: {
pointerEvents: "none",
color: token2.colorTextDisabled
},
// https://github.com/ant-design/ant-design/issues/23687
[`${componentCls}-preset > ${antCls}-tag-blue`]: {
color: colorPrimary,
background: cellActiveWithRangeBg,
borderColor: colorPrimaryBorder,
cursor: "pointer"
},
[`${componentCls}-ok`]: {
paddingBlock: token2.calc(lineWidth).mul(2).equal(),
marginInlineStart: "auto"
}
}
}
};
};
const initPickerPanelToken = (token2) => {
const {
componentCls,
controlHeightLG,
paddingXXS,
padding
} = token2;
return {
pickerCellCls: `${componentCls}-cell`,
pickerCellInnerCls: `${componentCls}-cell-inner`,
pickerYearMonthCellWidth: token2.calc(controlHeightLG).mul(1.5).equal(),
pickerQuarterPanelContentHeight: token2.calc(controlHeightLG).mul(1.4).equal(),
pickerCellPaddingVertical: token2.calc(paddingXXS).add(token2.calc(paddingXXS).div(2)).equal(),
pickerCellBorderGap: 2,
// Magic for gap between cells
pickerControlIconSize: 7,
pickerControlIconMargin: 4,
pickerControlIconBorderWidth: 1.5,
pickerDatePanelPaddingHorizontal: token2.calc(padding).add(token2.calc(paddingXXS).div(2)).equal()
// 18 in normal
};
};
const initPanelComponentToken = (token2) => {
const {
colorBgContainerDisabled,
controlHeight,
controlHeightSM,
controlHeightLG,
paddingXXS,
lineWidth
} = token2;
const dblPaddingXXS = paddingXXS * 2;
const dblLineWidth = lineWidth * 2;
const multipleItemHeight = Math.min(controlHeight - dblPaddingXXS, controlHeight - dblLineWidth);
const multipleItemHeightSM = Math.min(controlHeightSM - dblPaddingXXS, controlHeightSM - dblLineWidth);
const multipleItemHeightLG = Math.min(controlHeightLG - dblPaddingXXS, controlHeightLG - dblLineWidth);
const INTERNAL_FIXED_ITEM_MARGIN = Math.floor(paddingXXS / 2);
const filledToken = {
INTERNAL_FIXED_ITEM_MARGIN,
cellHoverBg: token2.controlItemBgHover,
cellActiveWithRangeBg: token2.controlItemBgActive,
cellHoverWithRangeBg: new TinyColor(token2.colorPrimary).lighten(35).toHexString(),
cellRangeBorderColor: new TinyColor(token2.colorPrimary).lighten(20).toHexString(),
cellBgDisabled: colorBgContainerDisabled,
timeColumnWidth: controlHeightLG * 1.4,
timeColumnHeight: 28 * 8,
timeCellHeight: 28,
cellWidth: controlHeightSM * 1.5,
cellHeight: controlHeightSM,
textHeight: controlHeightLG,
withoutTimeCellHeight: controlHeightLG * 1.65,
multipleItemBg: token2.colorFillSecondary,
multipleItemBorderColor: "transparent",
multipleItemHeight,
multipleItemHeightSM,
multipleItemHeightLG,
multipleSelectorBgDisabled: colorBgContainerDisabled,
multipleItemColorDisabled: token2.colorTextDisabled,
multipleItemBorderColorDisabled: "transparent"
};
return filledToken;
};
const prepareComponentToken$1 = (token2) => Object.assign(Object.assign(Object.assign(Object.assign({}, initComponentToken(token2)), initPanelComponentToken(token2)), getArrowToken(token2)), {
presetsWidth: 120,
presetsMaxWidth: 200,
zIndexPopup: token2.zIndexPopupBase + 50
});
const genVariantsStyle = (token2) => {
const {
componentCls
} = token2;
return {
[componentCls]: [
Object.assign(Object.assign(Object.assign({}, genOutlinedStyle(token2)), genFilledStyle(token2)), genBorderlessStyle(token2)),
// ========================= Multiple =========================
{
"&-outlined": {
[`&${componentCls}-multiple ${componentCls}-selection-item`]: {
background: token2.multipleItemBg,
border: `${unit(token2.lineWidth)} ${token2.lineType} ${token2.multipleItemBorderColor}`
}
},
"&-filled": {
[`&${componentCls}-multiple ${componentCls}-selection-item`]: {
background: token2.colorBgContainer,
border: `${unit(token2.lineWidth)} ${token2.lineType} ${token2.colorSplit}`
}
},
"&-borderless": {
[`&${componentCls}-multiple ${componentCls}-selection-item`]: {
background: token2.multipleItemBg,
border: `${unit(token2.lineWidth)} ${token2.lineType} ${token2.multipleItemBorderColor}`
}
}
}
]
};
};
const genPickerPadding = (token2, inputHeight, fontHeight, paddingHorizontal) => {
const height = token2.calc(fontHeight).add(2).equal();
const paddingTop = token2.max(token2.calc(inputHeight).sub(height).div(2).equal(), 0);
const paddingBottom = token2.max(token2.calc(inputHeight).sub(height).sub(paddingTop).equal(), 0);
return {
padding: `${unit(paddingTop)} ${unit(paddingHorizontal)} ${unit(paddingBottom)}`
};
};
const genPickerStatusStyle = (token2) => {
const {
componentCls,
colorError,
colorWarning
} = token2;
return {
[`${componentCls}:not(${componentCls}-disabled):not([disabled])`]: {
[`&${componentCls}-status-error`]: {
[`${componentCls}-active-bar`]: {
background: colorError
}
},
[`&${componentCls}-status-warning`]: {
[`${componentCls}-active-bar`]: {
background: colorWarning
}
}
}
};
};
const genPickerStyle = (token2) => {
const {
componentCls,
antCls,
controlHeight,
paddingInline,
lineWidth,
lineType,
colorBorder,
borderRadius,
motionDurationMid,
colorTextDisabled,
colorTextPlaceholder,
controlHeightLG,
fontSizeLG,
controlHeightSM,
paddingInlineSM,
paddingXS,
marginXS,
colorTextDescription,
lineWidthBold,
colorPrimary,
motionDurationSlow,
zIndexPopup,
paddingXXS,
sizePopupArrow,
colorBgElevated,
borderRadiusLG,
boxShadowSecondary,
borderRadiusSM,
colorSplit,
cellHoverBg,
presetsWidth,
presetsMaxWidth,
boxShadowPopoverArrow,
fontHeight,
fontHeightLG,
lineHeightLG
} = token2;
return [
{
[componentCls]: Object.assign(Object.assign(Object.assign({}, resetComponent(token2)), genPickerPadding(token2, controlHeight, fontHeight, paddingInline)), {
position: "relative",
display: "inline-flex",
alignItems: "center",
lineHeight: 1,
borderRadius,
transition: `border ${motionDurationMid}, box-shadow ${motionDurationMid}, background ${motionDurationMid}`,
// ======================== Input =========================
[`${componentCls}-input`]: {
position: "relative",
display: "inline-flex",
alignItems: "center",
width: "100%",
"> input": Object.assign(Object.assign({
position: "relative",
display: "inline-block",
width: "100%",
color: "inherit",
fontSize: token2.fontSize,
lineHeight: token2.lineHeight,
transition: `all ${motionDurationMid}`
}, genPlaceholderStyle(colorTextPlaceholder)), {
flex: "auto",
// Fix Firefox flex not correct:
// https://github.com/ant-design/ant-design/pull/20023#issuecomment-564389553
minWidth: 1,
height: "auto",
padding: 0,
background: "transparent",
border: 0,
fontFamily: "inherit",
"&:focus": {
boxShadow: "none",
outline: 0
},
"&[disabled]": {
background: "transparent",
color: colorTextDisabled,
cursor: "not-allowed"
}
}),
"&-placeholder": {
"> input": {
color: colorTextPlaceholder
}
}
},
// Size
"&-large": Object.assign(Object.assign({}, genPickerPadding(token2, controlHeightLG, fontHeightLG, paddingInline)), {
[`${componentCls}-input > input`]: {
fontSize: fontSizeLG,
lineHeight: lineHeightLG
}
}),
"&-small": Object.assign({}, genPickerPadding(token2, controlHeightSM, fontHeight, paddingInlineSM)),
[`${componentCls}-suffix`]: {
display: "flex",
flex: "none",
alignSelf: "center",
marginInlineStart: token2.calc(paddingXS).div(2).equal(),
color: colorTextDisabled,
lineHeight: 1,
pointerEvents: "none",
transition: `opacity ${motionDurationMid}, color ${motionDurationMid}`,
"> *": {
verticalAlign: "top",
"&:not(:last-child)": {
marginInlineEnd: marginXS
}
}
},
[`${componentCls}-clear`]: {
position: "absolute",
top: "50%",
insetInlineEnd: 0,
color: colorTextDisabled,
lineHeight: 1,
transform: "translateY(-50%)",
cursor: "pointer",
opacity: 0,
transition: `opacity ${motionDurationMid}, color ${motionDurationMid}`,
"> *": {
verticalAlign: "top"
},
"&:hover": {
color: colorTextDescription
}
},
"&:hover": {
[`${componentCls}-clear`]: {
opacity: 1
},
// Should use the following selector, but since `:has` has poor compatibility,
// we use `:not(:last-child)` instead, which may cause some problems in some cases.
// [`${componentCls}-suffix:has(+ ${componentCls}-clear)`]: {
[`${componentCls}-suffix:not(:last-child)`]: {
opacity: 0
}
},
[`${componentCls}-separator`]: {
position: "relative",
display: "inline-block",
width: "1em",
height: fontSizeLG,
color: colorTextDisabled,
fontSize: fontSizeLG,
verticalAlign: "top",
cursor: "default",
[`${componentCls}-focused &`]: {
color: colorTextDescription
},
[`${componentCls}-range-separator &`]: {
[`${componentCls}-disabled &`]: {
cursor: "not-allowed"
}
}
},
// ======================== Range =========================
"&-range": {
position: "relative",
display: "inline-flex",
// Active bar
[`${componentCls}-active-bar`]: {
bottom: token2.calc(lineWidth).mul(-1).equal(),
height: lineWidthBold,
background: colorPrimary,
opacity: 0,
transition: `all ${motionDurationSlow} ease-out`,
pointerEvents: "none"
},
[`&${componentCls}-focused`]: {
[`${componentCls}-active-bar`]: {
opacity: 1
}
},
[`${componentCls}-range-separator`]: {
alignItems: "center",
padding: `0 ${unit(paddingXS)}`,
lineHeight: 1
}
},
// ======================== Clear =========================
"&-range, &-multiple": {
// Clear
[`${componentCls}-clear`]: {
insetInlineEnd: paddingInline
},
[`&${componentCls}-small`]: {
[`${componentCls}-clear`]: {
insetInlineEnd: paddingInlineSM
}
}
},
// ======================= Dropdown =======================
"&-dropdown": Object.assign(Object.assign(Object.assign({}, resetComponent(token2)), genPanelStyle(token2)), {
pointerEvents: "none",
position: "absolute",
// Fix incorrect position of picker popup
// https://github.com/ant-design/ant-design/issues/35590
top: -9999,
left: {
_skip_check_: true,
value: -9999
},
zIndex: zIndexPopup,
[`&${componentCls}-dropdown-hidden`]: {
display: "none"
},
"&-rtl": {
direction: "rtl"
},
[`&${componentCls}-dropdown-placement-bottomLeft,
&${componentCls}-dropdown-placement-bottomRight`]: {
[`${componentCls}-range-arrow`]: {
top: 0,
display: "block",
transform: "translateY(-100%)"
}
},
[`&${componentCls}-dropdown-placement-topLeft,
&${componentCls}-dropdown-placement-topRight`]: {
[`${componentCls}-range-arrow`]: {
bottom: 0,
display: "block",
transform: "translateY(100%) rotate(180deg)"
}
},
[`&${antCls}-slide-up-enter${antCls}-slide-up-enter-active${componentCls}-dropdown-placement-topLeft,
&${antCls}-slide-up-enter${antCls}-slide-up-enter-active${componentCls}-dropdown-placement-topRight,
&${antCls}-slide-up-appear${antCls}-slide-up-appear-active${componentCls}-dropdown-placement-topLeft,
&${antCls}-slide-up-appear${antCls}-slide-up-appear-active${componentCls}-dropdown-placement-topRight`]: {
animationName: slideDownIn
},
[`&${antCls}-slide-up-enter${antCls}-slide-up-enter-active${componentCls}-dropdown-placement-bottomLeft,
&${antCls}-slide-up-enter${antCls}-slide-up-enter-active${componentCls}-dropdown-placement-bottomRight,
&${antCls}-slide-up-appear${antCls}-slide-up-appear-active${componentCls}-dropdown-placement-bottomLeft,
&${antCls}-slide-up-appear${antCls}-slide-up-appear-active${componentCls}-dropdown-placement-bottomRight`]: {
animationName: slideUpIn
},
// https://github.com/ant-design/ant-design/issues/48727
[`&${antCls}-slide-up-leave ${componentCls}-panel-container`]: {
pointerEvents: "none"
},
[`&${antCls}-slide-up-leave${antCls}-slide-up-leave-active${componentCls}-dropdown-placement-topLeft,
&${antCls}-slide-up-leave${antCls}-slide-up-leave-active${componentCls}-dropdown-placement-topRight`]: {
animationName: slideDownOut
},
[`&${antCls}-slide-up-leave${antCls}-slide-up-leave-active${componentCls}-dropdown-placement-bottomLeft,
&${antCls}-slide-up-leave${antCls}-slide-up-leave-active${componentCls}-dropdown-placement-bottomRight`]: {
animationName: slideUpOut
},
// Time picker with additional style
[`${componentCls}-panel > ${componentCls}-time-panel`]: {
paddingTop: paddingXXS
},
// ======================== Ranges ========================
[`${componentCls}-range-wrapper`]: {
display: "flex",
position: "relative"
},
[`${componentCls}-range-arrow`]: Object.assign(Object.assign({
position: "absolute",
zIndex: 1,
display: "none",
paddingInline: token2.calc(paddingInline).mul(1.5).equal(),
boxSizing: "content-box",
transition: `all ${motionDurationSlow} ease-out`
}, genRoundedArrow(token2, colorBgElevated, boxShadowPopoverArrow)), {
"&:before": {
insetInlineStart: token2.calc(paddingInline).mul(1.5).equal()
}
}),
[`${componentCls}-panel-container`]: {
overflow: "hidden",
verticalAlign: "top",
background: colorBgElevated,
borderRadius: borderRadiusLG,
boxShadow: boxShadowSecondary,
transition: `margin ${motionDurationSlow}`,
display: "inline-block",
pointerEvents: "auto",
// ======================== Layout ========================
[`${componentCls}-panel-layout`]: {
display: "flex",
flexWrap: "nowrap",
alignItems: "stretch"
},
// ======================== Preset ========================
[`${componentCls}-presets`]: {
display: "flex",
flexDirection: "column",
minWidth: presetsWidth,
maxWidth: presetsMaxWidth,
ul: {
height: 0,
flex: "auto",
listStyle: "none",
overflow: "auto",
margin: 0,
padding: paddingXS,
borderInlineEnd: `${unit(lineWidth)} ${lineType} ${colorSplit}`,
li: Object.assign(Object.assign({}, textEllipsis), {
borderRadius: borderRadiusSM,
paddingInline: paddingXS,
paddingBlock: token2.calc(controlHeightSM).sub(fontHeight).div(2).equal(),
cursor: "pointer",
transition: `all ${motionDurationSlow}`,
"+ li": {
marginTop: marginXS
},
"&:hover": {
background: cellHoverBg
}
})
}
},
// ======================== Panels ========================
[`${componentCls}-panels`]: {
display: "inline-flex",
flexWrap: "nowrap",
// [`${componentCls}-panel`]: {
// borderWidth: `0 0 ${unit(lineWidth)}`,
// },
"&:last-child": {
[`${componentCls}-panel`]: {
borderWidth: 0
}
}
},
[`${componentCls}-panel`]: {
verticalAlign: "top",
background: "transparent",
borderRadius: 0,
borderWidth: 0,
[`${componentCls}-content, table`]: {
textAlign: "center"
},
"&-focused": {
borderColor: colorBorder
}
}
}
}),
"&-dropdown-range": {
padding: `${unit(token2.calc(sizePopupArrow).mul(2).div(3).equal())} 0`,
"&-hidden": {
display: "none"
}
},
"&-rtl": {
direction: "rtl",
[`${componentCls}-separator`]: {
transform: "rotate(180deg)"
},
[`${componentCls}-footer`]: {
"&-extra": {
direction: "rtl"
}
}
}
})
},
// Follow code may reuse in other components
initSlideMotion(token2, "slide-up"),
initSlideMotion(token2, "slide-down"),
initMoveMotion(token2, "move-up"),
initMoveMotion(token2, "move-down")
];
};
const useStyle$2 = genStyleHooks("DatePicker", (token2) => {
const pickerToken = merge(initInputToken(token2), initPickerPanelToken(token2), {
inputPaddingHorizontalBase: token2.calc(token2.paddingSM).sub(1).equal(),
multipleSelectItemHeight: token2.multipleItemHeight,
selectHeight: token2.controlHeight
});
return [
genPickerPanelStyle(pickerToken),
genPickerStyle(pickerToken),
genVariantsStyle(pickerToken),
genPickerStatusStyle(pickerToken),
genPickerMultipleStyle(pickerToken),
// =====================================================
// == Space Compact ==
// =====================================================
genCompactItemStyle(token2, {
focusElCls: `${token2.componentCls}-focused`
})
];
}, prepareComponentToken$1);
var CheckOutlined$1 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 00-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1.4-12.8-6.3-12.8z" } }] }, "name": "check", "theme": "outlined" };
var CheckOutlined = function CheckOutlined2(props, ref) {
return /* @__PURE__ */ React.createElement(Icon$1, _extends({}, props, {
ref,
icon: CheckOutlined$1
}));
};
var RefIcon$5 = /* @__PURE__ */ React.forwardRef(CheckOutlined);
if (process.env.NODE_ENV !== "production") {
RefIcon$5.displayName = "CheckOutlined";
}
var CloseCircleFilled$1 = { "icon": { "tag": "svg", "attrs": { "fill-rule": "evenodd", "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M512 64c247.4 0 448 200.6 448 448S759.4 960 512 960 64 759.4 64 512 264.6 64 512 64zm127.98 274.82h-.04l-.08.06L512 466.75 384.14 338.88c-.04-.05-.06-.06-.08-.06a.12.12 0 00-.07 0c-.03 0-.05.01-.09.05l-45.02 45.02a.2.2 0 00-.05.09.12.12 0 000 .07v.02a.27.27 0 00.06.06L466.75 512 338.88 639.86c-.05.04-.06.06-.06.08a.12.12 0 000 .07c0 .03.01.05.05.09l45.02 45.02a.2.2 0 00.09.05.12.12 0 00.07 0c.02 0 .04-.01.08-.05L512 557.25l127.86 127.87c.04.04.06.05.08.05a.12.12 0 00.07 0c.03 0 .05-.01.09-.05l45.02-45.02a.2.2 0 00.05-.09.12.12 0 000-.07v-.02a.27.27 0 00-.05-.06L557.25 512l127.87-127.86c.04-.04.05-.06.05-.08a.12.12 0 000-.07c0-.03-.01-.05-.05-.09l-45.02-45.02a.2.2 0 00-.09-.05.12.12 0 00-.07 0z" } }] }, "name": "close-circle", "theme": "filled" };
var CloseCircleFilled = function CloseCircleFilled2(props, ref) {
return /* @__PURE__ */ React.createElement(Icon$1, _extends({}, props, {
ref,
icon: CloseCircleFilled$1
}));
};
var RefIcon$4 = /* @__PURE__ */ React.forwardRef(CloseCircleFilled);
if (process.env.NODE_ENV !== "production") {
RefIcon$4.displayName = "CloseCircleFilled";
}
var CloseOutlined$1 = { "icon": { "tag": "svg", "attrs": { "fill-rule": "evenodd", "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M799.86 166.31c.02 0 .04.02.08.06l57.69 57.7c.04.03.05.05.06.08a.12.12 0 010 .06c0 .03-.02.05-.06.09L569.93 512l287.7 287.7c.04.04.05.06.06.09a.12.12 0 010 .07c0 .02-.02.04-.06.08l-57.7 57.69c-.03.04-.05.05-.07.06a.12.12 0 01-.07 0c-.03 0-.05-.02-.09-.06L512 569.93l-287.7 287.7c-.04.04-.06.05-.09.06a.12.12 0 01-.07 0c-.02 0-.04-.02-.08-.06l-57.69-57.7c-.04-.03-.05-.05-.06-.07a.12.12 0 010-.07c0-.03.02-.05.06-.09L454.07 512l-287.7-287.7c-.04-.04-.05-.06-.06-.09a.12.12 0 010-.07c0-.02.02-.04.06-.08l57.7-57.69c.03-.04.05-.05.07-.06a.12.12 0 01.07 0c.03 0 .05.02.09.06L512 454.07l287.7-287.7c.04-.04.06-.05.09-.06a.12.12 0 01.07 0z" } }] }, "name": "close", "theme": "outlined" };
var CloseOutlined = function CloseOutlined2(props, ref) {
return /* @__PURE__ */ React.createElement(Icon$1, _extends({}, props, {
ref,
icon: CloseOutlined$1
}));
};
var RefIcon$3 = /* @__PURE__ */ React.forwardRef(CloseOutlined);
if (process.env.NODE_ENV !== "production") {
RefIcon$3.displayName = "CloseOutlined";
}
var DownOutlined$1 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z" } }] }, "name": "down", "theme": "outlined" };
var DownOutlined = function DownOutlined2(props, ref) {
return /* @__PURE__ */ React.createElement(Icon$1, _extends({}, props, {
ref,
icon: DownOutlined$1
}));
};
var RefIcon$2 = /* @__PURE__ */ React.forwardRef(DownOutlined);
if (process.env.NODE_ENV !== "production") {
RefIcon$2.displayName = "DownOutlined";
}
var LoadingOutlined$1 = { "icon": { "tag": "svg", "attrs": { "viewBox": "0 0 1024 1024", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z" } }] }, "name": "loading", "theme": "outlined" };
var LoadingOutlined = function LoadingOutlined2(props, ref) {
return /* @__PURE__ */ React.createElement(Icon$1, _extends({}, props, {
ref,
icon: LoadingOutlined$1
}));
};
var RefIcon$1 = /* @__PURE__ */ React.forwardRef(LoadingOutlined);
if (process.env.NODE_ENV !== "production") {
RefIcon$1.displayName = "LoadingOutlined";
}
var SearchOutlined$1 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0011.6 0l43.6-43.5a8.2 8.2 0 000-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z" } }] }, "name": "search", "theme": "outlined" };
var SearchOutlined = function SearchOutlined2(props, ref) {
return /* @__PURE__ */ React.createElement(Icon$1, _extends({}, props, {
ref,
icon: SearchOutlined$1
}));
};
var RefIcon = /* @__PURE__ */ React.forwardRef(SearchOutlined);
if (process.env.NODE_ENV !== "production") {
RefIcon.displayName = "SearchOutlined";
}
function useIcons$1(_ref) {
let {
suffixIcon,
clearIcon,
menuItemSelectedIcon,
removeIcon,
loading,
multiple,
hasFeedback,
prefixCls,
showSuffixIcon,
feedbackIcon,
showArrow,
componentName
} = _ref;
if (process.env.NODE_ENV !== "production") {
const warning3 = devUseWarning(componentName);
warning3.deprecated(!clearIcon, "clearIcon", "allowClear={{ clearIcon: React.ReactNode }}");
}
const mergedClearIcon = clearIcon !== null && clearIcon !== void 0 ? clearIcon : /* @__PURE__ */ React.createElement(RefIcon$4, null);
const getSuffixIconNode = (arrowIcon) => {
if (suffixIcon === null && !hasFeedback && !showArrow) {
return null;
}
return /* @__PURE__ */ React.createElement(React.Fragment, null, showSuffixIcon !== false && arrowIcon, hasFeedback && feedbackIcon);
};
let mergedSuffixIcon = null;
if (suffixIcon !== void 0) {
mergedSuffixIcon = getSuffixIconNode(suffixIcon);
} else if (loading) {
mergedSuffixIcon = getSuffixIconNode(/* @__PURE__ */ React.createElement(RefIcon$1, {
spin: true
}));
} else {
const iconCls = `${prefixCls}-suffix`;
mergedSuffixIcon = (_ref2) => {
let {
open,
showSearch
} = _ref2;
if (open && showSearch) {
return getSuffixIconNode(/* @__PURE__ */ React.createElement(RefIcon, {
className: iconCls
}));
}
return getSuffixIconNode(/* @__PURE__ */ React.createElement(RefIcon$2, {
className: iconCls
}));
};
}
let mergedItemIcon = null;
if (menuItemSelectedIcon !== void 0) {
mergedItemIcon = menuItemSelectedIcon;
} else if (multiple) {
mergedItemIcon = /* @__PURE__ */ React.createElement(RefIcon$5, null);
} else {
mergedItemIcon = null;
}
let mergedRemoveIcon = null;
if (removeIcon !== void 0) {
mergedRemoveIcon = removeIcon;
} else {
mergedRemoveIcon = /* @__PURE__ */ React.createElement(RefIcon$3, null);
}
return {
clearIcon: mergedClearIcon,
suffixIcon: mergedSuffixIcon,
itemIcon: mergedItemIcon,
removeIcon: mergedRemoveIcon
};
}
function getPlaceholder(locale2, picker, customizePlaceholder) {
if (customizePlaceholder !== void 0) {
return customizePlaceholder;
}
if (picker === "year" && locale2.lang.yearPlaceholder) {
return locale2.lang.yearPlaceholder;
}
if (picker === "quarter" && locale2.lang.quarterPlaceholder) {
return locale2.lang.quarterPlaceholder;
}
if (picker === "month" && locale2.lang.monthPlaceholder) {
return locale2.lang.monthPlaceholder;
}
if (picker === "week" && locale2.lang.weekPlaceholder) {
return locale2.lang.weekPlaceholder;
}
if (picker === "time" && locale2.timePickerLocale.placeholder) {
return locale2.timePickerLocale.placeholder;
}
return locale2.lang.placeholder;
}
function getRangePlaceholder(locale2, picker, customizePlaceholder) {
if (customizePlaceholder !== void 0) {
return customizePlaceholder;
}
if (picker === "year" && locale2.lang.yearPlaceholder) {
return locale2.lang.rangeYearPlaceholder;
}
if (picker === "quarter" && locale2.lang.quarterPlaceholder) {
return locale2.lang.rangeQuarterPlaceholder;
}
if (picker === "month" && locale2.lang.monthPlaceholder) {
return locale2.lang.rangeMonthPlaceholder;
}
if (picker === "week" && locale2.lang.weekPlaceholder) {
return locale2.lang.rangeWeekPlaceholder;
}
if (picker === "time" && locale2.timePickerLocale.placeholder) {
return locale2.timePickerLocale.rangePlaceholder;
}
return locale2.lang.rangePlaceholder;
}
function transPlacement2DropdownAlign(direction, placement) {
const overflow = {
adjustX: 1,
adjustY: 1
};
switch (placement) {
case "bottomLeft": {
return {
points: ["tl", "bl"],
offset: [0, 4],
overflow
};
}
case "bottomRight": {
return {
points: ["tr", "br"],
offset: [0, 4],
overflow
};
}
case "topLeft": {
return {
points: ["bl", "tl"],
offset: [0, -4],
overflow
};
}
case "topRight": {
return {
points: ["br", "tr"],
offset: [0, -4],
overflow
};
}
default: {
return {
points: direction === "rtl" ? ["tr", "br"] : ["tl", "bl"],
offset: [0, 4],
overflow
};
}
}
}
function useIcons(props, prefixCls) {
const {
allowClear = true
} = props;
const {
clearIcon,
removeIcon
} = useIcons$1(Object.assign(Object.assign({}, props), {
prefixCls,
componentName: "DatePicker"
}));
const mergedAllowClear = React.useMemo(() => {
if (allowClear === false) {
return false;
}
const allowClearConfig = allowClear === true ? {} : allowClear;
return Object.assign({
clearIcon
}, allowClearConfig);
}, [allowClear, clearIcon]);
return [mergedAllowClear, removeIcon];
}
function isFragment(child) {
return child && /* @__PURE__ */ React__default.isValidElement(child) && child.type === React__default.Fragment;
}
const replaceElement = (element, replacement, props) => {
if (!/* @__PURE__ */ React__default.isValidElement(element)) {
return replacement;
}
return /* @__PURE__ */ React__default.cloneElement(element, typeof props === "function" ? props(element.props || {}) : props);
};
function cloneElement(element, props) {
return replaceElement(element, element, props);
}
const genWaveStyle = (token2) => {
const {
componentCls,
colorPrimary
} = token2;
return {
[componentCls]: {
position: "absolute",
background: "transparent",
pointerEvents: "none",
boxSizing: "border-box",
color: `var(--wave-color, ${colorPrimary})`,
boxShadow: `0 0 0 0 currentcolor`,
opacity: 0.2,
// =================== Motion ===================
"&.wave-motion-appear": {
transition: [`box-shadow 0.4s ${token2.motionEaseOutCirc}`, `opacity 2s ${token2.motionEaseOutCirc}`].join(","),
"&-active": {
boxShadow: `0 0 0 6px currentcolor`,
opacity: 0
},
"&.wave-quick": {
transition: [`box-shadow ${token2.motionDurationSlow} ${token2.motionEaseInOut}`, `opacity ${token2.motionDurationSlow} ${token2.motionEaseInOut}`].join(",")
}
}
}
};
};
const useStyle$1 = genComponentStyleHook("Wave", (token2) => [genWaveStyle(token2)]);
const TARGET_CLS = `${defaultPrefixCls}-wave-target`;
var fullClone = _objectSpread2({}, ReactDOM);
var version = fullClone.version, reactRender = fullClone.render, unmountComponentAtNode = fullClone.unmountComponentAtNode;
var createRoot;
try {
var mainVersion = Number((version || "").split(".")[0]);
if (mainVersion >= 18) {
createRoot = fullClone.createRoot;
}
} catch (e) {
}
function toggleWarning(skip) {
var __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = fullClone.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
if (__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED && _typeof(__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === "object") {
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.usingClientEntryPoint = skip;
}
}
var MARK = "__rc_react_root__";
function modernRender(node2, container) {
toggleWarning(true);
var root = container[MARK] || createRoot(container);
toggleWarning(false);
root.render(node2);
container[MARK] = root;
}
function legacyRender(node2, container) {
reactRender(node2, container);
}
function render(node2, container) {
if (createRoot) {
modernRender(node2, container);
return;
}
legacyRender(node2, container);
}
function modernUnmount(_x) {
return _modernUnmount.apply(this, arguments);
}
function _modernUnmount() {
_modernUnmount = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee(container) {
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
return _context.abrupt("return", Promise.resolve().then(function() {
var _container$MARK;
(_container$MARK = container[MARK]) === null || _container$MARK === void 0 || _container$MARK.unmount();
delete container[MARK];
}));
case 1:
case "end":
return _context.stop();
}
}, _callee);
}));
return _modernUnmount.apply(this, arguments);
}
function legacyUnmount(container) {
unmountComponentAtNode(container);
}
function unmount(_x2) {
return _unmount.apply(this, arguments);
}
function _unmount() {
_unmount = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee2(container) {
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
if (!(createRoot !== void 0)) {
_context2.next = 2;
break;
}
return _context2.abrupt("return", modernUnmount(container));
case 2:
legacyUnmount(container);
case 3:
case "end":
return _context2.stop();
}
}, _callee2);
}));
return _unmount.apply(this, arguments);
}
function isNotGrey(color) {
const match2 = (color || "").match(/rgba?\((\d*), (\d*), (\d*)(, [\d.]*)?\)/);
if (match2 && match2[1] && match2[2] && match2[3]) {
return !(match2[1] === match2[2] && match2[2] === match2[3]);
}
return true;
}
function isValidWaveColor(color) {
return color && color !== "#fff" && color !== "#ffffff" && color !== "rgb(255, 255, 255)" && color !== "rgba(255, 255, 255, 1)" && isNotGrey(color) && !/rgba\((?:\d*, ){3}0\)/.test(color) && // any transparent rgba color
color !== "transparent";
}
function getTargetWaveColor(node2) {
const {
borderTopColor,
borderColor,
backgroundColor
} = getComputedStyle(node2);
if (isValidWaveColor(borderTopColor)) {
return borderTopColor;
}
if (isValidWaveColor(borderColor)) {
return borderColor;
}
if (isValidWaveColor(backgroundColor)) {
return backgroundColor;
}
return null;
}
function validateNum(value) {
return Number.isNaN(value) ? 0 : value;
}
const WaveEffect = (props) => {
const {
className,
target,
component
} = props;
const divRef = React.useRef(null);
const [color, setWaveColor] = React.useState(null);
const [borderRadius, setBorderRadius] = React.useState([]);
const [left, setLeft] = React.useState(0);
const [top, setTop] = React.useState(0);
const [width, setWidth] = React.useState(0);
const [height, setHeight] = React.useState(0);
const [enabled, setEnabled] = React.useState(false);
const waveStyle = {
left,
top,
width,
height,
borderRadius: borderRadius.map((radius) => `${radius}px`).join(" ")
};
if (color) {
waveStyle["--wave-color"] = color;
}
function syncPos() {
const nodeStyle = getComputedStyle(target);
setWaveColor(getTargetWaveColor(target));
const isStatic = nodeStyle.position === "static";
const {
borderLeftWidth,
borderTopWidth
} = nodeStyle;
setLeft(isStatic ? target.offsetLeft : validateNum(-parseFloat(borderLeftWidth)));
setTop(isStatic ? target.offsetTop : validateNum(-parseFloat(borderTopWidth)));
setWidth(target.offsetWidth);
setHeight(target.offsetHeight);
const {
borderTopLeftRadius,
borderTopRightRadius,
borderBottomLeftRadius,
borderBottomRightRadius
} = nodeStyle;
setBorderRadius([borderTopLeftRadius, borderTopRightRadius, borderBottomRightRadius, borderBottomLeftRadius].map((radius) => validateNum(parseFloat(radius))));
}
React.useEffect(() => {
if (target) {
const id = wrapperRaf(() => {
syncPos();
setEnabled(true);
});
let resizeObserver2;
if (typeof ResizeObserver !== "undefined") {
resizeObserver2 = new ResizeObserver(syncPos);
resizeObserver2.observe(target);
}
return () => {
wrapperRaf.cancel(id);
resizeObserver2 === null || resizeObserver2 === void 0 ? void 0 : resizeObserver2.disconnect();
};
}
}, []);
if (!enabled) {
return null;
}
const isSmallComponent = (component === "Checkbox" || component === "Radio") && (target === null || target === void 0 ? void 0 : target.classList.contains(TARGET_CLS));
return /* @__PURE__ */ React.createElement(CSSMotion, {
visible: true,
motionAppear: true,
motionName: "wave-motion",
motionDeadline: 5e3,
onAppearEnd: (_, event) => {
var _a;
if (event.deadline || event.propertyName === "opacity") {
const holder = (_a = divRef.current) === null || _a === void 0 ? void 0 : _a.parentElement;
unmount(holder).then(() => {
holder === null || holder === void 0 ? void 0 : holder.remove();
});
}
return false;
}
}, (_ref, ref) => {
let {
className: motionClassName
} = _ref;
return /* @__PURE__ */ React.createElement("div", {
ref: composeRef(divRef, ref),
className: classNames(className, motionClassName, {
"wave-quick": isSmallComponent
}),
style: waveStyle
});
});
};
const showWaveEffect = (target, info) => {
var _a;
const {
component
} = info;
if (component === "Checkbox" && !((_a = target.querySelector("input")) === null || _a === void 0 ? void 0 : _a.checked)) {
return;
}
const holder = document.createElement("div");
holder.style.position = "absolute";
holder.style.left = "0px";
holder.style.top = "0px";
target === null || target === void 0 ? void 0 : target.insertBefore(holder, target === null || target === void 0 ? void 0 : target.firstChild);
render(/* @__PURE__ */ React.createElement(WaveEffect, Object.assign({}, info, {
target
})), holder);
};
const useWave = (nodeRef, className, component) => {
const {
wave
} = React.useContext(ConfigContext);
const [, token2, hashId] = useToken();
const showWave = useEvent((event) => {
const node2 = nodeRef.current;
if ((wave === null || wave === void 0 ? void 0 : wave.disabled) || !node2) {
return;
}
const targetNode = node2.querySelector(`.${TARGET_CLS}`) || node2;
const {
showEffect
} = wave || {};
(showEffect || showWaveEffect)(targetNode, {
className,
token: token2,
component,
event,
hashId
});
});
const rafId = React.useRef();
const showDebounceWave = (event) => {
wrapperRaf.cancel(rafId.current);
rafId.current = wrapperRaf(() => {
showWave(event);
});
};
return showDebounceWave;
};
const Wave = (props) => {
const {
children,
disabled,
component
} = props;
const {
getPrefixCls
} = useContext(ConfigContext);
const containerRef = useRef(null);
const prefixCls = getPrefixCls("wave");
const [, hashId] = useStyle$1(prefixCls);
const showWave = useWave(containerRef, classNames(prefixCls, hashId), component);
React__default.useEffect(() => {
const node2 = containerRef.current;
if (!node2 || node2.nodeType !== 1 || disabled) {
return;
}
const onClick = (e) => {
if (!isVisible(e.target) || // No need wave
!node2.getAttribute || node2.getAttribute("disabled") || node2.disabled || node2.className.includes("disabled") || node2.className.includes("-leave")) {
return;
}
showWave(e);
};
node2.addEventListener("click", onClick, true);
return () => {
node2.removeEventListener("click", onClick, true);
};
}, [disabled]);
if (!/* @__PURE__ */ React__default.isValidElement(children)) {
return children !== null && children !== void 0 ? children : null;
}
const ref = supportRef(children) ? composeRef(children.ref, containerRef) : containerRef;
return cloneElement(children, {
ref
});
};
if (process.env.NODE_ENV !== "production") {
Wave.displayName = "Wave";
}
var __rest$3 = function(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
}
return t;
};
const GroupSizeContext = /* @__PURE__ */ React.createContext(void 0);
const ButtonGroup = (props) => {
const {
getPrefixCls,
direction
} = React.useContext(ConfigContext);
const {
prefixCls: customizePrefixCls,
size,
className
} = props, others = __rest$3(props, ["prefixCls", "size", "className"]);
const prefixCls = getPrefixCls("btn-group", customizePrefixCls);
const [, , hashId] = useToken();
let sizeCls = "";
switch (size) {
case "large":
sizeCls = "lg";
break;
case "small":
sizeCls = "sm";
break;
}
if (process.env.NODE_ENV !== "production") {
const warning3 = devUseWarning("Button.Group");
process.env.NODE_ENV !== "production" ? warning3(!size || ["large", "small", "middle"].includes(size), "usage", "Invalid prop `size`.") : void 0;
}
const classes = classNames(prefixCls, {
[`${prefixCls}-${sizeCls}`]: sizeCls,
[`${prefixCls}-rtl`]: direction === "rtl"
}, className, hashId);
return /* @__PURE__ */ React.createElement(GroupSizeContext.Provider, {
value: size
}, /* @__PURE__ */ React.createElement("div", Object.assign({}, others, {
className: classes
})));
};
const rxTwoCNChar = /^[\u4e00-\u9fa5]{2}$/;
const isTwoCNChar = rxTwoCNChar.test.bind(rxTwoCNChar);
function isString(str) {
return typeof str === "string";
}
function isUnBorderedButtonType(type4) {
return type4 === "text" || type4 === "link";
}
function splitCNCharsBySpace(child, needInserted) {
if (child === null || child === void 0) {
return;
}
const SPACE = needInserted ? " " : "";
if (typeof child !== "string" && typeof child !== "number" && isString(child.type) && isTwoCNChar(child.props.children)) {
return cloneElement(child, {
children: child.props.children.split("").join(SPACE)
});
}
if (isString(child)) {
return isTwoCNChar(child) ? /* @__PURE__ */ React__default.createElement("span", null, child.split("").join(SPACE)) : /* @__PURE__ */ React__default.createElement("span", null, child);
}
if (isFragment(child)) {
return /* @__PURE__ */ React__default.createElement("span", null, child);
}
return child;
}
function spaceChildren(children, needInserted) {
let isPrevChildPure = false;
const childList = [];
React__default.Children.forEach(children, (child) => {
const type4 = typeof child;
const isCurrentChildPure = type4 === "string" || type4 === "number";
if (isPrevChildPure && isCurrentChildPure) {
const lastIndex = childList.length - 1;
const lastChild = childList[lastIndex];
childList[lastIndex] = `${lastChild}${child}`;
} else {
childList.push(child);
}
isPrevChildPure = isCurrentChildPure;
});
return React__default.Children.map(childList, (child) => splitCNCharsBySpace(child, needInserted));
}
const IconWrapper = /* @__PURE__ */ forwardRef((props, ref) => {
const {
className,
style: style2,
children,
prefixCls
} = props;
const iconWrapperCls = classNames(`${prefixCls}-icon`, className);
return /* @__PURE__ */ React__default.createElement("span", {
ref,
className: iconWrapperCls,
style: style2
}, children);
});
const InnerLoadingIcon = /* @__PURE__ */ forwardRef((props, ref) => {
const {
prefixCls,
className,
style: style2,
iconClassName
} = props;
const mergedIconCls = classNames(`${prefixCls}-loading-icon`, className);
return /* @__PURE__ */ React__default.createElement(IconWrapper, {
prefixCls,
className: mergedIconCls,
style: style2,
ref
}, /* @__PURE__ */ React__default.createElement(RefIcon$1, {
className: iconClassName
}));
});
const getCollapsedWidth = () => ({
width: 0,
opacity: 0,
transform: "scale(0)"
});
const getRealWidth = (node2) => ({
width: node2.scrollWidth,
opacity: 1,
transform: "scale(1)"
});
const LoadingIcon = (props) => {
const {
prefixCls,
loading,
existIcon,
className,
style: style2
} = props;
const visible = !!loading;
if (existIcon) {
return /* @__PURE__ */ React__default.createElement(InnerLoadingIcon, {
prefixCls,
className,
style: style2
});
}
return /* @__PURE__ */ React__default.createElement(CSSMotion, {
visible,
// We do not really use this motionName
motionName: `${prefixCls}-loading-icon-motion`,
motionLeave: visible,
removeOnLeave: true,
onAppearStart: getCollapsedWidth,
onAppearActive: getRealWidth,
onEnterStart: getCollapsedWidth,
onEnterActive: getRealWidth,
onLeaveStart: getRealWidth,
onLeaveActive: getCollapsedWidth
}, (_ref, ref) => {
let {
className: motionCls,
style: motionStyle
} = _ref;
return /* @__PURE__ */ React__default.createElement(InnerLoadingIcon, {
prefixCls,
className,
style: Object.assign(Object.assign({}, style2), motionStyle),
ref,
iconClassName: motionCls
});
});
};
const genButtonBorderStyle = (buttonTypeCls, borderColor) => ({
// Border
[`> span, > ${buttonTypeCls}`]: {
"&:not(:last-child)": {
[`&, & > ${buttonTypeCls}`]: {
"&:not(:disabled)": {
borderInlineEndColor: borderColor
}
}
},
"&:not(:first-child)": {
[`&, & > ${buttonTypeCls}`]: {
"&:not(:disabled)": {
borderInlineStartColor: borderColor
}
}
}
}
});
const genGroupStyle = (token2) => {
const {
componentCls,
fontSize,
lineWidth,
groupBorderColor,
colorErrorHover
} = token2;
return {
[`${componentCls}-group`]: [
{
position: "relative",
display: "inline-flex",
// Border
[`> span, > ${componentCls}`]: {
"&:not(:last-child)": {
[`&, & > ${componentCls}`]: {
borderStartEndRadius: 0,
borderEndEndRadius: 0
}
},
"&:not(:first-child)": {
marginInlineStart: token2.calc(lineWidth).mul(-1).equal(),
[`&, & > ${componentCls}`]: {
borderStartStartRadius: 0,
borderEndStartRadius: 0
}
}
},
[componentCls]: {
position: "relative",
zIndex: 1,
"&:hover, &:focus, &:active": {
zIndex: 2
},
"&[disabled]": {
zIndex: 0
}
},
[`${componentCls}-icon-only`]: {
fontSize
}
},
// Border Color
genButtonBorderStyle(`${componentCls}-primary`, groupBorderColor),
genButtonBorderStyle(`${componentCls}-danger`, colorErrorHover)
]
};
};
const prepareToken = (token2) => {
const {
paddingInline,
onlyIconSize,
paddingBlock
} = token2;
const buttonToken = merge(token2, {
buttonPaddingHorizontal: paddingInline,
buttonPaddingVertical: paddingBlock,
buttonIconOnlyFontSize: onlyIconSize
});
return buttonToken;
};
const prepareComponentToken = (token2) => {
var _a, _b, _c, _d, _e, _f;
const contentFontSize = (_a = token2.contentFontSize) !== null && _a !== void 0 ? _a : token2.fontSize;
const contentFontSizeSM = (_b = token2.contentFontSizeSM) !== null && _b !== void 0 ? _b : token2.fontSize;
const contentFontSizeLG = (_c = token2.contentFontSizeLG) !== null && _c !== void 0 ? _c : token2.fontSizeLG;
const contentLineHeight = (_d = token2.contentLineHeight) !== null && _d !== void 0 ? _d : getLineHeight(contentFontSize);
const contentLineHeightSM = (_e = token2.contentLineHeightSM) !== null && _e !== void 0 ? _e : getLineHeight(contentFontSizeSM);
const contentLineHeightLG = (_f = token2.contentLineHeightLG) !== null && _f !== void 0 ? _f : getLineHeight(contentFontSizeLG);
return {
fontWeight: 400,
defaultShadow: `0 ${token2.controlOutlineWidth}px 0 ${token2.controlTmpOutline}`,
primaryShadow: `0 ${token2.controlOutlineWidth}px 0 ${token2.controlOutline}`,
dangerShadow: `0 ${token2.controlOutlineWidth}px 0 ${token2.colorErrorOutline}`,
primaryColor: token2.colorTextLightSolid,
dangerColor: token2.colorTextLightSolid,
borderColorDisabled: token2.colorBorder,
defaultGhostColor: token2.colorBgContainer,
ghostBg: "transparent",
defaultGhostBorderColor: token2.colorBgContainer,
paddingInline: token2.paddingContentHorizontal - token2.lineWidth,
paddingInlineLG: token2.paddingContentHorizontal - token2.lineWidth,
paddingInlineSM: 8 - token2.lineWidth,
onlyIconSize: token2.fontSizeLG,
onlyIconSizeSM: token2.fontSizeLG - 2,
onlyIconSizeLG: token2.fontSizeLG + 2,
groupBorderColor: token2.colorPrimaryHover,
linkHoverBg: "transparent",
textHoverBg: token2.colorBgTextHover,
defaultColor: token2.colorText,
defaultBg: token2.colorBgContainer,
defaultBorderColor: token2.colorBorder,
defaultBorderColorDisabled: token2.colorBorder,
defaultHoverBg: token2.colorBgContainer,
defaultHoverColor: token2.colorPrimaryHover,
defaultHoverBorderColor: token2.colorPrimaryHover,
defaultActiveBg: token2.colorBgContainer,
defaultActiveColor: token2.colorPrimaryActive,
defaultActiveBorderColor: token2.colorPrimaryActive,
contentFontSize,
contentFontSizeSM,
contentFontSizeLG,
contentLineHeight,
contentLineHeightSM,
contentLineHeightLG,
paddingBlock: Math.max((token2.controlHeight - contentFontSize * contentLineHeight) / 2 - token2.lineWidth, 0),
paddingBlockSM: Math.max((token2.controlHeightSM - contentFontSizeSM * contentLineHeightSM) / 2 - token2.lineWidth, 0),
paddingBlockLG: Math.max((token2.controlHeightLG - contentFontSizeLG * contentLineHeightLG) / 2 - token2.lineWidth, 0)
};
};
const genSharedButtonStyle = (token2) => {
const {
componentCls,
iconCls,
fontWeight
} = token2;
return {
[componentCls]: {
outline: "none",
position: "relative",
display: "inline-flex",
gap: token2.marginXS,
alignItems: "center",
justifyContent: "center",
fontWeight,
whiteSpace: "nowrap",
textAlign: "center",
backgroundImage: "none",
background: "transparent",
border: `${unit(token2.lineWidth)} ${token2.lineType} transparent`,
cursor: "pointer",
transition: `all ${token2.motionDurationMid} ${token2.motionEaseInOut}`,
userSelect: "none",
touchAction: "manipulation",
color: token2.colorText,
"&:disabled > *": {
pointerEvents: "none"
},
"> span": {
display: "inline-block"
},
[`${componentCls}-icon`]: {
lineHeight: 1
},
"> a": {
color: "currentColor"
},
"&:not(:disabled)": Object.assign({}, genFocusStyle(token2)),
[`&${componentCls}-two-chinese-chars::first-letter`]: {
letterSpacing: "0.34em"
},
[`&${componentCls}-two-chinese-chars > *:not(${iconCls})`]: {
marginInlineEnd: "-0.34em",
letterSpacing: "0.34em"
},
// iconPosition="end"
"&-icon-end": {
flexDirection: "row-reverse"
}
}
};
};
const genHoverActiveButtonStyle = (btnCls, hoverStyle, activeStyle) => ({
[`&:not(:disabled):not(${btnCls}-disabled)`]: {
"&:hover": hoverStyle,
"&:active": activeStyle
}
});
const genCircleButtonStyle = (token2) => ({
minWidth: token2.controlHeight,
paddingInlineStart: 0,
paddingInlineEnd: 0,
borderRadius: "50%"
});
const genRoundButtonStyle = (token2) => ({
borderRadius: token2.controlHeight,
paddingInlineStart: token2.calc(token2.controlHeight).div(2).equal(),
paddingInlineEnd: token2.calc(token2.controlHeight).div(2).equal()
});
const genDisabledStyle = (token2) => ({
cursor: "not-allowed",
borderColor: token2.borderColorDisabled,
color: token2.colorTextDisabled,
background: token2.colorBgContainerDisabled,
boxShadow: "none"
});
const genGhostButtonStyle = (btnCls, background, textColor, borderColor, textColorDisabled, borderColorDisabled, hoverStyle, activeStyle) => ({
[`&${btnCls}-background-ghost`]: Object.assign(Object.assign({
color: textColor || void 0,
background,
borderColor: borderColor || void 0,
boxShadow: "none"
}, genHoverActiveButtonStyle(btnCls, Object.assign({
background
}, hoverStyle), Object.assign({
background
}, activeStyle))), {
"&:disabled": {
cursor: "not-allowed",
color: textColorDisabled || void 0,
borderColor: borderColorDisabled || void 0
}
})
});
const genSolidDisabledButtonStyle = (token2) => ({
[`&:disabled, &${token2.componentCls}-disabled`]: Object.assign({}, genDisabledStyle(token2))
});
const genSolidButtonStyle = (token2) => Object.assign({}, genSolidDisabledButtonStyle(token2));
const genPureDisabledButtonStyle = (token2) => ({
[`&:disabled, &${token2.componentCls}-disabled`]: {
cursor: "not-allowed",
color: token2.colorTextDisabled
}
});
const genDefaultButtonStyle = (token2) => Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, genSolidButtonStyle(token2)), {
background: token2.defaultBg,
borderColor: token2.defaultBorderColor,
color: token2.defaultColor,
boxShadow: token2.defaultShadow
}), genHoverActiveButtonStyle(token2.componentCls, {
color: token2.defaultHoverColor,
borderColor: token2.defaultHoverBorderColor,
background: token2.defaultHoverBg
}, {
color: token2.defaultActiveColor,
borderColor: token2.defaultActiveBorderColor,
background: token2.defaultActiveBg
})), genGhostButtonStyle(token2.componentCls, token2.ghostBg, token2.defaultGhostColor, token2.defaultGhostBorderColor, token2.colorTextDisabled, token2.colorBorder)), {
[`&${token2.componentCls}-dangerous`]: Object.assign(Object.assign(Object.assign({
color: token2.colorError,
borderColor: token2.colorError
}, genHoverActiveButtonStyle(token2.componentCls, {
color: token2.colorErrorHover,
borderColor: token2.colorErrorBorderHover
}, {
color: token2.colorErrorActive,
borderColor: token2.colorErrorActive
})), genGhostButtonStyle(token2.componentCls, token2.ghostBg, token2.colorError, token2.colorError, token2.colorTextDisabled, token2.colorBorder)), genSolidDisabledButtonStyle(token2))
});
const genPrimaryButtonStyle = (token2) => Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, genSolidButtonStyle(token2)), {
color: token2.primaryColor,
background: token2.colorPrimary,
boxShadow: token2.primaryShadow
}), genHoverActiveButtonStyle(token2.componentCls, {
color: token2.colorTextLightSolid,
background: token2.colorPrimaryHover
}, {
color: token2.colorTextLightSolid,
background: token2.colorPrimaryActive
})), genGhostButtonStyle(token2.componentCls, token2.ghostBg, token2.colorPrimary, token2.colorPrimary, token2.colorTextDisabled, token2.colorBorder, {
color: token2.colorPrimaryHover,
borderColor: token2.colorPrimaryHover
}, {
color: token2.colorPrimaryActive,
borderColor: token2.colorPrimaryActive
})), {
[`&${token2.componentCls}-dangerous`]: Object.assign(Object.assign(Object.assign({
background: token2.colorError,
boxShadow: token2.dangerShadow,
color: token2.dangerColor
}, genHoverActiveButtonStyle(token2.componentCls, {
background: token2.colorErrorHover
}, {
background: token2.colorErrorActive
})), genGhostButtonStyle(token2.componentCls, token2.ghostBg, token2.colorError, token2.colorError, token2.colorTextDisabled, token2.colorBorder, {
color: token2.colorErrorHover,
borderColor: token2.colorErrorHover
}, {
color: token2.colorErrorActive,
borderColor: token2.colorErrorActive
})), genSolidDisabledButtonStyle(token2))
});
const genDashedButtonStyle = (token2) => Object.assign(Object.assign({}, genDefaultButtonStyle(token2)), {
borderStyle: "dashed"
});
const genLinkButtonStyle = (token2) => Object.assign(Object.assign(Object.assign({
color: token2.colorLink
}, genHoverActiveButtonStyle(token2.componentCls, {
color: token2.colorLinkHover,
background: token2.linkHoverBg
}, {
color: token2.colorLinkActive
})), genPureDisabledButtonStyle(token2)), {
[`&${token2.componentCls}-dangerous`]: Object.assign(Object.assign({
color: token2.colorError
}, genHoverActiveButtonStyle(token2.componentCls, {
color: token2.colorErrorHover
}, {
color: token2.colorErrorActive
})), genPureDisabledButtonStyle(token2))
});
const genTextButtonStyle = (token2) => Object.assign(Object.assign(Object.assign({}, genHoverActiveButtonStyle(token2.componentCls, {
color: token2.colorText,
background: token2.textHoverBg
}, {
color: token2.colorText,
background: token2.colorBgTextActive
})), genPureDisabledButtonStyle(token2)), {
[`&${token2.componentCls}-dangerous`]: Object.assign(Object.assign({
color: token2.colorError
}, genPureDisabledButtonStyle(token2)), genHoverActiveButtonStyle(token2.componentCls, {
color: token2.colorErrorHover,
background: token2.colorErrorBg
}, {
color: token2.colorErrorHover,
background: token2.colorErrorBgActive
}))
});
const genTypeButtonStyle = (token2) => {
const {
componentCls
} = token2;
return {
[`${componentCls}-default`]: genDefaultButtonStyle(token2),
[`${componentCls}-primary`]: genPrimaryButtonStyle(token2),
[`${componentCls}-dashed`]: genDashedButtonStyle(token2),
[`${componentCls}-link`]: genLinkButtonStyle(token2),
[`${componentCls}-text`]: genTextButtonStyle(token2),
[`${componentCls}-ghost`]: genGhostButtonStyle(token2.componentCls, token2.ghostBg, token2.colorBgContainer, token2.colorBgContainer, token2.colorTextDisabled, token2.colorBorder)
};
};
const genButtonStyle = function(token2) {
let prefixCls = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
const {
componentCls,
controlHeight,
fontSize,
lineHeight,
borderRadius,
buttonPaddingHorizontal,
iconCls,
buttonPaddingVertical
} = token2;
const iconOnlyCls = `${componentCls}-icon-only`;
return [
{
[`${prefixCls}`]: {
fontSize,
lineHeight,
height: controlHeight,
padding: `${unit(buttonPaddingVertical)} ${unit(buttonPaddingHorizontal)}`,
borderRadius,
[`&${iconOnlyCls}`]: {
width: controlHeight,
paddingInline: 0,
// make `btn-icon-only` not too narrow
[`&${componentCls}-compact-item`]: {
flex: "none"
},
[`&${componentCls}-round`]: {
width: "auto"
},
[iconCls]: {
fontSize: token2.buttonIconOnlyFontSize
}
},
// Loading
[`&${componentCls}-loading`]: {
opacity: token2.opacityLoading,
cursor: "default"
},
[`${componentCls}-loading-icon`]: {
transition: `width ${token2.motionDurationSlow} ${token2.motionEaseInOut}, opacity ${token2.motionDurationSlow} ${token2.motionEaseInOut}`
}
}
},
// Shape - patch prefixCls again to override solid border radius style
{
[`${componentCls}${componentCls}-circle${prefixCls}`]: genCircleButtonStyle(token2)
},
{
[`${componentCls}${componentCls}-round${prefixCls}`]: genRoundButtonStyle(token2)
}
];
};
const genSizeBaseButtonStyle = (token2) => {
const baseToken = merge(token2, {
fontSize: token2.contentFontSize,
lineHeight: token2.contentLineHeight
});
return genButtonStyle(baseToken, token2.componentCls);
};
const genSizeSmallButtonStyle = (token2) => {
const smallToken = merge(token2, {
controlHeight: token2.controlHeightSM,
fontSize: token2.contentFontSizeSM,
lineHeight: token2.contentLineHeightSM,
padding: token2.paddingXS,
buttonPaddingHorizontal: token2.paddingInlineSM,
buttonPaddingVertical: token2.paddingBlockSM,
borderRadius: token2.borderRadiusSM,
buttonIconOnlyFontSize: token2.onlyIconSizeSM
});
return genButtonStyle(smallToken, `${token2.componentCls}-sm`);
};
const genSizeLargeButtonStyle = (token2) => {
const largeToken = merge(token2, {
controlHeight: token2.controlHeightLG,
fontSize: token2.contentFontSizeLG,
lineHeight: token2.contentLineHeightLG,
buttonPaddingHorizontal: token2.paddingInlineLG,
buttonPaddingVertical: token2.paddingBlockLG,
borderRadius: token2.borderRadiusLG,
buttonIconOnlyFontSize: token2.onlyIconSizeLG
});
return genButtonStyle(largeToken, `${token2.componentCls}-lg`);
};
const genBlockButtonStyle = (token2) => {
const {
componentCls
} = token2;
return {
[componentCls]: {
[`&${componentCls}-block`]: {
width: "100%"
}
}
};
};
const useStyle = genStyleHooks("Button", (token2) => {
const buttonToken = prepareToken(token2);
return [
// Shared
genSharedButtonStyle(buttonToken),
// Size
genSizeBaseButtonStyle(buttonToken),
genSizeSmallButtonStyle(buttonToken),
genSizeLargeButtonStyle(buttonToken),
// Block
genBlockButtonStyle(buttonToken),
// Group (type, ghost, danger, loading)
genTypeButtonStyle(buttonToken),
// Button Group
genGroupStyle(buttonToken)
];
}, prepareComponentToken, {
unitless: {
fontWeight: true,
contentLineHeight: true,
contentLineHeightSM: true,
contentLineHeightLG: true
}
});
function compactItemVerticalBorder(token2, parentCls) {
return {
// border collapse
[`&-item:not(${parentCls}-last-item)`]: {
marginBottom: token2.calc(token2.lineWidth).mul(-1).equal()
},
"&-item": {
"&:hover,&:focus,&:active": {
zIndex: 2
},
"&[disabled]": {
zIndex: 0
}
}
};
}
function compactItemBorderVerticalRadius(prefixCls, parentCls) {
return {
[`&-item:not(${parentCls}-first-item):not(${parentCls}-last-item)`]: {
borderRadius: 0
},
[`&-item${parentCls}-first-item:not(${parentCls}-last-item)`]: {
[`&, &${prefixCls}-sm, &${prefixCls}-lg`]: {
borderEndEndRadius: 0,
borderEndStartRadius: 0
}
},
[`&-item${parentCls}-last-item:not(${parentCls}-first-item)`]: {
[`&, &${prefixCls}-sm, &${prefixCls}-lg`]: {
borderStartStartRadius: 0,
borderStartEndRadius: 0
}
}
};
}
function genCompactItemVerticalStyle(token2) {
const compactCls = `${token2.componentCls}-compact-vertical`;
return {
[compactCls]: Object.assign(Object.assign({}, compactItemVerticalBorder(token2, compactCls)), compactItemBorderVerticalRadius(token2.componentCls, compactCls))
};
}
const genButtonCompactStyle = (token2) => {
const {
componentCls,
calc
} = token2;
return {
[componentCls]: {
// Special styles for Primary Button
[`&-compact-item${componentCls}-primary`]: {
[`&:not([disabled]) + ${componentCls}-compact-item${componentCls}-primary:not([disabled])`]: {
position: "relative",
"&:before": {
position: "absolute",
top: calc(token2.lineWidth).mul(-1).equal(),
insetInlineStart: calc(token2.lineWidth).mul(-1).equal(),
display: "inline-block",
width: token2.lineWidth,
height: `calc(100% + ${unit(token2.lineWidth)} * 2)`,
backgroundColor: token2.colorPrimaryHover,
content: '""'
}
}
},
// Special styles for Primary Button
"&-compact-vertical-item": {
[`&${componentCls}-primary`]: {
[`&:not([disabled]) + ${componentCls}-compact-vertical-item${componentCls}-primary:not([disabled])`]: {
position: "relative",
"&:before": {
position: "absolute",
top: calc(token2.lineWidth).mul(-1).equal(),
insetInlineStart: calc(token2.lineWidth).mul(-1).equal(),
display: "inline-block",
width: `calc(100% + ${unit(token2.lineWidth)} * 2)`,
height: token2.lineWidth,
backgroundColor: token2.colorPrimaryHover,
content: '""'
}
}
}
}
}
};
};
const CompactCmp = genSubStyleComponent(["Button", "compact"], (token2) => {
const buttonToken = prepareToken(token2);
return [
// Space Compact
genCompactItemStyle(buttonToken),
genCompactItemVerticalStyle(buttonToken),
genButtonCompactStyle(buttonToken)
];
}, prepareComponentToken);
var __rest$2 = function(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
}
return t;
};
function getLoadingConfig(loading) {
if (typeof loading === "object" && loading) {
let delay = loading === null || loading === void 0 ? void 0 : loading.delay;
delay = !Number.isNaN(delay) && typeof delay === "number" ? delay : 0;
return {
loading: delay <= 0,
delay
};
}
return {
loading: !!loading,
delay: 0
};
}
const InternalCompoundedButton = /* @__PURE__ */ React__default.forwardRef((props, ref) => {
var _a, _b, _c;
const {
loading = false,
prefixCls: customizePrefixCls,
type: type4,
danger = false,
shape = "default",
size: customizeSize,
styles,
disabled: customDisabled,
className,
rootClassName,
children,
icon,
iconPosition = "start",
ghost = false,
block = false,
// React does not recognize the `htmlType` prop on a DOM element. Here we pick it out of `rest`.
htmlType = "button",
classNames: customClassNames,
style: customStyle = {},
autoInsertSpace
} = props, rest = __rest$2(props, ["loading", "prefixCls", "type", "danger", "shape", "size", "styles", "disabled", "className", "rootClassName", "children", "icon", "iconPosition", "ghost", "block", "htmlType", "classNames", "style", "autoInsertSpace"]);
const mergedType = type4 || "default";
const {
getPrefixCls,
direction,
button
} = useContext(ConfigContext);
const mergedInsertSpace = (_a = autoInsertSpace !== null && autoInsertSpace !== void 0 ? autoInsertSpace : button === null || button === void 0 ? void 0 : button.autoInsertSpace) !== null && _a !== void 0 ? _a : true;
const prefixCls = getPrefixCls("btn", customizePrefixCls);
const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);
const disabled = useContext(DisabledContext);
const mergedDisabled = customDisabled !== null && customDisabled !== void 0 ? customDisabled : disabled;
const groupSize = useContext(GroupSizeContext);
const loadingOrDelay = useMemo$1(() => getLoadingConfig(loading), [loading]);
const [innerLoading, setLoading] = useState(loadingOrDelay.loading);
const [hasTwoCNChar, setHasTwoCNChar] = useState(false);
const internalRef = /* @__PURE__ */ createRef();
const buttonRef = composeRef(ref, internalRef);
const needInserted = Children.count(children) === 1 && !icon && !isUnBorderedButtonType(mergedType);
useEffect(() => {
let delayTimer = null;
if (loadingOrDelay.delay > 0) {
delayTimer = setTimeout(() => {
delayTimer = null;
setLoading(true);
}, loadingOrDelay.delay);
} else {
setLoading(loadingOrDelay.loading);
}
function cleanupTimer() {
if (delayTimer) {
clearTimeout(delayTimer);
delayTimer = null;
}
}
return cleanupTimer;
}, [loadingOrDelay]);
useEffect(() => {
if (!buttonRef || !buttonRef.current || !mergedInsertSpace) {
return;
}
const buttonText = buttonRef.current.textContent;
if (needInserted && isTwoCNChar(buttonText)) {
if (!hasTwoCNChar) {
setHasTwoCNChar(true);
}
} else if (hasTwoCNChar) {
setHasTwoCNChar(false);
}
}, [buttonRef]);
const handleClick = (e) => {
const {
onClick
} = props;
if (innerLoading || mergedDisabled) {
e.preventDefault();
return;
}
onClick === null || onClick === void 0 ? void 0 : onClick(e);
};
if (process.env.NODE_ENV !== "production") {
const warning3 = devUseWarning("Button");
process.env.NODE_ENV !== "production" ? warning3(!(typeof icon === "string" && icon.length > 2), "breaking", `\`icon\` is using ReactNode instead of string naming in v4. Please check \`${icon}\` at https://ant.design/components/icon`) : void 0;
process.env.NODE_ENV !== "production" ? warning3(!(ghost && isUnBorderedButtonType(mergedType)), "usage", "`link` or `text` button can't be a `ghost` button.") : void 0;
}
const {
compactSize,
compactItemClassnames
} = useCompactItemContext(prefixCls, direction);
const sizeClassNameMap = {
large: "lg",
small: "sm",
middle: void 0
};
const sizeFullName = useSize((ctxSize) => {
var _a2, _b2;
return (_b2 = (_a2 = customizeSize !== null && customizeSize !== void 0 ? customizeSize : compactSize) !== null && _a2 !== void 0 ? _a2 : groupSize) !== null && _b2 !== void 0 ? _b2 : ctxSize;
});
const sizeCls = sizeFullName ? sizeClassNameMap[sizeFullName] || "" : "";
const iconType = innerLoading ? "loading" : icon;
const linkButtonRestProps = omit(rest, ["navigate"]);
const classes = classNames(prefixCls, hashId, cssVarCls, {
[`${prefixCls}-${shape}`]: shape !== "default" && shape,
[`${prefixCls}-${mergedType}`]: mergedType,
[`${prefixCls}-${sizeCls}`]: sizeCls,
[`${prefixCls}-icon-only`]: !children && children !== 0 && !!iconType,
[`${prefixCls}-background-ghost`]: ghost && !isUnBorderedButtonType(mergedType),
[`${prefixCls}-loading`]: innerLoading,
[`${prefixCls}-two-chinese-chars`]: hasTwoCNChar && mergedInsertSpace && !innerLoading,
[`${prefixCls}-block`]: block,
[`${prefixCls}-dangerous`]: danger,
[`${prefixCls}-rtl`]: direction === "rtl",
[`${prefixCls}-icon-end`]: iconPosition === "end"
}, compactItemClassnames, className, rootClassName, button === null || button === void 0 ? void 0 : button.className);
const fullStyle = Object.assign(Object.assign({}, button === null || button === void 0 ? void 0 : button.style), customStyle);
const iconClasses = classNames(customClassNames === null || customClassNames === void 0 ? void 0 : customClassNames.icon, (_b = button === null || button === void 0 ? void 0 : button.classNames) === null || _b === void 0 ? void 0 : _b.icon);
const iconStyle = Object.assign(Object.assign({}, (styles === null || styles === void 0 ? void 0 : styles.icon) || {}), ((_c = button === null || button === void 0 ? void 0 : button.styles) === null || _c === void 0 ? void 0 : _c.icon) || {});
const iconNode = icon && !innerLoading ? /* @__PURE__ */ React__default.createElement(IconWrapper, {
prefixCls,
className: iconClasses,
style: iconStyle
}, icon) : /* @__PURE__ */ React__default.createElement(LoadingIcon, {
existIcon: !!icon,
prefixCls,
loading: innerLoading
});
const kids = children || children === 0 ? spaceChildren(children, needInserted && mergedInsertSpace) : null;
if (linkButtonRestProps.href !== void 0) {
return wrapCSSVar(/* @__PURE__ */ React__default.createElement("a", Object.assign({}, linkButtonRestProps, {
className: classNames(classes, {
[`${prefixCls}-disabled`]: mergedDisabled
}),
href: mergedDisabled ? void 0 : linkButtonRestProps.href,
style: fullStyle,
onClick: handleClick,
ref: buttonRef,
tabIndex: mergedDisabled ? -1 : 0
}), iconNode, kids));
}
let buttonNode = /* @__PURE__ */ React__default.createElement("button", Object.assign({}, rest, {
type: htmlType,
className: classes,
style: fullStyle,
onClick: handleClick,
disabled: mergedDisabled,
ref: buttonRef
}), iconNode, kids, !!compactItemClassnames && /* @__PURE__ */ React__default.createElement(CompactCmp, {
key: "compact",
prefixCls
}));
if (!isUnBorderedButtonType(mergedType)) {
buttonNode = /* @__PURE__ */ React__default.createElement(Wave, {
component: "Button",
disabled: innerLoading
}, buttonNode);
}
return wrapCSSVar(buttonNode);
});
const Button = InternalCompoundedButton;
Button.Group = ButtonGroup;
Button.__ANT_BUTTON = true;
if (process.env.NODE_ENV !== "production") {
Button.displayName = "Button";
}
function PickerButton(props) {
return /* @__PURE__ */ React.createElement(Button, Object.assign({
size: "small",
type: "primary"
}, props));
}
function useComponents(components) {
return useMemo$1(() => Object.assign({
button: PickerButton
}, components), [components]);
}
var __rest$1 = function(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
}
return t;
};
function generateRangePicker(generateConfig) {
const RangePicker2 = /* @__PURE__ */ forwardRef((props, ref) => {
var _a;
const {
prefixCls: customizePrefixCls,
getPopupContainer: customGetPopupContainer,
components,
className,
style: style2,
placement,
size: customizeSize,
disabled: customDisabled,
bordered = true,
placeholder,
popupClassName,
dropdownClassName,
status: customStatus,
rootClassName,
variant: customVariant
} = props, restProps = __rest$1(props, ["prefixCls", "getPopupContainer", "components", "className", "style", "placement", "size", "disabled", "bordered", "placeholder", "popupClassName", "dropdownClassName", "status", "rootClassName", "variant"]);
const innerRef = React.useRef(null);
const {
getPrefixCls,
direction,
getPopupContainer,
rangePicker
} = useContext(ConfigContext);
const prefixCls = getPrefixCls("picker", customizePrefixCls);
const {
compactSize,
compactItemClassnames
} = useCompactItemContext(prefixCls, direction);
const {
picker
} = props;
const rootPrefixCls = getPrefixCls();
const [variant, enableVariantCls] = useVariant("rangePicker", customVariant, bordered);
const rootCls = useCSSVarCls(prefixCls);
const [wrapCSSVar, hashId, cssVarCls] = useStyle$2(prefixCls, rootCls);
if (process.env.NODE_ENV !== "production") {
const warning3 = devUseWarning("DatePicker.RangePicker");
warning3.deprecated(!dropdownClassName, "dropdownClassName", "popupClassName");
warning3.deprecated(!("bordered" in props), "bordered", "variant");
}
const [mergedAllowClear] = useIcons(props, prefixCls);
const mergedComponents = useComponents(components);
const mergedSize = useSize((ctx) => {
var _a2;
return (_a2 = customizeSize !== null && customizeSize !== void 0 ? customizeSize : compactSize) !== null && _a2 !== void 0 ? _a2 : ctx;
});
const disabled = React.useContext(DisabledContext);
const mergedDisabled = customDisabled !== null && customDisabled !== void 0 ? customDisabled : disabled;
const formItemContext = useContext(FormItemInputContext);
const {
hasFeedback,
status: contextStatus,
feedbackIcon
} = formItemContext;
const suffixNode = /* @__PURE__ */ React.createElement(React.Fragment, null, picker === "time" ? /* @__PURE__ */ React.createElement(RefIcon$7, null) : /* @__PURE__ */ React.createElement(RefIcon$8, null), hasFeedback && feedbackIcon);
useImperativeHandle(ref, () => innerRef.current);
const [contextLocale] = useLocale("Calendar", locale);
const locale$12 = Object.assign(Object.assign({}, contextLocale), props.locale);
const [zIndex] = useZIndex("DatePicker", (_a = props.popupStyle) === null || _a === void 0 ? void 0 : _a.zIndex);
return wrapCSSVar(/* @__PURE__ */ React.createElement(ContextIsolator, {
space: true
}, /* @__PURE__ */ React.createElement(RefRangePicker, Object.assign({
separator: /* @__PURE__ */ React.createElement("span", {
"aria-label": "to",
className: `${prefixCls}-separator`
}, /* @__PURE__ */ React.createElement(RefIcon$6, null)),
disabled: mergedDisabled,
ref: innerRef,
popupAlign: transPlacement2DropdownAlign(direction, placement),
placement,
placeholder: getRangePlaceholder(locale$12, picker, placeholder),
suffixIcon: suffixNode,
prevIcon: /* @__PURE__ */ React.createElement("span", {
className: `${prefixCls}-prev-icon`
}),
nextIcon: /* @__PURE__ */ React.createElement("span", {
className: `${prefixCls}-next-icon`
}),
superPrevIcon: /* @__PURE__ */ React.createElement("span", {
className: `${prefixCls}-super-prev-icon`
}),
superNextIcon: /* @__PURE__ */ React.createElement("span", {
className: `${prefixCls}-super-next-icon`
}),
transitionName: `${rootPrefixCls}-slide-up`
}, restProps, {
className: classNames({
[`${prefixCls}-${mergedSize}`]: mergedSize,
[`${prefixCls}-${variant}`]: enableVariantCls
}, getStatusClassNames(prefixCls, getMergedStatus(contextStatus, customStatus), hasFeedback), hashId, compactItemClassnames, className, rangePicker === null || rangePicker === void 0 ? void 0 : rangePicker.className, cssVarCls, rootCls, rootClassName),
style: Object.assign(Object.assign({}, rangePicker === null || rangePicker === void 0 ? void 0 : rangePicker.style), style2),
locale: locale$12.lang,
prefixCls,
getPopupContainer: customGetPopupContainer || getPopupContainer,
generateConfig,
components: mergedComponents,
direction,
classNames: {
popup: classNames(hashId, popupClassName || dropdownClassName, cssVarCls, rootCls, rootClassName)
},
styles: {
popup: Object.assign(Object.assign({}, props.popupStyle), {
zIndex
})
},
allowClear: mergedAllowClear
}))));
});
if (process.env.NODE_ENV !== "production") {
RangePicker2.displayName = "RangePicker";
}
return RangePicker2;
}
var __rest = function(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
}
return t;
};
function generatePicker$1(generateConfig) {
function getPicker(picker, displayName) {
const consumerName = displayName === "TimePicker" ? "timePicker" : "datePicker";
const Picker2 = /* @__PURE__ */ forwardRef((props, ref) => {
var _a;
const {
prefixCls: customizePrefixCls,
getPopupContainer: customizeGetPopupContainer,
components,
style: style2,
className,
rootClassName,
size: customizeSize,
bordered,
placement,
placeholder,
popupClassName,
dropdownClassName,
disabled: customDisabled,
status: customStatus,
variant: customVariant,
onCalendarChange
} = props, restProps = __rest(props, ["prefixCls", "getPopupContainer", "components", "style", "className", "rootClassName", "size", "bordered", "placement", "placeholder", "popupClassName", "dropdownClassName", "disabled", "status", "variant", "onCalendarChange"]);
const {
getPrefixCls,
direction,
getPopupContainer,
// Consume different styles according to different names
[consumerName]: consumerStyle
} = useContext(ConfigContext);
const prefixCls = getPrefixCls("picker", customizePrefixCls);
const {
compactSize,
compactItemClassnames
} = useCompactItemContext(prefixCls, direction);
const innerRef = React.useRef(null);
const [variant, enableVariantCls] = useVariant("datePicker", customVariant, bordered);
const rootCls = useCSSVarCls(prefixCls);
const [wrapCSSVar, hashId, cssVarCls] = useStyle$2(prefixCls, rootCls);
useImperativeHandle(ref, () => innerRef.current);
const additionalProps = {
showToday: true
};
const mergedPicker = picker || props.picker;
const rootPrefixCls = getPrefixCls();
const {
onSelect,
multiple
} = restProps;
const hasLegacyOnSelect = onSelect && picker === "time" && !multiple;
const onInternalCalendarChange = (date4, dateStr, info) => {
onCalendarChange === null || onCalendarChange === void 0 ? void 0 : onCalendarChange(date4, dateStr, info);
if (hasLegacyOnSelect) {
onSelect(date4);
}
};
if (process.env.NODE_ENV !== "production") {
const warning3 = devUseWarning(displayName || "DatePicker");
process.env.NODE_ENV !== "production" ? warning3(picker !== "quarter", "deprecated", `DatePicker.${displayName} is legacy usage. Please use DatePicker[picker='${picker}'] directly.`) : void 0;
warning3.deprecated(!dropdownClassName, "dropdownClassName", "popupClassName");
warning3.deprecated(!("bordered" in props), "bordered", "variant");
warning3.deprecated(!hasLegacyOnSelect, "onSelect", "onCalendarChange");
}
const [mergedAllowClear, removeIcon] = useIcons(props, prefixCls);
const mergedComponents = useComponents(components);
const mergedSize = useSize((ctx) => {
var _a2;
return (_a2 = customizeSize !== null && customizeSize !== void 0 ? customizeSize : compactSize) !== null && _a2 !== void 0 ? _a2 : ctx;
});
const disabled = React.useContext(DisabledContext);
const mergedDisabled = customDisabled !== null && customDisabled !== void 0 ? customDisabled : disabled;
const formItemContext = useContext(FormItemInputContext);
const {
hasFeedback,
status: contextStatus,
feedbackIcon
} = formItemContext;
const suffixNode = /* @__PURE__ */ React.createElement(React.Fragment, null, mergedPicker === "time" ? /* @__PURE__ */ React.createElement(RefIcon$7, null) : /* @__PURE__ */ React.createElement(RefIcon$8, null), hasFeedback && feedbackIcon);
const [contextLocale] = useLocale("DatePicker", locale);
const locale$12 = Object.assign(Object.assign({}, contextLocale), props.locale);
const [zIndex] = useZIndex("DatePicker", (_a = props.popupStyle) === null || _a === void 0 ? void 0 : _a.zIndex);
return wrapCSSVar(/* @__PURE__ */ React.createElement(ContextIsolator, {
space: true
}, /* @__PURE__ */ React.createElement(RefPicker, Object.assign({
ref: innerRef,
placeholder: getPlaceholder(locale$12, mergedPicker, placeholder),
suffixIcon: suffixNode,
dropdownAlign: transPlacement2DropdownAlign(direction, placement),
placement,
prevIcon: /* @__PURE__ */ React.createElement("span", {
className: `${prefixCls}-prev-icon`
}),
nextIcon: /* @__PURE__ */ React.createElement("span", {
className: `${prefixCls}-next-icon`
}),
superPrevIcon: /* @__PURE__ */ React.createElement("span", {
className: `${prefixCls}-super-prev-icon`
}),
superNextIcon: /* @__PURE__ */ React.createElement("span", {
className: `${prefixCls}-super-next-icon`
}),
transitionName: `${rootPrefixCls}-slide-up`,
picker,
onCalendarChange: onInternalCalendarChange
}, additionalProps, restProps, {
locale: locale$12.lang,
className: classNames({
[`${prefixCls}-${mergedSize}`]: mergedSize,
[`${prefixCls}-${variant}`]: enableVariantCls
}, getStatusClassNames(prefixCls, getMergedStatus(contextStatus, customStatus), hasFeedback), hashId, compactItemClassnames, consumerStyle === null || consumerStyle === void 0 ? void 0 : consumerStyle.className, className, cssVarCls, rootCls, rootClassName),
style: Object.assign(Object.assign({}, consumerStyle === null || consumerStyle === void 0 ? void 0 : consumerStyle.style), style2),
prefixCls,
getPopupContainer: customizeGetPopupContainer || getPopupContainer,
generateConfig,
components: mergedComponents,
direction,
disabled: mergedDisabled,
classNames: {
popup: classNames(hashId, cssVarCls, rootCls, rootClassName, popupClassName || dropdownClassName)
},
styles: {
popup: Object.assign(Object.assign({}, props.popupStyle), {
zIndex
})
},
allowClear: mergedAllowClear,
removeIcon
}))));
});
if (process.env.NODE_ENV !== "production" && displayName) {
Picker2.displayName = displayName;
}
return Picker2;
}
const DatePicker2 = getPicker();
const WeekPicker = getPicker("week", "WeekPicker");
const MonthPicker = getPicker("month", "MonthPicker");
const YearPicker = getPicker("year", "YearPicker");
const QuarterPicker = getPicker("quarter", "QuarterPicker");
const TimePicker = getPicker("time", "TimePicker");
return {
DatePicker: DatePicker2,
WeekPicker,
MonthPicker,
YearPicker,
TimePicker,
QuarterPicker
};
}
function generatePicker(generateConfig) {
const {
DatePicker: DatePicker2,
WeekPicker,
MonthPicker,
YearPicker,
TimePicker,
QuarterPicker
} = generatePicker$1(generateConfig);
const RangePicker2 = generateRangePicker(generateConfig);
const MergedDatePicker = DatePicker2;
MergedDatePicker.WeekPicker = WeekPicker;
MergedDatePicker.MonthPicker = MonthPicker;
MergedDatePicker.YearPicker = YearPicker;
MergedDatePicker.RangePicker = RangePicker2;
MergedDatePicker.TimePicker = TimePicker;
MergedDatePicker.QuarterPicker = QuarterPicker;
if (process.env.NODE_ENV !== "production") {
MergedDatePicker.displayName = "DatePicker";
}
return MergedDatePicker;
}
var weekOfYear$1 = { exports: {} };
(function(module2, exports) {
!function(e, t) {
module2.exports = t();
}(commonjsGlobal, function() {
var e = "week", t = "year";
return function(i, n, r) {
var f = n.prototype;
f.week = function(i2) {
if (void 0 === i2 && (i2 = null), null !== i2) return this.add(7 * (i2 - this.week()), "day");
var n2 = this.$locale().yearStart || 1;
if (11 === this.month() && this.date() > 25) {
var f2 = r(this).startOf(t).add(1, t).date(n2), s = r(this).endOf(e);
if (f2.isBefore(s)) return 1;
}
var a = r(this).startOf(t).date(n2).startOf(e).subtract(1, "millisecond"), o = this.diff(a, e, true);
return o < 0 ? r(this).startOf("week").week() : Math.ceil(o);
}, f.weeks = function(e2) {
return void 0 === e2 && (e2 = null), this.week(e2);
};
};
});
})(weekOfYear$1);
var weekOfYearExports = weekOfYear$1.exports;
const weekOfYear = /* @__PURE__ */ getDefaultExportFromCjs(weekOfYearExports);
const START_WEEK_DAY_OF_2000 = 3;
const START_ENGLISH_DATE_OF_2000_BS = "1943-04-14";
const ALL_NEPALI_DATES = [
{ year: 2e3, months: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31] },
{ year: 2001, months: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30] },
{ year: 2002, months: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30] },
{ year: 2003, months: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31] },
{ year: 2004, months: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31] },
{ year: 2005, months: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30] },
{ year: 2006, months: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30] },
{ year: 2007, months: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31] },
{ year: 2008, months: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31] },
{ year: 2009, months: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30] },
{ year: 2010, months: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30] },
{ year: 2011, months: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31] },
{ year: 2012, months: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30] },
{ year: 2013, months: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30] },
{ year: 2014, months: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30] },
{ year: 2015, months: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31] },
{ year: 2016, months: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30] },
{ year: 2017, months: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30] },
{ year: 2018, months: [31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30] },
{ year: 2019, months: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31] },
{ year: 2020, months: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30] },
{ year: 2021, months: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30] },
{ year: 2022, months: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30] },
{ year: 2023, months: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31] },
{ year: 2024, months: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30] },
{ year: 2025, months: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30] },
{ year: 2026, months: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31] },
{ year: 2027, months: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31] },
{ year: 2028, months: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30] },
{ year: 2029, months: [31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30] },
{ year: 2030, months: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31] },
{ year: 2031, months: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31] },
{ year: 2032, months: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30] },
{ year: 2033, months: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30] },
{ year: 2034, months: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31] },
{ year: 2035, months: [30, 32, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31] },
{ year: 2036, months: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30] },
{ year: 2037, months: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30] },
{ year: 2038, months: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31] },
{ year: 2039, months: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30] },
{ year: 2040, months: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30] },
{ year: 2041, months: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30] },
{ year: 2042, months: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31] },
{ year: 2043, months: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30] },
{ year: 2044, months: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30] },
{ year: 2045, months: [31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30] },
{ year: 2046, months: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31] },
{ year: 2047, months: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30] },
{ year: 2048, months: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30] },
{ year: 2049, months: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30] },
{ year: 2050, months: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31] },
{ year: 2051, months: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30] },
{ year: 2052, months: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30] },
{ year: 2053, months: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30] },
{ year: 2054, months: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31] },
{ year: 2055, months: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30] },
{ year: 2056, months: [31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30] },
{ year: 2057, months: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31] },
{ year: 2058, months: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31] },
{ year: 2059, months: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30] },
{ year: 2060, months: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30] },
{ year: 2061, months: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31] },
{ year: 2062, months: [31, 31, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31] },
{ year: 2063, months: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30] },
{ year: 2064, months: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30] },
{ year: 2065, months: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31] },
{ year: 2066, months: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31] },
{ year: 2067, months: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30] },
{ year: 2068, months: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30] },
{ year: 2069, months: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31] },
{ year: 2070, months: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30] },
{ year: 2071, months: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30] },
{ year: 2072, months: [31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30] },
{ year: 2073, months: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31] },
{ year: 2074, months: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30] },
{ year: 2075, months: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30] },
{ year: 2076, months: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30] },
{ year: 2077, months: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31] },
{ year: 2078, months: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30] },
{ year: 2079, months: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30] },
{ year: 2080, months: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30] },
{ year: 2081, months: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31] },
{ year: 2082, months: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30] },
{ year: 2083, months: [31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30] },
{ year: 2084, months: [31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30] },
{ year: 2085, months: [31, 32, 31, 32, 30, 31, 30, 30, 29, 30, 30, 30] },
{ year: 2086, months: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30] },
{ year: 2087, months: [31, 31, 32, 31, 31, 31, 30, 30, 30, 30, 30, 30] },
{ year: 2088, months: [30, 31, 32, 32, 30, 31, 30, 30, 29, 30, 30, 30] },
{ year: 2089, months: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30] },
{ year: 2090, months: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30] },
{ year: 2091, months: [31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30] },
{ year: 2092, months: [30, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30] },
{ year: 2093, months: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30] },
{ year: 2094, months: [31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30] },
{ year: 2095, months: [31, 31, 32, 31, 31, 31, 30, 29, 30, 30, 30, 30] },
{ year: 2096, months: [30, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30] },
{ year: 2097, months: [31, 32, 31, 31, 31, 30, 30, 30, 29, 30, 30, 30] },
{ year: 2098, months: [31, 31, 32, 31, 31, 31, 29, 30, 29, 30, 29, 31] },
{ year: 2099, months: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31] }
];
const nepaliMonthNames$2 = [
"बैशाख",
"जेठ",
"असार",
"श्रावण",
"भदौ",
"आश्विन",
"कार्तिक",
"मंसिर",
"पुष",
"माघ",
"फाल्गुन",
"चैत्र"
];
const weekNepaliDayNames$2 = [
"आइत",
"सोम",
"मंगल",
"बुध",
"बिही",
"शुक्र",
"शनि"
];
const neLocale = {
lang: {
locale: "ne",
placeholder: "मिति चयन गर्नुहोस्",
rangePlaceholder: ["सुरुको मिति", "अन्तिम मिति"],
today: "आज",
now: "अहिले",
backToToday: "आजमा फर्कनुहोस्",
ok: "ठीक छ",
clear: "स्पष्ट",
month: "महिना",
year: "वर्ष",
timeSelect: "समय चयन गर्नुहोस्",
dateSelect: "मिति चयन गर्नुहोस्",
weekSelect: "एक हप्ता चयन गर्नुहोस्",
monthSelect: "महिना चयन गर्नुहोस्",
yearSelect: "वर्ष चयन गर्नुहोस्",
decadeSelect: "एक दशक चयन गर्नुहोस्",
yearFormat: "YYYY",
dateFormat: "M/D/YYYY",
dayFormat: "D",
dateTimeFormat: "M/D/YYYY HH:mm:ss",
monthBeforeYear: true,
previousMonth: "अघिल्लो महिना (PageUp)",
nextMonth: "अर्को महिना (PageDown)",
previousYear: "अघिल्लो वर्ष (Control + left)",
nextYear: "अर्को वर्ष (Control + right)",
previousDecade: "अघिल्लो दशक",
nextDecade: "अर्को दशक",
previousCentury: "अघिल्लो शताब्दी",
nextCentury: "अर्को शताब्दी",
shortMonths: nepaliMonthNames$2,
shortWeekDays: weekNepaliDayNames$2
},
timePickerLocale: {
placeholder: "समय चयन गर्नुहोस्"
}
};
const nepaliMonthNames$1 = [
"Baishakh",
"Jestha",
"Ashad",
"Shrawan",
"Bhadra",
"Ashwin",
"Kartik",
"Mangsir",
"Poush",
"Magh",
"Falgun",
"Chaitra"
];
const weekNepaliDayNames$1 = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
const enLocale = {
lang: {
locale: "en",
placeholder: "Select date",
rangePlaceholder: ["Start date", "End date"],
today: "Today",
now: "Now",
backToToday: "Back to today",
ok: "OK",
clear: "Clear",
month: "Month",
year: "Year",
timeSelect: "Select time",
dateSelect: "Select date",
weekSelect: "Select a week",
monthSelect: "Select a month",
yearSelect: "Select a year",
decadeSelect: "Select a decade",
yearFormat: "YYYY",
dateFormat: "M/D/YYYY",
dayFormat: "D",
dateTimeFormat: "M/D/YYYY HH:mm:ss",
monthBeforeYear: true,
previousMonth: "Previous month (PageUp)",
nextMonth: "Next month (PageDown)",
previousYear: "Previous year (Control + left)",
nextYear: "Next year (Control + right)",
previousDecade: "Previous decade",
nextDecade: "Next decade",
previousCentury: "Previous century",
nextCentury: "Next century",
shortMonths: nepaliMonthNames$1,
shortWeekDays: weekNepaliDayNames$1
},
timePickerLocale: {
placeholder: "Select time"
}
};
const START_ENGINE_DATE = dayjs(START_ENGLISH_DATE_OF_2000_BS);
class NepaliDateConverter {
/**
* Validates a given Nepali date.
* @param {NepaliDateType} bsDate - The Nepali date to validate.
* @returns {boolean} - True if the date is valid, false otherwise.
*/
static validateBsDate(bsDate) {
const yearData = ALL_NEPALI_DATES.find((y) => y.year === bsDate.year);
if (!yearData) return false;
if (bsDate.month < 1 || bsDate.month > 12) return false;
const daysInMonth = yearData.months[bsDate.month - 1];
if (bsDate.day < 1 || bsDate.day > daysInMonth) return false;
return true;
}
/**
* Gets today's Nepali date.
* @returns {NepaliDateType} - The current Nepali date.
*/
static getTodayBs() {
return this.adToBs(dayjs());
}
/**
* Gets the weekday for a given Nepali date.
* @param {NepaliDateType} bsDate - The Nepali date.
* @returns {number} - The weekday (0 = Sunday, 6 = Saturday).
*/
static getWeekDay(bsDate) {
let totalDays = 0;
for (const yearData2 of ALL_NEPALI_DATES) {
if (yearData2.year >= bsDate.year) break;
totalDays += yearData2.months.reduce((sum, days) => sum + days, 0);
}
const yearData = ALL_NEPALI_DATES.find((y) => y.year === bsDate.year);
if (yearData) {
for (let i = 0; i < bsDate.month - 1; i++) {
totalDays += yearData.months[i];
}
}
totalDays += bsDate.day - 1;
return (START_WEEK_DAY_OF_2000 + totalDays) % 7;
}
/**
* Converts an AD date to a Nepali date.
* @param {Dayjs | Date | string} adDate - The AD date to convert.
* @returns {NepaliDateType} - The corresponding Nepali date.
*/
static adToBs(adDate, lang = { lang: "en" }) {
const isNepali = lang.lang === "ne";
const months = isNepali ? nepaliMonthNames$2 : nepaliMonthNames$1;
const date4 = dayjs(adDate);
if (!date4.isValid())
return { year: 2e3, month: 1, day: 1, monthName: months[0] };
const diffDays = date4.diff(START_ENGINE_DATE, "day");
if (diffDays < 0)
return { year: 2e3, month: 1, day: 1, monthName: months[0] };
let remainingDays = diffDays;
let year = 2e3;
let month = 1;
let day = 1;
for (const yearData of ALL_NEPALI_DATES) {
const daysInYear = yearData.months.reduce((sum, days) => sum + days, 0);
if (remainingDays >= daysInYear) {
remainingDays -= daysInYear;
continue;
}
year = yearData.year;
for (let i = 0; i < 12; i++) {
const daysInMonth = yearData.months[i] ?? 30;
if (remainingDays >= daysInMonth) {
remainingDays -= daysInMonth;
continue;
}
month = i + 1;
day = remainingDays + 1;
return { year, month, day, monthName: months[i] };
}
break;
}
return { year, month, day: day || 1, monthName: months[month - 1] };
}
/**
* Converts a Nepali date to an AD date.
* @param {NepaliDateType} bsDate - The Nepali date to convert.
* @returns {Dayjs} - The corresponding AD date.
*/
static bsToAd(bsDate) {
let daysToAdd = 0;
for (const yearData of ALL_NEPALI_DATES) {
if (yearData.year >= bsDate.year) {
break;
}
daysToAdd += yearData.months.reduce((sum, days) => sum + days, 0);
}
const currentYearData = ALL_NEPALI_DATES.find(
(d) => d.year === bsDate.year
);
if (currentYearData) {
for (let i = 0; i < bsDate.month - 1; i++) {
daysToAdd += currentYearData.months[i];
}
}
daysToAdd += bsDate.day - 1;
return START_ENGINE_DATE.add(daysToAdd, "day");
}
/**
* Gets the Nepali date for a given AD date.
* @param {Date} adDate - The AD date.
* @returns {NepaliDateType} - The corresponding Nepali date.
*/
static getNepaliDate(adDate) {
return this.adToBs(dayjs(adDate));
}
/**
* Gets the AD date for a given Nepali date.
* @param {number} npYear - The Nepali year.
* @param {number} npMonth - The Nepali month.
* @param {number} npDay - The Nepali day.
* @returns {Date} - The corresponding AD date.
*/
static getEnglishDate(npYear, npMonth, npDay) {
return this.bsToAd({ year: npYear, month: npMonth, day: npDay }).toDate();
}
/**
* Gets the number of days in a given Nepali month.
* @param {number} year - The Nepali year.
* @param {number} month - The Nepali month.
* @returns {number} - The number of days in the month.
*/
static getDaysInMonth(year, month) {
const yearData = ALL_NEPALI_DATES.find((d) => d.year === year);
if (!yearData) return 30;
return yearData.months[month - 1];
}
}
dayjs.extend(weekOfYear);
const nepaliMonthNames = [
"Baishakh",
"Jestha",
"Ashad",
"Shrawan",
"Bhadra",
"Ashwin",
"Kartik",
"Mangsir",
"Poush",
"Magh",
"Falgun",
"Chaitra"
];
const weekNepaliDayNames = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
const nepaliDateConfig = {
// Get methods
getNow: () => dayjs(),
getFixedDate: (string3) => {
return dayjs(string3);
},
getEndDate: (date4) => {
const bsDate = NepaliDateConverter.adToBs(date4);
const daysInMonth = NepaliDateConverter.getDaysInMonth(
bsDate.year,
bsDate.month
);
return date4.date(daysInMonth);
},
getWeekDay: (date4) => {
const bsDate = NepaliDateConverter.adToBs(date4);
return NepaliDateConverter.getWeekDay(bsDate);
},
getYear: (date4) => {
const bsDate = NepaliDateConverter.adToBs(date4);
return bsDate.year;
},
getMonth: (date4) => {
const bsDate = NepaliDateConverter.adToBs(date4);
return bsDate.month - 1;
},
getDate: (date4) => {
const bsDate = NepaliDateConverter.adToBs(date4);
return bsDate.day;
},
getHour: (date4) => {
return date4.hour();
},
getMinute: (date4) => {
return date4.minute();
},
getSecond: (date4) => {
return date4.second();
},
getMillisecond: (date4) => {
return date4.millisecond();
},
// Set methods
addYear: (date4, diff) => {
const bsDate = NepaliDateConverter.adToBs(date4);
const newDate = {
year: bsDate.year + diff,
month: bsDate.month,
day: bsDate.day
};
return NepaliDateConverter.validateBsDate(newDate) ? NepaliDateConverter.bsToAd(newDate) : date4;
},
addMonth: (date4, diff) => {
const bsDate = NepaliDateConverter.adToBs(date4);
let year = bsDate.year;
let month = bsDate.month + diff;
while (month > 12) {
year += 1;
month -= 12;
}
while (month < 1) {
year -= 1;
month += 12;
}
const daysInMonth = NepaliDateConverter.getDaysInMonth(year, month);
const day = Math.min(bsDate.day, daysInMonth);
const newDate = { year, month, day };
return NepaliDateConverter.validateBsDate(newDate) ? NepaliDateConverter.bsToAd(newDate) : date4;
},
addDate: (date4, diff) => {
return date4.add(diff, "day");
},
setYear: (date4, year) => {
const bsDate = NepaliDateConverter.adToBs(date4);
const newDate = {
year,
month: bsDate.month,
day: bsDate.day
};
return NepaliDateConverter.validateBsDate(newDate) ? NepaliDateConverter.bsToAd(newDate) : date4;
},
setMonth: (date4, month) => {
const bsDate = NepaliDateConverter.adToBs(date4);
const newDate = {
year: bsDate.year,
month: month + 1,
// Convert from 0-based month
day: bsDate.day
};
return NepaliDateConverter.validateBsDate(newDate) ? NepaliDateConverter.bsToAd(newDate) : date4;
},
setDate: (date4, day) => {
const bsDate = NepaliDateConverter.adToBs(date4);
const newDate = {
year: bsDate.year,
month: bsDate.month,
day
};
return NepaliDateConverter.validateBsDate(newDate) ? NepaliDateConverter.bsToAd(newDate) : date4;
},
setHour: (date4, hour) => {
return date4.hour(hour);
},
setMinute: (date4, minute) => {
return date4.minute(minute);
},
setSecond: (date4, second) => {
return date4.second(second);
},
setMillisecond: (date4, millisecond) => {
return date4.millisecond(millisecond);
},
// Compare methods
isAfter: (date1, date22) => {
if (!date1.isValid() || !date22.isValid()) return false;
return date1.isAfter(date22);
},
isValidate: (date4) => {
return date4.isValid();
},
locale: {
shortMonths: nepaliMonthNames,
shortWeekDays: weekNepaliDayNames,
getWeekFirstDay: () => 0,
getWeekFirstDate: (_, date4) => {
return date4.startOf("week");
},
getWeek: (_, date4) => {
return date4.week();
},
format: (_, date4, format2) => {
if (!date4 || !date4.isValid()) return "";
const bsDate = NepaliDateConverter.adToBs(date4);
if (format2 === "date") {
return bsDate.day.toString();
}
if (format2 === "YYYY" || format2 === "yearFormat") {
return bsDate.year.toString();
}
if (format2 === "M" || format2 === "monthFormat") {
return bsDate.month.toString();
}
if (format2 === "D" || format2 === "dayFormat") {
return bsDate.day.toString();
}
if (format2 === "dateFormat" || format2 === "YYYY-MM-DD") {
return `${bsDate.year}-${bsDate.month.toString().padStart(2, "0")}-${bsDate.day.toString().padStart(2, "0")}`;
}
return bsDate.year.toString();
},
parse: (_, text) => {
if (!text) return dayjs(null);
const [yearStr, monthStr, dayStr] = text.split("-");
const year = parseInt(yearStr, 10);
const month = parseInt(monthStr, 10);
const day = parseInt(dayStr, 10);
if (isNaN(year) || isNaN(month) || isNaN(day)) {
return dayjs(null);
}
const bsDate = { year, month, day };
return NepaliDateConverter.validateBsDate(bsDate) ? NepaliDateConverter.bsToAd(bsDate) : dayjs(null);
}
}
};
const CustomDatePicker$1 = generatePicker(nepaliDateConfig);
const NepaliDatePicker = forwardRef((props, ref) => {
const { type: type4, lang, ...rest } = props;
const locale2 = lang === "ne" ? neLocale : enLocale;
if (type4 === "ne")
return /* @__PURE__ */ jsxRuntimeExports.jsx(CustomDatePicker$1, { ...rest, locale: locale2, ref, lang: "nepali" });
return /* @__PURE__ */ jsxRuntimeExports.jsx(DatePicker, { ...rest, ref });
});
const { RangePicker: AntRangePicker } = DatePicker;
const CustomDatePicker = generatePicker(nepaliDateConfig);
const CustomRangePicker = CustomDatePicker.RangePicker;
const NepaliRangePicker = forwardRef((props, ref) => {
const { type: type4, lang, ...rest } = props;
const locale2 = lang === "ne" ? neLocale : enLocale;
if (type4 === "ne")
return /* @__PURE__ */ jsxRuntimeExports.jsx(CustomRangePicker, { ...rest, locale: locale2, ref });
return /* @__PURE__ */ jsxRuntimeExports.jsx(AntRangePicker, { ...rest, ref });
});
export {
NepaliDateConverter,
NepaliDatePicker,
NepaliRangePicker
};