{"version":3,"file":"static/js/main.d2198737.js","sources":["../node_modules/@ant-design/cssinjs-utils/es/util/calc/calculator.js","../node_modules/@ant-design/cssinjs-utils/es/util/calc/CSSCalculator.js","../node_modules/@ant-design/cssinjs-utils/es/util/calc/NumCalculator.js","../node_modules/@ant-design/cssinjs-utils/es/util/calc/index.js","../node_modules/@ant-design/cssinjs-utils/es/util/getCompVarPrefix.js","../node_modules/@ant-design/cssinjs-utils/es/util/getComponentToken.js","../node_modules/@ant-design/cssinjs-utils/es/util/statistic.js","../node_modules/@ant-design/cssinjs-utils/es/util/getDefaultComponentToken.js","../node_modules/@ant-design/cssinjs-utils/es/util/maxmin.js","../node_modules/@ant-design/cssinjs-utils/es/_util/hooks/useUniqueMemo.js","../node_modules/@ant-design/cssinjs-utils/es/hooks/useCSP.js","../node_modules/@ant-design/cssinjs-utils/es/util/genStyleUtils.js","../node_modules/@emotion/hash/dist/hash.browser.esm.js","../node_modules/@ant-design/cssinjs/es/Cache.js","../node_modules/@ant-design/cssinjs/es/StyleContext.js","../node_modules/@ant-design/cssinjs/es/theme/calc/calculator.js","../node_modules/@ant-design/cssinjs/es/theme/calc/CSSCalculator.js","../node_modules/@ant-design/cssinjs/es/theme/calc/NumCalculator.js","../node_modules/@ant-design/cssinjs/es/theme/calc/index.js","../node_modules/@ant-design/cssinjs/es/theme/ThemeCache.js","../node_modules/@ant-design/cssinjs/es/theme/Theme.js","../node_modules/@ant-design/cssinjs/es/theme/createTheme.js","../node_modules/@ant-design/cssinjs/es/util/index.js","../node_modules/@ant-design/cssinjs/es/util/css-variables.js","../node_modules/@ant-design/cssinjs/es/hooks/useCompatibleInsertionEffect.js","../node_modules/@ant-design/cssinjs/es/hooks/useEffectCleanupRegister.js","../node_modules/@ant-design/cssinjs/es/hooks/useHMR.js","../node_modules/@ant-design/cssinjs/es/hooks/useGlobalCache.js","../node_modules/@ant-design/cssinjs/es/hooks/useCacheToken.js","../node_modules/@emotion/unitless/dist/unitless.browser.esm.js","../node_modules/stylis/src/Enum.js","../node_modules/stylis/src/Utility.js","../node_modules/stylis/src/Serializer.js","../node_modules/stylis/src/Tokenizer.js","../node_modules/stylis/src/Parser.js","../node_modules/@ant-design/cssinjs/es/linters/utils.js","../node_modules/@ant-design/cssinjs/es/linters/legacyNotSelectorLinter.js","../node_modules/@ant-design/cssinjs/es/util/cacheMapUtil.js","../node_modules/@ant-design/cssinjs/es/linters/logicalPropertiesLinter.js","../node_modules/@ant-design/cssinjs/es/linters/NaNLinter.js","../node_modules/@ant-design/cssinjs/es/linters/parentSelectorLinter.js","../node_modules/@ant-design/cssinjs/es/hooks/useStyleRegister.js","../node_modules/@ant-design/cssinjs/es/extractStyle.js","../node_modules/@ant-design/cssinjs/es/hooks/useCSSVarRegister.js","../node_modules/@ant-design/cssinjs/es/Keyframes.js","../node_modules/@ant-design/cssinjs/es/transformers/legacyLogicalProperties.js","../node_modules/@ant-design/cssinjs/es/transformers/px2rem.js","../node_modules/@ant-design/cssinjs/es/index.js","../node_modules/@ant-design/fast-color/es/FastColor.js","../node_modules/@ant-design/icons-svg/lib/asn/CheckOutlined.js","../node_modules/@ant-design/icons-svg/lib/asn/CloseCircleFilled.js","../node_modules/@ant-design/icons-svg/lib/asn/CloseOutlined.js","../node_modules/@ant-design/icons-svg/lib/asn/DownOutlined.js","../node_modules/@ant-design/icons-svg/lib/asn/ExclamationCircleFilled.js","../node_modules/@ant-design/icons-svg/lib/asn/EyeInvisibleOutlined.js","../node_modules/@ant-design/icons-svg/lib/asn/EyeOutlined.js","../node_modules/@ant-design/icons-svg/lib/asn/LoadingOutlined.js","../node_modules/@ant-design/icons-svg/lib/asn/RightOutlined.js","../node_modules/@ant-design/icons-svg/lib/asn/SearchOutlined.js","../node_modules/@antv/event-emitter/src/index.ts","../node_modules/@antv/g-base/src/abstract/base.ts","../node_modules/d3-timer/src/timer.js","../node_modules/d3-color/src/define.js","../node_modules/d3-color/src/color.js","../node_modules/d3-interpolate/src/basis.js","../node_modules/d3-interpolate/src/constant.js","../node_modules/d3-interpolate/src/color.js","../node_modules/d3-interpolate/src/rgb.js","../node_modules/d3-interpolate/src/basisClosed.js","../node_modules/d3-interpolate/src/numberArray.js","../node_modules/d3-interpolate/src/array.js","../node_modules/d3-interpolate/src/date.js","../node_modules/d3-interpolate/src/number.js","../node_modules/d3-interpolate/src/object.js","../node_modules/d3-interpolate/src/string.js","../node_modules/d3-interpolate/src/value.js","../node_modules/@antv/g-base/src/util/color.ts","../node_modules/@antv/g-base/src/animate/timeline.ts","../node_modules/@antv/g-base/src/event/event-contoller.ts","../node_modules/@antv/g-base/src/abstract/canvas.ts","../node_modules/@antv/g-base/src/abstract/container.ts","../node_modules/@antv/g-base/src/abstract/element.ts","../node_modules/@antv/g-base/src/abstract/group.ts","../node_modules/@antv/g-base/src/abstract/shape.ts","../node_modules/d3-ease/src/linear.js","../node_modules/d3-ease/src/quad.js","../node_modules/d3-ease/src/cubic.js","../node_modules/d3-ease/src/poly.js","../node_modules/d3-ease/src/sin.js","../node_modules/d3-ease/src/math.js","../node_modules/d3-ease/src/exp.js","../node_modules/d3-ease/src/circle.js","../node_modules/d3-ease/src/bounce.js","../node_modules/d3-ease/src/back.js","../node_modules/d3-ease/src/elastic.js","../node_modules/@antv/g-base/src/animate/register.ts","../node_modules/@antv/g-base/src/bbox/register.ts","../node_modules/@antv/g-base/src/bbox/rect.ts","../node_modules/@antv/g-base/src/bbox/circle.ts","../node_modules/@antv/g-base/src/bbox/util.ts","../node_modules/@antv/g-base/node_modules/@antv/path-util/src/parse-path.ts","../node_modules/@antv/g-base/node_modules/@antv/path-util/src/parse-path-string.ts","../node_modules/@antv/g-base/node_modules/@antv/path-util/src/process/arc-2-cubic.ts","../node_modules/@antv/g-base/node_modules/@antv/path-util/src/get-arc-params.ts","../node_modules/@antv/g-base/node_modules/@antv/path-util/src/path-2-segments.ts","../node_modules/@antv/g-base/src/bbox/path.ts","../node_modules/@antv/g-base/src/bbox/index.ts","../node_modules/@antv/g-base/src/bbox/polyline.ts","../node_modules/@antv/g-base/src/bbox/polygon.ts","../node_modules/@antv/g-base/src/bbox/text.ts","../node_modules/@antv/g-base/src/bbox/line.ts","../node_modules/@antv/g-base/src/bbox/ellipse.ts","../node_modules/@antv/g-base/src/event/graph-event.ts","../node_modules/@antv/g-base/src/index.ts","../node_modules/@antv/g-base/src/util/matrix.ts","../node_modules/@antv/g-base/src/util/offscreen.ts","../node_modules/@antv/g-base/src/util/path.ts","../node_modules/@antv/g-base/src/util/text.ts","../node_modules/@antv/g-base/src/util/util.ts","../node_modules/@antv/g-math/src/util.ts","../node_modules/@antv/g-math/src/line.ts","../node_modules/@antv/g-math/src/bezier.ts","../node_modules/@antv/g-math/src/quadratic.ts","../node_modules/@antv/g-math/src/cubic.ts","../node_modules/@antv/g-math/src/ellipse.ts","../node_modules/@antv/g-math/src/arc.ts","../node_modules/@antv/g-math/src/segments.ts","../node_modules/@antv/g-math/src/polyline.ts","../node_modules/@antv/matrix-util/src/ext.ts","../node_modules/@antv/util/src/is-array-like.ts","../node_modules/@antv/util/src/contains.ts","../node_modules/@antv/util/src/filter.ts","../node_modules/@antv/util/src/difference.ts","../node_modules/@antv/util/src/is-type.ts","../node_modules/@antv/util/src/is-function.ts","../node_modules/@antv/util/src/is-nil.ts","../node_modules/@antv/util/src/is-array.ts","../node_modules/@antv/util/src/is-object.ts","../node_modules/@antv/util/src/each.ts","../node_modules/@antv/util/src/keys.ts","../node_modules/@antv/util/src/is-match.ts","../node_modules/@antv/util/src/is-object-like.ts","../node_modules/@antv/util/src/is-plain-object.ts","../node_modules/@antv/util/src/find.ts","../node_modules/@antv/util/src/find-index.ts","../node_modules/@antv/util/src/first-value.ts","../node_modules/@antv/util/src/flatten.ts","../node_modules/@antv/util/src/max.ts","../node_modules/@antv/util/src/min.ts","../node_modules/@antv/util/src/get-range.ts","../node_modules/@antv/util/src/pull.ts","../node_modules/@antv/util/src/pull-at.ts","../node_modules/@antv/util/src/reduce.ts","../node_modules/@antv/util/src/remove.ts","../node_modules/@antv/util/src/is-string.ts","../node_modules/@antv/util/src/sort-by.ts","../node_modules/@antv/util/src/uniq.ts","../node_modules/@antv/util/src/values-of-key.ts","../node_modules/@antv/util/src/head.ts","../node_modules/@antv/util/src/last.ts","../node_modules/@antv/util/src/ends-with.ts","../node_modules/@antv/util/src/every.ts","../node_modules/@antv/util/src/some.ts","../node_modules/@antv/util/src/group-by.ts","../node_modules/@antv/util/src/group-to-map.ts","../node_modules/@antv/util/src/group.ts","../node_modules/@antv/util/src/parse-radius.ts","../node_modules/@antv/util/src/clamp.ts","../node_modules/@antv/util/src/fixed-base.ts","../node_modules/@antv/util/src/is-number.ts","../node_modules/@antv/util/src/is-number-equal.ts","../node_modules/@antv/util/src/is-integer.ts","../node_modules/@antv/util/src/is-odd.ts","../node_modules/@antv/util/src/max-by.ts","../node_modules/@antv/util/src/min-by.ts","../node_modules/@antv/util/src/mod.ts","../node_modules/@antv/util/src/to-radian.ts","../node_modules/@antv/util/src/to-degree.ts","../node_modules/@antv/util/src/for-in.ts","../node_modules/@antv/util/src/has-key.ts","../node_modules/@antv/util/src/has.ts","../node_modules/@antv/util/src/values.ts","../node_modules/@antv/util/src/to-string.ts","../node_modules/@antv/util/src/lower-case.ts","../node_modules/@antv/util/src/substitute.ts","../node_modules/@antv/util/src/upper-first.ts","../node_modules/@antv/util/src/get-type.ts","../node_modules/@antv/util/src/is-boolean.ts","../node_modules/@antv/util/src/is-date.ts","../node_modules/@antv/util/src/is-null.ts","../node_modules/@antv/util/src/is-prototype.ts","../node_modules/@antv/util/src/is-undefined.ts","../node_modules/@antv/util/src/is-element.ts","../node_modules/@antv/util/src/request-animation-frame.ts","../node_modules/@antv/util/src/clear-animation-frame.ts","../node_modules/@antv/util/src/augment.ts","../node_modules/@antv/util/src/clone.ts","../node_modules/@antv/util/src/debounce.ts","../node_modules/@antv/util/src/memoize.ts","../node_modules/@antv/util/src/deep-mix.ts","../node_modules/@antv/util/src/index-of.ts","../node_modules/@antv/util/src/is-empty.ts","../node_modules/@antv/util/src/is-equal.ts","../node_modules/@antv/util/src/map.ts","../node_modules/@antv/util/src/map-values.ts","../node_modules/@antv/util/src/mix.ts","../node_modules/@antv/util/src/get.ts","../node_modules/@antv/util/src/set.ts","../node_modules/@antv/util/src/pick.ts","../node_modules/@antv/util/src/omit.ts","../node_modules/@antv/util/src/throttle.ts","../node_modules/@antv/util/src/to-array.ts","../node_modules/@antv/util/src/unique-id.ts","../node_modules/@antv/util/src/noop.ts","../node_modules/@antv/util/src/size.ts","../node_modules/@antv/util/src/measure-text-width.ts","../node_modules/@antv/util/src/get-ellipsis-text.ts","../node_modules/@antv/util/src/cache.ts","../node_modules/@rc-component/color-picker/es/color.js","../node_modules/@rc-component/color-picker/es/util.js","../node_modules/@rc-component/color-picker/es/components/ColorBlock.js","../node_modules/@rc-component/color-picker/es/hooks/useColorDrag.js","../node_modules/@rc-component/color-picker/es/components/Handler.js","../node_modules/@rc-component/color-picker/es/components/Palette.js","../node_modules/@rc-component/color-picker/es/components/Transform.js","../node_modules/@rc-component/color-picker/es/components/Picker.js","../node_modules/@rc-component/color-picker/es/hooks/useColorState.js","../node_modules/@rc-component/color-picker/es/components/Gradient.js","../node_modules/@rc-component/color-picker/es/components/Slider.js","../node_modules/@rc-component/color-picker/es/ColorPicker.js","../node_modules/@rc-component/color-picker/es/hooks/useComponent.js","../node_modules/@rc-component/color-picker/es/index.js","../node_modules/@rc-component/portal/es/Context.js","../node_modules/@rc-component/portal/es/useDom.js","../node_modules/@rc-component/portal/es/useScrollLocker.js","../node_modules/@rc-component/portal/es/util.js","../node_modules/@rc-component/portal/es/mock.js","../node_modules/@rc-component/portal/es/Portal.js","../node_modules/@rc-component/portal/es/index.js","../node_modules/@rc-component/trigger/es/Popup/Arrow.js","../node_modules/@rc-component/trigger/es/Popup/Mask.js","../node_modules/@rc-component/trigger/es/Popup/PopupContent.js","../node_modules/@rc-component/trigger/es/Popup/index.js","../node_modules/@rc-component/trigger/es/TriggerWrapper.js","../node_modules/@rc-component/trigger/es/context.js","../node_modules/@rc-component/trigger/es/hooks/useAction.js","../node_modules/@rc-component/trigger/es/util.js","../node_modules/@rc-component/trigger/es/hooks/useAlign.js","../node_modules/@rc-component/trigger/es/index.js","../node_modules/@rc-component/trigger/es/hooks/useWatch.js","../node_modules/@rc-component/trigger/es/hooks/useWinClick.js","../node_modules/abs-svg-path/index.js","../node_modules/antd/lib/_util/ActionButton.js","../node_modules/antd/lib/_util/ContextIsolator.js","../node_modules/antd/lib/_util/PurePanel.js","../node_modules/antd/lib/_util/colors.js","../node_modules/antd/lib/_util/getAllowClear.js","../node_modules/antd/lib/_util/getRenderPropValue.js","../node_modules/antd/lib/_util/hooks/useZIndex.js","../node_modules/antd/lib/_util/motion.js","../node_modules/antd/lib/_util/placements.js","../node_modules/antd/lib/_util/reactNode.js","../node_modules/antd/lib/_util/statusUtils.js","../node_modules/antd/lib/_util/warning.js","../node_modules/antd/lib/_util/wave/WaveEffect.js","../node_modules/antd/lib/_util/wave/index.js","../node_modules/antd/lib/_util/wave/interface.js","../node_modules/antd/lib/_util/wave/style.js","../node_modules/antd/lib/_util/wave/useWave.js","../node_modules/antd/lib/_util/wave/util.js","../node_modules/antd/lib/_util/zindexContext.js","../node_modules/antd/lib/button/DefaultLoadingIcon.js","../node_modules/antd/lib/button/IconWrapper.js","../node_modules/antd/lib/button/button-group.js","../node_modules/antd/lib/button/button.js","../node_modules/antd/lib/button/buttonHelpers.js","../node_modules/antd/lib/button/index.js","../node_modules/antd/lib/button/style/compact.js","../node_modules/antd/lib/button/style/group.js","../node_modules/antd/lib/button/style/index.js","../node_modules/antd/lib/button/style/token.js","../node_modules/antd/lib/calendar/locale/en_US.js","../node_modules/antd/lib/card/Meta.js","../node_modules/antd/lib/collapse/Collapse.js","../node_modules/antd/lib/collapse/CollapsePanel.js","../node_modules/antd/lib/collapse/index.js","../node_modules/antd/lib/collapse/style/index.js","../node_modules/antd/lib/color-picker/color.js","../node_modules/antd/lib/color-picker/components/ColorPresets.js","../node_modules/antd/lib/color-picker/util.js","../node_modules/antd/lib/config-provider/DisabledContext.js","../node_modules/antd/lib/config-provider/MotionWrapper.js","../node_modules/antd/lib/config-provider/PropWarning.js","../node_modules/antd/lib/config-provider/SizeContext.js","../node_modules/antd/lib/config-provider/UnstableContext.js","../node_modules/antd/lib/config-provider/context.js","../node_modules/antd/lib/config-provider/cssVariables.js","../node_modules/antd/lib/config-provider/defaultRenderEmpty.js","../node_modules/antd/lib/config-provider/hooks/useCSSVarCls.js","../node_modules/antd/lib/config-provider/hooks/useConfig.js","../node_modules/antd/lib/config-provider/hooks/useSize.js","../node_modules/antd/lib/config-provider/hooks/useTheme.js","../node_modules/antd/lib/config-provider/hooks/useThemeKey.js","../node_modules/antd/lib/config-provider/index.js","../node_modules/antd/lib/config-provider/style/index.js","../node_modules/antd/lib/date-picker/locale/en_US.js","../node_modules/antd/lib/empty/empty.js","../node_modules/antd/lib/empty/index.js","../node_modules/antd/lib/empty/simple.js","../node_modules/antd/lib/empty/style/index.js","../node_modules/antd/lib/form/context.js","../node_modules/antd/lib/form/hooks/useVariants.js","../node_modules/antd/lib/form/validateMessagesContext.js","../node_modules/antd/lib/input/Group.js","../node_modules/antd/lib/input/Input.js","../node_modules/antd/lib/input/OTP/OTPInput.js","../node_modules/antd/lib/input/OTP/index.js","../node_modules/antd/lib/input/Password.js","../node_modules/antd/lib/input/Search.js","../node_modules/antd/lib/input/TextArea.js","../node_modules/antd/lib/input/hooks/useRemovePasswordTimeout.js","../node_modules/antd/lib/input/index.js","../node_modules/antd/lib/input/style/index.js","../node_modules/antd/lib/input/style/otp.js","../node_modules/antd/lib/input/style/textarea.js","../node_modules/antd/lib/input/style/token.js","../node_modules/antd/lib/input/style/variants.js","../node_modules/antd/lib/input/utils.js","../node_modules/antd/lib/locale/context.js","../node_modules/antd/lib/locale/en_US.js","../node_modules/antd/lib/locale/index.js","../node_modules/antd/lib/locale/useLocale.js","../node_modules/antd/lib/modal/locale.js","../node_modules/antd/lib/popconfirm/PurePanel.js","../node_modules/antd/lib/popconfirm/index.js","../node_modules/antd/lib/popconfirm/style/index.js","../node_modules/antd/lib/popover/PurePanel.js","../node_modules/antd/lib/popover/index.js","../node_modules/antd/lib/popover/style/index.js","../node_modules/antd/lib/select/index.js","../node_modules/antd/lib/select/mergedBuiltinPlacements.js","../node_modules/antd/lib/select/style/dropdown.js","../node_modules/antd/lib/select/style/index.js","../node_modules/antd/lib/select/style/multiple.js","../node_modules/antd/lib/select/style/single.js","../node_modules/antd/lib/select/style/token.js","../node_modules/antd/lib/select/style/variants.js","../node_modules/antd/lib/select/useIcons.js","../node_modules/antd/lib/select/useShowArrow.js","../node_modules/antd/lib/space/Compact.js","../node_modules/antd/lib/space/style/compact.js","../node_modules/antd/lib/space/style/index.js","../node_modules/antd/lib/style/compact-item-vertical.js","../node_modules/antd/lib/style/compact-item.js","../node_modules/antd/lib/style/index.js","../node_modules/antd/lib/style/motion/collapse.js","../node_modules/antd/lib/style/motion/fade.js","../node_modules/antd/lib/style/motion/index.js","../node_modules/antd/lib/style/motion/motion.js","../node_modules/antd/lib/style/motion/move.js","../node_modules/antd/lib/style/motion/slide.js","../node_modules/antd/lib/style/motion/zoom.js","../node_modules/antd/lib/style/placementArrow.js","../node_modules/antd/lib/style/roundedArrow.js","../node_modules/antd/lib/theme/context.js","../node_modules/antd/lib/theme/interface/index.js","../node_modules/antd/lib/theme/interface/presetColors.js","../node_modules/antd/lib/theme/internal.js","../node_modules/antd/lib/theme/themes/default/colorAlgorithm.js","../node_modules/antd/lib/theme/themes/default/colors.js","../node_modules/antd/lib/theme/themes/default/index.js","../node_modules/antd/lib/theme/themes/default/theme.js","../node_modules/antd/lib/theme/themes/seed.js","../node_modules/antd/lib/theme/themes/shared/genColorMapToken.js","../node_modules/antd/lib/theme/themes/shared/genCommonMapToken.js","../node_modules/antd/lib/theme/themes/shared/genControlHeight.js","../node_modules/antd/lib/theme/themes/shared/genFontMapToken.js","../node_modules/antd/lib/theme/themes/shared/genFontSizes.js","../node_modules/antd/lib/theme/themes/shared/genRadius.js","../node_modules/antd/lib/theme/themes/shared/genSizeMapToken.js","../node_modules/antd/lib/theme/useToken.js","../node_modules/antd/lib/theme/util/alias.js","../node_modules/antd/lib/theme/util/genPresetColor.js","../node_modules/antd/lib/theme/util/genStyleUtils.js","../node_modules/antd/lib/theme/util/getAlphaColor.js","../node_modules/antd/lib/theme/util/useResetIconStyle.js","../node_modules/antd/lib/time-picker/locale/en_US.js","../node_modules/antd/lib/tooltip/PurePanel.js","../node_modules/antd/lib/tooltip/index.js","../node_modules/antd/lib/tooltip/style/index.js","../node_modules/antd/lib/tooltip/util.js","../node_modules/antd/lib/version/index.js","../node_modules/antd/lib/version/version.js","../node_modules/antd/node_modules/@ant-design/colors/es/generate.js","../node_modules/antd/node_modules/@ant-design/colors/es/presets.js","../node_modules/antd/node_modules/@ant-design/icons/CheckOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/CloseCircleFilled.js","../node_modules/antd/node_modules/@ant-design/icons/CloseOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/DownOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/ExclamationCircleFilled.js","../node_modules/antd/node_modules/@ant-design/icons/EyeInvisibleOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/EyeOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/LoadingOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/RightOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/SearchOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/lib/components/AntdIcon.js","../node_modules/antd/node_modules/@ant-design/icons/lib/components/Context.js","../node_modules/antd/node_modules/@ant-design/icons/lib/components/IconBase.js","../node_modules/antd/node_modules/@ant-design/icons/lib/components/twoTonePrimaryColor.js","../node_modules/antd/node_modules/@ant-design/icons/lib/icons/CheckOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/lib/icons/CloseCircleFilled.js","../node_modules/antd/node_modules/@ant-design/icons/lib/icons/CloseOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/lib/icons/DownOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/lib/icons/ExclamationCircleFilled.js","../node_modules/antd/node_modules/@ant-design/icons/lib/icons/EyeInvisibleOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/lib/icons/EyeOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/lib/icons/LoadingOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/lib/icons/RightOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/lib/icons/SearchOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/lib/utils.js","../node_modules/antd/node_modules/rc-field-form/es/FieldContext.js","../node_modules/antd/node_modules/rc-field-form/es/ListContext.js","../node_modules/antd/node_modules/rc-field-form/es/utils/typeUtil.js","../node_modules/@rc-component/async-validator/es/messages.js","../node_modules/@rc-component/async-validator/es/util.js","../node_modules/@rc-component/async-validator/es/rule/enum.js","../node_modules/@rc-component/async-validator/es/rule/url.js","../node_modules/@rc-component/async-validator/es/rule/required.js","../node_modules/@rc-component/async-validator/es/rule/type.js","../node_modules/@rc-component/async-validator/es/rule/index.js","../node_modules/@rc-component/async-validator/es/rule/whitespace.js","../node_modules/@rc-component/async-validator/es/rule/range.js","../node_modules/@rc-component/async-validator/es/rule/pattern.js","../node_modules/@rc-component/async-validator/es/validator/required.js","../node_modules/@rc-component/async-validator/es/validator/type.js","../node_modules/@rc-component/async-validator/es/validator/index.js","../node_modules/@rc-component/async-validator/es/validator/string.js","../node_modules/@rc-component/async-validator/es/validator/method.js","../node_modules/@rc-component/async-validator/es/validator/number.js","../node_modules/@rc-component/async-validator/es/validator/boolean.js","../node_modules/@rc-component/async-validator/es/validator/regexp.js","../node_modules/@rc-component/async-validator/es/validator/integer.js","../node_modules/@rc-component/async-validator/es/validator/float.js","../node_modules/@rc-component/async-validator/es/validator/array.js","../node_modules/@rc-component/async-validator/es/validator/object.js","../node_modules/@rc-component/async-validator/es/validator/enum.js","../node_modules/@rc-component/async-validator/es/validator/pattern.js","../node_modules/@rc-component/async-validator/es/validator/date.js","../node_modules/@rc-component/async-validator/es/validator/any.js","../node_modules/@rc-component/async-validator/es/index.js","../node_modules/antd/node_modules/rc-field-form/es/utils/messages.js","../node_modules/antd/node_modules/rc-field-form/es/utils/validateUtil.js","../node_modules/antd/node_modules/rc-field-form/es/utils/valueUtil.js","../node_modules/antd/node_modules/rc-field-form/es/Field.js","../node_modules/antd/node_modules/rc-field-form/es/List.js","../node_modules/antd/node_modules/rc-field-form/es/utils/NameMap.js","../node_modules/antd/node_modules/rc-field-form/es/useForm.js","../node_modules/antd/node_modules/rc-field-form/es/utils/asyncUtil.js","../node_modules/antd/node_modules/rc-field-form/es/FormContext.js","../node_modules/antd/node_modules/rc-field-form/es/Form.js","../node_modules/antd/node_modules/rc-field-form/es/useWatch.js","../node_modules/antd/node_modules/rc-field-form/es/index.js","../node_modules/base64-js/index.js","../node_modules/brotli/dec/bit_reader.js","../node_modules/brotli/dec/context.js","../node_modules/brotli/dec/decode.js","../node_modules/brotli/dec/dictionary-browser.js","../node_modules/brotli/dec/dictionary.bin.js","../node_modules/brotli/dec/dictionary.js","../node_modules/brotli/dec/huffman.js","../node_modules/brotli/dec/prefix.js","../node_modules/brotli/dec/streams.js","../node_modules/brotli/dec/transform.js","../node_modules/brotli/decompress.js","../node_modules/clone/clone.js","../node_modules/clsx/dist/clsx.m.js","../node_modules/color-name/index.js","../node_modules/color-string/index.js","../node_modules/copy-to-clipboard/index.js","../node_modules/cross-fetch/dist/browser-ponyfill.js","../node_modules/crypto-js/core.js","../node_modules/crypto-js/md5.js","../node_modules/d3-regression/dist/d3-regression.js","../node_modules/dayjs/dayjs.min.js","../node_modules/dayjs/plugin/advancedFormat.js","../node_modules/dayjs/plugin/customParseFormat.js","../node_modules/dayjs/plugin/isBetween.js","../node_modules/dayjs/plugin/localeData.js","../node_modules/dayjs/plugin/weekOfYear.js","../node_modules/dayjs/plugin/weekYear.js","../node_modules/dayjs/plugin/weekday.js","../node_modules/detect-browser/es/index.js","../node_modules/dfa/src/StateMachine.js","../node_modules/events/events.js","../node_modules/fast-deep-equal/index.js","../node_modules/fmin/build/fmin.js","../node_modules/gl-matrix/esm/common.js","../node_modules/gl-matrix/esm/mat3.js","../node_modules/gl-matrix/esm/vec2.js","../node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js","../node_modules/hsl-to-hex/index.js","../node_modules/hsl-to-rgb-for-reals/converter.js","../node_modules/hyphen/hyphen.js","../node_modules/hyphen/index.js","../node_modules/hyphen/patterns/en-us.js","../node_modules/inherits/inherits_browser.js","../node_modules/is-url/index.js","../node_modules/isarray/index.js","../node_modules/json2mq/index.js","../node_modules/lodash/_DataView.js","../node_modules/lodash/_Hash.js","../node_modules/lodash/_ListCache.js","../node_modules/lodash/_Map.js","../node_modules/lodash/_MapCache.js","../node_modules/lodash/_Promise.js","../node_modules/lodash/_Set.js","../node_modules/lodash/_SetCache.js","../node_modules/lodash/_Stack.js","../node_modules/lodash/_Symbol.js","../node_modules/lodash/_Uint8Array.js","../node_modules/lodash/_WeakMap.js","../node_modules/lodash/_arrayFilter.js","../node_modules/lodash/_arrayLikeKeys.js","../node_modules/lodash/_arrayPush.js","../node_modules/lodash/_arraySome.js","../node_modules/lodash/_assocIndexOf.js","../node_modules/lodash/_baseGetAllKeys.js","../node_modules/lodash/_baseGetTag.js","../node_modules/lodash/_baseIsArguments.js","../node_modules/lodash/_baseIsEqual.js","../node_modules/lodash/_baseIsEqualDeep.js","../node_modules/lodash/_baseIsNative.js","../node_modules/lodash/_baseIsTypedArray.js","../node_modules/lodash/_baseKeys.js","../node_modules/lodash/_baseTimes.js","../node_modules/lodash/_baseUnary.js","../node_modules/lodash/_cacheHas.js","../node_modules/lodash/_coreJsData.js","../node_modules/lodash/_equalArrays.js","../node_modules/lodash/_equalByTag.js","../node_modules/lodash/_equalObjects.js","../node_modules/lodash/_freeGlobal.js","../node_modules/lodash/_getAllKeys.js","../node_modules/lodash/_getMapData.js","../node_modules/lodash/_getNative.js","../node_modules/lodash/_getRawTag.js","../node_modules/lodash/_getSymbols.js","../node_modules/lodash/_getTag.js","../node_modules/lodash/_getValue.js","../node_modules/lodash/_hashClear.js","../node_modules/lodash/_hashDelete.js","../node_modules/lodash/_hashGet.js","../node_modules/lodash/_hashHas.js","../node_modules/lodash/_hashSet.js","../node_modules/lodash/_isIndex.js","../node_modules/lodash/_isKeyable.js","../node_modules/lodash/_isMasked.js","../node_modules/lodash/_isPrototype.js","../node_modules/lodash/_listCacheClear.js","../node_modules/lodash/_listCacheDelete.js","../node_modules/lodash/_listCacheGet.js","../node_modules/lodash/_listCacheHas.js","../node_modules/lodash/_listCacheSet.js","../node_modules/lodash/_mapCacheClear.js","../node_modules/lodash/_mapCacheDelete.js","../node_modules/lodash/_mapCacheGet.js","../node_modules/lodash/_mapCacheHas.js","../node_modules/lodash/_mapCacheSet.js","../node_modules/lodash/_mapToArray.js","../node_modules/lodash/_nativeCreate.js","../node_modules/lodash/_nativeKeys.js","../node_modules/lodash/_nodeUtil.js","../node_modules/lodash/_objectToString.js","../node_modules/lodash/_overArg.js","../node_modules/lodash/_root.js","../node_modules/lodash/_setCacheAdd.js","../node_modules/lodash/_setCacheHas.js","../node_modules/lodash/_setToArray.js","../node_modules/lodash/_stackClear.js","../node_modules/lodash/_stackDelete.js","../node_modules/lodash/_stackGet.js","../node_modules/lodash/_stackHas.js","../node_modules/lodash/_stackSet.js","../node_modules/lodash/_toSource.js","../node_modules/lodash/eq.js","../node_modules/lodash/isArguments.js","../node_modules/lodash/isArray.js","../node_modules/lodash/isArrayLike.js","../node_modules/lodash/isBuffer.js","../node_modules/lodash/isEqual.js","../node_modules/lodash/isFunction.js","../node_modules/lodash/isLength.js","../node_modules/lodash/isObject.js","../node_modules/lodash/isObjectLike.js","../node_modules/lodash/isTypedArray.js","../node_modules/lodash/keys.js","../node_modules/lodash/stubArray.js","../node_modules/lodash/stubFalse.js","../node_modules/media-engine/src/index.js","../node_modules/media-engine/src/operators.js","../node_modules/media-engine/src/parser.js","../node_modules/media-engine/src/queries.js","../node_modules/moment/locale/pt-br.js","../node_modules/moment/moment.js","../node_modules/normalize-wheel/index.js","../node_modules/normalize-wheel/src/ExecutionEnvironment.js","../node_modules/normalize-wheel/src/UserAgent_DEPRECATED.js","../node_modules/normalize-wheel/src/isEventSupported.js","../node_modules/normalize-wheel/src/normalizeWheel.js","../node_modules/object-assign/index.js","../node_modules/pako/lib/utils/common.js","../node_modules/pako/lib/zlib/adler32.js","../node_modules/pako/lib/zlib/constants.js","../node_modules/pako/lib/zlib/crc32.js","../node_modules/pako/lib/zlib/deflate.js","../node_modules/pako/lib/zlib/inffast.js","../node_modules/pako/lib/zlib/inflate.js","../node_modules/pako/lib/zlib/inftrees.js","../node_modules/pako/lib/zlib/messages.js","../node_modules/pako/lib/zlib/trees.js","../node_modules/pako/lib/zlib/zstream.js","../node_modules/parse-svg-path/index.js","../node_modules/path-to-regexp/index.js","../node_modules/pdfast/src/helper.js","../node_modules/pdfast/src/index.js","../node_modules/postcss-value-parser/lib/parse.js","../node_modules/postcss-value-parser/lib/unit.js","../node_modules/prop-types/factoryWithThrowingShims.js","../node_modules/prop-types/index.js","../node_modules/prop-types/lib/ReactPropTypesSecret.js","../node_modules/queue/index.js","../node_modules/quill/dist/quill.js","../node_modules/rc-collapse/es/PanelContent.js","../node_modules/rc-collapse/es/Panel.js","../node_modules/rc-collapse/es/hooks/useItems.js","../node_modules/rc-collapse/es/Collapse.js","../node_modules/rc-collapse/es/index.js","../node_modules/rc-input/es/hooks/useCount.js","../node_modules/rc-input/es/BaseInput.js","../node_modules/rc-input/es/Input.js","../node_modules/rc-input/es/index.js","../node_modules/rc-input/es/utils/commonUtils.js","../node_modules/rc-input/lib/utils/commonUtils.js","../node_modules/rc-motion/es/context.js","../node_modules/rc-motion/es/DomWrapper.js","../node_modules/rc-motion/es/interface.js","../node_modules/rc-motion/es/util/motion.js","../node_modules/rc-motion/es/hooks/useDomMotionEvents.js","../node_modules/rc-motion/es/hooks/useIsomorphicLayoutEffect.js","../node_modules/rc-motion/es/hooks/useStepQueue.js","../node_modules/rc-motion/es/hooks/useNextFrame.js","../node_modules/rc-motion/es/hooks/useStatus.js","../node_modules/rc-util/es/hooks/useSyncState.js","../node_modules/rc-motion/es/CSSMotion.js","../node_modules/rc-motion/es/util/diff.js","../node_modules/rc-motion/es/CSSMotionList.js","../node_modules/rc-motion/es/index.js","../node_modules/rc-overflow/es/Item.js","../node_modules/rc-overflow/es/hooks/useEffectState.js","../node_modules/rc-overflow/es/hooks/channelUpdate.js","../node_modules/rc-overflow/es/context.js","../node_modules/rc-overflow/es/RawItem.js","../node_modules/rc-overflow/es/Overflow.js","../node_modules/rc-overflow/es/index.js","../node_modules/rc-pagination/lib/locale/en_US.js","../node_modules/rc-picker/lib/locale/common.js","../node_modules/rc-picker/lib/locale/en_US.js","../node_modules/rc-resize-observer/es/Collection.js","../node_modules/rc-resize-observer/es/utils/observerUtil.js","../node_modules/rc-resize-observer/es/SingleObserver/DomWrapper.js","../node_modules/rc-resize-observer/es/SingleObserver/index.js","../node_modules/rc-resize-observer/es/index.js","../node_modules/rc-select/es/TransBtn.js","../node_modules/rc-select/es/hooks/useBaseProps.js","../node_modules/rc-select/es/hooks/useLock.js","../node_modules/rc-select/es/Selector/Input.js","../node_modules/rc-select/es/utils/commonUtil.js","../node_modules/rc-select/es/Selector/MultipleSelector.js","../node_modules/rc-select/es/hooks/useLayoutEffect.js","../node_modules/rc-select/es/Selector/SingleSelector.js","../node_modules/rc-select/es/Selector/index.js","../node_modules/rc-select/es/utils/keyUtil.js","../node_modules/rc-select/es/SelectTrigger.js","../node_modules/rc-select/es/utils/valueUtil.js","../node_modules/rc-select/es/SelectContext.js","../node_modules/rc-select/es/BaseSelect/Polite.js","../node_modules/rc-select/es/BaseSelect/index.js","../node_modules/rc-select/es/hooks/useDelayReset.js","../node_modules/rc-select/es/hooks/useSelectTriggerControl.js","../node_modules/rc-select/es/hooks/useAllowClear.js","../node_modules/rc-select/es/OptGroup.js","../node_modules/rc-select/es/Option.js","../node_modules/rc-select/es/OptionList.js","../node_modules/rc-select/es/utils/platformUtil.js","../node_modules/rc-select/es/hooks/useFilterOptions.js","../node_modules/rc-select/es/hooks/useId.js","../node_modules/rc-select/es/utils/legacyUtil.js","../node_modules/rc-select/es/hooks/useOptions.js","../node_modules/rc-select/es/hooks/useRefFunc.js","../node_modules/rc-select/es/utils/warningPropsUtil.js","../node_modules/rc-select/es/Select.js","../node_modules/rc-select/es/hooks/useCache.js","../node_modules/rc-select/es/index.js","../node_modules/rc-textarea/es/calculateNodeHeight.js","../node_modules/rc-textarea/es/ResizableTextArea.js","../node_modules/rc-textarea/es/TextArea.js","../node_modules/rc-textarea/es/index.js","../node_modules/rc-tooltip/es/Popup.js","../node_modules/rc-tooltip/es/placements.js","../node_modules/rc-tooltip/es/Tooltip.js","../node_modules/rc-tooltip/es/index.js","../node_modules/rc-util/es/Children/toArray.js","../node_modules/rc-util/es/Dom/canUseDom.js","../node_modules/rc-util/es/Dom/contains.js","../node_modules/rc-util/es/Dom/dynamicCSS.js","../node_modules/rc-util/es/Dom/findDOMNode.js","../node_modules/rc-util/es/Dom/isVisible.js","../node_modules/rc-util/es/Dom/shadow.js","../node_modules/rc-util/es/KeyCode.js","../node_modules/rc-util/es/React/isFragment.js","../node_modules/rc-util/es/getScrollBarSize.js","../node_modules/rc-util/es/hooks/useEvent.js","../node_modules/rc-util/es/hooks/useId.js","../node_modules/rc-util/es/hooks/useLayoutEffect.js","../node_modules/rc-util/es/hooks/useMemo.js","../node_modules/rc-util/es/hooks/useMergedState.js","../node_modules/rc-util/es/hooks/useState.js","../node_modules/rc-util/es/isEqual.js","../node_modules/rc-util/es/isMobile.js","../node_modules/rc-util/es/omit.js","../node_modules/rc-util/es/pickAttrs.js","../node_modules/rc-util/es/raf.js","../node_modules/rc-util/es/ref.js","../node_modules/rc-util/es/utils/get.js","../node_modules/rc-util/es/utils/set.js","../node_modules/rc-util/es/warning.js","../node_modules/rc-util/lib/Children/toArray.js","../node_modules/rc-util/lib/Dom/canUseDom.js","../node_modules/rc-util/lib/Dom/contains.js","../node_modules/rc-util/lib/Dom/dynamicCSS.js","../node_modules/rc-util/lib/Dom/isVisible.js","../node_modules/rc-util/lib/Dom/shadow.js","../node_modules/rc-util/lib/KeyCode.js","../node_modules/rc-util/lib/React/isFragment.js","../node_modules/rc-util/lib/React/render.js","../node_modules/rc-util/lib/hooks/useEvent.js","../node_modules/rc-util/lib/hooks/useLayoutEffect.js","../node_modules/rc-util/lib/hooks/useMemo.js","../node_modules/rc-util/lib/hooks/useMergedState.js","../node_modules/rc-util/lib/hooks/useState.js","../node_modules/rc-util/lib/isEqual.js","../node_modules/rc-util/lib/omit.js","../node_modules/rc-util/lib/pickAttrs.js","../node_modules/rc-util/lib/raf.js","../node_modules/rc-util/lib/ref.js","../node_modules/rc-util/lib/utils/get.js","../node_modules/rc-util/lib/utils/set.js","../node_modules/rc-util/lib/warning.js","../node_modules/rc-util/node_modules/react-is/cjs/react-is.production.min.js","../node_modules/rc-util/node_modules/react-is/index.js","../node_modules/rc-virtual-list/es/Filler.js","../node_modules/rc-virtual-list/es/Item.js","../node_modules/rc-virtual-list/es/hooks/useDiffItem.js","../node_modules/rc-virtual-list/es/utils/algorithmUtil.js","../node_modules/rc-virtual-list/es/utils/isFirefox.js","../node_modules/rc-virtual-list/es/hooks/useOriginScroll.js","../node_modules/rc-virtual-list/es/hooks/useFrameWheel.js","../node_modules/rc-virtual-list/es/utils/CacheMap.js","../node_modules/rc-virtual-list/es/hooks/useHeights.js","../node_modules/rc-virtual-list/es/hooks/useMobileTouchMove.js","../node_modules/rc-virtual-list/es/hooks/useScrollDrag.js","../node_modules/rc-virtual-list/es/hooks/useScrollTo.js","../node_modules/rc-virtual-list/es/ScrollBar.js","../node_modules/rc-virtual-list/es/utils/scrollbarUtil.js","../node_modules/rc-virtual-list/es/List.js","../node_modules/rc-virtual-list/es/hooks/useGetSize.js","../node_modules/rc-virtual-list/es/hooks/useChildren.js","../node_modules/rc-virtual-list/es/index.js","../node_modules/react-dom/cjs/react-dom.production.min.js","../node_modules/react-dom/index.js","../node_modules/react-dom/node_modules/scheduler/cjs/scheduler.production.min.js","../node_modules/react-dom/node_modules/scheduler/index.js","../node_modules/react-draggable/build/cjs/Draggable.js","../node_modules/react-draggable/build/cjs/DraggableCore.js","../node_modules/react-draggable/build/cjs/cjs.js","../node_modules/react-draggable/build/cjs/utils/domFns.js","../node_modules/react-draggable/build/cjs/utils/getPrefix.js","../node_modules/react-draggable/build/cjs/utils/log.js","../node_modules/react-draggable/build/cjs/utils/positionFns.js","../node_modules/react-draggable/build/cjs/utils/shims.js","../node_modules/react-is/cjs/react-is.production.min.js","../node_modules/react-is/index.js","../node_modules/react-quill/src/index.tsx","../node_modules/react/cjs/react-jsx-runtime.production.min.js","../node_modules/react/cjs/react.production.min.js","../node_modules/react/index.js","../node_modules/react/jsx-runtime.js","../node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js","../node_modules/scheduler/cjs/scheduler.production.min.js","../node_modules/scheduler/index.js","../node_modules/simple-swizzle/index.js","../node_modules/simple-swizzle/node_modules/is-arrayish/index.js","../node_modules/size-sensor/lib/constant.js","../node_modules/size-sensor/lib/debounce.js","../node_modules/size-sensor/lib/id.js","../node_modules/size-sensor/lib/index.js","../node_modules/size-sensor/lib/sensorPool.js","../node_modules/size-sensor/lib/sensors/index.js","../node_modules/size-sensor/lib/sensors/object.js","../node_modules/size-sensor/lib/sensors/resizeObserver.js","../node_modules/string-convert/camel2hyphen.js","../node_modules/tiny-inflate/index.js","../node_modules/toggle-selection/index.js","../node_modules/unicode-trie/index.js","../node_modules/unicode-trie/swap.js","../node_modules/@babel/runtime/helpers/arrayLikeToArray.js","../node_modules/@babel/runtime/helpers/arrayWithHoles.js","../node_modules/@babel/runtime/helpers/arrayWithoutHoles.js","../node_modules/@babel/runtime/helpers/assertThisInitialized.js","../node_modules/@babel/runtime/helpers/asyncToGenerator.js","../node_modules/@babel/runtime/helpers/classCallCheck.js","../node_modules/@babel/runtime/helpers/createClass.js","../node_modules/@babel/runtime/helpers/createForOfIteratorHelper.js","../node_modules/@babel/runtime/helpers/createSuper.js","../node_modules/@babel/runtime/helpers/defineProperty.js","../node_modules/@babel/runtime/helpers/extends.js","../node_modules/@babel/runtime/helpers/getPrototypeOf.js","../node_modules/@babel/runtime/helpers/inherits.js","../node_modules/@babel/runtime/helpers/interopRequireDefault.js","../node_modules/@babel/runtime/helpers/interopRequireWildcard.js","../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js","../node_modules/@babel/runtime/helpers/iterableToArray.js","../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js","../node_modules/@babel/runtime/helpers/nonIterableRest.js","../node_modules/@babel/runtime/helpers/nonIterableSpread.js","../node_modules/@babel/runtime/helpers/objectSpread2.js","../node_modules/@babel/runtime/helpers/objectWithoutProperties.js","../node_modules/@babel/runtime/helpers/objectWithoutPropertiesLoose.js","../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js","../node_modules/@babel/runtime/helpers/regeneratorRuntime.js","../node_modules/@babel/runtime/helpers/setPrototypeOf.js","../node_modules/@babel/runtime/helpers/slicedToArray.js","../node_modules/@babel/runtime/helpers/toArray.js","../node_modules/@babel/runtime/helpers/toConsumableArray.js","../node_modules/@babel/runtime/helpers/toPrimitive.js","../node_modules/@babel/runtime/helpers/toPropertyKey.js","../node_modules/@babel/runtime/helpers/typeof.js","../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js","../node_modules/classnames/index.js","../node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js","../node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js","../node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js","../node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js","../node_modules/@babel/runtime/helpers/esm/classCallCheck.js","../node_modules/@babel/runtime/helpers/esm/createClass.js","../node_modules/@babel/runtime/helpers/esm/createSuper.js","../node_modules/@babel/runtime/helpers/esm/defineProperty.js","../node_modules/@babel/runtime/helpers/esm/extends.js","../node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js","../node_modules/@babel/runtime/helpers/esm/inherits.js","../node_modules/@babel/runtime/helpers/esm/isNativeReflectConstruct.js","../node_modules/@babel/runtime/helpers/esm/iterableToArray.js","../node_modules/@babel/runtime/helpers/esm/nonIterableRest.js","../node_modules/@babel/runtime/helpers/esm/objectSpread2.js","../node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js","../node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js","../node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js","../node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js","../node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js","../node_modules/@babel/runtime/helpers/esm/slicedToArray.js","../node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js","../node_modules/@babel/runtime/helpers/esm/toArray.js","../node_modules/@babel/runtime/helpers/esm/toConsumableArray.js","../node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js","../node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js","../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js","../node_modules/@babel/runtime/helpers/esm/toPrimitive.js","../node_modules/@babel/runtime/helpers/esm/typeof.js","../node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js","../node_modules/@babel/runtime/helpers/esm/wrapNativeSuper.js","../node_modules/@babel/runtime/helpers/esm/isNativeFunction.js","../node_modules/@babel/runtime/helpers/esm/construct.js","../node_modules/tslib/tslib.es6.mjs","../webpack/bootstrap","../webpack/runtime/compat get default export","../webpack/runtime/create fake namespace object","../webpack/runtime/define property getters","../webpack/runtime/global","../webpack/runtime/hasOwnProperty shorthand","../webpack/runtime/make namespace object","../webpack/runtime/node module decorator","../node_modules/@sentry/utils/src/version.ts","../node_modules/@sentry/utils/src/worldwide.ts","../node_modules/@sentry/core/src/constants.ts","../node_modules/@sentry/core/src/carrier.ts","../node_modules/@sentry/utils/src/is.ts","../node_modules/@babel/runtime/helpers/esm/createForOfIteratorHelper.js","../node_modules/@sentry/utils/src/browser.ts","../node_modules/@sentry/utils/src/debug-build.ts","../node_modules/@sentry/utils/src/logger.ts","../node_modules/@sentry/utils/src/string.ts","../node_modules/@sentry/utils/src/object.ts","../node_modules/@sentry/utils/src/misc.ts","../node_modules/@sentry/utils/src/propagationContext.ts","../node_modules/@sentry/utils/src/time.ts","../node_modules/@sentry/core/src/session.ts","../node_modules/@sentry/core/src/utils/spanOnScope.ts","../node_modules/@sentry/core/src/scope.ts","../node_modules/@sentry/core/src/asyncContext/stackStrategy.ts","../node_modules/@sentry/core/src/defaultScopes.ts","../node_modules/@sentry/core/src/asyncContext/index.ts","../node_modules/@sentry/core/src/currentScopes.ts","../node_modules/@sentry/utils/src/stacktrace.ts","../node_modules/@sentry/utils/src/syncpromise.ts","../node_modules/@sentry/utils/src/normalize.ts","../node_modules/@sentry/utils/src/memo.ts","../node_modules/@sentry/core/src/debug-build.ts","../node_modules/@sentry/core/src/eventProcessors.ts","../node_modules/@sentry/utils/src/baggage.ts","../node_modules/@sentry/core/src/semanticAttributes.ts","../node_modules/@sentry/utils/src/tracing.ts","../node_modules/@sentry/core/src/metrics/metric-summary.ts","../node_modules/@sentry/core/src/tracing/spanstatus.ts","../node_modules/@sentry/core/src/utils/spanUtils.ts","../node_modules/@sentry/core/src/tracing/dynamicSamplingContext.ts","../node_modules/@sentry/core/src/utils/applyScopeDataToEvent.ts","../node_modules/@sentry/core/src/utils/prepareEvent.ts","../node_modules/@sentry/core/src/exports.ts","../node_modules/@sentry/core/src/integration.ts","../node_modules/@sentry/core/src/integrations/inboundfilters.ts","../node_modules/@sentry/core/src/integrations/functiontostring.ts","../node_modules/@sentry/core/src/integrations/dedupe.ts","../node_modules/@sentry/core/src/sdk.ts","../node_modules/@sentry/utils/src/supports.ts","../node_modules/@sentry/utils/src/instrument/handlers.ts","../node_modules/@sentry/utils/src/vendor/supportsHistory.ts","../node_modules/@sentry-internal/browser-utils/src/types.ts","../node_modules/@sentry-internal/browser-utils/src/instrument/history.ts","../node_modules/@babel/runtime/helpers/esm/get.js","../node_modules/@babel/runtime/helpers/esm/superPropBase.js","../node_modules/@sentry/core/src/utils/sdkMetadata.ts","../node_modules/@sentry/utils/src/dsn.ts","../node_modules/@sentry/utils/src/envelope.ts","../node_modules/@sentry/utils/src/error.ts","../node_modules/@sentry/core/src/api.ts","../node_modules/@sentry/core/src/envelope.ts","../node_modules/@sentry/core/src/utils/parseSampleRate.ts","../node_modules/@sentry/core/src/baseclient.ts","../node_modules/@sentry/utils/src/clientreport.ts","../node_modules/@sentry/browser/src/debug-build.ts","../node_modules/@sentry/browser/src/eventbuilder.ts","../node_modules/@sentry/browser/src/helpers.ts","../node_modules/@sentry/browser/src/client.ts","../node_modules/@sentry-internal/browser-utils/src/instrument/dom.ts","../node_modules/@sentry/utils/src/env.ts","../node_modules/@sentry/browser/src/userfeedback.ts","../node_modules/@sentry-internal/browser-utils/src/instrument/xhr.ts","../node_modules/@sentry/core/src/breadcrumbs.ts","../node_modules/@sentry/utils/src/instrument/console.ts","../node_modules/@sentry/utils/src/instrument/fetch.ts","../node_modules/@sentry/utils/src/severity.ts","../node_modules/@sentry/utils/src/url.ts","../node_modules/@sentry/browser/src/integrations/breadcrumbs.ts","../node_modules/@sentry/browser/src/integrations/browserapierrors.ts","../node_modules/@sentry/utils/src/instrument/globalError.ts","../node_modules/@sentry/utils/src/instrument/globalUnhandledRejection.ts","../node_modules/@sentry/browser/src/integrations/globalhandlers.ts","../node_modules/@sentry/browser/src/integrations/httpcontext.ts","../node_modules/@sentry/utils/src/aggregate-errors.ts","../node_modules/@sentry/browser/src/integrations/linkederrors.ts","../node_modules/@sentry/browser/src/stack-parsers.ts","../node_modules/@sentry-internal/browser-utils/src/debug-build.ts","../node_modules/@sentry-internal/browser-utils/src/getNativeImplementation.ts","../node_modules/@sentry/utils/src/promisebuffer.ts","../node_modules/@sentry/utils/src/ratelimit.ts","../node_modules/@sentry/core/src/transports/base.ts","../node_modules/@sentry/browser/src/transports/fetch.ts","../node_modules/@sentry/browser/src/sdk.ts","../node_modules/@sentry/core/src/utils/hasTracingEnabled.ts","../node_modules/@sentry/core/src/tracing/sentryNonRecordingSpan.ts","../node_modules/@sentry/core/src/tracing/measurement.ts","../node_modules/@sentry/core/src/tracing/utils.ts","../node_modules/@sentry/core/src/tracing/sentrySpan.ts","../node_modules/@sentry/core/src/tracing/logSpans.ts","../node_modules/@sentry/core/src/tracing/trace.ts","../node_modules/@sentry/core/src/tracing/sampling.ts","../node_modules/@sentry/utils/src/buildPolyfills/_optionalChain.ts","../node_modules/@sentry-internal/browser-utils/src/metrics/web-vitals/lib/bindReporter.ts","../node_modules/@sentry-internal/browser-utils/src/metrics/web-vitals/lib/polyfills/interactionCountPolyfill.ts","../node_modules/@sentry-internal/browser-utils/src/metrics/instrument.ts","../node_modules/@sentry-internal/browser-utils/src/metrics/web-vitals/lib/getNavigationEntry.ts","../node_modules/@sentry-internal/browser-utils/src/metrics/web-vitals/lib/getActivationStart.ts","../node_modules/@sentry-internal/browser-utils/src/metrics/web-vitals/lib/initMetric.ts","../node_modules/@sentry-internal/browser-utils/src/metrics/web-vitals/lib/generateUniqueID.ts","../node_modules/@sentry-internal/browser-utils/src/metrics/web-vitals/lib/observe.ts","../node_modules/@sentry-internal/browser-utils/src/metrics/web-vitals/lib/onHidden.ts","../node_modules/@sentry-internal/browser-utils/src/metrics/web-vitals/lib/runOnce.ts","../node_modules/@sentry-internal/browser-utils/src/metrics/web-vitals/lib/getVisibilityWatcher.ts","../node_modules/@sentry-internal/browser-utils/src/metrics/web-vitals/lib/whenActivated.ts","../node_modules/@sentry-internal/browser-utils/src/metrics/web-vitals/onFCP.ts","../node_modules/@sentry-internal/browser-utils/src/metrics/web-vitals/getCLS.ts","../node_modules/@sentry-internal/browser-utils/src/metrics/web-vitals/getFID.ts","../node_modules/@sentry-internal/browser-utils/src/metrics/web-vitals/getINP.ts","../node_modules/@sentry-internal/browser-utils/src/metrics/web-vitals/getLCP.ts","../node_modules/@sentry-internal/browser-utils/src/metrics/web-vitals/onTTFB.ts","../node_modules/@babel/runtime/helpers/esm/objectDestructuringEmpty.js","../node_modules/@sentry-internal/browser-utils/src/metrics/utils.ts","../node_modules/@sentry-internal/browser-utils/src/metrics/cls.ts","../node_modules/@sentry-internal/browser-utils/src/metrics/browserMetrics.ts","../node_modules/@sentry-internal/browser-utils/src/metrics/inp.ts","../node_modules/@sentry/core/src/tracing/idleSpan.ts","../node_modules/@sentry/core/src/tracing/errors.ts","../node_modules/@sentry/core/src/fetch.ts","../node_modules/@sentry/browser/src/tracing/request.ts","../node_modules/@sentry/browser/src/tracing/browserTracingIntegration.ts","../node_modules/@sentry/core/src/utils/isSentryRequestUrl.ts","../node_modules/@sentry/utils/src/node.ts","../node_modules/@sentry/utils/src/isBrowser.ts","../node_modules/@sentry-internal/replay/src/constants.ts","../node_modules/node_modules/@sentry-internal/rrweb/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js","../node_modules/node_modules/@sentry-internal/rrweb/es/rrweb/packages/rrweb/src/utils.js","../node_modules/@sentry/utils/src/buildPolyfills/_nullishCoalesce.ts","../node_modules/node_modules/@sentry-internal/rrweb/es/rrweb/packages/types/dist/rrweb-types.js","../node_modules/node_modules/@sentry-internal/rrweb/es/rrweb/packages/rrweb/src/record/mutation.js","../node_modules/node_modules/@sentry-internal/rrweb/es/rrweb/packages/rrweb/src/record/error-handler.js","../node_modules/node_modules/@sentry-internal/rrweb/es/rrweb/packages/rrweb/src/record/observer.js","../node_modules/node_modules/@sentry-internal/rrweb/es/rrweb/packages/rrweb/src/record/cross-origin-iframe-mirror.js","../node_modules/node_modules/@sentry-internal/rrweb/es/rrweb/packages/rrweb/src/record/iframe-manager.js","../node_modules/node_modules/@sentry-internal/rrweb/es/rrweb/packages/rrweb/src/record/index.js","../node_modules/node_modules/@sentry-internal/rrweb/es/rrweb/packages/rrweb/src/record/shadow-dom-manager.js","../node_modules/node_modules/@sentry-internal/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js","../node_modules/node_modules/@sentry-internal/rrweb/es/rrweb/packages/rrweb/src/record/stylesheet-manager.js","../node_modules/node_modules/@sentry-internal/rrweb/es/rrweb/packages/rrweb/src/record/processed-node-manager.js","../node_modules/@sentry-internal/replay/src/debug-build.ts","../node_modules/@sentry-internal/replay/src/util/logger.ts","../node_modules/@sentry-internal/replay/src/types/rrweb.ts","../node_modules/@sentry-internal/replay/src/util/timestamp.ts","../node_modules/@sentry-internal/replay/src/coreHandlers/util/addBreadcrumbEvent.ts","../node_modules/@sentry-internal/replay/src/coreHandlers/util/domUtils.ts","../node_modules/@sentry-internal/replay/src/coreHandlers/util/onWindowOpen.ts","../node_modules/@sentry-internal/replay/src/coreHandlers/handleClick.ts","../node_modules/node_modules/@sentry-internal/rrweb-snapshot/es/rrweb-snapshot.js","../node_modules/@sentry-internal/replay/src/util/createBreadcrumb.ts","../node_modules/@sentry-internal/replay/src/coreHandlers/util/getAttributesToRecord.ts","../node_modules/@sentry-internal/replay/src/coreHandlers/handleDom.ts","../node_modules/@sentry-internal/replay/src/coreHandlers/handleKeyboardEvent.ts","../node_modules/@sentry-internal/replay/src/util/createPerformanceEntries.ts","../node_modules/@sentry-internal/replay-worker/build/esm/worker.ts","../node_modules/@sentry-internal/replay/src/eventBuffer/error.ts","../node_modules/@sentry-internal/replay/src/eventBuffer/EventBufferArray.ts","../node_modules/@sentry-internal/replay/src/eventBuffer/WorkerHandler.ts","../node_modules/@sentry-internal/replay/src/eventBuffer/EventBufferCompressionWorker.ts","../node_modules/@sentry-internal/replay/src/eventBuffer/EventBufferProxy.ts","../node_modules/@sentry-internal/replay/src/eventBuffer/index.ts","../node_modules/@sentry-internal/replay-worker/build/esm/index.js","../node_modules/@sentry-internal/replay/src/util/hasSessionStorage.ts","../node_modules/@sentry-internal/replay/src/session/clearSession.ts","../node_modules/@sentry-internal/replay/src/util/isSampled.ts","../node_modules/@sentry-internal/replay/src/session/Session.ts","../node_modules/@sentry-internal/replay/src/session/saveSession.ts","../node_modules/@sentry-internal/replay/src/session/createSession.ts","../node_modules/@sentry-internal/replay/src/util/isExpired.ts","../node_modules/@sentry-internal/replay/src/util/isSessionExpired.ts","../node_modules/@sentry-internal/replay/src/session/shouldRefreshSession.ts","../node_modules/@sentry-internal/replay/src/session/loadOrCreateSession.ts","../node_modules/@sentry-internal/replay/src/session/fetchSession.ts","../node_modules/@sentry-internal/replay/src/util/addEvent.ts","../node_modules/@sentry-internal/replay/src/util/eventUtils.ts","../node_modules/@sentry-internal/replay/src/coreHandlers/handleAfterSendEvent.ts","../node_modules/@sentry-internal/replay/src/coreHandlers/handleBeforeSendEvent.ts","../node_modules/@sentry-internal/replay/src/coreHandlers/handleBreadcrumbs.ts","../node_modules/@sentry-internal/replay/src/coreHandlers/handleGlobalEvent.ts","../node_modules/@sentry-internal/replay/src/coreHandlers/util/addFeedbackBreadcrumb.ts","../node_modules/@sentry-internal/replay/src/util/isRrwebError.ts","../node_modules/@sentry-internal/replay/src/coreHandlers/util/shouldSampleForBufferEvent.ts","../node_modules/@sentry-internal/replay/src/util/createPerformanceSpans.ts","../node_modules/@sentry-internal/replay/src/coreHandlers/handleHistory.ts","../node_modules/@sentry-internal/replay/src/coreHandlers/util/addNetworkBreadcrumb.ts","../node_modules/@sentry-internal/replay/src/util/shouldFilterRequest.ts","../node_modules/@sentry-internal/replay/src/coreHandlers/util/networkUtils.ts","../node_modules/@sentry-internal/replay/src/coreHandlers/util/fetchUtils.ts","../node_modules/@sentry-internal/replay/src/coreHandlers/util/xhrUtils.ts","../node_modules/@sentry-internal/replay/src/coreHandlers/handleNetworkBreadcrumbs.ts","../node_modules/@sentry-internal/replay/src/util/addGlobalListeners.ts","../node_modules/@sentry-internal/replay/src/util/addMemoryEntry.ts","../node_modules/@sentry-internal/replay/src/util/handleRecordingEmit.ts","../node_modules/@sentry-internal/replay/src/util/createReplayEnvelope.ts","../node_modules/@sentry-internal/replay/src/util/prepareRecordingData.ts","../node_modules/@sentry-internal/replay/src/util/prepareReplayEvent.ts","../node_modules/@sentry-internal/replay/src/util/sendReplayRequest.ts","../node_modules/@sentry-internal/replay/src/util/sendReplay.ts","../node_modules/@sentry-internal/replay/src/util/throttle.ts","../node_modules/@sentry-internal/replay/src/replay.ts","../node_modules/@sentry-internal/replay/src/util/debounce.ts","../node_modules/@sentry-internal/replay/src/coreHandlers/performanceObserver.ts","../node_modules/@sentry-internal/replay/src/util/getPrivacyOptions.ts","../node_modules/@sentry-internal/replay/src/integration.ts","../node_modules/@sentry-internal/replay/src/util/maskAttribute.ts","../node_modules/antd/es/app/context.js","../node_modules/antd/es/config-provider/context.js","../node_modules/antd/node_modules/@ant-design/icons/es/components/Context.js","../node_modules/antd/es/_util/warning.js","../node_modules/antd/es/form/validateMessagesContext.js","../node_modules/rc-pagination/es/locale/en_US.js","../node_modules/rc-picker/es/locale/common.js","../node_modules/rc-picker/es/locale/en_US.js","../node_modules/antd/es/time-picker/locale/en_US.js","../node_modules/antd/es/date-picker/locale/en_US.js","../node_modules/antd/es/calendar/locale/en_US.js","../node_modules/antd/es/locale/en_US.js","../node_modules/antd/es/modal/locale.js","../node_modules/antd/es/locale/context.js","../node_modules/antd/es/locale/index.js","../node_modules/antd/es/theme/themes/seed.js","../node_modules/antd/es/theme/themes/shared/genRadius.js","../node_modules/antd/es/theme/themes/shared/genControlHeight.js","../node_modules/antd/es/theme/themes/shared/genFontSizes.js","../node_modules/antd/es/theme/themes/shared/genFontMapToken.js","../node_modules/antd/es/theme/themes/default/colorAlgorithm.js","../node_modules/antd/es/theme/themes/default/colors.js","../node_modules/antd/es/theme/themes/default/theme.js","../node_modules/antd/es/theme/themes/default/index.js","../node_modules/antd/es/theme/themes/shared/genColorMapToken.js","../node_modules/antd/es/theme/themes/shared/genSizeMapToken.js","../node_modules/antd/es/theme/themes/shared/genCommonMapToken.js","../node_modules/antd/es/theme/context.js","../node_modules/antd/es/config-provider/cssVariables.js","../node_modules/antd/es/config-provider/DisabledContext.js","../node_modules/antd/es/config-provider/SizeContext.js","../node_modules/antd/es/config-provider/hooks/useConfig.js","../node_modules/antd/es/config-provider/hooks/useThemeKey.js","../node_modules/antd/es/version/index.js","../node_modules/antd/es/version/version.js","../node_modules/antd/es/theme/util/getAlphaColor.js","../node_modules/antd/es/theme/util/alias.js","../node_modules/antd/es/theme/useToken.js","../node_modules/antd/es/config-provider/MotionWrapper.js","../node_modules/antd/es/config-provider/PropWarning.js","../node_modules/antd/es/config-provider/index.js","../node_modules/antd/es/style/index.js","../node_modules/antd/es/theme/util/useResetIconStyle.js","../node_modules/antd/es/config-provider/hooks/useTheme.js","../node_modules/rc-util/es/React/render.js","../node_modules/antd/es/config-provider/UnstableContext.js","../node_modules/@ant-design/icons-svg/es/asn/CheckCircleFilled.js","../node_modules/antd/node_modules/@ant-design/icons/es/utils.js","../node_modules/antd/node_modules/@ant-design/icons/es/components/IconBase.js","../node_modules/antd/node_modules/@ant-design/icons/es/components/twoTonePrimaryColor.js","../node_modules/antd/node_modules/@ant-design/icons/es/components/AntdIcon.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/CheckCircleFilled.js","../node_modules/@ant-design/icons-svg/es/asn/CloseCircleFilled.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/CloseCircleFilled.js","../node_modules/@ant-design/icons-svg/es/asn/ExclamationCircleFilled.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/ExclamationCircleFilled.js","../node_modules/@ant-design/icons-svg/es/asn/InfoCircleFilled.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/InfoCircleFilled.js","../node_modules/@ant-design/icons-svg/es/asn/LoadingOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/LoadingOutlined.js","../node_modules/rc-notification/es/Notice.js","../node_modules/rc-notification/es/NotificationProvider.js","../node_modules/rc-notification/es/hooks/useStack.js","../node_modules/rc-notification/es/NoticeList.js","../node_modules/rc-notification/es/Notifications.js","../node_modules/rc-notification/es/hooks/useNotification.js","../node_modules/antd/es/config-provider/hooks/useCSSVarCls.js","../node_modules/antd/es/_util/zindexContext.js","../node_modules/antd/es/_util/hooks/useZIndex.js","../node_modules/antd/es/theme/util/genStyleUtils.js","../node_modules/antd/es/message/style/index.js","../node_modules/antd/es/message/PurePanel.js","../node_modules/@ant-design/icons-svg/es/asn/CloseOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/CloseOutlined.js","../node_modules/antd/es/message/util.js","../node_modules/antd/es/message/useMessage.js","../node_modules/antd/es/message/index.js","config.ts","lib/Request.ts","lib/BackendRequest.ts","lib/API.ts","services/UserService.ts","lib/helpers/Authorization.helper.ts","lib/Authentication.ts","../node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","../node_modules/resolve-pathname/esm/resolve-pathname.js","../node_modules/value-equal/esm/value-equal.js","../node_modules/tiny-invariant/dist/esm/tiny-invariant.js","../node_modules/history/esm/history.js","../node_modules/react-router/modules/miniCreateReactContext.js","../node_modules/react-router/modules/createContext.js","../node_modules/react-router/modules/createNamedContext.js","../node_modules/react-router/modules/HistoryContext.js","../node_modules/react-router/modules/RouterContext.js","../node_modules/react-router/modules/Router.js","../node_modules/react-router/modules/MemoryRouter.js","../node_modules/react-router/modules/Lifecycle.js","../node_modules/react-router/modules/generatePath.js","../node_modules/react-router/modules/Redirect.js","../node_modules/react-router/modules/matchPath.js","../node_modules/react-router/modules/Route.js","../node_modules/react-router/modules/StaticRouter.js","../node_modules/react-router/modules/Switch.js","../node_modules/react-router/modules/hooks.js","../node_modules/react-router-dom/modules/BrowserRouter.js","../node_modules/react-router-dom/modules/HashRouter.js","../node_modules/react-router-dom/modules/utils/locationUtils.js","../node_modules/react-router-dom/modules/Link.js","../node_modules/react-router-dom/modules/NavLink.js","../node_modules/antd/es/_util/motion.js","../node_modules/antd/es/locale/useLocale.js","../node_modules/antd/es/_util/reactNode.js","../node_modules/antd/es/_util/wave/style.js","../node_modules/antd/es/_util/wave/interface.js","../node_modules/antd/es/_util/wave/util.js","../node_modules/antd/es/_util/wave/WaveEffect.js","../node_modules/antd/es/_util/wave/useWave.js","../node_modules/antd/es/_util/wave/index.js","../node_modules/antd/es/config-provider/hooks/useSize.js","../node_modules/antd/es/space/style/compact.js","../node_modules/antd/es/space/style/index.js","../node_modules/antd/es/space/Compact.js","../node_modules/antd/es/button/button-group.js","../node_modules/antd/es/theme/interface/presetColors.js","../node_modules/antd/es/button/buttonHelpers.js","../node_modules/antd/es/button/IconWrapper.js","../node_modules/antd/es/button/DefaultLoadingIcon.js","../node_modules/antd/es/button/style/group.js","../node_modules/antd/es/color-picker/color.js","../node_modules/@ant-design/icons-svg/es/asn/RightOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/RightOutlined.js","../node_modules/antd/es/collapse/CollapsePanel.js","../node_modules/antd/es/style/motion/collapse.js","../node_modules/antd/es/collapse/style/index.js","../node_modules/antd/es/collapse/Collapse.js","../node_modules/antd/es/collapse/index.js","../node_modules/antd/es/color-picker/util.js","../node_modules/antd/es/color-picker/components/ColorPresets.js","../node_modules/antd/es/button/style/token.js","../node_modules/antd/es/button/style/index.js","../node_modules/antd/es/style/compact-item.js","../node_modules/antd/es/style/compact-item-vertical.js","../node_modules/antd/es/button/style/compact.js","../node_modules/antd/es/button/button.js","../node_modules/antd/es/button/index.js","../node_modules/antd/es/_util/ActionButton.js","../node_modules/antd/es/modal/context.js","../node_modules/antd/es/modal/components/ConfirmCancelBtn.js","../node_modules/antd/es/modal/components/ConfirmOkBtn.js","../node_modules/rc-dialog/es/context.js","../node_modules/rc-dialog/es/util.js","../node_modules/rc-dialog/es/Dialog/Content/MemoChildren.js","../node_modules/rc-dialog/es/Dialog/Content/Panel.js","../node_modules/rc-dialog/es/Dialog/Content/index.js","../node_modules/rc-dialog/es/Dialog/Mask.js","../node_modules/rc-dialog/es/Dialog/index.js","../node_modules/rc-dialog/es/DialogWrap.js","../node_modules/rc-dialog/es/index.js","../node_modules/antd/es/form/context.js","../node_modules/antd/es/_util/ContextIsolator.js","../node_modules/antd/es/_util/hooks/useClosable.js","../node_modules/antd/es/_util/styleChecker.js","../node_modules/antd/es/skeleton/Element.js","../node_modules/antd/es/skeleton/style/index.js","../node_modules/antd/es/skeleton/Avatar.js","../node_modules/antd/es/skeleton/Button.js","../node_modules/antd/es/skeleton/Image.js","../node_modules/antd/es/skeleton/Input.js","../node_modules/antd/es/skeleton/Node.js","../node_modules/antd/es/skeleton/Paragraph.js","../node_modules/antd/es/skeleton/Title.js","../node_modules/antd/es/skeleton/Skeleton.js","../node_modules/antd/es/skeleton/index.js","../node_modules/antd/es/watermark/context.js","../node_modules/antd/es/modal/components/NormalCancelBtn.js","../node_modules/antd/es/modal/components/NormalOkBtn.js","../node_modules/antd/es/modal/shared.js","../node_modules/antd/es/grid/style/index.js","../node_modules/antd/es/style/motion/motion.js","../node_modules/antd/es/style/motion/fade.js","../node_modules/antd/es/style/motion/zoom.js","../node_modules/antd/es/modal/style/index.js","../node_modules/antd/es/modal/Modal.js","../node_modules/antd/es/modal/style/confirm.js","../node_modules/antd/es/modal/ConfirmDialog.js","../node_modules/antd/es/modal/destroyFns.js","../node_modules/antd/es/modal/confirm.js","../node_modules/antd/es/modal/useModal/HookModal.js","../node_modules/antd/es/modal/useModal/index.js","../node_modules/antd/es/_util/hooks/usePatchElement.js","../node_modules/antd/es/notification/style/placement.js","../node_modules/antd/es/notification/interface.js","../node_modules/antd/es/notification/style/stack.js","../node_modules/antd/es/notification/style/index.js","../node_modules/antd/es/notification/style/pure-panel.js","../node_modules/antd/es/notification/PurePanel.js","../node_modules/antd/es/notification/useNotification.js","../node_modules/antd/es/notification/util.js","../node_modules/antd/es/app/style/index.js","../node_modules/antd/es/app/App.js","../node_modules/antd/es/app/useApp.js","../node_modules/antd/es/app/index.js","../node_modules/rc-pagination/es/locale/pt_BR.js","../node_modules/rc-picker/es/locale/pt_BR.js","../node_modules/antd/es/time-picker/locale/pt_BR.js","../node_modules/antd/es/date-picker/locale/pt_BR.js","../node_modules/antd/es/locale/pt_BR.js","../node_modules/@ant-design/icons-svg/es/asn/WarningFilled.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/WarningFilled.js","../node_modules/antd/es/result/noFound.js","../node_modules/antd/es/result/serverError.js","../node_modules/antd/es/result/style/index.js","../node_modules/antd/es/result/index.js","../node_modules/antd/es/result/unauthorized.js","../node_modules/antd/es/alert/style/index.js","../node_modules/antd/es/alert/Alert.js","../node_modules/antd/es/alert/ErrorBoundary.js","../node_modules/@babel/runtime/helpers/esm/callSuper.js","../node_modules/antd/es/alert/index.js","components/_Common/_Routes/Routes.ts","components/_Common/InternalServerError.tsx","lib/AuthenticationErrorBoundary.tsx","lib/helpers/WhiteLabel.helper.ts","../node_modules/antd/es/_util/responsiveObserver.js","../node_modules/antd/es/_util/hooks/useForceUpdate.js","../node_modules/antd/es/grid/hooks/useBreakpoint.js","../node_modules/antd/es/grid/RowContext.js","../node_modules/antd/es/grid/row.js","../node_modules/antd/es/grid/hooks/useGutter.js","../node_modules/antd/es/row/index.js","../node_modules/antd/es/grid/col.js","../node_modules/antd/es/col/index.js","../node_modules/@ant-design/icons-svg/es/asn/EditOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/EditOutlined.js","../node_modules/rc-util/es/Dom/styleChecker.js","../node_modules/antd/es/style/roundedArrow.js","../node_modules/antd/es/style/placementArrow.js","../node_modules/antd/es/_util/placements.js","../node_modules/antd/es/theme/util/genPresetColor.js","../node_modules/antd/es/tooltip/style/index.js","../node_modules/antd/es/_util/colors.js","../node_modules/antd/es/tooltip/util.js","../node_modules/antd/es/tooltip/PurePanel.js","../node_modules/antd/es/tooltip/index.js","../node_modules/@ant-design/icons-svg/es/asn/EnterOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/EnterOutlined.js","../node_modules/antd/es/_util/getAllowClear.js","../node_modules/antd/es/_util/statusUtils.js","../node_modules/antd/es/form/hooks/useVariants.js","../node_modules/antd/es/input/style/token.js","../node_modules/antd/es/input/style/variants.js","../node_modules/antd/es/input/style/index.js","../node_modules/antd/es/input/style/textarea.js","../node_modules/antd/es/input/TextArea.js","../node_modules/antd/es/typography/style/index.js","../node_modules/antd/es/typography/style/mixins.js","../node_modules/antd/es/typography/Editable.js","../node_modules/antd/es/_util/toList.js","../node_modules/antd/es/typography/hooks/useCopyClick.js","../node_modules/antd/es/typography/hooks/useMergedConfig.js","../node_modules/antd/es/typography/hooks/usePrevious.js","../node_modules/antd/es/typography/hooks/useTooltipProps.js","../node_modules/antd/es/typography/Typography.js","../node_modules/@ant-design/icons-svg/es/asn/CheckOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/CheckOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/CopyOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/CopyOutlined.js","../node_modules/antd/es/typography/Base/util.js","../node_modules/antd/es/typography/Base/CopyBtn.js","../node_modules/antd/es/typography/Base/Ellipsis.js","../node_modules/antd/es/typography/Base/EllipsisTooltip.js","../node_modules/antd/es/typography/Base/index.js","../node_modules/antd/es/typography/Link.js","../node_modules/antd/es/typography/Paragraph.js","../node_modules/antd/es/typography/Text.js","../node_modules/antd/es/typography/Title.js","../node_modules/antd/es/typography/index.js","../node_modules/antd/es/form/hooks/useDebounce.js","../node_modules/antd/es/form/style/explain.js","../node_modules/antd/es/form/style/index.js","../node_modules/antd/es/form/ErrorList.js","../node_modules/compute-scroll-into-view/src/index.ts","../node_modules/scroll-into-view-if-needed/src/index.ts","../node_modules/antd/es/form/util.js","../node_modules/antd/es/form/hooks/useForm.js","../node_modules/antd/es/form/Form.js","../node_modules/antd/es/form/hooks/useFormItemStatus.js","../node_modules/antd/es/form/style/fallbackCmp.js","../node_modules/antd/es/form/FormItemInput.js","../node_modules/@ant-design/icons-svg/es/asn/QuestionCircleOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/QuestionCircleOutlined.js","../node_modules/antd/es/form/FormItemLabel.js","../node_modules/antd/es/form/FormItem/StatusProvider.js","../node_modules/antd/es/form/FormItem/ItemHolder.js","../node_modules/antd/es/form/FormItem/index.js","../node_modules/antd/es/form/hooks/useChildren.js","../node_modules/antd/es/form/hooks/useFrameState.js","../node_modules/antd/es/form/hooks/useItemRef.js","../node_modules/antd/es/form/FormList.js","../node_modules/antd/es/form/index.js","../node_modules/antd/es/form/hooks/useFormInstance.js","../node_modules/antd/es/_util/PurePanel.js","../node_modules/antd/es/modal/PurePanel.js","../node_modules/antd/es/modal/index.js","../node_modules/antd/es/divider/style/index.js","../node_modules/antd/es/divider/index.js","../node_modules/antd/es/input/Group.js","../node_modules/antd/es/input/hooks/useRemovePasswordTimeout.js","../node_modules/antd/es/input/Input.js","../node_modules/antd/es/input/utils.js","../node_modules/antd/es/input/style/otp.js","../node_modules/antd/es/input/OTP/OTPInput.js","../node_modules/antd/es/input/OTP/index.js","../node_modules/@ant-design/icons-svg/es/asn/EyeInvisibleOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/EyeInvisibleOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/EyeOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/EyeOutlined.js","../node_modules/antd/es/input/Password.js","../node_modules/@ant-design/icons-svg/es/asn/SearchOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/SearchOutlined.js","../node_modules/antd/es/input/Search.js","../node_modules/antd/es/input/index.js","../node_modules/antd/es/empty/empty.js","../node_modules/antd/es/empty/simple.js","../node_modules/antd/es/empty/style/index.js","../node_modules/antd/es/empty/index.js","../node_modules/antd/es/config-provider/defaultRenderEmpty.js","../node_modules/antd/es/select/mergedBuiltinPlacements.js","../node_modules/antd/es/style/motion/slide.js","../node_modules/antd/es/style/motion/move.js","../node_modules/antd/es/select/style/dropdown.js","../node_modules/antd/es/select/style/multiple.js","../node_modules/antd/es/select/style/single.js","../node_modules/antd/es/select/style/token.js","../node_modules/antd/es/select/style/variants.js","../node_modules/antd/es/select/style/index.js","../node_modules/@ant-design/icons-svg/es/asn/DownOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/DownOutlined.js","../node_modules/antd/es/select/useIcons.js","../node_modules/antd/es/select/index.js","../node_modules/antd/es/select/useShowArrow.js","../node_modules/antd/es/radio/context.js","../node_modules/rc-checkbox/es/index.js","../node_modules/antd/es/checkbox/useBubbleLock.js","../node_modules/antd/es/radio/style/index.js","../node_modules/antd/es/radio/radio.js","../node_modules/antd/es/radio/group.js","../node_modules/antd/es/radio/radioButton.js","../node_modules/antd/es/radio/index.js","../node_modules/imask/esm/_rollupPluginBabelHelpers-b054ecd2.js","../node_modules/imask/esm/core/change-details.js","../node_modules/imask/esm/core/utils.js","../node_modules/imask/esm/core/action-details.js","../node_modules/imask/esm/core/continuous-tail-details.js","../node_modules/imask/esm/core/holder.js","../node_modules/imask/esm/masked/base.js","../node_modules/imask/esm/masked/factory.js","../node_modules/imask/esm/masked/pattern/input-definition.js","../node_modules/imask/esm/masked/pattern/fixed-definition.js","../node_modules/imask/esm/masked/pattern/chunk-tail-details.js","../node_modules/imask/esm/masked/pattern/cursor.js","../node_modules/imask/esm/masked/regexp.js","../node_modules/imask/esm/masked/pattern.js","../node_modules/imask/esm/masked/range.js","../node_modules/imask/esm/masked/date.js","../node_modules/imask/esm/controls/mask-element.js","../node_modules/imask/esm/controls/html-mask-element.js","../node_modules/imask/esm/controls/html-contenteditable-mask-element.js","../node_modules/imask/esm/controls/input.js","../node_modules/imask/esm/masked/enum.js","../node_modules/imask/esm/masked/number.js","../node_modules/imask/esm/masked/function.js","../node_modules/imask/esm/masked/dynamic.js","../node_modules/imask/esm/masked/pipe.js","../node_modules/imask/esm/index.js","../node_modules/antd-mask-input/build/module/lib/MaskedInput.js","lib/helpers/Form.helper.ts","lib/helpers/Text.helper.ts","lib/helpers/ServiceHelper.ts","services/Account.service.ts","lib/providers/AccountContextProvider.tsx","lib/Show.tsx","lib/Sleep.ts","../node_modules/antd/es/_util/gapSize.js","../node_modules/antd/es/space/context.js","../node_modules/antd/es/space/Item.js","../node_modules/antd/es/space/index.js","../node_modules/antd/es/notification/index.js","../node_modules/rc-upload/es/attr-accept.js","../node_modules/rc-upload/es/request.js","../node_modules/rc-upload/es/traverseFileTree.js","../node_modules/rc-upload/es/uid.js","../node_modules/rc-upload/es/AjaxUploader.js","../node_modules/rc-upload/es/Upload.js","../node_modules/rc-upload/es/index.js","../node_modules/antd/es/upload/style/dragger.js","../node_modules/antd/es/upload/style/list.js","../node_modules/antd/es/upload/style/motion.js","../node_modules/antd/es/upload/style/picture.js","../node_modules/antd/es/upload/style/rtl.js","../node_modules/antd/es/upload/style/index.js","../node_modules/@ant-design/icons-svg/es/asn/FileTwoTone.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/FileTwoTone.js","../node_modules/@ant-design/icons-svg/es/asn/PaperClipOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/PaperClipOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/PictureTwoTone.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/PictureTwoTone.js","../node_modules/antd/es/upload/utils.js","../node_modules/@ant-design/icons-svg/es/asn/DeleteOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/DeleteOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/DownloadOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/DownloadOutlined.js","../node_modules/rc-progress/es/common.js","../node_modules/rc-progress/es/Line.js","../node_modules/rc-progress/es/hooks/useId.js","../node_modules/rc-progress/es/Circle/PtgCircle.js","../node_modules/rc-progress/es/Circle/util.js","../node_modules/rc-progress/es/Circle/index.js","../node_modules/antd/es/progress/utils.js","../node_modules/antd/es/progress/Circle.js","../node_modules/antd/es/progress/style/index.js","../node_modules/antd/es/progress/Line.js","../node_modules/antd/es/progress/Steps.js","../node_modules/antd/es/progress/progress.js","../node_modules/antd/es/progress/index.js","../node_modules/antd/es/upload/UploadList/ListItem.js","../node_modules/antd/es/upload/UploadList/index.js","../node_modules/antd/es/upload/Upload.js","../node_modules/antd/es/upload/Dragger.js","../node_modules/antd/es/upload/index.js","../node_modules/@ant-design/icons-svg/es/asn/UploadOutlined.js","../node_modules/@ant-design/icons/es/components/Context.js","../node_modules/@ctrl/tinycolor/dist/module/util.js","../node_modules/@ctrl/tinycolor/dist/module/conversion.js","../node_modules/@ctrl/tinycolor/dist/module/css-color-names.js","../node_modules/@ctrl/tinycolor/dist/module/format-input.js","../node_modules/@ant-design/colors/dist/index.esm.js","../node_modules/@ant-design/icons/es/utils.js","../node_modules/@ant-design/icons/es/components/IconBase.js","../node_modules/@ant-design/icons/es/components/twoTonePrimaryColor.js","../node_modules/@ant-design/icons/es/components/AntdIcon.js","../node_modules/@ant-design/icons/es/icons/UploadOutlined.js","services/Upload.service.ts","lib/helpers/File.helper.ts","lib/UploadField.tsx","services/Supplier.service.ts","components/Account/Client/ClientCreateModal.tsx","components/Account/Client/ClientEditModal.tsx","../node_modules/@ant-design/icons-svg/es/asn/EllipsisOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/EllipsisOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/PlusOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/PlusOutlined.js","../node_modules/rc-tabs/es/TabContext.js","../node_modules/rc-tabs/es/hooks/useIndicator.js","../node_modules/rc-tabs/es/hooks/useOffsets.js","../node_modules/rc-tabs/es/hooks/useSyncState.js","../node_modules/rc-tabs/es/hooks/useTouchMove.js","../node_modules/rc-tabs/es/hooks/useUpdate.js","../node_modules/rc-tabs/es/hooks/useVisibleRange.js","../node_modules/rc-tabs/es/util.js","../node_modules/rc-tabs/es/TabNavList/AddButton.js","../node_modules/rc-tabs/es/TabNavList/ExtraContent.js","../node_modules/rc-dropdown/es/hooks/useAccessibility.js","../node_modules/rc-dropdown/es/Overlay.js","../node_modules/rc-dropdown/es/placements.js","../node_modules/rc-dropdown/es/Dropdown.js","../node_modules/rc-dropdown/es/index.js","../node_modules/rc-menu/es/context/IdContext.js","../node_modules/rc-menu/es/context/MenuContext.js","../node_modules/rc-menu/es/context/PathContext.js","../node_modules/rc-menu/es/context/PrivateContext.js","../node_modules/rc-util/es/Dom/focus.js","../node_modules/rc-menu/es/hooks/useAccessibility.js","../node_modules/rc-menu/es/hooks/useKeyRecords.js","../node_modules/rc-menu/es/utils/timeUtil.js","../node_modules/rc-menu/es/hooks/useMemoCallback.js","../node_modules/rc-menu/es/hooks/useUUID.js","../node_modules/rc-menu/es/hooks/useActive.js","../node_modules/rc-menu/es/hooks/useDirectionStyle.js","../node_modules/rc-menu/es/Icon.js","../node_modules/rc-menu/es/utils/warnUtil.js","../node_modules/rc-menu/es/MenuItem.js","../node_modules/rc-menu/es/SubMenu/SubMenuList.js","../node_modules/rc-menu/es/utils/commonUtil.js","../node_modules/rc-menu/es/placements.js","../node_modules/rc-menu/es/utils/motionUtil.js","../node_modules/rc-menu/es/SubMenu/PopupTrigger.js","../node_modules/rc-menu/es/SubMenu/InlineSubMenuList.js","../node_modules/rc-menu/es/SubMenu/index.js","../node_modules/rc-menu/es/Divider.js","../node_modules/rc-menu/es/MenuItemGroup.js","../node_modules/rc-menu/es/utils/nodeUtil.js","../node_modules/rc-menu/es/Menu.js","../node_modules/rc-menu/es/index.js","../node_modules/rc-tabs/es/TabNavList/OperationNode.js","../node_modules/rc-tabs/es/TabNavList/TabNode.js","../node_modules/rc-tabs/es/TabNavList/index.js","../node_modules/rc-tabs/es/TabPanelList/TabPane.js","../node_modules/rc-tabs/es/TabNavList/Wrapper.js","../node_modules/rc-tabs/es/TabPanelList/index.js","../node_modules/rc-tabs/es/Tabs.js","../node_modules/rc-tabs/es/hooks/useAnimateConfig.js","../node_modules/rc-tabs/es/index.js","../node_modules/antd/es/tabs/hooks/useAnimateConfig.js","../node_modules/antd/es/tabs/hooks/useLegacyItems.js","../node_modules/antd/es/tabs/style/motion.js","../node_modules/antd/es/tabs/style/index.js","../node_modules/antd/es/tabs/TabPane.js","../node_modules/antd/es/tabs/index.js","../node_modules/antd/es/card/Grid.js","../node_modules/antd/es/card/style/index.js","../node_modules/antd/es/card/Card.js","../node_modules/antd/es/card/Meta.js","../node_modules/antd/es/card/index.js","../node_modules/@ant-design/icons-svg/es/asn/QrcodeOutlined.js","../node_modules/@ant-design/icons/es/icons/QrcodeOutlined.js","../node_modules/@ant-design/icons/es/icons/EditOutlined.js","../node_modules/@ant-design/icons/es/icons/DeleteOutlined.js","../node_modules/rc-table/es/constant.js","../node_modules/@rc-component/context/es/context.js","../node_modules/@rc-component/context/es/Immutable.js","../node_modules/@rc-component/context/es/index.js","../node_modules/rc-table/es/context/TableContext.js","../node_modules/rc-table/es/context/PerfContext.js","../node_modules/rc-table/es/utils/valueUtil.js","../node_modules/rc-table/es/Cell/useCellRender.js","../node_modules/rc-table/es/Cell/index.js","../node_modules/rc-table/es/Cell/useHoverState.js","../node_modules/rc-table/es/utils/fixUtil.js","../node_modules/rc-table/es/Footer/SummaryContext.js","../node_modules/rc-table/es/Footer/Row.js","../node_modules/rc-table/es/Footer/Summary.js","../node_modules/rc-table/es/Footer/Cell.js","../node_modules/rc-table/es/Footer/index.js","../node_modules/rc-table/es/hooks/useFlattenRecords.js","../node_modules/rc-table/es/hooks/useRowInfo.js","../node_modules/rc-table/es/Body/ExpandedRow.js","../node_modules/rc-table/es/utils/expandUtil.js","../node_modules/rc-table/es/Body/BodyRow.js","../node_modules/rc-table/es/Body/MeasureCell.js","../node_modules/rc-table/es/Body/MeasureRow.js","../node_modules/rc-table/es/Body/index.js","../node_modules/rc-table/es/utils/legacyUtil.js","../node_modules/rc-table/es/ColGroup.js","../node_modules/rc-table/es/FixedHolder/index.js","../node_modules/rc-table/es/Header/HeaderRow.js","../node_modules/rc-table/es/Header/Header.js","../node_modules/rc-table/es/hooks/useColumns/useWidthColumns.js","../node_modules/rc-table/es/hooks/useColumns/index.js","../node_modules/rc-table/es/hooks/useExpand.js","../node_modules/rc-table/es/hooks/useFrame.js","../node_modules/rc-table/es/hooks/useSticky.js","../node_modules/rc-table/es/hooks/useStickyOffsets.js","../node_modules/rc-table/es/Panel/index.js","../node_modules/rc-util/es/Dom/addEventListener.js","../node_modules/rc-table/es/utils/offsetUtil.js","../node_modules/rc-table/es/stickyScrollBar.js","../node_modules/rc-table/es/sugar/Column.js","../node_modules/rc-table/es/sugar/ColumnGroup.js","../node_modules/rc-table/es/Table.js","../node_modules/rc-table/es/hooks/useHover.js","../node_modules/rc-table/es/hooks/useFixedInfo.js","../node_modules/rc-table/es/VirtualTable/context.js","../node_modules/rc-table/es/VirtualTable/VirtualCell.js","../node_modules/rc-table/es/VirtualTable/BodyLine.js","../node_modules/rc-table/es/VirtualTable/BodyGrid.js","../node_modules/rc-table/es/VirtualTable/index.js","../node_modules/antd/es/table/Column.js","../node_modules/antd/es/table/ColumnGroup.js","../node_modules/rc-tree/es/contextTypes.js","../node_modules/rc-tree/es/Indent.js","../node_modules/rc-tree/es/utils/keyUtil.js","../node_modules/rc-tree/es/utils/treeUtil.js","../node_modules/rc-tree/es/TreeNode.js","../node_modules/rc-tree/es/util.js","../node_modules/rc-tree/es/utils/conductUtil.js","../node_modules/antd/es/checkbox/GroupContext.js","../node_modules/antd/es/checkbox/style/index.js","../node_modules/antd/es/checkbox/Checkbox.js","../node_modules/antd/es/checkbox/Group.js","../node_modules/antd/es/checkbox/index.js","../node_modules/@ant-design/icons-svg/es/asn/LeftOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/LeftOutlined.js","../node_modules/antd/es/_util/isPrimitive.js","../node_modules/@ant-design/icons-svg/es/asn/BarsOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/BarsOutlined.js","../node_modules/antd/es/layout/context.js","../node_modules/antd/es/layout/style/index.js","../node_modules/antd/es/layout/style/sider.js","../node_modules/antd/es/layout/Sider.js","../node_modules/antd/es/menu/MenuContext.js","../node_modules/antd/es/menu/MenuDivider.js","../node_modules/antd/es/menu/MenuItem.js","../node_modules/antd/es/menu/OverrideContext.js","../node_modules/antd/es/menu/style/horizontal.js","../node_modules/antd/es/menu/style/rtl.js","../node_modules/antd/es/menu/style/theme.js","../node_modules/antd/es/menu/style/vertical.js","../node_modules/antd/es/menu/style/index.js","../node_modules/antd/es/menu/SubMenu.js","../node_modules/antd/es/menu/menu.js","../node_modules/antd/es/menu/index.js","../node_modules/antd/es/dropdown/style/status.js","../node_modules/antd/es/dropdown/style/index.js","../node_modules/antd/es/dropdown/dropdown.js","../node_modules/antd/es/dropdown/dropdown-button.js","../node_modules/antd/es/dropdown/index.js","../node_modules/antd/es/table/hooks/useSelection.js","../node_modules/antd/es/_util/hooks/useMultipleSelect.js","../node_modules/antd/es/_util/hooks/useProxyImperativeHandle.js","../node_modules/antd/es/_util/getScroll.js","../node_modules/antd/es/_util/scrollTo.js","../node_modules/antd/es/_util/easings.js","../node_modules/@ant-design/icons-svg/es/asn/DoubleLeftOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/DoubleLeftOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/DoubleRightOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/DoubleRightOutlined.js","../node_modules/rc-pagination/es/locale/zh_CN.js","../node_modules/rc-pagination/es/Options.js","../node_modules/rc-pagination/es/Pager.js","../node_modules/rc-pagination/es/Pagination.js","../node_modules/antd/es/pagination/style/index.js","../node_modules/antd/es/pagination/style/bordered.js","../node_modules/antd/es/pagination/useShowSizeChanger.js","../node_modules/antd/es/pagination/Pagination.js","../node_modules/antd/es/pagination/index.js","../node_modules/throttle-debounce/debounce.js","../node_modules/throttle-debounce/throttle.js","../node_modules/antd/es/spin/Indicator/Progress.js","../node_modules/antd/es/spin/Indicator/Looper.js","../node_modules/antd/es/spin/Indicator/index.js","../node_modules/antd/es/spin/style/index.js","../node_modules/antd/es/spin/usePercent.js","../node_modules/antd/es/spin/index.js","../node_modules/antd/es/table/ExpandIcon.js","../node_modules/antd/es/table/util.js","../node_modules/@ant-design/icons-svg/es/asn/FilterFilled.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/FilterFilled.js","../node_modules/antd/es/_util/extendsObject.js","../node_modules/rc-tree/es/DropIndicator.js","../node_modules/rc-tree/es/useUnmount.js","../node_modules/rc-tree/es/MotionTreeNode.js","../node_modules/rc-tree/es/utils/diffUtil.js","../node_modules/rc-tree/es/NodeList.js","../node_modules/rc-tree/es/Tree.js","../node_modules/rc-tree/es/index.js","../node_modules/@ant-design/icons-svg/es/asn/FileOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/FileOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/FolderOpenOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/FolderOpenOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/FolderOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/FolderOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/HolderOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/HolderOutlined.js","../node_modules/antd/es/tree/style/directory.js","../node_modules/antd/es/tree/style/index.js","../node_modules/antd/es/tree/utils/dropIndicator.js","../node_modules/@ant-design/icons-svg/es/asn/CaretDownFilled.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/CaretDownFilled.js","../node_modules/@ant-design/icons-svg/es/asn/MinusSquareOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/MinusSquareOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/PlusSquareOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/PlusSquareOutlined.js","../node_modules/antd/es/tree/utils/iconUtil.js","../node_modules/antd/es/tree/Tree.js","../node_modules/antd/es/tree/utils/dictUtil.js","../node_modules/antd/es/tree/DirectoryTree.js","../node_modules/antd/es/tree/index.js","../node_modules/antd/es/table/hooks/useFilter/FilterSearch.js","../node_modules/antd/es/table/hooks/useFilter/FilterWrapper.js","../node_modules/antd/es/table/hooks/useFilter/FilterDropdown.js","../node_modules/antd/es/_util/hooks/useSyncState.js","../node_modules/antd/es/table/hooks/useFilter/index.js","../node_modules/antd/es/table/hooks/useLazyKVMap.js","../node_modules/antd/es/table/hooks/usePagination.js","../node_modules/@ant-design/icons-svg/es/asn/CaretDownOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/CaretDownOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/CaretUpOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/CaretUpOutlined.js","../node_modules/antd/es/table/hooks/useSorter.js","../node_modules/antd/es/table/hooks/useTitleColumns.js","../node_modules/antd/es/table/RcTable/index.js","../node_modules/antd/es/table/RcTable/VirtualTable.js","../node_modules/antd/es/table/style/bordered.js","../node_modules/antd/es/table/style/ellipsis.js","../node_modules/antd/es/table/style/empty.js","../node_modules/antd/es/table/style/expand.js","../node_modules/antd/es/table/style/filter.js","../node_modules/antd/es/table/style/fixed.js","../node_modules/antd/es/table/style/pagination.js","../node_modules/antd/es/table/style/radius.js","../node_modules/antd/es/table/style/rtl.js","../node_modules/antd/es/table/style/selection.js","../node_modules/antd/es/table/style/size.js","../node_modules/antd/es/table/style/sorter.js","../node_modules/antd/es/table/style/sticky.js","../node_modules/antd/es/table/style/summary.js","../node_modules/antd/es/table/style/virtual.js","../node_modules/antd/es/table/style/index.js","../node_modules/antd/es/table/InternalTable.js","../node_modules/antd/es/table/hooks/useContainerWidth.js","../node_modules/antd/es/table/Table.js","../node_modules/antd/es/table/index.js","components/_Common/List.tsx","../node_modules/@rc-component/qrcode/es/libs/qrcodegen.js","lib/CobreFacil.ts","lib/helpers/Contratc.helper.ts","components/Account/Client/ClientManagerCardClients.tsx","../node_modules/@rc-component/qrcode/es/utils.js","../node_modules/@rc-component/qrcode/es/hooks/useQRCode.js","../node_modules/@rc-component/qrcode/es/QRCodeCanvas.js","../node_modules/@rc-component/qrcode/es/QRCodeSVG.js","../node_modules/@ant-design/icons-svg/es/asn/ReloadOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/ReloadOutlined.js","../node_modules/antd/es/qr-code/QrcodeStatus.js","../node_modules/antd/es/qr-code/style/index.js","../node_modules/antd/es/qr-code/index.js","components/Account/Client/ClientQrCodeModal.tsx","../node_modules/antd/es/_util/getRenderPropValue.js","../node_modules/antd/es/popover/style/index.js","../node_modules/antd/es/popover/PurePanel.js","../node_modules/antd/es/popover/index.js","../node_modules/rc-segmented/es/MotionThumb.js","../node_modules/rc-segmented/es/index.js","../node_modules/antd/es/segmented/style/index.js","../node_modules/antd/es/segmented/index.js","../node_modules/antd/es/color-picker/context.js","../node_modules/antd/es/color-picker/components/ColorClear.js","../node_modules/antd/es/color-picker/interface.js","../node_modules/@ant-design/icons-svg/es/asn/UpOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/UpOutlined.js","../node_modules/@rc-component/mini-decimal/es/supportUtil.js","../node_modules/@rc-component/mini-decimal/es/numberUtil.js","../node_modules/@rc-component/mini-decimal/es/BigIntDecimal.js","../node_modules/@rc-component/mini-decimal/es/NumberDecimal.js","../node_modules/@rc-component/mini-decimal/es/MiniDecimal.js","../node_modules/@rc-component/mini-decimal/es/index.js","../node_modules/rc-util/es/hooks/useMobile.js","../node_modules/rc-input-number/es/StepHandler.js","../node_modules/rc-input-number/es/utils/numberUtil.js","../node_modules/rc-input-number/es/hooks/useFrame.js","../node_modules/rc-input-number/es/InputNumber.js","../node_modules/rc-input-number/es/hooks/useCursor.js","../node_modules/rc-util/es/proxyObject.js","../node_modules/rc-input-number/es/index.js","../node_modules/antd/es/input-number/style/index.js","../node_modules/antd/es/input-number/style/token.js","../node_modules/antd/es/input-number/index.js","../node_modules/antd/es/color-picker/components/ColorSteppers.js","../node_modules/antd/es/color-picker/components/ColorAlphaInput.js","../node_modules/antd/es/color-picker/components/ColorHexInput.js","../node_modules/antd/es/color-picker/components/ColorHsbInput.js","../node_modules/antd/es/color-picker/components/ColorRgbInput.js","../node_modules/antd/es/color-picker/components/ColorInput.js","../node_modules/rc-slider/es/util.js","../node_modules/rc-slider/es/context.js","../node_modules/rc-slider/es/Handles/Handle.js","../node_modules/rc-slider/es/Handles/index.js","../node_modules/rc-slider/es/Marks/Mark.js","../node_modules/rc-slider/es/Marks/index.js","../node_modules/rc-slider/es/Steps/Dot.js","../node_modules/rc-slider/es/Steps/index.js","../node_modules/rc-slider/es/Tracks/Track.js","../node_modules/rc-slider/es/Tracks/index.js","../node_modules/rc-slider/es/hooks/useDrag.js","../node_modules/rc-slider/es/Slider.js","../node_modules/rc-slider/es/hooks/useRange.js","../node_modules/rc-slider/es/hooks/useOffset.js","../node_modules/rc-slider/es/index.js","../node_modules/antd/es/slider/Context.js","../node_modules/antd/es/slider/SliderTooltip.js","../node_modules/antd/es/slider/style/index.js","../node_modules/antd/es/slider/useRafLock.js","../node_modules/antd/es/slider/index.js","../node_modules/antd/es/color-picker/components/ColorSlider.js","../node_modules/antd/es/color-picker/components/PanelPicker/GradientColorBar.js","../node_modules/antd/es/color-picker/components/PanelPicker/index.js","../node_modules/antd/es/color-picker/components/PanelPresets.js","../node_modules/antd/es/color-picker/ColorPickerPanel.js","../node_modules/antd/es/color-picker/components/ColorTrigger.js","../node_modules/antd/es/color-picker/style/color-block.js","../node_modules/antd/es/color-picker/style/input.js","../node_modules/antd/es/color-picker/style/picker.js","../node_modules/antd/es/color-picker/style/presets.js","../node_modules/antd/es/color-picker/style/slider.js","../node_modules/antd/es/color-picker/style/index.js","../node_modules/antd/es/color-picker/ColorPicker.js","../node_modules/antd/es/color-picker/hooks/useModeColor.js","../node_modules/antd/es/color-picker/index.js","../node_modules/@ant-design/icons-svg/es/asn/LinkOutlined.js","../node_modules/@ant-design/icons/es/icons/LinkOutlined.js","services/ZApi.service.ts","components/Account/ClientManagerCard.tsx","../node_modules/antd/es/list/context.js","../node_modules/antd/es/list/Item.js","../node_modules/antd/es/list/style/index.js","../node_modules/antd/es/list/index.js","lib/helpers/BRL.ts","components/Account/ClientManagerCardPlan.tsx","../node_modules/antd/es/layout/layout.js","../node_modules/antd/es/layout/hooks/useHasSider.js","../node_modules/antd/es/layout/index.js","../node_modules/@ant-design/icons-svg/es/asn/VerticalAlignTopOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/VerticalAlignTopOutlined.js","../node_modules/antd/es/_util/throttleByAnimationFrame.js","../node_modules/antd/es/float-button/context.js","../node_modules/antd/es/badge/style/index.js","../node_modules/antd/es/badge/style/ribbon.js","../node_modules/antd/es/badge/Ribbon.js","../node_modules/antd/es/badge/SingleNumber.js","../node_modules/antd/es/badge/ScrollNumber.js","../node_modules/antd/es/badge/index.js","../node_modules/@ant-design/icons-svg/es/asn/FileTextOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/FileTextOutlined.js","../node_modules/antd/es/float-button/FloatButtonContent.js","../node_modules/antd/es/float-button/util.js","../node_modules/antd/es/float-button/style/keyframes.js","../node_modules/antd/es/float-button/style/index.js","../node_modules/antd/es/float-button/FloatButton.js","../node_modules/antd/es/float-button/BackTop.js","../node_modules/antd/es/float-button/FloatButtonGroup.js","../node_modules/antd/es/float-button/PurePanel.js","../node_modules/antd/es/float-button/index.js","../node_modules/@ant-design/icons/es/icons/FileTextOutlined.js","services/ClientUserNotes.service.ts","components/Note/Modal.tsx","internal-constants.ts","../node_modules/antd/es/avatar/AvatarContext.js","../node_modules/antd/es/avatar/style/index.js","../node_modules/antd/es/avatar/Avatar.js","../node_modules/antd/es/avatar/AvatarGroup.js","../node_modules/antd/es/avatar/index.js","../node_modules/@ant-design/icons-svg/es/asn/UserOutlined.js","../node_modules/@ant-design/icons/es/icons/UserOutlined.js","../node_modules/@ant-design/icons/es/icons/DownOutlined.js","components/_Common/_Layout/Header.tsx","../node_modules/@ant-design/icons-svg/es/asn/HomeOutlined.js","../node_modules/@ant-design/icons/es/icons/HomeOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/BuildOutlined.js","../node_modules/@ant-design/icons/es/icons/BuildOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/CarOutlined.js","../node_modules/@ant-design/icons/es/icons/CarOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/SnippetsOutlined.js","../node_modules/@ant-design/icons/es/icons/SnippetsOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/SettingOutlined.js","../node_modules/@ant-design/icons/es/icons/SettingOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/FormatPainterOutlined.js","../node_modules/@ant-design/icons/es/icons/FormatPainterOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/ScheduleOutlined.js","../node_modules/@ant-design/icons/es/icons/ScheduleOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/NotificationOutlined.js","../node_modules/@ant-design/icons/es/icons/NotificationOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/BellOutlined.js","../node_modules/@ant-design/icons/es/icons/BellOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/CalendarOutlined.js","../node_modules/@ant-design/icons/es/icons/CalendarOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/RobotOutlined.js","../node_modules/@ant-design/icons/es/icons/RobotOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/ReadOutlined.js","../node_modules/@ant-design/icons/es/icons/ReadOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/FieldTimeOutlined.js","../node_modules/@ant-design/icons/es/icons/FieldTimeOutlined.js","lib/helpers/Router.helper.ts","components/_Common/_Layout/HeaderLogo.tsx","components/_Common/_Layout/Sider.tsx","../node_modules/react-router/modules/withRouter.js","components/_Common/_Layout/MainLayout.tsx","../node_modules/@ant-design/icons/es/icons/LeftOutlined.js","components/Account/LayoutHeader.tsx","components/Account/Layout.tsx","pages/account/Account.page.tsx","components/_Common/_Layout/Content.tsx","../node_modules/@ant-design/icons-svg/es/asn/TeamOutlined.js","../node_modules/@ant-design/icons/es/icons/TeamOutlined.js","lib/hooks/useAmbient.ts","services/Ambient.service.ts","components/Ambient/CreateAmbientModal.tsx","components/Ambient/EditAmbientModal.tsx","../node_modules/@ant-design/icons/es/icons/QuestionCircleOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/MinusCircleOutlined.js","../node_modules/@ant-design/icons/es/icons/MinusCircleOutlined.js","../node_modules/@ant-design/icons/es/icons/PlusOutlined.js","components/Ambient/AmbientDatesModal.tsx","../node_modules/antd/es/popconfirm/style/index.js","../node_modules/antd/es/popconfirm/PurePanel.js","../node_modules/antd/es/popconfirm/index.js","pages/ambient/AmbientActionsCell.tsx","pages/ambient/Columns.tsx","pages/ambient/Ambients.page.tsx","../node_modules/@ant-design/icons-svg/es/asn/FontSizeOutlined.js","../node_modules/@ant-design/icons/es/icons/FontSizeOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/FilePdfOutlined.js","../node_modules/@ant-design/icons/es/icons/FilePdfOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/WhatsAppOutlined.js","../node_modules/@ant-design/icons/es/icons/WhatsAppOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/OrderedListOutlined.js","../node_modules/@ant-design/icons/es/icons/OrderedListOutlined.js","services/Chatbot.service.ts","lib/providers/ChatbotContextProvider.tsx","components/ChatBot/CreateChatbotModal.tsx","components/ChatBot/EditChatbotModal.tsx","pages/chatbot/Chatbot.page.tsx","../node_modules/antd/es/flex/utils.js","../node_modules/antd/es/flex/style/index.js","../node_modules/antd/es/flex/index.js","../node_modules/@ant-design/icons-svg/es/asn/UserAddOutlined.js","../node_modules/@ant-design/icons/es/icons/UserAddOutlined.js","components/_Common/LoadingGcondo.tsx","components/Client/Layout.tsx","services/Client.service.ts","lib/providers/ClientContextProvider.tsx","pages/client/Client.page.tsx","../node_modules/react-google-recaptcha/lib/esm/recaptcha.js","../node_modules/react-async-script/lib/esm/async-script-loader.js","../node_modules/react-google-recaptcha/lib/esm/recaptcha-wrapper.js","../node_modules/react-google-recaptcha/lib/esm/index.js","lib/ReCAPTCHA.tsx","components/Client/ApartmentField.tsx","components/Client/CreateIssueForm.tsx","pages/client/issue/CreateIssue.page.tsx","../node_modules/@ant-design/react-slick/es/initial-state.js","../node_modules/@ant-design/react-slick/es/default-props.js","../node_modules/@ant-design/react-slick/es/utils/innerSliderUtils.js","../node_modules/@ant-design/react-slick/es/track.js","../node_modules/@ant-design/react-slick/es/dots.js","../node_modules/@ant-design/react-slick/es/arrows.js","../node_modules/@ant-design/react-slick/es/inner-slider.js","../node_modules/@ant-design/react-slick/es/slider.js","../node_modules/@ant-design/react-slick/es/index.js","../node_modules/antd/es/carousel/style/index.js","../node_modules/antd/es/carousel/index.js","pages/client/issue/list/Issues.page.tsx","../node_modules/compare-versions/src/utils.ts","../node_modules/react-easy-crop/node_modules/tslib/tslib.es6.js","../node_modules/src/helpers.ts","../node_modules/src/Cropper.tsx","../node_modules/antd-img-crop/dist/antd-img-crop.esm.js","../node_modules/compare-versions/src/compareVersions.ts","../node_modules/@ant-design/icons-svg/es/asn/LockOutlined.js","../node_modules/@ant-design/icons/es/icons/LockOutlined.js","lib/providers/ResidentFirstAccessContextProvider.tsx","components/Client/FormResidentExternal.tsx","components/Client/FormResidentIdentification.tsx","components/Client/SuccessPage.tsx","pages/client/ResidentFirstAccess.page.tsx","lib/providers/ClientManagerPageContextProvider.tsx","pages/client_manager/ClientManagerPage.page.tsx","../node_modules/rc-picker/es/generate/dayjs.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/CalendarOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/ClockCircleOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/ClockCircleOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/SwapRightOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/SwapRightOutlined.js","../node_modules/rc-picker/es/PickerInput/context.js","../node_modules/rc-picker/es/PickerTrigger/index.js","../node_modules/rc-picker/es/utils/uiUtil.js","../node_modules/rc-picker/es/utils/miscUtil.js","../node_modules/rc-picker/es/PickerTrigger/util.js","../node_modules/rc-picker/es/PickerInput/hooks/useCellRender.js","../node_modules/rc-picker/es/PickerInput/hooks/useFieldsInvalidate.js","../node_modules/rc-picker/es/hooks/useLocale.js","../node_modules/rc-picker/es/hooks/useTimeConfig.js","../node_modules/rc-picker/es/PickerInput/Selector/hooks/useClearIcon.js","../node_modules/rc-picker/es/utils/dateUtil.js","../node_modules/rc-picker/es/PickerInput/hooks/useFilledProps.js","../node_modules/rc-picker/es/PickerInput/hooks/useFieldFormat.js","../node_modules/rc-picker/es/PickerInput/hooks/useInputReadOnly.js","../node_modules/rc-picker/es/PickerInput/hooks/useDisabledBoundary.js","../node_modules/rc-picker/es/PickerInput/hooks/useInvalidate.js","../node_modules/rc-picker/es/PickerInput/hooks/useOpen.js","../node_modules/rc-picker/es/PickerInput/hooks/useDelayState.js","../node_modules/rc-picker/es/PickerInput/hooks/usePickerRef.js","../node_modules/rc-picker/es/PickerInput/hooks/usePresets.js","../node_modules/rc-picker/es/PickerInput/hooks/useLockEffect.js","../node_modules/rc-picker/es/PickerInput/hooks/useRangeActive.js","../node_modules/rc-picker/es/PickerInput/hooks/useRangePickerValue.js","../node_modules/rc-picker/es/hooks/useSyncState.js","../node_modules/rc-picker/es/PickerInput/hooks/useRangeValue.js","../node_modules/rc-picker/es/PickerInput/hooks/useShowNow.js","../node_modules/rc-picker/es/hooks/useTimeInfo.js","../node_modules/rc-picker/es/PickerPanel/TimePanel/TimePanelBody/util.js","../node_modules/rc-picker/es/PickerInput/Popup/Footer.js","../node_modules/rc-picker/es/hooks/useToggleDates.js","../node_modules/rc-picker/es/PickerPanel/context.js","../node_modules/rc-picker/es/PickerPanel/PanelBody.js","../node_modules/rc-picker/es/PickerPanel/PanelHeader.js","../node_modules/rc-picker/es/PickerPanel/DatePanel/index.js","../node_modules/rc-picker/es/PickerPanel/TimePanel/TimePanelBody/useScrollTo.js","../node_modules/rc-picker/es/PickerPanel/TimePanel/TimePanelBody/TimeColumn.js","../node_modules/rc-picker/es/PickerPanel/TimePanel/TimePanelBody/index.js","../node_modules/rc-picker/es/PickerPanel/TimePanel/index.js","../node_modules/rc-picker/es/PickerPanel/index.js","../node_modules/rc-picker/es/PickerPanel/DateTimePanel/index.js","../node_modules/rc-picker/es/PickerPanel/WeekPanel/index.js","../node_modules/rc-picker/es/PickerPanel/MonthPanel/index.js","../node_modules/rc-picker/es/PickerPanel/QuarterPanel/index.js","../node_modules/rc-picker/es/PickerPanel/YearPanel/index.js","../node_modules/rc-picker/es/PickerPanel/DecadePanel/index.js","../node_modules/rc-picker/es/PickerInput/Popup/PopupPanel.js","../node_modules/rc-picker/es/PickerInput/Popup/PresetPanel.js","../node_modules/rc-picker/es/PickerInput/Popup/index.js","../node_modules/rc-picker/es/PickerInput/Selector/hooks/useInputProps.js","../node_modules/rc-picker/es/PickerInput/Selector/hooks/useRootProps.js","../node_modules/rc-picker/es/PickerInput/Selector/Icon.js","../node_modules/rc-picker/es/PickerInput/Selector/MaskFormat.js","../node_modules/rc-picker/es/PickerInput/Selector/Input.js","../node_modules/rc-picker/es/PickerInput/Selector/util.js","../node_modules/rc-picker/es/PickerInput/Selector/RangeSelector.js","../node_modules/rc-picker/es/PickerInput/RangePicker.js","../node_modules/rc-picker/es/PickerInput/hooks/useRangeDisabledDate.js","../node_modules/rc-picker/es/PickerInput/Selector/SingleSelector/MultipleDates.js","../node_modules/rc-picker/es/PickerInput/Selector/SingleSelector/index.js","../node_modules/rc-picker/es/PickerInput/SinglePicker.js","../node_modules/rc-picker/es/index.js","../node_modules/antd/es/date-picker/style/multiple.js","../node_modules/antd/es/date-picker/style/panel.js","../node_modules/antd/es/date-picker/style/token.js","../node_modules/antd/es/date-picker/style/variants.js","../node_modules/antd/es/date-picker/style/index.js","../node_modules/antd/es/date-picker/util.js","../node_modules/antd/es/date-picker/generatePicker/constant.js","../node_modules/antd/es/date-picker/PickerButton.js","../node_modules/antd/es/date-picker/generatePicker/useComponents.js","../node_modules/antd/es/date-picker/generatePicker/generateRangePicker.js","../node_modules/antd/es/date-picker/generatePicker/generateSinglePicker.js","../node_modules/antd/es/date-picker/generatePicker/index.js","../node_modules/antd/es/date-picker/index.js","../node_modules/@ant-design/icons-svg/es/asn/ClearOutlined.js","../node_modules/@ant-design/icons/es/icons/ClearOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/FilterOutlined.js","../node_modules/@ant-design/icons/es/icons/FilterOutlined.js","services/Construction.service.ts","lib/providers/ConstructionContextProvider.tsx","lib/hooks/useSearchParams.ts","services/Issue.service.ts","lib/providers/IssueContextProvider.tsx","pages/issue/Filters.tsx","components/Construction/ConstructionFilterBar.tsx","components/Construction/CreateConstructionModal.tsx","../node_modules/antd/es/breadcrumb/BreadcrumbSeparator.js","../node_modules/antd/es/breadcrumb/useItemRender.js","../node_modules/antd/es/breadcrumb/BreadcrumbItem.js","../node_modules/antd/es/breadcrumb/style/index.js","../node_modules/antd/es/breadcrumb/useItems.js","../node_modules/antd/es/breadcrumb/Breadcrumb.js","../node_modules/antd/es/breadcrumb/index.js","../node_modules/antd/es/tag/style/index.js","../node_modules/antd/es/tag/CheckableTag.js","../node_modules/antd/es/tag/style/presetCmp.js","../node_modules/antd/es/tag/style/statusCmp.js","../node_modules/antd/es/_util/capitalize.js","../node_modules/antd/es/tag/index.js","../node_modules/rc-util/es/Dom/css.js","../node_modules/rc-image/es/context.js","../node_modules/rc-image/es/Operations.js","../node_modules/rc-image/es/hooks/useImageTransform.js","../node_modules/rc-image/es/getFixScaleEleTransPosition.js","../node_modules/rc-image/es/hooks/useStatus.js","../node_modules/rc-image/es/util.js","../node_modules/rc-image/es/hooks/useTouchEvent.js","../node_modules/rc-image/es/Preview.js","../node_modules/rc-image/es/hooks/useMouseEvent.js","../node_modules/rc-image/es/previewConfig.js","../node_modules/rc-image/es/common.js","../node_modules/rc-image/es/PreviewGroup.js","../node_modules/rc-image/es/hooks/usePreviewItems.js","../node_modules/rc-image/es/hooks/useRegisterImage.js","../node_modules/rc-image/es/Image.js","../node_modules/rc-image/es/index.js","../node_modules/@ant-design/icons-svg/es/asn/RotateLeftOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/RotateLeftOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/RotateRightOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/RotateRightOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/SwapOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/SwapOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/ZoomInOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/ZoomInOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/ZoomOutOutlined.js","../node_modules/antd/node_modules/@ant-design/icons/es/icons/ZoomOutOutlined.js","../node_modules/antd/es/image/style/index.js","../node_modules/antd/es/image/PreviewGroup.js","../node_modules/antd/es/image/index.js","components/_Common/FilesGalery.tsx","../node_modules/@ant-design/icons-svg/es/asn/BulbOutlined.js","../node_modules/@ant-design/icons/es/icons/BulbOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/CheckCircleOutlined.js","../node_modules/@ant-design/icons/es/icons/CheckCircleOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/PauseCircleOutlined.js","../node_modules/@ant-design/icons/es/icons/PauseCircleOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/CloseCircleOutlined.js","../node_modules/@ant-design/icons/es/icons/CloseCircleOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/HourglassOutlined.js","../node_modules/@ant-design/icons/es/icons/HourglassOutlined.js","lib/helpers/Construction.helper.ts","services/Report.service.ts","components/Construction/EditFollowUpModal.tsx","components/Construction/FollowUpCreateModal.tsx","components/Construction/DetailConstructionModal.tsx","components/Construction/EditConstructionModal.tsx","components/Construction/ConstructionActionsCell.tsx","pages/construction/Columns.tsx","pages/construction/Construction.page.tsx","lib/hooks/useConsumption.ts","services/Consumption.service.ts","components/Consumption/FormConsumptionModal.tsx","components/Consumption/ConsumptionListModal.tsx","components/Consumption/ConsumptionReadingFormModal.tsx","services/ApartmentService.ts","pages/consumption/ConsumptionActionsCell.tsx","pages/consumption/Columns.tsx","../node_modules/xlsx/xlsx.mjs","pages/consumption/Consumption.page.tsx","pages/consumption/Consumption.report.ts","../node_modules/antd/es/calendar/Header.js","../node_modules/antd/es/calendar/style/index.js","../node_modules/antd/es/calendar/generateCalendar.js","../node_modules/antd/es/calendar/index.js","../node_modules/@antv/g2/src/constant.ts","../node_modules/@antv/dom-util/src/create-dom.ts","../node_modules/@antv/g2/src/engine/index.ts","../node_modules/@antv/dom-util/src/modify-css.ts","../node_modules/@antv/g2/src/util/dom.ts","../node_modules/@antv/g2/src/base.ts","../node_modules/@antv/adjust/src/adjusts/adjust.ts","../node_modules/@antv/adjust/src/constant.ts","../node_modules/@antv/adjust/src/factory.ts","../node_modules/@antv/adjust/node_modules/tslib/tslib.es6.js","../node_modules/@antv/adjust/src/adjusts/dodge.ts","../node_modules/@antv/adjust/src/adjusts/jitter.ts","../node_modules/@antv/adjust/src/adjusts/stack.ts","../node_modules/@antv/adjust/src/adjusts/symmetric.ts","../node_modules/@antv/adjust/src/index.ts","../node_modules/@antv/attr/src/attributes/base.ts","../node_modules/@antv/color-util/src/index.ts","../node_modules/@antv/attr/src/attributes/color.ts","../node_modules/@antv/attr/src/attributes/opacity.ts","../node_modules/@antv/attr/src/attributes/position.ts","../node_modules/@antv/attr/src/attributes/shape.ts","../node_modules/@antv/attr/src/attributes/size.ts","../node_modules/@antv/scale/src/tick-method/register.ts","../node_modules/@antv/scale/src/base.ts","../node_modules/@antv/scale/src/category/base.ts","../node_modules/fecha/src/fecha.ts","../node_modules/@antv/scale/src/util/time.ts","../node_modules/@antv/scale/src/util/bisector.ts","../node_modules/@antv/scale/src/category/time.ts","../node_modules/@antv/scale/src/continuous/base.ts","../node_modules/@antv/scale/src/continuous/linear.ts","../node_modules/@antv/scale/src/util/math.ts","../node_modules/@antv/scale/src/continuous/log.ts","../node_modules/@antv/scale/src/continuous/pow.ts","../node_modules/@antv/scale/src/continuous/time.ts","../node_modules/@antv/scale/src/continuous/quantize.ts","../node_modules/@antv/scale/src/continuous/quantile.ts","../node_modules/@antv/scale/src/factory.ts","../node_modules/@antv/scale/src/identity/index.ts","../node_modules/@antv/scale/src/tick-method/cat.ts","../node_modules/@antv/scale/src/util/d3-linear.ts","../node_modules/@antv/scale/src/util/interval.ts","../node_modules/@antv/scale/src/util/strict-limit.ts","../node_modules/@antv/scale/src/util/pretty-number.ts","../node_modules/@antv/scale/src/util/extended.ts","../node_modules/@antv/scale/src/util/pretty.ts","../node_modules/@antv/scale/src/tick-method/quantile.ts","../node_modules/@antv/scale/src/tick-method/time-pretty.ts","../node_modules/@antv/scale/src/tick-method/index.ts","../node_modules/@antv/scale/src/tick-method/time-cat.ts","../node_modules/@antv/scale/src/tick-method/linear.ts","../node_modules/@antv/scale/src/tick-method/r-prettry.ts","../node_modules/@antv/scale/src/tick-method/time.ts","../node_modules/@antv/scale/src/tick-method/log.ts","../node_modules/@antv/scale/src/tick-method/pow.ts","../node_modules/@antv/scale/src/tick-method/d3-linear.ts","../node_modules/@antv/scale/src/index.ts","../node_modules/@antv/attr/src/factory.ts","../node_modules/@antv/attr/src/index.ts","../node_modules/gl-matrix/esm/vec3.js","../node_modules/@antv/coord/src/coord/base.ts","../node_modules/@antv/coord/src/coord/cartesian.ts","../node_modules/@antv/coord/src/coord/helix.ts","../node_modules/@antv/coord/src/coord/polar.ts","../node_modules/@antv/coord/src/factory.ts","../node_modules/@antv/component/src/util/event.ts","../node_modules/@antv/coord/src/index.ts","../node_modules/@antv/component/src/util/matrix.ts","../node_modules/@antv/component/src/util/util.ts","../node_modules/@antv/component/src/abstract/component.ts","../node_modules/@antv/component/src/abstract/group-component.ts","../node_modules/@antv/component/src/util/text.ts","../node_modules/@antv/component/src/util/label.ts","../node_modules/@antv/component/src/util/graphic.ts","../node_modules/@antv/component/src/util/theme.ts","../node_modules/@antv/component/src/annotation/line.ts","../node_modules/@antv/component/src/annotation/text.ts","../node_modules/@antv/component/src/annotation/arc.ts","../node_modules/@antv/component/src/annotation/region.ts","../node_modules/@antv/component/src/annotation/image.ts","../node_modules/@antv/component/src/annotation/data-marker.ts","../node_modules/@antv/component/src/annotation/data-region.ts","../node_modules/@antv/component/src/annotation/region-filter.ts","../node_modules/@antv/component/src/annotation/shape.ts","../node_modules/@antv/dom-util/src/get-style.ts","../node_modules/@antv/dom-util/src/get-outer-width.ts","../node_modules/@antv/dom-util/src/get-width.ts","../node_modules/@antv/dom-util/src/get-outer-height.ts","../node_modules/@antv/dom-util/src/get-height.ts","../node_modules/@antv/component/src/abstract/html-component.ts","../node_modules/@antv/component/src/annotation/html.ts","../node_modules/@antv/component/src/util/state.ts","../node_modules/@antv/component/src/axis/base.ts","../node_modules/@antv/component/src/axis/overlap/auto-ellipsis.ts","../node_modules/@antv/component/src/axis/overlap/auto-hide.ts","../node_modules/@antv/component/src/axis/overlap/auto-rotate.ts","../node_modules/@antv/component/src/axis/line.ts","../node_modules/@antv/component/src/axis/circle.ts","../node_modules/@antv/component/src/crosshair/base.ts","../node_modules/@antv/component/src/crosshair/line.ts","../node_modules/@antv/component/src/crosshair/circle.ts","../node_modules/@antv/component/src/crosshair/css-const.ts","../node_modules/@antv/component/src/crosshair/html-theme.ts","../node_modules/@antv/component/src/crosshair/html.ts","../node_modules/@antv/component/src/grid/base.ts","../node_modules/@antv/component/src/grid/circle.ts","../node_modules/@antv/component/src/grid/line.ts","../node_modules/@antv/component/src/legend/base.ts","../node_modules/@antv/component/src/legend/category.ts","../node_modules/@antv/component/src/legend/continuous.ts","../node_modules/@antv/component/src/tooltip/css-const.ts","../node_modules/@antv/component/src/tooltip/html-theme.ts","../node_modules/@antv/component/src/tooltip/html.ts","../node_modules/@antv/component/src/util/align.ts","../node_modules/@antv/component/src/trend/constant.ts","../node_modules/@antv/component/node_modules/@antv/path-util/src/catmull-rom-2-bezier.ts","../node_modules/@antv/component/node_modules/@antv/path-util/src/parse-path-string.ts","../node_modules/@antv/component/node_modules/@antv/path-util/src/process/arc-2-cubic.ts","../node_modules/@antv/component/src/trend/path.ts","../node_modules/@antv/component/src/trend/trend.ts","../node_modules/@antv/component/src/slider/handler.ts","../node_modules/@antv/component/src/slider/constant.ts","../node_modules/@antv/component/src/slider/slider.ts","../node_modules/@antv/dom-util/src/add-event-listener.ts","../node_modules/@antv/component/src/scrollbar/scrollbar.ts","../node_modules/@antv/g2/src/dependents.ts","../node_modules/@antv/g2/src/util/graphics.ts","../node_modules/@antv/g2/src/util/helper.ts","../node_modules/@antv/g2/src/util/bbox.ts","../node_modules/@antv/g2/src/util/coordinate.ts","../node_modules/@antv/g2/src/util/scale.ts","../node_modules/@antv/g2/src/util/axis.ts","../node_modules/@antv/g2/src/facet/facet.ts","../node_modules/@antv/g2/src/facet/index.ts","../node_modules/@antv/g2/src/interaction/action/base.ts","../node_modules/@antv/g2/src/interaction/action/callback.ts","../node_modules/@antv/g2/src/interaction/action/register.ts","../node_modules/@antv/g2/src/geometry/shape/util/path.ts","../node_modules/@antv/g2/node_modules/@antv/path-util/src/parse-path-string.ts","../node_modules/@antv/g2/node_modules/@antv/path-util/src/process/arc-2-cubic.ts","../node_modules/@antv/g2/node_modules/@antv/path-util/src/point-in-polygon.ts","../node_modules/@antv/g2/node_modules/@antv/path-util/src/get-line-intersect.ts","../node_modules/@antv/g2/node_modules/@antv/path-util/src/is-polygons-intersect.ts","../node_modules/@antv/g2/src/interaction/action/util.ts","../node_modules/@antv/g2/src/interaction/context.ts","../node_modules/@antv/g2/src/interaction/interaction.ts","../node_modules/@antv/g2/src/interaction/grammar-interaction.ts","../node_modules/@antv/g2/src/interaction/index.ts","../node_modules/@antv/g2/src/theme/util/create-by-style-sheet.ts","../node_modules/@antv/g2/src/theme/style-sheet/light.ts","../node_modules/@antv/g2/src/theme/util/create-theme.ts","../node_modules/@antv/g2/src/theme/index.ts","../node_modules/@antv/g2/src/util/tooltip.ts","../node_modules/@antv/g2/src/util/padding.ts","../node_modules/@antv/g2/src/chart/controller/index.ts","../node_modules/@antv/g2/src/chart/controller/coordinate.ts","../node_modules/@antv/g2/src/chart/event.ts","../node_modules/@antv/g2/src/chart/layout/index.ts","../node_modules/@antv/g2/src/chart/util/scale-pool.ts","../node_modules/@antv/g2/src/chart/layout/padding-cal.ts","../node_modules/@antv/g2/src/chart/layout/auto.ts","../node_modules/@antv/g2/src/chart/util/sync-view-padding.ts","../node_modules/@antv/g2/src/chart/view.ts","../node_modules/@antv/g2/src/chart/chart.ts","../node_modules/@antv/g2/src/chart/controller/base.ts","../node_modules/@antv/g2/src/chart/controller/tooltip.ts","../node_modules/@antv/g2/src/animate/animation/index.ts","../node_modules/@antv/g2/src/animate/index.ts","../node_modules/@antv/g2/src/geometry/shape/constant.ts","../node_modules/@antv/g2/src/geometry/element/index.ts","../node_modules/@antv/g2/src/geometry/label/index.ts","../node_modules/@antv/g2/src/geometry/shape/base.ts","../node_modules/@antv/g2/src/geometry/util/is-model-change.ts","../node_modules/@antv/g2/src/geometry/util/parse-fields.ts","../node_modules/@antv/g2/src/geometry/util/diff.ts","../node_modules/@antv/g2/src/geometry/base.ts","../node_modules/@antv/g2/src/geometry/util/group-data.ts","../node_modules/@antv/g2/src/util/transform.ts","../node_modules/@antv/g2/src/geometry/label/util/index.ts","../node_modules/@antv/g2/src/component/update-label.ts","../node_modules/@antv/g2/src/component/labels.ts","../node_modules/@antv/g2/src/geometry/label/base.ts","../node_modules/@antv/g2/src/util/attr.ts","../node_modules/@antv/g2/src/util/marker.ts","../node_modules/@antv/g2/src/util/legend.ts","../node_modules/@antv/g2/src/geometry/shape/util/get-path-points.ts","../node_modules/@antv/g2/src/geometry/shape/util/get-style.ts","../node_modules/@antv/g2/src/geometry/shape/util/split-points.ts","../node_modules/@antv/g2/src/geometry/shape/line/util.ts","../node_modules/@antv/g2/src/geometry/shape/line/index.ts","../node_modules/@antv/g2/src/core.ts","../node_modules/@antv/g2/src/theme/style-sheet/dark.ts","../node_modules/@antv/g-canvas/src/util/util.ts","../node_modules/@antv/g-canvas/src/util/parse.ts","../node_modules/@antv/g-canvas/src/util/arc-params.ts","../node_modules/@antv/g-canvas/src/util/arrow.ts","../node_modules/@antv/g-canvas/src/util/draw.ts","../node_modules/@antv/g-canvas/src/group.ts","../node_modules/@antv/g-canvas/src/shape/base.ts","../node_modules/@antv/g-canvas/src/shape/circle.ts","../node_modules/@antv/g-canvas/src/shape/ellipse.ts","../node_modules/@antv/g-canvas/src/shape/image.ts","../node_modules/@antv/g-canvas/src/util/in-stroke/line.ts","../node_modules/@antv/g-canvas/src/shape/line.ts","../node_modules/@antv/g-canvas/node_modules/@antv/path-util/src/parse-path.ts","../node_modules/@antv/g-canvas/node_modules/@antv/path-util/src/parse-path-string.ts","../node_modules/@antv/g-canvas/node_modules/@antv/path-util/src/path-2-absolute.ts","../node_modules/@antv/g-canvas/node_modules/@antv/path-util/src/process/arc-2-cubic.ts","../node_modules/@antv/g-canvas/node_modules/@antv/path-util/src/get-arc-params.ts","../node_modules/@antv/g-canvas/node_modules/@antv/path-util/src/path-2-segments.ts","../node_modules/@antv/g-canvas/src/shape/marker.ts","../node_modules/@antv/g-canvas/src/util/in-path/point-in-path.ts","../node_modules/@antv/g-canvas/src/util/in-path/polygon.ts","../node_modules/@antv/g-canvas/src/util/in-stroke/arc.ts","../node_modules/@antv/g-canvas/src/util/path.ts","../node_modules/@antv/g-canvas/src/shape/path.ts","../node_modules/@antv/g-canvas/src/util/in-stroke/polyline.ts","../node_modules/@antv/g-canvas/src/shape/polygon.ts","../node_modules/@antv/g-canvas/src/shape/polyline.ts","../node_modules/@antv/g-canvas/src/shape/rect.ts","../node_modules/@antv/g-canvas/src/util/in-stroke/rect-radius.ts","../node_modules/@antv/g-canvas/src/util/in-stroke/rect.ts","../node_modules/@antv/g-canvas/src/shape/text.ts","../node_modules/@antv/g-canvas/src/util/hit.ts","../node_modules/@antv/g-canvas/src/canvas.ts","../node_modules/@antv/g-canvas/src/index.ts","../node_modules/@antv/g-svg/src/constant.ts","../node_modules/@antv/g-svg/src/util/dom.ts","../node_modules/@antv/g-svg/src/util/svg.ts","../node_modules/@antv/g-svg/src/util/draw.ts","../node_modules/@antv/g-svg/src/group.ts","../node_modules/@antv/g-svg/src/shape/base.ts","../node_modules/@antv/g-svg/src/shape/circle.ts","../node_modules/@antv/g-svg/src/shape/dom.ts","../node_modules/@antv/g-svg/src/shape/ellipse.ts","../node_modules/@antv/g-svg/src/shape/image.ts","../node_modules/@antv/g-svg/src/shape/line.ts","../node_modules/@antv/g-svg/src/shape/marker/symbols.ts","../node_modules/@antv/g-svg/src/shape/marker/index.ts","../node_modules/@antv/g-svg/src/shape/path.ts","../node_modules/@antv/g-svg/src/shape/polygon.ts","../node_modules/@antv/g-svg/src/shape/polyline.ts","../node_modules/@antv/g-svg/src/shape/rect.ts","../node_modules/@antv/g-svg/src/util/format.ts","../node_modules/@antv/g-svg/src/shape/text.ts","../node_modules/@antv/g-svg/src/defs/gradient.ts","../node_modules/@antv/g-svg/src/defs/shadow.ts","../node_modules/@antv/g-svg/src/defs/arrow.ts","../node_modules/@antv/g-svg/src/defs/clip.ts","../node_modules/@antv/g-svg/src/defs/pattern.ts","../node_modules/@antv/g-svg/src/defs/index.ts","../node_modules/@antv/g-svg/src/canvas.ts","../node_modules/@antv/g-svg/src/index.ts","../node_modules/@antv/g2/src/geometry/path.ts","../node_modules/@antv/g2/src/geometry/shape/area/util.ts","../node_modules/@antv/g2/src/geometry/shape/area/index.ts","../node_modules/@antv/g2/src/geometry/area.ts","../node_modules/@antv/g2/src/geometry/shape/edge/index.ts","../node_modules/@antv/g2/src/geometry/edge.ts","../node_modules/@antv/g2/src/geometry/heatmap.ts","../node_modules/@antv/g2/src/geometry/shape/interval/util.ts","../node_modules/@antv/g2/src/geometry/shape/interval/index.ts","../node_modules/@antv/g2/src/geometry/util/shape-size.ts","../node_modules/@antv/g2/src/geometry/interval.ts","../node_modules/@antv/g2/src/geometry/line.ts","../node_modules/@antv/g2/src/geometry/shape/point/util.ts","../node_modules/@antv/g2/src/geometry/shape/point/index.ts","../node_modules/@antv/g2/src/geometry/point.ts","../node_modules/@antv/g2/src/geometry/shape/polygon/index.ts","../node_modules/@antv/g2/src/geometry/polygon.ts","../node_modules/@antv/g2/src/geometry/schema.ts","../node_modules/@antv/g2/src/geometry/shape/schema/index.ts","../node_modules/@antv/g2/src/geometry/shape/violin/index.ts","../node_modules/@antv/g2/src/geometry/violin.ts","../node_modules/@antv/g2/src/geometry/shape/edge/util.ts","../node_modules/@antv/g2/src/geometry/shape/area/line.ts","../node_modules/@antv/g2/src/geometry/shape/area/smooth.ts","../node_modules/@antv/g2/src/geometry/shape/area/smooth-line.ts","../node_modules/@antv/g2/src/geometry/shape/edge/arc.ts","../node_modules/@antv/g2/src/geometry/shape/edge/smooth.ts","../node_modules/@antv/g2/src/geometry/shape/edge/vhv.ts","../node_modules/@antv/g2/src/geometry/shape/interval/funnel.ts","../node_modules/@antv/g2/src/geometry/shape/interval/hollow-rect.ts","../node_modules/@antv/g2/src/geometry/shape/interval/line.ts","../node_modules/@antv/g2/src/geometry/shape/interval/pyramid.ts","../node_modules/@antv/g2/src/geometry/shape/interval/tick.ts","../node_modules/@antv/g2/src/geometry/shape/line/step.ts","../node_modules/@antv/g2/src/geometry/shape/schema/box.ts","../node_modules/@antv/g2/src/geometry/shape/schema/candle.ts","../node_modules/@antv/g2/src/geometry/shape/polygon/square.ts","../node_modules/@antv/g2/src/geometry/shape/point/hollow.ts","../node_modules/@antv/g2/src/geometry/shape/point/image.ts","../node_modules/@antv/g2/src/geometry/shape/point/solid.ts","../node_modules/@antv/g2/src/geometry/shape/violin/smooth.ts","../node_modules/@antv/g2/src/geometry/shape/violin/hollow.ts","../node_modules/@antv/g2/src/geometry/label/interval.ts","../node_modules/@antv/g2/src/geometry/label/polar.ts","../node_modules/@antv/g2/src/geometry/label/pie.ts","../node_modules/@antv/g2/src/geometry/label/layout/pie/util.ts","../node_modules/@antv/g2/src/geometry/label/layout/pie/outer.ts","../node_modules/@antv/g2/src/geometry/label/layout/pie/spider.ts","../node_modules/@antv/g2/src/geometry/label/layout/overlap.ts","../node_modules/@antv/g2/src/util/collision-detect.ts","../node_modules/@antv/g2/src/geometry/label/util/createWorker.ts","../node_modules/@antv/g2/src/geometry/label/layout/worker/hide-overlap.ts","../node_modules/@antv/g2/src/geometry/label/layout/hide-overlap.ts","../node_modules/@antv/g2/src/util/color.ts","../node_modules/@antv/g2/src/util/context.ts","../node_modules/@antv/g2/src/geometry/label/layout/interval/adjust-position.ts","../node_modules/@antv/g2/src/geometry/label/layout/point/adjust-position.ts","../node_modules/@antv/g2/src/geometry/label/layout/path/adjust-position.ts","../node_modules/@antv/g2/src/util/text.ts","../node_modules/@antv/g2/src/animate/animation/util.ts","../node_modules/@antv/g2/src/animate/animation/sector-path-update.ts","../node_modules/@antv/g2/src/animate/animation/zoom.ts","../node_modules/@antv/g2/src/util/facet.ts","../node_modules/@antv/g2/src/facet/circle.ts","../node_modules/@antv/g2/src/facet/list.ts","../node_modules/@antv/g2/src/facet/matrix.ts","../node_modules/@antv/g2/src/facet/mirror.ts","../node_modules/@antv/g2/src/facet/rect.ts","../node_modules/@antv/g2/src/facet/tree.ts","../node_modules/@antv/g2/src/util/stat.ts","../node_modules/@antv/g2/src/util/annotation.ts","../node_modules/@antv/g2/src/chart/controller/annotation.ts","../node_modules/@antv/g2/src/util/grid.ts","../node_modules/@antv/g2/src/chart/controller/axis.ts","../node_modules/@antv/g2/src/util/direction.ts","../node_modules/@antv/g2/src/chart/controller/legend.ts","../node_modules/@antv/g2/src/chart/controller/slider.ts","../node_modules/@antv/g2/src/chart/controller/scrollbar.ts","../node_modules/@antv/g2/src/interaction/action/active-region.ts","../node_modules/@antv/g2/src/interaction/action/component/tooltip/geometry.ts","../node_modules/@antv/g2/src/interaction/action/component/tooltip/sibling.ts","../node_modules/@antv/g2/src/interaction/action/component/tooltip/ellipsis-text.ts","../node_modules/@antv/g2/src/interaction/action/element/state-base.ts","../node_modules/@antv/g2/src/interaction/action/element/state.ts","../node_modules/@antv/g2/src/interaction/action/element/active.ts","../node_modules/@antv/g2/src/interaction/action/element/link-by-color.ts","../node_modules/@antv/g2/src/interaction/action/element/range-state.ts","../node_modules/@antv/g2/src/interaction/action/element/range-active.ts","../node_modules/@antv/g2/src/interaction/action/element/single-state.ts","../node_modules/@antv/g2/src/interaction/action/element/single-active.ts","../node_modules/@antv/g2/src/interaction/action/element/highlight-util.ts","../node_modules/@antv/g2/src/interaction/action/element/highlight.ts","../node_modules/@antv/g2/src/interaction/action/element/range-highlight.ts","../node_modules/@antv/g2/src/interaction/action/element/highlight-by-color.ts","../node_modules/@antv/g2/src/interaction/action/element/highlight-by-x.ts","../node_modules/@antv/g2/src/interaction/action/element/single-highlight.ts","../node_modules/@antv/g2/src/interaction/action/element/range-selected.ts","../node_modules/@antv/g2/src/interaction/action/element/selected.ts","../node_modules/@antv/g2/src/interaction/action/element/single-selected.ts","../node_modules/@antv/g2/src/interaction/action/component/list-state.ts","../node_modules/@antv/g2/src/interaction/action/component/list-active.ts","../node_modules/@antv/g2/src/interaction/action/component/list-highlight-util.ts","../node_modules/@antv/g2/src/interaction/action/component/list-highlight.ts","../node_modules/@antv/g2/src/interaction/action/component/list-selected.ts","../node_modules/@antv/g2/src/interaction/action/component/list-unchecked.ts","../node_modules/@antv/g2/src/interaction/action/component/list-checked.ts","../node_modules/@antv/g2/src/interaction/action/component/list-focus.ts","../node_modules/@antv/g2/src/interaction/action/component/list-radio.ts","../node_modules/@antv/g2/src/interaction/action/mask/base.ts","../node_modules/@antv/g2/src/interaction/action/mask/circle.ts","../node_modules/@antv/g2/src/interaction/action/mask/rect.ts","../node_modules/@antv/g2/src/interaction/action/mask/dim-rect.ts","../node_modules/@antv/g2/src/interaction/action/mask/path.ts","../node_modules/@antv/g2/src/interaction/action/mask/smooth-path.ts","../node_modules/@antv/g2/src/interaction/action/data/range-filter.ts","../node_modules/@antv/g2/src/interaction/action/mask/multiple/base.ts","../node_modules/@antv/g2/src/interaction/action/mask/multiple/rect.ts","../node_modules/@antv/g2/src/interaction/action/mask/multiple/dim-rect.ts","../node_modules/@antv/g2/src/interaction/action/mask/multiple/circle.ts","../node_modules/@antv/g2/src/interaction/action/mask/multiple/path.ts","../node_modules/@antv/g2/src/interaction/action/mask/multiple/smooth-path.ts","../node_modules/@antv/g2/src/interaction/action/cursor.ts","../node_modules/@antv/g2/src/interaction/action/data/filter.ts","../node_modules/@antv/g2/src/interaction/action/data/sibling-filter.ts","../node_modules/@antv/g2/src/interaction/action/element/filter.ts","../node_modules/@antv/g2/src/interaction/action/element/sibling-filter.ts","../node_modules/@antv/g2/src/interaction/action/view/button.ts","../node_modules/@antv/g2/src/interaction/action/view/drag.ts","../node_modules/@antv/g2/src/interaction/action/view/move.ts","../node_modules/@antv/g2/src/interaction/action/view/scale-transform.ts","../node_modules/@antv/g2/src/interaction/action/view/scale-translate.ts","../node_modules/@antv/g2/src/interaction/action/view/scale-zoom.ts","../node_modules/@antv/g2/src/interaction/action/view/mousewheel-scroll.ts","../node_modules/@antv/g2/src/interaction/action/component/axis/axis-description.ts","../node_modules/@antv/g2/src/index.ts","../node_modules/@antv/g2/src/geometry/label/layout/pie/distribute.ts","../node_modules/@antv/g2/src/geometry/label/layout/limit-in-shape.ts","../node_modules/@antv/g2/src/geometry/label/layout/limit-in-canvas.ts","../node_modules/@antv/g2/src/geometry/label/layout/limit-in-plot.ts","../node_modules/@antv/g2/src/geometry/label/layout/adjust-color.ts","../node_modules/@antv/g2/src/geometry/label/layout/interval/hide-overlap.ts","../node_modules/@antv/g2/src/animate/animation/fade.ts","../node_modules/@antv/g2/src/animate/animation/grow-in.ts","../node_modules/@antv/g2/src/animate/animation/scale-in.ts","../node_modules/@antv/g2/src/animate/animation/wave-in.ts","../node_modules/@antv/g2/src/animate/animation/position-update.ts","../node_modules/@antv/g2/src/animate/animation/path-in.ts","../node_modules/@antv/g2plot/src/constant.ts","../node_modules/@antv/g2plot/src/utils/invariant.ts","../node_modules/@antv/g2plot/src/utils/pick.ts","../node_modules/@antv/g2plot/src/utils/data.ts","../node_modules/@antv/g2plot/src/utils/deep-assign.ts","../node_modules/@antv/g2plot/src/utils/context.ts","../node_modules/@antv/g2plot/src/utils/dom.ts","../node_modules/@antv/g2plot/src/utils/flow.ts","../node_modules/@antv/g2plot/src/utils/geometry.ts","../node_modules/@antv/g2plot/src/utils/label.ts","../node_modules/@antv/g2plot/src/utils/measure-text.ts","../node_modules/@antv/g2plot/src/utils/number.ts","../node_modules/@antv/g2plot/src/utils/padding.ts","../node_modules/@antv/g2plot/src/utils/path.ts","../node_modules/@antv/g2plot/src/utils/kebab-case.ts","../node_modules/@antv/g2plot/src/utils/statistic.ts","../node_modules/@antv/g2plot/src/utils/template.ts","../node_modules/@antv/g2plot/src/utils/view.ts","../node_modules/@antv/g2plot/src/utils/pattern/util.ts","../node_modules/@antv/g2plot/src/utils/pattern/dot.ts","../node_modules/@antv/g2plot/src/utils/pattern/line.ts","../node_modules/@antv/g2plot/src/utils/pattern/square.ts","../node_modules/@antv/g2plot/src/utils/pattern/index.ts","../node_modules/@antv/g2plot/src/adaptor/pattern.ts","../node_modules/@antv/g2plot/src/adaptor/common.ts","../node_modules/@antv/g2plot/src/core/global.ts","../node_modules/@antv/g2plot/src/core/locale.ts","../node_modules/@antv/g2plot/src/utils/tooltip.ts","../node_modules/@antv/g2plot/src/adaptor/geometries/base.ts","../node_modules/@antv/g2plot/src/adaptor/geometries/area.ts","../node_modules/@antv/g2plot/src/adaptor/geometries/edge.ts","../node_modules/@antv/g2plot/src/adaptor/geometries/interval.ts","../node_modules/@antv/g2plot/src/adaptor/geometries/line.ts","../node_modules/@antv/g2plot/src/adaptor/geometries/point.ts","../node_modules/@antv/g2plot/src/adaptor/geometries/polygon.ts","../node_modules/@antv/g2plot/src/adaptor/geometries/schema.ts","../node_modules/@antv/g2plot/src/core/plot.ts","../node_modules/@antv/g2plot/src/utils/transform/percent.ts","../node_modules/@antv/g2plot/src/plots/line/adaptor.ts","../node_modules/@antv/g2plot/src/plots/area/adaptor.ts","../node_modules/@antv/g2plot/src/plots/area/constants.ts","../node_modules/@antv/g2plot/src/plots/area/index.ts","../node_modules/@antv/g2plot/src/interactions/actions/reset-button.ts","../node_modules/@antv/g2plot/src/interactions/brush.ts","../node_modules/@antv/g2plot/src/adaptor/brush.ts","../node_modules/@antv/g2plot/src/adaptor/connected-area.ts","../node_modules/@antv/g2plot/src/utils/conversion.ts","../node_modules/@antv/g2plot/src/adaptor/conversion-tag.ts","../node_modules/@antv/g2plot/src/plots/column/adaptor.ts","../node_modules/@antv/g2plot/src/plots/bar/adaptor.ts","../node_modules/@antv/g2plot/src/plots/bar/constants.ts","../node_modules/@antv/g2plot/src/plots/bar/index.ts","../node_modules/@antv/g2plot/src/plots/column/constants.ts","../node_modules/@antv/g2plot/src/plots/column/index.ts","../node_modules/@antv/g2plot/src/plots/funnel/constant.ts","../node_modules/@antv/g2plot/src/plots/funnel/geometries/common.ts","../node_modules/@antv/g2plot/src/plots/funnel/geometries/basic.ts","../node_modules/@antv/g2plot/src/plots/funnel/geometries/compare.ts","../node_modules/@antv/g2plot/src/plots/funnel/geometries/dynamic-height.ts","../node_modules/@antv/g2plot/src/plots/funnel/geometries/facet.ts","../node_modules/@antv/g2plot/src/plots/funnel/interactions/funnel-conversion-tag.ts","../node_modules/@antv/g2plot/src/plots/funnel/interactions/index.ts","../node_modules/@antv/g2plot/src/plots/funnel/adaptor.ts","../node_modules/@antv/g2plot/src/plots/funnel/index.ts","../node_modules/@antv/g2plot/src/plots/gauge/constants.ts","../node_modules/@antv/g2plot/src/plots/gauge/utils.ts","../node_modules/@antv/g2plot/src/plots/gauge/adaptor.ts","../node_modules/@antv/g2plot/src/plots/gauge/shapes/indicator.ts","../node_modules/@antv/g2plot/src/plots/gauge/shapes/meter-gauge.ts","../node_modules/@antv/g2plot/src/plots/gauge/index.ts","../node_modules/@antv/g2plot/src/utils/transform/histogram.ts","../node_modules/@antv/g2plot/src/plots/histogram/constant.ts","../node_modules/@antv/g2plot/src/plots/histogram/adaptor.ts","../node_modules/@antv/g2plot/src/plots/histogram/index.ts","../node_modules/@antv/g2plot/src/plots/line/constants.ts","../node_modules/@antv/g2plot/src/plots/line/interactions/marker-active.ts","../node_modules/@antv/g2plot/src/plots/line/interactions/index.ts","../node_modules/@antv/g2plot/src/plots/line/index.ts","../node_modules/@antv/g2plot/src/plots/pie/contants.ts","../node_modules/@antv/g2plot/src/utils/matrix.ts","../node_modules/@antv/g2plot/src/plots/pie/interactions/actions/legend-active.ts","../node_modules/@antv/g2plot/src/plots/pie/interactions/actions/statistic-active.ts","../node_modules/@antv/g2plot/src/plots/pie/interactions/util.ts","../node_modules/@antv/g2plot/src/plots/pie/interactions/index.ts","../node_modules/@antv/g2plot/src/plots/pie/utils.ts","../node_modules/@antv/g2plot/src/plots/pie/adaptor.ts","../node_modules/@antv/g2plot/src/plots/pie/index.ts","../node_modules/@antv/g2plot/src/plots/progress/constants.ts","../node_modules/@antv/g2plot/src/plots/progress/utils.ts","../node_modules/@antv/g2plot/src/plots/progress/adaptor.ts","../node_modules/@antv/g2plot/src/plots/progress/index.ts","../node_modules/@antv/g2plot/src/plots/ring-progress/adaptor.ts","../node_modules/@antv/g2plot/src/plots/ring-progress/constants.ts","../node_modules/@antv/g2plot/src/plots/ring-progress/index.ts","../node_modules/@antv/g2plot/src/plots/scatter/util.ts","../node_modules/@antv/g2plot/src/plots/scatter/adaptor.ts","../node_modules/@antv/g2plot/src/plots/scatter/constant.ts","../node_modules/@antv/g2plot/src/interactions/drag-move.ts","../node_modules/@antv/g2plot/src/plots/scatter/index.ts","../node_modules/@antv/g2plot/src/plots/stock/constant.ts","../node_modules/@antv/g2plot/src/plots/stock/utils.ts","../node_modules/@antv/g2plot/src/plots/stock/adaptor.ts","../node_modules/@antv/g2plot/src/plots/stock/index.ts","../node_modules/@antv/g2plot/src/plots/tiny-line/utils.ts","../node_modules/@antv/g2plot/src/plots/tiny-line/constants.ts","../node_modules/@antv/g2plot/src/plots/tiny-area/adaptor.ts","../node_modules/@antv/g2plot/src/plots/tiny-area/constants.ts","../node_modules/@antv/g2plot/src/plots/tiny-area/index.ts","../node_modules/@antv/g2plot/src/plots/tiny-column/adaptor.ts","../node_modules/@antv/g2plot/src/plots/tiny-column/constants.ts","../node_modules/@antv/g2plot/src/plots/tiny-column/index.ts","../node_modules/@antv/g2plot/src/plots/tiny-line/adaptor.ts","../node_modules/@antv/g2plot/src/plots/tiny-line/index.ts","../node_modules/@antv/g2plot/src/plots/mix/utils.ts","../node_modules/@antv/g2plot/src/plots/mix/adaptor.ts","../node_modules/@antv/g2plot/src/plots/mix/interactions/association.ts","../node_modules/@antv/g2plot/src/plots/mix/interactions/utils.ts","../node_modules/@antv/g2plot/src/plots/mix/index.ts","../node_modules/@antv/g2plot/src/lab.ts","../node_modules/@antv/g2plot/src/plots/bidirectional-bar/constant.ts","../node_modules/@antv/g2plot/src/plots/bidirectional-bar/utils.ts","../node_modules/@antv/g2plot/src/plots/bidirectional-bar/adaptor.ts","../node_modules/@antv/g2plot/src/plots/bidirectional-bar/index.ts","../node_modules/@antv/g2plot/src/plots/box/constant.ts","../node_modules/@antv/g2plot/src/plots/box/utils.ts","../node_modules/@antv/g2plot/src/plots/box/adaptor.ts","../node_modules/@antv/g2plot/src/plots/box/index.ts","../node_modules/@antv/g2plot/src/plots/bullet/utils.ts","../node_modules/@antv/g2plot/src/plots/bullet/adaptor.ts","../node_modules/@antv/g2plot/src/plots/bullet/constant.ts","../node_modules/@antv/g2plot/src/utils/transform/chord.ts","../node_modules/@antv/g2plot/src/plots/bullet/index.ts","../node_modules/@antv/g2plot/src/plots/chord/constant.ts","../node_modules/@antv/g2plot/src/plots/chord/adaptor.ts","../node_modules/@antv/g2plot/src/plots/chord/index.ts","../node_modules/@antv/g2plot/src/plots/circle-packing/constant.ts","../node_modules/@antv/g2plot/src/interactions/actions/drill-down.ts","../node_modules/d3-hierarchy/src/pack/enclose.js","../node_modules/d3-hierarchy/src/array.js","../node_modules/d3-hierarchy/src/pack/siblings.js","../node_modules/d3-hierarchy/src/accessors.js","../node_modules/d3-hierarchy/src/constant.js","../node_modules/d3-hierarchy/src/pack/index.js","../node_modules/d3-hierarchy/src/hierarchy/count.js","../node_modules/d3-hierarchy/src/hierarchy/iterator.js","../node_modules/d3-hierarchy/src/hierarchy/index.js","../node_modules/d3-hierarchy/src/hierarchy/each.js","../node_modules/d3-hierarchy/src/hierarchy/eachAfter.js","../node_modules/d3-hierarchy/src/hierarchy/eachBefore.js","../node_modules/d3-hierarchy/src/hierarchy/find.js","../node_modules/d3-hierarchy/src/hierarchy/sum.js","../node_modules/d3-hierarchy/src/hierarchy/sort.js","../node_modules/d3-hierarchy/src/hierarchy/path.js","../node_modules/d3-hierarchy/src/hierarchy/ancestors.js","../node_modules/d3-hierarchy/src/hierarchy/descendants.js","../node_modules/d3-hierarchy/src/hierarchy/leaves.js","../node_modules/d3-hierarchy/src/hierarchy/links.js","../node_modules/@antv/g2plot/src/utils/hierarchy/util.ts","../node_modules/@antv/g2plot/src/utils/hierarchy/pack.ts","../node_modules/@antv/g2plot/src/plots/circle-packing/utils.ts","../node_modules/@antv/g2plot/src/plots/circle-packing/adaptor.ts","../node_modules/@antv/g2plot/src/interactions/drill-down.ts","../node_modules/@antv/g2plot/src/plots/circle-packing/index.ts","../node_modules/@antv/g2plot/src/plots/dual-axes/types.ts","../node_modules/@antv/g2plot/src/plots/dual-axes/constant.ts","../node_modules/@antv/g2plot/src/plots/dual-axes/util/option.ts","../node_modules/@antv/g2plot/src/plots/dual-axes/util/legend.ts","../node_modules/@antv/g2plot/src/plots/dual-axes/util/render-sider.ts","../node_modules/@antv/g2plot/src/plots/dual-axes/adaptor.ts","../node_modules/@antv/g2plot/src/plots/dual-axes/util/geometry.ts","../node_modules/@antv/g2plot/src/plots/dual-axes/index.ts","../node_modules/@antv/g2plot/src/plots/facet/adaptor.ts","../node_modules/@antv/g2plot/src/plots/facet/utils.ts","../node_modules/@antv/g2plot/src/plots/facet/constant.ts","../node_modules/@antv/g2plot/src/plots/facet/index.ts","../node_modules/@antv/g2plot/src/plots/heatmap/adaptor.ts","../node_modules/@antv/g2plot/src/plots/heatmap/constant.ts","../node_modules/@antv/g2plot/src/plots/heatmap/shapes/circle.ts","../node_modules/@antv/g2plot/src/plots/heatmap/shapes/square.ts","../node_modules/@antv/g2plot/src/plots/heatmap/index.ts","../node_modules/@antv/g2plot/src/plots/liquid/utils.ts","../node_modules/@antv/g2plot/src/plots/liquid/adaptor.ts","../node_modules/@antv/g2plot/src/plots/liquid/constants.ts","../node_modules/@antv/g2plot/src/plots/liquid/shapes/liquid.ts","../node_modules/@antv/g2plot/src/plots/liquid/index.ts","../node_modules/@antv/g2plot/src/plots/radar/adaptor.ts","../node_modules/@antv/g2plot/src/plots/radar/interactions/radar-tooltip-action.ts","../node_modules/@antv/g2plot/src/plots/radar/interactions/index.ts","../node_modules/@antv/g2plot/src/plots/radar/index.ts","../node_modules/@antv/g2plot/src/plots/radial-bar/utils.ts","../node_modules/@antv/g2plot/src/plots/radial-bar/adaptor.ts","../node_modules/@antv/g2plot/src/plots/radial-bar/constant.ts","../node_modules/@antv/g2plot/src/plots/radial-bar/index.ts","../node_modules/@antv/g2plot/src/plots/rose/adaptor.ts","../node_modules/@antv/g2plot/src/plots/rose/constant.ts","../node_modules/@antv/g2plot/src/plots/sankey/constant.ts","../node_modules/@antv/g2plot/src/plots/rose/index.ts","../node_modules/@antv/g2plot/src/plots/sankey/circle.ts","../node_modules/@antv/g2plot/src/plots/sankey/sankey/align.ts","../node_modules/@antv/g2plot/src/plots/sankey/sankey/helper.ts","../node_modules/@antv/g2plot/src/plots/sankey/sankey/sankey.ts","../node_modules/@antv/g2plot/src/plots/sankey/layout.ts","../node_modules/@antv/g2plot/src/plots/sankey/helper.ts","../node_modules/@antv/g2plot/src/plots/sankey/adaptor.ts","../node_modules/@antv/g2plot/src/plots/sankey/interactions/actions/node-drag.ts","../node_modules/@antv/g2plot/src/plots/sankey/interactions/node-draggable.ts","../node_modules/@antv/g2plot/src/plots/sankey/index.ts","../node_modules/@antv/g2plot/src/plots/sunburst/constant.ts","../node_modules/d3-hierarchy/src/treemap/round.js","../node_modules/d3-hierarchy/src/treemap/dice.js","../node_modules/d3-hierarchy/src/partition.js","../node_modules/@antv/g2plot/src/utils/hierarchy/partition.ts","../node_modules/d3-hierarchy/src/cluster.js","../node_modules/d3-hierarchy/src/stratify.js","../node_modules/d3-hierarchy/src/tree.js","../node_modules/d3-hierarchy/src/treemap/slice.js","../node_modules/d3-hierarchy/src/treemap/squarify.js","../node_modules/d3-hierarchy/src/treemap/index.js","../node_modules/d3-hierarchy/src/treemap/binary.js","../node_modules/d3-hierarchy/src/treemap/sliceDice.js","../node_modules/d3-hierarchy/src/treemap/resquarify.js","../node_modules/@antv/g2plot/src/utils/hierarchy/treemap.ts","../node_modules/@antv/g2plot/src/plots/sunburst/utils.ts","../node_modules/@antv/g2plot/src/plots/sunburst/adaptor.ts","../node_modules/@antv/g2plot/src/plots/sunburst/index.ts","../node_modules/@antv/g2plot/src/plots/treemap/utils.ts","../node_modules/@antv/g2plot/src/plots/treemap/adaptor.ts","../node_modules/@antv/g2plot/src/plots/treemap/constant.ts","../node_modules/@antv/g2plot/src/plots/venn/constant.ts","../node_modules/@antv/g2plot/src/plots/treemap/index.ts","../node_modules/@antv/g2plot/src/plots/venn/interactions/util.ts","../node_modules/@antv/g2plot/src/plots/venn/interactions/actions/active.ts","../node_modules/@antv/g2plot/src/plots/venn/interactions/actions/highlight.ts","../node_modules/@antv/g2plot/src/plots/venn/interactions/actions/selected.ts","../node_modules/@antv/g2plot/src/plots/venn/interactions/index.ts","../node_modules/@antv/g2plot/src/plots/venn/label.ts","../node_modules/lodash-es/isArray.js","../node_modules/@antv/path-util/src/parse-path-string.ts","../node_modules/@antv/path-util/src/process/arc-2-cubic.ts","../node_modules/@antv/g2plot/src/plots/venn/shape.ts","../node_modules/@antv/g2plot/src/utils/color/blend.ts","../node_modules/@antv/g2plot/src/plots/venn/layout/circleintersection.ts","../node_modules/@antv/g2plot/src/plots/venn/layout/diagram.ts","../node_modules/@antv/g2plot/src/plots/venn/layout/layout.ts","../node_modules/@antv/g2plot/src/plots/venn/utils.ts","../node_modules/@antv/g2plot/src/plots/venn/adaptor.ts","../node_modules/@antv/g2plot/src/plots/venn/index.ts","../node_modules/@antv/g2plot/src/plots/violin/constant.ts","../node_modules/@antv/g2plot/src/utils/transform/quantile.ts","../node_modules/@antv/g2plot/src/plots/violin/utils.ts","../node_modules/@antv/g2plot/src/plots/violin/adaptor.ts","../node_modules/@antv/g2plot/src/adaptor/geometries/violin.ts","../node_modules/@antv/g2plot/src/plots/violin/index.ts","../node_modules/@antv/g2plot/src/plots/waterfall/constant.ts","../node_modules/@antv/g2plot/src/plots/waterfall/utils.ts","../node_modules/@antv/g2plot/src/plots/waterfall/adaptor.ts","../node_modules/@antv/g2plot/src/plots/waterfall/shape.ts","../node_modules/@antv/g2plot/src/plots/waterfall/index.ts","../node_modules/@antv/g2plot/src/plots/word-cloud/constant.ts","../node_modules/@antv/g2plot/src/utils/transform/word-cloud.ts","../node_modules/@antv/g2plot/src/plots/word-cloud/utils.ts","../node_modules/@antv/g2plot/src/plots/word-cloud/adaptor.ts","../node_modules/@antv/g2plot/src/plots/word-cloud/shapes/word-cloud.ts","../node_modules/@antv/g2plot/src/plots/word-cloud/index.ts","../node_modules/@antv/g2plot/src/plugin/index.ts","../node_modules/@antv/g2plot/src/index.ts","../node_modules/@antv/g2plot/src/locales/en_US.ts","../node_modules/@antv/g2plot/src/locales/zh_CN.ts","../node_modules/@ant-design/plots/es/utils/render.js","../node_modules/@ant-design/plots/es/utils/createNode.js","../node_modules/@ant-design/plots/es/utils/utils.js","../node_modules/@ant-design/plots/es/hooks/useChart.js","../node_modules/@ant-design/plots/es/utils/getChart.js","../node_modules/@ant-design/plots/es/errorBoundary/index.js","../node_modules/react-content-loader/src/shared/uid.ts","../node_modules/react-content-loader/src/web/Svg.tsx","../node_modules/react-content-loader/src/web/ContentLoader.tsx","../node_modules/react-content-loader/src/web/presets/FacebookStyle.tsx","../node_modules/@ant-design/plots/es/utils/createLoading.js","../node_modules/@ant-design/plots/es/components/column/index.js","../node_modules/@ant-design/plots/es/components/pie/index.js","../node_modules/@ant-design/icons/es/icons/ClockCircleOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/ExclamationCircleOutlined.js","../node_modules/@ant-design/icons/es/icons/ExclamationCircleOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/SolutionOutlined.js","../node_modules/@ant-design/icons/es/icons/SolutionOutlined.js","../node_modules/@ant-design/icons/es/icons/ExclamationCircleFilled.js","../node_modules/antd/es/statistic/Number.js","../node_modules/antd/es/statistic/style/index.js","../node_modules/antd/es/statistic/Statistic.js","../node_modules/antd/es/statistic/utils.js","../node_modules/antd/es/statistic/Countdown.js","../node_modules/antd/es/statistic/index.js","webpack://condo-web/./src/lib/Indicator/Indicator.module.scss?f905","lib/Indicator/Indicator.tsx","services/Dashboard.service.ts","lib/providers/DashboardContextProvider.tsx","pages/dashboard/Dashboard.page.tsx","services/Employee.service.ts","lib/providers/EmployeeContextProvider.tsx","components/Employee/CreateEmployeeModal.tsx","../node_modules/@ant-design/icons/es/icons/CheckCircleFilled.js","lib/helpers/Employe.helper.ts","components/Employee/DetailEmployeeVacationTimeModal.tsx","components/Employee/EmployeeFilterBar.tsx","components/Employee/EmployeeActionsCell.tsx","pages/employee/Columns.tsx","pages/employee/Employee.page.tsx","services/GeneralMeeting.service.ts","components/GeneralMeeting/AnswerGeneralMeetingForm.tsx","pages/general_meeting/[id]/external/ExternalGeneralMeeting.tsx","../node_modules/@ant-design/icons/es/icons/CloseOutlined.js","lib/providers/GeneralMeetingContextProvider.tsx","components/GeneralMeeting/CreateGeneralMeetingModal.tsx","components/GeneralMeeting/DuplicateGeneralMeetingModal.tsx","components/GeneralMeeting/EditGeneralMeetingModal.tsx","../node_modules/@ant-design/icons-svg/es/asn/StopOutlined.js","../node_modules/@ant-design/icons/es/icons/StopOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/SendOutlined.js","../node_modules/@ant-design/icons/es/icons/SendOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/PieChartOutlined.js","../node_modules/@ant-design/icons/es/icons/PieChartOutlined.js","../node_modules/@ant-design/icons/es/icons/CopyOutlined.js","pages/general_meeting/Columns.tsx","pages/general_meeting/GeneralMeeting.page.tsx","pages/general_meeting/GeneralMeetingReport.page.tsx","components/Invite/ExpiredInvite.tsx","../node_modules/rc-steps/es/Step.js","../node_modules/rc-steps/es/Steps.js","../node_modules/rc-steps/es/index.js","../node_modules/antd/es/steps/style/custom-icon.js","../node_modules/antd/es/steps/style/horizontal.js","../node_modules/antd/es/steps/style/inline.js","../node_modules/antd/es/steps/style/label-placement.js","../node_modules/antd/es/steps/style/nav.js","../node_modules/antd/es/steps/style/progress.js","../node_modules/antd/es/steps/style/progress-dot.js","../node_modules/antd/es/steps/style/rtl.js","../node_modules/antd/es/steps/style/small.js","../node_modules/antd/es/steps/style/vertical.js","../node_modules/antd/es/steps/style/index.js","../node_modules/antd/es/steps/index.js","../node_modules/antd/es/steps/useLegacyItems.js","lib/errors/UnexpectedTypeError.ts","../node_modules/antd/es/descriptions/constant.js","../node_modules/antd/es/descriptions/DescriptionsContext.js","../node_modules/antd/es/descriptions/hooks/useItems.js","../node_modules/antd/es/descriptions/hooks/useRow.js","../node_modules/antd/es/descriptions/Item.js","../node_modules/antd/es/descriptions/Cell.js","../node_modules/antd/es/descriptions/Row.js","../node_modules/antd/es/descriptions/style/index.js","../node_modules/antd/es/descriptions/index.js","components/Invite/SignUp/SignUpInviteDetails.tsx","../node_modules/@ant-design/icons-svg/es/asn/AuditOutlined.js","../node_modules/@ant-design/icons/es/icons/AuditOutlined.js","components/Invite/SignUp/SignUpInviteTitle.tsx","../node_modules/@ant-design/icons/es/icons/SearchOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/FileProtectOutlined.js","../node_modules/@ant-design/icons/es/icons/FileProtectOutlined.js","lib/CpfField.tsx","lib/smoothLoading.ts","services/Guest.service.ts","components/Invite/SignUp/Steps/InfoStep.tsx","components/Invite/SignUp/Steps/SignedUpStep.tsx","services/Invite.service.ts","components/Invite/SignUp/Steps/SignUpStep.tsx","components/Invite/SignUp/SignUpInvite.tsx","components/Invite/SignUp/Steps/useSteps.ts","components/Invite/SignUpLimitReachedInvite.tsx","lib/LoadingPage.tsx","pages/invite/Invite.page.tsx","../node_modules/@ant-design/icons-svg/es/asn/EditTwoTone.js","../node_modules/@ant-design/icons/es/icons/EditTwoTone.js","../node_modules/@ant-design/icons-svg/es/asn/CaretRightOutlined.js","../node_modules/@ant-design/icons/es/icons/CaretRightOutlined.js","lib/DynamicSelect.tsx","components/Issue/CreateChecklistModal.tsx","components/Issue/EditChecklistModal.tsx","components/Issue/CreateIssueModal.tsx","../node_modules/antd/es/timeline/style/index.js","../node_modules/antd/es/timeline/TimelineItem.js","../node_modules/antd/es/timeline/TimelineItemList.js","../node_modules/antd/es/timeline/useItems.js","../node_modules/antd/es/timeline/Timeline.js","../node_modules/antd/es/timeline/index.js","../node_modules/@ant-design/icons/es/icons/UpOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/EyeTwoTone.js","../node_modules/@ant-design/icons/es/icons/EyeTwoTone.js","../node_modules/@ant-design/icons-svg/es/asn/MailOutlined.js","../node_modules/@ant-design/icons/es/icons/MailOutlined.js","../node_modules/@ant-design/icons/es/icons/CheckOutlined.js","lib/helpers/Issue.helper.ts","../node_modules/@ant-design/icons-svg/es/asn/RetweetOutlined.js","../node_modules/@ant-design/icons/es/icons/RetweetOutlined.js","../node_modules/@ant-design/icons/es/icons/ReloadOutlined.js","services/contracts/Issue.contract.ts","pages/issue/Columns.tsx","components/Issue/FinishCheckboxModal.tsx","components/Issue/ViewTasksDisapprovedModal.tsx","components/Issue/FinishIssueFormModal.tsx","components/Issue/FollowUpCreateModal.tsx","../node_modules/rc-drawer/es/context.js","../node_modules/rc-drawer/es/DrawerPanel.js","../node_modules/rc-drawer/es/util.js","../node_modules/rc-drawer/es/DrawerPopup.js","../node_modules/rc-drawer/es/Drawer.js","../node_modules/rc-drawer/es/index.js","../node_modules/antd/es/drawer/DrawerPanel.js","../node_modules/antd/es/drawer/style/motion.js","../node_modules/antd/es/drawer/style/index.js","../node_modules/antd/es/drawer/index.js","components/Issue/ViewTaskModal.tsx","components/Issue/DetailIssueModal.tsx","components/Issue/DuplicateIssueModal.tsx","components/Issue/EditIssueModal.tsx","../node_modules/@ant-design/icons-svg/es/asn/CloudDownloadOutlined.js","../node_modules/@ant-design/icons/es/icons/CloudDownloadOutlined.js","services/contracts/File.contract.ts","components/Issue/Excel.ts","components/Issue/ReportIssueModal.tsx","pages/issue/Issue.page.tsx","services/Maintenance.service.ts","lib/providers/MaintenanceContextProvider.tsx","components/Maintenance/CreateMaintenanceModal.tsx","services/Overview.service.ts","lib/providers/OverviewContextProvider.tsx","components/Overview/PendingMaintenancesCard.tsx","components/Maintenance/DetailMaintenanceModal.tsx","components/Maintenance/EditMaintenanceModal.tsx","components/Maintenance/FinishMaintenanceModal.tsx","../node_modules/@react-pdf/primitives/src/index.js","../node_modules/restructure/src/DecodeStream.js","../node_modules/restructure/src/EncodeStream.js","../node_modules/restructure/src/Base.js","../node_modules/restructure/src/Number.js","../node_modules/restructure/src/utils.js","../node_modules/restructure/src/Array.js","../node_modules/restructure/src/LazyArray.js","../node_modules/restructure/src/Bitfield.js","../node_modules/restructure/src/Buffer.js","../node_modules/restructure/src/Optional.js","../node_modules/restructure/src/Reserved.js","../node_modules/restructure/src/String.js","../node_modules/restructure/src/Struct.js","../node_modules/restructure/src/VersionedStruct.js","../node_modules/restructure/src/Pointer.js","../node_modules/@swc/helpers/esm/_define_property.js","../node_modules/unicode-properties/dist/data.json","../node_modules/unicode-properties/dist/index.js","../node_modules/fontkit/dist/src/base.js","../node_modules/fontkit/dist/src/decorators.js","../node_modules/fontkit/dist/src/tables/cmap.js","../node_modules/fontkit/dist/src/tables/head.js","../node_modules/fontkit/dist/src/tables/hhea.js","../node_modules/fontkit/dist/src/tables/hmtx.js","../node_modules/fontkit/dist/src/tables/maxp.js","../node_modules/fontkit/dist/src/encodings.js","../node_modules/fontkit/dist/src/tables/name.js","../node_modules/fontkit/dist/src/tables/OS2.js","../node_modules/fontkit/dist/src/tables/post.js","../node_modules/fontkit/dist/src/tables/cvt.js","../node_modules/fontkit/dist/src/tables/fpgm.js","../node_modules/fontkit/dist/src/tables/loca.js","../node_modules/fontkit/dist/src/tables/prep.js","../node_modules/fontkit/dist/src/tables/glyf.js","../node_modules/fontkit/dist/src/cff/CFFIndex.js","../node_modules/fontkit/dist/src/cff/CFFOperand.js","../node_modules/fontkit/dist/src/cff/CFFDict.js","../node_modules/fontkit/dist/src/cff/CFFPointer.js","../node_modules/fontkit/dist/src/cff/CFFPrivateDict.js","../node_modules/fontkit/dist/src/cff/CFFStandardStrings.js","../node_modules/fontkit/dist/src/cff/CFFEncodings.js","../node_modules/fontkit/dist/src/cff/CFFCharsets.js","../node_modules/fontkit/dist/src/tables/opentype.js","../node_modules/fontkit/dist/src/tables/variations.js","../node_modules/fontkit/dist/src/cff/CFFTop.js","../node_modules/fontkit/dist/src/cff/CFFFont.js","../node_modules/fontkit/dist/src/tables/VORG.js","../node_modules/fontkit/dist/src/tables/EBDT.js","../node_modules/fontkit/dist/src/tables/EBLC.js","../node_modules/fontkit/dist/src/tables/sbix.js","../node_modules/fontkit/dist/src/tables/COLR.js","../node_modules/fontkit/dist/src/tables/CPAL.js","../node_modules/fontkit/dist/src/tables/BASE.js","../node_modules/fontkit/dist/src/tables/GDEF.js","../node_modules/fontkit/dist/src/tables/GPOS.js","../node_modules/fontkit/dist/src/tables/GSUB.js","../node_modules/fontkit/dist/src/tables/JSTF.js","../node_modules/fontkit/dist/src/tables/HVAR.js","../node_modules/fontkit/dist/src/tables/DSIG.js","../node_modules/fontkit/dist/src/tables/gasp.js","../node_modules/fontkit/dist/src/tables/hdmx.js","../node_modules/fontkit/dist/src/tables/kern.js","../node_modules/fontkit/dist/src/tables/LTSH.js","../node_modules/fontkit/dist/src/tables/PCLT.js","../node_modules/fontkit/dist/src/tables/VDMX.js","../node_modules/fontkit/dist/src/tables/vhea.js","../node_modules/fontkit/dist/src/tables/vmtx.js","../node_modules/fontkit/dist/src/tables/avar.js","../node_modules/fontkit/dist/src/tables/aat.js","../node_modules/fontkit/dist/src/tables/bsln.js","../node_modules/fontkit/dist/src/tables/feat.js","../node_modules/fontkit/dist/src/tables/fvar.js","../node_modules/fontkit/dist/src/tables/gvar.js","../node_modules/fontkit/dist/src/tables/just.js","../node_modules/fontkit/dist/src/tables/morx.js","../node_modules/fontkit/dist/src/tables/opbd.js","../node_modules/fontkit/dist/src/tables/index.js","../node_modules/fontkit/dist/src/tables/directory.js","../node_modules/fontkit/dist/src/utils.js","../node_modules/fontkit/dist/src/CmapProcessor.js","../node_modules/fontkit/dist/src/layout/KernProcessor.js","../node_modules/fontkit/dist/src/layout/UnicodeLayoutEngine.js","../node_modules/fontkit/dist/src/glyph/BBox.js","../node_modules/fontkit/dist/src/layout/Script.js","../node_modules/fontkit/dist/src/aat/AATFeatureMap.js","../node_modules/fontkit/dist/src/layout/GlyphRun.js","../node_modules/fontkit/dist/src/layout/GlyphPosition.js","../node_modules/fontkit/dist/src/aat/AATLookupTable.js","../node_modules/fontkit/dist/src/aat/AATStateMachine.js","../node_modules/fontkit/dist/src/aat/AATMorxProcessor.js","../node_modules/fontkit/dist/src/aat/AATLayoutEngine.js","../node_modules/fontkit/dist/src/opentype/ShapingPlan.js","../node_modules/fontkit/dist/src/opentype/shapers/DefaultShaper.js","../node_modules/fontkit/dist/src/opentype/shapers/ArabicShaper.js","../node_modules/fontkit/dist/src/opentype/GlyphIterator.js","../node_modules/fontkit/dist/src/opentype/OTProcessor.js","../node_modules/fontkit/dist/src/opentype/GlyphInfo.js","../node_modules/fontkit/dist/src/opentype/shapers/HangulShaper.js","../node_modules/fontkit/dist/src/opentype/shapers/indic.json","../node_modules/fontkit/dist/src/opentype/shapers/use.json","../node_modules/fontkit/dist/src/opentype/shapers/indic-data.js","../node_modules/fontkit/dist/src/opentype/shapers/IndicShaper.js","../node_modules/fontkit/dist/src/opentype/shapers/UniversalShaper.js","../node_modules/fontkit/dist/src/opentype/shapers/index.js","../node_modules/fontkit/dist/src/glyph/Path.js","../node_modules/fontkit/dist/src/opentype/GSUBProcessor.js","../node_modules/fontkit/dist/src/opentype/GPOSProcessor.js","../node_modules/fontkit/dist/src/opentype/OTLayoutEngine.js","../node_modules/fontkit/dist/src/layout/LayoutEngine.js","../node_modules/fontkit/dist/src/glyph/StandardNames.js","../node_modules/fontkit/dist/src/glyph/Glyph.js","../node_modules/fontkit/dist/src/glyph/TTFGlyph.js","../node_modules/fontkit/dist/src/glyph/CFFGlyph.js","../node_modules/fontkit/dist/src/glyph/SBIXGlyph.js","../node_modules/fontkit/dist/src/glyph/COLRGlyph.js","../node_modules/fontkit/dist/src/glyph/GlyphVariationProcessor.js","../node_modules/fontkit/dist/src/subset/Subset.js","../node_modules/fontkit/dist/src/glyph/TTFGlyphEncoder.js","../node_modules/fontkit/dist/src/subset/TTFSubset.js","../node_modules/fontkit/dist/src/subset/CFFSubset.js","../node_modules/fontkit/dist/src/TTFFont.js","../node_modules/fontkit/dist/src/tables/WOFFDirectory.js","../node_modules/fontkit/dist/src/WOFFFont.js","../node_modules/fontkit/dist/src/glyph/WOFF2Glyph.js","../node_modules/fontkit/dist/src/tables/WOFF2Directory.js","../node_modules/fontkit/dist/src/WOFF2Font.js","../node_modules/fontkit/dist/src/TrueTypeCollection.js","../node_modules/fontkit/dist/src/DFont.js","../node_modules/fontkit/dist/src/index.js","../node_modules/@react-pdf/font/lib/index.browser.es.js","../node_modules/@react-pdf/fns/lib/index.es.js","../node_modules/svg-arc-to-cubic-bezier/modules/index.js","../node_modules/normalize-svg-path/index.mjs","../node_modules/@react-pdf/render/lib/index.es.js","../node_modules/@babel/runtime/helpers/esm/createForOfIteratorHelperLoose.js","../node_modules/@react-pdf/png-js/lib/png-js.browser.es.js","../node_modules/@react-pdf/pdfkit/lib/pdfkit.browser.es.js","../node_modules/@react-pdf/stylesheet/lib/index.es.js","../node_modules/@react-pdf/textkit/lib/textkit.es.js","../node_modules/@react-pdf/image/lib/index.browser.es.js","../node_modules/@react-pdf/yoga/dist/index.esm.js","../node_modules/@react-pdf/layout/lib/index.es.js","../node_modules/emoji-regex/index.mjs","../node_modules/node_modules/react-reconciler/cjs/react-reconciler.production.min.js","../node_modules/@react-pdf/renderer/src/index.js","../node_modules/@react-pdf/renderer/src/utils/propsEqual.js","../node_modules/@react-pdf/renderer/src/renderer.js","../node_modules/@react-pdf/renderer/src/dom/usePDF.js","../node_modules/@react-pdf/renderer/src/dom/PDFViewer.js","../node_modules/@react-pdf/renderer/src/dom/index.js","../node_modules/@react-pdf/renderer/src/dom/BlobProvider.js","../node_modules/@react-pdf/renderer/src/dom/PDFDownloadLink.js","components/Maintenance/PDF.tsx","components/Maintenance/ReportMaintenanceModal.tsx","../node_modules/@ant-design/icons/es/icons/EyeOutlined.js","pages/maintenance/Columns.tsx","pages/maintenance/Filters.tsx","pages/maintenance/Maintenance.page.tsx","pages/morador/recuperar-senha/RecoverResidentPassword.page.tsx","services/External.service.ts","services/Notice.service.ts","lib/providers/NoticeContextProvider.tsx","components/Notice/SchedulesField.tsx","services/TowerService.ts","components/Notice/useNoticeOptions.ts","components/Notice/CreateNoticeModal.tsx","components/Notice/EditNoticeModal.tsx","components/Notice/NoticeActionsCell.tsx","pages/notice/Columns.tsx","pages/notice/Notices.page.tsx","services/Document.service.ts","lib/providers/DocumentContextProvider.tsx","components/Document/CreateDocumentModal.tsx","components/Document/DocumentsFilterBar.tsx","components/Document/EditDocumentModal.tsx","components/Document/DocumentActionsCell.tsx","pages/overview/document/Columns.tsx","pages/overview/document/Documents.page.tsx","services/Stats.service.ts","lib/providers/StatsContextProvider.tsx","components/Stats/ChartIssuesByType.tsx","../node_modules/@ant-design/plots/es/components/bar/index.js","components/Stats/ChartIssuesClosedBySupplier.tsx","components/Stats/ChartIssuesClosedByUser.tsx","components/Stats/ChartIssuesPerClient.tsx","components/Stats/ChartIssuesPerMonthAndYear.tsx","../node_modules/@ant-design/icons-svg/es/asn/StarFilled.js","../node_modules/@ant-design/icons/es/icons/StarFilled.js","components/Stats/IssueChampionUser.tsx","../node_modules/@ant-design/icons/es/icons/FilterFilled.js","pages/overview/issue/stats/Filters.tsx","pages/overview/issue/stats/Stats.page.tsx","../node_modules/@ant-design/icons-svg/es/asn/HistoryOutlined.js","../node_modules/@ant-design/icons/es/icons/HistoryOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/SyncOutlined.js","../node_modules/@ant-design/icons/es/icons/SyncOutlined.js","../node_modules/@ant-design/icons/es/icons/FileOutlined.js","components/CobreFacil/PendingInvoicesModal.tsx","components/Document/ListDocumentModal.tsx","lib/compareDates.ts","components/Issue/ListIssueModal.tsx","services/CobreFacil.service.ts","pages/overview/Overview.page.tsx","pages/password/ResetPasswordByEmail.page.tsx","../node_modules/@ant-design/icons-svg/es/asn/InfoCircleOutlined.js","../node_modules/@ant-design/icons/es/icons/InfoCircleOutlined.js","services/Payment.service.ts","lib/providers/PaymentContextProvider.tsx","components/Overview/CreatePaymentModal.tsx","components/Overview/EditPaymentModal.tsx","components/Overview/PaymentMadeModal.tsx","../node_modules/@ant-design/icons-svg/es/asn/AlertOutlined.js","../node_modules/@ant-design/icons/es/icons/AlertOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/DollarOutlined.js","../node_modules/@ant-design/icons/es/icons/DollarOutlined.js","pages/payment/Columns.tsx","components/Overview/PaymentsExcel.ts","components/Overview/PaymentsFilterBar.tsx","components/Overview/ViewPaymentModal.tsx","pages/payment/Payments.page.tsx","components/_Common/_Layout/Secondary/SecondaryHeader.tsx","lib/providers/ReportContextProvider.tsx","components/Report/CustomCard.tsx","components/Report/ModelCard.tsx","pages/report/Report.page.tsx","lib/helpers/Schedule.helper.ts","services/Schedule.service.ts","lib/providers/ScheduleContextProvider.tsx","components/Schedule/ScheduleCalendar.tsx","pages/schedule/Columns.tsx","components/Schedule/TodaySchedule.tsx","pages/schedule/Schedule.page.tsx","services/ServiceBudget.service.ts","lib/providers/ServiceBudgetContextProvider.tsx","components/Overview/ServiceBudgetFilterBar.tsx","components/ServiceBudget/ChangeStatusModal.tsx","../node_modules/rc-switch/es/index.js","../node_modules/antd/es/switch/style/index.js","../node_modules/antd/es/switch/index.js","components/_Common/CheckboxImage.tsx","lib/SupplierField.tsx","../node_modules/orderedmap/dist/index.js","../node_modules/prosemirror-model/dist/index.js","../node_modules/prosemirror-transform/dist/index.js","../node_modules/prosemirror-state/dist/index.js","../node_modules/prosemirror-view/dist/index.js","../node_modules/w3c-keyname/index.js","../node_modules/prosemirror-keymap/dist/index.js","../node_modules/prosemirror-commands/dist/index.js","../node_modules/prosemirror-schema-list/dist/index.js","../node_modules/@tiptap/core/src/helpers/createChainableState.ts","../node_modules/@tiptap/core/src/CommandManager.ts","../node_modules/@tiptap/core/src/EventEmitter.ts","../node_modules/@tiptap/core/src/helpers/getExtensionField.ts","../node_modules/@tiptap/core/src/helpers/splitExtensions.ts","../node_modules/@tiptap/core/src/helpers/getAttributesFromExtensions.ts","../node_modules/@tiptap/core/src/helpers/getNodeType.ts","../node_modules/@tiptap/core/src/utilities/mergeAttributes.ts","../node_modules/@tiptap/core/src/helpers/getRenderedAttributes.ts","../node_modules/@tiptap/core/src/utilities/isFunction.ts","../node_modules/@tiptap/core/src/utilities/callOrReturn.ts","../node_modules/@tiptap/core/src/helpers/injectExtensionAttributesToParseRule.ts","../node_modules/@tiptap/core/src/utilities/fromString.ts","../node_modules/@tiptap/core/src/helpers/getSchemaByResolvedExtensions.ts","../node_modules/@tiptap/core/src/utilities/isEmptyObject.ts","../node_modules/@tiptap/core/src/helpers/getSchemaTypeByName.ts","../node_modules/@tiptap/core/src/helpers/isExtensionRulesEnabled.ts","../node_modules/@tiptap/core/src/helpers/getHTMLFromFragment.ts","../node_modules/@tiptap/core/src/helpers/getTextContentFromNodes.ts","../node_modules/@tiptap/core/src/utilities/isRegExp.ts","../node_modules/@tiptap/core/src/InputRule.ts","../node_modules/@tiptap/core/src/utilities/isPlainObject.ts","../node_modules/@tiptap/core/src/utilities/mergeDeep.ts","../node_modules/@tiptap/core/src/Mark.ts","../node_modules/@tiptap/core/src/PasteRule.ts","../node_modules/@tiptap/core/src/utilities/isNumber.ts","../node_modules/@tiptap/core/src/utilities/findDuplicates.ts","../node_modules/@tiptap/core/src/ExtensionManager.ts","../node_modules/@tiptap/core/src/Extension.ts","../node_modules/@tiptap/core/src/helpers/getTextBetween.ts","../node_modules/@tiptap/core/src/helpers/getTextSerializersFromSchema.ts","../node_modules/@tiptap/core/src/extensions/clipboardTextSerializer.ts","../node_modules/@tiptap/core/src/utilities/objectIncludes.ts","../node_modules/@tiptap/core/src/helpers/getMarkRange.ts","../node_modules/@tiptap/core/src/helpers/getMarkType.ts","../node_modules/@tiptap/core/src/helpers/isTextSelection.ts","../node_modules/@tiptap/core/src/utilities/minMax.ts","../node_modules/@tiptap/core/src/helpers/resolveFocusPosition.ts","../node_modules/@tiptap/core/src/utilities/isAndroid.ts","../node_modules/@tiptap/core/src/utilities/isiOS.ts","../node_modules/@tiptap/core/src/commands/focus.ts","../node_modules/@tiptap/core/src/utilities/elementFromString.ts","../node_modules/@tiptap/core/src/helpers/createNodeFromContent.ts","../node_modules/@tiptap/core/src/utilities/isMacOS.ts","../node_modules/@tiptap/core/src/helpers/isNodeActive.ts","../node_modules/@tiptap/core/src/helpers/getSchemaTypeNameByName.ts","../node_modules/@tiptap/core/src/utilities/deleteProps.ts","../node_modules/@tiptap/core/src/helpers/createDocument.ts","../node_modules/@tiptap/core/src/helpers/getMarkAttributes.ts","../node_modules/@tiptap/core/src/helpers/findParentNode.ts","../node_modules/@tiptap/core/src/helpers/findParentNodeClosestToPos.ts","../node_modules/@tiptap/core/src/helpers/getText.ts","../node_modules/@tiptap/core/src/helpers/getAttributes.ts","../node_modules/@tiptap/core/src/helpers/getNodeAttributes.ts","../node_modules/@tiptap/core/src/helpers/getMarksBetween.ts","../node_modules/@tiptap/core/src/helpers/getSplittedAttributes.ts","../node_modules/@tiptap/core/src/helpers/isMarkActive.ts","../node_modules/@tiptap/core/src/helpers/isList.ts","../node_modules/@tiptap/core/src/helpers/isNodeEmpty.ts","../node_modules/@tiptap/core/src/commands/splitBlock.ts","../node_modules/@tiptap/core/src/commands/toggleList.ts","../node_modules/@tiptap/core/src/commands/blur.ts","../node_modules/@tiptap/core/src/commands/clearContent.ts","../node_modules/@tiptap/core/src/commands/clearNodes.ts","../node_modules/@tiptap/core/src/commands/command.ts","../node_modules/@tiptap/core/src/commands/createParagraphNear.ts","../node_modules/@tiptap/core/src/commands/cut.ts","../node_modules/@tiptap/core/src/commands/deleteCurrentNode.ts","../node_modules/@tiptap/core/src/commands/deleteNode.ts","../node_modules/@tiptap/core/src/commands/deleteRange.ts","../node_modules/@tiptap/core/src/commands/deleteSelection.ts","../node_modules/@tiptap/core/src/commands/enter.ts","../node_modules/@tiptap/core/src/commands/exitCode.ts","../node_modules/@tiptap/core/src/commands/extendMarkRange.ts","../node_modules/@tiptap/core/src/commands/first.ts","../node_modules/@tiptap/core/src/commands/forEach.ts","../node_modules/@tiptap/core/src/commands/insertContent.ts","../node_modules/@tiptap/core/src/commands/insertContentAt.ts","../node_modules/@tiptap/core/src/helpers/selectionToInsertionEnd.ts","../node_modules/@tiptap/core/src/commands/join.ts","../node_modules/@tiptap/core/src/commands/joinItemBackward.ts","../node_modules/@tiptap/core/src/commands/joinItemForward.ts","../node_modules/@tiptap/core/src/commands/joinTextblockBackward.ts","../node_modules/@tiptap/core/src/commands/joinTextblockForward.ts","../node_modules/@tiptap/core/src/commands/keyboardShortcut.ts","../node_modules/@tiptap/core/src/commands/lift.ts","../node_modules/@tiptap/core/src/commands/liftEmptyBlock.ts","../node_modules/@tiptap/core/src/commands/liftListItem.ts","../node_modules/@tiptap/core/src/commands/newlineInCode.ts","../node_modules/@tiptap/core/src/commands/resetAttributes.ts","../node_modules/@tiptap/core/src/commands/scrollIntoView.ts","../node_modules/@tiptap/core/src/commands/selectAll.ts","../node_modules/@tiptap/core/src/commands/selectNodeBackward.ts","../node_modules/@tiptap/core/src/commands/selectNodeForward.ts","../node_modules/@tiptap/core/src/commands/selectParentNode.ts","../node_modules/@tiptap/core/src/commands/selectTextblockEnd.ts","../node_modules/@tiptap/core/src/commands/selectTextblockStart.ts","../node_modules/@tiptap/core/src/commands/setContent.ts","../node_modules/@tiptap/core/src/commands/setMark.ts","../node_modules/@tiptap/core/src/commands/setMeta.ts","../node_modules/@tiptap/core/src/commands/setNode.ts","../node_modules/@tiptap/core/src/commands/setNodeSelection.ts","../node_modules/@tiptap/core/src/commands/setTextSelection.ts","../node_modules/@tiptap/core/src/commands/sinkListItem.ts","../node_modules/@tiptap/core/src/helpers/defaultBlockAt.ts","../node_modules/@tiptap/core/src/commands/splitListItem.ts","../node_modules/@tiptap/core/src/commands/toggleMark.ts","../node_modules/@tiptap/core/src/commands/toggleNode.ts","../node_modules/@tiptap/core/src/commands/toggleWrap.ts","../node_modules/@tiptap/core/src/commands/undoInputRule.ts","../node_modules/@tiptap/core/src/commands/unsetAllMarks.ts","../node_modules/@tiptap/core/src/commands/unsetMark.ts","../node_modules/@tiptap/core/src/commands/updateAttributes.ts","../node_modules/@tiptap/core/src/commands/wrapIn.ts","../node_modules/@tiptap/core/src/commands/wrapInList.ts","../node_modules/@tiptap/core/src/extensions/commands.ts","../node_modules/@tiptap/core/src/extensions/drop.ts","../node_modules/@tiptap/core/src/extensions/editable.ts","../node_modules/@tiptap/core/src/extensions/focusEvents.ts","../node_modules/@tiptap/core/src/extensions/keymap.ts","../node_modules/@tiptap/core/src/extensions/paste.ts","../node_modules/@tiptap/core/src/extensions/tabindex.ts","../node_modules/@tiptap/core/src/NodePos.ts","../node_modules/@tiptap/core/src/utilities/createStyleTag.ts","../node_modules/@tiptap/core/src/Editor.ts","../node_modules/@tiptap/core/src/style.ts","../node_modules/@tiptap/core/src/helpers/isActive.ts","../node_modules/@tiptap/core/src/inputRules/markInputRule.ts","../node_modules/@tiptap/core/src/inputRules/nodeInputRule.ts","../node_modules/@tiptap/core/src/inputRules/textblockTypeInputRule.ts","../node_modules/@tiptap/core/src/inputRules/wrappingInputRule.ts","../node_modules/@tiptap/core/src/Node.ts","../node_modules/@tiptap/core/src/pasteRules/markPasteRule.ts","../node_modules/@tiptap/core/src/pasteRules/textPasteRule.ts","../node_modules/node_modules/use-sync-external-store/shim/index.js","../node_modules/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js","../node_modules/@tiptap/react/src/EditorContent.tsx","../node_modules/node_modules/fast-deep-equal/es6/react.js","../node_modules/node_modules/use-sync-external-store/shim/with-selector.js","../node_modules/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js","../node_modules/@tiptap/react/src/useEditorState.ts","../node_modules/@tiptap/react/src/useEditor.ts","../node_modules/@tiptap/react/src/Context.tsx","../node_modules/@tiptap/react/src/BubbleMenu.tsx","../node_modules/@tiptap/react/src/useReactNodeView.ts","../node_modules/@tiptap/react/src/NodeViewWrapper.tsx","../node_modules/@tiptap/extension-blockquote/src/blockquote.ts","../node_modules/@tiptap/extension-bold/src/bold.ts","../node_modules/@tiptap/extension-bullet-list/src/bullet-list.ts","../node_modules/@tiptap/extension-code/src/code.ts","../node_modules/@tiptap/extension-code-block/src/code-block.ts","../node_modules/@tiptap/extension-document/src/document.ts","../node_modules/prosemirror-dropcursor/dist/index.js","../node_modules/@tiptap/extension-dropcursor/src/dropcursor.ts","../node_modules/prosemirror-gapcursor/dist/index.js","../node_modules/@tiptap/extension-gapcursor/src/gapcursor.ts","../node_modules/@tiptap/extension-hard-break/src/hard-break.ts","../node_modules/@tiptap/extension-heading/src/heading.ts","../node_modules/rope-sequence/dist/index.js","../node_modules/prosemirror-history/dist/index.js","../node_modules/@tiptap/extension-history/src/history.ts","../node_modules/@tiptap/extension-horizontal-rule/src/horizontal-rule.ts","../node_modules/@tiptap/core/src/helpers/isNodeSelection.ts","../node_modules/@tiptap/extension-italic/src/italic.ts","../node_modules/@tiptap/extension-list-item/src/list-item.ts","../node_modules/@tiptap/extension-ordered-list/src/ordered-list.ts","../node_modules/@tiptap/extension-paragraph/src/paragraph.ts","../node_modules/@tiptap/extension-strike/src/strike.ts","../node_modules/@tiptap/extension-text/src/text.ts","../node_modules/@tiptap/starter-kit/src/starter-kit.ts","lib/TextEditor.tsx","components/ServiceBudget/CreateServiceBudgetModal.tsx","../node_modules/@ant-design/icons-svg/es/asn/RiseOutlined.js","../node_modules/@ant-design/icons/es/icons/RiseOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/CheckCircleTwoTone.js","../node_modules/@ant-design/icons/es/icons/CheckCircleTwoTone.js","../node_modules/@ant-design/icons-svg/es/asn/DeleteTwoTone.js","../node_modules/@ant-design/icons/es/icons/DeleteTwoTone.js","lib/WhatsAppNumberField.tsx","components/ServiceBudget/EditRequestServiceBudgetModal.tsx","components/ServiceBudget/HistoryModal.tsx","components/ServiceBudget/DetailServiceBudgetModal.tsx","components/ServiceBudget/EditServiceBudgetModal.tsx","components/ServiceBudget/RequestServiceBudgetModal.tsx","components/ServiceBudget/ServiceBudgetActionsCell.tsx","pages/service_budget/Columns.tsx","pages/service_budget/ServiceBudget.page.tsx","../node_modules/@ant-design/icons/es/icons/DownloadOutlined.js","services/Setup.service.ts","components/Setup/ClientImportCard.tsx","components/Setup/ResidentImportCard.tsx","../node_modules/@ant-design/icons-svg/es/asn/MinusOutlined.js","../node_modules/@ant-design/icons/es/icons/MinusOutlined.js","lib/ClientsField.tsx","components/User/Form.tsx","services/Notification.service.ts","../node_modules/@ant-design/icons-svg/es/asn/UndoOutlined.js","../node_modules/@ant-design/icons/es/icons/UndoOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/UnlockOutlined.js","../node_modules/@ant-design/icons/es/icons/UnlockOutlined.js","pages/overview/user/Columns.tsx","pages/overview/user/Users.page.tsx","pages/setup/Steps.tsx","lib/providers/SetupContextProvider.tsx","pages/setup/Setup.page.tsx","services/Vehicle.service.ts","lib/providers/VehicleContextProvider.tsx","components/Vehicle/CreateVehicleModal.tsx","components/Vehicle/EditVehicleModal.tsx","components/Vehicle/VehicleFilterBar.tsx","components/Vehicle/VehicleActionsCell.tsx","pages/vehicle/Columns.tsx","pages/vehicle/Vehicle.page.tsx","../node_modules/@ant-design/icons-svg/es/asn/ThunderboltOutlined.js","../node_modules/@ant-design/icons/es/icons/ThunderboltOutlined.js","../node_modules/@ant-design/icons/es/icons/LoadingOutlined.js","lib/helpers/Trigger.helper.ts","services/Trigger.service.ts","lib/providers/WhatsAppContextProvider.tsx","components/WhatsApp/EditTriggerModal.tsx","../node_modules/@ant-design/icons-svg/es/asn/PlayCircleOutlined.js","../node_modules/@ant-design/icons/es/icons/PlayCircleOutlined.js","components/WhatsApp/ListTriggerLogModal.tsx","components/WhatsApp/NewTriggerModal.tsx","../node_modules/@ant-design/icons-svg/es/asn/SecurityScanOutlined.js","../node_modules/@ant-design/icons/es/icons/SecurityScanOutlined.js","pages/whatsapp/Columns.tsx","pages/whatsapp/WhatsApp.page.tsx","components/Supplier/Excel.ts","../node_modules/antd/es/auto-complete/AutoComplete.js","../node_modules/antd/es/auto-complete/index.js","services/ServiceCategory.service.ts","components/Supplier/Form.tsx","pages/overview/supplier/SupplierActionsCell.tsx","pages/overview/supplier/Suppliers.page.tsx","pages/overview/supplier/Columns.tsx","../node_modules/@ant-design/icons-svg/es/asn/FileSearchOutlined.js","../node_modules/@ant-design/icons/es/icons/FileSearchOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/FileWordOutlined.js","../node_modules/@ant-design/icons/es/icons/FileWordOutlined.js","../node_modules/@ant-design/icons-svg/es/asn/ShopOutlined.js","../node_modules/@ant-design/icons/es/icons/ShopOutlined.js","components/_Common/_Layout/Secondary/SecondaryHeaderLogo.tsx","components/_Common/_Layout/Secondary/SecondarySider.tsx","services/contracts/ResidentServiceContract.ts","components/_Common/_Layout/Secondary/SecondaryLayout.tsx","components/_Common/_Routes/ProtectedRoutes.tsx","components/_Common/Forbidden.tsx","components/_Common/NotFound.tsx","services/ResidentService.ts","components/Apartment/Form.tsx","components/Apartment/ModalReconcileUnitsWithDebit.tsx","components/Apartment/Tower/CreateTowerModal.tsx","components/Apartment/Types/TypeActionsCell.tsx","components/Apartment/Types/CreateTypeModal.tsx","components/Apartment/Types/EditTypeModal.tsx","components/Apartment/Types/TypesModal.tsx","components/Apartment/Types/Columns.tsx","components/Apartment/_Index.tsx","components/Apartment/Columns.tsx","components/Apartment/View/Issue.tsx","components/Apartment/View/Resident.tsx","components/Apartment/View.tsx","services/BudgetService.ts","components/Budget/_IndexMonthBudget.tsx","components/Budget/Form.tsx","services/CostCenterService.ts","components/Budget/FormCostCenter.tsx","components/Budget/_Index.tsx","components/_Common/UploadGcondo.tsx","components/Concierge/Form/Issue.tsx","components/Concierge/View/Apartment.tsx","components/Concierge/View/ApartmentSearch.tsx","components/Concierge/View/Reserve.tsx","components/Concierge/_Index.tsx","../node_modules/@ant-design/icons-svg/es/asn/ApartmentOutlined.js","../node_modules/@ant-design/icons/es/icons/ApartmentOutlined.js","components/Dashboard/Indicators.tsx","components/Dashboard/IssueChart.tsx","components/Dashboard/Issue.tsx","components/Dashboard/IssuePerMonthChart.tsx","services/Reserve.service.ts","components/Dashboard/useSchedule.tsx","components/Dashboard/ReserveActionsCell.tsx","components/Dashboard/Schedule.tsx","components/Dashboard/_Index.tsx","components/Device/_Index.tsx","components/Device/Columns.tsx","services/ClientDeviceService.ts","components/Login/Login.tsx","components/Reserve/CurrentBookingDateReserves/CurrentBookingDateActionsCell.tsx","components/Reserve/CurrentBookingDateReserves/CurrentBookingDateReservesModal.tsx","components/Reserve/CurrentBookingDateReserves/CurrentBookingDateColumns.tsx","components/Reserve/Excel.ts","components/Reserve/FormReserve.tsx","components/Reserve/PendingActionsCell.tsx","components/Reserve/PendingReservesModal.tsx","components/Reserve/PendingColumns.tsx","components/Reserve/_Index.tsx","components/Resident/FormResident.tsx","components/Resident/Logs/ListLog.tsx","components/Resident/Pet/FormPet.tsx","components/Resident/Pet/ListPet.tsx","components/Resident/ResidentFilterBar.tsx","components/Resident/Vehicle/FormVehicle.tsx","components/Resident/Vehicle/ListVehicle.tsx","components/Resident/_Index.tsx","components/UpdatePassword/UpdatePassword.tsx","services/AuthenticationService.ts","components/App.tsx","../node_modules/@sentry/react/src/sdk.ts","index.tsx","../node_modules/@sentry/browser/src/tracing/backgroundtab.ts"],"sourceRoot":"","sourcesContent":["import _createClass from \"@babel/runtime/helpers/esm/createClass\";\nimport _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nvar AbstractCalculator = /*#__PURE__*/_createClass(function AbstractCalculator() {\n _classCallCheck(this, AbstractCalculator);\n});\nexport default AbstractCalculator;","import _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/esm/createClass\";\nimport _assertThisInitialized from \"@babel/runtime/helpers/esm/assertThisInitialized\";\nimport _inherits from \"@babel/runtime/helpers/esm/inherits\";\nimport _createSuper from \"@babel/runtime/helpers/esm/createSuper\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport AbstractCalculator from \"./calculator\";\nvar CALC_UNIT = 'CALC_UNIT';\nvar regexp = new RegExp(CALC_UNIT, 'g');\nfunction unit(value) {\n if (typeof value === 'number') {\n return \"\".concat(value).concat(CALC_UNIT);\n }\n return value;\n}\nvar CSSCalculator = /*#__PURE__*/function (_AbstractCalculator) {\n _inherits(CSSCalculator, _AbstractCalculator);\n var _super = _createSuper(CSSCalculator);\n function CSSCalculator(num, unitlessCssVar) {\n var _this;\n _classCallCheck(this, CSSCalculator);\n _this = _super.call(this);\n _defineProperty(_assertThisInitialized(_this), \"result\", '');\n _defineProperty(_assertThisInitialized(_this), \"unitlessCssVar\", void 0);\n _defineProperty(_assertThisInitialized(_this), \"lowPriority\", void 0);\n var numType = _typeof(num);\n _this.unitlessCssVar = unitlessCssVar;\n if (num instanceof CSSCalculator) {\n _this.result = \"(\".concat(num.result, \")\");\n } else if (numType === 'number') {\n _this.result = unit(num);\n } else if (numType === 'string') {\n _this.result = num;\n }\n return _this;\n }\n _createClass(CSSCalculator, [{\n key: \"add\",\n value: function add(num) {\n if (num instanceof CSSCalculator) {\n this.result = \"\".concat(this.result, \" + \").concat(num.getResult());\n } else if (typeof num === 'number' || typeof num === 'string') {\n this.result = \"\".concat(this.result, \" + \").concat(unit(num));\n }\n this.lowPriority = true;\n return this;\n }\n }, {\n key: \"sub\",\n value: function sub(num) {\n if (num instanceof CSSCalculator) {\n this.result = \"\".concat(this.result, \" - \").concat(num.getResult());\n } else if (typeof num === 'number' || typeof num === 'string') {\n this.result = \"\".concat(this.result, \" - \").concat(unit(num));\n }\n this.lowPriority = true;\n return this;\n }\n }, {\n key: \"mul\",\n value: function mul(num) {\n if (this.lowPriority) {\n this.result = \"(\".concat(this.result, \")\");\n }\n if (num instanceof CSSCalculator) {\n this.result = \"\".concat(this.result, \" * \").concat(num.getResult(true));\n } else if (typeof num === 'number' || typeof num === 'string') {\n this.result = \"\".concat(this.result, \" * \").concat(num);\n }\n this.lowPriority = false;\n return this;\n }\n }, {\n key: \"div\",\n value: function div(num) {\n if (this.lowPriority) {\n this.result = \"(\".concat(this.result, \")\");\n }\n if (num instanceof CSSCalculator) {\n this.result = \"\".concat(this.result, \" / \").concat(num.getResult(true));\n } else if (typeof num === 'number' || typeof num === 'string') {\n this.result = \"\".concat(this.result, \" / \").concat(num);\n }\n this.lowPriority = false;\n return this;\n }\n }, {\n key: \"getResult\",\n value: function getResult(force) {\n return this.lowPriority || force ? \"(\".concat(this.result, \")\") : this.result;\n }\n }, {\n key: \"equal\",\n value: function equal(options) {\n var _this2 = this;\n var _ref = options || {},\n cssUnit = _ref.unit;\n var mergedUnit = true;\n if (typeof cssUnit === 'boolean') {\n mergedUnit = cssUnit;\n } else if (Array.from(this.unitlessCssVar).some(function (cssVar) {\n return _this2.result.includes(cssVar);\n })) {\n mergedUnit = false;\n }\n this.result = this.result.replace(regexp, mergedUnit ? 'px' : '');\n if (typeof this.lowPriority !== 'undefined') {\n return \"calc(\".concat(this.result, \")\");\n }\n return this.result;\n }\n }]);\n return CSSCalculator;\n}(AbstractCalculator);\nexport { CSSCalculator as default };","import _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/esm/createClass\";\nimport _assertThisInitialized from \"@babel/runtime/helpers/esm/assertThisInitialized\";\nimport _inherits from \"@babel/runtime/helpers/esm/inherits\";\nimport _createSuper from \"@babel/runtime/helpers/esm/createSuper\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport AbstractCalculator from \"./calculator\";\nvar NumCalculator = /*#__PURE__*/function (_AbstractCalculator) {\n _inherits(NumCalculator, _AbstractCalculator);\n var _super = _createSuper(NumCalculator);\n function NumCalculator(num) {\n var _this;\n _classCallCheck(this, NumCalculator);\n _this = _super.call(this);\n _defineProperty(_assertThisInitialized(_this), \"result\", 0);\n if (num instanceof NumCalculator) {\n _this.result = num.result;\n } else if (typeof num === 'number') {\n _this.result = num;\n }\n return _this;\n }\n _createClass(NumCalculator, [{\n key: \"add\",\n value: function add(num) {\n if (num instanceof NumCalculator) {\n this.result += num.result;\n } else if (typeof num === 'number') {\n this.result += num;\n }\n return this;\n }\n }, {\n key: \"sub\",\n value: function sub(num) {\n if (num instanceof NumCalculator) {\n this.result -= num.result;\n } else if (typeof num === 'number') {\n this.result -= num;\n }\n return this;\n }\n }, {\n key: \"mul\",\n value: function mul(num) {\n if (num instanceof NumCalculator) {\n this.result *= num.result;\n } else if (typeof num === 'number') {\n this.result *= num;\n }\n return this;\n }\n }, {\n key: \"div\",\n value: function div(num) {\n if (num instanceof NumCalculator) {\n this.result /= num.result;\n } else if (typeof num === 'number') {\n this.result /= num;\n }\n return this;\n }\n }, {\n key: \"equal\",\n value: function equal() {\n return this.result;\n }\n }]);\n return NumCalculator;\n}(AbstractCalculator);\nexport default NumCalculator;","import CSSCalculator from \"./CSSCalculator\";\nimport NumCalculator from \"./NumCalculator\";\nvar genCalc = function genCalc(type, unitlessCssVar) {\n var Calculator = type === 'css' ? CSSCalculator : NumCalculator;\n return function (num) {\n return new Calculator(num, unitlessCssVar);\n };\n};\nexport default genCalc;","var getCompVarPrefix = function getCompVarPrefix(component, prefix) {\n return \"\".concat([prefix, component.replace(/([A-Z]+)([A-Z][a-z]+)/g, '$1-$2').replace(/([a-z])([A-Z])/g, '$1-$2')].filter(Boolean).join('-'));\n};\nexport default getCompVarPrefix;","import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport { warning } from 'rc-util';\nfunction getComponentToken(component, token, defaultToken, options) {\n var customToken = _objectSpread({}, token[component]);\n if (options !== null && options !== void 0 && options.deprecatedTokens) {\n var deprecatedTokens = options.deprecatedTokens;\n deprecatedTokens.forEach(function (_ref) {\n var _ref2 = _slicedToArray(_ref, 2),\n oldTokenKey = _ref2[0],\n newTokenKey = _ref2[1];\n if (process.env.NODE_ENV !== 'production') {\n warning(!(customToken !== null && customToken !== void 0 && customToken[oldTokenKey]), \"Component Token `\".concat(String(oldTokenKey), \"` of \").concat(String(component), \" is deprecated. Please use `\").concat(String(newTokenKey), \"` instead.\"));\n }\n\n // Should wrap with `if` clause, or there will be `undefined` in object.\n if (customToken !== null && customToken !== void 0 && customToken[oldTokenKey] || customToken !== null && customToken !== void 0 && customToken[newTokenKey]) {\n var _customToken$newToken;\n (_customToken$newToken = customToken[newTokenKey]) !== null && _customToken$newToken !== void 0 ? _customToken$newToken : customToken[newTokenKey] = customToken === null || customToken === void 0 ? void 0 : customToken[oldTokenKey];\n }\n });\n }\n var mergedToken = _objectSpread(_objectSpread({}, defaultToken), customToken);\n\n // Remove same value as global token to minimize size\n Object.keys(mergedToken).forEach(function (key) {\n if (mergedToken[key] === token[key]) {\n delete mergedToken[key];\n }\n });\n return mergedToken;\n}\nexport default getComponentToken;","import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _typeof from \"@babel/runtime/helpers/esm/typeof\";\nvar enableStatistic = process.env.NODE_ENV !== 'production' || typeof CSSINJS_STATISTIC !== 'undefined';\nvar recording = true;\n\n/**\n * This function will do as `Object.assign` in production. But will use Object.defineProperty:get to\n * pass all value access in development. To support statistic field usage with alias token.\n */\nexport function merge() {\n for (var _len = arguments.length, objs = new Array(_len), _key = 0; _key < _len; _key++) {\n objs[_key] = arguments[_key];\n }\n /* istanbul ignore next */\n if (!enableStatistic) {\n return Object.assign.apply(Object, [{}].concat(objs));\n }\n recording = false;\n var ret = {};\n objs.forEach(function (obj) {\n if (_typeof(obj) !== 'object') {\n return;\n }\n var keys = Object.keys(obj);\n keys.forEach(function (key) {\n Object.defineProperty(ret, key, {\n configurable: true,\n enumerable: true,\n get: function get() {\n return obj[key];\n }\n });\n });\n });\n recording = true;\n return ret;\n}\n\n/** @internal Internal Usage. Not use in your production. */\nexport var statistic = {};\n\n/** @internal Internal Usage. Not use in your production. */\nexport var _statistic_build_ = {};\n\n/* istanbul ignore next */\nfunction noop() {}\n\n/** Statistic token usage case. Should use `merge` function if you do not want spread record. */\nvar statisticToken = function statisticToken(token) {\n var tokenKeys;\n var proxy = token;\n var flush = noop;\n if (enableStatistic && typeof Proxy !== 'undefined') {\n tokenKeys = new Set();\n proxy = new Proxy(token, {\n get: function get(obj, prop) {\n if (recording) {\n var _tokenKeys;\n (_tokenKeys = tokenKeys) === null || _tokenKeys === void 0 || _tokenKeys.add(prop);\n }\n return obj[prop];\n }\n });\n flush = function flush(componentName, componentToken) {\n var _statistic$componentN;\n statistic[componentName] = {\n global: Array.from(tokenKeys),\n component: _objectSpread(_objectSpread({}, (_statistic$componentN = statistic[componentName]) === null || _statistic$componentN === void 0 ? void 0 : _statistic$componentN.component), componentToken)\n };\n };\n }\n return {\n token: proxy,\n keys: tokenKeys,\n flush: flush\n };\n};\nexport default statisticToken;","import { merge as mergeToken } from \"./statistic\";\nfunction getDefaultComponentToken(component, token, getDefaultToken) {\n if (typeof getDefaultToken === 'function') {\n var _token$component;\n return getDefaultToken(mergeToken(token, (_token$component = token[component]) !== null && _token$component !== void 0 ? _token$component : {}));\n }\n return getDefaultToken !== null && getDefaultToken !== void 0 ? getDefaultToken : {};\n}\nexport default getDefaultComponentToken;","import { unit } from '@ant-design/cssinjs';\nfunction genMaxMin(type) {\n if (type === 'js') {\n return {\n max: Math.max,\n min: Math.min\n };\n }\n return {\n max: function max() {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n return \"max(\".concat(args.map(function (value) {\n return unit(value);\n }).join(','), \")\");\n },\n min: function min() {\n for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n return \"min(\".concat(args.map(function (value) {\n return unit(value);\n }).join(','), \")\");\n }\n };\n}\nexport default genMaxMin;","import _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/esm/createClass\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport React from 'react';\nvar BEAT_LIMIT = 1000 * 60 * 10;\n\n/**\n * A helper class to map keys to values.\n * It supports both primitive keys and object keys.\n */\nvar ArrayKeyMap = /*#__PURE__*/function () {\n function ArrayKeyMap() {\n _classCallCheck(this, ArrayKeyMap);\n _defineProperty(this, \"map\", new Map());\n // Use WeakMap to avoid memory leak\n _defineProperty(this, \"objectIDMap\", new WeakMap());\n _defineProperty(this, \"nextID\", 0);\n _defineProperty(this, \"lastAccessBeat\", new Map());\n // We will clean up the cache when reach the limit\n _defineProperty(this, \"accessBeat\", 0);\n }\n _createClass(ArrayKeyMap, [{\n key: \"set\",\n value: function set(keys, value) {\n // New set will trigger clear\n this.clear();\n\n // Set logic\n var compositeKey = this.getCompositeKey(keys);\n this.map.set(compositeKey, value);\n this.lastAccessBeat.set(compositeKey, Date.now());\n }\n }, {\n key: \"get\",\n value: function get(keys) {\n var compositeKey = this.getCompositeKey(keys);\n var cache = this.map.get(compositeKey);\n this.lastAccessBeat.set(compositeKey, Date.now());\n this.accessBeat += 1;\n return cache;\n }\n }, {\n key: \"getCompositeKey\",\n value: function getCompositeKey(keys) {\n var _this = this;\n var ids = keys.map(function (key) {\n if (key && _typeof(key) === 'object') {\n return \"obj_\".concat(_this.getObjectID(key));\n }\n return \"\".concat(_typeof(key), \"_\").concat(key);\n });\n return ids.join('|');\n }\n }, {\n key: \"getObjectID\",\n value: function getObjectID(obj) {\n if (this.objectIDMap.has(obj)) {\n return this.objectIDMap.get(obj);\n }\n var id = this.nextID;\n this.objectIDMap.set(obj, id);\n this.nextID += 1;\n return id;\n }\n }, {\n key: \"clear\",\n value: function clear() {\n var _this2 = this;\n if (this.accessBeat > 10000) {\n var now = Date.now();\n this.lastAccessBeat.forEach(function (beat, key) {\n if (now - beat > BEAT_LIMIT) {\n _this2.map.delete(key);\n _this2.lastAccessBeat.delete(key);\n }\n });\n this.accessBeat = 0;\n }\n }\n }]);\n return ArrayKeyMap;\n}();\nvar uniqueMap = new ArrayKeyMap();\n\n/**\n * Like `useMemo`, but this hook result will be shared across all instances.\n */\nfunction useUniqueMemo(memoFn, deps) {\n return React.useMemo(function () {\n var cachedValue = uniqueMap.get(deps);\n if (cachedValue) {\n return cachedValue;\n }\n var newValue = memoFn();\n uniqueMap.set(deps, newValue);\n return newValue;\n }, deps);\n}\nexport default useUniqueMemo;","/**\n * Provide a default hook since not everyone needs to config this.\n */\nvar useDefaultCSP = function useDefaultCSP() {\n return {};\n};\nexport default useDefaultCSP;","import _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport React from 'react';\nimport { token2CSSVar, useCSSVarRegister, useStyleRegister } from '@ant-design/cssinjs';\nimport genCalc from \"./calc\";\nimport getCompVarPrefix from \"./getCompVarPrefix\";\nimport getComponentToken from \"./getComponentToken\";\nimport getDefaultComponentToken from \"./getDefaultComponentToken\";\nimport genMaxMin from \"./maxmin\";\nimport statisticToken, { merge as mergeToken } from \"./statistic\";\nimport useUniqueMemo from \"../_util/hooks/useUniqueMemo\";\nimport useDefaultCSP from \"../hooks/useCSP\";\nfunction genStyleUtils(config) {\n // Dependency inversion for preparing basic config.\n var _config$useCSP = config.useCSP,\n useCSP = _config$useCSP === void 0 ? useDefaultCSP : _config$useCSP,\n useToken = config.useToken,\n usePrefix = config.usePrefix,\n getResetStyles = config.getResetStyles,\n getCommonStyle = config.getCommonStyle,\n getCompUnitless = config.getCompUnitless;\n function genStyleHooks(component, styleFn, getDefaultToken, options) {\n var componentName = Array.isArray(component) ? component[0] : component;\n function prefixToken(key) {\n return \"\".concat(String(componentName)).concat(key.slice(0, 1).toUpperCase()).concat(key.slice(1));\n }\n\n // Fill unitless\n var originUnitless = (options === null || options === void 0 ? void 0 : options.unitless) || {};\n var originCompUnitless = typeof getCompUnitless === 'function' ? getCompUnitless(component) : {};\n var compUnitless = _objectSpread(_objectSpread({}, originCompUnitless), {}, _defineProperty({}, prefixToken('zIndexPopup'), true));\n Object.keys(originUnitless).forEach(function (key) {\n compUnitless[prefixToken(key)] = originUnitless[key];\n });\n\n // Options\n var mergedOptions = _objectSpread(_objectSpread({}, options), {}, {\n unitless: compUnitless,\n prefixToken: prefixToken\n });\n\n // Hooks\n var useStyle = genComponentStyleHook(component, styleFn, getDefaultToken, mergedOptions);\n var useCSSVar = genCSSVarRegister(componentName, getDefaultToken, mergedOptions);\n return function (prefixCls) {\n var rootCls = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : prefixCls;\n var _useStyle = useStyle(prefixCls, rootCls),\n _useStyle2 = _slicedToArray(_useStyle, 2),\n hashId = _useStyle2[1];\n var _useCSSVar = useCSSVar(rootCls),\n _useCSSVar2 = _slicedToArray(_useCSSVar, 2),\n wrapCSSVar = _useCSSVar2[0],\n cssVarCls = _useCSSVar2[1];\n return [wrapCSSVar, hashId, cssVarCls];\n };\n }\n function genCSSVarRegister(component, getDefaultToken, options) {\n var compUnitless = options.unitless,\n _options$injectStyle = options.injectStyle,\n injectStyle = _options$injectStyle === void 0 ? true : _options$injectStyle,\n prefixToken = options.prefixToken,\n ignore = options.ignore;\n var CSSVarRegister = function CSSVarRegister(_ref) {\n var rootCls = _ref.rootCls,\n _ref$cssVar = _ref.cssVar,\n cssVar = _ref$cssVar === void 0 ? {} : _ref$cssVar;\n var _useToken = useToken(),\n realToken = _useToken.realToken;\n useCSSVarRegister({\n path: [component],\n prefix: cssVar.prefix,\n key: cssVar.key,\n unitless: compUnitless,\n ignore: ignore,\n token: realToken,\n scope: rootCls\n }, function () {\n var defaultToken = getDefaultComponentToken(component, realToken, getDefaultToken);\n var componentToken = getComponentToken(component, realToken, defaultToken, {\n deprecatedTokens: options === null || options === void 0 ? void 0 : options.deprecatedTokens\n });\n Object.keys(defaultToken).forEach(function (key) {\n componentToken[prefixToken(key)] = componentToken[key];\n delete componentToken[key];\n });\n return componentToken;\n });\n return null;\n };\n var useCSSVar = function useCSSVar(rootCls) {\n var _useToken2 = useToken(),\n cssVar = _useToken2.cssVar;\n return [function (node) {\n return injectStyle && cssVar ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CSSVarRegister, {\n rootCls: rootCls,\n cssVar: cssVar,\n component: component\n }), node) : node;\n }, cssVar === null || cssVar === void 0 ? void 0 : cssVar.key];\n };\n return useCSSVar;\n }\n function genComponentStyleHook(componentName, styleFn, getDefaultToken) {\n var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};\n var cells = Array.isArray(componentName) ? componentName : [componentName, componentName];\n var _cells = _slicedToArray(cells, 1),\n component = _cells[0];\n var concatComponent = cells.join('-');\n var mergedLayer = config.layer || {\n name: 'antd'\n };\n\n // Return new style hook\n return function (prefixCls) {\n var rootCls = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : prefixCls;\n var _useToken3 = useToken(),\n theme = _useToken3.theme,\n realToken = _useToken3.realToken,\n hashId = _useToken3.hashId,\n token = _useToken3.token,\n cssVar = _useToken3.cssVar;\n var _usePrefix = usePrefix(),\n rootPrefixCls = _usePrefix.rootPrefixCls,\n iconPrefixCls = _usePrefix.iconPrefixCls;\n var csp = useCSP();\n var type = cssVar ? 'css' : 'js';\n\n // Use unique memo to share the result across all instances\n var calc = useUniqueMemo(function () {\n var unitlessCssVar = new Set();\n if (cssVar) {\n Object.keys(options.unitless || {}).forEach(function (key) {\n // Some component proxy the AliasToken (e.g. Image) and some not (e.g. Modal)\n // We should both pass in `unitlessCssVar` to make sure the CSSVar can be unitless.\n unitlessCssVar.add(token2CSSVar(key, cssVar.prefix));\n unitlessCssVar.add(token2CSSVar(key, getCompVarPrefix(component, cssVar.prefix)));\n });\n }\n return genCalc(type, unitlessCssVar);\n }, [type, component, cssVar === null || cssVar === void 0 ? void 0 : cssVar.prefix]);\n var _genMaxMin = genMaxMin(type),\n max = _genMaxMin.max,\n min = _genMaxMin.min;\n\n // Shared config\n var sharedConfig = {\n theme: theme,\n token: token,\n hashId: hashId,\n nonce: function nonce() {\n return csp.nonce;\n },\n clientOnly: options.clientOnly,\n layer: mergedLayer,\n // antd is always at top of styles\n order: options.order || -999\n };\n\n // This if statement is safe, as it will only be used if the generator has the function. It's not dynamic.\n if (typeof getResetStyles === 'function') {\n // Generate style for all need reset tags.\n useStyleRegister(_objectSpread(_objectSpread({}, sharedConfig), {}, {\n clientOnly: false,\n path: ['Shared', rootPrefixCls]\n }), function () {\n return getResetStyles(token, {\n prefix: {\n rootPrefixCls: rootPrefixCls,\n iconPrefixCls: iconPrefixCls\n },\n csp: csp\n });\n });\n }\n var wrapSSR = useStyleRegister(_objectSpread(_objectSpread({}, sharedConfig), {}, {\n path: [concatComponent, prefixCls, iconPrefixCls]\n }), function () {\n if (options.injectStyle === false) {\n return [];\n }\n var _statisticToken = statisticToken(token),\n proxyToken = _statisticToken.token,\n flush = _statisticToken.flush;\n var defaultComponentToken = getDefaultComponentToken(component, realToken, getDefaultToken);\n var componentCls = \".\".concat(prefixCls);\n var componentToken = getComponentToken(component, realToken, defaultComponentToken, {\n deprecatedTokens: options.deprecatedTokens\n });\n if (cssVar && defaultComponentToken && _typeof(defaultComponentToken) === 'object') {\n Object.keys(defaultComponentToken).forEach(function (key) {\n defaultComponentToken[key] = \"var(\".concat(token2CSSVar(key, getCompVarPrefix(component, cssVar.prefix)), \")\");\n });\n }\n var mergedToken = mergeToken(proxyToken, {\n componentCls: componentCls,\n prefixCls: prefixCls,\n iconCls: \".\".concat(iconPrefixCls),\n antCls: \".\".concat(rootPrefixCls),\n calc: calc,\n // @ts-ignore\n max: max,\n // @ts-ignore\n min: min\n }, cssVar ? defaultComponentToken : componentToken);\n var styleInterpolation = styleFn(mergedToken, {\n hashId: hashId,\n prefixCls: prefixCls,\n rootPrefixCls: rootPrefixCls,\n iconPrefixCls: iconPrefixCls\n });\n flush(component, componentToken);\n var commonStyle = typeof getCommonStyle === 'function' ? getCommonStyle(mergedToken, prefixCls, rootCls, options.resetFont) : null;\n return [options.resetStyle === false ? null : commonStyle, styleInterpolation];\n });\n return [wrapSSR, hashId];\n };\n }\n function genSubStyleComponent(componentName, styleFn, getDefaultToken) {\n var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};\n var useStyle = genComponentStyleHook(componentName, styleFn, getDefaultToken, _objectSpread({\n resetStyle: false,\n // Sub Style should default after root one\n order: -998\n }, options));\n var StyledComponent = function StyledComponent(_ref2) {\n var prefixCls = _ref2.prefixCls,\n _ref2$rootCls = _ref2.rootCls,\n rootCls = _ref2$rootCls === void 0 ? prefixCls : _ref2$rootCls;\n useStyle(prefixCls, rootCls);\n return null;\n };\n if (process.env.NODE_ENV !== 'production') {\n StyledComponent.displayName = \"SubStyle_\".concat(String(Array.isArray(componentName) ? componentName.join('.') : componentName));\n }\n return StyledComponent;\n }\n return {\n genStyleHooks: genStyleHooks,\n genSubStyleComponent: genSubStyleComponent,\n genComponentStyleHook: genComponentStyleHook\n };\n}\nexport default genStyleUtils;","/* eslint-disable */\n// Inspired by https://github.com/garycourt/murmurhash-js\n// Ported from https://github.com/aappleby/smhasher/blob/61a0530f28277f2e850bfc39600ce61d02b518de/src/MurmurHash2.cpp#L37-L86\nfunction murmur2(str) {\n // 'm' and 'r' are mixing constants generated offline.\n // They're not really 'magic', they just happen to work well.\n // const m = 0x5bd1e995;\n // const r = 24;\n // Initialize the hash\n var h = 0; // Mix 4 bytes at a time into the hash\n\n var k,\n i = 0,\n len = str.length;\n\n for (; len >= 4; ++i, len -= 4) {\n k = str.charCodeAt(i) & 0xff | (str.charCodeAt(++i) & 0xff) << 8 | (str.charCodeAt(++i) & 0xff) << 16 | (str.charCodeAt(++i) & 0xff) << 24;\n k =\n /* Math.imul(k, m): */\n (k & 0xffff) * 0x5bd1e995 + ((k >>> 16) * 0xe995 << 16);\n k ^=\n /* k >>> r: */\n k >>> 24;\n h =\n /* Math.imul(k, m): */\n (k & 0xffff) * 0x5bd1e995 + ((k >>> 16) * 0xe995 << 16) ^\n /* Math.imul(h, m): */\n (h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);\n } // Handle the last few bytes of the input array\n\n\n switch (len) {\n case 3:\n h ^= (str.charCodeAt(i + 2) & 0xff) << 16;\n\n case 2:\n h ^= (str.charCodeAt(i + 1) & 0xff) << 8;\n\n case 1:\n h ^= str.charCodeAt(i) & 0xff;\n h =\n /* Math.imul(h, m): */\n (h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);\n } // Do a few final mixes of the hash to ensure the last few\n // bytes are well-incorporated.\n\n\n h ^= h >>> 13;\n h =\n /* Math.imul(h, m): */\n (h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);\n return ((h ^ h >>> 15) >>> 0).toString(36);\n}\n\nexport default murmur2;\n","import _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/esm/createClass\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\n// [times, realValue]\n\nvar SPLIT = '%';\n\n/** Connect key with `SPLIT` */\nexport function pathKey(keys) {\n return keys.join(SPLIT);\n}\nvar Entity = /*#__PURE__*/function () {\n function Entity(instanceId) {\n _classCallCheck(this, Entity);\n _defineProperty(this, \"instanceId\", void 0);\n /** @private Internal cache map. Do not access this directly */\n _defineProperty(this, \"cache\", new Map());\n this.instanceId = instanceId;\n }\n _createClass(Entity, [{\n key: \"get\",\n value: function get(keys) {\n return this.opGet(pathKey(keys));\n }\n\n /** A fast get cache with `get` concat. */\n }, {\n key: \"opGet\",\n value: function opGet(keyPathStr) {\n return this.cache.get(keyPathStr) || null;\n }\n }, {\n key: \"update\",\n value: function update(keys, valueFn) {\n return this.opUpdate(pathKey(keys), valueFn);\n }\n\n /** A fast get cache with `get` concat. */\n }, {\n key: \"opUpdate\",\n value: function opUpdate(keyPathStr, valueFn) {\n var prevValue = this.cache.get(keyPathStr);\n var nextValue = valueFn(prevValue);\n if (nextValue === null) {\n this.cache.delete(keyPathStr);\n } else {\n this.cache.set(keyPathStr, nextValue);\n }\n }\n }]);\n return Entity;\n}();\nexport default Entity;","import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nvar _excluded = [\"children\"];\nimport useMemo from \"rc-util/es/hooks/useMemo\";\nimport isEqual from \"rc-util/es/isEqual\";\nimport * as React from 'react';\nimport CacheEntity from \"./Cache\";\nexport var ATTR_TOKEN = 'data-token-hash';\nexport var ATTR_MARK = 'data-css-hash';\nexport var ATTR_CACHE_PATH = 'data-cache-path';\n\n// Mark css-in-js instance in style element\nexport var CSS_IN_JS_INSTANCE = '__cssinjs_instance__';\nexport function createCache() {\n var cssinjsInstanceId = Math.random().toString(12).slice(2);\n\n // Tricky SSR: Move all inline style to the head.\n // PS: We do not recommend tricky mode.\n if (typeof document !== 'undefined' && document.head && document.body) {\n var styles = document.body.querySelectorAll(\"style[\".concat(ATTR_MARK, \"]\")) || [];\n var firstChild = document.head.firstChild;\n Array.from(styles).forEach(function (style) {\n style[CSS_IN_JS_INSTANCE] = style[CSS_IN_JS_INSTANCE] || cssinjsInstanceId;\n\n // Not force move if no head\n if (style[CSS_IN_JS_INSTANCE] === cssinjsInstanceId) {\n document.head.insertBefore(style, firstChild);\n }\n });\n\n // Deduplicate of moved styles\n var styleHash = {};\n Array.from(document.querySelectorAll(\"style[\".concat(ATTR_MARK, \"]\"))).forEach(function (style) {\n var hash = style.getAttribute(ATTR_MARK);\n if (styleHash[hash]) {\n if (style[CSS_IN_JS_INSTANCE] === cssinjsInstanceId) {\n var _style$parentNode;\n (_style$parentNode = style.parentNode) === null || _style$parentNode === void 0 || _style$parentNode.removeChild(style);\n }\n } else {\n styleHash[hash] = true;\n }\n });\n }\n return new CacheEntity(cssinjsInstanceId);\n}\nvar StyleContext = /*#__PURE__*/React.createContext({\n hashPriority: 'low',\n cache: createCache(),\n defaultCache: true\n});\nexport var StyleProvider = function StyleProvider(props) {\n var children = props.children,\n restProps = _objectWithoutProperties(props, _excluded);\n var parentContext = React.useContext(StyleContext);\n var context = useMemo(function () {\n var mergedContext = _objectSpread({}, parentContext);\n Object.keys(restProps).forEach(function (key) {\n var value = restProps[key];\n if (restProps[key] !== undefined) {\n mergedContext[key] = value;\n }\n });\n var cache = restProps.cache;\n mergedContext.cache = mergedContext.cache || createCache();\n mergedContext.defaultCache = !cache && parentContext.defaultCache;\n return mergedContext;\n }, [parentContext, restProps], function (prev, next) {\n return !isEqual(prev[0], next[0], true) || !isEqual(prev[1], next[1], true);\n });\n return /*#__PURE__*/React.createElement(StyleContext.Provider, {\n value: context\n }, children);\n};\nexport default StyleContext;","import _createClass from \"@babel/runtime/helpers/esm/createClass\";\nimport _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nvar AbstractCalculator = /*#__PURE__*/_createClass(function AbstractCalculator() {\n _classCallCheck(this, AbstractCalculator);\n});\nexport default AbstractCalculator;","import _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/esm/createClass\";\nimport _assertThisInitialized from \"@babel/runtime/helpers/esm/assertThisInitialized\";\nimport _inherits from \"@babel/runtime/helpers/esm/inherits\";\nimport _createSuper from \"@babel/runtime/helpers/esm/createSuper\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport AbstractCalculator from \"./calculator\";\nvar CALC_UNIT = 'CALC_UNIT';\nvar regexp = new RegExp(CALC_UNIT, 'g');\nfunction unit(value) {\n if (typeof value === 'number') {\n return \"\".concat(value).concat(CALC_UNIT);\n }\n return value;\n}\nvar CSSCalculator = /*#__PURE__*/function (_AbstractCalculator) {\n _inherits(CSSCalculator, _AbstractCalculator);\n var _super = _createSuper(CSSCalculator);\n function CSSCalculator(num, unitlessCssVar) {\n var _this;\n _classCallCheck(this, CSSCalculator);\n _this = _super.call(this);\n _defineProperty(_assertThisInitialized(_this), \"result\", '');\n _defineProperty(_assertThisInitialized(_this), \"unitlessCssVar\", void 0);\n _defineProperty(_assertThisInitialized(_this), \"lowPriority\", void 0);\n var numType = _typeof(num);\n _this.unitlessCssVar = unitlessCssVar;\n if (num instanceof CSSCalculator) {\n _this.result = \"(\".concat(num.result, \")\");\n } else if (numType === 'number') {\n _this.result = unit(num);\n } else if (numType === 'string') {\n _this.result = num;\n }\n return _this;\n }\n _createClass(CSSCalculator, [{\n key: \"add\",\n value: function add(num) {\n if (num instanceof CSSCalculator) {\n this.result = \"\".concat(this.result, \" + \").concat(num.getResult());\n } else if (typeof num === 'number' || typeof num === 'string') {\n this.result = \"\".concat(this.result, \" + \").concat(unit(num));\n }\n this.lowPriority = true;\n return this;\n }\n }, {\n key: \"sub\",\n value: function sub(num) {\n if (num instanceof CSSCalculator) {\n this.result = \"\".concat(this.result, \" - \").concat(num.getResult());\n } else if (typeof num === 'number' || typeof num === 'string') {\n this.result = \"\".concat(this.result, \" - \").concat(unit(num));\n }\n this.lowPriority = true;\n return this;\n }\n }, {\n key: \"mul\",\n value: function mul(num) {\n if (this.lowPriority) {\n this.result = \"(\".concat(this.result, \")\");\n }\n if (num instanceof CSSCalculator) {\n this.result = \"\".concat(this.result, \" * \").concat(num.getResult(true));\n } else if (typeof num === 'number' || typeof num === 'string') {\n this.result = \"\".concat(this.result, \" * \").concat(num);\n }\n this.lowPriority = false;\n return this;\n }\n }, {\n key: \"div\",\n value: function div(num) {\n if (this.lowPriority) {\n this.result = \"(\".concat(this.result, \")\");\n }\n if (num instanceof CSSCalculator) {\n this.result = \"\".concat(this.result, \" / \").concat(num.getResult(true));\n } else if (typeof num === 'number' || typeof num === 'string') {\n this.result = \"\".concat(this.result, \" / \").concat(num);\n }\n this.lowPriority = false;\n return this;\n }\n }, {\n key: \"getResult\",\n value: function getResult(force) {\n return this.lowPriority || force ? \"(\".concat(this.result, \")\") : this.result;\n }\n }, {\n key: \"equal\",\n value: function equal(options) {\n var _this2 = this;\n var _ref = options || {},\n cssUnit = _ref.unit;\n var mergedUnit = true;\n if (typeof cssUnit === 'boolean') {\n mergedUnit = cssUnit;\n } else if (Array.from(this.unitlessCssVar).some(function (cssVar) {\n return _this2.result.includes(cssVar);\n })) {\n mergedUnit = false;\n }\n this.result = this.result.replace(regexp, mergedUnit ? 'px' : '');\n if (typeof this.lowPriority !== 'undefined') {\n return \"calc(\".concat(this.result, \")\");\n }\n return this.result;\n }\n }]);\n return CSSCalculator;\n}(AbstractCalculator);\nexport { CSSCalculator as default };","import _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/esm/createClass\";\nimport _assertThisInitialized from \"@babel/runtime/helpers/esm/assertThisInitialized\";\nimport _inherits from \"@babel/runtime/helpers/esm/inherits\";\nimport _createSuper from \"@babel/runtime/helpers/esm/createSuper\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport AbstractCalculator from \"./calculator\";\nvar NumCalculator = /*#__PURE__*/function (_AbstractCalculator) {\n _inherits(NumCalculator, _AbstractCalculator);\n var _super = _createSuper(NumCalculator);\n function NumCalculator(num) {\n var _this;\n _classCallCheck(this, NumCalculator);\n _this = _super.call(this);\n _defineProperty(_assertThisInitialized(_this), \"result\", 0);\n if (num instanceof NumCalculator) {\n _this.result = num.result;\n } else if (typeof num === 'number') {\n _this.result = num;\n }\n return _this;\n }\n _createClass(NumCalculator, [{\n key: \"add\",\n value: function add(num) {\n if (num instanceof NumCalculator) {\n this.result += num.result;\n } else if (typeof num === 'number') {\n this.result += num;\n }\n return this;\n }\n }, {\n key: \"sub\",\n value: function sub(num) {\n if (num instanceof NumCalculator) {\n this.result -= num.result;\n } else if (typeof num === 'number') {\n this.result -= num;\n }\n return this;\n }\n }, {\n key: \"mul\",\n value: function mul(num) {\n if (num instanceof NumCalculator) {\n this.result *= num.result;\n } else if (typeof num === 'number') {\n this.result *= num;\n }\n return this;\n }\n }, {\n key: \"div\",\n value: function div(num) {\n if (num instanceof NumCalculator) {\n this.result /= num.result;\n } else if (typeof num === 'number') {\n this.result /= num;\n }\n return this;\n }\n }, {\n key: \"equal\",\n value: function equal() {\n return this.result;\n }\n }]);\n return NumCalculator;\n}(AbstractCalculator);\nexport { NumCalculator as default };","import CSSCalculator from \"./CSSCalculator\";\nimport NumCalculator from \"./NumCalculator\";\nvar genCalc = function genCalc(type, unitlessCssVar) {\n var Calculator = type === 'css' ? CSSCalculator : NumCalculator;\n return function (num) {\n return new Calculator(num, unitlessCssVar);\n };\n};\nexport default genCalc;","import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/esm/createClass\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\n// ================================== Cache ==================================\n\nexport function sameDerivativeOption(left, right) {\n if (left.length !== right.length) {\n return false;\n }\n for (var i = 0; i < left.length; i++) {\n if (left[i] !== right[i]) {\n return false;\n }\n }\n return true;\n}\nvar ThemeCache = /*#__PURE__*/function () {\n function ThemeCache() {\n _classCallCheck(this, ThemeCache);\n _defineProperty(this, \"cache\", void 0);\n _defineProperty(this, \"keys\", void 0);\n _defineProperty(this, \"cacheCallTimes\", void 0);\n this.cache = new Map();\n this.keys = [];\n this.cacheCallTimes = 0;\n }\n _createClass(ThemeCache, [{\n key: \"size\",\n value: function size() {\n return this.keys.length;\n }\n }, {\n key: \"internalGet\",\n value: function internalGet(derivativeOption) {\n var _cache2, _cache3;\n var updateCallTimes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n var cache = {\n map: this.cache\n };\n derivativeOption.forEach(function (derivative) {\n if (!cache) {\n cache = undefined;\n } else {\n var _cache;\n cache = (_cache = cache) === null || _cache === void 0 || (_cache = _cache.map) === null || _cache === void 0 ? void 0 : _cache.get(derivative);\n }\n });\n if ((_cache2 = cache) !== null && _cache2 !== void 0 && _cache2.value && updateCallTimes) {\n cache.value[1] = this.cacheCallTimes++;\n }\n return (_cache3 = cache) === null || _cache3 === void 0 ? void 0 : _cache3.value;\n }\n }, {\n key: \"get\",\n value: function get(derivativeOption) {\n var _this$internalGet;\n return (_this$internalGet = this.internalGet(derivativeOption, true)) === null || _this$internalGet === void 0 ? void 0 : _this$internalGet[0];\n }\n }, {\n key: \"has\",\n value: function has(derivativeOption) {\n return !!this.internalGet(derivativeOption);\n }\n }, {\n key: \"set\",\n value: function set(derivativeOption, value) {\n var _this = this;\n // New cache\n if (!this.has(derivativeOption)) {\n if (this.size() + 1 > ThemeCache.MAX_CACHE_SIZE + ThemeCache.MAX_CACHE_OFFSET) {\n var _this$keys$reduce = this.keys.reduce(function (result, key) {\n var _result = _slicedToArray(result, 2),\n callTimes = _result[1];\n if (_this.internalGet(key)[1] < callTimes) {\n return [key, _this.internalGet(key)[1]];\n }\n return result;\n }, [this.keys[0], this.cacheCallTimes]),\n _this$keys$reduce2 = _slicedToArray(_this$keys$reduce, 1),\n targetKey = _this$keys$reduce2[0];\n this.delete(targetKey);\n }\n this.keys.push(derivativeOption);\n }\n var cache = this.cache;\n derivativeOption.forEach(function (derivative, index) {\n if (index === derivativeOption.length - 1) {\n cache.set(derivative, {\n value: [value, _this.cacheCallTimes++]\n });\n } else {\n var cacheValue = cache.get(derivative);\n if (!cacheValue) {\n cache.set(derivative, {\n map: new Map()\n });\n } else if (!cacheValue.map) {\n cacheValue.map = new Map();\n }\n cache = cache.get(derivative).map;\n }\n });\n }\n }, {\n key: \"deleteByPath\",\n value: function deleteByPath(currentCache, derivatives) {\n var cache = currentCache.get(derivatives[0]);\n if (derivatives.length === 1) {\n var _cache$value;\n if (!cache.map) {\n currentCache.delete(derivatives[0]);\n } else {\n currentCache.set(derivatives[0], {\n map: cache.map\n });\n }\n return (_cache$value = cache.value) === null || _cache$value === void 0 ? void 0 : _cache$value[0];\n }\n var result = this.deleteByPath(cache.map, derivatives.slice(1));\n if ((!cache.map || cache.map.size === 0) && !cache.value) {\n currentCache.delete(derivatives[0]);\n }\n return result;\n }\n }, {\n key: \"delete\",\n value: function _delete(derivativeOption) {\n // If cache exists\n if (this.has(derivativeOption)) {\n this.keys = this.keys.filter(function (item) {\n return !sameDerivativeOption(item, derivativeOption);\n });\n return this.deleteByPath(this.cache, derivativeOption);\n }\n return undefined;\n }\n }]);\n return ThemeCache;\n}();\n_defineProperty(ThemeCache, \"MAX_CACHE_SIZE\", 20);\n_defineProperty(ThemeCache, \"MAX_CACHE_OFFSET\", 5);\nexport { ThemeCache as default };","import _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/esm/createClass\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport { warning } from \"rc-util/es/warning\";\nvar uuid = 0;\n\n/**\n * Theme with algorithms to derive tokens from design tokens.\n * Use `createTheme` first which will help to manage the theme instance cache.\n */\nvar Theme = /*#__PURE__*/function () {\n function Theme(derivatives) {\n _classCallCheck(this, Theme);\n _defineProperty(this, \"derivatives\", void 0);\n _defineProperty(this, \"id\", void 0);\n this.derivatives = Array.isArray(derivatives) ? derivatives : [derivatives];\n this.id = uuid;\n if (derivatives.length === 0) {\n warning(derivatives.length > 0, '[Ant Design CSS-in-JS] Theme should have at least one derivative function.');\n }\n uuid += 1;\n }\n _createClass(Theme, [{\n key: \"getDerivativeToken\",\n value: function getDerivativeToken(token) {\n return this.derivatives.reduce(function (result, derivative) {\n return derivative(token, result);\n }, undefined);\n }\n }]);\n return Theme;\n}();\nexport { Theme as default };","import ThemeCache from \"./ThemeCache\";\nimport Theme from \"./Theme\";\nvar cacheThemes = new ThemeCache();\n\n/**\n * Same as new Theme, but will always return same one if `derivative` not changed.\n */\nexport default function createTheme(derivatives) {\n var derivativeArr = Array.isArray(derivatives) ? derivatives : [derivatives];\n // Create new theme if not exist\n if (!cacheThemes.has(derivativeArr)) {\n cacheThemes.set(derivativeArr, new Theme(derivativeArr));\n }\n\n // Get theme from cache and return\n return cacheThemes.get(derivativeArr);\n}","import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport hash from '@emotion/hash';\nimport canUseDom from \"rc-util/es/Dom/canUseDom\";\nimport { removeCSS, updateCSS } from \"rc-util/es/Dom/dynamicCSS\";\nimport { ATTR_MARK, ATTR_TOKEN } from \"../StyleContext\";\nimport { Theme } from \"../theme\";\n\n// Create a cache for memo concat\n\nvar resultCache = new WeakMap();\nvar RESULT_VALUE = {};\nexport function memoResult(callback, deps) {\n var current = resultCache;\n for (var i = 0; i < deps.length; i += 1) {\n var dep = deps[i];\n if (!current.has(dep)) {\n current.set(dep, new WeakMap());\n }\n current = current.get(dep);\n }\n if (!current.has(RESULT_VALUE)) {\n current.set(RESULT_VALUE, callback());\n }\n return current.get(RESULT_VALUE);\n}\n\n// Create a cache here to avoid always loop generate\nvar flattenTokenCache = new WeakMap();\n\n/**\n * Flatten token to string, this will auto cache the result when token not change\n */\nexport function flattenToken(token) {\n var str = flattenTokenCache.get(token) || '';\n if (!str) {\n Object.keys(token).forEach(function (key) {\n var value = token[key];\n str += key;\n if (value instanceof Theme) {\n str += value.id;\n } else if (value && _typeof(value) === 'object') {\n str += flattenToken(value);\n } else {\n str += value;\n }\n });\n\n // https://github.com/ant-design/ant-design/issues/48386\n // Should hash the string to avoid style tag name too long\n str = hash(str);\n\n // Put in cache\n flattenTokenCache.set(token, str);\n }\n return str;\n}\n\n/**\n * Convert derivative token to key string\n */\nexport function token2key(token, salt) {\n return hash(\"\".concat(salt, \"_\").concat(flattenToken(token)));\n}\nvar randomSelectorKey = \"random-\".concat(Date.now(), \"-\").concat(Math.random()).replace(/\\./g, '');\n\n// Magic `content` for detect selector support\nvar checkContent = '_bAmBoO_';\nfunction supportSelector(styleStr, handleElement, supportCheck) {\n if (canUseDom()) {\n var _getComputedStyle$con, _ele$parentNode;\n updateCSS(styleStr, randomSelectorKey);\n var _ele = document.createElement('div');\n _ele.style.position = 'fixed';\n _ele.style.left = '0';\n _ele.style.top = '0';\n handleElement === null || handleElement === void 0 || handleElement(_ele);\n document.body.appendChild(_ele);\n if (process.env.NODE_ENV !== 'production') {\n _ele.innerHTML = 'Test';\n _ele.style.zIndex = '9999999';\n }\n var support = supportCheck ? supportCheck(_ele) : (_getComputedStyle$con = getComputedStyle(_ele).content) === null || _getComputedStyle$con === void 0 ? void 0 : _getComputedStyle$con.includes(checkContent);\n (_ele$parentNode = _ele.parentNode) === null || _ele$parentNode === void 0 || _ele$parentNode.removeChild(_ele);\n removeCSS(randomSelectorKey);\n return support;\n }\n return false;\n}\nvar canLayer = undefined;\nexport function supportLayer() {\n if (canLayer === undefined) {\n canLayer = supportSelector(\"@layer \".concat(randomSelectorKey, \" { .\").concat(randomSelectorKey, \" { content: \\\"\").concat(checkContent, \"\\\"!important; } }\"), function (ele) {\n ele.className = randomSelectorKey;\n });\n }\n return canLayer;\n}\nvar canWhere = undefined;\nexport function supportWhere() {\n if (canWhere === undefined) {\n canWhere = supportSelector(\":where(.\".concat(randomSelectorKey, \") { content: \\\"\").concat(checkContent, \"\\\"!important; }\"), function (ele) {\n ele.className = randomSelectorKey;\n });\n }\n return canWhere;\n}\nvar canLogic = undefined;\nexport function supportLogicProps() {\n if (canLogic === undefined) {\n canLogic = supportSelector(\".\".concat(randomSelectorKey, \" { inset-block: 93px !important; }\"), function (ele) {\n ele.className = randomSelectorKey;\n }, function (ele) {\n return getComputedStyle(ele).bottom === '93px';\n });\n }\n return canLogic;\n}\nexport var isClientSide = canUseDom();\nexport function unit(num) {\n if (typeof num === 'number') {\n return \"\".concat(num, \"px\");\n }\n return num;\n}\nexport function toStyleStr(style, tokenKey, styleId) {\n var _objectSpread2;\n var customizeAttrs = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};\n var plain = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;\n if (plain) {\n return style;\n }\n var attrs = _objectSpread(_objectSpread({}, customizeAttrs), {}, (_objectSpread2 = {}, _defineProperty(_objectSpread2, ATTR_TOKEN, tokenKey), _defineProperty(_objectSpread2, ATTR_MARK, styleId), _objectSpread2));\n var attrStr = Object.keys(attrs).map(function (attr) {\n var val = attrs[attr];\n return val ? \"\".concat(attr, \"=\\\"\").concat(val, \"\\\"\") : null;\n }).filter(function (v) {\n return v;\n }).join(' ');\n return \"\");\n}","import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nexport var token2CSSVar = function token2CSSVar(token) {\n var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';\n return \"--\".concat(prefix ? \"\".concat(prefix, \"-\") : '').concat(token).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();\n};\nexport var serializeCSSVar = function serializeCSSVar(cssVars, hashId, options) {\n if (!Object.keys(cssVars).length) {\n return '';\n }\n return \".\".concat(hashId).concat(options !== null && options !== void 0 && options.scope ? \".\".concat(options.scope) : '', \"{\").concat(Object.entries(cssVars).map(function (_ref) {\n var _ref2 = _slicedToArray(_ref, 2),\n key = _ref2[0],\n value = _ref2[1];\n return \"\".concat(key, \":\").concat(value, \";\");\n }).join(''), \"}\");\n};\nexport var transformToken = function transformToken(token, themeKey, config) {\n var cssVars = {};\n var result = {};\n Object.entries(token).forEach(function (_ref3) {\n var _config$preserve, _config$ignore;\n var _ref4 = _slicedToArray(_ref3, 2),\n key = _ref4[0],\n value = _ref4[1];\n if (config !== null && config !== void 0 && (_config$preserve = config.preserve) !== null && _config$preserve !== void 0 && _config$preserve[key]) {\n result[key] = value;\n } 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])) {\n var _config$unitless;\n var cssVar = token2CSSVar(key, config === null || config === void 0 ? void 0 : config.prefix);\n 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);\n result[key] = \"var(\".concat(cssVar, \")\");\n }\n });\n return [result, serializeCSSVar(cssVars, themeKey, {\n scope: config === null || config === void 0 ? void 0 : config.scope\n })];\n};","import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\n// import canUseDom from 'rc-util/lib/Dom/canUseDom';\nimport useLayoutEffect from \"rc-util/es/hooks/useLayoutEffect\";\nimport * as React from 'react';\n\n// We need fully clone React function here\n// to avoid webpack warning React 17 do not export `useId`\nvar fullClone = _objectSpread({}, React);\nvar useInsertionEffect = fullClone.useInsertionEffect;\n/**\n * Polyfill `useInsertionEffect` for React < 18\n * @param renderEffect will be executed in `useMemo`, and do not have callback\n * @param effect will be executed in `useLayoutEffect`\n * @param deps\n */\nvar useInsertionEffectPolyfill = function useInsertionEffectPolyfill(renderEffect, effect, deps) {\n React.useMemo(renderEffect, deps);\n useLayoutEffect(function () {\n return effect(true);\n }, deps);\n};\n\n/**\n * Compatible `useInsertionEffect`\n * will use `useInsertionEffect` if React version >= 18,\n * otherwise use `useInsertionEffectPolyfill`.\n */\nvar useCompatibleInsertionEffect = useInsertionEffect ? function (renderEffect, effect, deps) {\n return useInsertionEffect(function () {\n renderEffect();\n return effect();\n }, deps);\n} : useInsertionEffectPolyfill;\nexport default useCompatibleInsertionEffect;","import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport { warning } from \"rc-util/es/warning\";\nimport * as React from 'react';\nvar fullClone = _objectSpread({}, React);\nvar useInsertionEffect = fullClone.useInsertionEffect;\n\n// DO NOT register functions in useEffect cleanup function, or functions that registered will never be called.\nvar useCleanupRegister = function useCleanupRegister(deps) {\n var effectCleanups = [];\n var cleanupFlag = false;\n function register(fn) {\n if (cleanupFlag) {\n if (process.env.NODE_ENV !== 'production') {\n warning(false, '[Ant Design CSS-in-JS] You are registering a cleanup function after unmount, which will not have any effect.');\n }\n return;\n }\n effectCleanups.push(fn);\n }\n React.useEffect(function () {\n // Compatible with strict mode\n cleanupFlag = false;\n return function () {\n cleanupFlag = true;\n if (effectCleanups.length) {\n effectCleanups.forEach(function (fn) {\n return fn();\n });\n }\n };\n }, deps);\n return register;\n};\nvar useRun = function useRun() {\n return function (fn) {\n fn();\n };\n};\n\n// Only enable register in React 18\nvar useEffectCleanupRegister = typeof useInsertionEffect !== 'undefined' ? useCleanupRegister : useRun;\nexport default useEffectCleanupRegister;","function useProdHMR() {\n return false;\n}\nvar webpackHMR = false;\nfunction useDevHMR() {\n return webpackHMR;\n}\nexport default process.env.NODE_ENV === 'production' ? useProdHMR : useDevHMR;\n\n// Webpack `module.hot.accept` do not support any deps update trigger\n// We have to hack handler to force mark as HRM\nif (process.env.NODE_ENV !== 'production' && typeof module !== 'undefined' && module && module.hot && typeof window !== 'undefined') {\n // Use `globalThis` first, and `window` for older browsers\n // const win = globalThis as any;\n var win = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : null;\n if (win && typeof win.webpackHotUpdate === 'function') {\n var originWebpackHotUpdate = win.webpackHotUpdate;\n win.webpackHotUpdate = function () {\n webpackHMR = true;\n setTimeout(function () {\n webpackHMR = false;\n }, 0);\n return originWebpackHotUpdate.apply(void 0, arguments);\n };\n }\n}","import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport * as React from 'react';\nimport { pathKey } from \"../Cache\";\nimport StyleContext from \"../StyleContext\";\nimport useCompatibleInsertionEffect from \"./useCompatibleInsertionEffect\";\nimport useEffectCleanupRegister from \"./useEffectCleanupRegister\";\nimport useHMR from \"./useHMR\";\nexport default function useGlobalCache(prefix, keyPath, cacheFn, onCacheRemove,\n// Add additional effect trigger by `useInsertionEffect`\nonCacheEffect) {\n var _React$useContext = React.useContext(StyleContext),\n globalCache = _React$useContext.cache;\n var fullPath = [prefix].concat(_toConsumableArray(keyPath));\n var fullPathStr = pathKey(fullPath);\n var register = useEffectCleanupRegister([fullPathStr]);\n var HMRUpdate = useHMR();\n var buildCache = function buildCache(updater) {\n globalCache.opUpdate(fullPathStr, function (prevCache) {\n var _ref = prevCache || [undefined, undefined],\n _ref2 = _slicedToArray(_ref, 2),\n _ref2$ = _ref2[0],\n times = _ref2$ === void 0 ? 0 : _ref2$,\n cache = _ref2[1];\n\n // HMR should always ignore cache since developer may change it\n var tmpCache = cache;\n if (process.env.NODE_ENV !== 'production' && cache && HMRUpdate) {\n onCacheRemove === null || onCacheRemove === void 0 || onCacheRemove(tmpCache, HMRUpdate);\n tmpCache = null;\n }\n var mergedCache = tmpCache || cacheFn();\n var data = [times, mergedCache];\n\n // Call updater if need additional logic\n return updater ? updater(data) : data;\n });\n };\n\n // Create cache\n React.useMemo(function () {\n buildCache();\n }, /* eslint-disable react-hooks/exhaustive-deps */\n [fullPathStr]\n /* eslint-enable */);\n\n var cacheEntity = globalCache.opGet(fullPathStr);\n\n // HMR clean the cache but not trigger `useMemo` again\n // Let's fallback of this\n // ref https://github.com/ant-design/cssinjs/issues/127\n if (process.env.NODE_ENV !== 'production' && !cacheEntity) {\n buildCache();\n cacheEntity = globalCache.opGet(fullPathStr);\n }\n var cacheContent = cacheEntity[1];\n\n // Remove if no need anymore\n useCompatibleInsertionEffect(function () {\n onCacheEffect === null || onCacheEffect === void 0 || onCacheEffect(cacheContent);\n }, function (polyfill) {\n // It's bad to call build again in effect.\n // But we have to do this since StrictMode will call effect twice\n // which will clear cache on the first time.\n buildCache(function (_ref3) {\n var _ref4 = _slicedToArray(_ref3, 2),\n times = _ref4[0],\n cache = _ref4[1];\n if (polyfill && times === 0) {\n onCacheEffect === null || onCacheEffect === void 0 || onCacheEffect(cacheContent);\n }\n return [times + 1, cache];\n });\n return function () {\n globalCache.opUpdate(fullPathStr, function (prevCache) {\n var _ref5 = prevCache || [],\n _ref6 = _slicedToArray(_ref5, 2),\n _ref6$ = _ref6[0],\n times = _ref6$ === void 0 ? 0 : _ref6$,\n cache = _ref6[1];\n var nextCount = times - 1;\n if (nextCount === 0) {\n // Always remove styles in useEffect callback\n register(function () {\n // With polyfill, registered callback will always be called synchronously\n // But without polyfill, it will be called in effect clean up,\n // And by that time this cache is cleaned up.\n if (polyfill || !globalCache.opGet(fullPathStr)) {\n onCacheRemove === null || onCacheRemove === void 0 || onCacheRemove(cache, false);\n }\n });\n return null;\n }\n return [times - 1, cache];\n });\n };\n }, [fullPathStr]);\n return cacheContent;\n}","import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport hash from '@emotion/hash';\nimport { updateCSS } from \"rc-util/es/Dom/dynamicCSS\";\nimport { useContext } from 'react';\nimport StyleContext, { ATTR_MARK, ATTR_TOKEN, CSS_IN_JS_INSTANCE } from \"../StyleContext\";\nimport { flattenToken, memoResult, token2key, toStyleStr } from \"../util\";\nimport { transformToken } from \"../util/css-variables\";\nimport useGlobalCache from \"./useGlobalCache\";\nvar EMPTY_OVERRIDE = {};\n\n// Generate different prefix to make user selector break in production env.\n// This helps developer not to do style override directly on the hash id.\nvar hashPrefix = process.env.NODE_ENV !== 'production' ? 'css-dev-only-do-not-override' : 'css';\nvar tokenKeys = new Map();\nfunction recordCleanToken(tokenKey) {\n tokenKeys.set(tokenKey, (tokenKeys.get(tokenKey) || 0) + 1);\n}\nfunction removeStyleTags(key, instanceId) {\n if (typeof document !== 'undefined') {\n var styles = document.querySelectorAll(\"style[\".concat(ATTR_TOKEN, \"=\\\"\").concat(key, \"\\\"]\"));\n styles.forEach(function (style) {\n if (style[CSS_IN_JS_INSTANCE] === instanceId) {\n var _style$parentNode;\n (_style$parentNode = style.parentNode) === null || _style$parentNode === void 0 || _style$parentNode.removeChild(style);\n }\n });\n }\n}\nvar TOKEN_THRESHOLD = 0;\n\n// Remove will check current keys first\nfunction cleanTokenStyle(tokenKey, instanceId) {\n tokenKeys.set(tokenKey, (tokenKeys.get(tokenKey) || 0) - 1);\n var tokenKeyList = Array.from(tokenKeys.keys());\n var cleanableKeyList = tokenKeyList.filter(function (key) {\n var count = tokenKeys.get(key) || 0;\n return count <= 0;\n });\n\n // Should keep tokens under threshold for not to insert style too often\n if (tokenKeyList.length - cleanableKeyList.length > TOKEN_THRESHOLD) {\n cleanableKeyList.forEach(function (key) {\n removeStyleTags(key, instanceId);\n tokenKeys.delete(key);\n });\n }\n}\nexport var getComputedToken = function getComputedToken(originToken, overrideToken, theme, format) {\n var derivativeToken = theme.getDerivativeToken(originToken);\n\n // Merge with override\n var mergedDerivativeToken = _objectSpread(_objectSpread({}, derivativeToken), overrideToken);\n\n // Format if needed\n if (format) {\n mergedDerivativeToken = format(mergedDerivativeToken);\n }\n return mergedDerivativeToken;\n};\nexport var TOKEN_PREFIX = 'token';\n/**\n * Cache theme derivative token as global shared one\n * @param theme Theme entity\n * @param tokens List of tokens, used for cache. Please do not dynamic generate object directly\n * @param option Additional config\n * @returns Call Theme.getDerivativeToken(tokenObject) to get token\n */\nexport default function useCacheToken(theme, tokens) {\n var option = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n var _useContext = useContext(StyleContext),\n instanceId = _useContext.cache.instanceId,\n container = _useContext.container;\n var _option$salt = option.salt,\n salt = _option$salt === void 0 ? '' : _option$salt,\n _option$override = option.override,\n override = _option$override === void 0 ? EMPTY_OVERRIDE : _option$override,\n formatToken = option.formatToken,\n compute = option.getComputedToken,\n cssVar = option.cssVar;\n\n // Basic - We do basic cache here\n var mergedToken = memoResult(function () {\n return Object.assign.apply(Object, [{}].concat(_toConsumableArray(tokens)));\n }, tokens);\n var tokenStr = flattenToken(mergedToken);\n var overrideTokenStr = flattenToken(override);\n var cssVarStr = cssVar ? flattenToken(cssVar) : '';\n var cachedToken = useGlobalCache(TOKEN_PREFIX, [salt, theme.id, tokenStr, overrideTokenStr, cssVarStr], function () {\n var _cssVar$key;\n var mergedDerivativeToken = compute ? compute(mergedToken, override, theme) : getComputedToken(mergedToken, override, theme, formatToken);\n\n // Replace token value with css variables\n var actualToken = _objectSpread({}, mergedDerivativeToken);\n var cssVarsStr = '';\n if (!!cssVar) {\n var _transformToken = transformToken(mergedDerivativeToken, cssVar.key, {\n prefix: cssVar.prefix,\n ignore: cssVar.ignore,\n unitless: cssVar.unitless,\n preserve: cssVar.preserve\n });\n var _transformToken2 = _slicedToArray(_transformToken, 2);\n mergedDerivativeToken = _transformToken2[0];\n cssVarsStr = _transformToken2[1];\n }\n\n // Optimize for `useStyleRegister` performance\n var tokenKey = token2key(mergedDerivativeToken, salt);\n mergedDerivativeToken._tokenKey = tokenKey;\n actualToken._tokenKey = token2key(actualToken, salt);\n var themeKey = (_cssVar$key = cssVar === null || cssVar === void 0 ? void 0 : cssVar.key) !== null && _cssVar$key !== void 0 ? _cssVar$key : tokenKey;\n mergedDerivativeToken._themeKey = themeKey;\n recordCleanToken(themeKey);\n var hashId = \"\".concat(hashPrefix, \"-\").concat(hash(tokenKey));\n mergedDerivativeToken._hashId = hashId; // Not used\n\n return [mergedDerivativeToken, hashId, actualToken, cssVarsStr, (cssVar === null || cssVar === void 0 ? void 0 : cssVar.key) || ''];\n }, function (cache) {\n // Remove token will remove all related style\n cleanTokenStyle(cache[0]._themeKey, instanceId);\n }, function (_ref) {\n var _ref2 = _slicedToArray(_ref, 4),\n token = _ref2[0],\n cssVarsStr = _ref2[3];\n if (cssVar && cssVarsStr) {\n var style = updateCSS(cssVarsStr, hash(\"css-variables-\".concat(token._themeKey)), {\n mark: ATTR_MARK,\n prepend: 'queue',\n attachTo: container,\n priority: -999\n });\n style[CSS_IN_JS_INSTANCE] = instanceId;\n\n // Used for `useCacheToken` to remove on batch when token removed\n style.setAttribute(ATTR_TOKEN, token._themeKey);\n }\n });\n return cachedToken;\n}\nexport var extract = function extract(cache, effectStyles, options) {\n var _cache = _slicedToArray(cache, 5),\n realToken = _cache[2],\n styleStr = _cache[3],\n cssVarKey = _cache[4];\n var _ref3 = options || {},\n plain = _ref3.plain;\n if (!styleStr) {\n return null;\n }\n var styleId = realToken._tokenKey;\n var order = -999;\n\n // ====================== Style ======================\n // Used for rc-util\n var sharedAttrs = {\n 'data-rc-order': 'prependQueue',\n 'data-rc-priority': \"\".concat(order)\n };\n var styleText = toStyleStr(styleStr, cssVarKey, styleId, sharedAttrs, plain);\n return [order, styleId, styleText];\n};","var unitlessKeys = {\n animationIterationCount: 1,\n borderImageOutset: 1,\n borderImageSlice: 1,\n borderImageWidth: 1,\n boxFlex: 1,\n boxFlexGroup: 1,\n boxOrdinalGroup: 1,\n columnCount: 1,\n columns: 1,\n flex: 1,\n flexGrow: 1,\n flexPositive: 1,\n flexShrink: 1,\n flexNegative: 1,\n flexOrder: 1,\n gridRow: 1,\n gridRowEnd: 1,\n gridRowSpan: 1,\n gridRowStart: 1,\n gridColumn: 1,\n gridColumnEnd: 1,\n gridColumnSpan: 1,\n gridColumnStart: 1,\n msGridRow: 1,\n msGridRowSpan: 1,\n msGridColumn: 1,\n msGridColumnSpan: 1,\n fontWeight: 1,\n lineHeight: 1,\n opacity: 1,\n order: 1,\n orphans: 1,\n tabSize: 1,\n widows: 1,\n zIndex: 1,\n zoom: 1,\n WebkitLineClamp: 1,\n // SVG-related properties\n fillOpacity: 1,\n floodOpacity: 1,\n stopOpacity: 1,\n strokeDasharray: 1,\n strokeDashoffset: 1,\n strokeMiterlimit: 1,\n strokeOpacity: 1,\n strokeWidth: 1\n};\n\nexport default unitlessKeys;\n","export var MS = '-ms-'\nexport var MOZ = '-moz-'\nexport var WEBKIT = '-webkit-'\n\nexport var COMMENT = 'comm'\nexport var RULESET = 'rule'\nexport var DECLARATION = 'decl'\n\nexport var PAGE = '@page'\nexport var MEDIA = '@media'\nexport var IMPORT = '@import'\nexport var CHARSET = '@charset'\nexport var VIEWPORT = '@viewport'\nexport var SUPPORTS = '@supports'\nexport var DOCUMENT = '@document'\nexport var NAMESPACE = '@namespace'\nexport var KEYFRAMES = '@keyframes'\nexport var FONT_FACE = '@font-face'\nexport var COUNTER_STYLE = '@counter-style'\nexport var FONT_FEATURE_VALUES = '@font-feature-values'\nexport var LAYER = '@layer'\nexport var SCOPE = '@scope'\n","/**\n * @param {number}\n * @return {number}\n */\nexport var abs = Math.abs\n\n/**\n * @param {number}\n * @return {string}\n */\nexport var from = String.fromCharCode\n\n/**\n * @param {object}\n * @return {object}\n */\nexport var assign = Object.assign\n\n/**\n * @param {string} value\n * @param {number} length\n * @return {number}\n */\nexport function hash (value, length) {\n\treturn charat(value, 0) ^ 45 ? (((((((length << 2) ^ charat(value, 0)) << 2) ^ charat(value, 1)) << 2) ^ charat(value, 2)) << 2) ^ charat(value, 3) : 0\n}\n\n/**\n * @param {string} value\n * @return {string}\n */\nexport function trim (value) {\n\treturn value.trim()\n}\n\n/**\n * @param {string} value\n * @param {RegExp} pattern\n * @return {string?}\n */\nexport function match (value, pattern) {\n\treturn (value = pattern.exec(value)) ? value[0] : value\n}\n\n/**\n * @param {string} value\n * @param {(string|RegExp)} pattern\n * @param {string} replacement\n * @return {string}\n */\nexport function replace (value, pattern, replacement) {\n\treturn value.replace(pattern, replacement)\n}\n\n/**\n * @param {string} value\n * @param {string} search\n * @param {number} position\n * @return {number}\n */\nexport function indexof (value, search, position) {\n\treturn value.indexOf(search, position)\n}\n\n/**\n * @param {string} value\n * @param {number} index\n * @return {number}\n */\nexport function charat (value, index) {\n\treturn value.charCodeAt(index) | 0\n}\n\n/**\n * @param {string} value\n * @param {number} begin\n * @param {number} end\n * @return {string}\n */\nexport function substr (value, begin, end) {\n\treturn value.slice(begin, end)\n}\n\n/**\n * @param {string} value\n * @return {number}\n */\nexport function strlen (value) {\n\treturn value.length\n}\n\n/**\n * @param {any[]} value\n * @return {number}\n */\nexport function sizeof (value) {\n\treturn value.length\n}\n\n/**\n * @param {any} value\n * @param {any[]} array\n * @return {any}\n */\nexport function append (value, array) {\n\treturn array.push(value), value\n}\n\n/**\n * @param {string[]} array\n * @param {function} callback\n * @return {string}\n */\nexport function combine (array, callback) {\n\treturn array.map(callback).join('')\n}\n\n/**\n * @param {string[]} array\n * @param {RegExp} pattern\n * @return {string[]}\n */\nexport function filter (array, pattern) {\n\treturn array.filter(function (value) { return !match(value, pattern) })\n}\n","import {IMPORT, LAYER, COMMENT, RULESET, DECLARATION, KEYFRAMES, NAMESPACE} from './Enum.js'\nimport {strlen} from './Utility.js'\n\n/**\n * @param {object[]} children\n * @param {function} callback\n * @return {string}\n */\nexport function serialize (children, callback) {\n\tvar output = ''\n\n\tfor (var i = 0; i < children.length; i++)\n\t\toutput += callback(children[i], i, children, callback) || ''\n\n\treturn output\n}\n\n/**\n * @param {object} element\n * @param {number} index\n * @param {object[]} children\n * @param {function} callback\n * @return {string}\n */\nexport function stringify (element, index, children, callback) {\n\tswitch (element.type) {\n\t\tcase LAYER: if (element.children.length) break\n\t\tcase IMPORT: case NAMESPACE: case DECLARATION: return element.return = element.return || element.value\n\t\tcase COMMENT: return ''\n\t\tcase KEYFRAMES: return element.return = element.value + '{' + serialize(element.children, callback) + '}'\n\t\tcase RULESET: if (!strlen(element.value = element.props.join(','))) return ''\n\t}\n\n\treturn strlen(children = serialize(element.children, callback)) ? element.return = element.value + '{' + children + '}' : ''\n}\n","import {from, trim, charat, strlen, substr, append, assign} from './Utility.js'\n\nexport var line = 1\nexport var column = 1\nexport var length = 0\nexport var position = 0\nexport var character = 0\nexport var characters = ''\n\n/**\n * @param {string} value\n * @param {object | null} root\n * @param {object | null} parent\n * @param {string} type\n * @param {string[] | string} props\n * @param {object[] | string} children\n * @param {object[]} siblings\n * @param {number} length\n */\nexport function node (value, root, parent, type, props, children, length, siblings) {\n\treturn {value: value, root: root, parent: parent, type: type, props: props, children: children, line: line, column: column, length: length, return: '', siblings: siblings}\n}\n\n/**\n * @param {object} root\n * @param {object} props\n * @return {object}\n */\nexport function copy (root, props) {\n\treturn assign(node('', null, null, '', null, null, 0, root.siblings), root, {length: -root.length}, props)\n}\n\n/**\n * @param {object} root\n */\nexport function lift (root) {\n\twhile (root.root)\n\t\troot = copy(root.root, {children: [root]})\n\n\tappend(root, root.siblings)\n}\n\n/**\n * @return {number}\n */\nexport function char () {\n\treturn character\n}\n\n/**\n * @return {number}\n */\nexport function prev () {\n\tcharacter = position > 0 ? charat(characters, --position) : 0\n\n\tif (column--, character === 10)\n\t\tcolumn = 1, line--\n\n\treturn character\n}\n\n/**\n * @return {number}\n */\nexport function next () {\n\tcharacter = position < length ? charat(characters, position++) : 0\n\n\tif (column++, character === 10)\n\t\tcolumn = 1, line++\n\n\treturn character\n}\n\n/**\n * @return {number}\n */\nexport function peek () {\n\treturn charat(characters, position)\n}\n\n/**\n * @return {number}\n */\nexport function caret () {\n\treturn position\n}\n\n/**\n * @param {number} begin\n * @param {number} end\n * @return {string}\n */\nexport function slice (begin, end) {\n\treturn substr(characters, begin, end)\n}\n\n/**\n * @param {number} type\n * @return {number}\n */\nexport function token (type) {\n\tswitch (type) {\n\t\t// \\0 \\t \\n \\r \\s whitespace token\n\t\tcase 0: case 9: case 10: case 13: case 32:\n\t\t\treturn 5\n\t\t// ! + , / > @ ~ isolate token\n\t\tcase 33: case 43: case 44: case 47: case 62: case 64: case 126:\n\t\t// ; { } breakpoint token\n\t\tcase 59: case 123: case 125:\n\t\t\treturn 4\n\t\t// : accompanied token\n\t\tcase 58:\n\t\t\treturn 3\n\t\t// \" ' ( [ opening delimit token\n\t\tcase 34: case 39: case 40: case 91:\n\t\t\treturn 2\n\t\t// ) ] closing delimit token\n\t\tcase 41: case 93:\n\t\t\treturn 1\n\t}\n\n\treturn 0\n}\n\n/**\n * @param {string} value\n * @return {any[]}\n */\nexport function alloc (value) {\n\treturn line = column = 1, length = strlen(characters = value), position = 0, []\n}\n\n/**\n * @param {any} value\n * @return {any}\n */\nexport function dealloc (value) {\n\treturn characters = '', value\n}\n\n/**\n * @param {number} type\n * @return {string}\n */\nexport function delimit (type) {\n\treturn trim(slice(position - 1, delimiter(type === 91 ? type + 2 : type === 40 ? type + 1 : type)))\n}\n\n/**\n * @param {string} value\n * @return {string[]}\n */\nexport function tokenize (value) {\n\treturn dealloc(tokenizer(alloc(value)))\n}\n\n/**\n * @param {number} type\n * @return {string}\n */\nexport function whitespace (type) {\n\twhile (character = peek())\n\t\tif (character < 33)\n\t\t\tnext()\n\t\telse\n\t\t\tbreak\n\n\treturn token(type) > 2 || token(character) > 3 ? '' : ' '\n}\n\n/**\n * @param {string[]} children\n * @return {string[]}\n */\nexport function tokenizer (children) {\n\twhile (next())\n\t\tswitch (token(character)) {\n\t\t\tcase 0: append(identifier(position - 1), children)\n\t\t\t\tbreak\n\t\t\tcase 2: append(delimit(character), children)\n\t\t\t\tbreak\n\t\t\tdefault: append(from(character), children)\n\t\t}\n\n\treturn children\n}\n\n/**\n * @param {number} index\n * @param {number} count\n * @return {string}\n */\nexport function escaping (index, count) {\n\twhile (--count && next())\n\t\t// not 0-9 A-F a-f\n\t\tif (character < 48 || character > 102 || (character > 57 && character < 65) || (character > 70 && character < 97))\n\t\t\tbreak\n\n\treturn slice(index, caret() + (count < 6 && peek() == 32 && next() == 32))\n}\n\n/**\n * @param {number} type\n * @return {number}\n */\nexport function delimiter (type) {\n\twhile (next())\n\t\tswitch (character) {\n\t\t\t// ] ) \" '\n\t\t\tcase type:\n\t\t\t\treturn position\n\t\t\t// \" '\n\t\t\tcase 34: case 39:\n\t\t\t\tif (type !== 34 && type !== 39)\n\t\t\t\t\tdelimiter(character)\n\t\t\t\tbreak\n\t\t\t// (\n\t\t\tcase 40:\n\t\t\t\tif (type === 41)\n\t\t\t\t\tdelimiter(type)\n\t\t\t\tbreak\n\t\t\t// \\\n\t\t\tcase 92:\n\t\t\t\tnext()\n\t\t\t\tbreak\n\t\t}\n\n\treturn position\n}\n\n/**\n * @param {number} type\n * @param {number} index\n * @return {number}\n */\nexport function commenter (type, index) {\n\twhile (next())\n\t\t// //\n\t\tif (type + character === 47 + 10)\n\t\t\tbreak\n\t\t// /*\n\t\telse if (type + character === 42 + 42 && peek() === 47)\n\t\t\tbreak\n\n\treturn '/*' + slice(index, position - 1) + '*' + from(type === 47 ? type : next())\n}\n\n/**\n * @param {number} index\n * @return {string}\n */\nexport function identifier (index) {\n\twhile (!token(peek()))\n\t\tnext()\n\n\treturn slice(index, position)\n}\n","import {COMMENT, RULESET, DECLARATION} from './Enum.js'\nimport {abs, charat, trim, from, sizeof, strlen, substr, append, replace, indexof} from './Utility.js'\nimport {node, char, prev, next, peek, token, caret, alloc, dealloc, delimit, whitespace, escaping, identifier, commenter} from './Tokenizer.js'\n\n/**\n * @param {string} value\n * @return {object[]}\n */\nexport function compile (value) {\n\treturn dealloc(parse('', null, null, null, [''], value = alloc(value), 0, [0], value))\n}\n\n/**\n * @param {string} value\n * @param {object} root\n * @param {object?} parent\n * @param {string[]} rule\n * @param {string[]} rules\n * @param {string[]} rulesets\n * @param {number[]} pseudo\n * @param {number[]} points\n * @param {string[]} declarations\n * @return {object}\n */\nexport function parse (value, root, parent, rule, rules, rulesets, pseudo, points, declarations) {\n\tvar index = 0\n\tvar offset = 0\n\tvar length = pseudo\n\tvar atrule = 0\n\tvar property = 0\n\tvar previous = 0\n\tvar variable = 1\n\tvar scanning = 1\n\tvar ampersand = 1\n\tvar character = 0\n\tvar type = ''\n\tvar props = rules\n\tvar children = rulesets\n\tvar reference = rule\n\tvar characters = type\n\n\twhile (scanning)\n\t\tswitch (previous = character, character = next()) {\n\t\t\t// (\n\t\t\tcase 40:\n\t\t\t\tif (previous != 108 && charat(characters, length - 1) == 58) {\n\t\t\t\t\tif (indexof(characters += replace(delimit(character), '&', '&\\f'), '&\\f', abs(index ? points[index - 1] : 0)) != -1)\n\t\t\t\t\t\tampersand = -1\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t// \" ' [\n\t\t\tcase 34: case 39: case 91:\n\t\t\t\tcharacters += delimit(character)\n\t\t\t\tbreak\n\t\t\t// \\t \\n \\r \\s\n\t\t\tcase 9: case 10: case 13: case 32:\n\t\t\t\tcharacters += whitespace(previous)\n\t\t\t\tbreak\n\t\t\t// \\\n\t\t\tcase 92:\n\t\t\t\tcharacters += escaping(caret() - 1, 7)\n\t\t\t\tcontinue\n\t\t\t// /\n\t\t\tcase 47:\n\t\t\t\tswitch (peek()) {\n\t\t\t\t\tcase 42: case 47:\n\t\t\t\t\t\tappend(comment(commenter(next(), caret()), root, parent, declarations), declarations)\n\t\t\t\t\t\tif ((token(previous || 1) == 5 || token(peek() || 1) == 5) && strlen(characters) && substr(characters, -1, void 0) !== ' ') characters += ' '\n\t\t\t\t\t\tbreak\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tcharacters += '/'\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t// {\n\t\t\tcase 123 * variable:\n\t\t\t\tpoints[index++] = strlen(characters) * ampersand\n\t\t\t// } ; \\0\n\t\t\tcase 125 * variable: case 59: case 0:\n\t\t\t\tswitch (character) {\n\t\t\t\t\t// \\0 }\n\t\t\t\t\tcase 0: case 125: scanning = 0\n\t\t\t\t\t// ;\n\t\t\t\t\tcase 59 + offset: if (ampersand == -1) characters = replace(characters, /\\f/g, '')\n\t\t\t\t\t\tif (property > 0 && (strlen(characters) - length || (variable === 0 && previous === 47)))\n\t\t\t\t\t\t\tappend(property > 32 ? declaration(characters + ';', rule, parent, length - 1, declarations) : declaration(replace(characters, ' ', '') + ';', rule, parent, length - 2, declarations), declarations)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t// @ ;\n\t\t\t\t\tcase 59: characters += ';'\n\t\t\t\t\t// { rule/at-rule\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tappend(reference = ruleset(characters, root, parent, index, offset, rules, points, type, props = [], children = [], length, rulesets), rulesets)\n\n\t\t\t\t\t\tif (character === 123)\n\t\t\t\t\t\t\tif (offset === 0)\n\t\t\t\t\t\t\t\tparse(characters, root, reference, reference, props, rulesets, length, points, children)\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tswitch (atrule) {\n\t\t\t\t\t\t\t\t\t// c(ontainer)\n\t\t\t\t\t\t\t\t\tcase 99:\n\t\t\t\t\t\t\t\t\t\tif (charat(characters, 3) === 110) break\n\t\t\t\t\t\t\t\t\t// l(ayer)\n\t\t\t\t\t\t\t\t\tcase 108:\n\t\t\t\t\t\t\t\t\t\tif (charat(characters, 2) === 97) break\n\t\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\t\toffset = 0\n\t\t\t\t\t\t\t\t\t// d(ocument) m(edia) s(upports)\n\t\t\t\t\t\t\t\t\tcase 100: case 109: case 115:\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (offset) parse(value, reference, reference, rule && append(ruleset(value, reference, reference, 0, 0, rules, points, type, rules, props = [], length, children), children), rules, children, length, points, rule ? props : children)\n\t\t\t\t\t\t\t\telse parse(characters, reference, reference, reference, [''], children, 0, points, children)\n\t\t\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tindex = offset = property = 0, variable = ampersand = 1, type = characters = '', length = pseudo\n\t\t\t\tbreak\n\t\t\t// :\n\t\t\tcase 58:\n\t\t\t\tlength = 1 + strlen(characters), property = previous\n\t\t\tdefault:\n\t\t\t\tif (variable < 1)\n\t\t\t\t\tif (character == 123)\n\t\t\t\t\t\t--variable\n\t\t\t\t\telse if (character == 125 && variable++ == 0 && prev() == 125)\n\t\t\t\t\t\tcontinue\n\n\t\t\t\tswitch (characters += from(character), character * variable) {\n\t\t\t\t\t// &\n\t\t\t\t\tcase 38:\n\t\t\t\t\t\tampersand = offset > 0 ? 1 : (characters += '\\f', -1)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t// ,\n\t\t\t\t\tcase 44:\n\t\t\t\t\t\tpoints[index++] = (strlen(characters) - 1) * ampersand, ampersand = 1\n\t\t\t\t\t\tbreak\n\t\t\t\t\t// @\n\t\t\t\t\tcase 64:\n\t\t\t\t\t\t// -\n\t\t\t\t\t\tif (peek() === 45)\n\t\t\t\t\t\t\tcharacters += delimit(next())\n\n\t\t\t\t\t\tatrule = peek(), offset = length = strlen(type = characters += identifier(caret())), character++\n\t\t\t\t\t\tbreak\n\t\t\t\t\t// -\n\t\t\t\t\tcase 45:\n\t\t\t\t\t\tif (previous === 45 && strlen(characters) == 2)\n\t\t\t\t\t\t\tvariable = 0\n\t\t\t\t}\n\t\t}\n\n\treturn rulesets\n}\n\n/**\n * @param {string} value\n * @param {object} root\n * @param {object?} parent\n * @param {number} index\n * @param {number} offset\n * @param {string[]} rules\n * @param {number[]} points\n * @param {string} type\n * @param {string[]} props\n * @param {string[]} children\n * @param {number} length\n * @param {object[]} siblings\n * @return {object}\n */\nexport function ruleset (value, root, parent, index, offset, rules, points, type, props, children, length, siblings) {\n\tvar post = offset - 1\n\tvar rule = offset === 0 ? rules : ['']\n\tvar size = sizeof(rule)\n\n\tfor (var i = 0, j = 0, k = 0; i < index; ++i)\n\t\tfor (var x = 0, y = substr(value, post + 1, post = abs(j = points[i])), z = value; x < size; ++x)\n\t\t\tif (z = trim(j > 0 ? rule[x] + ' ' + y : replace(y, /&\\f/g, rule[x])))\n\t\t\t\tprops[k++] = z\n\n\treturn node(value, root, parent, offset === 0 ? RULESET : type, props, children, length, siblings)\n}\n\n/**\n * @param {number} value\n * @param {object} root\n * @param {object?} parent\n * @param {object[]} siblings\n * @return {object}\n */\nexport function comment (value, root, parent, siblings) {\n\treturn node(value, root, parent, COMMENT, from(char()), substr(value, 2, -2), 0, siblings)\n}\n\n/**\n * @param {string} value\n * @param {object} root\n * @param {object?} parent\n * @param {number} length\n * @param {object[]} siblings\n * @return {object}\n */\nexport function declaration (value, root, parent, length, siblings) {\n\treturn node(value, root, parent, DECLARATION, substr(value, 0, length), substr(value, length + 1, -1), length, siblings)\n}\n","import devWarning from \"rc-util/es/warning\";\nexport function lintWarning(message, info) {\n var path = info.path,\n parentSelectors = info.parentSelectors;\n devWarning(false, \"[Ant Design CSS-in-JS] \".concat(path ? \"Error in \".concat(path, \": \") : '').concat(message).concat(parentSelectors.length ? \" Selector: \".concat(parentSelectors.join(' | ')) : ''));\n}","import { lintWarning } from \"./utils\";\nfunction isConcatSelector(selector) {\n var _selector$match;\n var notContent = ((_selector$match = selector.match(/:not\\(([^)]*)\\)/)) === null || _selector$match === void 0 ? void 0 : _selector$match[1]) || '';\n\n // split selector. e.g.\n // `h1#a.b` => ['h1', #a', '.b']\n var splitCells = notContent.split(/(\\[[^[]*])|(?=[.#])/).filter(function (str) {\n return str;\n });\n return splitCells.length > 1;\n}\nfunction parsePath(info) {\n return info.parentSelectors.reduce(function (prev, cur) {\n if (!prev) {\n return cur;\n }\n return cur.includes('&') ? cur.replace(/&/g, prev) : \"\".concat(prev, \" \").concat(cur);\n }, '');\n}\nvar linter = function linter(key, value, info) {\n var parentSelectorPath = parsePath(info);\n var notList = parentSelectorPath.match(/:not\\([^)]*\\)/g) || [];\n if (notList.length > 0 && notList.some(isConcatSelector)) {\n lintWarning(\"Concat ':not' selector not support in legacy browsers.\", info);\n }\n};\nexport default linter;","import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport canUseDom from \"rc-util/es/Dom/canUseDom\";\nimport { ATTR_MARK } from \"../StyleContext\";\nexport var ATTR_CACHE_MAP = 'data-ant-cssinjs-cache-path';\n\n/**\n * This marks style from the css file.\n * Which means not exist in `'];\n\topts.cellXfs.forEach(function(xf, id) {\n\t\tvar payload/*:Array*/ = [];\n\t\tpayload.push(writextag('NumberFormat', null, {\"ss:Format\": escapexml(table_fmt[xf.numFmtId])}));\n\n\t\tvar o = /*::(*/{\"ss:ID\": \"s\" + (21+id)}/*:: :any)*/;\n\t\tstyles.push(writextag('Style', payload.join(\"\"), o));\n\t});\n\treturn writextag(\"Styles\", styles.join(\"\"));\n}\nfunction write_name_xlml(n) { return writextag(\"NamedRange\", null, {\"ss:Name\": n.Name, \"ss:RefersTo\":\"=\" + a1_to_rc(n.Ref, {r:0,c:0})}); }\nfunction write_names_xlml(wb/*::, opts*/)/*:string*/ {\n\tif(!((wb||{}).Workbook||{}).Names) return \"\";\n\t/*:: if(!wb || !wb.Workbook || !wb.Workbook.Names) throw new Error(\"unreachable\"); */\n\tvar names/*:Array*/ = wb.Workbook.Names;\n\tvar out/*:Array*/ = [];\n\tfor(var i = 0; i < names.length; ++i) {\n\t\tvar n = names[i];\n\t\tif(n.Sheet != null) continue;\n\t\tif(n.Name.match(/^_xlfn\\./)) continue;\n\t\tout.push(write_name_xlml(n));\n\t}\n\treturn writextag(\"Names\", out.join(\"\"));\n}\nfunction write_ws_xlml_names(ws/*:Worksheet*/, opts, idx/*:number*/, wb/*:Workbook*/)/*:string*/ {\n\tif(!ws) return \"\";\n\tif(!((wb||{}).Workbook||{}).Names) return \"\";\n\t/*:: if(!wb || !wb.Workbook || !wb.Workbook.Names) throw new Error(\"unreachable\"); */\n\tvar names/*:Array*/ = wb.Workbook.Names;\n\tvar out/*:Array*/ = [];\n\tfor(var i = 0; i < names.length; ++i) {\n\t\tvar n = names[i];\n\t\tif(n.Sheet != idx) continue;\n\t\t/*switch(n.Name) {\n\t\t\tcase \"_\": continue;\n\t\t}*/\n\t\tif(n.Name.match(/^_xlfn\\./)) continue;\n\t\tout.push(write_name_xlml(n));\n\t}\n\treturn out.join(\"\");\n}\n/* WorksheetOptions */\nfunction write_ws_xlml_wsopts(ws/*:Worksheet*/, opts, idx/*:number*/, wb/*:Workbook*/)/*:string*/ {\n\tif(!ws) return \"\";\n\tvar o/*:Array*/ = [];\n\t/* NOTE: spec technically allows any order, but stick with implied order */\n\n\t/* FitToPage */\n\t/* DoNotDisplayColHeaders */\n\t/* DoNotDisplayRowHeaders */\n\t/* ViewableRange */\n\t/* Selection */\n\t/* GridlineColor */\n\t/* Name */\n\t/* ExcelWorksheetType */\n\t/* IntlMacro */\n\t/* Unsynced */\n\t/* Selected */\n\t/* CodeName */\n\n\tif(ws['!margins']) {\n\t\to.push(\"\");\n\t\tif(ws['!margins'].header) o.push(writextag(\"Header\", null, {'x:Margin':ws['!margins'].header}));\n\t\tif(ws['!margins'].footer) o.push(writextag(\"Footer\", null, {'x:Margin':ws['!margins'].footer}));\n\t\to.push(writextag(\"PageMargins\", null, {\n\t\t\t'x:Bottom': ws['!margins'].bottom || \"0.75\",\n\t\t\t'x:Left': ws['!margins'].left || \"0.7\",\n\t\t\t'x:Right': ws['!margins'].right || \"0.7\",\n\t\t\t'x:Top': ws['!margins'].top || \"0.75\"\n\t\t}));\n\t\to.push(\"\");\n\t}\n\n\t/* PageSetup */\n\t/* DisplayPageBreak */\n\t/* TransitionExpressionEvaluation */\n\t/* TransitionFormulaEntry */\n\t/* Print */\n\t/* Zoom */\n\t/* PageLayoutZoom */\n\t/* PageBreakZoom */\n\t/* ShowPageBreakZoom */\n\t/* DefaultRowHeight */\n\t/* DefaultColumnWidth */\n\t/* StandardWidth */\n\n\tif(wb && wb.Workbook && wb.Workbook.Sheets && wb.Workbook.Sheets[idx]) {\n\t\t/* Visible */\n\t\tif(wb.Workbook.Sheets[idx].Hidden) o.push(writextag(\"Visible\", (wb.Workbook.Sheets[idx].Hidden == 1 ? \"SheetHidden\" : \"SheetVeryHidden\"), {}));\n\t\telse {\n\t\t\t/* Selected */\n\t\t\tfor(var i = 0; i < idx; ++i) if(wb.Workbook.Sheets[i] && !wb.Workbook.Sheets[i].Hidden) break;\n\t\t\tif(i == idx) o.push(\"\");\n\t\t}\n\t}\n\n\t/* LeftColumnVisible */\n\n\tif(((((wb||{}).Workbook||{}).Views||[])[0]||{}).RTL) o.push(\"\");\n\n\t/* GridlineColorIndex */\n\t/* DisplayFormulas */\n\t/* DoNotDisplayGridlines */\n\t/* DoNotDisplayHeadings */\n\t/* DoNotDisplayOutline */\n\t/* ApplyAutomaticOutlineStyles */\n\t/* NoSummaryRowsBelowDetail */\n\t/* NoSummaryColumnsRightDetail */\n\t/* DoNotDisplayZeros */\n\t/* ActiveRow */\n\t/* ActiveColumn */\n\t/* FilterOn */\n\t/* RangeSelection */\n\t/* TopRowVisible */\n\t/* TopRowBottomPane */\n\t/* LeftColumnRightPane */\n\t/* ActivePane */\n\t/* SplitHorizontal */\n\t/* SplitVertical */\n\t/* FreezePanes */\n\t/* FrozenNoSplit */\n\t/* TabColorIndex */\n\t/* Panes */\n\n\t/* NOTE: Password not supported in XLML Format */\n\tif(ws['!protect']) {\n\t\to.push(writetag(\"ProtectContents\", \"True\"));\n\t\tif(ws['!protect'].objects) o.push(writetag(\"ProtectObjects\", \"True\"));\n\t\tif(ws['!protect'].scenarios) o.push(writetag(\"ProtectScenarios\", \"True\"));\n\t\tif(ws['!protect'].selectLockedCells != null && !ws['!protect'].selectLockedCells) o.push(writetag(\"EnableSelection\", \"NoSelection\"));\n\t\telse if(ws['!protect'].selectUnlockedCells != null && !ws['!protect'].selectUnlockedCells) o.push(writetag(\"EnableSelection\", \"UnlockedCells\"));\n\t[\n\t\t[ \"formatCells\", \"AllowFormatCells\" ],\n\t\t[ \"formatColumns\", \"AllowSizeCols\" ],\n\t\t[ \"formatRows\", \"AllowSizeRows\" ],\n\t\t[ \"insertColumns\", \"AllowInsertCols\" ],\n\t\t[ \"insertRows\", \"AllowInsertRows\" ],\n\t\t[ \"insertHyperlinks\", \"AllowInsertHyperlinks\" ],\n\t\t[ \"deleteColumns\", \"AllowDeleteCols\" ],\n\t\t[ \"deleteRows\", \"AllowDeleteRows\" ],\n\t\t[ \"sort\", \"AllowSort\" ],\n\t\t[ \"autoFilter\", \"AllowFilter\" ],\n\t\t[ \"pivotTables\", \"AllowUsePivotTables\" ]\n\t].forEach(function(x) { if(ws['!protect'][x[0]]) o.push(\"<\"+x[1]+\"/>\"); });\n\t}\n\n\tif(o.length == 0) return \"\";\n\treturn writextag(\"WorksheetOptions\", o.join(\"\"), {xmlns:XLMLNS.x});\n}\nfunction write_ws_xlml_comment(comments/*:Array*/)/*:string*/ {\n\treturn comments.map(function(c) {\n\t\t// TODO: formatted text\n\t\tvar t = xlml_unfixstr(c.t||\"\");\n\t\tvar d =writextag(\"ss:Data\", t, {\"xmlns\":\"http://www.w3.org/TR/REC-html40\"});\n\t\treturn writextag(\"Comment\", d, {\"ss:Author\":c.a});\n\t}).join(\"\");\n}\nfunction write_ws_xlml_cell(cell, ref/*:string*/, ws, opts, idx/*:number*/, wb, addr)/*:string*/{\n\tif(!cell || (cell.v == undefined && cell.f == undefined)) return \"\";\n\n\tvar attr = {};\n\tif(cell.f) attr[\"ss:Formula\"] = \"=\" + escapexml(a1_to_rc(cell.f, addr));\n\tif(cell.F && cell.F.slice(0, ref.length) == ref) {\n\t\tvar end = decode_cell(cell.F.slice(ref.length + 1));\n\t\tattr[\"ss:ArrayRange\"] = \"RC:R\" + (end.r == addr.r ? \"\" : \"[\" + (end.r - addr.r) + \"]\") + \"C\" + (end.c == addr.c ? \"\" : \"[\" + (end.c - addr.c) + \"]\");\n\t}\n\n\tif(cell.l && cell.l.Target) {\n\t\tattr[\"ss:HRef\"] = escapexml(cell.l.Target);\n\t\tif(cell.l.Tooltip) attr[\"x:HRefScreenTip\"] = escapexml(cell.l.Tooltip);\n\t}\n\n\tif(ws['!merges']) {\n\t\tvar marr = ws['!merges'];\n\t\tfor(var mi = 0; mi != marr.length; ++mi) {\n\t\t\tif(marr[mi].s.c != addr.c || marr[mi].s.r != addr.r) continue;\n\t\t\tif(marr[mi].e.c > marr[mi].s.c) attr['ss:MergeAcross'] = marr[mi].e.c - marr[mi].s.c;\n\t\t\tif(marr[mi].e.r > marr[mi].s.r) attr['ss:MergeDown'] = marr[mi].e.r - marr[mi].s.r;\n\t\t}\n\t}\n\n\tvar t = \"\", p = \"\";\n\tswitch(cell.t) {\n\t\tcase 'z': if(!opts.sheetStubs) return \"\"; break;\n\t\tcase 'n': t = 'Number'; p = String(cell.v); break;\n\t\tcase 'b': t = 'Boolean'; p = (cell.v ? \"1\" : \"0\"); break;\n\t\tcase 'e': t = 'Error'; p = BErr[cell.v]; break;\n\t\tcase 'd': t = 'DateTime'; p = new Date(cell.v).toISOString(); if(cell.z == null) cell.z = cell.z || table_fmt[14]; break;\n\t\tcase 's': t = 'String'; p = escapexlml(cell.v||\"\"); break;\n\t}\n\t/* TODO: cell style */\n\tvar os = get_cell_style(opts.cellXfs, cell, opts);\n\tattr[\"ss:StyleID\"] = \"s\" + (21+os);\n\tattr[\"ss:Index\"] = addr.c + 1;\n\tvar _v = (cell.v != null ? p : \"\");\n\tvar m = cell.t == 'z' ? \"\" : ('' + _v + '');\n\n\tif((cell.c||[]).length > 0) m += write_ws_xlml_comment(cell.c);\n\n\treturn writextag(\"Cell\", m, attr);\n}\nfunction write_ws_xlml_row(R/*:number*/, row)/*:string*/ {\n\tvar o = '';\n}\n/* TODO */\nfunction write_ws_xlml_table(ws/*:Worksheet*/, opts, idx/*:number*/, wb/*:Workbook*/)/*:string*/ {\n\tif(!ws['!ref']) return \"\";\n\tvar range/*:Range*/ = safe_decode_range(ws['!ref']);\n\tvar marr/*:Array*/ = ws['!merges'] || [], mi = 0;\n\tvar o/*:Array*/ = [];\n\tif(ws['!cols']) ws['!cols'].forEach(function(n, i) {\n\t\tprocess_col(n);\n\t\tvar w = !!n.width;\n\t\tvar p = col_obj_w(i, n);\n\t\tvar k/*:any*/ = {\"ss:Index\":i+1};\n\t\tif(w) k['ss:Width'] = width2px(p.width);\n\t\tif(n.hidden) k['ss:Hidden']=\"1\";\n\t\to.push(writextag(\"Column\",null,k));\n\t});\n\tvar dense = Array.isArray(ws);\n\tfor(var R = range.s.r; R <= range.e.r; ++R) {\n\t\tvar row = [write_ws_xlml_row(R, (ws['!rows']||[])[R])];\n\t\tfor(var C = range.s.c; C <= range.e.c; ++C) {\n\t\t\tvar skip = false;\n\t\t\tfor(mi = 0; mi != marr.length; ++mi) {\n\t\t\t\tif(marr[mi].s.c > C) continue;\n\t\t\t\tif(marr[mi].s.r > R) continue;\n\t\t\t\tif(marr[mi].e.c < C) continue;\n\t\t\t\tif(marr[mi].e.r < R) continue;\n\t\t\t\tif(marr[mi].s.c != C || marr[mi].s.r != R) skip = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif(skip) continue;\n\t\t\tvar addr = {r:R,c:C};\n\t\t\tvar ref = encode_cell(addr), cell = dense ? (ws[R]||[])[C] : ws[ref];\n\t\t\trow.push(write_ws_xlml_cell(cell, ref, ws, opts, idx, wb, addr));\n\t\t}\n\t\trow.push(\"\");\n\t\tif(row.length > 2) o.push(row.join(\"\"));\n\t}\n\treturn o.join(\"\");\n}\nfunction write_ws_xlml(idx/*:number*/, opts, wb/*:Workbook*/)/*:string*/ {\n\tvar o/*:Array*/ = [];\n\tvar s = wb.SheetNames[idx];\n\tvar ws = wb.Sheets[s];\n\n\tvar t/*:string*/ = ws ? write_ws_xlml_names(ws, opts, idx, wb) : \"\";\n\tif(t.length > 0) o.push(\"\" + t + \"\");\n\n\t/* Table */\n\tt = ws ? write_ws_xlml_table(ws, opts, idx, wb) : \"\";\n\tif(t.length > 0) o.push(\"\" + t + \"
\");\n\n\t/* WorksheetOptions */\n\to.push(write_ws_xlml_wsopts(ws, opts, idx, wb));\n\n\treturn o.join(\"\");\n}\nfunction write_xlml(wb, opts)/*:string*/ {\n\tif(!opts) opts = {};\n\tif(!wb.SSF) wb.SSF = dup(table_fmt);\n\tif(wb.SSF) {\n\t\tmake_ssf(); SSF_load_table(wb.SSF);\n\t\t// $FlowIgnore\n\t\topts.revssf = evert_num(wb.SSF); opts.revssf[wb.SSF[65535]] = 0;\n\t\topts.ssf = wb.SSF;\n\t\topts.cellXfs = [];\n\t\tget_cell_style(opts.cellXfs, {}, {revssf:{\"General\":0}});\n\t}\n\tvar d/*:Array*/ = [];\n\td.push(write_props_xlml(wb, opts));\n\td.push(write_wb_xlml(wb, opts));\n\td.push(\"\");\n\td.push(\"\");\n\tfor(var i = 0; i < wb.SheetNames.length; ++i)\n\t\td.push(writextag(\"Worksheet\", write_ws_xlml(i, opts, wb), {\"ss:Name\":escapexml(wb.SheetNames[i])}));\n\td[2] = write_sty_xlml(wb, opts);\n\td[3] = write_names_xlml(wb, opts);\n\treturn XML_HEADER + writextag(\"Workbook\", d.join(\"\"), {\n\t\t'xmlns': XLMLNS.ss,\n\t\t'xmlns:o': XLMLNS.o,\n\t\t'xmlns:x': XLMLNS.x,\n\t\t'xmlns:ss': XLMLNS.ss,\n\t\t'xmlns:dt': XLMLNS.dt,\n\t\t'xmlns:html': XLMLNS.html\n\t});\n}\n/* [MS-OLEDS] 2.3.8 CompObjStream */\nfunction parse_compobj(obj/*:CFBEntry*/) {\n\tvar v = {};\n\tvar o = obj.content;\n\t/*:: if(o == null) return; */\n\n\t/* [MS-OLEDS] 2.3.7 CompObjHeader -- All fields MUST be ignored */\n\to.l = 28;\n\n\tv.AnsiUserType = o.read_shift(0, \"lpstr-ansi\");\n\tv.AnsiClipboardFormat = parse_ClipboardFormatOrAnsiString(o);\n\n\tif(o.length - o.l <= 4) return v;\n\n\tvar m/*:number*/ = o.read_shift(4);\n\tif(m == 0 || m > 40) return v;\n\to.l-=4; v.Reserved1 = o.read_shift(0, \"lpstr-ansi\");\n\n\tif(o.length - o.l <= 4) return v;\n\tm = o.read_shift(4);\n\tif(m !== 0x71b239f4) return v;\n\tv.UnicodeClipboardFormat = parse_ClipboardFormatOrUnicodeString(o);\n\n\tm = o.read_shift(4);\n\tif(m == 0 || m > 40) return v;\n\to.l-=4; v.Reserved2 = o.read_shift(0, \"lpwstr\");\n}\n\n/*\n\tContinue logic for:\n\t- 2.4.58 Continue 0x003c\n\t- 2.4.59 ContinueBigName 0x043c\n\t- 2.4.60 ContinueFrt 0x0812\n\t- 2.4.61 ContinueFrt11 0x0875\n\t- 2.4.62 ContinueFrt12 0x087f\n*/\nvar CONTINUE_RT = [ 0x003c, 0x043c, 0x0812, 0x0875, 0x087f ];\nfunction slurp(RecordType, R, blob, length/*:number*/, opts)/*:any*/ {\n\tvar l = length;\n\tvar bufs = [];\n\tvar d = blob.slice(blob.l,blob.l+l);\n\tif(opts && opts.enc && opts.enc.insitu && d.length > 0) switch(RecordType) {\n\tcase 0x0009: case 0x0209: case 0x0409: case 0x0809/* BOF */: case 0x002f /* FilePass */: case 0x0195 /* FileLock */: case 0x00e1 /* InterfaceHdr */: case 0x0196 /* RRDInfo */: case 0x0138 /* RRDHead */: case 0x0194 /* UsrExcl */: case 0x000a /* EOF */:\n\t\tbreak;\n\tcase 0x0085 /* BoundSheet8 */:\n\t\tbreak;\n\tdefault:\n\t\topts.enc.insitu(d);\n\t}\n\tbufs.push(d);\n\tblob.l += l;\n\tvar nextrt = __readUInt16LE(blob,blob.l), next = XLSRecordEnum[nextrt];\n\tvar start = 0;\n\twhile(next != null && CONTINUE_RT.indexOf(nextrt) > -1) {\n\t\tl = __readUInt16LE(blob,blob.l+2);\n\t\tstart = blob.l + 4;\n\t\tif(nextrt == 0x0812 /* ContinueFrt */) start += 4;\n\t\telse if(nextrt == 0x0875 || nextrt == 0x087f) {\n\t\t\tstart += 12;\n\t\t}\n\t\td = blob.slice(start,blob.l+4+l);\n\t\tbufs.push(d);\n\t\tblob.l += 4+l;\n\t\tnext = (XLSRecordEnum[nextrt = __readUInt16LE(blob, blob.l)]);\n\t}\n\tvar b = (bconcat(bufs)/*:any*/);\n\tprep_blob(b, 0);\n\tvar ll = 0; b.lens = [];\n\tfor(var j = 0; j < bufs.length; ++j) { b.lens.push(ll); ll += bufs[j].length; }\n\tif(b.length < length) throw \"XLS Record 0x\" + RecordType.toString(16) + \" Truncated: \" + b.length + \" < \" + length;\n\treturn R.f(b, b.length, opts);\n}\n\nfunction safe_format_xf(p/*:any*/, opts/*:ParseOpts*/, date1904/*:?boolean*/) {\n\tif(p.t === 'z') return;\n\tif(!p.XF) return;\n\tvar fmtid = 0;\n\ttry {\n\t\tfmtid = p.z || p.XF.numFmtId || 0;\n\t\tif(opts.cellNF) p.z = table_fmt[fmtid];\n\t} catch(e) { if(opts.WTF) throw e; }\n\tif(!opts || opts.cellText !== false) try {\n\t\tif(p.t === 'e') { p.w = p.w || BErr[p.v]; }\n\t\telse if(fmtid === 0 || fmtid == \"General\") {\n\t\t\tif(p.t === 'n') {\n\t\t\t\tif((p.v|0) === p.v) p.w = p.v.toString(10);\n\t\t\t\telse p.w = SSF_general_num(p.v);\n\t\t\t}\n\t\t\telse p.w = SSF_general(p.v);\n\t\t}\n\t\telse p.w = SSF_format(fmtid,p.v, {date1904:!!date1904, dateNF: opts && opts.dateNF});\n\t} catch(e) { if(opts.WTF) throw e; }\n\tif(opts.cellDates && fmtid && p.t == 'n' && fmt_is_date(table_fmt[fmtid] || String(fmtid))) {\n\t\tvar _d = SSF_parse_date_code(p.v); if(_d) { p.t = 'd'; p.v = new Date(_d.y, _d.m-1,_d.d,_d.H,_d.M,_d.S,_d.u); }\n\t}\n}\n\nfunction make_cell(val, ixfe, t)/*:Cell*/ {\n\treturn ({v:val, ixfe:ixfe, t:t}/*:any*/);\n}\n\n// 2.3.2\nfunction parse_workbook(blob, options/*:ParseOpts*/)/*:Workbook*/ {\n\tvar wb = ({opts:{}}/*:any*/);\n\tvar Sheets = {};\n\tif(DENSE != null && options.dense == null) options.dense = DENSE;\n\tvar out/*:Worksheet*/ = ((options.dense ? [] : {})/*:any*/);\n\tvar Directory = {};\n\tvar range/*:Range*/ = ({}/*:any*/);\n\tvar last_formula = null;\n\tvar sst/*:SST*/ = ([]/*:any*/);\n\tvar cur_sheet = \"\";\n\tvar Preamble = {};\n\tvar lastcell, last_cell = \"\", cc/*:Cell*/, cmnt, rngC, rngR;\n\tvar sharedf = {};\n\tvar arrayf/*:Array<[Range, string]>*/ = [];\n\tvar temp_val/*:Cell*/;\n\tvar country;\n\tvar XFs = []; /* XF records */\n\tvar palette/*:Array<[number, number, number]>*/ = [];\n\tvar Workbook/*:WBWBProps*/ = ({ Sheets:[], WBProps:{date1904:false}, Views:[{}] }/*:any*/), wsprops = {};\n\tvar get_rgb = function getrgb(icv/*:number*/)/*:[number, number, number]*/ {\n\t\tif(icv < 8) return XLSIcv[icv];\n\t\tif(icv < 64) return palette[icv-8] || XLSIcv[icv];\n\t\treturn XLSIcv[icv];\n\t};\n\tvar process_cell_style = function pcs(cell, line/*:any*/, options) {\n\t\tvar xfd = line.XF.data;\n\t\tif(!xfd || !xfd.patternType || !options || !options.cellStyles) return;\n\t\tline.s = ({}/*:any*/);\n\t\tline.s.patternType = xfd.patternType;\n\t\tvar t;\n\t\tif((t = rgb2Hex(get_rgb(xfd.icvFore)))) { line.s.fgColor = {rgb:t}; }\n\t\tif((t = rgb2Hex(get_rgb(xfd.icvBack)))) { line.s.bgColor = {rgb:t}; }\n\t};\n\tvar addcell = function addcell(cell/*:any*/, line/*:any*/, options/*:any*/) {\n\t\tif(file_depth > 1) return;\n\t\tif(options.sheetRows && cell.r >= options.sheetRows) return;\n\t\tif(options.cellStyles && line.XF && line.XF.data) process_cell_style(cell, line, options);\n\t\tdelete line.ixfe; delete line.XF;\n\t\tlastcell = cell;\n\t\tlast_cell = encode_cell(cell);\n\t\tif(!range || !range.s || !range.e) range = {s:{r:0,c:0},e:{r:0,c:0}};\n\t\tif(cell.r < range.s.r) range.s.r = cell.r;\n\t\tif(cell.c < range.s.c) range.s.c = cell.c;\n\t\tif(cell.r + 1 > range.e.r) range.e.r = cell.r + 1;\n\t\tif(cell.c + 1 > range.e.c) range.e.c = cell.c + 1;\n\t\tif(options.cellFormula && line.f) {\n\t\t\tfor(var afi = 0; afi < arrayf.length; ++afi) {\n\t\t\t\tif(arrayf[afi][0].s.c > cell.c || arrayf[afi][0].s.r > cell.r) continue;\n\t\t\t\tif(arrayf[afi][0].e.c < cell.c || arrayf[afi][0].e.r < cell.r) continue;\n\t\t\t\tline.F = encode_range(arrayf[afi][0]);\n\t\t\t\tif(arrayf[afi][0].s.c != cell.c || arrayf[afi][0].s.r != cell.r) delete line.f;\n\t\t\t\tif(line.f) line.f = \"\" + stringify_formula(arrayf[afi][1], range, cell, supbooks, opts);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t{\n\t\t\tif(options.dense) {\n\t\t\t\tif(!out[cell.r]) out[cell.r] = [];\n\t\t\t\tout[cell.r][cell.c] = line;\n\t\t\t} else out[last_cell] = line;\n\t\t}\n\t};\n\tvar opts = ({\n\t\tenc: false, // encrypted\n\t\tsbcch: 0, // cch in the preceding SupBook\n\t\tsnames: [], // sheetnames\n\t\tsharedf: sharedf, // shared formulae by address\n\t\tarrayf: arrayf, // array formulae array\n\t\trrtabid: [], // RRTabId\n\t\tlastuser: \"\", // Last User from WriteAccess\n\t\tbiff: 8, // BIFF version\n\t\tcodepage: 0, // CP from CodePage record\n\t\twinlocked: 0, // fLockWn from WinProtect\n\t\tcellStyles: !!options && !!options.cellStyles,\n\t\tWTF: !!options && !!options.wtf\n\t}/*:any*/);\n\tif(options.password) opts.password = options.password;\n\tvar themes;\n\tvar merges/*:Array*/ = [];\n\tvar objects = [];\n\tvar colinfo/*:Array*/ = [], rowinfo/*:Array*/ = [];\n\tvar seencol = false;\n\tvar supbooks = ([]/*:any*/); // 1-indexed, will hold extern names\n\tsupbooks.SheetNames = opts.snames;\n\tsupbooks.sharedf = opts.sharedf;\n\tsupbooks.arrayf = opts.arrayf;\n\tsupbooks.names = [];\n\tsupbooks.XTI = [];\n\tvar last_RT = 0;\n\tvar file_depth = 0; /* TODO: make a real stack */\n\tvar BIFF2Fmt = 0, BIFF2FmtTable/*:Array*/ = [];\n\tvar FilterDatabases = []; /* TODO: sort out supbooks and process elsewhere */\n\tvar last_lbl/*:?DefinedName*/;\n\n\t/* explicit override for some broken writers */\n\topts.codepage = 1200;\n\tset_cp(1200);\n\tvar seen_codepage = false;\n\twhile(blob.l < blob.length - 1) {\n\t\tvar s = blob.l;\n\t\tvar RecordType = blob.read_shift(2);\n\t\tif(RecordType === 0 && last_RT === 0x000a /* EOF */) break;\n\t\tvar length = (blob.l === blob.length ? 0 : blob.read_shift(2));\n\t\tvar R = XLSRecordEnum[RecordType];\n\t\t//console.log(RecordType.toString(16), RecordType, R, blob.l, length, blob.length);\n\t\t//if(!R) console.log(blob.slice(blob.l, blob.l + length));\n\t\tif(R && R.f) {\n\t\t\tif(options.bookSheets) {\n\t\t\t\tif(last_RT === 0x0085 /* BoundSheet8 */ && RecordType !== 0x0085 /* R.n !== 'BoundSheet8' */) break;\n\t\t\t}\n\t\t\tlast_RT = RecordType;\n\t\t\tif(R.r === 2 || R.r == 12) {\n\t\t\t\tvar rt = blob.read_shift(2); length -= 2;\n\t\t\t\tif(!opts.enc && rt !== RecordType && (((rt&0xFF)<<8)|(rt>>8)) !== RecordType) throw new Error(\"rt mismatch: \" + rt + \"!=\" + RecordType);\n\t\t\t\tif(R.r == 12){\n\t\t\t\t\tblob.l += 10; length -= 10;\n\t\t\t\t} // skip FRT\n\t\t\t}\n\t\t\t//console.error(R,blob.l,length,blob.length);\n\t\t\tvar val/*:any*/ = ({}/*:any*/);\n\t\t\tif(RecordType === 0x000a /* EOF */) val = /*::(*/R.f(blob, length, opts)/*:: :any)*/;\n\t\t\telse val = /*::(*/slurp(RecordType, R, blob, length, opts)/*:: :any)*/;\n\t\t\t/*:: val = (val:any); */\n\t\t\tif(file_depth == 0 && [0x0009, 0x0209, 0x0409, 0x0809].indexOf(last_RT) === -1 /* 'BOF' */) continue;\n\t\t\tswitch(RecordType) {\n\t\t\t\tcase 0x0022 /* Date1904 */:\n\t\t\t\t\t/*:: if(!Workbook.WBProps) Workbook.WBProps = {}; */\n\t\t\t\t\twb.opts.Date1904 = Workbook.WBProps.date1904 = val; break;\n\t\t\t\tcase 0x0086 /* WriteProtect */: wb.opts.WriteProtect = true; break;\n\t\t\t\tcase 0x002f /* FilePass */:\n\t\t\t\t\tif(!opts.enc) blob.l = 0;\n\t\t\t\t\topts.enc = val;\n\t\t\t\t\tif(!options.password) throw new Error(\"File is password-protected\");\n\t\t\t\t\tif(val.valid == null) throw new Error(\"Encryption scheme unsupported\");\n\t\t\t\t\tif(!val.valid) throw new Error(\"Password is incorrect\");\n\t\t\t\t\tbreak;\n\t\t\t\tcase 0x005c /* WriteAccess */: opts.lastuser = val; break;\n\t\t\t\tcase 0x0042 /* CodePage */:\n\t\t\t\t\tvar cpval = Number(val);\n\t\t\t\t\t/* overrides based on test cases */\n\t\t\t\t\tswitch(cpval) {\n\t\t\t\t\t\tcase 0x5212: cpval = 1200; break;\n\t\t\t\t\t\tcase 0x8000: cpval = 10000; break;\n\t\t\t\t\t\tcase 0x8001: cpval = 1252; break;\n\t\t\t\t\t}\n\t\t\t\t\tset_cp(opts.codepage = cpval);\n\t\t\t\t\tseen_codepage = true;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 0x013d /* RRTabId */: opts.rrtabid = val; break;\n\t\t\t\tcase 0x0019 /* WinProtect */: opts.winlocked = val; break;\n\t\t\t\tcase 0x01b7 /* RefreshAll */: wb.opts[\"RefreshAll\"] = val; break;\n\t\t\t\tcase 0x000c /* CalcCount */: wb.opts[\"CalcCount\"] = val; break;\n\t\t\t\tcase 0x0010 /* CalcDelta */: wb.opts[\"CalcDelta\"] = val; break;\n\t\t\t\tcase 0x0011 /* CalcIter */: wb.opts[\"CalcIter\"] = val; break;\n\t\t\t\tcase 0x000d /* CalcMode */: wb.opts[\"CalcMode\"] = val; break;\n\t\t\t\tcase 0x000e /* CalcPrecision */: wb.opts[\"CalcPrecision\"] = val; break;\n\t\t\t\tcase 0x005f /* CalcSaveRecalc */: wb.opts[\"CalcSaveRecalc\"] = val; break;\n\t\t\t\tcase 0x000f /* CalcRefMode */: opts.CalcRefMode = val; break; // TODO: implement R1C1\n\t\t\t\tcase 0x08a3 /* ForceFullCalculation */: wb.opts.FullCalc = val; break;\n\t\t\t\tcase 0x0081 /* WsBool */:\n\t\t\t\t\tif(val.fDialog) out[\"!type\"] = \"dialog\";\n\t\t\t\t\tif(!val.fBelow) (out[\"!outline\"] || (out[\"!outline\"] = {})).above = true;\n\t\t\t\t\tif(!val.fRight) (out[\"!outline\"] || (out[\"!outline\"] = {})).left = true;\n\t\t\t\t\tbreak; // TODO\n\t\t\t\tcase 0x00e0 /* XF */:\n\t\t\t\t\tXFs.push(val); break;\n\t\t\t\tcase 0x01ae /* SupBook */:\n\t\t\t\t\tsupbooks.push([val]);\n\t\t\t\t\tsupbooks[supbooks.length-1].XTI = [];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 0x0023: case 0x0223 /* ExternName */:\n\t\t\t\t\tsupbooks[supbooks.length-1].push(val);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 0x0018: case 0x0218 /* Lbl */:\n\t\t\t\t\tlast_lbl = ({\n\t\t\t\t\t\tName: val.Name,\n\t\t\t\t\t\tRef: stringify_formula(val.rgce,range,null,supbooks,opts)\n\t\t\t\t\t}/*:DefinedName*/);\n\t\t\t\t\tif(val.itab > 0) last_lbl.Sheet = val.itab - 1;\n\t\t\t\t\tsupbooks.names.push(last_lbl);\n\t\t\t\t\tif(!supbooks[0]) { supbooks[0] = []; supbooks[0].XTI = []; }\n\t\t\t\t\tsupbooks[supbooks.length-1].push(val);\n\t\t\t\t\tif(val.Name == \"_xlnm._FilterDatabase\" && val.itab > 0)\n\t\t\t\t\t\tif(val.rgce && val.rgce[0] && val.rgce[0][0] && val.rgce[0][0][0] == 'PtgArea3d')\n\t\t\t\t\t\t\tFilterDatabases[val.itab - 1] = { ref: encode_range(val.rgce[0][0][1][2]) };\n\t\t\t\t\tbreak;\n\t\t\t\tcase 0x0016 /* ExternCount */: opts.ExternCount = val; break;\n\t\t\t\tcase 0x0017 /* ExternSheet */:\n\t\t\t\t\tif(supbooks.length == 0) { supbooks[0] = []; supbooks[0].XTI = []; }\n\t\t\t\t\tsupbooks[supbooks.length - 1].XTI = supbooks[supbooks.length - 1].XTI.concat(val); supbooks.XTI = supbooks.XTI.concat(val); break;\n\t\t\t\tcase 0x0894 /* NameCmt */:\n\t\t\t\t\t/* TODO: search for correct name */\n\t\t\t\t\tif(opts.biff < 8) break;\n\t\t\t\t\tif(last_lbl != null) last_lbl.Comment = val[1];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 0x0012 /* Protect */: out[\"!protect\"] = val; break; /* for sheet or book */\n\t\t\t\tcase 0x0013 /* Password */: if(val !== 0 && opts.WTF) console.error(\"Password verifier: \" + val); break;\n\t\t\t\tcase 0x0085 /* BoundSheet8 */: {\n\t\t\t\t\tDirectory[val.pos] = val;\n\t\t\t\t\topts.snames.push(val.name);\n\t\t\t\t} break;\n\t\t\t\tcase 0x000a /* EOF */: {\n\t\t\t\t\tif(--file_depth) break;\n\t\t\t\t\tif(range.e) {\n\t\t\t\t\t\tif(range.e.r > 0 && range.e.c > 0) {\n\t\t\t\t\t\t\trange.e.r--; range.e.c--;\n\t\t\t\t\t\t\tout[\"!ref\"] = encode_range(range);\n\t\t\t\t\t\t\tif(options.sheetRows && options.sheetRows <= range.e.r) {\n\t\t\t\t\t\t\t\tvar tmpri = range.e.r;\n\t\t\t\t\t\t\t\trange.e.r = options.sheetRows - 1;\n\t\t\t\t\t\t\t\tout[\"!fullref\"] = out[\"!ref\"];\n\t\t\t\t\t\t\t\tout[\"!ref\"] = encode_range(range);\n\t\t\t\t\t\t\t\trange.e.r = tmpri;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\trange.e.r++; range.e.c++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(merges.length > 0) out[\"!merges\"] = merges;\n\t\t\t\t\t\tif(objects.length > 0) out[\"!objects\"] = objects;\n\t\t\t\t\t\tif(colinfo.length > 0) out[\"!cols\"] = colinfo;\n\t\t\t\t\t\tif(rowinfo.length > 0) out[\"!rows\"] = rowinfo;\n\t\t\t\t\t\tWorkbook.Sheets.push(wsprops);\n\t\t\t\t\t}\n\t\t\t\t\tif(cur_sheet === \"\") Preamble = out; else Sheets[cur_sheet] = out;\n\t\t\t\t\tout = ((options.dense ? [] : {})/*:any*/);\n\t\t\t\t} break;\n\t\t\t\tcase 0x0009: case 0x0209: case 0x0409: case 0x0809 /* BOF */: {\n\t\t\t\t\tif(opts.biff === 8) opts.biff = {\n\t\t\t\t\t\t/*::[*/0x0009/*::]*/:2,\n\t\t\t\t\t\t/*::[*/0x0209/*::]*/:3,\n\t\t\t\t\t\t/*::[*/0x0409/*::]*/:4\n\t\t\t\t\t}[RecordType] || {\n\t\t\t\t\t\t/*::[*/0x0200/*::]*/:2,\n\t\t\t\t\t\t/*::[*/0x0300/*::]*/:3,\n\t\t\t\t\t\t/*::[*/0x0400/*::]*/:4,\n\t\t\t\t\t\t/*::[*/0x0500/*::]*/:5,\n\t\t\t\t\t\t/*::[*/0x0600/*::]*/:8,\n\t\t\t\t\t\t/*::[*/0x0002/*::]*/:2,\n\t\t\t\t\t\t/*::[*/0x0007/*::]*/:2\n\t\t\t\t\t}[val.BIFFVer] || 8;\n\t\t\t\t\topts.biffguess = val.BIFFVer == 0;\n\t\t\t\t\tif(val.BIFFVer == 0 && val.dt == 0x1000) { opts.biff = 5; seen_codepage = true; set_cp(opts.codepage = 28591); }\n\t\t\t\t\tif(opts.biff == 8 && val.BIFFVer == 0 && val.dt == 16) opts.biff = 2;\n\t\t\t\t\tif(file_depth++) break;\n\t\t\t\t\tout = ((options.dense ? [] : {})/*:any*/);\n\n\t\t\t\t\tif(opts.biff < 8 && !seen_codepage) { seen_codepage = true; set_cp(opts.codepage = options.codepage || 1252); }\n\n\t\t\t\t\tif(opts.biff < 5 || val.BIFFVer == 0 && val.dt == 0x1000) {\n\t\t\t\t\t\tif(cur_sheet === \"\") cur_sheet = \"Sheet1\";\n\t\t\t\t\t\trange = {s:{r:0,c:0},e:{r:0,c:0}};\n\t\t\t\t\t\t/* fake BoundSheet8 */\n\t\t\t\t\t\tvar fakebs8 = {pos: blob.l - length, name:cur_sheet};\n\t\t\t\t\t\tDirectory[fakebs8.pos] = fakebs8;\n\t\t\t\t\t\topts.snames.push(cur_sheet);\n\t\t\t\t\t}\n\t\t\t\t\telse cur_sheet = (Directory[s] || {name:\"\"}).name;\n\t\t\t\t\tif(val.dt == 0x20) out[\"!type\"] = \"chart\";\n\t\t\t\t\tif(val.dt == 0x40) out[\"!type\"] = \"macro\";\n\t\t\t\t\tmerges = [];\n\t\t\t\t\tobjects = [];\n\t\t\t\t\topts.arrayf = arrayf = [];\n\t\t\t\t\tcolinfo = []; rowinfo = [];\n\t\t\t\t\tseencol = false;\n\t\t\t\t\twsprops = {Hidden:(Directory[s]||{hs:0}).hs, name:cur_sheet };\n\t\t\t\t} break;\n\t\t\t\tcase 0x0203 /* Number */: case 0x0003 /* BIFF2NUM */: case 0x0002 /* BIFF2INT */: {\n\t\t\t\t\tif(out[\"!type\"] == \"chart\") if(options.dense ? (out[val.r]||[])[val.c]: out[encode_cell({c:val.c, r:val.r})]) ++val.c;\n\t\t\t\t\ttemp_val = ({ixfe: val.ixfe, XF: XFs[val.ixfe]||{}, v:val.val, t:'n'}/*:any*/);\n\t\t\t\t\tif(BIFF2Fmt > 0) temp_val.z = BIFF2FmtTable[(temp_val.ixfe>>8) & 0x3F];\n\t\t\t\t\tsafe_format_xf(temp_val, options, wb.opts.Date1904);\n\t\t\t\t\taddcell({c:val.c, r:val.r}, temp_val, options);\n\t\t\t\t} break;\n\t\t\t\tcase 0x0005: case 0x0205 /* BoolErr */: {\n\t\t\t\t\ttemp_val = ({ixfe: val.ixfe, XF: XFs[val.ixfe], v:val.val, t:val.t}/*:any*/);\n\t\t\t\t\tif(BIFF2Fmt > 0) temp_val.z = BIFF2FmtTable[(temp_val.ixfe>>8) & 0x3F];\n\t\t\t\t\tsafe_format_xf(temp_val, options, wb.opts.Date1904);\n\t\t\t\t\taddcell({c:val.c, r:val.r}, temp_val, options);\n\t\t\t\t} break;\n\t\t\t\tcase 0x027e /* RK */: {\n\t\t\t\t\ttemp_val = ({ixfe: val.ixfe, XF: XFs[val.ixfe], v:val.rknum, t:'n'}/*:any*/);\n\t\t\t\t\tif(BIFF2Fmt > 0) temp_val.z = BIFF2FmtTable[(temp_val.ixfe>>8) & 0x3F];\n\t\t\t\t\tsafe_format_xf(temp_val, options, wb.opts.Date1904);\n\t\t\t\t\taddcell({c:val.c, r:val.r}, temp_val, options);\n\t\t\t\t} break;\n\t\t\t\tcase 0x00bd /* MulRk */: {\n\t\t\t\t\tfor(var j = val.c; j <= val.C; ++j) {\n\t\t\t\t\t\tvar ixfe = val.rkrec[j-val.c][0];\n\t\t\t\t\t\ttemp_val= ({ixfe:ixfe, XF:XFs[ixfe], v:val.rkrec[j-val.c][1], t:'n'}/*:any*/);\n\t\t\t\t\t\tif(BIFF2Fmt > 0) temp_val.z = BIFF2FmtTable[(temp_val.ixfe>>8) & 0x3F];\n\t\t\t\t\t\tsafe_format_xf(temp_val, options, wb.opts.Date1904);\n\t\t\t\t\t\taddcell({c:j, r:val.r}, temp_val, options);\n\t\t\t\t\t}\n\t\t\t\t} break;\n\t\t\t\tcase 0x0006: case 0x0206: case 0x0406 /* Formula */: {\n\t\t\t\t\tif(val.val == 'String') { last_formula = val; break; }\n\t\t\t\t\ttemp_val = make_cell(val.val, val.cell.ixfe, val.tt);\n\t\t\t\t\ttemp_val.XF = XFs[temp_val.ixfe];\n\t\t\t\t\tif(options.cellFormula) {\n\t\t\t\t\t\tvar _f = val.formula;\n\t\t\t\t\t\tif(_f && _f[0] && _f[0][0] && _f[0][0][0] == 'PtgExp') {\n\t\t\t\t\t\t\tvar _fr = _f[0][0][1][0], _fc = _f[0][0][1][1];\n\t\t\t\t\t\t\tvar _fe = encode_cell({r:_fr, c:_fc});\n\t\t\t\t\t\t\tif(sharedf[_fe]) temp_val.f = \"\"+stringify_formula(val.formula,range,val.cell,supbooks, opts);\n\t\t\t\t\t\t\telse temp_val.F = ((options.dense ? (out[_fr]||[])[_fc]: out[_fe]) || {}).F;\n\t\t\t\t\t\t} else temp_val.f = \"\"+stringify_formula(val.formula,range,val.cell,supbooks, opts);\n\t\t\t\t\t}\n\t\t\t\t\tif(BIFF2Fmt > 0) temp_val.z = BIFF2FmtTable[(temp_val.ixfe>>8) & 0x3F];\n\t\t\t\t\tsafe_format_xf(temp_val, options, wb.opts.Date1904);\n\t\t\t\t\taddcell(val.cell, temp_val, options);\n\t\t\t\t\tlast_formula = val;\n\t\t\t\t} break;\n\t\t\t\tcase 0x0007: case 0x0207 /* String */: {\n\t\t\t\t\tif(last_formula) { /* technically always true */\n\t\t\t\t\t\tlast_formula.val = val;\n\t\t\t\t\t\ttemp_val = make_cell(val, last_formula.cell.ixfe, 's');\n\t\t\t\t\t\ttemp_val.XF = XFs[temp_val.ixfe];\n\t\t\t\t\t\tif(options.cellFormula) {\n\t\t\t\t\t\t\ttemp_val.f = \"\"+stringify_formula(last_formula.formula, range, last_formula.cell, supbooks, opts);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(BIFF2Fmt > 0) temp_val.z = BIFF2FmtTable[(temp_val.ixfe>>8) & 0x3F];\n\t\t\t\t\t\tsafe_format_xf(temp_val, options, wb.opts.Date1904);\n\t\t\t\t\t\taddcell(last_formula.cell, temp_val, options);\n\t\t\t\t\t\tlast_formula = null;\n\t\t\t\t\t} else throw new Error(\"String record expects Formula\");\n\t\t\t\t} break;\n\t\t\t\tcase 0x0021: case 0x0221 /* Array */: {\n\t\t\t\t\tarrayf.push(val);\n\t\t\t\t\tvar _arraystart = encode_cell(val[0].s);\n\t\t\t\t\tcc = options.dense ? (out[val[0].s.r]||[])[val[0].s.c] : out[_arraystart];\n\t\t\t\t\tif(options.cellFormula && cc) {\n\t\t\t\t\t\tif(!last_formula) break; /* technically unreachable */\n\t\t\t\t\t\tif(!_arraystart || !cc) break;\n\t\t\t\t\t\tcc.f = \"\"+stringify_formula(val[1], range, val[0], supbooks, opts);\n\t\t\t\t\t\tcc.F = encode_range(val[0]);\n\t\t\t\t\t}\n\t\t\t\t} break;\n\t\t\t\tcase 0x04bc /* ShrFmla */: {\n\t\t\t\t\tif(!options.cellFormula) break;\n\t\t\t\t\tif(last_cell) {\n\t\t\t\t\t\t/* TODO: capture range */\n\t\t\t\t\t\tif(!last_formula) break; /* technically unreachable */\n\t\t\t\t\t\tsharedf[encode_cell(last_formula.cell)]= val[0];\n\t\t\t\t\t\tcc = options.dense ? (out[last_formula.cell.r]||[])[last_formula.cell.c] : out[encode_cell(last_formula.cell)];\n\t\t\t\t\t\t(cc||{}).f = \"\"+stringify_formula(val[0], range, lastcell, supbooks, opts);\n\t\t\t\t\t}\n\t\t\t\t} break;\n\t\t\t\tcase 0x00fd /* LabelSst */:\n\t\t\t\t\ttemp_val=make_cell(sst[val.isst].t, val.ixfe, 's');\n\t\t\t\t\tif(sst[val.isst].h) temp_val.h = sst[val.isst].h;\n\t\t\t\t\ttemp_val.XF = XFs[temp_val.ixfe];\n\t\t\t\t\tif(BIFF2Fmt > 0) temp_val.z = BIFF2FmtTable[(temp_val.ixfe>>8) & 0x3F];\n\t\t\t\t\tsafe_format_xf(temp_val, options, wb.opts.Date1904);\n\t\t\t\t\taddcell({c:val.c, r:val.r}, temp_val, options);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 0x0201 /* Blank */: if(options.sheetStubs) {\n\t\t\t\t\ttemp_val = ({ixfe: val.ixfe, XF: XFs[val.ixfe], t:'z'}/*:any*/);\n\t\t\t\t\tif(BIFF2Fmt > 0) temp_val.z = BIFF2FmtTable[(temp_val.ixfe>>8) & 0x3F];\n\t\t\t\t\tsafe_format_xf(temp_val, options, wb.opts.Date1904);\n\t\t\t\t\taddcell({c:val.c, r:val.r}, temp_val, options);\n\t\t\t\t} break;\n\t\t\t\tcase 0x00be /* MulBlank */: if(options.sheetStubs) {\n\t\t\t\t\tfor(var _j = val.c; _j <= val.C; ++_j) {\n\t\t\t\t\t\tvar _ixfe = val.ixfe[_j-val.c];\n\t\t\t\t\t\ttemp_val= ({ixfe:_ixfe, XF:XFs[_ixfe], t:'z'}/*:any*/);\n\t\t\t\t\t\tif(BIFF2Fmt > 0) temp_val.z = BIFF2FmtTable[(temp_val.ixfe>>8) & 0x3F];\n\t\t\t\t\t\tsafe_format_xf(temp_val, options, wb.opts.Date1904);\n\t\t\t\t\t\taddcell({c:_j, r:val.r}, temp_val, options);\n\t\t\t\t\t}\n\t\t\t\t} break;\n\t\t\t\tcase 0x00d6 /* RString */:\n\t\t\t\tcase 0x0204 /* Label */: case 0x0004 /* BIFF2STR */:\n\t\t\t\t\ttemp_val=make_cell(val.val, val.ixfe, 's');\n\t\t\t\t\ttemp_val.XF = XFs[temp_val.ixfe];\n\t\t\t\t\tif(BIFF2Fmt > 0) temp_val.z = BIFF2FmtTable[(temp_val.ixfe>>8) & 0x3F];\n\t\t\t\t\tsafe_format_xf(temp_val, options, wb.opts.Date1904);\n\t\t\t\t\taddcell({c:val.c, r:val.r}, temp_val, options);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 0x0000: case 0x0200 /* Dimensions */: {\n\t\t\t\t\tif(file_depth === 1) range = val; /* TODO: stack */\n\t\t\t\t} break;\n\t\t\t\tcase 0x00fc /* SST */: {\n\t\t\t\t\tsst = val;\n\t\t\t\t} break;\n\t\t\t\tcase 0x041e /* Format */: { /* val = [id, fmt] */\n\t\t\t\t\tif(opts.biff == 4) {\n\t\t\t\t\t\tBIFF2FmtTable[BIFF2Fmt++] = val[1];\n\t\t\t\t\t\tfor(var b4idx = 0; b4idx < BIFF2Fmt + 163; ++b4idx) if(table_fmt[b4idx] == val[1]) break;\n\t\t\t\t\t\tif(b4idx >= 163) SSF_load(val[1], BIFF2Fmt + 163);\n\t\t\t\t\t}\n\t\t\t\t\telse SSF_load(val[1], val[0]);\n\t\t\t\t} break;\n\t\t\t\tcase 0x001e /* BIFF2FORMAT */: {\n\t\t\t\t\tBIFF2FmtTable[BIFF2Fmt++] = val;\n\t\t\t\t\tfor(var b2idx = 0; b2idx < BIFF2Fmt + 163; ++b2idx) if(table_fmt[b2idx] == val) break;\n\t\t\t\t\tif(b2idx >= 163) SSF_load(val, BIFF2Fmt + 163);\n\t\t\t\t} break;\n\n\t\t\t\tcase 0x00e5 /* MergeCells */: merges = merges.concat(val); break;\n\n\t\t\t\tcase 0x005d /* Obj */: objects[val.cmo[0]] = opts.lastobj = val; break;\n\t\t\t\tcase 0x01b6 /* TxO */: opts.lastobj.TxO = val; break;\n\t\t\t\tcase 0x007f /* ImData */: opts.lastobj.ImData = val; break;\n\n\t\t\t\tcase 0x01b8 /* HLink */: {\n\t\t\t\t\tfor(rngR = val[0].s.r; rngR <= val[0].e.r; ++rngR)\n\t\t\t\t\t\tfor(rngC = val[0].s.c; rngC <= val[0].e.c; ++rngC) {\n\t\t\t\t\t\t\tcc = options.dense ? (out[rngR]||[])[rngC] : out[encode_cell({c:rngC,r:rngR})];\n\t\t\t\t\t\t\tif(cc) cc.l = val[1];\n\t\t\t\t\t\t}\n\t\t\t\t} break;\n\t\t\t\tcase 0x0800 /* HLinkTooltip */: {\n\t\t\t\t\tfor(rngR = val[0].s.r; rngR <= val[0].e.r; ++rngR)\n\t\t\t\t\t\tfor(rngC = val[0].s.c; rngC <= val[0].e.c; ++rngC) {\n\t\t\t\t\t\t\tcc = options.dense ? (out[rngR]||[])[rngC] : out[encode_cell({c:rngC,r:rngR})];\n\t\t\t\t\t\t\tif(cc && cc.l) cc.l.Tooltip = val[1];\n\t\t\t\t\t\t\t}\n\t\t\t\t} break;\n\t\t\t\tcase 0x001c /* Note */: {\n\t\t\t\t\tif(opts.biff <= 5 && opts.biff >= 2) break; /* TODO: BIFF5 */\n\t\t\t\t\tcc = options.dense ? (out[val[0].r]||[])[val[0].c] : out[encode_cell(val[0])];\n\t\t\t\t\tvar noteobj = objects[val[2]];\n\t\t\t\t\tif(!cc) {\n\t\t\t\t\t\tif(options.dense) {\n\t\t\t\t\t\t\tif(!out[val[0].r]) out[val[0].r] = [];\n\t\t\t\t\t\t\tcc = out[val[0].r][val[0].c] = ({t:\"z\"}/*:any*/);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tcc = out[encode_cell(val[0])] = ({t:\"z\"}/*:any*/);\n\t\t\t\t\t\t}\n\t\t\t\t\t\trange.e.r = Math.max(range.e.r, val[0].r);\n\t\t\t\t\t\trange.s.r = Math.min(range.s.r, val[0].r);\n\t\t\t\t\t\trange.e.c = Math.max(range.e.c, val[0].c);\n\t\t\t\t\t\trange.s.c = Math.min(range.s.c, val[0].c);\n\t\t\t\t\t}\n\t\t\t\t\tif(!cc.c) cc.c = [];\n\t\t\t\t\tcmnt = {a:val[1],t:noteobj.TxO.t};\n\t\t\t\t\tcc.c.push(cmnt);\n\t\t\t\t} break;\n\t\t\t\tcase 0x087d /* XFExt */: update_xfext(XFs[val.ixfe], val.ext); break;\n\t\t\t\tcase 0x007d /* ColInfo */: {\n\t\t\t\t\tif(!opts.cellStyles) break;\n\t\t\t\t\twhile(val.e >= val.s) {\n\t\t\t\t\t\tcolinfo[val.e--] = { width: val.w/256, level: (val.level || 0), hidden: !!(val.flags & 1) };\n\t\t\t\t\t\tif(!seencol) { seencol = true; find_mdw_colw(val.w/256); }\n\t\t\t\t\t\tprocess_col(colinfo[val.e+1]);\n\t\t\t\t\t}\n\t\t\t\t} break;\n\t\t\t\tcase 0x0208 /* Row */: {\n\t\t\t\t\tvar rowobj = {};\n\t\t\t\t\tif(val.level != null) { rowinfo[val.r] = rowobj; rowobj.level = val.level; }\n\t\t\t\t\tif(val.hidden) { rowinfo[val.r] = rowobj; rowobj.hidden = true; }\n\t\t\t\t\tif(val.hpt) {\n\t\t\t\t\t\trowinfo[val.r] = rowobj;\n\t\t\t\t\t\trowobj.hpt = val.hpt; rowobj.hpx = pt2px(val.hpt);\n\t\t\t\t\t}\n\t\t\t\t} break;\n\t\t\t\tcase 0x0026 /* LeftMargin */:\n\t\t\t\tcase 0x0027 /* RightMargin */:\n\t\t\t\tcase 0x0028 /* TopMargin */:\n\t\t\t\tcase 0x0029 /* BottomMargin */:\n\t\t\t\t\tif(!out['!margins']) default_margins(out['!margins'] = {});\n\t\t\t\t\tout['!margins'][({0x26: \"left\", 0x27:\"right\", 0x28:\"top\", 0x29:\"bottom\"})[RecordType]] = val;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 0x00a1 /* Setup */: // TODO\n\t\t\t\t\tif(!out['!margins']) default_margins(out['!margins'] = {});\n\t\t\t\t\tout['!margins'].header = val.header;\n\t\t\t\t\tout['!margins'].footer = val.footer;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 0x023e /* Window2 */: // TODO\n\t\t\t\t\t// $FlowIgnore\n\t\t\t\t\tif(val.RTL) Workbook.Views[0].RTL = true;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 0x0092 /* Palette */: palette = val; break;\n\t\t\t\tcase 0x0896 /* Theme */: themes = val; break;\n\t\t\t\tcase 0x008c /* Country */: country = val; break;\n\t\t\t\tcase 0x01ba /* CodeName */: {\n\t\t\t\t\t/*:: if(!Workbook.WBProps) Workbook.WBProps = {}; */\n\t\t\t\t\tif(!cur_sheet) Workbook.WBProps.CodeName = val || \"ThisWorkbook\";\n\t\t\t\t\telse wsprops.CodeName = val || wsprops.name;\n\t\t\t\t} break;\n\t\t\t}\n\t\t} else {\n\t\t\tif(!R) console.error(\"Missing Info for XLS Record 0x\" + RecordType.toString(16));\n\t\t\tblob.l += length;\n\t\t}\n\t}\n\twb.SheetNames=keys(Directory).sort(function(a,b) { return Number(a) - Number(b); }).map(function(x){return Directory[x].name;});\n\tif(!options.bookSheets) wb.Sheets=Sheets;\n\tif(!wb.SheetNames.length && Preamble[\"!ref\"]) {\n\t\twb.SheetNames.push(\"Sheet1\");\n\t\t/*jshint -W069 */\n\t\tif(wb.Sheets) wb.Sheets[\"Sheet1\"] = Preamble;\n\t\t/*jshint +W069 */\n\t} else wb.Preamble=Preamble;\n\tif(wb.Sheets) FilterDatabases.forEach(function(r,i) { wb.Sheets[wb.SheetNames[i]]['!autofilter'] = r; });\n\twb.Strings = sst;\n\twb.SSF = dup(table_fmt);\n\tif(opts.enc) wb.Encryption = opts.enc;\n\tif(themes) wb.Themes = themes;\n\twb.Metadata = {};\n\tif(country !== undefined) wb.Metadata.Country = country;\n\tif(supbooks.names.length > 0) Workbook.Names = supbooks.names;\n\twb.Workbook = Workbook;\n\treturn wb;\n}\n\n/* TODO: split props*/\nvar PSCLSID = {\n\tSI: \"e0859ff2f94f6810ab9108002b27b3d9\",\n\tDSI: \"02d5cdd59c2e1b10939708002b2cf9ae\",\n\tUDI: \"05d5cdd59c2e1b10939708002b2cf9ae\"\n};\nfunction parse_xls_props(cfb/*:CFBContainer*/, props, o) {\n\t/* [MS-OSHARED] 2.3.3.2.2 Document Summary Information Property Set */\n\tvar DSI = CFB.find(cfb, '/!DocumentSummaryInformation');\n\tif(DSI && DSI.size > 0) try {\n\t\tvar DocSummary = parse_PropertySetStream(DSI, DocSummaryPIDDSI, PSCLSID.DSI);\n\t\tfor(var d in DocSummary) props[d] = DocSummary[d];\n\t} catch(e) {if(o.WTF) throw e;/* empty */}\n\n\t/* [MS-OSHARED] 2.3.3.2.1 Summary Information Property Set*/\n\tvar SI = CFB.find(cfb, '/!SummaryInformation');\n\tif(SI && SI.size > 0) try {\n\t\tvar Summary = parse_PropertySetStream(SI, SummaryPIDSI, PSCLSID.SI);\n\t\tfor(var s in Summary) if(props[s] == null) props[s] = Summary[s];\n\t} catch(e) {if(o.WTF) throw e;/* empty */}\n\n\tif(props.HeadingPairs && props.TitlesOfParts) {\n\t\tload_props_pairs(props.HeadingPairs, props.TitlesOfParts, props, o);\n\t\tdelete props.HeadingPairs; delete props.TitlesOfParts;\n\t}\n}\nfunction write_xls_props(wb/*:Workbook*/, cfb/*:CFBContainer*/) {\n\tvar DSEntries = [], SEntries = [], CEntries = [];\n\tvar i = 0, Keys;\n\tvar DocSummaryRE/*:{[key:string]:string}*/ = evert_key(DocSummaryPIDDSI, \"n\");\n\tvar SummaryRE/*:{[key:string]:string}*/ = evert_key(SummaryPIDSI, \"n\");\n\tif(wb.Props) {\n\t\tKeys = keys(wb.Props);\n\t\t// $FlowIgnore\n\t\tfor(i = 0; i < Keys.length; ++i) (Object.prototype.hasOwnProperty.call(DocSummaryRE, Keys[i]) ? DSEntries : Object.prototype.hasOwnProperty.call(SummaryRE, Keys[i]) ? SEntries : CEntries).push([Keys[i], wb.Props[Keys[i]]]);\n\t}\n\tif(wb.Custprops) {\n\t\tKeys = keys(wb.Custprops);\n\t\t// $FlowIgnore\n\t\tfor(i = 0; i < Keys.length; ++i) if(!Object.prototype.hasOwnProperty.call((wb.Props||{}), Keys[i])) (Object.prototype.hasOwnProperty.call(DocSummaryRE, Keys[i]) ? DSEntries : Object.prototype.hasOwnProperty.call(SummaryRE, Keys[i]) ? SEntries : CEntries).push([Keys[i], wb.Custprops[Keys[i]]]);\n\t}\n\tvar CEntries2 = [];\n\tfor(i = 0; i < CEntries.length; ++i) {\n\t\tif(XLSPSSkip.indexOf(CEntries[i][0]) > -1 || PseudoPropsPairs.indexOf(CEntries[i][0]) > -1) continue;\n\t\tif(CEntries[i][1] == null) continue;\n\t\tCEntries2.push(CEntries[i]);\n\t}\n\tif(SEntries.length) CFB.utils.cfb_add(cfb, \"/\\u0005SummaryInformation\", write_PropertySetStream(SEntries, PSCLSID.SI, SummaryRE, SummaryPIDSI));\n\tif(DSEntries.length || CEntries2.length) CFB.utils.cfb_add(cfb, \"/\\u0005DocumentSummaryInformation\", write_PropertySetStream(DSEntries, PSCLSID.DSI, DocSummaryRE, DocSummaryPIDDSI, CEntries2.length ? CEntries2 : null, PSCLSID.UDI));\n}\n\nfunction parse_xlscfb(cfb/*:any*/, options/*:?ParseOpts*/)/*:Workbook*/ {\nif(!options) options = {};\nfix_read_opts(options);\nreset_cp();\nif(options.codepage) set_ansi(options.codepage);\nvar CompObj/*:?CFBEntry*/, WB/*:?any*/;\nif(cfb.FullPaths) {\n\tif(CFB.find(cfb, '/encryption')) throw new Error(\"File is password-protected\");\n\tCompObj = CFB.find(cfb, '!CompObj');\n\tWB = CFB.find(cfb, '/Workbook') || CFB.find(cfb, '/Book');\n} else {\n\tswitch(options.type) {\n\t\tcase 'base64': cfb = s2a(Base64_decode(cfb)); break;\n\t\tcase 'binary': cfb = s2a(cfb); break;\n\t\tcase 'buffer': break;\n\t\tcase 'array': if(!Array.isArray(cfb)) cfb = Array.prototype.slice.call(cfb); break;\n\t}\n\tprep_blob(cfb, 0);\n\tWB = ({content: cfb}/*:any*/);\n}\nvar /*::CompObjP, */WorkbookP/*:: :Workbook = XLSX.utils.book_new(); */;\n\nvar _data/*:?any*/;\nif(CompObj) /*::CompObjP = */parse_compobj(CompObj);\nif(options.bookProps && !options.bookSheets) WorkbookP = ({}/*:any*/);\nelse/*:: if(cfb instanceof CFBContainer) */ {\n\tvar T = has_buf ? 'buffer' : 'array';\n\tif(WB && WB.content) WorkbookP = parse_workbook(WB.content, options);\n\t/* Quattro Pro 7-8 */\n\telse if((_data=CFB.find(cfb, 'PerfectOffice_MAIN')) && _data.content) WorkbookP = WK_.to_workbook(_data.content, (options.type = T, options));\n\t/* Quattro Pro 9 */\n\telse if((_data=CFB.find(cfb, 'NativeContent_MAIN')) && _data.content) WorkbookP = WK_.to_workbook(_data.content, (options.type = T, options));\n\t/* Works 4 for Mac */\n\telse if((_data=CFB.find(cfb, 'MN0')) && _data.content) throw new Error(\"Unsupported Works 4 for Mac file\");\n\telse throw new Error(\"Cannot find Workbook stream\");\n\tif(options.bookVBA && cfb.FullPaths && CFB.find(cfb, '/_VBA_PROJECT_CUR/VBA/dir')) WorkbookP.vbaraw = make_vba_xls(cfb);\n}\n\nvar props = {};\nif(cfb.FullPaths) parse_xls_props(/*::((*/cfb/*:: :any):CFBContainer)*/, props, options);\n\nWorkbookP.Props = WorkbookP.Custprops = props; /* TODO: split up properties */\nif(options.bookFiles) WorkbookP.cfb = cfb;\n/*WorkbookP.CompObjP = CompObjP; // TODO: storage? */\nreturn WorkbookP;\n}\n\n\nfunction write_xlscfb(wb/*:Workbook*/, opts/*:WriteOpts*/)/*:CFBContainer*/ {\n\tvar o = opts || {};\n\tvar cfb = CFB.utils.cfb_new({root:\"R\"});\n\tvar wbpath = \"/Workbook\";\n\tswitch(o.bookType || \"xls\") {\n\t\tcase \"xls\": o.bookType = \"biff8\";\n\t\t/* falls through */\n\t\tcase \"xla\": if(!o.bookType) o.bookType = \"xla\";\n\t\t/* falls through */\n\t\tcase \"biff8\": wbpath = \"/Workbook\"; o.biff = 8; break;\n\t\tcase \"biff5\": wbpath = \"/Book\"; o.biff = 5; break;\n\t\tdefault: throw new Error(\"invalid type \" + o.bookType + \" for XLS CFB\");\n\t}\n\tCFB.utils.cfb_add(cfb, wbpath, write_biff_buf(wb, o));\n\tif(o.biff == 8 && (wb.Props || wb.Custprops)) write_xls_props(wb, cfb);\n\t// TODO: SI, DSI, CO\n\tif(o.biff == 8 && wb.vbaraw) fill_vba_xls(cfb, CFB.read(wb.vbaraw, {type: typeof wb.vbaraw == \"string\" ? \"binary\" : \"buffer\"}));\n\treturn cfb;\n}\n/* [MS-XLSB] 2.3 Record Enumeration */\nvar XLSBRecordEnum = {\n\t/*::[*/0x0000/*::]*/: { /* n:\"BrtRowHdr\", */ f:parse_BrtRowHdr },\n\t/*::[*/0x0001/*::]*/: { /* n:\"BrtCellBlank\", */ f:parse_BrtCellBlank },\n\t/*::[*/0x0002/*::]*/: { /* n:\"BrtCellRk\", */ f:parse_BrtCellRk },\n\t/*::[*/0x0003/*::]*/: { /* n:\"BrtCellError\", */ f:parse_BrtCellError },\n\t/*::[*/0x0004/*::]*/: { /* n:\"BrtCellBool\", */ f:parse_BrtCellBool },\n\t/*::[*/0x0005/*::]*/: { /* n:\"BrtCellReal\", */ f:parse_BrtCellReal },\n\t/*::[*/0x0006/*::]*/: { /* n:\"BrtCellSt\", */ f:parse_BrtCellSt },\n\t/*::[*/0x0007/*::]*/: { /* n:\"BrtCellIsst\", */ f:parse_BrtCellIsst },\n\t/*::[*/0x0008/*::]*/: { /* n:\"BrtFmlaString\", */ f:parse_BrtFmlaString },\n\t/*::[*/0x0009/*::]*/: { /* n:\"BrtFmlaNum\", */ f:parse_BrtFmlaNum },\n\t/*::[*/0x000A/*::]*/: { /* n:\"BrtFmlaBool\", */ f:parse_BrtFmlaBool },\n\t/*::[*/0x000B/*::]*/: { /* n:\"BrtFmlaError\", */ f:parse_BrtFmlaError },\n\t/*::[*/0x000C/*::]*/: { /* n:\"BrtShortBlank\", */ f:parse_BrtShortBlank },\n\t/*::[*/0x000D/*::]*/: { /* n:\"BrtShortRk\", */ f:parse_BrtShortRk },\n\t/*::[*/0x000E/*::]*/: { /* n:\"BrtShortError\", */ f:parse_BrtShortError },\n\t/*::[*/0x000F/*::]*/: { /* n:\"BrtShortBool\", */ f:parse_BrtShortBool },\n\t/*::[*/0x0010/*::]*/: { /* n:\"BrtShortReal\", */ f:parse_BrtShortReal },\n\t/*::[*/0x0011/*::]*/: { /* n:\"BrtShortSt\", */ f:parse_BrtShortSt },\n\t/*::[*/0x0012/*::]*/: { /* n:\"BrtShortIsst\", */ f:parse_BrtShortIsst },\n\t/*::[*/0x0013/*::]*/: { /* n:\"BrtSSTItem\", */ f:parse_RichStr },\n\t/*::[*/0x0014/*::]*/: { /* n:\"BrtPCDIMissing\" */ },\n\t/*::[*/0x0015/*::]*/: { /* n:\"BrtPCDINumber\" */ },\n\t/*::[*/0x0016/*::]*/: { /* n:\"BrtPCDIBoolean\" */ },\n\t/*::[*/0x0017/*::]*/: { /* n:\"BrtPCDIError\" */ },\n\t/*::[*/0x0018/*::]*/: { /* n:\"BrtPCDIString\" */ },\n\t/*::[*/0x0019/*::]*/: { /* n:\"BrtPCDIDatetime\" */ },\n\t/*::[*/0x001A/*::]*/: { /* n:\"BrtPCDIIndex\" */ },\n\t/*::[*/0x001B/*::]*/: { /* n:\"BrtPCDIAMissing\" */ },\n\t/*::[*/0x001C/*::]*/: { /* n:\"BrtPCDIANumber\" */ },\n\t/*::[*/0x001D/*::]*/: { /* n:\"BrtPCDIABoolean\" */ },\n\t/*::[*/0x001E/*::]*/: { /* n:\"BrtPCDIAError\" */ },\n\t/*::[*/0x001F/*::]*/: { /* n:\"BrtPCDIAString\" */ },\n\t/*::[*/0x0020/*::]*/: { /* n:\"BrtPCDIADatetime\" */ },\n\t/*::[*/0x0021/*::]*/: { /* n:\"BrtPCRRecord\" */ },\n\t/*::[*/0x0022/*::]*/: { /* n:\"BrtPCRRecordDt\" */ },\n\t/*::[*/0x0023/*::]*/: { /* n:\"BrtFRTBegin\", */ T:1 },\n\t/*::[*/0x0024/*::]*/: { /* n:\"BrtFRTEnd\", */ T:-1 },\n\t/*::[*/0x0025/*::]*/: { /* n:\"BrtACBegin\", */ T:1 },\n\t/*::[*/0x0026/*::]*/: { /* n:\"BrtACEnd\", */ T:-1 },\n\t/*::[*/0x0027/*::]*/: { /* n:\"BrtName\", */ f:parse_BrtName },\n\t/*::[*/0x0028/*::]*/: { /* n:\"BrtIndexRowBlock\" */ },\n\t/*::[*/0x002A/*::]*/: { /* n:\"BrtIndexBlock\" */ },\n\t/*::[*/0x002B/*::]*/: { /* n:\"BrtFont\", */ f:parse_BrtFont },\n\t/*::[*/0x002C/*::]*/: { /* n:\"BrtFmt\", */ f:parse_BrtFmt },\n\t/*::[*/0x002D/*::]*/: { /* n:\"BrtFill\", */ f:parse_BrtFill },\n\t/*::[*/0x002E/*::]*/: { /* n:\"BrtBorder\", */ f:parse_BrtBorder },\n\t/*::[*/0x002F/*::]*/: { /* n:\"BrtXF\", */ f:parse_BrtXF },\n\t/*::[*/0x0030/*::]*/: { /* n:\"BrtStyle\" */ },\n\t/*::[*/0x0031/*::]*/: { /* n:\"BrtCellMeta\", */ f:parse_Int32LE },\n\t/*::[*/0x0032/*::]*/: { /* n:\"BrtValueMeta\" */ },\n\t/*::[*/0x0033/*::]*/: { /* n:\"BrtMdb\" */ f:parse_BrtMdb },\n\t/*::[*/0x0034/*::]*/: { /* n:\"BrtBeginFmd\", */ T:1 },\n\t/*::[*/0x0035/*::]*/: { /* n:\"BrtEndFmd\", */ T:-1 },\n\t/*::[*/0x0036/*::]*/: { /* n:\"BrtBeginMdx\", */ T:1 },\n\t/*::[*/0x0037/*::]*/: { /* n:\"BrtEndMdx\", */ T:-1 },\n\t/*::[*/0x0038/*::]*/: { /* n:\"BrtBeginMdxTuple\", */ T:1 },\n\t/*::[*/0x0039/*::]*/: { /* n:\"BrtEndMdxTuple\", */ T:-1 },\n\t/*::[*/0x003A/*::]*/: { /* n:\"BrtMdxMbrIstr\" */ },\n\t/*::[*/0x003B/*::]*/: { /* n:\"BrtStr\" */ },\n\t/*::[*/0x003C/*::]*/: { /* n:\"BrtColInfo\", */ f:parse_ColInfo },\n\t/*::[*/0x003E/*::]*/: { /* n:\"BrtCellRString\", */ f:parse_BrtCellRString },\n\t/*::[*/0x003F/*::]*/: { /* n:\"BrtCalcChainItem$\", */ f:parse_BrtCalcChainItem$ },\n\t/*::[*/0x0040/*::]*/: { /* n:\"BrtDVal\", */ f:parse_BrtDVal },\n\t/*::[*/0x0041/*::]*/: { /* n:\"BrtSxvcellNum\" */ },\n\t/*::[*/0x0042/*::]*/: { /* n:\"BrtSxvcellStr\" */ },\n\t/*::[*/0x0043/*::]*/: { /* n:\"BrtSxvcellBool\" */ },\n\t/*::[*/0x0044/*::]*/: { /* n:\"BrtSxvcellErr\" */ },\n\t/*::[*/0x0045/*::]*/: { /* n:\"BrtSxvcellDate\" */ },\n\t/*::[*/0x0046/*::]*/: { /* n:\"BrtSxvcellNil\" */ },\n\t/*::[*/0x0080/*::]*/: { /* n:\"BrtFileVersion\" */ },\n\t/*::[*/0x0081/*::]*/: { /* n:\"BrtBeginSheet\", */ T:1 },\n\t/*::[*/0x0082/*::]*/: { /* n:\"BrtEndSheet\", */ T:-1 },\n\t/*::[*/0x0083/*::]*/: { /* n:\"BrtBeginBook\", */ T:1, f:parsenoop, p:0 },\n\t/*::[*/0x0084/*::]*/: { /* n:\"BrtEndBook\", */ T:-1 },\n\t/*::[*/0x0085/*::]*/: { /* n:\"BrtBeginWsViews\", */ T:1 },\n\t/*::[*/0x0086/*::]*/: { /* n:\"BrtEndWsViews\", */ T:-1 },\n\t/*::[*/0x0087/*::]*/: { /* n:\"BrtBeginBookViews\", */ T:1 },\n\t/*::[*/0x0088/*::]*/: { /* n:\"BrtEndBookViews\", */ T:-1 },\n\t/*::[*/0x0089/*::]*/: { /* n:\"BrtBeginWsView\", */ T:1, f:parse_BrtBeginWsView },\n\t/*::[*/0x008A/*::]*/: { /* n:\"BrtEndWsView\", */ T:-1 },\n\t/*::[*/0x008B/*::]*/: { /* n:\"BrtBeginCsViews\", */ T:1 },\n\t/*::[*/0x008C/*::]*/: { /* n:\"BrtEndCsViews\", */ T:-1 },\n\t/*::[*/0x008D/*::]*/: { /* n:\"BrtBeginCsView\", */ T:1 },\n\t/*::[*/0x008E/*::]*/: { /* n:\"BrtEndCsView\", */ T:-1 },\n\t/*::[*/0x008F/*::]*/: { /* n:\"BrtBeginBundleShs\", */ T:1 },\n\t/*::[*/0x0090/*::]*/: { /* n:\"BrtEndBundleShs\", */ T:-1 },\n\t/*::[*/0x0091/*::]*/: { /* n:\"BrtBeginSheetData\", */ T:1 },\n\t/*::[*/0x0092/*::]*/: { /* n:\"BrtEndSheetData\", */ T:-1 },\n\t/*::[*/0x0093/*::]*/: { /* n:\"BrtWsProp\", */ f:parse_BrtWsProp },\n\t/*::[*/0x0094/*::]*/: { /* n:\"BrtWsDim\", */ f:parse_BrtWsDim, p:16 },\n\t/*::[*/0x0097/*::]*/: { /* n:\"BrtPane\", */ f:parse_BrtPane },\n\t/*::[*/0x0098/*::]*/: { /* n:\"BrtSel\" */ },\n\t/*::[*/0x0099/*::]*/: { /* n:\"BrtWbProp\", */ f:parse_BrtWbProp },\n\t/*::[*/0x009A/*::]*/: { /* n:\"BrtWbFactoid\" */ },\n\t/*::[*/0x009B/*::]*/: { /* n:\"BrtFileRecover\" */ },\n\t/*::[*/0x009C/*::]*/: { /* n:\"BrtBundleSh\", */ f:parse_BrtBundleSh },\n\t/*::[*/0x009D/*::]*/: { /* n:\"BrtCalcProp\" */ },\n\t/*::[*/0x009E/*::]*/: { /* n:\"BrtBookView\" */ },\n\t/*::[*/0x009F/*::]*/: { /* n:\"BrtBeginSst\", */ T:1, f:parse_BrtBeginSst },\n\t/*::[*/0x00A0/*::]*/: { /* n:\"BrtEndSst\", */ T:-1 },\n\t/*::[*/0x00A1/*::]*/: { /* n:\"BrtBeginAFilter\", */ T:1, f:parse_UncheckedRfX },\n\t/*::[*/0x00A2/*::]*/: { /* n:\"BrtEndAFilter\", */ T:-1 },\n\t/*::[*/0x00A3/*::]*/: { /* n:\"BrtBeginFilterColumn\", */ T:1 },\n\t/*::[*/0x00A4/*::]*/: { /* n:\"BrtEndFilterColumn\", */ T:-1 },\n\t/*::[*/0x00A5/*::]*/: { /* n:\"BrtBeginFilters\", */ T:1 },\n\t/*::[*/0x00A6/*::]*/: { /* n:\"BrtEndFilters\", */ T:-1 },\n\t/*::[*/0x00A7/*::]*/: { /* n:\"BrtFilter\" */ },\n\t/*::[*/0x00A8/*::]*/: { /* n:\"BrtColorFilter\" */ },\n\t/*::[*/0x00A9/*::]*/: { /* n:\"BrtIconFilter\" */ },\n\t/*::[*/0x00AA/*::]*/: { /* n:\"BrtTop10Filter\" */ },\n\t/*::[*/0x00AB/*::]*/: { /* n:\"BrtDynamicFilter\" */ },\n\t/*::[*/0x00AC/*::]*/: { /* n:\"BrtBeginCustomFilters\", */ T:1 },\n\t/*::[*/0x00AD/*::]*/: { /* n:\"BrtEndCustomFilters\", */ T:-1 },\n\t/*::[*/0x00AE/*::]*/: { /* n:\"BrtCustomFilter\" */ },\n\t/*::[*/0x00AF/*::]*/: { /* n:\"BrtAFilterDateGroupItem\" */ },\n\t/*::[*/0x00B0/*::]*/: { /* n:\"BrtMergeCell\", */ f:parse_BrtMergeCell },\n\t/*::[*/0x00B1/*::]*/: { /* n:\"BrtBeginMergeCells\", */ T:1 },\n\t/*::[*/0x00B2/*::]*/: { /* n:\"BrtEndMergeCells\", */ T:-1 },\n\t/*::[*/0x00B3/*::]*/: { /* n:\"BrtBeginPivotCacheDef\", */ T:1 },\n\t/*::[*/0x00B4/*::]*/: { /* n:\"BrtEndPivotCacheDef\", */ T:-1 },\n\t/*::[*/0x00B5/*::]*/: { /* n:\"BrtBeginPCDFields\", */ T:1 },\n\t/*::[*/0x00B6/*::]*/: { /* n:\"BrtEndPCDFields\", */ T:-1 },\n\t/*::[*/0x00B7/*::]*/: { /* n:\"BrtBeginPCDField\", */ T:1 },\n\t/*::[*/0x00B8/*::]*/: { /* n:\"BrtEndPCDField\", */ T:-1 },\n\t/*::[*/0x00B9/*::]*/: { /* n:\"BrtBeginPCDSource\", */ T:1 },\n\t/*::[*/0x00BA/*::]*/: { /* n:\"BrtEndPCDSource\", */ T:-1 },\n\t/*::[*/0x00BB/*::]*/: { /* n:\"BrtBeginPCDSRange\", */ T:1 },\n\t/*::[*/0x00BC/*::]*/: { /* n:\"BrtEndPCDSRange\", */ T:-1 },\n\t/*::[*/0x00BD/*::]*/: { /* n:\"BrtBeginPCDFAtbl\", */ T:1 },\n\t/*::[*/0x00BE/*::]*/: { /* n:\"BrtEndPCDFAtbl\", */ T:-1 },\n\t/*::[*/0x00BF/*::]*/: { /* n:\"BrtBeginPCDIRun\", */ T:1 },\n\t/*::[*/0x00C0/*::]*/: { /* n:\"BrtEndPCDIRun\", */ T:-1 },\n\t/*::[*/0x00C1/*::]*/: { /* n:\"BrtBeginPivotCacheRecords\", */ T:1 },\n\t/*::[*/0x00C2/*::]*/: { /* n:\"BrtEndPivotCacheRecords\", */ T:-1 },\n\t/*::[*/0x00C3/*::]*/: { /* n:\"BrtBeginPCDHierarchies\", */ T:1 },\n\t/*::[*/0x00C4/*::]*/: { /* n:\"BrtEndPCDHierarchies\", */ T:-1 },\n\t/*::[*/0x00C5/*::]*/: { /* n:\"BrtBeginPCDHierarchy\", */ T:1 },\n\t/*::[*/0x00C6/*::]*/: { /* n:\"BrtEndPCDHierarchy\", */ T:-1 },\n\t/*::[*/0x00C7/*::]*/: { /* n:\"BrtBeginPCDHFieldsUsage\", */ T:1 },\n\t/*::[*/0x00C8/*::]*/: { /* n:\"BrtEndPCDHFieldsUsage\", */ T:-1 },\n\t/*::[*/0x00C9/*::]*/: { /* n:\"BrtBeginExtConnection\", */ T:1 },\n\t/*::[*/0x00CA/*::]*/: { /* n:\"BrtEndExtConnection\", */ T:-1 },\n\t/*::[*/0x00CB/*::]*/: { /* n:\"BrtBeginECDbProps\", */ T:1 },\n\t/*::[*/0x00CC/*::]*/: { /* n:\"BrtEndECDbProps\", */ T:-1 },\n\t/*::[*/0x00CD/*::]*/: { /* n:\"BrtBeginECOlapProps\", */ T:1 },\n\t/*::[*/0x00CE/*::]*/: { /* n:\"BrtEndECOlapProps\", */ T:-1 },\n\t/*::[*/0x00CF/*::]*/: { /* n:\"BrtBeginPCDSConsol\", */ T:1 },\n\t/*::[*/0x00D0/*::]*/: { /* n:\"BrtEndPCDSConsol\", */ T:-1 },\n\t/*::[*/0x00D1/*::]*/: { /* n:\"BrtBeginPCDSCPages\", */ T:1 },\n\t/*::[*/0x00D2/*::]*/: { /* n:\"BrtEndPCDSCPages\", */ T:-1 },\n\t/*::[*/0x00D3/*::]*/: { /* n:\"BrtBeginPCDSCPage\", */ T:1 },\n\t/*::[*/0x00D4/*::]*/: { /* n:\"BrtEndPCDSCPage\", */ T:-1 },\n\t/*::[*/0x00D5/*::]*/: { /* n:\"BrtBeginPCDSCPItem\", */ T:1 },\n\t/*::[*/0x00D6/*::]*/: { /* n:\"BrtEndPCDSCPItem\", */ T:-1 },\n\t/*::[*/0x00D7/*::]*/: { /* n:\"BrtBeginPCDSCSets\", */ T:1 },\n\t/*::[*/0x00D8/*::]*/: { /* n:\"BrtEndPCDSCSets\", */ T:-1 },\n\t/*::[*/0x00D9/*::]*/: { /* n:\"BrtBeginPCDSCSet\", */ T:1 },\n\t/*::[*/0x00DA/*::]*/: { /* n:\"BrtEndPCDSCSet\", */ T:-1 },\n\t/*::[*/0x00DB/*::]*/: { /* n:\"BrtBeginPCDFGroup\", */ T:1 },\n\t/*::[*/0x00DC/*::]*/: { /* n:\"BrtEndPCDFGroup\", */ T:-1 },\n\t/*::[*/0x00DD/*::]*/: { /* n:\"BrtBeginPCDFGItems\", */ T:1 },\n\t/*::[*/0x00DE/*::]*/: { /* n:\"BrtEndPCDFGItems\", */ T:-1 },\n\t/*::[*/0x00DF/*::]*/: { /* n:\"BrtBeginPCDFGRange\", */ T:1 },\n\t/*::[*/0x00E0/*::]*/: { /* n:\"BrtEndPCDFGRange\", */ T:-1 },\n\t/*::[*/0x00E1/*::]*/: { /* n:\"BrtBeginPCDFGDiscrete\", */ T:1 },\n\t/*::[*/0x00E2/*::]*/: { /* n:\"BrtEndPCDFGDiscrete\", */ T:-1 },\n\t/*::[*/0x00E3/*::]*/: { /* n:\"BrtBeginPCDSDTupleCache\", */ T:1 },\n\t/*::[*/0x00E4/*::]*/: { /* n:\"BrtEndPCDSDTupleCache\", */ T:-1 },\n\t/*::[*/0x00E5/*::]*/: { /* n:\"BrtBeginPCDSDTCEntries\", */ T:1 },\n\t/*::[*/0x00E6/*::]*/: { /* n:\"BrtEndPCDSDTCEntries\", */ T:-1 },\n\t/*::[*/0x00E7/*::]*/: { /* n:\"BrtBeginPCDSDTCEMembers\", */ T:1 },\n\t/*::[*/0x00E8/*::]*/: { /* n:\"BrtEndPCDSDTCEMembers\", */ T:-1 },\n\t/*::[*/0x00E9/*::]*/: { /* n:\"BrtBeginPCDSDTCEMember\", */ T:1 },\n\t/*::[*/0x00EA/*::]*/: { /* n:\"BrtEndPCDSDTCEMember\", */ T:-1 },\n\t/*::[*/0x00EB/*::]*/: { /* n:\"BrtBeginPCDSDTCQueries\", */ T:1 },\n\t/*::[*/0x00EC/*::]*/: { /* n:\"BrtEndPCDSDTCQueries\", */ T:-1 },\n\t/*::[*/0x00ED/*::]*/: { /* n:\"BrtBeginPCDSDTCQuery\", */ T:1 },\n\t/*::[*/0x00EE/*::]*/: { /* n:\"BrtEndPCDSDTCQuery\", */ T:-1 },\n\t/*::[*/0x00EF/*::]*/: { /* n:\"BrtBeginPCDSDTCSets\", */ T:1 },\n\t/*::[*/0x00F0/*::]*/: { /* n:\"BrtEndPCDSDTCSets\", */ T:-1 },\n\t/*::[*/0x00F1/*::]*/: { /* n:\"BrtBeginPCDSDTCSet\", */ T:1 },\n\t/*::[*/0x00F2/*::]*/: { /* n:\"BrtEndPCDSDTCSet\", */ T:-1 },\n\t/*::[*/0x00F3/*::]*/: { /* n:\"BrtBeginPCDCalcItems\", */ T:1 },\n\t/*::[*/0x00F4/*::]*/: { /* n:\"BrtEndPCDCalcItems\", */ T:-1 },\n\t/*::[*/0x00F5/*::]*/: { /* n:\"BrtBeginPCDCalcItem\", */ T:1 },\n\t/*::[*/0x00F6/*::]*/: { /* n:\"BrtEndPCDCalcItem\", */ T:-1 },\n\t/*::[*/0x00F7/*::]*/: { /* n:\"BrtBeginPRule\", */ T:1 },\n\t/*::[*/0x00F8/*::]*/: { /* n:\"BrtEndPRule\", */ T:-1 },\n\t/*::[*/0x00F9/*::]*/: { /* n:\"BrtBeginPRFilters\", */ T:1 },\n\t/*::[*/0x00FA/*::]*/: { /* n:\"BrtEndPRFilters\", */ T:-1 },\n\t/*::[*/0x00FB/*::]*/: { /* n:\"BrtBeginPRFilter\", */ T:1 },\n\t/*::[*/0x00FC/*::]*/: { /* n:\"BrtEndPRFilter\", */ T:-1 },\n\t/*::[*/0x00FD/*::]*/: { /* n:\"BrtBeginPNames\", */ T:1 },\n\t/*::[*/0x00FE/*::]*/: { /* n:\"BrtEndPNames\", */ T:-1 },\n\t/*::[*/0x00FF/*::]*/: { /* n:\"BrtBeginPName\", */ T:1 },\n\t/*::[*/0x0100/*::]*/: { /* n:\"BrtEndPName\", */ T:-1 },\n\t/*::[*/0x0101/*::]*/: { /* n:\"BrtBeginPNPairs\", */ T:1 },\n\t/*::[*/0x0102/*::]*/: { /* n:\"BrtEndPNPairs\", */ T:-1 },\n\t/*::[*/0x0103/*::]*/: { /* n:\"BrtBeginPNPair\", */ T:1 },\n\t/*::[*/0x0104/*::]*/: { /* n:\"BrtEndPNPair\", */ T:-1 },\n\t/*::[*/0x0105/*::]*/: { /* n:\"BrtBeginECWebProps\", */ T:1 },\n\t/*::[*/0x0106/*::]*/: { /* n:\"BrtEndECWebProps\", */ T:-1 },\n\t/*::[*/0x0107/*::]*/: { /* n:\"BrtBeginEcWpTables\", */ T:1 },\n\t/*::[*/0x0108/*::]*/: { /* n:\"BrtEndECWPTables\", */ T:-1 },\n\t/*::[*/0x0109/*::]*/: { /* n:\"BrtBeginECParams\", */ T:1 },\n\t/*::[*/0x010A/*::]*/: { /* n:\"BrtEndECParams\", */ T:-1 },\n\t/*::[*/0x010B/*::]*/: { /* n:\"BrtBeginECParam\", */ T:1 },\n\t/*::[*/0x010C/*::]*/: { /* n:\"BrtEndECParam\", */ T:-1 },\n\t/*::[*/0x010D/*::]*/: { /* n:\"BrtBeginPCDKPIs\", */ T:1 },\n\t/*::[*/0x010E/*::]*/: { /* n:\"BrtEndPCDKPIs\", */ T:-1 },\n\t/*::[*/0x010F/*::]*/: { /* n:\"BrtBeginPCDKPI\", */ T:1 },\n\t/*::[*/0x0110/*::]*/: { /* n:\"BrtEndPCDKPI\", */ T:-1 },\n\t/*::[*/0x0111/*::]*/: { /* n:\"BrtBeginDims\", */ T:1 },\n\t/*::[*/0x0112/*::]*/: { /* n:\"BrtEndDims\", */ T:-1 },\n\t/*::[*/0x0113/*::]*/: { /* n:\"BrtBeginDim\", */ T:1 },\n\t/*::[*/0x0114/*::]*/: { /* n:\"BrtEndDim\", */ T:-1 },\n\t/*::[*/0x0115/*::]*/: { /* n:\"BrtIndexPartEnd\" */ },\n\t/*::[*/0x0116/*::]*/: { /* n:\"BrtBeginStyleSheet\", */ T:1 },\n\t/*::[*/0x0117/*::]*/: { /* n:\"BrtEndStyleSheet\", */ T:-1 },\n\t/*::[*/0x0118/*::]*/: { /* n:\"BrtBeginSXView\", */ T:1 },\n\t/*::[*/0x0119/*::]*/: { /* n:\"BrtEndSXVI\", */ T:-1 },\n\t/*::[*/0x011A/*::]*/: { /* n:\"BrtBeginSXVI\", */ T:1 },\n\t/*::[*/0x011B/*::]*/: { /* n:\"BrtBeginSXVIs\", */ T:1 },\n\t/*::[*/0x011C/*::]*/: { /* n:\"BrtEndSXVIs\", */ T:-1 },\n\t/*::[*/0x011D/*::]*/: { /* n:\"BrtBeginSXVD\", */ T:1 },\n\t/*::[*/0x011E/*::]*/: { /* n:\"BrtEndSXVD\", */ T:-1 },\n\t/*::[*/0x011F/*::]*/: { /* n:\"BrtBeginSXVDs\", */ T:1 },\n\t/*::[*/0x0120/*::]*/: { /* n:\"BrtEndSXVDs\", */ T:-1 },\n\t/*::[*/0x0121/*::]*/: { /* n:\"BrtBeginSXPI\", */ T:1 },\n\t/*::[*/0x0122/*::]*/: { /* n:\"BrtEndSXPI\", */ T:-1 },\n\t/*::[*/0x0123/*::]*/: { /* n:\"BrtBeginSXPIs\", */ T:1 },\n\t/*::[*/0x0124/*::]*/: { /* n:\"BrtEndSXPIs\", */ T:-1 },\n\t/*::[*/0x0125/*::]*/: { /* n:\"BrtBeginSXDI\", */ T:1 },\n\t/*::[*/0x0126/*::]*/: { /* n:\"BrtEndSXDI\", */ T:-1 },\n\t/*::[*/0x0127/*::]*/: { /* n:\"BrtBeginSXDIs\", */ T:1 },\n\t/*::[*/0x0128/*::]*/: { /* n:\"BrtEndSXDIs\", */ T:-1 },\n\t/*::[*/0x0129/*::]*/: { /* n:\"BrtBeginSXLI\", */ T:1 },\n\t/*::[*/0x012A/*::]*/: { /* n:\"BrtEndSXLI\", */ T:-1 },\n\t/*::[*/0x012B/*::]*/: { /* n:\"BrtBeginSXLIRws\", */ T:1 },\n\t/*::[*/0x012C/*::]*/: { /* n:\"BrtEndSXLIRws\", */ T:-1 },\n\t/*::[*/0x012D/*::]*/: { /* n:\"BrtBeginSXLICols\", */ T:1 },\n\t/*::[*/0x012E/*::]*/: { /* n:\"BrtEndSXLICols\", */ T:-1 },\n\t/*::[*/0x012F/*::]*/: { /* n:\"BrtBeginSXFormat\", */ T:1 },\n\t/*::[*/0x0130/*::]*/: { /* n:\"BrtEndSXFormat\", */ T:-1 },\n\t/*::[*/0x0131/*::]*/: { /* n:\"BrtBeginSXFormats\", */ T:1 },\n\t/*::[*/0x0132/*::]*/: { /* n:\"BrtEndSxFormats\", */ T:-1 },\n\t/*::[*/0x0133/*::]*/: { /* n:\"BrtBeginSxSelect\", */ T:1 },\n\t/*::[*/0x0134/*::]*/: { /* n:\"BrtEndSxSelect\", */ T:-1 },\n\t/*::[*/0x0135/*::]*/: { /* n:\"BrtBeginISXVDRws\", */ T:1 },\n\t/*::[*/0x0136/*::]*/: { /* n:\"BrtEndISXVDRws\", */ T:-1 },\n\t/*::[*/0x0137/*::]*/: { /* n:\"BrtBeginISXVDCols\", */ T:1 },\n\t/*::[*/0x0138/*::]*/: { /* n:\"BrtEndISXVDCols\", */ T:-1 },\n\t/*::[*/0x0139/*::]*/: { /* n:\"BrtEndSXLocation\", */ T:-1 },\n\t/*::[*/0x013A/*::]*/: { /* n:\"BrtBeginSXLocation\", */ T:1 },\n\t/*::[*/0x013B/*::]*/: { /* n:\"BrtEndSXView\", */ T:-1 },\n\t/*::[*/0x013C/*::]*/: { /* n:\"BrtBeginSXTHs\", */ T:1 },\n\t/*::[*/0x013D/*::]*/: { /* n:\"BrtEndSXTHs\", */ T:-1 },\n\t/*::[*/0x013E/*::]*/: { /* n:\"BrtBeginSXTH\", */ T:1 },\n\t/*::[*/0x013F/*::]*/: { /* n:\"BrtEndSXTH\", */ T:-1 },\n\t/*::[*/0x0140/*::]*/: { /* n:\"BrtBeginISXTHRws\", */ T:1 },\n\t/*::[*/0x0141/*::]*/: { /* n:\"BrtEndISXTHRws\", */ T:-1 },\n\t/*::[*/0x0142/*::]*/: { /* n:\"BrtBeginISXTHCols\", */ T:1 },\n\t/*::[*/0x0143/*::]*/: { /* n:\"BrtEndISXTHCols\", */ T:-1 },\n\t/*::[*/0x0144/*::]*/: { /* n:\"BrtBeginSXTDMPS\", */ T:1 },\n\t/*::[*/0x0145/*::]*/: { /* n:\"BrtEndSXTDMPs\", */ T:-1 },\n\t/*::[*/0x0146/*::]*/: { /* n:\"BrtBeginSXTDMP\", */ T:1 },\n\t/*::[*/0x0147/*::]*/: { /* n:\"BrtEndSXTDMP\", */ T:-1 },\n\t/*::[*/0x0148/*::]*/: { /* n:\"BrtBeginSXTHItems\", */ T:1 },\n\t/*::[*/0x0149/*::]*/: { /* n:\"BrtEndSXTHItems\", */ T:-1 },\n\t/*::[*/0x014A/*::]*/: { /* n:\"BrtBeginSXTHItem\", */ T:1 },\n\t/*::[*/0x014B/*::]*/: { /* n:\"BrtEndSXTHItem\", */ T:-1 },\n\t/*::[*/0x014C/*::]*/: { /* n:\"BrtBeginMetadata\", */ T:1 },\n\t/*::[*/0x014D/*::]*/: { /* n:\"BrtEndMetadata\", */ T:-1 },\n\t/*::[*/0x014E/*::]*/: { /* n:\"BrtBeginEsmdtinfo\", */ T:1 },\n\t/*::[*/0x014F/*::]*/: { /* n:\"BrtMdtinfo\", */ f:parse_BrtMdtinfo },\n\t/*::[*/0x0150/*::]*/: { /* n:\"BrtEndEsmdtinfo\", */ T:-1 },\n\t/*::[*/0x0151/*::]*/: { /* n:\"BrtBeginEsmdb\", */ f:parse_BrtBeginEsmdb, T:1 },\n\t/*::[*/0x0152/*::]*/: { /* n:\"BrtEndEsmdb\", */ T:-1 },\n\t/*::[*/0x0153/*::]*/: { /* n:\"BrtBeginEsfmd\", */ T:1 },\n\t/*::[*/0x0154/*::]*/: { /* n:\"BrtEndEsfmd\", */ T:-1 },\n\t/*::[*/0x0155/*::]*/: { /* n:\"BrtBeginSingleCells\", */ T:1 },\n\t/*::[*/0x0156/*::]*/: { /* n:\"BrtEndSingleCells\", */ T:-1 },\n\t/*::[*/0x0157/*::]*/: { /* n:\"BrtBeginList\", */ T:1 },\n\t/*::[*/0x0158/*::]*/: { /* n:\"BrtEndList\", */ T:-1 },\n\t/*::[*/0x0159/*::]*/: { /* n:\"BrtBeginListCols\", */ T:1 },\n\t/*::[*/0x015A/*::]*/: { /* n:\"BrtEndListCols\", */ T:-1 },\n\t/*::[*/0x015B/*::]*/: { /* n:\"BrtBeginListCol\", */ T:1 },\n\t/*::[*/0x015C/*::]*/: { /* n:\"BrtEndListCol\", */ T:-1 },\n\t/*::[*/0x015D/*::]*/: { /* n:\"BrtBeginListXmlCPr\", */ T:1 },\n\t/*::[*/0x015E/*::]*/: { /* n:\"BrtEndListXmlCPr\", */ T:-1 },\n\t/*::[*/0x015F/*::]*/: { /* n:\"BrtListCCFmla\" */ },\n\t/*::[*/0x0160/*::]*/: { /* n:\"BrtListTrFmla\" */ },\n\t/*::[*/0x0161/*::]*/: { /* n:\"BrtBeginExternals\", */ T:1 },\n\t/*::[*/0x0162/*::]*/: { /* n:\"BrtEndExternals\", */ T:-1 },\n\t/*::[*/0x0163/*::]*/: { /* n:\"BrtSupBookSrc\", */ f:parse_RelID},\n\t/*::[*/0x0165/*::]*/: { /* n:\"BrtSupSelf\" */ },\n\t/*::[*/0x0166/*::]*/: { /* n:\"BrtSupSame\" */ },\n\t/*::[*/0x0167/*::]*/: { /* n:\"BrtSupTabs\" */ },\n\t/*::[*/0x0168/*::]*/: { /* n:\"BrtBeginSupBook\", */ T:1 },\n\t/*::[*/0x0169/*::]*/: { /* n:\"BrtPlaceholderName\" */ },\n\t/*::[*/0x016A/*::]*/: { /* n:\"BrtExternSheet\", */ f:parse_ExternSheet },\n\t/*::[*/0x016B/*::]*/: { /* n:\"BrtExternTableStart\" */ },\n\t/*::[*/0x016C/*::]*/: { /* n:\"BrtExternTableEnd\" */ },\n\t/*::[*/0x016E/*::]*/: { /* n:\"BrtExternRowHdr\" */ },\n\t/*::[*/0x016F/*::]*/: { /* n:\"BrtExternCellBlank\" */ },\n\t/*::[*/0x0170/*::]*/: { /* n:\"BrtExternCellReal\" */ },\n\t/*::[*/0x0171/*::]*/: { /* n:\"BrtExternCellBool\" */ },\n\t/*::[*/0x0172/*::]*/: { /* n:\"BrtExternCellError\" */ },\n\t/*::[*/0x0173/*::]*/: { /* n:\"BrtExternCellString\" */ },\n\t/*::[*/0x0174/*::]*/: { /* n:\"BrtBeginEsmdx\", */ T:1 },\n\t/*::[*/0x0175/*::]*/: { /* n:\"BrtEndEsmdx\", */ T:-1 },\n\t/*::[*/0x0176/*::]*/: { /* n:\"BrtBeginMdxSet\", */ T:1 },\n\t/*::[*/0x0177/*::]*/: { /* n:\"BrtEndMdxSet\", */ T:-1 },\n\t/*::[*/0x0178/*::]*/: { /* n:\"BrtBeginMdxMbrProp\", */ T:1 },\n\t/*::[*/0x0179/*::]*/: { /* n:\"BrtEndMdxMbrProp\", */ T:-1 },\n\t/*::[*/0x017A/*::]*/: { /* n:\"BrtBeginMdxKPI\", */ T:1 },\n\t/*::[*/0x017B/*::]*/: { /* n:\"BrtEndMdxKPI\", */ T:-1 },\n\t/*::[*/0x017C/*::]*/: { /* n:\"BrtBeginEsstr\", */ T:1 },\n\t/*::[*/0x017D/*::]*/: { /* n:\"BrtEndEsstr\", */ T:-1 },\n\t/*::[*/0x017E/*::]*/: { /* n:\"BrtBeginPRFItem\", */ T:1 },\n\t/*::[*/0x017F/*::]*/: { /* n:\"BrtEndPRFItem\", */ T:-1 },\n\t/*::[*/0x0180/*::]*/: { /* n:\"BrtBeginPivotCacheIDs\", */ T:1 },\n\t/*::[*/0x0181/*::]*/: { /* n:\"BrtEndPivotCacheIDs\", */ T:-1 },\n\t/*::[*/0x0182/*::]*/: { /* n:\"BrtBeginPivotCacheID\", */ T:1 },\n\t/*::[*/0x0183/*::]*/: { /* n:\"BrtEndPivotCacheID\", */ T:-1 },\n\t/*::[*/0x0184/*::]*/: { /* n:\"BrtBeginISXVIs\", */ T:1 },\n\t/*::[*/0x0185/*::]*/: { /* n:\"BrtEndISXVIs\", */ T:-1 },\n\t/*::[*/0x0186/*::]*/: { /* n:\"BrtBeginColInfos\", */ T:1 },\n\t/*::[*/0x0187/*::]*/: { /* n:\"BrtEndColInfos\", */ T:-1 },\n\t/*::[*/0x0188/*::]*/: { /* n:\"BrtBeginRwBrk\", */ T:1 },\n\t/*::[*/0x0189/*::]*/: { /* n:\"BrtEndRwBrk\", */ T:-1 },\n\t/*::[*/0x018A/*::]*/: { /* n:\"BrtBeginColBrk\", */ T:1 },\n\t/*::[*/0x018B/*::]*/: { /* n:\"BrtEndColBrk\", */ T:-1 },\n\t/*::[*/0x018C/*::]*/: { /* n:\"BrtBrk\" */ },\n\t/*::[*/0x018D/*::]*/: { /* n:\"BrtUserBookView\" */ },\n\t/*::[*/0x018E/*::]*/: { /* n:\"BrtInfo\" */ },\n\t/*::[*/0x018F/*::]*/: { /* n:\"BrtCUsr\" */ },\n\t/*::[*/0x0190/*::]*/: { /* n:\"BrtUsr\" */ },\n\t/*::[*/0x0191/*::]*/: { /* n:\"BrtBeginUsers\", */ T:1 },\n\t/*::[*/0x0193/*::]*/: { /* n:\"BrtEOF\" */ },\n\t/*::[*/0x0194/*::]*/: { /* n:\"BrtUCR\" */ },\n\t/*::[*/0x0195/*::]*/: { /* n:\"BrtRRInsDel\" */ },\n\t/*::[*/0x0196/*::]*/: { /* n:\"BrtRREndInsDel\" */ },\n\t/*::[*/0x0197/*::]*/: { /* n:\"BrtRRMove\" */ },\n\t/*::[*/0x0198/*::]*/: { /* n:\"BrtRREndMove\" */ },\n\t/*::[*/0x0199/*::]*/: { /* n:\"BrtRRChgCell\" */ },\n\t/*::[*/0x019A/*::]*/: { /* n:\"BrtRREndChgCell\" */ },\n\t/*::[*/0x019B/*::]*/: { /* n:\"BrtRRHeader\" */ },\n\t/*::[*/0x019C/*::]*/: { /* n:\"BrtRRUserView\" */ },\n\t/*::[*/0x019D/*::]*/: { /* n:\"BrtRRRenSheet\" */ },\n\t/*::[*/0x019E/*::]*/: { /* n:\"BrtRRInsertSh\" */ },\n\t/*::[*/0x019F/*::]*/: { /* n:\"BrtRRDefName\" */ },\n\t/*::[*/0x01A0/*::]*/: { /* n:\"BrtRRNote\" */ },\n\t/*::[*/0x01A1/*::]*/: { /* n:\"BrtRRConflict\" */ },\n\t/*::[*/0x01A2/*::]*/: { /* n:\"BrtRRTQSIF\" */ },\n\t/*::[*/0x01A3/*::]*/: { /* n:\"BrtRRFormat\" */ },\n\t/*::[*/0x01A4/*::]*/: { /* n:\"BrtRREndFormat\" */ },\n\t/*::[*/0x01A5/*::]*/: { /* n:\"BrtRRAutoFmt\" */ },\n\t/*::[*/0x01A6/*::]*/: { /* n:\"BrtBeginUserShViews\", */ T:1 },\n\t/*::[*/0x01A7/*::]*/: { /* n:\"BrtBeginUserShView\", */ T:1 },\n\t/*::[*/0x01A8/*::]*/: { /* n:\"BrtEndUserShView\", */ T:-1 },\n\t/*::[*/0x01A9/*::]*/: { /* n:\"BrtEndUserShViews\", */ T:-1 },\n\t/*::[*/0x01AA/*::]*/: { /* n:\"BrtArrFmla\", */ f:parse_BrtArrFmla },\n\t/*::[*/0x01AB/*::]*/: { /* n:\"BrtShrFmla\", */ f:parse_BrtShrFmla },\n\t/*::[*/0x01AC/*::]*/: { /* n:\"BrtTable\" */ },\n\t/*::[*/0x01AD/*::]*/: { /* n:\"BrtBeginExtConnections\", */ T:1 },\n\t/*::[*/0x01AE/*::]*/: { /* n:\"BrtEndExtConnections\", */ T:-1 },\n\t/*::[*/0x01AF/*::]*/: { /* n:\"BrtBeginPCDCalcMems\", */ T:1 },\n\t/*::[*/0x01B0/*::]*/: { /* n:\"BrtEndPCDCalcMems\", */ T:-1 },\n\t/*::[*/0x01B1/*::]*/: { /* n:\"BrtBeginPCDCalcMem\", */ T:1 },\n\t/*::[*/0x01B2/*::]*/: { /* n:\"BrtEndPCDCalcMem\", */ T:-1 },\n\t/*::[*/0x01B3/*::]*/: { /* n:\"BrtBeginPCDHGLevels\", */ T:1 },\n\t/*::[*/0x01B4/*::]*/: { /* n:\"BrtEndPCDHGLevels\", */ T:-1 },\n\t/*::[*/0x01B5/*::]*/: { /* n:\"BrtBeginPCDHGLevel\", */ T:1 },\n\t/*::[*/0x01B6/*::]*/: { /* n:\"BrtEndPCDHGLevel\", */ T:-1 },\n\t/*::[*/0x01B7/*::]*/: { /* n:\"BrtBeginPCDHGLGroups\", */ T:1 },\n\t/*::[*/0x01B8/*::]*/: { /* n:\"BrtEndPCDHGLGroups\", */ T:-1 },\n\t/*::[*/0x01B9/*::]*/: { /* n:\"BrtBeginPCDHGLGroup\", */ T:1 },\n\t/*::[*/0x01BA/*::]*/: { /* n:\"BrtEndPCDHGLGroup\", */ T:-1 },\n\t/*::[*/0x01BB/*::]*/: { /* n:\"BrtBeginPCDHGLGMembers\", */ T:1 },\n\t/*::[*/0x01BC/*::]*/: { /* n:\"BrtEndPCDHGLGMembers\", */ T:-1 },\n\t/*::[*/0x01BD/*::]*/: { /* n:\"BrtBeginPCDHGLGMember\", */ T:1 },\n\t/*::[*/0x01BE/*::]*/: { /* n:\"BrtEndPCDHGLGMember\", */ T:-1 },\n\t/*::[*/0x01BF/*::]*/: { /* n:\"BrtBeginQSI\", */ T:1 },\n\t/*::[*/0x01C0/*::]*/: { /* n:\"BrtEndQSI\", */ T:-1 },\n\t/*::[*/0x01C1/*::]*/: { /* n:\"BrtBeginQSIR\", */ T:1 },\n\t/*::[*/0x01C2/*::]*/: { /* n:\"BrtEndQSIR\", */ T:-1 },\n\t/*::[*/0x01C3/*::]*/: { /* n:\"BrtBeginDeletedNames\", */ T:1 },\n\t/*::[*/0x01C4/*::]*/: { /* n:\"BrtEndDeletedNames\", */ T:-1 },\n\t/*::[*/0x01C5/*::]*/: { /* n:\"BrtBeginDeletedName\", */ T:1 },\n\t/*::[*/0x01C6/*::]*/: { /* n:\"BrtEndDeletedName\", */ T:-1 },\n\t/*::[*/0x01C7/*::]*/: { /* n:\"BrtBeginQSIFs\", */ T:1 },\n\t/*::[*/0x01C8/*::]*/: { /* n:\"BrtEndQSIFs\", */ T:-1 },\n\t/*::[*/0x01C9/*::]*/: { /* n:\"BrtBeginQSIF\", */ T:1 },\n\t/*::[*/0x01CA/*::]*/: { /* n:\"BrtEndQSIF\", */ T:-1 },\n\t/*::[*/0x01CB/*::]*/: { /* n:\"BrtBeginAutoSortScope\", */ T:1 },\n\t/*::[*/0x01CC/*::]*/: { /* n:\"BrtEndAutoSortScope\", */ T:-1 },\n\t/*::[*/0x01CD/*::]*/: { /* n:\"BrtBeginConditionalFormatting\", */ T:1 },\n\t/*::[*/0x01CE/*::]*/: { /* n:\"BrtEndConditionalFormatting\", */ T:-1 },\n\t/*::[*/0x01CF/*::]*/: { /* n:\"BrtBeginCFRule\", */ T:1 },\n\t/*::[*/0x01D0/*::]*/: { /* n:\"BrtEndCFRule\", */ T:-1 },\n\t/*::[*/0x01D1/*::]*/: { /* n:\"BrtBeginIconSet\", */ T:1 },\n\t/*::[*/0x01D2/*::]*/: { /* n:\"BrtEndIconSet\", */ T:-1 },\n\t/*::[*/0x01D3/*::]*/: { /* n:\"BrtBeginDatabar\", */ T:1 },\n\t/*::[*/0x01D4/*::]*/: { /* n:\"BrtEndDatabar\", */ T:-1 },\n\t/*::[*/0x01D5/*::]*/: { /* n:\"BrtBeginColorScale\", */ T:1 },\n\t/*::[*/0x01D6/*::]*/: { /* n:\"BrtEndColorScale\", */ T:-1 },\n\t/*::[*/0x01D7/*::]*/: { /* n:\"BrtCFVO\" */ },\n\t/*::[*/0x01D8/*::]*/: { /* n:\"BrtExternValueMeta\" */ },\n\t/*::[*/0x01D9/*::]*/: { /* n:\"BrtBeginColorPalette\", */ T:1 },\n\t/*::[*/0x01DA/*::]*/: { /* n:\"BrtEndColorPalette\", */ T:-1 },\n\t/*::[*/0x01DB/*::]*/: { /* n:\"BrtIndexedColor\" */ },\n\t/*::[*/0x01DC/*::]*/: { /* n:\"BrtMargins\", */ f:parse_BrtMargins },\n\t/*::[*/0x01DD/*::]*/: { /* n:\"BrtPrintOptions\" */ },\n\t/*::[*/0x01DE/*::]*/: { /* n:\"BrtPageSetup\" */ },\n\t/*::[*/0x01DF/*::]*/: { /* n:\"BrtBeginHeaderFooter\", */ T:1 },\n\t/*::[*/0x01E0/*::]*/: { /* n:\"BrtEndHeaderFooter\", */ T:-1 },\n\t/*::[*/0x01E1/*::]*/: { /* n:\"BrtBeginSXCrtFormat\", */ T:1 },\n\t/*::[*/0x01E2/*::]*/: { /* n:\"BrtEndSXCrtFormat\", */ T:-1 },\n\t/*::[*/0x01E3/*::]*/: { /* n:\"BrtBeginSXCrtFormats\", */ T:1 },\n\t/*::[*/0x01E4/*::]*/: { /* n:\"BrtEndSXCrtFormats\", */ T:-1 },\n\t/*::[*/0x01E5/*::]*/: { /* n:\"BrtWsFmtInfo\", */ f:parse_BrtWsFmtInfo },\n\t/*::[*/0x01E6/*::]*/: { /* n:\"BrtBeginMgs\", */ T:1 },\n\t/*::[*/0x01E7/*::]*/: { /* n:\"BrtEndMGs\", */ T:-1 },\n\t/*::[*/0x01E8/*::]*/: { /* n:\"BrtBeginMGMaps\", */ T:1 },\n\t/*::[*/0x01E9/*::]*/: { /* n:\"BrtEndMGMaps\", */ T:-1 },\n\t/*::[*/0x01EA/*::]*/: { /* n:\"BrtBeginMG\", */ T:1 },\n\t/*::[*/0x01EB/*::]*/: { /* n:\"BrtEndMG\", */ T:-1 },\n\t/*::[*/0x01EC/*::]*/: { /* n:\"BrtBeginMap\", */ T:1 },\n\t/*::[*/0x01ED/*::]*/: { /* n:\"BrtEndMap\", */ T:-1 },\n\t/*::[*/0x01EE/*::]*/: { /* n:\"BrtHLink\", */ f:parse_BrtHLink },\n\t/*::[*/0x01EF/*::]*/: { /* n:\"BrtBeginDCon\", */ T:1 },\n\t/*::[*/0x01F0/*::]*/: { /* n:\"BrtEndDCon\", */ T:-1 },\n\t/*::[*/0x01F1/*::]*/: { /* n:\"BrtBeginDRefs\", */ T:1 },\n\t/*::[*/0x01F2/*::]*/: { /* n:\"BrtEndDRefs\", */ T:-1 },\n\t/*::[*/0x01F3/*::]*/: { /* n:\"BrtDRef\" */ },\n\t/*::[*/0x01F4/*::]*/: { /* n:\"BrtBeginScenMan\", */ T:1 },\n\t/*::[*/0x01F5/*::]*/: { /* n:\"BrtEndScenMan\", */ T:-1 },\n\t/*::[*/0x01F6/*::]*/: { /* n:\"BrtBeginSct\", */ T:1 },\n\t/*::[*/0x01F7/*::]*/: { /* n:\"BrtEndSct\", */ T:-1 },\n\t/*::[*/0x01F8/*::]*/: { /* n:\"BrtSlc\" */ },\n\t/*::[*/0x01F9/*::]*/: { /* n:\"BrtBeginDXFs\", */ T:1 },\n\t/*::[*/0x01FA/*::]*/: { /* n:\"BrtEndDXFs\", */ T:-1 },\n\t/*::[*/0x01FB/*::]*/: { /* n:\"BrtDXF\" */ },\n\t/*::[*/0x01FC/*::]*/: { /* n:\"BrtBeginTableStyles\", */ T:1 },\n\t/*::[*/0x01FD/*::]*/: { /* n:\"BrtEndTableStyles\", */ T:-1 },\n\t/*::[*/0x01FE/*::]*/: { /* n:\"BrtBeginTableStyle\", */ T:1 },\n\t/*::[*/0x01FF/*::]*/: { /* n:\"BrtEndTableStyle\", */ T:-1 },\n\t/*::[*/0x0200/*::]*/: { /* n:\"BrtTableStyleElement\" */ },\n\t/*::[*/0x0201/*::]*/: { /* n:\"BrtTableStyleClient\" */ },\n\t/*::[*/0x0202/*::]*/: { /* n:\"BrtBeginVolDeps\", */ T:1 },\n\t/*::[*/0x0203/*::]*/: { /* n:\"BrtEndVolDeps\", */ T:-1 },\n\t/*::[*/0x0204/*::]*/: { /* n:\"BrtBeginVolType\", */ T:1 },\n\t/*::[*/0x0205/*::]*/: { /* n:\"BrtEndVolType\", */ T:-1 },\n\t/*::[*/0x0206/*::]*/: { /* n:\"BrtBeginVolMain\", */ T:1 },\n\t/*::[*/0x0207/*::]*/: { /* n:\"BrtEndVolMain\", */ T:-1 },\n\t/*::[*/0x0208/*::]*/: { /* n:\"BrtBeginVolTopic\", */ T:1 },\n\t/*::[*/0x0209/*::]*/: { /* n:\"BrtEndVolTopic\", */ T:-1 },\n\t/*::[*/0x020A/*::]*/: { /* n:\"BrtVolSubtopic\" */ },\n\t/*::[*/0x020B/*::]*/: { /* n:\"BrtVolRef\" */ },\n\t/*::[*/0x020C/*::]*/: { /* n:\"BrtVolNum\" */ },\n\t/*::[*/0x020D/*::]*/: { /* n:\"BrtVolErr\" */ },\n\t/*::[*/0x020E/*::]*/: { /* n:\"BrtVolStr\" */ },\n\t/*::[*/0x020F/*::]*/: { /* n:\"BrtVolBool\" */ },\n\t/*::[*/0x0210/*::]*/: { /* n:\"BrtBeginCalcChain$\", */ T:1 },\n\t/*::[*/0x0211/*::]*/: { /* n:\"BrtEndCalcChain$\", */ T:-1 },\n\t/*::[*/0x0212/*::]*/: { /* n:\"BrtBeginSortState\", */ T:1 },\n\t/*::[*/0x0213/*::]*/: { /* n:\"BrtEndSortState\", */ T:-1 },\n\t/*::[*/0x0214/*::]*/: { /* n:\"BrtBeginSortCond\", */ T:1 },\n\t/*::[*/0x0215/*::]*/: { /* n:\"BrtEndSortCond\", */ T:-1 },\n\t/*::[*/0x0216/*::]*/: { /* n:\"BrtBookProtection\" */ },\n\t/*::[*/0x0217/*::]*/: { /* n:\"BrtSheetProtection\" */ },\n\t/*::[*/0x0218/*::]*/: { /* n:\"BrtRangeProtection\" */ },\n\t/*::[*/0x0219/*::]*/: { /* n:\"BrtPhoneticInfo\" */ },\n\t/*::[*/0x021A/*::]*/: { /* n:\"BrtBeginECTxtWiz\", */ T:1 },\n\t/*::[*/0x021B/*::]*/: { /* n:\"BrtEndECTxtWiz\", */ T:-1 },\n\t/*::[*/0x021C/*::]*/: { /* n:\"BrtBeginECTWFldInfoLst\", */ T:1 },\n\t/*::[*/0x021D/*::]*/: { /* n:\"BrtEndECTWFldInfoLst\", */ T:-1 },\n\t/*::[*/0x021E/*::]*/: { /* n:\"BrtBeginECTwFldInfo\", */ T:1 },\n\t/*::[*/0x0224/*::]*/: { /* n:\"BrtFileSharing\" */ },\n\t/*::[*/0x0225/*::]*/: { /* n:\"BrtOleSize\" */ },\n\t/*::[*/0x0226/*::]*/: { /* n:\"BrtDrawing\", */ f:parse_RelID },\n\t/*::[*/0x0227/*::]*/: { /* n:\"BrtLegacyDrawing\" */ },\n\t/*::[*/0x0228/*::]*/: { /* n:\"BrtLegacyDrawingHF\" */ },\n\t/*::[*/0x0229/*::]*/: { /* n:\"BrtWebOpt\" */ },\n\t/*::[*/0x022A/*::]*/: { /* n:\"BrtBeginWebPubItems\", */ T:1 },\n\t/*::[*/0x022B/*::]*/: { /* n:\"BrtEndWebPubItems\", */ T:-1 },\n\t/*::[*/0x022C/*::]*/: { /* n:\"BrtBeginWebPubItem\", */ T:1 },\n\t/*::[*/0x022D/*::]*/: { /* n:\"BrtEndWebPubItem\", */ T:-1 },\n\t/*::[*/0x022E/*::]*/: { /* n:\"BrtBeginSXCondFmt\", */ T:1 },\n\t/*::[*/0x022F/*::]*/: { /* n:\"BrtEndSXCondFmt\", */ T:-1 },\n\t/*::[*/0x0230/*::]*/: { /* n:\"BrtBeginSXCondFmts\", */ T:1 },\n\t/*::[*/0x0231/*::]*/: { /* n:\"BrtEndSXCondFmts\", */ T:-1 },\n\t/*::[*/0x0232/*::]*/: { /* n:\"BrtBkHim\" */ },\n\t/*::[*/0x0234/*::]*/: { /* n:\"BrtColor\" */ },\n\t/*::[*/0x0235/*::]*/: { /* n:\"BrtBeginIndexedColors\", */ T:1 },\n\t/*::[*/0x0236/*::]*/: { /* n:\"BrtEndIndexedColors\", */ T:-1 },\n\t/*::[*/0x0239/*::]*/: { /* n:\"BrtBeginMRUColors\", */ T:1 },\n\t/*::[*/0x023A/*::]*/: { /* n:\"BrtEndMRUColors\", */ T:-1 },\n\t/*::[*/0x023C/*::]*/: { /* n:\"BrtMRUColor\" */ },\n\t/*::[*/0x023D/*::]*/: { /* n:\"BrtBeginDVals\", */ T:1 },\n\t/*::[*/0x023E/*::]*/: { /* n:\"BrtEndDVals\", */ T:-1 },\n\t/*::[*/0x0241/*::]*/: { /* n:\"BrtSupNameStart\" */ },\n\t/*::[*/0x0242/*::]*/: { /* n:\"BrtSupNameValueStart\" */ },\n\t/*::[*/0x0243/*::]*/: { /* n:\"BrtSupNameValueEnd\" */ },\n\t/*::[*/0x0244/*::]*/: { /* n:\"BrtSupNameNum\" */ },\n\t/*::[*/0x0245/*::]*/: { /* n:\"BrtSupNameErr\" */ },\n\t/*::[*/0x0246/*::]*/: { /* n:\"BrtSupNameSt\" */ },\n\t/*::[*/0x0247/*::]*/: { /* n:\"BrtSupNameNil\" */ },\n\t/*::[*/0x0248/*::]*/: { /* n:\"BrtSupNameBool\" */ },\n\t/*::[*/0x0249/*::]*/: { /* n:\"BrtSupNameFmla\" */ },\n\t/*::[*/0x024A/*::]*/: { /* n:\"BrtSupNameBits\" */ },\n\t/*::[*/0x024B/*::]*/: { /* n:\"BrtSupNameEnd\" */ },\n\t/*::[*/0x024C/*::]*/: { /* n:\"BrtEndSupBook\", */ T:-1 },\n\t/*::[*/0x024D/*::]*/: { /* n:\"BrtCellSmartTagProperty\" */ },\n\t/*::[*/0x024E/*::]*/: { /* n:\"BrtBeginCellSmartTag\", */ T:1 },\n\t/*::[*/0x024F/*::]*/: { /* n:\"BrtEndCellSmartTag\", */ T:-1 },\n\t/*::[*/0x0250/*::]*/: { /* n:\"BrtBeginCellSmartTags\", */ T:1 },\n\t/*::[*/0x0251/*::]*/: { /* n:\"BrtEndCellSmartTags\", */ T:-1 },\n\t/*::[*/0x0252/*::]*/: { /* n:\"BrtBeginSmartTags\", */ T:1 },\n\t/*::[*/0x0253/*::]*/: { /* n:\"BrtEndSmartTags\", */ T:-1 },\n\t/*::[*/0x0254/*::]*/: { /* n:\"BrtSmartTagType\" */ },\n\t/*::[*/0x0255/*::]*/: { /* n:\"BrtBeginSmartTagTypes\", */ T:1 },\n\t/*::[*/0x0256/*::]*/: { /* n:\"BrtEndSmartTagTypes\", */ T:-1 },\n\t/*::[*/0x0257/*::]*/: { /* n:\"BrtBeginSXFilters\", */ T:1 },\n\t/*::[*/0x0258/*::]*/: { /* n:\"BrtEndSXFilters\", */ T:-1 },\n\t/*::[*/0x0259/*::]*/: { /* n:\"BrtBeginSXFILTER\", */ T:1 },\n\t/*::[*/0x025A/*::]*/: { /* n:\"BrtEndSXFilter\", */ T:-1 },\n\t/*::[*/0x025B/*::]*/: { /* n:\"BrtBeginFills\", */ T:1 },\n\t/*::[*/0x025C/*::]*/: { /* n:\"BrtEndFills\", */ T:-1 },\n\t/*::[*/0x025D/*::]*/: { /* n:\"BrtBeginCellWatches\", */ T:1 },\n\t/*::[*/0x025E/*::]*/: { /* n:\"BrtEndCellWatches\", */ T:-1 },\n\t/*::[*/0x025F/*::]*/: { /* n:\"BrtCellWatch\" */ },\n\t/*::[*/0x0260/*::]*/: { /* n:\"BrtBeginCRErrs\", */ T:1 },\n\t/*::[*/0x0261/*::]*/: { /* n:\"BrtEndCRErrs\", */ T:-1 },\n\t/*::[*/0x0262/*::]*/: { /* n:\"BrtCrashRecErr\" */ },\n\t/*::[*/0x0263/*::]*/: { /* n:\"BrtBeginFonts\", */ T:1 },\n\t/*::[*/0x0264/*::]*/: { /* n:\"BrtEndFonts\", */ T:-1 },\n\t/*::[*/0x0265/*::]*/: { /* n:\"BrtBeginBorders\", */ T:1 },\n\t/*::[*/0x0266/*::]*/: { /* n:\"BrtEndBorders\", */ T:-1 },\n\t/*::[*/0x0267/*::]*/: { /* n:\"BrtBeginFmts\", */ T:1 },\n\t/*::[*/0x0268/*::]*/: { /* n:\"BrtEndFmts\", */ T:-1 },\n\t/*::[*/0x0269/*::]*/: { /* n:\"BrtBeginCellXFs\", */ T:1 },\n\t/*::[*/0x026A/*::]*/: { /* n:\"BrtEndCellXFs\", */ T:-1 },\n\t/*::[*/0x026B/*::]*/: { /* n:\"BrtBeginStyles\", */ T:1 },\n\t/*::[*/0x026C/*::]*/: { /* n:\"BrtEndStyles\", */ T:-1 },\n\t/*::[*/0x0271/*::]*/: { /* n:\"BrtBigName\" */ },\n\t/*::[*/0x0272/*::]*/: { /* n:\"BrtBeginCellStyleXFs\", */ T:1 },\n\t/*::[*/0x0273/*::]*/: { /* n:\"BrtEndCellStyleXFs\", */ T:-1 },\n\t/*::[*/0x0274/*::]*/: { /* n:\"BrtBeginComments\", */ T:1 },\n\t/*::[*/0x0275/*::]*/: { /* n:\"BrtEndComments\", */ T:-1 },\n\t/*::[*/0x0276/*::]*/: { /* n:\"BrtBeginCommentAuthors\", */ T:1 },\n\t/*::[*/0x0277/*::]*/: { /* n:\"BrtEndCommentAuthors\", */ T:-1 },\n\t/*::[*/0x0278/*::]*/: { /* n:\"BrtCommentAuthor\", */ f:parse_BrtCommentAuthor },\n\t/*::[*/0x0279/*::]*/: { /* n:\"BrtBeginCommentList\", */ T:1 },\n\t/*::[*/0x027A/*::]*/: { /* n:\"BrtEndCommentList\", */ T:-1 },\n\t/*::[*/0x027B/*::]*/: { /* n:\"BrtBeginComment\", */ T:1, f:parse_BrtBeginComment},\n\t/*::[*/0x027C/*::]*/: { /* n:\"BrtEndComment\", */ T:-1 },\n\t/*::[*/0x027D/*::]*/: { /* n:\"BrtCommentText\", */ f:parse_BrtCommentText },\n\t/*::[*/0x027E/*::]*/: { /* n:\"BrtBeginOleObjects\", */ T:1 },\n\t/*::[*/0x027F/*::]*/: { /* n:\"BrtOleObject\" */ },\n\t/*::[*/0x0280/*::]*/: { /* n:\"BrtEndOleObjects\", */ T:-1 },\n\t/*::[*/0x0281/*::]*/: { /* n:\"BrtBeginSxrules\", */ T:1 },\n\t/*::[*/0x0282/*::]*/: { /* n:\"BrtEndSxRules\", */ T:-1 },\n\t/*::[*/0x0283/*::]*/: { /* n:\"BrtBeginActiveXControls\", */ T:1 },\n\t/*::[*/0x0284/*::]*/: { /* n:\"BrtActiveX\" */ },\n\t/*::[*/0x0285/*::]*/: { /* n:\"BrtEndActiveXControls\", */ T:-1 },\n\t/*::[*/0x0286/*::]*/: { /* n:\"BrtBeginPCDSDTCEMembersSortBy\", */ T:1 },\n\t/*::[*/0x0288/*::]*/: { /* n:\"BrtBeginCellIgnoreECs\", */ T:1 },\n\t/*::[*/0x0289/*::]*/: { /* n:\"BrtCellIgnoreEC\" */ },\n\t/*::[*/0x028A/*::]*/: { /* n:\"BrtEndCellIgnoreECs\", */ T:-1 },\n\t/*::[*/0x028B/*::]*/: { /* n:\"BrtCsProp\", */ f:parse_BrtCsProp },\n\t/*::[*/0x028C/*::]*/: { /* n:\"BrtCsPageSetup\" */ },\n\t/*::[*/0x028D/*::]*/: { /* n:\"BrtBeginUserCsViews\", */ T:1 },\n\t/*::[*/0x028E/*::]*/: { /* n:\"BrtEndUserCsViews\", */ T:-1 },\n\t/*::[*/0x028F/*::]*/: { /* n:\"BrtBeginUserCsView\", */ T:1 },\n\t/*::[*/0x0290/*::]*/: { /* n:\"BrtEndUserCsView\", */ T:-1 },\n\t/*::[*/0x0291/*::]*/: { /* n:\"BrtBeginPcdSFCIEntries\", */ T:1 },\n\t/*::[*/0x0292/*::]*/: { /* n:\"BrtEndPCDSFCIEntries\", */ T:-1 },\n\t/*::[*/0x0293/*::]*/: { /* n:\"BrtPCDSFCIEntry\" */ },\n\t/*::[*/0x0294/*::]*/: { /* n:\"BrtBeginListParts\", */ T:1 },\n\t/*::[*/0x0295/*::]*/: { /* n:\"BrtListPart\" */ },\n\t/*::[*/0x0296/*::]*/: { /* n:\"BrtEndListParts\", */ T:-1 },\n\t/*::[*/0x0297/*::]*/: { /* n:\"BrtSheetCalcProp\" */ },\n\t/*::[*/0x0298/*::]*/: { /* n:\"BrtBeginFnGroup\", */ T:1 },\n\t/*::[*/0x0299/*::]*/: { /* n:\"BrtFnGroup\" */ },\n\t/*::[*/0x029A/*::]*/: { /* n:\"BrtEndFnGroup\", */ T:-1 },\n\t/*::[*/0x029B/*::]*/: { /* n:\"BrtSupAddin\" */ },\n\t/*::[*/0x029C/*::]*/: { /* n:\"BrtSXTDMPOrder\" */ },\n\t/*::[*/0x029D/*::]*/: { /* n:\"BrtCsProtection\" */ },\n\t/*::[*/0x029F/*::]*/: { /* n:\"BrtBeginWsSortMap\", */ T:1 },\n\t/*::[*/0x02A0/*::]*/: { /* n:\"BrtEndWsSortMap\", */ T:-1 },\n\t/*::[*/0x02A1/*::]*/: { /* n:\"BrtBeginRRSort\", */ T:1 },\n\t/*::[*/0x02A2/*::]*/: { /* n:\"BrtEndRRSort\", */ T:-1 },\n\t/*::[*/0x02A3/*::]*/: { /* n:\"BrtRRSortItem\" */ },\n\t/*::[*/0x02A4/*::]*/: { /* n:\"BrtFileSharingIso\" */ },\n\t/*::[*/0x02A5/*::]*/: { /* n:\"BrtBookProtectionIso\" */ },\n\t/*::[*/0x02A6/*::]*/: { /* n:\"BrtSheetProtectionIso\" */ },\n\t/*::[*/0x02A7/*::]*/: { /* n:\"BrtCsProtectionIso\" */ },\n\t/*::[*/0x02A8/*::]*/: { /* n:\"BrtRangeProtectionIso\" */ },\n\t/*::[*/0x02A9/*::]*/: { /* n:\"BrtDValList\" */ },\n\t/*::[*/0x0400/*::]*/: { /* n:\"BrtRwDescent\" */ },\n\t/*::[*/0x0401/*::]*/: { /* n:\"BrtKnownFonts\" */ },\n\t/*::[*/0x0402/*::]*/: { /* n:\"BrtBeginSXTupleSet\", */ T:1 },\n\t/*::[*/0x0403/*::]*/: { /* n:\"BrtEndSXTupleSet\", */ T:-1 },\n\t/*::[*/0x0404/*::]*/: { /* n:\"BrtBeginSXTupleSetHeader\", */ T:1 },\n\t/*::[*/0x0405/*::]*/: { /* n:\"BrtEndSXTupleSetHeader\", */ T:-1 },\n\t/*::[*/0x0406/*::]*/: { /* n:\"BrtSXTupleSetHeaderItem\" */ },\n\t/*::[*/0x0407/*::]*/: { /* n:\"BrtBeginSXTupleSetData\", */ T:1 },\n\t/*::[*/0x0408/*::]*/: { /* n:\"BrtEndSXTupleSetData\", */ T:-1 },\n\t/*::[*/0x0409/*::]*/: { /* n:\"BrtBeginSXTupleSetRow\", */ T:1 },\n\t/*::[*/0x040A/*::]*/: { /* n:\"BrtEndSXTupleSetRow\", */ T:-1 },\n\t/*::[*/0x040B/*::]*/: { /* n:\"BrtSXTupleSetRowItem\" */ },\n\t/*::[*/0x040C/*::]*/: { /* n:\"BrtNameExt\" */ },\n\t/*::[*/0x040D/*::]*/: { /* n:\"BrtPCDH14\" */ },\n\t/*::[*/0x040E/*::]*/: { /* n:\"BrtBeginPCDCalcMem14\", */ T:1 },\n\t/*::[*/0x040F/*::]*/: { /* n:\"BrtEndPCDCalcMem14\", */ T:-1 },\n\t/*::[*/0x0410/*::]*/: { /* n:\"BrtSXTH14\" */ },\n\t/*::[*/0x0411/*::]*/: { /* n:\"BrtBeginSparklineGroup\", */ T:1 },\n\t/*::[*/0x0412/*::]*/: { /* n:\"BrtEndSparklineGroup\", */ T:-1 },\n\t/*::[*/0x0413/*::]*/: { /* n:\"BrtSparkline\" */ },\n\t/*::[*/0x0414/*::]*/: { /* n:\"BrtSXDI14\" */ },\n\t/*::[*/0x0415/*::]*/: { /* n:\"BrtWsFmtInfoEx14\" */ },\n\t/*::[*/0x0416/*::]*/: { /* n:\"BrtBeginConditionalFormatting14\", */ T:1 },\n\t/*::[*/0x0417/*::]*/: { /* n:\"BrtEndConditionalFormatting14\", */ T:-1 },\n\t/*::[*/0x0418/*::]*/: { /* n:\"BrtBeginCFRule14\", */ T:1 },\n\t/*::[*/0x0419/*::]*/: { /* n:\"BrtEndCFRule14\", */ T:-1 },\n\t/*::[*/0x041A/*::]*/: { /* n:\"BrtCFVO14\" */ },\n\t/*::[*/0x041B/*::]*/: { /* n:\"BrtBeginDatabar14\", */ T:1 },\n\t/*::[*/0x041C/*::]*/: { /* n:\"BrtBeginIconSet14\", */ T:1 },\n\t/*::[*/0x041D/*::]*/: { /* n:\"BrtDVal14\", */ f: parse_BrtDVal14 },\n\t/*::[*/0x041E/*::]*/: { /* n:\"BrtBeginDVals14\", */ T:1 },\n\t/*::[*/0x041F/*::]*/: { /* n:\"BrtColor14\" */ },\n\t/*::[*/0x0420/*::]*/: { /* n:\"BrtBeginSparklines\", */ T:1 },\n\t/*::[*/0x0421/*::]*/: { /* n:\"BrtEndSparklines\", */ T:-1 },\n\t/*::[*/0x0422/*::]*/: { /* n:\"BrtBeginSparklineGroups\", */ T:1 },\n\t/*::[*/0x0423/*::]*/: { /* n:\"BrtEndSparklineGroups\", */ T:-1 },\n\t/*::[*/0x0425/*::]*/: { /* n:\"BrtSXVD14\" */ },\n\t/*::[*/0x0426/*::]*/: { /* n:\"BrtBeginSXView14\", */ T:1 },\n\t/*::[*/0x0427/*::]*/: { /* n:\"BrtEndSXView14\", */ T:-1 },\n\t/*::[*/0x0428/*::]*/: { /* n:\"BrtBeginSXView16\", */ T:1 },\n\t/*::[*/0x0429/*::]*/: { /* n:\"BrtEndSXView16\", */ T:-1 },\n\t/*::[*/0x042A/*::]*/: { /* n:\"BrtBeginPCD14\", */ T:1 },\n\t/*::[*/0x042B/*::]*/: { /* n:\"BrtEndPCD14\", */ T:-1 },\n\t/*::[*/0x042C/*::]*/: { /* n:\"BrtBeginExtConn14\", */ T:1 },\n\t/*::[*/0x042D/*::]*/: { /* n:\"BrtEndExtConn14\", */ T:-1 },\n\t/*::[*/0x042E/*::]*/: { /* n:\"BrtBeginSlicerCacheIDs\", */ T:1 },\n\t/*::[*/0x042F/*::]*/: { /* n:\"BrtEndSlicerCacheIDs\", */ T:-1 },\n\t/*::[*/0x0430/*::]*/: { /* n:\"BrtBeginSlicerCacheID\", */ T:1 },\n\t/*::[*/0x0431/*::]*/: { /* n:\"BrtEndSlicerCacheID\", */ T:-1 },\n\t/*::[*/0x0433/*::]*/: { /* n:\"BrtBeginSlicerCache\", */ T:1 },\n\t/*::[*/0x0434/*::]*/: { /* n:\"BrtEndSlicerCache\", */ T:-1 },\n\t/*::[*/0x0435/*::]*/: { /* n:\"BrtBeginSlicerCacheDef\", */ T:1 },\n\t/*::[*/0x0436/*::]*/: { /* n:\"BrtEndSlicerCacheDef\", */ T:-1 },\n\t/*::[*/0x0437/*::]*/: { /* n:\"BrtBeginSlicersEx\", */ T:1 },\n\t/*::[*/0x0438/*::]*/: { /* n:\"BrtEndSlicersEx\", */ T:-1 },\n\t/*::[*/0x0439/*::]*/: { /* n:\"BrtBeginSlicerEx\", */ T:1 },\n\t/*::[*/0x043A/*::]*/: { /* n:\"BrtEndSlicerEx\", */ T:-1 },\n\t/*::[*/0x043B/*::]*/: { /* n:\"BrtBeginSlicer\", */ T:1 },\n\t/*::[*/0x043C/*::]*/: { /* n:\"BrtEndSlicer\", */ T:-1 },\n\t/*::[*/0x043D/*::]*/: { /* n:\"BrtSlicerCachePivotTables\" */ },\n\t/*::[*/0x043E/*::]*/: { /* n:\"BrtBeginSlicerCacheOlapImpl\", */ T:1 },\n\t/*::[*/0x043F/*::]*/: { /* n:\"BrtEndSlicerCacheOlapImpl\", */ T:-1 },\n\t/*::[*/0x0440/*::]*/: { /* n:\"BrtBeginSlicerCacheLevelsData\", */ T:1 },\n\t/*::[*/0x0441/*::]*/: { /* n:\"BrtEndSlicerCacheLevelsData\", */ T:-1 },\n\t/*::[*/0x0442/*::]*/: { /* n:\"BrtBeginSlicerCacheLevelData\", */ T:1 },\n\t/*::[*/0x0443/*::]*/: { /* n:\"BrtEndSlicerCacheLevelData\", */ T:-1 },\n\t/*::[*/0x0444/*::]*/: { /* n:\"BrtBeginSlicerCacheSiRanges\", */ T:1 },\n\t/*::[*/0x0445/*::]*/: { /* n:\"BrtEndSlicerCacheSiRanges\", */ T:-1 },\n\t/*::[*/0x0446/*::]*/: { /* n:\"BrtBeginSlicerCacheSiRange\", */ T:1 },\n\t/*::[*/0x0447/*::]*/: { /* n:\"BrtEndSlicerCacheSiRange\", */ T:-1 },\n\t/*::[*/0x0448/*::]*/: { /* n:\"BrtSlicerCacheOlapItem\" */ },\n\t/*::[*/0x0449/*::]*/: { /* n:\"BrtBeginSlicerCacheSelections\", */ T:1 },\n\t/*::[*/0x044A/*::]*/: { /* n:\"BrtSlicerCacheSelection\" */ },\n\t/*::[*/0x044B/*::]*/: { /* n:\"BrtEndSlicerCacheSelections\", */ T:-1 },\n\t/*::[*/0x044C/*::]*/: { /* n:\"BrtBeginSlicerCacheNative\", */ T:1 },\n\t/*::[*/0x044D/*::]*/: { /* n:\"BrtEndSlicerCacheNative\", */ T:-1 },\n\t/*::[*/0x044E/*::]*/: { /* n:\"BrtSlicerCacheNativeItem\" */ },\n\t/*::[*/0x044F/*::]*/: { /* n:\"BrtRangeProtection14\" */ },\n\t/*::[*/0x0450/*::]*/: { /* n:\"BrtRangeProtectionIso14\" */ },\n\t/*::[*/0x0451/*::]*/: { /* n:\"BrtCellIgnoreEC14\" */ },\n\t/*::[*/0x0457/*::]*/: { /* n:\"BrtList14\" */ },\n\t/*::[*/0x0458/*::]*/: { /* n:\"BrtCFIcon\" */ },\n\t/*::[*/0x0459/*::]*/: { /* n:\"BrtBeginSlicerCachesPivotCacheIDs\", */ T:1 },\n\t/*::[*/0x045A/*::]*/: { /* n:\"BrtEndSlicerCachesPivotCacheIDs\", */ T:-1 },\n\t/*::[*/0x045B/*::]*/: { /* n:\"BrtBeginSlicers\", */ T:1 },\n\t/*::[*/0x045C/*::]*/: { /* n:\"BrtEndSlicers\", */ T:-1 },\n\t/*::[*/0x045D/*::]*/: { /* n:\"BrtWbProp14\" */ },\n\t/*::[*/0x045E/*::]*/: { /* n:\"BrtBeginSXEdit\", */ T:1 },\n\t/*::[*/0x045F/*::]*/: { /* n:\"BrtEndSXEdit\", */ T:-1 },\n\t/*::[*/0x0460/*::]*/: { /* n:\"BrtBeginSXEdits\", */ T:1 },\n\t/*::[*/0x0461/*::]*/: { /* n:\"BrtEndSXEdits\", */ T:-1 },\n\t/*::[*/0x0462/*::]*/: { /* n:\"BrtBeginSXChange\", */ T:1 },\n\t/*::[*/0x0463/*::]*/: { /* n:\"BrtEndSXChange\", */ T:-1 },\n\t/*::[*/0x0464/*::]*/: { /* n:\"BrtBeginSXChanges\", */ T:1 },\n\t/*::[*/0x0465/*::]*/: { /* n:\"BrtEndSXChanges\", */ T:-1 },\n\t/*::[*/0x0466/*::]*/: { /* n:\"BrtSXTupleItems\" */ },\n\t/*::[*/0x0468/*::]*/: { /* n:\"BrtBeginSlicerStyle\", */ T:1 },\n\t/*::[*/0x0469/*::]*/: { /* n:\"BrtEndSlicerStyle\", */ T:-1 },\n\t/*::[*/0x046A/*::]*/: { /* n:\"BrtSlicerStyleElement\" */ },\n\t/*::[*/0x046B/*::]*/: { /* n:\"BrtBeginStyleSheetExt14\", */ T:1 },\n\t/*::[*/0x046C/*::]*/: { /* n:\"BrtEndStyleSheetExt14\", */ T:-1 },\n\t/*::[*/0x046D/*::]*/: { /* n:\"BrtBeginSlicerCachesPivotCacheID\", */ T:1 },\n\t/*::[*/0x046E/*::]*/: { /* n:\"BrtEndSlicerCachesPivotCacheID\", */ T:-1 },\n\t/*::[*/0x046F/*::]*/: { /* n:\"BrtBeginConditionalFormattings\", */ T:1 },\n\t/*::[*/0x0470/*::]*/: { /* n:\"BrtEndConditionalFormattings\", */ T:-1 },\n\t/*::[*/0x0471/*::]*/: { /* n:\"BrtBeginPCDCalcMemExt\", */ T:1 },\n\t/*::[*/0x0472/*::]*/: { /* n:\"BrtEndPCDCalcMemExt\", */ T:-1 },\n\t/*::[*/0x0473/*::]*/: { /* n:\"BrtBeginPCDCalcMemsExt\", */ T:1 },\n\t/*::[*/0x0474/*::]*/: { /* n:\"BrtEndPCDCalcMemsExt\", */ T:-1 },\n\t/*::[*/0x0475/*::]*/: { /* n:\"BrtPCDField14\" */ },\n\t/*::[*/0x0476/*::]*/: { /* n:\"BrtBeginSlicerStyles\", */ T:1 },\n\t/*::[*/0x0477/*::]*/: { /* n:\"BrtEndSlicerStyles\", */ T:-1 },\n\t/*::[*/0x0478/*::]*/: { /* n:\"BrtBeginSlicerStyleElements\", */ T:1 },\n\t/*::[*/0x0479/*::]*/: { /* n:\"BrtEndSlicerStyleElements\", */ T:-1 },\n\t/*::[*/0x047A/*::]*/: { /* n:\"BrtCFRuleExt\" */ },\n\t/*::[*/0x047B/*::]*/: { /* n:\"BrtBeginSXCondFmt14\", */ T:1 },\n\t/*::[*/0x047C/*::]*/: { /* n:\"BrtEndSXCondFmt14\", */ T:-1 },\n\t/*::[*/0x047D/*::]*/: { /* n:\"BrtBeginSXCondFmts14\", */ T:1 },\n\t/*::[*/0x047E/*::]*/: { /* n:\"BrtEndSXCondFmts14\", */ T:-1 },\n\t/*::[*/0x0480/*::]*/: { /* n:\"BrtBeginSortCond14\", */ T:1 },\n\t/*::[*/0x0481/*::]*/: { /* n:\"BrtEndSortCond14\", */ T:-1 },\n\t/*::[*/0x0482/*::]*/: { /* n:\"BrtEndDVals14\", */ T:-1 },\n\t/*::[*/0x0483/*::]*/: { /* n:\"BrtEndIconSet14\", */ T:-1 },\n\t/*::[*/0x0484/*::]*/: { /* n:\"BrtEndDatabar14\", */ T:-1 },\n\t/*::[*/0x0485/*::]*/: { /* n:\"BrtBeginColorScale14\", */ T:1 },\n\t/*::[*/0x0486/*::]*/: { /* n:\"BrtEndColorScale14\", */ T:-1 },\n\t/*::[*/0x0487/*::]*/: { /* n:\"BrtBeginSxrules14\", */ T:1 },\n\t/*::[*/0x0488/*::]*/: { /* n:\"BrtEndSxrules14\", */ T:-1 },\n\t/*::[*/0x0489/*::]*/: { /* n:\"BrtBeginPRule14\", */ T:1 },\n\t/*::[*/0x048A/*::]*/: { /* n:\"BrtEndPRule14\", */ T:-1 },\n\t/*::[*/0x048B/*::]*/: { /* n:\"BrtBeginPRFilters14\", */ T:1 },\n\t/*::[*/0x048C/*::]*/: { /* n:\"BrtEndPRFilters14\", */ T:-1 },\n\t/*::[*/0x048D/*::]*/: { /* n:\"BrtBeginPRFilter14\", */ T:1 },\n\t/*::[*/0x048E/*::]*/: { /* n:\"BrtEndPRFilter14\", */ T:-1 },\n\t/*::[*/0x048F/*::]*/: { /* n:\"BrtBeginPRFItem14\", */ T:1 },\n\t/*::[*/0x0490/*::]*/: { /* n:\"BrtEndPRFItem14\", */ T:-1 },\n\t/*::[*/0x0491/*::]*/: { /* n:\"BrtBeginCellIgnoreECs14\", */ T:1 },\n\t/*::[*/0x0492/*::]*/: { /* n:\"BrtEndCellIgnoreECs14\", */ T:-1 },\n\t/*::[*/0x0493/*::]*/: { /* n:\"BrtDxf14\" */ },\n\t/*::[*/0x0494/*::]*/: { /* n:\"BrtBeginDxF14s\", */ T:1 },\n\t/*::[*/0x0495/*::]*/: { /* n:\"BrtEndDxf14s\", */ T:-1 },\n\t/*::[*/0x0499/*::]*/: { /* n:\"BrtFilter14\" */ },\n\t/*::[*/0x049A/*::]*/: { /* n:\"BrtBeginCustomFilters14\", */ T:1 },\n\t/*::[*/0x049C/*::]*/: { /* n:\"BrtCustomFilter14\" */ },\n\t/*::[*/0x049D/*::]*/: { /* n:\"BrtIconFilter14\" */ },\n\t/*::[*/0x049E/*::]*/: { /* n:\"BrtPivotCacheConnectionName\" */ },\n\t/*::[*/0x0800/*::]*/: { /* n:\"BrtBeginDecoupledPivotCacheIDs\", */ T:1 },\n\t/*::[*/0x0801/*::]*/: { /* n:\"BrtEndDecoupledPivotCacheIDs\", */ T:-1 },\n\t/*::[*/0x0802/*::]*/: { /* n:\"BrtDecoupledPivotCacheID\" */ },\n\t/*::[*/0x0803/*::]*/: { /* n:\"BrtBeginPivotTableRefs\", */ T:1 },\n\t/*::[*/0x0804/*::]*/: { /* n:\"BrtEndPivotTableRefs\", */ T:-1 },\n\t/*::[*/0x0805/*::]*/: { /* n:\"BrtPivotTableRef\" */ },\n\t/*::[*/0x0806/*::]*/: { /* n:\"BrtSlicerCacheBookPivotTables\" */ },\n\t/*::[*/0x0807/*::]*/: { /* n:\"BrtBeginSxvcells\", */ T:1 },\n\t/*::[*/0x0808/*::]*/: { /* n:\"BrtEndSxvcells\", */ T:-1 },\n\t/*::[*/0x0809/*::]*/: { /* n:\"BrtBeginSxRow\", */ T:1 },\n\t/*::[*/0x080A/*::]*/: { /* n:\"BrtEndSxRow\", */ T:-1 },\n\t/*::[*/0x080C/*::]*/: { /* n:\"BrtPcdCalcMem15\" */ },\n\t/*::[*/0x0813/*::]*/: { /* n:\"BrtQsi15\" */ },\n\t/*::[*/0x0814/*::]*/: { /* n:\"BrtBeginWebExtensions\", */ T:1 },\n\t/*::[*/0x0815/*::]*/: { /* n:\"BrtEndWebExtensions\", */ T:-1 },\n\t/*::[*/0x0816/*::]*/: { /* n:\"BrtWebExtension\" */ },\n\t/*::[*/0x0817/*::]*/: { /* n:\"BrtAbsPath15\" */ },\n\t/*::[*/0x0818/*::]*/: { /* n:\"BrtBeginPivotTableUISettings\", */ T:1 },\n\t/*::[*/0x0819/*::]*/: { /* n:\"BrtEndPivotTableUISettings\", */ T:-1 },\n\t/*::[*/0x081B/*::]*/: { /* n:\"BrtTableSlicerCacheIDs\" */ },\n\t/*::[*/0x081C/*::]*/: { /* n:\"BrtTableSlicerCacheID\" */ },\n\t/*::[*/0x081D/*::]*/: { /* n:\"BrtBeginTableSlicerCache\", */ T:1 },\n\t/*::[*/0x081E/*::]*/: { /* n:\"BrtEndTableSlicerCache\", */ T:-1 },\n\t/*::[*/0x081F/*::]*/: { /* n:\"BrtSxFilter15\" */ },\n\t/*::[*/0x0820/*::]*/: { /* n:\"BrtBeginTimelineCachePivotCacheIDs\", */ T:1 },\n\t/*::[*/0x0821/*::]*/: { /* n:\"BrtEndTimelineCachePivotCacheIDs\", */ T:-1 },\n\t/*::[*/0x0822/*::]*/: { /* n:\"BrtTimelineCachePivotCacheID\" */ },\n\t/*::[*/0x0823/*::]*/: { /* n:\"BrtBeginTimelineCacheIDs\", */ T:1 },\n\t/*::[*/0x0824/*::]*/: { /* n:\"BrtEndTimelineCacheIDs\", */ T:-1 },\n\t/*::[*/0x0825/*::]*/: { /* n:\"BrtBeginTimelineCacheID\", */ T:1 },\n\t/*::[*/0x0826/*::]*/: { /* n:\"BrtEndTimelineCacheID\", */ T:-1 },\n\t/*::[*/0x0827/*::]*/: { /* n:\"BrtBeginTimelinesEx\", */ T:1 },\n\t/*::[*/0x0828/*::]*/: { /* n:\"BrtEndTimelinesEx\", */ T:-1 },\n\t/*::[*/0x0829/*::]*/: { /* n:\"BrtBeginTimelineEx\", */ T:1 },\n\t/*::[*/0x082A/*::]*/: { /* n:\"BrtEndTimelineEx\", */ T:-1 },\n\t/*::[*/0x082B/*::]*/: { /* n:\"BrtWorkBookPr15\" */ },\n\t/*::[*/0x082C/*::]*/: { /* n:\"BrtPCDH15\" */ },\n\t/*::[*/0x082D/*::]*/: { /* n:\"BrtBeginTimelineStyle\", */ T:1 },\n\t/*::[*/0x082E/*::]*/: { /* n:\"BrtEndTimelineStyle\", */ T:-1 },\n\t/*::[*/0x082F/*::]*/: { /* n:\"BrtTimelineStyleElement\" */ },\n\t/*::[*/0x0830/*::]*/: { /* n:\"BrtBeginTimelineStylesheetExt15\", */ T:1 },\n\t/*::[*/0x0831/*::]*/: { /* n:\"BrtEndTimelineStylesheetExt15\", */ T:-1 },\n\t/*::[*/0x0832/*::]*/: { /* n:\"BrtBeginTimelineStyles\", */ T:1 },\n\t/*::[*/0x0833/*::]*/: { /* n:\"BrtEndTimelineStyles\", */ T:-1 },\n\t/*::[*/0x0834/*::]*/: { /* n:\"BrtBeginTimelineStyleElements\", */ T:1 },\n\t/*::[*/0x0835/*::]*/: { /* n:\"BrtEndTimelineStyleElements\", */ T:-1 },\n\t/*::[*/0x0836/*::]*/: { /* n:\"BrtDxf15\" */ },\n\t/*::[*/0x0837/*::]*/: { /* n:\"BrtBeginDxfs15\", */ T:1 },\n\t/*::[*/0x0838/*::]*/: { /* n:\"BrtEndDxfs15\", */ T:-1 },\n\t/*::[*/0x0839/*::]*/: { /* n:\"BrtSlicerCacheHideItemsWithNoData\" */ },\n\t/*::[*/0x083A/*::]*/: { /* n:\"BrtBeginItemUniqueNames\", */ T:1 },\n\t/*::[*/0x083B/*::]*/: { /* n:\"BrtEndItemUniqueNames\", */ T:-1 },\n\t/*::[*/0x083C/*::]*/: { /* n:\"BrtItemUniqueName\" */ },\n\t/*::[*/0x083D/*::]*/: { /* n:\"BrtBeginExtConn15\", */ T:1 },\n\t/*::[*/0x083E/*::]*/: { /* n:\"BrtEndExtConn15\", */ T:-1 },\n\t/*::[*/0x083F/*::]*/: { /* n:\"BrtBeginOledbPr15\", */ T:1 },\n\t/*::[*/0x0840/*::]*/: { /* n:\"BrtEndOledbPr15\", */ T:-1 },\n\t/*::[*/0x0841/*::]*/: { /* n:\"BrtBeginDataFeedPr15\", */ T:1 },\n\t/*::[*/0x0842/*::]*/: { /* n:\"BrtEndDataFeedPr15\", */ T:-1 },\n\t/*::[*/0x0843/*::]*/: { /* n:\"BrtTextPr15\" */ },\n\t/*::[*/0x0844/*::]*/: { /* n:\"BrtRangePr15\" */ },\n\t/*::[*/0x0845/*::]*/: { /* n:\"BrtDbCommand15\" */ },\n\t/*::[*/0x0846/*::]*/: { /* n:\"BrtBeginDbTables15\", */ T:1 },\n\t/*::[*/0x0847/*::]*/: { /* n:\"BrtEndDbTables15\", */ T:-1 },\n\t/*::[*/0x0848/*::]*/: { /* n:\"BrtDbTable15\" */ },\n\t/*::[*/0x0849/*::]*/: { /* n:\"BrtBeginDataModel\", */ T:1 },\n\t/*::[*/0x084A/*::]*/: { /* n:\"BrtEndDataModel\", */ T:-1 },\n\t/*::[*/0x084B/*::]*/: { /* n:\"BrtBeginModelTables\", */ T:1 },\n\t/*::[*/0x084C/*::]*/: { /* n:\"BrtEndModelTables\", */ T:-1 },\n\t/*::[*/0x084D/*::]*/: { /* n:\"BrtModelTable\" */ },\n\t/*::[*/0x084E/*::]*/: { /* n:\"BrtBeginModelRelationships\", */ T:1 },\n\t/*::[*/0x084F/*::]*/: { /* n:\"BrtEndModelRelationships\", */ T:-1 },\n\t/*::[*/0x0850/*::]*/: { /* n:\"BrtModelRelationship\" */ },\n\t/*::[*/0x0851/*::]*/: { /* n:\"BrtBeginECTxtWiz15\", */ T:1 },\n\t/*::[*/0x0852/*::]*/: { /* n:\"BrtEndECTxtWiz15\", */ T:-1 },\n\t/*::[*/0x0853/*::]*/: { /* n:\"BrtBeginECTWFldInfoLst15\", */ T:1 },\n\t/*::[*/0x0854/*::]*/: { /* n:\"BrtEndECTWFldInfoLst15\", */ T:-1 },\n\t/*::[*/0x0855/*::]*/: { /* n:\"BrtBeginECTWFldInfo15\", */ T:1 },\n\t/*::[*/0x0856/*::]*/: { /* n:\"BrtFieldListActiveItem\" */ },\n\t/*::[*/0x0857/*::]*/: { /* n:\"BrtPivotCacheIdVersion\" */ },\n\t/*::[*/0x0858/*::]*/: { /* n:\"BrtSXDI15\" */ },\n\t/*::[*/0x0859/*::]*/: { /* n:\"BrtBeginModelTimeGroupings\", */ T:1 },\n\t/*::[*/0x085A/*::]*/: { /* n:\"BrtEndModelTimeGroupings\", */ T:-1 },\n\t/*::[*/0x085B/*::]*/: { /* n:\"BrtBeginModelTimeGrouping\", */ T:1 },\n\t/*::[*/0x085C/*::]*/: { /* n:\"BrtEndModelTimeGrouping\", */ T:-1 },\n\t/*::[*/0x085D/*::]*/: { /* n:\"BrtModelTimeGroupingCalcCol\" */ },\n\t/*::[*/0x0C00/*::]*/: { /* n:\"BrtUid\" */ },\n\t/*::[*/0x0C01/*::]*/: { /* n:\"BrtRevisionPtr\" */ },\n\t/*::[*/0x1000/*::]*/: { /* n:\"BrtBeginDynamicArrayPr\", */ T:1 },\n\t/*::[*/0x1001/*::]*/: { /* n:\"BrtEndDynamicArrayPr\", */ T:-1 },\n\t/*::[*/0x138A/*::]*/: { /* n:\"BrtBeginRichValueBlock\", */ T:1 },\n\t/*::[*/0x138B/*::]*/: { /* n:\"BrtEndRichValueBlock\", */ T:-1 },\n\t/*::[*/0x13D9/*::]*/: { /* n:\"BrtBeginRichFilters\", */ T:1 },\n\t/*::[*/0x13DA/*::]*/: { /* n:\"BrtEndRichFilters\", */ T:-1 },\n\t/*::[*/0x13DB/*::]*/: { /* n:\"BrtRichFilter\" */ },\n\t/*::[*/0x13DC/*::]*/: { /* n:\"BrtBeginRichFilterColumn\", */ T:1 },\n\t/*::[*/0x13DD/*::]*/: { /* n:\"BrtEndRichFilterColumn\", */ T:-1 },\n\t/*::[*/0x13DE/*::]*/: { /* n:\"BrtBeginCustomRichFilters\", */ T:1 },\n\t/*::[*/0x13DF/*::]*/: { /* n:\"BrtEndCustomRichFilters\", */ T:-1 },\n\t/*::[*/0x13E0/*::]*/: { /* n:\"BrtCustomRichFilter\" */ },\n\t/*::[*/0x13E1/*::]*/: { /* n:\"BrtTop10RichFilter\" */ },\n\t/*::[*/0x13E2/*::]*/: { /* n:\"BrtDynamicRichFilter\" */ },\n\t/*::[*/0x13E4/*::]*/: { /* n:\"BrtBeginRichSortCondition\", */ T:1 },\n\t/*::[*/0x13E5/*::]*/: { /* n:\"BrtEndRichSortCondition\", */ T:-1 },\n\t/*::[*/0x13E6/*::]*/: { /* n:\"BrtRichFilterDateGroupItem\" */ },\n\t/*::[*/0x13E7/*::]*/: { /* n:\"BrtBeginCalcFeatures\", */ T:1 },\n\t/*::[*/0x13E8/*::]*/: { /* n:\"BrtEndCalcFeatures\", */ T:-1 },\n\t/*::[*/0x13E9/*::]*/: { /* n:\"BrtCalcFeature\" */ },\n\t/*::[*/0x13EB/*::]*/: { /* n:\"BrtExternalLinksPr\" */ },\n\t/*::[*/0xFFFF/*::]*/: { n:\"\" }\n};\n\n/* [MS-XLS] 2.3 Record Enumeration (and other sources) */\nvar XLSRecordEnum = {\n\t/* [MS-XLS] 2.3 Record Enumeration 2021-08-17 */\n\t/*::[*/0x0006/*::]*/: { /* n:\"Formula\", */ f:parse_Formula },\n\t/*::[*/0x000a/*::]*/: { /* n:\"EOF\", */ f:parsenoop2 },\n\t/*::[*/0x000c/*::]*/: { /* n:\"CalcCount\", */ f:parseuint16 }, //\n\t/*::[*/0x000d/*::]*/: { /* n:\"CalcMode\", */ f:parseuint16 }, //\n\t/*::[*/0x000e/*::]*/: { /* n:\"CalcPrecision\", */ f:parsebool }, //\n\t/*::[*/0x000f/*::]*/: { /* n:\"CalcRefMode\", */ f:parsebool }, //\n\t/*::[*/0x0010/*::]*/: { /* n:\"CalcDelta\", */ f:parse_Xnum }, //\n\t/*::[*/0x0011/*::]*/: { /* n:\"CalcIter\", */ f:parsebool }, //\n\t/*::[*/0x0012/*::]*/: { /* n:\"Protect\", */ f:parsebool },\n\t/*::[*/0x0013/*::]*/: { /* n:\"Password\", */ f:parseuint16 },\n\t/*::[*/0x0014/*::]*/: { /* n:\"Header\", */ f:parse_XLHeaderFooter },\n\t/*::[*/0x0015/*::]*/: { /* n:\"Footer\", */ f:parse_XLHeaderFooter },\n\t/*::[*/0x0017/*::]*/: { /* n:\"ExternSheet\", */ f:parse_ExternSheet },\n\t/*::[*/0x0018/*::]*/: { /* n:\"Lbl\", */ f:parse_Lbl },\n\t/*::[*/0x0019/*::]*/: { /* n:\"WinProtect\", */ f:parsebool },\n\t/*::[*/0x001a/*::]*/: { /* n:\"VerticalPageBreaks\", */ },\n\t/*::[*/0x001b/*::]*/: { /* n:\"HorizontalPageBreaks\", */ },\n\t/*::[*/0x001c/*::]*/: { /* n:\"Note\", */ f:parse_Note },\n\t/*::[*/0x001d/*::]*/: { /* n:\"Selection\", */ },\n\t/*::[*/0x0022/*::]*/: { /* n:\"Date1904\", */ f:parsebool },\n\t/*::[*/0x0023/*::]*/: { /* n:\"ExternName\", */ f:parse_ExternName },\n\t/*::[*/0x0026/*::]*/: { /* n:\"LeftMargin\", */ f:parse_Xnum }, // *\n\t/*::[*/0x0027/*::]*/: { /* n:\"RightMargin\", */ f:parse_Xnum }, // *\n\t/*::[*/0x0028/*::]*/: { /* n:\"TopMargin\", */ f:parse_Xnum }, // *\n\t/*::[*/0x0029/*::]*/: { /* n:\"BottomMargin\", */ f:parse_Xnum }, // *\n\t/*::[*/0x002a/*::]*/: { /* n:\"PrintRowCol\", */ f:parsebool },\n\t/*::[*/0x002b/*::]*/: { /* n:\"PrintGrid\", */ f:parsebool },\n\t/*::[*/0x002f/*::]*/: { /* n:\"FilePass\", */ f:parse_FilePass },\n\t/*::[*/0x0031/*::]*/: { /* n:\"Font\", */ f:parse_Font },\n\t/*::[*/0x0033/*::]*/: { /* n:\"PrintSize\", */ f:parseuint16 },\n\t/*::[*/0x003c/*::]*/: { /* n:\"Continue\", */ },\n\t/*::[*/0x003d/*::]*/: { /* n:\"Window1\", */ f:parse_Window1 },\n\t/*::[*/0x0040/*::]*/: { /* n:\"Backup\", */ f:parsebool },\n\t/*::[*/0x0041/*::]*/: { /* n:\"Pane\", */ f:parse_Pane },\n\t/*::[*/0x0042/*::]*/: { /* n:\"CodePage\", */ f:parseuint16 },\n\t/*::[*/0x004d/*::]*/: { /* n:\"Pls\", */ },\n\t/*::[*/0x0050/*::]*/: { /* n:\"DCon\", */ },\n\t/*::[*/0x0051/*::]*/: { /* n:\"DConRef\", */ },\n\t/*::[*/0x0052/*::]*/: { /* n:\"DConName\", */ },\n\t/*::[*/0x0055/*::]*/: { /* n:\"DefColWidth\", */ f:parseuint16 },\n\t/*::[*/0x0059/*::]*/: { /* n:\"XCT\", */ },\n\t/*::[*/0x005a/*::]*/: { /* n:\"CRN\", */ },\n\t/*::[*/0x005b/*::]*/: { /* n:\"FileSharing\", */ },\n\t/*::[*/0x005c/*::]*/: { /* n:\"WriteAccess\", */ f:parse_WriteAccess },\n\t/*::[*/0x005d/*::]*/: { /* n:\"Obj\", */ f:parse_Obj },\n\t/*::[*/0x005e/*::]*/: { /* n:\"Uncalced\", */ },\n\t/*::[*/0x005f/*::]*/: { /* n:\"CalcSaveRecalc\", */ f:parsebool }, //\n\t/*::[*/0x0060/*::]*/: { /* n:\"Template\", */ },\n\t/*::[*/0x0061/*::]*/: { /* n:\"Intl\", */ },\n\t/*::[*/0x0063/*::]*/: { /* n:\"ObjProtect\", */ f:parsebool },\n\t/*::[*/0x007d/*::]*/: { /* n:\"ColInfo\", */ f:parse_ColInfo },\n\t/*::[*/0x0080/*::]*/: { /* n:\"Guts\", */ f:parse_Guts },\n\t/*::[*/0x0081/*::]*/: { /* n:\"WsBool\", */ f:parse_WsBool },\n\t/*::[*/0x0082/*::]*/: { /* n:\"GridSet\", */ f:parseuint16 },\n\t/*::[*/0x0083/*::]*/: { /* n:\"HCenter\", */ f:parsebool },\n\t/*::[*/0x0084/*::]*/: { /* n:\"VCenter\", */ f:parsebool },\n\t/*::[*/0x0085/*::]*/: { /* n:\"BoundSheet8\", */ f:parse_BoundSheet8 },\n\t/*::[*/0x0086/*::]*/: { /* n:\"WriteProtect\", */ },\n\t/*::[*/0x008c/*::]*/: { /* n:\"Country\", */ f:parse_Country },\n\t/*::[*/0x008d/*::]*/: { /* n:\"HideObj\", */ f:parseuint16 },\n\t/*::[*/0x0090/*::]*/: { /* n:\"Sort\", */ },\n\t/*::[*/0x0092/*::]*/: { /* n:\"Palette\", */ f:parse_Palette },\n\t/*::[*/0x0097/*::]*/: { /* n:\"Sync\", */ },\n\t/*::[*/0x0098/*::]*/: { /* n:\"LPr\", */ },\n\t/*::[*/0x0099/*::]*/: { /* n:\"DxGCol\", */ },\n\t/*::[*/0x009a/*::]*/: { /* n:\"FnGroupName\", */ },\n\t/*::[*/0x009b/*::]*/: { /* n:\"FilterMode\", */ },\n\t/*::[*/0x009c/*::]*/: { /* n:\"BuiltInFnGroupCount\", */ f:parseuint16 },\n\t/*::[*/0x009d/*::]*/: { /* n:\"AutoFilterInfo\", */ },\n\t/*::[*/0x009e/*::]*/: { /* n:\"AutoFilter\", */ },\n\t/*::[*/0x00a0/*::]*/: { /* n:\"Scl\", */ f:parse_Scl },\n\t/*::[*/0x00a1/*::]*/: { /* n:\"Setup\", */ f:parse_Setup },\n\t/*::[*/0x00ae/*::]*/: { /* n:\"ScenMan\", */ },\n\t/*::[*/0x00af/*::]*/: { /* n:\"SCENARIO\", */ },\n\t/*::[*/0x00b0/*::]*/: { /* n:\"SxView\", */ },\n\t/*::[*/0x00b1/*::]*/: { /* n:\"Sxvd\", */ },\n\t/*::[*/0x00b2/*::]*/: { /* n:\"SXVI\", */ },\n\t/*::[*/0x00b4/*::]*/: { /* n:\"SxIvd\", */ },\n\t/*::[*/0x00b5/*::]*/: { /* n:\"SXLI\", */ },\n\t/*::[*/0x00b6/*::]*/: { /* n:\"SXPI\", */ },\n\t/*::[*/0x00b8/*::]*/: { /* n:\"DocRoute\", */ },\n\t/*::[*/0x00b9/*::]*/: { /* n:\"RecipName\", */ },\n\t/*::[*/0x00bd/*::]*/: { /* n:\"MulRk\", */ f:parse_MulRk },\n\t/*::[*/0x00be/*::]*/: { /* n:\"MulBlank\", */ f:parse_MulBlank },\n\t/*::[*/0x00c1/*::]*/: { /* n:\"Mms\", */ f:parsenoop2 },\n\t/*::[*/0x00c5/*::]*/: { /* n:\"SXDI\", */ },\n\t/*::[*/0x00c6/*::]*/: { /* n:\"SXDB\", */ },\n\t/*::[*/0x00c7/*::]*/: { /* n:\"SXFDB\", */ },\n\t/*::[*/0x00c8/*::]*/: { /* n:\"SXDBB\", */ },\n\t/*::[*/0x00c9/*::]*/: { /* n:\"SXNum\", */ },\n\t/*::[*/0x00ca/*::]*/: { /* n:\"SxBool\", */ f:parsebool },\n\t/*::[*/0x00cb/*::]*/: { /* n:\"SxErr\", */ },\n\t/*::[*/0x00cc/*::]*/: { /* n:\"SXInt\", */ },\n\t/*::[*/0x00cd/*::]*/: { /* n:\"SXString\", */ },\n\t/*::[*/0x00ce/*::]*/: { /* n:\"SXDtr\", */ },\n\t/*::[*/0x00cf/*::]*/: { /* n:\"SxNil\", */ },\n\t/*::[*/0x00d0/*::]*/: { /* n:\"SXTbl\", */ },\n\t/*::[*/0x00d1/*::]*/: { /* n:\"SXTBRGIITM\", */ },\n\t/*::[*/0x00d2/*::]*/: { /* n:\"SxTbpg\", */ },\n\t/*::[*/0x00d3/*::]*/: { /* n:\"ObProj\", */ },\n\t/*::[*/0x00d5/*::]*/: { /* n:\"SXStreamID\", */ },\n\t/*::[*/0x00d7/*::]*/: { /* n:\"DBCell\", */ },\n\t/*::[*/0x00d8/*::]*/: { /* n:\"SXRng\", */ },\n\t/*::[*/0x00d9/*::]*/: { /* n:\"SxIsxoper\", */ },\n\t/*::[*/0x00da/*::]*/: { /* n:\"BookBool\", */ f:parseuint16 },\n\t/*::[*/0x00dc/*::]*/: { /* n:\"DbOrParamQry\", */ },\n\t/*::[*/0x00dd/*::]*/: { /* n:\"ScenarioProtect\", */ f:parsebool },\n\t/*::[*/0x00de/*::]*/: { /* n:\"OleObjectSize\", */ },\n\t/*::[*/0x00e0/*::]*/: { /* n:\"XF\", */ f:parse_XF },\n\t/*::[*/0x00e1/*::]*/: { /* n:\"InterfaceHdr\", */ f:parse_InterfaceHdr },\n\t/*::[*/0x00e2/*::]*/: { /* n:\"InterfaceEnd\", */ f:parsenoop2 },\n\t/*::[*/0x00e3/*::]*/: { /* n:\"SXVS\", */ },\n\t/*::[*/0x00e5/*::]*/: { /* n:\"MergeCells\", */ f:parse_MergeCells },\n\t/*::[*/0x00e9/*::]*/: { /* n:\"BkHim\", */ },\n\t/*::[*/0x00eb/*::]*/: { /* n:\"MsoDrawingGroup\", */ },\n\t/*::[*/0x00ec/*::]*/: { /* n:\"MsoDrawing\", */ },\n\t/*::[*/0x00ed/*::]*/: { /* n:\"MsoDrawingSelection\", */ },\n\t/*::[*/0x00ef/*::]*/: { /* n:\"PhoneticInfo\", */ },\n\t/*::[*/0x00f0/*::]*/: { /* n:\"SxRule\", */ },\n\t/*::[*/0x00f1/*::]*/: { /* n:\"SXEx\", */ },\n\t/*::[*/0x00f2/*::]*/: { /* n:\"SxFilt\", */ },\n\t/*::[*/0x00f4/*::]*/: { /* n:\"SxDXF\", */ },\n\t/*::[*/0x00f5/*::]*/: { /* n:\"SxItm\", */ },\n\t/*::[*/0x00f6/*::]*/: { /* n:\"SxName\", */ },\n\t/*::[*/0x00f7/*::]*/: { /* n:\"SxSelect\", */ },\n\t/*::[*/0x00f8/*::]*/: { /* n:\"SXPair\", */ },\n\t/*::[*/0x00f9/*::]*/: { /* n:\"SxFmla\", */ },\n\t/*::[*/0x00fb/*::]*/: { /* n:\"SxFormat\", */ },\n\t/*::[*/0x00fc/*::]*/: { /* n:\"SST\", */ f:parse_SST },\n\t/*::[*/0x00fd/*::]*/: { /* n:\"LabelSst\", */ f:parse_LabelSst },\n\t/*::[*/0x00ff/*::]*/: { /* n:\"ExtSST\", */ f:parse_ExtSST },\n\t/*::[*/0x0100/*::]*/: { /* n:\"SXVDEx\", */ },\n\t/*::[*/0x0103/*::]*/: { /* n:\"SXFormula\", */ },\n\t/*::[*/0x0122/*::]*/: { /* n:\"SXDBEx\", */ },\n\t/*::[*/0x0137/*::]*/: { /* n:\"RRDInsDel\", */ },\n\t/*::[*/0x0138/*::]*/: { /* n:\"RRDHead\", */ },\n\t/*::[*/0x013b/*::]*/: { /* n:\"RRDChgCell\", */ },\n\t/*::[*/0x013d/*::]*/: { /* n:\"RRTabId\", */ f:parseuint16a },\n\t/*::[*/0x013e/*::]*/: { /* n:\"RRDRenSheet\", */ },\n\t/*::[*/0x013f/*::]*/: { /* n:\"RRSort\", */ },\n\t/*::[*/0x0140/*::]*/: { /* n:\"RRDMove\", */ },\n\t/*::[*/0x014a/*::]*/: { /* n:\"RRFormat\", */ },\n\t/*::[*/0x014b/*::]*/: { /* n:\"RRAutoFmt\", */ },\n\t/*::[*/0x014d/*::]*/: { /* n:\"RRInsertSh\", */ },\n\t/*::[*/0x014e/*::]*/: { /* n:\"RRDMoveBegin\", */ },\n\t/*::[*/0x014f/*::]*/: { /* n:\"RRDMoveEnd\", */ },\n\t/*::[*/0x0150/*::]*/: { /* n:\"RRDInsDelBegin\", */ },\n\t/*::[*/0x0151/*::]*/: { /* n:\"RRDInsDelEnd\", */ },\n\t/*::[*/0x0152/*::]*/: { /* n:\"RRDConflict\", */ },\n\t/*::[*/0x0153/*::]*/: { /* n:\"RRDDefName\", */ },\n\t/*::[*/0x0154/*::]*/: { /* n:\"RRDRstEtxp\", */ },\n\t/*::[*/0x015f/*::]*/: { /* n:\"LRng\", */ },\n\t/*::[*/0x0160/*::]*/: { /* n:\"UsesELFs\", */ f:parsebool },\n\t/*::[*/0x0161/*::]*/: { /* n:\"DSF\", */ f:parsenoop2 },\n\t/*::[*/0x0191/*::]*/: { /* n:\"CUsr\", */ },\n\t/*::[*/0x0192/*::]*/: { /* n:\"CbUsr\", */ },\n\t/*::[*/0x0193/*::]*/: { /* n:\"UsrInfo\", */ },\n\t/*::[*/0x0194/*::]*/: { /* n:\"UsrExcl\", */ },\n\t/*::[*/0x0195/*::]*/: { /* n:\"FileLock\", */ },\n\t/*::[*/0x0196/*::]*/: { /* n:\"RRDInfo\", */ },\n\t/*::[*/0x0197/*::]*/: { /* n:\"BCUsrs\", */ },\n\t/*::[*/0x0198/*::]*/: { /* n:\"UsrChk\", */ },\n\t/*::[*/0x01a9/*::]*/: { /* n:\"UserBView\", */ },\n\t/*::[*/0x01aa/*::]*/: { /* n:\"UserSViewBegin\", */ },\n\t/*::[*/0x01ab/*::]*/: { /* n:\"UserSViewEnd\", */ },\n\t/*::[*/0x01ac/*::]*/: { /* n:\"RRDUserView\", */ },\n\t/*::[*/0x01ad/*::]*/: { /* n:\"Qsi\", */ },\n\t/*::[*/0x01ae/*::]*/: { /* n:\"SupBook\", */ f:parse_SupBook },\n\t/*::[*/0x01af/*::]*/: { /* n:\"Prot4Rev\", */ f:parsebool },\n\t/*::[*/0x01b0/*::]*/: { /* n:\"CondFmt\", */ },\n\t/*::[*/0x01b1/*::]*/: { /* n:\"CF\", */ },\n\t/*::[*/0x01b2/*::]*/: { /* n:\"DVal\", */ },\n\t/*::[*/0x01b5/*::]*/: { /* n:\"DConBin\", */ },\n\t/*::[*/0x01b6/*::]*/: { /* n:\"TxO\", */ f:parse_TxO },\n\t/*::[*/0x01b7/*::]*/: { /* n:\"RefreshAll\", */ f:parsebool }, //\n\t/*::[*/0x01b8/*::]*/: { /* n:\"HLink\", */ f:parse_HLink },\n\t/*::[*/0x01b9/*::]*/: { /* n:\"Lel\", */ },\n\t/*::[*/0x01ba/*::]*/: { /* n:\"CodeName\", */ f:parse_XLUnicodeString },\n\t/*::[*/0x01bb/*::]*/: { /* n:\"SXFDBType\", */ },\n\t/*::[*/0x01bc/*::]*/: { /* n:\"Prot4RevPass\", */ f:parseuint16 },\n\t/*::[*/0x01bd/*::]*/: { /* n:\"ObNoMacros\", */ },\n\t/*::[*/0x01be/*::]*/: { /* n:\"Dv\", */ },\n\t/*::[*/0x01c0/*::]*/: { /* n:\"Excel9File\", */ f:parsenoop2 },\n\t/*::[*/0x01c1/*::]*/: { /* n:\"RecalcId\", */ f:parse_RecalcId, r:2},\n\t/*::[*/0x01c2/*::]*/: { /* n:\"EntExU2\", */ f:parsenoop2 },\n\t/*::[*/0x0200/*::]*/: { /* n:\"Dimensions\", */ f:parse_Dimensions },\n\t/*::[*/0x0201/*::]*/: { /* n:\"Blank\", */ f:parse_Blank },\n\t/*::[*/0x0203/*::]*/: { /* n:\"Number\", */ f:parse_Number },\n\t/*::[*/0x0204/*::]*/: { /* n:\"Label\", */ f:parse_Label },\n\t/*::[*/0x0205/*::]*/: { /* n:\"BoolErr\", */ f:parse_BoolErr },\n\t/*::[*/0x0207/*::]*/: { /* n:\"String\", */ f:parse_String },\n\t/*::[*/0x0208/*::]*/: { /* n:\"Row\", */ f:parse_Row },\n\t/*::[*/0x020b/*::]*/: { /* n:\"Index\", */ },\n\t/*::[*/0x0221/*::]*/: { /* n:\"Array\", */ f:parse_Array },\n\t/*::[*/0x0225/*::]*/: { /* n:\"DefaultRowHeight\", */ f:parse_DefaultRowHeight },\n\t/*::[*/0x0236/*::]*/: { /* n:\"Table\", */ },\n\t/*::[*/0x023e/*::]*/: { /* n:\"Window2\", */ f:parse_Window2 },\n\t/*::[*/0x027e/*::]*/: { /* n:\"RK\", */ f:parse_RK },\n\t/*::[*/0x0293/*::]*/: { /* n:\"Style\", */ },\n\t/*::[*/0x0418/*::]*/: { /* n:\"BigName\", */ },\n\t/*::[*/0x041e/*::]*/: { /* n:\"Format\", */ f:parse_Format },\n\t/*::[*/0x043c/*::]*/: { /* n:\"ContinueBigName\", */ },\n\t/*::[*/0x04bc/*::]*/: { /* n:\"ShrFmla\", */ f:parse_ShrFmla },\n\t/*::[*/0x0800/*::]*/: { /* n:\"HLinkTooltip\", */ f:parse_HLinkTooltip },\n\t/*::[*/0x0801/*::]*/: { /* n:\"WebPub\", */ },\n\t/*::[*/0x0802/*::]*/: { /* n:\"QsiSXTag\", */ },\n\t/*::[*/0x0803/*::]*/: { /* n:\"DBQueryExt\", */ },\n\t/*::[*/0x0804/*::]*/: { /* n:\"ExtString\", */ },\n\t/*::[*/0x0805/*::]*/: { /* n:\"TxtQry\", */ },\n\t/*::[*/0x0806/*::]*/: { /* n:\"Qsir\", */ },\n\t/*::[*/0x0807/*::]*/: { /* n:\"Qsif\", */ },\n\t/*::[*/0x0808/*::]*/: { /* n:\"RRDTQSIF\", */ },\n\t/*::[*/0x0809/*::]*/: { /* n:\"BOF\", */ f:parse_BOF },\n\t/*::[*/0x080a/*::]*/: { /* n:\"OleDbConn\", */ },\n\t/*::[*/0x080b/*::]*/: { /* n:\"WOpt\", */ },\n\t/*::[*/0x080c/*::]*/: { /* n:\"SXViewEx\", */ },\n\t/*::[*/0x080d/*::]*/: { /* n:\"SXTH\", */ },\n\t/*::[*/0x080e/*::]*/: { /* n:\"SXPIEx\", */ },\n\t/*::[*/0x080f/*::]*/: { /* n:\"SXVDTEx\", */ },\n\t/*::[*/0x0810/*::]*/: { /* n:\"SXViewEx9\", */ },\n\t/*::[*/0x0812/*::]*/: { /* n:\"ContinueFrt\", */ },\n\t/*::[*/0x0813/*::]*/: { /* n:\"RealTimeData\", */ },\n\t/*::[*/0x0850/*::]*/: { /* n:\"ChartFrtInfo\", */ },\n\t/*::[*/0x0851/*::]*/: { /* n:\"FrtWrapper\", */ },\n\t/*::[*/0x0852/*::]*/: { /* n:\"StartBlock\", */ },\n\t/*::[*/0x0853/*::]*/: { /* n:\"EndBlock\", */ },\n\t/*::[*/0x0854/*::]*/: { /* n:\"StartObject\", */ },\n\t/*::[*/0x0855/*::]*/: { /* n:\"EndObject\", */ },\n\t/*::[*/0x0856/*::]*/: { /* n:\"CatLab\", */ },\n\t/*::[*/0x0857/*::]*/: { /* n:\"YMult\", */ },\n\t/*::[*/0x0858/*::]*/: { /* n:\"SXViewLink\", */ },\n\t/*::[*/0x0859/*::]*/: { /* n:\"PivotChartBits\", */ },\n\t/*::[*/0x085a/*::]*/: { /* n:\"FrtFontList\", */ },\n\t/*::[*/0x0862/*::]*/: { /* n:\"SheetExt\", */ },\n\t/*::[*/0x0863/*::]*/: { /* n:\"BookExt\", */ r:12},\n\t/*::[*/0x0864/*::]*/: { /* n:\"SXAddl\", */ },\n\t/*::[*/0x0865/*::]*/: { /* n:\"CrErr\", */ },\n\t/*::[*/0x0866/*::]*/: { /* n:\"HFPicture\", */ },\n\t/*::[*/0x0867/*::]*/: { /* n:\"FeatHdr\", */ f:parsenoop2 },\n\t/*::[*/0x0868/*::]*/: { /* n:\"Feat\", */ },\n\t/*::[*/0x086a/*::]*/: { /* n:\"DataLabExt\", */ },\n\t/*::[*/0x086b/*::]*/: { /* n:\"DataLabExtContents\", */ },\n\t/*::[*/0x086c/*::]*/: { /* n:\"CellWatch\", */ },\n\t/*::[*/0x0871/*::]*/: { /* n:\"FeatHdr11\", */ },\n\t/*::[*/0x0872/*::]*/: { /* n:\"Feature11\", */ },\n\t/*::[*/0x0874/*::]*/: { /* n:\"DropDownObjIds\", */ },\n\t/*::[*/0x0875/*::]*/: { /* n:\"ContinueFrt11\", */ },\n\t/*::[*/0x0876/*::]*/: { /* n:\"DConn\", */ },\n\t/*::[*/0x0877/*::]*/: { /* n:\"List12\", */ },\n\t/*::[*/0x0878/*::]*/: { /* n:\"Feature12\", */ },\n\t/*::[*/0x0879/*::]*/: { /* n:\"CondFmt12\", */ },\n\t/*::[*/0x087a/*::]*/: { /* n:\"CF12\", */ },\n\t/*::[*/0x087b/*::]*/: { /* n:\"CFEx\", */ },\n\t/*::[*/0x087c/*::]*/: { /* n:\"XFCRC\", */ f:parse_XFCRC, r:12 },\n\t/*::[*/0x087d/*::]*/: { /* n:\"XFExt\", */ f:parse_XFExt, r:12 },\n\t/*::[*/0x087e/*::]*/: { /* n:\"AutoFilter12\", */ },\n\t/*::[*/0x087f/*::]*/: { /* n:\"ContinueFrt12\", */ },\n\t/*::[*/0x0884/*::]*/: { /* n:\"MDTInfo\", */ },\n\t/*::[*/0x0885/*::]*/: { /* n:\"MDXStr\", */ },\n\t/*::[*/0x0886/*::]*/: { /* n:\"MDXTuple\", */ },\n\t/*::[*/0x0887/*::]*/: { /* n:\"MDXSet\", */ },\n\t/*::[*/0x0888/*::]*/: { /* n:\"MDXProp\", */ },\n\t/*::[*/0x0889/*::]*/: { /* n:\"MDXKPI\", */ },\n\t/*::[*/0x088a/*::]*/: { /* n:\"MDB\", */ },\n\t/*::[*/0x088b/*::]*/: { /* n:\"PLV\", */ },\n\t/*::[*/0x088c/*::]*/: { /* n:\"Compat12\", */ f:parsebool, r:12 },\n\t/*::[*/0x088d/*::]*/: { /* n:\"DXF\", */ },\n\t/*::[*/0x088e/*::]*/: { /* n:\"TableStyles\", */ r:12 },\n\t/*::[*/0x088f/*::]*/: { /* n:\"TableStyle\", */ },\n\t/*::[*/0x0890/*::]*/: { /* n:\"TableStyleElement\", */ },\n\t/*::[*/0x0892/*::]*/: { /* n:\"StyleExt\", */ },\n\t/*::[*/0x0893/*::]*/: { /* n:\"NamePublish\", */ },\n\t/*::[*/0x0894/*::]*/: { /* n:\"NameCmt\", */ f:parse_NameCmt, r:12 },\n\t/*::[*/0x0895/*::]*/: { /* n:\"SortData\", */ },\n\t/*::[*/0x0896/*::]*/: { /* n:\"Theme\", */ f:parse_Theme, r:12 },\n\t/*::[*/0x0897/*::]*/: { /* n:\"GUIDTypeLib\", */ },\n\t/*::[*/0x0898/*::]*/: { /* n:\"FnGrp12\", */ },\n\t/*::[*/0x0899/*::]*/: { /* n:\"NameFnGrp12\", */ },\n\t/*::[*/0x089a/*::]*/: { /* n:\"MTRSettings\", */ f:parse_MTRSettings, r:12 },\n\t/*::[*/0x089b/*::]*/: { /* n:\"CompressPictures\", */ f:parsenoop2 },\n\t/*::[*/0x089c/*::]*/: { /* n:\"HeaderFooter\", */ },\n\t/*::[*/0x089d/*::]*/: { /* n:\"CrtLayout12\", */ },\n\t/*::[*/0x089e/*::]*/: { /* n:\"CrtMlFrt\", */ },\n\t/*::[*/0x089f/*::]*/: { /* n:\"CrtMlFrtContinue\", */ },\n\t/*::[*/0x08a3/*::]*/: { /* n:\"ForceFullCalculation\", */ f:parse_ForceFullCalculation },\n\t/*::[*/0x08a4/*::]*/: { /* n:\"ShapePropsStream\", */ },\n\t/*::[*/0x08a5/*::]*/: { /* n:\"TextPropsStream\", */ },\n\t/*::[*/0x08a6/*::]*/: { /* n:\"RichTextStream\", */ },\n\t/*::[*/0x08a7/*::]*/: { /* n:\"CrtLayout12A\", */ },\n\t/*::[*/0x1001/*::]*/: { /* n:\"Units\", */ },\n\t/*::[*/0x1002/*::]*/: { /* n:\"Chart\", */ },\n\t/*::[*/0x1003/*::]*/: { /* n:\"Series\", */ },\n\t/*::[*/0x1006/*::]*/: { /* n:\"DataFormat\", */ },\n\t/*::[*/0x1007/*::]*/: { /* n:\"LineFormat\", */ },\n\t/*::[*/0x1009/*::]*/: { /* n:\"MarkerFormat\", */ },\n\t/*::[*/0x100a/*::]*/: { /* n:\"AreaFormat\", */ },\n\t/*::[*/0x100b/*::]*/: { /* n:\"PieFormat\", */ },\n\t/*::[*/0x100c/*::]*/: { /* n:\"AttachedLabel\", */ },\n\t/*::[*/0x100d/*::]*/: { /* n:\"SeriesText\", */ },\n\t/*::[*/0x1014/*::]*/: { /* n:\"ChartFormat\", */ },\n\t/*::[*/0x1015/*::]*/: { /* n:\"Legend\", */ },\n\t/*::[*/0x1016/*::]*/: { /* n:\"SeriesList\", */ },\n\t/*::[*/0x1017/*::]*/: { /* n:\"Bar\", */ },\n\t/*::[*/0x1018/*::]*/: { /* n:\"Line\", */ },\n\t/*::[*/0x1019/*::]*/: { /* n:\"Pie\", */ },\n\t/*::[*/0x101a/*::]*/: { /* n:\"Area\", */ },\n\t/*::[*/0x101b/*::]*/: { /* n:\"Scatter\", */ },\n\t/*::[*/0x101c/*::]*/: { /* n:\"CrtLine\", */ },\n\t/*::[*/0x101d/*::]*/: { /* n:\"Axis\", */ },\n\t/*::[*/0x101e/*::]*/: { /* n:\"Tick\", */ },\n\t/*::[*/0x101f/*::]*/: { /* n:\"ValueRange\", */ },\n\t/*::[*/0x1020/*::]*/: { /* n:\"CatSerRange\", */ },\n\t/*::[*/0x1021/*::]*/: { /* n:\"AxisLine\", */ },\n\t/*::[*/0x1022/*::]*/: { /* n:\"CrtLink\", */ },\n\t/*::[*/0x1024/*::]*/: { /* n:\"DefaultText\", */ },\n\t/*::[*/0x1025/*::]*/: { /* n:\"Text\", */ },\n\t/*::[*/0x1026/*::]*/: { /* n:\"FontX\", */ f:parseuint16 },\n\t/*::[*/0x1027/*::]*/: { /* n:\"ObjectLink\", */ },\n\t/*::[*/0x1032/*::]*/: { /* n:\"Frame\", */ },\n\t/*::[*/0x1033/*::]*/: { /* n:\"Begin\", */ },\n\t/*::[*/0x1034/*::]*/: { /* n:\"End\", */ },\n\t/*::[*/0x1035/*::]*/: { /* n:\"PlotArea\", */ },\n\t/*::[*/0x103a/*::]*/: { /* n:\"Chart3d\", */ },\n\t/*::[*/0x103c/*::]*/: { /* n:\"PicF\", */ },\n\t/*::[*/0x103d/*::]*/: { /* n:\"DropBar\", */ },\n\t/*::[*/0x103e/*::]*/: { /* n:\"Radar\", */ },\n\t/*::[*/0x103f/*::]*/: { /* n:\"Surf\", */ },\n\t/*::[*/0x1040/*::]*/: { /* n:\"RadarArea\", */ },\n\t/*::[*/0x1041/*::]*/: { /* n:\"AxisParent\", */ },\n\t/*::[*/0x1043/*::]*/: { /* n:\"LegendException\", */ },\n\t/*::[*/0x1044/*::]*/: { /* n:\"ShtProps\", */ f:parse_ShtProps },\n\t/*::[*/0x1045/*::]*/: { /* n:\"SerToCrt\", */ },\n\t/*::[*/0x1046/*::]*/: { /* n:\"AxesUsed\", */ },\n\t/*::[*/0x1048/*::]*/: { /* n:\"SBaseRef\", */ },\n\t/*::[*/0x104a/*::]*/: { /* n:\"SerParent\", */ },\n\t/*::[*/0x104b/*::]*/: { /* n:\"SerAuxTrend\", */ },\n\t/*::[*/0x104e/*::]*/: { /* n:\"IFmtRecord\", */ },\n\t/*::[*/0x104f/*::]*/: { /* n:\"Pos\", */ },\n\t/*::[*/0x1050/*::]*/: { /* n:\"AlRuns\", */ },\n\t/*::[*/0x1051/*::]*/: { /* n:\"BRAI\", */ },\n\t/*::[*/0x105b/*::]*/: { /* n:\"SerAuxErrBar\", */ },\n\t/*::[*/0x105c/*::]*/: { /* n:\"ClrtClient\", */ f:parse_ClrtClient },\n\t/*::[*/0x105d/*::]*/: { /* n:\"SerFmt\", */ },\n\t/*::[*/0x105f/*::]*/: { /* n:\"Chart3DBarShape\", */ },\n\t/*::[*/0x1060/*::]*/: { /* n:\"Fbi\", */ },\n\t/*::[*/0x1061/*::]*/: { /* n:\"BopPop\", */ },\n\t/*::[*/0x1062/*::]*/: { /* n:\"AxcExt\", */ },\n\t/*::[*/0x1063/*::]*/: { /* n:\"Dat\", */ },\n\t/*::[*/0x1064/*::]*/: { /* n:\"PlotGrowth\", */ },\n\t/*::[*/0x1065/*::]*/: { /* n:\"SIIndex\", */ },\n\t/*::[*/0x1066/*::]*/: { /* n:\"GelFrame\", */ },\n\t/*::[*/0x1067/*::]*/: { /* n:\"BopPopCustom\", */ },\n\t/*::[*/0x1068/*::]*/: { /* n:\"Fbi2\", */ },\n\n\t/*::[*/0x0000/*::]*/: { /* n:\"Dimensions\", */ f:parse_Dimensions },\n\t/*::[*/0x0001/*::]*/: { /* n:\"BIFF2BLANK\", */ },\n\t/*::[*/0x0002/*::]*/: { /* n:\"BIFF2INT\", */ f:parse_BIFF2INT },\n\t/*::[*/0x0003/*::]*/: { /* n:\"BIFF2NUM\", */ f:parse_BIFF2NUM },\n\t/*::[*/0x0004/*::]*/: { /* n:\"BIFF2STR\", */ f:parse_BIFF2STR },\n\t/*::[*/0x0005/*::]*/: { /* n:\"BoolErr\", */ f:parse_BoolErr },\n\t/*::[*/0x0007/*::]*/: { /* n:\"String\", */ f:parse_BIFF2STRING },\n\t/*::[*/0x0008/*::]*/: { /* n:\"BIFF2ROW\", */ },\n\t/*::[*/0x0009/*::]*/: { /* n:\"BOF\", */ f:parse_BOF },\n\t/*::[*/0x000b/*::]*/: { /* n:\"Index\", */ },\n\t/*::[*/0x0016/*::]*/: { /* n:\"ExternCount\", */ f:parseuint16 },\n\t/*::[*/0x001e/*::]*/: { /* n:\"BIFF2FORMAT\", */ f:parse_BIFF2Format },\n\t/*::[*/0x001f/*::]*/: { /* n:\"BIFF2FMTCNT\", */ }, /* 16-bit cnt of BIFF2FORMAT records */\n\t/*::[*/0x0020/*::]*/: { /* n:\"BIFF2COLINFO\", */ },\n\t/*::[*/0x0021/*::]*/: { /* n:\"Array\", */ f:parse_Array },\n\t/*::[*/0x0024/*::]*/: { /* n:\"COLWIDTH\", */ },\n\t/*::[*/0x0025/*::]*/: { /* n:\"DefaultRowHeight\", */ f:parse_DefaultRowHeight },\n\t// 0x2c ??\n\t// 0x2d ??\n\t// 0x2e ??\n\t// 0x30 FONTCOUNT: number of fonts\n\t/*::[*/0x0032/*::]*/: { /* n:\"BIFF2FONTXTRA\", */ f:parse_BIFF2FONTXTRA },\n\t// 0x35: INFOOPTS\n\t// 0x36: TABLE (BIFF2 only)\n\t// 0x37: TABLE2 (BIFF2 only)\n\t// 0x38: WNDESK\n\t// 0x39 ??\n\t// 0x3a: BEGINPREF\n\t// 0x3b: ENDPREF\n\t/*::[*/0x003e/*::]*/: { /* n:\"BIFF2WINDOW2\", */ },\n\t// 0x3f ??\n\t// 0x46: SHOWSCROLL\n\t// 0x47: SHOWFORMULA\n\t// 0x48: STATUSBAR\n\t// 0x49: SHORTMENUS\n\t// 0x4A:\n\t// 0x4B:\n\t// 0x4C:\n\t// 0x4E:\n\t// 0x4F:\n\t// 0x58: TOOLBAR (BIFF3)\n\n\t/* - - - */\n\t/*::[*/0x0034/*::]*/: { /* n:\"DDEObjName\", */ },\n\t/*::[*/0x0043/*::]*/: { /* n:\"BIFF2XF\", */ },\n\t/*::[*/0x0044/*::]*/: { /* n:\"BIFF2XFINDEX\", */ f:parseuint16 },\n\t/*::[*/0x0045/*::]*/: { /* n:\"BIFF2FONTCLR\", */ },\n\t/*::[*/0x0056/*::]*/: { /* n:\"BIFF4FMTCNT\", */ }, /* 16-bit cnt, similar to BIFF2 */\n\t/*::[*/0x007e/*::]*/: { /* n:\"RK\", */ }, /* Not necessarily same as 0x027e */\n\t/*::[*/0x007f/*::]*/: { /* n:\"ImData\", */ f:parse_ImData },\n\t/*::[*/0x0087/*::]*/: { /* n:\"Addin\", */ },\n\t/*::[*/0x0088/*::]*/: { /* n:\"Edg\", */ },\n\t/*::[*/0x0089/*::]*/: { /* n:\"Pub\", */ },\n\t// 0x8A\n\t// 0x8B LH: alternate menu key flag (BIFF3/4)\n\t// 0x8E\n\t// 0x8F\n\t/*::[*/0x0091/*::]*/: { /* n:\"Sub\", */ },\n\t// 0x93 STYLE\n\t/*::[*/0x0094/*::]*/: { /* n:\"LHRecord\", */ },\n\t/*::[*/0x0095/*::]*/: { /* n:\"LHNGraph\", */ },\n\t/*::[*/0x0096/*::]*/: { /* n:\"Sound\", */ },\n\t// 0xA2 FNPROTO: function prototypes (BIFF4)\n\t// 0xA3\n\t// 0xA8\n\t/*::[*/0x00a9/*::]*/: { /* n:\"CoordList\", */ },\n\t/*::[*/0x00ab/*::]*/: { /* n:\"GCW\", */ },\n\t/*::[*/0x00bc/*::]*/: { /* n:\"ShrFmla\", */ }, /* Not necessarily same as 0x04bc */\n\t/*::[*/0x00bf/*::]*/: { /* n:\"ToolbarHdr\", */ },\n\t/*::[*/0x00c0/*::]*/: { /* n:\"ToolbarEnd\", */ },\n\t/*::[*/0x00c2/*::]*/: { /* n:\"AddMenu\", */ },\n\t/*::[*/0x00c3/*::]*/: { /* n:\"DelMenu\", */ },\n\t/*::[*/0x00d6/*::]*/: { /* n:\"RString\", */ f:parse_RString },\n\t/*::[*/0x00df/*::]*/: { /* n:\"UDDesc\", */ },\n\t/*::[*/0x00ea/*::]*/: { /* n:\"TabIdConf\", */ },\n\t/*::[*/0x0162/*::]*/: { /* n:\"XL5Modify\", */ },\n\t/*::[*/0x01a5/*::]*/: { /* n:\"FileSharing2\", */ },\n\t/*::[*/0x0206/*::]*/: { /* n:\"Formula\", */ f:parse_Formula },\n\t/*::[*/0x0209/*::]*/: { /* n:\"BOF\", */ f:parse_BOF },\n\t/*::[*/0x0218/*::]*/: { /* n:\"Lbl\", */ f:parse_Lbl },\n\t/*::[*/0x0223/*::]*/: { /* n:\"ExternName\", */ f:parse_ExternName },\n\t/*::[*/0x0231/*::]*/: { /* n:\"Font\", */ },\n\t/*::[*/0x0243/*::]*/: { /* n:\"BIFF3XF\", */ },\n\t/*::[*/0x0406/*::]*/: { /* n:\"Formula\", */ f:parse_Formula },\n\t/*::[*/0x0409/*::]*/: { /* n:\"BOF\", */ f:parse_BOF },\n\t/*::[*/0x0443/*::]*/: { /* n:\"BIFF4XF\", */ },\n\t/*::[*/0x086d/*::]*/: { /* n:\"FeatInfo\", */ },\n\t/*::[*/0x0873/*::]*/: { /* n:\"FeatInfo11\", */ },\n\t/*::[*/0x0881/*::]*/: { /* n:\"SXAddl12\", */ },\n\t/*::[*/0x08c0/*::]*/: { /* n:\"AutoWebPub\", */ },\n\t/*::[*/0x08c1/*::]*/: { /* n:\"ListObj\", */ },\n\t/*::[*/0x08c2/*::]*/: { /* n:\"ListField\", */ },\n\t/*::[*/0x08c3/*::]*/: { /* n:\"ListDV\", */ },\n\t/*::[*/0x08c4/*::]*/: { /* n:\"ListCondFmt\", */ },\n\t/*::[*/0x08c5/*::]*/: { /* n:\"ListCF\", */ },\n\t/*::[*/0x08c6/*::]*/: { /* n:\"FMQry\", */ },\n\t/*::[*/0x08c7/*::]*/: { /* n:\"FMSQry\", */ },\n\t/*::[*/0x08c8/*::]*/: { /* n:\"PLV\", */ },\n\t/*::[*/0x08c9/*::]*/: { /* n:\"LnExt\", */ },\n\t/*::[*/0x08ca/*::]*/: { /* n:\"MkrExt\", */ },\n\t/*::[*/0x08cb/*::]*/: { /* n:\"CrtCoopt\", */ },\n\t/*::[*/0x08d6/*::]*/: { /* n:\"FRTArchId$\", */ r:12 },\n\n\t/*::[*/0x7262/*::]*/: {}\n};\n\nfunction write_biff_rec(ba/*:BufArray*/, type/*:number*/, payload, length/*:?number*/)/*:void*/ {\n\tvar t/*:number*/ = type;\n\tif(isNaN(t)) return;\n\tvar len = length || (payload||[]).length || 0;\n\tvar o = ba.next(4);\n\to.write_shift(2, t);\n\to.write_shift(2, len);\n\tif(/*:: len != null &&*/len > 0 && is_buf(payload)) ba.push(payload);\n}\n\nfunction write_biff_continue(ba/*:BufArray*/, type/*:number*/, payload, length/*:?number*/)/*:void*/ {\n\tvar len = length || (payload||[]).length || 0;\n\tif(len <= 8224) return write_biff_rec(ba, type, payload, len);\n\tvar t = type;\n\tif(isNaN(t)) return;\n\tvar parts = payload.parts || [], sidx = 0;\n\tvar i = 0, w = 0;\n\twhile(w + (parts[sidx] || 8224) <= 8224) { w+= (parts[sidx] || 8224); sidx++; }\n\tvar o = ba.next(4);\n\to.write_shift(2, t);\n\to.write_shift(2, w);\n\tba.push(payload.slice(i, i + w));\n\ti += w;\n\twhile(i < len) {\n\t\to = ba.next(4);\n\t\to.write_shift(2, 0x3c); // TODO: figure out correct continue type\n\t\tw = 0;\n\t\twhile(w + (parts[sidx] || 8224) <= 8224) { w+= (parts[sidx] || 8224); sidx++; }\n\t\to.write_shift(2, w);\n\t\tba.push(payload.slice(i, i+w)); i+= w;\n\t}\n}\n\nfunction write_BIFF2Cell(out, r/*:number*/, c/*:number*/) {\n\tif(!out) out = new_buf(7);\n\tout.write_shift(2, r);\n\tout.write_shift(2, c);\n\tout.write_shift(2, 0);\n\tout.write_shift(1, 0);\n\treturn out;\n}\n\nfunction write_BIFF2BERR(r/*:number*/, c/*:number*/, val, t/*:?string*/) {\n\tvar out = new_buf(9);\n\twrite_BIFF2Cell(out, r, c);\n\twrite_Bes(val, t || 'b', out);\n\treturn out;\n}\n\n/* TODO: codepage, large strings */\nfunction write_BIFF2LABEL(r/*:number*/, c/*:number*/, val) {\n\tvar out = new_buf(8 + 2*val.length);\n\twrite_BIFF2Cell(out, r, c);\n\tout.write_shift(1, val.length);\n\tout.write_shift(val.length, val, 'sbcs');\n\treturn out.l < out.length ? out.slice(0, out.l) : out;\n}\n\nfunction write_ws_biff2_cell(ba/*:BufArray*/, cell/*:Cell*/, R/*:number*/, C/*:number*//*::, opts*/) {\n\tif(cell.v != null) switch(cell.t) {\n\t\tcase 'd': case 'n':\n\t\t\tvar v = cell.t == 'd' ? datenum(parseDate(cell.v)) : cell.v;\n\t\t\tif((v == (v|0)) && (v >= 0) && (v < 65536))\n\t\t\t\twrite_biff_rec(ba, 0x0002, write_BIFF2INT(R, C, v));\n\t\t\telse\n\t\t\t\twrite_biff_rec(ba, 0x0003, write_BIFF2NUM(R,C, v));\n\t\t\treturn;\n\t\tcase 'b': case 'e': write_biff_rec(ba, 0x0005, write_BIFF2BERR(R, C, cell.v, cell.t)); return;\n\t\t/* TODO: codepage, sst */\n\t\tcase 's': case 'str':\n\t\t\twrite_biff_rec(ba, 0x0004, write_BIFF2LABEL(R, C, (cell.v||\"\").slice(0,255)));\n\t\t\treturn;\n\t}\n\twrite_biff_rec(ba, 0x0001, write_BIFF2Cell(null, R, C));\n}\n\nfunction write_ws_biff2(ba/*:BufArray*/, ws/*:Worksheet*/, idx/*:number*/, opts/*::, wb:Workbook*/) {\n\tvar dense = Array.isArray(ws);\n\tvar range = safe_decode_range(ws['!ref'] || \"A1\"), ref/*:string*/, rr = \"\", cols/*:Array*/ = [];\n\tif(range.e.c > 0xFF || range.e.r > 0x3FFF) {\n\t\tif(opts.WTF) throw new Error(\"Range \" + (ws['!ref'] || \"A1\") + \" exceeds format limit A1:IV16384\");\n\t\trange.e.c = Math.min(range.e.c, 0xFF);\n\t\trange.e.r = Math.min(range.e.c, 0x3FFF);\n\t\tref = encode_range(range);\n\t}\n\tfor(var R = range.s.r; R <= range.e.r; ++R) {\n\t\trr = encode_row(R);\n\t\tfor(var C = range.s.c; C <= range.e.c; ++C) {\n\t\t\tif(R === range.s.r) cols[C] = encode_col(C);\n\t\t\tref = cols[C] + rr;\n\t\t\tvar cell = dense ? (ws[R]||[])[C] : ws[ref];\n\t\t\tif(!cell) continue;\n\t\t\t/* write cell */\n\t\t\twrite_ws_biff2_cell(ba, cell, R, C, opts);\n\t\t}\n\t}\n}\n\n/* Based on test files */\nfunction write_biff2_buf(wb/*:Workbook*/, opts/*:WriteOpts*/) {\n\tvar o = opts || {};\n\tif(DENSE != null && o.dense == null) o.dense = DENSE;\n\tvar ba = buf_array();\n\tvar idx = 0;\n\tfor(var i=0;i*/ = [];\n\tvar range = safe_decode_range(ws['!ref'] || \"A1\");\n\tvar MAX_ROWS = b8 ? 65536 : 16384;\n\tif(range.e.c > 0xFF || range.e.r >= MAX_ROWS) {\n\t\tif(opts.WTF) throw new Error(\"Range \" + (ws['!ref'] || \"A1\") + \" exceeds format limit A1:IV16384\");\n\t\trange.e.c = Math.min(range.e.c, 0xFF);\n\t\trange.e.r = Math.min(range.e.c, MAX_ROWS-1);\n\t}\n\n\twrite_biff_rec(ba, 0x0809, write_BOF(wb, 0x10, opts));\n\t/* [Uncalced] Index */\n\twrite_biff_rec(ba, 0x000d /* CalcMode */, writeuint16(1));\n\twrite_biff_rec(ba, 0x000c /* CalcCount */, writeuint16(100));\n\twrite_biff_rec(ba, 0x000f /* CalcRefMode */, writebool(true));\n\twrite_biff_rec(ba, 0x0011 /* CalcIter */, writebool(false));\n\twrite_biff_rec(ba, 0x0010 /* CalcDelta */, write_Xnum(0.001));\n\twrite_biff_rec(ba, 0x005f /* CalcSaveRecalc */, writebool(true));\n\twrite_biff_rec(ba, 0x002a /* PrintRowCol */, writebool(false));\n\twrite_biff_rec(ba, 0x002b /* PrintGrid */, writebool(false));\n\twrite_biff_rec(ba, 0x0082 /* GridSet */, writeuint16(1));\n\twrite_biff_rec(ba, 0x0080 /* Guts */, write_Guts([0,0]));\n\t/* DefaultRowHeight WsBool [Sync] [LPr] [HorizontalPageBreaks] [VerticalPageBreaks] */\n\t/* Header (string) */\n\t/* Footer (string) */\n\twrite_biff_rec(ba, 0x0083 /* HCenter */, writebool(false));\n\twrite_biff_rec(ba, 0x0084 /* VCenter */, writebool(false));\n\t/* ... */\n\tif(b8) write_ws_cols_biff8(ba, ws[\"!cols\"]);\n\t/* ... */\n\twrite_biff_rec(ba, 0x200, write_Dimensions(range, opts));\n\t/* ... */\n\n\tif(b8) ws['!links'] = [];\n\tfor(var R = range.s.r; R <= range.e.r; ++R) {\n\t\trr = encode_row(R);\n\t\tfor(var C = range.s.c; C <= range.e.c; ++C) {\n\t\t\tif(R === range.s.r) cols[C] = encode_col(C);\n\t\t\tref = cols[C] + rr;\n\t\t\tvar cell = dense ? (ws[R]||[])[C] : ws[ref];\n\t\t\tif(!cell) continue;\n\t\t\t/* write cell */\n\t\t\twrite_ws_biff8_cell(ba, cell, R, C, opts);\n\t\t\tif(b8 && cell.l) ws['!links'].push([ref, cell.l]);\n\t\t}\n\t}\n\tvar cname/*:string*/ = _sheet.CodeName || _sheet.name || s;\n\t/* ... */\n\tif(b8) write_biff_rec(ba, 0x023e /* Window2 */, write_Window2((_WB.Views||[])[0]));\n\t/* ... */\n\tif(b8 && (ws['!merges']||[]).length) write_biff_rec(ba, 0x00e5 /* MergeCells */, write_MergeCells(ws['!merges']));\n\t/* [LRng] *QUERYTABLE [PHONETICINFO] CONDFMTS */\n\tif(b8) write_ws_biff8_hlinks(ba, ws);\n\t/* [DVAL] */\n\twrite_biff_rec(ba, 0x01ba /* CodeName */, write_XLUnicodeString(cname, opts));\n\t/* *WebPub *CellWatch [SheetExt] */\n\tif(b8) write_FEAT(ba, ws);\n\t/* *FEAT11 *RECORD12 */\n\twrite_biff_rec(ba, 0x000a /* EOF */);\n\treturn ba.end();\n}\n\n/* [MS-XLS] 2.1.7.20.3 */\nfunction write_biff8_global(wb/*:Workbook*/, bufs, opts/*:WriteOpts*/) {\n\tvar A = buf_array();\n\tvar _WB/*:WBWBProps*/ = ((wb||{}).Workbook||{}/*:any*/);\n\tvar _sheets/*:Array*/ = (_WB.Sheets||[]);\n\tvar _wb/*:WBProps*/ = /*::((*/_WB.WBProps||{/*::CodeName:\"ThisWorkbook\"*/}/*:: ):any)*/;\n\tvar b8 = opts.biff == 8, b5 = opts.biff == 5;\n\twrite_biff_rec(A, 0x0809, write_BOF(wb, 0x05, opts));\n\tif(opts.bookType == \"xla\") write_biff_rec(A, 0x0087 /* Addin */);\n\twrite_biff_rec(A, 0x00e1 /* InterfaceHdr */, b8 ? writeuint16(0x04b0) : null);\n\twrite_biff_rec(A, 0x00c1 /* Mms */, writezeroes(2));\n\tif(b5) write_biff_rec(A, 0x00bf /* ToolbarHdr */);\n\tif(b5) write_biff_rec(A, 0x00c0 /* ToolbarEnd */);\n\twrite_biff_rec(A, 0x00e2 /* InterfaceEnd */);\n\twrite_biff_rec(A, 0x005c /* WriteAccess */, write_WriteAccess(\"SheetJS\", opts));\n\t/* [FileSharing] */\n\twrite_biff_rec(A, 0x0042 /* CodePage */, writeuint16(b8 ? 0x04b0 : 0x04E4));\n\t/* *2047 Lel */\n\tif(b8) write_biff_rec(A, 0x0161 /* DSF */, writeuint16(0));\n\tif(b8) write_biff_rec(A, 0x01c0 /* Excel9File */);\n\twrite_biff_rec(A, 0x013d /* RRTabId */, write_RRTabId(wb.SheetNames.length));\n\tif(b8 && wb.vbaraw) write_biff_rec(A, 0x00d3 /* ObProj */);\n\t/* [ObNoMacros] */\n\tif(b8 && wb.vbaraw) {\n\t\tvar cname/*:string*/ = _wb.CodeName || \"ThisWorkbook\";\n\t\twrite_biff_rec(A, 0x01ba /* CodeName */, write_XLUnicodeString(cname, opts));\n\t}\n\twrite_biff_rec(A, 0x009c /* BuiltInFnGroupCount */, writeuint16(0x11));\n\t/* *FnGroupName *FnGrp12 */\n\t/* *Lbl */\n\t/* [OleObjectSize] */\n\twrite_biff_rec(A, 0x0019 /* WinProtect */, writebool(false));\n\twrite_biff_rec(A, 0x0012 /* Protect */, writebool(false));\n\twrite_biff_rec(A, 0x0013 /* Password */, writeuint16(0));\n\tif(b8) write_biff_rec(A, 0x01af /* Prot4Rev */, writebool(false));\n\tif(b8) write_biff_rec(A, 0x01bc /* Prot4RevPass */, writeuint16(0));\n\twrite_biff_rec(A, 0x003d /* Window1 */, write_Window1(opts));\n\twrite_biff_rec(A, 0x0040 /* Backup */, writebool(false));\n\twrite_biff_rec(A, 0x008d /* HideObj */, writeuint16(0));\n\twrite_biff_rec(A, 0x0022 /* Date1904 */, writebool(safe1904(wb)==\"true\"));\n\twrite_biff_rec(A, 0x000e /* CalcPrecision */, writebool(true));\n\tif(b8) write_biff_rec(A, 0x01b7 /* RefreshAll */, writebool(false));\n\twrite_biff_rec(A, 0x00DA /* BookBool */, writeuint16(0));\n\t/* ... */\n\twrite_FONTS_biff8(A, wb, opts);\n\twrite_FMTS_biff8(A, wb.SSF, opts);\n\twrite_CELLXFS_biff8(A, opts);\n\t/* ... */\n\tif(b8) write_biff_rec(A, 0x0160 /* UsesELFs */, writebool(false));\n\tvar a = A.end();\n\n\tvar C = buf_array();\n\t/* METADATA [MTRSettings] [ForceFullCalculation] */\n\tif(b8) write_biff_rec(C, 0x008C, write_Country());\n\t/* *SUPBOOK *LBL *RTD [RecalcId] *HFPicture *MSODRAWINGGROUP */\n\n\t/* BIFF8: [SST *Continue] ExtSST */\n\tif(b8 && opts.Strings) write_biff_continue(C, 0x00FC, write_SST(opts.Strings, opts));\n\n\t/* *WebPub [WOpt] [CrErr] [BookExt] *FeatHdr *DConn [THEME] [CompressPictures] [Compat12] [GUIDTypeLib] */\n\twrite_biff_rec(C, 0x000A /* EOF */);\n\tvar c = C.end();\n\n\tvar B = buf_array();\n\tvar blen = 0, j = 0;\n\tfor(j = 0; j < wb.SheetNames.length; ++j) blen += (b8 ? 12 : 11) + (b8 ? 2 : 1) * wb.SheetNames[j].length;\n\tvar start = a.length + blen + c.length;\n\tfor(j = 0; j < wb.SheetNames.length; ++j) {\n\t\tvar _sheet/*:WBWSProp*/ = _sheets[j] || ({}/*:any*/);\n\t\twrite_biff_rec(B, 0x0085 /* BoundSheet8 */, write_BoundSheet8({pos:start, hs:_sheet.Hidden||0, dt:0, name:wb.SheetNames[j]}, opts));\n\t\tstart += bufs[j].length;\n\t}\n\t/* 1*BoundSheet8 */\n\tvar b = B.end();\n\tif(blen != b.length) throw new Error(\"BS8 \" + blen + \" != \" + b.length);\n\n\tvar out = [];\n\tif(a.length) out.push(a);\n\tif(b.length) out.push(b);\n\tif(c.length) out.push(c);\n\treturn bconcat(out);\n}\n\n/* [MS-XLS] 2.1.7.20 Workbook Stream */\nfunction write_biff8_buf(wb/*:Workbook*/, opts/*:WriteOpts*/) {\n\tvar o = opts || {};\n\tvar bufs = [];\n\n\tif(wb && !wb.SSF) {\n\t\twb.SSF = dup(table_fmt);\n\t}\n\tif(wb && wb.SSF) {\n\t\tmake_ssf(); SSF_load_table(wb.SSF);\n\t\t// $FlowIgnore\n\t\to.revssf = evert_num(wb.SSF); o.revssf[wb.SSF[65535]] = 0;\n\t\to.ssf = wb.SSF;\n\t}\n\n\to.Strings = /*::((*/[]/*:: :any):SST)*/; o.Strings.Count = 0; o.Strings.Unique = 0;\n\tfix_write_opts(o);\n\n\to.cellXfs = [];\n\tget_cell_style(o.cellXfs, {}, {revssf:{\"General\":0}});\n\n\tif(!wb.Props) wb.Props = {};\n\n\tfor(var i = 0; i < wb.SheetNames.length; ++i) bufs[bufs.length] = write_ws_biff8(i, o, wb);\n\tbufs.unshift(write_biff8_global(wb, bufs, o));\n\treturn bconcat(bufs);\n}\n\nfunction write_biff_buf(wb/*:Workbook*/, opts/*:WriteOpts*/) {\n\tfor(var i = 0; i <= wb.SheetNames.length; ++i) {\n\t\tvar ws = wb.Sheets[wb.SheetNames[i]];\n\t\tif(!ws || !ws[\"!ref\"]) continue;\n\t\tvar range = decode_range(ws[\"!ref\"]);\n\t\tif(range.e.c > 255) { // note: 255 is IV\n\t\tif(typeof console != \"undefined\" && console.error) console.error(\"Worksheet '\" + wb.SheetNames[i] + \"' extends beyond column IV (255). Data may be lost.\");\n\t\t}\n\t}\n\n\tvar o = opts || {};\n\tswitch(o.biff || 2) {\n\t\tcase 8: case 5: return write_biff8_buf(wb, opts);\n\t\tcase 4: case 3: case 2: return write_biff2_buf(wb, opts);\n\t}\n\tthrow new Error(\"invalid type \" + o.bookType + \" for BIFF\");\n}\n/* note: browser DOM element cannot see mso- style attrs, must parse */\nfunction html_to_sheet(str/*:string*/, _opts)/*:Workbook*/ {\n\tvar opts = _opts || {};\n\tif(DENSE != null && opts.dense == null) opts.dense = DENSE;\n\tvar ws/*:Worksheet*/ = opts.dense ? ([]/*:any*/) : ({}/*:any*/);\n\tstr = str.replace(//g, \"\");\n\tvar mtch/*:any*/ = str.match(/\");\n\tvar mtch2/*:any*/ = str.match(/<\\/table/i);\n\tvar i/*:number*/ = mtch.index, j/*:number*/ = mtch2 && mtch2.index || str.length;\n\tvar rows = split_regex(str.slice(i, j), /(:?]*>)/i, \"\");\n\tvar R = -1, C = 0, RS = 0, CS = 0;\n\tvar range/*:Range*/ = {s:{r:10000000, c:10000000},e:{r:0,c:0}};\n\tvar merges/*:Array*/ = [];\n\tfor(i = 0; i < rows.length; ++i) {\n\t\tvar row = rows[i].trim();\n\t\tvar hd = row.slice(0,3).toLowerCase();\n\t\tif(hd == \"/i);\n\t\tfor(j = 0; j < cells.length; ++j) {\n\t\t\tvar cell = cells[j].trim();\n\t\t\tif(!cell.match(/\")) > -1) m = m.slice(cc+1);\n\t\t\tfor(var midx = 0; midx < merges.length; ++midx) {\n\t\t\t\tvar _merge/*:Range*/ = merges[midx];\n\t\t\t\tif(_merge.s.c == C && _merge.s.r < R && R <= _merge.e.r) { C = _merge.e.c + 1; midx = -1; }\n\t\t\t}\n\t\t\tvar tag = parsexmltag(cell.slice(0, cell.indexOf(\">\")));\n\t\t\tCS = tag.colspan ? +tag.colspan : 1;\n\t\t\tif((RS = +tag.rowspan)>1 || CS>1) merges.push({s:{r:R,c:C},e:{r:R + (RS||1) - 1, c:C + CS - 1}});\n\t\t\tvar _t/*:string*/ = tag.t || tag[\"data-t\"] || \"\";\n\t\t\t/* TODO: generate stub cells */\n\t\t\tif(!m.length) { C += CS; continue; }\n\t\t\tm = htmldecode(m);\n\t\t\tif(range.s.r > R) range.s.r = R; if(range.e.r < R) range.e.r = R;\n\t\t\tif(range.s.c > C) range.s.c = C; if(range.e.c < C) range.e.c = C;\n\t\t\tif(!m.length) { C += CS; continue; }\n\t\t\tvar o/*:Cell*/ = {t:'s', v:m};\n\t\t\tif(opts.raw || !m.trim().length || _t == 's'){}\n\t\t\telse if(m === 'TRUE') o = {t:'b', v:true};\n\t\t\telse if(m === 'FALSE') o = {t:'b', v:false};\n\t\t\telse if(!isNaN(fuzzynum(m))) o = {t:'n', v:fuzzynum(m)};\n\t\t\telse if(!isNaN(fuzzydate(m).getDate())) {\n\t\t\t\to = ({t:'d', v:parseDate(m)}/*:any*/);\n\t\t\t\tif(!opts.cellDates) o = ({t:'n', v:datenum(o.v)}/*:any*/);\n\t\t\t\to.z = opts.dateNF || table_fmt[14];\n\t\t\t}\n\t\t\tif(opts.dense) { if(!ws[R]) ws[R] = []; ws[R][C] = o; }\n\t\t\telse ws[encode_cell({r:R, c:C})] = o;\n\t\t\tC += CS;\n\t\t}\n\t}\n\tws['!ref'] = encode_range(range);\n\tif(merges.length) ws[\"!merges\"] = merges;\n\treturn ws;\n}\nfunction make_html_row(ws/*:Worksheet*/, r/*:Range*/, R/*:number*/, o/*:Sheet2HTMLOpts*/)/*:string*/ {\n\tvar M/*:Array*/ = (ws['!merges'] ||[]);\n\tvar oo/*:Array*/ = [];\n\tfor(var C = r.s.c; C <= r.e.c; ++C) {\n\t\tvar RS = 0, CS = 0;\n\t\tfor(var j = 0; j < M.length; ++j) {\n\t\t\tif(M[j].s.r > R || M[j].s.c > C) continue;\n\t\t\tif(M[j].e.r < R || M[j].e.c < C) continue;\n\t\t\tif(M[j].s.r < R || M[j].s.c < C) { RS = -1; break; }\n\t\t\tRS = M[j].e.r - M[j].s.r + 1; CS = M[j].e.c - M[j].s.c + 1; break;\n\t\t}\n\t\tif(RS < 0) continue;\n\t\tvar coord = encode_cell({r:R,c:C});\n\t\tvar cell = o.dense ? (ws[R]||[])[C] : ws[coord];\n\t\t/* TODO: html entities */\n\t\tvar w = (cell && cell.v != null) && (cell.h || escapehtml(cell.w || (format_cell(cell), cell.w) || \"\")) || \"\";\n\t\tvar sp = ({}/*:any*/);\n\t\tif(RS > 1) sp.rowspan = RS;\n\t\tif(CS > 1) sp.colspan = CS;\n\t\tif(o.editable) w = '' + w + '';\n\t\telse if(cell) {\n\t\t\tsp[\"data-t\"] = cell && cell.t || 'z';\n\t\t\tif(cell.v != null) sp[\"data-v\"] = cell.v;\n\t\t\tif(cell.z != null) sp[\"data-z\"] = cell.z;\n\t\t\tif(cell.l && (cell.l.Target || \"#\").charAt(0) != \"#\") w = '' + w + '';\n\t\t}\n\t\tsp.id = (o.id || \"sjs\") + \"-\" + coord;\n\t\too.push(writextag('td', w, sp));\n\t}\n\tvar preamble = \"\";\n\treturn preamble + oo.join(\"\") + \"\";\n}\n\nvar HTML_BEGIN = 'SheetJS Table Export';\nvar HTML_END = '';\n\nfunction html_to_workbook(str/*:string*/, opts)/*:Workbook*/ {\n\tvar mtch = str.match(/[\\s\\S]*?<\\/table>/gi);\n\tif(!mtch || mtch.length == 0) throw new Error(\"Invalid HTML: could not find
\");\n\tif(mtch.length == 1) return sheet_to_workbook(html_to_sheet(mtch[0], opts), opts);\n\tvar wb = book_new();\n\tmtch.forEach(function(s, idx) { book_append_sheet(wb, html_to_sheet(s, opts), \"Sheet\" + (idx+1)); });\n\treturn wb;\n}\n\nfunction make_html_preamble(ws/*:Worksheet*/, R/*:Range*/, o/*:Sheet2HTMLOpts*/)/*:string*/ {\n\tvar out/*:Array*/ = [];\n\treturn out.join(\"\") + '';\n}\n\nfunction sheet_to_html(ws/*:Worksheet*/, opts/*:?Sheet2HTMLOpts*//*, wb:?Workbook*/)/*:string*/ {\n\tvar o = opts || {};\n\tvar header = o.header != null ? o.header : HTML_BEGIN;\n\tvar footer = o.footer != null ? o.footer : HTML_END;\n\tvar out/*:Array*/ = [header];\n\tvar r = decode_range(ws['!ref']);\n\to.dense = Array.isArray(ws);\n\tout.push(make_html_preamble(ws, r, o));\n\tfor(var R = r.s.r; R <= r.e.r; ++R) out.push(make_html_row(ws, r, R, o));\n\tout.push(\"
\" + footer);\n\treturn out.join(\"\");\n}\n\nfunction sheet_add_dom(ws/*:Worksheet*/, table/*:HTMLElement*/, _opts/*:?any*/)/*:Worksheet*/ {\n\tvar opts = _opts || {};\n\tif(DENSE != null) opts.dense = DENSE;\n\tvar or_R = 0, or_C = 0;\n\tif(opts.origin != null) {\n\t\tif(typeof opts.origin == 'number') or_R = opts.origin;\n\t\telse {\n\t\t\tvar _origin/*:CellAddress*/ = typeof opts.origin == \"string\" ? decode_cell(opts.origin) : opts.origin;\n\t\t\tor_R = _origin.r; or_C = _origin.c;\n\t\t}\n\t}\n\n\tvar rows/*:HTMLCollection*/ = table.getElementsByTagName('tr');\n\tvar sheetRows = Math.min(opts.sheetRows||10000000, rows.length);\n\tvar range/*:Range*/ = {s:{r:0,c:0},e:{r:or_R,c:or_C}};\n\tif(ws[\"!ref\"]) {\n\t\tvar _range/*:Range*/ = decode_range(ws[\"!ref\"]);\n\t\trange.s.r = Math.min(range.s.r, _range.s.r);\n\t\trange.s.c = Math.min(range.s.c, _range.s.c);\n\t\trange.e.r = Math.max(range.e.r, _range.e.r);\n\t\trange.e.c = Math.max(range.e.c, _range.e.c);\n\t\tif(or_R == -1) range.e.r = or_R = _range.e.r + 1;\n\t}\n\tvar merges/*:Array*/ = [], midx = 0;\n\tvar rowinfo/*:Array*/ = ws[\"!rows\"] || (ws[\"!rows\"] = []);\n\tvar _R = 0, R = 0, _C = 0, C = 0, RS = 0, CS = 0;\n\tif(!ws[\"!cols\"]) ws['!cols'] = [];\n\tfor(; _R < rows.length && R < sheetRows; ++_R) {\n\t\tvar row/*:HTMLTableRowElement*/ = rows[_R];\n\t\tif (is_dom_element_hidden(row)) {\n\t\t\tif (opts.display) continue;\n\t\t\trowinfo[R] = {hidden: true};\n\t\t}\n\t\tvar elts/*:HTMLCollection*/ = (row.children/*:any*/);\n\t\tfor(_C = C = 0; _C < elts.length; ++_C) {\n\t\t\tvar elt/*:HTMLTableCellElement*/ = elts[_C];\n\t\t\tif (opts.display && is_dom_element_hidden(elt)) continue;\n\t\t\tvar v/*:?string*/ = elt.hasAttribute('data-v') ? elt.getAttribute('data-v') : elt.hasAttribute('v') ? elt.getAttribute('v') : htmldecode(elt.innerHTML);\n\t\t\tvar z/*:?string*/ = elt.getAttribute('data-z') || elt.getAttribute('z');\n\t\t\tfor(midx = 0; midx < merges.length; ++midx) {\n\t\t\t\tvar m/*:Range*/ = merges[midx];\n\t\t\t\tif(m.s.c == C + or_C && m.s.r < R + or_R && R + or_R <= m.e.r) { C = m.e.c+1 - or_C; midx = -1; }\n\t\t\t}\n\t\t\t/* TODO: figure out how to extract nonstandard mso- style */\n\t\t\tCS = +elt.getAttribute(\"colspan\") || 1;\n\t\t\tif( ((RS = (+elt.getAttribute(\"rowspan\") || 1)))>1 || CS>1) merges.push({s:{r:R + or_R,c:C + or_C},e:{r:R + or_R + (RS||1) - 1, c:C + or_C + (CS||1) - 1}});\n\t\t\tvar o/*:Cell*/ = {t:'s', v:v};\n\t\t\tvar _t/*:string*/ = elt.getAttribute(\"data-t\") || elt.getAttribute(\"t\") || \"\";\n\t\t\tif(v != null) {\n\t\t\t\tif(v.length == 0) o.t = _t || 'z';\n\t\t\t\telse if(opts.raw || v.trim().length == 0 || _t == \"s\"){}\n\t\t\t\telse if(v === 'TRUE') o = {t:'b', v:true};\n\t\t\t\telse if(v === 'FALSE') o = {t:'b', v:false};\n\t\t\t\telse if(!isNaN(fuzzynum(v))) o = {t:'n', v:fuzzynum(v)};\n\t\t\t\telse if(!isNaN(fuzzydate(v).getDate())) {\n\t\t\t\t\to = ({t:'d', v:parseDate(v)}/*:any*/);\n\t\t\t\t\tif(!opts.cellDates) o = ({t:'n', v:datenum(o.v)}/*:any*/);\n\t\t\t\t\to.z = opts.dateNF || table_fmt[14];\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(o.z === undefined && z != null) o.z = z;\n\t\t\t/* The first link is used. Links are assumed to be fully specified.\n\t\t\t * TODO: The right way to process relative links is to make a new */\n\t\t\tvar l = \"\", Aelts = elt.getElementsByTagName(\"A\");\n\t\t\tif(Aelts && Aelts.length) for(var Aelti = 0; Aelti < Aelts.length; ++Aelti)\tif(Aelts[Aelti].hasAttribute(\"href\")) {\n\t\t\t\tl = Aelts[Aelti].getAttribute(\"href\"); if(l.charAt(0) != \"#\") break;\n\t\t\t}\n\t\t\tif(l && l.charAt(0) != \"#\") o.l = ({ Target: l });\n\t\t\tif(opts.dense) { if(!ws[R + or_R]) ws[R + or_R] = []; ws[R + or_R][C + or_C] = o; }\n\t\t\telse ws[encode_cell({c:C + or_C, r:R + or_R})] = o;\n\t\t\tif(range.e.c < C + or_C) range.e.c = C + or_C;\n\t\t\tC += CS;\n\t\t}\n\t\t++R;\n\t}\n\tif(merges.length) ws['!merges'] = (ws[\"!merges\"] || []).concat(merges);\n\trange.e.r = Math.max(range.e.r, R - 1 + or_R);\n\tws['!ref'] = encode_range(range);\n\tif(R >= sheetRows) ws['!fullref'] = encode_range((range.e.r = rows.length-_R+R-1 + or_R,range)); // We can count the real number of rows to parse but we don't to improve the performance\n\treturn ws;\n}\n\nfunction parse_dom_table(table/*:HTMLElement*/, _opts/*:?any*/)/*:Worksheet*/ {\n\tvar opts = _opts || {};\n\tvar ws/*:Worksheet*/ = opts.dense ? ([]/*:any*/) : ({}/*:any*/);\n\treturn sheet_add_dom(ws, table, _opts);\n}\n\nfunction table_to_book(table/*:HTMLElement*/, opts/*:?any*/)/*:Workbook*/ {\n\treturn sheet_to_workbook(parse_dom_table(table, opts), opts);\n}\n\nfunction is_dom_element_hidden(element/*:HTMLElement*/)/*:boolean*/ {\n\tvar display/*:string*/ = '';\n\tvar get_computed_style/*:?function*/ = get_get_computed_style_function(element);\n\tif(get_computed_style) display = get_computed_style(element).getPropertyValue('display');\n\tif(!display) display = element.style && element.style.display;\n\treturn display === 'none';\n}\n\n/* global getComputedStyle */\nfunction get_get_computed_style_function(element/*:HTMLElement*/)/*:?function*/ {\n\t// The proper getComputedStyle implementation is the one defined in the element window\n\tif(element.ownerDocument.defaultView && typeof element.ownerDocument.defaultView.getComputedStyle === 'function') return element.ownerDocument.defaultView.getComputedStyle;\n\t// If it is not available, try to get one from the global namespace\n\tif(typeof getComputedStyle === 'function') return getComputedStyle;\n\treturn null;\n}\n/* OpenDocument */\nfunction parse_text_p(text/*:string*//*::, tag*/)/*:Array*/ {\n\t/* 6.1.2 White Space Characters */\n\tvar fixed = text\n\t\t.replace(/[\\t\\r\\n]/g, \" \").trim().replace(/ +/g, \" \")\n\t\t.replace(//g,\" \")\n\t\t.replace(//g, function($$,$1) { return Array(parseInt($1,10)+1).join(\" \"); })\n\t\t.replace(/]*\\/>/g,\"\\t\")\n\t\t.replace(//g,\"\\n\");\n\tvar v = unescapexml(fixed.replace(/<[^>]*>/g,\"\"));\n\n\treturn [v];\n}\n\nvar number_formats_ods = {\n\t/* ods name: [short ssf fmt, long ssf fmt] */\n\tday: [\"d\", \"dd\"],\n\tmonth: [\"m\", \"mm\"],\n\tyear: [\"y\", \"yy\"],\n\thours: [\"h\", \"hh\"],\n\tminutes: [\"m\", \"mm\"],\n\tseconds: [\"s\", \"ss\"],\n\t\"am-pm\": [\"A/P\", \"AM/PM\"],\n\t\"day-of-week\": [\"ddd\", \"dddd\"],\n\tera: [\"e\", \"ee\"],\n\t/* there is no native representation of LO \"Q\" format */\n\tquarter: [\"\\\\Qm\", \"m\\\\\\\"th quarter\\\"\"]\n};\n\n\nfunction parse_content_xml(d/*:string*/, _opts)/*:Workbook*/ {\n\t\tvar opts = _opts || {};\n\t\tif(DENSE != null && opts.dense == null) opts.dense = DENSE;\n\t\tvar str = xlml_normalize(d);\n\t\tvar state/*:Array*/ = [], tmp;\n\t\tvar tag/*:: = {}*/;\n\t\tvar NFtag = {name:\"\"}, NF = \"\", pidx = 0;\n\t\tvar sheetag/*:: = {name:\"\", '名称':\"\"}*/;\n\t\tvar rowtag/*:: = {'行号':\"\"}*/;\n\t\tvar Sheets = {}, SheetNames/*:Array*/ = [];\n\t\tvar ws = opts.dense ? ([]/*:any*/) : ({}/*:any*/);\n\t\tvar Rn, q/*:: :any = ({t:\"\", v:null, z:null, w:\"\",c:[],}:any)*/;\n\t\tvar ctag = ({value:\"\"}/*:any*/);\n\t\tvar textp = \"\", textpidx = 0, textptag/*:: = {}*/;\n\t\tvar textR = [];\n\t\tvar R = -1, C = -1, range = {s: {r:1000000,c:10000000}, e: {r:0, c:0}};\n\t\tvar row_ol = 0;\n\t\tvar number_format_map = {};\n\t\tvar merges/*:Array*/ = [], mrange = {}, mR = 0, mC = 0;\n\t\tvar rowinfo/*:Array*/ = [], rowpeat = 1, colpeat = 1;\n\t\tvar arrayf/*:Array<[Range, string]>*/ = [];\n\t\tvar WB = {Names:[]};\n\t\tvar atag = ({}/*:any*/);\n\t\tvar _Ref/*:[string, string]*/ = [\"\", \"\"];\n\t\tvar comments/*:Array*/ = [], comment/*:Comment*/ = ({}/*:any*/);\n\t\tvar creator = \"\", creatoridx = 0;\n\t\tvar isstub = false, intable = false;\n\t\tvar i = 0;\n\t\txlmlregex.lastIndex = 0;\n\t\tstr = str.replace(//mg,\"\").replace(//gm,\"\");\n\t\twhile((Rn = xlmlregex.exec(str))) switch((Rn[3]=Rn[3].replace(/_.*$/,\"\"))) {\n\n\t\t\tcase 'table': case '工作表': // 9.1.2 \n\t\t\t\tif(Rn[1]==='/') {\n\t\t\t\t\tif(range.e.c >= range.s.c && range.e.r >= range.s.r) ws['!ref'] = encode_range(range);\n\t\t\t\t\telse ws['!ref'] = \"A1:A1\";\n\t\t\t\t\tif(opts.sheetRows > 0 && opts.sheetRows <= range.e.r) {\n\t\t\t\t\t\tws['!fullref'] = ws['!ref'];\n\t\t\t\t\t\trange.e.r = opts.sheetRows - 1;\n\t\t\t\t\t\tws['!ref'] = encode_range(range);\n\t\t\t\t\t}\n\t\t\t\t\tif(merges.length) ws['!merges'] = merges;\n\t\t\t\t\tif(rowinfo.length) ws[\"!rows\"] = rowinfo;\n\t\t\t\t\tsheetag.name = sheetag['名称'] || sheetag.name;\n\t\t\t\t\tif(typeof JSON !== 'undefined') JSON.stringify(sheetag);\n\t\t\t\t\tSheetNames.push(sheetag.name);\n\t\t\t\t\tSheets[sheetag.name] = ws;\n\t\t\t\t\tintable = false;\n\t\t\t\t}\n\t\t\t\telse if(Rn[0].charAt(Rn[0].length-2) !== '/') {\n\t\t\t\t\tsheetag = parsexmltag(Rn[0], false);\n\t\t\t\t\tR = C = -1;\n\t\t\t\t\trange.s.r = range.s.c = 10000000; range.e.r = range.e.c = 0;\n\t\t\t\t\tws = opts.dense ? ([]/*:any*/) : ({}/*:any*/); merges = [];\n\t\t\t\t\trowinfo = [];\n\t\t\t\t\tintable = true;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 'table-row-group': // 9.1.9 \n\t\t\t\tif(Rn[1] === \"/\") --row_ol; else ++row_ol;\n\t\t\t\tbreak;\n\t\t\tcase 'table-row': case '行': // 9.1.3 \n\t\t\t\tif(Rn[1] === '/') { R+=rowpeat; rowpeat = 1; break; }\n\t\t\t\trowtag = parsexmltag(Rn[0], false);\n\t\t\t\tif(rowtag['行号']) R = rowtag['行号'] - 1; else if(R == -1) R = 0;\n\t\t\t\trowpeat = +rowtag['number-rows-repeated'] || 1;\n\t\t\t\t/* TODO: remove magic */\n\t\t\t\tif(rowpeat < 10) for(i = 0; i < rowpeat; ++i) if(row_ol > 0) rowinfo[R + i] = {level: row_ol};\n\t\t\t\tC = -1; break;\n\t\t\tcase 'covered-table-cell': // 9.1.5 \n\t\t\t\tif(Rn[1] !== '/') ++C;\n\t\t\t\tif(opts.sheetStubs) {\n\t\t\t\t\tif(opts.dense) { if(!ws[R]) ws[R] = []; ws[R][C] = {t:'z'}; }\n\t\t\t\t\telse ws[encode_cell({r:R,c:C})] = {t:'z'};\n\t\t\t\t}\n\t\t\t\ttextp = \"\"; textR = [];\n\t\t\t\tbreak; /* stub */\n\t\t\tcase 'table-cell': case '数据':\n\t\t\t\tif(Rn[0].charAt(Rn[0].length-2) === '/') {\n\t\t\t\t\t++C;\n\t\t\t\t\tctag = parsexmltag(Rn[0], false);\n\t\t\t\t\tcolpeat = parseInt(ctag['number-columns-repeated']||\"1\", 10);\n\t\t\t\t\tq = ({t:'z', v:null/*:: , z:null, w:\"\",c:[]*/}/*:any*/);\n\t\t\t\t\tif(ctag.formula && opts.cellFormula != false) q.f = ods_to_csf_formula(unescapexml(ctag.formula));\n\t\t\t\t\tif((ctag['数据类型'] || ctag['value-type']) == \"string\") {\n\t\t\t\t\t\tq.t = \"s\"; q.v = unescapexml(ctag['string-value'] || \"\");\n\t\t\t\t\t\tif(opts.dense) {\n\t\t\t\t\t\t\tif(!ws[R]) ws[R] = [];\n\t\t\t\t\t\t\tws[R][C] = q;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tws[encode_cell({r:R,c:C})] = q;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tC+= colpeat-1;\n\t\t\t\t} else if(Rn[1]!=='/') {\n\t\t\t\t\t++C;\n\t\t\t\t\ttextp = \"\"; textpidx = 0; textR = [];\n\t\t\t\t\tcolpeat = 1;\n\t\t\t\t\tvar rptR = rowpeat ? R + rowpeat - 1 : R;\n\t\t\t\t\tif(C > range.e.c) range.e.c = C;\n\t\t\t\t\tif(C < range.s.c) range.s.c = C;\n\t\t\t\t\tif(R < range.s.r) range.s.r = R;\n\t\t\t\t\tif(rptR > range.e.r) range.e.r = rptR;\n\t\t\t\t\tctag = parsexmltag(Rn[0], false);\n\t\t\t\t\tcomments = []; comment = ({}/*:any*/);\n\t\t\t\t\tq = ({t:ctag['数据类型'] || ctag['value-type'], v:null/*:: , z:null, w:\"\",c:[]*/}/*:any*/);\n\t\t\t\t\tif(opts.cellFormula) {\n\t\t\t\t\t\tif(ctag.formula) ctag.formula = unescapexml(ctag.formula);\n\t\t\t\t\t\tif(ctag['number-matrix-columns-spanned'] && ctag['number-matrix-rows-spanned']) {\n\t\t\t\t\t\t\tmR = parseInt(ctag['number-matrix-rows-spanned'],10) || 0;\n\t\t\t\t\t\t\tmC = parseInt(ctag['number-matrix-columns-spanned'],10) || 0;\n\t\t\t\t\t\t\tmrange = {s: {r:R,c:C}, e:{r:R + mR-1,c:C + mC-1}};\n\t\t\t\t\t\t\tq.F = encode_range(mrange);\n\t\t\t\t\t\t\tarrayf.push([mrange, q.F]);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(ctag.formula) q.f = ods_to_csf_formula(ctag.formula);\n\t\t\t\t\t\telse for(i = 0; i < arrayf.length; ++i)\n\t\t\t\t\t\t\tif(R >= arrayf[i][0].s.r && R <= arrayf[i][0].e.r)\n\t\t\t\t\t\t\t\tif(C >= arrayf[i][0].s.c && C <= arrayf[i][0].e.c)\n\t\t\t\t\t\t\t\t\tq.F = arrayf[i][1];\n\t\t\t\t\t}\n\t\t\t\t\tif(ctag['number-columns-spanned'] || ctag['number-rows-spanned']) {\n\t\t\t\t\t\tmR = parseInt(ctag['number-rows-spanned'],10) || 0;\n\t\t\t\t\t\tmC = parseInt(ctag['number-columns-spanned'],10) || 0;\n\t\t\t\t\t\tmrange = {s: {r:R,c:C}, e:{r:R + mR-1,c:C + mC-1}};\n\t\t\t\t\t\tmerges.push(mrange);\n\t\t\t\t\t}\n\n\t\t\t\t\t/* 19.675.2 table:number-columns-repeated */\n\t\t\t\t\tif(ctag['number-columns-repeated']) colpeat = parseInt(ctag['number-columns-repeated'], 10);\n\n\t\t\t\t\t/* 19.385 office:value-type */\n\t\t\t\t\tswitch(q.t) {\n\t\t\t\t\t\tcase 'boolean': q.t = 'b'; q.v = parsexmlbool(ctag['boolean-value']); break;\n\t\t\t\t\t\tcase 'float': q.t = 'n'; q.v = parseFloat(ctag.value); break;\n\t\t\t\t\t\tcase 'percentage': q.t = 'n'; q.v = parseFloat(ctag.value); break;\n\t\t\t\t\t\tcase 'currency': q.t = 'n'; q.v = parseFloat(ctag.value); break;\n\t\t\t\t\t\tcase 'date': q.t = 'd'; q.v = parseDate(ctag['date-value']);\n\t\t\t\t\t\t\tif(!opts.cellDates) { q.t = 'n'; q.v = datenum(q.v); }\n\t\t\t\t\t\t\tq.z = 'm/d/yy'; break;\n\t\t\t\t\t\tcase 'time': q.t = 'n'; q.v = parse_isodur(ctag['time-value'])/86400;\n\t\t\t\t\t\t\tif(opts.cellDates) { q.t = 'd'; q.v = numdate(q.v); }\n\t\t\t\t\t\t\tq.z = 'HH:MM:SS'; break;\n\t\t\t\t\t\tcase 'number': q.t = 'n'; q.v = parseFloat(ctag['数据数值']); break;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tif(q.t === 'string' || q.t === 'text' || !q.t) {\n\t\t\t\t\t\t\t\tq.t = 's';\n\t\t\t\t\t\t\t\tif(ctag['string-value'] != null) { textp = unescapexml(ctag['string-value']); textR = []; }\n\t\t\t\t\t\t\t} else throw new Error('Unsupported value type ' + q.t);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tisstub = false;\n\t\t\t\t\tif(q.t === 's') {\n\t\t\t\t\t\tq.v = textp || '';\n\t\t\t\t\t\tif(textR.length) q.R = textR;\n\t\t\t\t\t\tisstub = textpidx == 0;\n\t\t\t\t\t}\n\t\t\t\t\tif(atag.Target) q.l = atag;\n\t\t\t\t\tif(comments.length > 0) { q.c = comments; comments = []; }\n\t\t\t\t\tif(textp && opts.cellText !== false) q.w = textp;\n\t\t\t\t\tif(isstub) { q.t = \"z\"; delete q.v; }\n\t\t\t\t\tif(!isstub || opts.sheetStubs) {\n\t\t\t\t\t\tif(!(opts.sheetRows && opts.sheetRows <= R)) {\n\t\t\t\t\t\t\tfor(var rpt = 0; rpt < rowpeat; ++rpt) {\n\t\t\t\t\t\t\t\tcolpeat = parseInt(ctag['number-columns-repeated']||\"1\", 10);\n\t\t\t\t\t\t\t\tif(opts.dense) {\n\t\t\t\t\t\t\t\t\tif(!ws[R + rpt]) ws[R + rpt] = [];\n\t\t\t\t\t\t\t\t\tws[R + rpt][C] = rpt == 0 ? q : dup(q);\n\t\t\t\t\t\t\t\t\twhile(--colpeat > 0) ws[R + rpt][C + colpeat] = dup(q);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tws[encode_cell({r:R + rpt,c:C})] = q;\n\t\t\t\t\t\t\t\t\twhile(--colpeat > 0) ws[encode_cell({r:R + rpt,c:C + colpeat})] = dup(q);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif(range.e.c <= C) range.e.c = C;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcolpeat = parseInt(ctag['number-columns-repeated']||\"1\", 10);\n\t\t\t\t\tC += colpeat-1; colpeat = 0;\n\t\t\t\t\tq = {/*:: t:\"\", v:null, z:null, w:\"\",c:[]*/};\n\t\t\t\t\ttextp = \"\"; textR = [];\n\t\t\t\t}\n\t\t\t\tatag = ({}/*:any*/);\n\t\t\t\tbreak; // 9.1.4 \n\n\t\t\t/* pure state */\n\t\t\tcase 'document': // TODO: is the root for FODS\n\t\t\tcase 'document-content': case '电子表格文档': // 3.1.3.2 \n\t\t\tcase 'spreadsheet': case '主体': // 3.7 \n\t\t\tcase 'scripts': // 3.12 \n\t\t\tcase 'styles': // TODO \n\t\t\tcase 'font-face-decls': // 3.14 \n\t\t\tcase 'master-styles': // 3.15.4 -- relevant for FODS\n\t\t\t\tif(Rn[1]==='/'){if((tmp=state.pop())[0]!==Rn[3]) throw \"Bad state: \"+tmp;}\n\t\t\t\telse if(Rn[0].charAt(Rn[0].length-2) !== '/') state.push([Rn[3], true]);\n\t\t\t\tbreak;\n\n\t\t\tcase 'annotation': // 14.1 \n\t\t\t\tif(Rn[1]==='/'){\n\t\t\t\t\tif((tmp=state.pop())[0]!==Rn[3]) throw \"Bad state: \"+tmp;\n\t\t\t\t\tcomment.t = textp;\n\t\t\t\t\tif(textR.length) /*::(*/comment/*:: :any)*/.R = textR;\n\t\t\t\t\tcomment.a = creator;\n\t\t\t\t\tcomments.push(comment);\n\t\t\t\t}\n\t\t\t\telse if(Rn[0].charAt(Rn[0].length-2) !== '/') {state.push([Rn[3], false]);}\n\t\t\t\tcreator = \"\"; creatoridx = 0;\n\t\t\t\ttextp = \"\"; textpidx = 0; textR = [];\n\t\t\t\tbreak;\n\n\t\t\tcase 'creator': // 4.3.2.7 \n\t\t\t\tif(Rn[1]==='/') { creator = str.slice(creatoridx,Rn.index); }\n\t\t\t\telse creatoridx = Rn.index + Rn[0].length;\n\t\t\t\tbreak;\n\n\t\t\t/* ignore state */\n\t\t\tcase 'meta': case '元数据': // TODO: FODS/UOF\n\t\t\tcase 'settings': // TODO: \n\t\t\tcase 'config-item-set': // TODO: \n\t\t\tcase 'config-item-map-indexed': // TODO: \n\t\t\tcase 'config-item-map-entry': // TODO: \n\t\t\tcase 'config-item-map-named': // TODO: \n\t\t\tcase 'shapes': // 9.2.8 \n\t\t\tcase 'frame': // 10.4.2 \n\t\t\tcase 'text-box': // 10.4.3 \n\t\t\tcase 'image': // 10.4.4 \n\t\t\tcase 'data-pilot-tables': // 9.6.2 \n\t\t\tcase 'list-style': // 16.30 \n\t\t\tcase 'form': // 13.13 \n\t\t\tcase 'dde-links': // 9.8 \n\t\t\tcase 'event-listeners': // TODO\n\t\t\tcase 'chart': // TODO\n\t\t\t\tif(Rn[1]==='/'){if((tmp=state.pop())[0]!==Rn[3]) throw \"Bad state: \"+tmp;}\n\t\t\t\telse if(Rn[0].charAt(Rn[0].length-2) !== '/') state.push([Rn[3], false]);\n\t\t\t\ttextp = \"\"; textpidx = 0; textR = [];\n\t\t\t\tbreak;\n\n\t\t\tcase 'scientific-number': // TODO: \n\t\t\t\tbreak;\n\t\t\tcase 'currency-symbol': // TODO: \n\t\t\t\tbreak;\n\t\t\tcase 'currency-style': // TODO: \n\t\t\t\tbreak;\n\t\t\tcase 'number-style': // 16.27.2 \n\t\t\tcase 'percentage-style': // 16.27.9 \n\t\t\tcase 'date-style': // 16.27.10 \n\t\t\tcase 'time-style': // 16.27.18 \n\t\t\t\tif(Rn[1]==='/'){\n\t\t\t\t\tnumber_format_map[NFtag.name] = NF;\n\t\t\t\t\tif((tmp=state.pop())[0]!==Rn[3]) throw \"Bad state: \"+tmp;\n\t\t\t\t} else if(Rn[0].charAt(Rn[0].length-2) !== '/') {\n\t\t\t\t\tNF = \"\";\n\t\t\t\t\tNFtag = parsexmltag(Rn[0], false);\n\t\t\t\t\tstate.push([Rn[3], true]);\n\t\t\t\t} break;\n\n\t\t\tcase 'script': break; // 3.13 \n\t\t\tcase 'libraries': break; // TODO: \n\t\t\tcase 'automatic-styles': break; // 3.15.3 \n\n\t\t\tcase 'default-style': // TODO: \n\t\t\tcase 'page-layout': break; // TODO: \n\t\t\tcase 'style': // 16.2 \n\t\t\t\tbreak;\n\t\t\tcase 'map': break; // 16.3 \n\t\t\tcase 'font-face': break; // 16.21 \n\n\t\t\tcase 'paragraph-properties': break; // 17.6 \n\t\t\tcase 'table-properties': break; // 17.15 \n\t\t\tcase 'table-column-properties': break; // 17.16 \n\t\t\tcase 'table-row-properties': break; // 17.17 \n\t\t\tcase 'table-cell-properties': break; // 17.18 \n\n\t\t\tcase 'number': // 16.27.3 \n\t\t\t\tswitch(state[state.length-1][0]) {\n\t\t\t\t\tcase 'time-style':\n\t\t\t\t\tcase 'date-style':\n\t\t\t\t\t\ttag = parsexmltag(Rn[0], false);\n\t\t\t\t\t\tNF += number_formats_ods[Rn[3]][tag.style==='long'?1:0]; break;\n\t\t\t\t} break;\n\n\t\t\tcase 'fraction': break; // TODO 16.27.6 \n\n\t\t\tcase 'day': // 16.27.11 \n\t\t\tcase 'month': // 16.27.12 \n\t\t\tcase 'year': // 16.27.13 \n\t\t\tcase 'era': // 16.27.14 \n\t\t\tcase 'day-of-week': // 16.27.15 \n\t\t\tcase 'week-of-year': // 16.27.16 \n\t\t\tcase 'quarter': // 16.27.17 \n\t\t\tcase 'hours': // 16.27.19 \n\t\t\tcase 'minutes': // 16.27.20 \n\t\t\tcase 'seconds': // 16.27.21 \n\t\t\tcase 'am-pm': // 16.27.22 \n\t\t\t\tswitch(state[state.length-1][0]) {\n\t\t\t\t\tcase 'time-style':\n\t\t\t\t\tcase 'date-style':\n\t\t\t\t\t\ttag = parsexmltag(Rn[0], false);\n\t\t\t\t\t\tNF += number_formats_ods[Rn[3]][tag.style==='long'?1:0]; break;\n\t\t\t\t} break;\n\n\t\t\tcase 'boolean-style': break; // 16.27.23 \n\t\t\tcase 'boolean': break; // 16.27.24 \n\t\t\tcase 'text-style': break; // 16.27.25 \n\t\t\tcase 'text': // 16.27.26 \n\t\t\t\tif(Rn[0].slice(-2) === \"/>\") break;\n\t\t\t\telse if(Rn[1]===\"/\") switch(state[state.length-1][0]) {\n\t\t\t\t\tcase 'number-style':\n\t\t\t\t\tcase 'date-style':\n\t\t\t\t\tcase 'time-style':\n\t\t\t\t\t\tNF += str.slice(pidx, Rn.index);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\telse pidx = Rn.index + Rn[0].length;\n\t\t\t\tbreak;\n\n\t\t\tcase 'named-range': // 9.4.12 \n\t\t\t\ttag = parsexmltag(Rn[0], false);\n\t\t\t\t_Ref = ods_to_csf_3D(tag['cell-range-address']);\n\t\t\t\tvar nrange = ({Name:tag.name, Ref:_Ref[0] + '!' + _Ref[1]}/*:any*/);\n\t\t\t\tif(intable) nrange.Sheet = SheetNames.length;\n\t\t\t\tWB.Names.push(nrange);\n\t\t\t\tbreak;\n\n\t\t\tcase 'text-content': break; // 16.27.27 \n\t\t\tcase 'text-properties': break; // 16.27.27 \n\t\t\tcase 'embedded-text': break; // 16.27.4 \n\n\t\t\tcase 'body': case '电子表格': break; // 3.3 16.9.6 19.726.3\n\n\t\t\tcase 'forms': break; // 12.25.2 13.2\n\t\t\tcase 'table-column': break; // 9.1.6 \n\t\t\tcase 'table-header-rows': break; // 9.1.7 \n\t\t\tcase 'table-rows': break; // 9.1.12 \n\t\t\t/* TODO: outline levels */\n\t\t\tcase 'table-column-group': break; // 9.1.10 \n\t\t\tcase 'table-header-columns': break; // 9.1.11 \n\t\t\tcase 'table-columns': break; // 9.1.12 \n\n\t\t\tcase 'null-date': break; // 9.4.2 TODO: date1904\n\n\t\t\tcase 'graphic-properties': break; // 17.21 \n\t\t\tcase 'calculation-settings': break; // 9.4.1 \n\t\t\tcase 'named-expressions': break; // 9.4.11 \n\t\t\tcase 'label-range': break; // 9.4.9 \n\t\t\tcase 'label-ranges': break; // 9.4.10 \n\t\t\tcase 'named-expression': break; // 9.4.13 \n\t\t\tcase 'sort': break; // 9.4.19 \n\t\t\tcase 'sort-by': break; // 9.4.20 \n\t\t\tcase 'sort-groups': break; // 9.4.22 \n\n\t\t\tcase 'tab': break; // 6.1.4 \n\t\t\tcase 'line-break': break; // 6.1.5 \n\t\t\tcase 'span': break; // 6.1.7 \n\t\t\tcase 'p': case '文本串': // 5.1.3 \n\t\t\t\tif(['master-styles'].indexOf(state[state.length-1][0]) > -1) break;\n\t\t\t\tif(Rn[1]==='/' && (!ctag || !ctag['string-value'])) {\n\t\t\t\t\tvar ptp = parse_text_p(str.slice(textpidx,Rn.index), textptag);\n\t\t\t\t\ttextp = (textp.length > 0 ? textp + \"\\n\" : \"\") + ptp[0];\n\t\t\t\t} else { textptag = parsexmltag(Rn[0], false); textpidx = Rn.index + Rn[0].length; }\n\t\t\t\tbreak; // \n\t\t\tcase 's': break; // \n\n\t\t\tcase 'database-range': // 9.4.15 \n\t\t\t\tif(Rn[1]==='/') break;\n\t\t\t\ttry {\n\t\t\t\t\t_Ref = ods_to_csf_3D(parsexmltag(Rn[0])['target-range-address']);\n\t\t\t\t\tSheets[_Ref[0]]['!autofilter'] = { ref:_Ref[1] };\n\t\t\t\t} catch(e) {/* empty */}\n\t\t\t\tbreak;\n\n\t\t\tcase 'date': break; // <*:date>\n\n\t\t\tcase 'object': break; // 10.4.6.2 \n\t\t\tcase 'title': case '标题': break; // <*:title> OR \n\t\t\tcase 'desc': break; // <*:desc>\n\t\t\tcase 'binary-data': break; // 10.4.5 TODO: b64 blob\n\n\t\t\t/* 9.2 Advanced Tables */\n\t\t\tcase 'table-source': break; // 9.2.6\n\t\t\tcase 'scenario': break; // 9.2.6\n\n\t\t\tcase 'iteration': break; // 9.4.3 \n\t\t\tcase 'content-validations': break; // 9.4.4 \n\t\t\tcase 'filter': break; // 9.5.2 \n\t\t\tcase 'filter-and': break; // 9.5.3 \n\t\t\tcase 'filter-or': break; // 9.5.4 \n\t\t\tcase 'filter-condition': break; // 9.5.5 \n\n\t\t\tcase 'list-level-style-bullet': break; // 16.31 \n\t\t\tcase 'page-count': break; // TODO \n\t\t\tcase 'time': break; // TODO \n\n\t\t\t/* 9.3 Advanced Table Cells */\n\t\t\tcase 'cell-range-source': break; // 9.3.1 \n\t\t\tcase 'property': break; // 13.8 \n\n\t\t\tcase 'a': // 6.1.8 hyperlink\n\t\t\t\tif(Rn[1]!== '/') {\n\t\t\t\t\tatag = parsexmltag(Rn[0], false);\n\t\t\t\t\tif(!atag.href) break;\n\t\t\t\t\tatag.Target = unescapexml(atag.href); delete atag.href;\n\t\t\t\t\tif(atag.Target.charAt(0) == \"#\" && atag.Target.indexOf(\".\") > -1) {\n\t\t\t\t\t\t_Ref = ods_to_csf_3D(atag.Target.slice(1));\n\t\t\t\t\t\tatag.Target = \"#\" + _Ref[0] + \"!\" + _Ref[1];\n\t\t\t\t\t} else if(atag.Target.match(/^\\.\\.[\\\\\\/]/)) atag.Target = atag.Target.slice(3);\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\t/* non-standard */\n\t\t\tcase 'table-protection': break;\n\t\t\tcase 'data-pilot-grand-total': break; // ',\n\t\t\t'',\n\t\t\t\t'',\n\t\t\t\t'',\n\t\t\t\t'',\n\t\t\t\t'',\n\t\t\t'',\n\t\t''\n\t].join(\"\");\n\n\tvar payload = '' + master_styles + '';\n\n\treturn function wso(/*::wb, opts*/) {\n\t\treturn XML_HEADER + payload;\n\t};\n})();\nvar write_content_ods/*:{(wb:any, opts:any):string}*/ = /* @__PURE__ */(function() {\n\t/* 6.1.2 White Space Characters */\n\tvar write_text_p = function(text/*:string*/)/*:string*/ {\n\t\treturn escapexml(text)\n\t\t\t.replace(/ +/g, function($$){return '';})\n\t\t\t.replace(/\\t/g, \"\")\n\t\t\t.replace(/\\n/g, \"\")\n\t\t\t.replace(/^ /, \"\").replace(/ $/, \"\");\n\t};\n\n\tvar null_cell_xml = ' \\n';\n\tvar covered_cell_xml = ' \\n';\n\tvar write_ws = function(ws, wb/*:Workbook*/, i/*:number*//*::, opts*/)/*:string*/ {\n\t\t/* Section 9 Tables */\n\t\tvar o/*:Array*/ = [];\n\t\to.push(' \\n');\n\t\tvar R=0,C=0, range = decode_range(ws['!ref']||\"A1\");\n\t\tvar marr/*:Array*/ = ws['!merges'] || [], mi = 0;\n\t\tvar dense = Array.isArray(ws);\n\t\tif(ws[\"!cols\"]) {\n\t\t\tfor(C = 0; C <= range.e.c; ++C) o.push(' \\n');\n\t\t}\n\t\tvar H = \"\", ROWS = ws[\"!rows\"]||[];\n\t\tfor(R = 0; R < range.s.r; ++R) {\n\t\t\tH = ROWS[R] ? ' table:style-name=\"ro' + ROWS[R].ods + '\"' : \"\";\n\t\t\to.push(' \\n');\n\t\t}\n\t\tfor(; R <= range.e.r; ++R) {\n\t\t\tH = ROWS[R] ? ' table:style-name=\"ro' + ROWS[R].ods + '\"' : \"\";\n\t\t\to.push(' \\n');\n\t\t\tfor(C=0; C < range.s.c; ++C) o.push(null_cell_xml);\n\t\t\tfor(; C <= range.e.c; ++C) {\n\t\t\t\tvar skip = false, ct = {}, textp = \"\";\n\t\t\t\tfor(mi = 0; mi != marr.length; ++mi) {\n\t\t\t\t\tif(marr[mi].s.c > C) continue;\n\t\t\t\t\tif(marr[mi].s.r > R) continue;\n\t\t\t\t\tif(marr[mi].e.c < C) continue;\n\t\t\t\t\tif(marr[mi].e.r < R) continue;\n\t\t\t\t\tif(marr[mi].s.c != C || marr[mi].s.r != R) skip = true;\n\t\t\t\t\tct['table:number-columns-spanned'] = (marr[mi].e.c - marr[mi].s.c + 1);\n\t\t\t\t\tct['table:number-rows-spanned'] = (marr[mi].e.r - marr[mi].s.r + 1);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif(skip) { o.push(covered_cell_xml); continue; }\n\t\t\t\tvar ref = encode_cell({r:R, c:C}), cell = dense ? (ws[R]||[])[C]: ws[ref];\n\t\t\t\tif(cell && cell.f) {\n\t\t\t\t\tct['table:formula'] = escapexml(csf_to_ods_formula(cell.f));\n\t\t\t\t\tif(cell.F) {\n\t\t\t\t\t\tif(cell.F.slice(0, ref.length) == ref) {\n\t\t\t\t\t\t\tvar _Fref = decode_range(cell.F);\n\t\t\t\t\t\t\tct['table:number-matrix-columns-spanned'] = (_Fref.e.c - _Fref.s.c + 1);\n\t\t\t\t\t\t\tct['table:number-matrix-rows-spanned'] = (_Fref.e.r - _Fref.s.r + 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(!cell) { o.push(null_cell_xml); continue; }\n\t\t\t\tswitch(cell.t) {\n\t\t\t\t\tcase 'b':\n\t\t\t\t\t\ttextp = (cell.v ? 'TRUE' : 'FALSE');\n\t\t\t\t\t\tct['office:value-type'] = \"boolean\";\n\t\t\t\t\t\tct['office:boolean-value'] = (cell.v ? 'true' : 'false');\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'n':\n\t\t\t\t\t\ttextp = (cell.w||String(cell.v||0));\n\t\t\t\t\t\tct['office:value-type'] = \"float\";\n\t\t\t\t\t\tct['office:value'] = (cell.v||0);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 's': case 'str':\n\t\t\t\t\t\ttextp = cell.v == null ? \"\" : cell.v;\n\t\t\t\t\t\tct['office:value-type'] = \"string\";\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'd':\n\t\t\t\t\t\ttextp = (cell.w||(parseDate(cell.v).toISOString()));\n\t\t\t\t\t\tct['office:value-type'] = \"date\";\n\t\t\t\t\t\tct['office:date-value'] = (parseDate(cell.v).toISOString());\n\t\t\t\t\t\tct['table:style-name'] = \"ce1\";\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t//case 'e':\n\t\t\t\t\tdefault: o.push(null_cell_xml); continue;\n\t\t\t\t}\n\t\t\t\tvar text_p = write_text_p(textp);\n\t\t\t\tif(cell.l && cell.l.Target) {\n\t\t\t\t\tvar _tgt = cell.l.Target;\n\t\t\t\t\t_tgt = _tgt.charAt(0) == \"#\" ? \"#\" + csf_to_ods_3D(_tgt.slice(1)) : _tgt;\n\t\t\t\t\t// TODO: choose correct parent path format based on link delimiters\n\t\t\t\t\tif(_tgt.charAt(0) != \"#\" && !_tgt.match(/^\\w+:/)) _tgt = '../' + _tgt;\n\t\t\t\t\ttext_p = writextag('text:a', text_p, {'xlink:href': _tgt.replace(/&/g, \"&\")});\n\t\t\t\t}\n\t\t\t\to.push(' ' + writextag('table:table-cell', writextag('text:p', text_p, {}), ct) + '\\n');\n\t\t\t}\n\t\t\to.push(' \\n');\n\t\t}\n\t\to.push(' \\n');\n\t\treturn o.join(\"\");\n\t};\n\n\tvar write_automatic_styles_ods = function(o/*:Array*/, wb) {\n\t\to.push(' \\n');\n\n\t\to.push(' \\n');\n\t\to.push(' \\n');\n\t\to.push(' /\\n');\n\t\to.push(' \\n');\n\t\to.push(' /\\n');\n\t\to.push(' \\n');\n\t\to.push(' \\n');\n\n\t\t/* column styles */\n\t\tvar cidx = 0;\n\t\twb.SheetNames.map(function(n) { return wb.Sheets[n]; }).forEach(function(ws) {\n\t\t\tif(!ws) return;\n\t\t\tif(ws[\"!cols\"]) {\n\t\t\t\tfor(var C = 0; C < ws[\"!cols\"].length; ++C) if(ws[\"!cols\"][C]) {\n\t\t\t\t\tvar colobj = ws[\"!cols\"][C];\n\t\t\t\t\tif(colobj.width == null && colobj.wpx == null && colobj.wch == null) continue;\n\t\t\t\t\tprocess_col(colobj);\n\t\t\t\t\tcolobj.ods = cidx;\n\t\t\t\t\tvar w = ws[\"!cols\"][C].wpx + \"px\";\n\t\t\t\t\to.push(' \\n');\n\t\t\t\t\to.push(' \\n');\n\t\t\t\t\to.push(' \\n');\n\t\t\t\t\t++cidx;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t/* row styles */\n\t\tvar ridx = 0;\n\t\twb.SheetNames.map(function(n) { return wb.Sheets[n]; }).forEach(function(ws) {\n\t\t\tif(!ws) return;\n\t\t\tif(ws[\"!rows\"]) {\n\t\t\t\tfor(var R = 0; R < ws[\"!rows\"].length; ++R) if(ws[\"!rows\"][R]) {\n\t\t\t\t\tws[\"!rows\"][R].ods = ridx;\n\t\t\t\t\tvar h = ws[\"!rows\"][R].hpx + \"px\";\n\t\t\t\t\to.push(' \\n');\n\t\t\t\t\to.push(' \\n');\n\t\t\t\t\to.push(' \\n');\n\t\t\t\t\t++ridx;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t/* table */\n\t\to.push(' \\n');\n\t\to.push(' \\n');\n\t\to.push(' \\n');\n\n\t\t/* table cells, text */\n\t\to.push(' \\n');\n\n\t\t/* page-layout */\n\n\t\to.push(' \\n');\n\t};\n\n\treturn function wcx(wb, opts) {\n\t\tvar o = [XML_HEADER];\n\t\t/* 3.1.3.2 */\n\t\tvar attr = wxt_helper({\n\t\t\t'xmlns:office': \"urn:oasis:names:tc:opendocument:xmlns:office:1.0\",\n\t\t\t'xmlns:table': \"urn:oasis:names:tc:opendocument:xmlns:table:1.0\",\n\t\t\t'xmlns:style': \"urn:oasis:names:tc:opendocument:xmlns:style:1.0\",\n\t\t\t'xmlns:text': \"urn:oasis:names:tc:opendocument:xmlns:text:1.0\",\n\t\t\t'xmlns:draw': \"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0\",\n\t\t\t'xmlns:fo': \"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0\",\n\t\t\t'xmlns:xlink': \"http://www.w3.org/1999/xlink\",\n\t\t\t'xmlns:dc': \"http://purl.org/dc/elements/1.1/\",\n\t\t\t'xmlns:meta': \"urn:oasis:names:tc:opendocument:xmlns:meta:1.0\",\n\t\t\t'xmlns:number': \"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0\",\n\t\t\t'xmlns:presentation': \"urn:oasis:names:tc:opendocument:xmlns:presentation:1.0\",\n\t\t\t'xmlns:svg': \"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0\",\n\t\t\t'xmlns:chart': \"urn:oasis:names:tc:opendocument:xmlns:chart:1.0\",\n\t\t\t'xmlns:dr3d': \"urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0\",\n\t\t\t'xmlns:math': \"http://www.w3.org/1998/Math/MathML\",\n\t\t\t'xmlns:form': \"urn:oasis:names:tc:opendocument:xmlns:form:1.0\",\n\t\t\t'xmlns:script': \"urn:oasis:names:tc:opendocument:xmlns:script:1.0\",\n\t\t\t'xmlns:ooo': \"http://openoffice.org/2004/office\",\n\t\t\t'xmlns:ooow': \"http://openoffice.org/2004/writer\",\n\t\t\t'xmlns:oooc': \"http://openoffice.org/2004/calc\",\n\t\t\t'xmlns:dom': \"http://www.w3.org/2001/xml-events\",\n\t\t\t'xmlns:xforms': \"http://www.w3.org/2002/xforms\",\n\t\t\t'xmlns:xsd': \"http://www.w3.org/2001/XMLSchema\",\n\t\t\t'xmlns:xsi': \"http://www.w3.org/2001/XMLSchema-instance\",\n\t\t\t'xmlns:sheet': \"urn:oasis:names:tc:opendocument:sh33tjs:1.0\",\n\t\t\t'xmlns:rpt': \"http://openoffice.org/2005/report\",\n\t\t\t'xmlns:of': \"urn:oasis:names:tc:opendocument:xmlns:of:1.2\",\n\t\t\t'xmlns:xhtml': \"http://www.w3.org/1999/xhtml\",\n\t\t\t'xmlns:grddl': \"http://www.w3.org/2003/g/data-view#\",\n\t\t\t'xmlns:tableooo': \"http://openoffice.org/2009/table\",\n\t\t\t'xmlns:drawooo': \"http://openoffice.org/2010/draw\",\n\t\t\t'xmlns:calcext': \"urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0\",\n\t\t\t'xmlns:loext': \"urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0\",\n\t\t\t'xmlns:field': \"urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0\",\n\t\t\t'xmlns:formx': \"urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0\",\n\t\t\t'xmlns:css3t': \"http://www.w3.org/TR/css3-text/\",\n\t\t\t'office:version': \"1.2\"\n\t\t});\n\n\t\tvar fods = wxt_helper({\n\t\t\t'xmlns:config': \"urn:oasis:names:tc:opendocument:xmlns:config:1.0\",\n\t\t\t'office:mimetype': \"application/vnd.oasis.opendocument.spreadsheet\"\n\t\t});\n\n\t\tif(opts.bookType == \"fods\") {\n\t\t\to.push('\\n');\n\t\t\to.push(write_meta_ods().replace(/office:document-meta/g, \"office:meta\"));\n\t\t\t// TODO: settings (equiv of settings.xml for ODS)\n\t\t} else o.push('\\n');\n\t\t// o.push(' \\n');\n\t\twrite_automatic_styles_ods(o, wb);\n\t\to.push(' \\n');\n\t\to.push(' \\n');\n\t\tfor(var i = 0; i != wb.SheetNames.length; ++i) o.push(write_ws(wb.Sheets[wb.SheetNames[i]], wb, i, opts));\n\t\to.push(' \\n');\n\t\to.push(' \\n');\n\t\tif(opts.bookType == \"fods\") o.push('');\n\t\telse o.push('');\n\t\treturn o.join(\"\");\n\t};\n})();\n\nfunction write_ods(wb/*:any*/, opts/*:any*/) {\n\tif(opts.bookType == \"fods\") return write_content_ods(wb, opts);\n\n\tvar zip = zip_new();\n\tvar f = \"\";\n\n\tvar manifest/*:Array >*/ = [];\n\tvar rdf/*:Array<[string, string]>*/ = [];\n\n\t/* Part 3 Section 3.3 MIME Media Type */\n\tf = \"mimetype\";\n\tzip_add_file(zip, f, \"application/vnd.oasis.opendocument.spreadsheet\");\n\n\t/* Part 1 Section 2.2 Documents */\n\tf = \"content.xml\";\n\tzip_add_file(zip, f, write_content_ods(wb, opts));\n\tmanifest.push([f, \"text/xml\"]);\n\trdf.push([f, \"ContentFile\"]);\n\n\t/* TODO: these are hard-coded styles to satiate excel */\n\tf = \"styles.xml\";\n\tzip_add_file(zip, f, write_styles_ods(wb, opts));\n\tmanifest.push([f, \"text/xml\"]);\n\trdf.push([f, \"StylesFile\"]);\n\n\t/* TODO: this is hard-coded to satiate excel */\n\tf = \"meta.xml\";\n\tzip_add_file(zip, f, XML_HEADER + write_meta_ods(/*::wb, opts*/));\n\tmanifest.push([f, \"text/xml\"]);\n\trdf.push([f, \"MetadataFile\"]);\n\n\t/* Part 3 Section 6 Metadata Manifest File */\n\tf = \"manifest.rdf\";\n\tzip_add_file(zip, f, write_rdf(rdf/*, opts*/));\n\tmanifest.push([f, \"application/rdf+xml\"]);\n\n\t/* Part 3 Section 4 Manifest File */\n\tf = \"META-INF/manifest.xml\";\n\tzip_add_file(zip, f, write_manifest(manifest/*, opts*/));\n\n\treturn zip;\n}\n\n/*! sheetjs (C) 2013-present SheetJS -- http://sheetjs.com */\nfunction u8_to_dataview(array) {\n return new DataView(array.buffer, array.byteOffset, array.byteLength);\n}\nfunction u8str(u8) {\n return typeof TextDecoder != \"undefined\" ? new TextDecoder().decode(u8) : utf8read(a2s(u8));\n}\nfunction stru8(str) {\n return typeof TextEncoder != \"undefined\" ? new TextEncoder().encode(str) : s2a(utf8write(str));\n}\nfunction u8contains(body, search) {\n outer:\n for (var L = 0; L <= body.length - search.length; ++L) {\n for (var j = 0; j < search.length; ++j)\n if (body[L + j] != search[j])\n continue outer;\n return true;\n }\n return false;\n}\nfunction u8concat(u8a) {\n var len = u8a.reduce(function(acc, x) {\n return acc + x.length;\n }, 0);\n var out = new Uint8Array(len);\n var off = 0;\n u8a.forEach(function(u8) {\n out.set(u8, off);\n off += u8.length;\n });\n return out;\n}\nfunction popcnt(x) {\n x -= x >> 1 & 1431655765;\n x = (x & 858993459) + (x >> 2 & 858993459);\n return (x + (x >> 4) & 252645135) * 16843009 >>> 24;\n}\nfunction readDecimal128LE(buf, offset) {\n var exp = (buf[offset + 15] & 127) << 7 | buf[offset + 14] >> 1;\n var mantissa = buf[offset + 14] & 1;\n for (var j = offset + 13; j >= offset; --j)\n mantissa = mantissa * 256 + buf[j];\n return (buf[offset + 15] & 128 ? -mantissa : mantissa) * Math.pow(10, exp - 6176);\n}\nfunction writeDecimal128LE(buf, offset, value) {\n var exp = Math.floor(value == 0 ? 0 : Math.LOG10E * Math.log(Math.abs(value))) + 6176 - 20;\n var mantissa = value / Math.pow(10, exp - 6176);\n buf[offset + 15] |= exp >> 7;\n buf[offset + 14] |= (exp & 127) << 1;\n for (var i = 0; mantissa >= 1; ++i, mantissa /= 256)\n buf[offset + i] = mantissa & 255;\n buf[offset + 15] |= value >= 0 ? 0 : 128;\n}\nfunction parse_varint49(buf, ptr) {\n var l = ptr ? ptr[0] : 0;\n var usz = buf[l] & 127;\n varint:\n if (buf[l++] >= 128) {\n usz |= (buf[l] & 127) << 7;\n if (buf[l++] < 128)\n break varint;\n usz |= (buf[l] & 127) << 14;\n if (buf[l++] < 128)\n break varint;\n usz |= (buf[l] & 127) << 21;\n if (buf[l++] < 128)\n break varint;\n usz += (buf[l] & 127) * Math.pow(2, 28);\n ++l;\n if (buf[l++] < 128)\n break varint;\n usz += (buf[l] & 127) * Math.pow(2, 35);\n ++l;\n if (buf[l++] < 128)\n break varint;\n usz += (buf[l] & 127) * Math.pow(2, 42);\n ++l;\n if (buf[l++] < 128)\n break varint;\n }\n if (ptr)\n ptr[0] = l;\n return usz;\n}\nfunction write_varint49(v) {\n var usz = new Uint8Array(7);\n usz[0] = v & 127;\n var L = 1;\n sz:\n if (v > 127) {\n usz[L - 1] |= 128;\n usz[L] = v >> 7 & 127;\n ++L;\n if (v <= 16383)\n break sz;\n usz[L - 1] |= 128;\n usz[L] = v >> 14 & 127;\n ++L;\n if (v <= 2097151)\n break sz;\n usz[L - 1] |= 128;\n usz[L] = v >> 21 & 127;\n ++L;\n if (v <= 268435455)\n break sz;\n usz[L - 1] |= 128;\n usz[L] = v / 256 >>> 21 & 127;\n ++L;\n if (v <= 34359738367)\n break sz;\n usz[L - 1] |= 128;\n usz[L] = v / 65536 >>> 21 & 127;\n ++L;\n if (v <= 4398046511103)\n break sz;\n usz[L - 1] |= 128;\n usz[L] = v / 16777216 >>> 21 & 127;\n ++L;\n }\n return usz.slice(0, L);\n}\nfunction varint_to_i32(buf) {\n var l = 0, i32 = buf[l] & 127;\n varint:\n if (buf[l++] >= 128) {\n i32 |= (buf[l] & 127) << 7;\n if (buf[l++] < 128)\n break varint;\n i32 |= (buf[l] & 127) << 14;\n if (buf[l++] < 128)\n break varint;\n i32 |= (buf[l] & 127) << 21;\n if (buf[l++] < 128)\n break varint;\n i32 |= (buf[l] & 127) << 28;\n }\n return i32;\n}\nfunction parse_shallow(buf) {\n var out = [], ptr = [0];\n while (ptr[0] < buf.length) {\n var off = ptr[0];\n var num = parse_varint49(buf, ptr);\n var type = num & 7;\n num = Math.floor(num / 8);\n var len = 0;\n var res;\n if (num == 0)\n break;\n switch (type) {\n case 0:\n {\n var l = ptr[0];\n while (buf[ptr[0]++] >= 128)\n ;\n res = buf.slice(l, ptr[0]);\n }\n break;\n case 5:\n len = 4;\n res = buf.slice(ptr[0], ptr[0] + len);\n ptr[0] += len;\n break;\n case 1:\n len = 8;\n res = buf.slice(ptr[0], ptr[0] + len);\n ptr[0] += len;\n break;\n case 2:\n len = parse_varint49(buf, ptr);\n res = buf.slice(ptr[0], ptr[0] + len);\n ptr[0] += len;\n break;\n case 3:\n case 4:\n default:\n throw new Error(\"PB Type \".concat(type, \" for Field \").concat(num, \" at offset \").concat(off));\n }\n var v = { data: res, type: type };\n if (out[num] == null)\n out[num] = [v];\n else\n out[num].push(v);\n }\n return out;\n}\nfunction write_shallow(proto) {\n var out = [];\n proto.forEach(function(field, idx) {\n field.forEach(function(item) {\n if (!item.data)\n return;\n out.push(write_varint49(idx * 8 + item.type));\n if (item.type == 2)\n out.push(write_varint49(item.data.length));\n out.push(item.data);\n });\n });\n return u8concat(out);\n}\nfunction mappa(data, cb) {\n return (data == null ? void 0 : data.map(function(d) {\n return cb(d.data);\n })) || [];\n}\nfunction parse_iwa_file(buf) {\n var _a;\n var out = [], ptr = [0];\n while (ptr[0] < buf.length) {\n var len = parse_varint49(buf, ptr);\n var ai = parse_shallow(buf.slice(ptr[0], ptr[0] + len));\n ptr[0] += len;\n var res = {\n id: varint_to_i32(ai[1][0].data),\n messages: []\n };\n ai[2].forEach(function(b) {\n var mi = parse_shallow(b.data);\n var fl = varint_to_i32(mi[3][0].data);\n res.messages.push({\n meta: mi,\n data: buf.slice(ptr[0], ptr[0] + fl)\n });\n ptr[0] += fl;\n });\n if ((_a = ai[3]) == null ? void 0 : _a[0])\n res.merge = varint_to_i32(ai[3][0].data) >>> 0 > 0;\n out.push(res);\n }\n return out;\n}\nfunction write_iwa_file(ias) {\n var bufs = [];\n ias.forEach(function(ia) {\n var ai = [];\n ai[1] = [{ data: write_varint49(ia.id), type: 0 }];\n ai[2] = [];\n if (ia.merge != null)\n ai[3] = [{ data: write_varint49(+!!ia.merge), type: 0 }];\n var midata = [];\n ia.messages.forEach(function(mi) {\n midata.push(mi.data);\n mi.meta[3] = [{ type: 0, data: write_varint49(mi.data.length) }];\n ai[2].push({ data: write_shallow(mi.meta), type: 2 });\n });\n var aipayload = write_shallow(ai);\n bufs.push(write_varint49(aipayload.length));\n bufs.push(aipayload);\n midata.forEach(function(mid) {\n return bufs.push(mid);\n });\n });\n return u8concat(bufs);\n}\nfunction parse_snappy_chunk(type, buf) {\n if (type != 0)\n throw new Error(\"Unexpected Snappy chunk type \".concat(type));\n var ptr = [0];\n var usz = parse_varint49(buf, ptr);\n var chunks = [];\n while (ptr[0] < buf.length) {\n var tag = buf[ptr[0]] & 3;\n if (tag == 0) {\n var len = buf[ptr[0]++] >> 2;\n if (len < 60)\n ++len;\n else {\n var c = len - 59;\n len = buf[ptr[0]];\n if (c > 1)\n len |= buf[ptr[0] + 1] << 8;\n if (c > 2)\n len |= buf[ptr[0] + 2] << 16;\n if (c > 3)\n len |= buf[ptr[0] + 3] << 24;\n len >>>= 0;\n len++;\n ptr[0] += c;\n }\n chunks.push(buf.slice(ptr[0], ptr[0] + len));\n ptr[0] += len;\n continue;\n } else {\n var offset = 0, length = 0;\n if (tag == 1) {\n length = (buf[ptr[0]] >> 2 & 7) + 4;\n offset = (buf[ptr[0]++] & 224) << 3;\n offset |= buf[ptr[0]++];\n } else {\n length = (buf[ptr[0]++] >> 2) + 1;\n if (tag == 2) {\n offset = buf[ptr[0]] | buf[ptr[0] + 1] << 8;\n ptr[0] += 2;\n } else {\n offset = (buf[ptr[0]] | buf[ptr[0] + 1] << 8 | buf[ptr[0] + 2] << 16 | buf[ptr[0] + 3] << 24) >>> 0;\n ptr[0] += 4;\n }\n }\n chunks = [u8concat(chunks)];\n if (offset == 0)\n throw new Error(\"Invalid offset 0\");\n if (offset > chunks[0].length)\n throw new Error(\"Invalid offset beyond length\");\n if (length >= offset) {\n chunks.push(chunks[0].slice(-offset));\n length -= offset;\n while (length >= chunks[chunks.length - 1].length) {\n chunks.push(chunks[chunks.length - 1]);\n length -= chunks[chunks.length - 1].length;\n }\n }\n chunks.push(chunks[0].slice(-offset, -offset + length));\n }\n }\n var o = u8concat(chunks);\n if (o.length != usz)\n throw new Error(\"Unexpected length: \".concat(o.length, \" != \").concat(usz));\n return o;\n}\nfunction decompress_iwa_file(buf) {\n var out = [];\n var l = 0;\n while (l < buf.length) {\n var t = buf[l++];\n var len = buf[l] | buf[l + 1] << 8 | buf[l + 2] << 16;\n l += 3;\n out.push(parse_snappy_chunk(t, buf.slice(l, l + len)));\n l += len;\n }\n if (l !== buf.length)\n throw new Error(\"data is not a valid framed stream!\");\n return u8concat(out);\n}\nfunction compress_iwa_file(buf) {\n var out = [];\n var l = 0;\n while (l < buf.length) {\n var c = Math.min(buf.length - l, 268435455);\n var frame = new Uint8Array(4);\n out.push(frame);\n var usz = write_varint49(c);\n var L = usz.length;\n out.push(usz);\n if (c <= 60) {\n L++;\n out.push(new Uint8Array([c - 1 << 2]));\n } else if (c <= 256) {\n L += 2;\n out.push(new Uint8Array([240, c - 1 & 255]));\n } else if (c <= 65536) {\n L += 3;\n out.push(new Uint8Array([244, c - 1 & 255, c - 1 >> 8 & 255]));\n } else if (c <= 16777216) {\n L += 4;\n out.push(new Uint8Array([248, c - 1 & 255, c - 1 >> 8 & 255, c - 1 >> 16 & 255]));\n } else if (c <= 4294967296) {\n L += 5;\n out.push(new Uint8Array([252, c - 1 & 255, c - 1 >> 8 & 255, c - 1 >> 16 & 255, c - 1 >>> 24 & 255]));\n }\n out.push(buf.slice(l, l + c));\n L += c;\n frame[0] = 0;\n frame[1] = L & 255;\n frame[2] = L >> 8 & 255;\n frame[3] = L >> 16 & 255;\n l += c;\n }\n return u8concat(out);\n}\nfunction parse_old_storage(buf, sst, rsst, v) {\n var dv = u8_to_dataview(buf);\n var flags = dv.getUint32(4, true);\n var data_offset = (v > 1 ? 12 : 8) + popcnt(flags & (v > 1 ? 3470 : 398)) * 4;\n var ridx = -1, sidx = -1, ieee = NaN, dt = new Date(2001, 0, 1);\n if (flags & 512) {\n ridx = dv.getUint32(data_offset, true);\n data_offset += 4;\n }\n data_offset += popcnt(flags & (v > 1 ? 12288 : 4096)) * 4;\n if (flags & 16) {\n sidx = dv.getUint32(data_offset, true);\n data_offset += 4;\n }\n if (flags & 32) {\n ieee = dv.getFloat64(data_offset, true);\n data_offset += 8;\n }\n if (flags & 64) {\n dt.setTime(dt.getTime() + dv.getFloat64(data_offset, true) * 1e3);\n data_offset += 8;\n }\n var ret;\n switch (buf[2]) {\n case 0:\n break;\n case 2:\n ret = { t: \"n\", v: ieee };\n break;\n case 3:\n ret = { t: \"s\", v: sst[sidx] };\n break;\n case 5:\n ret = { t: \"d\", v: dt };\n break;\n case 6:\n ret = { t: \"b\", v: ieee > 0 };\n break;\n case 7:\n ret = { t: \"n\", v: ieee / 86400 };\n break;\n case 8:\n ret = { t: \"e\", v: 0 };\n break;\n case 9:\n {\n if (ridx > -1)\n ret = { t: \"s\", v: rsst[ridx] };\n else if (sidx > -1)\n ret = { t: \"s\", v: sst[sidx] };\n else if (!isNaN(ieee))\n ret = { t: \"n\", v: ieee };\n else\n throw new Error(\"Unsupported cell type \".concat(buf.slice(0, 4)));\n }\n break;\n default:\n throw new Error(\"Unsupported cell type \".concat(buf.slice(0, 4)));\n }\n return ret;\n}\nfunction parse_new_storage(buf, sst, rsst) {\n var dv = u8_to_dataview(buf);\n var flags = dv.getUint32(8, true);\n var data_offset = 12;\n var ridx = -1, sidx = -1, d128 = NaN, ieee = NaN, dt = new Date(2001, 0, 1);\n if (flags & 1) {\n d128 = readDecimal128LE(buf, data_offset);\n data_offset += 16;\n }\n if (flags & 2) {\n ieee = dv.getFloat64(data_offset, true);\n data_offset += 8;\n }\n if (flags & 4) {\n dt.setTime(dt.getTime() + dv.getFloat64(data_offset, true) * 1e3);\n data_offset += 8;\n }\n if (flags & 8) {\n sidx = dv.getUint32(data_offset, true);\n data_offset += 4;\n }\n if (flags & 16) {\n ridx = dv.getUint32(data_offset, true);\n data_offset += 4;\n }\n var ret;\n switch (buf[1]) {\n case 0:\n break;\n case 2:\n ret = { t: \"n\", v: d128 };\n break;\n case 3:\n ret = { t: \"s\", v: sst[sidx] };\n break;\n case 5:\n ret = { t: \"d\", v: dt };\n break;\n case 6:\n ret = { t: \"b\", v: ieee > 0 };\n break;\n case 7:\n ret = { t: \"n\", v: ieee / 86400 };\n break;\n case 8:\n ret = { t: \"e\", v: 0 };\n break;\n case 9:\n {\n if (ridx > -1)\n ret = { t: \"s\", v: rsst[ridx] };\n else\n throw new Error(\"Unsupported cell type \".concat(buf[1], \" : \").concat(flags & 31, \" : \").concat(buf.slice(0, 4)));\n }\n break;\n case 10:\n ret = { t: \"n\", v: d128 };\n break;\n default:\n throw new Error(\"Unsupported cell type \".concat(buf[1], \" : \").concat(flags & 31, \" : \").concat(buf.slice(0, 4)));\n }\n return ret;\n}\nfunction write_new_storage(cell, sst) {\n var out = new Uint8Array(32), dv = u8_to_dataview(out), l = 12, flags = 0;\n out[0] = 5;\n switch (cell.t) {\n case \"n\":\n out[1] = 2;\n writeDecimal128LE(out, l, cell.v);\n flags |= 1;\n l += 16;\n break;\n case \"b\":\n out[1] = 6;\n dv.setFloat64(l, cell.v ? 1 : 0, true);\n flags |= 2;\n l += 8;\n break;\n case \"s\":\n if (sst.indexOf(cell.v) == -1)\n throw new Error(\"Value \".concat(cell.v, \" missing from SST!\"));\n out[1] = 3;\n dv.setUint32(l, sst.indexOf(cell.v), true);\n flags |= 8;\n l += 4;\n break;\n default:\n throw \"unsupported cell type \" + cell.t;\n }\n dv.setUint32(8, flags, true);\n return out.slice(0, l);\n}\nfunction write_old_storage(cell, sst) {\n var out = new Uint8Array(32), dv = u8_to_dataview(out), l = 12, flags = 0;\n out[0] = 3;\n switch (cell.t) {\n case \"n\":\n out[2] = 2;\n dv.setFloat64(l, cell.v, true);\n flags |= 32;\n l += 8;\n break;\n case \"b\":\n out[2] = 6;\n dv.setFloat64(l, cell.v ? 1 : 0, true);\n flags |= 32;\n l += 8;\n break;\n case \"s\":\n if (sst.indexOf(cell.v) == -1)\n throw new Error(\"Value \".concat(cell.v, \" missing from SST!\"));\n out[2] = 3;\n dv.setUint32(l, sst.indexOf(cell.v), true);\n flags |= 16;\n l += 4;\n break;\n default:\n throw \"unsupported cell type \" + cell.t;\n }\n dv.setUint32(4, flags, true);\n return out.slice(0, l);\n}\nfunction parse_cell_storage(buf, sst, rsst) {\n switch (buf[0]) {\n case 0:\n case 1:\n case 2:\n case 3:\n return parse_old_storage(buf, sst, rsst, buf[0]);\n case 5:\n return parse_new_storage(buf, sst, rsst);\n default:\n throw new Error(\"Unsupported payload version \".concat(buf[0]));\n }\n}\nfunction parse_TSP_Reference(buf) {\n var pb = parse_shallow(buf);\n return parse_varint49(pb[1][0].data);\n}\nfunction write_TSP_Reference(idx) {\n var out = [];\n out[1] = [{ type: 0, data: write_varint49(idx) }];\n return write_shallow(out);\n}\nfunction parse_TST_TableDataList(M, root) {\n var pb = parse_shallow(root.data);\n var type = varint_to_i32(pb[1][0].data);\n var entries = pb[3];\n var data = [];\n (entries || []).forEach(function(entry) {\n var le = parse_shallow(entry.data);\n var key = varint_to_i32(le[1][0].data) >>> 0;\n switch (type) {\n case 1:\n data[key] = u8str(le[3][0].data);\n break;\n case 8:\n {\n var rt = M[parse_TSP_Reference(le[9][0].data)][0];\n var rtp = parse_shallow(rt.data);\n var rtpref = M[parse_TSP_Reference(rtp[1][0].data)][0];\n var mtype = varint_to_i32(rtpref.meta[1][0].data);\n if (mtype != 2001)\n throw new Error(\"2000 unexpected reference to \".concat(mtype));\n var tswpsa = parse_shallow(rtpref.data);\n data[key] = tswpsa[3].map(function(x) {\n return u8str(x.data);\n }).join(\"\");\n }\n break;\n }\n });\n return data;\n}\nfunction parse_TST_TileRowInfo(u8, type) {\n var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;\n var pb = parse_shallow(u8);\n var R = varint_to_i32(pb[1][0].data) >>> 0;\n var cnt = varint_to_i32(pb[2][0].data) >>> 0;\n var wide_offsets = ((_b = (_a = pb[8]) == null ? void 0 : _a[0]) == null ? void 0 : _b.data) && varint_to_i32(pb[8][0].data) > 0 || false;\n var used_storage_u8, used_storage;\n if (((_d = (_c = pb[7]) == null ? void 0 : _c[0]) == null ? void 0 : _d.data) && type != 0) {\n used_storage_u8 = (_f = (_e = pb[7]) == null ? void 0 : _e[0]) == null ? void 0 : _f.data;\n used_storage = (_h = (_g = pb[6]) == null ? void 0 : _g[0]) == null ? void 0 : _h.data;\n } else if (((_j = (_i = pb[4]) == null ? void 0 : _i[0]) == null ? void 0 : _j.data) && type != 1) {\n used_storage_u8 = (_l = (_k = pb[4]) == null ? void 0 : _k[0]) == null ? void 0 : _l.data;\n used_storage = (_n = (_m = pb[3]) == null ? void 0 : _m[0]) == null ? void 0 : _n.data;\n } else\n throw \"NUMBERS Tile missing \".concat(type, \" cell storage\");\n var width = wide_offsets ? 4 : 1;\n var used_storage_offsets = u8_to_dataview(used_storage_u8);\n var offsets = [];\n for (var C = 0; C < used_storage_u8.length / 2; ++C) {\n var off = used_storage_offsets.getUint16(C * 2, true);\n if (off < 65535)\n offsets.push([C, off]);\n }\n if (offsets.length != cnt)\n throw \"Expected \".concat(cnt, \" cells, found \").concat(offsets.length);\n var cells = [];\n for (C = 0; C < offsets.length - 1; ++C)\n cells[offsets[C][0]] = used_storage.subarray(offsets[C][1] * width, offsets[C + 1][1] * width);\n if (offsets.length >= 1)\n cells[offsets[offsets.length - 1][0]] = used_storage.subarray(offsets[offsets.length - 1][1] * width);\n return { R: R, cells: cells };\n}\nfunction parse_TST_Tile(M, root) {\n var _a;\n var pb = parse_shallow(root.data);\n var storage = ((_a = pb == null ? void 0 : pb[7]) == null ? void 0 : _a[0]) ? varint_to_i32(pb[7][0].data) >>> 0 > 0 ? 1 : 0 : -1;\n var ri = mappa(pb[5], function(u8) {\n return parse_TST_TileRowInfo(u8, storage);\n });\n return {\n nrows: varint_to_i32(pb[4][0].data) >>> 0,\n data: ri.reduce(function(acc, x) {\n if (!acc[x.R])\n acc[x.R] = [];\n x.cells.forEach(function(cell, C) {\n if (acc[x.R][C])\n throw new Error(\"Duplicate cell r=\".concat(x.R, \" c=\").concat(C));\n acc[x.R][C] = cell;\n });\n return acc;\n }, [])\n };\n}\nfunction parse_TST_TableModelArchive(M, root, ws) {\n var _a;\n var pb = parse_shallow(root.data);\n var range = { s: { r: 0, c: 0 }, e: { r: 0, c: 0 } };\n range.e.r = (varint_to_i32(pb[6][0].data) >>> 0) - 1;\n if (range.e.r < 0)\n throw new Error(\"Invalid row varint \".concat(pb[6][0].data));\n range.e.c = (varint_to_i32(pb[7][0].data) >>> 0) - 1;\n if (range.e.c < 0)\n throw new Error(\"Invalid col varint \".concat(pb[7][0].data));\n ws[\"!ref\"] = encode_range(range);\n var store = parse_shallow(pb[4][0].data);\n var sst = parse_TST_TableDataList(M, M[parse_TSP_Reference(store[4][0].data)][0]);\n var rsst = ((_a = store[17]) == null ? void 0 : _a[0]) ? parse_TST_TableDataList(M, M[parse_TSP_Reference(store[17][0].data)][0]) : [];\n var tile = parse_shallow(store[3][0].data);\n var _R = 0;\n tile[1].forEach(function(t) {\n var tl = parse_shallow(t.data);\n var ref = M[parse_TSP_Reference(tl[2][0].data)][0];\n var mtype = varint_to_i32(ref.meta[1][0].data);\n if (mtype != 6002)\n throw new Error(\"6001 unexpected reference to \".concat(mtype));\n var _tile = parse_TST_Tile(M, ref);\n _tile.data.forEach(function(row, R) {\n row.forEach(function(buf, C) {\n var addr = encode_cell({ r: _R + R, c: C });\n var res = parse_cell_storage(buf, sst, rsst);\n if (res)\n ws[addr] = res;\n });\n });\n _R += _tile.nrows;\n });\n}\nfunction parse_TST_TableInfoArchive(M, root) {\n var pb = parse_shallow(root.data);\n var out = { \"!ref\": \"A1\" };\n var tableref = M[parse_TSP_Reference(pb[2][0].data)];\n var mtype = varint_to_i32(tableref[0].meta[1][0].data);\n if (mtype != 6001)\n throw new Error(\"6000 unexpected reference to \".concat(mtype));\n parse_TST_TableModelArchive(M, tableref[0], out);\n return out;\n}\nfunction parse_TN_SheetArchive(M, root) {\n var _a;\n var pb = parse_shallow(root.data);\n var out = {\n name: ((_a = pb[1]) == null ? void 0 : _a[0]) ? u8str(pb[1][0].data) : \"\",\n sheets: []\n };\n var shapeoffs = mappa(pb[2], parse_TSP_Reference);\n shapeoffs.forEach(function(off) {\n M[off].forEach(function(m) {\n var mtype = varint_to_i32(m.meta[1][0].data);\n if (mtype == 6e3)\n out.sheets.push(parse_TST_TableInfoArchive(M, m));\n });\n });\n return out;\n}\nfunction parse_TN_DocumentArchive(M, root) {\n var out = book_new();\n var pb = parse_shallow(root.data);\n var sheetoffs = mappa(pb[1], parse_TSP_Reference);\n sheetoffs.forEach(function(off) {\n M[off].forEach(function(m) {\n var mtype = varint_to_i32(m.meta[1][0].data);\n if (mtype == 2) {\n var root2 = parse_TN_SheetArchive(M, m);\n root2.sheets.forEach(function(sheet, idx) {\n book_append_sheet(out, sheet, idx == 0 ? root2.name : root2.name + \"_\" + idx, true);\n });\n }\n });\n });\n if (out.SheetNames.length == 0)\n throw new Error(\"Empty NUMBERS file\");\n return out;\n}\nfunction parse_numbers_iwa(cfb) {\n var _a, _b, _c, _d;\n var M = {}, indices = [];\n cfb.FullPaths.forEach(function(p) {\n if (p.match(/\\.iwpv2/))\n throw new Error(\"Unsupported password protection\");\n });\n cfb.FileIndex.forEach(function(s) {\n if (!s.name.match(/\\.iwa$/))\n return;\n var o;\n try {\n o = decompress_iwa_file(s.content);\n } catch (e) {\n return console.log(\"?? \" + s.content.length + \" \" + (e.message || e));\n }\n var packets;\n try {\n packets = parse_iwa_file(o);\n } catch (e) {\n return console.log(\"## \" + (e.message || e));\n }\n packets.forEach(function(packet) {\n M[packet.id] = packet.messages;\n indices.push(packet.id);\n });\n });\n if (!indices.length)\n throw new Error(\"File has no messages\");\n var docroot = ((_d = (_c = (_b = (_a = M == null ? void 0 : M[1]) == null ? void 0 : _a[0]) == null ? void 0 : _b.meta) == null ? void 0 : _c[1]) == null ? void 0 : _d[0].data) && varint_to_i32(M[1][0].meta[1][0].data) == 1 && M[1][0];\n if (!docroot)\n indices.forEach(function(idx) {\n M[idx].forEach(function(iwam) {\n var mtype = varint_to_i32(iwam.meta[1][0].data) >>> 0;\n if (mtype == 1) {\n if (!docroot)\n docroot = iwam;\n else\n throw new Error(\"Document has multiple roots\");\n }\n });\n });\n if (!docroot)\n throw new Error(\"Cannot find Document root\");\n return parse_TN_DocumentArchive(M, docroot);\n}\nfunction write_tile_row(tri, data, SST) {\n var _a, _b, _c, _d;\n if (!((_a = tri[6]) == null ? void 0 : _a[0]) || !((_b = tri[7]) == null ? void 0 : _b[0]))\n throw \"Mutation only works on post-BNC storages!\";\n var wide_offsets = ((_d = (_c = tri[8]) == null ? void 0 : _c[0]) == null ? void 0 : _d.data) && varint_to_i32(tri[8][0].data) > 0 || false;\n if (wide_offsets)\n throw \"Math only works with normal offsets\";\n var cnt = 0;\n var dv = u8_to_dataview(tri[7][0].data), last_offset = 0, cell_storage = [];\n var _dv = u8_to_dataview(tri[4][0].data), _last_offset = 0, _cell_storage = [];\n for (var C = 0; C < data.length; ++C) {\n if (data[C] == null) {\n dv.setUint16(C * 2, 65535, true);\n _dv.setUint16(C * 2, 65535);\n continue;\n }\n dv.setUint16(C * 2, last_offset, true);\n _dv.setUint16(C * 2, _last_offset, true);\n var celload, _celload;\n switch (typeof data[C]) {\n case \"string\":\n celload = write_new_storage({ t: \"s\", v: data[C] }, SST);\n _celload = write_old_storage({ t: \"s\", v: data[C] }, SST);\n break;\n case \"number\":\n celload = write_new_storage({ t: \"n\", v: data[C] }, SST);\n _celload = write_old_storage({ t: \"n\", v: data[C] }, SST);\n break;\n case \"boolean\":\n celload = write_new_storage({ t: \"b\", v: data[C] }, SST);\n _celload = write_old_storage({ t: \"b\", v: data[C] }, SST);\n break;\n default:\n throw new Error(\"Unsupported value \" + data[C]);\n }\n cell_storage.push(celload);\n last_offset += celload.length;\n _cell_storage.push(_celload);\n _last_offset += _celload.length;\n ++cnt;\n }\n tri[2][0].data = write_varint49(cnt);\n for (; C < tri[7][0].data.length / 2; ++C) {\n dv.setUint16(C * 2, 65535, true);\n _dv.setUint16(C * 2, 65535, true);\n }\n tri[6][0].data = u8concat(cell_storage);\n tri[3][0].data = u8concat(_cell_storage);\n return cnt;\n}\nfunction write_numbers_iwa(wb, opts) {\n if (!opts || !opts.numbers)\n throw new Error(\"Must pass a `numbers` option -- check the README\");\n var ws = wb.Sheets[wb.SheetNames[0]];\n if (wb.SheetNames.length > 1)\n console.error(\"The Numbers writer currently writes only the first table\");\n var range = decode_range(ws[\"!ref\"]);\n range.s.r = range.s.c = 0;\n var trunc = false;\n if (range.e.c > 9) {\n trunc = true;\n range.e.c = 9;\n }\n if (range.e.r > 49) {\n trunc = true;\n range.e.r = 49;\n }\n if (trunc)\n console.error(\"The Numbers writer is currently limited to \".concat(encode_range(range)));\n var data = sheet_to_json(ws, { range: range, header: 1 });\n var SST = [\"~Sh33tJ5~\"];\n data.forEach(function(row) {\n return row.forEach(function(cell) {\n if (typeof cell == \"string\")\n SST.push(cell);\n });\n });\n var dependents = {};\n var indices = [];\n var cfb = CFB.read(opts.numbers, { type: \"base64\" });\n cfb.FileIndex.map(function(fi, idx) {\n return [fi, cfb.FullPaths[idx]];\n }).forEach(function(row) {\n var fi = row[0], fp = row[1];\n if (fi.type != 2)\n return;\n if (!fi.name.match(/\\.iwa/))\n return;\n var old_content = fi.content;\n var raw1 = decompress_iwa_file(old_content);\n var x2 = parse_iwa_file(raw1);\n x2.forEach(function(packet2) {\n indices.push(packet2.id);\n dependents[packet2.id] = { deps: [], location: fp, type: varint_to_i32(packet2.messages[0].meta[1][0].data) };\n });\n });\n indices.sort(function(x2, y2) {\n return x2 - y2;\n });\n var indices_varint = indices.filter(function(x2) {\n return x2 > 1;\n }).map(function(x2) {\n return [x2, write_varint49(x2)];\n });\n cfb.FileIndex.map(function(fi, idx) {\n return [fi, cfb.FullPaths[idx]];\n }).forEach(function(row) {\n var fi = row[0], fp = row[1];\n if (!fi.name.match(/\\.iwa/))\n return;\n var x2 = parse_iwa_file(decompress_iwa_file(fi.content));\n x2.forEach(function(ia) {\n ia.messages.forEach(function(m) {\n indices_varint.forEach(function(ivi) {\n if (ia.messages.some(function(mess) {\n return varint_to_i32(mess.meta[1][0].data) != 11006 && u8contains(mess.data, ivi[1]);\n })) {\n dependents[ivi[0]].deps.push(ia.id);\n }\n });\n });\n });\n });\n function get_unique_msgid() {\n for (var i = 927262; i < 2e6; ++i)\n if (!dependents[i])\n return i;\n throw new Error(\"Too many messages\");\n }\n var entry = CFB.find(cfb, dependents[1].location);\n var x = parse_iwa_file(decompress_iwa_file(entry.content));\n var docroot;\n for (var xi = 0; xi < x.length; ++xi) {\n var packet = x[xi];\n if (packet.id == 1)\n docroot = packet;\n }\n var sheetrootref = parse_TSP_Reference(parse_shallow(docroot.messages[0].data)[1][0].data);\n entry = CFB.find(cfb, dependents[sheetrootref].location);\n x = parse_iwa_file(decompress_iwa_file(entry.content));\n for (xi = 0; xi < x.length; ++xi) {\n packet = x[xi];\n if (packet.id == sheetrootref)\n docroot = packet;\n }\n sheetrootref = parse_TSP_Reference(parse_shallow(docroot.messages[0].data)[2][0].data);\n entry = CFB.find(cfb, dependents[sheetrootref].location);\n x = parse_iwa_file(decompress_iwa_file(entry.content));\n for (xi = 0; xi < x.length; ++xi) {\n packet = x[xi];\n if (packet.id == sheetrootref)\n docroot = packet;\n }\n sheetrootref = parse_TSP_Reference(parse_shallow(docroot.messages[0].data)[2][0].data);\n entry = CFB.find(cfb, dependents[sheetrootref].location);\n x = parse_iwa_file(decompress_iwa_file(entry.content));\n for (xi = 0; xi < x.length; ++xi) {\n packet = x[xi];\n if (packet.id == sheetrootref)\n docroot = packet;\n }\n var pb = parse_shallow(docroot.messages[0].data);\n {\n pb[6][0].data = write_varint49(range.e.r + 1);\n pb[7][0].data = write_varint49(range.e.c + 1);\n var cruidsref = parse_TSP_Reference(pb[46][0].data);\n var oldbucket = CFB.find(cfb, dependents[cruidsref].location);\n var _x = parse_iwa_file(decompress_iwa_file(oldbucket.content));\n {\n for (var j = 0; j < _x.length; ++j) {\n if (_x[j].id == cruidsref)\n break;\n }\n if (_x[j].id != cruidsref)\n throw \"Bad ColumnRowUIDMapArchive\";\n var cruids = parse_shallow(_x[j].messages[0].data);\n cruids[1] = [];\n cruids[2] = [], cruids[3] = [];\n for (var C = 0; C <= range.e.c; ++C) {\n var uuid = [];\n uuid[1] = uuid[2] = [{ type: 0, data: write_varint49(C + 420690) }];\n cruids[1].push({ type: 2, data: write_shallow(uuid) });\n cruids[2].push({ type: 0, data: write_varint49(C) });\n cruids[3].push({ type: 0, data: write_varint49(C) });\n }\n cruids[4] = [];\n cruids[5] = [], cruids[6] = [];\n for (var R = 0; R <= range.e.r; ++R) {\n uuid = [];\n uuid[1] = uuid[2] = [{ type: 0, data: write_varint49(R + 726270) }];\n cruids[4].push({ type: 2, data: write_shallow(uuid) });\n cruids[5].push({ type: 0, data: write_varint49(R) });\n cruids[6].push({ type: 0, data: write_varint49(R) });\n }\n _x[j].messages[0].data = write_shallow(cruids);\n }\n oldbucket.content = compress_iwa_file(write_iwa_file(_x));\n oldbucket.size = oldbucket.content.length;\n delete pb[46];\n var store = parse_shallow(pb[4][0].data);\n {\n store[7][0].data = write_varint49(range.e.r + 1);\n var row_headers = parse_shallow(store[1][0].data);\n var row_header_ref = parse_TSP_Reference(row_headers[2][0].data);\n oldbucket = CFB.find(cfb, dependents[row_header_ref].location);\n _x = parse_iwa_file(decompress_iwa_file(oldbucket.content));\n {\n if (_x[0].id != row_header_ref)\n throw \"Bad HeaderStorageBucket\";\n var base_bucket = parse_shallow(_x[0].messages[0].data);\n for (R = 0; R < data.length; ++R) {\n var _bucket = parse_shallow(base_bucket[2][0].data);\n _bucket[1][0].data = write_varint49(R);\n _bucket[4][0].data = write_varint49(data[R].length);\n base_bucket[2][R] = { type: base_bucket[2][0].type, data: write_shallow(_bucket) };\n }\n _x[0].messages[0].data = write_shallow(base_bucket);\n }\n oldbucket.content = compress_iwa_file(write_iwa_file(_x));\n oldbucket.size = oldbucket.content.length;\n var col_header_ref = parse_TSP_Reference(store[2][0].data);\n oldbucket = CFB.find(cfb, dependents[col_header_ref].location);\n _x = parse_iwa_file(decompress_iwa_file(oldbucket.content));\n {\n if (_x[0].id != col_header_ref)\n throw \"Bad HeaderStorageBucket\";\n base_bucket = parse_shallow(_x[0].messages[0].data);\n for (C = 0; C <= range.e.c; ++C) {\n _bucket = parse_shallow(base_bucket[2][0].data);\n _bucket[1][0].data = write_varint49(C);\n _bucket[4][0].data = write_varint49(range.e.r + 1);\n base_bucket[2][C] = { type: base_bucket[2][0].type, data: write_shallow(_bucket) };\n }\n _x[0].messages[0].data = write_shallow(base_bucket);\n }\n oldbucket.content = compress_iwa_file(write_iwa_file(_x));\n oldbucket.size = oldbucket.content.length;\n var sstref = parse_TSP_Reference(store[4][0].data);\n (function() {\n var sentry = CFB.find(cfb, dependents[sstref].location);\n var sx = parse_iwa_file(decompress_iwa_file(sentry.content));\n var sstroot;\n for (var sxi = 0; sxi < sx.length; ++sxi) {\n var packet2 = sx[sxi];\n if (packet2.id == sstref)\n sstroot = packet2;\n }\n var sstdata = parse_shallow(sstroot.messages[0].data);\n {\n sstdata[3] = [];\n var newsst = [];\n SST.forEach(function(str, i) {\n newsst[1] = [{ type: 0, data: write_varint49(i) }];\n newsst[2] = [{ type: 0, data: write_varint49(1) }];\n newsst[3] = [{ type: 2, data: stru8(str) }];\n sstdata[3].push({ type: 2, data: write_shallow(newsst) });\n });\n }\n sstroot.messages[0].data = write_shallow(sstdata);\n var sy = write_iwa_file(sx);\n var raw32 = compress_iwa_file(sy);\n sentry.content = raw32;\n sentry.size = sentry.content.length;\n })();\n var tile = parse_shallow(store[3][0].data);\n {\n var t = tile[1][0];\n delete tile[2];\n var tl = parse_shallow(t.data);\n {\n var tileref = parse_TSP_Reference(tl[2][0].data);\n (function() {\n var tentry = CFB.find(cfb, dependents[tileref].location);\n var tx = parse_iwa_file(decompress_iwa_file(tentry.content));\n var tileroot;\n for (var sxi = 0; sxi < tx.length; ++sxi) {\n var packet2 = tx[sxi];\n if (packet2.id == tileref)\n tileroot = packet2;\n }\n var tiledata = parse_shallow(tileroot.messages[0].data);\n {\n delete tiledata[6];\n delete tile[7];\n var rowload = new Uint8Array(tiledata[5][0].data);\n tiledata[5] = [];\n var cnt = 0;\n for (var R2 = 0; R2 <= range.e.r; ++R2) {\n var tilerow = parse_shallow(rowload);\n cnt += write_tile_row(tilerow, data[R2], SST);\n tilerow[1][0].data = write_varint49(R2);\n tiledata[5].push({ data: write_shallow(tilerow), type: 2 });\n }\n tiledata[1] = [{ type: 0, data: write_varint49(range.e.c + 1) }];\n tiledata[2] = [{ type: 0, data: write_varint49(range.e.r + 1) }];\n tiledata[3] = [{ type: 0, data: write_varint49(cnt) }];\n tiledata[4] = [{ type: 0, data: write_varint49(range.e.r + 1) }];\n }\n tileroot.messages[0].data = write_shallow(tiledata);\n var ty = write_iwa_file(tx);\n var raw32 = compress_iwa_file(ty);\n tentry.content = raw32;\n tentry.size = tentry.content.length;\n })();\n }\n t.data = write_shallow(tl);\n }\n store[3][0].data = write_shallow(tile);\n }\n pb[4][0].data = write_shallow(store);\n }\n docroot.messages[0].data = write_shallow(pb);\n var y = write_iwa_file(x);\n var raw3 = compress_iwa_file(y);\n entry.content = raw3;\n entry.size = entry.content.length;\n return cfb;\n}\nfunction fix_opts_func(defaults/*:Array >*/)/*:{(o:any):void}*/ {\n\treturn function fix_opts(opts) {\n\t\tfor(var i = 0; i != defaults.length; ++i) {\n\t\t\tvar d = defaults[i];\n\t\t\tif(opts[d[0]] === undefined) opts[d[0]] = d[1];\n\t\t\tif(d[2] === 'n') opts[d[0]] = Number(opts[d[0]]);\n\t\t}\n\t};\n}\n\nfunction fix_read_opts(opts) {\nfix_opts_func([\n\t['cellNF', false], /* emit cell number format string as .z */\n\t['cellHTML', true], /* emit html string as .h */\n\t['cellFormula', true], /* emit formulae as .f */\n\t['cellStyles', false], /* emits style/theme as .s */\n\t['cellText', true], /* emit formatted text as .w */\n\t['cellDates', false], /* emit date cells with type `d` */\n\n\t['sheetStubs', false], /* emit empty cells */\n\t['sheetRows', 0, 'n'], /* read n rows (0 = read all rows) */\n\n\t['bookDeps', false], /* parse calculation chains */\n\t['bookSheets', false], /* only try to get sheet names (no Sheets) */\n\t['bookProps', false], /* only try to get properties (no Sheets) */\n\t['bookFiles', false], /* include raw file structure (keys, files, cfb) */\n\t['bookVBA', false], /* include vba raw data (vbaraw) */\n\n\t['password',''], /* password */\n\t['WTF', false] /* WTF mode (throws errors) */\n])(opts);\n}\n\nfunction fix_write_opts(opts) {\nfix_opts_func([\n\t['cellDates', false], /* write date cells with type `d` */\n\n\t['bookSST', false], /* Generate Shared String Table */\n\n\t['bookType', 'xlsx'], /* Type of workbook (xlsx/m/b) */\n\n\t['compression', false], /* Use file compression */\n\n\t['WTF', false] /* WTF mode (throws errors) */\n])(opts);\n}\nfunction get_sheet_type(n/*:string*/)/*:string*/ {\n\tif(RELS.WS.indexOf(n) > -1) return \"sheet\";\n\tif(RELS.CS && n == RELS.CS) return \"chart\";\n\tif(RELS.DS && n == RELS.DS) return \"dialog\";\n\tif(RELS.MS && n == RELS.MS) return \"macro\";\n\treturn (n && n.length) ? n : \"sheet\";\n}\nfunction safe_parse_wbrels(wbrels, sheets) {\n\tif(!wbrels) return 0;\n\ttry {\n\t\twbrels = sheets.map(function pwbr(w) { if(!w.id) w.id = w.strRelID; return [w.name, wbrels['!id'][w.id].Target, get_sheet_type(wbrels['!id'][w.id].Type)]; });\n\t} catch(e) { return null; }\n\treturn !wbrels || wbrels.length === 0 ? null : wbrels;\n}\n\nfunction safe_parse_sheet(zip, path/*:string*/, relsPath/*:string*/, sheet, idx/*:number*/, sheetRels, sheets, stype/*:string*/, opts, wb, themes, styles) {\n\ttry {\n\t\tsheetRels[sheet]=parse_rels(getzipstr(zip, relsPath, true), path);\n\t\tvar data = getzipdata(zip, path);\n\t\tvar _ws;\n\t\tswitch(stype) {\n\t\t\tcase 'sheet': _ws = parse_ws(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;\n\t\t\tcase 'chart': _ws = parse_cs(data, path, idx, opts, sheetRels[sheet], wb, themes, styles);\n\t\t\t\tif(!_ws || !_ws['!drawel']) break;\n\t\t\t\tvar dfile = resolve_path(_ws['!drawel'].Target, path);\n\t\t\t\tvar drelsp = get_rels_path(dfile);\n\t\t\t\tvar draw = parse_drawing(getzipstr(zip, dfile, true), parse_rels(getzipstr(zip, drelsp, true), dfile));\n\t\t\t\tvar chartp = resolve_path(draw, dfile);\n\t\t\t\tvar crelsp = get_rels_path(chartp);\n\t\t\t\t_ws = parse_chart(getzipstr(zip, chartp, true), chartp, opts, parse_rels(getzipstr(zip, crelsp, true), chartp), wb, _ws);\n\t\t\t\tbreak;\n\t\t\tcase 'macro': _ws = parse_ms(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;\n\t\t\tcase 'dialog': _ws = parse_ds(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;\n\t\t\tdefault: throw new Error(\"Unrecognized sheet type \" + stype);\n\t\t}\n\t\tsheets[sheet] = _ws;\n\n\t\t/* scan rels for comments and threaded comments */\n\t\tvar tcomments = [];\n\t\tif(sheetRels && sheetRels[sheet]) keys(sheetRels[sheet]).forEach(function(n) {\n\t\t\tvar dfile = \"\";\n\t\t\tif(sheetRels[sheet][n].Type == RELS.CMNT) {\n\t\t\t\tdfile = resolve_path(sheetRels[sheet][n].Target, path);\n\t\t\t\tvar comments = parse_cmnt(getzipdata(zip, dfile, true), dfile, opts);\n\t\t\t\tif(!comments || !comments.length) return;\n\t\t\t\tsheet_insert_comments(_ws, comments, false);\n\t\t\t}\n\t\t\tif(sheetRels[sheet][n].Type == RELS.TCMNT) {\n\t\t\t\tdfile = resolve_path(sheetRels[sheet][n].Target, path);\n\t\t\t\ttcomments = tcomments.concat(parse_tcmnt_xml(getzipdata(zip, dfile, true), opts));\n\t\t\t}\n\t\t});\n\t\tif(tcomments && tcomments.length) sheet_insert_comments(_ws, tcomments, true, opts.people || []);\n\t} catch(e) { if(opts.WTF) throw e; }\n}\n\nfunction strip_front_slash(x/*:string*/)/*:string*/ { return x.charAt(0) == '/' ? x.slice(1) : x; }\n\nfunction parse_zip(zip/*:ZIP*/, opts/*:?ParseOpts*/)/*:Workbook*/ {\n\tmake_ssf();\n\topts = opts || {};\n\tfix_read_opts(opts);\n\n\t/* OpenDocument Part 3 Section 2.2.1 OpenDocument Package */\n\tif(safegetzipfile(zip, 'META-INF/manifest.xml')) return parse_ods(zip, opts);\n\t/* UOC */\n\tif(safegetzipfile(zip, 'objectdata.xml')) return parse_ods(zip, opts);\n\t/* Numbers */\n\tif(safegetzipfile(zip, 'Index/Document.iwa')) {\n\t\tif(typeof Uint8Array == \"undefined\") throw new Error('NUMBERS file parsing requires Uint8Array support');\n\t\tif(typeof parse_numbers_iwa != \"undefined\") {\n\t\t\tif(zip.FileIndex) return parse_numbers_iwa(zip);\n\t\t\tvar _zip = CFB.utils.cfb_new();\n\t\t\tzipentries(zip).forEach(function(e) { zip_add_file(_zip, e, getzipbin(zip, e)); });\n\t\t\treturn parse_numbers_iwa(_zip);\n\t\t}\n\t\tthrow new Error('Unsupported NUMBERS file');\n\t}\n\tif(!safegetzipfile(zip, '[Content_Types].xml')) {\n\t\tif(safegetzipfile(zip, 'index.xml.gz')) throw new Error('Unsupported NUMBERS 08 file');\n\t\tif(safegetzipfile(zip, 'index.xml')) throw new Error('Unsupported NUMBERS 09 file');\n\t\tthrow new Error('Unsupported ZIP file');\n\t}\n\n\tvar entries = zipentries(zip);\n\tvar dir = parse_ct((getzipstr(zip, '[Content_Types].xml')/*:?any*/));\n\tvar xlsb = false;\n\tvar sheets, binname;\n\tif(dir.workbooks.length === 0) {\n\t\tbinname = \"xl/workbook.xml\";\n\t\tif(getzipdata(zip,binname, true)) dir.workbooks.push(binname);\n\t}\n\tif(dir.workbooks.length === 0) {\n\t\tbinname = \"xl/workbook.bin\";\n\t\tif(!getzipdata(zip,binname,true)) throw new Error(\"Could not find workbook\");\n\t\tdir.workbooks.push(binname);\n\t\txlsb = true;\n\t}\n\tif(dir.workbooks[0].slice(-3) == \"bin\") xlsb = true;\n\n\tvar themes = ({}/*:any*/);\n\tvar styles = ({}/*:any*/);\n\tif(!opts.bookSheets && !opts.bookProps) {\n\t\tstrs = [];\n\t\tif(dir.sst) try { strs=parse_sst(getzipdata(zip, strip_front_slash(dir.sst)), dir.sst, opts); } catch(e) { if(opts.WTF) throw e; }\n\n\t\tif(opts.cellStyles && dir.themes.length) themes = parse_theme(getzipstr(zip, dir.themes[0].replace(/^\\//,''), true)||\"\",dir.themes[0], opts);\n\n\t\tif(dir.style) styles = parse_sty(getzipdata(zip, strip_front_slash(dir.style)), dir.style, themes, opts);\n\t}\n\n\t/*var externbooks = */dir.links.map(function(link) {\n\t\ttry {\n\t\t\tvar rels = parse_rels(getzipstr(zip, get_rels_path(strip_front_slash(link))), link);\n\t\t\treturn parse_xlink(getzipdata(zip, strip_front_slash(link)), rels, link, opts);\n\t\t} catch(e) {}\n\t});\n\n\tvar wb = parse_wb(getzipdata(zip, strip_front_slash(dir.workbooks[0])), dir.workbooks[0], opts);\n\n\tvar props = {}, propdata = \"\";\n\n\tif(dir.coreprops.length) {\n\t\tpropdata = getzipdata(zip, strip_front_slash(dir.coreprops[0]), true);\n\t\tif(propdata) props = parse_core_props(propdata);\n\t\tif(dir.extprops.length !== 0) {\n\t\t\tpropdata = getzipdata(zip, strip_front_slash(dir.extprops[0]), true);\n\t\t\tif(propdata) parse_ext_props(propdata, props, opts);\n\t\t}\n\t}\n\n\tvar custprops = {};\n\tif(!opts.bookSheets || opts.bookProps) {\n\t\tif (dir.custprops.length !== 0) {\n\t\t\tpropdata = getzipstr(zip, strip_front_slash(dir.custprops[0]), true);\n\t\t\tif(propdata) custprops = parse_cust_props(propdata, opts);\n\t\t}\n\t}\n\n\tvar out = ({}/*:any*/);\n\tif(opts.bookSheets || opts.bookProps) {\n\t\tif(wb.Sheets) sheets = wb.Sheets.map(function pluck(x){ return x.name; });\n\t\telse if(props.Worksheets && props.SheetNames.length > 0) sheets=props.SheetNames;\n\t\tif(opts.bookProps) { out.Props = props; out.Custprops = custprops; }\n\t\tif(opts.bookSheets && typeof sheets !== 'undefined') out.SheetNames = sheets;\n\t\tif(opts.bookSheets ? out.SheetNames : opts.bookProps) return out;\n\t}\n\tsheets = {};\n\n\tvar deps = {};\n\tif(opts.bookDeps && dir.calcchain) deps=parse_cc(getzipdata(zip, strip_front_slash(dir.calcchain)),dir.calcchain,opts);\n\n\tvar i=0;\n\tvar sheetRels = ({}/*:any*/);\n\tvar path, relsPath;\n\n\t{\n\t\tvar wbsheets = wb.Sheets;\n\t\tprops.Worksheets = wbsheets.length;\n\t\tprops.SheetNames = [];\n\t\tfor(var j = 0; j != wbsheets.length; ++j) {\n\t\t\tprops.SheetNames[j] = wbsheets[j].name;\n\t\t}\n\t}\n\n\tvar wbext = xlsb ? \"bin\" : \"xml\";\n\tvar wbrelsi = dir.workbooks[0].lastIndexOf(\"/\");\n\tvar wbrelsfile = (dir.workbooks[0].slice(0, wbrelsi+1) + \"_rels/\" + dir.workbooks[0].slice(wbrelsi+1) + \".rels\").replace(/^\\//,\"\");\n\tif(!safegetzipfile(zip, wbrelsfile)) wbrelsfile = 'xl/_rels/workbook.' + wbext + '.rels';\n\tvar wbrels = parse_rels(getzipstr(zip, wbrelsfile, true), wbrelsfile.replace(/_rels.*/, \"s5s\"));\n\n\tif((dir.metadata || []).length >= 1) {\n\t\t/* TODO: MDX and other types of metadata */\n\t\topts.xlmeta = parse_xlmeta(getzipdata(zip, strip_front_slash(dir.metadata[0])),dir.metadata[0],opts);\n\t}\n\n\tif((dir.people || []).length >= 1) {\n\t\topts.people = parse_people_xml(getzipdata(zip, strip_front_slash(dir.people[0])),opts);\n\t}\n\n\tif(wbrels) wbrels = safe_parse_wbrels(wbrels, wb.Sheets);\n\n\t/* Numbers iOS hack */\n\tvar nmode = (getzipdata(zip,\"xl/worksheets/sheet.xml\",true))?1:0;\n\twsloop: for(i = 0; i != props.Worksheets; ++i) {\n\t\tvar stype = \"sheet\";\n\t\tif(wbrels && wbrels[i]) {\n\t\t\tpath = 'xl/' + (wbrels[i][1]).replace(/[\\/]?xl\\//, \"\");\n\t\t\tif(!safegetzipfile(zip, path)) path = wbrels[i][1];\n\t\t\tif(!safegetzipfile(zip, path)) path = wbrelsfile.replace(/_rels\\/.*$/,\"\") + wbrels[i][1];\n\t\t\tstype = wbrels[i][2];\n\t\t} else {\n\t\t\tpath = 'xl/worksheets/sheet'+(i+1-nmode)+\".\" + wbext;\n\t\t\tpath = path.replace(/sheet0\\./,\"sheet.\");\n\t\t}\n\t\trelsPath = path.replace(/^(.*)(\\/)([^\\/]*)$/, \"$1/_rels/$3.rels\");\n\t\tif(opts && opts.sheets != null) switch(typeof opts.sheets) {\n\t\t\tcase \"number\": if(i != opts.sheets) continue wsloop; break;\n\t\t\tcase \"string\": if(props.SheetNames[i].toLowerCase() != opts.sheets.toLowerCase()) continue wsloop; break;\n\t\t\tdefault: if(Array.isArray && Array.isArray(opts.sheets)) {\n\t\t\t\tvar snjseen = false;\n\t\t\t\tfor(var snj = 0; snj != opts.sheets.length; ++snj) {\n\t\t\t\t\tif(typeof opts.sheets[snj] == \"number\" && opts.sheets[snj] == i) snjseen=1;\n\t\t\t\t\tif(typeof opts.sheets[snj] == \"string\" && opts.sheets[snj].toLowerCase() == props.SheetNames[i].toLowerCase()) snjseen = 1;\n\t\t\t\t}\n\t\t\t\tif(!snjseen) continue wsloop;\n\t\t\t}\n\t\t}\n\t\tsafe_parse_sheet(zip, path, relsPath, props.SheetNames[i], i, sheetRels, sheets, stype, opts, wb, themes, styles);\n\t}\n\n\tout = ({\n\t\tDirectory: dir,\n\t\tWorkbook: wb,\n\t\tProps: props,\n\t\tCustprops: custprops,\n\t\tDeps: deps,\n\t\tSheets: sheets,\n\t\tSheetNames: props.SheetNames,\n\t\tStrings: strs,\n\t\tStyles: styles,\n\t\tThemes: themes,\n\t\tSSF: dup(table_fmt)\n\t}/*:any*/);\n\tif(opts && opts.bookFiles) {\n\t\tif(zip.files) {\n\t\t\tout.keys = entries;\n\t\t\tout.files = zip.files;\n\t\t} else {\n\t\t\tout.keys = [];\n\t\t\tout.files = {};\n\t\t\tzip.FullPaths.forEach(function(p, idx) {\n\t\t\t\tp = p.replace(/^Root Entry[\\/]/, \"\");\n\t\t\t\tout.keys.push(p);\n\t\t\t\tout.files[p] = zip.FileIndex[idx];\n\t\t\t});\n\t\t}\n\t}\n\tif(opts && opts.bookVBA) {\n\t\tif(dir.vba.length > 0) out.vbaraw = getzipdata(zip,strip_front_slash(dir.vba[0]),true);\n\t\telse if(dir.defaults && dir.defaults.bin === CT_VBA) out.vbaraw = getzipdata(zip, 'xl/vbaProject.bin',true);\n\t}\n\treturn out;\n}\n\n/* [MS-OFFCRYPTO] 2.1.1 */\nfunction parse_xlsxcfb(cfb, _opts/*:?ParseOpts*/)/*:Workbook*/ {\n\tvar opts = _opts || {};\n\tvar f = 'Workbook', data = CFB.find(cfb, f);\n\ttry {\n\tf = '/!DataSpaces/Version';\n\tdata = CFB.find(cfb, f); if(!data || !data.content) throw new Error(\"ECMA-376 Encrypted file missing \" + f);\n\t/*var version = */parse_DataSpaceVersionInfo(data.content);\n\n\t/* 2.3.4.1 */\n\tf = '/!DataSpaces/DataSpaceMap';\n\tdata = CFB.find(cfb, f); if(!data || !data.content) throw new Error(\"ECMA-376 Encrypted file missing \" + f);\n\tvar dsm = parse_DataSpaceMap(data.content);\n\tif(dsm.length !== 1 || dsm[0].comps.length !== 1 || dsm[0].comps[0].t !== 0 || dsm[0].name !== \"StrongEncryptionDataSpace\" || dsm[0].comps[0].v !== \"EncryptedPackage\")\n\t\tthrow new Error(\"ECMA-376 Encrypted file bad \" + f);\n\n\t/* 2.3.4.2 */\n\tf = '/!DataSpaces/DataSpaceInfo/StrongEncryptionDataSpace';\n\tdata = CFB.find(cfb, f); if(!data || !data.content) throw new Error(\"ECMA-376 Encrypted file missing \" + f);\n\tvar seds = parse_DataSpaceDefinition(data.content);\n\tif(seds.length != 1 || seds[0] != \"StrongEncryptionTransform\")\n\t\tthrow new Error(\"ECMA-376 Encrypted file bad \" + f);\n\n\t/* 2.3.4.3 */\n\tf = '/!DataSpaces/TransformInfo/StrongEncryptionTransform/!Primary';\n\tdata = CFB.find(cfb, f); if(!data || !data.content) throw new Error(\"ECMA-376 Encrypted file missing \" + f);\n\t/*var hdr = */parse_Primary(data.content);\n\t} catch(e) {}\n\n\tf = '/EncryptionInfo';\n\tdata = CFB.find(cfb, f); if(!data || !data.content) throw new Error(\"ECMA-376 Encrypted file missing \" + f);\n\tvar einfo = parse_EncryptionInfo(data.content);\n\n\t/* 2.3.4.4 */\n\tf = '/EncryptedPackage';\n\tdata = CFB.find(cfb, f); if(!data || !data.content) throw new Error(\"ECMA-376 Encrypted file missing \" + f);\n\n/*global decrypt_agile */\n/*:: declare var decrypt_agile:any; */\n\tif(einfo[0] == 0x04 && typeof decrypt_agile !== 'undefined') return decrypt_agile(einfo[1], data.content, opts.password || \"\", opts);\n/*global decrypt_std76 */\n/*:: declare var decrypt_std76:any; */\n\tif(einfo[0] == 0x02 && typeof decrypt_std76 !== 'undefined') return decrypt_std76(einfo[1], data.content, opts.password || \"\", opts);\n\tthrow new Error(\"File is password-protected\");\n}\n\nfunction write_zip(wb/*:Workbook*/, opts/*:WriteOpts*/)/*:ZIP*/ {\n\tif(opts.bookType == \"ods\") return write_ods(wb, opts);\n\tif(opts.bookType == \"numbers\") return write_numbers_iwa(wb, opts);\n\tif(opts.bookType == \"xlsb\") return write_zip_xlsxb(wb, opts);\n\treturn write_zip_xlsx(wb, opts);\n}\n\n/* XLSX and XLSB writing are very similar. Originally they were unified in one\n export function. This is horrible for tree shaking in the common case (most\n applications need to export files in one format) so this function supports\n both formats while write_zip_xlsx only handles XLSX */\nfunction write_zip_xlsxb(wb/*:Workbook*/, opts/*:WriteOpts*/)/*:ZIP*/ {\n\t_shapeid = 1024;\n\tif(wb && !wb.SSF) {\n\t\twb.SSF = dup(table_fmt);\n\t}\n\tif(wb && wb.SSF) {\n\t\tmake_ssf(); SSF_load_table(wb.SSF);\n\t\t// $FlowIgnore\n\t\topts.revssf = evert_num(wb.SSF); opts.revssf[wb.SSF[65535]] = 0;\n\t\topts.ssf = wb.SSF;\n\t}\n\topts.rels = {}; opts.wbrels = {};\n\topts.Strings = /*::((*/[]/*:: :any):SST)*/; opts.Strings.Count = 0; opts.Strings.Unique = 0;\n\tif(browser_has_Map) opts.revStrings = new Map();\n\telse { opts.revStrings = {}; opts.revStrings.foo = []; delete opts.revStrings.foo; }\n\tvar wbext = opts.bookType == \"xlsb\" ? \"bin\" : \"xml\";\n\tvar vbafmt = VBAFMTS.indexOf(opts.bookType) > -1;\n\tvar ct = new_ct();\n\tfix_write_opts(opts = opts || {});\n\tvar zip = zip_new();\n\tvar f = \"\", rId = 0;\n\n\topts.cellXfs = [];\n\tget_cell_style(opts.cellXfs, {}, {revssf:{\"General\":0}});\n\n\tif(!wb.Props) wb.Props = {};\n\n\tf = \"docProps/core.xml\";\n\tzip_add_file(zip, f, write_core_props(wb.Props, opts));\n\tct.coreprops.push(f);\n\tadd_rels(opts.rels, 2, f, RELS.CORE_PROPS);\n\n\t/*::if(!wb.Props) throw \"unreachable\"; */\n\tf = \"docProps/app.xml\";\n\tif(wb.Props && wb.Props.SheetNames){/* empty */}\n\telse if(!wb.Workbook || !wb.Workbook.Sheets) wb.Props.SheetNames = wb.SheetNames;\n\telse {\n\t\tvar _sn = [];\n\t\tfor(var _i = 0; _i < wb.SheetNames.length; ++_i)\n\t\t\tif((wb.Workbook.Sheets[_i]||{}).Hidden != 2) _sn.push(wb.SheetNames[_i]);\n\t\twb.Props.SheetNames = _sn;\n\t}\n\twb.Props.Worksheets = wb.Props.SheetNames.length;\n\tzip_add_file(zip, f, write_ext_props(wb.Props, opts));\n\tct.extprops.push(f);\n\tadd_rels(opts.rels, 3, f, RELS.EXT_PROPS);\n\n\tif(wb.Custprops !== wb.Props && keys(wb.Custprops||{}).length > 0) {\n\t\tf = \"docProps/custom.xml\";\n\t\tzip_add_file(zip, f, write_cust_props(wb.Custprops, opts));\n\t\tct.custprops.push(f);\n\t\tadd_rels(opts.rels, 4, f, RELS.CUST_PROPS);\n\t}\n\n\tfor(rId=1;rId <= wb.SheetNames.length; ++rId) {\n\t\tvar wsrels = {'!id':{}};\n\t\tvar ws = wb.Sheets[wb.SheetNames[rId-1]];\n\t\tvar _type = (ws || {})[\"!type\"] || \"sheet\";\n\t\tswitch(_type) {\n\t\tcase \"chart\":\n\t\t\t/* falls through */\n\t\tdefault:\n\t\t\tf = \"xl/worksheets/sheet\" + rId + \".\" + wbext;\n\t\t\tzip_add_file(zip, f, write_ws(rId-1, f, opts, wb, wsrels));\n\t\t\tct.sheets.push(f);\n\t\t\tadd_rels(opts.wbrels, -1, \"worksheets/sheet\" + rId + \".\" + wbext, RELS.WS[0]);\n\t\t}\n\n\t\tif(ws) {\n\t\t\tvar comments = ws['!comments'];\n\t\t\tvar need_vml = false;\n\t\t\tvar cf = \"\";\n\t\t\tif(comments && comments.length > 0) {\n\t\t\t\tcf = \"xl/comments\" + rId + \".\" + wbext;\n\t\t\t\tzip_add_file(zip, cf, write_cmnt(comments, cf, opts));\n\t\t\t\tct.comments.push(cf);\n\t\t\t\tadd_rels(wsrels, -1, \"../comments\" + rId + \".\" + wbext, RELS.CMNT);\n\t\t\t\tneed_vml = true;\n\t\t\t}\n\t\t\tif(ws['!legacy']) {\n\t\t\t\tif(need_vml) zip_add_file(zip, \"xl/drawings/vmlDrawing\" + (rId) + \".vml\", write_comments_vml(rId, ws['!comments']));\n\t\t\t}\n\t\t\tdelete ws['!comments'];\n\t\t\tdelete ws['!legacy'];\n\t\t}\n\n\t\tif(wsrels['!id'].rId1) zip_add_file(zip, get_rels_path(f), write_rels(wsrels));\n\t}\n\n\tif(opts.Strings != null && opts.Strings.length > 0) {\n\t\tf = \"xl/sharedStrings.\" + wbext;\n\t\tzip_add_file(zip, f, write_sst(opts.Strings, f, opts));\n\t\tct.strs.push(f);\n\t\tadd_rels(opts.wbrels, -1, \"sharedStrings.\" + wbext, RELS.SST);\n\t}\n\n\tf = \"xl/workbook.\" + wbext;\n\tzip_add_file(zip, f, write_wb(wb, f, opts));\n\tct.workbooks.push(f);\n\tadd_rels(opts.rels, 1, f, RELS.WB);\n\n\t/* TODO: something more intelligent with themes */\n\n\tf = \"xl/theme/theme1.xml\";\n\tzip_add_file(zip, f, write_theme(wb.Themes, opts));\n\tct.themes.push(f);\n\tadd_rels(opts.wbrels, -1, \"theme/theme1.xml\", RELS.THEME);\n\n\t/* TODO: something more intelligent with styles */\n\n\tf = \"xl/styles.\" + wbext;\n\tzip_add_file(zip, f, write_sty(wb, f, opts));\n\tct.styles.push(f);\n\tadd_rels(opts.wbrels, -1, \"styles.\" + wbext, RELS.STY);\n\n\tif(wb.vbaraw && vbafmt) {\n\t\tf = \"xl/vbaProject.bin\";\n\t\tzip_add_file(zip, f, wb.vbaraw);\n\t\tct.vba.push(f);\n\t\tadd_rels(opts.wbrels, -1, \"vbaProject.bin\", RELS.VBA);\n\t}\n\n\tf = \"xl/metadata.\" + wbext;\n\tzip_add_file(zip, f, write_xlmeta(f));\n\tct.metadata.push(f);\n\tadd_rels(opts.wbrels, -1, \"metadata.\" + wbext, RELS.XLMETA);\n\n\tzip_add_file(zip, \"[Content_Types].xml\", write_ct(ct, opts));\n\tzip_add_file(zip, '_rels/.rels', write_rels(opts.rels));\n\tzip_add_file(zip, 'xl/_rels/workbook.' + wbext + '.rels', write_rels(opts.wbrels));\n\n\tdelete opts.revssf; delete opts.ssf;\n\treturn zip;\n}\n\nfunction write_zip_xlsx(wb/*:Workbook*/, opts/*:WriteOpts*/)/*:ZIP*/ {\n\t_shapeid = 1024;\n\tif(wb && !wb.SSF) {\n\t\twb.SSF = dup(table_fmt);\n\t}\n\tif(wb && wb.SSF) {\n\t\tmake_ssf(); SSF_load_table(wb.SSF);\n\t\t// $FlowIgnore\n\t\topts.revssf = evert_num(wb.SSF); opts.revssf[wb.SSF[65535]] = 0;\n\t\topts.ssf = wb.SSF;\n\t}\n\topts.rels = {}; opts.wbrels = {};\n\topts.Strings = /*::((*/[]/*:: :any):SST)*/; opts.Strings.Count = 0; opts.Strings.Unique = 0;\n\tif(browser_has_Map) opts.revStrings = new Map();\n\telse { opts.revStrings = {}; opts.revStrings.foo = []; delete opts.revStrings.foo; }\n\tvar wbext = \"xml\";\n\tvar vbafmt = VBAFMTS.indexOf(opts.bookType) > -1;\n\tvar ct = new_ct();\n\tfix_write_opts(opts = opts || {});\n\tvar zip = zip_new();\n\tvar f = \"\", rId = 0;\n\n\topts.cellXfs = [];\n\tget_cell_style(opts.cellXfs, {}, {revssf:{\"General\":0}});\n\n\tif(!wb.Props) wb.Props = {};\n\n\tf = \"docProps/core.xml\";\n\tzip_add_file(zip, f, write_core_props(wb.Props, opts));\n\tct.coreprops.push(f);\n\tadd_rels(opts.rels, 2, f, RELS.CORE_PROPS);\n\n\t/*::if(!wb.Props) throw \"unreachable\"; */\n\tf = \"docProps/app.xml\";\n\tif(wb.Props && wb.Props.SheetNames){/* empty */}\n\telse if(!wb.Workbook || !wb.Workbook.Sheets) wb.Props.SheetNames = wb.SheetNames;\n\telse {\n\t\tvar _sn = [];\n\t\tfor(var _i = 0; _i < wb.SheetNames.length; ++_i)\n\t\t\tif((wb.Workbook.Sheets[_i]||{}).Hidden != 2) _sn.push(wb.SheetNames[_i]);\n\t\twb.Props.SheetNames = _sn;\n\t}\n\twb.Props.Worksheets = wb.Props.SheetNames.length;\n\tzip_add_file(zip, f, write_ext_props(wb.Props, opts));\n\tct.extprops.push(f);\n\tadd_rels(opts.rels, 3, f, RELS.EXT_PROPS);\n\n\tif(wb.Custprops !== wb.Props && keys(wb.Custprops||{}).length > 0) {\n\t\tf = \"docProps/custom.xml\";\n\t\tzip_add_file(zip, f, write_cust_props(wb.Custprops, opts));\n\t\tct.custprops.push(f);\n\t\tadd_rels(opts.rels, 4, f, RELS.CUST_PROPS);\n\t}\n\n\tvar people = [\"SheetJ5\"];\n\topts.tcid = 0;\n\n\tfor(rId=1;rId <= wb.SheetNames.length; ++rId) {\n\t\tvar wsrels = {'!id':{}};\n\t\tvar ws = wb.Sheets[wb.SheetNames[rId-1]];\n\t\tvar _type = (ws || {})[\"!type\"] || \"sheet\";\n\t\tswitch(_type) {\n\t\tcase \"chart\":\n\t\t\t/* falls through */\n\t\tdefault:\n\t\t\tf = \"xl/worksheets/sheet\" + rId + \".\" + wbext;\n\t\t\tzip_add_file(zip, f, write_ws_xml(rId-1, opts, wb, wsrels));\n\t\t\tct.sheets.push(f);\n\t\t\tadd_rels(opts.wbrels, -1, \"worksheets/sheet\" + rId + \".\" + wbext, RELS.WS[0]);\n\t\t}\n\n\t\tif(ws) {\n\t\t\tvar comments = ws['!comments'];\n\t\t\tvar need_vml = false;\n\t\t\tvar cf = \"\";\n\t\t\tif(comments && comments.length > 0) {\n\t\t\t\tvar needtc = false;\n\t\t\t\tcomments.forEach(function(carr) {\n\t\t\t\t\tcarr[1].forEach(function(c) { if(c.T == true) needtc = true; });\n\t\t\t\t});\n\t\t\t\tif(needtc) {\n\t\t\t\t\tcf = \"xl/threadedComments/threadedComment\" + rId + \".\" + wbext;\n\t\t\t\t\tzip_add_file(zip, cf, write_tcmnt_xml(comments, people, opts));\n\t\t\t\t\tct.threadedcomments.push(cf);\n\t\t\t\t\tadd_rels(wsrels, -1, \"../threadedComments/threadedComment\" + rId + \".\" + wbext, RELS.TCMNT);\n\t\t\t\t}\n\n\t\t\t\tcf = \"xl/comments\" + rId + \".\" + wbext;\n\t\t\t\tzip_add_file(zip, cf, write_comments_xml(comments, opts));\n\t\t\t\tct.comments.push(cf);\n\t\t\t\tadd_rels(wsrels, -1, \"../comments\" + rId + \".\" + wbext, RELS.CMNT);\n\t\t\t\tneed_vml = true;\n\t\t\t}\n\t\t\tif(ws['!legacy']) {\n\t\t\t\tif(need_vml) zip_add_file(zip, \"xl/drawings/vmlDrawing\" + (rId) + \".vml\", write_comments_vml(rId, ws['!comments']));\n\t\t\t}\n\t\t\tdelete ws['!comments'];\n\t\t\tdelete ws['!legacy'];\n\t\t}\n\n\t\tif(wsrels['!id'].rId1) zip_add_file(zip, get_rels_path(f), write_rels(wsrels));\n\t}\n\n\tif(opts.Strings != null && opts.Strings.length > 0) {\n\t\tf = \"xl/sharedStrings.\" + wbext;\n\t\tzip_add_file(zip, f, write_sst_xml(opts.Strings, opts));\n\t\tct.strs.push(f);\n\t\tadd_rels(opts.wbrels, -1, \"sharedStrings.\" + wbext, RELS.SST);\n\t}\n\n\tf = \"xl/workbook.\" + wbext;\n\tzip_add_file(zip, f, write_wb_xml(wb, opts));\n\tct.workbooks.push(f);\n\tadd_rels(opts.rels, 1, f, RELS.WB);\n\n\t/* TODO: something more intelligent with themes */\n\n\tf = \"xl/theme/theme1.xml\";\n\tzip_add_file(zip, f, write_theme(wb.Themes, opts));\n\tct.themes.push(f);\n\tadd_rels(opts.wbrels, -1, \"theme/theme1.xml\", RELS.THEME);\n\n\t/* TODO: something more intelligent with styles */\n\n\tf = \"xl/styles.\" + wbext;\n\tzip_add_file(zip, f, write_sty_xml(wb, opts));\n\tct.styles.push(f);\n\tadd_rels(opts.wbrels, -1, \"styles.\" + wbext, RELS.STY);\n\n\tif(wb.vbaraw && vbafmt) {\n\t\tf = \"xl/vbaProject.bin\";\n\t\tzip_add_file(zip, f, wb.vbaraw);\n\t\tct.vba.push(f);\n\t\tadd_rels(opts.wbrels, -1, \"vbaProject.bin\", RELS.VBA);\n\t}\n\n\tf = \"xl/metadata.\" + wbext;\n\tzip_add_file(zip, f, write_xlmeta_xml());\n\tct.metadata.push(f);\n\tadd_rels(opts.wbrels, -1, \"metadata.\" + wbext, RELS.XLMETA);\n\n\tif(people.length > 1) {\n\t\tf = \"xl/persons/person.xml\";\n\t\tzip_add_file(zip, f, write_people_xml(people, opts));\n\t\tct.people.push(f);\n\t\tadd_rels(opts.wbrels, -1, \"persons/person.xml\", RELS.PEOPLE);\n\t}\n\n\tzip_add_file(zip, \"[Content_Types].xml\", write_ct(ct, opts));\n\tzip_add_file(zip, '_rels/.rels', write_rels(opts.rels));\n\tzip_add_file(zip, 'xl/_rels/workbook.' + wbext + '.rels', write_rels(opts.wbrels));\n\n\tdelete opts.revssf; delete opts.ssf;\n\treturn zip;\n}\n\nfunction firstbyte(f/*:RawData*/,o/*:?TypeOpts*/)/*:Array*/ {\n\tvar x = \"\";\n\tswitch((o||{}).type || \"base64\") {\n\t\tcase 'buffer': return [f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7]];\n\t\tcase 'base64': x = Base64_decode(f.slice(0,12)); break;\n\t\tcase 'binary': x = f; break;\n\t\tcase 'array': return [f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7]];\n\t\tdefault: throw new Error(\"Unrecognized type \" + (o && o.type || \"undefined\"));\n\t}\n\treturn [x.charCodeAt(0), x.charCodeAt(1), x.charCodeAt(2), x.charCodeAt(3), x.charCodeAt(4), x.charCodeAt(5), x.charCodeAt(6), x.charCodeAt(7)];\n}\n\nfunction read_cfb(cfb/*:CFBContainer*/, opts/*:?ParseOpts*/)/*:Workbook*/ {\n\tif(CFB.find(cfb, \"EncryptedPackage\")) return parse_xlsxcfb(cfb, opts);\n\treturn parse_xlscfb(cfb, opts);\n}\n\nfunction read_zip(data/*:RawData*/, opts/*:?ParseOpts*/)/*:Workbook*/ {\n\tvar zip, d = data;\n\tvar o = opts||{};\n\tif(!o.type) o.type = (has_buf && Buffer.isBuffer(data)) ? \"buffer\" : \"base64\";\n\tzip = zip_read(d, o);\n\treturn parse_zip(zip, o);\n}\n\nfunction read_plaintext(data/*:string*/, o/*:ParseOpts*/)/*:Workbook*/ {\n\tvar i = 0;\n\tmain: while(i < data.length) switch(data.charCodeAt(i)) {\n\t\tcase 0x0A: case 0x0D: case 0x20: ++i; break;\n\t\tcase 0x3C: return parse_xlml(data.slice(i),o);\n\t\tdefault: break main;\n\t}\n\treturn PRN.to_workbook(data, o);\n}\n\nfunction read_plaintext_raw(data/*:RawData*/, o/*:ParseOpts*/)/*:Workbook*/ {\n\tvar str = \"\", bytes = firstbyte(data, o);\n\tswitch(o.type) {\n\t\tcase 'base64': str = Base64_decode(data); break;\n\t\tcase 'binary': str = data; break;\n\t\tcase 'buffer': str = data.toString('binary'); break;\n\t\tcase 'array': str = cc2str(data); break;\n\t\tdefault: throw new Error(\"Unrecognized type \" + o.type);\n\t}\n\tif(bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF) str = utf8read(str);\n\to.type = \"binary\";\n\treturn read_plaintext(str, o);\n}\n\nfunction read_utf16(data/*:RawData*/, o/*:ParseOpts*/)/*:Workbook*/ {\n\tvar d = data;\n\tif(o.type == 'base64') d = Base64_decode(d);\n\td = $cptable.utils.decode(1200, d.slice(2), 'str');\n\to.type = \"binary\";\n\treturn read_plaintext(d, o);\n}\n\nfunction bstrify(data/*:string*/)/*:string*/ {\n\treturn !data.match(/[^\\x00-\\x7F]/) ? data : utf8write(data);\n}\n\nfunction read_prn(data, d, o, str) {\n\tif(str) { o.type = \"string\"; return PRN.to_workbook(data, o); }\n\treturn PRN.to_workbook(d, o);\n}\n\nfunction readSync(data/*:RawData*/, opts/*:?ParseOpts*/)/*:Workbook*/ {\n\treset_cp();\n\tvar o = opts||{};\n\tif(typeof ArrayBuffer !== 'undefined' && data instanceof ArrayBuffer) return readSync(new Uint8Array(data), (o = dup(o), o.type = \"array\", o));\n\tif(typeof Uint8Array !== 'undefined' && data instanceof Uint8Array && !o.type) o.type = typeof Deno !== \"undefined\" ? \"buffer\" : \"array\";\n\tvar d = data, n = [0,0,0,0], str = false;\n\tif(o.cellStyles) { o.cellNF = true; o.sheetStubs = true; }\n\t_ssfopts = {};\n\tif(o.dateNF) _ssfopts.dateNF = o.dateNF;\n\tif(!o.type) o.type = (has_buf && Buffer.isBuffer(data)) ? \"buffer\" : \"base64\";\n\tif(o.type == \"file\") { o.type = has_buf ? \"buffer\" : \"binary\"; d = read_binary(data); if(typeof Uint8Array !== 'undefined' && !has_buf) o.type = \"array\"; }\n\tif(o.type == \"string\") { str = true; o.type = \"binary\"; o.codepage = 65001; d = bstrify(data); }\n\tif(o.type == 'array' && typeof Uint8Array !== 'undefined' && data instanceof Uint8Array && typeof ArrayBuffer !== 'undefined') {\n\t\t// $FlowIgnore\n\t\tvar ab=new ArrayBuffer(3), vu=new Uint8Array(ab); vu.foo=\"bar\";\n\t\t// $FlowIgnore\n\t\tif(!vu.foo) {o=dup(o); o.type='array'; return readSync(ab2a(d), o);}\n\t}\n\tswitch((n = firstbyte(d, o))[0]) {\n\t\tcase 0xD0: if(n[1] === 0xCF && n[2] === 0x11 && n[3] === 0xE0 && n[4] === 0xA1 && n[5] === 0xB1 && n[6] === 0x1A && n[7] === 0xE1) return read_cfb(CFB.read(d, o), o); break;\n\t\tcase 0x09: if(n[1] <= 0x08) return parse_xlscfb(d, o); break;\n\t\tcase 0x3C: return parse_xlml(d, o);\n\t\tcase 0x49:\n\t\t\tif(n[1] === 0x49 && n[2] === 0x2a && n[3] === 0x00) throw new Error(\"TIFF Image File is not a spreadsheet\");\n\t\t\tif(n[1] === 0x44) return read_wb_ID(d, o);\n\t\t\tbreak;\n\t\tcase 0x54: if(n[1] === 0x41 && n[2] === 0x42 && n[3] === 0x4C) return DIF.to_workbook(d, o); break;\n\t\tcase 0x50: return (n[1] === 0x4B && n[2] < 0x09 && n[3] < 0x09) ? read_zip(d, o) : read_prn(data, d, o, str);\n\t\tcase 0xEF: return n[3] === 0x3C ? parse_xlml(d, o) : read_prn(data, d, o, str);\n\t\tcase 0xFF:\n\t\t\tif(n[1] === 0xFE) { return read_utf16(d, o); }\n\t\t\telse if(n[1] === 0x00 && n[2] === 0x02 && n[3] === 0x00) return WK_.to_workbook(d, o);\n\t\t\tbreak;\n\t\tcase 0x00:\n\t\t\tif(n[1] === 0x00) {\n\t\t\t\tif(n[2] >= 0x02 && n[3] === 0x00) return WK_.to_workbook(d, o);\n\t\t\t\tif(n[2] === 0x00 && (n[3] === 0x08 || n[3] === 0x09)) return WK_.to_workbook(d, o);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 0x03: case 0x83: case 0x8B: case 0x8C: return DBF.to_workbook(d, o);\n\t\tcase 0x7B: if(n[1] === 0x5C && n[2] === 0x72 && n[3] === 0x74) return RTF.to_workbook(d, o); break;\n\t\tcase 0x0A: case 0x0D: case 0x20: return read_plaintext_raw(d, o);\n\t\tcase 0x89: if(n[1] === 0x50 && n[2] === 0x4E && n[3] === 0x47) throw new Error(\"PNG Image File is not a spreadsheet\"); break;\n\t}\n\tif(DBF_SUPPORTED_VERSIONS.indexOf(n[0]) > -1 && n[2] <= 12 && n[3] <= 31) return DBF.to_workbook(d, o);\n\treturn read_prn(data, d, o, str);\n}\n\nfunction readFileSync(filename/*:string*/, opts/*:?ParseOpts*/)/*:Workbook*/ {\n\tvar o = opts||{}; o.type = 'file';\n\treturn readSync(filename, o);\n}\nfunction write_cfb_ctr(cfb/*:CFBContainer*/, o/*:WriteOpts*/)/*:any*/ {\n\tswitch(o.type) {\n\t\tcase \"base64\": case \"binary\": break;\n\t\tcase \"buffer\": case \"array\": o.type = \"\"; break;\n\t\tcase \"file\": return write_dl(o.file, CFB.write(cfb, {type:has_buf ? 'buffer' : \"\"}));\n\t\tcase \"string\": throw new Error(\"'string' output type invalid for '\" + o.bookType + \"' files\");\n\t\tdefault: throw new Error(\"Unrecognized type \" + o.type);\n\t}\n\treturn CFB.write(cfb, o);\n}\n\n/*:: declare var encrypt_agile:any; */\nfunction write_zip_type(wb/*:Workbook*/, opts/*:?WriteOpts*/)/*:any*/ {\n\tvar o = dup(opts||{});\n\tvar z = write_zip(wb, o);\n\treturn write_zip_denouement(z, o);\n}\nfunction write_zip_typeXLSX(wb/*:Workbook*/, opts/*:?WriteOpts*/)/*:any*/ {\n\tvar o = dup(opts||{});\n\tvar z = write_zip_xlsx(wb, o);\n\treturn write_zip_denouement(z, o);\n}\nfunction write_zip_denouement(z/*:any*/, o/*:?WriteOpts*/)/*:any*/ {\n\tvar oopts = {};\n\tvar ftype = has_buf ? \"nodebuffer\" : (typeof Uint8Array !== \"undefined\" ? \"array\" : \"string\");\n\tif(o.compression) oopts.compression = 'DEFLATE';\n\tif(o.password) oopts.type = ftype;\n\telse switch(o.type) {\n\t\tcase \"base64\": oopts.type = \"base64\"; break;\n\t\tcase \"binary\": oopts.type = \"string\"; break;\n\t\tcase \"string\": throw new Error(\"'string' output type invalid for '\" + o.bookType + \"' files\");\n\t\tcase \"buffer\":\n\t\tcase \"file\": oopts.type = ftype; break;\n\t\tdefault: throw new Error(\"Unrecognized type \" + o.type);\n\t}\n\tvar out = z.FullPaths ? CFB.write(z, {fileType:\"zip\", type: /*::(*/{\"nodebuffer\": \"buffer\", \"string\": \"binary\"}/*:: :any)*/[oopts.type] || oopts.type, compression: !!o.compression}) : z.generate(oopts);\n\tif(typeof Deno !== \"undefined\") {\n\t\tif(typeof out == \"string\") {\n\t\t\tif(o.type == \"binary\" || o.type == \"base64\") return out;\n\t\t\tout = new Uint8Array(s2ab(out));\n\t\t}\n\t}\n/*jshint -W083 */\n\tif(o.password && typeof encrypt_agile !== 'undefined') return write_cfb_ctr(encrypt_agile(out, o.password), o); // eslint-disable-line no-undef\n/*jshint +W083 */\n\tif(o.type === \"file\") return write_dl(o.file, out);\n\treturn o.type == \"string\" ? utf8read(/*::(*/out/*:: :any)*/) : out;\n}\n\nfunction write_cfb_type(wb/*:Workbook*/, opts/*:?WriteOpts*/)/*:any*/ {\n\tvar o = opts||{};\n\tvar cfb/*:CFBContainer*/ = write_xlscfb(wb, o);\n\treturn write_cfb_ctr(cfb, o);\n}\n\nfunction write_string_type(out/*:string*/, opts/*:WriteOpts*/, bom/*:?string*/)/*:any*/ {\n\tif(!bom) bom = \"\";\n\tvar o = bom + out;\n\tswitch(opts.type) {\n\t\tcase \"base64\": return Base64_encode(utf8write(o));\n\t\tcase \"binary\": return utf8write(o);\n\t\tcase \"string\": return out;\n\t\tcase \"file\": return write_dl(opts.file, o, 'utf8');\n\t\tcase \"buffer\": {\n\t\t\tif(has_buf) return Buffer_from(o, 'utf8');\n\t\t\telse if(typeof TextEncoder !== \"undefined\") return new TextEncoder().encode(o);\n\t\t\telse return write_string_type(o, {type:'binary'}).split(\"\").map(function(c) { return c.charCodeAt(0); });\n\t\t}\n\t}\n\tthrow new Error(\"Unrecognized type \" + opts.type);\n}\n\nfunction write_stxt_type(out/*:string*/, opts/*:WriteOpts*/)/*:any*/ {\n\tswitch(opts.type) {\n\t\tcase \"base64\": return Base64_encode(out);\n\t\tcase \"binary\": return out;\n\t\tcase \"string\": return out; /* override in sheet_to_txt */\n\t\tcase \"file\": return write_dl(opts.file, out, 'binary');\n\t\tcase \"buffer\": {\n\t\t\tif(has_buf) return Buffer_from(out, 'binary');\n\t\t\telse return out.split(\"\").map(function(c) { return c.charCodeAt(0); });\n\t\t}\n\t}\n\tthrow new Error(\"Unrecognized type \" + opts.type);\n}\n\n/* TODO: test consistency */\nfunction write_binary_type(out, opts/*:WriteOpts*/)/*:any*/ {\n\tswitch(opts.type) {\n\t\tcase \"string\":\n\t\tcase \"base64\":\n\t\tcase \"binary\":\n\t\t\tvar bstr = \"\";\n\t\t\t// $FlowIgnore\n\t\t\tfor(var i = 0; i < out.length; ++i) bstr += String.fromCharCode(out[i]);\n\t\t\treturn opts.type == 'base64' ? Base64_encode(bstr) : opts.type == 'string' ? utf8read(bstr) : bstr;\n\t\tcase \"file\": return write_dl(opts.file, out);\n\t\tcase \"buffer\": return out;\n\t\tdefault: throw new Error(\"Unrecognized type \" + opts.type);\n\t}\n}\n\nfunction writeSyncXLSX(wb/*:Workbook*/, opts/*:?WriteOpts*/) {\n\treset_cp();\n\tcheck_wb(wb);\n\tvar o = dup(opts||{});\n\tif(o.cellStyles) { o.cellNF = true; o.sheetStubs = true; }\n\tif(o.type == \"array\") { o.type = \"binary\"; var out/*:string*/ = (writeSyncXLSX(wb, o)/*:any*/); o.type = \"array\"; return s2ab(out); }\n\treturn write_zip_typeXLSX(wb, o);\n}\n\nfunction writeSync(wb/*:Workbook*/, opts/*:?WriteOpts*/) {\n\treset_cp();\n\tcheck_wb(wb);\n\tvar o = dup(opts||{});\n\tif(o.cellStyles) { o.cellNF = true; o.sheetStubs = true; }\n\tif(o.type == \"array\") { o.type = \"binary\"; var out/*:string*/ = (writeSync(wb, o)/*:any*/); o.type = \"array\"; return s2ab(out); }\n\tvar idx = 0;\n\tif(o.sheet) {\n\t\tif(typeof o.sheet == \"number\") idx = o.sheet;\n\t\telse idx = wb.SheetNames.indexOf(o.sheet);\n\t\tif(!wb.SheetNames[idx]) throw new Error(\"Sheet not found: \" + o.sheet + \" : \" + (typeof o.sheet));\n\t}\n\tswitch(o.bookType || 'xlsb') {\n\t\tcase 'xml':\n\t\tcase 'xlml': return write_string_type(write_xlml(wb, o), o);\n\t\tcase 'slk':\n\t\tcase 'sylk': return write_string_type(SYLK.from_sheet(wb.Sheets[wb.SheetNames[idx]], o), o);\n\t\tcase 'htm':\n\t\tcase 'html': return write_string_type(sheet_to_html(wb.Sheets[wb.SheetNames[idx]], o), o);\n\t\tcase 'txt': return write_stxt_type(sheet_to_txt(wb.Sheets[wb.SheetNames[idx]], o), o);\n\t\tcase 'csv': return write_string_type(sheet_to_csv(wb.Sheets[wb.SheetNames[idx]], o), o, \"\\ufeff\");\n\t\tcase 'dif': return write_string_type(DIF.from_sheet(wb.Sheets[wb.SheetNames[idx]], o), o);\n\t\tcase 'dbf': return write_binary_type(DBF.from_sheet(wb.Sheets[wb.SheetNames[idx]], o), o);\n\t\tcase 'prn': return write_string_type(PRN.from_sheet(wb.Sheets[wb.SheetNames[idx]], o), o);\n\t\tcase 'rtf': return write_string_type(RTF.from_sheet(wb.Sheets[wb.SheetNames[idx]], o), o);\n\t\tcase 'eth': return write_string_type(ETH.from_sheet(wb.Sheets[wb.SheetNames[idx]], o), o);\n\t\tcase 'fods': return write_string_type(write_ods(wb, o), o);\n\t\tcase 'wk1': return write_binary_type(WK_.sheet_to_wk1(wb.Sheets[wb.SheetNames[idx]], o), o);\n\t\tcase 'wk3': return write_binary_type(WK_.book_to_wk3(wb, o), o);\n\t\tcase 'biff2': if(!o.biff) o.biff = 2; /* falls through */\n\t\tcase 'biff3': if(!o.biff) o.biff = 3; /* falls through */\n\t\tcase 'biff4': if(!o.biff) o.biff = 4; return write_binary_type(write_biff_buf(wb, o), o);\n\t\tcase 'biff5': if(!o.biff) o.biff = 5; /* falls through */\n\t\tcase 'biff8':\n\t\tcase 'xla':\n\t\tcase 'xls': if(!o.biff) o.biff = 8; return write_cfb_type(wb, o);\n\t\tcase 'xlsx':\n\t\tcase 'xlsm':\n\t\tcase 'xlam':\n\t\tcase 'xlsb':\n\t\tcase 'numbers':\n\t\tcase 'ods': return write_zip_type(wb, o);\n\t\tdefault: throw new Error (\"Unrecognized bookType |\" + o.bookType + \"|\");\n\t}\n}\n\nfunction resolve_book_type(o/*:WriteFileOpts*/) {\n\tif(o.bookType) return;\n\tvar _BT = {\n\t\t\"xls\": \"biff8\",\n\t\t\"htm\": \"html\",\n\t\t\"slk\": \"sylk\",\n\t\t\"socialcalc\": \"eth\",\n\t\t\"Sh33tJS\": \"WTF\"\n\t};\n\tvar ext = o.file.slice(o.file.lastIndexOf(\".\")).toLowerCase();\n\tif(ext.match(/^\\.[a-z]+$/)) o.bookType = ext.slice(1);\n\to.bookType = _BT[o.bookType] || o.bookType;\n}\n\nfunction writeFileSync(wb/*:Workbook*/, filename/*:string*/, opts/*:?WriteFileOpts*/) {\n\tvar o = opts||{}; o.type = 'file';\n\to.file = filename;\n\tresolve_book_type(o);\n\treturn writeSync(wb, o);\n}\n\nfunction writeFileSyncXLSX(wb/*:Workbook*/, filename/*:string*/, opts/*:?WriteFileOpts*/) {\n\tvar o = opts||{}; o.type = 'file';\n\to.file = filename;\n\tresolve_book_type(o);\n\treturn writeSyncXLSX(wb, o);\n}\n\n\nfunction writeFileAsync(filename/*:string*/, wb/*:Workbook*/, opts/*:?WriteFileOpts*/, cb/*:?(e?:ErrnoError)=>void*/) {\n\tvar o = opts||{}; o.type = 'file';\n\to.file = filename;\n\tresolve_book_type(o);\n\to.type = 'buffer';\n\tvar _cb = cb; if(!(_cb instanceof Function)) _cb = (opts/*:any*/);\n\treturn _fs.writeFile(filename, writeSync(wb, o), _cb);\n}\n/*::\ntype MJRObject = {\n\trow: any;\n\tisempty: boolean;\n};\n*/\nfunction make_json_row(sheet/*:Worksheet*/, r/*:Range*/, R/*:number*/, cols/*:Array*/, header/*:number*/, hdr/*:Array*/, dense/*:boolean*/, o/*:Sheet2JSONOpts*/)/*:MJRObject*/ {\n\tvar rr = encode_row(R);\n\tvar defval = o.defval, raw = o.raw || !Object.prototype.hasOwnProperty.call(o, \"raw\");\n\tvar isempty = true;\n\tvar row/*:any*/ = (header === 1) ? [] : {};\n\tif(header !== 1) {\n\t\tif(Object.defineProperty) try { Object.defineProperty(row, '__rowNum__', {value:R, enumerable:false}); } catch(e) { row.__rowNum__ = R; }\n\t\telse row.__rowNum__ = R;\n\t}\n\tif(!dense || sheet[R]) for (var C = r.s.c; C <= r.e.c; ++C) {\n\t\tvar val = dense ? sheet[R][C] : sheet[cols[C] + rr];\n\t\tif(val === undefined || val.t === undefined) {\n\t\t\tif(defval === undefined) continue;\n\t\t\tif(hdr[C] != null) { row[hdr[C]] = defval; }\n\t\t\tcontinue;\n\t\t}\n\t\tvar v = val.v;\n\t\tswitch(val.t){\n\t\t\tcase 'z': if(v == null) break; continue;\n\t\t\tcase 'e': v = (v == 0 ? null : void 0); break;\n\t\t\tcase 's': case 'd': case 'b': case 'n': break;\n\t\t\tdefault: throw new Error('unrecognized type ' + val.t);\n\t\t}\n\t\tif(hdr[C] != null) {\n\t\t\tif(v == null) {\n\t\t\t\tif(val.t == \"e\" && v === null) row[hdr[C]] = null;\n\t\t\t\telse if(defval !== undefined) row[hdr[C]] = defval;\n\t\t\t\telse if(raw && v === null) row[hdr[C]] = null;\n\t\t\t\telse continue;\n\t\t\t} else {\n\t\t\t\trow[hdr[C]] = raw && (val.t !== \"n\" || (val.t === \"n\" && o.rawNumbers !== false)) ? v : format_cell(val,v,o);\n\t\t\t}\n\t\t\tif(v != null) isempty = false;\n\t\t}\n\t}\n\treturn { row: row, isempty: isempty };\n}\n\n\nfunction sheet_to_json(sheet/*:Worksheet*/, opts/*:?Sheet2JSONOpts*/) {\n\tif(sheet == null || sheet[\"!ref\"] == null) return [];\n\tvar val = {t:'n',v:0}, header = 0, offset = 1, hdr/*:Array*/ = [], v=0, vv=\"\";\n\tvar r = {s:{r:0,c:0},e:{r:0,c:0}};\n\tvar o = opts || {};\n\tvar range = o.range != null ? o.range : sheet[\"!ref\"];\n\tif(o.header === 1) header = 1;\n\telse if(o.header === \"A\") header = 2;\n\telse if(Array.isArray(o.header)) header = 3;\n\telse if(o.header == null) header = 0;\n\tswitch(typeof range) {\n\t\tcase 'string': r = safe_decode_range(range); break;\n\t\tcase 'number': r = safe_decode_range(sheet[\"!ref\"]); r.s.r = range; break;\n\t\tdefault: r = range;\n\t}\n\tif(header > 0) offset = 0;\n\tvar rr = encode_row(r.s.r);\n\tvar cols/*:Array*/ = [];\n\tvar out/*:Array*/ = [];\n\tvar outi = 0, counter = 0;\n\tvar dense = Array.isArray(sheet);\n\tvar R = r.s.r, C = 0;\n\tvar header_cnt = {};\n\tif(dense && !sheet[R]) sheet[R] = [];\n\tvar colinfo/*:Array*/ = o.skipHidden && sheet[\"!cols\"] || [];\n\tvar rowinfo/*:Array*/ = o.skipHidden && sheet[\"!rows\"] || [];\n\tfor(C = r.s.c; C <= r.e.c; ++C) {\n\t\tif(((colinfo[C]||{}).hidden)) continue;\n\t\tcols[C] = encode_col(C);\n\t\tval = dense ? sheet[R][C] : sheet[cols[C] + rr];\n\t\tswitch(header) {\n\t\t\tcase 1: hdr[C] = C - r.s.c; break;\n\t\t\tcase 2: hdr[C] = cols[C]; break;\n\t\t\tcase 3: hdr[C] = o.header[C - r.s.c]; break;\n\t\t\tdefault:\n\t\t\t\tif(val == null) val = {w: \"__EMPTY\", t: \"s\"};\n\t\t\t\tvv = v = format_cell(val, null, o);\n\t\t\t\tcounter = header_cnt[v] || 0;\n\t\t\t\tif(!counter) header_cnt[v] = 1;\n\t\t\t\telse {\n\t\t\t\t\tdo { vv = v + \"_\" + (counter++); } while(header_cnt[vv]); header_cnt[v] = counter;\n\t\t\t\t\theader_cnt[vv] = 1;\n\t\t\t\t}\n\t\t\t\thdr[C] = vv;\n\t\t}\n\t}\n\tfor (R = r.s.r + offset; R <= r.e.r; ++R) {\n\t\tif ((rowinfo[R]||{}).hidden) continue;\n\t\tvar row = make_json_row(sheet, r, R, cols, header, hdr, dense, o);\n\t\tif((row.isempty === false) || (header === 1 ? o.blankrows !== false : !!o.blankrows)) out[outi++] = row.row;\n\t}\n\tout.length = outi;\n\treturn out;\n}\n\nvar qreg = /\"/g;\nfunction make_csv_row(sheet/*:Worksheet*/, r/*:Range*/, R/*:number*/, cols/*:Array*/, fs/*:number*/, rs/*:number*/, FS/*:string*/, o/*:Sheet2CSVOpts*/)/*:?string*/ {\n\tvar isempty = true;\n\tvar row/*:Array*/ = [], txt = \"\", rr = encode_row(R);\n\tfor(var C = r.s.c; C <= r.e.c; ++C) {\n\t\tif (!cols[C]) continue;\n\t\tvar val = o.dense ? (sheet[R]||[])[C]: sheet[cols[C] + rr];\n\t\tif(val == null) txt = \"\";\n\t\telse if(val.v != null) {\n\t\t\tisempty = false;\n\t\t\ttxt = ''+(o.rawNumbers && val.t == \"n\" ? val.v : format_cell(val, null, o));\n\t\t\tfor(var i = 0, cc = 0; i !== txt.length; ++i) if((cc = txt.charCodeAt(i)) === fs || cc === rs || cc === 34 || o.forceQuotes) {txt = \"\\\"\" + txt.replace(qreg, '\"\"') + \"\\\"\"; break; }\n\t\t\tif(txt == \"ID\") txt = '\"ID\"';\n\t\t} else if(val.f != null && !val.F) {\n\t\t\tisempty = false;\n\t\t\ttxt = '=' + val.f; if(txt.indexOf(\",\") >= 0) txt = '\"' + txt.replace(qreg, '\"\"') + '\"';\n\t\t} else txt = \"\";\n\t\t/* NOTE: Excel CSV does not support array formulae */\n\t\trow.push(txt);\n\t}\n\tif(o.blankrows === false && isempty) return null;\n\treturn row.join(FS);\n}\n\nfunction sheet_to_csv(sheet/*:Worksheet*/, opts/*:?Sheet2CSVOpts*/)/*:string*/ {\n\tvar out/*:Array*/ = [];\n\tvar o = opts == null ? {} : opts;\n\tif(sheet == null || sheet[\"!ref\"] == null) return \"\";\n\tvar r = safe_decode_range(sheet[\"!ref\"]);\n\tvar FS = o.FS !== undefined ? o.FS : \",\", fs = FS.charCodeAt(0);\n\tvar RS = o.RS !== undefined ? o.RS : \"\\n\", rs = RS.charCodeAt(0);\n\tvar endregex = new RegExp((FS==\"|\" ? \"\\\\|\" : FS)+\"+$\");\n\tvar row = \"\", cols/*:Array*/ = [];\n\to.dense = Array.isArray(sheet);\n\tvar colinfo/*:Array*/ = o.skipHidden && sheet[\"!cols\"] || [];\n\tvar rowinfo/*:Array*/ = o.skipHidden && sheet[\"!rows\"] || [];\n\tfor(var C = r.s.c; C <= r.e.c; ++C) if (!((colinfo[C]||{}).hidden)) cols[C] = encode_col(C);\n\tvar w = 0;\n\tfor(var R = r.s.r; R <= r.e.r; ++R) {\n\t\tif ((rowinfo[R]||{}).hidden) continue;\n\t\trow = make_csv_row(sheet, r, R, cols, fs, rs, FS, o);\n\t\tif(row == null) { continue; }\n\t\tif(o.strip) row = row.replace(endregex,\"\");\n\t\tif(row || (o.blankrows !== false)) out.push((w++ ? RS : \"\") + row);\n\t}\n\tdelete o.dense;\n\treturn out.join(\"\");\n}\n\nfunction sheet_to_txt(sheet/*:Worksheet*/, opts/*:?Sheet2CSVOpts*/) {\n\tif(!opts) opts = {}; opts.FS = \"\\t\"; opts.RS = \"\\n\";\n\tvar s = sheet_to_csv(sheet, opts);\n\tif(typeof $cptable == 'undefined' || opts.type == 'string') return s;\n\tvar o = $cptable.utils.encode(1200, s, 'str');\n\treturn String.fromCharCode(255) + String.fromCharCode(254) + o;\n}\n\nfunction sheet_to_formulae(sheet/*:Worksheet*/)/*:Array*/ {\n\tvar y = \"\", x, val=\"\";\n\tif(sheet == null || sheet[\"!ref\"] == null) return [];\n\tvar r = safe_decode_range(sheet['!ref']), rr = \"\", cols/*:Array*/ = [], C;\n\tvar cmds/*:Array*/ = [];\n\tvar dense = Array.isArray(sheet);\n\tfor(C = r.s.c; C <= r.e.c; ++C) cols[C] = encode_col(C);\n\tfor(var R = r.s.r; R <= r.e.r; ++R) {\n\t\trr = encode_row(R);\n\t\tfor(C = r.s.c; C <= r.e.c; ++C) {\n\t\t\ty = cols[C] + rr;\n\t\t\tx = dense ? (sheet[R]||[])[C] : sheet[y];\n\t\t\tval = \"\";\n\t\t\tif(x === undefined) continue;\n\t\t\telse if(x.F != null) {\n\t\t\t\ty = x.F;\n\t\t\t\tif(!x.f) continue;\n\t\t\t\tval = x.f;\n\t\t\t\tif(y.indexOf(\":\") == -1) y = y + \":\" + y;\n\t\t\t}\n\t\t\tif(x.f != null) val = x.f;\n\t\t\telse if(x.t == 'z') continue;\n\t\t\telse if(x.t == 'n' && x.v != null) val = \"\" + x.v;\n\t\t\telse if(x.t == 'b') val = x.v ? \"TRUE\" : \"FALSE\";\n\t\t\telse if(x.w !== undefined) val = \"'\" + x.w;\n\t\t\telse if(x.v === undefined) continue;\n\t\t\telse if(x.t == 's') val = \"'\" + x.v;\n\t\t\telse val = \"\"+x.v;\n\t\t\tcmds[cmds.length] = y + \"=\" + val;\n\t\t}\n\t}\n\treturn cmds;\n}\n\nfunction sheet_add_json(_ws/*:?Worksheet*/, js/*:Array*/, opts)/*:Worksheet*/ {\n\tvar o = opts || {};\n\tvar offset = +!o.skipHeader;\n\tvar ws/*:Worksheet*/ = _ws || ({}/*:any*/);\n\tvar _R = 0, _C = 0;\n\tif(ws && o.origin != null) {\n\t\tif(typeof o.origin == 'number') _R = o.origin;\n\t\telse {\n\t\t\tvar _origin/*:CellAddress*/ = typeof o.origin == \"string\" ? decode_cell(o.origin) : o.origin;\n\t\t\t_R = _origin.r; _C = _origin.c;\n\t\t}\n\t}\n\tvar cell/*:Cell*/;\n\tvar range/*:Range*/ = ({s: {c:0, r:0}, e: {c:_C, r:_R + js.length - 1 + offset}}/*:any*/);\n\tif(ws['!ref']) {\n\t\tvar _range = safe_decode_range(ws['!ref']);\n\t\trange.e.c = Math.max(range.e.c, _range.e.c);\n\t\trange.e.r = Math.max(range.e.r, _range.e.r);\n\t\tif(_R == -1) { _R = _range.e.r + 1; range.e.r = _R + js.length - 1 + offset; }\n\t} else {\n\t\tif(_R == -1) { _R = 0; range.e.r = js.length - 1 + offset; }\n\t}\n\tvar hdr/*:Array*/ = o.header || [], C = 0;\n\n\tjs.forEach(function (JS, R/*:number*/) {\n\t\tkeys(JS).forEach(function(k) {\n\t\t\tif((C=hdr.indexOf(k)) == -1) hdr[C=hdr.length] = k;\n\t\t\tvar v = JS[k];\n\t\t\tvar t = 'z';\n\t\t\tvar z = \"\";\n\t\t\tvar ref = encode_cell({c:_C + C,r:_R + R + offset});\n\t\t\tcell = ws_get_cell_stub(ws, ref);\n\t\t\tif(v && typeof v === 'object' && !(v instanceof Date)){\n\t\t\t\tws[ref] = v;\n\t\t\t} else {\n\t\t\t\tif(typeof v == 'number') t = 'n';\n\t\t\t\telse if(typeof v == 'boolean') t = 'b';\n\t\t\t\telse if(typeof v == 'string') t = 's';\n\t\t\t\telse if(v instanceof Date) {\n\t\t\t\t\tt = 'd';\n\t\t\t\t\tif(!o.cellDates) { t = 'n'; v = datenum(v); }\n\t\t\t\t\tz = (o.dateNF || table_fmt[14]);\n\t\t\t\t}\n\t\t\t\telse if(v === null && o.nullError) { t = 'e'; v = 0; }\n\t\t\t\tif(!cell) ws[ref] = cell = ({t:t, v:v}/*:any*/);\n\t\t\t\telse {\n\t\t\t\t\tcell.t = t; cell.v = v;\n\t\t\t\t\tdelete cell.w; delete cell.R;\n\t\t\t\t\tif(z) cell.z = z;\n\t\t\t\t}\n\t\t\t\tif(z) cell.z = z;\n\t\t\t}\n\t\t});\n\t});\n\trange.e.c = Math.max(range.e.c, _C + hdr.length - 1);\n\tvar __R = encode_row(_R);\n\tif(offset) for(C = 0; C < hdr.length; ++C) ws[encode_col(C + _C) + __R] = {t:'s', v:hdr[C]};\n\tws['!ref'] = encode_range(range);\n\treturn ws;\n}\nfunction json_to_sheet(js/*:Array*/, opts)/*:Worksheet*/ { return sheet_add_json(null, js, opts); }\n\n/* get cell, creating a stub if necessary */\nfunction ws_get_cell_stub(ws/*:Worksheet*/, R, C/*:?number*/)/*:Cell*/ {\n\t/* A1 cell address */\n\tif(typeof R == \"string\") {\n\t\t/* dense */\n\t\tif(Array.isArray(ws)) {\n\t\t\tvar RC = decode_cell(R);\n\t\t\tif(!ws[RC.r]) ws[RC.r] = [];\n\t\t\treturn ws[RC.r][RC.c] || (ws[RC.r][RC.c] = {t:'z'});\n\t\t}\n\t\treturn ws[R] || (ws[R] = {t:'z'});\n\t}\n\t/* cell address object */\n\tif(typeof R != \"number\") return ws_get_cell_stub(ws, encode_cell(R));\n\t/* R and C are 0-based indices */\n\treturn ws_get_cell_stub(ws, encode_cell({r:R,c:C||0}));\n}\n\n/* find sheet index for given name / validate index */\nfunction wb_sheet_idx(wb/*:Workbook*/, sh/*:number|string*/) {\n\tif(typeof sh == \"number\") {\n\t\tif(sh >= 0 && wb.SheetNames.length > sh) return sh;\n\t\tthrow new Error(\"Cannot find sheet # \" + sh);\n\t} else if(typeof sh == \"string\") {\n\t\tvar idx = wb.SheetNames.indexOf(sh);\n\t\tif(idx > -1) return idx;\n\t\tthrow new Error(\"Cannot find sheet name |\" + sh + \"|\");\n\t} else throw new Error(\"Cannot find sheet |\" + sh + \"|\");\n}\n\n/* simple blank workbook object */\nfunction book_new()/*:Workbook*/ {\n\treturn { SheetNames: [], Sheets: {} };\n}\n\n/* add a worksheet to the end of a given workbook */\nfunction book_append_sheet(wb/*:Workbook*/, ws/*:Worksheet*/, name/*:?string*/, roll/*:?boolean*/)/*:string*/ {\n\tvar i = 1;\n\tif(!name) for(; i <= 0xFFFF; ++i, name = undefined) if(wb.SheetNames.indexOf(name = \"Sheet\" + i) == -1) break;\n\tif(!name || wb.SheetNames.length >= 0xFFFF) throw new Error(\"Too many worksheets\");\n\tif(roll && wb.SheetNames.indexOf(name) >= 0) {\n\t\tvar m = name.match(/(^.*?)(\\d+)$/);\n\t\ti = m && +m[2] || 0;\n\t\tvar root = m && m[1] || name;\n\t\tfor(++i; i <= 0xFFFF; ++i) if(wb.SheetNames.indexOf(name = root + i) == -1) break;\n\t}\n\tcheck_ws_name(name);\n\tif(wb.SheetNames.indexOf(name) >= 0) throw new Error(\"Worksheet with name |\" + name + \"| already exists!\");\n\n\twb.SheetNames.push(name);\n\twb.Sheets[name] = ws;\n\treturn name;\n}\n\n/* set sheet visibility (visible/hidden/very hidden) */\nfunction book_set_sheet_visibility(wb/*:Workbook*/, sh/*:number|string*/, vis/*:number*/) {\n\tif(!wb.Workbook) wb.Workbook = {};\n\tif(!wb.Workbook.Sheets) wb.Workbook.Sheets = [];\n\n\tvar idx = wb_sheet_idx(wb, sh);\n\t// $FlowIgnore\n\tif(!wb.Workbook.Sheets[idx]) wb.Workbook.Sheets[idx] = {};\n\n\tswitch(vis) {\n\t\tcase 0: case 1: case 2: break;\n\t\tdefault: throw new Error(\"Bad sheet visibility setting \" + vis);\n\t}\n\t// $FlowIgnore\n\twb.Workbook.Sheets[idx].Hidden = vis;\n}\n\n/* set number format */\nfunction cell_set_number_format(cell/*:Cell*/, fmt/*:string|number*/) {\n\tcell.z = fmt;\n\treturn cell;\n}\n\n/* set cell hyperlink */\nfunction cell_set_hyperlink(cell/*:Cell*/, target/*:string*/, tooltip/*:?string*/) {\n\tif(!target) {\n\t\tdelete cell.l;\n\t} else {\n\t\tcell.l = ({ Target: target }/*:Hyperlink*/);\n\t\tif(tooltip) cell.l.Tooltip = tooltip;\n\t}\n\treturn cell;\n}\nfunction cell_set_internal_link(cell/*:Cell*/, range/*:string*/, tooltip/*:?string*/) { return cell_set_hyperlink(cell, \"#\" + range, tooltip); }\n\n/* add to cell comments */\nfunction cell_add_comment(cell/*:Cell*/, text/*:string*/, author/*:?string*/) {\n\tif(!cell.c) cell.c = [];\n\tcell.c.push({t:text, a:author||\"SheetJS\"});\n}\n\n/* set array formula and flush related cells */\nfunction sheet_set_array_formula(ws/*:Worksheet*/, range, formula/*:string*/, dynamic/*:boolean*/) {\n\tvar rng = typeof range != \"string\" ? range : safe_decode_range(range);\n\tvar rngstr = typeof range == \"string\" ? range : encode_range(range);\n\tfor(var R = rng.s.r; R <= rng.e.r; ++R) for(var C = rng.s.c; C <= rng.e.c; ++C) {\n\t\tvar cell = ws_get_cell_stub(ws, R, C);\n\t\tcell.t = 'n';\n\t\tcell.F = rngstr;\n\t\tdelete cell.v;\n\t\tif(R == rng.s.r && C == rng.s.c) {\n\t\t\tcell.f = formula;\n\t\t\tif(dynamic) cell.D = true;\n\t\t}\n\t}\n\treturn ws;\n}\n\nvar utils/*:any*/ = {\n\tencode_col: encode_col,\n\tencode_row: encode_row,\n\tencode_cell: encode_cell,\n\tencode_range: encode_range,\n\tdecode_col: decode_col,\n\tdecode_row: decode_row,\n\tsplit_cell: split_cell,\n\tdecode_cell: decode_cell,\n\tdecode_range: decode_range,\n\tformat_cell: format_cell,\n\tsheet_add_aoa: sheet_add_aoa,\n\tsheet_add_json: sheet_add_json,\n\tsheet_add_dom: sheet_add_dom,\n\taoa_to_sheet: aoa_to_sheet,\n\tjson_to_sheet: json_to_sheet,\n\ttable_to_sheet: parse_dom_table,\n\ttable_to_book: table_to_book,\n\tsheet_to_csv: sheet_to_csv,\n\tsheet_to_txt: sheet_to_txt,\n\tsheet_to_json: sheet_to_json,\n\tsheet_to_html: sheet_to_html,\n\tsheet_to_formulae: sheet_to_formulae,\n\tsheet_to_row_object_array: sheet_to_json,\n\tsheet_get_cell: ws_get_cell_stub,\n\tbook_new: book_new,\n\tbook_append_sheet: book_append_sheet,\n\tbook_set_sheet_visibility: book_set_sheet_visibility,\n\tcell_set_number_format: cell_set_number_format,\n\tcell_set_hyperlink: cell_set_hyperlink,\n\tcell_set_internal_link: cell_set_internal_link,\n\tcell_add_comment: cell_add_comment,\n\tsheet_set_array_formula: sheet_set_array_formula,\n\tconsts: {\n\t\tSHEET_VISIBLE: 0,\n\t\tSHEET_HIDDEN: 1,\n\t\tSHEET_VERY_HIDDEN: 2\n\t}\n};\n\nvar _Readable;\nfunction set_readable(R) { _Readable = R; }\n\nfunction write_csv_stream(sheet/*:Worksheet*/, opts/*:?Sheet2CSVOpts*/) {\n\tvar stream = _Readable();\n\tvar o = opts == null ? {} : opts;\n\tif(sheet == null || sheet[\"!ref\"] == null) { stream.push(null); return stream; }\n\tvar r = safe_decode_range(sheet[\"!ref\"]);\n\tvar FS = o.FS !== undefined ? o.FS : \",\", fs = FS.charCodeAt(0);\n\tvar RS = o.RS !== undefined ? o.RS : \"\\n\", rs = RS.charCodeAt(0);\n\tvar endregex = new RegExp((FS==\"|\" ? \"\\\\|\" : FS)+\"+$\");\n\tvar row/*:?string*/ = \"\", cols/*:Array*/ = [];\n\to.dense = Array.isArray(sheet);\n\tvar colinfo/*:Array*/ = o.skipHidden && sheet[\"!cols\"] || [];\n\tvar rowinfo/*:Array*/ = o.skipHidden && sheet[\"!rows\"] || [];\n\tfor(var C = r.s.c; C <= r.e.c; ++C) if (!((colinfo[C]||{}).hidden)) cols[C] = encode_col(C);\n\tvar R = r.s.r;\n\tvar BOM = false, w = 0;\n\tstream._read = function() {\n\t\tif(!BOM) { BOM = true; return stream.push(\"\\uFEFF\"); }\n\t\twhile(R <= r.e.r) {\n\t\t\t++R;\n\t\t\tif ((rowinfo[R-1]||{}).hidden) continue;\n\t\t\trow = make_csv_row(sheet, r, R-1, cols, fs, rs, FS, o);\n\t\t\tif(row != null) {\n\t\t\t\tif(o.strip) row = row.replace(endregex,\"\");\n\t\t\t\tif(row || (o.blankrows !== false)) return stream.push((w++ ? RS : \"\") + row);\n\t\t\t}\n\t\t}\n\t\treturn stream.push(null);\n\t};\n\treturn stream;\n}\n\nfunction write_html_stream(ws/*:Worksheet*/, opts/*:?Sheet2HTMLOpts*/) {\n\tvar stream = _Readable();\n\n\tvar o = opts || {};\n\tvar header = o.header != null ? o.header : HTML_BEGIN;\n\tvar footer = o.footer != null ? o.footer : HTML_END;\n\tstream.push(header);\n\tvar r = decode_range(ws['!ref']);\n\to.dense = Array.isArray(ws);\n\tstream.push(make_html_preamble(ws, r, o));\n\tvar R = r.s.r;\n\tvar end = false;\n\tstream._read = function() {\n\t\tif(R > r.e.r) {\n\t\t\tif(!end) { end = true; stream.push(\"\" + footer); }\n\t\t\treturn stream.push(null);\n\t\t}\n\t\twhile(R <= r.e.r) {\n\t\t\tstream.push(make_html_row(ws, r, R, o));\n\t\t\t++R;\n\t\t\tbreak;\n\t\t}\n\t};\n\treturn stream;\n}\n\nfunction write_json_stream(sheet/*:Worksheet*/, opts/*:?Sheet2CSVOpts*/) {\n\tvar stream = _Readable({objectMode:true});\n\n\tif(sheet == null || sheet[\"!ref\"] == null) { stream.push(null); return stream; }\n\tvar val = {t:'n',v:0}, header = 0, offset = 1, hdr/*:Array*/ = [], v=0, vv=\"\";\n\tvar r = {s:{r:0,c:0},e:{r:0,c:0}};\n\tvar o = opts || {};\n\tvar range = o.range != null ? o.range : sheet[\"!ref\"];\n\tif(o.header === 1) header = 1;\n\telse if(o.header === \"A\") header = 2;\n\telse if(Array.isArray(o.header)) header = 3;\n\tswitch(typeof range) {\n\t\tcase 'string': r = safe_decode_range(range); break;\n\t\tcase 'number': r = safe_decode_range(sheet[\"!ref\"]); r.s.r = range; break;\n\t\tdefault: r = range;\n\t}\n\tif(header > 0) offset = 0;\n\tvar rr = encode_row(r.s.r);\n\tvar cols/*:Array*/ = [];\n\tvar counter = 0;\n\tvar dense = Array.isArray(sheet);\n\tvar R = r.s.r, C = 0;\n\tvar header_cnt = {};\n\tif(dense && !sheet[R]) sheet[R] = [];\n\tvar colinfo/*:Array*/ = o.skipHidden && sheet[\"!cols\"] || [];\n\tvar rowinfo/*:Array*/ = o.skipHidden && sheet[\"!rows\"] || [];\n\tfor(C = r.s.c; C <= r.e.c; ++C) {\n\t\tif(((colinfo[C]||{}).hidden)) continue;\n\t\tcols[C] = encode_col(C);\n\t\tval = dense ? sheet[R][C] : sheet[cols[C] + rr];\n\t\tswitch(header) {\n\t\t\tcase 1: hdr[C] = C - r.s.c; break;\n\t\t\tcase 2: hdr[C] = cols[C]; break;\n\t\t\tcase 3: hdr[C] = o.header[C - r.s.c]; break;\n\t\t\tdefault:\n\t\t\t\tif(val == null) val = {w: \"__EMPTY\", t: \"s\"};\n\t\t\t\tvv = v = format_cell(val, null, o);\n\t\t\t\tcounter = header_cnt[v] || 0;\n\t\t\t\tif(!counter) header_cnt[v] = 1;\n\t\t\t\telse {\n\t\t\t\t\tdo { vv = v + \"_\" + (counter++); } while(header_cnt[vv]); header_cnt[v] = counter;\n\t\t\t\t\theader_cnt[vv] = 1;\n\t\t\t\t}\n\t\t\t\thdr[C] = vv;\n\t\t}\n\t}\n\tR = r.s.r + offset;\n\tstream._read = function() {\n\t\twhile(R <= r.e.r) {\n\t\t\tif ((rowinfo[R-1]||{}).hidden) continue;\n\t\t\tvar row = make_json_row(sheet, r, R, cols, header, hdr, dense, o);\n\t\t\t++R;\n\t\t\tif((row.isempty === false) || (header === 1 ? o.blankrows !== false : !!o.blankrows)) {\n\t\t\t\tstream.push(row.row);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\treturn stream.push(null);\n\t};\n\treturn stream;\n}\n\nvar __stream = {\n\tto_json: write_json_stream,\n\tto_html: write_html_stream,\n\tto_csv: write_csv_stream,\n set_readable: set_readable\n};\nexport const version = XLSX.version;\nexport {\n\tparse_xlscfb,\n\tparse_zip,\n\treadSync as read,\n\treadFileSync as readFile,\n\treadFileSync,\n\twriteSync as write,\n\twriteFileSync as writeFile,\n\twriteFileSync,\n\twriteFileAsync,\n\twriteSyncXLSX as writeXLSX,\n\twriteFileSyncXLSX as writeFileXLSX,\n\tutils,\n\t__stream as stream,\n\tSSF,\n\tCFB\n};\n","import React, { useCallback, useEffect, useState } from 'react';\n\nimport { App, Button, Row, Space, Typography } from 'antd';\n\nimport Content from 'components/_Common/_Layout/Content';\nimport List from 'components/_Common/List';\nimport { ConsumptionListModal, ConsumptionReadingFormModal, FormConsumptionModal } from 'components/Consumption';\nimport { ConsumptionContext, Value } from 'lib/hooks/useConsumption';\nimport { Show } from 'lib/Show';\nimport { listApartment } from 'services/ApartmentService';\nimport { listConsumption, listConsumptionReading, listTypeConsumption } from 'services/Consumption.service';\n\nimport { Columns } from './Columns';\nimport { ConsumptionReport } from './Consumption.report';\n\nexport function Consumptions() {\n const [typeConsumption, setTypeConsumption] = useState([]);\n const [consumptions, setConsumptions] = useState([]);\n const [consumptionsReading, setConsumptionsReading] = useState([]);\n const [apartments, setApartments] = useState([]);\n const [isFormConsumptionModalVisible, setIsFormConsumptionModalVisible] = useState(false);\n const [isConsumptionListModalVisible, setIsConsumptionListModalVisible] = useState(false);\n const [isConsumptionReadingFormModalVisible, setIsConsumptionReadingFormModalVisible] = useState(false);\n const [isFetching, setIsFetching] = useState(false);\n\n const app = App.useApp();\n\n const fetchConsumptions = useCallback(async () => {\n setIsFetching(true);\n\n const promises = [];\n\n promises.push(listConsumptionReading().then((response) => {\n if ('status' in response)\n return;\n setConsumptionsReading(response);\n }));\n\n promises.push(listTypeConsumption().then((response) => {\n if ('status' in response)\n return;\n setTypeConsumption(response);\n }));\n\n promises.push(listConsumption().then((response) => {\n if ('status' in response)\n return;\n setConsumptions(response);\n }));\n\n Promise.all(promises).then(() => setIsFetching(false));\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [app]);\n\n const fetchApartments = useCallback(async () => {\n const response = await listApartment();\n\n if ('status' in response)\n return;\n\n setApartments(response);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [app]);\n\n useEffect(() => {\n fetchApartments();\n fetchConsumptions();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [fetchConsumptions]);\n\n\n\n const value: Value = {\n isFetching,\n\n apartments,\n\n typeConsumption,\n consumptions,\n consumptionsReading,\n fetchConsumptions,\n\n isFormConsumptionModalVisible,\n setIsFormConsumptionModalVisible,\n\n isConsumptionListModalVisible,\n setIsConsumptionListModalVisible,\n\n isConsumptionReadingFormModalVisible,\n setIsConsumptionReadingFormModalVisible\n };\n\n return (\n \n \n \n \n Leituras realizadas\n \n\n \n ConsumptionReport(consumptionsReading)}\n >\n Exportar\n \n setIsConsumptionListModalVisible(true)}\n >\n Definições de consumo\n \n\n \n \n \n \n \n\n \n \n \n\n \n \n \n\n \n \n \n\n \n );\n}\n","import dayjs from 'dayjs';\nimport Authentication from 'lib/Authentication';\nimport { formatBRL } from 'lib/helpers/BRL';\nimport * as XLSX from 'xlsx';\n\nexport function ConsumptionReport(consumptionsReading: Consumption.Reading[]) {\n const client = Authentication.getClients().find(c => c.id === Authentication.getCurrentClientId());\n\n const currentMonth: any = [];\n const lastMonth: any = [];\n\n consumptionsReading\n .filter(reading => (dayjs(reading.reading_date).format('MM-YYYY') === dayjs().format('MM-YYYY')) || (dayjs(reading.reading_date).format('MM-YYYY') === dayjs().subtract(1, 'month').format('MM-YYYY')))\n .forEach(reading => {\n const body = {\n 'Consumo': reading.consumption.type_consumption.name,\n 'Unidade': reading.apartment\n ? `${reading.apartment.tower.name} - ${reading.apartment.name}`\n : 'Coletivo',\n 'Data da leitura': dayjs(reading.reading_date).format('DD/MM/YYYY'),\n 'Última leitura': reading.last_read,\n 'Leitura atual': reading.current_reading,\n 'Consumo do mês': reading.monthly_consumption,\n 'Valor do consumo': formatBRL(reading.monthly_consumption * reading.consumption.price)\n };\n\n if (dayjs(reading.reading_date).format('MM-YYYY') === dayjs().format('MM-YYYY'))\n currentMonth.push(body);\n\n if (dayjs(reading.reading_date).format('MM-YYYY') === dayjs().subtract(1, 'month').format('MM-YYYY'))\n lastMonth.push(body);\n });\n\n const workbook = XLSX.utils.book_new();\n XLSX.utils.book_append_sheet(workbook, XLSX.utils.json_to_sheet(currentMonth), `Leituras ${dayjs().format('MM-YYYY')}`);\n XLSX.utils.book_append_sheet(workbook, XLSX.utils.json_to_sheet(lastMonth), `Leituras ${dayjs().subtract(1, 'month').format('MM-YYYY')}`);\n\n const excelBase64 = XLSX.write(workbook, { bookType: 'xlsx', type: 'base64' });\n\n const link = document.createElement('a');\n link.href = 'data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,' + excelBase64;\n link.download = `${client?.name} - Relatório de leituras.xlsx`;\n link.target = '_blank';\n\n return link.click();\n}","\"use client\";\n\nimport * as React from 'react';\nimport { useContext, useMemo } from 'react';\nimport { FormItemInputContext } from '../form/context';\nimport { Button, Group } from '../radio';\nimport Select from '../select';\nconst YEAR_SELECT_OFFSET = 10;\nconst YEAR_SELECT_TOTAL = 20;\nfunction YearSelect(props) {\n const {\n fullscreen,\n validRange,\n generateConfig,\n locale,\n prefixCls,\n value,\n onChange,\n divRef\n } = props;\n const year = generateConfig.getYear(value || generateConfig.getNow());\n let start = year - YEAR_SELECT_OFFSET;\n let end = start + YEAR_SELECT_TOTAL;\n if (validRange) {\n start = generateConfig.getYear(validRange[0]);\n end = generateConfig.getYear(validRange[1]) + 1;\n }\n const suffix = locale && locale.year === '年' ? '年' : '';\n const options = [];\n for (let index = start; index < end; index++) {\n options.push({\n label: `${index}${suffix}`,\n value: index\n });\n }\n return /*#__PURE__*/React.createElement(Select, {\n size: fullscreen ? undefined : 'small',\n options: options,\n value: year,\n className: `${prefixCls}-year-select`,\n onChange: numYear => {\n let newDate = generateConfig.setYear(value, numYear);\n if (validRange) {\n const [startDate, endDate] = validRange;\n const newYear = generateConfig.getYear(newDate);\n const newMonth = generateConfig.getMonth(newDate);\n if (newYear === generateConfig.getYear(endDate) && newMonth > generateConfig.getMonth(endDate)) {\n newDate = generateConfig.setMonth(newDate, generateConfig.getMonth(endDate));\n }\n if (newYear === generateConfig.getYear(startDate) && newMonth < generateConfig.getMonth(startDate)) {\n newDate = generateConfig.setMonth(newDate, generateConfig.getMonth(startDate));\n }\n }\n onChange(newDate);\n },\n getPopupContainer: () => divRef.current\n });\n}\nfunction MonthSelect(props) {\n const {\n prefixCls,\n fullscreen,\n validRange,\n value,\n generateConfig,\n locale,\n onChange,\n divRef\n } = props;\n const month = generateConfig.getMonth(value || generateConfig.getNow());\n let start = 0;\n let end = 11;\n if (validRange) {\n const [rangeStart, rangeEnd] = validRange;\n const currentYear = generateConfig.getYear(value);\n if (generateConfig.getYear(rangeEnd) === currentYear) {\n end = generateConfig.getMonth(rangeEnd);\n }\n if (generateConfig.getYear(rangeStart) === currentYear) {\n start = generateConfig.getMonth(rangeStart);\n }\n }\n const months = locale.shortMonths || generateConfig.locale.getShortMonths(locale.locale);\n const options = [];\n for (let index = start; index <= end; index += 1) {\n options.push({\n label: months[index],\n value: index\n });\n }\n return /*#__PURE__*/React.createElement(Select, {\n size: fullscreen ? undefined : 'small',\n className: `${prefixCls}-month-select`,\n value: month,\n options: options,\n onChange: newMonth => {\n onChange(generateConfig.setMonth(value, newMonth));\n },\n getPopupContainer: () => divRef.current\n });\n}\nfunction ModeSwitch(props) {\n const {\n prefixCls,\n locale,\n mode,\n fullscreen,\n onModeChange\n } = props;\n return /*#__PURE__*/React.createElement(Group, {\n onChange: _ref => {\n let {\n target: {\n value\n }\n } = _ref;\n onModeChange(value);\n },\n value: mode,\n size: fullscreen ? undefined : 'small',\n className: `${prefixCls}-mode-switch`\n }, /*#__PURE__*/React.createElement(Button, {\n value: \"month\"\n }, locale.month), /*#__PURE__*/React.createElement(Button, {\n value: \"year\"\n }, locale.year));\n}\nfunction CalendarHeader(props) {\n const {\n prefixCls,\n fullscreen,\n mode,\n onChange,\n onModeChange\n } = props;\n const divRef = React.useRef(null);\n const formItemInputContext = useContext(FormItemInputContext);\n const mergedFormItemInputContext = useMemo(() => Object.assign(Object.assign({}, formItemInputContext), {\n isFormItemInput: false\n }), [formItemInputContext]);\n const sharedProps = Object.assign(Object.assign({}, props), {\n fullscreen,\n divRef\n });\n return /*#__PURE__*/React.createElement(\"div\", {\n className: `${prefixCls}-header`,\n ref: divRef\n }, /*#__PURE__*/React.createElement(FormItemInputContext.Provider, {\n value: mergedFormItemInputContext\n }, /*#__PURE__*/React.createElement(YearSelect, Object.assign({}, sharedProps, {\n onChange: v => {\n onChange(v, 'year');\n }\n })), mode === 'month' && (/*#__PURE__*/React.createElement(MonthSelect, Object.assign({}, sharedProps, {\n onChange: v => {\n onChange(v, 'month');\n }\n })))), /*#__PURE__*/React.createElement(ModeSwitch, Object.assign({}, sharedProps, {\n onModeChange: onModeChange\n })));\n}\nexport default CalendarHeader;","import { unit } from '@ant-design/cssinjs';\nimport { genPanelStyle, initPanelComponentToken, initPickerPanelToken } from '../../date-picker/style';\nimport { resetComponent } from '../../style';\nimport { genStyleHooks, mergeToken } from '../../theme/internal';\nexport const genCalendarStyles = token => {\n const {\n calendarCls,\n componentCls,\n fullBg,\n fullPanelBg,\n itemActiveBg\n } = token;\n return {\n [calendarCls]: Object.assign(Object.assign(Object.assign({}, genPanelStyle(token)), resetComponent(token)), {\n background: fullBg,\n '&-rtl': {\n direction: 'rtl'\n },\n [`${calendarCls}-header`]: {\n display: 'flex',\n justifyContent: 'flex-end',\n padding: `${unit(token.paddingSM)} 0`,\n [`${calendarCls}-year-select`]: {\n minWidth: token.yearControlWidth\n },\n [`${calendarCls}-month-select`]: {\n minWidth: token.monthControlWidth,\n marginInlineStart: token.marginXS\n },\n [`${calendarCls}-mode-switch`]: {\n marginInlineStart: token.marginXS\n }\n }\n }),\n [`${calendarCls} ${componentCls}-panel`]: {\n background: fullPanelBg,\n border: 0,\n borderTop: `${unit(token.lineWidth)} ${token.lineType} ${token.colorSplit}`,\n borderRadius: 0,\n [`${componentCls}-month-panel, ${componentCls}-date-panel`]: {\n width: 'auto'\n },\n [`${componentCls}-body`]: {\n padding: `${unit(token.paddingXS)} 0`\n },\n [`${componentCls}-content`]: {\n width: '100%'\n }\n },\n [`${calendarCls}-mini`]: {\n borderRadius: token.borderRadiusLG,\n [`${calendarCls}-header`]: {\n paddingInlineEnd: token.paddingXS,\n paddingInlineStart: token.paddingXS\n },\n [`${componentCls}-panel`]: {\n borderRadius: `0 0 ${unit(token.borderRadiusLG)} ${unit(token.borderRadiusLG)}`\n },\n [`${componentCls}-content`]: {\n height: token.miniContentHeight,\n th: {\n height: 'auto',\n padding: 0,\n lineHeight: unit(token.weekHeight)\n }\n },\n [`${componentCls}-cell::before`]: {\n pointerEvents: 'none'\n }\n },\n [`${calendarCls}${calendarCls}-full`]: {\n [`${componentCls}-panel`]: {\n display: 'block',\n width: '100%',\n textAlign: 'end',\n background: fullBg,\n border: 0,\n [`${componentCls}-body`]: {\n 'th, td': {\n padding: 0\n },\n th: {\n height: 'auto',\n paddingInlineEnd: token.paddingSM,\n paddingBottom: token.paddingXXS,\n lineHeight: unit(token.weekHeight)\n }\n }\n },\n [`${componentCls}-cell-week ${componentCls}-cell-inner`]: {\n display: 'block',\n borderRadius: 0,\n borderTop: `${unit(token.lineWidthBold)} ${token.lineType} ${token.colorSplit}`,\n width: '100%',\n height: token.calc(token.dateValueHeight).add(token.dateContentHeight).add(token.calc(token.paddingXS).div(2)).add(token.lineWidthBold).equal()\n },\n [`${componentCls}-cell`]: {\n '&::before': {\n display: 'none'\n },\n '&:hover': {\n [`${calendarCls}-date`]: {\n background: token.controlItemBgHover\n }\n },\n [`${calendarCls}-date-today::before`]: {\n display: 'none'\n },\n // >>> Selected\n [`&-in-view${componentCls}-cell-selected`]: {\n [`${calendarCls}-date, ${calendarCls}-date-today`]: {\n background: itemActiveBg\n }\n },\n '&-selected, &-selected:hover': {\n [`${calendarCls}-date, ${calendarCls}-date-today`]: {\n [`${calendarCls}-date-value`]: {\n color: token.colorPrimary\n }\n }\n }\n },\n [`${calendarCls}-date`]: {\n display: 'block',\n width: 'auto',\n height: 'auto',\n margin: `0 ${unit(token.calc(token.marginXS).div(2).equal())}`,\n padding: `${unit(token.calc(token.paddingXS).div(2).equal())} ${unit(token.paddingXS)} 0`,\n border: 0,\n borderTop: `${unit(token.lineWidthBold)} ${token.lineType} ${token.colorSplit}`,\n borderRadius: 0,\n transition: `background ${token.motionDurationSlow}`,\n '&-value': {\n lineHeight: unit(token.dateValueHeight),\n transition: `color ${token.motionDurationSlow}`\n },\n '&-content': {\n position: 'static',\n width: 'auto',\n height: token.dateContentHeight,\n overflowY: 'auto',\n color: token.colorText,\n lineHeight: token.lineHeight,\n textAlign: 'start'\n },\n '&-today': {\n borderColor: token.colorPrimary,\n [`${calendarCls}-date-value`]: {\n color: token.colorText\n }\n }\n }\n },\n [`@media only screen and (max-width: ${unit(token.screenXS)}) `]: {\n [calendarCls]: {\n [`${calendarCls}-header`]: {\n display: 'block',\n [`${calendarCls}-year-select`]: {\n width: '50%'\n },\n [`${calendarCls}-month-select`]: {\n width: `calc(50% - ${unit(token.paddingXS)})`\n },\n [`${calendarCls}-mode-switch`]: {\n width: '100%',\n marginTop: token.marginXS,\n marginInlineStart: 0,\n '> label': {\n width: '50%',\n textAlign: 'center'\n }\n }\n }\n }\n }\n };\n};\nexport const prepareComponentToken = token => Object.assign({\n fullBg: token.colorBgContainer,\n fullPanelBg: token.colorBgContainer,\n itemActiveBg: token.controlItemBgActive,\n yearControlWidth: 80,\n monthControlWidth: 70,\n miniContentHeight: 256\n}, initPanelComponentToken(token));\nexport default genStyleHooks('Calendar', token => {\n const calendarCls = `${token.componentCls}-calendar`;\n const calendarToken = mergeToken(token, initPickerPanelToken(token), {\n calendarCls,\n pickerCellInnerCls: `${token.componentCls}-cell-inner`,\n dateValueHeight: token.controlHeightSM,\n weekHeight: token.calc(token.controlHeightSM).mul(0.75).equal(),\n dateContentHeight: token.calc(token.calc(token.fontHeightSM).add(token.marginXS)).mul(3).add(token.calc(token.lineWidth).mul(2)).equal()\n });\n return [genCalendarStyles(calendarToken)];\n}, prepareComponentToken);","\"use client\";\n\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport { PickerPanel as RCPickerPanel } from 'rc-picker';\nimport useMergedState from \"rc-util/es/hooks/useMergedState\";\nimport { devUseWarning } from '../_util/warning';\nimport { useComponentConfig } from '../config-provider/context';\nimport { useLocale } from '../locale';\nimport CalendarHeader from './Header';\nimport enUS from './locale/en_US';\nimport useStyle from './style';\nconst isSameYear = (date1, date2, config) => {\n const {\n getYear\n } = config;\n return date1 && date2 && getYear(date1) === getYear(date2);\n};\nconst isSameMonth = (date1, date2, config) => {\n const {\n getMonth\n } = config;\n return isSameYear(date1, date2, config) && getMonth(date1) === getMonth(date2);\n};\nconst isSameDate = (date1, date2, config) => {\n const {\n getDate\n } = config;\n return isSameMonth(date1, date2, config) && getDate(date1) === getDate(date2);\n};\nconst generateCalendar = generateConfig => {\n const Calendar = props => {\n const {\n prefixCls: customizePrefixCls,\n className,\n rootClassName,\n style,\n dateFullCellRender,\n dateCellRender,\n monthFullCellRender,\n monthCellRender,\n cellRender,\n fullCellRender,\n headerRender,\n value,\n defaultValue,\n disabledDate,\n mode,\n validRange,\n fullscreen = true,\n showWeek,\n onChange,\n onPanelChange,\n onSelect\n } = props;\n const {\n getPrefixCls,\n direction,\n className: contextClassName,\n style: contextStyle\n } = useComponentConfig('calendar');\n const prefixCls = getPrefixCls('picker', customizePrefixCls);\n const calendarPrefixCls = `${prefixCls}-calendar`;\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls, calendarPrefixCls);\n const today = generateConfig.getNow();\n // ====================== Warning =======================\n if (process.env.NODE_ENV !== 'production') {\n const warning = devUseWarning('Calendar');\n [['dateFullCellRender', 'fullCellRender'], ['dateCellRender', 'cellRender'], ['monthFullCellRender', 'fullCellRender'], ['monthCellRender', 'cellRender']].forEach(_ref => {\n let [deprecatedName, newName] = _ref;\n warning.deprecated(!(deprecatedName in props), deprecatedName, newName);\n });\n }\n // ====================== State =======================\n // Value\n const [mergedValue, setMergedValue] = useMergedState(() => value || generateConfig.getNow(), {\n defaultValue,\n value\n });\n // Mode\n const [mergedMode, setMergedMode] = useMergedState('month', {\n value: mode\n });\n const panelMode = React.useMemo(() => mergedMode === 'year' ? 'month' : 'date', [mergedMode]);\n // Disabled Date\n const mergedDisabledDate = React.useCallback(date => {\n const notInRange = validRange ? generateConfig.isAfter(validRange[0], date) || generateConfig.isAfter(date, validRange[1]) : false;\n return notInRange || !!(disabledDate === null || disabledDate === void 0 ? void 0 : disabledDate(date));\n }, [disabledDate, validRange]);\n // ====================== Events ======================\n const triggerPanelChange = (date, newMode) => {\n onPanelChange === null || onPanelChange === void 0 ? void 0 : onPanelChange(date, newMode);\n };\n const triggerChange = date => {\n setMergedValue(date);\n if (!isSameDate(date, mergedValue, generateConfig)) {\n // Trigger when month panel switch month\n if (panelMode === 'date' && !isSameMonth(date, mergedValue, generateConfig) || panelMode === 'month' && !isSameYear(date, mergedValue, generateConfig)) {\n triggerPanelChange(date, mergedMode);\n }\n onChange === null || onChange === void 0 ? void 0 : onChange(date);\n }\n };\n const triggerModeChange = newMode => {\n setMergedMode(newMode);\n triggerPanelChange(mergedValue, newMode);\n };\n const onInternalSelect = (date, source) => {\n triggerChange(date);\n onSelect === null || onSelect === void 0 ? void 0 : onSelect(date, {\n source\n });\n };\n // ====================== Render ======================\n const dateRender = React.useCallback((date, info) => {\n if (fullCellRender) {\n return fullCellRender(date, info);\n }\n if (dateFullCellRender) {\n return dateFullCellRender(date);\n }\n return /*#__PURE__*/React.createElement(\"div\", {\n className: classNames(`${prefixCls}-cell-inner`, `${calendarPrefixCls}-date`, {\n [`${calendarPrefixCls}-date-today`]: isSameDate(today, date, generateConfig)\n })\n }, /*#__PURE__*/React.createElement(\"div\", {\n className: `${calendarPrefixCls}-date-value`\n }, String(generateConfig.getDate(date)).padStart(2, '0')), /*#__PURE__*/React.createElement(\"div\", {\n className: `${calendarPrefixCls}-date-content`\n }, cellRender ? cellRender(date, info) : dateCellRender === null || dateCellRender === void 0 ? void 0 : dateCellRender(date)));\n }, [dateFullCellRender, dateCellRender, cellRender, fullCellRender]);\n const monthRender = React.useCallback((date, info) => {\n if (fullCellRender) {\n return fullCellRender(date, info);\n }\n if (monthFullCellRender) {\n return monthFullCellRender(date);\n }\n const months = info.locale.shortMonths || generateConfig.locale.getShortMonths(info.locale.locale);\n return /*#__PURE__*/React.createElement(\"div\", {\n className: classNames(`${prefixCls}-cell-inner`, `${calendarPrefixCls}-date`, {\n [`${calendarPrefixCls}-date-today`]: isSameMonth(today, date, generateConfig)\n })\n }, /*#__PURE__*/React.createElement(\"div\", {\n className: `${calendarPrefixCls}-date-value`\n }, months[generateConfig.getMonth(date)]), /*#__PURE__*/React.createElement(\"div\", {\n className: `${calendarPrefixCls}-date-content`\n }, cellRender ? cellRender(date, info) : monthCellRender === null || monthCellRender === void 0 ? void 0 : monthCellRender(date)));\n }, [monthFullCellRender, monthCellRender, cellRender, fullCellRender]);\n const [contextLocale] = useLocale('Calendar', enUS);\n const locale = Object.assign(Object.assign({}, contextLocale), props.locale);\n const mergedCellRender = (current, info) => {\n if (info.type === 'date') {\n return dateRender(current, info);\n }\n if (info.type === 'month') {\n return monthRender(current, Object.assign(Object.assign({}, info), {\n locale: locale === null || locale === void 0 ? void 0 : locale.lang\n }));\n }\n };\n return wrapCSSVar(/*#__PURE__*/React.createElement(\"div\", {\n className: classNames(calendarPrefixCls, {\n [`${calendarPrefixCls}-full`]: fullscreen,\n [`${calendarPrefixCls}-mini`]: !fullscreen,\n [`${calendarPrefixCls}-rtl`]: direction === 'rtl'\n }, contextClassName, className, rootClassName, hashId, cssVarCls),\n style: Object.assign(Object.assign({}, contextStyle), style)\n }, headerRender ? headerRender({\n value: mergedValue,\n type: mergedMode,\n onChange: nextDate => {\n onInternalSelect(nextDate, 'customize');\n },\n onTypeChange: triggerModeChange\n }) : (/*#__PURE__*/React.createElement(CalendarHeader, {\n prefixCls: calendarPrefixCls,\n value: mergedValue,\n generateConfig: generateConfig,\n mode: mergedMode,\n fullscreen: fullscreen,\n locale: locale === null || locale === void 0 ? void 0 : locale.lang,\n validRange: validRange,\n onChange: onInternalSelect,\n onModeChange: triggerModeChange\n })), /*#__PURE__*/React.createElement(RCPickerPanel, {\n value: mergedValue,\n prefixCls: prefixCls,\n locale: locale === null || locale === void 0 ? void 0 : locale.lang,\n generateConfig: generateConfig,\n cellRender: mergedCellRender,\n onSelect: nextDate => {\n onInternalSelect(nextDate, panelMode);\n },\n mode: panelMode,\n picker: panelMode,\n disabledDate: mergedDisabledDate,\n hideHeader: true,\n showWeek: showWeek\n })));\n };\n if (process.env.NODE_ENV !== 'production') {\n Calendar.displayName = 'Calendar';\n }\n return Calendar;\n};\nexport default generateCalendar;","\"use client\";\n\nimport dayjsGenerateConfig from \"rc-picker/es/generate/dayjs\";\nimport generateCalendar from './generateCalendar';\nconst Calendar = generateCalendar(dayjsGenerateConfig);\nCalendar.generateCalendar = generateCalendar;\nexport default Calendar;","/**\n * view 中三层 group 分层 key\n */\nexport enum LAYER {\n /** 前景层 */\n FORE = 'fore',\n /** 中间层 */\n MID = 'mid',\n /** 背景层 */\n BG = 'bg',\n}\n\n/**\n * 组件在画布的布局方位 12 方位\n */\nexport enum DIRECTION {\n TOP = 'top',\n TOP_LEFT = 'top-left',\n TOP_RIGHT = 'top-right',\n RIGHT = 'right',\n RIGHT_TOP = 'right-top',\n RIGHT_BOTTOM = 'right-bottom',\n LEFT = 'left',\n LEFT_TOP = 'left-top',\n LEFT_BOTTOM = 'left-bottom',\n BOTTOM = 'bottom',\n BOTTOM_LEFT = 'bottom-left',\n BOTTOM_RIGHT = 'bottom-right',\n RADIUS = 'radius',\n CIRCLE = 'circle',\n // no direction information\n NONE = 'none',\n}\n\n/**\n * 组件的类型,可能会影响到布局算法\n */\nexport enum COMPONENT_TYPE {\n /** axis 组件 */\n AXIS = 'axis',\n /** grid 组件 */\n GRID = 'grid',\n /** legend 组件 */\n LEGEND = 'legend',\n /** tooltip 组件 */\n TOOLTIP = 'tooltip',\n /** annotation 组件 */\n ANNOTATION = 'annotation',\n /** 缩略轴组件 */\n SLIDER = 'slider',\n /** 滚动条组件 */\n SCROLLBAR = 'scrollbar',\n /** 其他组件,自定义组件 */\n OTHER = 'other',\n}\n\n/**\n * 三层 group 的 z index\n */\nexport const GROUP_Z_INDEX = {\n FORE: 3,\n MID: 2,\n BG: 1,\n};\n\n/**\n * View 的生命周期阶段(和 3.x 的生命周期略有不同)\n * 我们需要先确定在那写场景需要用到生命周期,如果只是为了在生命周期插入一下什么组件之类的,那么在现有架构就是不需要的\n */\nexport enum VIEW_LIFE_CIRCLE {\n BEFORE_RENDER = 'beforerender',\n AFTER_RENDER = 'afterrender',\n\n BEFORE_PAINT = 'beforepaint',\n AFTER_PAINT = 'afterpaint',\n\n BEFORE_CHANGE_DATA = 'beforechangedata',\n AFTER_CHANGE_DATA = 'afterchangedata',\n\n BEFORE_CLEAR = 'beforeclear',\n AFTER_CLEAR = 'afterclear',\n\n BEFORE_DESTROY = 'beforedestroy',\n\n BEFORE_CHANGE_SIZE = 'beforechangesize',\n AFTER_CHANGE_SIZE = 'afterchangesize',\n}\n\n/**\n * geometry 的生命周期\n */\nexport enum GEOMETRY_LIFE_CIRCLE {\n BEFORE_DRAW_ANIMATE = 'beforeanimate',\n AFTER_DRAW_ANIMATE = 'afteranimate',\n\n BEFORE_RENDER_LABEL = 'beforerenderlabel',\n AFTER_RENDER_LABEL = 'afterrenderlabel',\n}\n\n/**\n * 绘图区的事件列表\n */\nexport enum PLOT_EVENTS {\n // mouse 事件\n MOUSE_ENTER = 'plot:mouseenter',\n MOUSE_DOWN = 'plot:mousedown',\n MOUSE_MOVE = 'plot:mousemove',\n MOUSE_UP = 'plot:mouseup',\n MOUSE_LEAVE = 'plot:mouseleave',\n // 移动端事件\n TOUCH_START = 'plot:touchstart',\n TOUCH_MOVE = 'plot:touchmove',\n TOUCH_END = 'plot:touchend',\n TOUCH_CANCEL = 'plot:touchcancel',\n // click 事件\n CLICK = 'plot:click',\n DBLCLICK = 'plot:dblclick',\n CONTEXTMENU = 'plot:contextmenu',\n\n LEAVE = 'plot:leave',\n ENTER = 'plot:enter',\n}\n\n/**\n * Element 图形交互状态\n */\nexport enum ELEMENT_STATE {\n ACTIVE = 'active',\n INACTIVE = 'inactive',\n SELECTED = 'selected',\n DEFAULT = 'default',\n}\n\n/** 参与分组的图形属性名 */\nexport const GROUP_ATTRS = ['color', 'shape', 'size'];\n/** 存储原始数据的字段名 */\nexport const FIELD_ORIGIN = '_origin';\n/** 最小的图表宽度 */\nexport const MIN_CHART_WIDTH = 1;\n/** 最小的图表高度 */\nexport const MIN_CHART_HEIGHT = 1;\n/** 辅助组件占图表的尺寸的最大比例:如图表上方的图例最多占图表高度的25% */\nexport const COMPONENT_MAX_VIEW_PERCENTAGE = 0.25;\n","/**\n * 创建DOM 节点\n * @param {String} str Dom 字符串\n * @return {HTMLElement} DOM 节点\n */\n\nlet TABLE:HTMLTableElement;\nlet TABLE_TR:HTMLTableRowElement;\nlet FRAGMENT_REG:RegExp;\nlet CONTAINERS:{\n '*': HTMLDivElement;\n [key:string]: any;\n};\n\nfunction initConstants() {\n TABLE = document.createElement('table');\n TABLE_TR = document.createElement('tr');\n FRAGMENT_REG = /^\\s*<(\\w+|!)[^>]*>/;\n CONTAINERS = {\n tr: document.createElement('tbody'),\n tbody: TABLE,\n thead: TABLE,\n tfoot: TABLE,\n td: TABLE_TR,\n th: TABLE_TR,\n '*': document.createElement('div'),\n };\n}\n\nexport default function createDom(str:string): any {\n if (!TABLE) {\n initConstants();\n }\n let name = FRAGMENT_REG.test(str) && RegExp.$1;\n if (!name || !(name in CONTAINERS)) {\n name = '*';\n }\n const container = CONTAINERS[name];\n str = typeof str === 'string' ? str.replace(/(^\\s*)|(\\s*$)/g, '') : str;\n container.innerHTML = '' + str;\n const dom = container.childNodes[0];\n if (dom && container.contains(dom)) {\n container.removeChild(dom);\n }\n return dom;\n}\n","import { IG } from '../dependents';\n\nconst ENGINES: Record = {};\n\n/**\n * 通过名字获取渲染 engine\n * @param name 渲染引擎名字\n * @returns G engine\n */\nexport function getEngine(name: string): IG {\n const G = ENGINES[name];\n\n if (!G) {\n throw new Error(`G engine '${name}' is not exist, please register it at first.`);\n }\n\n return G;\n}\n\n/**\n * 注册渲染引擎\n * @param name\n * @param engine\n */\nexport function registerEngine(name: string, engine: IG) {\n ENGINES[name] = engine;\n}\n","export default function modifyCSS(dom: HTMLElement, css: { [key:string]: any }): HTMLElement {\n if (dom) {\n for (const key in css) {\n if (css.hasOwnProperty(key)) {\n dom.style[key] = css[key];\n }\n }\n }\n return dom;\n}\n","import { MIN_CHART_HEIGHT, MIN_CHART_WIDTH } from '../constant';\nimport { Size } from '../interface';\n\n/**\n * get the element's bounding size\n * @param ele dom element\n * @returns the element width and height\n */\nfunction getElementSize(ele: HTMLElement): Size {\n const style = getComputedStyle(ele);\n\n return {\n width:\n (ele.clientWidth || parseInt(style.width, 10)) -\n parseInt(style.paddingLeft, 10) -\n parseInt(style.paddingRight, 10),\n height:\n (ele.clientHeight || parseInt(style.height, 10)) -\n parseInt(style.paddingTop, 10) -\n parseInt(style.paddingBottom, 10),\n };\n}\n\n/**\n * is value a valid number\n * @param v the input value\n * @returns whether it is a number\n */\nfunction isNumber(v: any): boolean {\n return typeof v === 'number' && !isNaN(v);\n}\n\n/**\n * @ignore\n * calculate the chart size\n * @param ele DOM element\n * @param autoFit should auto fit\n * @param width chart width which is set by user\n * @param height chart height which is set by user\n * @returns the chart width and height\n */\nexport function getChartSize(ele: HTMLElement, autoFit: boolean, width: number, height: number): Size {\n let w = width;\n let h = height;\n\n if (autoFit) {\n const size = getElementSize(ele);\n\n w = size.width ? size.width : w;\n h = size.height ? size.height : h;\n }\n\n return {\n width: Math.max(isNumber(w) ? w : MIN_CHART_WIDTH, MIN_CHART_WIDTH),\n height: Math.max(isNumber(h) ? h : MIN_CHART_HEIGHT, MIN_CHART_HEIGHT),\n };\n}\n\n/**\n * @ignore\n * remove html element from its parent\n * @param dom\n */\nexport function removeDom(dom: HTMLElement) {\n const parent = dom.parentNode;\n\n if (parent) {\n parent.removeChild(dom);\n }\n}\n\n/** @ignore */\nexport { createDom, modifyCSS } from '@antv/dom-util';\n","import EE from '@antv/event-emitter';\n\ninterface BaseCfg {\n visible?: boolean;\n}\n\n/**\n * G2 Chart、View、Geometry 以及 Element 等的基类,提供事件以及一些通用的方法。\n */\nexport default class Base extends EE {\n /** 是否可见 */\n public visible: boolean;\n /** 标识对象是否已销毁 */\n public destroyed: boolean = false;\n\n constructor(cfg: BaseCfg) {\n super();\n const { visible = true } = cfg;\n this.visible = visible;\n }\n\n /**\n * 显示。\n */\n public show() {\n const visible = this.visible;\n if (!visible) {\n this.changeVisible(true);\n }\n }\n\n /**\n * 隐藏。\n */\n public hide() {\n const visible = this.visible;\n if (visible) {\n this.changeVisible(false);\n }\n }\n\n /**\n * 销毁。\n */\n public destroy() {\n this.off();\n this.destroyed = true;\n }\n\n /**\n * 显示或者隐藏。\n * @param visible\n * @returns\n */\n public changeVisible(visible: boolean) {\n if (this.visible === visible) {\n return;\n }\n this.visible = visible;\n }\n}\n","import * as _ from '@antv/util';\nimport { DEFAULT_Y } from '../constant';\nimport { AdjustCfg, Data, Range } from '../interface';\n\nexport type AdjustConstructor = new (cfg: any) => Adjust;\n\nexport interface DimValuesMapType {\n [dim: string]: number[];\n}\n\nexport default abstract class Adjust {\n /** 参与调整的维度 */\n public adjustNames: string[];\n /** x 维度对应的字段 */\n public xField: string;\n /** y 维度对应的字段 */\n public yField: string;\n\n // Dodge 属性\n /** 调整占单位宽度的比例,例如:占 2 个分类间距的 1 / 2 */\n public dodgeRatio: number;\n /** 调整过程中 2 个数据的间距,以 dodgeRatio 为分母 */\n public marginRatio: number;\n /** 指定进行 dodge 的字段 */\n public dodgeBy: string;\n /** 自定义 offset */\n public customOffset: ((data: any, range: any) => number) | number;\n\n // Stack 属性\n public height: number;\n public size: number;\n public reverseOrder: boolean;\n\n /** 像素级组间距 */\n public intervalPadding: number;\n /** 像素级组内间距 */\n public dodgePadding: number;\n /** x维度长度,计算归一化padding使用 */\n public xDimensionLegenth: number;\n /** 分组数 */\n public groupNum: number;\n\n // 图形宽度相关配置\n /** 用户配置宽度 */\n public defaultSize: number;\n /** 最大宽度约束 */\n public maxColumnWidth: number;\n /** 最小宽度约束 */\n public minColumnWidth: number;\n /** 宽度比例 */\n public columnWidthRatio: number;\n\n /** 用户自定义的dimValuesMap */\n public dimValuesMap: DimValuesMapType;\n\n constructor(cfg: AdjustCfg & { dimValuesMap?: DimValuesMapType }) {\n const { xField, yField, adjustNames = ['x', 'y'], dimValuesMap } = cfg;\n\n this.adjustNames = adjustNames;\n this.xField = xField;\n this.yField = yField;\n this.dimValuesMap = dimValuesMap;\n }\n\n // 需要各自实现的方法\n public abstract process(dataArray: Data[][]): Data[][];\n\n /**\n * 查看维度是否是 adjust 字段\n * @param dim\n */\n public isAdjust(dim: string): boolean {\n return this.adjustNames.indexOf(dim) >= 0;\n }\n\n protected getAdjustRange(dim: string, dimValue: number, values: number[]): Range {\n const { yField } = this;\n\n const index = values.indexOf(dimValue);\n const length = values.length;\n\n let pre;\n let next;\n\n // 没有 y 字段,但是需要根据 y 调整\n if (!yField && this.isAdjust('y')) {\n pre = 0;\n next = 1;\n } else if (length > 1) {\n // 如果以其开头,则取之,否则取他前面一个\n pre = values[index === 0 ? 0 : index - 1];\n // 如果以其结尾,则取之,否则取他后面一个\n next = values[index === length - 1 ? length - 1 : index + 1];\n\n if (index !== 0) {\n pre += (dimValue - pre) / 2;\n } else {\n pre -= (next - dimValue) / 2;\n }\n\n if (index !== length - 1) {\n next -= (next - dimValue) / 2;\n } else {\n next += (dimValue - values[length - 2]) / 2;\n }\n } else {\n pre = dimValue === 0 ? 0 : dimValue - 0.5;\n next = dimValue === 0 ? 1 : dimValue + 0.5;\n }\n\n return {\n pre,\n next,\n };\n }\n\n protected adjustData(groupedDataArray: Data[][], mergedData: Data[]) {\n // 所有调整维度的值数组\n const dimValuesMap = this.getDimValues(mergedData);\n\n // 按照每一个分组来进行调整\n _.each(groupedDataArray, (dataArray, index) => {\n // 遍历所有数据集合\n // 每个分组中,分别按照不同的 dim 进行调整\n _.each(dimValuesMap, (values: number[], dim: string) => {\n // 根据不同的度量分别调整位置\n this.adjustDim(dim, values, dataArray, index);\n });\n });\n }\n\n /**\n * 对数据进行分组adjustData\n * @param data 数据\n * @param dim 分组的字段\n * @return 分组结果\n */\n protected groupData(data: Data[], dim: string): { [dim: string]: Data[] } {\n // 补齐数据空数据为默认值\n _.each(data, (record: Data) => {\n if (record[dim] === undefined) {\n record[dim] = DEFAULT_Y;\n }\n });\n\n // 按照 dim 维度分组\n return _.groupBy(data, dim);\n }\n\n /** @override */\n protected adjustDim(dim: string, values: number[], data: Data[], index?: number): void {}\n\n /**\n * 获取可调整度量对应的值\n * @param mergedData 数据\n * @return 值的映射\n */\n private getDimValues(mergedData: Data[]): DimValuesMapType {\n const { xField, yField } = this;\n\n const dimValuesMap: DimValuesMapType = _.assign({}, this.dimValuesMap);\n\n // 所有的维度\n const dims = [];\n if (xField && this.isAdjust('x')) {\n dims.push(xField);\n }\n if (yField && this.isAdjust('y')) {\n dims.push(yField);\n }\n\n dims.forEach((dim: string): void => {\n if (dimValuesMap && dimValuesMap[dim]) {\n return;\n }\n // 在每个维度上,所有的值\n dimValuesMap[dim] = _.valuesOfKey(mergedData, dim).sort((v1, v2) => v1 - v2) as number[];\n });\n\n // 只有一维的情况下,同时调整 y,赋予默认值\n if (!yField && this.isAdjust('y')) {\n const dim = 'y';\n dimValuesMap[dim] = [DEFAULT_Y, 1]; // 默认分布在 y 轴的 0 与 1 之间\n }\n\n return dimValuesMap;\n }\n}\n","export const DEFAULT_Y = 0; // 默认的 y 的值\n\n// 偏移之后,间距\nexport const MARGIN_RATIO = 1 / 2;\nexport const DODGE_RATIO = 1 / 2;\n\n// 散点分开之后,距离边界的距离\nexport const GAP = 0.05;\n","import Adjust, { AdjustConstructor } from './adjusts/adjust';\n\ninterface AdjustMapType {\n [type: string]: AdjustConstructor;\n}\n\nconst ADJUST_MAP: AdjustMapType = {};\n\n/**\n * 根据类型获取 Adjust 类\n * @param type\n */\nconst getAdjust = (type: string): AdjustConstructor => {\n return ADJUST_MAP[type.toLowerCase()];\n};\n\n/**\n * 注册自定义 Adjust\n * @param type\n * @param ctor\n */\nconst registerAdjust = (type: string, ctor: AdjustConstructor): void => {\n // 注册的时候,需要校验 type 重名,不区分大小写\n if (getAdjust(type)) {\n throw new Error(`Adjust type '${type}' existed.`);\n }\n // 存储到 map 中\n ADJUST_MAP[type.toLowerCase()] = ctor;\n};\n\nexport { getAdjust, registerAdjust, Adjust };\n\nexport * from './interface';\n","/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __createBinding(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n","import * as _ from '@antv/util';\nimport { DODGE_RATIO, MARGIN_RATIO } from '../constant';\nimport { Data, DodgeCfg, Range } from '../interface';\nimport Adjust from './adjust';\n\nexport default class Dodge extends Adjust {\n private cacheMap: { [key: string]: any } = {};\n private adjustDataArray: Data[][] = [];\n private mergeData: Data[] = [];\n\n constructor(cfg: DodgeCfg) {\n super(cfg);\n const {\n marginRatio = MARGIN_RATIO,\n dodgeRatio = DODGE_RATIO,\n dodgeBy,\n intervalPadding,\n dodgePadding,\n xDimensionLength,\n groupNum,\n defaultSize,\n maxColumnWidth,\n minColumnWidth,\n columnWidthRatio,\n customOffset\n } = cfg;\n this.marginRatio = marginRatio;\n this.dodgeRatio = dodgeRatio;\n this.dodgeBy = dodgeBy;\n this.intervalPadding = intervalPadding;\n this.dodgePadding = dodgePadding;\n this.xDimensionLegenth = xDimensionLength;\n this.groupNum = groupNum;\n this.defaultSize = defaultSize;\n this.maxColumnWidth = maxColumnWidth;\n this.minColumnWidth = minColumnWidth;\n this.columnWidthRatio = columnWidthRatio;\n this.customOffset = customOffset;\n }\n\n public process(groupDataArray: Data[][]): Data[][] {\n const groupedDataArray = _.clone(groupDataArray);\n // 将数据数组展开一层\n const mergeData = _.flatten(groupedDataArray);\n\n const { dodgeBy } = this;\n\n // 如果指定了分组 dim 的字段\n const adjustDataArray = dodgeBy ? _.group(mergeData, dodgeBy) : groupedDataArray;\n\n this.cacheMap = {};\n this.adjustDataArray = adjustDataArray;\n this.mergeData = mergeData;\n\n this.adjustData(adjustDataArray, mergeData);\n\n this.adjustDataArray = [];\n this.mergeData = [];\n\n return groupedDataArray;\n }\n\n protected adjustDim(dim: string, values: number[], data: Data[], frameIndex: number): any[] {\n const { customOffset } = this;\n const map = this.getDistribution(dim);\n const groupData = this.groupData(data, dim); // 根据值分组\n \n _.each(groupData, (group, key) => {\n let range: Range;\n\n // xField 中只有一个值,不需要做 dodge\n if (values.length === 1) {\n range = {\n pre: values[0] - 1,\n next: values[0] + 1,\n };\n } else {\n // 如果有多个,则需要获取调整的范围\n range = this.getAdjustRange(dim, parseFloat(key), values);\n }\n _.each(group, (d) => {\n const value = d[dim];\n const valueArr = map[value];\n const valIndex = valueArr.indexOf(frameIndex);\n if (!_.isNil(customOffset)) {\n const { pre, next } = range;\n d[dim] = _.isFunction(customOffset) ? customOffset(d, range) : (pre + next) / 2 + customOffset;\n } else {\n d[dim] = this.getDodgeOffset(range, valIndex, valueArr.length);\n }\n });\n });\n return [];\n }\n\n private getDodgeOffset(range: Range, idx: number, len: number): number {\n const {\n dodgeRatio,\n marginRatio,\n intervalPadding,\n dodgePadding,\n } = this;\n const { pre, next } = range;\n\n const tickLength = next - pre;\n let position;\n // 分多种输入情况\n if (!_.isNil(intervalPadding) && _.isNil(dodgePadding) && intervalPadding >= 0) {\n // 仅配置intervalPadding\n const offset = this.getIntervalOnlyOffset(len, idx);\n position = pre + offset;\n } else if (!_.isNil(dodgePadding) && _.isNil(intervalPadding) && dodgePadding >= 0) {\n // 仅配置dodgePadding\n const offset = this.getDodgeOnlyOffset(len, idx);\n position = pre + offset;\n } else if (\n !_.isNil(intervalPadding) &&\n !_.isNil(dodgePadding) &&\n intervalPadding >= 0 &&\n dodgePadding >= 0\n ) {\n // 同时配置intervalPadding和dodgePadding\n const offset = this.getIntervalAndDodgeOffset(len, idx);\n position = pre + offset;\n } else {\n // 默认情况\n const width = (tickLength * dodgeRatio) / len;\n const margin = marginRatio * width;\n const offset =\n (1 / 2) * (tickLength - len * width - (len - 1) * margin) +\n ((idx + 1) * width + idx * margin) -\n (1 / 2) * width -\n (1 / 2) * tickLength;\n position = (pre + next) / 2 + offset;\n }\n return position;\n }\n\n private getIntervalOnlyOffset(len: number, idx: number): number {\n const {\n defaultSize,\n intervalPadding,\n xDimensionLegenth,\n groupNum,\n dodgeRatio,\n maxColumnWidth,\n minColumnWidth,\n columnWidthRatio,\n } = this;\n const normalizedIntervalPadding = intervalPadding / xDimensionLegenth;\n let normalizedDodgePadding = (1 - (groupNum - 1) * normalizedIntervalPadding) / groupNum * dodgeRatio / (len - 1);\n let geomWidth = ((1 - normalizedIntervalPadding * (groupNum - 1)) / groupNum - normalizedDodgePadding * (len - 1)) / len;\n // 根据columnWidthRatio/defaultSize/maxColumnWidth/minColumnWidth调整宽度\n geomWidth = (!_.isNil(columnWidthRatio)) ? 1 / groupNum / len * columnWidthRatio : geomWidth;\n if (!_.isNil(maxColumnWidth)) {\n const normalizedMaxWidht = maxColumnWidth / xDimensionLegenth;\n geomWidth = Math.min(geomWidth, normalizedMaxWidht);\n }\n if (!_.isNil(minColumnWidth)) {\n const normalizedMinWidht = minColumnWidth / xDimensionLegenth;\n geomWidth = Math.max(geomWidth, normalizedMinWidht);\n }\n geomWidth = defaultSize ? (defaultSize / xDimensionLegenth) : geomWidth;\n // 调整组内间隔\n normalizedDodgePadding = ((1 - (groupNum - 1) * normalizedIntervalPadding) / groupNum - len * geomWidth) / (len - 1);\n const offset =\n ((1 / 2 + idx) * geomWidth + idx * normalizedDodgePadding +\n (1 / 2) * normalizedIntervalPadding) * groupNum -\n normalizedIntervalPadding / 2;\n return offset;\n }\n\n private getDodgeOnlyOffset(len: number, idx: number): number {\n const {\n defaultSize,\n dodgePadding,\n xDimensionLegenth,\n groupNum,\n marginRatio,\n maxColumnWidth,\n minColumnWidth,\n columnWidthRatio,\n } = this;\n const normalizedDodgePadding = dodgePadding / xDimensionLegenth;\n let normalizedIntervalPadding = 1 * marginRatio / (groupNum - 1);\n let geomWidth = ((1 - normalizedIntervalPadding * (groupNum - 1)) / groupNum - normalizedDodgePadding * (len - 1)) / len;\n // 根据columnWidthRatio/defaultSize/maxColumnWidth/minColumnWidth调整宽度\n geomWidth = columnWidthRatio ? 1 / groupNum / len * columnWidthRatio : geomWidth;\n if (!_.isNil(maxColumnWidth)) {\n const normalizedMaxWidht = maxColumnWidth / xDimensionLegenth;\n geomWidth = Math.min(geomWidth, normalizedMaxWidht);\n }\n if (!_.isNil(minColumnWidth)) {\n const normalizedMinWidht = minColumnWidth / xDimensionLegenth;\n geomWidth = Math.max(geomWidth, normalizedMinWidht);\n }\n geomWidth = defaultSize ? (defaultSize / xDimensionLegenth) : geomWidth;\n // 调整组间距\n normalizedIntervalPadding = (1 - (geomWidth * len + normalizedDodgePadding * (len - 1)) * groupNum) / (groupNum - 1);\n const offset =\n ((1 / 2 + idx) * geomWidth + idx * normalizedDodgePadding +\n (1 / 2) * normalizedIntervalPadding) * groupNum -\n normalizedIntervalPadding / 2;\n return offset;\n }\n\n private getIntervalAndDodgeOffset(len: number, idx: number): number {\n const {\n intervalPadding,\n dodgePadding,\n xDimensionLegenth,\n groupNum,\n } = this;\n const normalizedIntervalPadding = intervalPadding / xDimensionLegenth;\n const normalizedDodgePadding = dodgePadding / xDimensionLegenth;\n const geomWidth = ((1 - normalizedIntervalPadding * (groupNum - 1)) / groupNum - normalizedDodgePadding * (len - 1)) / len;\n const offset =\n ((1 / 2 + idx) * geomWidth + idx * normalizedDodgePadding +\n (1 / 2) * normalizedIntervalPadding) * groupNum -\n normalizedIntervalPadding / 2;\n return offset;\n }\n\n private getDistribution(dim: string) {\n const groupedDataArray = this.adjustDataArray;\n const cacheMap = this.cacheMap;\n let map = cacheMap[dim];\n\n if (!map) {\n map = {};\n _.each(groupedDataArray, (data, index) => {\n const values = _.valuesOfKey(data, dim) as number[];\n if (!values.length) {\n values.push(0);\n }\n _.each(values, (val: number) => {\n if (!map[val]) {\n map[val] = [];\n }\n map[val].push(index);\n });\n });\n cacheMap[dim] = map;\n }\n\n return map;\n }\n}\n","import * as _ from '@antv/util';\nimport { GAP } from '../constant';\nimport { Data, Range } from '../interface';\nimport Adjust from './adjust';\n\nfunction randomNumber(min: number, max: number): number {\n return (max - min) * Math.random() + min;\n}\n\nexport default class Jitter extends Adjust {\n public process(groupDataArray: Data[][]): Data[][] {\n const groupedDataArray = _.clone(groupDataArray);\n\n // 之前分组之后的数据,然后有合并回去(和分组前可以理解成是一样的)\n const mergeData = _.flatten(groupedDataArray) as Data[];\n\n // 返回值\n this.adjustData(groupedDataArray, mergeData);\n\n return groupedDataArray;\n }\n\n /**\n * 当前数据分组(index)中,按照维度 dim 进行 jitter 调整\n * @param dim\n * @param values\n * @param dataArray\n */\n protected adjustDim(dim: string, values: number[], dataArray: Data[]) {\n // 在每一个分组中,将数据再按照 dim 分组,用于散列\n const groupDataArray = this.groupData(dataArray, dim);\n return _.each(groupDataArray, (data: Data[], dimValue: string) => {\n return this.adjustGroup(data, dim, parseFloat(dimValue), values);\n });\n }\n\n // 随机出来的字段值\n private getAdjustOffset(range: Range): number {\n const { pre, next } = range;\n // 随机的范围\n const margin = (next - pre) * GAP;\n return randomNumber(pre + margin, next - margin);\n }\n\n // adjust group data\n private adjustGroup(group: Data[], dim: string, dimValue: number, values: number[]): Data[] {\n // 调整范围\n const range = this.getAdjustRange(dim, dimValue, values);\n\n _.each(group, (data: Data) => {\n data[dim] = this.getAdjustOffset(range); // 获取调整的位置\n });\n return group;\n }\n}\n","import * as _ from '@antv/util';\nimport { Data, StackCfg } from '../interface';\nimport Adjust from './adjust';\n\nconst Cache = _.Cache;\n\nexport default class Stack extends Adjust {\n constructor(cfg: StackCfg) {\n super(cfg);\n\n const { adjustNames = ['y'], height = NaN, size = 10, reverseOrder = false } = cfg;\n this.adjustNames = adjustNames;\n this.height = height;\n this.size = size;\n this.reverseOrder = reverseOrder;\n }\n\n /**\n * 方法入参是经过数据分组、数据数字化之后的二维数组\n * @param groupDataArray 分组之后的数据\n */\n public process(groupDataArray: Data[][]): Data[][] {\n const { yField, reverseOrder } = this;\n\n // 如果有指定 y 字段,那么按照 y 字段来 stack\n // 否则,按照高度均分\n const d = yField ? this.processStack(groupDataArray) : this.processOneDimStack(groupDataArray);\n\n return reverseOrder ? this.reverse(d) : d;\n }\n\n private reverse(groupedDataArray: Data[][]): Data[][] {\n return groupedDataArray.slice(0).reverse();\n }\n\n private processStack(groupDataArray: Data[][]): Data[][] {\n const { xField, yField, reverseOrder } = this;\n\n // 层叠顺序翻转\n const groupedDataArray = reverseOrder ? this.reverse(groupDataArray) : groupDataArray;\n\n // 用来缓存,正数和负数的堆叠问题\n const positive = new Cache();\n const negative = new Cache();\n\n return groupedDataArray.map((dataArray) => {\n return dataArray.map((data) => {\n const x: number = _.get(data, xField, 0);\n let y: number = _.get(data, [yField]);\n\n const xKey = x.toString();\n\n // todo 是否应该取 _origin?因为 y 可能取到的值不正确,比如先 symmetric,再 stack!\n y = _.isArray(y) ? y[1] : y;\n\n if (!_.isNil(y)) {\n const cache = y >= 0 ? positive : negative;\n\n if (!cache.has(xKey)) {\n cache.set(xKey, 0);\n }\n const xValue = cache.get(xKey) as number;\n const newXValue = y + xValue;\n\n // 存起来\n cache.set(xKey, newXValue);\n\n return {\n ...data,\n // 叠加成数组,覆盖之前的数据\n [yField]: [xValue, newXValue],\n };\n }\n\n // 没有修改,则直接返回\n return data;\n });\n });\n }\n\n private processOneDimStack(groupDataArray: Data[][]): Data[][] {\n const { xField, height, reverseOrder } = this;\n const yField = 'y';\n\n // 如果层叠的顺序翻转\n const groupedDataArray = reverseOrder ? this.reverse(groupDataArray) : groupDataArray;\n\n // 缓存累加数据\n const cache = new Cache();\n\n return groupedDataArray.map((dataArray): Data[] => {\n return dataArray.map(\n (data): Data => {\n const { size } = this;\n const xValue: string = data[xField];\n\n // todo 没有看到这个 stack 计算原理\n const stackHeight = (size * 2) / height;\n\n if (!cache.has(xValue)) {\n cache.set(xValue, stackHeight / 2); // 初始值大小\n }\n\n const stackValue = cache.get(xValue) as number;\n // 增加一层 stackHeight\n cache.set(xValue, stackValue + stackHeight);\n\n return {\n ...data,\n [yField]: stackValue,\n };\n }\n );\n });\n }\n}\n","import * as _ from '@antv/util';\nimport { Data } from '../interface';\nimport Adjust from './adjust';\n\nexport default class Symmetric extends Adjust {\n public process(groupDataArray: Data[][]): Data[][] {\n const mergeData = _.flatten(groupDataArray);\n\n const { xField, yField } = this;\n\n // 每个 x 值对应的 最大值\n const cache = this.getXValuesMaxMap(mergeData);\n\n // 所有数据的最大的值\n const max = Math.max(...Object.keys(cache).map((key) => cache[key]));\n\n return _.map(groupDataArray, (dataArray) => {\n return _.map(dataArray, (data) => {\n const yValue = data[yField];\n const xValue = data[xField];\n\n // 数组处理逻辑\n if (_.isArray(yValue)) {\n const off = (max - cache[xValue]) / 2;\n\n return {\n ...data,\n [yField]: _.map(yValue, (y: number) => off + y),\n };\n }\n\n // 非数组处理逻辑\n const offset = (max - yValue) / 2;\n return {\n ...data,\n [yField]: [offset, yValue + offset],\n };\n });\n });\n }\n\n // 获取每个 x 对应的最大的值\n private getXValuesMaxMap(mergeData: Data[]): { [key: string]: number } {\n const { xField, yField } = this;\n\n // 根据 xField 的值进行分组\n const groupDataArray = _.groupBy(mergeData, (data) => data[xField] as string);\n\n // 获取每个 xField 值中的最大值\n return _.mapValues(groupDataArray, (dataArray) => this.getDimMaxValue(dataArray, yField));\n }\n\n private getDimMaxValue(mergeData: Data[], dim: string): number {\n // 所有的 value 值\n const dimValues = _.map(mergeData, (data) => _.get(data, dim, []));\n // 将数组打平(dim value 有可能是数组,比如 stack 之后的)\n const flattenValues = _.flatten(dimValues);\n\n // 求出数组的最大值\n return Math.max(...flattenValues);\n }\n}\n","import { getAdjust, registerAdjust } from './factory';\n\nimport Adjust from './adjusts/adjust';\n\nimport Dodge from './adjusts/dodge';\nimport Jitter from './adjusts/jitter';\nimport Stack from './adjusts/stack';\nimport Symmetric from './adjusts/symmetric';\n\n// 注册内置的 adjust\nregisterAdjust('Dodge', Dodge);\nregisterAdjust('Jitter', Jitter);\nregisterAdjust('Stack', Stack);\nregisterAdjust('Symmetric', Symmetric);\n\n// 最终暴露给外部的方法\nexport { getAdjust, registerAdjust, Adjust };\n\nexport * from './interface';\n","import { each, identity, isArray, isNil, isString, mix } from '@antv/util';\nimport { AttributeCfg, CallbackType, Scale } from '../interface';\n\n// todo 这个到底目的是什么?\nconst toScaleString = (scale: Scale, value: any): any => {\n if (isString(value)) {\n return value;\n }\n return scale.invert(scale.scale(value));\n};\n\nexport type AttributeConstructor = new (cfg: any) => Attribute;\n\n/**\n * 所有视觉通道属性的基类\n * @class Base\n */\nexport default class Attribute {\n public type: string;\n public names: string[] = [];\n public scales: Scale[] = [];\n public linear: boolean = false;\n\n public values: any[] = [];\n\n constructor(cfg: AttributeCfg) {\n // 解析配置\n this._parseCfg(cfg);\n }\n public callback: CallbackType = () => [];\n\n /**\n * 映射的值组成的数组\n * @param params 对应 scale 顺序的值传入\n */\n public mapping(...params: any[]): any[] {\n const values = params.map((param, idx) => {\n return this._toOriginParam(param, this.scales[idx]);\n });\n\n return this.callback.apply(this, values);\n }\n\n /**\n * 如果进行线性映射,返回对应的映射值\n * @param percent\n */\n public getLinearValue(percent: number): number | string {\n // 分段数量\n const steps = this.values.length - 1;\n\n const step = Math.floor(steps * percent);\n const leftPercent = steps * percent - step;\n\n // todo 不懂这个逻辑\n const start = this.values[step];\n const end = step === steps ? start : this.values[step + 1];\n\n // 线性方程\n return start + (end - start) * leftPercent;\n }\n\n /**\n * 根据度量获取属性名\n */\n public getNames() {\n const scales = this.scales;\n const names = this.names;\n\n const length = Math.min(scales.length, names.length);\n const rst = [];\n for (let i = 0; i < length; i += 1) {\n rst.push(names[i]);\n }\n return rst;\n }\n\n /**\n * 获取所有的维度名\n */\n public getFields() {\n return this.scales.map((scale) => scale.field);\n }\n\n /**\n * 根据名称获取度量\n * @param name\n */\n public getScale(name: string) {\n return this.scales[this.names.indexOf(name)];\n }\n\n /**\n * 默认的回调函数(用户没有自定义 callback,或者用户自定义 callback 返回空的时候,使用 values 映射)\n * @param params\n */\n private defaultCallback(...params: any[]): any[] {\n // 没有 params 的情况,是指没有指定 fields,直接返回配置的 values 常量\n if (params.length === 0) {\n return this.values;\n }\n\n return params.map((param, idx) => {\n const scale = this.scales[idx];\n\n return scale.type === 'identity' ? scale.values[0] : this._getAttributeValue(scale, param);\n });\n }\n\n // 解析配置\n private _parseCfg(cfg: AttributeCfg) {\n const { type = 'base', names = [], scales = [], values = [], callback } = cfg;\n\n this.type = type;\n\n this.scales = scales;\n this.values = values;\n this.names = names;\n\n // 构造 callback 方法\n this.callback = (...params: any[]): any[] => {\n /**\n * 当用户设置的 callback 返回 null 时, 应该返回默认 callback 中的值\n */\n if (callback) {\n // 使用用户返回的值处理\n const ret = callback(...params);\n if (!isNil(ret)) {\n return [ret];\n }\n }\n\n // 没有 callback 或者用户 callback 返回值为空,则使用默认的逻辑处理\n return this.defaultCallback.apply(this, params);\n };\n }\n\n // 获取属性值,将值映射到视觉通道\n private _getAttributeValue(scale: Scale, value: any) {\n // 如果是非线性的字段,直接从 values 中取值即可\n if (scale.isCategory && !this.linear) {\n // 离散 scale 变换成索引\n const idx = scale.translate(value) as number;\n return this.values[idx % this.values.length];\n }\n\n // 线性则使用线性值\n const percent = scale.scale(value);\n return this.getLinearValue(percent);\n }\n\n /**\n * 通过 scale 拿到数据对应的原始的参数\n * @param param\n * @param scale\n * @private\n */\n private _toOriginParam(param: any, scale: Scale) {\n // 是线性,直接返回\n // 非线性,使用 scale 变换\n return !scale.isLinear\n ? isArray(param)\n ? param.map((p: any) => toScaleString(scale, p))\n : toScaleString(scale, param)\n : param;\n }\n}\n","import { map, memoize, isString, each } from '@antv/util';\n\nconst RGB_REG = /rgba?\\(([\\s.,0-9]+)\\)/;\nconst regexLG = /^l\\s*\\(\\s*([\\d.]+)\\s*\\)\\s*(.*)/i;\nconst regexRG = /^r\\s*\\(\\s*([\\d.]+)\\s*,\\s*([\\d.]+)\\s*,\\s*([\\d.]+)\\s*\\)\\s*(.*)/i;\nconst regexColorStop = /[\\d.]+:(#[^\\s]+|[^\\)]+\\))/gi;\n\nconst isGradientColor = (val) => /^[r,R,L,l]{1}[\\s]*\\(/.test(val);\n\n// 创建辅助 tag 取颜色\nconst createTmp = (): HTMLElement => {\n const i = document.createElement('i');\n i.title = 'Web Colour Picker';\n i.style.display = 'none';\n document.body.appendChild(i);\n return i;\n};\n\n// 获取颜色之间的插值\nconst getValue = (start: number[], end: number[], percent: number, index: number): number => {\n return start[index] + (end[index] - start[index]) * percent;\n};\n\n// 数组转换成颜色\nfunction arr2rgb(arr: number[]): string {\n return `#${toHex(arr[0])}${toHex(arr[1])}${toHex(arr[2])}`;\n}\n\n// rgb 颜色转换成数组\nconst rgb2arr = (str: string): number[] => {\n return [\n parseInt(str.substr(1, 2), 16),\n parseInt(str.substr(3, 2), 16),\n parseInt(str.substr(5, 2), 16),\n ];\n};\n\n// 将数值从 0-255 转换成16进制字符串\nconst toHex = (value: number): string => {\n const x16Value = Math.round(value).toString(16);\n\n return x16Value.length === 1 ? `0${x16Value}` : x16Value;\n};\n\n// 计算颜色\nconst calColor = (points: number[][], percent: number) => {\n const fixedPercent = isNaN(Number(percent)) || percent < 0 ? 0 :\n percent > 1 ? 1 :\n Number(percent);\n\n const steps = points.length - 1;\n\n const step = Math.floor(steps * fixedPercent);\n\n const left = steps * fixedPercent - step;\n\n const start = points[step];\n\n const end = step === steps ? start : points[step + 1];\n\n return arr2rgb([\n getValue(start, end, left, 0),\n getValue(start, end, left, 1),\n getValue(start, end, left, 2),\n ]);\n};\n\n// 用于给 toRGB 的缓存(使用 memoize 方法替换)\n// const colorCache = {};\nlet iEl: HTMLElement;\n\n/**\n * 将颜色转换到 rgb 的格式\n * @param {color} color 颜色\n * @return 将颜色转换到 '#ffffff' 的格式\n */\nconst toRGB = (color: string): string => {\n // 如果已经是 rgb的格式\n if (color[0] === '#' && color.length === 7) {\n return color;\n }\n\n if (!iEl) {\n // 防止防止在页头报错\n iEl = createTmp();\n }\n\n iEl.style.color = color;\n\n let rst = document.defaultView.getComputedStyle(iEl, '').getPropertyValue('color');\n\n const matches = RGB_REG.exec(rst) as string[] ;\n const cArray: number[] = matches[1].split(/\\s*,\\s*/).map((s) => Number(s));\n\n rst = arr2rgb(cArray);\n\n return rst;\n};\n\n/**\n * 获取渐变函数\n * @param colors 多个颜色\n * @return 颜色值\n */\nconst gradient = (colors: string | string[]) => {\n const colorArray = isString(colors) ? (colors as string).split('-') : colors;\n\n const points = map(colorArray, (color) => {\n return rgb2arr(color.indexOf('#') === -1 ? toRGB(color) : color);\n });\n\n // 返回一个函数\n return (percent: number): string => {\n return calColor(points, percent);\n };\n};\n\nconst toCSSGradient = (gradientColor) => {\n if (isGradientColor(gradientColor)) {\n let cssColor;\n let steps;\n if (gradientColor[0] === 'l') {\n // 线性渐变\n const arr = regexLG.exec(gradientColor);\n const angle = +arr[1] + 90; // css 和 g 的渐变起始角度不同\n steps = arr[2];\n\n cssColor = `linear-gradient(${angle}deg, `;\n } else if (gradientColor[0] === 'r') {\n // 径向渐变\n cssColor = 'radial-gradient(';\n const arr = regexRG.exec(gradientColor);\n steps = arr[4];\n }\n\n const colorStops: string[] = steps.match(regexColorStop);\n each(colorStops, (item, index) => {\n const itemArr = item.split(':');\n cssColor += `${itemArr[1]} ${itemArr[0] * 100}%`;\n if (index !== (colorStops.length - 1)) {\n cssColor += ', ';\n }\n });\n\n cssColor += ')';\n\n return cssColor;\n }\n\n return gradientColor;\n};\n\nexport default {\n rgb2arr,\n gradient,\n toRGB: memoize(toRGB),\n toCSSGradient,\n};\n","import colorUtil from '@antv/color-util';\nimport { isString } from '@antv/util';\nimport { AttributeCfg } from '../interface';\nimport Attribute from './base';\n\nexport default class Color extends Attribute {\n public gradient: (percent: number) => string;\n\n constructor(cfg: AttributeCfg) {\n super(cfg);\n this.type = 'color';\n this.names = ['color'];\n\n if (isString(this.values)) {\n this.linear = true;\n }\n\n this.gradient = colorUtil.gradient(this.values);\n }\n\n /**\n * @override\n */\n public getLinearValue(percent: number): string {\n return this.gradient(percent);\n }\n}\n","import { AttributeCfg } from '../interface';\nimport Attribute from './base';\n\nexport default class Opacity extends Attribute {\n constructor(cfg: AttributeCfg) {\n super(cfg);\n this.type = 'opacity';\n this.names = ['opacity'];\n }\n}\n","import { isArray, isNil } from '@antv/util';\nimport { AttributeCfg } from '../interface';\nimport Attribute from './base';\n\nexport type Value = number | string;\nexport type MappingValue = Value[] | Value;\n\nexport default class Position extends Attribute {\n constructor(cfg: AttributeCfg) {\n super(cfg);\n this.names = ['x', 'y'];\n this.type = 'position';\n }\n\n public mapping(x: MappingValue, y: MappingValue) {\n const [scaleX, scaleY] = this.scales;\n\n if (isNil(x) || isNil(y)) {\n return [];\n }\n\n return [\n isArray(x) ? x.map((xi) => scaleX.scale(xi)) : scaleX.scale(x),\n isArray(y) ? y.map((yi) => scaleY.scale(yi)) : scaleY.scale(y),\n ];\n }\n}\n","import { AttributeCfg } from '../interface';\nimport Attribute from './base';\n\nexport default class Shape extends Attribute {\n constructor(cfg: AttributeCfg) {\n super(cfg);\n this.type = 'shape';\n this.names = ['shape'];\n }\n\n /**\n * @override\n */\n public getLinearValue(percent: number): string {\n const idx = Math.round((this.values.length - 1) * percent);\n return this.values[idx];\n }\n}\n","import { AttributeCfg } from '../interface';\nimport Attribute from './base';\n\nexport default class Size extends Attribute {\n constructor(cfg: AttributeCfg) {\n super(cfg);\n this.type = 'size';\n this.names = ['size'];\n }\n}\n","import { TickMethod } from '../types';\ninterface MethodMap {\n [key: string]: TickMethod;\n}\nconst methodCache: MethodMap = {};\n\n/**\n * 获取计算 ticks 的方法\n * @param key 键值\n * @returns 计算 ticks 的方法\n */\nexport function getTickMethod(key: string): TickMethod {\n return methodCache[key];\n}\n\n/**\n * 注册计算 ticks 的方法\n * @param key 键值\n * @param method 方法\n */\nexport function registerTickMethod(key: string, method: TickMethod) {\n methodCache[key] = method;\n}\n","import { assign, isEmpty, isFunction, isNil, isNumber, isObject, isString, map } from '@antv/util';\nimport { getTickMethod } from './tick-method/register';\nimport { ScaleConfig, Tick } from './types';\nexport default abstract class Scale {\n /**\n * 度量的类型\n */\n public type: string = 'base';\n /**\n * 是否分类类型的度量\n */\n public isCategory?: boolean = false;\n /**\n * 是否线性度量,有linear, time 度量\n */\n public isLinear?: boolean = false;\n /**\n * 是否连续类型的度量,linear,time,log, pow, quantile, quantize 都支持\n */\n public isContinuous?: boolean = false;\n /**\n * 是否是常量的度量,传入和传出一致\n */\n public isIdentity: boolean = false;\n\n public field?: ScaleConfig['field'];\n public alias?: ScaleConfig['alias'];\n public values: ScaleConfig['values'] = [];\n public min?: ScaleConfig['min'];\n public max?: ScaleConfig['max'];\n public minLimit?: ScaleConfig['minLimit'];\n public maxLimit?: ScaleConfig['maxLimit'];\n public range: ScaleConfig['range'] = [0, 1];\n public ticks: ScaleConfig['ticks'] = [];\n public tickCount: ScaleConfig['tickCount'];\n public tickInterval: ScaleConfig['tickInterval'];\n public formatter?: ScaleConfig['formatter'];\n public tickMethod?: ScaleConfig['tickMethod'];\n protected __cfg__: ScaleConfig; // 缓存的旧配置, 用于 clone\n\n constructor(cfg: ScaleConfig) {\n this.__cfg__ = cfg;\n this.initCfg();\n this.init();\n }\n\n // 对于原始值的必要转换,如分类、时间字段需转换成数值,用transform/map命名可能更好\n public translate(v: any) {\n return v;\n }\n\n /** 将定义域转换为值域 */\n public abstract scale(value: any): number;\n\n /** 将值域转换为定义域 */\n public abstract invert(scaled: number): any;\n\n /** 重新初始化 */\n public change(cfg: ScaleConfig) {\n // 覆盖配置项,而不替代\n assign(this.__cfg__, cfg);\n this.init();\n }\n\n public clone(): Scale {\n return this.constructor(this.__cfg__);\n }\n\n /** 获取坐标轴需要的ticks */\n public getTicks(): Tick[] {\n return map(this.ticks, (tick: any, idx: number) => {\n if (isObject(tick)) {\n // 仅当符合Tick类型时才有意义\n return tick as Tick;\n }\n return {\n text: this.getText(tick, idx),\n tickValue: tick, // 原始value\n value: this.scale(tick), // scaled\n };\n });\n }\n\n /** 获取Tick的格式化结果 */\n public getText(value: any, key?: number): string {\n const formatter = this.formatter;\n const res = formatter ? formatter(value, key) : value;\n if (isNil(res) || !isFunction(res.toString)) {\n return '';\n }\n return res.toString();\n }\n\n // 获取配置项中的值,当前 scale 上的值可能会被修改\n protected getConfig(key) {\n return this.__cfg__[key];\n }\n\n // scale初始化\n protected init(): void {\n assign(this, this.__cfg__);\n this.setDomain();\n if (isEmpty(this.getConfig('ticks'))) {\n this.ticks = this.calculateTicks();\n }\n }\n\n // 子类上覆盖某些属性,不能直接在类上声明,否则会被覆盖\n protected initCfg() {}\n\n protected setDomain(): void {}\n\n protected calculateTicks(): any[] {\n const tickMethod = this.tickMethod;\n let ticks = [];\n if (isString(tickMethod)) {\n const method = getTickMethod(tickMethod);\n if (!method) {\n throw new Error('There is no method to to calculate ticks!');\n }\n ticks = method(this);\n } else if (isFunction(tickMethod)) {\n ticks = tickMethod(this);\n }\n return ticks;\n }\n\n // range 的最小值\n protected rangeMin() {\n return this.range[0];\n }\n\n // range 的最大值\n protected rangeMax() {\n return this.range[1];\n }\n\n /** 定义域转 0~1 */\n protected calcPercent(value: any, min: number, max: number): number {\n if (isNumber(value)) {\n return (value - min) / (max - min);\n }\n return NaN;\n }\n\n /** 0~1转定义域 */\n protected calcValue(percent: number, min: number, max: number): number {\n return min + percent * (max - min);\n }\n}\n","import { indexOf, isNil, isNumber } from '@antv/util';\nimport Base from '../base';\n\n/**\n * 分类度量\n * @class\n */\nclass Category extends Base {\n public readonly type: string = 'cat';\n public readonly isCategory: boolean = true;\n\n // 用于缓存 translate 函数\n private translateIndexMap;\n\n private buildIndexMap() {\n if (!this.translateIndexMap) {\n this.translateIndexMap = new Map();\n // 重新构建缓存\n for (let i = 0; i < this.values.length; i ++) {\n this.translateIndexMap.set(this.values[i], i);\n }\n }\n }\n\n public translate(value: any): number {\n // 按需构建 map\n this.buildIndexMap();\n // 找得到\n let idx = this.translateIndexMap.get(value);\n \n if (idx === undefined) {\n idx = isNumber(value) ? value : NaN;\n }\n return idx;\n }\n\n public scale(value: any): number {\n const order = this.translate(value);\n // 分类数据允许 0.5 范围内调整\n // if (order < this.min - 0.5 || order > this.max + 0.5) {\n // return NaN;\n // }\n const percent = this.calcPercent(order, this.min, this.max);\n return this.calcValue(percent, this.rangeMin(), this.rangeMax());\n }\n\n public invert(scaledValue: number) {\n const domainRange = this.max - this.min;\n const percent = this.calcPercent(scaledValue, this.rangeMin(), this.rangeMax());\n const idx = Math.round(domainRange * percent) + this.min;\n if (idx < this.min || idx > this.max) {\n return NaN;\n }\n return this.values[idx];\n }\n\n public getText(value: any, ...args: any[]): string {\n let v = value;\n // value为index\n if (isNumber(value) && !this.values.includes(value)) {\n v = this.values[v];\n }\n return super.getText(v, ...args);\n }\n // 复写属性\n protected initCfg() {\n this.tickMethod = 'cat';\n }\n // 设置 min, max\n protected setDomain() {\n // 用户有可能设置 min\n if (isNil(this.getConfig('min'))) {\n this.min = 0;\n }\n if (isNil(this.getConfig('max'))) {\n const size = this.values.length;\n this.max = size > 1 ? size - 1 : size;\n }\n\n // scale.init 的时候清除缓存\n if (this.translateIndexMap) {\n this.translateIndexMap = undefined;\n }\n }\n}\n\nexport default Category;\n","const token = /d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\\1?|[aA]|\"[^\"]*\"|'[^']*'/g;\nconst twoDigitsOptional = \"\\\\d\\\\d?\";\nconst twoDigits = \"\\\\d\\\\d\";\nconst threeDigits = \"\\\\d{3}\";\nconst fourDigits = \"\\\\d{4}\";\nconst word = \"[^\\\\s]+\";\nconst literal = /\\[([^]*?)\\]/gm;\n\ntype DateInfo = {\n year: number;\n month: number;\n day: number;\n hour: number;\n minute: number;\n second: number;\n millisecond: number;\n isPm: number | null;\n timezoneOffset: number | null;\n};\n\nexport type I18nSettings = {\n amPm: [string, string];\n dayNames: Days;\n dayNamesShort: Days;\n monthNames: Months;\n monthNamesShort: Months;\n DoFn(dayOfMonth: number): string;\n};\n\nexport type I18nSettingsOptional = Partial;\n\nexport type Days = [string, string, string, string, string, string, string];\nexport type Months = [\n string,\n string,\n string,\n string,\n string,\n string,\n string,\n string,\n string,\n string,\n string,\n string\n];\n\nfunction shorten(arr: T, sLen: number): string[] {\n const newArr: string[] = [];\n for (let i = 0, len = arr.length; i < len; i++) {\n newArr.push(arr[i].substr(0, sLen));\n }\n return newArr;\n}\n\nconst monthUpdate = (\n arrName: \"monthNames\" | \"monthNamesShort\" | \"dayNames\" | \"dayNamesShort\"\n) => (v: string, i18n: I18nSettings): number | null => {\n const lowerCaseArr = i18n[arrName].map(v => v.toLowerCase());\n const index = lowerCaseArr.indexOf(v.toLowerCase());\n if (index > -1) {\n return index;\n }\n return null;\n};\n\nexport function assign(a: A): A;\nexport function assign(a: A, b: B): A & B;\nexport function assign(a: A, b: B, c: C): A & B & C;\nexport function assign(a: A, b: B, c: C, d: D): A & B & C & D;\nexport function assign(origObj: any, ...args: any[]): any {\n for (const obj of args) {\n for (const key in obj) {\n // @ts-ignore ex\n origObj[key] = obj[key];\n }\n }\n return origObj;\n}\n\nconst dayNames: Days = [\n \"Sunday\",\n \"Monday\",\n \"Tuesday\",\n \"Wednesday\",\n \"Thursday\",\n \"Friday\",\n \"Saturday\"\n];\nconst monthNames: Months = [\n \"January\",\n \"February\",\n \"March\",\n \"April\",\n \"May\",\n \"June\",\n \"July\",\n \"August\",\n \"September\",\n \"October\",\n \"November\",\n \"December\"\n];\n\nconst monthNamesShort: Months = shorten(monthNames, 3) as Months;\nconst dayNamesShort: Days = shorten(dayNames, 3) as Days;\n\nconst defaultI18n: I18nSettings = {\n dayNamesShort,\n dayNames,\n monthNamesShort,\n monthNames,\n amPm: [\"am\", \"pm\"],\n DoFn(dayOfMonth: number) {\n return (\n dayOfMonth +\n [\"th\", \"st\", \"nd\", \"rd\"][\n dayOfMonth % 10 > 3\n ? 0\n : ((dayOfMonth - (dayOfMonth % 10) !== 10 ? 1 : 0) * dayOfMonth) % 10\n ]\n );\n }\n};\nlet globalI18n = assign({}, defaultI18n);\nconst setGlobalDateI18n = (i18n: I18nSettingsOptional): I18nSettings =>\n (globalI18n = assign(globalI18n, i18n));\n\nconst regexEscape = (str: string): string =>\n str.replace(/[|\\\\{()[^$+*?.-]/g, \"\\\\$&\");\n\nconst pad = (val: string | number, len = 2): string => {\n val = String(val);\n while (val.length < len) {\n val = \"0\" + val;\n }\n return val;\n};\n\nconst formatFlags: Record<\n string,\n (dateObj: Date, i18n: I18nSettings) => string\n> = {\n D: (dateObj: Date): string => String(dateObj.getDate()),\n DD: (dateObj: Date): string => pad(dateObj.getDate()),\n Do: (dateObj: Date, i18n: I18nSettings): string =>\n i18n.DoFn(dateObj.getDate()),\n d: (dateObj: Date): string => String(dateObj.getDay()),\n dd: (dateObj: Date): string => pad(dateObj.getDay()),\n ddd: (dateObj: Date, i18n: I18nSettings): string =>\n i18n.dayNamesShort[dateObj.getDay()],\n dddd: (dateObj: Date, i18n: I18nSettings): string =>\n i18n.dayNames[dateObj.getDay()],\n M: (dateObj: Date): string => String(dateObj.getMonth() + 1),\n MM: (dateObj: Date): string => pad(dateObj.getMonth() + 1),\n MMM: (dateObj: Date, i18n: I18nSettings): string =>\n i18n.monthNamesShort[dateObj.getMonth()],\n MMMM: (dateObj: Date, i18n: I18nSettings): string =>\n i18n.monthNames[dateObj.getMonth()],\n YY: (dateObj: Date): string =>\n pad(String(dateObj.getFullYear()), 4).substr(2),\n YYYY: (dateObj: Date): string => pad(dateObj.getFullYear(), 4),\n h: (dateObj: Date): string => String(dateObj.getHours() % 12 || 12),\n hh: (dateObj: Date): string => pad(dateObj.getHours() % 12 || 12),\n H: (dateObj: Date): string => String(dateObj.getHours()),\n HH: (dateObj: Date): string => pad(dateObj.getHours()),\n m: (dateObj: Date): string => String(dateObj.getMinutes()),\n mm: (dateObj: Date): string => pad(dateObj.getMinutes()),\n s: (dateObj: Date): string => String(dateObj.getSeconds()),\n ss: (dateObj: Date): string => pad(dateObj.getSeconds()),\n S: (dateObj: Date): string =>\n String(Math.round(dateObj.getMilliseconds() / 100)),\n SS: (dateObj: Date): string =>\n pad(Math.round(dateObj.getMilliseconds() / 10), 2),\n SSS: (dateObj: Date): string => pad(dateObj.getMilliseconds(), 3),\n a: (dateObj: Date, i18n: I18nSettings): string =>\n dateObj.getHours() < 12 ? i18n.amPm[0] : i18n.amPm[1],\n A: (dateObj: Date, i18n: I18nSettings): string =>\n dateObj.getHours() < 12\n ? i18n.amPm[0].toUpperCase()\n : i18n.amPm[1].toUpperCase(),\n ZZ(dateObj: Date): string {\n const offset = dateObj.getTimezoneOffset();\n return (\n (offset > 0 ? \"-\" : \"+\") +\n pad(Math.floor(Math.abs(offset) / 60) * 100 + (Math.abs(offset) % 60), 4)\n );\n },\n Z(dateObj: Date): string {\n const offset = dateObj.getTimezoneOffset();\n return (\n (offset > 0 ? \"-\" : \"+\") +\n pad(Math.floor(Math.abs(offset) / 60), 2) +\n \":\" +\n pad(Math.abs(offset) % 60, 2)\n );\n }\n};\n\ntype ParseInfo = [\n keyof DateInfo,\n string,\n ((v: string, i18n: I18nSettings) => number | null)?,\n string?\n];\nconst monthParse = (v: string): number => +v - 1;\nconst emptyDigits: ParseInfo = [null, twoDigitsOptional];\nconst emptyWord: ParseInfo = [null, word];\nconst amPm: ParseInfo = [\n \"isPm\",\n word,\n (v: string, i18n: I18nSettings): number | null => {\n const val = v.toLowerCase();\n if (val === i18n.amPm[0]) {\n return 0;\n } else if (val === i18n.amPm[1]) {\n return 1;\n }\n return null;\n }\n];\nconst timezoneOffset: ParseInfo = [\n \"timezoneOffset\",\n \"[^\\\\s]*?[\\\\+\\\\-]\\\\d\\\\d:?\\\\d\\\\d|[^\\\\s]*?Z?\",\n (v: string): number | null => {\n const parts = (v + \"\").match(/([+-]|\\d\\d)/gi);\n\n if (parts) {\n const minutes = +parts[1] * 60 + parseInt(parts[2], 10);\n return parts[0] === \"+\" ? minutes : -minutes;\n }\n\n return 0;\n }\n];\nconst parseFlags: Record = {\n D: [\"day\", twoDigitsOptional],\n DD: [\"day\", twoDigits],\n Do: [\"day\", twoDigitsOptional + word, (v: string): number => parseInt(v, 10)],\n M: [\"month\", twoDigitsOptional, monthParse],\n MM: [\"month\", twoDigits, monthParse],\n YY: [\n \"year\",\n twoDigits,\n (v: string): number => {\n const now = new Date();\n const cent = +(\"\" + now.getFullYear()).substr(0, 2);\n return +(\"\" + (+v > 68 ? cent - 1 : cent) + v);\n }\n ],\n h: [\"hour\", twoDigitsOptional, undefined, \"isPm\"],\n hh: [\"hour\", twoDigits, undefined, \"isPm\"],\n H: [\"hour\", twoDigitsOptional],\n HH: [\"hour\", twoDigits],\n m: [\"minute\", twoDigitsOptional],\n mm: [\"minute\", twoDigits],\n s: [\"second\", twoDigitsOptional],\n ss: [\"second\", twoDigits],\n YYYY: [\"year\", fourDigits],\n S: [\"millisecond\", \"\\\\d\", (v: string): number => +v * 100],\n SS: [\"millisecond\", twoDigits, (v: string): number => +v * 10],\n SSS: [\"millisecond\", threeDigits],\n d: emptyDigits,\n dd: emptyDigits,\n ddd: emptyWord,\n dddd: emptyWord,\n MMM: [\"month\", word, monthUpdate(\"monthNamesShort\")],\n MMMM: [\"month\", word, monthUpdate(\"monthNames\")],\n a: amPm,\n A: amPm,\n ZZ: timezoneOffset,\n Z: timezoneOffset\n};\n\n// Some common format strings\nconst globalMasks: { [key: string]: string } = {\n default: \"ddd MMM DD YYYY HH:mm:ss\",\n shortDate: \"M/D/YY\",\n mediumDate: \"MMM D, YYYY\",\n longDate: \"MMMM D, YYYY\",\n fullDate: \"dddd, MMMM D, YYYY\",\n isoDate: \"YYYY-MM-DD\",\n isoDateTime: \"YYYY-MM-DDTHH:mm:ssZ\",\n shortTime: \"HH:mm\",\n mediumTime: \"HH:mm:ss\",\n longTime: \"HH:mm:ss.SSS\"\n};\nconst setGlobalDateMasks = (masks: {\n [key: string]: string;\n}): { [key: string]: string } => assign(globalMasks, masks);\n\n/***\n * Format a date\n * @method format\n * @param {Date|number} dateObj\n * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'\n * @returns {string} Formatted date string\n */\nconst format = (\n dateObj: Date,\n mask: string = globalMasks[\"default\"],\n i18n: I18nSettingsOptional = {}\n): string => {\n if (typeof dateObj === \"number\") {\n dateObj = new Date(dateObj);\n }\n\n if (\n Object.prototype.toString.call(dateObj) !== \"[object Date]\" ||\n isNaN(dateObj.getTime())\n ) {\n throw new Error(\"Invalid Date pass to format\");\n }\n\n mask = globalMasks[mask] || mask;\n\n const literals: string[] = [];\n\n // Make literals inactive by replacing them with @@@\n mask = mask.replace(literal, function($0, $1) {\n literals.push($1);\n return \"@@@\";\n });\n\n const combinedI18nSettings: I18nSettings = assign(\n assign({}, globalI18n),\n i18n\n );\n // Apply formatting rules\n mask = mask.replace(token, $0 =>\n formatFlags[$0](dateObj, combinedI18nSettings)\n );\n // Inline literal values back into the formatted value\n return mask.replace(/@@@/g, () => literals.shift());\n};\n\n/**\n * Parse a date string into a Javascript Date object /\n * @method parse\n * @param {string} dateStr Date string\n * @param {string} format Date parse format\n * @param {i18n} I18nSettingsOptional Full or subset of I18N settings\n * @returns {Date|null} Returns Date object. Returns null what date string is invalid or doesn't match format\n */\nfunction parse(\n dateStr: string,\n format: string,\n i18n: I18nSettingsOptional = {}\n): Date | null {\n if (typeof format !== \"string\") {\n throw new Error(\"Invalid format in fecha parse\");\n }\n\n // Check to see if the format is actually a mask\n format = globalMasks[format] || format;\n\n // Avoid regular expression denial of service, fail early for really long strings\n // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS\n if (dateStr.length > 1000) {\n return null;\n }\n\n // Default to the beginning of the year.\n const today = new Date();\n const dateInfo: DateInfo = {\n year: today.getFullYear(),\n month: 0,\n day: 1,\n hour: 0,\n minute: 0,\n second: 0,\n millisecond: 0,\n isPm: null,\n timezoneOffset: null\n };\n const parseInfo: ParseInfo[] = [];\n const literals: string[] = [];\n\n // Replace all the literals with @@@. Hopefully a string that won't exist in the format\n let newFormat = format.replace(literal, ($0, $1) => {\n literals.push(regexEscape($1));\n return \"@@@\";\n });\n const specifiedFields: { [field: string]: boolean } = {};\n const requiredFields: { [field: string]: boolean } = {};\n\n // Change every token that we find into the correct regex\n newFormat = regexEscape(newFormat).replace(token, $0 => {\n const info = parseFlags[$0];\n const [field, regex, , requiredField] = info;\n\n // Check if the person has specified the same field twice. This will lead to confusing results.\n if (specifiedFields[field]) {\n throw new Error(`Invalid format. ${field} specified twice in format`);\n }\n\n specifiedFields[field] = true;\n\n // Check if there are any required fields. For instance, 12 hour time requires AM/PM specified\n if (requiredField) {\n requiredFields[requiredField] = true;\n }\n\n parseInfo.push(info);\n return \"(\" + regex + \")\";\n });\n\n // Check all the required fields are present\n Object.keys(requiredFields).forEach(field => {\n if (!specifiedFields[field]) {\n throw new Error(\n `Invalid format. ${field} is required in specified format`\n );\n }\n });\n\n // Add back all the literals after\n newFormat = newFormat.replace(/@@@/g, () => literals.shift());\n\n // Check if the date string matches the format. If it doesn't return null\n const matches = dateStr.match(new RegExp(newFormat, \"i\"));\n if (!matches) {\n return null;\n }\n\n const combinedI18nSettings: I18nSettings = assign(\n assign({}, globalI18n),\n i18n\n );\n\n // For each match, call the parser function for that date part\n for (let i = 1; i < matches.length; i++) {\n const [field, , parser] = parseInfo[i - 1];\n const value = parser\n ? parser(matches[i], combinedI18nSettings)\n : +matches[i];\n\n // If the parser can't make sense of the value, return null\n if (value == null) {\n return null;\n }\n\n dateInfo[field] = value;\n }\n\n if (dateInfo.isPm === 1 && dateInfo.hour != null && +dateInfo.hour !== 12) {\n dateInfo.hour = +dateInfo.hour + 12;\n } else if (dateInfo.isPm === 0 && +dateInfo.hour === 12) {\n dateInfo.hour = 0;\n }\n\n let dateTZ: Date;\n if (dateInfo.timezoneOffset == null) {\n dateTZ = new Date(\n dateInfo.year,\n dateInfo.month,\n dateInfo.day,\n dateInfo.hour,\n dateInfo.minute,\n dateInfo.second,\n dateInfo.millisecond\n );\n const validateFields: [\n \"month\" | \"day\" | \"hour\" | \"minute\" | \"second\",\n \"getMonth\" | \"getDate\" | \"getHours\" | \"getMinutes\" | \"getSeconds\"\n ][] = [\n [\"month\", \"getMonth\"],\n [\"day\", \"getDate\"],\n [\"hour\", \"getHours\"],\n [\"minute\", \"getMinutes\"],\n [\"second\", \"getSeconds\"]\n ];\n for (let i = 0, len = validateFields.length; i < len; i++) {\n // Check to make sure the date field is within the allowed range. Javascript dates allows values\n // outside the allowed range. If the values don't match the value was invalid\n if (\n specifiedFields[validateFields[i][0]] &&\n dateInfo[validateFields[i][0]] !== dateTZ[validateFields[i][1]]()\n ) {\n return null;\n }\n }\n } else {\n dateTZ = new Date(\n Date.UTC(\n dateInfo.year,\n dateInfo.month,\n dateInfo.day,\n dateInfo.hour,\n dateInfo.minute - dateInfo.timezoneOffset,\n dateInfo.second,\n dateInfo.millisecond\n )\n );\n\n // We can't validate dates in another timezone unfortunately. Do a basic check instead\n if (\n dateInfo.month > 11 ||\n dateInfo.month < 0 ||\n dateInfo.day > 31 ||\n dateInfo.day < 1 ||\n dateInfo.hour > 23 ||\n dateInfo.hour < 0 ||\n dateInfo.minute > 59 ||\n dateInfo.minute < 0 ||\n dateInfo.second > 59 ||\n dateInfo.second < 0\n ) {\n return null;\n }\n }\n\n // Don't allow invalid dates\n\n return dateTZ;\n}\nexport default {\n format,\n parse,\n defaultI18n,\n setGlobalDateI18n,\n setGlobalDateMasks\n};\nexport { format, parse, defaultI18n, setGlobalDateI18n, setGlobalDateMasks };\n","import { isDate, isString, last } from '@antv/util';\nimport fecha from 'fecha';\nimport * as fecha1 from 'fecha';\n\nimport bisector from './bisector';\nconst FORMAT_METHOD = 'format';\n\nexport function timeFormat(time, mask) { // 由于 fecha 包的 typescript 定义有问题,所以暂时兼容一下\n const method = fecha1[FORMAT_METHOD] || fecha[FORMAT_METHOD];\n return method(time, mask);\n}\n/**\n * 转换成时间戳\n * @param value 时间值\n */\nexport function toTimeStamp(value: any): number {\n if (isString(value)) {\n if (value.indexOf('T') > 0) {\n value = new Date(value).getTime();\n } else {\n // new Date('2010/01/10') 和 new Date('2010-01-10') 的差别在于:\n // 如果仅有年月日时,前者是带有时区的: Fri Jan 10 2020 02:40:13 GMT+0800 (中国标准时间)\n // 后者会格式化成 Sun Jan 10 2010 08:00:00 GMT+0800 (中国标准时间)\n value = new Date(value.replace(/-/gi, '/')).getTime();\n }\n }\n if (isDate(value)) {\n value = value.getTime();\n }\n return value;\n}\n\nconst SECOND = 1000;\nconst MINUTE = 60 * SECOND;\nconst HOUR = 60 * MINUTE;\nconst DAY = 24 * HOUR;\nconst MONTH = DAY * 31;\nconst YEAR = DAY * 365;\n\nexport { SECOND, MINUTE, HOUR, DAY, MONTH, YEAR };\ntype Interval = [string, number]; // [defaultMomentFormat, interval]\nconst intervals: Interval[] = [\n ['HH:mm:ss', SECOND],\n ['HH:mm:ss', SECOND * 10],\n ['HH:mm:ss', SECOND * 30],\n ['HH:mm', MINUTE],\n ['HH:mm', MINUTE * 10],\n ['HH:mm', MINUTE * 30],\n ['HH', HOUR],\n ['HH', HOUR * 6],\n ['HH', HOUR * 12],\n ['YYYY-MM-DD', DAY],\n ['YYYY-MM-DD', DAY * 4],\n ['YYYY-WW', DAY * 7],\n ['YYYY-MM', MONTH],\n ['YYYY-MM', MONTH * 4],\n ['YYYY-MM', MONTH * 6],\n ['YYYY', DAY * 380], // 借鉴echarts,保证每个周期累加时不会碰到恰巧不够的问题\n];\n\nexport function getTickInterval(min: number, max: number, tickCount: number): Interval {\n const target = (max - min) / tickCount;\n const idx = bisector((o: Interval) => o[1])(intervals, target) - 1;\n let interval: Interval = intervals[idx];\n if (idx < 0) {\n interval = intervals[0];\n } else if (idx >= intervals.length) {\n interval = last(intervals);\n }\n return interval;\n}\n","import { isNil } from '@antv/util';\n\ntype GetterFunc = (o: T) => number;\n\n/**\n * 二分右侧查找\n * https://github.com/d3/d3-array/blob/master/src/bisector.js\n */\nexport default function(getter: GetterFunc) {\n /**\n * x: 目标值\n * lo: 起始位置\n * hi: 结束位置\n */\n return function(a: T[], x: number, _lo?: number, _hi?: number) {\n let lo = isNil(_lo) ? 0 : _lo;\n let hi = isNil(_hi) ? a.length : _hi;\n while (lo < hi) {\n const mid = (lo + hi) >>> 1;\n if (getter(a[mid]) > x) {\n hi = mid;\n } else {\n lo = mid + 1;\n }\n }\n return lo;\n };\n}\n","import { each, isNumber } from '@antv/util';\nimport { timeFormat, toTimeStamp } from '../util/time';\nimport Category from './base';\n\n/**\n * 时间分类度量\n * @class\n */\nclass TimeCat extends Category {\n public readonly type: string = 'timeCat';\n public mask;\n /**\n * @override\n */\n public translate(value) {\n value = toTimeStamp(value);\n let index = this.values.indexOf(value);\n if (index === -1) {\n if (isNumber(value) && value < this.values.length) {\n index = value;\n } else {\n index = NaN;\n }\n }\n return index;\n }\n\n /**\n * 由于时间类型数据需要转换一下,所以复写 getText\n * @override\n */\n public getText(value: string | number, tickIndex?: number) {\n const index = this.translate(value);\n if (index > -1) {\n let result = this.values[index];\n const formatter = this.formatter;\n result = formatter ? formatter(result, tickIndex) : timeFormat(result, this.mask);\n return result;\n }\n return value;\n }\n protected initCfg() {\n this.tickMethod = 'time-cat';\n this.mask = 'YYYY-MM-DD';\n this.tickCount = 7; // 一般时间数据会显示 7, 14, 30 天的数字\n }\n\n protected setDomain() {\n const values = this.values;\n // 针对时间分类类型,会将时间统一转换为时间戳\n each(values, (v, i) => {\n values[i] = toTimeStamp(v);\n });\n values.sort((v1, v2) => {\n return v1 - v2;\n });\n super.setDomain();\n }\n}\n\nexport default TimeCat;\n","import { filter, getRange, head, isNil, last } from '@antv/util';\nimport Base from '../base';\n\n/**\n * 连续度量的基类\n * @class\n */\nexport default abstract class Continuous extends Base {\n public isContinuous?: boolean = true;\n public nice: boolean;\n\n public scale(value: any): number {\n if (isNil(value)) {\n return NaN;\n }\n const rangeMin = this.rangeMin();\n const rangeMax = this.rangeMax();\n const max = this.max;\n const min = this.min;\n if (max === min) {\n return rangeMin;\n }\n const percent = this.getScalePercent(value);\n return rangeMin + percent * (rangeMax - rangeMin);\n }\n\n protected init() {\n super.init();\n // init 完成后保证 min, max 包含 ticks 的范围\n const ticks = this.ticks;\n const firstTick = head(ticks);\n const lastTick = last(ticks);\n if (firstTick < this.min) {\n this.min = firstTick;\n }\n if (lastTick > this.max) {\n this.max = lastTick;\n }\n // strict-limit 方式\n if (!isNil(this.minLimit)) {\n this.min = firstTick;\n }\n if (!isNil(this.maxLimit)) {\n this.max = lastTick;\n }\n }\n\n protected setDomain() {\n const { min, max } = getRange(this.values);\n if (isNil(this.min)) {\n this.min = min;\n }\n if (isNil(this.max)) {\n this.max = max;\n }\n if (this.min > this.max) {\n this.min = min;\n this.max = max;\n }\n }\n\n protected calculateTicks(): any[] {\n let ticks = super.calculateTicks();\n if (!this.nice) {\n ticks = filter(ticks, (tick) => {\n return tick >= this.min && tick <= this.max;\n });\n }\n return ticks;\n }\n\n // 计算原始值值占的百分比\n protected getScalePercent(value) {\n const max = this.max;\n const min = this.min;\n return (value - min) / (max - min);\n }\n\n protected getInvertPercent(value) {\n return (value - this.rangeMin()) / (this.rangeMax() - this.rangeMin());\n }\n}\n","import Continuous from './base';\n\n/**\n * 线性度量\n * @class\n */\nexport default class Linear extends Continuous {\n public minTickInterval: number;\n public type = 'linear';\n public readonly isLinear: boolean = true;\n\n public invert(value: number): any {\n const percent = this.getInvertPercent(value);\n return this.min + percent * (this.max - this.min);\n }\n\n protected initCfg() {\n this.tickMethod = 'wilkinson-extended';\n this.nice = false;\n }\n}\n","import { each, isNil } from '@antv/util';\n\n// 求以a为次幂,结果为b的基数,如 x^^a = b;求x\n// 虽然数学上 b 不支持负数,但是这里需要支持 负数\nexport function calBase(a: number, b: number) {\n const e = Math.E;\n let value;\n if (b >= 0) {\n value = Math.pow(e, Math.log(b) / a); // 使用换底公式求底\n } else {\n value = Math.pow(e, Math.log(-b) / a) * -1; // 使用换底公式求底\n }\n return value;\n}\n\nexport function log(a: number, b: number) {\n if (a === 1) {\n return 1;\n }\n return Math.log(b) / Math.log(a);\n}\n\nexport function getLogPositiveMin(values, base, max?: number) {\n if (isNil(max)) {\n max = Math.max.apply(null, values);\n }\n let positiveMin = max;\n each(values, (value) => {\n if (value > 0 && value < positiveMin) {\n positiveMin = value;\n }\n });\n if (positiveMin === max) {\n positiveMin = max / base;\n }\n if (positiveMin > 1) {\n positiveMin = 1;\n }\n return positiveMin;\n}\n\nfunction digitLength(num: number) {\n // Get digit length of e\n const eSplit = num.toString().split(/[eE]/);\n const len = (eSplit[0].split('.')[1] || '').length - +(eSplit[1] || 0);\n return len > 0 ? len : 0;\n}\n\n/**\n * 高精度加法,解决 0.1 + 0.2 !== 0.3 的经典问题\n *\n * @param num1 加数\n * @param num2 被加数\n * @return {number} 返回值\n */\nexport function precisionAdd(num1: number, num2: number) {\n const num1Digits = digitLength(num1);\n const num2Digits = digitLength(num2);\n const baseNum = 10 ** Math.max(num1Digits, num2Digits);\n return (num1 * baseNum + num2 * baseNum) / baseNum;\n}\n","import { getLogPositiveMin, log } from '../util/math';\nimport Continuous from './base';\n/**\n * Log 度量,处理非均匀分布\n */\nclass Log extends Continuous {\n public readonly type: string = 'log';\n public base: number;\n // 用于解决 min: 0 的场景下的问题\n private positiveMin: number;\n\n /**\n * @override\n */\n public invert(value: number) {\n const base = this.base;\n const max = log(base, this.max);\n const rangeMin = this.rangeMin();\n const range = this.rangeMax() - rangeMin;\n let min;\n const positiveMin = this.positiveMin;\n if (positiveMin) {\n if (value === 0) {\n return 0;\n }\n min = log(base, positiveMin / base);\n const appendPercent = (1 / (max - min)) * range; // 0 到 positiveMin的占比\n if (value < appendPercent) {\n // 落到 0 - positiveMin 之间\n return (value / appendPercent) * positiveMin;\n }\n } else {\n min = log(base, this.min);\n }\n const percent = (value - rangeMin) / range;\n const tmp = percent * (max - min) + min;\n return Math.pow(base, tmp);\n }\n\n protected initCfg() {\n this.tickMethod = 'log';\n this.base = 10;\n this.tickCount = 6;\n this.nice = true;\n }\n\n // 设置\n protected setDomain() {\n super.setDomain();\n const min = this.min;\n if (min < 0) {\n throw new Error('When you use log scale, the minimum value must be greater than zero!');\n }\n if (min === 0) {\n this.positiveMin = getLogPositiveMin(this.values, this.base, this.max);\n }\n }\n\n // 根据当前值获取占比\n protected getScalePercent(value: number) {\n const max = this.max;\n let min = this.min;\n if (max === min) {\n return 0;\n }\n // 如果值小于等于0,则按照0处理\n if (value <= 0) {\n return 0;\n }\n const base = this.base;\n const positiveMin = this.positiveMin;\n // 如果min == 0, 则根据比0大的最小值,计算比例关系。这个最小值作为坐标轴上的第二个tick,第一个是0但是不显示\n if (positiveMin) {\n min = (positiveMin * 1) / base;\n }\n let percent;\n // 如果数值小于次小值,那么就计算 value / 次小值 占整体的比例\n if (value < positiveMin) {\n percent = value / positiveMin / (log(base, max) - log(base, min));\n } else {\n percent = (log(base, value) - log(base, min)) / (log(base, max) - log(base, min));\n }\n return percent;\n }\n}\n\nexport default Log;\n","import { calBase } from '../util/math';\nimport Continuous from './base';\n\n/**\n * Pow 度量,处理非均匀分布\n */\nclass Pow extends Continuous {\n public readonly type: string = 'pow';\n /**\n * 指数\n */\n public exponent: number;\n\n /**\n * @override\n */\n public invert(value: number) {\n const percent = this.getInvertPercent(value);\n const exponent = this.exponent;\n const max = calBase(exponent, this.max);\n const min = calBase(exponent, this.min);\n const tmp = percent * (max - min) + min;\n const factor = tmp >= 0 ? 1 : -1;\n return Math.pow(tmp, exponent) * factor;\n }\n\n protected initCfg() {\n this.tickMethod = 'pow';\n this.exponent = 2;\n this.tickCount = 5;\n this.nice = true;\n }\n\n // 获取度量计算时,value占的定义域百分比\n protected getScalePercent(value: number) {\n const max = this.max;\n const min = this.min;\n if (max === min) {\n return 0;\n }\n const exponent = this.exponent;\n const percent =\n (calBase(exponent, value) - calBase(exponent, min)) / (calBase(exponent, max) - calBase(exponent, min));\n return percent;\n }\n}\n\nexport default Pow;\n","import { each, isDate, isNil, isNumber, isString } from '@antv/util';\nimport { timeFormat, toTimeStamp } from '../util/time';\nimport Linear from './linear';\n\n/**\n * 时间度量\n * @class\n */\nclass Time extends Linear {\n public readonly type: string = 'time';\n public mask: string;\n\n /**\n * @override\n */\n public getText(value: string | number | Date, index?: number) {\n const numberValue = this.translate(value);\n const formatter = this.formatter;\n return formatter ? formatter(numberValue, index) : timeFormat(numberValue, this.mask);\n }\n /**\n * @override\n */\n public scale(value): number {\n let v = value;\n if (isString(v) || isDate(v)) {\n v = this.translate(v);\n }\n return super.scale(v);\n }\n /**\n * 将时间转换成数字\n * @override\n */\n public translate(v): number {\n return toTimeStamp(v);\n }\n protected initCfg() {\n this.tickMethod = 'time-pretty';\n this.mask = 'YYYY-MM-DD';\n this.tickCount = 7;\n this.nice = false;\n }\n\n protected setDomain() {\n const values = this.values;\n // 是否设置了 min, max,而不是直接取 this.min, this.max\n const minConfig = this.getConfig('min');\n const maxConfig = this.getConfig('max');\n // 如果设置了 min,max 则转换成时间戳\n if (!isNil(minConfig) || !isNumber(minConfig)) {\n this.min = this.translate(this.min);\n }\n if (!isNil(maxConfig) || !isNumber(maxConfig)) {\n this.max = this.translate(this.max);\n }\n // 没有设置 min, max 时\n if (values && values.length) {\n // 重新计算最大最小值\n const timeStamps = [];\n let min = Infinity; // 最小值\n let secondMin = min; // 次小值\n let max = 0;\n // 使用一个循环,计算min,max,secondMin\n each(values, (v) => {\n const timeStamp = toTimeStamp(v);\n if (isNaN(timeStamp)) {\n throw new TypeError(`Invalid Time: ${v} in time scale!`);\n }\n if (min > timeStamp) {\n secondMin = min;\n min = timeStamp;\n } else if (secondMin > timeStamp) {\n secondMin = timeStamp;\n }\n if (max < timeStamp) {\n max = timeStamp;\n }\n timeStamps.push(timeStamp);\n });\n // 存在多个值时,设置最小间距\n if (values.length > 1) {\n this.minTickInterval = secondMin - min;\n }\n if (isNil(minConfig)) {\n this.min = min;\n }\n if (isNil(maxConfig)) {\n this.max = max;\n }\n }\n }\n}\nexport default Time;\n","import { each, head, last } from '@antv/util';\nimport Continuous from './base';\n\n/**\n * 分段度量\n */\nclass Quantize extends Continuous {\n public type = 'quantize';\n\n public invert(value): number {\n const ticks = this.ticks;\n const length = ticks.length;\n const percent = this.getInvertPercent(value);\n const minIndex = Math.floor(percent * (length - 1));\n // 最后一个\n if (minIndex >= length - 1) {\n return last(ticks);\n }\n // 超出左边界, 则取第一个\n if (minIndex < 0) {\n return head(ticks);\n }\n const minTick = ticks[minIndex];\n const nextTick = ticks[minIndex + 1];\n // 比当前值小的 tick 在度量上的占比\n const minIndexPercent = minIndex / (length - 1);\n const maxIndexPercent = (minIndex + 1) / (length - 1);\n return minTick + (percent - minIndexPercent) / (maxIndexPercent - minIndexPercent) * (nextTick - minTick);\n }\n\n protected initCfg() {\n this.tickMethod = 'r-pretty';\n this.tickCount = 5;\n this.nice = true;\n }\n\n protected calculateTicks(): any[] {\n const ticks = super.calculateTicks();\n if (!this.nice) { // 如果 nice = false ,补充 min, max\n if (last(ticks) !== this.max) {\n ticks.push(this.max);\n }\n if (head(ticks) !== this.min) {\n ticks.unshift(this.min);\n }\n }\n return ticks;\n }\n\n // 计算当前值在刻度中的占比\n protected getScalePercent(value) {\n const ticks = this.ticks;\n // 超出左边界\n if (value < head(ticks)) {\n return 0;\n }\n // 超出右边界\n if (value > last(ticks)) {\n return 1;\n }\n let minIndex = 0;\n each(ticks, (tick, index) => {\n if (value >= tick) {\n minIndex = index;\n } else {\n return false;\n }\n });\n return minIndex / (ticks.length - 1);\n }\n}\n\nexport default Quantize;\n","import Quantize from './quantize';\n\nclass Quantile extends Quantize {\n public type = 'quantile';\n protected initCfg() {\n this.tickMethod = 'quantile';\n this.tickCount = 5;\n this.nice = true;\n }\n}\n\nexport default Quantile;\n","import Scale from './base';\nimport { ScaleConfig } from './types';\ntype ScaleConstructor = new (cfg: ScaleConfig) => T;\n\ninterface ScaleMap {\n [key: string]: ScaleConstructor;\n}\n\nconst map: ScaleMap = {};\n\nfunction getClass(key: string): ScaleConstructor {\n return map[key];\n}\n\nfunction registerClass(key: string, cls: ScaleConstructor) {\n if (getClass(key)) {\n throw new Error(`type '${key}' existed.`);\n }\n map[key] = cls;\n}\n\nexport { Scale, getClass as getScale, registerClass as registerScale };\n","import { has, isNumber } from '@antv/util';\nimport Base from '../base';\nimport { ScaleType } from '../types';\n\n/**\n * identity scale原则上是定义域和值域一致,scale/invert方法也是一致的\n * 参考R的实现:https://github.com/r-lib/scales/blob/master/R/pal-identity.r\n * 参考d3的实现(做了下转型):https://github.com/d3/d3-scale/blob/master/src/identity.js\n */\nexport default class Identity extends Base {\n public readonly type: ScaleType = 'identity';\n public readonly isIdentity: boolean = true;\n\n public calculateTicks() {\n return this.values;\n }\n\n public scale(value: any): number {\n // 如果传入的值不等于 identity 的值,则直接返回,用于一维图时的 dodge\n if (this.values[0] !== value && isNumber(value)) {\n return value;\n }\n return this.range[0];\n }\n\n public invert(value?: number): number {\n const range = this.range;\n if (value < range[0] || value > range[1]) {\n return NaN;\n }\n return this.values[0];\n }\n}\n","import { filter, isNil, isNumber, last } from '@antv/util';\nimport { ScaleConfig } from '../types';\n\n/**\n * 计算分类 ticks\n * @param cfg 度量的配置项\n * @returns 计算后的 ticks\n */\nexport default function calculateCatTicks(cfg: ScaleConfig): any[] {\n const { values, tickInterval, tickCount, showLast } = cfg;\n\n if (isNumber(tickInterval)) {\n const ticks = filter(values, (__: any, i: number) => i % tickInterval === 0);\n const lastValue = last(values);\n if (showLast && last(ticks) !== lastValue) {\n ticks.push(lastValue);\n }\n return ticks;\n }\n\n const len = values.length;\n let { min, max } = cfg;\n if (isNil(min)) {\n min = 0;\n }\n if (isNil(max)) {\n max = values.length - 1;\n }\n\n if (!isNumber(tickCount) || tickCount >= len) return values.slice(min, max + 1);\n if (tickCount <= 0 || max <= 0) return [];\n\n const interval = tickCount === 1 ? len : Math.floor(len / (tickCount - 1));\n const ticks = [];\n\n let idx = min;\n for (let i = 0; i < tickCount; i++) {\n if (idx >= max) break;\n\n idx = Math.min(min + i * interval, max);\n if (i === tickCount - 1 && showLast) ticks.push(values[max]);\n else ticks.push(values[idx]);\n }\n return ticks;\n}\n","import { ScaleConfig } from '../types';\n\nexport default function d3Linear(cfg: ScaleConfig): number[] {\n const { min, max, nice, tickCount } = cfg;\n const linear = new D3Linear();\n linear.domain([min, max]);\n if (nice) {\n linear.nice(tickCount);\n }\n return linear.ticks(tickCount);\n}\n\nconst DEFAULT_COUNT = 5;\nconst e10 = Math.sqrt(50);\nconst e5 = Math.sqrt(10);\nconst e2 = Math.sqrt(2);\n\n// https://github.com/d3/d3-scale\nexport class D3Linear {\n private _domain: number[] = [0, 1];\n\n public domain(domain?: number[]): D3Linear | number[] {\n if (domain) {\n this._domain = Array.from(domain, Number);\n return this;\n }\n return this._domain.slice();\n }\n\n public nice(count = DEFAULT_COUNT) {\n const d = this._domain.slice();\n let i0 = 0;\n let i1 = this._domain.length - 1;\n let start = this._domain[i0];\n let stop = this._domain[i1];\n let step;\n\n if (stop < start) {\n [start, stop] = [stop, start];\n [i0, i1] = [i1, i0];\n }\n step = tickIncrement(start, stop, count);\n\n if (step > 0) {\n start = Math.floor(start / step) * step;\n stop = Math.ceil(stop / step) * step;\n step = tickIncrement(start, stop, count);\n } else if (step < 0) {\n start = Math.ceil(start * step) / step;\n stop = Math.floor(stop * step) / step;\n step = tickIncrement(start, stop, count);\n }\n\n if (step > 0) {\n d[i0] = Math.floor(start / step) * step;\n d[i1] = Math.ceil(stop / step) * step;\n this.domain(d);\n } else if (step < 0) {\n d[i0] = Math.ceil(start * step) / step;\n d[i1] = Math.floor(stop * step) / step;\n this.domain(d);\n }\n\n return this;\n }\n\n public ticks(count = DEFAULT_COUNT): number[] {\n return d3ArrayTicks(this._domain[0], this._domain[this._domain.length - 1], count || DEFAULT_COUNT);\n }\n}\n\nfunction d3ArrayTicks(start: number, stop: number, count: number): number[] {\n let reverse;\n let i = -1;\n let n;\n let ticks;\n let step;\n\n (stop = +stop), (start = +start), (count = +count);\n if (start === stop && count > 0) {\n return [start];\n }\n // tslint:disable-next-line\n if ((reverse = stop < start)) {\n (n = start), (start = stop), (stop = n);\n }\n // tslint:disable-next-line\n if ((step = tickIncrement(start, stop, count)) === 0 || !isFinite(step)) {\n return [];\n }\n\n if (step > 0) {\n start = Math.ceil(start / step);\n stop = Math.floor(stop / step);\n ticks = new Array((n = Math.ceil(stop - start + 1)));\n while (++i < n) {\n ticks[i] = (start + i) * step;\n }\n } else {\n start = Math.floor(start * step);\n stop = Math.ceil(stop * step);\n ticks = new Array((n = Math.ceil(start - stop + 1)));\n while (++i < n) {\n ticks[i] = (start - i) / step;\n }\n }\n\n if (reverse) {\n ticks.reverse();\n }\n\n return ticks;\n}\n\nfunction tickIncrement(start: number, stop: number, count: number): number {\n const step = (stop - start) / Math.max(0, count);\n const power = Math.floor(Math.log(step) / Math.LN10);\n const error = step / Math.pow(10, power);\n\n return power >= 0\n ? (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(10, power)\n : -Math.pow(10, -power) / (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1);\n}\n","\nimport { fixedBase } from '@antv/util';\n\nfunction snapMultiple(v, base, snapType) {\n let div;\n if (snapType === 'ceil') {\n div = Math.ceil(v / base);\n } else if (snapType === 'floor') {\n div = Math.floor(v / base);\n } else {\n div = Math.round(v / base);\n }\n return div * base;\n}\n\nexport default function intervalTicks(min, max, interval) {\n // 变成 interval 的倍数\n let minTick = snapMultiple(min, interval, 'floor');\n let maxTick = snapMultiple(max, interval, 'ceil');\n // 统一小数位数\n minTick = fixedBase(minTick, interval);\n maxTick = fixedBase(maxTick, interval);\n const ticks = [];\n // https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Errors/Invalid_array_length\n const availableInterval = Math.max((maxTick - minTick) / (2 ** 12 - 1), interval);\n for (let i = minTick; i <= maxTick; i = i + availableInterval) {\n const tickValue = fixedBase(i, availableInterval); // 防止浮点数加法出现问题\n ticks.push(tickValue);\n }\n return {\n min: minTick,\n max: maxTick,\n ticks\n };\n}","import { isNil } from '@antv/util';\nimport { ScaleConfig } from '../types';\n\n/**\n * 按照给定的 minLimit/maxLimit/tickCount 均匀计算出刻度 ticks\n *\n * @param cfg Scale 配置项\n * @return ticks\n */\nexport default function strictLimit(cfg: ScaleConfig, defaultMin?: number, defaultMax?: number): number[] {\n const { minLimit, maxLimit, min, max, tickCount = 5 } = cfg;\n let tickMin = isNil(minLimit) ? (isNil(defaultMin) ? min : defaultMin) : minLimit;\n let tickMax = isNil(maxLimit) ? (isNil(defaultMax) ? max : defaultMax) : maxLimit;\n\n if (tickMin > tickMax) {\n [tickMax, tickMin] = [tickMin, tickMax];\n }\n\n if (tickCount <= 2) {\n return [tickMin, tickMax];\n }\n\n const step = (tickMax - tickMin) / (tickCount - 1);\n const ticks: number[] = [];\n\n for (let i = 0; i < tickCount; i++) {\n ticks.push(tickMin + step * i);\n }\n\n return ticks;\n}\n","// 为了解决 js 运算的精度问题\nexport function prettyNumber(n: number) {\n return Math.abs(n) < 1e-15 ? n : parseFloat(n.toFixed(15));\n}\n","import { head, indexOf, size, last } from '@antv/util';\nimport { prettyNumber } from './pretty-number';\n\nexport const DEFAULT_Q = [1, 5, 2, 2.5, 4, 3];\n\nexport const ALL_Q = [1, 5, 2, 2.5, 4, 3, 1.5, 7, 6, 8, 9];\n\nconst eps = Number.EPSILON * 100;\n\nfunction mod(n: number, m: number) {\n return ((n % m) + m) % m;\n}\n\nfunction round(n: number) {\n return Math.round(n * 1e12) / 1e12;\n}\n\nfunction simplicity(q: number, Q: number[], j: number, lmin: number, lmax: number, lstep: number) {\n const n = size(Q);\n const i = indexOf(Q, q);\n let v = 0;\n const m = mod(lmin, lstep);\n if ((m < eps || lstep - m < eps) && lmin <= 0 && lmax >= 0) {\n v = 1;\n }\n return 1 - i / (n - 1) - j + v;\n}\n\nfunction simplicityMax(q: number, Q: number[], j: number) {\n const n = size(Q);\n const i = indexOf(Q, q);\n const v = 1;\n return 1 - i / (n - 1) - j + v;\n}\n\nfunction density(k: number, m: number, dMin: number, dMax: number, lMin: number, lMax: number) {\n const r = (k - 1) / (lMax - lMin);\n const rt = (m - 1) / (Math.max(lMax, dMax) - Math.min(dMin, lMin));\n return 2 - Math.max(r / rt, rt / r);\n}\n\nfunction densityMax(k: number, m: number) {\n if (k >= m) {\n return 2 - (k - 1) / (m - 1);\n }\n return 1;\n}\n\nfunction coverage(dMin: number, dMax: number, lMin: number, lMax: number) {\n const range = dMax - dMin;\n return 1 - (0.5 * ((dMax - lMax) ** 2 + (dMin - lMin) ** 2)) / (0.1 * range) ** 2;\n}\n\nfunction coverageMax(dMin: number, dMax: number, span: number) {\n const range = dMax - dMin;\n if (span > range) {\n const half = (span - range) / 2;\n return 1 - half ** 2 / (0.1 * range) ** 2;\n }\n return 1;\n}\n\nfunction legibility() {\n return 1;\n}\n\n/**\n * An Extension of Wilkinson's Algorithm for Position Tick Labels on Axes\n * https://www.yuque.com/preview/yuque/0/2019/pdf/185317/1546999150858-45c3b9c2-4e86-4223-bf1a-8a732e8195ed.pdf\n * @param dMin 最小值\n * @param dMax 最大值\n * @param m tick个数\n * @param onlyLoose 是否允许扩展min、max,不绝对强制,例如[3, 97]\n * @param Q nice numbers集合\n * @param w 四个优化组件的权重\n */\nexport default function extended(\n dMin: number,\n dMax: number,\n n: number = 5,\n onlyLoose: boolean = true,\n Q: number[] = DEFAULT_Q,\n w: [number, number, number, number] = [0.25, 0.2, 0.5, 0.05]\n): { min: number; max: number; ticks: number[] } {\n // 处理小于 0 和小数的 tickCount\n const m = n < 0 ? 0 : Math.round(n);\n\n // nan 也会导致异常\n if (Number.isNaN(dMin) || Number.isNaN(dMax) || typeof dMin !== 'number' || typeof dMax !== 'number' || !m) {\n return {\n min: 0,\n max: 0,\n ticks: [],\n };\n }\n\n // js 极大值极小值问题,差值小于 1e-15 会导致计算出错\n if (dMax - dMin < 1e-15 || m === 1) {\n return {\n min: dMin,\n max: dMax,\n ticks: [dMin],\n };\n }\n\n // js 超大值问题\n if (dMax - dMin > 1e148) {\n const count = n || 5;\n const step = (dMax - dMin) / count;\n return {\n min: dMin,\n max: dMax,\n ticks: Array(count).fill(null).map((_,idx) => {\n return prettyNumber(dMin + step * idx);\n }),\n };\n }\n\n const best = {\n score: -2,\n lmin: 0,\n lmax: 0,\n lstep: 0,\n };\n\n let j = 1;\n while (j < Infinity) {\n for (let i = 0; i < Q.length; i += 1) {\n const q = Q[i];\n const sm = simplicityMax(q, Q, j);\n if (w[0] * sm + w[1] + w[2] + w[3] < best.score) {\n j = Infinity;\n break;\n }\n let k = 2;\n while (k < Infinity) {\n const dm = densityMax(k, m);\n if (w[0] * sm + w[1] + w[2] * dm + w[3] < best.score) {\n break;\n }\n\n const delta = (dMax - dMin) / (k + 1) / j / q;\n let z = Math.ceil(Math.log10(delta));\n\n while (z < Infinity) {\n const step = j * q * 10 ** z;\n const cm = coverageMax(dMin, dMax, step * (k - 1));\n\n if (w[0] * sm + w[1] * cm + w[2] * dm + w[3] < best.score) {\n break;\n }\n\n const minStart = Math.floor(dMax / step) * j - (k - 1) * j;\n const maxStart = Math.ceil(dMin / step) * j;\n\n if (minStart <= maxStart) {\n const count = maxStart - minStart;\n for (let i = 0; i <= count; i += 1) {\n const start = minStart + i;\n const lMin = start * (step / j);\n const lMax = lMin + step * (k - 1);\n const lStep = step;\n\n const s = simplicity(q, Q, j, lMin, lMax, lStep);\n const c = coverage(dMin, dMax, lMin, lMax);\n const g = density(k, m, dMin, dMax, lMin, lMax);\n const l = legibility();\n\n const score = w[0] * s + w[1] * c + w[2] * g + w[3] * l;\n if (score > best.score && (!onlyLoose || (lMin <= dMin && lMax >= dMax))) {\n best.lmin = lMin;\n best.lmax = lMax;\n best.lstep = lStep;\n best.score = score;\n }\n }\n }\n z += 1;\n }\n k += 1;\n }\n }\n j += 1;\n }\n\n // 处理精度问题,保证这三个数没有精度问题\n const lmax = prettyNumber(best.lmax);\n const lmin = prettyNumber(best.lmin);\n const lstep = prettyNumber(best.lstep);\n\n // 加 round 是为处理 extended(0.94, 1, 5)\n // 保证生成的 tickCount 没有精度问题\n const tickCount = Math.floor(round((lmax - lmin) / lstep)) + 1;\n const ticks = new Array(tickCount);\n\n // 少用乘法:防止出现 -1.2 + 1.2 * 3 = 2.3999999999999995 的情况\n ticks[0] = prettyNumber(lmin);\n for (let i = 1; i < tickCount; i++) {\n ticks[i] = prettyNumber(ticks[i - 1] + lstep);\n }\n\n return {\n min: Math.min(dMin, head(ticks)),\n max: Math.max(dMax, last(ticks)),\n ticks,\n };\n}\n","import { prettyNumber } from './pretty-number';\n\nexport default function pretty(min: number, max: number, m: number = 5) {\n if (min === max) {\n return {\n max,\n min,\n ticks: [min],\n };\n }\n\n const n = m < 0 ? 0 : Math.round(m);\n if (n === 0) return { max, min, ticks: [] };\n\n /*\n R pretty:\n https://svn.r-project.org/R/trunk/src/appl/pretty.c\n https://www.rdocumentation.org/packages/base/versions/3.5.2/topics/pretty\n */\n const h = 1.5; // high.u.bias\n const h5 = 0.5 + 1.5 * h; // u5.bias\n // 反正我也不会调参,跳过所有判断步骤\n const d = max - min;\n const c = d / n;\n // 当d非常小的时候触发,但似乎没什么用\n // const min_n = Math.floor(n / 3);\n // const shrink_sml = Math.pow(2, 5);\n // if (Math.log10(d) < -2) {\n // c = (_.max([ Math.abs(max), Math.abs(min) ]) * shrink_sml) / min_n;\n // }\n\n const base = Math.pow(10, Math.floor(Math.log10(c)));\n let unit = base;\n if (2 * base - c < h * (c - unit)) {\n unit = 2 * base;\n if (5 * base - c < h5 * (c - unit)) {\n unit = 5 * base;\n if (10 * base - c < h * (c - unit)) {\n unit = 10 * base;\n }\n }\n }\n const nu = Math.ceil(max / unit);\n const ns = Math.floor(min / unit);\n\n const hi = Math.max(nu * unit, max);\n const lo = Math.min(ns * unit, min);\n\n const size = Math.floor((hi - lo) / unit) + 1;\n const ticks = new Array(size);\n for (let i = 0; i < size; i++) {\n ticks[i] = prettyNumber(lo + i * unit);\n }\n\n return {\n min: lo,\n max: hi,\n ticks,\n };\n}\n","import { ScaleConfig } from '../types';\n/**\n * 计算几分位 https://github.com/simple-statistics/simple-statistics/blob/master/src/quantile_sorted.js\n * @param x 数组\n * @param p 百分比\n */\nfunction quantileSorted(x, p) {\n const idx = x.length * p;\n /*if (x.length === 0) { // 当前场景这些条件不可能命中\n throw new Error('quantile requires at least one value.');\n } else if (p < 0 || p > 1) {\n throw new Error('quantiles must be between 0 and 1');\n } else */\n \n if (p === 1) {\n // If p is 1, directly return the last element\n return x[x.length - 1];\n } else if (p === 0) {\n // If p is 0, directly return the first element\n return x[0];\n } else if (idx % 1 !== 0) {\n // If p is not integer, return the next element in array\n return x[Math.ceil(idx) - 1];\n } else if (x.length % 2 === 0) {\n // If the list has even-length, we'll take the average of this number\n // and the next value, if there is one\n return (x[idx - 1] + x[idx]) / 2;\n } else {\n // Finally, in the simple case of an integer value\n // with an odd-length list, return the x value at the index.\n return x[idx];\n }\n}\n\nexport default function calculateTicks(cfg: ScaleConfig) {\n const { tickCount, values } = cfg;\n if (!values || !values.length) {\n return [];\n }\n const sorted = values.slice().sort((a, b) => {\n return a - b;\n });\n const ticks = [];\n for (let i = 0; i < tickCount; i++) {\n const p = i / (tickCount - 1);\n ticks.push(quantileSorted(sorted, p));\n }\n return ticks;\n}\n","import { ScaleConfig } from '../types';\nimport { DAY, getTickInterval, HOUR, MINUTE, MONTH, SECOND, YEAR } from '../util/time';\n\nfunction getYear(date: number) {\n return new Date(date).getFullYear();\n}\n\nfunction createYear(year: number) {\n return new Date(year, 0, 1).getTime();\n}\n\nfunction getMonth(date: number) {\n return new Date(date).getMonth();\n}\n\nfunction diffMonth(min: number, max: number) {\n const minYear = getYear(min);\n const maxYear = getYear(max);\n const minMonth = getMonth(min);\n const maxMonth = getMonth(max);\n return (maxYear - minYear) * 12 + ((maxMonth - minMonth) % 12);\n}\n\nfunction creatMonth(year: number, month: number) {\n return new Date(year, month, 1).getTime();\n}\n\nfunction diffDay(min: number, max: number) {\n return Math.ceil((max - min) / DAY);\n}\n\nfunction diffHour(min: number, max: number) {\n return Math.ceil((max - min) / HOUR);\n}\n\nfunction diffMinus(min: number, max: number) {\n return Math.ceil((max - min) / (60 * 1000));\n}\n\n/**\n * 计算 time 的 ticks,对 month, year 进行 pretty 处理\n * @param cfg 度量的配置项\n * @returns 计算后的 ticks\n */\nexport default function timePretty(cfg: ScaleConfig): number[] {\n const { min, max, minTickInterval, tickCount } = cfg;\n let { tickInterval } = cfg;\n const ticks: number[] = [];\n // 指定 tickInterval 后 tickCount 不生效,需要重新计算\n if (!tickInterval) {\n tickInterval = (max - min) / tickCount;\n // 如果设置了最小间距,则使用最小间距\n if (minTickInterval && tickInterval < minTickInterval) {\n tickInterval = minTickInterval;\n }\n }\n tickInterval = Math.max(Math.floor((max - min) / (2 ** 12 - 1)), tickInterval);\n const minYear = getYear(min);\n // 如果间距大于 1 年,则将开始日期从整年开始\n if (tickInterval > YEAR) {\n const maxYear = getYear(max);\n const yearInterval = Math.ceil(tickInterval / YEAR);\n for (let i = minYear; i <= maxYear + yearInterval; i = i + yearInterval) {\n ticks.push(createYear(i));\n }\n } else if (tickInterval > MONTH) {\n // 大于月时\n const monthInterval = Math.ceil(tickInterval / MONTH);\n const mmMoth = getMonth(min);\n const dMonths = diffMonth(min, max);\n for (let i = 0; i <= dMonths + monthInterval; i = i + monthInterval) {\n ticks.push(creatMonth(minYear, i + mmMoth));\n }\n } else if (tickInterval > DAY) {\n // 大于天\n const date = new Date(min);\n const year = date.getFullYear();\n const month = date.getMonth();\n const mday = date.getDate();\n const day = Math.ceil(tickInterval / DAY);\n const ddays = diffDay(min, max);\n for (let i = 0; i < ddays + day; i = i + day) {\n ticks.push(new Date(year, month, mday + i).getTime());\n }\n } else if (tickInterval > HOUR) {\n // 大于小时\n const date = new Date(min);\n const year = date.getFullYear();\n const month = date.getMonth();\n const day = date.getDate();\n const hour = date.getHours();\n const hours = Math.ceil(tickInterval / HOUR);\n const dHours = diffHour(min, max);\n for (let i = 0; i <= dHours + hours; i = i + hours) {\n ticks.push(new Date(year, month, day, hour + i).getTime());\n }\n } else if (tickInterval > MINUTE) {\n // 大于分钟\n const dMinus = diffMinus(min, max);\n const minutes = Math.ceil(tickInterval / MINUTE);\n for (let i = 0; i <= dMinus + minutes; i = i + minutes) {\n ticks.push(min + i * MINUTE);\n }\n } else {\n // 小于分钟\n let interval = tickInterval;\n if (interval < SECOND) {\n interval = SECOND;\n }\n const minSecond = Math.floor(min / SECOND) * SECOND;\n const dSeconds = Math.ceil((max - min) / SECOND);\n const seconds = Math.ceil(interval / SECOND);\n for (let i = 0; i < dSeconds + seconds; i = i + seconds) {\n ticks.push(minSecond + i * SECOND);\n }\n }\n\n // 最好是能从算法能解决这个问题,但是如果指定了 tickInterval,计算 ticks,也只能这么算,所以\n // 打印警告提示\n if (ticks.length >= 512) {\n console.warn(`Notice: current ticks length(${ticks.length}) >= 512, may cause performance issues, even out of memory. Because of the configure \"tickInterval\"(in milliseconds, current is ${tickInterval}) is too small, increase the value to solve the problem!`);\n }\n\n return ticks;\n}\n","import cat from './cat';\nimport d3Linear from './d3-linear';\nimport linear from './linear';\nimport log from './log';\nimport pow from './pow';\nimport quantile from './quantile';\nimport rPretty from './r-prettry';\nimport { getTickMethod, registerTickMethod } from './register';\nimport time from './time';\nimport timeCat from './time-cat';\nimport timePretty from './time-pretty';\n\nregisterTickMethod('cat', cat);\nregisterTickMethod('time-cat', timeCat);\nregisterTickMethod('wilkinson-extended', linear);\nregisterTickMethod('r-pretty', rPretty);\nregisterTickMethod('time', time);\nregisterTickMethod('time-pretty', timePretty);\nregisterTickMethod('log', log);\nregisterTickMethod('pow', pow);\nregisterTickMethod('quantile', quantile);\nregisterTickMethod('d3-linear', d3Linear);\n\nexport { getTickMethod, registerTickMethod };\n","import { ScaleConfig } from '../types';\nimport catTicks from './cat';\n/**\n * 计算时间分类的 ticks, 保头,保尾\n * @param cfg 度量的配置项\n * @returns 计算后的 ticks\n */\nexport default function timeCat(cfg: ScaleConfig): any[] {\n // 默认保留最后一条\n const ticks = catTicks({ showLast: true, ...cfg });\n return ticks;\n}\n","import { head, isNil, last } from '@antv/util';\nimport { ScaleConfig } from '../types';\nimport extended from '../util/extended';\nimport interval from '../util/interval';\nimport strictLimit from '../util/strict-limit';\n\n/**\n * 计算线性的 ticks,使用 wilkinson extended 方法\n * @param cfg 度量的配置项\n * @returns 计算后的 ticks\n */\nexport default function linear(cfg: ScaleConfig): number[] {\n const { min, max, tickCount, nice, tickInterval, minLimit, maxLimit } = cfg;\n const ticks = extended(min, max, tickCount, nice).ticks;\n\n if (!isNil(minLimit) || !isNil(maxLimit)) {\n return strictLimit(cfg, head(ticks), last(ticks));\n }\n if (tickInterval) {\n return interval(min, max, tickInterval).ticks;\n }\n return ticks;\n}\n","import { head, isNil, last } from '@antv/util';\nimport { ScaleConfig } from '../types';\nimport interval from '../util/interval';\nimport pretty from '../util/pretty';\nimport strictLimit from '../util/strict-limit';\n\n/**\n * 计算线性的 ticks,使用 R's pretty 方法\n * @param cfg 度量的配置项\n * @returns 计算后的 ticks\n */\nexport default function linearPretty(cfg: ScaleConfig): number[] {\n const { min, max, tickCount, tickInterval, minLimit, maxLimit } = cfg;\n const ticks = pretty(min, max, tickCount).ticks;\n\n if (!isNil(minLimit) || !isNil(maxLimit)) {\n return strictLimit(cfg, head(ticks), last(ticks));\n }\n if (tickInterval) {\n return interval(min, max, tickInterval).ticks;\n }\n return ticks;\n}\n","import { ScaleConfig } from '../types';\nimport { getTickInterval } from '../util/time';\n\nexport default function calculateTimeTicks(cfg: ScaleConfig): number[] {\n const { min, max, minTickInterval } = cfg;\n let tickInterval = cfg.tickInterval;\n let tickCount = cfg.tickCount;\n // 指定 tickInterval 后 tickCount 不生效,需要重新计算\n if (tickInterval) {\n tickCount = Math.ceil((max - min) / tickInterval);\n } else {\n tickInterval = getTickInterval(min, max, tickCount)[1];\n const count = (max - min) / tickInterval;\n const ratio = count / tickCount;\n if (ratio > 1) {\n tickInterval = tickInterval * Math.ceil(ratio);\n }\n // 如果设置了最小间距,则使用最小间距\n if (minTickInterval && tickInterval < minTickInterval) {\n tickInterval = minTickInterval;\n }\n }\n\n tickInterval = Math.max(Math.floor((max - min) / (2 ** 12 - 1)), tickInterval);\n const ticks = [];\n for (let i = min; i < max + tickInterval; i += tickInterval) {\n ticks.push(i);\n }\n return ticks;\n}\n","import { isEmpty } from '@antv/util';\nimport { ScaleConfig } from '../types';\nimport { getLogPositiveMin, log } from '../util/math';\n\n/**\n * 计算 log 的 ticks,考虑 min = 0 的场景\n * @param cfg 度量的配置项\n * @returns 计算后的 ticks\n */\nexport default function calculateLogTicks(cfg: ScaleConfig) {\n const { base, tickCount, min, max, values } = cfg;\n let minTick;\n const maxTick = log(base, max);\n if (min > 0) {\n minTick = Math.floor(log(base, min));\n } else {\n const positiveMin = getLogPositiveMin(values, base, max);\n minTick = Math.floor(log(base, positiveMin));\n }\n const count = maxTick - minTick;\n const avg = Math.ceil(count / tickCount);\n const ticks = [];\n for (let i = minTick; i < maxTick + avg; i = i + avg) {\n ticks.push(Math.pow(base, i));\n }\n if (min <= 0) {\n // 最小值 <= 0 时显示 0\n ticks.unshift(0);\n }\n return ticks;\n}\n","import { ScaleConfig } from '../types';\nimport { calBase } from '../util/math';\nimport pretty from '../util/pretty';\n/**\n * 计算 Pow 的 ticks\n * @param cfg 度量的配置项\n * @returns 计算后的 ticks\n */\nexport default function calculatePowTicks(cfg: ScaleConfig) {\n const { exponent, tickCount } = cfg;\n const max = Math.ceil(calBase(exponent, cfg.max));\n const min = Math.floor(calBase(exponent, cfg.min));\n const ticks = pretty(min, max, tickCount).ticks;\n return ticks.map((tick) => {\n const factor = tick >= 0 ? 1 : -1;\n return Math.pow(tick, exponent) * factor;\n });\n}\n","import { head, isNil, last } from '@antv/util';\nimport { ScaleConfig } from '../types';\nimport d3Linear from '../util/d3-linear';\nimport interval from '../util/interval';\nimport strictLimit from '../util/strict-limit';\n\nexport default function d3LinearTickMethod(cfg: ScaleConfig): number[] {\n const { min, max, tickInterval, minLimit, maxLimit } = cfg;\n const ticks = d3Linear(cfg);\n\n if (!isNil(minLimit) || !isNil(maxLimit)) {\n return strictLimit(cfg, head(ticks), last(ticks));\n }\n if (tickInterval) {\n return interval(min, max, tickInterval).ticks;\n }\n return ticks;\n}\n","import Scale from './base';\nimport Category from './category/base';\nimport TimeCat from './category/time';\nimport Linear from './continuous/linear';\nimport Log from './continuous/log';\nimport Pow from './continuous/pow';\nimport Time from './continuous/time';\nimport Quantize from './continuous/quantize';\nimport Quantile from './continuous/quantile';\nimport { getScale, registerScale } from './factory';\nimport Identity from './identity/index';\nimport { getTickMethod, registerTickMethod } from './tick-method/index';\nimport { ScaleConfig, Tick } from './types';\n\nregisterScale('cat', Category);\nregisterScale('category', Category);\nregisterScale('identity', Identity);\nregisterScale('linear', Linear);\nregisterScale('log', Log);\nregisterScale('pow', Pow);\nregisterScale('time', Time);\nregisterScale('timeCat', TimeCat);\nregisterScale('quantize', Quantize);\nregisterScale('quantile', Quantile);\n\nexport {\n Category,\n Identity,\n Linear,\n Log,\n Pow,\n Time,\n TimeCat,\n Quantile,\n Quantize,\n Scale,\n getScale,\n registerScale,\n ScaleConfig,\n Tick,\n getTickMethod,\n registerTickMethod,\n};\n","import Attribute, { AttributeConstructor } from './attributes/base';\n\ninterface AttributeMapType {\n [key: string]: any;\n}\n\n// 所有的 attribute map\nconst ATTRIBUTE_MAP: AttributeMapType = {};\n\n/**\n * 通过类型获得 Attribute 类\n * @param type\n */\nconst getAttribute = (type: string) => {\n return ATTRIBUTE_MAP[type.toLowerCase()];\n};\n\nconst registerAttribute = (type: string, ctor: AttributeConstructor) => {\n // 注册的时候,需要校验 type 重名,不区分大小写\n if (getAttribute(type)) {\n throw new Error(`Attribute type '${type}' existed.`);\n }\n // 存储到 map 中\n ATTRIBUTE_MAP[type.toLowerCase()] = ctor;\n};\n\nexport { getAttribute, registerAttribute, Attribute };\nexport * from './interface';\n","import Attribute from './attributes/base';\n\nimport Color from './attributes/color';\nimport Opacity from './attributes/opacity';\nimport Position from './attributes/position';\nimport Shape from './attributes/shape';\nimport Size from './attributes/size';\n\nimport { getAttribute, registerAttribute } from './factory';\n\nregisterAttribute('Color', Color);\nregisterAttribute('Opacity', Opacity);\nregisterAttribute('Position', Position);\nregisterAttribute('Shape', Shape);\nregisterAttribute('Size', Size);\n\nexport {\n registerAttribute,\n getAttribute,\n Attribute,\n // 以下 export 是为了兼容,理论上是不需要的\n Color,\n Opacity,\n Position,\n Shape,\n Size,\n};\n\nexport * from './interface';\n","import * as glMatrix from \"./common.js\";\n/**\n * 3 Dimensional Vector\n * @module vec3\n */\n\n/**\n * Creates a new, empty vec3\n *\n * @returns {vec3} a new 3D vector\n */\n\nexport function create() {\n var out = new glMatrix.ARRAY_TYPE(3);\n\n if (glMatrix.ARRAY_TYPE != Float32Array) {\n out[0] = 0;\n out[1] = 0;\n out[2] = 0;\n }\n\n return out;\n}\n/**\n * Creates a new vec3 initialized with values from an existing vector\n *\n * @param {ReadonlyVec3} a vector to clone\n * @returns {vec3} a new 3D vector\n */\n\nexport function clone(a) {\n var out = new glMatrix.ARRAY_TYPE(3);\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n return out;\n}\n/**\n * Calculates the length of a vec3\n *\n * @param {ReadonlyVec3} a vector to calculate length of\n * @returns {Number} length of a\n */\n\nexport function length(a) {\n var x = a[0];\n var y = a[1];\n var z = a[2];\n return Math.hypot(x, y, z);\n}\n/**\n * Creates a new vec3 initialized with the given values\n *\n * @param {Number} x X component\n * @param {Number} y Y component\n * @param {Number} z Z component\n * @returns {vec3} a new 3D vector\n */\n\nexport function fromValues(x, y, z) {\n var out = new glMatrix.ARRAY_TYPE(3);\n out[0] = x;\n out[1] = y;\n out[2] = z;\n return out;\n}\n/**\n * Copy the values from one vec3 to another\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the source vector\n * @returns {vec3} out\n */\n\nexport function copy(out, a) {\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n return out;\n}\n/**\n * Set the components of a vec3 to the given values\n *\n * @param {vec3} out the receiving vector\n * @param {Number} x X component\n * @param {Number} y Y component\n * @param {Number} z Z component\n * @returns {vec3} out\n */\n\nexport function set(out, x, y, z) {\n out[0] = x;\n out[1] = y;\n out[2] = z;\n return out;\n}\n/**\n * Adds two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\n\nexport function add(out, a, b) {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n out[2] = a[2] + b[2];\n return out;\n}\n/**\n * Subtracts vector b from vector a\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\n\nexport function subtract(out, a, b) {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n out[2] = a[2] - b[2];\n return out;\n}\n/**\n * Multiplies two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\n\nexport function multiply(out, a, b) {\n out[0] = a[0] * b[0];\n out[1] = a[1] * b[1];\n out[2] = a[2] * b[2];\n return out;\n}\n/**\n * Divides two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\n\nexport function divide(out, a, b) {\n out[0] = a[0] / b[0];\n out[1] = a[1] / b[1];\n out[2] = a[2] / b[2];\n return out;\n}\n/**\n * Math.ceil the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to ceil\n * @returns {vec3} out\n */\n\nexport function ceil(out, a) {\n out[0] = Math.ceil(a[0]);\n out[1] = Math.ceil(a[1]);\n out[2] = Math.ceil(a[2]);\n return out;\n}\n/**\n * Math.floor the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to floor\n * @returns {vec3} out\n */\n\nexport function floor(out, a) {\n out[0] = Math.floor(a[0]);\n out[1] = Math.floor(a[1]);\n out[2] = Math.floor(a[2]);\n return out;\n}\n/**\n * Returns the minimum of two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\n\nexport function min(out, a, b) {\n out[0] = Math.min(a[0], b[0]);\n out[1] = Math.min(a[1], b[1]);\n out[2] = Math.min(a[2], b[2]);\n return out;\n}\n/**\n * Returns the maximum of two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\n\nexport function max(out, a, b) {\n out[0] = Math.max(a[0], b[0]);\n out[1] = Math.max(a[1], b[1]);\n out[2] = Math.max(a[2], b[2]);\n return out;\n}\n/**\n * Math.round the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to round\n * @returns {vec3} out\n */\n\nexport function round(out, a) {\n out[0] = Math.round(a[0]);\n out[1] = Math.round(a[1]);\n out[2] = Math.round(a[2]);\n return out;\n}\n/**\n * Scales a vec3 by a scalar number\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the vector to scale\n * @param {Number} b amount to scale the vector by\n * @returns {vec3} out\n */\n\nexport function scale(out, a, b) {\n out[0] = a[0] * b;\n out[1] = a[1] * b;\n out[2] = a[2] * b;\n return out;\n}\n/**\n * Adds two vec3's after scaling the second operand by a scalar value\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @param {Number} scale the amount to scale b by before adding\n * @returns {vec3} out\n */\n\nexport function scaleAndAdd(out, a, b, scale) {\n out[0] = a[0] + b[0] * scale;\n out[1] = a[1] + b[1] * scale;\n out[2] = a[2] + b[2] * scale;\n return out;\n}\n/**\n * Calculates the euclidian distance between two vec3's\n *\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {Number} distance between a and b\n */\n\nexport function distance(a, b) {\n var x = b[0] - a[0];\n var y = b[1] - a[1];\n var z = b[2] - a[2];\n return Math.hypot(x, y, z);\n}\n/**\n * Calculates the squared euclidian distance between two vec3's\n *\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {Number} squared distance between a and b\n */\n\nexport function squaredDistance(a, b) {\n var x = b[0] - a[0];\n var y = b[1] - a[1];\n var z = b[2] - a[2];\n return x * x + y * y + z * z;\n}\n/**\n * Calculates the squared length of a vec3\n *\n * @param {ReadonlyVec3} a vector to calculate squared length of\n * @returns {Number} squared length of a\n */\n\nexport function squaredLength(a) {\n var x = a[0];\n var y = a[1];\n var z = a[2];\n return x * x + y * y + z * z;\n}\n/**\n * Negates the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to negate\n * @returns {vec3} out\n */\n\nexport function negate(out, a) {\n out[0] = -a[0];\n out[1] = -a[1];\n out[2] = -a[2];\n return out;\n}\n/**\n * Returns the inverse of the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to invert\n * @returns {vec3} out\n */\n\nexport function inverse(out, a) {\n out[0] = 1.0 / a[0];\n out[1] = 1.0 / a[1];\n out[2] = 1.0 / a[2];\n return out;\n}\n/**\n * Normalize a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to normalize\n * @returns {vec3} out\n */\n\nexport function normalize(out, a) {\n var x = a[0];\n var y = a[1];\n var z = a[2];\n var len = x * x + y * y + z * z;\n\n if (len > 0) {\n //TODO: evaluate use of glm_invsqrt here?\n len = 1 / Math.sqrt(len);\n }\n\n out[0] = a[0] * len;\n out[1] = a[1] * len;\n out[2] = a[2] * len;\n return out;\n}\n/**\n * Calculates the dot product of two vec3's\n *\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {Number} dot product of a and b\n */\n\nexport function dot(a, b) {\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\n}\n/**\n * Computes the cross product of two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\n\nexport function cross(out, a, b) {\n var ax = a[0],\n ay = a[1],\n az = a[2];\n var bx = b[0],\n by = b[1],\n bz = b[2];\n out[0] = ay * bz - az * by;\n out[1] = az * bx - ax * bz;\n out[2] = ax * by - ay * bx;\n return out;\n}\n/**\n * Performs a linear interpolation between two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec3} out\n */\n\nexport function lerp(out, a, b, t) {\n var ax = a[0];\n var ay = a[1];\n var az = a[2];\n out[0] = ax + t * (b[0] - ax);\n out[1] = ay + t * (b[1] - ay);\n out[2] = az + t * (b[2] - az);\n return out;\n}\n/**\n * Performs a hermite interpolation with two control points\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @param {ReadonlyVec3} c the third operand\n * @param {ReadonlyVec3} d the fourth operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec3} out\n */\n\nexport function hermite(out, a, b, c, d, t) {\n var factorTimes2 = t * t;\n var factor1 = factorTimes2 * (2 * t - 3) + 1;\n var factor2 = factorTimes2 * (t - 2) + t;\n var factor3 = factorTimes2 * (t - 1);\n var factor4 = factorTimes2 * (3 - 2 * t);\n out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;\n out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;\n out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;\n return out;\n}\n/**\n * Performs a bezier interpolation with two control points\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @param {ReadonlyVec3} c the third operand\n * @param {ReadonlyVec3} d the fourth operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec3} out\n */\n\nexport function bezier(out, a, b, c, d, t) {\n var inverseFactor = 1 - t;\n var inverseFactorTimesTwo = inverseFactor * inverseFactor;\n var factorTimes2 = t * t;\n var factor1 = inverseFactorTimesTwo * inverseFactor;\n var factor2 = 3 * t * inverseFactorTimesTwo;\n var factor3 = 3 * factorTimes2 * inverseFactor;\n var factor4 = factorTimes2 * t;\n out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;\n out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;\n out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;\n return out;\n}\n/**\n * Generates a random vector with the given scale\n *\n * @param {vec3} out the receiving vector\n * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned\n * @returns {vec3} out\n */\n\nexport function random(out, scale) {\n scale = scale || 1.0;\n var r = glMatrix.RANDOM() * 2.0 * Math.PI;\n var z = glMatrix.RANDOM() * 2.0 - 1.0;\n var zScale = Math.sqrt(1.0 - z * z) * scale;\n out[0] = Math.cos(r) * zScale;\n out[1] = Math.sin(r) * zScale;\n out[2] = z * scale;\n return out;\n}\n/**\n * Transforms the vec3 with a mat4.\n * 4th vector component is implicitly '1'\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the vector to transform\n * @param {ReadonlyMat4} m matrix to transform with\n * @returns {vec3} out\n */\n\nexport function transformMat4(out, a, m) {\n var x = a[0],\n y = a[1],\n z = a[2];\n var w = m[3] * x + m[7] * y + m[11] * z + m[15];\n w = w || 1.0;\n out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;\n out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;\n out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;\n return out;\n}\n/**\n * Transforms the vec3 with a mat3.\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the vector to transform\n * @param {ReadonlyMat3} m the 3x3 matrix to transform with\n * @returns {vec3} out\n */\n\nexport function transformMat3(out, a, m) {\n var x = a[0],\n y = a[1],\n z = a[2];\n out[0] = x * m[0] + y * m[3] + z * m[6];\n out[1] = x * m[1] + y * m[4] + z * m[7];\n out[2] = x * m[2] + y * m[5] + z * m[8];\n return out;\n}\n/**\n * Transforms the vec3 with a quat\n * Can also be used for dual quaternions. (Multiply it with the real part)\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the vector to transform\n * @param {ReadonlyQuat} q quaternion to transform with\n * @returns {vec3} out\n */\n\nexport function transformQuat(out, a, q) {\n // benchmarks: https://jsperf.com/quaternion-transform-vec3-implementations-fixed\n var qx = q[0],\n qy = q[1],\n qz = q[2],\n qw = q[3];\n var x = a[0],\n y = a[1],\n z = a[2]; // var qvec = [qx, qy, qz];\n // var uv = vec3.cross([], qvec, a);\n\n var uvx = qy * z - qz * y,\n uvy = qz * x - qx * z,\n uvz = qx * y - qy * x; // var uuv = vec3.cross([], qvec, uv);\n\n var uuvx = qy * uvz - qz * uvy,\n uuvy = qz * uvx - qx * uvz,\n uuvz = qx * uvy - qy * uvx; // vec3.scale(uv, uv, 2 * w);\n\n var w2 = qw * 2;\n uvx *= w2;\n uvy *= w2;\n uvz *= w2; // vec3.scale(uuv, uuv, 2);\n\n uuvx *= 2;\n uuvy *= 2;\n uuvz *= 2; // return vec3.add(out, a, vec3.add(out, uv, uuv));\n\n out[0] = x + uvx + uuvx;\n out[1] = y + uvy + uuvy;\n out[2] = z + uvz + uuvz;\n return out;\n}\n/**\n * Rotate a 3D vector around the x-axis\n * @param {vec3} out The receiving vec3\n * @param {ReadonlyVec3} a The vec3 point to rotate\n * @param {ReadonlyVec3} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @returns {vec3} out\n */\n\nexport function rotateX(out, a, b, rad) {\n var p = [],\n r = []; //Translate point to the origin\n\n p[0] = a[0] - b[0];\n p[1] = a[1] - b[1];\n p[2] = a[2] - b[2]; //perform rotation\n\n r[0] = p[0];\n r[1] = p[1] * Math.cos(rad) - p[2] * Math.sin(rad);\n r[2] = p[1] * Math.sin(rad) + p[2] * Math.cos(rad); //translate to correct position\n\n out[0] = r[0] + b[0];\n out[1] = r[1] + b[1];\n out[2] = r[2] + b[2];\n return out;\n}\n/**\n * Rotate a 3D vector around the y-axis\n * @param {vec3} out The receiving vec3\n * @param {ReadonlyVec3} a The vec3 point to rotate\n * @param {ReadonlyVec3} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @returns {vec3} out\n */\n\nexport function rotateY(out, a, b, rad) {\n var p = [],\n r = []; //Translate point to the origin\n\n p[0] = a[0] - b[0];\n p[1] = a[1] - b[1];\n p[2] = a[2] - b[2]; //perform rotation\n\n r[0] = p[2] * Math.sin(rad) + p[0] * Math.cos(rad);\n r[1] = p[1];\n r[2] = p[2] * Math.cos(rad) - p[0] * Math.sin(rad); //translate to correct position\n\n out[0] = r[0] + b[0];\n out[1] = r[1] + b[1];\n out[2] = r[2] + b[2];\n return out;\n}\n/**\n * Rotate a 3D vector around the z-axis\n * @param {vec3} out The receiving vec3\n * @param {ReadonlyVec3} a The vec3 point to rotate\n * @param {ReadonlyVec3} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @returns {vec3} out\n */\n\nexport function rotateZ(out, a, b, rad) {\n var p = [],\n r = []; //Translate point to the origin\n\n p[0] = a[0] - b[0];\n p[1] = a[1] - b[1];\n p[2] = a[2] - b[2]; //perform rotation\n\n r[0] = p[0] * Math.cos(rad) - p[1] * Math.sin(rad);\n r[1] = p[0] * Math.sin(rad) + p[1] * Math.cos(rad);\n r[2] = p[2]; //translate to correct position\n\n out[0] = r[0] + b[0];\n out[1] = r[1] + b[1];\n out[2] = r[2] + b[2];\n return out;\n}\n/**\n * Get the angle between two 3D vectors\n * @param {ReadonlyVec3} a The first operand\n * @param {ReadonlyVec3} b The second operand\n * @returns {Number} The angle in radians\n */\n\nexport function angle(a, b) {\n var ax = a[0],\n ay = a[1],\n az = a[2],\n bx = b[0],\n by = b[1],\n bz = b[2],\n mag1 = Math.sqrt(ax * ax + ay * ay + az * az),\n mag2 = Math.sqrt(bx * bx + by * by + bz * bz),\n mag = mag1 * mag2,\n cosine = mag && dot(a, b) / mag;\n return Math.acos(Math.min(Math.max(cosine, -1), 1));\n}\n/**\n * Set the components of a vec3 to zero\n *\n * @param {vec3} out the receiving vector\n * @returns {vec3} out\n */\n\nexport function zero(out) {\n out[0] = 0.0;\n out[1] = 0.0;\n out[2] = 0.0;\n return out;\n}\n/**\n * Returns a string representation of a vector\n *\n * @param {ReadonlyVec3} a vector to represent as a string\n * @returns {String} string representation of the vector\n */\n\nexport function str(a) {\n return \"vec3(\" + a[0] + \", \" + a[1] + \", \" + a[2] + \")\";\n}\n/**\n * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)\n *\n * @param {ReadonlyVec3} a The first vector.\n * @param {ReadonlyVec3} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\n\nexport function exactEquals(a, b) {\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];\n}\n/**\n * Returns whether or not the vectors have approximately the same elements in the same position.\n *\n * @param {ReadonlyVec3} a The first vector.\n * @param {ReadonlyVec3} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\n\nexport function equals(a, b) {\n var a0 = a[0],\n a1 = a[1],\n a2 = a[2];\n var b0 = b[0],\n b1 = b[1],\n b2 = b[2];\n return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2));\n}\n/**\n * Alias for {@link vec3.subtract}\n * @function\n */\n\nexport var sub = subtract;\n/**\n * Alias for {@link vec3.multiply}\n * @function\n */\n\nexport var mul = multiply;\n/**\n * Alias for {@link vec3.divide}\n * @function\n */\n\nexport var div = divide;\n/**\n * Alias for {@link vec3.distance}\n * @function\n */\n\nexport var dist = distance;\n/**\n * Alias for {@link vec3.squaredDistance}\n * @function\n */\n\nexport var sqrDist = squaredDistance;\n/**\n * Alias for {@link vec3.length}\n * @function\n */\n\nexport var len = length;\n/**\n * Alias for {@link vec3.squaredLength}\n * @function\n */\n\nexport var sqrLen = squaredLength;\n/**\n * Perform some operation over an array of vec3s.\n *\n * @param {Array} a the array of vectors to iterate over\n * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed\n * @param {Number} offset Number of elements to skip at the beginning of the array\n * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array\n * @param {Function} fn Function to call for each vector in the array\n * @param {Object} [arg] additional argument to pass to fn\n * @returns {Array} a\n * @function\n */\n\nexport var forEach = function () {\n var vec = create();\n return function (a, stride, offset, count, fn, arg) {\n var i, l;\n\n if (!stride) {\n stride = 3;\n }\n\n if (!offset) {\n offset = 0;\n }\n\n if (count) {\n l = Math.min(count * stride + offset, a.length);\n } else {\n l = a.length;\n }\n\n for (i = offset; i < l; i += stride) {\n vec[0] = a[i];\n vec[1] = a[i + 1];\n vec[2] = a[i + 2];\n fn(vec, vec, arg);\n a[i] = vec[0];\n a[i + 1] = vec[1];\n a[i + 2] = vec[2];\n }\n\n return a;\n };\n}();","import { ext, mat3, vec3 } from '@antv/matrix-util';\nimport { assign } from '@antv/util';\nimport { CoordinateCfg, ICoordinate, Point, Range } from '../interface';\n\nexport type CoordinateCtor = new (cfg: any) => Coordinate;\nexport type Vector2 = [number, number];\nexport type Vector3 = [number, number, number];\nexport type Matrix3 = [number, number, number, number, number, number, number, number, number];\n\n/**\n * Coordinate Base Class\n */\nexport default abstract class Coordinate implements ICoordinate {\n // 自身属性\n public readonly type: string = 'coordinate';\n public readonly isRect: boolean = false;\n public readonly isHelix: boolean = false;\n public readonly isPolar: boolean = false;\n\n // 外部属性\n public start: Point;\n public end: Point;\n public matrix: Matrix3;\n public isTransposed: boolean;\n\n // 极坐标下的属性\n public startAngle: number;\n public endAngle: number;\n public innerRadius: number;\n public radius: number;\n\n public x: Range;\n public y: Range;\n\n // 计算属性,通过相应的 get 方法获取,所以使用 protected 访问修饰符\n protected center: Point;\n protected width: number;\n protected height: number;\n private isReflectX = false;\n private isReflectY = false;\n // 初始构造时候的 matrix,存储起来用于 reset\n private originalMatrix: Matrix3;\n\n constructor(cfg: CoordinateCfg) {\n const { start, end, matrix = [1, 0, 0, 0, 1, 0, 0, 0, 1], isTransposed = false } = cfg;\n this.start = start;\n this.end = end;\n this.matrix = matrix as Matrix3;\n this.originalMatrix = [...matrix] as Matrix3; // 去除引用\n this.isTransposed = isTransposed;\n }\n\n /**\n * 初始化流程\n */\n public initial() {\n // center、width、height\n this.center = {\n x: (this.start.x + this.end.x) / 2,\n y: (this.start.y + this.end.y) / 2,\n };\n\n this.width = Math.abs(this.end.x - this.start.x);\n this.height = Math.abs(this.end.y - this.start.y);\n }\n\n /**\n * 更新配置\n * @param cfg\n */\n public update(cfg: CoordinateCfg) {\n assign(this, cfg);\n this.initial();\n }\n\n public convertDim(percent: number, dim: string): number {\n let { start, end } = this[dim];\n\n // 交换\n if (this.isReflect(dim)) {\n [start, end] = [end, start];\n }\n\n return start + percent * (end - start);\n }\n\n public invertDim(value: number, dim: string): number {\n let { start, end } = this[dim];\n // 交换\n if (this.isReflect(dim)) {\n [start, end] = [end, start];\n }\n\n return (value - start) / (end - start);\n }\n\n /**\n * 将坐标点进行矩阵变换\n * @param x 对应 x 轴画布坐标\n * @param y 对应 y 轴画布坐标\n * @param tag 默认为 0,可取值 0, 1\n * @return 返回变换后的三阶向量 [x, y, z]\n */\n public applyMatrix(x: number, y: number, tag: number = 0): number[] {\n const matrix = this.matrix;\n const vector: Vector3 = [x, y, tag];\n vec3.transformMat3(vector, vector, matrix);\n return vector;\n }\n\n /**\n * 将坐标点进行矩阵逆变换\n * @param x 对应 x 轴画布坐标\n * @param y 对应 y 轴画布坐标\n * @param tag 默认为 0,可取值 0, 1\n * @return 返回矩阵逆变换后的三阶向量 [x, y, z]\n */\n public invertMatrix(x: number, y: number, tag: number = 0): number[] {\n const matrix = this.matrix;\n const inverted = mat3.invert([0, 0, 0, 0, 0, 0, 0, 0, 0], matrix);\n const vector: Vector3 = [x, y, tag];\n if (inverted) {\n // 如果为空则不进行矩阵变化,防止报错\n vec3.transformMat3(vector, vector, inverted);\n }\n return vector;\n }\n\n /**\n * 将归一化的坐标点数据转换为画布坐标,并根据坐标系当前矩阵进行变换\n * @param point 归一化的坐标点\n * @return 返回进行矩阵变换后的画布坐标\n */\n public convert(point: Point): Point {\n const { x, y } = this.convertPoint(point);\n const vector = this.applyMatrix(x, y, 1);\n return {\n x: vector[0],\n y: vector[1],\n };\n }\n\n /**\n * 将进行过矩阵变换画布坐标转换为归一化坐标\n * @param point 画布坐标\n * @return 返回归一化的坐标点\n */\n public invert(point: Point): Point {\n const vector = this.invertMatrix(point.x, point.y, 1);\n return this.invertPoint({\n x: vector[0],\n y: vector[1],\n });\n }\n\n /**\n * 坐标系旋转变换\n * @param radian 旋转弧度\n * @return 返回坐标系对象\n */\n public rotate(radian: number) {\n const matrix = this.matrix;\n const center = this.center;\n ext.leftTranslate(matrix, matrix, [-center.x, -center.y]);\n ext.leftRotate(matrix, matrix, radian);\n ext.leftTranslate(matrix, matrix, [center.x, center.y]);\n return this;\n }\n\n /**\n * 坐标系反射变换\n * @param dim 反射维度\n * @return 返回坐标系对象\n */\n public reflect(dim: string) {\n if (dim === 'x') {\n this.isReflectX = !this.isReflectX;\n } else {\n this.isReflectY = !this.isReflectY;\n }\n return this;\n }\n\n /**\n * 坐标系比例变换\n * @param s1 x 方向缩放比例\n * @param s2 y 方向缩放比例\n * @return 返回坐标系对象\n */\n public scale(s1: number, s2: number) {\n const matrix = this.matrix;\n const center = this.center;\n ext.leftTranslate(matrix, matrix, [-center.x, -center.y]);\n ext.leftScale(matrix, matrix, [s1, s2]);\n ext.leftTranslate(matrix, matrix, [center.x, center.y]);\n return this;\n }\n\n /**\n * 坐标系平移变换\n * @param x x 方向平移像素\n * @param y y 方向平移像素\n * @return 返回坐标系对象\n */\n public translate(x: number, y: number) {\n const matrix = this.matrix;\n ext.leftTranslate(matrix, matrix, [x, y]);\n return this;\n }\n\n /**\n * 将坐标系 x y 两个轴进行转置\n * @return 返回坐标系对象\n */\n public transpose() {\n this.isTransposed = !this.isTransposed;\n return this;\n }\n\n public getCenter(): Point {\n return this.center;\n }\n\n public getWidth(): number {\n return this.width;\n }\n\n public getHeight(): number {\n return this.height;\n }\n\n public getRadius(): number {\n return this.radius;\n }\n\n /**\n * whether has reflect\n * @param dim\n */\n public isReflect(dim: string): boolean {\n return dim === 'x' ? this.isReflectX : this.isReflectY;\n }\n\n /**\n * 重置 matrix\n * @param matrix 如果传入,则使用,否则使用构造函数中传入的默认 matrix\n */\n public resetMatrix(matrix?: Matrix3) {\n // 去除引用关系\n this.matrix = matrix ? matrix : ([...this.originalMatrix] as Matrix3);\n }\n\n /**\n * 将归一化的坐标点数据转换为画布坐标\n * @param point\n */\n public abstract convertPoint(point: Point): Point;\n\n /**\n * 画布坐标转换为归一化的坐标点数据\n * @param point\n */\n public abstract invertPoint(point: Point): Point;\n}\n","import { CoordinateCfg, Point } from '../interface';\nimport Coordinate from './base';\n\n/**\n * 笛卡尔坐标系\n * https://www.zhihu.com/question/20665303\n */\nexport default class Cartesian extends Coordinate {\n public readonly isRect: boolean = true;\n public readonly type: string = 'cartesian';\n\n constructor(cfg: CoordinateCfg) {\n super(cfg);\n\n this.initial();\n }\n\n public initial() {\n super.initial();\n\n const start = this.start;\n const end = this.end;\n\n this.x = {\n start: start.x,\n end: end.x,\n };\n this.y = {\n start: start.y,\n end: end.y,\n };\n }\n\n public convertPoint(point: Point) {\n let { x, y } = point;\n\n // 交换\n if (this.isTransposed) {\n [x, y] = [y, x];\n }\n return {\n x: this.convertDim(x, 'x'),\n y: this.convertDim(y, 'y'),\n };\n }\n\n public invertPoint(point: Point) {\n let x = this.invertDim(point.x, 'x');\n let y = this.invertDim(point.y, 'y');\n\n if (this.isTransposed) {\n [x, y] = [y, x];\n }\n\n return { x, y };\n }\n}\n","import { ext, vec2 } from '@antv/matrix-util';\nimport { isNumberEqual } from '@antv/util';\nimport { Point, PolarCfg } from '../interface';\nimport Coordinate, { Vector2 } from './base';\n\n/**\n * 螺旋坐标系\n */\nexport default class Helix extends Coordinate {\n public readonly isHelix: boolean = true;\n public readonly type: string = 'helix';\n\n // 螺线系数\n private a: number;\n private d: number;\n\n constructor(cfg: PolarCfg) {\n super(cfg);\n\n const { startAngle = 1.25 * Math.PI, endAngle = 7.25 * Math.PI, innerRadius = 0, radius } = cfg;\n\n this.startAngle = startAngle;\n this.endAngle = endAngle;\n this.innerRadius = innerRadius;\n this.radius = radius;\n\n this.initial();\n }\n\n public initial() {\n super.initial();\n\n const index: number = (this.endAngle - this.startAngle) / (2 * Math.PI) + 1; // 螺线圈数\n let maxRadius: number = Math.min(this.width, this.height) / 2;\n\n if (this.radius && this.radius >= 0 && this.radius <= 1) {\n maxRadius = maxRadius * this.radius;\n }\n\n this.d = Math.floor((maxRadius * (1 - this.innerRadius)) / index);\n this.a = this.d / (Math.PI * 2); // 螺线系数\n\n this.x = {\n start: this.startAngle,\n end: this.endAngle,\n };\n this.y = {\n start: this.innerRadius * maxRadius,\n end: this.innerRadius * maxRadius + this.d * 0.99,\n };\n }\n\n /**\n * 将百分比数据变成屏幕坐标\n * @param point 归一化的点坐标\n * @return 返回对应的屏幕坐标\n */\n public convertPoint(point: Point): Point {\n let { x, y } = point;\n if (this.isTransposed) {\n [x, y] = [y, x];\n }\n\n const thi = this.convertDim(x, 'x');\n const r = this.a * thi;\n const newY = this.convertDim(y, 'y');\n\n return {\n x: this.center.x + Math.cos(thi) * (r + newY),\n y: this.center.y + Math.sin(thi) * (r + newY),\n };\n }\n\n /**\n * 将屏幕坐标点还原成百分比数据\n * @param point 屏幕坐标\n * @return 返回对应的归一化后的数据\n */\n public invertPoint(point: Point): Point {\n const d = this.d + this.y.start;\n\n const v = vec2.subtract([0, 0], [point.x, point.y], [this.center.x, this.center.y]) as Vector2;\n\n let thi = ext.angleTo(v, [1, 0], true);\n let rMin = thi * this.a; // 坐标与原点的连线在第一圈上的交点,最小r值\n\n if (vec2.length(v) < rMin) {\n // 坐标与原点的连线不可能小于最小r值,但不排除因小数计算产生的略小于rMin的情况\n rMin = vec2.length(v);\n }\n\n const index = Math.floor((vec2.length(v) - rMin) / d); // 当前点位于第index圈\n thi = 2 * index * Math.PI + thi;\n const r = this.a * thi;\n let newY = vec2.length(v) - r;\n newY = isNumberEqual(newY, 0) ? 0 : newY;\n\n let x = this.invertDim(thi, 'x');\n let y = this.invertDim(newY, 'y');\n x = isNumberEqual(x, 0) ? 0 : x;\n y = isNumberEqual(y, 0) ? 0 : y;\n\n if (this.isTransposed) {\n [x, y] = [y, x];\n }\n\n return { x, y };\n }\n}\n","import { ext, vec2, vec3 } from '@antv/matrix-util';\nimport { isNumberEqual } from '@antv/util';\nimport { Point, PolarCfg } from '../interface';\nimport Coordinate, { Matrix3, Vector2, Vector3 } from './base';\n\nexport default class Polar extends Coordinate {\n public readonly isPolar: boolean = true;\n public readonly type: string = 'polar';\n\n public circleCenter: Point;\n\n // 极坐标的半径值,区别于用户设置的归一化 radius\n private polarRadius: number;\n\n constructor(cfg: PolarCfg) {\n super(cfg);\n\n const { startAngle = -Math.PI / 2, endAngle = (Math.PI * 3) / 2, innerRadius = 0, radius } = cfg;\n this.startAngle = startAngle;\n this.endAngle = endAngle;\n this.innerRadius = innerRadius;\n this.radius = radius;\n\n this.initial();\n }\n\n public initial() {\n super.initial();\n\n while (this.endAngle < this.startAngle) {\n this.endAngle += Math.PI * 2;\n }\n\n const oneBox = this.getOneBox();\n\n const oneWidth = oneBox.maxX - oneBox.minX;\n const oneHeight = oneBox.maxY - oneBox.minY;\n\n const left = Math.abs(oneBox.minX) / oneWidth;\n const top = Math.abs(oneBox.minY) / oneHeight;\n\n let maxRadius: number;\n\n if (this.height / oneHeight > this.width / oneWidth) {\n // width 为主\n maxRadius = this.width / oneWidth;\n this.circleCenter = {\n x: this.center.x - (0.5 - left) * this.width,\n y: this.center.y - (0.5 - top) * maxRadius * oneHeight,\n };\n } else {\n // height 为主\n maxRadius = this.height / oneHeight;\n this.circleCenter = {\n x: this.center.x - (0.5 - left) * maxRadius * oneWidth,\n y: this.center.y - (0.5 - top) * this.height,\n };\n }\n\n this.polarRadius = this.radius;\n if (!this.radius) {\n this.polarRadius = maxRadius;\n } else if (this.radius > 0 && this.radius <= 1) {\n this.polarRadius = maxRadius * this.radius;\n } else if (this.radius <= 0 || this.radius > maxRadius) {\n this.polarRadius = maxRadius;\n }\n\n this.x = {\n start: this.startAngle,\n end: this.endAngle,\n };\n\n this.y = {\n start: this.innerRadius * this.polarRadius,\n end: this.polarRadius,\n };\n }\n\n public getRadius() {\n return this.polarRadius;\n }\n\n public convertPoint(point: Point): Point {\n const center = this.getCenter();\n\n let { x, y } = point;\n\n if (this.isTransposed) {\n [x, y] = [y, x];\n }\n\n x = this.convertDim(x, 'x');\n y = this.convertDim(y, 'y');\n\n return {\n x: center.x + Math.cos(x) * y,\n y: center.y + Math.sin(x) * y,\n };\n }\n\n public invertPoint(point: Point): Point {\n const center = this.getCenter();\n const vPoint: Vector2 = [point.x - center.x, point.y - center.y];\n\n let { startAngle, endAngle } = this;\n if (this.isReflect('x')) {\n [startAngle, endAngle] = [endAngle, startAngle];\n }\n\n const m: Matrix3 = [1, 0, 0, 0, 1, 0, 0, 0, 1];\n ext.leftRotate(m, m, startAngle);\n\n const vStart3: Vector3 = [1, 0, 0];\n vec3.transformMat3(vStart3, vStart3, m);\n const vStart2: Vector2 = [vStart3[0], vStart3[1]];\n let angle = ext.angleTo(vStart2, vPoint, endAngle < startAngle);\n if (isNumberEqual(angle, Math.PI * 2)) {\n angle = 0;\n }\n const radius = vec2.length(vPoint);\n\n let xPercent = angle / (endAngle - startAngle);\n xPercent = endAngle - startAngle > 0 ? xPercent : -xPercent;\n\n const yPercent = this.invertDim(radius, 'y');\n const rst = { x: 0, y: 0 };\n rst.x = this.isTransposed ? yPercent : xPercent;\n rst.y = this.isTransposed ? xPercent : yPercent;\n return rst;\n }\n\n public getCenter() {\n return this.circleCenter;\n }\n\n private getOneBox() {\n const startAngle = this.startAngle;\n const endAngle = this.endAngle;\n if (Math.abs(endAngle - startAngle) >= Math.PI * 2) {\n return {\n minX: -1,\n maxX: 1,\n minY: -1,\n maxY: 1,\n };\n }\n const xs = [0, Math.cos(startAngle), Math.cos(endAngle)];\n const ys = [0, Math.sin(startAngle), Math.sin(endAngle)];\n\n for (let i = Math.min(startAngle, endAngle); i < Math.max(startAngle, endAngle); i += Math.PI / 18) {\n xs.push(Math.cos(i));\n ys.push(Math.sin(i));\n }\n\n return {\n minX: Math.min(...xs),\n maxX: Math.max(...xs),\n minY: Math.min(...ys),\n maxY: Math.max(...ys),\n };\n }\n}\n","import { CoordinateCtor } from './coord/base';\n\n// 所有的 Coordinate map\nconst COORDINATE_MAP: Record = {};\n\n/**\n * 通过类型获得 coordinate 类\n * @param type\n */\nexport const getCoordinate = (type: string): CoordinateCtor => {\n return COORDINATE_MAP[type.toLowerCase()];\n};\n\n/**\n * 注册 coordinate 类\n * @param type\n * @param ctor\n */\nexport const registerCoordinate = (type: string, ctor: CoordinateCtor): void => {\n // 存储到 map 中\n COORDINATE_MAP[type.toLowerCase()] = ctor;\n};\n\nexport * from './interface';\n","import { IGroup } from '@antv/g-base';\nimport { Event as GraphEvent } from '@antv/g-base';\nimport { LooseObject } from '../types';\n\n/**\n *\n * @param group 分组\n * @param eventName 事件名\n * @param eventObject 事件对象\n */\nexport function propagationDelegate(group: IGroup, eventName: string, eventObject: LooseObject) {\n const event = new GraphEvent(eventName, eventObject);\n event.target = group;\n event.propagationPath.push(group); // 从当前 group 开始触发 delegation\n group.emitDelegation(eventName, event);\n let parent = group.getParent() as IGroup;\n // 执行冒泡\n while (parent) {\n // 委托事件要先触发\n parent.emitDelegation(eventName, event);\n event.propagationPath.push(parent);\n parent = parent.getParent() as IGroup;\n }\n}\n","import Coordinate from './coord/base';\nimport Cartesian from './coord/cartesian';\nimport Helix from './coord/helix';\nimport Polar from './coord/polar';\n\nimport { getCoordinate, registerCoordinate } from './factory';\n\nregisterCoordinate('rect', Cartesian);\nregisterCoordinate('cartesian', Cartesian);\nregisterCoordinate('polar', Polar);\nregisterCoordinate('helix', Helix);\n\nexport { getCoordinate, registerCoordinate, Coordinate };\n\nexport { Point, PolarCfg, CoordinateCfg } from './interface';\n","import { IElement } from '@antv/g-base';\nimport { ext, vec2, vec3 } from '@antv/matrix-util';\nimport { BBox, Point } from '../types';\n\nconst identityMatrix = [1, 0, 0, 0, 1, 0, 0, 0, 1];\nexport function getMatrixByAngle(point: Point, angle: number, matrix = identityMatrix): number[] {\n if (!angle) {\n // 角度为 0 或者 null 时返回 null\n return null;\n }\n const m = ext.transform(matrix, [\n ['t', -point.x, -point.y],\n ['r', angle],\n ['t', point.x, point.y],\n ]);\n return m;\n}\n\nexport function getMatrixByTranslate(point: Point, currentMatrix?: number[]): number[] {\n if (!point.x && !point.y) {\n // 0,0 或者 nan 的情况下返回 null\n return null;\n }\n return ext.transform(currentMatrix || identityMatrix, [['t', point.x, point.y]]);\n}\n\n// 从矩阵获取旋转的角度\nexport function getAngleByMatrix(matrix: [\n number, number, number,\n number, number, number,\n number, number, number\n]): number {\n const xVector: [number, number, number] = [1, 0, 0];\n const out: [ number, number, number ] = [0, 0, 0];\n vec3.transformMat3(out, xVector, matrix);\n return Math.atan2(out[1], out[0]);\n}\n// 矩阵 * 向量\nfunction multiplyVec2(matrix, v) {\n const out: [number, number] = [0, 0];\n vec2.transformMat3(out, v, matrix);\n return out;\n}\n\nexport function applyMatrix2BBox(matrix: number[], bbox: BBox) {\n const topLeft = multiplyVec2(matrix, [bbox.minX, bbox.minY]);\n const topRight = multiplyVec2(matrix, [bbox.maxX, bbox.minY]);\n const bottomLeft = multiplyVec2(matrix, [bbox.minX, bbox.maxY]);\n const bottomRight = multiplyVec2(matrix, [bbox.maxX, bbox.maxY]);\n const minX = Math.min(topLeft[0], topRight[0], bottomLeft[0], bottomRight[0]);\n const maxX = Math.max(topLeft[0], topRight[0], bottomLeft[0], bottomRight[0]);\n const minY = Math.min(topLeft[1], topRight[1], bottomLeft[1], bottomRight[1]);\n const maxY = Math.max(topLeft[1], topRight[1], bottomLeft[1], bottomRight[1]);\n return {\n x: minX,\n y: minY,\n minX,\n minY,\n maxX,\n maxY,\n width: maxX - minX,\n height: maxY - minY,\n };\n}\n\nexport function applyRotate(shape: IElement, rotate: number, x: number, y: number) {\n if (rotate) {\n const matrix = getMatrixByAngle({ x, y }, rotate, shape.getMatrix());\n shape.setMatrix(matrix);\n }\n}\n\nexport function applyTranslate(shape: IElement, x: number, y: number) {\n const translateMatrix = getMatrixByTranslate({ x, y });\n shape.attr('matrix', translateMatrix);\n}\n","import { IElement, IGroup } from '@antv/g-base';\nimport { each, isArray, isNil, isNumber } from '@antv/util';\nimport { BBox, Point, Region } from '../types';\n\nexport function formatPadding(padding: number | number[]): number[] {\n let top = 0;\n let left = 0;\n let right = 0;\n let bottom = 0;\n\n if (isNumber(padding)) {\n top = left = right = bottom = padding;\n } else if (isArray(padding)) {\n top = padding[0];\n right = !isNil(padding[1]) ? padding[1] : padding[0];\n bottom = !isNil(padding[2]) ? padding[2] : padding[0];\n left = !isNil(padding[3]) ? padding[3] : right;\n }\n\n return [top, right, bottom, left];\n}\n\nexport function clearDom(container: HTMLElement) {\n const children = container.childNodes;\n const length = children.length;\n for (let i = length - 1; i >= 0; i--) {\n container.removeChild(children[i]);\n }\n}\n\nexport function hasClass(elements, cName): boolean {\n return !!elements.className.match(new RegExp(`(\\\\s|^)${cName}(\\\\s|$)`));\n}\n\nexport function regionToBBox(region: Region): BBox {\n const { start, end } = region;\n const minX = Math.min(start.x, end.x);\n const minY = Math.min(start.y, end.y);\n const maxX = Math.max(start.x, end.x);\n const maxY = Math.max(start.y, end.y);\n return {\n x: minX,\n y: minY,\n minX,\n minY,\n maxX,\n maxY,\n width: maxX - minX,\n height: maxY - minY,\n };\n}\n\nexport function pointsToBBox(points: Point[]): BBox {\n const xs: number[] = points.map((point) => point.x);\n const ys: number[] = points.map((point) => point.y);\n const minX = Math.min(...xs);\n const minY = Math.min(...ys);\n const maxX = Math.max(...xs);\n const maxY = Math.max(...ys);\n return {\n x: minX,\n y: minY,\n minX,\n minY,\n maxX,\n maxY,\n width: maxX - minX,\n height: maxY - minY,\n };\n}\n\nexport function createBBox(x: number, y: number, width: number, height: number): BBox {\n const maxX = x + width;\n const maxY = y + height;\n\n return {\n x,\n y,\n width,\n height,\n minX: x,\n minY: y,\n // 非常奇葩的 js 特性\n // Infinity + Infinity = Infinity\n // Infinity - Infinity = NaN\n // fixed https://github.com/antvis/G2Plot/issues/1243\n maxX: isNaN(maxX) ? 0 : maxX,\n maxY: isNaN(maxY) ? 0 : maxY,\n };\n}\n\nexport function getValueByPercent(min: number, max: number, percent: number) {\n return (1 - percent) * min + max * percent;\n}\n\nexport function getCirclePoint(center: Point, radius: number, angle: number) {\n return {\n x: center.x + Math.cos(angle) * radius,\n y: center.y + Math.sin(angle) * radius,\n };\n}\n\nexport function distance(p1: Point, p2: Point): number {\n const dx = p2.x - p1.x;\n const dy = p2.y - p1.y;\n return Math.sqrt(dx * dx + dy * dy);\n}\n\nexport const wait = (interval: number): Promise => {\n return new Promise((resolve) => {\n setTimeout(resolve, interval);\n });\n};\n\n/**\n * 判断两个数值 是否接近\n * - 解决精度问题(由于无法确定精度上限,根据具体场景可传入 精度 参数)\n */\nexport const near = (x: number, y: number, e = Number.EPSILON ** 0.5): boolean =>\n [x, y].includes(Infinity) ? Math.abs(x) === Math.abs(y) : Math.abs(x - y) < e;\n\nexport function intersectBBox(box1: BBox, box2: BBox): BBox {\n const minX = Math.max(box1.minX, box2.minX);\n const minY = Math.max(box1.minY, box2.minY);\n const maxX = Math.min(box1.maxX, box2.maxX);\n const maxY = Math.min(box1.maxY, box2.maxY);\n return createBBox(minX, minY, maxX - minX, maxY - minY);\n}\n\nexport function mergeBBox(box1: BBox, box2: BBox): BBox {\n const minX = Math.min(box1.minX, box2.minX);\n const minY = Math.min(box1.minY, box2.minY);\n const maxX = Math.max(box1.maxX, box2.maxX);\n const maxY = Math.max(box1.maxY, box2.maxY);\n return createBBox(minX, minY, maxX - minX, maxY - minY);\n}\n\nexport function getBBoxWithClip(element: IElement): BBox {\n const clipShape = element.getClip();\n const clipBBox = clipShape && clipShape.getBBox();\n let bbox;\n if (!element.isGroup()) {\n // 如果是普通的图形\n bbox = element.getBBox();\n } else {\n let minX = Infinity;\n let maxX = -Infinity;\n let minY = Infinity;\n let maxY = -Infinity;\n const children = (element as IGroup).getChildren();\n if (children.length > 0) {\n each(children, (child: IElement) => {\n if (child.get('visible')) {\n // 如果分组没有子元素,则直接跳过\n if (child.isGroup() && child.get('children').length === 0) {\n return true;\n }\n const box = getBBoxWithClip(child);\n // 计算 4 个顶点\n const leftTop = child.applyToMatrix([box.minX, box.minY, 1]);\n const leftBottom = child.applyToMatrix([box.minX, box.maxY, 1]);\n const rightTop = child.applyToMatrix([box.maxX, box.minY, 1]);\n const rightBottom = child.applyToMatrix([box.maxX, box.maxY, 1]);\n // 从中取最小的范围\n const boxMinX = Math.min(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0]);\n const boxMaxX = Math.max(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0]);\n const boxMinY = Math.min(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1]);\n const boxMaxY = Math.max(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1]);\n\n if (boxMinX < minX) {\n minX = boxMinX;\n }\n\n if (boxMaxX > maxX) {\n maxX = boxMaxX;\n }\n\n if (boxMinY < minY) {\n minY = boxMinY;\n }\n\n if (boxMaxY > maxY) {\n maxY = boxMaxY;\n }\n }\n });\n } else {\n minX = 0;\n maxX = 0;\n minY = 0;\n maxY = 0;\n }\n bbox = createBBox(minX, minY, maxX - minX, maxY - minY);\n }\n if (clipBBox) {\n return intersectBBox(bbox, clipBBox);\n } else {\n return bbox;\n }\n}\n\nexport function updateClip(element: IElement, newElement: IElement) {\n if (!element.getClip() && !newElement.getClip()) {\n // 两者都没有 clip\n return;\n }\n const newClipShape = newElement.getClip();\n if (!newClipShape) {\n // 新的 element 没有 clip\n element.setClip(null); // 移除 clip\n return;\n }\n const clipCfg = {\n type: newClipShape.get('type'),\n attrs: newClipShape.attr(),\n };\n element.setClip(clipCfg);\n}\n\nexport function toPx(number) {\n return `${number}px`;\n}\n\nexport function getTextPoint(start: Point, end: Point, position: string, offset: number): Point {\n const lineLength = distance(start, end);\n const offsetPercent = offset / lineLength; // 计算间距同线的比例,用于计算最终的位置\n let percent = 0;\n if (position === 'start') {\n percent = 0 - offsetPercent;\n } else if (position === 'end') {\n percent = 1 + offsetPercent;\n }\n return {\n x: getValueByPercent(start.x, end.x, percent),\n y: getValueByPercent(start.y, end.y, percent),\n };\n}\n","import { Base } from '@antv/g-base';\nimport { deepMix, each, hasKey, isObject } from '@antv/util';\nimport { ILocation } from '../interfaces';\nimport { BBox, ComponentCfg, LocationCfg, OffsetPoint } from '../types';\nconst LOCATION_FIELD_MAP = {\n none: [],\n point: ['x', 'y'],\n region: ['start', 'end'],\n points: ['points'],\n circle: ['center', 'radius', 'startAngle', 'endAngle'],\n};\n\nabstract class Component extends Base implements ILocation {\n constructor(cfg: T) {\n super(cfg);\n this.initCfg();\n }\n /**\n * @protected\n * 默认的配置项\n * @returns {object} 默认的配置项\n */\n public getDefaultCfg() {\n return {\n id: '',\n name: '',\n type: '',\n locationType: 'none',\n offsetX: 0,\n offsetY: 0,\n animate: false,\n capture: true,\n updateAutoRender: false,\n animateOption: {\n appear: null, // 初始入场动画配置\n update: {\n duration: 400,\n easing: 'easeQuadInOut',\n }, // 更新时发生变更的动画配置\n enter: {\n duration: 400,\n easing: 'easeQuadInOut',\n }, // 更新时新增元素的入场动画配置\n leave: {\n duration: 350,\n easing: 'easeQuadIn',\n }, // 更新时销毁动画配置\n },\n events: null,\n defaultCfg: {},\n visible: true,\n };\n }\n\n /**\n * 清理组件的内容,一般配合 render 使用\n * @example\n * axis.clear();\n * axis.render();\n */\n public clear() {}\n\n /**\n * 更新组件\n * @param {object} cfg 更新属性\n */\n public update(cfg: Partial) {\n const defaultCfg = this.get('defaultCfg') || {};\n each(cfg, (value, name) => {\n const originCfg = this.get(name);\n let newCfg = value;\n if (originCfg !== value) {\n // 判断两者是否相等,主要是进行 null 的判定\n if (isObject(value) && defaultCfg[name]) {\n // 新设置的属性与默认值进行合并\n newCfg = deepMix({}, defaultCfg[name], value);\n }\n this.set(name, newCfg);\n }\n });\n this.updateInner(cfg);\n this.afterUpdate(cfg);\n }\n // 更新内部\n protected updateInner(cfg: Partial) {\n\n }\n\n protected afterUpdate(cfg: Partial) {\n // 更新时考虑显示、隐藏\n if (hasKey(cfg, 'visible')) {\n if (cfg.visible) {\n this.show();\n } else {\n this.hide();\n }\n }\n // 更新时考虑capture\n if (hasKey(cfg, 'capture')) {\n this.setCapture(cfg.capture);\n }\n }\n\n public abstract getBBox(): BBox;\n\n public getLayoutBBox(): BBox {\n return this.getBBox(); // 默认返回 getBBox,不同的组件内部单独实现\n }\n\n public getLocationType() {\n return this.get('locationType');\n }\n\n public getOffset(): OffsetPoint {\n return {\n offsetX: this.get('offsetX'),\n offsetY: this.get('offsetY'),\n };\n }\n\n // 默认使用 update\n public setOffset(offsetX: number, offsetY: number) {\n this.update({\n offsetX,\n offsetY,\n } as T);\n }\n\n public setLocation(cfg: LocationCfg) {\n const location = { ...cfg } as Partial;\n this.update(location);\n }\n\n // 实现 ILocation 接口的 getLocation\n public getLocation(): LocationCfg {\n const location = {} as LocationCfg;\n const locationType = this.get('locationType');\n const fields = LOCATION_FIELD_MAP[locationType];\n each(fields, (field) => {\n location[field] = this.get(field);\n });\n return location;\n }\n\n public isList(): boolean {\n return false;\n }\n\n public isSlider(): boolean {\n return false;\n }\n\n /**\n * @protected\n * 初始化,用于具体的组件继承\n */\n public init() {}\n\n /**\n * 绘制组件\n */\n public abstract render();\n\n /**\n * 显示\n */\n public abstract show();\n\n public abstract setCapture(capture: boolean);\n\n /**\n * 隐藏\n */\n public abstract hide();\n\n // 将组件默认的配置项设置合并到传入的配置项\n private initCfg() {\n const defaultCfg = this.get('defaultCfg');\n each(defaultCfg, (value, name) => {\n const cfg = this.get(name);\n if (isObject(cfg)) {\n const newCfg = deepMix({}, value, cfg);\n this.set(name, newCfg);\n }\n });\n }\n}\n\nexport default Component;\n","/**\n * @fileoverview 使用 G.Group 的组件\n * @author dxq613@gmail.com\n */\nimport { IElement, IGroup, IShape } from '@antv/g-base';\nimport { difference, each, isNil, keys, mix, pick } from '@antv/util';\nimport { BBox, GroupComponentCfg, LooseObject, Point } from '../types';\nimport { propagationDelegate } from '../util/event';\nimport { applyMatrix2BBox, getMatrixByTranslate } from '../util/matrix';\nimport { getBBoxWithClip, updateClip } from '../util/util';\nimport Component from './component';\ntype Callback = (evt: object) => void;\n\nconst STATUS_UPDATE = 'update_status';\nconst COPY_PROPERTIES = ['visible', 'tip', 'delegateObject']; // 更新对象时需要复制的属性\nconst COPY_PROPERTIES_EXCLUDES = ['container', 'group', 'shapesMap', 'isRegister', 'isUpdating', 'destroyed']; // 更新子组件时排除的属性\n\nexport type GroupComponentCtor<\n C extends GroupComponentCfg = GroupComponentCfg,\n T extends GroupComponent = GroupComponent\n> = new (cfg: C) => T;\n\nabstract class GroupComponent extends Component {\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n container: null,\n /**\n * @private\n * 缓存图形的 Map\n */\n shapesMap: {},\n group: null,\n capture: true,\n /**\n * @private 组件或者图形是否允许注册\n * @type {false}\n */\n isRegister: false,\n /**\n * @private 是否正在更新\n * @type {false}\n */\n isUpdating: false,\n /**\n * @private\n * 是否初始状态,一旦 render,update 后,这个状态就变成 false, clear 后恢复\n */\n isInit: true,\n };\n }\n\n public remove() {\n this.clear();\n const group = this.get('group');\n group.remove();\n }\n\n public clear() {\n const group = this.get('group');\n group.clear();\n this.set('shapesMap', {});\n this.clearOffScreenCache();\n this.set('isInit', true);\n }\n\n public getChildComponentById(id: string) {\n const group = this.getElementById(id);\n const inst = group && group.get('component');\n return inst;\n }\n\n public getElementById(id: string) {\n return this.get('shapesMap')[id];\n }\n\n public getElementByLocalId(localId) {\n const id = this.getElementId(localId);\n return this.getElementById(id);\n }\n\n public getElementsByName(name: string) {\n const rst = [];\n each(this.get('shapesMap'), (elem) => {\n if (elem.get('name') === name) {\n rst.push(elem);\n }\n });\n\n return rst;\n }\n\n public getContainer(): IGroup {\n return this.get('container') as IGroup;\n }\n\n public updateInner(cfg: Partial) {\n // this.updateInner();\n // this.set('isUpdating', false);\n this.offScreenRender();\n if (this.get('updateAutoRender')) {\n this.render();\n }\n }\n\n public render() {\n let offScreenGroup = this.get('offScreenGroup');\n if (!offScreenGroup) {\n offScreenGroup = this.offScreenRender();\n }\n const group = this.get('group');\n this.updateElements(offScreenGroup, group);\n this.deleteElements();\n this.applyOffset();\n if (!this.get('eventInitted')) {\n this.initEvent();\n this.set('eventInitted', true);\n }\n this.set('isInit', false);\n }\n\n public show() {\n const group = this.get('group');\n group.show();\n this.set('visible', true);\n }\n\n public hide() {\n const group = this.get('group');\n group.hide();\n this.set('visible', false);\n }\n\n public setCapture(capture) {\n const group = this.get('group');\n group.set('capture', capture);\n this.set('capture', capture);\n }\n\n public destroy() {\n this.removeEvent();\n this.remove();\n super.destroy();\n }\n\n public getBBox(): BBox {\n return this.get('group').getCanvasBBox();\n }\n\n public getLayoutBBox(): BBox {\n const group = this.get('group');\n // 防止被 clear 了,offScreenBBox 不存在\n let bbox = this.getInnerLayoutBBox();\n const matrix = group.getTotalMatrix();\n if (matrix) {\n bbox = applyMatrix2BBox(matrix, bbox);\n }\n return bbox; // 默认返回 getBBox,不同的组件内部单独实现\n }\n\n // 复写 on, off, emit 透传到 group\n public on(evt: string, callback: Callback, once?: boolean): this {\n const group = this.get('group');\n group.on(evt, callback, once);\n return this;\n }\n\n public off(evt?: string, callback?: Callback): this {\n const group = this.get('group');\n group && group.off(evt, callback);\n return this;\n }\n\n public emit(eventName: string, eventObject: LooseObject) {\n const group = this.get('group');\n group.emit(eventName, eventObject);\n }\n\n public init() {\n super.init();\n if (!this.get('group')) {\n this.initGroup();\n }\n this.offScreenRender(); // 绘制离屏 group\n }\n\n // 获取组件内部布局占的包围盒\n protected getInnerLayoutBBox() {\n return this.get('offScreenBBox') || this.get('group').getBBox();\n }\n\n // 抛出委托对象\n protected delegateEmit(eventName: string, eventObject: LooseObject) {\n const group = this.get('group');\n eventObject.target = group;\n group.emit(eventName, eventObject);\n propagationDelegate(group, eventName, eventObject);\n }\n // 创建离屏的 group ,不添加在 canvas 中\n protected createOffScreenGroup() {\n const group = this.get('group');\n const GroupClass = group.getGroupBase(); // 获取分组的构造函数\n const newGroup = new GroupClass({\n delegateObject: this.getDelegateObject(), // 生成委托事件触发时附加的对象\n });\n return newGroup;\n }\n\n // 应用 offset\n protected applyOffset() {\n const offsetX = this.get('offsetX');\n const offsetY = this.get('offsetY');\n this.moveElementTo(this.get('group'), {\n x: offsetX,\n y: offsetY,\n });\n }\n\n protected initGroup() {\n const container = this.get('container');\n this.set(\n 'group',\n container.addGroup({\n id: this.get('id'),\n name: this.get('name'),\n capture: this.get('capture'),\n visible: this.get('visible'),\n isComponent: true,\n component: this,\n delegateObject: this.getDelegateObject(),\n })\n );\n }\n\n // 离屏渲染\n protected offScreenRender() {\n this.clearOffScreenCache();\n const offScreenGroup = this.createOffScreenGroup();\n\n this.renderInner(offScreenGroup);\n this.set('offScreenGroup', offScreenGroup);\n // 包含包围盒的 bbox\n this.set('offScreenBBox', getBBoxWithClip(offScreenGroup));\n return offScreenGroup;\n }\n\n /**\n * @protected\n * 在组件上添加分组,主要解决 isReigeter 的问题\n * @param {IGroup} parent 父元素\n * @param {object} cfg 分组的配置项\n */\n protected addGroup(parent: IGroup, cfg) {\n this.appendDelegateObject(parent, cfg);\n const group = parent.addGroup(cfg);\n if (this.get('isRegister')) {\n this.registerElement(group);\n }\n return group;\n }\n\n /**\n * @protected\n * 在组件上添加图形,主要解决 isReigeter 的问题\n * @param {IGroup} parent 父元素\n * @param {object} cfg 分组的配置项\n */\n protected addShape(parent: IGroup, cfg) {\n this.appendDelegateObject(parent, cfg);\n const shape = parent.addShape(cfg);\n if (this.get('isRegister')) {\n this.registerElement(shape);\n }\n return shape;\n }\n\n /**\n * 在组件上添加子组件\n *\n * @param parent 父元素\n * @param cfg 子组件配置项\n */\n protected addComponent(\n parent: IGroup,\n cfg: Omit & { component: GroupComponentCtor }\n ) {\n const { id, component: Ctor, ...restCfg } = cfg;\n // @ts-ignore\n const inst: CT = new Ctor({\n ...restCfg,\n id,\n container: parent,\n updateAutoRender: this.get('updateAutoRender'),\n });\n inst.init();\n inst.render();\n\n if (this.get('isRegister')) {\n this.registerElement(inst.get('group'));\n }\n\n return inst;\n }\n\n protected initEvent() {}\n\n protected removeEvent() {\n const group = this.get('group');\n group.off();\n }\n\n protected getElementId(localId: string) {\n const id = this.get('id'); // 组件的 Id\n const name = this.get('name'); // 组件的名称\n return `${id}-${name}-${localId}`;\n }\n\n protected registerElement(element) {\n const id = element.get('id');\n this.get('shapesMap')[id] = element;\n }\n\n protected unregisterElement(element) {\n const id = element.get('id');\n delete this.get('shapesMap')[id];\n }\n\n // 移动元素\n protected moveElementTo(element: IElement, point: Point) {\n const matrix = getMatrixByTranslate(point);\n element.attr('matrix', matrix);\n }\n\n /**\n * 内部的渲染\n * @param {IGroup} group 图形分组\n */\n protected abstract renderInner(group: IGroup);\n\n /**\n * 图形元素新出现时的动画,默认图形从透明度 0 到当前透明度\n * @protected\n * @param {string} elmentName 图形元素名称\n * @param {IElement} newElement 新的图形元素\n * @param {object} animateCfg 动画的配置项\n */\n protected addAnimation(elmentName, newElement, animateCfg) {\n // 缓存透明度\n let originOpacity = newElement.attr('opacity');\n if (isNil(originOpacity)) {\n originOpacity = 1;\n }\n newElement.attr('opacity', 0);\n newElement.animate({ opacity: originOpacity }, animateCfg);\n }\n\n /**\n * 图形元素新出现时的动画,默认图形从透明度 0 到当前透明度\n * @protected\n * @param {string} elmentName 图形元素名称\n * @param {IElement} originElement 要删除的图形元素\n * @param {object} animateCfg 动画的配置项\n */\n protected removeAnimation(elementName, originElement, animateCfg) {\n originElement.animate({ opacity: 0 }, animateCfg);\n }\n\n /**\n * 图形元素的更新动画\n * @param {string} elmentName 图形元素名称\n * @param {IElement} originElement 现有的图形元素\n * @param {object} newAttrs 新的图形元素\n * @param {object} animateCfg 动画的配置项\n */\n protected updateAnimation(elementName, originElement, newAttrs, animateCfg) {\n originElement.animate(newAttrs, animateCfg);\n }\n\n // 更新组件的图形\n protected updateElements(newGroup, originGroup) {\n const animate = this.get('animate');\n const animateOption = this.get('animateOption');\n const children = newGroup.getChildren().slice(0); // 创建一个新数组,防止添加到 originGroup 时, children 变动\n let preElement; // 前面已经匹配到的图形元素,用于\n each(children, (element) => {\n const elementId = element.get('id');\n const originElement = this.getElementById(elementId);\n const elementName = element.get('name');\n if (originElement) {\n if (element.get('isComponent')) {\n // 嵌套子组件更新\n const childComponent = element.get('component');\n const origChildComponent: GroupComponent = originElement.get('component');\n const newCfg = pick(childComponent.cfg, difference(keys(childComponent.cfg), COPY_PROPERTIES_EXCLUDES));\n origChildComponent.update(newCfg);\n originElement.set(STATUS_UPDATE, 'update');\n } else {\n const replaceAttrs = this.getReplaceAttrs(originElement, element);\n // 更新\n if (animate && animateOption.update) {\n // 没有动画\n this.updateAnimation(elementName, originElement, replaceAttrs, animateOption.update);\n } else {\n // originElement.attrs = replaceAttrs; // 直接替换\n originElement.attr(replaceAttrs);\n }\n // 如果是分组,则继续执行\n if (element.isGroup()) {\n this.updateElements(element, originElement);\n }\n // 复制属性\n each(COPY_PROPERTIES, (name) => {\n originElement.set(name, element.get(name));\n });\n updateClip(originElement, element);\n\n preElement = originElement;\n // 执行完更新后设置状态位为更新\n originElement.set(STATUS_UPDATE, 'update');\n }\n } else {\n // 没有对应的图形,则插入当前图形\n originGroup.add(element); // 应该在 group 加个 insertAt 的方法\n const siblings = originGroup.getChildren(); // 兄弟节点\n siblings.splice(siblings.length - 1, 1); // 先从数组中移除,然后放到合适的位置\n if (preElement) {\n // 前面已经有更新的图形或者插入的图形,则在这个图形后面插入\n const index = siblings.indexOf(preElement);\n siblings.splice(index + 1, 0, element); // 在已经更新的图形元素后面插入\n } else {\n siblings.unshift(element);\n }\n this.registerElement(element); // 注册节点\n element.set(STATUS_UPDATE, 'add'); // 执行完更新后设置状态位为添加\n if (element.get('isComponent')) {\n // 直接新增子组件container属性,实例不变\n const childComponent = element.get('component');\n childComponent.set('container', originGroup);\n } else if (element.isGroup()) {\n // 如果元素是新增加的元素,则遍历注册所有的子节点\n this.registerNewGroup(element);\n }\n preElement = element;\n if (animate) {\n const animateCfg = this.get('isInit') ? animateOption.appear : animateOption.enter;\n if (animateCfg) {\n this.addAnimation(elementName, element, animateCfg);\n }\n }\n }\n });\n }\n\n protected clearUpdateStatus(group: IGroup) {\n const children = group.getChildren();\n each(children, (el) => {\n el.set(STATUS_UPDATE, null); // 清理掉更新状态\n });\n }\n\n // 清理离屏缓存\n private clearOffScreenCache() {\n const offScreenGroup = this.get('offScreenGroup');\n if (offScreenGroup) {\n // 销毁原先的离线 Group\n offScreenGroup.destroy();\n }\n this.set('offScreenGroup', null);\n this.set('offScreenBBox', null);\n }\n\n // private updateInner() {\n // const group = this.get('group');\n // const newGroup = this.createOffScreenGroup();\n // this.renderInner(newGroup);\n // this.applyOffset();\n // this.updateElements(newGroup, group);\n // this.deleteElements();\n // newGroup.destroy(); // 销毁虚拟分组\n // }\n\n // 获取发生委托时的对象,在事件中抛出\n private getDelegateObject() {\n const name = this.get('name');\n const delegateObject = {\n [name]: this,\n component: this,\n };\n return delegateObject;\n }\n\n // 附加委托信息,用于事件\n private appendDelegateObject(parent: IGroup, cfg) {\n const parentObject = parent.get('delegateObject');\n if (!cfg.delegateObject) {\n cfg.delegateObject = {};\n }\n mix(cfg.delegateObject, parentObject); // 将父元素上的委托信息复制到自身\n }\n\n // 获取需要替换的属性,如果原先图形元素存在,而新图形不存在,则设置 undefined\n private getReplaceAttrs(originElement: IElement, newElement: IElement) {\n const originAttrs = originElement.attr();\n const newAttrs = newElement.attr();\n each(originAttrs, (v, k) => {\n if (newAttrs[k] === undefined) {\n newAttrs[k] = undefined;\n }\n });\n return newAttrs;\n }\n\n private registerNewGroup(group) {\n const children = group.getChildren();\n each(children, (element) => {\n this.registerElement(element); // 注册节点\n element.set(STATUS_UPDATE, 'add'); // 执行完更新后设置状态位为添加\n if (element.isGroup()) {\n this.registerNewGroup(element);\n }\n });\n }\n\n // 移除多余的元素\n private deleteElements() {\n const shapesMap = this.get('shapesMap');\n const deleteArray = [];\n // 遍历获取需要删除的图形元素\n each(shapesMap, (element, id) => {\n if (!element.get(STATUS_UPDATE) || element.destroyed) {\n deleteArray.push([id, element]);\n } else {\n element.set(STATUS_UPDATE, null); // 清理掉更新状态\n }\n });\n const animate = this.get('animate');\n const animateOption = this.get('animateOption');\n // 删除图形元素\n each(deleteArray, (item) => {\n const [id, element] = item;\n if (!element.destroyed) {\n const elementName = element.get('name');\n if (animate && animateOption.leave) {\n // 需要动画结束时移除图形\n const callbackAnimCfg = mix(\n {\n callback: () => {\n this.removeElement(element);\n },\n },\n animateOption.leave\n );\n this.removeAnimation(elementName, element, callbackAnimCfg);\n } else {\n this.removeElement(element);\n }\n }\n delete shapesMap[id]; // 从缓存中移除\n });\n }\n\n private removeElement(element: IShape | IGroup) {\n if (element.get('isGroup')) {\n const component = element.get('component');\n if (component) {\n component.destroy();\n }\n }\n element.remove();\n }\n}\n\nexport default GroupComponent;\n","const ELLIPSIS_CODE = '\\u2026';\n\n/** 获取字符串长度 */\nexport function strLen(str: string) {\n let len = 0;\n for (let i = 0; i < str.length; i++) {\n len += charAtLength(str, i);\n }\n return len;\n}\n\n/** 是否属于ASCII编码范畴 */\nexport function charAtLength(str: string, i: number) {\n if (str.charCodeAt(i) > 0 && str.charCodeAt(i) < 128) {\n return 1;\n } else {\n return 2;\n }\n}\n\n/** 文本省略 */\nexport function ellipsisString(str: string, reseveLength: number, position:string = 'tail') {\n const count = str.length;\n let rst = '';\n if (position === 'tail') {\n for (let i = 0, index = 0; i < reseveLength; ) {\n const charLength = charAtLength(str, index);\n if (i + charLength <= reseveLength) {\n rst += str[index];\n i += charAtLength(str, index);\n index++;\n } else {\n break;\n }\n }\n rst += ELLIPSIS_CODE;\n } else if (position === 'head') {\n for (let i = 0, index = count - 1; i < reseveLength; ) {\n const charLength = charAtLength(str, index);\n if (i + charLength <= reseveLength) {\n rst += str[index];\n i += charAtLength(str, index);\n index--;\n } else {\n break;\n }\n }\n rst = ELLIPSIS_CODE + rst;\n } else {\n let startStr = '';\n let endStr = '';\n for (let i = 0, startIndex = 0, endIndex = count - 1; i < reseveLength; ) {\n const startCodeLen = charAtLength(str, startIndex);\n let hasAdd = false; // 设置标志位,防止头尾都没有附加字符\n if (startCodeLen + i <= reseveLength) {\n startStr += str[startIndex];\n startIndex++;\n i += startCodeLen;\n hasAdd = true;\n }\n\n const endCodeLen = charAtLength(str, endIndex);\n if (endCodeLen + i <= reseveLength) {\n endStr = str[endIndex] + endStr;\n i += endCodeLen;\n endIndex--;\n hasAdd = true;\n }\n if (!hasAdd) {\n // 如果都没有增加字符,说明都不适合则中断\n break;\n }\n }\n rst = startStr + ELLIPSIS_CODE + endStr;\n }\n return rst;\n }\n","import { IElement } from '@antv/g-base';\nimport { each, isNil, getEllipsisText, pick } from '@antv/util';\n\nimport { ellipsisString, strLen } from './text';\n\nconst ELLIPSIS_CODE = '\\u2026';\nconst ELLIPSIS_CODE_LENGTH = 2; // 省略号的长度\n\n/** 大数据量阈值 */\nconst OPTIMIZE_THRESHOLD = 400;\n/**\n * 针对大数据量做优化的 getMaxLabelWidth,做法不是直接去比较每一个 label 的最大宽度\n * 而是先通过比较每个 label 每个的字符串的长度,这里区分了下中英文字符\n * 最终是去字符串最“长”的那个 label 的宽度。\n * @param labels\n */\nfunction getMaxLabelWidthOptimized(labels: IElement[]) {\n const texts: string[] = labels.map((label) => {\n const text = label.attr('text');\n return isNil(text) ? '' : `${text}`;\n });\n let maxLen = 0;\n let maxIdx = 0;\n\n for (let i = 0; i < texts.length; i += 1) {\n let len = 0;\n for (let j = 0; j <= texts[i].length; j += 1) {\n const code = texts[i].charCodeAt(j);\n if (code >= 19968 && code <= 40869) {\n len += 2;\n } else {\n len += 1;\n }\n }\n if (len > maxLen) {\n maxLen = len;\n maxIdx = i;\n }\n }\n\n return labels[maxIdx].getBBox().width;\n}\n\n/** 获取最长的 label */\nexport function getMaxLabelWidth(labels: IElement[]) {\n if (labels.length > OPTIMIZE_THRESHOLD) {\n return getMaxLabelWidthOptimized(labels);\n }\n\n let max = 0;\n each(labels, (label) => {\n const bbox = label.getBBox();\n const width = bbox.width;\n if (max < width) {\n max = width;\n }\n });\n return max;\n}\n\n/** 获取label长度 */\nexport function getLabelLength(isVertical: boolean, label) {\n const bbox = label.getCanvasBBox();\n return isVertical ? bbox.width : bbox.height;\n}\n\n/* label长度是否超过约束值 */\nexport function testLabel(label: IElement, limitLength: number): boolean {\n return label.getBBox().width < limitLength;\n}\n\n/** 处理 text shape 的自动省略 */\nexport function ellipsisLabel(isVertical: boolean, label: IElement, limitLength: number, position: string = 'tail') {\n const text = label.attr('text') ?? ''; // 避免出现null、undefined\n\n if (position === 'tail') {\n // component 里的缩略处理做得很糟糕,文字长度测算完全不准确\n // 这里暂时只对 tail 做处理\n const font = pick(label.attr(), ['fontSize', 'fontFamily', 'fontWeight', 'fontStyle', 'fontVariant']);\n const ellipsisText = getEllipsisText(text, limitLength, font, '…') as string;\n if (text !== ellipsisText) {\n label.attr('text', ellipsisText);\n label.set('tip', text);\n return true;\n }\n label.set('tip', null);\n return false;\n }\n\n const labelLength = getLabelLength(isVertical, label);\n const codeLength = strLen(text);\n let ellipsisFlag = false;\n if (limitLength < labelLength) {\n const reserveLength = Math.floor((limitLength / labelLength) * codeLength) - ELLIPSIS_CODE_LENGTH; // 计算出来的应该保存的长度\n let newText;\n if (reserveLength >= 0) {\n newText = ellipsisString(text, reserveLength, position);\n } else {\n newText = ELLIPSIS_CODE;\n }\n if (newText) {\n label.attr('text', newText);\n ellipsisFlag = true;\n }\n }\n if (ellipsisFlag) {\n label.set('tip', text);\n } else {\n label.set('tip', null);\n }\n return ellipsisFlag;\n}\n","import { IGroup } from '@antv/g-base';\nimport { get } from '@antv/util';\n\nimport { EnhancedTextCfg } from '../types';\nimport { ellipsisLabel } from './label';\nimport { applyRotate, applyTranslate } from './matrix';\nimport { formatPadding } from './util';\n\nexport interface TagCfg extends EnhancedTextCfg {\n /** 组件的 id 标识 */\n id?: string;\n /** 组件的名字 */\n name?: string;\n /**\n * 文本标注位置 x\n */\n x: number;\n /**\n * 文本标注位置 y\n */\n y: number;\n}\n\nexport function renderTag(container: IGroup, tagCfg: TagCfg) {\n const { x, y, content, style, id, name, rotate, maxLength, autoEllipsis, isVertical, ellipsisPosition, background } = tagCfg;\n const tagGroup = container.addGroup({\n id: `${id}-group`,\n name: `${name}-group`,\n attrs: {\n x,\n y,\n }\n });\n\n // Text shape\n const text = tagGroup.addShape({\n type: 'text',\n id,\n name,\n attrs: {\n x: 0,\n y: 0,\n text: content,\n ...style,\n },\n });\n\n // maxLength 应包含 background 中的 padding 值\n const padding = formatPadding(get(background, 'padding', 0));\n if (maxLength && autoEllipsis) {\n const maxTextLength = maxLength - (padding[1] + padding[3]);\n // 超出自动省略\n ellipsisLabel(!isVertical, text, maxTextLength, ellipsisPosition);\n }\n\n if (background) {\n // 渲染文本背景\n const backgroundStyle = get(background, 'style', {});\n const { minX, minY, width, height } = text.getCanvasBBox();\n const tagBg = tagGroup.addShape('rect', {\n id: `${id}-bg`,\n name: `${id}-bg`,\n attrs: {\n x: minX - padding[3],\n y: minY - padding[0],\n width: width + padding[1] + padding[3],\n height: height + padding[0] + padding[2],\n ...backgroundStyle,\n },\n });\n tagBg.toBack();\n }\n\n applyTranslate(tagGroup, x, y);\n applyRotate(tagGroup, rotate, x, y);\n}\n","export default {\n fontFamily: `\n BlinkMacSystemFont, \"Segoe UI\", Roboto,\"Helvetica Neue\",\n Helvetica, \"PingFang SC\", \"Hiragino Sans GB\", \"Microsoft YaHei\",\n SimSun, \"sans-serif\"`,\n textColor: '#2C3542',\n activeTextColor: '#333333',\n uncheckedColor: '#D8D8D8',\n lineColor: '#416180',\n regionColor: '#CCD7EB',\n verticalAxisRotate: -Math.PI / 4,\n horizontalAxisRotate: Math.PI / 4,\n\n // descriptionIcon theme\n descriptionIconStroke: '#fff',\n descriptionIconFill: 'rgba(58, 73, 101, .25)',\n};\n","import { IGroup, Point } from '@antv/g-base';\nimport { isNumber, isString } from '@antv/util';\nimport GroupComponent from '../abstract/group-component';\nimport { ILocation } from '../interfaces';\nimport { LineAnnotationCfg, RegionLocationCfg } from '../types';\nimport { renderTag, TagCfg } from '../util/graphic';\nimport Theme from '../util/theme';\nimport { getValueByPercent } from '../util/util';\n\nclass LineAnnotation extends GroupComponent implements ILocation {\n /**\n * @protected\n * 默认的配置项\n * @returns {object} 默认的配置项\n */\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n name: 'annotation',\n type: 'line',\n locationType: 'region',\n start: null,\n end: null,\n style: {},\n text: null,\n defaultCfg: {\n style: {\n fill: Theme.textColor,\n fontSize: 12,\n textAlign: 'center',\n textBaseline: 'bottom',\n fontFamily: Theme.fontFamily,\n },\n text: {\n position: 'center',\n autoRotate: true,\n content: null,\n offsetX: 0,\n offsetY: 0,\n style: {\n stroke: Theme.lineColor,\n lineWidth: 1,\n },\n },\n },\n };\n }\n\n protected renderInner(group: IGroup) {\n this.renderLine(group);\n if (this.get('text')) {\n this.renderLabel(group);\n }\n }\n\n // 绘制线\n private renderLine(group: IGroup) {\n const start = this.get('start');\n const end = this.get('end');\n const style = this.get('style');\n this.addShape(group, {\n type: 'line',\n id: this.getElementId('line'),\n name: 'annotation-line',\n attrs: {\n x1: start.x,\n y1: start.y,\n x2: end.x,\n y2: end.y,\n ...style,\n },\n });\n }\n\n // 获取 label 的位置\n private getLabelPoint(start: Point, end: Point, position: string) {\n let percent;\n if (position === 'start') {\n percent = 0;\n } else if (position === 'center') {\n percent = 0.5;\n } else if (isString(position) && position.indexOf('%') !== -1) {\n percent = parseInt(position, 10) / 100;\n } else if (isNumber(position)) {\n percent = position;\n } else {\n percent = 1;\n }\n\n if (percent > 1 || percent < 0) {\n percent = 1;\n }\n\n return {\n x: getValueByPercent(start.x, end.x, percent),\n y: getValueByPercent(start.y, end.y, percent),\n };\n }\n\n // 绘制 label\n private renderLabel(group: IGroup) {\n const text = this.get('text');\n const start = this.get('start');\n const end = this.get('end');\n const { position, content, style, offsetX, offsetY, autoRotate,\n maxLength, autoEllipsis, ellipsisPosition, background, isVertical = false } = text;\n const point = this.getLabelPoint(start, end, position);\n const x = point.x + offsetX;\n const y = point.y + offsetY;\n\n const cfg: TagCfg = {\n id: this.getElementId('line-text'),\n name: 'annotation-line-text',\n x,\n y,\n content,\n style,\n maxLength,\n autoEllipsis,\n ellipsisPosition,\n background,\n isVertical,\n };\n\n // 如果自动旋转\n if (autoRotate) {\n const vector = [end.x - start.x, end.y - start.y];\n cfg.rotate = Math.atan2(vector[1], vector[0]);\n }\n\n renderTag(group, cfg);\n }\n}\n\nexport default LineAnnotation;\n","import { IGroup } from '@antv/g-base';\n\nimport GroupComponent from '../abstract/group-component';\nimport { ILocation } from '../interfaces';\nimport { PointLocationCfg, TextAnnotationCfg } from '../types';\nimport { renderTag } from '../util/graphic';\nimport { applyRotate, applyTranslate } from '../util/matrix';\nimport Theme from '../util/theme';\n\nclass TextAnnotation extends GroupComponent implements ILocation {\n /**\n * @protected\n * 默认的配置项\n * @returns {object} 默认的配置项\n */\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n name: 'annotation',\n type: 'text',\n locationType: 'point',\n x: 0,\n y: 0,\n content: '',\n rotate: null,\n style: {},\n background: null,\n maxLength: null,\n autoEllipsis: true,\n isVertical: false,\n ellipsisPosition: 'tail',\n defaultCfg: {\n style: {\n fill: Theme.textColor,\n fontSize: 12,\n textAlign: 'center',\n textBaseline: 'middle',\n fontFamily: Theme.fontFamily,\n },\n },\n };\n }\n\n // 复写 setLocation 方法,不需要重新创建 text\n public setLocation(location: PointLocationCfg) {\n this.set('x', location.x);\n this.set('y', location.y);\n this.resetLocation();\n }\n\n protected renderInner(group: IGroup) {\n const { x, y } = this.getLocation();\n const content = this.get('content');\n const style = this.get('style');\n const id = this.getElementId('text');\n const name = `${this.get('name')}-text`;\n const maxLength = this.get('maxLength');\n const autoEllipsis = this.get('autoEllipsis');\n const isVertical = this.get('isVertical');\n const ellipsisPosition = this.get('ellipsisPosition');\n const background = this.get('background');\n const rotate = this.get('rotate');\n\n const cfg = {\n id,\n name,\n x,\n y,\n content,\n style,\n maxLength,\n autoEllipsis,\n isVertical,\n ellipsisPosition,\n background,\n rotate,\n };\n\n renderTag(group, cfg);\n }\n\n private resetLocation() {\n const textGroup = this.getElementByLocalId('text-group');\n if (textGroup) {\n const {x, y} = this.getLocation();\n const rotate = this.get('rotate')\n applyTranslate(textGroup, x, y);\n applyRotate(textGroup, rotate, x, y);\n }\n }\n}\n\nexport default TextAnnotation;\n","import { IGroup } from '@antv/g-base';\nimport GroupComponent from '../abstract/group-component';\nimport { ILocation } from '../interfaces';\nimport { ArcAnnotationCfg, CircleLocationCfg } from '../types';\nimport { getCirclePoint } from '../util/util';\n\nclass ArcAnnotation extends GroupComponent implements ILocation {\n /**\n * @protected\n * 默认的配置项\n * @returns {object} 默认的配置项\n */\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n name: 'annotation',\n type: 'arc',\n locationType: 'circle',\n center: null,\n radius: 100,\n startAngle: -Math.PI / 2,\n endAngle: (Math.PI * 3) / 2,\n style: {\n stroke: '#999',\n lineWidth: 1,\n },\n };\n }\n\n protected renderInner(group: IGroup) {\n this.renderArc(group);\n }\n\n private getArcPath() {\n const { center, radius, startAngle, endAngle } = this.getLocation();\n const startPoint = getCirclePoint(center, radius, startAngle);\n const endPoint = getCirclePoint(center, radius, endAngle);\n const largeFlag = endAngle - startAngle > Math.PI ? 1 : 0;\n\n const path = [['M', startPoint.x, startPoint.y]];\n if (endAngle - startAngle === Math.PI * 2) {\n // 整个圆是分割成两个圆\n const middlePoint = getCirclePoint(center, radius, startAngle + Math.PI);\n path.push(['A', radius, radius, 0, largeFlag, 1, middlePoint.x, middlePoint.y]);\n path.push(['A', radius, radius, 0, largeFlag, 1, endPoint.x, endPoint.y]);\n } else {\n path.push(['A', radius, radius, 0, largeFlag, 1, endPoint.x, endPoint.y]);\n }\n return path;\n }\n\n // 绘制 arc\n private renderArc(group: IGroup) {\n // 也可以 通过 get('center') 类似的方式逐个获取\n const path = this.getArcPath();\n const style = this.get('style');\n this.addShape(group, {\n type: 'path',\n id: this.getElementId('arc'),\n name: 'annotation-arc',\n attrs: {\n path,\n ...style,\n },\n });\n }\n}\n\nexport default ArcAnnotation;\n","import { IGroup } from '@antv/g-base';\nimport GroupComponent from '../abstract/group-component';\nimport { ILocation } from '../interfaces';\nimport { RegionAnnotationCfg, RegionLocationCfg } from '../types';\nimport Theme from '../util/theme';\nimport { regionToBBox } from '../util/util';\n\nclass RegionAnnotation extends GroupComponent implements ILocation {\n /**\n * @protected\n * 默认的配置项\n * @returns {object} 默认的配置项\n */\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n name: 'annotation',\n type: 'region',\n locationType: 'region',\n start: null,\n end: null,\n style: {},\n defaultCfg: {\n style: {\n lineWidth: 0,\n fill: Theme.regionColor,\n opacity: 0.4,\n },\n },\n };\n }\n\n protected renderInner(group: IGroup) {\n this.renderRegion(group);\n }\n\n private renderRegion(group: IGroup) {\n const start = this.get('start');\n const end = this.get('end');\n const style = this.get('style');\n const bbox = regionToBBox({ start, end });\n this.addShape(group, {\n type: 'rect',\n id: this.getElementId('region'),\n name: 'annotation-region',\n attrs: {\n x: bbox.x,\n y: bbox.y,\n width: bbox.width,\n height: bbox.height,\n ...style,\n },\n });\n }\n}\n\nexport default RegionAnnotation;\n","import { IGroup } from '@antv/g-base';\nimport GroupComponent from '../abstract/group-component';\nimport { ILocation } from '../interfaces';\nimport { ImageAnnotationCfg, RegionLocationCfg } from '../types';\nimport { regionToBBox } from '../util/util';\n\nclass ImageAnnotation extends GroupComponent implements ILocation {\n /**\n * @protected\n * 默认的配置项\n * @returns {object} 默认的配置项\n */\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n name: 'annotation',\n type: 'image',\n locationType: 'region',\n start: null,\n end: null,\n src: null,\n style: {},\n };\n }\n\n public renderInner(group: IGroup) {\n this.renderImage(group);\n }\n\n private getImageAttrs() {\n const start = this.get('start');\n const end = this.get('end');\n const style = this.get('style');\n const bbox = regionToBBox({ start, end });\n const src = this.get('src');\n return {\n x: bbox.x,\n y: bbox.y,\n img: src,\n width: bbox.width,\n height: bbox.height,\n ...style,\n };\n }\n\n // 绘制图片\n private renderImage(group: IGroup) {\n this.addShape(group, {\n type: 'image',\n id: this.getElementId('image'),\n name: 'annotation-image',\n attrs: this.getImageAttrs(),\n });\n }\n}\n\nexport default ImageAnnotation;\n","import { IGroup } from '@antv/g-base';\nimport { get } from '@antv/util';\nimport GroupComponent from '../abstract/group-component';\nimport { ILocation } from '../interfaces';\nimport { DataMarkerAnnotationCfg, PointLocationCfg } from '../types';\nimport { renderTag } from '../util/graphic';\nimport { applyTranslate } from '../util/matrix';\nimport Theme from '../util/theme';\n\nclass DataMarkerAnnotation extends GroupComponent implements ILocation {\n /**\n * 默认的配置项\n * @returns {object} 默认的配置项\n */\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n name: 'annotation',\n type: 'dataMarker',\n locationType: 'point',\n x: 0,\n y: 0,\n point: {},\n line: {},\n text: {},\n direction: 'upward',\n autoAdjust: true,\n coordinateBBox: null,\n defaultCfg: {\n point: {\n display: true,\n style: {\n r: 3,\n fill: '#FFFFFF',\n stroke: '#1890FF',\n lineWidth: 2,\n },\n },\n line: {\n display: true,\n length: 20,\n style: {\n stroke: Theme.lineColor,\n lineWidth: 1,\n },\n },\n text: {\n content: '',\n display: true,\n style: {\n fill: Theme.textColor,\n opacity: 0.65,\n fontSize: 12,\n textAlign: 'start',\n fontFamily: Theme.fontFamily,\n },\n },\n },\n };\n }\n\n protected renderInner(group: IGroup) {\n if (get(this.get('line'), 'display')) {\n this.renderLine(group);\n }\n if (get(this.get('text'), 'display')) {\n this.renderText(group);\n }\n if (get(this.get('point'), 'display')) {\n this.renderPoint(group);\n }\n\n if (this.get('autoAdjust')) {\n this.autoAdjust(group);\n }\n }\n\n protected applyOffset() {\n this.moveElementTo(this.get('group'), {\n x: this.get('x') + this.get('offsetX'),\n y: this.get('y') + this.get('offsetY'),\n });\n }\n\n private renderPoint(group: IGroup) {\n const { point } = this.getShapeAttrs();\n\n this.addShape(group, {\n type: 'circle',\n id: this.getElementId('point'),\n name: 'annotation-point',\n attrs: point,\n });\n }\n\n private renderLine(group: IGroup) {\n const { line } = this.getShapeAttrs();\n\n this.addShape(group, {\n type: 'path',\n id: this.getElementId('line'),\n name: 'annotation-line',\n attrs: line,\n });\n }\n\n private renderText(group: IGroup) {\n const { text: textAttrs } = this.getShapeAttrs();\n\n const { x, y, text, ...style } = textAttrs;\n const { background, maxLength, autoEllipsis, isVertival, ellipsisPosition } = this.get('text');\n const tagCfg = {\n x,\n y,\n id: this.getElementId('text'),\n name: 'annotation-text',\n content: text,\n style,\n background,\n maxLength,\n autoEllipsis,\n isVertival,\n ellipsisPosition,\n };\n\n renderTag(group, tagCfg);\n }\n\n private autoAdjust(group: IGroup) {\n const direction: string = this.get('direction');\n const x: number = this.get('x');\n const y: number = this.get('y');\n const lineLength: number = get(this.get('line'), 'length', 0);\n const coordinateBBox = this.get('coordinateBBox');\n const { minX, maxX, minY, maxY } = group.getBBox();\n\n const textGroup = group.findById(this.getElementId('text-group'));\n const textShape = group.findById(this.getElementId('text'));\n const lineShape = group.findById(this.getElementId('line'));\n\n if (!coordinateBBox) {\n return;\n }\n\n if (textGroup) {\n let translateX = textGroup.attr('x'), translateY = textGroup.attr('y');\n let { width, height } = textShape.getCanvasBBox();\n let xFactor = 0, yFactor = 0;\n if (x + minX <= coordinateBBox.minX) {\n // 左侧超出\n if (direction === 'leftward') {\n xFactor = 1;\n } else {\n const overflow = coordinateBBox.minX - (x + minX);\n translateX = textGroup.attr('x') + overflow;\n }\n } else if (x + maxX >= coordinateBBox.maxX) {\n // 右侧超出\n if (direction === 'rightward') {\n xFactor = -1;\n } else {\n const overflow = x + maxX - coordinateBBox.maxX;\n translateX = textGroup.attr('x') - overflow;\n }\n }\n if (!!xFactor) {\n if (lineShape) {\n lineShape.attr('path', [\n ['M', 0, 0],\n ['L', lineLength * xFactor, 0],\n ]);\n }\n translateX = (lineLength + 2 + width) * xFactor;\n }\n if (y + minY <= coordinateBBox.minY) {\n // 上方超出\n if (direction === 'upward') {\n yFactor = 1;\n } else {\n const overflow = coordinateBBox.minY - (y + minY);\n translateY = textGroup.attr('y') + overflow;\n }\n } else if (y + maxY >= coordinateBBox.maxY) {\n // 下方超出\n if (direction === 'downward') {\n yFactor = -1;\n } else {\n const overflow = y + maxY - coordinateBBox.maxY;\n translateY = textGroup.attr('y') - overflow;\n }\n }\n if (!!yFactor) {\n if (lineShape) {\n lineShape.attr('path', [\n ['M', 0, 0],\n ['L', 0, lineLength * yFactor],\n ]);\n }\n translateY = (lineLength + 2 + height) * yFactor;\n }\n if (translateX !== textGroup.attr('x') || translateY !== textGroup.attr('y'))\n applyTranslate(textGroup, translateX, translateY);\n }\n }\n\n private getShapeAttrs() {\n const lineDisplay = get(this.get('line'), 'display');\n const pointStyle = get(this.get('point'), 'style', {});\n const lineStyle = get(this.get('line'), 'style', {});\n const textStyle = get(this.get('text'), 'style', {});\n const direction = this.get('direction');\n const lineLength = lineDisplay ? get(this.get('line'), 'length', 0) : 0;\n let xFactor = 0, yFactor = 0;\n let textBaseline = 'top',\n textAlign = 'start';\n switch (direction) {\n case 'upward':\n yFactor = -1;\n textBaseline = 'bottom';\n break;\n case 'downward':\n yFactor = 1;\n textBaseline = 'top';\n break;\n case 'leftward':\n xFactor = -1;\n textAlign = 'end';\n break;\n case 'rightward':\n xFactor = 1;\n textAlign = 'start';\n break;\n }\n return {\n point: {\n x: 0,\n y: 0,\n ...pointStyle,\n },\n line: {\n path: [\n ['M', 0, 0],\n ['L', lineLength * xFactor, lineLength * yFactor],\n ],\n ...lineStyle,\n },\n text: {\n x: (lineLength + 2) * xFactor,\n y: (lineLength + 2) * yFactor,\n text: get(this.get('text'), 'content', ''),\n textBaseline,\n textAlign,\n ...textStyle,\n },\n };\n }\n}\n\nexport default DataMarkerAnnotation;\n","import { IGroup } from '@antv/g-base';\nimport { get } from '@antv/util';\nimport GroupComponent from '../abstract/group-component';\nimport { ILocation } from '../interfaces';\nimport { DataRegionAnnotationCfg, Point, PointsLocationCfg } from '../types';\nimport Theme from '../util/theme';\nimport { pointsToBBox } from '../util/util';\nimport { renderTag } from '../util/graphic';\n\nclass DataRegionAnnotation extends GroupComponent implements ILocation {\n /**\n * 默认的配置项\n * @returns {object} 默认的配置项\n */\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n name: 'annotation',\n type: 'dataRegion',\n locationType: 'points',\n points: [],\n lineLength: 0,\n region: {},\n text: {},\n defaultCfg: {\n region: {\n style: {\n lineWidth: 0,\n fill: Theme.regionColor,\n opacity: 0.4,\n },\n },\n text: {\n content: '',\n style: {\n textAlign: 'center',\n textBaseline: 'bottom',\n fontSize: 12,\n fill: Theme.textColor,\n fontFamily: Theme.fontFamily,\n },\n },\n },\n };\n }\n\n protected renderInner(group: IGroup) {\n const regionStyle = get(this.get('region'), 'style', {});\n const textStyle = get(this.get('text'), 'style', {});\n const lineLength = this.get('lineLength') || 0;\n const points: Point[] = this.get('points');\n\n if (!points.length) {\n return;\n }\n const bbox = pointsToBBox(points);\n\n // render region\n const path = [];\n path.push(['M', points[0].x, bbox.minY - lineLength]);\n points.forEach((point) => {\n path.push(['L', point.x, point.y]);\n });\n path.push(['L', points[points.length - 1].x, points[points.length - 1].y - lineLength]);\n this.addShape(group, {\n type: 'path',\n id: this.getElementId('region'),\n name: 'annotation-region',\n attrs: {\n path,\n ...regionStyle,\n },\n });\n\n // render text\n const textCfg = {\n id: this.getElementId('text'),\n name: 'annotation-text',\n x: (bbox.minX + bbox.maxX) / 2,\n y: bbox.minY - lineLength,\n ...this.get('text'),\n };\n\n renderTag(group, textCfg);\n }\n}\n\nexport default DataRegionAnnotation;\n","import { IGroup, IShape, Point, ShapeAttrs } from '@antv/g-base';\nimport { clone, each } from '@antv/util';\nimport GroupComponent from '../abstract/group-component';\nimport { ILocation } from '../interfaces';\nimport { RegionFilterAnnotationCfg, RegionLocationCfg } from '../types';\nimport { regionToBBox } from '../util/util';\n\nclass RegionFilterAnnotation extends GroupComponent implements ILocation {\n /**\n * 默认的配置项\n * @returns {object} 默认的配置项\n */\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n name: 'annotation',\n type: 'regionFilter',\n locationType: 'region',\n start: null,\n end: null,\n color: null,\n shape: [],\n };\n }\n\n protected renderInner(group: IGroup) {\n const start: Point = this.get('start');\n const end: Point = this.get('end');\n\n // 1. add region layer\n const layer: IGroup = this.addGroup(group, {\n id: this.getElementId('region-filter'),\n capture: false,\n });\n\n // 2. clone shape & color it\n each(this.get('shapes'), (shape: IShape, shapeIdx: number) => {\n const type = shape.get('type');\n const attrs = clone(shape.attr());\n this.adjustShapeAttrs(attrs);\n this.addShape(layer, {\n id: this.getElementId(`shape-${type}-${shapeIdx}`),\n capture: false,\n type,\n attrs,\n });\n });\n\n // 3. clip\n const clipBBox = regionToBBox({ start, end });\n layer.setClip({\n type: 'rect',\n attrs: {\n x: clipBBox.minX,\n y: clipBBox.minY,\n width: clipBBox.width,\n height: clipBBox.height,\n },\n });\n }\n\n private adjustShapeAttrs(attr: ShapeAttrs) {\n const color = this.get('color');\n if (attr.fill) {\n attr.fill = attr.fillStyle = color;\n }\n attr.stroke = attr.strokeStyle = color;\n }\n}\n\nexport default RegionFilterAnnotation;\n","import { IGroup } from '@antv/g-base';\nimport { isFunction, noop } from '@antv/util';\n\nimport GroupComponent from '../abstract/group-component';\nimport { ShapeAnnotationCfg } from '../types';\n\nexport default class ShapeAnnotation extends GroupComponent {\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n name: 'annotation',\n type: 'shape',\n draw: noop,\n };\n }\n\n protected renderInner(group: IGroup) {\n const render = this.get('render');\n if (isFunction(render)) {\n render(group);\n }\n }\n}\n","/**\n * 获取样式\n * @param {Object} dom DOM节点\n * @param {String} name 样式名\n * @param {Any} defaultValue 默认值\n * @return {String} 属性值\n */\nexport default function getStyle(dom: HTMLElement, name: string, defaultValue?: any) {\n let v;\n try {\n v = window.getComputedStyle ?\n window.getComputedStyle(dom, null)[name] :\n dom.style[name]; // 一般不会走到这个逻辑,dom.style 获取的是标签 style 属性,也不准确\n } catch (e) {\n // do nothing\n } finally {\n v = v === undefined ? defaultValue : v;\n }\n return v;\n}\n","\nimport getStyle from './get-style';\nimport getWidth from './get-width';\n\nexport default function getOuterWidth(el: HTMLElement, defaultValue?: any): number {\n const width = getWidth(el, defaultValue);\n const bLeft = parseFloat(getStyle(el, 'borderLeftWidth')) || 0;\n const pLeft = parseFloat(getStyle(el, 'paddingLeft')) || 0;\n const pRight = parseFloat(getStyle(el, 'paddingRight')) || 0;\n const bRight = parseFloat(getStyle(el, 'borderRightWidth')) || 0;\n const mRight = parseFloat(getStyle(el, 'marginRight')) || 0;\n const mLeft = parseFloat(getStyle(el, 'marginLeft')) || 0;\n return width + bLeft + bRight + pLeft + pRight + mLeft + mRight;\n}\n","import getStyle from './get-style';\n\nexport default function getHeight(el: HTMLElement, defaultValue?: any): number {\n let width = getStyle(el, 'width', defaultValue);\n if (width === 'auto') {\n width = el.offsetWidth;\n }\n return parseFloat(width);\n}\n","\nimport getStyle from './get-style';\nimport getHeight from './get-height';\n\nexport default function getOuterHeight(el: HTMLElement, defaultValue?: any): number {\n const height = getHeight(el, defaultValue);\n const bTop = parseFloat(getStyle(el, 'borderTopWidth')) || 0;\n const pTop = parseFloat(getStyle(el, 'paddingTop')) || 0;\n const pBottom = parseFloat(getStyle(el, 'paddingBottom')) || 0;\n const bBottom = parseFloat(getStyle(el, 'borderBottomWidth')) || 0;\n const mTop = parseFloat(getStyle(el, 'marginTop')) || 0;\n const mBottom = parseFloat(getStyle(el, 'marginBottom')) || 0;\n return height + bTop + bBottom + pTop + pBottom + mTop + mBottom;\n}\n","import getStyle from './get-style';\n\nexport default function getHeight(el: HTMLElement, defaultValue?: any): number {\n let height = getStyle(el, 'height', defaultValue);\n if (height === 'auto') {\n height = el.offsetHeight;\n }\n return parseFloat(height);\n}\n","import { createDom, modifyCSS } from '@antv/dom-util';\nimport { isNil, isString, deepMix, each, hasKey } from '@antv/util';\nimport { BBox, ComponentCfg, HtmlComponentCfg } from '../types';\nimport { clearDom, createBBox, hasClass } from '../util/util';\nimport Component from './component';\n\nabstract class HtmlComponent extends Component {\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n container: null,\n containerTpl: '
',\n updateAutoRender: true,\n containerClassName: '',\n parent: null,\n };\n }\n\n public getContainer(): HTMLElement {\n return this.get('container') as HTMLElement;\n }\n\n /**\n * 显示组件\n */\n public show() {\n const container = this.get('container');\n container.style.display = '';\n this.set('visible', true);\n }\n /**\n * 隐藏组件\n */\n public hide() {\n const container = this.get('container');\n container.style.display = 'none';\n this.set('visible', false);\n }\n /**\n * 是否允许捕捉事件\n * @param capture 事件捕捉\n */\n public setCapture(capture) {\n const container = this.getContainer();\n const value = capture ? 'auto' : 'none';\n container.style.pointerEvents = value;\n this.set('capture', capture);\n }\n public getBBox(): BBox {\n const container = this.getContainer();\n const x = parseFloat(container.style.left) || 0;\n const y = parseFloat(container.style.top) || 0;\n return createBBox(x, y, container.clientWidth, container.clientHeight);\n }\n\n public clear() {\n const container = this.get('container');\n clearDom(container);\n }\n\n public destroy() {\n this.removeEvent();\n this.removeDom();\n super.destroy();\n }\n\n /**\n * 复写 init,主要是初始化 DOM 和事件\n */\n public init() {\n super.init();\n this.initContainer();\n this.initDom();\n this.resetStyles(); // 初始化样式\n this.applyStyles(); // 应用样式\n this.initEvent();\n this.initCapture();\n this.initVisible();\n }\n\n protected initCapture() {\n this.setCapture(this.get('capture'));\n }\n protected initVisible() {\n if (!this.get('visible')) {\n // 设置初始显示状态\n this.hide();\n } else {\n this.show();\n }\n }\n\n protected initDom() {\n\n }\n\n protected initContainer() {\n let container = this.get('container');\n if (isNil(container)) {\n // 未指定 container 则创建\n container = this.createDom();\n let parent = this.get('parent');\n if (isString(parent)) {\n parent = document.getElementById(parent);\n this.set('parent', parent);\n }\n parent.appendChild(container);\n if (this.get('containerId')) {\n container.setAttribute('id', this.get('containerId'));\n }\n this.set('container', container);\n } else if (isString(container)) {\n // 用户传入的 id, 作为 container\n container = document.getElementById(container);\n this.set('container', container);\n } // else container 是 DOM\n if (!this.get('parent')) {\n this.set('parent', container.parentNode);\n }\n }\n\n // 样式需要进行合并,不能单纯的替换,否则使用非常不方便\n protected resetStyles() {\n let style = this.get('domStyles');\n const defaultStyles = this.get('defaultStyles');\n if (!style) {\n style = defaultStyles;\n } else {\n style = deepMix({}, defaultStyles, style);\n }\n this.set('domStyles', style);\n }\n // 应用所有的样式\n protected applyStyles() {\n const domStyles = this.get('domStyles');\n if (!domStyles) {\n return;\n }\n const container = this.getContainer();\n this.applyChildrenStyles(container, domStyles);\n const containerClassName = this.get('containerClassName');\n if (containerClassName && hasClass(container, containerClassName)) {\n const containerCss = domStyles[containerClassName];\n modifyCSS(container, containerCss);\n }\n }\n\n protected applyChildrenStyles(element, styles) {\n each(styles, (style, name) => {\n const elements = element.getElementsByClassName(name);\n each(elements, (el) => {\n modifyCSS(el, style);\n });\n });\n }\n // 应用到单个 DOM\n protected applyStyle(cssName, dom) {\n const domStyles = this.get('domStyles');\n modifyCSS(dom, domStyles[cssName]);\n }\n\n /**\n * @protected\n */\n protected createDom() {\n const containerTpl = this.get('containerTpl');\n return createDom(containerTpl);\n }\n\n /**\n * @protected\n * 初始化事件\n */\n protected initEvent() { }\n\n /**\n * @protected\n * 清理 DOM\n */\n protected removeDom() {\n const container = this.get('container');\n // 节点不一定有parentNode\n container && container.parentNode && container.parentNode.removeChild(container);\n }\n\n /**\n * @protected\n * 清理事件\n */\n protected removeEvent() { }\n\n protected updateInner(cfg) {\n // 更新样式\n if (hasKey(cfg, 'domStyles')) {\n this.resetStyles();\n this.applyStyles();\n }\n // 只要属性发生变化,都调整一些位置\n this.resetPosition();\n }\n protected resetPosition() { };\n}\n\nexport default HtmlComponent;\n","import { createDom, getOuterHeight, getOuterWidth, modifyCSS } from '@antv/dom-util';\nimport { isElement, isFunction, isNumber, isString } from '@antv/util';\nimport HtmlComponent from '../abstract/html-component';\nimport { ILocation } from '../interfaces';\nimport { HtmlAnnotationCfg, PointLocationCfg } from '../types';\nimport { clearDom } from '../util/util';\n\nexport default class HtmlAnnotation extends HtmlComponent implements ILocation {\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n name: 'annotation',\n type: 'html',\n locationType: 'point',\n x: 0,\n y: 0,\n containerTpl: `
`,\n alignX: 'left',\n alignY: 'top',\n html: '',\n zIndex: 7,\n };\n }\n\n public render() {\n const container = this.getContainer();\n const html = this.get('html');\n\n clearDom(container);\n\n const rst: HTMLElement | string = isFunction(html) ? html(container) : html;\n\n if (isElement(rst)) {\n container.appendChild(rst as HTMLElement);\n } else if (isString(rst) || isNumber(rst)) {\n const dom = createDom(`${rst}` as string);\n if (dom) {\n container.appendChild(dom);\n }\n }\n\n this.resetPosition();\n }\n\n protected resetPosition() {\n const container = this.getContainer();\n const { x, y } = this.getLocation();\n const alignX = this.get('alignX');\n const alignY = this.get('alignY');\n const offsetX = this.get('offsetX');\n const offsetY = this.get('offsetY');\n const domWidth = getOuterWidth(container);\n const domHeight = getOuterHeight(container);\n\n const position = {\n x, // alignX left\n y, // alignY top\n };\n\n if (alignX === 'middle') {\n position.x -= Math.round(domWidth / 2);\n } else if (alignX === 'right') {\n position.x -= Math.round(domWidth);\n }\n if (alignY === 'middle') {\n position.y -= Math.round(domHeight / 2);\n } else if (alignY === 'bottom') {\n position.y -= Math.round(domHeight);\n }\n if (offsetX) {\n position.x += offsetX;\n }\n if (offsetY) {\n position.y += offsetY;\n }\n\n modifyCSS(container, {\n position: 'absolute',\n left: `${position.x}px`,\n top: `${position.y}px`,\n zIndex: this.get('zIndex'),\n });\n }\n}\n","import { each, mix } from '@antv/util';\nimport { ListItem } from '../types';\n\n// 获取多个状态量的合并值\nexport function getStatesStyle(item: ListItem, elementName: string, stateStyles: object) {\n const styleName = `${elementName}Style`; // activeStyle\n let styles = null;\n each(stateStyles, (v, state) => {\n if (item[state] && v[styleName]) {\n if (!styles) {\n styles = {};\n }\n mix(styles, v[styleName]); // 合并样式\n }\n });\n return styles;\n}\n","import { IGroup, IShape } from '@antv/g-base';\nimport { ext } from '@antv/matrix-util';\nimport { each, filter, get, isFunction, isNil, isNumberEqual, mix, size, isArray } from '@antv/util';\nimport GroupComponent from '../abstract/group-component';\nimport { IList } from '../interfaces';\nimport { AxisBaseCfg, ListItem, OptimizeCfg, Point } from '../types';\nimport { getMatrixByAngle } from '../util/matrix';\nimport { getStatesStyle } from '../util/state';\nimport Theme from '../util/theme';\n\nabstract class AxisBase extends GroupComponent implements IList {\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n name: 'axis',\n ticks: [],\n line: {},\n tickLine: {},\n subTickLine: null,\n title: null,\n /**\n * 文本标签的配置项\n */\n label: {},\n /**\n * 垂直于坐标轴方向的因子,决定文本、title、tickLine 在坐标轴的哪一侧\n */\n verticalFactor: 1,\n // 垂直方向限制的长度,对文本自适应有很大影响\n verticalLimitLength: null,\n overlapOrder: ['autoRotate', 'autoEllipsis', 'autoHide'],\n tickStates: {},\n optimize: {},\n defaultCfg: {\n line: {\n // @type {Attrs} 坐标轴线的图形属性,如果设置成null,则不显示轴线\n style: {\n lineWidth: 1,\n stroke: Theme.lineColor,\n },\n },\n tickLine: {\n // @type {Attrs} 标注坐标线的图形属性\n style: {\n lineWidth: 1,\n stroke: Theme.lineColor,\n },\n alignTick: true, // 是否同 tick 对齐\n length: 5,\n displayWithLabel: true,\n },\n subTickLine: {\n // @type {Attrs} 标注坐标线的图形属性\n style: {\n lineWidth: 1,\n stroke: Theme.lineColor,\n },\n count: 4, // 子刻度线的数量,将两个刻度线划分成 5 份\n length: 2,\n },\n label: {\n autoRotate: true,\n autoHide: false,\n autoEllipsis: false,\n style: {\n fontSize: 12,\n fill: Theme.textColor,\n fontFamily: Theme.fontFamily,\n fontWeight: 'normal',\n },\n offset: 10,\n offsetX: 0,\n offsetY: 0,\n },\n title: {\n autoRotate: true,\n spacing: 5,\n position: 'center', // start, center, end\n style: {\n fontSize: 12,\n fill: Theme.textColor,\n textBaseline: 'middle',\n fontFamily: Theme.fontFamily,\n textAlign: 'center',\n },\n iconStyle: {\n fill: Theme.descriptionIconFill,\n stroke: Theme.descriptionIconStroke,\n },\n description: ''\n },\n tickStates: {\n active: {\n labelStyle: {\n fontWeight: 500,\n },\n tickLineStyle: {\n lineWidth: 2,\n },\n },\n inactive: {\n labelStyle: {\n fill: Theme.uncheckedColor,\n },\n },\n },\n // 针对大数据量进行优化配置\n optimize: {\n enable: true,\n threshold: 400,\n },\n },\n theme: {},\n };\n }\n\n /**\n * 绘制组件\n */\n public renderInner(group: IGroup) {\n if (this.get('line')) {\n this.drawLine(group);\n }\n // drawTicks 包括 drawLabels 和 drawTickLines\n this.drawTicks(group);\n if (this.get('title')) {\n this.drawTitle(group);\n }\n }\n\n // 实现 IList 接口\n public isList(): boolean {\n return true;\n }\n\n /**\n * 获取图例项\n * @return {ListItem[]} 列表项集合\n */\n public getItems(): ListItem[] {\n return this.get('ticks');\n }\n\n /**\n * 设置列表项\n * @param {ListItem[]} items 列表项集合\n */\n public setItems(items: ListItem[]) {\n this.update({\n ticks: items,\n } as Partial);\n }\n\n /**\n * 更新列表项\n * @param {ListItem} item 列表项\n * @param {object} cfg 列表项\n */\n public updateItem(item: ListItem, cfg: object) {\n mix(item, cfg);\n this.clear(); // 由于单个图例项变化,会引起全局变化,所以全部更新\n this.render();\n }\n\n /**\n * 清空列表\n */\n public clearItems() {\n const itemGroup = this.getElementByLocalId('label-group');\n itemGroup && itemGroup.clear();\n }\n\n /**\n * 设置列表项的状态\n * @param {ListItem} item 列表项\n * @param {string} state 状态名\n * @param {boolean} value 状态值, true, false\n */\n public setItemState(item: ListItem, state: string, value: boolean) {\n item[state] = value;\n this.updateTickStates(item); // 应用状态样式\n }\n\n /**\n * 是否存在指定的状态\n * @param {ListItem} item 列表项\n * @param {boolean} state 状态名\n */\n public hasState(item: ListItem, state: string): boolean {\n return !!item[state];\n }\n\n public getItemStates(item: ListItem): string[] {\n const tickStates = this.get('tickStates');\n const rst = [];\n each(tickStates, (v, k) => {\n if (item[k]) {\n // item.selected\n rst.push(k);\n }\n });\n return rst;\n }\n\n /**\n * 清楚所有列表项的状态\n * @param {string} state 状态值\n */\n public clearItemsState(state: string) {\n const items = this.getItemsByState(state);\n each(items, (item) => {\n this.setItemState(item, state, false);\n });\n }\n\n /**\n * 根据状态获取图例项\n * @param {string} state [description]\n * @return {ListItem[]} [description]\n */\n public getItemsByState(state: string): ListItem[] {\n const items = this.getItems();\n return filter(items, (item) => {\n return this.hasState(item, state);\n });\n }\n\n /**\n * @protected\n * 获取坐标轴线的路径,不同的坐标轴不一样\n */\n protected abstract getLinePath(): any[];\n\n /**\n * 获取坐标轴垂直方向的向量\n * @param {number} offset 距离点距离\n * @param {Point} point 坐标轴上的一点\n */\n protected abstract getSideVector(offset: number, point: Point);\n /**\n * 获取坐标轴的向量\n * @param {Point} point 坐标轴上的点\n */\n protected abstract getAxisVector(point: Point): [number, number];\n\n protected getSidePoint(point: Point, offset: number): Point {\n const self = this;\n const vector = self.getSideVector(offset, point);\n return {\n x: point.x + vector[0],\n y: point.y + vector[1],\n };\n }\n\n /**\n * 根据 tick.value 获取坐标轴上对应的点\n * @param {number} tickValue\n * @returns {Point}\n */\n protected abstract getTickPoint(tickValue: number): Point;\n\n protected getTextAnchor(vector: number[]): string {\n let align;\n if (isNumberEqual(vector[0], 0)) {\n align = 'center';\n } else if (vector[0] > 0) {\n align = 'start';\n } else if (vector[0] < 0) {\n align = 'end';\n }\n return align;\n }\n\n protected getTextBaseline(vector: number[]): string {\n let base;\n if (isNumberEqual(vector[1], 0)) {\n base = 'middle';\n } else if (vector[1] > 0) {\n base = 'top';\n } else if (vector[1] < 0) {\n base = 'bottom';\n }\n return base;\n }\n\n protected processOverlap(labelGroup) {}\n\n // 绘制坐标轴线\n private drawLine(group: IGroup) {\n const path = this.getLinePath();\n const line = this.get('line'); // line 的判空在调用 drawLine 之前,不在这里判定\n this.addShape(group, {\n type: 'path',\n id: this.getElementId('line'),\n name: 'axis-line',\n attrs: mix(\n {\n path,\n },\n line.style\n ),\n });\n }\n\n private getTickLineItems(ticks: ListItem[]) {\n const tickLineItems = [];\n const tickLine = this.get('tickLine');\n const alignTick = tickLine.alignTick;\n const tickLineLength = tickLine.length;\n let tickSegment = 1;\n const tickCount = ticks.length;\n if (tickCount >= 2) {\n tickSegment = ticks[1].value - ticks[0].value;\n }\n\n each(ticks, (tick) => {\n let point = tick.point;\n if (!alignTick) {\n // tickLine 不同 tick 对齐时需要调整 point\n point = this.getTickPoint(tick.value - tickSegment / 2);\n }\n const endPoint = this.getSidePoint(point, tickLineLength);\n tickLineItems.push({\n startPoint: point,\n tickValue: tick.value,\n endPoint,\n tickId: tick.id,\n id: `tickline-${tick.id}`,\n });\n });\n\n // 如果 tickLine 不居中对齐,则需要在最后面补充一个 tickLine\n // if (!alignTick && tickCount > 0) {\n // const tick = ticks[tickCount - 1];\n // const point = this.getTickPoint(tick.value + tickSegment / 2);\n // }\n return tickLineItems;\n }\n\n private getSubTickLineItems(tickLineItems) {\n const subTickLineItems = [];\n const subTickLine = this.get('subTickLine');\n const subCount = subTickLine.count;\n const tickLineCount = tickLineItems.length;\n // 刻度线的数量大于 2 时,才绘制子刻度\n if (tickLineCount >= 2) {\n for (let i = 0; i < tickLineCount - 1; i++) {\n const pre = tickLineItems[i];\n const next = tickLineItems[i + 1];\n for (let j = 0; j < subCount; j++) {\n const percent = (j + 1) / (subCount + 1);\n const tickValue = (1 - percent) * pre.tickValue + percent * next.tickValue;\n const point = this.getTickPoint(tickValue);\n const endPoint = this.getSidePoint(point, subTickLine.length);\n subTickLineItems.push({\n startPoint: point,\n endPoint,\n tickValue,\n id: `sub-${pre.id}-${j}`,\n });\n }\n }\n }\n return subTickLineItems;\n }\n\n private getTickLineAttrs(tickItem: ListItem, type: string, index: number, tickItems: ListItem[]) {\n let style = this.get(type).style;\n\n // 保持和 grid 相同的数据结构\n const item = {\n points: [tickItem.startPoint, tickItem.endPoint],\n };\n\n const defaultTickLineStyle = get(this.get('theme'), ['tickLine', 'style'], {});\n style = isFunction(style) ? mix({}, defaultTickLineStyle, style(item, index, tickItems)) : style;\n\n const { startPoint, endPoint } = tickItem;\n return {\n x1: startPoint.x,\n y1: startPoint.y,\n x2: endPoint.x,\n y2: endPoint.y,\n ...style,\n };\n }\n\n // 绘制坐标轴刻度线\n private drawTick(tickItem: ListItem, tickLineGroup: IGroup, type: string, index: number, tickItems: ListItem[]) {\n this.addShape(tickLineGroup, {\n type: 'line',\n id: this.getElementId(tickItem.id),\n name: `axis-${type}`,\n attrs: this.getTickLineAttrs(tickItem, type, index, tickItems),\n });\n }\n\n // 绘制坐标轴刻度线,包括子刻度线\n private drawTickLines(group: IGroup) {\n const ticks = this.get('ticks');\n const subTickLine = this.get('subTickLine');\n const tickLineItems = this.getTickLineItems(ticks);\n const tickLineGroup = this.addGroup(group, {\n name: 'axis-tickline-group',\n id: this.getElementId('tickline-group'),\n });\n const tickCfg = this.get('tickLine');\n each(tickLineItems, (item, index) => {\n if (tickCfg.displayWithLabel) {\n // 如果跟随 label 显示,则检测是否存在对应的 label\n const labelId = this.getElementId(`label-${item.tickId}`);\n if (group.findById(labelId)) {\n this.drawTick(item, tickLineGroup, 'tickLine', index, tickLineItems);\n }\n } else {\n this.drawTick(item, tickLineGroup, 'tickLine', index, tickLineItems);\n }\n });\n\n if (subTickLine) {\n const subTickLineItems = this.getSubTickLineItems(tickLineItems);\n each(subTickLineItems, (item, index: number) => {\n this.drawTick(item, tickLineGroup, 'subTickLine', index, subTickLineItems);\n });\n }\n }\n\n // 预处理 ticks 确定位置和补充 id\n private processTicks() {\n const ticks = this.get('ticks');\n each(ticks, (tick) => {\n tick.point = this.getTickPoint(tick.value);\n // 补充 tick 的 id,为动画和更新做准备\n if (isNil(tick.id)) {\n // 默认使用 tick.name 作为id\n tick.id = tick.name;\n }\n });\n }\n\n // 绘制 ticks 包括文本和 tickLine\n private drawTicks(group: IGroup) {\n this.optimizeTicks();\n this.processTicks();\n if (this.get('label')) {\n this.drawLabels(group);\n }\n\n if (this.get('tickLine')) {\n this.drawTickLines(group);\n }\n\n const ticks = this.get('ticks');\n each(ticks, (tick) => {\n this.applyTickStates(tick, group);\n });\n }\n\n /**\n * 根据 optimize 配置对 ticks 进行抽样,对抽样过后的 ticks 才进行真实的渲染\n */\n private optimizeTicks() {\n const optimize: OptimizeCfg = this.get('optimize');\n const ticks = this.get('ticks');\n if (optimize && optimize.enable && optimize.threshold > 0) {\n const len = size(ticks);\n if (len > optimize.threshold) {\n const page = Math.ceil(len / optimize.threshold);\n const optimizedTicks = ticks.filter((tick, idx) => idx % page === 0);\n this.set('ticks', optimizedTicks);\n this.set('originalTicks', ticks);\n }\n }\n }\n\n // 获取 label 的配置项\n private getLabelAttrs(tick: ListItem, index: number, ticks: ListItem[]) {\n const labelCfg = this.get('label');\n const { offset, offsetX, offsetY, rotate, formatter } = labelCfg;\n const point = this.getSidePoint(tick.point, offset);\n const vector = this.getSideVector(offset, point);\n const text = formatter ? formatter(tick.name, tick, index) : tick.name;\n let { style } = labelCfg;\n style = isFunction(style) ? get(this.get('theme'), ['label', 'style'], {}) : style;\n\n const attrs = mix(\n {\n x: point.x + offsetX,\n y: point.y + offsetY,\n text,\n textAlign: this.getTextAnchor(vector),\n textBaseline: this.getTextBaseline(vector),\n },\n style\n );\n if (rotate) {\n attrs.matrix = getMatrixByAngle(point, rotate);\n }\n return attrs;\n }\n\n // 绘制文本\n private drawLabels(group: IGroup) {\n const ticks = this.get('ticks');\n const labelGroup = this.addGroup(group, {\n name: 'axis-label-group',\n id: this.getElementId('label-group'),\n });\n each(ticks, (tick: ListItem, index: number) => {\n this.addShape(labelGroup, {\n type: 'text',\n name: 'axis-label',\n id: this.getElementId(`label-${tick.id}`),\n attrs: this.getLabelAttrs(tick, index, ticks),\n delegateObject: {\n tick,\n item: tick,\n index,\n },\n });\n });\n this.processOverlap(labelGroup);\n\n // 处理完后再进行 style 回调处理\n const labels = labelGroup.getChildren();\n const defaultLabelStyle = get(this.get('theme'), ['label', 'style'], {});\n const { style, formatter } = this.get('label');\n if (isFunction(style)) {\n const afterProcessTicks = labels.map((label) => get(label.get('delegateObject'), 'tick'));\n each(labels, (label, index) => {\n const { tick } = label.get('delegateObject');\n const text = formatter ? formatter(tick.name, tick, index) : tick.name;\n const newStyle = mix({}, defaultLabelStyle, style(text, index, afterProcessTicks));\n label.attr(newStyle);\n });\n }\n }\n\n // 标题的属性\n private getTitleAttrs() {\n const titleCfg = this.get('title');\n const { style, position, offset, spacing = 0, autoRotate } = titleCfg;\n const titleHeight = style.fontSize;\n let percent = 0.5;\n if (position === 'start') {\n percent = 0;\n } else if (position === 'end') {\n percent = 1;\n }\n const point = this.getTickPoint(percent); // 标题对应的坐标轴上的点\n // 如果没有指定 titleOffset 也没有渲染 label,这里需要自动计算 offset\n const titlePoint = this.getSidePoint(point, offset || spacing + titleHeight / 2); // 标题的点\n\n const attrs = mix(\n {\n x: titlePoint.x,\n y: titlePoint.y,\n text: titleCfg.text,\n },\n style\n );\n\n const rotate = titleCfg.rotate; // rotate 是角度值\n let angle = rotate;\n if (isNil(rotate) && autoRotate) {\n // 用户没有设定旋转角度,同时设置自动旋转\n const vector = this.getAxisVector(point);\n const v1: [number, number] = [1, 0]; // 水平方向的向量\n angle = ext.angleTo(vector, v1, true);\n }\n if (angle) {\n const matrix = getMatrixByAngle(titlePoint, angle);\n attrs.matrix = matrix;\n }\n return attrs;\n }\n\n // 绘制标题\n private drawTitle(group: IGroup) {\n const titleAttrs = this.getTitleAttrs();\n const titleShape = this.addShape(group, {\n type: 'text',\n id: this.getElementId('title'),\n name: 'axis-title',\n attrs: titleAttrs\n });\n // description字段存在时,显示icon\n if(this.get('title')?.description) {\n this.drawDescriptionIcon(group, titleShape, titleAttrs.matrix)\n }\n }\n\n private drawDescriptionIcon(group: IGroup, titleShape: IShape, matrix: number[]) {\n const descriptionShape = this.addGroup(group, {\n name: 'axis-description',\n id: this.getElementById('description')\n })\n\n const { maxX, maxY, height } = titleShape.getBBox();\n const { iconStyle } = this.get('title')\n const spacing = 4; // 设置icon与文本之间距离\n const r = height / 2;\n const lineWidth = r / 6;\n const startX = maxX + spacing;\n const startY = maxY - height / 2;\n // 绘制 information icon 路径\n // 外圆环path\n const [x0, y0] = [startX + r, startY - r];\n const [x1, y1] = [x0 + r, y0 + r];\n const [x2, y2] = [x0, y1 + r];\n const [x3, y3] = [startX, y0 + r];\n // i path\n const [x4, y4] = [startX + r, startY - height / 4];\n const [x5, y5] = [x4, y4 + lineWidth];\n const [x6, y6] = [x5, y5 + lineWidth];\n const [x7, y7] = [x6, y6 + r * 3 / 4];\n this.addShape(descriptionShape, {\n type: 'path',\n id: this.getElementId('title-description-icon'),\n name: 'axis-title-description-icon',\n attrs: {\n path: [\n ['M', x0, y0],\n ['A', r, r, 0, 0, 1, x1, y1],\n ['A', r, r, 0, 0, 1, x2, y2],\n ['A', r, r, 0, 0, 1, x3, y3],\n ['A', r, r, 0, 0, 1, x0, y0],\n ['M', x4, y4],\n ['L', x5, y5],\n ['M', x6, y6],\n ['L', x7, y7]\n ],\n lineWidth,\n matrix,\n ...iconStyle\n },\n });\n // 点击热区,设置透明矩形\n this.addShape(descriptionShape, {\n type: 'rect',\n id: this.getElementId('title-description-rect'),\n name: 'axis-title-description-rect',\n attrs: {\n x: startX,\n y: startY - height / 2,\n width: height,\n height,\n stroke: '#000',\n fill: '#000',\n opacity: 0,\n matrix,\n cursor: 'pointer'\n }\n })\n\n }\n\n private applyTickStates(tick, group) {\n const states = this.getItemStates(tick);\n if (states.length) {\n const tickStates = this.get('tickStates');\n // 分别更新 label 和 tickLine\n const labelId = this.getElementId(`label-${tick.id}`);\n const labelShape = group.findById(labelId);\n if (labelShape) {\n const labelStateStyle = getStatesStyle(tick, 'label', tickStates);\n labelStateStyle && labelShape.attr(labelStateStyle);\n }\n const tickLineId = this.getElementId(`tickline-${tick.id}`);\n const tickLineShape = group.findById(tickLineId);\n if (tickLineShape) {\n const tickLineStateStyle = getStatesStyle(tick, 'tickLine', tickStates);\n tickLineStateStyle && tickLineShape.attr(tickLineStateStyle);\n }\n }\n }\n\n private updateTickStates(tick) {\n const states = this.getItemStates(tick);\n const tickStates = this.get('tickStates');\n const labelCfg = this.get('label');\n const labelShape = this.getElementByLocalId(`label-${tick.id}`);\n const tickLineCfg = this.get('tickLine');\n const tickLineShape = this.getElementByLocalId(`tickline-${tick.id}`);\n\n if (states.length) {\n if (labelShape) {\n const labelStateStyle = getStatesStyle(tick, 'label', tickStates);\n labelStateStyle && labelShape.attr(labelStateStyle);\n }\n if (tickLineShape) {\n const tickLineStateStyle = getStatesStyle(tick, 'tickLine', tickStates);\n tickLineStateStyle && tickLineShape.attr(tickLineStateStyle);\n }\n } else {\n if (labelShape) {\n labelShape.attr(labelCfg.style);\n }\n if (tickLineShape) {\n tickLineShape.attr(tickLineCfg.style);\n }\n }\n }\n}\n\nexport default AxisBase;\n","import { IGroup } from '@antv/g-base';\nimport { each } from '@antv/util';\nimport { ellipsisLabel } from '../../util/label';\n\nfunction ellipseLabels(isVertical: boolean, labelGroup: IGroup, limitLength: number, position: string): boolean {\n const children = labelGroup.getChildren();\n let ellipsisFlag = false;\n each(children, (label) => {\n const rst = ellipsisLabel(isVertical, label, limitLength, position);\n ellipsisFlag = ellipsisFlag || rst;\n });\n return ellipsisFlag;\n}\n\nexport function getDefault() {\n return ellipsisTail;\n}\n\nexport function ellipsisHead(isVertical: boolean, labelGroup: IGroup, limitLength: number): boolean {\n return ellipseLabels(isVertical, labelGroup, limitLength, 'head');\n}\n\nexport function ellipsisTail(isVertical: boolean, labelGroup: IGroup, limitLength: number): boolean {\n return ellipseLabels(isVertical, labelGroup, limitLength, 'tail');\n}\n\nexport function ellipsisMiddle(isVertical: boolean, labelGroup: IGroup, limitLength: number): boolean {\n return ellipseLabels(isVertical, labelGroup, limitLength, 'middle');\n}\n","import { IElement, IGroup } from '@antv/g-base';\nimport { AxisLabelAutoHideCfg } from '../../types';\nimport { getMaxLabelWidth } from '../../util/label';\nimport { getAngleByMatrix } from '../../util/matrix';\nimport { near } from '../../util/util';\n\n// 文本是否旋转\nfunction isRotate(label: IElement) {\n const matrix = label.attr('matrix');\n return matrix && matrix[0] !== 1; // 仅在这个场景下判定\n}\n\nfunction getRotateAngle(label: IElement) {\n const angle = isRotate(label) ? getAngleByMatrix(label.attr('matrix')) : 0;\n return angle % 360;\n}\n\n// autohide 不再考虑超出限制\n// function isOutLimit(isVertical: boolean, label: IElement, limitLength: number) {\n// if (!limitLength) {\n// // 如果没限制 limitLength 则直接返回 false\n// return false;\n// }\n// const canvasBBox = label.getCanvasBBox();\n// let isOut = false;\n// if (isVertical) {\n// isOut = canvasBBox.width > limitLength;\n// } else {\n// isOut = canvasBBox.height > limitLength;\n// }\n// return isOut;\n// }\n\n// 是否重叠\nfunction isOverlap(isVertical: boolean, first: IElement, second: IElement, minGap: number) {\n let overlap = false;\n const angle = getRotateAngle(first);\n const distance = isVertical\n ? Math.abs(second.attr('y') - first.attr('y'))\n : Math.abs(second.attr('x') - first.attr('x'));\n const prevBBox = (isVertical\n ? second.attr('y') > first.attr('y')\n : second.attr('x') > first.attr('x'))\n ? first.getBBox()\n : second.getBBox();\n\n if (isVertical) {\n const ratio = Math.abs(Math.cos(angle));\n if (near(ratio, 0, Math.PI / 180)) {\n overlap = prevBBox.width + minGap > distance;\n } else {\n overlap = prevBBox.height / ratio + minGap > distance;\n }\n } else {\n const ratio = Math.abs(Math.sin(angle));\n if (near(ratio, 0, Math.PI / 180)) {\n overlap = prevBBox.width + minGap > distance;\n } else {\n overlap = prevBBox.height / ratio + minGap > distance;\n }\n }\n\n return overlap;\n}\n\n// 保留第一个或者最后一个\nfunction reserveOne(isVertical: boolean, labelsGroup: IGroup, reversed: boolean, autoHideCfg?: AxisLabelAutoHideCfg) {\n const minGap = autoHideCfg?.minGap || 0;\n const labels = labelsGroup\n .getChildren()\n .slice() // 复制数组\n .filter((item) => item.get('visible'));\n if (!labels.length) {\n return false;\n }\n let hasHide = false;\n if (reversed) {\n // 翻转\n labels.reverse();\n }\n const count = labels.length;\n const first = labels[0];\n let prev = first;\n for (let i = 1; i < count; i++) {\n const label = labels[i];\n const curBBox = label.getBBox();\n // 不再考虑超出限制,而仅仅根据是否重叠进行隐藏 isOutLimit(isVertical, label, limitLength) ||\n const isHide = isOverlap(isVertical, prev, label, minGap);\n if (isHide) {\n label.hide();\n hasHide = true;\n } else {\n prev = label;\n }\n }\n return hasHide;\n}\n\n// 均匀抽样隐藏标签,注意这里假设 label/tick 是均匀的\nfunction parityHide(isVertical: boolean, labelsGroup: IGroup, autoHideCfg?: AxisLabelAutoHideCfg) {\n const minGap = autoHideCfg?.minGap || 0;\n const labels = labelsGroup.getChildren().slice(); // 复制数组\n if (labels.length < 2) {\n // 如果数量小于 2 则直接返回,等于 2 时可能也会重合\n return false;\n }\n let hasHide = false;\n const first = labels[0];\n const firstBBox = first.getBBox();\n const second = labels[1];\n const count = labels.length;\n const angle = getRotateAngle(first);\n const distance = isVertical\n ? Math.abs(second.attr('y') - first.attr('y'))\n : Math.abs(second.attr('x') - first.attr('x'));\n let interval = 0; // 不重叠的坐标文本间距个数\n if (isVertical) {\n // 垂直的坐标轴计算垂直方向的间距\n const ratio = Math.abs(Math.cos(angle));\n if (near(ratio, 0, Math.PI / 180)) {\n const maxWidth = getMaxLabelWidth(labels);\n interval = (maxWidth + minGap) / distance;\n } else {\n interval = (firstBBox.height / ratio + minGap) / distance;\n }\n } else {\n // 水平坐标轴\n const ratio = Math.abs(Math.sin(angle));\n if (near(ratio, 0, Math.PI / 180)) {\n const maxWidth = getMaxLabelWidth(labels);\n interval = (maxWidth + minGap) / distance;\n } else {\n interval = (firstBBox.height / ratio + minGap) / distance;\n }\n }\n // interval > 1 时需要对 label 进行隐藏\n if (interval > 1) {\n interval = Math.ceil(interval);\n for (let i = 0; i < count; i++) {\n if (i % interval !== 0) {\n // 仅保留被整除的 label\n labels[i].hide();\n hasHide = true;\n }\n }\n }\n return hasHide;\n}\n\nexport function getDefault() {\n return equidistance;\n}\n\n/**\n * 保证首个 label 可见,即使超过 limitLength 也不隐藏\n * @param {boolean} isVertical 是否垂直\n * @param {IGroup} labelsGroup label 的分组\n * @param {number} limitLength 另一个方向的长度限制,autoHide 不关心\n * @param {AxisLabelAutoHideCfg} autoHideCfg autoHide overlap 的可选配置参数\n */\nexport function reserveFirst(\n isVertical: boolean,\n labelsGroup: IGroup,\n limitLength?: number,\n autoHideCfg?: AxisLabelAutoHideCfg\n): boolean {\n return reserveOne(isVertical, labelsGroup, false, autoHideCfg);\n}\n\n/**\n * 保证最后一个 label 可见,即使超过 limitLength 也不隐藏\n * @param {boolean} isVertical 是否垂直\n * @param {IGroup} labelsGroup label 的分组\n * @param {number} limitLength 另一个方向的长度限制,autoHide 不关心\n * @param {AxisLabelAutoHideCfg} autoHideCfg autoHide overlap 的可选配置参数\n */\nexport function reserveLast(\n isVertical: boolean,\n labelsGroup: IGroup,\n limitLength?: number,\n autoHideCfg?: AxisLabelAutoHideCfg\n): boolean {\n return reserveOne(isVertical, labelsGroup, true, autoHideCfg);\n}\n\n/**\n * 保证第一个最后一个 label 可见,即使超过 limitLength 也不隐藏\n * @param {boolean} isVertical 是否垂直\n * @param {IGroup} labelsGroup label 的分组\n * @param {number} limitLength 另一个方向的长度限制,autoHide 不关心\n * @param {AxisLabelAutoHideCfg} autoHideCfg autoHide overlap 的可选配置参数\n */\nexport function reserveBoth(\n isVertical: boolean,\n labelsGroup: IGroup,\n limitLength?: number,\n autoHideCfg?: AxisLabelAutoHideCfg\n): boolean {\n const minGap = autoHideCfg?.minGap || 0;\n const labels = labelsGroup.getChildren().slice(); // 复制数组\n if (labels.length <= 2) {\n // 如果数量小于或等于 2 则直接返回\n return false;\n }\n let hasHide = false;\n const count = labels.length;\n const first = labels[0];\n const last = labels[count - 1];\n let preLabel = first;\n // 按照先保存第一个的逻辑循环一遍,最后一个不参与循环\n for (let i = 1; i < count - 1; i++) {\n const label = labels[i];\n const curBBox = label.getBBox();\n // 废弃 isOutLimit(isVertical, label, limitLength) ||\n const isHide = isOverlap(isVertical, preLabel, label, minGap);\n if (isHide) {\n label.hide();\n hasHide = true;\n } else {\n preLabel = label;\n }\n }\n\n const overlap = isOverlap(isVertical, preLabel, last, minGap);\n if (overlap) {\n // 发生冲突,则隐藏前一个保留后一个\n preLabel.hide();\n hasHide = true;\n }\n return hasHide;\n}\n\n/**\n * 保证 label 均匀显示 和 不出现重叠,主要解决文本层叠的问题,对于 limitLength 不处理\n * @param {boolean} isVertical 是否垂直\n * @param {IGroup} labelsGroup label 的分组\n * @param {number} limitLength 另一个方向的长度限制,autoHide 不关心\n * @param {AxisLabelAutoHideCfg} autoHideCfg autoHide overlap 的可选配置参数\n */\nexport function equidistance(\n isVertical: boolean,\n labelsGroup: IGroup,\n limitLength?: number,\n autoHideCfg?: AxisLabelAutoHideCfg\n): boolean {\n let hasHide = parityHide(isVertical, labelsGroup, autoHideCfg);\n\n // 处理 timeCat 类型的 tick,在均匀的基础上,再次检查出现重叠的进行隐藏\n if (reserveOne(isVertical, labelsGroup, false)) {\n hasHide = true;\n }\n\n return hasHide;\n}\n\n/**\n * 同 equidistance, 首先会保证 labels 均匀显示,然后会保留首尾\n * @param isVertical\n * @param labelsGroup\n * @param {number} limitLength 另一个方向的长度限制,autoHide 不关心\n * @param {AxisLabelAutoHideCfg} autoHideCfg autoHide overlap 的可选配置参数\n */\nexport function equidistanceWithReverseBoth(\n isVertical: boolean,\n labelsGroup: IGroup,\n limitLength?: number,\n autoHideCfg?: AxisLabelAutoHideCfg\n): boolean {\n const labels = labelsGroup.getChildren().slice(); // 复制数组\n let hasHide = parityHide(isVertical, labelsGroup, autoHideCfg);\n\n if (labels.length > 2) {\n const first = labels[0];\n const last = labels[labels.length - 1];\n\n // 如果第一个被隐藏了\n if (!first.get('visible')) {\n first.show();\n if (reserveOne(isVertical, labelsGroup, false, autoHideCfg)) {\n hasHide = true;\n }\n }\n\n // 如果最后一个被隐藏了\n if (!last.get('visible')) {\n last.show();\n if (reserveOne(isVertical, labelsGroup, true, autoHideCfg)) {\n hasHide = true;\n }\n }\n }\n\n return hasHide;\n}\n","import { IElement, IGroup } from '@antv/g-base';\nimport { each, isNumber } from '@antv/util';\nimport { getMaxLabelWidth } from '../../util/label';\nimport { getMatrixByAngle } from '../../util/matrix';\nimport Theme from '../../util/theme';\n\n// 统一设置文本的角度\nfunction setLabelsAngle(labels: IElement[], angle: number) {\n each(labels, (label) => {\n const x = label.attr('x');\n const y = label.attr('y');\n const matrix = getMatrixByAngle({ x, y }, angle);\n label.attr('matrix', matrix);\n });\n}\n\ntype getAngleCallback = (limitLength: number, maxWidth: number) => number;\n\n// 旋转文本\nfunction labelRotate(\n isVertical: boolean,\n labelsGroup: IGroup,\n limitLength: number,\n getAngle: getAngleCallback\n): boolean {\n const labels = labelsGroup.getChildren();\n if (!labels.length) {\n return false;\n }\n if (!isVertical && labels.length < 2) {\n // 水平时至少有两个时才旋转\n return false;\n }\n\n const maxWidth = getMaxLabelWidth(labels);\n let isOverlap = false;\n if (isVertical) {\n // limitLength 为 0 或者 null 时不生效\n isOverlap = !!limitLength && maxWidth > limitLength;\n } else {\n // 同 limitLength 无关\n const tickWidth = Math.abs(labels[1].attr('x') - labels[0].attr('x'));\n isOverlap = maxWidth > tickWidth;\n }\n\n if (isOverlap) {\n const angle = getAngle(limitLength, maxWidth);\n setLabelsAngle(labels, angle);\n }\n return isOverlap;\n}\n\nexport function getDefault() {\n return fixedAngle;\n}\n\n/**\n * 固定角度旋转文本\n * @param {boolean} isVertical 是否垂直方向\n * @param {IGroup} labelsGroup 文本的 group\n * @param {number} limitLength 限定长度\n * @param {number} customRotate 自定义旋转角度\n * @return {boolean} 是否发生了旋转\n */\nexport function fixedAngle(\n isVertical: boolean,\n labelsGroup: IGroup,\n limitLength: number,\n customRotate?: number\n): boolean {\n return labelRotate(isVertical, labelsGroup, limitLength, () => {\n if (isNumber(customRotate)) {\n return customRotate;\n }\n return isVertical ? Theme.verticalAxisRotate : Theme.horizontalAxisRotate;\n });\n}\n\n/**\n * 非固定角度旋转文本\n * @param {boolean} isVertical 是否垂直方向\n * @param {IGroup} labelsGroup 文本的 group\n * @param {number} limitLength 限定长度\n * @return {boolean} 是否发生了旋转\n */\nexport function unfixedAngle(isVertical: boolean, labelsGroup: IGroup, limitLength: number): boolean {\n return labelRotate(isVertical, labelsGroup, limitLength, (length, maxWidth) => {\n if (!length) {\n // 如果没有设置 limitLength,则使用固定的角度旋转\n return isVertical ? Theme.verticalAxisRotate : Theme.horizontalAxisRotate;\n }\n if (isVertical) {\n // 垂直时不需要判定 limitLength > maxWidth ,因为此时不会 overlap\n return -Math.acos(length / maxWidth);\n } else {\n let angle = 0;\n if (length > maxWidth) {\n // 需要判定,asin 的参数 -1, 1\n angle = Math.PI / 4;\n } else {\n angle = Math.asin(length / maxWidth);\n if (angle > Math.PI / 4) {\n // 大于 Math.PI / 4 时没意义\n angle = Math.PI / 4;\n }\n }\n return angle;\n }\n });\n}\n","import { IGroup } from '@antv/g-base';\nimport { vec2 } from '@antv/matrix-util';\nimport { each, isFunction, isNil, isNumberEqual, isObject } from '@antv/util';\nimport { ILocation } from '../interfaces';\nimport { AxisLabelAutoHideCfg, BBox, LineAxisCfg, Point, RegionLocationCfg } from '../types';\nimport Theme from '../util/theme';\nimport AxisBase from './base';\nimport * as OverlapUtil from './overlap';\n\nclass Line extends AxisBase implements ILocation {\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n type: 'line',\n locationType: 'region',\n /**\n * 起始点, x, y\n * @type {object}\n */\n start: null,\n /**\n * 结束点, x, y\n * @type {object}\n */\n end: null,\n };\n }\n\n // 获取坐标轴线的 path\n public getLinePath(): any[] {\n const start = this.get('start');\n const end = this.get('end');\n const path = [];\n path.push(['M', start.x, start.y]);\n path.push(['L', end.x, end.y]);\n return path;\n }\n\n // 重新计算 layout bbox,考虑到 line 不显示\n protected getInnerLayoutBBox(): BBox {\n const start = this.get('start');\n const end = this.get('end');\n const bbox = super.getInnerLayoutBBox();\n const minX = Math.min(start.x, end.x, bbox.x);\n const minY = Math.min(start.y, end.y, bbox.y);\n const maxX = Math.max(start.x, end.x, bbox.maxX);\n const maxY = Math.max(start.y, end.y, bbox.maxY);\n return {\n x: minX,\n y: minY,\n minX,\n minY,\n maxX,\n maxY,\n width: maxX - minX,\n height: maxY - minY,\n };\n }\n\n protected isVertical() {\n const start = this.get('start');\n const end = this.get('end');\n return isNumberEqual(start.x, end.x);\n }\n\n protected isHorizontal() {\n const start = this.get('start');\n const end = this.get('end');\n return isNumberEqual(start.y, end.y);\n }\n\n protected getTickPoint(tickValue: number): Point {\n const self = this;\n const start = self.get('start');\n const end = self.get('end');\n const regionX = end.x - start.x;\n const regionY = end.y - start.y;\n return {\n x: start.x + regionX * tickValue,\n y: start.y + regionY * tickValue,\n };\n }\n\n // 直线坐标轴下任一点的向量方向都相同\n protected getSideVector(offset: number) {\n const axisVector = this.getAxisVector();\n const normal = vec2.normalize([0, 0], axisVector);\n const factor = this.get('verticalFactor');\n const verticalVector: [number, number] = [normal[1], normal[0] * -1]; // 垂直方向,逆时针方向\n return vec2.scale([0, 0], verticalVector, offset * factor);\n }\n\n // 获取坐标轴的向量\n protected getAxisVector(): [number, number] {\n const start = this.get('start');\n const end = this.get('end');\n return [end.x - start.x, end.y - start.y];\n }\n\n protected processOverlap(labelGroup) {\n const isVertical = this.isVertical();\n const isHorizontal = this.isHorizontal();\n // 非垂直,或者非水平时不处理遮挡问题\n if (!isVertical && !isHorizontal) {\n return;\n }\n const labelCfg = this.get('label');\n const titleCfg = this.get('title');\n const verticalLimitLength = this.get('verticalLimitLength');\n const labelOffset = labelCfg.offset;\n let limitLength = verticalLimitLength;\n let titleHeight = 0;\n let titleSpacing = 0;\n if (titleCfg) {\n titleHeight = titleCfg.style.fontSize;\n titleSpacing = titleCfg.spacing;\n }\n if (limitLength) {\n limitLength = limitLength - labelOffset - titleSpacing - titleHeight;\n }\n const overlapOrder = this.get('overlapOrder');\n each(overlapOrder, (name) => {\n if (labelCfg[name] && this.canProcessOverlap(name)) {\n this.autoProcessOverlap(name, labelCfg[name], labelGroup, limitLength);\n }\n });\n if (titleCfg) {\n if (isNil(titleCfg.offset)) {\n // 调整 title 的 offset\n const bbox = labelGroup.getCanvasBBox();\n const length = isVertical ? bbox.width : bbox.height;\n // 如果用户没有设置 offset,则自动计算\n titleCfg.offset = labelOffset + length + titleSpacing + titleHeight / 2;\n }\n }\n }\n\n /**\n * 是否可以执行某一 overlap\n * @param name\n */\n private canProcessOverlap(name: string) {\n const labelCfg = this.get('label');\n\n // 对 autoRotate,如果配置了旋转角度,直接进行固定角度旋转\n if (name === 'autoRotate') {\n return isNil(labelCfg.rotate);\n }\n\n // 默认所有 overlap 都可执行\n return true;\n }\n\n private autoProcessOverlap(name: string, value: any, labelGroup: IGroup, limitLength: number) {\n const isVertical = this.isVertical();\n let hasAdjusted = false;\n const util = OverlapUtil[name];\n if (value === true) {\n const labelCfg = this.get('label');\n // true 形式的配置:使用 overlap 默认的的处理方法进行处理\n hasAdjusted = util.getDefault()(isVertical, labelGroup, limitLength);\n } else if (isFunction(value)) {\n // 回调函数形式的配置: 用户可以传入回调函数\n hasAdjusted = value(isVertical, labelGroup, limitLength);\n } else if (isObject(value)) {\n // object 形式的配置方式:包括 处理方法 type, 和可选参数配置 cfg\n const overlapCfg = value as { type: string; cfg?: AxisLabelAutoHideCfg };\n if (util[overlapCfg.type]) {\n hasAdjusted = util[overlapCfg.type](isVertical, labelGroup, limitLength, overlapCfg.cfg);\n }\n } else if (util[value]) {\n // 字符串类型的配置:按照名称执行 overlap 处理方法\n hasAdjusted = util[value](isVertical, labelGroup, limitLength);\n }\n if (name === 'autoRotate') {\n // 文本旋转后,文本的对齐方式可能就不合适了\n if (hasAdjusted) {\n const labels = labelGroup.getChildren();\n const verticalFactor = this.get('verticalFactor');\n each(labels, (label) => {\n const textAlign = label.attr('textAlign');\n if (textAlign === 'center') {\n // 居中的文本需要调整旋转度\n const newAlign = verticalFactor > 0 ? 'end' : 'start';\n label.attr('textAlign', newAlign);\n }\n });\n }\n } else if (name === 'autoHide') {\n const children = labelGroup.getChildren().slice(0); // 复制数组,删除时不会出错\n each(children, (label) => {\n if (!label.get('visible')) {\n if (this.get('isRegister')) {\n // 已经注册过了,则删除\n this.unregisterElement(label);\n }\n label.remove(); // 防止 label 数量太多,所以统一删除\n }\n });\n }\n }\n}\n\nexport default Line;\n","import { IGroup } from '@antv/g-base';\nimport { each, isNil, isFunction, isObject } from '@antv/util';\nimport { vec2 } from '@antv/matrix-util';\nimport AxisBase from './base';\nimport * as OverlapUtil from './overlap';\nimport type { AxisLabelAutoHideCfg } from '../types';\nimport type { CircleAxisCfg, Point, } from '../types';\n\nclass Circle extends AxisBase {\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n type: 'circle',\n locationType: 'circle',\n center: null,\n radius: null,\n startAngle: -Math.PI / 2,\n endAngle: (Math.PI * 3) / 2,\n };\n }\n\n protected getLinePath(): any[] {\n const center = this.get('center');\n const x = center.x;\n const y = center.y;\n const rx = this.get('radius');\n const ry = rx;\n const startAngle = this.get('startAngle');\n const endAngle = this.get('endAngle');\n\n let path = [];\n if (Math.abs(endAngle - startAngle) === Math.PI * 2) {\n path = [['M', x, y - ry], ['A', rx, ry, 0, 1, 1, x, y + ry], ['A', rx, ry, 0, 1, 1, x, y - ry], ['Z']];\n } else {\n const startPoint = this.getCirclePoint(startAngle);\n const endPoint = this.getCirclePoint(endAngle);\n const large = Math.abs(endAngle - startAngle) > Math.PI ? 1 : 0;\n const sweep = startAngle > endAngle ? 0 : 1;\n path = [\n ['M', x, y],\n ['L', startPoint.x, startPoint.y],\n ['A', rx, ry, 0, large, sweep, endPoint.x, endPoint.y],\n ['L', x, y],\n ];\n }\n return path;\n }\n\n protected getTickPoint(tickValue): Point {\n const startAngle = this.get('startAngle');\n const endAngle = this.get('endAngle');\n const angle = startAngle + (endAngle - startAngle) * tickValue;\n return this.getCirclePoint(angle);\n }\n\n // 获取垂直于坐标轴的向量\n protected getSideVector(offset: number, point: Point) {\n const center = this.get('center');\n const vector: [number, number] = [point.x - center.x, point.y - center.y];\n const factor = this.get('verticalFactor');\n const vecLen = vec2.length(vector);\n vec2.scale(vector, vector, (factor * offset) / vecLen);\n return vector;\n }\n\n // 获取沿坐标轴方向的向量\n protected getAxisVector(point: Point): [number, number] {\n const center = this.get('center');\n const vector = [point.x - center.x, point.y - center.y];\n return [vector[1], -1 * vector[0]]; // 获取顺时针方向的向量\n }\n\n // 根据圆心和半径获取点\n private getCirclePoint(angle: number, radius?: number) {\n const center = this.get('center');\n radius = radius || this.get('radius');\n return {\n x: center.x + Math.cos(angle) * radius,\n y: center.y + Math.sin(angle) * radius,\n };\n }\n\n /**\n * 是否可以执行某一 overlap\n * @param name\n */\n private canProcessOverlap(name: string) {\n const labelCfg = this.get('label');\n\n // 对 autoRotate,如果配置了旋转角度,直接进行固定角度旋转\n if (name === 'autoRotate') {\n return isNil(labelCfg.rotate);\n }\n\n // 默认所有 overlap 都可执行\n return true;\n }\n\n protected processOverlap(labelGroup) {\n const labelCfg = this.get('label');\n const titleCfg = this.get('title');\n const verticalLimitLength = this.get('verticalLimitLength');\n const labelOffset = labelCfg.offset;\n let limitLength = verticalLimitLength;\n let titleHeight = 0;\n let titleSpacing = 0;\n if (titleCfg) {\n titleHeight = titleCfg.style.fontSize;\n titleSpacing = titleCfg.spacing;\n }\n if (limitLength) {\n limitLength = limitLength - labelOffset - titleSpacing - titleHeight;\n }\n const overlapOrder = this.get('overlapOrder');\n each(overlapOrder, (name) => {\n if (labelCfg[name] && this.canProcessOverlap(name)) {\n this.autoProcessOverlap(name, labelCfg[name], labelGroup, limitLength);\n }\n });\n if (titleCfg) {\n if (isNil(titleCfg.offset)) {\n // 调整 title 的 offset\n const { height: length } = labelGroup.getCanvasBBox();\n // 如果用户没有设置 offset,则自动计算\n titleCfg.offset = labelOffset + length + titleSpacing + titleHeight / 2;\n }\n }\n }\n\n private autoProcessOverlap(name: string, value: any, labelGroup: IGroup, limitLength: number) {\n let hasAdjusted = false;\n const util = OverlapUtil[name];\n if (limitLength > 0) {\n if (value === true) {\n // true 形式的配置:使用 overlap 默认的的处理方法进行处理\n hasAdjusted = util.getDefault()(false, labelGroup, limitLength);\n } else if (isFunction(value)) {\n // 回调函数形式的配置: 用户可以传入回调函数\n hasAdjusted = value(false, labelGroup, limitLength);\n } else if (isObject(value)) {\n // object 形式的配置方式:包括 处理方法 type, 和可选参数配置 cfg\n const overlapCfg = value as { type: string; cfg?: AxisLabelAutoHideCfg };\n if (util[overlapCfg.type]) {\n hasAdjusted = util[overlapCfg.type](false, labelGroup, limitLength, overlapCfg.cfg);\n }\n } else if (util[value]) {\n // 字符串类型的配置:按照名称执行 overlap 处理方法\n hasAdjusted = util[value](false, labelGroup, limitLength);\n }\n }\n if (name === 'autoRotate') {\n // 文本旋转后,文本的对齐方式可能就不合适了\n if (hasAdjusted) {\n const labels = labelGroup.getChildren();\n const verticalFactor = this.get('verticalFactor');\n each(labels, (label) => {\n const textAlign = label.attr('textAlign');\n if (textAlign === 'center') {\n // 居中的文本需要调整旋转度\n const newAlign = verticalFactor > 0 ? 'end' : 'start';\n label.attr('textAlign', newAlign);\n }\n });\n }\n } else if (name === 'autoHide') {\n const children = labelGroup.getChildren().slice(0); // 复制数组,删除时不会出错\n each(children, (label) => {\n if (!label.get('visible')) {\n if (this.get('isRegister')) {\n // 已经注册过了,则删除\n this.unregisterElement(label);\n }\n label.remove(); // 防止 label 数量太多,所以统一删除\n }\n });\n }\n }\n}\n\nexport default Circle;\n","import { IGroup } from '@antv/g-base';\nimport { isNil } from '@antv/util';\nimport GroupComponent from '../abstract/group-component';\nimport { CrosshairBaseCfg, Point } from '../types';\nimport { getMatrixByAngle } from '../util/matrix';\nimport Theme from '../util/theme';\nimport { formatPadding } from '../util/util';\n\nabstract class CrosshairBase extends GroupComponent {\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n name: 'crosshair',\n type: 'base',\n line: {},\n text: null,\n textBackground: {},\n capture: false, // 不能被拾取\n defaultCfg: {\n line: {\n style: {\n lineWidth: 1,\n stroke: Theme.lineColor,\n },\n },\n text: {\n position: 'start',\n offset: 10,\n autoRotate: false,\n content: null,\n style: {\n fill: Theme.textColor,\n textAlign: 'center',\n textBaseline: 'middle',\n fontFamily: Theme.fontFamily,\n },\n },\n textBackground: {\n padding: 5,\n style: {\n stroke: Theme.lineColor,\n },\n },\n },\n };\n }\n\n protected renderInner(group: IGroup) {\n if (this.get('line')) {\n this.renderLine(group);\n }\n if (this.get('text')) {\n this.renderText(group);\n this.renderBackground(group);\n }\n }\n\n /**\n * @protected\n * 获取文本点的位置\n * @return {Point} 文本的位置\n */\n protected abstract getTextPoint(): Point;\n\n protected abstract getRotateAngle(): number;\n\n protected renderText(group: IGroup) {\n const text = this.get('text');\n const { style, autoRotate, content } = text;\n if (!isNil(content)) {\n const textPoint = this.getTextPoint();\n let matrix = null;\n if (autoRotate) {\n const angle = this.getRotateAngle();\n matrix = getMatrixByAngle(textPoint, angle);\n }\n this.addShape(group, {\n type: 'text',\n name: 'crosshair-text',\n id: this.getElementId('text'),\n attrs: {\n ...textPoint,\n text: content,\n matrix,\n ...style,\n },\n });\n }\n }\n\n protected abstract getLinePath(): any[];\n\n protected renderLine(group: IGroup) {\n const path = this.getLinePath();\n const line = this.get('line');\n const style = line.style;\n this.addShape(group, {\n type: 'path',\n name: 'crosshair-line',\n id: this.getElementId('line'),\n attrs: {\n path,\n ...style,\n },\n });\n }\n\n // 绘制文本的背景\n private renderBackground(group: IGroup) {\n const textId = this.getElementId('text');\n const textShape = group.findById(textId); // 查找文本\n const textBackground = this.get('textBackground');\n\n if (textBackground && textShape) {\n const textBBox = textShape.getBBox();\n const padding = formatPadding(textBackground.padding); // 用户传入的 padding 格式不定\n const style = textBackground.style;\n const backgroundShape = this.addShape(group, {\n type: 'rect',\n name: 'crosshair-text-background',\n id: this.getElementId('text-background'),\n attrs: {\n x: textBBox.x - padding[3],\n y: textBBox.y - padding[0],\n width: textBBox.width + padding[1] + padding[3],\n height: textBBox.height + padding[0] + padding[2],\n matrix: textShape.attr('matrix'),\n ...style,\n },\n });\n backgroundShape.toBack();\n }\n }\n}\n\nexport default CrosshairBase;\n","import { ILocation } from '../interfaces';\nimport { LineCrosshairCfg, Point, RegionLocationCfg } from '../types';\nimport { getTextPoint } from '../util/util';\nimport CrosshairBase from './base';\n\nclass LineCrosshair extends CrosshairBase implements ILocation {\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n type: 'line',\n locationType: 'region',\n start: null,\n end: null,\n };\n }\n\n // 直线的文本需要同直线垂直\n protected getRotateAngle(): number {\n const { start, end } = this.getLocation();\n const { position } = this.get('text');\n const angle = Math.atan2(end.y - start.y, end.x - start.x);\n const tangentAngle = position === 'start' ? angle - Math.PI / 2 : angle + Math.PI / 2;\n return tangentAngle;\n }\n\n protected getTextPoint() {\n const { start, end } = this.getLocation();\n const { position, offset } = this.get('text');\n return getTextPoint(start, end, position, offset);\n }\n\n protected getLinePath(): any[] {\n const { start, end } = this.getLocation();\n return [\n ['M', start.x, start.y],\n ['L', end.x, end.y],\n ];\n }\n}\n\nexport default LineCrosshair;\n","import { ILocation } from '../interfaces';\nimport { CircleCrosshairCfg, CircleLocationCfg, Point } from '../types';\nimport { getCirclePoint } from '../util/util';\nimport CrosshairBase from './base';\n\nclass LineCrosshair extends CrosshairBase implements ILocation {\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n type: 'circle',\n locationType: 'circle',\n center: null,\n radius: 100,\n startAngle: -Math.PI / 2,\n endAngle: (Math.PI * 3) / 2,\n };\n }\n\n protected getRotateAngle(): number {\n const { startAngle, endAngle } = this.getLocation();\n const { position } = this.get('text');\n const tangentAngle = position === 'start' ? startAngle + Math.PI / 2 : endAngle - Math.PI / 2;\n return tangentAngle;\n }\n\n protected getTextPoint(): Point {\n const text = this.get('text');\n const { position, offset } = text;\n const { center, radius, startAngle, endAngle } = this.getLocation();\n const angle = position === 'start' ? startAngle : endAngle;\n const tangentAngle = this.getRotateAngle() - Math.PI;\n const point = getCirclePoint(center, radius, angle);\n // 这个地方其实应该求切线向量然后在乘以 offset,但是太啰嗦了,直接给出结果\n // const tangent = [Math.cos(tangentAngle), Math.sin(tangentAngle)];\n // const offsetVector = vec2.scale([], tangent, offset);\n const offsetX = Math.cos(tangentAngle) * offset;\n const offsetY = Math.sin(tangentAngle) * offset;\n return {\n x: point.x + offsetX,\n y: point.y + offsetY,\n };\n }\n\n protected getLinePath(): any[] {\n const { center, radius, startAngle, endAngle } = this.getLocation();\n let path = null;\n if (endAngle - startAngle === Math.PI * 2) {\n // 整圆\n const { x, y } = center;\n path = [\n ['M', x, y - radius],\n ['A', radius, radius, 0, 1, 1, x, y + radius],\n ['A', radius, radius, 0, 1, 1, x, y - radius],\n ['Z'],\n ];\n } else {\n const startPoint = getCirclePoint(center, radius, startAngle);\n const endPoint = getCirclePoint(center, radius, endAngle);\n const large = Math.abs(endAngle - startAngle) > Math.PI ? 1 : 0;\n const sweep = startAngle > endAngle ? 0 : 1;\n path = [\n ['M', startPoint.x, startPoint.y],\n ['A', radius, radius, 0, large, sweep, endPoint.x, endPoint.y],\n ];\n }\n return path;\n }\n}\n\nexport default LineCrosshair;\n","export const CONTAINER_CLASS = 'g2-crosshair';\nexport const CROSSHAIR_LINE = `${CONTAINER_CLASS}-line`;\nexport const CROSSHAIR_TEXT = `${CONTAINER_CLASS}-text`;\n","import Theme from '../util/theme';\n\n// tooltip 相关 dom 的 css 类名\nimport * as CssConst from './css-const';\n\nexport default {\n // css style for tooltip\n [`${CssConst.CONTAINER_CLASS}`]: {\n position: 'relative'\n },\n [`${CssConst.CROSSHAIR_LINE}`]: {\n position: 'absolute',\n backgroundColor: 'rgba(0, 0, 0, 0.25)',\n },\n [`${CssConst.CROSSHAIR_TEXT}`]: {\n position: 'absolute',\n color: Theme.textColor,\n fontFamily: Theme.fontFamily,\n }\n};","import { createDom, modifyCSS } from '@antv/dom-util';\nimport { substitute, hasKey } from '@antv/util';\nimport { toPx, getTextPoint } from '../util/util';\nimport HtmlComponent from '../abstract/html-component';\nimport * as CssConst from './css-const';\nimport HtmlTheme from './html-theme';\nimport {HtmlCrossHairCfg} from '../types';\nclass HtmlCrosshair extends HtmlComponent {\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n name: 'crosshair',\n type: 'html',\n locationType: 'region',\n start: {x: 0, y: 0}, // 防止初始化报错\n end: {x: 0, y: 0}, // 防止初始化报错\n capture: false,\n text: null,\n containerTpl: `
`,\n crosshairTpl: `
`,\n textTpl: `{content}`,\n domStyles: null,\n containerClassName: CssConst.CONTAINER_CLASS,\n defaultStyles: HtmlTheme,\n defaultCfg: {\n text: {\n position: 'start',\n content: null,\n align: 'center',\n offset: 10\n }\n },\n };\n }\n\n render() {\n this.resetText();\n this.resetPosition();\n }\n\n // 绘制 crosshair\n private initCrossHair() {\n const container = this.getContainer();\n const crosshairTpl = this.get('crosshairTpl');\n const crosshairEl = createDom(crosshairTpl);\n container.appendChild(crosshairEl);\n this.applyStyle(CssConst.CROSSHAIR_LINE, crosshairEl);\n this.set('crosshairEl', crosshairEl);\n }\n\n // 获取文本的位置\n private getTextPoint() {\n const { start, end } = this.getLocation();\n const { position, offset } = this.get('text');\n return getTextPoint(start, end, position, offset);\n }\n\n // 设置 text\n private resetText() {\n const text = this.get('text');\n let textEl = this.get('textEl') as HTMLElement;\n if (text) {\n const {content} = text;\n if (!textEl) {\n const container = this.getContainer();\n const textTpl = substitute(this.get('textTpl'), text);\n textEl = createDom(textTpl);\n container.appendChild(textEl);\n this.applyStyle(CssConst.CROSSHAIR_TEXT, textEl);\n this.set('textEl', textEl);\n }\n textEl.innerHTML = content;\n } else if (textEl) {\n textEl.remove();\n }\n }\n // 是否垂直\n private isVertical(start, end) {\n return start.x === end.x;\n }\n // 重新调整位置\n protected resetPosition() {\n let crosshairEl = this.get('crosshairEl');\n if (!crosshairEl) {\n this.initCrossHair();\n crosshairEl = this.get('crosshairEl');\n }\n const start = this.get('start');\n const end = this.get('end');\n const minX = Math.min(start.x, end.x);\n const minY = Math.min(start.y, end.y);\n if (this.isVertical(start, end)) {\n modifyCSS(crosshairEl, {\n width: '1px',\n height: toPx(Math.abs(end.y - start.y))\n });\n } else {\n modifyCSS(crosshairEl, {\n height: '1px',\n width: toPx(Math.abs(end.x - start.x))\n });\n }\n modifyCSS(crosshairEl, {\n top: toPx(minY),\n left: toPx(minX)\n });\n this.alignText();\n }\n\n private alignText() {\n // 重新设置 text 位置\n const textEl = this.get('textEl');\n if (textEl) {\n const { align } = this.get('text');\n const clientWidth = textEl.clientWidth;\n const point = this.getTextPoint();\n switch(align) {\n case 'center': \n point.x = point.x - clientWidth / 2;\n break;\n case 'right':\n point.x = point.x - clientWidth;\n case 'left':\n break;\n }\n modifyCSS(textEl, {\n top: toPx(point.y),\n left: toPx(point.x)\n });\n }\n }\n\n protected updateInner(cfg: Partial) {\n if (hasKey(cfg, 'text')) {\n this.resetText();\n }\n super.updateInner(cfg);\n }\n}\n\nexport default HtmlCrosshair;","import { IGroup } from '@antv/g-base';\nimport { each, isString, mix, isFunction } from '@antv/util';\nimport GroupComponent from '../abstract/group-component';\nimport { GridBaseCfg, GroupComponentCfg, Point } from '../types';\nimport Theme from '../util/theme';\n\nabstract class GridBase extends GroupComponent {\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n name: 'grid',\n line: {},\n alternateColor: null,\n capture: false,\n items: [],\n closed: false,\n defaultCfg: {\n line: {\n type: 'line', // 对于 line 类型的 grid 有 line, smooth 两种,cirle 类型的 grid 有 line 和 circle\n style: {\n lineWidth: 1,\n stroke: Theme.lineColor,\n },\n },\n },\n };\n }\n\n /**\n * 获取栅格线的类型\n * @return {string} 栅格线类型\n */\n protected getLineType(): string {\n const line = this.get('line') || this.get('defaultCfg').line;\n return line.type;\n }\n\n protected renderInner(group: IGroup) {\n this.drawGrid(group);\n }\n\n /**\n * 获取栅格线的路径\n * @param {Point[]} points 栅格线的点集合\n * @param {boolean} reversed 顺序是否相反\n * @return {any[]} 路径\n */\n protected abstract getGridPath(points: Point[], reversed?: boolean): any[];\n\n protected getAlternatePath(prePoints: Point[], points: Point[]) {\n let regionPath = this.getGridPath(prePoints);\n const reversePoints = points.slice(0).reverse();\n const nextPath = this.getGridPath(reversePoints, true);\n const closed = this.get('closed');\n if (closed) {\n regionPath = regionPath.concat(nextPath);\n } else {\n nextPath[0][0] = 'L'; // 更新第一个节点\n regionPath = regionPath.concat(nextPath);\n regionPath.push(['Z']);\n }\n return regionPath;\n }\n // 获取路径的配置项\n private getPathStyle() {\n return this.get('line').style;\n }\n\n // 绘制栅格\n private drawGrid(group: IGroup) {\n const line = this.get('line');\n const items = this.get('items');\n const alternateColor = this.get('alternateColor');\n let preItem = null;\n each(items, (item, index) => {\n const id = item.id || index;\n // 绘制栅格线\n if (line) {\n let style = this.getPathStyle();\n style = isFunction(style) ? style(item, index, items) : style;\n\n const lineId = this.getElementId(`line-${id}`);\n const gridPath = this.getGridPath(item.points);\n this.addShape(group, {\n type: 'path',\n name: 'grid-line',\n id: lineId,\n attrs: mix(\n {\n path: gridPath,\n },\n style\n ),\n });\n }\n // 如果存在 alternateColor 则绘制矩形\n // 从第二个栅格线开始绘制\n if (alternateColor && index > 0) {\n const regionId = this.getElementId(`region-${id}`);\n const isEven = index % 2 === 0;\n if (isString(alternateColor)) {\n // 如果颜色是单值,则是仅绘制偶数时的区域\n if (isEven) {\n this.drawAlternateRegion(regionId, group, preItem.points, item.points, alternateColor);\n }\n } else {\n const color = isEven ? alternateColor[1] : alternateColor[0];\n this.drawAlternateRegion(regionId, group, preItem.points, item.points, color);\n }\n }\n preItem = item;\n });\n }\n\n // 绘制栅格线间的间隔\n private drawAlternateRegion(id: string, group: IGroup, prePoints: Point[], points: Point[], color: string) {\n const regionPath = this.getAlternatePath(prePoints, points);\n this.addShape(group, {\n type: 'path',\n id,\n name: 'grid-region',\n attrs: {\n path: regionPath,\n fill: color,\n },\n });\n }\n}\n\nexport default GridBase;\n","import { each } from '@antv/util';\nimport { CircleGridCfg, Point } from '../types';\nimport GridBase from './base';\n\nfunction distance(x1, y1, x2, y2) {\n const dx = x2 - x1;\n const dy = y2 - y1;\n return Math.sqrt(dx * dx + dy * dy);\n}\n\nclass Circle extends GridBase {\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n type: 'circle',\n /**\n * 中心点\n * @type {object}\n */\n center: null,\n /**\n * 栅格线是否封闭\n * @type {true}\n */\n closed: true,\n };\n }\n\n protected getGridPath(points: Point[], reversed: boolean) {\n const lineType = this.getLineType();\n const closed = this.get('closed');\n const path = [];\n if (points.length) {\n // 防止出错\n if (lineType === 'circle') {\n const center = this.get('center');\n const firstPoint = points[0];\n const radius = distance(center.x, center.y, firstPoint.x, firstPoint.y);\n const sweepFlag = reversed ? 0 : 1; // 顺时针还是逆时针\n if (closed) {\n // 封闭时,绘制整个圆\n path.push(['M', center.x, center.y - radius]);\n path.push(['A', radius, radius, 0, 0, sweepFlag, center.x, center.y + radius]);\n path.push(['A', radius, radius, 0, 0, sweepFlag, center.x, center.y - radius]);\n path.push(['Z']);\n } else {\n each(points, (point, index) => {\n if (index === 0) {\n path.push(['M', point.x, point.y]);\n } else {\n path.push(['A', radius, radius, 0, 0, sweepFlag, point.x, point.y]);\n }\n });\n }\n } else {\n each(points, (point, index) => {\n if (index === 0) {\n path.push(['M', point.x, point.y]);\n } else {\n path.push(['L', point.x, point.y]);\n }\n });\n if (closed) {\n path.push(['Z']);\n }\n }\n }\n return path;\n }\n}\n\nexport default Circle;\n","import { each } from '@antv/util';\nimport { Point } from '../types';\nimport GridBase from './base';\n\nclass Line extends GridBase {\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n type: 'line',\n };\n }\n\n protected getGridPath(points: Point[]): any[] {\n const path = [];\n each(points, (point, index) => {\n if (index === 0) {\n path.push(['M', point.x, point.y]);\n } else {\n path.push(['L', point.x, point.y]);\n }\n });\n return path;\n }\n}\n\nexport default Line;\n","import { IGroup } from '@antv/g-base';\nimport GroupComponent from '../abstract/group-component';\nimport { ILocation } from '../interfaces';\nimport { BBox, LegendBaseCfg, Point, PointLocationCfg } from '../types';\nimport { createBBox, formatPadding } from '../util/util';\n\nabstract class LegendBase extends GroupComponent\n implements ILocation {\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n name: 'legend',\n /**\n * 布局方式: horizontal,vertical\n * @type {String}\n */\n layout: 'horizontal',\n locationType: 'point',\n x: 0,\n y: 0,\n offsetX: 0,\n offsetY: 0,\n title: null,\n background: null,\n };\n }\n\n public getLayoutBBox(): BBox {\n const bbox = super.getLayoutBBox();\n const maxWidth = this.get('maxWidth');\n const maxHeight = this.get('maxHeight');\n\n let { width, height } = bbox;\n if (maxWidth) {\n width = Math.min(width, maxWidth);\n }\n if (maxHeight) {\n height = Math.min(height, maxHeight);\n }\n \n return createBBox(bbox.minX, bbox.minY, width, height);\n }\n\n public setLocation(cfg: PointLocationCfg) {\n this.set('x', cfg.x);\n this.set('y', cfg.y);\n this.resetLocation();\n }\n\n protected resetLocation() {\n const x = this.get('x');\n const y = this.get('y');\n const offsetX = this.get('offsetX');\n const offsetY = this.get('offsetY');\n this.moveElementTo(this.get('group'), {\n x: x + offsetX,\n y: y + offsetY,\n });\n }\n\n protected applyOffset() {\n this.resetLocation();\n }\n\n // 获取当前绘制的点\n protected getDrawPoint(): Point {\n return this.get('currentPoint');\n }\n\n protected setDrawPoint(point: Point) {\n return this.set('currentPoint', point);\n }\n // 复写父类定义的绘制方法\n protected renderInner(group: IGroup) {\n this.resetDraw();\n if (this.get('title')) {\n this.drawTitle(group);\n }\n this.drawLegendContent(group);\n if (this.get('background')) {\n this.drawBackground(group);\n }\n // this.resetLocation(); // 在顶层已经在处理偏移时一起处理了\n }\n\n protected abstract drawLegendContent(group);\n\n // 绘制背景\n protected drawBackground(group: IGroup) {\n const background = this.get('background');\n const bbox = group.getBBox();\n const padding = formatPadding(background.padding);\n const attrs = {\n // 背景从 (0,0) 开始绘制\n x: 0,\n y: 0,\n width: bbox.width + padding[1] + padding[3],\n height: bbox.height + padding[0] + padding[2],\n ...background.style,\n };\n const backgroundShape = this.addShape(group, {\n type: 'rect',\n id: this.getElementId('background'),\n name: 'legend-background',\n attrs,\n });\n backgroundShape.toBack();\n }\n\n // 绘制标题,标题在图例项的上面\n protected drawTitle(group: IGroup) {\n const currentPoint = this.get('currentPoint');\n const titleCfg = this.get('title');\n const { spacing, style, text } = titleCfg;\n const shape = this.addShape(group, {\n type: 'text',\n id: this.getElementId('title'),\n name: 'legend-title',\n attrs: {\n text,\n x: currentPoint.x,\n y: currentPoint.y,\n ...style,\n },\n });\n const bbox = shape.getBBox();\n // 标题单独在一行\n this.set('currentPoint', { x: currentPoint.x, y: bbox.maxY + spacing });\n }\n\n // 重置绘制时开始的位置,如果绘制边框,考虑边框的 padding\n private resetDraw() {\n const background = this.get('background');\n const currentPoint = { x: 0, y: 0 };\n if (background) {\n const padding = formatPadding(background.padding);\n currentPoint.x = padding[3]; // 左边 padding\n currentPoint.y = padding[0]; // 上面 padding\n }\n this.set('currentPoint', currentPoint); // 设置绘制的初始位置\n }\n}\n\nexport default LegendBase;\n","import { IGroup, IShape } from '@antv/g-base';\nimport { clamp, deepMix, each, filter, get, mix, isNumber, isFunction } from '@antv/util';\nimport { IList } from '../interfaces';\nimport {\n CategoryLegendCfg,\n LegendPageNavigatorCfg,\n LegendItemNameCfg,\n LegendMarkerCfg,\n ListItem,\n LegendRadio,\n} from '../types';\nimport { ellipsisLabel } from '../util/label';\nimport { getMatrixByAngle, getMatrixByTranslate } from '../util/matrix';\nimport { getStatesStyle } from '../util/state';\nimport Theme from '../util/theme';\nimport LegendBase from './base';\n\n/**\n * 分页器 默认配置\n */\nconst DEFAULT_PAGE_NAVIGATOR = {\n marker: {\n style: {\n inactiveFill: '#000',\n inactiveOpacity: 0.45,\n fill: '#000',\n opacity: 1,\n size: 12,\n },\n },\n text: {\n style: {\n fill: '#ccc',\n fontSize: 12,\n },\n },\n};\n\n// 默认 文本style\nconst textStyle = {\n fill: Theme.textColor,\n fontSize: 12,\n textAlign: 'start',\n textBaseline: 'middle',\n fontFamily: Theme.fontFamily,\n fontWeight: 'normal',\n lineHeight: 12,\n};\n\nconst RIGHT_ARROW_NAME = 'navigation-arrow-right';\nconst LEFT_ARROW_NAME = 'navigation-arrow-left';\n\nconst ROTATE_MAP = {\n right: (90 * Math.PI) / 180,\n left: ((360 - 90) * Math.PI) / 180,\n up: 0,\n down: (180 * Math.PI) / 180,\n};\nclass Category extends LegendBase implements IList {\n private currentPageIndex = 1;\n private totalPagesCnt = 1;\n private pageWidth = 0;\n private pageHeight = 0;\n private startX = 0;\n private startY = 0;\n\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n name: 'legend',\n type: 'category',\n itemSpacing: 24,\n itemMarginBottom: 8,\n maxItemWidth: null,\n itemWidth: null,\n itemHeight: null,\n itemName: {},\n itemValue: null,\n maxWidth: null,\n maxHeight: null,\n marker: {},\n radio: null,\n items: [],\n itemStates: {},\n itemBackground: {},\n pageNavigator: {},\n defaultCfg: {\n title: {\n spacing: 5,\n style: {\n fill: Theme.textColor,\n fontSize: 12,\n textAlign: 'start',\n textBaseline: 'top',\n },\n },\n background: {\n padding: 5,\n style: {\n stroke: Theme.lineColor,\n },\n },\n itemBackground: {\n style: {\n opacity: 0,\n fill: '#fff',\n },\n },\n pageNavigator: DEFAULT_PAGE_NAVIGATOR,\n itemName: {\n spacing: 16, // 如果右边有 value 或者 RadioIcon 使用这个间距\n style: textStyle,\n },\n marker: {\n spacing: 8,\n style: {\n r: 6,\n symbol: 'circle',\n },\n },\n itemValue: {\n alignRight: false, // 只有itemWidth 不为 null 时此属性有效\n formatter: null,\n style: textStyle,\n spacing: 6, // 如果右边有 RadioIcon 使用在这个间距\n },\n itemStates: {\n active: {\n nameStyle: {\n opacity: 0.8,\n },\n },\n unchecked: {\n nameStyle: {\n fill: Theme.uncheckedColor,\n },\n markerStyle: {\n fill: Theme.uncheckedColor,\n stroke: Theme.uncheckedColor,\n },\n },\n inactive: {\n nameStyle: {\n fill: Theme.uncheckedColor,\n },\n markerStyle: {\n opacity: 0.2,\n },\n },\n },\n },\n };\n }\n\n // 实现 IList 接口\n public isList(): boolean {\n return true;\n }\n\n /**\n * 获取图例项\n * @return {ListItem[]} 列表项集合\n */\n public getItems(): ListItem[] {\n return this.get('items');\n }\n\n /**\n * 设置列表项\n * @param {ListItem[]} items 列表项集合\n */\n public setItems(items: ListItem[]) {\n this.update({\n items,\n });\n }\n\n /**\n * 更新列表项\n * @param {ListItem} item 列表项\n * @param {object} cfg 列表项\n */\n public updateItem(item: ListItem, cfg: object) {\n mix(item, cfg);\n this.clear(); // 由于单个图例项变化,会引起全局变化,所以全部更新\n this.render();\n }\n\n /**\n * 清空列表\n */\n public clearItems() {\n const itemGroup = this.getElementByLocalId('item-group');\n itemGroup && itemGroup.clear();\n }\n\n /**\n * 设置列表项的状态\n * @param {ListItem} item 列表项\n * @param {string} state 状态名\n * @param {boolean} value 状态值, true, false\n */\n public setItemState(item: ListItem, state: string, value: boolean) {\n item[state] = value;\n const itemElement = this.getElementByLocalId(`item-${item.id}`);\n if (itemElement) {\n const items = this.getItems();\n const index = items.indexOf(item);\n const offsetGroup = this.createOffScreenGroup(); // 离屏的 group\n const newElement = this.drawItem(item, index, this.getItemHeight(), offsetGroup);\n this.updateElements(newElement, itemElement); // 更新整个分组\n this.clearUpdateStatus(itemElement); // 清理更新状态,防止出现 bug\n }\n }\n /**\n * 是否存在指定的状态\n * @param {ListItem} item 列表项\n * @param {boolean} state 状态名\n */\n public hasState(item: ListItem, state: string): boolean {\n return !!item[state];\n }\n\n public getItemStates(item: ListItem): string[] {\n const itemStates = this.get('itemStates');\n const rst = [];\n each(itemStates, (v, k) => {\n if (item[k]) {\n // item.selected\n rst.push(k);\n }\n });\n return rst;\n }\n\n /**\n * 清楚所有列表项的状态\n * @param {string} state 状态值\n */\n public clearItemsState(state: string) {\n const items = this.getItemsByState(state);\n each(items, (item) => {\n this.setItemState(item, state, false);\n });\n }\n\n /**\n * 根据状态获取图例项\n * @param {string} state [description]\n * @return {ListItem[]} [description]\n */\n public getItemsByState(state: string): ListItem[] {\n const items = this.getItems();\n return filter(items, (item) => {\n return this.hasState(item, state);\n });\n }\n\n // 绘制 legend 的选项\n protected drawLegendContent(group) {\n this.processItems();\n this.drawItems(group);\n }\n\n // 防止未设置 id\n private processItems() {\n const items = this.get('items');\n each(items, (item) => {\n if (!item.id) {\n // 如果没有设置 id,默认使用 name\n item.id = item.name;\n }\n });\n }\n\n // 绘制所有的图例选项\n private drawItems(group: IGroup) {\n const itemContainerGroup = this.addGroup(group, {\n id: this.getElementId('item-container-group'),\n name: 'legend-item-container-group',\n });\n const itemGroup = this.addGroup(itemContainerGroup, {\n id: this.getElementId('item-group'),\n name: 'legend-item-group',\n });\n const itemHeight = this.getItemHeight();\n const itemWidth = this.get('itemWidth');\n const itemSpacing = this.get('itemSpacing');\n const itemMarginBottom = this.get('itemMarginBottom');\n const currentPoint = this.get('currentPoint');\n const startX = currentPoint.x;\n const startY = currentPoint.y;\n const layout = this.get('layout');\n const items = this.get('items');\n let wrapped = false;\n let pageWidth = 0;\n\n const maxWidth = this.get('maxWidth'); // 最大宽度,会导致 layout : 'horizontal' 时自动换行\n const maxHeight = this.get('maxHeight'); // 最大高度,会导致出现分页\n // 暂时不考虑分页\n each(items, (item, index) => {\n const subGroup = this.drawItem(item, index, itemHeight, itemGroup);\n const bbox = subGroup.getBBox();\n const width = itemWidth || bbox.width;\n if (width > pageWidth) {\n pageWidth = width;\n }\n if (layout === 'horizontal') {\n // 如果水平布局\n if (maxWidth && maxWidth < currentPoint.x + width - startX) {\n // 检测是否换行\n wrapped = true;\n currentPoint.x = startX;\n currentPoint.y += itemHeight + itemMarginBottom;\n }\n this.moveElementTo(subGroup, currentPoint);\n currentPoint.x += width + itemSpacing;\n } else {\n // 如果垂直布局\n if (maxHeight && maxHeight < currentPoint.y + itemHeight + itemMarginBottom - startY) {\n // 换行\n wrapped = true;\n currentPoint.x += pageWidth + itemSpacing;\n currentPoint.y = startY;\n pageWidth = 0;\n }\n this.moveElementTo(subGroup, currentPoint);\n currentPoint.y += itemHeight + itemMarginBottom; // itemSpacing 仅影响水平间距\n }\n });\n\n if (wrapped && this.get('flipPage')) {\n this.pageHeight = 0;\n this.pageWidth = 0;\n this.totalPagesCnt = 1;\n this.startX = startX;\n this.startY = startY;\n this.adjustNavigation(group, itemGroup);\n }\n }\n // 获取图例项的高度,如果未定义,则按照 name 的高度计算\n private getItemHeight() {\n let itemHeight = this.get('itemHeight');\n if (!itemHeight) {\n const { style }: LegendItemNameCfg = this.get('itemName') || {};\n\n if (isFunction(style)) {\n const items = this.getItems();\n items.forEach((item, index) => {\n const { fontSize } = { ...textStyle, ...style(item, index, items) };\n if (itemHeight < fontSize) {\n itemHeight = fontSize;\n }\n });\n } else if (style) {\n itemHeight = style.fontSize;\n }\n }\n return itemHeight;\n }\n // 绘制 marker\n private drawMarker(container: IGroup, markerCfg: LegendMarkerCfg, item: ListItem, itemHeight: number) {\n const markerAttrs = {\n x: 0,\n y: itemHeight / 2,\n ...markerCfg.style,\n symbol: get(item.marker, 'symbol', 'circle'),\n ...get(item.marker, 'style', {}),\n };\n\n const shape = this.addShape(container, {\n type: 'marker',\n id: this.getElementId(`item-${item.id}-marker`),\n name: 'legend-item-marker',\n attrs: markerAttrs,\n });\n const bbox = shape.getBBox();\n shape.attr('x', bbox.width / 2); // marker 需要左对齐,所以不能占用左侧的空间\n\n const { stroke, fill } = shape.attr();\n if (stroke) {\n shape.set('isStroke', true);\n }\n if (fill) {\n shape.set('isFill', true);\n }\n\n return shape;\n }\n // 绘制文本\n private drawItemText(\n container: IGroup,\n textName: string,\n cfg: LegendItemNameCfg,\n item: ListItem,\n itemHeight: number,\n xPosition: number,\n index: number\n ) {\n const formatter = cfg.formatter;\n const { style } = cfg;\n\n const attrs = {\n x: xPosition,\n y: itemHeight / 2,\n text: formatter ? formatter(item[textName], item, index) : item[textName],\n ...textStyle,\n ...(isFunction(style) ? style(item, index, this.getItems()) : style),\n };\n\n return this.addShape(container, {\n type: 'text',\n id: this.getElementId(`item-${item.id}-${textName}`),\n name: `legend-item-${textName}`,\n attrs,\n });\n }\n\n private drawRadio(container: IGroup, radioCfg: LegendRadio, item: ListItem, itemHeight: number, x: number) {\n const style = radioCfg.style || {};\n // 以用户设置的 r 为主\n const r = style.r ?? itemHeight / 2;\n const lineWidth = (r * 3.6) / 8;\n const [x0, y0] = [x + r, itemHeight / 2 - r];\n const [x1, y1] = [x0 + r, y0 + r];\n const [x2, y2] = [x0, y1 + r];\n const [x3, y3] = [x, y0 + r];\n const { showRadio } = item;\n const attrs = {\n path: [\n ['M', x0, y0],\n ['A', r, r, 0, 0, 1, x1, y1],\n ['L', x1 - lineWidth, y1],\n ['L', x1, y1],\n ['A', r, r, 0, 0, 1, x2, y2],\n ['L', x2, y2 - lineWidth],\n ['L', x2, y2],\n ['A', r, r, 0, 0, 1, x3, y3],\n ['L', x3 + lineWidth, y3],\n ['L', x3, y3],\n ['A', r, r, 0, 0, 1, x0, y0],\n ['L', x0, y0 + lineWidth],\n ],\n stroke: '#000000',\n fill: '#ffffff',\n ...style,\n opacity: showRadio ? (style?.opacity ?? 0.45) : 0,\n };\n\n const radioShape = this.addShape(container, {\n type: 'path',\n id: this.getElementId(`item-${item.id}-radio`),\n name: 'legend-item-radio',\n attrs,\n });\n radioShape.set('tip', radioCfg.tip);\n return radioShape;\n }\n\n // 绘制图例项\n private drawItem(item: ListItem, index: number, itemHeight: number, itemGroup: IGroup) {\n const groupId = `item-${item.id}`;\n // 设置单独的 Group 用于 setClip\n const subContainer = this.addGroup(itemGroup, {\n name: 'legend-item-container',\n id: this.getElementId(`item-container-${groupId}`),\n delegateObject: {\n item,\n index,\n },\n });\n const subGroup = this.addGroup(subContainer, {\n name: 'legend-item',\n id: this.getElementId(groupId),\n delegateObject: {\n item,\n index,\n },\n });\n const marker = this.get('marker');\n const itemName = this.get('itemName');\n const itemValue = this.get('itemValue');\n const itemBackground = this.get('itemBackground');\n const radio = this.get('radio');\n const itemWidth = this.getLimitItemWidth();\n\n let curX = 0; // 记录当前 x 的位置\n if (marker) {\n const markerShape = this.drawMarker(subGroup, marker, item, itemHeight);\n let spacing = marker.spacing;\n const itemMarkerSpacing = get(item, ['marker', 'spacing']);\n\n if (isNumber(itemMarkerSpacing)) {\n // 如果 item 有配置 marker.spacing,采用 item 的配置\n spacing = itemMarkerSpacing;\n }\n\n curX = markerShape.getBBox().maxX + spacing;\n }\n\n if (itemName) {\n const nameShape = this.drawItemText(subGroup, 'name', itemName, item, itemHeight, curX, index);\n if (itemWidth) {\n // 设置了 item 的最大宽度限制,并且超出了,进行省略处理\n ellipsisLabel(true, nameShape, clamp(itemWidth - curX, 0, itemWidth));\n }\n curX = nameShape.getBBox().maxX + itemName.spacing;\n }\n\n if (itemValue) {\n const valueShape = this.drawItemText(subGroup, 'value', itemValue, item, itemHeight, curX, index);\n if (itemWidth) {\n if (itemValue.alignRight) {\n valueShape.attr({\n textAlign: 'right',\n x: itemWidth,\n });\n ellipsisLabel(true, valueShape, clamp(itemWidth - curX, 0, itemWidth), 'head');\n } else {\n ellipsisLabel(true, valueShape, clamp(itemWidth - curX, 0, itemWidth));\n }\n }\n curX = valueShape.getBBox().maxX + itemValue.spacing;\n }\n\n if (radio) {\n this.drawRadio(subGroup, radio, item, itemHeight, curX);\n }\n\n // 添加透明的背景,便于拾取和包围盒计算\n if (itemBackground) {\n const bbox = subGroup.getBBox();\n const backShape = this.addShape(subGroup, {\n type: 'rect',\n name: 'legend-item-background',\n id: this.getElementId(`${groupId}-background`),\n attrs: {\n x: 0,\n y: 0,\n width: bbox.width,\n height: itemHeight,\n ...itemBackground.style,\n },\n });\n backShape.toBack();\n }\n\n this.applyItemStates(item, subGroup);\n return subGroup;\n }\n\n // 加上分页器并重新排序 items\n private adjustNavigation(container: IGroup, itemGroup: IGroup) {\n const startX = this.startX;\n const startY = this.startY;\n const layout = this.get('layout');\n const subGroups = itemGroup.findAll((item) => item.get('name') === 'legend-item');\n const maxWidth = this.get('maxWidth');\n const maxHeight = this.get('maxHeight');\n const itemWidth = this.get('itemWidth');\n const itemSpacing = this.get('itemSpacing');\n const itemHeight = this.getItemHeight();\n const pageNavigator: LegendPageNavigatorCfg = deepMix({}, DEFAULT_PAGE_NAVIGATOR, this.get('pageNavigator'));\n const navigation = this.drawNavigation(container, layout, '00/00', pageNavigator);\n const navigationBBox = navigation.getBBox();\n const currentPoint = { x: startX, y: startY };\n let pages = 1;\n let widthLimit = 0;\n let pageWidth = 0;\n let maxItemWidth = 0;\n const itemMarginBottom = this.get('itemMarginBottom');\n\n /** 判断当前 item 是否溢出当前页。是的话,需要换行 */\n function shouldWrap(item, currentPoint) {\n const bbox = item.getBBox();\n const width = itemWidth || bbox.width;\n const newItemXPos = currentPoint.x + width + itemSpacing + navigationBBox.width;\n return newItemXPos > maxWidth;\n }\n\n if (layout === 'horizontal') {\n const maxRow = this.get('maxRow') || 1;\n const maxRowHeight = itemHeight + (maxRow === 1 ? 0 : itemMarginBottom);\n // 分页器一直靠右上角\n const navigationX = maxWidth - itemSpacing - navigationBBox.width - navigationBBox.minX; // 理论上不需要减 navigationBBox.minX\n this.pageHeight = maxRowHeight * maxRow;\n this.pageWidth = navigationX;\n each(subGroups, (item) => {\n const bbox = item.getBBox();\n const width = itemWidth || bbox.width;\n if ((widthLimit && widthLimit < currentPoint.x + width + itemSpacing) ||\n shouldWrap(item, currentPoint)) {\n if (pages === 1) {\n widthLimit = currentPoint.x + itemSpacing;\n this.moveElementTo(navigation, {\n x: navigationX,\n y: currentPoint.y + itemHeight / 2 - navigationBBox.height / 2 - navigationBBox.minY,\n });\n }\n pages += 1;\n currentPoint.x = startX;\n currentPoint.y += maxRowHeight;\n }\n this.moveElementTo(item, currentPoint);\n item.getParent().setClip({\n type: 'rect',\n attrs: {\n x: currentPoint.x,\n y: currentPoint.y,\n width: width + itemSpacing,\n height: itemHeight,\n },\n });\n currentPoint.x += width + itemSpacing;\n });\n } else {\n each(subGroups, (item) => {\n const bbox = item.getBBox();\n if (bbox.width > pageWidth) {\n pageWidth = bbox.width;\n }\n });\n maxItemWidth = pageWidth;\n pageWidth += itemSpacing;\n if (maxWidth) {\n // maxWidth 限制加上\n pageWidth = Math.min(maxWidth, pageWidth);\n maxItemWidth = Math.min(maxWidth, maxItemWidth);\n }\n this.pageWidth = pageWidth;\n this.pageHeight = maxHeight - Math.max(navigationBBox.height, itemHeight + itemMarginBottom);\n const cntPerPage = Math.floor(this.pageHeight / (itemHeight + itemMarginBottom));\n each(subGroups, (item, index) => {\n if (index !== 0 && index % cntPerPage === 0) {\n pages += 1;\n currentPoint.x += pageWidth;\n currentPoint.y = startY;\n }\n this.moveElementTo(item, currentPoint);\n item.getParent().setClip({\n type: 'rect',\n attrs: {\n x: currentPoint.x,\n y: currentPoint.y,\n width: pageWidth,\n height: itemHeight,\n },\n });\n currentPoint.y += itemHeight + itemMarginBottom;\n });\n this.totalPagesCnt = pages;\n this.moveElementTo(navigation, {\n x: startX + maxItemWidth / 2 - navigationBBox.width / 2 - navigationBBox.minX,\n y: maxHeight - navigationBBox.height - navigationBBox.minY,\n });\n }\n\n if (this.pageHeight && this.pageWidth) {\n // 为了使固定的 clip 生效,clip 设置在 itemContainerGroup 上,itemGroup 需要在翻页时会设置 matrix\n itemGroup.getParent().setClip({\n type: 'rect',\n attrs: {\n x: this.startX,\n y: this.startY,\n width: this.pageWidth,\n height: this.pageHeight,\n },\n });\n }\n // 重新计算 totalPagesCnt\n if (layout === 'horizontal' && this.get('maxRow')) {\n this.totalPagesCnt = Math.ceil(pages / this.get('maxRow'));\n } else {\n this.totalPagesCnt = pages;\n }\n if (this.currentPageIndex > this.totalPagesCnt) {\n this.currentPageIndex = 1;\n }\n this.updateNavigation(navigation);\n // update initial matrix\n itemGroup.attr('matrix', this.getCurrentNavigationMatrix());\n }\n\n /**\n * 绘制分页器\n */\n private drawNavigation(\n group: IGroup,\n layout: 'horizontal' | 'vertical',\n text: string,\n styleCfg?: LegendPageNavigatorCfg\n ) {\n const currentPoint = { x: 0, y: 0 };\n const subGroup = this.addGroup(group, {\n id: this.getElementId('navigation-group'),\n name: 'legend-navigation',\n });\n const { size = 12, ...arrowStyle } = get(styleCfg.marker, 'style', {});\n const leftArrow = this.drawArrow(\n subGroup,\n currentPoint,\n LEFT_ARROW_NAME,\n layout === 'horizontal' ? 'up' : 'left',\n size,\n arrowStyle\n );\n leftArrow.on('click', this.onNavigationBack);\n const leftArrowBBox = leftArrow.getBBox();\n currentPoint.x += leftArrowBBox.width + 2;\n\n const textShape = this.addShape(subGroup, {\n type: 'text',\n id: this.getElementId('navigation-text'),\n name: 'navigation-text',\n attrs: {\n x: currentPoint.x,\n y: currentPoint.y + size / 2,\n text,\n textBaseline: 'middle',\n ...get(styleCfg.text, 'style'),\n },\n });\n const textBBox = textShape.getBBox();\n currentPoint.x += textBBox.width + 2;\n\n const rightArrow = this.drawArrow(\n subGroup,\n currentPoint,\n RIGHT_ARROW_NAME,\n layout === 'horizontal' ? 'down' : 'right',\n size,\n arrowStyle\n );\n rightArrow.on('click', this.onNavigationAfter);\n\n return subGroup;\n }\n\n private updateNavigation(navigation?: IGroup) {\n const pageNavigator: LegendPageNavigatorCfg = deepMix({}, DEFAULT_PAGE_NAVIGATOR, this.get('pageNavigator'));\n const { fill, opacity, inactiveFill, inactiveOpacity } = pageNavigator.marker.style;\n\n const text = `${this.currentPageIndex}/${this.totalPagesCnt}`;\n const textShape = navigation ? navigation.getChildren()[1] : this.getElementByLocalId('navigation-text');\n const leftArrow = navigation\n ? navigation.findById(this.getElementId(LEFT_ARROW_NAME))\n : this.getElementByLocalId(LEFT_ARROW_NAME);\n const rightArrow = navigation\n ? navigation.findById(this.getElementId(RIGHT_ARROW_NAME))\n : this.getElementByLocalId(RIGHT_ARROW_NAME);\n textShape.attr('text', text);\n // 更新 left-arrow marker\n leftArrow.attr('opacity', this.currentPageIndex === 1 ? inactiveOpacity : opacity);\n leftArrow.attr('fill', this.currentPageIndex === 1 ? inactiveFill : fill);\n leftArrow.attr('cursor', this.currentPageIndex === 1 ? 'not-allowed' : 'pointer');\n // 更新 right-arrow marker\n rightArrow.attr('opacity', this.currentPageIndex === this.totalPagesCnt ? inactiveOpacity : opacity);\n rightArrow.attr('fill', this.currentPageIndex === this.totalPagesCnt ? inactiveFill : fill);\n rightArrow.attr('cursor', this.currentPageIndex === this.totalPagesCnt ? 'not-allowed' : 'pointer');\n // 更新位置\n let cursorX = leftArrow.getBBox().maxX + 2;\n textShape.attr('x', cursorX);\n cursorX += textShape.getBBox().width + 2;\n this.updateArrowPath(rightArrow, { x: cursorX, y: 0 });\n\n }\n\n private drawArrow(\n group: IGroup,\n currentPoint: { x: number; y: number },\n name: string,\n direction: 'left' | 'right' | 'up' | 'down',\n size: number,\n style?: LegendPageNavigatorCfg['marker']['style']\n ) {\n const { x, y } = currentPoint;\n const shape = this.addShape(group, {\n type: 'path',\n id: this.getElementId(name),\n name,\n attrs: {\n size,\n direction,\n path: [['M', x + size / 2, y], ['L', x, y + size], ['L', x + size, y + size], ['Z']],\n cursor: 'pointer',\n ...style,\n },\n });\n shape.attr('matrix', getMatrixByAngle({ x: x + size / 2, y: y + size / 2 }, ROTATE_MAP[direction]));\n\n return shape;\n }\n\n /**\n * 更新分页器 arrow 组件\n */\n private updateArrowPath(arrow: IShape, point: { x: number; y: number }): void {\n const { x, y } = point;\n const { size, direction } = arrow.attr();\n let matrix = getMatrixByAngle({ x: x + size / 2, y: y + size / 2 }, ROTATE_MAP[direction]);\n arrow.attr('path', [['M', x + size / 2, y], ['L', x, y + size], ['L', x + size, y + size], ['Z']]);\n arrow.attr('matrix', matrix);\n }\n\n private getCurrentNavigationMatrix() {\n const { currentPageIndex, pageWidth, pageHeight } = this;\n const layout = this.get('layout');\n const translate =\n layout === 'horizontal'\n ? {\n x: 0,\n y: pageHeight * (1 - currentPageIndex),\n }\n : {\n x: pageWidth * (1 - currentPageIndex),\n y: 0,\n };\n\n return getMatrixByTranslate(translate);\n }\n\n private onNavigationBack = () => {\n const itemGroup = this.getElementByLocalId('item-group');\n if (this.currentPageIndex > 1) {\n this.currentPageIndex -= 1;\n this.updateNavigation();\n const matrix = this.getCurrentNavigationMatrix();\n if (this.get('animate')) {\n itemGroup.animate(\n {\n matrix,\n },\n 100\n );\n } else {\n itemGroup.attr({ matrix });\n }\n }\n };\n\n private onNavigationAfter = () => {\n const itemGroup = this.getElementByLocalId('item-group');\n if (this.currentPageIndex < this.totalPagesCnt) {\n this.currentPageIndex += 1;\n this.updateNavigation();\n const matrix = this.getCurrentNavigationMatrix();\n if (this.get('animate')) {\n itemGroup.animate(\n {\n matrix,\n },\n 100\n );\n } else {\n itemGroup.attr({ matrix });\n }\n }\n };\n\n // 附加状态对应的样式\n private applyItemStates(item: ListItem, subGroup: IGroup) {\n const states = this.getItemStates(item);\n const hasStates = states.length > 0;\n if (hasStates) {\n const children = subGroup.getChildren();\n const itemStates = this.get('itemStates');\n each(children, (element) => {\n const name = element.get('name');\n const elName = name.split('-')[2]; // marker, name, value\n const statesStyle = getStatesStyle(item, elName, itemStates);\n if (statesStyle) {\n element.attr(statesStyle);\n if (elName === 'marker' && !(element.get('isStroke') && element.get('isFill'))) {\n // 如果 marker 是单填充或者单描边的话,就不要额外添加 stroke 或这 fill 属性,否则会影响 unchecked 后的显示\n if (element.get('isStroke')) {\n element.attr('fill', null);\n }\n if (element.get('isFill')) {\n element.attr('stroke', null);\n }\n }\n }\n });\n }\n }\n\n // 获取 itemWidth 的最终设置\n private getLimitItemWidth() {\n const itemWidth = this.get('itemWidth');\n let maxItemWidth = this.get('maxItemWidth');\n\n if (maxItemWidth) {\n // 设置了最大宽度\n if (itemWidth) {\n maxItemWidth = itemWidth <= maxItemWidth ? itemWidth : maxItemWidth;\n }\n } else if (itemWidth) {\n maxItemWidth = itemWidth;\n }\n\n return maxItemWidth;\n }\n}\n\nexport default Category;\n","import { IElement, IGroup } from '@antv/g-base';\nimport { clone, isFunction, mix, upperFirst } from '@antv/util';\nimport { ISlider } from '../interfaces';\nimport { BBox, ContinueLegendCfg } from '../types';\nimport Theme from '../util/theme';\nimport { getValueByPercent } from '../util/util';\nimport LegendBase from './base';\nconst HANDLER_HEIGHT_RATIO = 1.4;\nconst HANDLER_TRIANGLE_RATIO = 0.4;\n\nclass ContinueLegend extends LegendBase implements ISlider {\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n type: 'continue',\n min: 0,\n max: 100,\n value: null,\n colors: [],\n track: {},\n rail: {},\n label: {},\n handler: {},\n slidable: true,\n tip: null,\n step: null,\n maxWidth: null,\n maxHeight: null,\n defaultCfg: {\n label: {\n align: 'rail',\n spacing: 5, // 文本和 rail 的间距\n formatter: null,\n style: {\n fontSize: 12,\n fill: Theme.textColor,\n textBaseline: 'middle',\n fontFamily: Theme.fontFamily,\n },\n },\n handler: {\n size: 10, // handler 的默认宽度\n style: {\n fill: '#fff',\n stroke: '#333',\n },\n },\n track: {},\n rail: {\n type: 'color',\n size: 20,\n defaultLength: 100,\n style: {\n fill: '#DCDEE2',\n },\n },\n title: {\n spacing: 5,\n style: {\n fill: Theme.textColor,\n fontSize: 12,\n textAlign: 'start',\n textBaseline: 'top',\n },\n },\n },\n };\n }\n\n public isSlider() {\n return true;\n }\n\n // 实现 IList 接口\n public getValue() {\n return this.getCurrentValue();\n }\n\n public getRange() {\n return {\n min: this.get('min'),\n max: this.get('max'),\n };\n }\n\n // 改变 range\n public setRange(min, max) {\n this.update({\n min,\n max,\n });\n }\n\n public setValue(value: number[]) {\n const originValue = this.getValue();\n this.set('value', value);\n const group = this.get('group');\n this.resetTrackClip();\n if (this.get('slidable')) {\n this.resetHandlers(group);\n }\n this.delegateEmit('valuechanged', {\n originValue,\n value,\n });\n }\n\n protected initEvent() {\n const group = this.get('group');\n this.bindSliderEvent(group);\n this.bindRailEvent(group);\n this.bindTrackEvent(group);\n }\n\n protected drawLegendContent(group: IGroup) {\n this.drawRail(group);\n this.drawLabels(group);\n this.fixedElements(group); // 调整各个图形位置,适应宽高的限制\n this.resetTrack(group);\n this.resetTrackClip(group);\n if (this.get('slidable')) {\n this.resetHandlers(group);\n }\n }\n\n private bindSliderEvent(group) {\n this.bindHandlersEvent(group);\n }\n\n private bindHandlersEvent(group) {\n group.on('legend-handler-min:drag', (ev) => {\n const minValue = this.getValueByCanvasPoint(ev.x, ev.y);\n const currentValue = this.getCurrentValue();\n let maxValue = currentValue[1];\n if (maxValue < minValue) {\n // 如果小于最小值,则调整最小值\n maxValue = minValue;\n }\n this.setValue([minValue, maxValue]);\n });\n group.on('legend-handler-max:drag', (ev) => {\n const maxValue = this.getValueByCanvasPoint(ev.x, ev.y);\n const currentValue = this.getCurrentValue();\n let minValue = currentValue[0];\n if (minValue > maxValue) {\n // 如果小于最小值,则调整最小值\n minValue = maxValue;\n }\n this.setValue([minValue, maxValue]);\n });\n }\n\n private bindRailEvent(group) {}\n\n private bindTrackEvent(group) {\n let prePoint = null;\n group.on('legend-track:dragstart', (ev) => {\n prePoint = {\n x: ev.x,\n y: ev.y,\n };\n });\n group.on('legend-track:drag', (ev) => {\n if (!prePoint) {\n return;\n }\n const preValue = this.getValueByCanvasPoint(prePoint.x, prePoint.y);\n const curValue = this.getValueByCanvasPoint(ev.x, ev.y);\n const currentValue = this.getCurrentValue();\n const curDiff = currentValue[1] - currentValue[0];\n const range = this.getRange();\n const dValue = curValue - preValue;\n if (dValue < 0) {\n // 减小, 同时未出边界\n if (currentValue[0] + dValue > range.min) {\n this.setValue([currentValue[0] + dValue, currentValue[1] + dValue]);\n } else {\n this.setValue([range.min, range.min + curDiff]);\n }\n // && ||\n } else if (dValue > 0) {\n if (dValue > 0 && currentValue[1] + dValue < range.max) {\n this.setValue([currentValue[0] + dValue, currentValue[1] + dValue]);\n } else {\n this.setValue([range.max - curDiff, range.max]);\n }\n }\n prePoint = {\n x: ev.x,\n y: ev.y,\n };\n });\n group.on('legend-track:dragend', (ev) => {\n prePoint = null;\n });\n }\n\n private drawLabels(group: IGroup) {\n this.drawLabel('min', group);\n this.drawLabel('max', group);\n }\n\n private drawLabel(name, group: IGroup) {\n const labelCfg = this.get('label');\n const style = labelCfg.style;\n const labelAlign = labelCfg.align;\n const labelFormatter = labelCfg.formatter;\n const value = this.get(name);\n const alignAttrs = this.getLabelAlignAttrs(name, labelAlign);\n const localId = `label-${name}`;\n this.addShape(group, {\n type: 'text',\n id: this.getElementId(localId),\n name: `legend-label-${name}`,\n attrs: {\n x: 0,\n y: 0,\n text: isFunction(labelFormatter) ? labelFormatter(value) : value,\n ...style,\n ...alignAttrs,\n },\n });\n }\n\n // 获取文本的对齐方式,为了自适应真实操碎了心\n private getLabelAlignAttrs(name, align) {\n const isVertical = this.isVertical();\n let textAlign = 'center';\n let textBaseline = 'middle';\n if (isVertical) {\n // 垂直布局的所有的文本都左对齐\n textAlign = 'start';\n if (align !== 'rail') {\n if (name === 'min') {\n textBaseline = 'top';\n } else {\n textBaseline = 'bottom';\n }\n } else {\n textBaseline = 'top';\n }\n } else {\n if (align !== 'rail') {\n textBaseline = 'top';\n if (name === 'min') {\n textAlign = 'start';\n } else {\n textAlign = 'end';\n }\n } else {\n textAlign = 'start';\n textBaseline = 'middle';\n }\n }\n return {\n textAlign,\n textBaseline,\n };\n }\n\n private getRailPath(x: number, y: number, w?: number, h?: number) {\n const railCfg = this.get('rail');\n const { size, defaultLength, type } = railCfg;\n const isVertical = this.isVertical();\n const length = defaultLength;\n let width = w;\n let height = h;\n if (!width) {\n width = isVertical ? size : length;\n }\n if (!height) {\n height = isVertical ? length : size;\n }\n const path = [];\n if (type === 'color') {\n path.push(['M', x, y]);\n path.push(['L', x + width, y]);\n path.push(['L', x + width, y + height]);\n path.push(['L', x, y + height]);\n path.push(['Z']);\n } else {\n path.push(['M', x + width, y]);\n path.push(['L', x + width, y + height]);\n path.push(['L', x, y + height]);\n path.push(['Z']);\n }\n return path;\n }\n\n private drawRail(group: IGroup) {\n const railCfg = this.get('rail');\n const style = railCfg.style;\n this.addShape(group, {\n type: 'path',\n id: this.getElementId('rail'),\n name: 'legend-rail',\n attrs: {\n path: this.getRailPath(0, 0),\n ...style,\n },\n });\n }\n\n // 将传入的颜色转换成渐变色\n private getTrackColor(colors) {\n const count = colors.length;\n if (!count) {\n return null;\n }\n if (count === 1) {\n return colors[0];\n }\n let color; // 最终形态 l(0) 0:colors[0] 0.5:colors[1] 1:colors[2];\n if (this.isVertical()) {\n // 根据方向设置渐变方向\n color = 'l(90)';\n } else {\n color = 'l(0)';\n }\n for (let i = 0; i < count; i++) {\n const percent = i / (count - 1);\n color += ` ${percent}:${colors[i]}`;\n }\n return color;\n }\n\n private getTrackPath(group?: IGroup) {\n const railShape = this.getRailShape(group);\n const path = railShape.attr('path');\n return clone(path);\n }\n\n private getClipTrackAttrs(group?: IGroup) {\n const value = this.getCurrentValue();\n const [min, max] = value;\n const railBBox = this.getRailBBox(group);\n const startPoint = this.getPointByValue(min, group);\n const endPoint = this.getPointByValue(max, group);\n const isVertical = this.isVertical();\n let x;\n let y;\n let width;\n let height;\n if (isVertical) {\n x = railBBox.minX;\n y = startPoint.y;\n width = railBBox.width;\n height = endPoint.y - startPoint.y;\n } else {\n x = startPoint.x;\n y = railBBox.minY;\n width = endPoint.x - startPoint.x;\n height = railBBox.height;\n }\n return {\n x,\n y,\n width,\n height,\n };\n }\n\n // 获取 track 的属性,由 path 和 颜色构成\n private getTrackAttrs(group?: IGroup) {\n const trackCfg = this.get('track');\n const colors = this.get('colors');\n const path = this.getTrackPath(group);\n return mix(\n {\n path,\n fill: this.getTrackColor(colors),\n },\n trackCfg.style\n );\n }\n\n private resetTrackClip(group?: IGroup) {\n const container = group || (this.get('group') as IGroup);\n const trackId = this.getElementId('track');\n const trackShape = container.findById(trackId);\n const clipShape = trackShape.getClip();\n const attrs = this.getClipTrackAttrs(group);\n if (!clipShape) {\n trackShape.setClip({\n type: 'rect',\n attrs,\n });\n } else {\n clipShape.attr(attrs);\n }\n }\n\n private resetTrack(group: IGroup) {\n const trackId = this.getElementId('track');\n const trackShape = group.findById(trackId);\n const trackAttrs = this.getTrackAttrs(group);\n if (trackShape) {\n trackShape.attr(trackAttrs);\n } else {\n this.addShape(group, {\n type: 'path',\n id: trackId,\n draggable: this.get('slidable'),\n name: 'legend-track',\n attrs: trackAttrs,\n });\n }\n }\n\n private getPointByValue(value, group?: IGroup) {\n const { min, max } = this.getRange();\n const percent = (value - min) / (max - min);\n const bbox = this.getRailBBox(group);\n const isVertcal = this.isVertical();\n const point = { x: 0, y: 0 };\n if (isVertcal) {\n point.x = bbox.minX + bbox.width / 2;\n point.y = getValueByPercent(bbox.minY, bbox.maxY, percent);\n } else {\n point.x = getValueByPercent(bbox.minX, bbox.maxX, percent);\n point.y = bbox.minY + bbox.height / 2;\n }\n return point;\n }\n\n private getRailShape(group?: IGroup) {\n const container = group || (this.get('group') as IGroup);\n return container.findById(this.getElementId('rail'));\n }\n\n // 获取滑轨的宽高信息\n private getRailBBox(group?: IGroup): BBox {\n const railShape = this.getRailShape(group);\n const bbox = railShape.getBBox();\n return bbox;\n }\n\n private getRailCanvasBBox(): BBox {\n const container = this.get('group');\n const railShape = container.findById(this.getElementId('rail'));\n const bbox = railShape.getCanvasBBox();\n return bbox;\n }\n\n // 是否垂直\n private isVertical(): boolean {\n return this.get('layout') === 'vertical';\n }\n\n // 用于交互时\n private getValueByCanvasPoint(x, y) {\n const { min, max } = this.getRange();\n const bbox = this.getRailCanvasBBox(); // 因为 x, y 是画布坐标\n const isVertcal = this.isVertical();\n const step = this.get('step');\n let percent;\n if (isVertcal) {\n // 垂直时计算 y\n percent = (y - bbox.minY) / bbox.height;\n } else {\n // 水平时计算 x\n percent = (x - bbox.minX) / bbox.width;\n }\n let value = getValueByPercent(min, max, percent);\n if (step) {\n const count = Math.round((value - min) / step);\n value = min + count * step; // 移动到最近的\n }\n if (value > max) {\n value = max;\n }\n if (value < min) {\n value = min;\n }\n return value;\n }\n\n // 当前选中的范围\n private getCurrentValue(): number[] {\n const value = this.get('value');\n if (!value) {\n const values = this.get('values');\n if (!values) {\n return [this.get('min'), this.get('max')];\n }\n // 如果没有定义,取最大范围 最小值 为 values 中的最小值, 如果最小值 超过了 定义的最大值 则 做限制 最大值 反之\n return [Math.max(Math.min(...values, this.get('max')), this.get('min')), Math.min(Math.max(...values, this.get('min')), this.get('max'))];\n }\n return value;\n }\n\n // 重置滑块 handler\n private resetHandlers(group: IGroup) {\n const currentValue = this.getCurrentValue();\n const [min, max] = currentValue;\n this.resetHandler(group, 'min', min);\n this.resetHandler(group, 'max', max);\n }\n // 获取滑块的 path\n private getHandlerPath(handlerCfg, point) {\n const isVertical = this.isVertical();\n const path = [];\n const width = handlerCfg.size;\n const { x, y } = point;\n const height = width * HANDLER_HEIGHT_RATIO;\n const halfWidth = width / 2;\n const oneSixthWidth = width / 6;\n if (isVertical) {\n /**\n * 竖直情况下的滑块 handler,左侧顶点是 x,y\n * /----|\n * -- |\n * -- |\n * \\----|\n */\n const triangleX = x + height * HANDLER_TRIANGLE_RATIO;\n path.push(['M', x, y]);\n path.push(['L', triangleX, y + halfWidth]);\n path.push(['L', x + height, y + halfWidth]);\n path.push(['L', x + height, y - halfWidth]);\n path.push(['L', triangleX, y - halfWidth]);\n path.push(['Z']);\n // 绘制两条横线\n path.push(['M', triangleX, y + oneSixthWidth]);\n path.push(['L', x + height - 2, y + oneSixthWidth]);\n path.push(['M', triangleX, y - oneSixthWidth]);\n path.push(['L', x + height - 2, y - oneSixthWidth]);\n } else {\n /**\n * 水平情况下的滑块,上面顶点处是 x,y\n * / \\\n * | | | |\n * | | | |\n * -----\n */\n const triangleY = y + height * HANDLER_TRIANGLE_RATIO;\n path.push(['M', x, y]);\n path.push(['L', x - halfWidth, triangleY]);\n path.push(['L', x - halfWidth, y + height]);\n path.push(['L', x + halfWidth, y + height]);\n path.push(['L', x + halfWidth, triangleY]);\n path.push(['Z']);\n // 绘制两条竖线\n path.push(['M', x - oneSixthWidth, triangleY]);\n path.push(['L', x - oneSixthWidth, y + height - 2]);\n path.push(['M', x + oneSixthWidth, triangleY]);\n path.push(['L', x + oneSixthWidth, y + height - 2]);\n }\n return path;\n }\n\n // 调整 handler 的位置,如果未存在则绘制\n private resetHandler(group: IGroup, name, value) {\n const point = this.getPointByValue(value, group);\n const handlerCfg = this.get('handler');\n const path = this.getHandlerPath(handlerCfg, point);\n const id = this.getElementId(`handler-${name}`);\n const handlerShape = group.findById(id);\n const isVertical = this.isVertical();\n if (handlerShape) {\n handlerShape.attr('path', path);\n } else {\n this.addShape(group, {\n type: 'path',\n name: `legend-handler-${name}`,\n draggable: true, // 可拖拽\n id,\n attrs: {\n path,\n ...handlerCfg.style,\n cursor: isVertical ? 'ns-resize' : 'ew-resize',\n },\n });\n }\n }\n\n // 当设置了 maxWidth, maxHeight 时调整 rail 的宽度,\n // 文本的位置\n private fixedElements(group: IGroup) {\n const railShape = group.findById(this.getElementId('rail'));\n const minLabel = group.findById(this.getElementId('label-min'));\n const maxLabel = group.findById(this.getElementId('label-max'));\n const startPoint = this.getDrawPoint();\n if (this.isVertical()) {\n // 横向布局\n this.fixedVertail(minLabel, maxLabel, railShape, startPoint);\n } else {\n // 水平布局\n this.fixedHorizontal(minLabel, maxLabel, railShape, startPoint);\n }\n }\n\n private fitRailLength(minLabelBBox, maxLabelBBox, railBBox, railShape) {\n const isVertical = this.isVertical();\n const lengthField = isVertical ? 'height' : 'width';\n const labelCfg = this.get('label');\n const labelAlign = labelCfg.align;\n const spacing = labelCfg.spacing;\n const maxLength = this.get(`max${upperFirst(lengthField)}`); // get('maxWidth')\n if (maxLength) {\n const elementsLength =\n labelAlign === 'rail'\n ? railBBox[lengthField] + minLabelBBox[lengthField] + maxLabelBBox[lengthField] + spacing * 2\n : railBBox[lengthField];\n const diff = elementsLength - maxLength;\n if (diff > 0) {\n // 大于限制的长度\n this.changeRailLength(railShape, lengthField, railBBox[lengthField] - diff);\n }\n }\n }\n\n private changeRailLength(railShape, lengthField, length) {\n const bbox = railShape.getBBox();\n let path;\n if (lengthField === 'height') {\n path = this.getRailPath(bbox.x, bbox.y, bbox.width, length);\n } else {\n path = this.getRailPath(bbox.x, bbox.y, length, bbox.height);\n }\n railShape.attr('path', path);\n }\n\n private changeRailPosition(railShape, x, y) {\n const bbox = railShape.getBBox();\n const path = this.getRailPath(x, y, bbox.width, bbox.height);\n railShape.attr('path', path);\n }\n\n private fixedHorizontal(minLabel: IElement, maxLabel: IElement, railShape: IElement, startPoint) {\n const labelCfg = this.get('label');\n const labelAlign = labelCfg.align;\n const spacing = labelCfg.spacing;\n let railBBox = railShape.getBBox();\n const minLabelBBox = minLabel.getBBox();\n const maxLabelBBox = maxLabel.getBBox();\n const railHeight = railBBox.height; // 取 rail 的高度,作为高度\n this.fitRailLength(minLabelBBox, maxLabelBBox, railBBox, railShape);\n railBBox = railShape.getBBox();\n if (labelAlign === 'rail') {\n // 沿着 rail 方向\n minLabel.attr({\n x: startPoint.x,\n y: startPoint.y + railHeight / 2,\n });\n this.changeRailPosition(railShape, startPoint.x + minLabelBBox.width + spacing, startPoint.y);\n maxLabel.attr({\n x: startPoint.x + minLabelBBox.width + railBBox.width + spacing * 2,\n y: startPoint.y + railHeight / 2,\n });\n } else if (labelAlign === 'top') {\n minLabel.attr({\n x: startPoint.x,\n y: startPoint.y,\n });\n maxLabel.attr({\n x: startPoint.x + railBBox.width,\n y: startPoint.y,\n });\n this.changeRailPosition(railShape, startPoint.x, startPoint.y + minLabelBBox.height + spacing);\n } else {\n this.changeRailPosition(railShape, startPoint.x, startPoint.y);\n minLabel.attr({\n x: startPoint.x,\n y: startPoint.y + railBBox.height + spacing,\n });\n maxLabel.attr({\n x: startPoint.x + railBBox.width,\n y: startPoint.y + railBBox.height + spacing,\n });\n }\n }\n\n private fixedVertail(minLabel: IElement, maxLabel: IElement, railShape: IElement, startPoint) {\n const labelCfg = this.get('label');\n const labelAlign = labelCfg.align;\n const spacing = labelCfg.spacing;\n let railBBox = railShape.getBBox();\n const minLabelBBox = minLabel.getBBox();\n const maxLabelBBox = maxLabel.getBBox();\n this.fitRailLength(minLabelBBox, maxLabelBBox, railBBox, railShape);\n railBBox = railShape.getBBox();\n\n if (labelAlign === 'rail') {\n // 沿着 rail 方向\n minLabel.attr({\n x: startPoint.x,\n y: startPoint.y,\n });\n this.changeRailPosition(railShape, startPoint.x, startPoint.y + minLabelBBox.height + spacing);\n maxLabel.attr({\n x: startPoint.x,\n y: startPoint.y + minLabelBBox.height + railBBox.height + spacing * 2,\n });\n } else if (labelAlign === 'right') {\n minLabel.attr({\n x: startPoint.x + railBBox.width + spacing,\n y: startPoint.y,\n });\n this.changeRailPosition(railShape, startPoint.x, startPoint.y);\n maxLabel.attr({\n x: startPoint.x + railBBox.width + spacing,\n y: startPoint.y + railBBox.height,\n });\n } else {\n // left\n const maxLabelWidth = Math.max(minLabelBBox.width, maxLabelBBox.width);\n minLabel.attr({\n x: startPoint.x,\n y: startPoint.y,\n });\n this.changeRailPosition(railShape, startPoint.x + maxLabelWidth + spacing, startPoint.y);\n maxLabel.attr({\n x: startPoint.x,\n y: startPoint.y + railBBox.height,\n });\n }\n }\n}\n\nexport default ContinueLegend;\n","export const CONTAINER_CLASS = 'g2-tooltip';\nexport const TITLE_CLASS = 'g2-tooltip-title';\nexport const LIST_CLASS = 'g2-tooltip-list';\nexport const LIST_ITEM_CLASS = 'g2-tooltip-list-item';\nexport const MARKER_CLASS = 'g2-tooltip-marker';\nexport const VALUE_CLASS = 'g2-tooltip-value';\nexport const NAME_CLASS = 'g2-tooltip-name';\nexport const CROSSHAIR_X = 'g2-tooltip-crosshair-x';\nexport const CROSSHAIR_Y = 'g2-tooltip-crosshair-y';\n","import Theme from '../util/theme';\n\n// tooltip 相关 dom 的 css 类名\nimport * as CssConst from './css-const';\n\nexport default {\n // css style for tooltip\n [`${CssConst.CONTAINER_CLASS}`]: {\n position: 'absolute',\n visibility: 'visible',\n // @2018-07-25 by blue.lb 这里去掉浮动,火狐上存在样式错位\n // whiteSpace: 'nowrap',\n zIndex: 8,\n transition:\n 'visibility 0.2s cubic-bezier(0.23, 1, 0.32, 1), ' +\n 'left 0.4s cubic-bezier(0.23, 1, 0.32, 1), ' +\n 'top 0.4s cubic-bezier(0.23, 1, 0.32, 1)',\n backgroundColor: 'rgba(255, 255, 255, 0.9)',\n boxShadow: '0px 0px 10px #aeaeae',\n borderRadius: '3px',\n color: 'rgb(87, 87, 87)',\n fontSize: '12px',\n fontFamily: Theme.fontFamily,\n lineHeight: '20px',\n padding: '10px 10px 6px 10px',\n },\n [`${CssConst.TITLE_CLASS}`]: {\n marginBottom: '4px',\n },\n [`${CssConst.LIST_CLASS}`]: {\n margin: '0px',\n listStyleType: 'none',\n padding: '0px',\n },\n [`${CssConst.LIST_ITEM_CLASS}`]: {\n listStyleType: 'none',\n marginBottom: '4px',\n },\n [`${CssConst.MARKER_CLASS}`]: {\n width: '8px',\n height: '8px',\n borderRadius: '50%',\n display: 'inline-block',\n marginRight: '8px',\n },\n [`${CssConst.VALUE_CLASS}`]: {\n display: 'inline-block',\n float: 'right',\n marginLeft: '30px',\n },\n [`${CssConst.CROSSHAIR_X}`]: {\n position: 'absolute',\n width: '1px',\n backgroundColor: 'rgba(0, 0, 0, 0.25)',\n },\n [`${CssConst.CROSSHAIR_Y}`]: {\n position: 'absolute',\n height: '1px',\n backgroundColor: 'rgba(0, 0, 0, 0.25)',\n },\n};\n","import colorUtil from '@antv/color-util';\nimport { createDom, modifyCSS } from '@antv/dom-util';\nimport { each, hasKey, isElement, substitute } from '@antv/util';\nimport HtmlComponent from '../abstract/html-component';\nimport { Point, PointLocationCfg } from '../types';\nimport { TooltipCfg } from '../types';\nimport { clearDom, regionToBBox, toPx } from '../util/util';\nimport * as CssConst from './css-const';\nimport TooltipTheme from './html-theme';\n\nimport { ILocation } from '../interfaces';\nimport { getAlignPoint } from '../util/align';\n\nfunction hasOneKey(obj, keys) {\n let result = false;\n each(keys, (key) => {\n if (hasKey(obj, key)) {\n result = true;\n return false;\n }\n });\n return result;\n}\n\nclass Tooltip extends HtmlComponent implements ILocation {\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n name: 'tooltip',\n type: 'html',\n x: 0,\n y: 0,\n items: [],\n customContent: null,\n containerTpl: `
    `,\n itemTpl: `
  • \n \n {name}:\n {value}\n
  • `,\n xCrosshairTpl: `
    `,\n yCrosshairTpl: `
    `,\n title: null,\n showTitle: true,\n /**\n * tooltip 限制的区域\n * @type {Region}\n */\n region: null,\n // crosshair 的限制区域\n crosshairsRegion: null,\n containerClassName: CssConst.CONTAINER_CLASS,\n // x, y, xy\n crosshairs: null,\n offset: 10,\n position: 'right',\n domStyles: null,\n defaultStyles: TooltipTheme,\n };\n }\n\n // tooltip 渲染时,渲染 title,items 和 corosshairs\n public render() {\n if (this.get('customContent')) {\n this.renderCustomContent();\n } else {\n this.resetTitle();\n this.renderItems();\n }\n // 绘制完成后,再定位\n this.resetPosition();\n }\n\n // 复写清空函数,因为有模板的存在,所以默认的写法不合适\n public clear() {\n // 由于 crosshair 没有在 container 内,所以需要单独清理\n this.clearCrosshairs();\n this.setTitle(''); // 清空标题\n this.clearItemDoms();\n }\n\n public show() {\n const container = this.getContainer();\n if (!container || this.destroyed) {\n // 防止容器不存在或者被销毁时报错\n return;\n }\n this.set('visible', true);\n modifyCSS(container, {\n visibility: 'visible',\n });\n this.setCrossHairsVisible(true);\n }\n\n public hide() {\n const container = this.getContainer();\n // relative: https://github.com/antvis/g2/issues/1221\n if (!container || this.destroyed) {\n return;\n }\n this.set('visible', false);\n modifyCSS(container, {\n visibility: 'hidden',\n });\n this.setCrossHairsVisible(false);\n }\n\n // 实现 IPointLocation 的接口\n public getLocation() {\n return { x: this.get('x'), y: this.get('y') };\n }\n // 实现 IPointLocation 的接口\n public setLocation(point: Point) {\n this.set('x', point.x);\n this.set('y', point.y);\n this.resetPosition();\n }\n\n public setCrossHairsVisible(visible) {\n const display = visible ? '' : 'none';\n const xCrosshairDom = this.get('xCrosshairDom');\n const yCrosshairDom = this.get('yCrosshairDom');\n xCrosshairDom &&\n modifyCSS(xCrosshairDom, {\n display,\n });\n yCrosshairDom &&\n modifyCSS(yCrosshairDom, {\n display,\n });\n }\n\n // 如有 customContent 则根据 customContent 设置 container\n protected initContainer() {\n super.initContainer();\n if (this.get('customContent')) {\n if (this.get('container')) {\n this.get('container').remove();\n }\n const container = this.getHtmlContentNode();\n this.get('parent').appendChild(container);\n this.set('container', container);\n this.resetStyles();\n this.applyStyles();\n }\n }\n\n // 更新属性的同时,可能会引起 DOM 的变化,这里对可能引起 DOM 变化的场景做了处理\n protected updateInner(cfg: Partial) {\n if (this.get('customContent')) {\n this.renderCustomContent();\n } else {\n // 更新标题\n if (hasOneKey(cfg, ['title', 'showTitle'])) {\n this.resetTitle();\n }\n // 更新内容\n if (hasKey(cfg, 'items')) {\n this.renderItems();\n }\n }\n super.updateInner(cfg);\n }\n\n protected initDom() {\n this.cacheDoms();\n }\n // 清理 DOM\n protected removeDom() {\n super.removeDom();\n this.clearCrosshairs();\n }\n // 调整位置\n protected resetPosition() {\n const x = this.get('x');\n const y = this.get('y');\n const offset = this.get('offset');\n const { offsetX, offsetY } = this.getOffset();\n const position = this.get('position');\n const region = this.get('region');\n const container = this.getContainer();\n const bbox = this.getBBox();\n const { width, height } = bbox;\n let limitBox;\n if (region) {\n // 不限制位置\n limitBox = regionToBBox(region);\n }\n const point = getAlignPoint(x, y, offset, width, height, position, limitBox);\n modifyCSS(container, {\n left: toPx(point.x + offsetX),\n top: toPx(point.y + offsetY),\n });\n this.resetCrosshairs();\n }\n\n // 根据 customContent 渲染\n private renderCustomContent() {\n const node = this.getHtmlContentNode();\n const parent: HTMLElement = this.get('parent');\n const curContainer: HTMLElement = this.get('container');\n if (curContainer && curContainer.parentNode === parent) {\n parent.replaceChild(node, curContainer);\n } else {\n parent.appendChild(node);\n }\n this.set('container', node);\n this.resetStyles();\n this.applyStyles();\n }\n\n private getHtmlContentNode() {\n let node: HTMLElement | undefined;\n const customContent = this.get('customContent');\n if (customContent) {\n const elem = customContent(this.get('title'), this.get('items'));\n if (isElement(elem)) {\n node = elem as HTMLElement;\n } else {\n node = createDom(elem);\n }\n }\n return node;\n }\n\n // 缓存模板设置的各种 DOM\n private cacheDoms() {\n const container = this.getContainer();\n const titleDom = container.getElementsByClassName(CssConst.TITLE_CLASS)[0];\n const listDom = container.getElementsByClassName(CssConst.LIST_CLASS)[0];\n this.set('titleDom', titleDom);\n this.set('listDom', listDom);\n }\n\n // 重置 title\n private resetTitle() {\n const title = this.get('title');\n const showTitle = this.get('showTitle');\n if (showTitle && title) {\n this.setTitle(title);\n } else {\n this.setTitle('');\n }\n }\n // 设置 title 文本\n private setTitle(text) {\n const titleDom = this.get('titleDom');\n if (titleDom) {\n titleDom.innerText = text;\n }\n }\n // 终止 crosshair\n private resetCrosshairs() {\n const crosshairsRegion = this.get('crosshairsRegion');\n const crosshairs = this.get('crosshairs');\n if (!crosshairsRegion || !crosshairs) {\n // 不显示 crosshair,都移除,没有设定 region 也都移除掉\n this.clearCrosshairs();\n } else {\n const crosshairBox = regionToBBox(crosshairsRegion);\n const xCrosshairDom = this.get('xCrosshairDom');\n const yCrosshairDom = this.get('yCrosshairDom');\n if (crosshairs === 'x') {\n this.resetCrosshair('x', crosshairBox);\n // 仅显示 x 的 crosshair,y 移除\n if (yCrosshairDom) {\n yCrosshairDom.remove();\n this.set('yCrosshairDom', null);\n }\n } else if (crosshairs === 'y') {\n this.resetCrosshair('y', crosshairBox);\n // 仅显示 y 的 crosshair,x 移除\n if (xCrosshairDom) {\n xCrosshairDom.remove();\n this.set('xCrosshairDom', null);\n }\n } else {\n this.resetCrosshair('x', crosshairBox);\n this.resetCrosshair('y', crosshairBox);\n }\n this.setCrossHairsVisible(this.get('visible'));\n }\n }\n // 设定 crosshair 的位置,需要区分 x,y\n private resetCrosshair(name: string, bbox) {\n const croshairDom = this.checkCrosshair(name);\n const value = this.get(name);\n if (name === 'x') {\n modifyCSS(croshairDom, {\n left: toPx(value),\n top: toPx(bbox.y),\n height: toPx(bbox.height),\n });\n } else {\n modifyCSS(croshairDom, {\n top: toPx(value),\n left: toPx(bbox.x),\n width: toPx(bbox.width),\n });\n }\n }\n\n // 如果 crosshair 对应的 dom 不存在,则创建\n private checkCrosshair(name: string) {\n const domName = `${name}CrosshairDom`;\n const tplName = `${name}CrosshairTpl`;\n const constName = `CROSSHAIR_${name.toUpperCase()}`;\n const styleName = CssConst[constName];\n let croshairDom = this.get(domName);\n const parent = this.get('parent') as HTMLElement;\n if (!croshairDom) {\n croshairDom = createDom(this.get(tplName)); // 创建\n this.applyStyle(styleName, croshairDom); // 设置初始样式\n parent.appendChild(croshairDom); // 添加到跟 tooltip 同级的目录下\n this.set(domName, croshairDom);\n }\n return croshairDom;\n }\n\n private renderItems() {\n this.clearItemDoms();\n const items = this.get('items');\n const itemTpl = this.get('itemTpl');\n const listDom = this.get('listDom');\n if (listDom) {\n each(items, (item) => {\n const color = colorUtil.toCSSGradient(item.color);\n const substituteObj = {\n ...item,\n color,\n };\n\n const domStr = substitute(itemTpl, substituteObj);\n const itemDom = createDom(domStr);\n listDom.appendChild(itemDom);\n });\n this.applyChildrenStyles(listDom, this.get('domStyles'));\n }\n }\n\n private clearItemDoms() {\n if (this.get('listDom')) {\n clearDom(this.get('listDom'));\n }\n }\n\n private clearCrosshairs() {\n const xCrosshairDom = this.get('xCrosshairDom');\n const yCrosshairDom = this.get('yCrosshairDom');\n xCrosshairDom && xCrosshairDom.remove();\n yCrosshairDom && yCrosshairDom.remove();\n this.set('xCrosshairDom', null);\n this.set('yCrosshairDom', null);\n }\n}\n\nexport default Tooltip;\n","import { BBox, Point } from '../types';\n\ninterface OutSides {\n left: boolean;\n right: boolean;\n top: boolean;\n bottom: boolean;\n}\n\n// 检测各边是否超出\nexport function getOutSides(x: number, y: number, width: number, height: number, limitBox: BBox): OutSides {\n const hits = {\n left: x < limitBox.x,\n right: x + width > limitBox.x + limitBox.width,\n top: y < limitBox.y,\n bottom: y + height > limitBox.y + limitBox.height,\n };\n return hits;\n}\n\nexport function getPointByPosition(\n x: number,\n y: number,\n offset: number,\n width: number,\n height: number,\n position: string\n): Point {\n let px = x;\n let py = y;\n switch (position) {\n case 'left': // left center\n px = x - width - offset;\n py = y - height / 2;\n break;\n case 'right':\n px = x + offset;\n py = y - height / 2;\n break;\n case 'top':\n px = x - width / 2;\n py = y - height - offset;\n break;\n case 'bottom':\n // bottom\n px = x - width / 2;\n py = y + offset;\n break;\n default:\n // auto, 在 top-right\n px = x + offset;\n py = y - height - offset;\n break;\n }\n\n return {\n x: px,\n y: py,\n };\n}\n\nexport function getAlignPoint(\n x: number,\n y: number,\n offset: number,\n width: number,\n height: number,\n position: string,\n limitBox?: BBox\n): Point {\n const point = getPointByPosition(x, y, offset, width, height, position);\n if (limitBox) {\n const outSides = getOutSides(point.x, point.y, width, height, limitBox);\n if (position === 'auto') {\n // 如果是 auto,默认 tooltip 在右上角,仅需要判定右侧和上测冲突即可\n if (outSides.right) {\n point.x = Math.max(0, x - width - offset);\n }\n if (outSides.top) {\n point.y = Math.max(0, y - height - offset);\n }\n } else if (position === 'top' || position === 'bottom') {\n if (outSides.left) {\n // 左侧躲避\n point.x = limitBox.x;\n }\n if (outSides.right) {\n // 右侧躲避\n point.x = limitBox.x + limitBox.width - width;\n }\n if (position === 'top' && outSides.top) {\n // 如果上面对齐检测上面,不检测下面\n point.y = y + offset;\n }\n if (position === 'bottom' && outSides.bottom) {\n point.y = y - height - offset;\n }\n } else {\n // 检测左右位置\n if (outSides.top) {\n point.y = limitBox.y;\n }\n if (outSides.bottom) {\n point.y = limitBox.y + limitBox.height - height;\n }\n if (position === 'left' && outSides.left) {\n point.x = x + offset;\n }\n if (position === 'right' && outSides.right) {\n point.x = x - width - offset;\n }\n }\n }\n return point;\n}\n","export const BACKGROUND_STYLE = {\n // fill: 'red',\n opacity: 0,\n};\n\nexport const LINE_STYLE = {\n stroke: '#C5C5C5',\n strokeOpacity: 0.85,\n};\n\nexport const AREA_STYLE = {\n fill: '#CACED4',\n opacity: 0.85,\n};\n","import { vec2 } from '@antv/matrix-util';\nimport type { PathCommand } from './types';\n\ntype Pos = [number, number];\n\nfunction smoothBezier(points: Pos[], smooth: number, isLoop: boolean, constraint: Pos[]) {\n const cps: vec2[] = [];\n const hasConstraint = !!constraint;\n\n let prevPoint: Pos;\n let nextPoint: Pos;\n let min: vec2;\n let max: vec2;\n let nextCp0: vec2;\n let cp1: vec2;\n let cp0: vec2;\n\n if (hasConstraint) {\n [ min, max ] = constraint;\n for (let i = 0, l = points.length; i < l; i += 1) {\n const point = points[i];\n min = vec2.min([ 0, 0 ], min, point);\n max = vec2.max([ 0, 0 ], max, point);\n }\n }\n\n for (let i = 0, len = points.length; i < len; i += 1) {\n const point = points[i];\n if (i === 0 && !isLoop) {\n cp0 = point;\n } else if (i === len - 1 && !isLoop) {\n cp1 = point;\n cps.push(cp0);\n cps.push(cp1);\n } else {\n const prevIdx = [ i ? i - 1 : len - 1, i - 1 ][isLoop ? 0 : 1];\n prevPoint = points[prevIdx];\n nextPoint = points[isLoop ? (i + 1) % len : i + 1];\n\n let v: vec2 = [ 0, 0 ];\n v = vec2.sub(v, nextPoint, prevPoint);\n v = vec2.scale(v, v, smooth);\n\n let d0 = vec2.distance(point, prevPoint);\n let d1 = vec2.distance(point, nextPoint);\n\n const sum = d0 + d1;\n if (sum !== 0) {\n d0 /= sum;\n d1 /= sum;\n }\n\n let v1 = vec2.scale([ 0, 0 ], v, -d0);\n let v2 = vec2.scale([ 0, 0 ], v, d1);\n\n cp1 = vec2.add([ 0, 0 ], point, v1);\n nextCp0 = vec2.add([ 0, 0 ], point, v2);\n\n // 下一个控制点必须在这个点和下一个点之间\n nextCp0 = vec2.min([ 0, 0 ], nextCp0, vec2.max([ 0, 0 ], nextPoint, point));\n nextCp0 = vec2.max([ 0, 0 ], nextCp0, vec2.min([ 0, 0 ], nextPoint, point));\n\n // 重新计算 cp1 的值\n v1 = vec2.sub([ 0, 0 ], nextCp0, point);\n v1 = vec2.scale([ 0, 0 ], v1, -d0 / d1);\n cp1 = vec2.add([ 0, 0 ], point, v1);\n\n // 上一个控制点必须要在上一个点和这一个点之间\n cp1 = vec2.min([ 0, 0 ], cp1, vec2.max([ 0, 0 ], prevPoint, point));\n cp1 = vec2.max([ 0, 0 ], cp1, vec2.min([ 0, 0 ], prevPoint, point));\n\n // 重新计算 nextCp0 的值\n v2 = vec2.sub([ 0, 0 ], point, cp1);\n v2 = vec2.scale([ 0, 0 ], v2, d1 / d0);\n nextCp0 = vec2.add([ 0, 0 ], point, v2);\n\n if (hasConstraint) {\n cp1 = vec2.max([ 0, 0 ], cp1, min);\n cp1 = vec2.min([ 0, 0 ], cp1, max);\n nextCp0 = vec2.max([ 0, 0 ], nextCp0, min);\n nextCp0 = vec2.min([ 0, 0 ], nextCp0, max);\n }\n\n cps.push(cp0);\n cps.push(cp1);\n cp0 = nextCp0;\n }\n }\n\n if (isLoop) {\n cps.push(cps.shift());\n }\n\n return cps;\n}\n\n/**\n * create bezier spline from catmull rom spline\n * @param {Array} crp Catmull Rom Points\n * @param {boolean} z Spline is loop\n * @param {Array} constraint Constraint\n */\nfunction catmullRom2Bezier(\n crp: number[],\n z: boolean = false,\n constraint: Pos[] = [\n [ 0, 0 ],\n [ 1, 1 ],\n ]\n): PathCommand[] {\n const isLoop = !!z;\n const pointList: Pos[] = [];\n for (let i = 0, l = crp.length; i < l; i += 2) {\n pointList.push([ crp[i], crp[i + 1] ]);\n }\n\n const controlPointList = smoothBezier(pointList, 0.4, isLoop, constraint);\n const len = pointList.length;\n const d1: PathCommand[] = [];\n\n let cp1: vec2;\n let cp2: vec2;\n let p: Pos;\n\n for (let i = 0; i < len - 1; i += 1) {\n cp1 = controlPointList[i * 2];\n cp2 = controlPointList[i * 2 + 1];\n p = pointList[i + 1];\n\n d1.push([ 'C', cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1] ]);\n }\n\n if (isLoop) {\n cp1 = controlPointList[len];\n cp2 = controlPointList[len + 1];\n [ p ] = pointList;\n\n d1.push([ 'C', cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1] ]);\n }\n return d1;\n}\n\nexport default catmullRom2Bezier;\n","import { isArray } from '@antv/util';\n\nconst SPACES = '\\x09\\x0a\\x0b\\x0c\\x0d\\x20\\xa0\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\u2028\\u2029';\nconst PATH_COMMAND = new RegExp('([a-z])[' + SPACES + ',]*((-?\\\\d*\\\\.?\\\\d*(?:e[\\\\-+]?\\\\d+)?[' + SPACES + ']*,?[' + SPACES + ']*)+)', 'ig');\nconst PATH_VALUES = new RegExp('(-?\\\\d*\\\\.?\\\\d*(?:e[\\\\-+]?\\\\d+)?)[' + SPACES + ']*,?[' + SPACES + ']*', 'ig');\n\n// Parses given path string into an array of arrays of path segments\nexport default function parsePathString(pathString: string) {\n if (!pathString) {\n return null;\n }\n\n if (isArray(pathString)) {\n return pathString;\n }\n const paramCounts = {\n a: 7,\n c: 6,\n o: 2,\n h: 1,\n l: 2,\n m: 2,\n r: 4,\n q: 4,\n s: 4,\n t: 2,\n v: 1,\n u: 3,\n z: 0,\n };\n const data = [];\n\n String(pathString).replace(PATH_COMMAND, function (a, b, c) {\n const params = [];\n let name = b.toLowerCase();\n c.replace(PATH_VALUES, function (a, b) {\n b && params.push(+b);\n });\n if (name === 'm' && params.length > 2) {\n data.push([ b ].concat(params.splice(0, 2)));\n name = 'l';\n b = b === 'm' ? 'l' : 'L';\n }\n if (name === 'o' && params.length === 1) {\n data.push([ b, params[0] ]);\n }\n if (name === 'r') {\n data.push([ b ].concat(params));\n } else {\n while (params.length >= paramCounts[name]) {\n data.push([ b ].concat(params.splice(0, paramCounts[name])));\n if (!paramCounts[name]) {\n break;\n }\n }\n }\n return '';\n });\n\n return data;\n}\n","const TAU = Math.PI * 2\n\nconst mapToEllipse = ({ x, y }: { x: number, y: number }, rx: number, ry: number, cosphi: number, sinphi: number, centerx: number, centery: number) => {\n x *= rx\n y *= ry\n\n const xp = cosphi * x - sinphi * y\n const yp = sinphi * x + cosphi * y\n\n return {\n x: xp + centerx,\n y: yp + centery\n }\n}\n\nconst approxUnitArc = (ang1: number, ang2: number) => {\n // If 90 degree circular arc, use a constant\n // as derived from http://spencermortensen.com/articles/bezier-circle\n const a = ang2 === 1.5707963267948966\n ? 0.551915024494\n : ang2 === -1.5707963267948966\n ? -0.551915024494\n : 4 / 3 * Math.tan(ang2 / 4)\n\n const x1 = Math.cos(ang1)\n const y1 = Math.sin(ang1)\n const x2 = Math.cos(ang1 + ang2)\n const y2 = Math.sin(ang1 + ang2)\n\n return [\n {\n x: x1 - y1 * a,\n y: y1 + x1 * a\n },\n {\n x: x2 + y2 * a,\n y: y2 - x2 * a\n },\n {\n x: x2,\n y: y2\n }\n ]\n}\n\nconst vectorAngle = (ux: number, uy: number, vx: number, vy: number) => {\n const sign = (ux * vy - uy * vx < 0) ? -1 : 1\n\n let dot = ux * vx + uy * vy\n\n if (dot > 1) {\n dot = 1\n }\n\n if (dot < -1) {\n dot = -1\n }\n\n return sign * Math.acos(dot)\n}\n\nconst getArcCenter = (\n px: any,\n py: any,\n cx: any,\n cy: any,\n rx: number,\n ry: number,\n largeArcFlag: number,\n sweepFlag: number,\n sinphi: number,\n cosphi: number,\n pxp: number,\n pyp: number\n) => {\n const rxsq = Math.pow(rx, 2)\n const rysq = Math.pow(ry, 2)\n const pxpsq = Math.pow(pxp, 2)\n const pypsq = Math.pow(pyp, 2)\n\n let radicant = (rxsq * rysq) - (rxsq * pypsq) - (rysq * pxpsq)\n\n if (radicant < 0) {\n radicant = 0\n }\n\n radicant /= (rxsq * pypsq) + (rysq * pxpsq)\n radicant = Math.sqrt(radicant) * (largeArcFlag === sweepFlag ? -1 : 1)\n\n const centerxp = radicant * rx / ry * pyp\n const centeryp = radicant * -ry / rx * pxp\n\n const centerx = cosphi * centerxp - sinphi * centeryp + (px + cx) / 2\n const centery = sinphi * centerxp + cosphi * centeryp + (py + cy) / 2\n\n const vx1 = (pxp - centerxp) / rx\n const vy1 = (pyp - centeryp) / ry\n const vx2 = (-pxp - centerxp) / rx\n const vy2 = (-pyp - centeryp) / ry\n\n let ang1 = vectorAngle(1, 0, vx1, vy1)\n let ang2 = vectorAngle(vx1, vy1, vx2, vy2)\n\n if (sweepFlag === 0 && ang2 > 0) {\n ang2 -= TAU\n }\n\n if (sweepFlag === 1 && ang2 < 0) {\n ang2 += TAU\n }\n\n return [ centerx, centery, ang1, ang2 ]\n}\n\nconst arcToBezier = ({\n px,\n py,\n cx,\n cy,\n rx,\n ry,\n xAxisRotation = 0,\n largeArcFlag = 0,\n sweepFlag = 0\n}) => {\n const curves = []\n\n if (rx === 0 || ry === 0) {\n return [{ x1: 0, y1: 0, x2: 0, y2: 0, x: cx, y: cy }];\n }\n\n const sinphi = Math.sin(xAxisRotation * TAU / 360)\n const cosphi = Math.cos(xAxisRotation * TAU / 360)\n\n const pxp = cosphi * (px - cx) / 2 + sinphi * (py - cy) / 2\n const pyp = -sinphi * (px - cx) / 2 + cosphi * (py - cy) / 2\n\n if (pxp === 0 && pyp === 0) {\n return [{ x1: 0, y1: 0, x2: 0, y2: 0, x: cx, y: cy }];\n }\n\n rx = Math.abs(rx)\n ry = Math.abs(ry)\n\n const lambda =\n Math.pow(pxp, 2) / Math.pow(rx, 2) +\n Math.pow(pyp, 2) / Math.pow(ry, 2)\n\n if (lambda > 1) {\n rx *= Math.sqrt(lambda)\n ry *= Math.sqrt(lambda)\n }\n\n let [ centerx, centery, ang1, ang2 ] = getArcCenter(\n px,\n py,\n cx,\n cy,\n rx,\n ry,\n largeArcFlag,\n sweepFlag,\n sinphi,\n cosphi,\n pxp,\n pyp\n )\n\n // If 'ang2' == 90.0000000001, then `ratio` will evaluate to\n // 1.0000000001. This causes `segments` to be greater than one, which is an\n // unecessary split, and adds extra points to the bezier curve. To alleviate\n // this issue, we round to 1.0 when the ratio is close to 1.0.\n let ratio = Math.abs(ang2) / (TAU / 4)\n if (Math.abs(1.0 - ratio) < 0.0000001) {\n ratio = 1.0\n }\n\n const segments = Math.max(Math.ceil(ratio), 1)\n\n ang2 /= segments\n\n for (let i = 0; i < segments; i++) {\n curves.push(approxUnitArc(ang1, ang2))\n ang1 += ang2\n }\n\n return curves.map(curve => {\n const { x: x1, y: y1 } = mapToEllipse(curve[ 0 ], rx, ry, cosphi, sinphi, centerx, centery)\n const { x: x2, y: y2 } = mapToEllipse(curve[ 1 ], rx, ry, cosphi, sinphi, centerx, centery)\n const { x, y } = mapToEllipse(curve[ 2 ], rx, ry, cosphi, sinphi, centerx, centery)\n\n return { x1, y1, x2, y2, x, y }\n })\n}\n\nexport function arcToCubic(x1: number, y1: number, rx: number, ry: number, angle: number, LAF: number, SF: number, x2: number, y2: number) {\n const curves = arcToBezier({\n px: x1,\n py: y1,\n cx: x2,\n cy: y2,\n rx,\n ry,\n xAxisRotation: angle,\n largeArcFlag: LAF,\n sweepFlag: SF,\n });\n\n return curves.reduce((prev, cur) => {\n const { x1, y1, x2, y2, x, y } = cur;\n prev.push(x1, y1, x2, y2, x, y);\n return prev;\n }, [] as number[]);\n}\n","import { catmullRom2Bezier } from '@antv/path-util';\nimport { Category, Linear } from '@antv/scale';\nimport { each, head, isEqual, map } from '@antv/util';\n\ntype Point = [number, number];\n\n/**\n * 点数组转 path\n * @param points\n */\nfunction pointsToPath(points: Point[]): any[][] {\n return map(points, (p: Point, idx: number) => {\n const command = idx === 0 ? 'M' : 'L';\n const [x, y] = p;\n return [command, x, y];\n });\n}\n\n/**\n * 将点连接成路径 path\n * @param points\n */\nexport function getLinePath(points: Point[]): any[][] {\n return pointsToPath(points);\n}\n\n/**\n * 将点连成平滑的曲线\n * @param points\n */\nexport function getSmoothLinePath(points: Point[]): any[][] {\n if (points.length <= 2) {\n // 两点以内直接绘制成路径\n return getLinePath(points);\n }\n\n const data = [];\n\n each(points, (p) => {\n // 当前点和上一个点一样的时候,忽略掉\n if (!isEqual(p, data.slice(data.length - 2))) {\n data.push(p[0], p[1]);\n }\n });\n\n // const constraint = [ // 范围\n // [ 0, 0 ],\n // [ 1, 1 ],\n // ];\n const path = catmullRom2Bezier(data, false);\n const [x, y] = head(points);\n path.unshift(['M', x, y]);\n\n return path;\n}\n\n/**\n * 将数据转成 path,利用 scale 的归一化能力\n * @param data\n * @param width\n * @param height\n * @param smooth\n */\nexport function dataToPath(data: number[], width: number, height: number, smooth: boolean = true): any[][] {\n // 利用 scale 来获取 y 上的映射\n const y = new Linear({\n values: data,\n });\n\n const x = new Category({\n values: map(data, (v, idx) => idx),\n });\n\n const points = map(data, (v: number, idx: number) => {\n return [x.scale(idx) * width, height - y.scale(v) * height] as [number, number];\n });\n\n return smooth ? getSmoothLinePath(points) : getLinePath(points);\n}\n\n/**\n * 获得 area 面积的横向连接线的 px 位置\n * @param data \n * @param width \n * @param height \n */\nexport function getAreaLineY(data: number[], height: number): number {\n const y = new Linear({\n values: data,\n });\n // 当曲线全部为负数时,取最大值,当曲线全部为正数时,取最小值,当曲线有正有负,则取零点\n const lineY = y.max < 0 ? y.max : Math.max(0, y.min);\n return height - y.scale(lineY) * height;\n}\n\n/**\n * 线 path 转 area path\n * @param path\n * @param width\n * @param height\n */\nexport function linePathToAreaPath(path: any[][], width: number, height: number, data: number[]): any[][] {\n const areaPath = [...path];\n\n const lineYPx = getAreaLineY(data, height);\n\n areaPath.push(['L', width, lineYPx]);\n areaPath.push(['L', 0, lineYPx]);\n areaPath.push(['Z']);\n\n return areaPath;\n}\n","import { IGroup } from '@antv/g-base';\nimport GroupComponent from '../abstract/group-component';\nimport { GroupComponentCfg } from '../types';\nimport { AREA_STYLE, BACKGROUND_STYLE, LINE_STYLE } from './constant';\nimport { dataToPath, linePathToAreaPath } from './path';\n\nexport interface TrendCfg extends GroupComponentCfg {\n // 位置大小\n readonly x?: number;\n readonly y?: number;\n readonly width?: number;\n readonly height?: number;\n // 数据\n readonly data?: number[];\n // 样式\n readonly smooth?: boolean;\n readonly isArea?: boolean;\n readonly backgroundStyle?: object;\n readonly lineStyle?: object;\n readonly areaStyle?: object;\n}\n\nexport class Trend extends GroupComponent {\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n name: 'trend',\n x: 0,\n y: 0,\n width: 200,\n height: 16,\n smooth: true,\n isArea: false,\n data: [],\n backgroundStyle: BACKGROUND_STYLE,\n lineStyle: LINE_STYLE,\n areaStyle: AREA_STYLE,\n };\n }\n\n protected renderInner(group: IGroup) {\n const { width, height, data, smooth, isArea, backgroundStyle, lineStyle, areaStyle } = this.cfg as TrendCfg;\n\n // 背景\n this.addShape(group, {\n id: this.getElementId('background'),\n type: 'rect',\n attrs: {\n x: 0,\n y: 0,\n width,\n height,\n ...backgroundStyle,\n },\n });\n\n const path = dataToPath(data, width, height, smooth);\n // 线\n this.addShape(group, {\n id: this.getElementId('line'),\n type: 'path',\n attrs: {\n path,\n ...lineStyle,\n },\n });\n\n // area\n // 在 path 的基础上,增加两个坐标点\n if (isArea) {\n const areaPath = linePathToAreaPath(path, width, height, data);\n this.addShape(group, {\n id: this.getElementId('area'),\n type: 'path',\n attrs: {\n path: areaPath,\n ...areaStyle,\n },\n });\n }\n }\n\n protected applyOffset() {\n const { x, y } = this.cfg as TrendCfg;\n\n // 统一移动到对应的位置\n this.moveElementTo(this.get('group'), {\n x,\n y,\n });\n }\n}\n\nexport default Trend;\n","import { IGroup } from '@antv/g-base';\nimport GroupComponent from '../abstract/group-component';\nimport { GroupComponentCfg } from '../types';\n\ninterface IStyle {\n fill?: string;\n stroke?: string;\n radius?: number;\n opacity?: number;\n cursor?: string;\n highLightFill?: string;\n}\n\nexport interface HandlerCfg extends GroupComponentCfg {\n // position size\n readonly x: number;\n readonly y: number;\n readonly width: number;\n readonly height: number;\n // style\n readonly style?: IStyle;\n}\n\nexport const DEFAULT_HANDLER_STYLE = {\n fill: '#F7F7F7',\n stroke: '#BFBFBF',\n radius: 2,\n opacity: 1,\n cursor: 'ew-resize',\n // 高亮的颜色\n highLightFill: '#FFF',\n};\n\nexport class Handler extends GroupComponent {\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n name: 'handler',\n x: 0,\n y: 0,\n width: 10,\n height: 24,\n style: DEFAULT_HANDLER_STYLE,\n };\n }\n protected renderInner(group: IGroup) {\n const { width, height, style } = this.cfg as HandlerCfg;\n const { fill, stroke, radius, opacity, cursor } = style;\n\n // 按钮框框\n this.addShape(group, {\n type: 'rect',\n id: this.getElementId('background'),\n attrs: {\n x: 0,\n y: 0,\n width,\n height,\n fill,\n stroke,\n radius,\n opacity,\n cursor,\n },\n });\n\n // 两根竖线\n const x1 = (1 / 3) * width;\n const x2 = (2 / 3) * width;\n\n const y1 = (1 / 4) * height;\n const y2 = (3 / 4) * height;\n\n this.addShape(group, {\n id: this.getElementId('line-left'),\n type: 'line',\n attrs: {\n x1,\n y1,\n x2: x1,\n y2,\n stroke,\n cursor,\n },\n });\n\n this.addShape(group, {\n id: this.getElementId('line-right'),\n type: 'line',\n attrs: {\n x1: x2,\n y1,\n x2,\n y2,\n stroke,\n cursor,\n },\n });\n }\n\n protected applyOffset() {\n this.moveElementTo(this.get('group'), {\n x: this.get('x'),\n y: this.get('y'),\n });\n }\n\n protected initEvent() {\n this.bindEvents();\n }\n\n private bindEvents() {\n this.get('group').on('mouseenter', () => {\n const { highLightFill } = this.get('style');\n this.getElementByLocalId('background').attr('fill', highLightFill);\n\n this.draw();\n });\n\n this.get('group').on('mouseleave', () => {\n const { fill } = this.get('style');\n this.getElementByLocalId('background').attr('fill', fill);\n\n this.draw();\n });\n }\n\n private draw() {\n const canvas = this.get('container').get('canvas');\n if (canvas) {\n canvas.draw();\n }\n }\n}\n\nexport default Handler;\n","/**\n * 一些默认的样式配置\n */\n\nexport const BACKGROUND_STYLE = {\n fill: '#416180',\n opacity: 0.05,\n};\n\nexport const FOREGROUND_STYLE = {\n fill: '#5B8FF9',\n opacity: 0.15,\n cursor: 'move',\n};\n\nexport const DEFAULT_HANDLER_WIDTH = 10;\n\nexport const HANDLER_STYLE = {\n width: DEFAULT_HANDLER_WIDTH,\n height: 24,\n};\n\nexport const TEXT_STYLE = {\n textBaseline: 'middle',\n fill: '#000',\n opacity: 0.45,\n};\n\nexport const SLIDER_CHANGE = 'sliderchange';\n","import { Event, IGroup, IShape } from '@antv/g-base';\nimport { clamp, deepMix, each, get, isArray, isNil, size } from '@antv/util';\nimport GroupComponent from '../abstract/group-component';\nimport { ISlider } from '../interfaces';\nimport { Trend } from '../trend/trend';\nimport { DEFAULT_HANDLER_STYLE, Handler, HandlerCfg } from './handler';\nimport { GroupComponentCfg, Range } from '../types';\nimport {\n BACKGROUND_STYLE,\n DEFAULT_HANDLER_WIDTH,\n FOREGROUND_STYLE,\n HANDLER_STYLE,\n SLIDER_CHANGE,\n TEXT_STYLE,\n} from './constant';\n\nexport interface TrendCfg {\n // 数据\n readonly data: number[];\n // 样式\n readonly smooth?: boolean;\n readonly isArea?: boolean;\n readonly backgroundStyle?: object;\n readonly lineStyle?: object;\n readonly areaStyle?: object;\n}\n\n/**\n * slider handler style 设置\n */\ntype HandlerStyle = HandlerCfg['style'] & {\n readonly width?: number;\n readonly height?: number;\n};\n\nexport interface SliderCfg extends GroupComponentCfg {\n // position size\n readonly x: number;\n readonly y: number;\n readonly width: number;\n readonly height: number;\n\n // style\n readonly trendCfg?: TrendCfg;\n readonly backgroundStyle?: any;\n readonly foregroundStyle?: any;\n readonly handlerStyle?: HandlerStyle;\n readonly textStyle?: any;\n // 允许滑动位置\n readonly minLimit?: number;\n readonly maxLimit?: number;\n // 初始位置\n readonly start?: number;\n readonly end?: number;\n // 滑块文本\n readonly minText?: string;\n readonly maxText?: string;\n}\n\nexport class Slider extends GroupComponent implements ISlider {\n public cfg: SliderCfg;\n\n private minHandler: Handler;\n private maxHandler: Handler;\n private trend: Trend;\n private currentTarget: string;\n private prevX: number;\n private prevY: number;\n\n public setRange(min: number, max: number) {\n this.set('minLimit', min);\n this.set('maxLimit', max);\n const oldStart = this.get('start');\n const oldEnd = this.get('end');\n const newStart = clamp(oldStart, min, max);\n const newEnd = clamp(oldEnd, min, max);\n if (!this.get('isInit') && (oldStart !== newStart || oldEnd !== newEnd)) {\n this.setValue([newStart, newEnd]);\n }\n }\n\n public getRange(): Range {\n return {\n min: this.get('minLimit') || 0,\n max: this.get('maxLimit') || 1,\n };\n }\n\n public setValue(value: number | number[]) {\n const range = this.getRange();\n if (isArray(value) && value.length === 2) {\n const originValue = [this.get('start'), this.get('end')];\n this.update({\n start: clamp(value[0], range.min, range.max),\n end: clamp(value[1], range.min, range.max),\n });\n if (!this.get('updateAutoRender')) {\n this.render();\n }\n this.delegateEmit('valuechanged', {\n originValue,\n value,\n });\n }\n }\n\n public getValue(): number | number[] {\n return [this.get('start'), this.get('end')];\n }\n\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n name: 'slider',\n x: 0,\n y: 0,\n width: 100,\n height: 16,\n backgroundStyle: {},\n foregroundStyle: {},\n handlerStyle: {},\n textStyle: {},\n defaultCfg: {\n backgroundStyle: BACKGROUND_STYLE,\n foregroundStyle: FOREGROUND_STYLE,\n handlerStyle: HANDLER_STYLE,\n textStyle: TEXT_STYLE,\n },\n };\n }\n\n public update(cfg: Partial) {\n const { start, end } = cfg;\n const validCfg = { ...cfg };\n if (!isNil(start)) {\n validCfg.start = clamp(start, 0, 1);\n }\n if (!isNil(end)) {\n validCfg.end = clamp(end, 0, 1);\n }\n super.update(validCfg);\n this.minHandler = this.getChildComponentById(this.getElementId('minHandler'));\n this.maxHandler = this.getChildComponentById(this.getElementId('maxHandler'));\n this.trend = this.getChildComponentById(this.getElementId('trend'));\n }\n\n public init() {\n this.set('start', clamp(this.get('start'), 0, 1));\n this.set('end', clamp(this.get('end'), 0, 1));\n super.init();\n }\n\n public render() {\n super.render();\n\n this.updateUI(\n this.getElementByLocalId('foreground'),\n this.getElementByLocalId('minText'),\n this.getElementByLocalId('maxText')\n );\n }\n\n protected renderInner(group: IGroup) {\n const {\n start,\n end,\n width,\n height,\n trendCfg = {},\n minText,\n maxText,\n backgroundStyle = {},\n foregroundStyle = {},\n textStyle = {},\n } = this.cfg;\n\n const handlerStyle = deepMix({}, DEFAULT_HANDLER_STYLE, this.cfg.handlerStyle);\n\n const min = start * width;\n const max = end * width;\n\n // 趋势图数据\n if (size(get(trendCfg, 'data'))) {\n this.trend = this.addComponent(group, {\n component: Trend,\n id: this.getElementId('trend'),\n x: 0,\n y: 0,\n width,\n height,\n ...trendCfg,\n });\n }\n\n // 1. 背景\n this.addShape(group, {\n id: this.getElementId('background'),\n type: 'rect',\n attrs: {\n x: 0,\n y: 0,\n width,\n height,\n ...backgroundStyle,\n },\n });\n\n // 2. 左右文字\n const minTextShape = this.addShape(group, {\n id: this.getElementId('minText'),\n type: 'text',\n attrs: {\n // x: 0,\n y: height / 2,\n textAlign: 'right',\n text: minText,\n silent: false,\n ...textStyle,\n },\n });\n\n const maxTextShape = this.addShape(group, {\n id: this.getElementId('maxText'),\n type: 'text',\n attrs: {\n // x: 0,\n y: height / 2,\n textAlign: 'left',\n text: maxText,\n silent: false,\n ...textStyle,\n },\n });\n\n // 3. 前景 选中背景框\n const foregroundShape = this.addShape(group, {\n id: this.getElementId('foreground'),\n name: 'foreground',\n type: 'rect',\n attrs: {\n // x: 0,\n y: 0,\n // width: 0,\n height,\n ...foregroundStyle,\n },\n });\n\n // 滑块相关的大小信息\n const handlerWidth = get(handlerStyle, 'width', DEFAULT_HANDLER_WIDTH);\n const handlerHeight = get(handlerStyle, 'height', 24);\n\n // 4. 左右滑块\n this.minHandler = this.addComponent(group, {\n component: Handler,\n id: this.getElementId('minHandler'),\n name: 'handler-min',\n x: 0,\n y: (height - handlerHeight) / 2,\n width: handlerWidth,\n height: handlerHeight,\n cursor: 'ew-resize',\n style: handlerStyle,\n });\n\n this.maxHandler = this.addComponent(group, {\n component: Handler,\n id: this.getElementId('maxHandler'),\n name: 'handler-max',\n x: 0,\n y: (height - handlerHeight) / 2,\n width: handlerWidth,\n height: handlerHeight,\n cursor: 'ew-resize',\n style: handlerStyle,\n });\n }\n\n protected applyOffset() {\n this.moveElementTo(this.get('group'), {\n x: this.get('x'),\n y: this.get('y'),\n });\n }\n\n protected initEvent() {\n this.bindEvents();\n }\n\n private updateUI(foregroundShape: IShape, minTextShape: IShape, maxTextShape: IShape) {\n const { start, end, width, minText, maxText, handlerStyle, height } = this.cfg as SliderCfg;\n const min = start * width;\n const max = end * width;\n\n if (this.trend) {\n this.trend.update({\n width,\n height,\n });\n if (!this.get('updateAutoRender')) {\n this.trend.render();\n }\n }\n\n // 1. foreground\n foregroundShape.attr('x', min);\n foregroundShape.attr('width', max - min);\n\n // 滑块相关的大小信息\n const handlerWidth = get(handlerStyle, 'width', DEFAULT_HANDLER_WIDTH);\n\n // 设置文本\n minTextShape.attr('text', minText);\n maxTextShape.attr('text', maxText);\n\n const [minAttrs, maxAttrs] = this._dodgeText([min, max], minTextShape, maxTextShape);\n // 2. 左侧滑块和文字位置\n if (this.minHandler) {\n this.minHandler.update({\n x: min - handlerWidth / 2,\n });\n if (!this.get('updateAutoRender')) {\n this.minHandler.render();\n }\n }\n each(minAttrs, (v, k) => minTextShape.attr(k, v));\n\n // 3. 右侧滑块和文字位置\n if (this.maxHandler) {\n this.maxHandler.update({\n x: max - handlerWidth / 2,\n });\n if (!this.get('updateAutoRender')) {\n this.maxHandler.render();\n }\n }\n each(maxAttrs, (v, k) => maxTextShape.attr(k, v));\n }\n\n private bindEvents() {\n const group: IGroup = this.get('group');\n\n group.on('handler-min:mousedown', this.onMouseDown('minHandler'));\n group.on('handler-min:touchstart', this.onMouseDown('minHandler'));\n\n // 2. 右滑块的滑动\n group.on('handler-max:mousedown', this.onMouseDown('maxHandler'));\n group.on('handler-max:touchstart', this.onMouseDown('maxHandler'));\n\n // 3. 前景选中区域\n const foreground = group.findById(this.getElementId('foreground'));\n foreground.on('mousedown', this.onMouseDown('foreground'));\n foreground.on('touchstart', this.onMouseDown('foreground'));\n }\n\n private onMouseDown = (target: string) => (e: Event) => {\n this.currentTarget = target;\n // 取出原生事件\n const event = e.originalEvent as MouseEvent;\n\n // 2. 存储当前点击位置\n event.stopPropagation();\n event.preventDefault();\n\n // 兼容移动端获取数据\n this.prevX = get(event, 'touches.0.pageX', event.pageX);\n this.prevY = get(event, 'touches.0.pageY', event.pageY);\n\n // 3. 开始滑动的时候,绑定 move 和 up 事件\n const containerDOM = this.getContainerDOM();\n\n containerDOM.addEventListener('mousemove', this.onMouseMove);\n containerDOM.addEventListener('mouseup', this.onMouseUp);\n containerDOM.addEventListener('mouseleave', this.onMouseUp);\n\n // 移动端事件\n containerDOM.addEventListener('touchmove', this.onMouseMove);\n containerDOM.addEventListener('touchend', this.onMouseUp);\n containerDOM.addEventListener('touchcancel', this.onMouseUp);\n };\n\n private onMouseMove = (event: MouseEvent) => {\n const { width } = this.cfg as SliderCfg;\n const originValue = [this.get('start'), this.get('end')];\n // 滑动过程中,计算偏移,更新滑块,然后 emit 数据出去\n event.stopPropagation();\n event.preventDefault();\n\n const x = get(event, 'touches.0.pageX', event.pageX);\n const y = get(event, 'touches.0.pageY', event.pageY);\n\n // 横向的 slider 只处理 x\n const offsetX = x - this.prevX;\n\n const offsetXRange = this.adjustOffsetRange(offsetX / width);\n\n // 更新 start end range 范围\n this.updateStartEnd(offsetXRange);\n // 更新 ui\n this.updateUI(\n this.getElementByLocalId('foreground'),\n this.getElementByLocalId('minText'),\n this.getElementByLocalId('maxText')\n );\n\n this.prevX = x;\n this.prevY = y;\n\n this.draw();\n\n // 因为存储的 start、end 可能不一定是按大小存储的,所以排序一下,对外是 end >= start\n this.emit(SLIDER_CHANGE, [this.get('start'), this.get('end')].sort());\n this.delegateEmit('valuechanged', {\n originValue,\n value: [this.get('start'), this.get('end')],\n });\n };\n\n private onMouseUp = () => {\n // 结束之后,取消绑定的事件\n if (this.currentTarget) {\n this.currentTarget = undefined;\n }\n\n const containerDOM = this.getContainerDOM();\n if (containerDOM) {\n containerDOM.removeEventListener('mousemove', this.onMouseMove);\n containerDOM.removeEventListener('mouseup', this.onMouseUp);\n // 防止滑动到 canvas 外部之后,状态丢失\n containerDOM.removeEventListener('mouseleave', this.onMouseUp);\n\n // 移动端事件\n containerDOM.removeEventListener('touchmove', this.onMouseMove);\n containerDOM.removeEventListener('touchend', this.onMouseUp);\n containerDOM.removeEventListener('touchcancel', this.onMouseUp);\n }\n };\n\n /**\n * 调整 offsetRange,因为一些范围的限制\n * @param offsetRange\n */\n private adjustOffsetRange(offsetRange: number): number {\n const { start, end } = this.cfg as SliderCfg;\n // 针对不同的滑动组件,处理的方式不同\n switch (this.currentTarget) {\n case 'minHandler': {\n const min = 0 - start;\n const max = 1 - start;\n\n return Math.min(max, Math.max(min, offsetRange));\n }\n case 'maxHandler': {\n const min = 0 - end;\n const max = 1 - end;\n\n return Math.min(max, Math.max(min, offsetRange));\n }\n case 'foreground': {\n const min = 0 - start;\n const max = 1 - end;\n\n return Math.min(max, Math.max(min, offsetRange));\n }\n }\n }\n\n private updateStartEnd(offsetRange: number) {\n let { start, end } = this.cfg as SliderCfg;\n // 操作不同的组件,反馈不一样\n switch (this.currentTarget) {\n case 'minHandler':\n start += offsetRange;\n break;\n case 'maxHandler':\n end += offsetRange;\n break;\n case 'foreground':\n start += offsetRange;\n end += offsetRange;\n break;\n }\n this.set('start', start);\n this.set('end', end);\n }\n\n /**\n * 调整 text 的位置,自动躲避\n * 根据位置,调整返回新的位置\n * @param range\n */\n private _dodgeText(range: [number, number], minTextShape, maxTextShape): [object, object] {\n const { handlerStyle, width } = this.cfg as SliderCfg;\n const PADDING = 2;\n const handlerWidth = get(handlerStyle, 'width', DEFAULT_HANDLER_WIDTH);\n\n let [min, max] = range;\n let sorted = false;\n\n // 如果交换了位置,则对应的 min max 也交互\n if (min > max) {\n [min, max] = [max, min];\n [minTextShape, maxTextShape] = [maxTextShape, minTextShape];\n sorted = true;\n }\n\n // 避让规则,优先显示在两侧,只有显示不下的时候,才显示在中间\n const minBBox = minTextShape.getBBox();\n const maxBBox = maxTextShape.getBBox();\n\n const minAttrs =\n minBBox.width > min - PADDING\n ? { x: min + handlerWidth / 2 + PADDING, textAlign: 'left' }\n : { x: min - handlerWidth / 2 - PADDING, textAlign: 'right' };\n\n const maxAttrs =\n maxBBox.width > width - max - PADDING\n ? { x: max - handlerWidth / 2 - PADDING, textAlign: 'right' }\n : { x: max + handlerWidth / 2 + PADDING, textAlign: 'left' };\n\n return !sorted ? [minAttrs, maxAttrs] : [maxAttrs, minAttrs];\n }\n\n public draw() {\n const container = this.get('container');\n const canvas = container && container.get('canvas');\n if (canvas) {\n canvas.draw();\n }\n }\n\n private getContainerDOM() {\n const container = this.get('container');\n const canvas = container && container.get('canvas');\n\n return canvas && canvas.get('container');\n }\n}\n\nexport default Slider;\n","export default function addEventListener(target: HTMLElement, eventType: string, callback: any) {\n if (target) {\n if (typeof target.addEventListener === 'function') {\n target.addEventListener(eventType, callback, false);\n return {\n remove() {\n target.removeEventListener(eventType, callback, false);\n },\n };\n // @ts-ignore\n } if (typeof target.attachEvent === 'function') {\n // @ts-ignore\n target.attachEvent('on' + eventType, callback);\n return {\n remove() {\n // @ts-ignore\n target.detachEvent('on' + eventType, callback);\n },\n };\n }\n }\n}\n","import { addEventListener } from '@antv/dom-util';\nimport { Event, IGroup } from '@antv/g-base';\nimport { clamp, deepMix, get, noop } from '@antv/util';\nimport GroupComponent from '../abstract/group-component';\nimport { ISlider } from '../interfaces';\nimport { GroupComponentCfg, Range } from '../types';\n\nexport interface ScrollbarStyle {\n trackColor: string;\n thumbColor: string;\n size: number;\n lineCap: string;\n}\n\nexport interface ScrollbarTheme {\n default?: Partial>;\n hover?: Pick, 'thumbColor'>;\n}\n\nconst DEFAULT_STYLE: ScrollbarStyle = {\n trackColor: 'rgba(0,0,0,0)',\n thumbColor: 'rgba(0,0,0,0.15)',\n size: 8,\n lineCap: 'round',\n};\n\nexport const DEFAULT_THEME: ScrollbarTheme = {\n // 默认样式\n default: DEFAULT_STYLE,\n // 鼠标 hover 的样式\n hover: {\n thumbColor: 'rgba(0,0,0,0.2)',\n },\n};\n\nexport interface ScrollbarCfg extends GroupComponentCfg {\n // scrollBar 的位置\n x: number;\n y: number;\n // 滚动条的布局,横向 | 纵向, 非必传,默认为 false(纵向)\n isHorizontal?: boolean;\n // 滑道长度,必传\n trackLen: number;\n // 滑块长度,必传\n thumbLen: number;\n // 滑块的最小长度,非必传,默认值为 20\n minThumbLen?: number;\n // 滑块相对滑道的偏移, 非必传,默认值为 0\n thumbOffset?: number;\n // 滚动条大小(横向代表高度,纵向代表宽度),优先级大于 theme\n size?: number;\n // 滚动条样式,非必传\n theme?: ScrollbarTheme;\n\n minLimit?: number;\n maxLimit?: number;\n}\n\nexport class Scrollbar extends GroupComponent implements ISlider {\n public cfg: ScrollbarCfg;\n // 通过拖拽开始的事件是 mousedown 还是 touchstart 来决定是移动端还是 pc 端\n private isMobile: boolean;\n private clearEvents = noop;\n private startPos: number;\n\n public setRange(min: number, max: number) {\n this.set('minLimit', min);\n this.set('maxLimit', max);\n const curValue = this.getValue();\n const newValue = clamp(curValue, min, max);\n if (curValue !== newValue && !this.get('isInit')) {\n this.setValue(newValue);\n }\n }\n\n public getRange(): Range {\n const min: number = this.get('minLimit') || 0;\n const max: number = this.get('maxLimit') || 1;\n\n return { min, max };\n }\n\n public setValue(value: number) {\n const range = this.getRange();\n const originalValue = this.getValue();\n this.update({\n thumbOffset: (this.get('trackLen') - this.get('thumbLen')) * clamp(value, range.min, range.max),\n });\n this.delegateEmit('valuechange', {\n originalValue,\n value: this.getValue(),\n });\n }\n\n public getValue(): number {\n return clamp(this.get('thumbOffset') / (this.get('trackLen') - this.get('thumbLen')), 0, 1);\n }\n\n public getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n return {\n ...cfg,\n name: 'scrollbar',\n isHorizontal: true,\n minThumbLen: 20,\n thumbOffset: 0,\n theme: DEFAULT_THEME,\n };\n }\n\n protected renderInner(group: IGroup) {\n this.renderTrackShape(group);\n this.renderThumbShape(group);\n }\n\n protected applyOffset() {\n this.moveElementTo(this.get('group'), {\n x: this.get('x'),\n y: this.get('y'),\n });\n }\n\n protected initEvent() {\n this.bindEvents();\n }\n\n // 创建滑道的 shape\n private renderTrackShape(group: IGroup) {\n const { trackLen, theme = { default: {} } } = this.cfg;\n const { lineCap, trackColor, size: themeSize } = deepMix({}, DEFAULT_THEME, theme).default;\n const size = get(this.cfg, 'size', themeSize);\n\n const attrs = this.get('isHorizontal')\n ? {\n x1: 0 + size / 2,\n y1: size / 2,\n x2: trackLen - size / 2,\n y2: size / 2,\n lineWidth: size,\n stroke: trackColor,\n lineCap,\n }\n : {\n x1: size / 2,\n y1: 0 + size / 2,\n x2: size / 2,\n y2: trackLen - size / 2,\n lineWidth: size,\n stroke: trackColor,\n lineCap,\n };\n return this.addShape(group, {\n id: this.getElementId('track'),\n name: 'track',\n type: 'line',\n attrs,\n });\n }\n\n // 创建滑块的 shape\n private renderThumbShape(group: IGroup) {\n const { thumbOffset, thumbLen, theme } = this.cfg;\n const { size: themeSize, lineCap, thumbColor } = deepMix({}, DEFAULT_THEME, theme).default;\n const size = get(this.cfg, 'size', themeSize);\n\n const attrs = this.get('isHorizontal')\n ? {\n x1: thumbOffset + size / 2,\n y1: size / 2,\n x2: thumbOffset + thumbLen - size / 2,\n y2: size / 2,\n lineWidth: size,\n stroke: thumbColor,\n lineCap,\n cursor: 'default',\n }\n : {\n x1: size / 2,\n y1: thumbOffset + size / 2,\n x2: size / 2,\n y2: thumbOffset + thumbLen - size / 2,\n lineWidth: size,\n stroke: thumbColor,\n lineCap,\n cursor: 'default',\n };\n return this.addShape(group, {\n id: this.getElementId('thumb'),\n name: 'thumb',\n type: 'line',\n attrs,\n });\n }\n\n private bindEvents() {\n const group: IGroup = this.get('group');\n group.on('mousedown', this.onStartEvent(false));\n group.on('mouseup', this.onMouseUp);\n\n group.on('touchstart', this.onStartEvent(true));\n group.on('touchend', this.onMouseUp);\n\n const trackShape = group.findById(this.getElementId('track'));\n trackShape.on('click', this.onTrackClick);\n const thumbShape = group.findById(this.getElementId('thumb'));\n thumbShape.on('mouseover', this.onThumbMouseOver);\n thumbShape.on('mouseout', this.onThumbMouseOut);\n }\n\n private onStartEvent = (isMobile: boolean) => (e: Event) => {\n this.isMobile = isMobile;\n e.originalEvent.preventDefault();\n const clientX = isMobile ? get(e.originalEvent, 'touches.0.clientX') : e.clientX;\n const clientY = isMobile ? get(e.originalEvent, 'touches.0.clientY') : e.clientY;\n\n // 将开始的点记录下来\n this.startPos = this.cfg.isHorizontal ? clientX : clientY;\n\n this.bindLaterEvent();\n };\n\n private bindLaterEvent = () => {\n const containerDOM = this.getContainerDOM();\n let events = [];\n\n if (this.isMobile) {\n events = [\n addEventListener(containerDOM, 'touchmove', this.onMouseMove),\n addEventListener(containerDOM, 'touchend', this.onMouseUp),\n addEventListener(containerDOM, 'touchcancel', this.onMouseUp),\n ];\n } else {\n events = [\n addEventListener(containerDOM, 'mousemove', this.onMouseMove),\n addEventListener(containerDOM, 'mouseup', this.onMouseUp),\n // 为了保证划出 canvas containerDom 时还没触发 mouseup\n addEventListener(containerDOM, 'mouseleave', this.onMouseUp),\n ];\n }\n this.clearEvents = () => {\n events.forEach((e) => {\n e.remove();\n });\n };\n };\n\n // 拖拽滑块的事件回调\n // 这里是 dom 原生事件,绑定在 dom 元素上的\n private onMouseMove = (e: MouseEvent) => {\n const { isHorizontal, thumbOffset } = this.cfg;\n e.preventDefault();\n const clientX = this.isMobile ? get(e, 'touches.0.clientX') : e.clientX;\n const clientY = this.isMobile ? get(e, 'touches.0.clientY') : e.clientY;\n // 鼠标松开的位置\n const endPos = isHorizontal ? clientX : clientY;\n // 滑块需要移动的距离, 由于这里是对滑块监听,所以移动的距离就是 diffDis, 如果监听对象是 container dom,则需要算比例\n const diff = endPos - this.startPos;\n // 更新 _startPos\n this.startPos = endPos;\n\n this.updateThumbOffset(thumbOffset + diff);\n };\n\n private onMouseUp = (e: Event) => {\n e.preventDefault();\n this.clearEvents();\n };\n\n // 点击滑道的事件回调,移动滑块位置\n private onTrackClick = (e: Event) => {\n const { isHorizontal, x, y, thumbLen } = this.cfg;\n const containerDOM = this.getContainerDOM();\n const rect = containerDOM.getBoundingClientRect();\n const { clientX, clientY } = e;\n const offset = isHorizontal ? clientX - rect.left - x - thumbLen / 2 : clientY - rect.top - y - thumbLen / 2;\n\n const newOffset = this.validateRange(offset);\n this.updateThumbOffset(newOffset);\n };\n\n private onThumbMouseOver = () => {\n const { thumbColor } = this.cfg.theme.hover;\n this.getElementByLocalId('thumb').attr('stroke', thumbColor);\n this.draw();\n };\n\n private onThumbMouseOut = () => {\n const { thumbColor } = this.cfg.theme.default;\n this.getElementByLocalId('thumb').attr('stroke', thumbColor);\n this.draw();\n };\n\n private getContainerDOM() {\n const container = this.get('container');\n const canvas = container && container.get('canvas');\n\n return canvas && canvas.get('container');\n }\n\n private validateRange(offset: number) {\n const { thumbLen, trackLen } = this.cfg;\n let newOffset = offset;\n if (offset + thumbLen > trackLen) {\n newOffset = trackLen - thumbLen;\n } else if (offset + thumbLen < thumbLen) {\n newOffset = 0;\n }\n return newOffset;\n }\n\n private draw() {\n const container = this.get('container');\n const canvas = container && container.get('canvas');\n\n if (canvas) {\n canvas.draw();\n }\n }\n\n private updateThumbOffset(offset: number) {\n const { thumbOffset, isHorizontal, thumbLen, size } = this.cfg;\n const newOffset = this.validateRange(offset);\n if (newOffset === thumbOffset) {\n // 如果更新后的 offset 与原值相同,则不改变\n return;\n }\n const thumbShape = this.getElementByLocalId('thumb');\n\n if (isHorizontal) {\n thumbShape.attr({\n x1: newOffset + size / 2,\n x2: newOffset + thumbLen - size / 2,\n });\n } else {\n thumbShape.attr({\n y1: newOffset + size / 2,\n y2: newOffset + thumbLen - size / 2,\n });\n }\n this.emitOffsetChange(newOffset);\n }\n\n private emitOffsetChange(offset: number) {\n const { thumbOffset: originalValue, trackLen, thumbLen } = this.cfg;\n this.cfg.thumbOffset = offset;\n // 发送事件\n this.emit('scrollchange', {\n thumbOffset: offset,\n ratio: clamp(offset / (trackLen - thumbLen), 0, 1),\n });\n this.delegateEmit('valuechange', {\n originalValue,\n value: offset,\n });\n }\n}\n","/* 依赖的模块,在这里统一引入,方便打包优化 */\n\n// G\nexport {\n ICanvas,\n IElement,\n IGroup,\n IShape,\n PathCommand,\n BBox,\n Point,\n ShapeAttrs,\n Event,\n AbstractGroup,\n AbstractShape,\n} from '@antv/g-base';\n// 需要有 G-base 提供 g engine 类型定义\nexport type IG = any;\n\n// adjust\nexport { registerAdjust, getAdjust, Adjust } from '@antv/adjust';\n\n// attr\nexport { getAttribute, Attribute } from '@antv/attr';\nexport { Color } from '@antv/attr';\n\n// coordinate\nexport { getCoordinate, registerCoordinate, Coordinate, CoordinateCfg } from '@antv/coord';\n\n// scale\nexport { getScale, registerScale, Scale, ScaleConfig, Tick } from '@antv/scale';\n\n// component\nimport {\n Annotation,\n Axis,\n Component,\n Crosshair,\n Grid,\n GroupComponent,\n HtmlComponent,\n Legend,\n Slider,\n Tooltip,\n Scrollbar,\n} from '@antv/component';\n\nexport {\n CategoryLegendCfg,\n CircleAxisCfg,\n LineAxisCfg,\n GroupComponentCfg,\n ListItem,\n AxisLineCfg,\n AxisTickLineCfg,\n AxisSubTickLineCfg,\n AxisTitleCfg,\n AxisLabelCfg,\n GridLineCfg,\n LegendMarkerCfg,\n LegendTitleCfg,\n LegendBackgroundCfg,\n LegendItemNameCfg,\n LegendItemValueCfg,\n LegendPageNavigatorCfg,\n ContinueLegendCfg,\n ContinueLegendTrackCfg,\n ContinueLegendRailCfg,\n ContinueLegendLabelCfg,\n ContinueLegendHandlerCfg,\n CrosshairLineCfg,\n CrosshairTextCfg,\n CrosshairTextBackgroundCfg,\n SliderCfg,\n TrendCfg,\n EnhancedTextCfg,\n LineAnnotationTextCfg,\n IComponent,\n IList,\n} from '@antv/component';\n\nexport { HtmlComponent, GroupComponent, Component, Crosshair };\nexport { Annotation };\n// axis\nconst { Line: LineAxis, Circle: CircleAxis } = Axis;\nexport { LineAxis, CircleAxis };\n// grid\nconst { Line: LineGrid, Circle: CircleGrid } = Grid;\nexport { LineGrid, CircleGrid };\n// legend\nconst { Category: CategoryLegend, Continuous: ContinuousLegend } = Legend;\nexport { CategoryLegend, ContinuousLegend };\n// Tooltip\nconst { Html: HtmlTooltip } = Tooltip;\nexport { HtmlTooltip };\n// Slider\nexport { Slider };\n// Scrollbar\nexport { Scrollbar };\n","import { BBox } from '@antv/g-svg';\nimport { each, isEmpty, isNumber, isNumberEqual, max, min } from '@antv/util';\nimport { Coordinate, IShape, Point } from '../dependents';\nimport { ShapeInfo } from '../interface';\n\n// 获取图形的包围盒\nfunction getPointsBox(points) {\n if (isEmpty(points)) {\n return null;\n }\n\n let minX = points[0].x;\n let maxX = points[0].x;\n let minY = points[0].y;\n let maxY = points[0].y;\n each(points, (point) => {\n minX = minX > point.x ? point.x : minX;\n maxX = maxX < point.x ? point.x : maxX;\n minY = minY > point.y ? point.y : minY;\n maxY = maxY < point.y ? point.y : maxY;\n });\n\n return {\n minX,\n maxX,\n minY,\n maxY,\n centerX: (minX + maxX) / 2,\n centerY: (minY + maxY) / 2,\n };\n}\n\nfunction uniqueValues(array: T[]) {\n return Array.from(new Set(array)).length === 1;\n}\n\nfunction mid(array: number[]) {\n return (min(array) + max(array)) / 2;\n}\n\n/**\n * @ignore\n * 根据弧度计算极坐标系下的坐标点\n * @param centerX\n * @param centerY\n * @param radius\n * @param angleInRadian\n * @returns\n */\nexport function polarToCartesian(centerX: number, centerY: number, radius: number, angleInRadian: number) {\n return {\n x: centerX + radius * Math.cos(angleInRadian),\n y: centerY + radius * Math.sin(angleInRadian),\n };\n}\n\n/**\n * @ignore\n * 根据起始角度计算绘制扇形的 path\n * @param centerX\n * @param centerY\n * @param radius\n * @param startAngleInRadian\n * @param endAngleInRadian\n * @returns\n */\nexport function getSectorPath(\n centerX: number,\n centerY: number,\n radius: number,\n startAngleInRadian: number,\n endAngleInRadian: number,\n innerRadius: number = 0\n) {\n const start = polarToCartesian(centerX, centerY, radius, startAngleInRadian);\n const end = polarToCartesian(centerX, centerY, radius, endAngleInRadian);\n\n const innerStart = polarToCartesian(centerX, centerY, innerRadius, startAngleInRadian);\n const innerEnd = polarToCartesian(centerX, centerY, innerRadius, endAngleInRadian);\n\n if (endAngleInRadian - startAngleInRadian === Math.PI * 2) {\n // 整个圆是分割成两个圆\n const middlePoint = polarToCartesian(centerX, centerY, radius, startAngleInRadian + Math.PI);\n const innerMiddlePoint = polarToCartesian(centerX, centerY, innerRadius, startAngleInRadian + Math.PI);\n const circlePathCommands = [\n ['M', start.x, start.y],\n ['A', radius, radius, 0, 1, 1, middlePoint.x, middlePoint.y],\n ['A', radius, radius, 0, 1, 1, end.x, end.y],\n ['M', innerStart.x, innerStart.y],\n ];\n if (innerRadius) {\n circlePathCommands.push(['A', innerRadius, innerRadius, 0, 1, 0, innerMiddlePoint.x, innerMiddlePoint.y]);\n circlePathCommands.push(['A', innerRadius, innerRadius, 0, 1, 0, innerEnd.x, innerEnd.y]);\n }\n\n circlePathCommands.push(['M', start.x, start.y]);\n circlePathCommands.push(['Z']);\n\n return circlePathCommands;\n }\n\n const arcSweep = endAngleInRadian - startAngleInRadian <= Math.PI ? 0 : 1;\n const sectorPathCommands = [\n ['M', start.x, start.y],\n ['A', radius, radius, 0, arcSweep, 1, end.x, end.y],\n ['L', innerEnd.x, innerEnd.y],\n ];\n if (innerRadius) {\n sectorPathCommands.push(['A', innerRadius, innerRadius, 0, arcSweep, 0, innerStart.x, innerStart.y]);\n }\n sectorPathCommands.push(['L', start.x, start.y]);\n sectorPathCommands.push(['Z']);\n\n return sectorPathCommands;\n}\n\n/**\n * @ignore\n * Gets arc path\n * @param centerX\n * @param centerY\n * @param radius\n * @param startAngleInRadian\n * @param endAngleInRadian\n * @returns\n */\nexport function getArcPath(\n centerX: number,\n centerY: number,\n radius: number,\n startAngleInRadian: number,\n endAngleInRadian: number\n) {\n const start = polarToCartesian(centerX, centerY, radius, startAngleInRadian);\n const end = polarToCartesian(centerX, centerY, radius, endAngleInRadian);\n\n if (isNumberEqual(endAngleInRadian - startAngleInRadian, Math.PI * 2)) {\n const middlePoint = polarToCartesian(centerX, centerY, radius, startAngleInRadian + Math.PI);\n return [\n ['M', start.x, start.y],\n ['A', radius, radius, 0, 1, 1, middlePoint.x, middlePoint.y],\n ['A', radius, radius, 0, 1, 1, start.x, start.y],\n ['A', radius, radius, 0, 1, 0, middlePoint.x, middlePoint.y],\n ['A', radius, radius, 0, 1, 0, start.x, start.y],\n ['Z'],\n ];\n }\n const arcSweep = endAngleInRadian - startAngleInRadian <= Math.PI ? 0 : 1;\n return [\n ['M', start.x, start.y],\n ['A', radius, radius, 0, arcSweep, 1, end.x, end.y],\n ];\n}\n\n/**\n * @ignore\n * 从数据模型中的 points 换算角度\n * @param shapeModel\n * @param coordinate\n * @returns\n */\nexport function getAngle(shapeModel: ShapeInfo, coordinate: Coordinate) {\n const points = shapeModel.points;\n const box = getPointsBox(points);\n let endAngle;\n let startAngle;\n const { startAngle: coordStartAngle, endAngle: coordEndAngle } = coordinate;\n const diffAngle = coordEndAngle - coordStartAngle;\n\n if (coordinate.isTransposed) {\n endAngle = box.maxY * diffAngle;\n startAngle = box.minY * diffAngle;\n } else {\n endAngle = box.maxX * diffAngle;\n startAngle = box.minX * diffAngle;\n }\n endAngle += coordStartAngle;\n startAngle += coordStartAngle;\n return {\n startAngle,\n endAngle,\n };\n}\n\n/**\n * @ignore\n * 计算多边形重心: https://en.wikipedia.org/wiki/Centroid#Of_a_polygon\n */\nexport function getPolygonCentroid(xs: number | number[], ys: number | number[]) {\n if (isNumber(xs) && isNumber(ys)) {\n // 普通色块图,xs 和 ys 是数值\n return [xs, ys];\n }\n\n xs = xs as number[];\n ys = ys as number[];\n // 当这个 polygon 的点在一条线上的时候\n // 也就是说 xs 里面的值都相同,比如:[1, 1, 1, 1]\n // 或者说 ys 里面的值都相同,比如:[0, 0, 0, 0]\n // 下面计算得到的 k = 0\n // 导致返回的值是 [NaN, NaN]\n // 所以这里做相应的处理\n if (uniqueValues(xs) || uniqueValues(ys)) return [mid(xs), mid(ys)];\n\n let i = -1;\n let x = 0;\n let y = 0;\n let former;\n let current = xs.length - 1;\n let diff;\n let k = 0;\n while (++i < xs.length) {\n former = current;\n current = i;\n k += diff = xs[former] * ys[current] - xs[current] * ys[former];\n x += (xs[former] + xs[current]) * diff;\n y += (ys[former] + ys[current]) * diff;\n }\n k *= 3;\n return [x / k, y / k];\n}\n\n/**\n * @ignore\n * 获取需要替换的属性,如果原先图形元素存在,而新图形不存在,则设置 undefined\n */\nexport function getReplaceAttrs(sourceShape: IShape, targetShape: IShape) {\n const originAttrs = sourceShape.attr();\n const newAttrs = targetShape.attr();\n each(originAttrs, (v, k) => {\n if (newAttrs[k] === undefined) {\n newAttrs[k] = undefined;\n }\n });\n return newAttrs;\n}\n","import { isArray, isString } from '@antv/util';\n\n/**\n * @ignore\n * Determines whether between is\n * @param value\n * @param start\n * @param end\n * @returns true if between\n */\nexport function isBetween(value: number, start: number, end: number): boolean {\n const min = Math.min(start, end);\n const max = Math.max(start, end);\n\n return value >= min && value <= max;\n}\n\n/**\n * @ignore\n * pads the current string/array with a given value (repeated, if needed) so that the resulting reaches a given length.\n * The padding is applied from the end of the current value.\n *\n * @param source\n * @param targetLength\n * @param padValue\n * @returns\n */\nexport function padEnd(source: string | any[], targetLength: number, padValue: any) {\n if (isString(source)) {\n return source.padEnd(targetLength, padValue);\n } else if (isArray(source)) {\n const sourceLength = source.length;\n if (sourceLength < targetLength) {\n const diff = targetLength - sourceLength;\n for (let i = 0; i < diff; i++) {\n source.push(padValue);\n }\n }\n }\n\n return source;\n}\n\n/**\n * @ignore\n * omit keys of an object.\n * @param obj\n * @param keys\n */\nexport function omit(obj: T, keys: string[]): T {\n if (typeof obj === 'object') {\n keys.forEach((key: string) => {\n delete obj[key];\n });\n }\n\n return obj;\n}\n\n/**\n * @ignore\n * @param sourceArray\n * @param targetArray\n * @param map\n */\nexport function uniq(sourceArray: any[], targetArray: any[] = [], map: Map = new Map()) {\n for (const source of sourceArray) {\n if (!map.has(source)) {\n targetArray.push(source);\n map.set(source, true);\n }\n }\n return targetArray;\n}\n","import { each } from '@antv/util';\nimport { DIRECTION } from '../constant';\nimport { Padding, Point, Region } from '../interface';\nimport { BBox as BBoxObject } from '../dependents';\n\n/**\n * 用于包围盒计算。\n */\nexport class BBox {\n /** x 轴坐标系 */\n public x: number;\n /** y 轴坐标系 */\n public y: number;\n /** 包围盒高度 */\n public height: number;\n /** 包围盒宽度 */\n public width: number;\n\n public static fromRange(minX: number, minY: number, maxX: number, maxY: number) {\n return new BBox(minX, minY, maxX - minX, maxY - minY);\n }\n\n public static fromObject(bbox: BBoxObject) {\n return new BBox(bbox.minX, bbox.minY, bbox.width, bbox.height);\n }\n\n constructor(x: number = 0, y: number = 0, width: number = 0, height: number = 0) {\n this.x = x;\n this.y = y;\n this.height = height;\n this.width = width;\n }\n\n public get minX(): number {\n return this.x;\n }\n\n public get maxX(): number {\n return this.x + this.width;\n }\n\n public get minY(): number {\n return this.y;\n }\n\n public get maxY(): number {\n return this.y + this.height;\n }\n\n public get tl(): Point {\n return { x: this.x, y: this.y };\n }\n\n public get tr(): Point {\n return { x: this.maxX, y: this.y };\n }\n\n public get bl(): Point {\n return { x: this.x, y: this.maxY };\n }\n\n public get br(): Point {\n return { x: this.maxX, y: this.maxY };\n }\n\n public get top(): Point {\n return {\n x: this.x + this.width / 2,\n y: this.minY,\n };\n }\n\n public get right(): Point {\n return {\n x: this.maxX,\n y: this.y + this.height / 2,\n };\n }\n public get bottom(): Point {\n return {\n x: this.x + this.width / 2,\n y: this.maxY,\n };\n }\n public get left(): Point {\n return {\n x: this.minX,\n y: this.y + this.height / 2,\n };\n }\n // end 计算属性\n\n /**\n * 包围盒是否相等\n * @param {BBox} bbox 包围盒\n * @returns 包围盒是否相等\n */\n public isEqual(bbox: BBox): boolean {\n return this.x === bbox.x && this.y === bbox.y && this.width === bbox.width && this.height === bbox.height;\n }\n\n /**\n * 是否包含了另一个包围盒\n * @param child\n */\n public contains(child: BBox): boolean {\n return child.minX >= this.minX && child.maxX <= this.maxX && child.minY >= this.minY && child.maxY <= this.maxY;\n }\n\n /**\n * 克隆包围盒\n * @returns 包围盒\n */\n public clone(): BBox {\n return new BBox(this.x, this.y, this.width, this.height);\n }\n\n /**\n * 取并集\n * @param subBBox\n */\n public add(...subBBox: BBox[]): BBox {\n const bbox = this.clone();\n each(subBBox, (b: BBox) => {\n bbox.x = Math.min(b.x, bbox.x);\n bbox.y = Math.min(b.y, bbox.y);\n bbox.width = Math.max(b.maxX, bbox.maxX) - bbox.x;\n bbox.height = Math.max(b.maxY, bbox.maxY) - bbox.y;\n });\n\n return bbox;\n }\n\n /**\n * 取交集\n * @param subBBox\n */\n public merge(...subBBox: BBox[]): BBox {\n const bbox = this.clone();\n each(subBBox, (b: BBox) => {\n bbox.x = Math.max(b.x, bbox.x);\n bbox.y = Math.max(b.y, bbox.y);\n bbox.width = Math.min(b.maxX, bbox.maxX) - bbox.x;\n bbox.height = Math.min(b.maxY, bbox.maxY) - bbox.y;\n });\n\n return bbox;\n }\n\n /**\n * bbox 剪裁\n * @param subBBox\n * @param direction\n */\n public cut(subBBox: BBox, direction: DIRECTION): BBox {\n const width = subBBox.width;\n const height = subBBox.height;\n\n switch (direction) {\n case DIRECTION.TOP:\n case DIRECTION.TOP_LEFT:\n case DIRECTION.TOP_RIGHT:\n return BBox.fromRange(this.minX, this.minY + height, this.maxX, this.maxY);\n\n case DIRECTION.RIGHT:\n case DIRECTION.RIGHT_TOP:\n case DIRECTION.RIGHT_BOTTOM:\n return BBox.fromRange(this.minX, this.minY, this.maxX - width, this.maxY);\n\n case DIRECTION.BOTTOM:\n case DIRECTION.BOTTOM_LEFT:\n case DIRECTION.BOTTOM_RIGHT:\n return BBox.fromRange(this.minX, this.minY, this.maxX, this.maxY - height);\n\n case DIRECTION.LEFT:\n case DIRECTION.LEFT_TOP:\n case DIRECTION.LEFT_BOTTOM:\n return BBox.fromRange(this.minX + width, this.minY, this.maxX, this.maxY);\n default:\n // 其他情况不裁剪,原样返回\n return this;\n }\n }\n\n /**\n * 收缩形成新的\n * @param gap\n */\n public shrink(gap: Padding): BBox {\n const [top, right, bottom, left] = gap;\n\n return new BBox(this.x + left, this.y + top, this.width - left - right, this.height - top - bottom);\n }\n\n /**\n * 扩张形成新的\n * @param gap\n */\n public expand(gap: Padding): BBox {\n const [top, right, bottom, left] = gap;\n\n return new BBox(this.x - left, this.y - top, this.width + left + right, this.height + top + bottom);\n }\n\n /**\n * get the gap of two bbox, if not exceed, then 0\n * @param bbox\n * @returns [top, right, bottom, left]\n */\n public exceed(bbox: BBox): Padding {\n return [\n Math.max(-this.minY + bbox.minY, 0),\n Math.max(this.maxX - bbox.maxX, 0),\n Math.max(this.maxY - bbox.maxY, 0),\n Math.max(-this.minX + bbox.minX, 0),\n ];\n }\n\n /**\n * 是否碰撞\n * @param bbox\n */\n public collide(bbox: BBox): boolean {\n return this.minX < bbox.maxX && this.maxX > bbox.minX && this.minY < bbox.maxY && this.maxY > bbox.minY;\n }\n\n /**\n * 获取包围盒大小\n * @returns 包围盒大小\n */\n public size(): number {\n return this.width * this.height;\n }\n\n /**\n * 点是否在 bbox 中\n * @param p\n */\n public isPointIn(p: Point) {\n return p.x >= this.minX && p.x <= this.maxX && p.y >= this.minY && p.y <= this.maxY;\n }\n}\n\n/**\n * 从一个 bbox 的 region 获取 bbox\n * @param bbox\n * @param region\n */\nexport const getRegionBBox = (bbox: BBox, region: Region): BBox => {\n const { start, end } = region;\n\n return new BBox(\n bbox.x + bbox.width * start.x,\n bbox.y + bbox.height * start.y,\n bbox.width * Math.abs(end.x - start.x),\n bbox.height * Math.abs(end.y - start.y)\n );\n};\n\n/**\n * 将 bbox 转换成 points\n * @param bbox\n */\nexport function toPoints(bbox: Partial): any[] {\n return [\n [bbox.minX, bbox.minY],\n [bbox.maxX, bbox.minY],\n [bbox.maxX, bbox.maxY],\n [bbox.minX, bbox.maxY],\n ];\n}\n","import { Coordinate } from '../dependents';\nimport { Point } from '../interface';\nimport { getSectorPath } from './graphics';\nimport { isBetween } from './helper';\nimport { BBox } from './bbox';\n\n/**\n * @ignore\n * Gets x dimension length\n * @param coordinate\n * @returns x dimension length\n */\nexport function getXDimensionLength(coordinate): number {\n if (coordinate.isPolar && !coordinate.isTransposed) {\n // 极坐标系下 width 为弧长\n return (coordinate.endAngle - coordinate.startAngle) * coordinate.getRadius();\n }\n\n // 直角坐标系\n const start = coordinate.convert({ x: 0, y: 0 });\n const end = coordinate.convert({ x: 1, y: 0 });\n // 坐标系有可能发生 transpose 等变换,所有通过两点之间的距离进行计算\n return Math.sqrt(Math.pow(end.x - start.x, 2) + Math.pow(end.y - start.y, 2));\n}\n\n/**\n * @ignore\n * Determines whether full circle is\n * @param coordinate\n * @returns true if full circle\n */\nexport function isFullCircle(coordinate: Coordinate): boolean {\n if (coordinate.isPolar) {\n const { startAngle, endAngle } = coordinate;\n return endAngle - startAngle === Math.PI * 2;\n }\n return false;\n}\n\n/**\n * @ignore\n * 获取当前点到坐标系圆心的距离\n * @param coordinate 坐标系\n * @param point 当前点\n * @returns distance to center\n */\nexport function getDistanceToCenter(coordinate: Coordinate, point: Point): number {\n const center = coordinate.getCenter() as Point;\n return Math.sqrt((point.x - center.x) ** 2 + (point.y - center.y) ** 2);\n}\n\n/**\n * @ignore\n * 坐标点是否在坐标系中\n * @param coordinate\n * @param point\n */\nexport function isPointInCoordinate(coordinate: Coordinate, point: Point) {\n let result = false;\n\n if (coordinate) {\n if (coordinate.type === 'theta') {\n const { start, end } = coordinate;\n result = isBetween(point.x, start.x, end.x) && isBetween(point.y, start.y, end.y);\n } else {\n const invertPoint = coordinate.invert(point);\n \n result = isBetween(invertPoint.x, 0, 1) && isBetween(invertPoint.y, 0, 1);\n }\n }\n\n return result;\n}\n\n/**\n * @ignore\n * 获取点到圆心的连线与水平方向的夹角\n */\nexport function getAngleByPoint(coordinate: Coordinate, point: Point): number {\n const center = coordinate.getCenter();\n return Math.atan2(point.y - center.y, point.x - center.x);\n}\n\n/**\n * @ignore\n * 获取同坐标系范围相同的剪切区域\n * @param coordinate\n * @returns\n */\nexport function getCoordinateClipCfg(coordinate: Coordinate, margin: number = 0) {\n const { start, end } = coordinate;\n const width = coordinate.getWidth();\n const height = coordinate.getHeight();\n\n if (coordinate.isPolar) {\n const { startAngle, endAngle } = coordinate;\n const center = coordinate.getCenter();\n const radius = coordinate.getRadius();\n\n return {\n type: 'path',\n startState: {\n path: getSectorPath(center.x, center.y, radius + margin, startAngle, startAngle),\n },\n endState: (ratio) => {\n const diff = (endAngle - startAngle) * ratio + startAngle;\n const path = getSectorPath(center.x, center.y, radius + margin, startAngle, diff);\n return {\n path,\n };\n },\n attrs: {\n path: getSectorPath(center.x, center.y, radius + margin, startAngle, endAngle),\n },\n };\n }\n\n let endState;\n if (coordinate.isTransposed) {\n endState = {\n height: height + margin * 2,\n };\n } else {\n endState = {\n width: width + margin * 2,\n };\n }\n\n return {\n type: 'rect',\n startState: {\n x: start.x - margin,\n y: end.y - margin,\n width: coordinate.isTransposed ? width + margin * 2 : 0,\n height: coordinate.isTransposed ? 0 : height + margin * 2,\n },\n endState,\n attrs: {\n x: start.x - margin,\n y: end.y - margin,\n width: width + margin * 2,\n height: height + margin * 2,\n },\n };\n}\n\n/**\n * 获取坐标系范围的 BBox\n * @param coordinate\n * @param margin\n */\nexport function getCoordinateBBox(coordinate: Coordinate, margin = 0) {\n const { start, end } = coordinate;\n const width = coordinate.getWidth();\n const height = coordinate.getHeight();\n const minX = Math.min(start.x, end.x);\n const minY = Math.min(start.y, end.y);\n\n return BBox.fromRange(minX - margin, minY - margin, minX + width + margin, minY + height + margin);\n}\n","import { firstValue, get, isEmpty, isNil, isNumber, isString, valuesOfKey } from '@antv/util';\nimport { GROUP_ATTRS } from '../constant';\nimport { getScale, Scale, Coordinate } from '../dependents';\nimport { LooseObject, ScaleOption, ViewCfg } from '../interface';\nimport { isFullCircle } from './coordinate';\n\nconst dateRegex =\n /^(?:(?!0000)[0-9]{4}([-/.]+)(?:(?:0?[1-9]|1[0-2])\\1(?:0?[1-9]|1[0-9]|2[0-8])|(?:0?[13-9]|1[0-2])\\1(?:29|30)|(?:0?[13578]|1[02])\\1(?:31))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)([-/.]+)0?2\\2(?:29))(\\s+([01]|([01][0-9]|2[0-3])):([0-9]|[0-5][0-9]):([0-9]|[0-5][0-9]))?$/;\n\n/**\n * 获取字段对应数据的类型\n * @param field 数据字段名\n * @param data 数据源\n * @returns default type 返回对应的数据类型\n */\nfunction getDefaultType(value: any): string {\n let type = 'linear';\n if (dateRegex.test(value)) {\n type = 'timeCat';\n } else if (isString(value)) {\n type = 'cat';\n }\n return type;\n}\n\n/**\n * using the scale type if user specified, otherwise infer the type\n */\nexport function inferScaleType(scale: Scale, scaleDef: ScaleOption = {}, attrType: string, geometryType: string): string {\n if (scaleDef.type) return scaleDef.type;\n // identity scale 直接返回\n // geometry 类型有: edge,heatmap,interval,line,path,point,polygon,schema,voilin等;理论上,interval 下,可以用 linear scale 作为分组字段\n if (scale.type !== 'identity' && GROUP_ATTRS.includes(attrType) && ['interval'].includes(geometryType)) {\n return 'cat';\n }\n return scale.isCategory ? 'cat' : scale.type;\n}\n\n/**\n * @ignore\n * 为指定的 `field` 字段数据创建 scale\n * @param field 字段名\n * @param [data] 数据集,可为空\n * @param [scaleDef] 列定义,可为空\n * @returns scale 返回创建的 Scale 实例\n */\nexport function createScaleByField(field: string | number, data?: LooseObject[] | [], scaleDef?: ScaleOption): Scale {\n const validData = data || [];\n\n if (isNumber(field) || (isNil(firstValue(validData, field)) && isEmpty(scaleDef))) {\n const Identity = getScale('identity');\n return new Identity({\n field: field.toString(),\n values: [field],\n });\n }\n\n const values = valuesOfKey(validData, field);\n\n // 如果已经定义过这个度量 (fix-later 单纯从数据中,推断 scale type 是不精确的)\n const type = get(scaleDef, 'type', getDefaultType(values[0]));\n const ScaleCtor = getScale(type);\n return new ScaleCtor({\n field,\n values,\n ...scaleDef,\n });\n}\n\n/**\n * @ignore\n * 同步 scale\n * @todo 是否可以通过 scale.update() 方法进行更新\n * @param scale 需要同步的 scale 实例\n * @param newScale 同步源 Scale\n */\nexport function syncScale(scale: Scale, newScale: Scale) {\n if (scale.type !== 'identity' && newScale.type !== 'identity') {\n const obj = {};\n for (const k in newScale) {\n if (Object.prototype.hasOwnProperty.call(newScale, k)) {\n obj[k] = newScale[k];\n }\n }\n\n scale.change(obj);\n }\n}\n\n/**\n * @ignore\n * get the scale name, if alias exist, return alias, or else field\n * @param scale\n * @returns the name of field\n */\nexport function getName(scale: Scale): string {\n return scale.alias || scale.field;\n}\n\n/**\n * 根据 scale values 和 coordinate 获取分类默认 range\n * @param scale 需要获取的 scale 实例\n * @param coordinate coordinate 实例\n * @param theme theme\n */\nexport function getDefaultCategoryScaleRange(\n scale: Scale,\n coordinate: Coordinate,\n theme: ViewCfg['theme']\n): Scale['range'] {\n const { values } = scale;\n const count = values.length;\n let range;\n\n if (count === 1) {\n range = [0.5, 1]; // 只有一个分类时,防止计算出现 [0.5,0.5] 的状态\n } else {\n let widthRatio = 1;\n let offset = 0;\n\n if (isFullCircle(coordinate)) {\n if (!coordinate.isTransposed) {\n range = [0, 1 - 1 / count];\n } else {\n widthRatio = get(theme, 'widthRatio.multiplePie', 1 / 1.3);\n offset = (1 / count) * widthRatio;\n range = [offset / 2, 1 - offset / 2];\n }\n } else {\n offset = 1 / count / 2; // 两边留下分类空间的一半\n range = [offset, 1 - offset]; // 坐标轴最前面和最后面留下空白防止绘制柱状图时\n }\n }\n return range;\n}\n\n/**\n * @function y轴scale的max\n * @param {yScale}\n */\nexport function getMaxScale(scale: Scale) {\n // 过滤values[]中 NaN/undefined/null 等\n const values = scale.values.filter((item) => !isNil(item) && !isNaN(item));\n\n return Math.max(...values, isNil(scale.max) ? -Infinity : scale.max);\n}\n","import { deepMix, get, isBoolean } from '@antv/util';\nimport { DIRECTION } from '../constant';\nimport { Coordinate, Scale } from '../dependents';\nimport { AxisCfg, AxisOption, Point, Region } from '../interface';\nimport { getName } from './scale';\nimport { vec2 } from '@antv/matrix-util';\n\n/**\n * @ignore\n * get axis relative region ( 0 ~ 1) by direction when coordinate is rect\n * @param direction\n * @returns axis coordinate region\n */\nexport function getLineAxisRelativeRegion(direction: DIRECTION): Region {\n let start;\n let end;\n\n switch (direction) {\n case DIRECTION.TOP:\n start = { x: 0, y: 1 };\n end = { x: 1, y: 1 };\n break;\n case DIRECTION.RIGHT:\n start = { x: 1, y: 0 };\n end = { x: 1, y: 1 };\n break;\n case DIRECTION.BOTTOM:\n start = { x: 0, y: 0 };\n end = { x: 1, y: 0 };\n break;\n case DIRECTION.LEFT:\n start = { x: 0, y: 0 };\n end = { x: 0, y: 1 };\n break;\n default:\n start = end = { x: 0, y: 0 };\n }\n\n return { start, end };\n}\n\n/**\n * @ignore\n * get axis relative region ( 0 ~ 1) by direction when coordinate is polar\n * @param coordinate\n * @returns axis coordinate region\n */\nexport function getCircleAxisRelativeRegion(coordinate: Coordinate) {\n let start;\n let end;\n if (coordinate.isTransposed) {\n start = {\n x: 0,\n y: 0,\n };\n end = {\n x: 1,\n y: 0,\n };\n } else {\n start = {\n x: 0,\n y: 0,\n };\n end = {\n x: 0,\n y: 1,\n };\n }\n\n return { start, end };\n}\n\n/**\n * @ignore\n * get the axis region from coordinate\n * @param coordinate\n * @param direction\n * @returns the axis region (start point, end point)\n */\nexport function getAxisRegion(coordinate: Coordinate, direction: DIRECTION): Region {\n let region = { start: { x: 0, y: 0 }, end: { x: 0, y: 0 } };\n if (coordinate.isRect) {\n region = getLineAxisRelativeRegion(direction);\n } else if (coordinate.isPolar) {\n region = getCircleAxisRelativeRegion(coordinate);\n }\n\n const { start, end } = region;\n return {\n start: coordinate.convert(start),\n end: coordinate.convert(end),\n };\n}\n\n/**\n * @ignore\n * get axis factor\n * @param coordinate\n * @param direction\n * @returns factor\n */\nexport function getAxisFactor(coordinate: Coordinate, direction: DIRECTION): number {\n // rect coordinate, by direction\n if (coordinate.isRect) {\n return coordinate.isTransposed\n ? [DIRECTION.RIGHT, DIRECTION.BOTTOM].includes(direction)\n ? 1\n : -1\n : [DIRECTION.BOTTOM, DIRECTION.RIGHT].includes(direction)\n ? -1\n : 1;\n }\n\n // polar y axis, by angle\n if (coordinate.isPolar) {\n const startAngle = coordinate.x.start;\n return startAngle < 0 ? -1 : 1;\n }\n\n return 1;\n}\n\n/**\n * @ignore\n * whether the axis isVertical\n * @param region\n * @returns isVertical\n */\nexport function isVertical(region: Region): boolean {\n const { start, end } = region;\n\n return start.x === end.x;\n}\n\n/**\n * @ignore\n * get factor by region (real position)\n * @param region\n * @param center\n * @returns factor\n */\nexport function getAxisFactorByRegion(region: Region, center: Point): number {\n const { start, end } = region;\n\n const isAxisVertical = isVertical(region);\n\n // 垂直\n if (isAxisVertical) {\n // 左方,从下到上、右方,从上到下\n if ((start.y - end.y) * (center.x - start.x) > 0) {\n return 1;\n } else {\n return -1;\n }\n } else {\n // 下方,从左到右、上方,从右到做\n if ((end.x - start.x) * (start.y - center.y) > 0) {\n return -1;\n } else {\n return 1;\n }\n }\n}\n\n/**\n * @ignore\n * get the axis cfg from theme, will mix the common cfg of legend theme\n *\n * @param theme view theme object\n * @param direction axis direction\n * @returns axis theme cfg\n */\nexport function getAxisThemeCfg(theme: object, direction: string): object {\n const axisTheme = get(theme, ['components', 'axis'], {});\n return deepMix({}, get(axisTheme, ['common'], {}), deepMix({}, get(axisTheme, [direction], {})));\n}\n\n/**\n * get the options of axis title,mix the cfg from theme, avoid common themeCfg not work\n * @param theme\n * @param direction\n * @param axisOptions\n * @returns axis title options\n */\nexport function getAxisTitleOptions(theme: object, direction: string, axisOptions?: object): object {\n const axisTheme = get(theme, ['components', 'axis'], {});\n return deepMix(\n {},\n get(axisTheme, ['common', 'title'], {}),\n deepMix({}, get(axisTheme, [direction, 'title'], {})),\n axisOptions\n );\n}\n\n/**\n * @ignore\n * get circle axis center and radius\n * @param coordinate\n */\nexport function getCircleAxisCenterRadius(coordinate: Coordinate) {\n // @ts-ignore\n const { x, y, circleCenter: center } = coordinate;\n const isReflectY = y.start > y.end;\n const start = coordinate.isTransposed\n ? coordinate.convert({\n x: isReflectY ? 0 : 1,\n y: 0,\n })\n : coordinate.convert({\n x: 0,\n y: isReflectY ? 0 : 1,\n });\n\n const startVector: [number, number] = [start.x - center.x, start.y - center.y];\n const normalVector: [number, number] = [1, 0];\n const startAngle =\n start.y > center.y ? vec2.angle(startVector, normalVector) : vec2.angle(startVector, normalVector) * -1;\n const endAngle = startAngle + (x.end - x.start);\n const radius = Math.sqrt((start.x - center.x) ** 2 + (start.y - center.y) ** 2);\n\n return {\n center,\n radius,\n startAngle,\n endAngle,\n };\n}\n\n/**\n * @ignore\n * 从配置中获取单个字段的 axis 配置\n * @param axes\n * @param field\n * @returns the axis option of field\n */\nexport function getAxisOption(axes: Record | boolean, field: string) {\n if (isBoolean(axes)) {\n return axes === false ? false : {};\n }\n return get(axes, [field]);\n}\n\n/**\n * @ignore\n * 如果配置了 position,则使用配置\n * @param axisOption\n * @param def\n */\nexport function getAxisDirection(axisOption: AxisOption, def: DIRECTION): DIRECTION {\n return get(axisOption, 'position', def);\n}\n\n/**\n * 获取 axis 的 title 文本\n * @param scale\n * @param axisOption\n */\nexport function getAxisTitleText(scale: Scale, axisOption: AxisCfg): string {\n return get(axisOption, ['title', 'text'], getName(scale));\n}\n","import { deepMix, each, every, get, isNil, isNumber } from '@antv/util';\nimport { LAYER } from '../constant';\nimport { IGroup } from '../dependents';\nimport { AxisCfg, Condition, Datum, FacetCfg, FacetData, FacetDataFilter, Region } from '../interface';\n\nimport View from '../chart/view';\nimport { getAxisOption } from '../util/axis';\n\n/**\n * facet 基类\n * - 定义生命周期,方便自定义 facet\n * - 提供基础的生命流程方法\n *\n * 生命周期:\n *\n * 初始化 init\n * 1. 初始化容器\n * 2. 数据分面,生成分面布局信息\n *\n * 渲染阶段 render\n * 1. view 创建\n * 2. title\n * 3. axis\n *\n * 清除阶段 clear\n * 1. 清除 view\n *\n * 销毁阶段 destroy\n * 1. clear\n * 2. 清除事件\n * 3. 清除 group\n */\nexport abstract class Facet = FacetCfg, F extends FacetData = FacetData> {\n /** 分面所在的 view */\n public view: View;\n /** 分面容器 */\n public container: IGroup;\n /** 是否销毁 */\n public destroyed: boolean = false;\n\n /** 分面的配置项 */\n protected cfg: C;\n /** 分面之后的所有分面数据结构 */\n protected facets: F[] = [];\n\n constructor(view: View, cfg: C) {\n this.view = view;\n this.cfg = deepMix({}, this.getDefaultCfg(), cfg);\n }\n\n /**\n * 初始化过程\n */\n public init() {\n // 初始化容器\n if (!this.container) {\n this.container = this.createContainer();\n }\n\n // 生成分面布局信息\n const data = this.view.getData();\n this.facets = this.generateFacets(data);\n }\n\n /**\n * 渲染分面,由上层 view 调用。包括:\n * - 分面 view\n * - 轴\n * - title\n *\n * 子类可以复写,添加一些其他组件,比如滚动条等\n */\n public render() {\n this.renderViews();\n }\n\n /**\n * 更新 facet\n */\n public update() {\n // 其实不用做任何事情,因为 facet 最终生成的 View 和 Geometry 都在父 view 的更新中处理了\n }\n\n /**\n * 清空,clear 之后如果还需要使用,需要重新调用 init 初始化过程\n * 一般在数据有变更的时候调用,重新进行数据的分面逻辑\n */\n public clear() {\n this.clearFacetViews();\n }\n\n /**\n * 销毁\n */\n public destroy() {\n this.clear();\n\n if (this.container) {\n this.container.remove(true);\n this.container = undefined;\n }\n\n this.destroyed = true;\n this.view = undefined;\n this.facets = [];\n }\n\n /**\n * 根据 facet 生成 view,可以给上层自定义使用\n * @param facet\n */\n protected facetToView(facet: F): View {\n const { region, data, padding = this.cfg.padding } = facet;\n\n const view = this.view.createView({\n region,\n padding,\n });\n\n // 设置分面的数据\n view.data(data || []);\n facet.view = view;\n\n // 前置钩子\n this.beforeEachView(view, facet);\n\n const { eachView } = this.cfg;\n if (eachView) {\n eachView(view, facet);\n }\n\n // 后置钩子\n this.afterEachView(view, facet);\n\n return view;\n }\n\n // 创建容器\n private createContainer(): IGroup {\n const foregroundGroup = this.view.getLayer(LAYER.FORE);\n return foregroundGroup.addGroup();\n }\n\n /**\n * 初始化 view\n */\n private renderViews() {\n this.createFacetViews();\n }\n\n /**\n * 创建 分面 view\n */\n private createFacetViews(): View[] {\n // 使用分面数据 创建分面 view\n return this.facets.map((facet): View => {\n return this.facetToView(facet);\n });\n }\n\n /**\n * 从 view 中清除 facetView\n */\n private clearFacetViews() {\n // 从 view 中移除分面 view\n each(this.facets, (facet) => {\n if (facet.view) {\n this.view.removeView(facet.view);\n facet.view = undefined;\n }\n });\n }\n\n /**\n * 解析 spacing\n */\n private parseSpacing() {\n /**\n * @example\n *\n * // 仅使用百分比或像素值\n * // 横向间隔为 10%,纵向间隔为 10%\n * ['10%', '10%']\n * // 横向间隔为 10px,纵向间隔为 10px\n * [10, 10]\n *\n * // 同时使用百分比和像素值\n * ['10%', 10]\n * // 横向间隔为 10%,纵向间隔为 10px\n */\n const { width, height } = this.view.viewBBox;\n const { spacing } = this.cfg;\n return spacing.map((s: number, idx: number) => {\n if (isNumber(s)) return s / (idx === 0 ? width : height);\n else return parseFloat(s) / 100;\n });\n }\n\n // 其他一些提供给子类使用的方法\n\n /**\n * 获取这个字段对应的所有值,数组\n * @protected\n * @param data 数据\n * @param field 字段名\n * @return 字段对应的值\n */\n protected getFieldValues(data: Datum[], field: string): string[] {\n const rst = [];\n const cache: Record = {};\n\n // 去重、去除 Nil 值\n each(data, (d: Datum) => {\n const value = d[field];\n if (!isNil(value) && !cache[value]) {\n rst.push(value);\n cache[value] = true;\n }\n });\n\n return rst;\n }\n\n /**\n * 获得每个分面的 region,平分区域\n * @param rows row 总数\n * @param cols col 总数\n * @param xIndex x 方向 index\n * @param yIndex y 方向 index\n */\n protected getRegion(rows: number, cols: number, xIndex: number, yIndex: number): Region {\n const [xSpacing, ySpacing] = this.parseSpacing();\n // 每两个分面区域横向间隔xSPacing, 纵向间隔ySpacing\n // 每个分面区域的横纵占比\n /**\n * ratio * num + spacing * (num - 1) = 1\n * => ratio = (1 - (spacing * (num - 1))) / num\n * = (1 + spacing) / num - spacing\n *\n * num 对应 cols/rows\n * spacing 对应 xSpacing/ySpacing\n */\n const xRatio = (1 + xSpacing) / (cols === 0 ? 1 : cols) - xSpacing;\n const yRatio = (1 + ySpacing) / (rows === 0 ? 1 : rows) - ySpacing;\n\n // 得到第 index 个分面区域百分比位置\n const start = {\n x: (xRatio + xSpacing) * xIndex,\n y: (yRatio + ySpacing) * yIndex,\n };\n const end = {\n x: start.x + xRatio,\n y: start.y + yRatio,\n };\n return { start, end };\n }\n\n protected getDefaultCfg() {\n return {\n eachView: undefined,\n showTitle: true,\n spacing: [0, 0],\n padding: 10,\n fields: [],\n };\n }\n\n /**\n * 默认的 title 样式,因为有的分面是 title,有的分面配置是 columnTitle、rowTitle\n */\n protected getDefaultTitleCfg() {\n // @ts-ignore\n const fontFamily = this.view.getTheme().fontFamily;\n return {\n style: {\n fontSize: 14,\n fill: '#666',\n fontFamily,\n },\n };\n }\n\n /**\n * 处理 axis 的默认配置\n * @param view\n * @param facet\n */\n protected processAxis(view: View, facet: F) {\n const options = view.getOptions();\n\n const coordinateOption = options.coordinate;\n const geometries = view.geometries;\n\n const coordinateType = get(coordinateOption, 'type', 'rect');\n\n if (coordinateType === 'rect' && geometries.length) {\n if (isNil(options.axes)) {\n // @ts-ignore\n options.axes = {};\n }\n const axes = options.axes;\n\n const [x, y] = geometries[0].getXYFields();\n\n const xOption = getAxisOption(axes, x);\n const yOption = getAxisOption(axes, y);\n\n if (xOption !== false) {\n options.axes[x] = this.getXAxisOption(x, axes, xOption, facet);\n }\n\n if (yOption !== false) {\n options.axes[y] = this.getYAxisOption(y, axes, yOption, facet);\n }\n }\n }\n\n /**\n * 获取分面数据\n * @param conditions\n */\n protected getFacetDataFilter(conditions: Condition[]): FacetDataFilter {\n return (datum: Datum) => {\n // 过滤出全部满足条件的数据\n return every(conditions, (condition) => {\n const { field, value } = condition;\n\n if (!isNil(value) && field) {\n return datum[field] === value;\n }\n return true;\n });\n };\n }\n\n /**\n * @override 开始处理 eachView\n * @param view\n * @param facet\n */\n protected abstract beforeEachView(view: View, facet: F);\n\n /**\n * @override 处理 eachView 之后\n * @param view\n * @param facet\n */\n protected abstract afterEachView(view: View, facet: F);\n\n /**\n * @override 生成分面数据,包含布局\n * @param data\n */\n protected abstract generateFacets(data: Datum[]): F[];\n\n /**\n * 获取 x 轴的配置\n * @param x\n * @param axes\n * @param option\n * @param facet\n */\n protected abstract getXAxisOption(x: string, axes: any, option: AxisCfg, facet: F): object;\n\n /**\n * 获取 y 轴的配置\n * @param y\n * @param axes\n * @param option\n * @param facet\n */\n protected abstract getYAxisOption(y: string, axes: any, option: AxisCfg, facet: F): object;\n}\n","import { lowerCase } from '@antv/util';\nimport { FacetCtor } from '../interface';\nexport { Facet } from './facet';\n\n/**\n * 所有的 Facet 类\n */\nconst Facets: Record = {};\n\n/**\n * 根据 type 获取 facet 类\n * @param type 分面类型\n */\nexport const getFacet = (type: string): FacetCtor => {\n return Facets[lowerCase(type)];\n};\n\n/**\n * 注册一个 Facet 类\n * @param type 分面类型\n * @param ctor 分面类\n */\nexport const registerFacet = (type: string, ctor: FacetCtor) => {\n Facets[lowerCase(type)] = ctor;\n};\n","import { assign } from '@antv/util';\nimport { IAction, IInteractionContext, LooseObject } from '../../interface';\n\n/**\n * Action 的基类\n */\nabstract class Action implements IAction {\n /** Action 名字 */\n public name;\n /** 上下文对象 */\n public context: IInteractionContext;\n /** Action 配置 */\n protected cfg: T;\n /** 配置项的字段,自动负值到 this 上 */\n protected cfgFields: string[];\n\n constructor(context: IInteractionContext, cfg?: T) {\n this.context = context;\n this.cfg = cfg;\n context.addAction(this);\n }\n\n /**\n * 设置配置项传入的值\n * @param cfg\n */\n protected applyCfg(cfg) {\n assign(this, cfg);\n }\n\n /**\n * Inits action,提供给子类用于继承\n */\n public init() {\n this.applyCfg(this.cfg);\n }\n\n /**\n * Destroys action\n */\n public destroy() {\n // 移除 action\n this.context.removeAction(this);\n // 清空\n this.context = null;\n }\n}\n\nexport default Action;\n","import { ActionCallback } from '../../interface';\nimport Action from './base';\n\n/** 回调函数构建的 Action */\nexport default class CallbackAction extends Action {\n /**\n * 回调函数\n */\n public callback: ActionCallback;\n /**\n * 执行\n */\n public execute() {\n if (this.callback) {\n this.callback(this.context);\n }\n }\n /**\n * 销毁\n */\n public destroy() {\n super.destroy();\n this.callback = null;\n }\n}\n","import { ActionCallback, IInteractionContext, LooseObject } from '../../interface';\nimport Action from './base';\nimport CallbackAction from './callback';\nimport { get } from '@antv/util';\n\n/** Action 构造函数 */\ntype ActionConstructor = new (context: IInteractionContext, cfg?: LooseObject) => Action;\n\n/** @ignore */\ninterface ActionOption {\n ActionClass: ActionConstructor;\n cfg: LooseObject;\n}\n\n// Action 类的缓存\nconst ActionCache: Record = {};\n\n/**\n * 根据名称获取 Action 实例\n * @param actionName - action 的名称\n * @param context 上下文\n * @returns Action 实例\n */\nexport function createAction(actionName: string, context: IInteractionContext): Action {\n const actionOption = ActionCache[actionName];\n let action = null;\n if (actionOption) {\n const { ActionClass, cfg } = actionOption;\n action = new ActionClass(context, cfg);\n action.name = actionName;\n action.init();\n }\n return action;\n}\n\n/**\n * 根据 action 的 name 获取定义的类\n * @param actionName action 的 name\n */\nexport function getActionClass(actionName: string): ActionConstructor {\n const actionOption = ActionCache[actionName];\n return get(actionOption, 'ActionClass');\n}\n\n/**\n * 注册 Action\n * @param actionName - action 的名称\n * @param ActionClass - 继承自 action 的类\n */\nexport function registerAction(actionName: string, ActionClass: ActionConstructor, cfg?: LooseObject) {\n ActionCache[actionName] = {\n ActionClass,\n cfg,\n };\n}\n\n/**\n * 取消注册 Action\n * @param actionName action 名称\n */\nexport function unregisterAction(actionName: string) {\n delete ActionCache[actionName];\n}\n\n/**\n * 根据回调函数获取 Action 实例\n * @param callback - action 的回调函数\n * @param context 上下文\n * @returns Action 实例\n */\nexport function createCallbackAction(callback: ActionCallback, context: IInteractionContext): CallbackAction {\n const action = new CallbackAction(context);\n action.callback = callback;\n action.name = 'callback';\n return action;\n}\n","import { vec2 } from '@antv/matrix-util';\nimport { each } from '@antv/util';\nimport { Coordinate, PathCommand } from '../../../dependents';\nimport { Point, Position } from '../../../interface';\nimport { getDistanceToCenter } from '../../../util/coordinate';\n\nfunction _points2path(points: Point[], isInCircle: boolean): PathCommand[] {\n const path = [];\n if (points.length) {\n path.push(['M', points[0].x, points[0].y]);\n for (let i = 1, length = points.length; i < length; i += 1) {\n const item = points[i];\n path.push(['L', item.x, item.y]);\n }\n\n if (isInCircle) {\n path.push(['Z']);\n }\n }\n\n return path;\n}\n\nfunction _convertArr(arr: number[], coord: Coordinate): any[] {\n const tmp = [arr[0]];\n for (let i = 1, len = arr.length; i < len; i = i + 2) {\n const point = coord.convert({\n x: arr[i],\n y: arr[i + 1],\n });\n tmp.push(point.x, point.y);\n }\n return tmp;\n}\nfunction _convertArcPath(path: PathCommand, coord: Coordinate): any[] {\n const { isTransposed } = coord;\n const r = path[1];\n const x = path[6];\n const y = path[7];\n const point = coord.convert({ x, y });\n const direction = isTransposed ? 0 : 1;\n return ['A', r, r, 0, 0, direction, point.x, point.y];\n}\n\nfunction _convertPolarPath(pre: PathCommand, cur: PathCommand, coord: Coordinate): PathCommand[] {\n const { isTransposed, startAngle, endAngle } = coord;\n const prePoint =\n pre[0].toLowerCase() === 'a'\n ? {\n x: pre[6],\n y: pre[7],\n }\n : {\n x: pre[1],\n y: pre[2],\n };\n const curPoint = {\n x: cur[1],\n y: cur[2],\n };\n const rst = [];\n const xDim = isTransposed ? 'y' : 'x';\n const angleRange = Math.abs(curPoint[xDim] - prePoint[xDim]) * (endAngle - startAngle);\n const direction = curPoint[xDim] >= prePoint[xDim] ? 1 : 0; // 圆弧的方向\n const flag = angleRange > Math.PI ? 1 : 0; // 大弧还是小弧标志位\n const convertPoint = coord.convert(curPoint);\n const r = getDistanceToCenter(coord, convertPoint);\n if (r >= 0.5) {\n // 小于1像素的圆在图像上无法识别\n if (angleRange === Math.PI * 2) {\n const middlePoint = {\n x: (curPoint.x + prePoint.x) / 2,\n y: (curPoint.y + prePoint.y) / 2,\n };\n const middleConvertPoint = coord.convert(middlePoint);\n rst.push(['A', r, r, 0, flag, direction, middleConvertPoint.x, middleConvertPoint.y]);\n rst.push(['A', r, r, 0, flag, direction, convertPoint.x, convertPoint.y]);\n } else {\n rst.push(['A', r, r, 0, flag, direction, convertPoint.x, convertPoint.y]);\n }\n }\n return rst;\n}\n\n// 当存在整体的圆时,去除圆前面和后面的线,防止出现直线穿过整个圆的情形\nfunction _filterFullCirleLine(path: PathCommand[]) {\n each(path, (subPath, index) => {\n const cur = subPath;\n if (cur[0].toLowerCase() === 'a') {\n const pre = path[index - 1];\n const next = path[index + 1];\n if (next && next[0].toLowerCase() === 'a') {\n if (pre && pre[0].toLowerCase() === 'l') {\n pre[0] = 'M';\n }\n } else if (pre && pre[0].toLowerCase() === 'a') {\n if (next && next[0].toLowerCase() === 'l') {\n next[0] = 'M';\n }\n }\n }\n });\n}\n\n/**\n * @ignore\n * 计算光滑的贝塞尔曲线\n */\nexport const smoothBezier = (\n points: Position[],\n smooth: number,\n isLoop: boolean,\n constraint: Position[]\n): Position[] => {\n const cps = [];\n const hasConstraint = !!constraint;\n\n let prevPoint: Position;\n let nextPoint: Position;\n let min: Position;\n let max: Position;\n let nextCp0: Position;\n let cp1: Position;\n let cp0: Position;\n\n if (hasConstraint) {\n [min, max] = constraint;\n for (let i = 0, l = points.length; i < l; i++) {\n const point = points[i];\n min = vec2.min([0, 0], min, point) as [number, number];\n max = vec2.max([0, 0], max, point) as [number, number];\n }\n }\n\n for (let i = 0, len = points.length; i < len; i++) {\n const point = points[i];\n if (i === 0 && !isLoop) {\n cp0 = point;\n } else if (i === len - 1 && !isLoop) {\n cp1 = point;\n cps.push(cp0);\n cps.push(cp1);\n } else {\n prevPoint = points[isLoop ? (i ? i - 1 : len - 1) : i - 1];\n nextPoint = points[isLoop ? (i + 1) % len : i + 1];\n\n let v: [number, number] = [0, 0];\n v = vec2.sub(v, nextPoint, prevPoint) as [number, number];\n v = vec2.scale(v, v, smooth) as [number, number];\n\n let d0 = vec2.distance(point, prevPoint);\n let d1 = vec2.distance(point, nextPoint);\n\n const sum = d0 + d1;\n if (sum !== 0) {\n d0 /= sum;\n d1 /= sum;\n }\n\n let v1 = vec2.scale([0, 0], v, -d0);\n let v2 = vec2.scale([0, 0], v, d1);\n\n cp1 = vec2.add([0, 0], point, v1) as Position;\n nextCp0 = vec2.add([0, 0], point, v2) as Position;\n\n // 下一个控制点必须在这个点和下一个点之间\n nextCp0 = vec2.min([0, 0], nextCp0, vec2.max([0, 0], nextPoint, point)) as Position;\n nextCp0 = vec2.max([0, 0], nextCp0, vec2.min([0, 0], nextPoint, point)) as Position;\n\n // 重新计算 cp1 的值\n v1 = vec2.sub([0, 0], nextCp0, point);\n v1 = vec2.scale([0, 0], v1, -d0 / d1);\n cp1 = vec2.add([0, 0], point, v1) as Position;\n\n // 上一个控制点必须要在上一个点和这一个点之间\n cp1 = vec2.min([0, 0], cp1, vec2.max([0, 0], prevPoint, point)) as Position;\n cp1 = vec2.max([0, 0], cp1, vec2.min([0, 0], prevPoint, point)) as Position;\n\n // 重新计算 nextCp0 的值\n v2 = vec2.sub([0, 0], point, cp1);\n v2 = vec2.scale([0, 0], v2, d1 / d0);\n nextCp0 = vec2.add([0, 0], point, v2) as Position;\n\n if (hasConstraint) {\n cp1 = vec2.max([0, 0], cp1, min) as Position;\n cp1 = vec2.min([0, 0], cp1, max) as Position;\n nextCp0 = vec2.max([0, 0], nextCp0, min) as Position;\n nextCp0 = vec2.min([0, 0], nextCp0, max) as Position;\n }\n\n cps.push(cp0);\n cps.push(cp1);\n cp0 = nextCp0;\n }\n }\n\n if (isLoop) {\n cps.push(cps.shift());\n }\n\n return cps;\n};\n\n/**\n * @ignore\n * 贝塞尔曲线\n */\nexport function catmullRom2bezier(crp: number[], z: boolean, constraint: Position[]): PathCommand[] {\n const isLoop = !!z;\n const pointList = [];\n for (let i = 0, l = crp.length; i < l; i += 2) {\n pointList.push([crp[i], crp[i + 1]]);\n }\n\n const controlPointList = smoothBezier(pointList, 0.4, isLoop, constraint);\n const len = pointList.length;\n const d1 = [];\n\n let cp1: Position;\n let cp2: Position;\n let p: Position;\n\n for (let i = 0; i < len - 1; i++) {\n cp1 = controlPointList[i * 2];\n cp2 = controlPointList[i * 2 + 1];\n p = pointList[i + 1];\n\n d1.push(['C', cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1]]);\n }\n\n if (isLoop) {\n cp1 = controlPointList[len];\n cp2 = controlPointList[len + 1];\n p = pointList[0];\n\n d1.push(['C', cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1]]);\n }\n return d1;\n}\n\n/**\n * @ignore\n * 将点连接成路径 path\n */\nexport function getLinePath(points: Point[], isInCircle?: boolean): PathCommand[] {\n return _points2path(points, isInCircle);\n}\n\n/**\n * @ignore\n * 根据关键点获取限定了范围的平滑线\n */\nexport function getSplinePath(points: Point[], isInCircle?: boolean, constaint?: Position[]): PathCommand[] {\n const data = [];\n const first = points[0];\n let prePoint = null;\n if (points.length <= 2) {\n // 两点以内直接绘制成路径\n return getLinePath(points, isInCircle);\n }\n for (let i = 0, len = points.length; i < len; i++) {\n const point = points[i];\n if (!prePoint || !(prePoint.x === point.x && prePoint.y === point.y)) {\n data.push(point.x);\n data.push(point.y);\n prePoint = point;\n }\n }\n const constraint = constaint || [\n // 范围\n [0, 0],\n [1, 1],\n ];\n const splinePath = catmullRom2bezier(data, isInCircle, constraint);\n splinePath.unshift(['M', first.x, first.y]);\n return splinePath;\n}\n\n/**\n * @ignore\n * 将归一化后的路径数据转换成坐标\n */\nexport function convertNormalPath(coord, path: PathCommand[]): PathCommand[] {\n const tmp = [];\n each(path, (subPath) => {\n const action = subPath[0];\n switch (action.toLowerCase()) {\n case 'm':\n case 'l':\n case 'c':\n tmp.push(_convertArr(subPath, coord));\n break;\n case 'a':\n tmp.push(_convertArcPath(subPath, coord));\n break;\n case 'z':\n default:\n tmp.push(subPath);\n break;\n }\n });\n return tmp;\n}\n\n/**\n * @ignore\n * 将路径转换为极坐标下的真实路径\n */\nexport function convertPolarPath(coord, path: PathCommand[]): PathCommand[] {\n let tmp = [];\n let pre: PathCommand;\n let cur: PathCommand;\n let transposed: boolean;\n let equals: boolean;\n each(path, (subPath, index) => {\n const action = subPath[0];\n\n switch (action.toLowerCase()) {\n case 'm':\n case 'c':\n case 'q':\n tmp.push(_convertArr(subPath, coord));\n break;\n case 'l':\n pre = path[index - 1];\n cur = subPath;\n transposed = coord.isTransposed;\n // 是否半径相同,转换成圆弧\n equals = transposed ? pre[pre.length - 2] === cur[1] : pre[pre.length - 1] === cur[2];\n if (equals) {\n tmp = tmp.concat(_convertPolarPath(pre, cur, coord));\n } else {\n // y 不相等,所以直接转换\n tmp.push(_convertArr(subPath, coord));\n }\n break;\n case 'a':\n tmp.push(_convertArcPath(subPath, coord));\n break;\n case 'z':\n default:\n tmp.push(subPath);\n break;\n }\n });\n _filterFullCirleLine(tmp); // 过滤多余的直线\n return tmp;\n}\n","import { isArray } from '@antv/util';\n\nconst SPACES = '\\x09\\x0a\\x0b\\x0c\\x0d\\x20\\xa0\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\u2028\\u2029';\nconst PATH_COMMAND = new RegExp('([a-z])[' + SPACES + ',]*((-?\\\\d*\\\\.?\\\\d*(?:e[\\\\-+]?\\\\d+)?[' + SPACES + ']*,?[' + SPACES + ']*)+)', 'ig');\nconst PATH_VALUES = new RegExp('(-?\\\\d*\\\\.?\\\\d*(?:e[\\\\-+]?\\\\d+)?)[' + SPACES + ']*,?[' + SPACES + ']*', 'ig');\n\n// Parses given path string into an array of arrays of path segments\nexport default function parsePathString(pathString: string) {\n if (!pathString) {\n return null;\n }\n\n if (isArray(pathString)) {\n return pathString;\n }\n const paramCounts = {\n a: 7,\n c: 6,\n o: 2,\n h: 1,\n l: 2,\n m: 2,\n r: 4,\n q: 4,\n s: 4,\n t: 2,\n v: 1,\n u: 3,\n z: 0,\n };\n const data = [];\n\n String(pathString).replace(PATH_COMMAND, function (a, b, c) {\n const params = [];\n let name = b.toLowerCase();\n c.replace(PATH_VALUES, function (a, b) {\n b && params.push(+b);\n });\n if (name === 'm' && params.length > 2) {\n data.push([ b ].concat(params.splice(0, 2)));\n name = 'l';\n b = b === 'm' ? 'l' : 'L';\n }\n if (name === 'o' && params.length === 1) {\n data.push([ b, params[0] ]);\n }\n if (name === 'r') {\n data.push([ b ].concat(params));\n } else {\n while (params.length >= paramCounts[name]) {\n data.push([ b ].concat(params.splice(0, paramCounts[name])));\n if (!paramCounts[name]) {\n break;\n }\n }\n }\n return '';\n });\n\n return data;\n}\n","const TAU = Math.PI * 2\n\nconst mapToEllipse = ({ x, y }: { x: number, y: number }, rx: number, ry: number, cosphi: number, sinphi: number, centerx: number, centery: number) => {\n x *= rx\n y *= ry\n\n const xp = cosphi * x - sinphi * y\n const yp = sinphi * x + cosphi * y\n\n return {\n x: xp + centerx,\n y: yp + centery\n }\n}\n\nconst approxUnitArc = (ang1: number, ang2: number) => {\n // If 90 degree circular arc, use a constant\n // as derived from http://spencermortensen.com/articles/bezier-circle\n const a = ang2 === 1.5707963267948966\n ? 0.551915024494\n : ang2 === -1.5707963267948966\n ? -0.551915024494\n : 4 / 3 * Math.tan(ang2 / 4)\n\n const x1 = Math.cos(ang1)\n const y1 = Math.sin(ang1)\n const x2 = Math.cos(ang1 + ang2)\n const y2 = Math.sin(ang1 + ang2)\n\n return [\n {\n x: x1 - y1 * a,\n y: y1 + x1 * a\n },\n {\n x: x2 + y2 * a,\n y: y2 - x2 * a\n },\n {\n x: x2,\n y: y2\n }\n ]\n}\n\nconst vectorAngle = (ux: number, uy: number, vx: number, vy: number) => {\n const sign = (ux * vy - uy * vx < 0) ? -1 : 1\n\n let dot = ux * vx + uy * vy\n\n if (dot > 1) {\n dot = 1\n }\n\n if (dot < -1) {\n dot = -1\n }\n\n return sign * Math.acos(dot)\n}\n\nconst getArcCenter = (\n px: any,\n py: any,\n cx: any,\n cy: any,\n rx: number,\n ry: number,\n largeArcFlag: number,\n sweepFlag: number,\n sinphi: number,\n cosphi: number,\n pxp: number,\n pyp: number\n) => {\n const rxsq = Math.pow(rx, 2)\n const rysq = Math.pow(ry, 2)\n const pxpsq = Math.pow(pxp, 2)\n const pypsq = Math.pow(pyp, 2)\n\n let radicant = (rxsq * rysq) - (rxsq * pypsq) - (rysq * pxpsq)\n\n if (radicant < 0) {\n radicant = 0\n }\n\n radicant /= (rxsq * pypsq) + (rysq * pxpsq)\n radicant = Math.sqrt(radicant) * (largeArcFlag === sweepFlag ? -1 : 1)\n\n const centerxp = radicant * rx / ry * pyp\n const centeryp = radicant * -ry / rx * pxp\n\n const centerx = cosphi * centerxp - sinphi * centeryp + (px + cx) / 2\n const centery = sinphi * centerxp + cosphi * centeryp + (py + cy) / 2\n\n const vx1 = (pxp - centerxp) / rx\n const vy1 = (pyp - centeryp) / ry\n const vx2 = (-pxp - centerxp) / rx\n const vy2 = (-pyp - centeryp) / ry\n\n let ang1 = vectorAngle(1, 0, vx1, vy1)\n let ang2 = vectorAngle(vx1, vy1, vx2, vy2)\n\n if (sweepFlag === 0 && ang2 > 0) {\n ang2 -= TAU\n }\n\n if (sweepFlag === 1 && ang2 < 0) {\n ang2 += TAU\n }\n\n return [ centerx, centery, ang1, ang2 ]\n}\n\nconst arcToBezier = ({\n px,\n py,\n cx,\n cy,\n rx,\n ry,\n xAxisRotation = 0,\n largeArcFlag = 0,\n sweepFlag = 0\n}) => {\n const curves = []\n\n if (rx === 0 || ry === 0) {\n return [{ x1: 0, y1: 0, x2: 0, y2: 0, x: cx, y: cy }];\n }\n\n const sinphi = Math.sin(xAxisRotation * TAU / 360)\n const cosphi = Math.cos(xAxisRotation * TAU / 360)\n\n const pxp = cosphi * (px - cx) / 2 + sinphi * (py - cy) / 2\n const pyp = -sinphi * (px - cx) / 2 + cosphi * (py - cy) / 2\n\n if (pxp === 0 && pyp === 0) {\n return [{ x1: 0, y1: 0, x2: 0, y2: 0, x: cx, y: cy }];\n }\n\n rx = Math.abs(rx)\n ry = Math.abs(ry)\n\n const lambda =\n Math.pow(pxp, 2) / Math.pow(rx, 2) +\n Math.pow(pyp, 2) / Math.pow(ry, 2)\n\n if (lambda > 1) {\n rx *= Math.sqrt(lambda)\n ry *= Math.sqrt(lambda)\n }\n\n let [ centerx, centery, ang1, ang2 ] = getArcCenter(\n px,\n py,\n cx,\n cy,\n rx,\n ry,\n largeArcFlag,\n sweepFlag,\n sinphi,\n cosphi,\n pxp,\n pyp\n )\n\n // If 'ang2' == 90.0000000001, then `ratio` will evaluate to\n // 1.0000000001. This causes `segments` to be greater than one, which is an\n // unecessary split, and adds extra points to the bezier curve. To alleviate\n // this issue, we round to 1.0 when the ratio is close to 1.0.\n let ratio = Math.abs(ang2) / (TAU / 4)\n if (Math.abs(1.0 - ratio) < 0.0000001) {\n ratio = 1.0\n }\n\n const segments = Math.max(Math.ceil(ratio), 1)\n\n ang2 /= segments\n\n for (let i = 0; i < segments; i++) {\n curves.push(approxUnitArc(ang1, ang2))\n ang1 += ang2\n }\n\n return curves.map(curve => {\n const { x: x1, y: y1 } = mapToEllipse(curve[ 0 ], rx, ry, cosphi, sinphi, centerx, centery)\n const { x: x2, y: y2 } = mapToEllipse(curve[ 1 ], rx, ry, cosphi, sinphi, centerx, centery)\n const { x, y } = mapToEllipse(curve[ 2 ], rx, ry, cosphi, sinphi, centerx, centery)\n\n return { x1, y1, x2, y2, x, y }\n })\n}\n\nexport function arcToCubic(x1: number, y1: number, rx: number, ry: number, angle: number, LAF: number, SF: number, x2: number, y2: number) {\n const curves = arcToBezier({\n px: x1,\n py: y1,\n cx: x2,\n cy: y2,\n rx,\n ry,\n xAxisRotation: angle,\n largeArcFlag: LAF,\n sweepFlag: SF,\n });\n\n return curves.reduce((prev, cur) => {\n const { x1, y1, x2, y2, x, y } = cur;\n prev.push(x1, y1, x2, y2, x, y);\n return prev;\n }, [] as number[]);\n}\n","/**\n * @fileoverview 判断点是否在多边形内\n * @author dxq613@gmail.com\n */\n\n// 多边形的射线检测,参考:https://blog.csdn.net/WilliamSun0122/article/details/77994526\nconst tolerance = 1e-6;\n// 三态函数,判断两个double在eps精度下的大小关系\nfunction dcmp(x) {\n if (Math.abs(x) < tolerance) {\n return 0;\n }\n\n return x < 0 ? -1 : 1;\n}\n\n// 判断点Q是否在p1和p2的线段上\nfunction onSegment(p1, p2, q) {\n if (\n (q[0] - p1[0]) * (p2[1] - p1[1]) === (p2[0] - p1[0]) * (q[1] - p1[1]) &&\n Math.min(p1[0], p2[0]) <= q[0] &&\n q[0] <= Math.max(p1[0], p2[0]) &&\n Math.min(p1[1], p2[1]) <= q[1] &&\n q[1] <= Math.max(p1[1], p2[1])\n ) {\n return true;\n }\n return false;\n}\n\n// 判断点P在多边形内-射线法\nexport default function isInPolygon(points, x, y) {\n let isHit = false;\n const n = points.length;\n if (n <= 2) {\n // svg 中点小于 3 个时,不显示,也无法被拾取\n return false;\n }\n for (let i = 0; i < n; i++) {\n const p1 = points[i];\n const p2 = points[(i + 1) % n];\n if (onSegment(p1, p2, [x, y])) {\n // 点在多边形一条边上\n return true;\n }\n // 前一个判断min(p1[1],p2[1]) 0 !== dcmp(p2[1] - y) > 0 &&\n dcmp(x - ((y - p1[1]) * (p1[0] - p2[0])) / (p1[1] - p2[1]) - p1[0]) < 0\n ) {\n isHit = !isHit;\n }\n }\n return isHit;\n}\n","type Point = {\n /**\n * x 值\n * @type {number}\n */\n x: number;\n /**\n * y 值\n * @type {number}\n */\n y: number;\n};\n\nconst isBetween = (value: number, min: number, max: number) => value >= min && value <= max;\n\n\nexport default function getLineIntersect(p0: Point, p1: Point, p2: Point, p3: Point): Point | null {\n const tolerance = 0.001;\n const E: Point = {\n x: p2.x - p0.x,\n y: p2.y - p0.y,\n };\n const D0: Point = {\n x: p1.x - p0.x,\n y: p1.y - p0.y,\n };\n const D1: Point = {\n x: p3.x - p2.x,\n y: p3.y - p2.y,\n };\n const kross: number = D0.x * D1.y - D0.y * D1.x;\n const sqrKross: number = kross * kross;\n const sqrLen0: number = D0.x * D0.x + D0.y * D0.y;\n const sqrLen1: number = D1.x * D1.x + D1.y * D1.y;\n let point: Point | null = null;\n if (sqrKross > tolerance * sqrLen0 * sqrLen1) {\n const s = (E.x * D1.y - E.y * D1.x) / kross;\n const t = (E.x * D0.y - E.y * D0.x) / kross;\n if (isBetween(s, 0, 1) && isBetween(t, 0, 1)) {\n point = {\n x: p0.x + s * D0.x,\n y: p0.y + s * D0.y,\n };\n }\n }\n return point;\n};","\nimport isPointInPolygon from './point-in-polygon';\nimport getLineIntersect from './get-line-intersect';\nimport {each} from '@antv/util';\n\nfunction parseToLines(points) {\n const lines = [];\n const count = points.length;\n for(let i = 0; i < count - 1; i++) {\n const point = points[i];\n const next = points[i + 1];\n lines.push({\n from: {\n x: point[0],\n y: point[1]\n },\n to: {\n x: next[0],\n y: next[1]\n }\n });\n }\n if (lines.length > 1) {\n const first = points[0];\n const last = points[count - 1];\n lines.push({\n from: {\n x: last[0],\n y: last[1]\n },\n to: {\n x: first[0],\n y: first[1]\n }\n });\n }\n return lines;\n}\n\nfunction lineIntersectPolygon(lines, line) {\n let isIntersect = false;\n each(lines, l => {\n if (getLineIntersect(l.from, l.to, line.from, line.to)) {\n isIntersect = true;\n return false;\n }\n });\n return isIntersect;\n}\n\ntype BBox = {\n minX: number;\n minY: number;\n maxX: number;\n maxY: number;\n};\n\nfunction getBBox(points): BBox {\n const xArr = points.map(p => p[0]);\n const yArr = points.map(p => p[1]);\n return {\n minX: Math.min.apply(null, xArr),\n maxX: Math.max.apply(null, xArr),\n minY: Math.min.apply(null, yArr),\n maxY: Math.max.apply(null, yArr)\n };\n}\n\nfunction intersectBBox(box1:BBox, box2:BBox) {\n return !(box2.minX > box1.maxX || box2.maxX < box1.minX || box2.minY > box1.maxY || box2.maxY < box1.minY);\n}\n\nexport default function isPolygonsIntersect(points1, points2) {\n // 空数组,或者一个点返回 false\n if (points1.length < 2 || points2.length < 2) {\n return false;\n }\n\n const bbox1 = getBBox(points1);\n const bbox2 = getBBox(points2);\n // 判定包围盒是否相交,比判定点是否在多边形内要快的多,可以筛选掉大多数情况\n if (!intersectBBox(bbox1, bbox2)) {\n return false;\n }\n \n let isIn = false;\n // 判定点是否在多边形内部,一旦有一个点在另一个多边形内,则返回\n each(points2, point => {\n if (isPointInPolygon(points1, point[0], point[1])) {\n isIn = true;\n return false;\n }\n });\n if (isIn) {\n return true;\n }\n // 两个多边形都需要判定\n each(points1, point => {\n if (isPointInPolygon(points2, point[0], point[1])) {\n isIn = true;\n return false;\n }\n });\n if (isIn) {\n return true;\n }\n\n const lines1 = parseToLines(points1);\n const lines2 = parseToLines(points2);\n let isIntersect = false;\n each(lines2, line => {\n if (lineIntersectPolygon(lines1, line)) {\n isIntersect = true;\n return false;\n }\n });\n return isIntersect;\n}","import { each, isArray } from '@antv/util';\nimport { View } from '../../chart';\nimport { BBox, PathCommand, Point } from '../../dependents';\nimport Geometry from '../../geometry/base';\nimport Element from '../../geometry/element/';\nimport { catmullRom2bezier, getLinePath } from '../../geometry/shape/util/path';\nimport { toPoints } from '../../util/bbox';\nimport { isPolygonsIntersect } from '@antv/path-util';\nimport { ComponentOption, IInteractionContext, LooseObject } from '../../interface';\n\nfunction getMaskBBox(context: IInteractionContext, tolerance: number) {\n const event = context.event;\n const maskShape = event.target;\n return getMaskBBoxByShape(maskShape, tolerance);\n}\n\n/**\n * 如果 mask BBox 过小则不返回\n */\nfunction isValidMaskBBox(maskShape, tolerance: number) {\n const maskBBox = maskShape.getCanvasBBox();\n const { width, height } = maskBBox;\n return width > 0 && height > 0 && (width >= tolerance || height >= tolerance);\n}\n\n/**\n * 通过 maskShape 获取 mask 的 canvasBBox\n * @param maskShape\n * @param tolerance\n * @returns\n */\nfunction getMaskBBoxByShape(maskShape, tolerance: number) {\n const maskBBox = maskShape.getCanvasBBox();\n return isValidMaskBBox(maskShape, tolerance) ? maskBBox : null;\n}\n\n/**\n * 获取 multiple 模式下 mask 的 canvasBBox 数组\n * @param context 上下文\n * @param tolerance box 宽高小于则不返回\n * @returns\n */\nfunction getMultiMaskBBoxList(context: IInteractionContext, tolerance: number) {\n const { maskShapes } = context.event;\n return maskShapes.map((maskShape) => getMaskBBoxByShape(maskShape, tolerance)).filter((bBox) => !!bBox);\n}\n\nfunction getMaskPath(context: IInteractionContext, tolerance: number) {\n const event = context.event;\n const maskShape = event.target;\n return getMaskPathByMaskShape(maskShape, tolerance);\n}\n\n/**\n * 通过 maskShape 获取 mask path\n * @param maskShape\n * @param tolerance box 宽高小于则不返回\n * @returns\n */\nfunction getMaskPathByMaskShape(maskShape, tolerance: number) {\n return isValidMaskBBox(maskShape, tolerance) ? maskShape.attr('path') : null;\n}\n\n/**\n * 获取 multiple 模式下 mask path 数组\n * @param context 上下文\n * @param tolerance box 宽高小于则不返回\n * @returns\n */\nfunction getMultiMaskPathList(context: IInteractionContext, tolerance: number) {\n const { maskShapes } = context.event;\n return maskShapes.map((maskShape) => getMaskPathByMaskShape(maskShape, tolerance));\n}\n\n/**\n * 获取当前事件相关的图表元素\n * @param context 交互的上下文\n * @ignore\n */\nexport function getCurrentElement(context: IInteractionContext): Element {\n const event = context.event;\n let element;\n const target = event.target;\n if (target) {\n element = target.get('element');\n }\n return element;\n}\n\n/**\n * 获取委托对象\n * @param context 上下文\n * @ignore\n */\nexport function getDelegationObject(context: IInteractionContext): LooseObject {\n const event = context.event;\n const target = event.target;\n let delegateObject;\n if (target) {\n delegateObject = target.get('delegateObject');\n }\n return delegateObject;\n}\n\nexport function isElementChange(context: IInteractionContext) {\n const event = context.event.gEvent;\n // 在同一个 element 内部移动,label 和 shape 之间\n if (event && event.fromShape && event.toShape && event.fromShape.get('element') === event.toShape.get('element')) {\n return false;\n }\n return true;\n}\n\n/**\n * 是否是列表组件\n * @param delegateObject 委托对象\n * @ignore\n */\nexport function isList(delegateObject: LooseObject): boolean {\n return delegateObject && delegateObject.component && delegateObject.component.isList();\n}\n\n/**\n * 是否是滑块组件\n * @param delegateObject 委托对象\n * @ignore\n */\nexport function isSlider(delegateObject: LooseObject): boolean {\n return delegateObject && delegateObject.component && delegateObject.component.isSlider();\n}\n\n/**\n * 是否由 mask 触发\n * @param context 上下文\n * @ignore\n */\nexport function isMask(context: IInteractionContext): boolean {\n const event = context.event;\n const target = event.target;\n return (target && target?.get('name') === 'mask') || isMultipleMask(context);\n}\n\n/**\n * 是否由 multiple mask 触发\n * @param context\n * @returns\n */\nexport function isMultipleMask(context: IInteractionContext): boolean {\n return context.event.target?.get('name') === 'multi-mask';\n}\n\n/**\n * 获取被遮挡的 elements\n * @param context 上下文\n * @ignore\n */\nexport function getMaskedElements(context: IInteractionContext, tolerance: number): Element[] {\n const target = context.event.target;\n\n // multiple 模式下\n if (isMultipleMask(context)) {\n return getMultiMaskedElements(context, tolerance);\n }\n\n // 正常模式下\n if (target.get('type') === 'path') {\n const maskPath = getMaskPath(context, tolerance);\n if (!maskPath) {\n return;\n }\n return getElementsByPath(context.view, maskPath);\n }\n const maskBBox = getMaskBBox(context, tolerance);\n // 如果 bbox 过小则不返回\n if (!maskBBox) {\n return null;\n }\n return getIntersectElements(context.view, maskBBox);\n}\n\n/**\n * 获取 multiple 模式下被 mask 遮挡的 elements\n * @param context 上下文\n * @returns\n */\nfunction getMultiMaskedElements(context: IInteractionContext, tolerance: number): Element[] {\n const { target } = context.event;\n if (target.get('type') === 'path') {\n const maskPathList = getMultiMaskPathList(context, tolerance);\n if (maskPathList.length > 0) {\n return maskPathList.flatMap((maskPath) => getElementsByPath(context.view, maskPath));\n }\n return null;\n }\n const maskBBoxList = getMultiMaskBBoxList(context, tolerance);\n if (maskBBoxList.length > 0) {\n return maskBBoxList.flatMap((maskBBox) => getIntersectElements(context.view, maskBBox));\n }\n return null;\n}\n\n/**\n * @ignore\n */\nexport function getSiblingMaskElements(context: IInteractionContext, sibling: View, tolerance: number) {\n // multiple 模式下\n if (isMultipleMask(context)) {\n return getSiblingMultiMaskedElements(context, sibling, tolerance);\n }\n\n // 正常模式下\n const maskBBox = getMaskBBox(context, tolerance);\n // 如果 bbox 过小则不返回\n if (!maskBBox) {\n return null;\n }\n return getSiblingMaskElementsByBBox(maskBBox, context, sibling);\n}\n\n/**\n * 通过 mashBBox 获取 sibling 模式下被 mask 遮挡的 elements\n * @param maskBBox\n * @param context 上下文\n * @param sibling sibling view\n * @returns\n */\nfunction getSiblingMaskElementsByBBox(maskBBox, context: IInteractionContext, sibling: View) {\n const view = context.view;\n const start = getSiblingPoint(view, sibling, { x: maskBBox.x, y: maskBBox.y });\n const end = getSiblingPoint(view, sibling, { x: maskBBox.maxX, y: maskBBox.maxY });\n const box = {\n minX: start.x,\n minY: start.y,\n maxX: end.x,\n maxY: end.y,\n };\n return getIntersectElements(sibling, box);\n}\n\n/**\n * 获取 sibling 模式下被 multiple mask 遮挡的 elements\n * @param context 上下文\n * @param sibling sibling view\n * @param tolerance box 宽高小于则不返回\n * @returns\n */\nfunction getSiblingMultiMaskedElements(context: IInteractionContext, sibling: View, tolerance: number): Element[] {\n const maskBBoxList = getMultiMaskBBoxList(context, tolerance);\n if (maskBBoxList.length > 0) {\n return maskBBoxList.flatMap((maskBBox) => getSiblingMaskElementsByBBox(maskBBox, context, sibling));\n }\n return null;\n}\n\n/**\n * 获取所有的图表元素\n * @param view View/Chart\n * @ignore\n */\nexport function getElements(view: View): Element[] {\n const geometries = view.geometries;\n let rst: Element[] = [];\n each(geometries, (geom: Geometry) => {\n const elements = geom.elements;\n rst = rst.concat(elements);\n });\n if (view.views && view.views.length) {\n each(view.views, (subView) => {\n rst = rst.concat(getElements(subView));\n });\n }\n return rst;\n}\n\n/**\n * 获取所有的图表元素\n * @param view View/Chart\n * @param field 字段名\n * @param value 字段值\n * @ignore\n */\nexport function getElementsByField(view: View, field: string, value: any) {\n const elements = getElements(view);\n return elements.filter((el) => {\n return getElementValue(el, field) === value;\n });\n}\n\n/**\n * 根据状态名获取图表元素\n * @param view View/Chart\n * @param stateName 状态名\n * @ignore\n */\nexport function getElementsByState(view: View, stateName: string): Element[] {\n const geometries = view.geometries;\n let rst: Element[] = [];\n each(geometries, (geom: Geometry) => {\n const elements = geom.getElementsBy((el) => el.hasState(stateName));\n rst = rst.concat(elements);\n });\n return rst;\n}\n\n/**\n * 获取图表元素对应字段的值\n * @param element 图表元素\n * @param field 字段名\n * @ignore\n */\nexport function getElementValue(element: Element, field) {\n const model = element.getModel();\n const record = model.data;\n let value;\n if (isArray(record)) {\n value = record[0][field];\n } else {\n value = record[field];\n }\n return value;\n}\n\n/**\n * 两个包围盒是否相交\n * @param box1 包围盒1\n * @param box2 包围盒2\n * @ignore\n */\nexport function intersectRect(box1, box2) {\n return !(box2.minX > box1.maxX || box2.maxX < box1.minX || box2.minY > box1.maxY || box2.maxY < box1.minY);\n}\n\n/**\n * 获取包围盒内的图表元素\n * @param view View/Chart\n * @param box 包围盒\n * @ignore\n */\nexport function getIntersectElements(view: View, box) {\n const elements = getElements(view);\n const rst = [];\n each(elements, (el) => {\n const shape = el.shape;\n const shapeBBox = shape.getCanvasBBox();\n if (intersectRect(box, shapeBBox)) {\n rst.push(el);\n }\n });\n return rst;\n}\nfunction pathToPoints(path: any[]) {\n const points = [];\n each(path, (seg) => {\n const command = seg[0];\n if (command !== 'A') {\n for (let i = 1; i < seg.length; i = i + 2) {\n points.push([seg[i], seg[i + 1]]);\n }\n } else {\n const length = seg.length;\n points.push([seg[length - 2], seg[length - 1]]);\n }\n });\n return points;\n}\n/**\n * 获取包围盒内的图表元素\n * @param view View/Chart\n * @param path 路径\n * @ignore\n */\nexport function getElementsByPath(view: View, path: any[]) {\n const elements = getElements(view);\n const points = pathToPoints(path);\n const rst = elements.filter((el: Element) => {\n const shape = el.shape;\n let shapePoints;\n if (shape.get('type') === 'path') {\n shapePoints = pathToPoints(shape.attr('path'));\n } else {\n const shapeBBox = shape.getCanvasBBox();\n shapePoints = toPoints(shapeBBox);\n }\n return isPolygonsIntersect(points, shapePoints);\n });\n return rst;\n}\n\n/**\n * 获取当前 View 的所有组件\n * @param view View/Chart\n * @ignore\n */\nexport function getComponents(view) {\n return view.getComponents().map((co: ComponentOption) => co.component);\n}\n\n/** @ignore */\nexport function distance(p1: Point, p2: Point) {\n const dx = p2.x - p1.x;\n const dy = p2.y - p1.y;\n return Math.sqrt(dx * dx + dy * dy);\n}\n\n/** @ignore */\nexport function getSpline(points: Point[], z: boolean): PathCommand[] {\n if (points.length <= 2) {\n return getLinePath(points, false);\n }\n const first = points[0];\n const arr = [];\n each(points, (point) => {\n arr.push(point.x);\n arr.push(point.y);\n });\n const path = catmullRom2bezier(arr, z, null);\n path.unshift(['M', first.x, first.y]);\n return path;\n}\n\n/**\n * 检测点是否在包围盒内\n * @param box 包围盒\n * @param point 点\n * @ignore\n */\nexport function isInBox(box: BBox, point: Point) {\n return box.x <= point.x && box.maxX >= point.x && box.y <= point.y && box.maxY > point.y;\n}\n\n/**\n * 获取同 view 同一级的 views\n * @param view 当前 view\n * @returns 同一级的 views\n * @ignore\n */\nexport function getSilbings(view: View): View[] {\n const parent = view.parent;\n let siblings = null;\n if (parent) {\n siblings = parent.views.filter((sub) => sub !== view);\n }\n return siblings;\n}\n\nfunction point2Normalize(view: View, point: Point): Point {\n const coord = view.getCoordinate();\n return coord.invert(point);\n}\n/**\n * 将 view 上的一点转换成另一个 view 的点\n * @param view 当前的 view\n * @param sibling 同一层级的 view\n * @param point 指定点\n * @ignore\n */\nexport function getSiblingPoint(view: View, sibling: View, point: Point): Point {\n const normalPoint = point2Normalize(view, point);\n return sibling.getCoordinate().convert(normalPoint);\n}\n\n/**\n * 是否在记录中,临时因为所有的 view 中的数据不是引用,而使用的方法\n * 不同 view 上对数据的引用不相等,导致无法直接用 includes\n * 假设 x, y 值相等时是同一条数据,这个假设不完全正确,而改成 isEqual 则成本太高\n * 后面改成同一个引用时可以修改回来\n * @param records\n * @param record\n * @param xFiled\n * @param yField\n * @returns\n * @ignore\n */\nexport function isInRecords(records: object[], record: object, xFiled: string, yField: string) {\n let isIn = false;\n each(records, (r) => {\n if (r[xFiled] === record[xFiled] && r[yField] === record[yField]) {\n isIn = true;\n return false;\n }\n });\n return isIn;\n}\n\n// 级联获取 field 对应的 scale,如果 view 上没有,遍历子 view\nexport function getScaleByField(view: View, field: string) {\n let scale = view.getScaleByField(field);\n if (!scale && view.views) {\n each(view.views, (subView) => {\n scale = getScaleByField(subView, field);\n if (scale) {\n return false; // 终止循环\n }\n });\n }\n return scale;\n}\n","import { each, get } from '@antv/util';\nimport { View } from '../chart';\nimport { BBox, IShape, Point } from '../dependents';\nimport { IAction, IInteractionContext, LooseObject } from '../interface';\nimport { getComponents, isInBox } from './action/util';\n\n/**\n * 交互的上下文\n */\nexport default class Context implements IInteractionContext {\n /** 当前所有的 Action */\n public actions: IAction[] = [];\n /** 当前 View 实例 */\n public view: View;\n /** 当前事件对象 */\n public event: LooseObject = null;\n\n private cacheMap: LooseObject = {};\n\n constructor(view: View) {\n this.view = view;\n }\n\n /**\n * 缓存信息\n * @param params 缓存的字段\n * - 如果一个字段则获取缓存\n * - 两个字段则设置缓存\n */\n public cache(...params) {\n if (params.length === 1) {\n return this.cacheMap[params[0]];\n } else if (params.length === 2) {\n this.cacheMap[params[0]] = params[1];\n }\n }\n\n /**\n * 获取 Action\n * @param name Action 的名称\n */\n public getAction(name: string): IAction {\n return this.actions.find((action) => action.name === name);\n }\n\n /**\n * 获取 Action\n * @param action Action 对象\n */\n public addAction(action: IAction) {\n this.actions.push(action);\n }\n\n /**\n * 移除 Action\n * @param action Action 对象\n */\n public removeAction(action: IAction) {\n const actions = this.actions;\n const index = this.actions.indexOf(action);\n if (index >= 0) {\n actions.splice(index, 1);\n }\n }\n\n /**\n * 获取当前的点\n */\n public getCurrentPoint(): Point {\n const event = this.event;\n if (event) {\n if (event.target instanceof HTMLElement) {\n const canvas = this.view.getCanvas();\n const point = canvas.getPointByClient(event.clientX, event.clientY);\n return point;\n } else {\n return {\n x: event.x,\n y: event.y,\n };\n }\n }\n return null;\n }\n\n /**\n * 获取当前 shape\n * @returns current shape\n */\n public getCurrentShape(): IShape {\n return get(this.event, ['gEvent', 'shape']);\n }\n\n /**\n * 当前的触发是否在 View 内\n */\n public isInPlot() {\n const point = this.getCurrentPoint();\n if (point) {\n return this.view.isPointInPlot(point);\n }\n return false;\n }\n\n /**\n * 是否在指定的图形内\n * @param name shape 的 name\n */\n public isInShape(name) {\n const shape = this.getCurrentShape(); // 不再考虑在 shape 的 parent 内的情况\n if (shape) {\n return shape.get('name') === name;\n }\n return false;\n }\n\n /**\n * 当前的触发是组件内部\n * @param name 组件名,可以为空\n */\n public isInComponent(name?: string) {\n const components = getComponents(this.view);\n const point = this.getCurrentPoint();\n if (point) {\n return !!components.find((component) => {\n const bbox = component.getBBox() as BBox;\n if (name) {\n return component.get('name') === name && isInBox(bbox, point);\n } else {\n return isInBox(bbox, point);\n }\n });\n }\n return false;\n }\n\n /**\n * 销毁\n */\n public destroy() {\n // 先销毁 action 再清空,一边遍历,一边删除,所以数组需要更新引用\n each(this.actions.slice(), (action) => {\n action.destroy();\n });\n this.view = null;\n this.event = null;\n this.actions = null;\n this.cacheMap = null;\n }\n}\n","import { View } from '../chart';\nimport { LooseObject } from '../interface';\n\nexport type InteractionConstructor = new (view: View, cfg: LooseObject) => Interaction;\n\n/**\n * 交互的基类。\n */\nexport default class Interaction {\n /** view 或者 chart */\n protected view: View;\n /** 配置项 */\n protected cfg: LooseObject;\n\n constructor(view: View, cfg: LooseObject) {\n this.view = view;\n this.cfg = cfg;\n }\n\n /**\n * 初始化。\n */\n public init() {\n this.initEvents();\n }\n\n /**\n * 绑定事件\n */\n protected initEvents() {}\n\n /**\n * 销毁事件\n */\n protected clearEvents() {}\n\n /**\n * 销毁。\n */\n public destroy() {\n this.clearEvents();\n }\n}\n","import { each, isArray, isFunction, isString, debounce, throttle } from '@antv/util';\nimport { View } from '../chart';\nimport { ActionCallback, IAction, IInteractionContext, LooseObject } from '../interface';\nimport { createAction, createCallbackAction } from './action/register';\nimport InteractionContext from './context';\nimport Interaction from './interaction';\n\n// 将字符串转换成 action\nexport function parseAction(actionStr: string, context: IInteractionContext, arg?: any): ActionObject {\n const arr = actionStr.split(':');\n const actionName = arr[0];\n // 如果已经初始化过 action ,则直接引用之前的 action\n const action = context.getAction(actionName) || createAction(actionName, context);\n if (!action) {\n throw new Error(`There is no action named ${actionName}`);\n }\n const methodName = arr[1];\n return {\n action,\n methodName,\n arg,\n };\n}\n\n// 执行 Action\nfunction executeAction(actionObject: ActionObject) {\n const { action, methodName, arg } = actionObject;\n if (action[methodName]) {\n action[methodName](arg);\n } else {\n throw new Error(`Action(${action.name}) doesn't have a method called ${methodName}`);\n }\n}\n\nconst STEP_NAMES = {\n START: 'start',\n SHOW_ENABLE: 'showEnable',\n END: 'end',\n ROLLBACK: 'rollback',\n PROCESSING: 'processing',\n};\n\n/** 交互环节的定义 */\nexport interface InteractionStep {\n /**\n * 触发事件,支持 view,chart 的各种事件,也支持 document、window 的事件\n */\n trigger: string;\n /**\n * 是否可以触发 action\n * @param context - 交互的上下文\n */\n isEnable?: (context: IInteractionContext) => boolean;\n /**\n * 反馈,支持三种方式:\n * - action:method : action 的名字和方法的组合\n * - [’action1:method1‘, ’action2:method‘]\n * - ActionCallback: 回调函数\n */\n action: string | string[] | ActionCallback;\n /**\n * 反馈,具体 action method 的参数:\n * - 当传递多个 action 时,args 必须是一个数组\n */\n arg?: any | any[];\n /**\n * 回调函数,action 执行后执行\n */\n callback?: (context: IInteractionContext) => void;\n /**\n * @private\n * 不需要用户传入,通过上面的属性计算出来的属性\n */\n actionObject?: ActionObject | ActionObject[];\n /**\n * 在一个环节内是否只允许执行一次\n */\n once?: boolean;\n /**\n * 是否增加节流\n */\n throttle?: ThrottleOption;\n /**\n * 是否延迟\n */\n debounce?: DebounceOption;\n}\n\n// action 执行时支持 debounce 和 throttle,可以参考:https://css-tricks.com/debouncing-throttling-explained-examples/\n/**\n * debounce 的配置\n */\nexport interface DebounceOption {\n /**\n * 等待时间\n */\n wait: number;\n /**\n * 是否马上执行\n */\n immediate?: boolean;\n}\n\n/**\n * throttle 的配置\n */\nexport interface ThrottleOption {\n /**\n * 等待时间\n */\n wait: number;\n /**\n * 马上就执行\n */\n leading?: boolean;\n /**\n * 执行完毕后再执行一次\n */\n trailing?: boolean;\n}\n\n/** 缓存 action 对象,仅用于当前文件 */\ninterface ActionObject {\n /**\n * 缓存的 action\n */\n action: IAction;\n /**\n * action 的方法\n */\n methodName: string;\n /**\n * 用户传递的 action 方法的参数\n */\n arg?: any;\n}\n\n/** 交互的所有环节 */\nexport interface InteractionSteps {\n /**\n * 显示交互可以进行\n */\n showEnable?: InteractionStep[];\n /**\n * 交互开始\n */\n start?: InteractionStep[];\n /**\n * 交互持续\n */\n processing?: InteractionStep[];\n /**\n * 交互结束\n */\n end?: InteractionStep[];\n /**\n * 交互回滚\n */\n rollback?: InteractionStep[];\n}\n\n/**\n * 支持语法的交互类\n */\nexport default class GrammarInteraction extends Interaction {\n // 存储的交互环节\n private steps: InteractionSteps;\n /** 当前执行到的阶段 */\n public currentStepName: string;\n /**\n * 当前交互的上下文\n */\n public context: IInteractionContext;\n\n private callbackCaches: LooseObject = {};\n // 某个触发和反馈在本环节是否执行或\n private emitCaches: LooseObject = {};\n\n constructor(view: View, steps: InteractionSteps) {\n super(view, steps);\n this.steps = steps;\n }\n\n /**\n * 初始化\n */\n public init() {\n this.initContext();\n super.init();\n }\n\n /**\n * 清理资源\n */\n public destroy() {\n super.destroy(); // 先清理事件\n this.steps = null;\n if (this.context) {\n this.context.destroy();\n this.context = null;\n }\n\n this.callbackCaches = null;\n this.view = null;\n }\n\n /**\n * 绑定事件\n */\n protected initEvents() {\n each(this.steps, (stepArr, stepName) => {\n each(stepArr, (step) => {\n const callback = this.getActionCallback(stepName, step);\n if (callback) {\n // 如果存在 callback,才绑定,有时候会出现无 callback 的情况\n this.bindEvent(step.trigger, callback);\n }\n });\n });\n }\n\n /**\n * 清理绑定的事件\n */\n protected clearEvents() {\n each(this.steps, (stepArr, stepName) => {\n each(stepArr, (step) => {\n const callback = this.getActionCallback(stepName, step);\n if (callback) {\n this.offEvent(step.trigger, callback);\n }\n });\n });\n }\n\n // 初始化上下文,并初始化 action\n private initContext() {\n const view = this.view;\n const context = new InteractionContext(view);\n this.context = context;\n const steps = this.steps;\n // 生成具体的 Action\n each(steps, (subSteps: InteractionStep[]) => {\n each(subSteps, (step: InteractionStep) => {\n if (isFunction(step.action)) {\n // 如果传入回调函数,则直接生成 CallbackAction\n step.actionObject = {\n action: createCallbackAction(step.action, context),\n methodName: 'execute',\n };\n } else if (isString(step.action)) {\n // 如果是字符串\n step.actionObject = parseAction(step.action, context, step.arg);\n } else if (isArray(step.action)) {\n // 如果是数组\n const actionArr = step.action;\n const argArr = isArray(step.arg) ? step.arg : [step.arg];\n step.actionObject = [];\n each(actionArr, (actionStr, idx) => {\n (step.actionObject as ActionObject[]).push(parseAction(actionStr, context, argArr[idx]));\n });\n }\n // 如果 action 既不是字符串,也不是函数,则不会生成 actionObject\n });\n });\n }\n\n // 是否允许指定阶段名称执行\n private isAllowStep(stepName: string): boolean {\n const currentStepName = this.currentStepName;\n const steps = this.steps;\n // 相同的阶段允许同时执行\n if (currentStepName === stepName) {\n return true;\n }\n\n if (stepName === STEP_NAMES.SHOW_ENABLE) {\n // 示能在整个过程中都可用\n return true;\n }\n\n if (stepName === STEP_NAMES.PROCESSING) {\n // 只有当前是 start 时,才允许 processing\n return currentStepName === STEP_NAMES.START;\n }\n\n if (stepName === STEP_NAMES.START) {\n // 如果当前是 processing,则无法 start,必须等待 end 后才能执行\n return currentStepName !== STEP_NAMES.PROCESSING;\n }\n\n if (stepName === STEP_NAMES.END) {\n return currentStepName === STEP_NAMES.PROCESSING || currentStepName === STEP_NAMES.START;\n }\n\n if (stepName === STEP_NAMES.ROLLBACK) {\n if (steps[STEP_NAMES.END]) {\n // 如果定义了 end, 只有 end 时才允许回滚\n return currentStepName === STEP_NAMES.END;\n } else if (currentStepName === STEP_NAMES.START) {\n // 如果未定义 end, 则判断是否是开始\n return true;\n }\n }\n return false;\n }\n\n // 具体的指定阶段是否允许执行\n private isAllowExecute(stepName: string, step: InteractionStep): boolean {\n if (this.isAllowStep(stepName)) {\n const key = this.getKey(stepName, step);\n // 如果是在本环节内仅允许触发一次,同时已经触发过,则不允许再触发\n if (step.once && this.emitCaches[key]) {\n return false;\n }\n // 如果是允许的阶段,则验证 isEnable 方法\n if (step.isEnable) {\n return step.isEnable(this.context);\n }\n return true; // 如果没有 isEnable 则允许执行\n }\n return false;\n }\n\n private enterStep(stepName: string) {\n this.currentStepName = stepName;\n this.emitCaches = {}; // 清除所有本环节触发的缓存\n }\n\n // 执行完某个触发和反馈(子环节)\n private afterExecute(stepName: string, step) {\n // show enable 不计入正常的流程,其他情况则设置当前的 step\n if (stepName !== STEP_NAMES.SHOW_ENABLE && this.currentStepName !== stepName) {\n this.enterStep(stepName);\n }\n const key = this.getKey(stepName, step);\n // 一旦执行,则缓存标记为,一直保持到跳出改环节\n this.emitCaches[key] = true;\n }\n // 获取某个环节的唯一的键值\n private getKey(stepName, step) {\n return stepName + step.trigger + step.action;\n }\n\n // 获取 step 的回调函数,如果已经生成,则直接返回,如果未生成,则创建\n private getActionCallback(stepName: string, step: InteractionStep): (e: object) => void {\n const context = this.context;\n const callbackCaches = this.callbackCaches;\n const actionObject = step.actionObject;\n if (step.action && actionObject) {\n const key = this.getKey(stepName, step);\n if (!callbackCaches[key]) {\n // 动态生成执行的方法,执行对应 action 的名称\n const actionCallback = (event) => {\n context.event = event; // 保证检测时的 event\n if (this.isAllowExecute(stepName, step)) {\n // 如果是数组时,则依次执行\n if (isArray(actionObject)) {\n each(actionObject, (obj: ActionObject) => {\n context.event = event; // 可能触发新的事件,保证执行前的 context.event 是正确的\n executeAction(obj);\n });\n } else {\n context.event = event; // 保证执行前的 context.event 是正确的\n executeAction(actionObject);\n }\n this.afterExecute(stepName, step);\n if (step.callback) {\n context.event = event; // 保证执行前的 context.event 是正确的\n step.callback(context);\n }\n } else {\n // 如果未通过验证,则事件不要绑定在上面\n context.event = null;\n }\n };\n // 如果设置了 debounce\n if (step.debounce) {\n callbackCaches[key] = debounce(actionCallback, step.debounce.wait, step.debounce.immediate);\n } else if (step.throttle) {\n // 设置 throttle\n callbackCaches[key] = throttle(actionCallback, step.throttle.wait, {\n leading: step.throttle.leading,\n trailing: step.throttle.trailing,\n });\n } else {\n // 直接设置\n callbackCaches[key] = actionCallback;\n }\n }\n return callbackCaches[key];\n }\n return null;\n }\n\n private bindEvent(eventName, callback) {\n const nameArr = eventName.split(':');\n if (nameArr[0] === 'window') {\n window.addEventListener(nameArr[1], callback);\n } else if (nameArr[0] === 'document') {\n document.addEventListener(nameArr[1], callback);\n } else {\n this.view.on(eventName, callback);\n }\n }\n\n private offEvent(eventName, callback) {\n const nameArr = eventName.split(':');\n if (nameArr[0] === 'window') {\n window.removeEventListener(nameArr[1], callback);\n } else if (nameArr[0] === 'document') {\n document.removeEventListener(nameArr[1], callback);\n } else {\n this.view.off(eventName, callback);\n }\n }\n}\n","import { clone, isPlainObject, lowerCase, mix } from '@antv/util';\nimport { View } from '../chart';\nimport { LooseObject } from '../interface';\nimport GrammarInteraction, { InteractionSteps } from './grammar-interaction';\nimport { InteractionConstructor } from './interaction';\n\nconst Interactions: LooseObject = {};\n\n/**\n * 根据交互行为名字获取对应的交互类\n * @param name 交互名字\n * @returns 交互类\n */\nexport function getInteraction(name: string): InteractionSteps | InteractionConstructor {\n return Interactions[lowerCase(name)];\n}\n\n/**\n * 注册交互行为\n * @param name 交互行为名字\n * @param interaction 交互类\n */\nexport function registerInteraction(name: string, interaction: InteractionSteps | InteractionConstructor) {\n Interactions[lowerCase(name)] = interaction;\n}\n\n/**\n * 创建交互实例\n * @param name 交互名\n * @param view 交互应用的 View 实例\n * @param cfg 交互行为配置\n */\nexport function createInteraction(name: string, view: View, cfg?: LooseObject) {\n const interaciton = getInteraction(name);\n if (!interaciton) {\n return null;\n }\n if (isPlainObject(interaciton)) {\n // 如果不 clone 则会多个 interaction 实例共享 step 的定义\n const steps = mix(clone(interaciton), cfg) as InteractionSteps;\n return new GrammarInteraction(view, steps);\n } else {\n const cls = interaciton as InteractionConstructor;\n return new cls(view, cfg);\n }\n}\n\nexport { default as Interaction } from './interaction';\nexport { Action, registerAction, getActionClass } from './action';\n","import { TOOLTIP_CSS_CONST } from '@antv/component';\nimport { ext } from '@antv/matrix-util';\nimport { deepMix } from '@antv/util';\nimport Element from '../../geometry/element';\nimport { LooseObject, StyleSheet } from '../../interface';\nimport { getAngle } from '../../util/graphics';\n\n/**\n * 根据样式表创建 axis 组件主题样式\n * @param styleSheet\n */\nfunction createAxisStyles(styleSheet: StyleSheet): LooseObject {\n return {\n title: {\n autoRotate: true,\n position: 'center', // start, center, end\n spacing: styleSheet.axisTitleSpacing,\n style: {\n fill: styleSheet.axisTitleTextFillColor,\n fontSize: styleSheet.axisTitleTextFontSize,\n lineHeight: styleSheet.axisTitleTextLineHeight,\n textBaseline: 'middle',\n fontFamily: styleSheet.fontFamily,\n },\n iconStyle: {\n fill: styleSheet.axisDescriptionIconFillColor\n }\n },\n label: {\n autoRotate: false,\n autoEllipsis: false,\n autoHide: { type: 'equidistance', cfg: { minGap: 6 } },\n offset: styleSheet.axisLabelOffset,\n style: {\n fill: styleSheet.axisLabelFillColor,\n fontSize: styleSheet.axisLabelFontSize,\n lineHeight: styleSheet.axisLabelLineHeight,\n fontFamily: styleSheet.fontFamily,\n },\n },\n line: {\n style: {\n lineWidth: styleSheet.axisLineBorder,\n stroke: styleSheet.axisLineBorderColor,\n },\n },\n grid: {\n line: {\n type: 'line',\n style: {\n stroke: styleSheet.axisGridBorderColor,\n lineWidth: styleSheet.axisGridBorder,\n lineDash: styleSheet.axisGridLineDash,\n },\n },\n alignTick: true,\n animate: true,\n },\n tickLine: {\n style: {\n lineWidth: styleSheet.axisTickLineBorder,\n stroke: styleSheet.axisTickLineBorderColor,\n },\n alignTick: true, // 默认刻度线和文本对齐\n length: styleSheet.axisTickLineLength,\n },\n subTickLine: null,\n animate: true,\n };\n}\n\n/**\n *\n * @param styleSheet\n */\n// export function\n\n/**\n * 根据样式表创建 legend 组件主题样式\n * @param styleSheet\n */\nfunction createLegendStyles(styleSheet: StyleSheet): LooseObject {\n return {\n title: null,\n marker: {\n symbol: 'circle',\n spacing: styleSheet.legendMarkerSpacing,\n style: {\n r: styleSheet.legendCircleMarkerSize,\n fill: styleSheet.legendMarkerColor,\n },\n },\n itemName: {\n spacing: 5, // 如果右边有 value 使用这个间距\n style: {\n fill: styleSheet.legendItemNameFillColor,\n fontFamily: styleSheet.fontFamily,\n fontSize: styleSheet.legendItemNameFontSize,\n lineHeight: styleSheet.legendItemNameLineHeight,\n fontWeight: styleSheet.legendItemNameFontWeight,\n textAlign: 'start',\n textBaseline: 'middle',\n },\n },\n itemStates: {\n active: {\n nameStyle: {\n opacity: 0.8,\n },\n },\n unchecked: {\n nameStyle: {\n fill: '#D8D8D8',\n },\n markerStyle: {\n fill: '#D8D8D8',\n stroke: '#D8D8D8',\n },\n },\n inactive: {\n nameStyle: {\n fill: '#D8D8D8',\n },\n markerStyle: {\n opacity: 0.2,\n },\n },\n },\n flipPage: true,\n pageNavigator: {\n marker: {\n style: {\n size: styleSheet.legendPageNavigatorMarkerSize,\n inactiveFill: styleSheet.legendPageNavigatorMarkerInactiveFillColor,\n inactiveOpacity: styleSheet.legendPageNavigatorMarkerInactiveFillOpacity,\n fill: styleSheet.legendPageNavigatorMarkerFillColor,\n opacity: styleSheet.legendPageNavigatorMarkerFillOpacity,\n },\n },\n text: {\n style: {\n fill: styleSheet.legendPageNavigatorTextFillColor,\n fontSize: styleSheet.legendPageNavigatorTextFontSize,\n },\n },\n },\n animate: false,\n maxItemWidth: 200,\n itemSpacing: styleSheet.legendItemSpacing,\n itemMarginBottom: styleSheet.legendItemMarginBottom,\n padding: styleSheet.legendPadding, // 图例组件自己的外边距\n };\n}\n\n/**\n * 根据主题样式表生成主题结构\n * @param styleSheet 主题样式表\n */\nexport function createThemeByStyleSheet(styleSheet: StyleSheet): LooseObject {\n const shapeStyles = {\n point: {\n default: {\n fill: styleSheet.pointFillColor,\n r: styleSheet.pointSize,\n stroke: styleSheet.pointBorderColor,\n lineWidth: styleSheet.pointBorder,\n fillOpacity: styleSheet.pointFillOpacity,\n },\n active: {\n stroke: styleSheet.pointActiveBorderColor,\n lineWidth: styleSheet.pointActiveBorder,\n },\n selected: {\n stroke: styleSheet.pointSelectedBorderColor,\n lineWidth: styleSheet.pointSelectedBorder,\n },\n inactive: {\n fillOpacity: styleSheet.pointInactiveFillOpacity,\n strokeOpacity: styleSheet.pointInactiveBorderOpacity,\n },\n },\n hollowPoint: {\n default: {\n fill: styleSheet.hollowPointFillColor,\n lineWidth: styleSheet.hollowPointBorder,\n stroke: styleSheet.hollowPointBorderColor,\n strokeOpacity: styleSheet.hollowPointBorderOpacity,\n r: styleSheet.hollowPointSize,\n },\n active: {\n stroke: styleSheet.hollowPointActiveBorderColor,\n strokeOpacity: styleSheet.hollowPointActiveBorderOpacity,\n },\n selected: {\n lineWidth: styleSheet.hollowPointSelectedBorder,\n stroke: styleSheet.hollowPointSelectedBorderColor,\n strokeOpacity: styleSheet.hollowPointSelectedBorderOpacity,\n },\n inactive: {\n strokeOpacity: styleSheet.hollowPointInactiveBorderOpacity,\n },\n },\n area: {\n default: {\n fill: styleSheet.areaFillColor,\n fillOpacity: styleSheet.areaFillOpacity,\n stroke: null,\n },\n active: {\n fillOpacity: styleSheet.areaActiveFillOpacity,\n },\n selected: {\n fillOpacity: styleSheet.areaSelectedFillOpacity,\n },\n inactive: {\n fillOpacity: styleSheet.areaInactiveFillOpacity,\n },\n },\n hollowArea: {\n default: {\n fill: null,\n stroke: styleSheet.hollowAreaBorderColor,\n lineWidth: styleSheet.hollowAreaBorder,\n strokeOpacity: styleSheet.hollowAreaBorderOpacity,\n },\n active: {\n fill: null,\n lineWidth: styleSheet.hollowAreaActiveBorder,\n },\n selected: {\n fill: null,\n lineWidth: styleSheet.hollowAreaSelectedBorder,\n },\n inactive: {\n strokeOpacity: styleSheet.hollowAreaInactiveBorderOpacity,\n },\n },\n interval: {\n default: {\n fill: styleSheet.intervalFillColor,\n fillOpacity: styleSheet.intervalFillOpacity,\n },\n active: {\n stroke: styleSheet.intervalActiveBorderColor,\n lineWidth: styleSheet.intervalActiveBorder,\n },\n selected: {\n stroke: styleSheet.intervalSelectedBorderColor,\n lineWidth: styleSheet.intervalSelectedBorder,\n },\n inactive: {\n fillOpacity: styleSheet.intervalInactiveFillOpacity,\n strokeOpacity: styleSheet.intervalInactiveBorderOpacity,\n },\n },\n hollowInterval: {\n default: {\n fill: styleSheet.hollowIntervalFillColor,\n stroke: styleSheet.hollowIntervalBorderColor,\n lineWidth: styleSheet.hollowIntervalBorder,\n strokeOpacity: styleSheet.hollowIntervalBorderOpacity,\n },\n active: {\n stroke: styleSheet.hollowIntervalActiveBorderColor,\n lineWidth: styleSheet.hollowIntervalActiveBorder,\n strokeOpacity: styleSheet.hollowIntervalActiveBorderOpacity,\n },\n selected: {\n stroke: styleSheet.hollowIntervalSelectedBorderColor,\n lineWidth: styleSheet.hollowIntervalSelectedBorder,\n strokeOpacity: styleSheet.hollowIntervalSelectedBorderOpacity,\n },\n inactive: {\n stroke: styleSheet.hollowIntervalInactiveBorderColor,\n lineWidth: styleSheet.hollowIntervalInactiveBorder,\n strokeOpacity: styleSheet.hollowIntervalInactiveBorderOpacity,\n },\n },\n line: {\n default: {\n stroke: styleSheet.lineBorderColor,\n lineWidth: styleSheet.lineBorder,\n strokeOpacity: styleSheet.lineBorderOpacity,\n fill: null,\n lineAppendWidth: 10,\n lineCap: 'round',\n lineJoin: 'round',\n },\n active: {\n lineWidth: styleSheet.lineActiveBorder,\n },\n selected: {\n lineWidth: styleSheet.lineSelectedBorder,\n },\n inactive: {\n strokeOpacity: styleSheet.lineInactiveBorderOpacity,\n },\n },\n };\n const axisStyles = createAxisStyles(styleSheet);\n const legendStyles = createLegendStyles(styleSheet);\n\n return {\n background: styleSheet.backgroundColor,\n defaultColor: styleSheet.brandColor,\n subColor: styleSheet.subColor,\n semanticRed: styleSheet.paletteSemanticRed,\n semanticGreen: styleSheet.paletteSemanticGreen,\n padding: 'auto',\n fontFamily: styleSheet.fontFamily,\n // 兼容Theme配置\n /** 一般柱状图宽度占比,geometry中已添加默认值,为了geometry配置生效默认值为null */\n columnWidthRatio: 1 / 2,\n /** 柱状图最大宽度 */\n maxColumnWidth: null,\n /** 柱状图最小宽度 */\n minColumnWidth: null,\n /** 玫瑰图占比 */\n roseWidthRatio: 0.9999999,\n /** 多层饼图/环图占比 */\n multiplePieWidthRatio: 1 / 1.3,\n colors10: styleSheet.paletteQualitative10,\n colors20: styleSheet.paletteQualitative20,\n sequenceColors: styleSheet.paletteSequence,\n shapes: {\n point: [\n 'hollow-circle',\n 'hollow-square',\n 'hollow-bowtie',\n 'hollow-diamond',\n 'hollow-hexagon',\n 'hollow-triangle',\n 'hollow-triangle-down',\n 'circle',\n 'square',\n 'bowtie',\n 'diamond',\n 'hexagon',\n 'triangle',\n 'triangle-down',\n 'cross',\n 'tick',\n 'plus',\n 'hyphen',\n 'line',\n ],\n line: ['line', 'dash', 'dot', 'smooth'],\n area: ['area', 'smooth', 'line', 'smooth-line'],\n interval: ['rect', 'hollow-rect', 'line', 'tick'],\n },\n sizes: [1, 10],\n geometries: {\n interval: {\n rect: {\n default: {\n style: shapeStyles.interval.default,\n },\n active: {\n style: shapeStyles.interval.active,\n },\n inactive: {\n style: shapeStyles.interval.inactive,\n },\n selected: {\n style: (element: Element) => {\n const coordinate = element.geometry.coordinate;\n if (coordinate.isPolar && coordinate.isTransposed) {\n const { startAngle, endAngle } = getAngle(element.getModel(), coordinate);\n const middleAngle = (startAngle + endAngle) / 2;\n const r = 7.5;\n const x = r * Math.cos(middleAngle);\n const y = r * Math.sin(middleAngle);\n return {\n matrix: ext.transform(null, [['t', x, y]]),\n };\n }\n return shapeStyles.interval.selected;\n },\n },\n },\n 'hollow-rect': {\n default: {\n style: shapeStyles.hollowInterval.default,\n },\n active: {\n style: shapeStyles.hollowInterval.active,\n },\n inactive: {\n style: shapeStyles.hollowInterval.inactive,\n },\n selected: {\n style: shapeStyles.hollowInterval.selected,\n },\n },\n line: {\n default: {\n style: shapeStyles.hollowInterval.default,\n },\n active: {\n style: shapeStyles.hollowInterval.active,\n },\n inactive: {\n style: shapeStyles.hollowInterval.inactive,\n },\n selected: {\n style: shapeStyles.hollowInterval.selected,\n },\n },\n tick: {\n default: {\n style: shapeStyles.hollowInterval.default,\n },\n active: {\n style: shapeStyles.hollowInterval.active,\n },\n inactive: {\n style: shapeStyles.hollowInterval.inactive,\n },\n selected: {\n style: shapeStyles.hollowInterval.selected,\n },\n },\n funnel: {\n default: {\n style: shapeStyles.interval.default,\n },\n active: {\n style: shapeStyles.interval.active,\n },\n inactive: {\n style: shapeStyles.interval.inactive,\n },\n selected: {\n style: shapeStyles.interval.selected,\n },\n },\n pyramid: {\n default: {\n style: shapeStyles.interval.default,\n },\n active: {\n style: shapeStyles.interval.active,\n },\n inactive: {\n style: shapeStyles.interval.inactive,\n },\n selected: {\n style: shapeStyles.interval.selected,\n },\n },\n },\n line: {\n line: {\n default: {\n style: shapeStyles.line.default,\n },\n active: {\n style: shapeStyles.line.active,\n },\n inactive: {\n style: shapeStyles.line.inactive,\n },\n selected: {\n style: shapeStyles.line.selected,\n },\n },\n dot: {\n default: {\n style: {\n ...shapeStyles.line.default,\n lineCap: null,\n lineDash: [1, 1],\n },\n },\n active: {\n style: {\n ...shapeStyles.line.active,\n lineCap: null,\n lineDash: [1, 1],\n },\n },\n inactive: {\n style: {\n ...shapeStyles.line.inactive,\n lineCap: null,\n lineDash: [1, 1],\n },\n },\n selected: {\n style: {\n ...shapeStyles.line.selected,\n lineCap: null,\n lineDash: [1, 1],\n },\n },\n },\n dash: {\n default: {\n style: {\n ...shapeStyles.line.default,\n lineCap: null,\n lineDash: [5.5, 1],\n },\n },\n active: {\n style: {\n ...shapeStyles.line.active,\n lineCap: null,\n lineDash: [5.5, 1],\n },\n },\n inactive: {\n style: {\n ...shapeStyles.line.inactive,\n lineCap: null,\n lineDash: [5.5, 1],\n },\n },\n selected: {\n style: {\n ...shapeStyles.line.selected,\n lineCap: null,\n lineDash: [5.5, 1],\n },\n },\n },\n smooth: {\n default: {\n style: shapeStyles.line.default,\n },\n active: {\n style: shapeStyles.line.active,\n },\n inactive: {\n style: shapeStyles.line.inactive,\n },\n selected: {\n style: shapeStyles.line.selected,\n },\n },\n hv: {\n default: {\n style: shapeStyles.line.default,\n },\n active: {\n style: shapeStyles.line.active,\n },\n inactive: {\n style: shapeStyles.line.inactive,\n },\n selected: {\n style: shapeStyles.line.selected,\n },\n },\n vh: {\n default: {\n style: shapeStyles.line.default,\n },\n active: {\n style: shapeStyles.line.active,\n },\n inactive: {\n style: shapeStyles.line.inactive,\n },\n selected: {\n style: shapeStyles.line.selected,\n },\n },\n hvh: {\n default: {\n style: shapeStyles.line.default,\n },\n active: {\n style: shapeStyles.line.active,\n },\n inactive: {\n style: shapeStyles.line.inactive,\n },\n selected: {\n style: shapeStyles.line.selected,\n },\n },\n vhv: {\n default: {\n style: shapeStyles.line.default,\n },\n active: {\n style: shapeStyles.line.active,\n },\n inactive: {\n style: shapeStyles.line.inactive,\n },\n selected: {\n style: shapeStyles.line.selected,\n },\n },\n },\n polygon: {\n polygon: {\n default: {\n style: shapeStyles.interval.default,\n },\n active: {\n style: shapeStyles.interval.active,\n },\n inactive: {\n style: shapeStyles.interval.inactive,\n },\n selected: {\n style: shapeStyles.interval.selected,\n },\n },\n },\n point: {\n circle: {\n default: {\n style: shapeStyles.point.default,\n },\n active: {\n style: shapeStyles.point.active,\n },\n inactive: {\n style: shapeStyles.point.inactive,\n },\n selected: {\n style: shapeStyles.point.selected,\n },\n },\n square: {\n default: {\n style: shapeStyles.point.default,\n },\n active: {\n style: shapeStyles.point.active,\n },\n inactive: {\n style: shapeStyles.point.inactive,\n },\n selected: {\n style: shapeStyles.point.selected,\n },\n },\n bowtie: {\n default: {\n style: shapeStyles.point.default,\n },\n active: {\n style: shapeStyles.point.active,\n },\n inactive: {\n style: shapeStyles.point.inactive,\n },\n selected: {\n style: shapeStyles.point.selected,\n },\n },\n diamond: {\n default: {\n style: shapeStyles.point.default,\n },\n active: {\n style: shapeStyles.point.active,\n },\n inactive: {\n style: shapeStyles.point.inactive,\n },\n selected: {\n style: shapeStyles.point.selected,\n },\n },\n hexagon: {\n default: {\n style: shapeStyles.point.default,\n },\n active: {\n style: shapeStyles.point.active,\n },\n inactive: {\n style: shapeStyles.point.inactive,\n },\n selected: {\n style: shapeStyles.point.selected,\n },\n },\n triangle: {\n default: {\n style: shapeStyles.point.default,\n },\n active: {\n style: shapeStyles.point.active,\n },\n inactive: {\n style: shapeStyles.point.inactive,\n },\n selected: {\n style: shapeStyles.point.selected,\n },\n },\n 'triangle-down': {\n default: {\n style: shapeStyles.point.default,\n },\n active: {\n style: shapeStyles.point.active,\n },\n inactive: {\n style: shapeStyles.point.inactive,\n },\n selected: {\n style: shapeStyles.point.selected,\n },\n },\n 'hollow-circle': {\n default: {\n style: shapeStyles.hollowPoint.default,\n },\n active: {\n style: shapeStyles.hollowPoint.active,\n },\n inactive: {\n style: shapeStyles.hollowPoint.inactive,\n },\n selected: {\n style: shapeStyles.hollowPoint.selected,\n },\n },\n 'hollow-square': {\n default: {\n style: shapeStyles.hollowPoint.default,\n },\n active: {\n style: shapeStyles.hollowPoint.active,\n },\n inactive: {\n style: shapeStyles.hollowPoint.inactive,\n },\n selected: {\n style: shapeStyles.hollowPoint.selected,\n },\n },\n 'hollow-bowtie': {\n default: {\n style: shapeStyles.hollowPoint.default,\n },\n active: {\n style: shapeStyles.hollowPoint.active,\n },\n inactive: {\n style: shapeStyles.hollowPoint.inactive,\n },\n selected: {\n style: shapeStyles.hollowPoint.selected,\n },\n },\n 'hollow-diamond': {\n default: {\n style: shapeStyles.hollowPoint.default,\n },\n active: {\n style: shapeStyles.hollowPoint.active,\n },\n inactive: {\n style: shapeStyles.hollowPoint.inactive,\n },\n selected: {\n style: shapeStyles.hollowPoint.selected,\n },\n },\n 'hollow-hexagon': {\n default: {\n style: shapeStyles.hollowPoint.default,\n },\n active: {\n style: shapeStyles.hollowPoint.active,\n },\n inactive: {\n style: shapeStyles.hollowPoint.inactive,\n },\n selected: {\n style: shapeStyles.hollowPoint.selected,\n },\n },\n 'hollow-triangle': {\n default: {\n style: shapeStyles.hollowPoint.default,\n },\n active: {\n style: shapeStyles.hollowPoint.active,\n },\n inactive: {\n style: shapeStyles.hollowPoint.inactive,\n },\n selected: {\n style: shapeStyles.hollowPoint.selected,\n },\n },\n 'hollow-triangle-down': {\n default: {\n style: shapeStyles.hollowPoint.default,\n },\n active: {\n style: shapeStyles.hollowPoint.active,\n },\n inactive: {\n style: shapeStyles.hollowPoint.inactive,\n },\n selected: {\n style: shapeStyles.hollowPoint.selected,\n },\n },\n cross: {\n default: {\n style: shapeStyles.hollowPoint.default,\n },\n active: {\n style: shapeStyles.hollowPoint.active,\n },\n inactive: {\n style: shapeStyles.hollowPoint.inactive,\n },\n selected: {\n style: shapeStyles.hollowPoint.selected,\n },\n },\n tick: {\n default: {\n style: shapeStyles.hollowPoint.default,\n },\n active: {\n style: shapeStyles.hollowPoint.active,\n },\n inactive: {\n style: shapeStyles.hollowPoint.inactive,\n },\n selected: {\n style: shapeStyles.hollowPoint.selected,\n },\n },\n plus: {\n default: {\n style: shapeStyles.hollowPoint.default,\n },\n active: {\n style: shapeStyles.hollowPoint.active,\n },\n inactive: {\n style: shapeStyles.hollowPoint.inactive,\n },\n selected: {\n style: shapeStyles.hollowPoint.selected,\n },\n },\n hyphen: {\n default: {\n style: shapeStyles.hollowPoint.default,\n },\n active: {\n style: shapeStyles.hollowPoint.active,\n },\n inactive: {\n style: shapeStyles.hollowPoint.inactive,\n },\n selected: {\n style: shapeStyles.hollowPoint.selected,\n },\n },\n line: {\n default: {\n style: shapeStyles.hollowPoint.default,\n },\n active: {\n style: shapeStyles.hollowPoint.active,\n },\n inactive: {\n style: shapeStyles.hollowPoint.inactive,\n },\n selected: {\n style: shapeStyles.hollowPoint.selected,\n },\n },\n },\n area: {\n area: {\n default: {\n style: shapeStyles.area.default,\n },\n active: {\n style: shapeStyles.area.active,\n },\n inactive: {\n style: shapeStyles.area.inactive,\n },\n selected: {\n style: shapeStyles.area.selected,\n },\n },\n smooth: {\n default: {\n style: shapeStyles.area.default,\n },\n active: {\n style: shapeStyles.area.active,\n },\n inactive: {\n style: shapeStyles.area.inactive,\n },\n selected: {\n style: shapeStyles.area.selected,\n },\n },\n line: {\n default: {\n style: shapeStyles.hollowArea.default,\n },\n active: {\n style: shapeStyles.hollowArea.active,\n },\n inactive: {\n style: shapeStyles.hollowArea.inactive,\n },\n selected: {\n style: shapeStyles.hollowArea.selected,\n },\n },\n 'smooth-line': {\n default: {\n style: shapeStyles.hollowArea.default,\n },\n active: {\n style: shapeStyles.hollowArea.active,\n },\n inactive: {\n style: shapeStyles.hollowArea.inactive,\n },\n selected: {\n style: shapeStyles.hollowArea.selected,\n },\n },\n },\n schema: {\n candle: {\n default: {\n style: shapeStyles.hollowInterval.default,\n },\n active: {\n style: shapeStyles.hollowInterval.active,\n },\n inactive: {\n style: shapeStyles.hollowInterval.inactive,\n },\n selected: {\n style: shapeStyles.hollowInterval.selected,\n },\n },\n box: {\n default: {\n style: shapeStyles.hollowInterval.default,\n },\n active: {\n style: shapeStyles.hollowInterval.active,\n },\n inactive: {\n style: shapeStyles.hollowInterval.inactive,\n },\n selected: {\n style: shapeStyles.hollowInterval.selected,\n },\n },\n },\n edge: {\n line: {\n default: {\n style: shapeStyles.line.default,\n },\n active: {\n style: shapeStyles.line.active,\n },\n inactive: {\n style: shapeStyles.line.inactive,\n },\n selected: {\n style: shapeStyles.line.selected,\n },\n },\n vhv: {\n default: {\n style: shapeStyles.line.default,\n },\n active: {\n style: shapeStyles.line.active,\n },\n inactive: {\n style: shapeStyles.line.inactive,\n },\n selected: {\n style: shapeStyles.line.selected,\n },\n },\n smooth: {\n default: {\n style: shapeStyles.line.default,\n },\n active: {\n style: shapeStyles.line.active,\n },\n inactive: {\n style: shapeStyles.line.inactive,\n },\n selected: {\n style: shapeStyles.line.selected,\n },\n },\n arc: {\n default: {\n style: shapeStyles.line.default,\n },\n active: {\n style: shapeStyles.line.active,\n },\n inactive: {\n style: shapeStyles.line.inactive,\n },\n selected: {\n style: shapeStyles.line.selected,\n },\n },\n },\n violin: {\n violin: {\n default: {\n style: shapeStyles.line.default,\n },\n active: {\n style: shapeStyles.line.active,\n },\n inactive: {\n style: shapeStyles.line.inactive,\n },\n selected: {\n style: shapeStyles.line.selected,\n },\n },\n smooth: {\n default: {\n style: shapeStyles.line.default,\n },\n active: {\n style: shapeStyles.line.active,\n },\n inactive: {\n style: shapeStyles.line.inactive,\n },\n selected: {\n style: shapeStyles.line.selected,\n },\n },\n hollow: {\n default: {\n style: shapeStyles.hollowArea.default,\n },\n active: {\n style: shapeStyles.hollowArea.active,\n },\n inactive: {\n style: shapeStyles.hollowArea.inactive,\n },\n selected: {\n style: shapeStyles.hollowArea.selected,\n },\n },\n 'hollow-smooth': {\n default: {\n style: shapeStyles.hollowArea.default,\n },\n active: {\n style: shapeStyles.hollowArea.active,\n },\n inactive: {\n style: shapeStyles.hollowArea.inactive,\n },\n selected: {\n style: shapeStyles.hollowArea.selected,\n },\n },\n },\n },\n components: {\n axis: {\n common: axisStyles,\n top: {\n position: 'top',\n grid: null,\n title: null,\n verticalLimitLength: 1 / 2,\n },\n bottom: {\n position: 'bottom',\n grid: null,\n title: null,\n verticalLimitLength: 1 / 2,\n },\n left: {\n position: 'left',\n title: null,\n line: null,\n tickLine: null,\n verticalLimitLength: 1 / 3,\n },\n right: {\n position: 'right',\n title: null,\n line: null,\n tickLine: null,\n verticalLimitLength: 1 / 3,\n },\n circle: {\n title: null,\n grid: deepMix({}, axisStyles.grid, { line: { type: 'line' } }),\n },\n radius: {\n title: null,\n grid: deepMix({}, axisStyles.grid, { line: { type: 'circle' } }),\n },\n },\n legend: {\n common: legendStyles,\n right: {\n layout: 'vertical',\n padding: styleSheet.legendVerticalPadding,\n },\n left: {\n layout: 'vertical',\n padding: styleSheet.legendVerticalPadding,\n },\n top: {\n layout: 'horizontal',\n padding: styleSheet.legendHorizontalPadding,\n },\n bottom: {\n layout: 'horizontal',\n padding: styleSheet.legendHorizontalPadding,\n },\n continuous: {\n title: null,\n background: null,\n track: {},\n rail: {\n type: 'color',\n size: styleSheet.sliderRailHeight,\n defaultLength: styleSheet.sliderRailWidth,\n style: {\n fill: styleSheet.sliderRailFillColor,\n stroke: styleSheet.sliderRailBorderColor,\n lineWidth: styleSheet.sliderRailBorder,\n },\n },\n label: {\n align: 'rail',\n spacing: 4, // 文本和 rail 的间距\n formatter: null,\n style: {\n fill: styleSheet.sliderLabelTextFillColor,\n fontSize: styleSheet.sliderLabelTextFontSize,\n lineHeight: styleSheet.sliderLabelTextLineHeight,\n textBaseline: 'middle',\n fontFamily: styleSheet.fontFamily,\n },\n },\n handler: {\n size: styleSheet.sliderHandlerWidth,\n style: {\n fill: styleSheet.sliderHandlerFillColor,\n stroke: styleSheet.sliderHandlerBorderColor,\n },\n },\n slidable: true,\n padding: legendStyles.padding,\n },\n },\n tooltip: {\n showContent: true,\n follow: true,\n showCrosshairs: false,\n showMarkers: true,\n shared: false,\n enterable: false,\n position: 'auto',\n marker: {\n symbol: 'circle',\n stroke: '#fff',\n shadowBlur: 10,\n shadowOffsetX: 0,\n shadowOffsetY: 0,\n shadowColor: 'rgba(0,0,0,0.09)',\n lineWidth: 2,\n r: 4,\n },\n crosshairs: {\n line: {\n style: {\n stroke: styleSheet.tooltipCrosshairsBorderColor,\n lineWidth: styleSheet.tooltipCrosshairsBorder,\n },\n },\n text: null,\n textBackground: {\n padding: 2,\n style: {\n fill: 'rgba(0, 0, 0, 0.25)',\n lineWidth: 0,\n stroke: null,\n },\n },\n follow: false,\n },\n // tooltip dom 样式\n domStyles: {\n [`${TOOLTIP_CSS_CONST.CONTAINER_CLASS}`]: {\n position: 'absolute',\n visibility: 'hidden',\n zIndex: 8,\n transition: 'left 0.4s cubic-bezier(0.23, 1, 0.32, 1) 0s, top 0.4s cubic-bezier(0.23, 1, 0.32, 1) 0s',\n backgroundColor: styleSheet.tooltipContainerFillColor,\n opacity: styleSheet.tooltipContainerFillOpacity,\n boxShadow: styleSheet.tooltipContainerShadow,\n borderRadius: `${styleSheet.tooltipContainerBorderRadius}px`,\n color: styleSheet.tooltipTextFillColor,\n fontSize: `${styleSheet.tooltipTextFontSize}px`,\n fontFamily: styleSheet.fontFamily,\n lineHeight: `${styleSheet.tooltipTextLineHeight}px`,\n padding: '0 12px 0 12px',\n },\n [`${TOOLTIP_CSS_CONST.TITLE_CLASS}`]: {\n marginBottom: '12px',\n marginTop: '12px',\n },\n [`${TOOLTIP_CSS_CONST.LIST_CLASS}`]: {\n margin: 0,\n listStyleType: 'none',\n padding: 0,\n },\n [`${TOOLTIP_CSS_CONST.LIST_ITEM_CLASS}`]: {\n listStyleType: 'none',\n padding: 0,\n marginBottom: '12px',\n marginTop: '12px',\n marginLeft: 0,\n marginRight: 0,\n },\n [`${TOOLTIP_CSS_CONST.MARKER_CLASS}`]: {\n width: '8px',\n height: '8px',\n borderRadius: '50%',\n display: 'inline-block',\n marginRight: '8px',\n },\n [`${TOOLTIP_CSS_CONST.VALUE_CLASS}`]: {\n display: 'inline-block',\n float: 'right',\n marginLeft: '30px',\n },\n },\n },\n annotation: {\n arc: {\n style: {\n stroke: styleSheet.annotationArcBorderColor,\n lineWidth: styleSheet.annotationArcBorder,\n },\n animate: true,\n },\n line: {\n style: {\n stroke: styleSheet.annotationLineBorderColor,\n lineDash: styleSheet.annotationLineDash,\n lineWidth: styleSheet.annotationLineBorder,\n },\n text: {\n position: 'start',\n autoRotate: true,\n style: {\n fill: styleSheet.annotationTextFillColor,\n stroke: styleSheet.annotationTextBorderColor,\n lineWidth: styleSheet.annotationTextBorder,\n fontSize: styleSheet.annotationTextFontSize,\n textAlign: 'start',\n fontFamily: styleSheet.fontFamily,\n textBaseline: 'bottom',\n },\n },\n animate: true,\n },\n text: {\n style: {\n fill: styleSheet.annotationTextFillColor,\n stroke: styleSheet.annotationTextBorderColor,\n lineWidth: styleSheet.annotationTextBorder,\n fontSize: styleSheet.annotationTextFontSize,\n textBaseline: 'middle',\n textAlign: 'start',\n fontFamily: styleSheet.fontFamily,\n },\n animate: true,\n },\n region: {\n top: false,\n style: {\n lineWidth: styleSheet.annotationRegionBorder,\n stroke: styleSheet.annotationRegionBorderColor,\n fill: styleSheet.annotationRegionFillColor,\n fillOpacity: styleSheet.annotationRegionFillOpacity,\n }, // 辅助框的图形样式属性\n animate: true,\n },\n image: {\n top: false,\n animate: true,\n },\n dataMarker: {\n top: true,\n point: {\n style: {\n r: 3,\n stroke: styleSheet.brandColor,\n lineWidth: 2,\n },\n },\n line: {\n style: {\n stroke: styleSheet.annotationLineBorderColor,\n lineWidth: styleSheet.annotationLineBorder,\n },\n length: styleSheet.annotationDataMarkerLineLength,\n },\n text: {\n style: {\n textAlign: 'start',\n fill: styleSheet.annotationTextFillColor,\n stroke: styleSheet.annotationTextBorderColor,\n lineWidth: styleSheet.annotationTextBorder,\n fontSize: styleSheet.annotationTextFontSize,\n fontFamily: styleSheet.fontFamily,\n },\n },\n direction: 'upward',\n autoAdjust: true,\n animate: true,\n },\n dataRegion: {\n style: {\n region: {\n fill: styleSheet.annotationRegionFillColor,\n fillOpacity: styleSheet.annotationRegionFillOpacity,\n },\n text: {\n textAlign: 'center',\n textBaseline: 'bottom',\n fill: styleSheet.annotationTextFillColor,\n stroke: styleSheet.annotationTextBorderColor,\n lineWidth: styleSheet.annotationTextBorder,\n fontSize: styleSheet.annotationTextFontSize,\n fontFamily: styleSheet.fontFamily,\n },\n },\n animate: true,\n },\n },\n slider: {\n common: {\n padding: [8, 8, 8, 8],\n backgroundStyle: {\n fill: styleSheet.cSliderBackgroundFillColor,\n opacity: styleSheet.cSliderBackgroundFillOpacity,\n },\n foregroundStyle: {\n fill: styleSheet.cSliderForegroundFillColor,\n opacity: styleSheet.cSliderForegroundFillOpacity,\n },\n handlerStyle: {\n width: styleSheet.cSliderHandlerWidth,\n height: styleSheet.cSliderHandlerHeight,\n fill: styleSheet.cSliderHandlerFillColor,\n opacity: styleSheet.cSliderHandlerFillOpacity,\n stroke: styleSheet.cSliderHandlerBorderColor,\n lineWidth: styleSheet.cSliderHandlerBorder,\n radius: styleSheet.cSliderHandlerBorderRadius,\n // 高亮的颜色\n highLightFill: styleSheet.cSliderHandlerHighlightFillColor,\n },\n textStyle: {\n fill: styleSheet.cSliderTextFillColor,\n opacity: styleSheet.cSliderTextFillOpacity,\n fontSize: styleSheet.cSliderTextFontSize,\n lineHeight: styleSheet.cSliderTextLineHeight,\n fontWeight: styleSheet.cSliderTextFontWeight,\n stroke: styleSheet.cSliderTextBorderColor,\n lineWidth: styleSheet.cSliderTextBorder,\n },\n },\n },\n scrollbar: {\n common: {\n padding: [8, 8, 8, 8],\n },\n default: {\n style: {\n trackColor: styleSheet.scrollbarTrackFillColor,\n thumbColor: styleSheet.scrollbarThumbFillColor,\n },\n },\n hover: {\n style: {\n thumbColor: styleSheet.scrollbarThumbHighlightFillColor,\n },\n },\n },\n },\n labels: {\n offset: 12,\n style: {\n fill: styleSheet.labelFillColor,\n fontSize: styleSheet.labelFontSize,\n fontFamily: styleSheet.fontFamily,\n stroke: styleSheet.labelBorderColor,\n lineWidth: styleSheet.labelBorder,\n },\n fillColorDark: styleSheet.labelFillColorDark,\n fillColorLight: styleSheet.labelFillColorLight,\n autoRotate: true,\n },\n innerLabels: {\n style: {\n fill: styleSheet.innerLabelFillColor,\n fontSize: styleSheet.innerLabelFontSize,\n fontFamily: styleSheet.fontFamily,\n stroke: styleSheet.innerLabelBorderColor,\n lineWidth: styleSheet.innerLabelBorder,\n },\n autoRotate: true,\n },\n overflowLabels: {\n style: {\n fill: styleSheet.overflowLabelFillColor,\n fontSize: styleSheet.overflowLabelFontSize,\n fontFamily: styleSheet.fontFamily,\n stroke: styleSheet.overflowLabelBorderColor,\n lineWidth: styleSheet.overflowLabelBorder,\n },\n },\n pieLabels: {\n labelHeight: 14,\n offset: 10,\n labelLine: {\n style: {\n lineWidth: styleSheet.labelLineBorder,\n },\n },\n autoRotate: true,\n },\n };\n}\n","import { StyleSheetCfg } from '../../interface';\n\nconst BLACK_COLORS = {\n 100: '#000',\n 95: '#0D0D0D',\n 85: '#262626',\n 65: '#595959',\n 45: '#8C8C8C',\n 25: '#BFBFBF',\n 15: '#D9D9D9',\n 6: '#F0F0F0',\n};\n\nconst WHITE_COLORS = {\n 100: '#FFFFFF',\n 95: '#F2F2F2',\n 85: '#D9D9D9',\n 65: '#A6A6A6',\n 45: '#737373',\n 25: '#404040',\n 15: '#262626',\n 6: '#0F0F0F',\n};\n\nconst QUALITATIVE_10 = [\n '#5B8FF9',\n '#5AD8A6',\n '#5D7092',\n '#F6BD16',\n '#6F5EF9',\n '#6DC8EC',\n '#945FB9',\n '#FF9845',\n '#1E9493',\n '#FF99C3',\n];\n\nconst QUALITATIVE_20 = [\n '#5B8FF9',\n '#CDDDFD',\n '#5AD8A6',\n '#CDF3E4',\n '#5D7092',\n '#CED4DE',\n '#F6BD16',\n '#FCEBB9',\n '#6F5EF9',\n '#D3CEFD',\n '#6DC8EC',\n '#D3EEF9',\n '#945FB9',\n '#DECFEA',\n '#FF9845',\n '#FFE0C7',\n '#1E9493',\n '#BBDEDE',\n '#FF99C3',\n '#FFE0ED',\n];\n\n/** 单色顺序色板 */\nconst SINGLE_SEQUENCE = [\n '#B8E1FF',\n '#9AC5FF',\n '#7DAAFF',\n '#5B8FF9',\n '#3D76DD',\n '#085EC0',\n '#0047A5',\n '#00318A',\n '#001D70',\n];\n\nexport const createLightStyleSheet = (cfg: StyleSheetCfg = {}) => {\n const { paletteQualitative10 = QUALITATIVE_10, paletteQualitative20 = QUALITATIVE_20 } = cfg;\n const { brandColor = paletteQualitative10[0] } = cfg;\n\n const token = {\n /** 图表背景色 */\n backgroundColor: 'transparent',\n /** 主题色 */\n brandColor,\n /** 图表辅助色 */\n subColor: 'rgba(0,0,0,0.05)',\n /** 分类色板 1,在数据量小于等于 10 时使用 */\n paletteQualitative10,\n /** 分类色板 2,在数据量大于 10 时使用 */\n paletteQualitative20,\n /** 语义色 */\n paletteSemanticRed: '#F4664A',\n /** 语义色 */\n paletteSemanticGreen: '#30BF78',\n /** 语义色 */\n paletteSemanticYellow: '#FAAD14',\n /** (单色)顺序色板 */\n paletteSequence: SINGLE_SEQUENCE,\n /** 字体 */\n fontFamily: `\"Segoe UI\", Roboto, \"Helvetica Neue\", Arial,\n \"Noto Sans\", sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\",\n \"Noto Color Emoji\"`,\n\n // -------------------- 坐标轴 --------------------\n /** 坐标轴线颜色 */\n axisLineBorderColor: BLACK_COLORS[25],\n /** 坐标轴线粗细 */\n axisLineBorder: 1,\n /** 坐标轴线 lineDash 设置 */\n axisLineDash: null,\n\n /** 坐标轴标题颜色 */\n axisTitleTextFillColor: BLACK_COLORS[65],\n /** 坐标轴标题文本字体大小 */\n axisTitleTextFontSize: 12,\n /** 坐标轴标题文本行高 */\n axisTitleTextLineHeight: 12,\n /** 坐标轴标题文本字体粗细 */\n axisTitleTextFontWeight: 'normal',\n /** 坐标轴标题距离坐标轴文本的间距 */\n axisTitleSpacing: 12,\n /** 坐标轴标题详细说明icon颜色 */\n axisDescriptionIconFillColor: WHITE_COLORS[85],\n\n /** 坐标轴刻度线颜色 */\n axisTickLineBorderColor: BLACK_COLORS[25],\n /** 坐标轴刻度线长度 */\n axisTickLineLength: 4,\n /** 坐标轴刻度线粗细 */\n axisTickLineBorder: 1,\n\n /** 坐标轴次刻度线颜色 */\n axisSubTickLineBorderColor: BLACK_COLORS[15],\n /** 坐标轴次刻度线长度 */\n axisSubTickLineLength: 2,\n /** 坐标轴次刻度线粗细 */\n axisSubTickLineBorder: 1,\n\n /** 坐标轴刻度文本颜色 */\n axisLabelFillColor: BLACK_COLORS[45],\n /** 坐标轴刻度文本字体大小 */\n axisLabelFontSize: 12,\n /** 坐标轴刻度文本行高 */\n axisLabelLineHeight: 12,\n /** 坐标轴刻度文本字体粗细 */\n axisLabelFontWeight: 'normal',\n /** 坐标轴刻度文本距离坐标轴线的间距 */\n axisLabelOffset: 8,\n\n /** 坐标轴网格线颜色 */\n axisGridBorderColor: BLACK_COLORS[15],\n /** 坐标轴网格线粗细 */\n axisGridBorder: 1,\n /** 坐标轴网格线虚线设置 */\n axisGridLineDash: null,\n\n // -------------------- 图例 --------------------\n /** 图例标题颜色 */\n legendTitleTextFillColor: BLACK_COLORS[45],\n /** 图例标题文本字体大小 */\n legendTitleTextFontSize: 12,\n /** 图例标题文本行高 */\n legendTitleTextLineHeight: 21,\n /** 图例标题文本字体粗细 */\n legendTitleTextFontWeight: 'normal',\n\n /** 图例 marker 颜色 */\n legendMarkerColor: brandColor,\n /** 图例 marker 距离图例文本的间距 */\n legendMarkerSpacing: 8,\n /** 图例 marker 默认半径大小 */\n legendMarkerSize: 4,\n /** 图例 'circle' marker 半径 */\n legendCircleMarkerSize: 4,\n /** 图例 'square' marker 半径 */\n legendSquareMarkerSize: 4,\n /** 图例 'line' marker 半径 */\n legendLineMarkerSize: 5,\n\n /** 图例项文本颜色 */\n legendItemNameFillColor: BLACK_COLORS[65],\n /** 图例项文本字体大小 */\n legendItemNameFontSize: 12,\n /** 图例项文本行高 */\n legendItemNameLineHeight: 12,\n /** 图例项粗细 */\n legendItemNameFontWeight: 'normal',\n /** 图例项之间的水平间距 */\n legendItemSpacing: 24,\n /** 图例项垂直方向的间隔 */\n legendItemMarginBottom: 12,\n /** 图例与图表绘图区域的偏移距离 */\n legendPadding: [8, 8, 8, 8],\n /** 水平布局的图例与绘图区域偏移距离 */\n legendHorizontalPadding: [8, 0, 8, 0],\n /** 垂直布局的图例与绘图区域偏移距离 */\n legendVerticalPadding: [0, 8, 0, 8],\n\n // 图例分页器\n /** 图例分页器 marker 大小 */\n legendPageNavigatorMarkerSize: 12,\n /** 图例分页器 marker 非激活状态填充色 */\n legendPageNavigatorMarkerInactiveFillColor: BLACK_COLORS[100],\n /** 图例分页器 marker 非激活状态填充色透明度 */\n legendPageNavigatorMarkerInactiveFillOpacity: 0.45,\n /** 图例分页器 marker 填充色 */\n legendPageNavigatorMarkerFillColor: BLACK_COLORS[100],\n /** 图例分页器 marker 填充色透明度 */\n legendPageNavigatorMarkerFillOpacity: 1,\n /** 图例分页器文本颜色 */\n legendPageNavigatorTextFillColor: BLACK_COLORS[45],\n /** 图例分页器文本字体大小 */\n legendPageNavigatorTextFontSize: 12,\n\n /** 连续图例滑块填充色 */\n sliderRailFillColor: BLACK_COLORS[15],\n /** 连续图例滑块边框粗细 */\n sliderRailBorder: 0,\n /** 连续图例滑块边框颜色 */\n sliderRailBorderColor: null,\n /** 连续图例滑块宽度 */\n sliderRailWidth: 100,\n /** 连续图例滑块高度 */\n sliderRailHeight: 12,\n\n /** 连续图例文本颜色 */\n sliderLabelTextFillColor: BLACK_COLORS[45],\n /** 连续图例文本字体大小 */\n sliderLabelTextFontSize: 12,\n /** 连续图例文本行高 */\n sliderLabelTextLineHeight: 12,\n /** 连续图例文本字体粗细 */\n sliderLabelTextFontWeight: 'normal',\n\n /** 连续图例滑块颜色 */\n sliderHandlerFillColor: BLACK_COLORS[6],\n /** 连续图例滑块宽度 */\n sliderHandlerWidth: 10,\n /** 连续图例滑块高度 */\n sliderHandlerHeight: 14,\n /** 连续图例滑块边框粗细 */\n sliderHandlerBorder: 1,\n /** 连续图例滑块边框颜色 */\n sliderHandlerBorderColor: BLACK_COLORS[25],\n\n // -------------------- Annotation,图形标注 --------------------\n /** arc 图形标注描边颜色 */\n annotationArcBorderColor: BLACK_COLORS[15],\n /** arc 图形标注粗细 */\n annotationArcBorder: 1,\n\n /** line 图形标注颜色 */\n annotationLineBorderColor: BLACK_COLORS[25],\n /** line 图形标注粗细 */\n annotationLineBorder: 1,\n /** lube 图形标注的虚线间隔 */\n annotationLineDash: null,\n\n /** text 图形标注文本颜色 */\n annotationTextFillColor: BLACK_COLORS[65],\n /** text 图形标注文本字体大小 */\n annotationTextFontSize: 12,\n /** text 图形标注文本行高 */\n annotationTextLineHeight: 12,\n /** text 图形标注文本字体粗细 */\n annotationTextFontWeight: 'normal',\n /** text 图形标注文本边框颜色 */\n annotationTextBorderColor: null,\n /** text 图形标注文本边框粗细 */\n annotationTextBorder: 0,\n\n /** region 图形标注填充颜色 */\n annotationRegionFillColor: BLACK_COLORS[100],\n /** region 图形标注填充颜色透明色 */\n annotationRegionFillOpacity: 0.06,\n /** region 图形标注描边粗细 */\n annotationRegionBorder: 0,\n /** region 图形标注描边颜色 */\n annotationRegionBorderColor: null,\n\n /** dataMarker 图形标注线的长度 */\n annotationDataMarkerLineLength: 16,\n\n // -------------------- Tooltip --------------------\n /** tooltip crosshairs 辅助线颜色 */\n tooltipCrosshairsBorderColor: BLACK_COLORS[25],\n /** tooltip crosshairs 辅助线粗细 */\n tooltipCrosshairsBorder: 1,\n /** tooltip crosshairs 辅助线虚线间隔 */\n tooltipCrosshairsLineDash: null,\n\n /** tooltip 内容框背景色 */\n tooltipContainerFillColor: 'rgb(255, 255, 255)',\n tooltipContainerFillOpacity: 0.95,\n /** tooltip 内容框阴影 */\n tooltipContainerShadow: '0px 0px 10px #aeaeae',\n /** tooltip 内容框圆角 */\n tooltipContainerBorderRadius: 3,\n\n /** tooltip 文本颜色 */\n tooltipTextFillColor: BLACK_COLORS[65],\n /** tooltip 文本字体大小 */\n tooltipTextFontSize: 12,\n /** tooltip 文本行高 */\n tooltipTextLineHeight: 12,\n /** tooltip 文本字体粗细 */\n tooltipTextFontWeight: 'bold',\n\n // -------------------- Geometry labels --------------------\n /** Geometry label 文本颜色 */\n labelFillColor: BLACK_COLORS[65],\n labelFillColorDark: '#2c3542',\n labelFillColorLight: '#ffffff',\n /** Geometry label 文本字体大小 */\n labelFontSize: 12,\n /** Geometry label 文本行高 */\n labelLineHeight: 12,\n /** Geometry label 文本字体粗细 */\n labelFontWeight: 'normal',\n /** Geometry label 文本描边颜色 */\n labelBorderColor: null,\n /** Geometry label 文本描边粗细 */\n labelBorder: 0,\n\n /** Geometry innerLabel 文本颜色 */\n innerLabelFillColor: WHITE_COLORS[100],\n /** Geometry innerLabel 文本字体大小 */\n innerLabelFontSize: 12,\n /** Geometry innerLabel 文本行高 */\n innerLabelLineHeight: 12,\n /** Geometry innerLabel 文本字体粗细 */\n innerLabelFontWeight: 'normal',\n /** Geometry innerLabel 文本描边颜色 */\n innerLabelBorderColor: null,\n /** Geometry innerLabel 文本描边粗细 */\n innerLabelBorder: 0,\n\n /** Geometry overflowLabel 文本颜色 */\n overflowLabelFillColor: BLACK_COLORS[65],\n /** Geometry overflowLabel 文本字体大小 */\n overflowLabelFontSize: 12,\n /** Geometry overflowLabel 文本行高 */\n overflowLabelLineHeight: 12,\n /** Geometry overflowLabel 文本字体粗细 */\n overflowLabelFontWeight: 'normal',\n /** Geometry overflowLabel 文本描边颜色 */\n overflowLabelBorderColor: WHITE_COLORS[100],\n /** Geometry overflowLabel 文本描边粗细 */\n overflowLabelBorder: 1,\n\n /** Geometry label 文本连接线粗细 */\n labelLineBorder: 1,\n /** Geometry label 文本连接线颜色 */\n labelLineBorderColor: BLACK_COLORS[25],\n\n // -------------------- Slider 组件样式--------------------\n /** slider 滑道高度 */\n cSliderRailHieght: 16,\n /** slider 滑道背景色 */\n cSliderBackgroundFillColor: '#416180',\n /** slider 滑道背景色透明度 */\n cSliderBackgroundFillOpacity: 0.05,\n /** slider 滑道前景色 */\n cSliderForegroundFillColor: '#5B8FF9',\n /** slider 滑道前景色透明度 */\n cSliderForegroundFillOpacity: 0.15,\n // slider handlerStyle 手柄样式\n /** slider 手柄高度 */\n cSliderHandlerHeight: 24,\n /** Slider 手柄宽度 */\n cSliderHandlerWidth: 10,\n /** Slider 手柄背景色 */\n cSliderHandlerFillColor: '#F7F7F7',\n /** Slider 手柄背景色透明度 */\n cSliderHandlerFillOpacity: 1,\n /** Slider 手柄高亮背景色 */\n cSliderHandlerHighlightFillColor: '#FFF',\n /** Slider 手柄边框色 */\n cSliderHandlerBorderColor: '#BFBFBF',\n /** Slider 手柄边框粗细 */\n cSliderHandlerBorder: 1,\n /** Slider 手柄边框圆角 */\n cSliderHandlerBorderRadius: 2,\n // slider textStyle 字体标签样式\n /** Slider 字体标签颜色 */\n cSliderTextFillColor: '#000',\n /** Slider 字体标签透明度 */\n cSliderTextFillOpacity: 0.45,\n /** Slider 字体标签大小 */\n cSliderTextFontSize: 12,\n /** Slider 字体标签行高 */\n cSliderTextLineHeight: 12,\n /** Slider 字体标签字重 */\n cSliderTextFontWeight: 'normal',\n /** Slider 字体标签描边色 */\n cSliderTextBorderColor: null,\n /** Slider 字体标签描边粗细 */\n cSliderTextBorder: 0,\n\n // -------------------- Scrollbar 组件样式--------------------\n /** 滚动条 滚道填充色 */\n scrollbarTrackFillColor: 'rgba(0,0,0,0)',\n /** 滚动条 滑块填充色 */\n scrollbarThumbFillColor: 'rgba(0,0,0,0.15)',\n /** 滚动条 滑块高亮填充色 */\n scrollbarThumbHighlightFillColor: 'rgba(0,0,0,0.2)',\n\n // -------------------- Geometry 图形样式--------------------\n /** 点图填充颜色 */\n pointFillColor: brandColor,\n /** 点图填充颜色透明度 */\n pointFillOpacity: 0.95,\n /** 点图大小 */\n pointSize: 4,\n /** 点图描边粗细 */\n pointBorder: 1,\n /** 点图描边颜色 */\n pointBorderColor: WHITE_COLORS[100],\n /** 点图描边透明度 */\n pointBorderOpacity: 1,\n\n /** 点图 active 状态下描边颜色 */\n pointActiveBorderColor: BLACK_COLORS[100],\n\n /** 点图 selected 状态下描边粗细 */\n pointSelectedBorder: 2,\n /** 点图 selected 状态下描边颜色 */\n pointSelectedBorderColor: BLACK_COLORS[100],\n\n /** 点图 inactive 状态下填充颜色透明度 */\n pointInactiveFillOpacity: 0.3,\n /** 点图 inactive 状态下描边透明度 */\n pointInactiveBorderOpacity: 0.3,\n\n /** 空心点图大小 */\n hollowPointSize: 4,\n /** 空心点图描边粗细 */\n hollowPointBorder: 1,\n /** 空心点图描边颜色 */\n hollowPointBorderColor: brandColor,\n /** 空心点图描边透明度 */\n hollowPointBorderOpacity: 0.95,\n hollowPointFillColor: WHITE_COLORS[100],\n\n /** 空心点图 active 状态下描边粗细 */\n hollowPointActiveBorder: 1,\n /** 空心点图 active 状态下描边颜色 */\n hollowPointActiveBorderColor: BLACK_COLORS[100],\n /** 空心点图 active 状态下描边透明度 */\n hollowPointActiveBorderOpacity: 1,\n\n /** 空心点图 selected 状态下描边粗细 */\n hollowPointSelectedBorder: 2,\n /** 空心点图 selected 状态下描边颜色 */\n hollowPointSelectedBorderColor: BLACK_COLORS[100],\n /** 空心点图 selected 状态下描边透明度 */\n hollowPointSelectedBorderOpacity: 1,\n\n /** 空心点图 inactive 状态下描边透明度 */\n hollowPointInactiveBorderOpacity: 0.3,\n\n /** 线图粗细 */\n lineBorder: 2,\n /** 线图颜色 */\n lineBorderColor: brandColor,\n /** 线图透明度 */\n lineBorderOpacity: 1,\n\n /** 线图 Active 状态下粗细 */\n lineActiveBorder: 3,\n\n /** 线图 selected 状态下粗细 */\n lineSelectedBorder: 3,\n\n /** 线图 inactive 状态下透明度 */\n lineInactiveBorderOpacity: 0.3,\n\n /** area 填充颜色 */\n areaFillColor: brandColor,\n /** area 填充透明度 */\n areaFillOpacity: 0.25,\n\n /** area 在 active 状态下的填充透明度 */\n areaActiveFillColor: brandColor,\n areaActiveFillOpacity: 0.5,\n\n /** area 在 selected 状态下的填充透明度 */\n areaSelectedFillColor: brandColor,\n areaSelectedFillOpacity: 0.5,\n\n /** area inactive 状态下填充透明度 */\n areaInactiveFillOpacity: 0.3,\n\n /** hollowArea 颜色 */\n hollowAreaBorderColor: brandColor,\n /** hollowArea 边框粗细 */\n hollowAreaBorder: 2,\n /** hollowArea 边框透明度 */\n hollowAreaBorderOpacity: 1,\n\n /** hollowArea active 状态下的边框粗细 */\n hollowAreaActiveBorder: 3,\n hollowAreaActiveBorderColor: BLACK_COLORS[100],\n\n /** hollowArea selected 状态下的边框粗细 */\n hollowAreaSelectedBorder: 3,\n hollowAreaSelectedBorderColor: BLACK_COLORS[100],\n\n /** hollowArea inactive 状态下的边框透明度 */\n hollowAreaInactiveBorderOpacity: 0.3,\n\n /** interval 填充颜色 */\n intervalFillColor: brandColor,\n /** interval 填充透明度 */\n intervalFillOpacity: 0.95,\n\n /** interval active 状态下边框粗细 */\n intervalActiveBorder: 1,\n /** interval active 状态下边框颜色 */\n intervalActiveBorderColor: BLACK_COLORS[100],\n intervalActiveBorderOpacity: 1,\n\n /** interval selected 状态下边框粗细 */\n intervalSelectedBorder: 2,\n /** interval selected 状态下边框颜色 */\n intervalSelectedBorderColor: BLACK_COLORS[100],\n /** interval selected 状态下边框透明度 */\n intervalSelectedBorderOpacity: 1,\n\n /** interval inactive 状态下边框透明度 */\n intervalInactiveBorderOpacity: 0.3,\n /** interval inactive 状态下填充透明度 */\n intervalInactiveFillOpacity: 0.3,\n\n /** interval 边框粗细 */\n hollowIntervalBorder: 2,\n /** hollowInterval 边框颜色 */\n hollowIntervalBorderColor: brandColor,\n /** hollowInterval 边框透明度 */\n hollowIntervalBorderOpacity: 1,\n hollowIntervalFillColor: WHITE_COLORS[100],\n\n /** hollowInterval active 状态下边框粗细 */\n hollowIntervalActiveBorder: 2,\n /** hollowInterval active 状态下边框颜色 */\n hollowIntervalActiveBorderColor: BLACK_COLORS[100],\n\n /** hollowInterval selected 状态下边框粗细 */\n hollowIntervalSelectedBorder: 3,\n /** hollowInterval selected 状态下边框颜色 */\n hollowIntervalSelectedBorderColor: BLACK_COLORS[100],\n /** hollowInterval selected 状态下边框透明度 */\n hollowIntervalSelectedBorderOpacity: 1,\n\n /** hollowInterval inactive 状态下边框透明度 */\n hollowIntervalInactiveBorderOpacity: 0.3,\n };\n\n return { ...token, ...cfg };\n};\n\nexport const antvLight = createLightStyleSheet();\n","import { deepMix } from '@antv/util';\nimport { createThemeByStyleSheet } from './create-by-style-sheet';\nimport { createLightStyleSheet } from '../style-sheet/light';\nimport { LooseObject, StyleSheetCfg } from '../../interface';\n\ninterface ThemeCfg extends LooseObject {\n styleSheet?: StyleSheetCfg;\n}\n\nexport function createTheme(themeCfg: ThemeCfg): LooseObject {\n const { styleSheet: styleSheetCfg = {}, ...themeObject } = themeCfg;\n\n // ① 创建样式表 (默认创建 light 的样式表)\n const styleSheet = createLightStyleSheet(styleSheetCfg);\n // ② 创建主题\n return deepMix({}, createThemeByStyleSheet(styleSheet), themeObject);\n}\n","import { get, lowerCase } from '@antv/util';\nimport { LooseObject } from '../interface';\n\nimport { createTheme } from './util';\n\nconst defaultTheme = createTheme({});\n\n// 所有已经存在的主题\nconst Themes: Record = {\n default: defaultTheme,\n};\n\n/**\n * 获取主题配置信息。\n * @param theme 主题名\n */\nexport function getTheme(theme?: string): LooseObject {\n return get(Themes, lowerCase(theme), Themes.default);\n}\n\n/**\n * 注册新的主题配置信息。\n * @param theme 主题名。\n * @param value 具体的主题配置。\n */\nexport function registerTheme(theme: string, value: LooseObject) {\n Themes[lowerCase(theme)] = createTheme(value);\n}\n","import {\n contains,\n filter,\n find,\n isArray,\n isEmpty,\n isFunction,\n isNil,\n isNumberEqual,\n isObject,\n memoize,\n get,\n values,\n} from '@antv/util';\nimport { View } from '../chart';\nimport { FIELD_ORIGIN, GROUP_ATTRS } from '../constant';\nimport { Attribute, Scale } from '../dependents';\nimport Geometry from '../geometry/base';\nimport { Data, Datum, MappingDatum, Point, TooltipCfg, TooltipTitle } from '../interface';\nimport { getName, inferScaleType } from './scale';\n\nfunction snapEqual(v1: any, v2: any, scale: Scale) {\n const value1 = scale.translate(v1);\n const value2 = scale.translate(v2);\n\n return isNumberEqual(value1, value2);\n}\n\nfunction getXValueByPoint(point: Point, geometry: Geometry): number {\n const coordinate = geometry.coordinate;\n const xScale = geometry.getXScale();\n const range = xScale.range;\n const rangeMax = range[range.length - 1];\n const rangeMin = range[0];\n\n const invertPoint = coordinate.invert(point);\n\n let xValue = invertPoint.x;\n if (coordinate.isPolar && xValue > (1 + rangeMax) / 2) {\n xValue = rangeMin; // 极坐标下,scale 的 range 被做过特殊处理\n }\n return xScale.translate(xScale.invert(xValue));\n}\n\nfunction filterYValue(data: Data, point: Point, geometry: Geometry) {\n const coordinate = geometry.coordinate;\n const yScale = geometry.getYScale();\n const yField = yScale.field;\n const invertPoint = coordinate.invert(point);\n const yValue = yScale.invert(invertPoint.y);\n\n const result = find(data, (obj: Datum) => {\n const originData = obj[FIELD_ORIGIN];\n return originData[yField][0] <= yValue && originData[yField][1] >= yValue;\n });\n return result || data[data.length - 1];\n}\n\nconst getXDistance = memoize((scale: Scale) => {\n if (scale.isCategory) {\n return 1;\n }\n const scaleValues = scale.values; // values 是无序的\n const length = scaleValues.length;\n let min = scale.translate(scaleValues[0]);\n let max = min;\n\n for (let index = 0; index < length; index++) {\n const value = scaleValues[index];\n // 时间类型需要 translate\n const numericValue = scale.translate(value);\n if (numericValue < min) {\n min = numericValue;\n }\n if (numericValue > max) {\n max = numericValue;\n }\n }\n return (max - min) / (length - 1);\n});\n\n/**\n * 获得 tooltip 的 title\n * @param originData\n * @param geometry\n * @param title\n */\nfunction getTooltipTitle(originData: Datum, geometry: Geometry, title: TooltipTitle): string {\n const positionAttr = geometry.getAttribute('position');\n const fields = positionAttr.getFields();\n const scales = geometry.scales;\n\n const titleField = isFunction(title) || !title ? fields[0] : title;\n const titleScale = scales[titleField];\n\n // 如果创建了该字段对应的 scale,则通过 scale.getText() 方式取值,因为用户可能对数据进行了格式化\n // 如果没有对应的 scale,则从原始数据中取值,如果原始数据中仍不存在,则直接放回 title 值\n const tooltipTitle = titleScale ? titleScale.getText(originData[titleField]) : originData[titleField] || titleField;\n\n return isFunction(title) ? title(tooltipTitle, originData) : tooltipTitle;\n}\n\nfunction getAttributesForLegend(geometry: Geometry) {\n const attributes = values(geometry.attributes);\n return filter(attributes, (attribute: Attribute) => contains(GROUP_ATTRS, attribute.type));\n}\n\nfunction getTooltipValueScale(geometry: Geometry) {\n const attributes = getAttributesForLegend(geometry);\n let scale;\n for (const attribute of attributes) {\n const tmpScale = attribute.getScale(attribute.type);\n if (tmpScale && tmpScale.isLinear) {\n const tmpScaleDef = get(geometry.scaleDefs, tmpScale.field);\n const inferedScaleType = inferScaleType(tmpScale, tmpScaleDef, attribute.type, geometry.type);\n if (inferedScaleType !== 'cat') {\n // 如果指定字段是非 position 的,同时是连续的\n scale = tmpScale;\n break;\n }\n }\n }\n\n const xScale = geometry.getXScale();\n const yScale = geometry.getYScale();\n\n return scale || yScale || xScale;\n}\n\nfunction getTooltipValue(originData: Datum, valueScale: Scale) {\n const field = valueScale.field;\n const value = originData[field];\n\n if (isArray(value)) {\n const texts = value.map((eachValue) => {\n return valueScale.getText(eachValue);\n });\n return texts.join('-');\n }\n return valueScale.getText(value);\n}\n\n// 根据原始数据获取 tooltip item 中 name 值\nfunction getTooltipName(originData: Datum, geometry: Geometry) {\n let nameScale: Scale;\n const groupScales = geometry.getGroupScales();\n if (groupScales.length) {\n // 如果存在分组类型,取第一个分组类型\n nameScale = groupScales[0];\n }\n if (nameScale) {\n const field = nameScale.field;\n return nameScale.getText(originData[field]);\n }\n\n const valueScale = getTooltipValueScale(geometry);\n return getName(valueScale);\n}\n\n/**\n * @ignore\n * Finds data from geometry by point\n * @param point canvas point\n * @param data an item of geometry.dataArray\n * @param geometry\n * @returns\n */\nexport function findDataByPoint(point: Point, data: MappingDatum[], geometry: Geometry) {\n if (data.length === 0) {\n return null;\n }\n\n const geometryType = geometry.type;\n const xScale = geometry.getXScale();\n const yScale = geometry.getYScale();\n\n const xField = xScale.field;\n const yField = yScale.field;\n\n let rst = null;\n\n // 热力图采用最小逼近策略查找 point 击中的数据\n if (geometryType === 'heatmap' || geometryType === 'point') {\n // 将 point 画布坐标转换为原始数据值\n const coordinate = geometry.coordinate;\n const invertPoint = coordinate.invert(point); // 转换成归一化的数据\n const x = xScale.invert(invertPoint.x); // 转换为原始值\n const y = yScale.invert(invertPoint.y); // 转换为原始值\n\n let min = Infinity;\n for (let index = 0; index < data.length; index++) {\n const obj = data[index];\n const originData = obj[FIELD_ORIGIN];\n const range = (originData[xField] - x) ** 2 + (originData[yField] - y) ** 2;\n if (range < min) {\n min = range;\n rst = obj;\n }\n }\n\n return rst;\n }\n\n // 其他 Geometry 类型按照 x 字段数据进行查找\n const first = data[0];\n let last = data[data.length - 1];\n const xValue = getXValueByPoint(point, geometry);\n const firstXValue = first[FIELD_ORIGIN][xField];\n const firstYValue = first[FIELD_ORIGIN][yField];\n const lastXValue = last[FIELD_ORIGIN][xField];\n const isYArray = yScale.isLinear && isArray(firstYValue); // 考虑 x 维度相同,y 是数组区间的情况\n\n // 如果 x 的值是数组\n if (isArray(firstXValue)) {\n for (let index = 0; index < data.length; index++) {\n const record = data[index];\n const originData = record[FIELD_ORIGIN];\n // xValue 在 originData[xField] 的数值区间内\n if (xScale.translate(originData[xField][0]) <= xValue && xScale.translate(originData[xField][1]) >= xValue) {\n if (isYArray) {\n // 层叠直方图场景,x 和 y 都是数组区间\n if (!isArray(rst)) {\n rst = [];\n }\n rst.push(record);\n } else {\n rst = record;\n break;\n }\n }\n }\n if (isArray(rst)) {\n rst = filterYValue(rst, point, geometry);\n }\n } else {\n let next;\n if (!xScale.isLinear && xScale.type !== 'timeCat') {\n // x 轴对应的数据为非线性以及非时间类型的数据采用遍历查找\n for (let index = 0; index < data.length; index++) {\n const record = data[index];\n const originData = record[FIELD_ORIGIN];\n if (snapEqual(originData[xField], xValue, xScale)) {\n if (isYArray) {\n if (!isArray(rst)) {\n rst = [];\n }\n rst.push(record);\n } else {\n rst = record;\n break;\n }\n } else if (xScale.translate(originData[xField]) <= xValue) {\n last = record;\n next = data[index + 1];\n }\n }\n\n if (isArray(rst)) {\n rst = filterYValue(rst, point, geometry);\n }\n } else {\n // x 轴对应的数据为线性以及时间类型,进行二分查找,性能更好\n if (\n (xValue > xScale.translate(lastXValue) || xValue < xScale.translate(firstXValue)) &&\n (xValue > xScale.max || xValue < xScale.min)\n ) {\n // 不在数据范围内\n return null;\n }\n\n let firstIdx = 0;\n let lastIdx = data.length - 1;\n let middleIdx;\n while (firstIdx <= lastIdx) {\n middleIdx = Math.floor((firstIdx + lastIdx) / 2);\n const item = data[middleIdx][FIELD_ORIGIN][xField];\n if (snapEqual(item, xValue, xScale)) {\n return data[middleIdx];\n }\n\n if (xScale.translate(item) <= xScale.translate(xValue)) {\n firstIdx = middleIdx + 1;\n last = data[middleIdx];\n next = data[middleIdx + 1];\n } else {\n if (lastIdx === 0) {\n last = data[0];\n }\n lastIdx = middleIdx - 1;\n }\n }\n }\n\n if (last && next) {\n // 计算最逼近的\n if (\n Math.abs(xScale.translate(last[FIELD_ORIGIN][xField]) - xValue) >\n Math.abs(xScale.translate(next[FIELD_ORIGIN][xField]) - xValue)\n ) {\n last = next;\n }\n }\n }\n\n const distance = getXDistance(geometry.getXScale()); // 每个分类间的平均间距\n if (!rst && Math.abs(xScale.translate(last[FIELD_ORIGIN][xField]) - xValue) <= distance / 2) {\n rst = last;\n }\n\n return rst;\n}\n\n/**\n * @ignore\n * Gets tooltip items\n * @param data\n * @param geometry\n * @param [title]\n * @returns\n */\nexport function getTooltipItems(\n data: MappingDatum,\n geometry: Geometry,\n title: TooltipTitle = '',\n showNil: boolean = false\n) {\n const originData = data[FIELD_ORIGIN];\n const tooltipTitle = getTooltipTitle(originData, geometry, title);\n const tooltipOption = geometry.tooltipOption;\n const { defaultColor } = geometry.theme;\n const items = [];\n let name;\n let value;\n\n function addItem(itemName, itemValue) {\n if (showNil || (!isNil(itemValue) && itemValue !== '')) {\n // 值为 null的时候,忽视\n const item = {\n title: tooltipTitle,\n data: originData, // 原始数据\n mappingData: data, // 映射后的数据\n name: itemName,\n value: itemValue,\n color: data.color || defaultColor,\n marker: true,\n };\n\n items.push(item);\n }\n }\n\n if (isObject(tooltipOption)) {\n const { fields, callback } = tooltipOption;\n if (callback) {\n // 用户定义了回调函数\n const callbackParams = fields.map((field: string) => {\n return data[FIELD_ORIGIN][field];\n });\n const cfg = callback(...callbackParams);\n const itemCfg = {\n data: data[FIELD_ORIGIN], // 原始数据\n mappingData: data, // 映射后的数据\n title: tooltipTitle,\n color: data.color || defaultColor,\n marker: true, // 默认展示 marker\n ...cfg,\n };\n\n items.push(itemCfg);\n } else {\n const scales = geometry.scales;\n for (const field of fields) {\n if (!isNil(originData[field])) {\n // 字段数据为null, undefined 时不显示\n const scale = scales[field];\n name = getName(scale);\n value = scale.getText(originData[field]);\n addItem(name, value);\n }\n }\n }\n } else {\n const valueScale = getTooltipValueScale(geometry);\n // 字段数据为null ,undefined时不显示\n value = getTooltipValue(originData, valueScale);\n name = getTooltipName(originData, geometry);\n addItem(name, value);\n }\n return items;\n}\n\nfunction getTooltipItemsByFindData(geometry: Geometry, point, title, tooltipCfg: TooltipCfg) {\n const { showNil } = tooltipCfg;\n const result = [];\n const dataArray = geometry.dataArray;\n if (!isEmpty(dataArray)) {\n geometry.sort(dataArray); // 先进行排序,便于 tooltip 查找\n for (const data of dataArray) {\n const record = findDataByPoint(point, data, geometry);\n if (record) {\n const elementId = geometry.getElementId(record);\n const element = geometry.elementsMap[elementId];\n if (geometry.type === 'heatmap' || element.visible) {\n // Heatmap 没有 Element\n // 如果图形元素隐藏了,怎不再 tooltip 上展示相关数据\n const items = getTooltipItems(record, geometry, title, showNil);\n if (items.length) {\n result.push(items);\n }\n }\n }\n }\n }\n\n return result;\n}\n\nfunction getTooltipItemsByHitShape(geometry, point, title, tooltipCfg: TooltipCfg) {\n const { showNil } = tooltipCfg;\n const result = [];\n const container = geometry.container;\n const shape = container.getShape(point.x, point.y);\n if (shape && shape.get('visible') && shape.get('origin')) {\n const mappingData = shape.get('origin').mappingData;\n const items = getTooltipItems(mappingData, geometry, title, showNil);\n if (items.length) {\n result.push(items);\n }\n }\n\n return result;\n}\n\n/**\n * 不进行递归查找\n */\nexport function findItemsFromView(view: View, point: Point, tooltipCfg: TooltipCfg) {\n const result = [];\n // 先从 view 本身查找\n const geometries = view.geometries;\n const { shared, title, reversed } = tooltipCfg;\n for (const geometry of geometries) {\n if (geometry.visible && geometry.tooltipOption !== false) {\n // geometry 可见同时未关闭 tooltip\n const geometryType = geometry.type;\n let tooltipItems;\n if (['point', 'edge', 'polygon'].includes(geometryType)) {\n // 始终通过图形拾取\n tooltipItems = getTooltipItemsByHitShape(geometry, point, title, tooltipCfg);\n } else if (['area', 'line', 'path', 'heatmap'].includes(geometryType)) {\n // 如果是 'area', 'line', 'path',始终通过数据查找方法查找 tooltip\n tooltipItems = getTooltipItemsByFindData(geometry, point, title, tooltipCfg);\n } else {\n if (shared !== false) {\n tooltipItems = getTooltipItemsByFindData(geometry, point, title, tooltipCfg);\n } else {\n tooltipItems = getTooltipItemsByHitShape(geometry, point, title, tooltipCfg);\n }\n }\n if (tooltipItems.length) {\n if (reversed) {\n tooltipItems.reverse();\n }\n // geometry 有可能会有多个 item,因为用户可以设置 geometry.tooltip('x*y*z')\n result.push(tooltipItems);\n }\n }\n }\n\n return result;\n}\n\nexport function findItemsFromViewRecurisive(view: View, point: Point, tooltipCfg: TooltipCfg) {\n let result = findItemsFromView(view, point, tooltipCfg);\n\n // 递归查找,并合并结果\n for (const childView of view.views) {\n result = result.concat(findItemsFromView(childView, point, tooltipCfg));\n }\n\n return result;\n}\n","import { isArray, isNumber } from '@antv/util';\nimport { Padding, ViewPadding } from '../interface';\n\n/**\n * @ignore\n * 是否是自动 padding\n * @param padding\n */\nexport function isAutoPadding(padding: ViewPadding): padding is 'auto' {\n return !isNumber(padding) && !isArray(padding);\n}\n\n/**\n * @ignore\n * padding 的解析逻辑\n * @param padding\n * @return [ top, right, bottom, left ]\n */\nexport function parsePadding(padding: number[] | number = 0): Padding {\n let paddingArray = isArray(padding) ? padding : [padding];\n\n switch (paddingArray.length) {\n case 0:\n paddingArray = [0, 0, 0, 0];\n break;\n case 1:\n paddingArray = new Array(4).fill(paddingArray[0]);\n break;\n case 2:\n paddingArray = [...paddingArray, ...paddingArray];\n break;\n case 3:\n paddingArray = [...paddingArray, paddingArray[1]];\n break;\n default:\n // 其他情况,只去四个\n paddingArray = paddingArray.slice(0, 4);\n break;\n }\n\n return paddingArray as [number, number, number, number];\n}\n","import { ControllerCtor } from './base';\n\nconst LOAD_COMPONENT_CONTROLLERS: Record = {};\n\n/**\n * 全局注册组件。\n * @param name 组件名称\n * @param plugin 注册的组件类\n * @returns void\n */\nexport function registerComponentController(name: string, plugin: ControllerCtor) {\n LOAD_COMPONENT_CONTROLLERS[name] = plugin;\n}\n\n/**\n * 删除全局组件。\n * @param name 组件名\n * @returns void\n */\nexport function unregisterComponentController(name: string) {\n delete LOAD_COMPONENT_CONTROLLERS[name];\n}\n\n/**\n * 获取以注册的组件名。\n * @returns string[] 返回已注册的组件名称\n */\nexport function getComponentControllerNames(): string[] {\n return Object.keys(LOAD_COMPONENT_CONTROLLERS);\n}\n\n/**\n * 根据组件名获取组件类。\n * @param name 组件名\n * @returns 返回组件类\n */\nexport function getComponentController(name: string): ControllerCtor {\n return LOAD_COMPONENT_CONTROLLERS[name];\n}\n","import { each, isNil, some } from '@antv/util';\nimport { Coordinate, getCoordinate, Point } from '../../dependents';\nimport { CoordinateOption } from '../../interface';\n\n/**\n * coordinate controller,职责:\n * 1. 创建实例\n * 2. 暂存配置\n */\nexport default class CoordinateController {\n private option: CoordinateOption;\n private coordinate: Coordinate;\n\n constructor(option?: CoordinateOption) {\n // 设置默认值,并存储配置\n this.option = this.wrapperOption(option);\n }\n\n /**\n * 更新配置\n * @param option\n */\n public update(option: CoordinateOption) {\n this.option = this.wrapperOption(option);\n return this;\n }\n\n /**\n * 是否存在某一个 action\n * @param actionName\n */\n public hasAction(actionName: string) {\n const { actions } = this.option;\n\n return some(actions, (action) => action[0] === actionName);\n }\n /**\n * 创建坐标系对象\n * @param start 起始位置\n * @param end 结束位置\n * @return 坐标系实例\n */\n public create(start: Point, end: Point) {\n const { type, cfg } = this.option;\n const isTheta = type === 'theta';\n\n // 1. 起始位置\n const props = {\n start,\n end,\n ...cfg,\n };\n\n // 2. 创建实例\n const C = getCoordinate(isTheta ? 'polar' : type);\n\n this.coordinate = new C(props);\n\n // @ts-ignore FIXME coordinate 包问题导致 type 不正确\n this.coordinate.type = type;\n\n // 3. 添加默认 action\n if (isTheta) {\n // 不存在 transpose,为其自动设置一个 action\n if (!this.hasAction('transpose')) {\n this.transpose();\n }\n }\n\n // 4. 执行 action\n this.execActions();\n\n return this.coordinate;\n }\n\n /**\n * 更新坐标系对象\n * @param start 起始位置\n * @param end 结束位置\n * @return 坐标系实例\n */\n public adjust(start: Point, end: Point) {\n this.coordinate.update({\n start,\n end,\n });\n\n // 更新坐标系大小的时候,需要:\n // 1. 重置 matrix\n // 2. 重新执行作用于 matrix 的 action\n this.coordinate.resetMatrix();\n this.execActions(['scale', 'rotate', 'translate']);\n\n return this.coordinate;\n }\n\n /**\n * 旋转弧度\n * @param angle\n */\n public rotate(angle: number) {\n this.option.actions.push(['rotate', angle]);\n return this;\n }\n\n /**\n * 镜像\n * @param dim\n */\n public reflect(dim: 'x' | 'y') {\n this.option.actions.push(['reflect', dim]);\n return this;\n }\n\n /**\n * scale\n * @param sx\n * @param sy\n */\n public scale(sx: number, sy: number) {\n this.option.actions.push(['scale', sx, sy]);\n return this;\n }\n\n /**\n * 对角变换\n */\n public transpose() {\n this.option.actions.push(['transpose']);\n return this;\n }\n\n /**\n * 获取配置\n */\n public getOption(): CoordinateOption {\n return this.option;\n }\n\n /**\n * 获得 coordinate 实例\n */\n public getCoordinate() {\n return this.coordinate;\n }\n\n /**\n * 包装配置的默认值\n * @param option\n */\n private wrapperOption(option: CoordinateOption): CoordinateOption {\n return {\n type: 'rect',\n actions: [],\n cfg: {},\n ...option,\n };\n }\n\n /**\n * coordinate 实例执行 actions\n * @params includeActions 如果没有指定,则执行全部,否则,执行指定的 action\n */\n private execActions(includeActions?: string[]) {\n const { actions } = this.option;\n\n each(actions, (action) => {\n const [actionName, ...args] = action;\n\n const shouldExec = isNil(includeActions) ? true : includeActions.includes(actionName);\n\n if (shouldExec) {\n this.coordinate[actionName](...args);\n }\n });\n }\n}\n","import { Event as GEvent, IShape } from '../dependents';\nimport { Datum } from '../interface';\nimport View from './view';\n\n/**\n * @todo Whether it can(or necessary to) keep consistent with the structure of G.Event or directly use the structure of G.Event\n * G2 事件的事件包装类,基于 G.Event\n */\nexport default class Event {\n /** 当前 target 归属的 view 实例 */\n public view: View;\n /** 被包装的原生 G 事件 */\n public gEvent: GEvent;\n /** 原始数据 */\n public data?: Datum;\n /** 事件类型 */\n public type: string;\n\n constructor(view: View, gEvent: GEvent, data?: Datum) {\n this.view = view;\n this.gEvent = gEvent;\n this.data = data;\n this.type = gEvent.type;\n }\n\n /**\n * 非交互产生的事件\n * @param view\n * @param type\n * @param data\n */\n public static fromData(view: View, type: string, data: Datum) {\n return new Event(view, new GEvent(type, {}), data);\n }\n\n // below props are proxy props of G.event convenient\n\n /** the real trigger shape of the event */\n public get target(): IShape {\n // @todo G 中事件定义为 object 不正确,这里先 ignore\n // @ts-ignore\n return this.gEvent.target;\n }\n\n /** 获取对应的 dom 原生时间 */\n public get event(): any {\n return this.gEvent.originalEvent;\n }\n\n /** x 画布坐标 */\n public get x(): number {\n return this.gEvent.x;\n }\n\n /** y 画布坐标 */\n public get y(): number {\n return this.gEvent.y;\n }\n\n /** x 窗口坐标 */\n public get clientX(): number {\n return this.gEvent.clientX;\n }\n\n /** y 窗口坐标 */\n public get clientY(): number {\n return this.gEvent.clientY;\n }\n // end for proxy events\n\n /**\n * event string\n * @returns string\n */\n public toString(): string {\n return `[Event (type=${this.type})]`;\n }\n\n /**\n * clone a new event with same attributes\n * @returns [[Event]]\n */\n public clone(): Event {\n return new Event(this.view, this.gEvent, this.data);\n }\n}\n","import { Controller } from '../controller/base';\nimport View from '../view';\n\n// 布局函数的定义\n// 布局函数的职责:根据 view 中组件信息,计算出最终的图形 padding 数值,以及最终各个组件的布局和位置\nexport type Layout = (view: View) => void;\n\n/**\n * @ignore\n * G2 默认提供的 layout 函数\n * 内置布局函数处理的逻辑:\n *\n * 1. 如果 padding = 'auto',那么自动根据组件的 direction 来计算 padding 数组\n * 2. 根据 padding 和 direction 去分配对应方向的 padding 数值\n * 3. 移动组件位置\n *\n * 前面 1,2 步骤在 view 中已经做掉了。对于组件响应式布局,可以尝试使用约束布局的方式去求解位置信息。\n * @param view\n */\nexport default function defaultLayout(view: View): void {\n const axis = view.getController('axis');\n const legend = view.getController('legend');\n const annotation = view.getController('annotation');\n const slider = view.getController('slider');\n const scrollbar = view.getController('scrollbar');\n\n // 根据最新的 coordinate 重新布局组件\n [axis, slider, scrollbar, legend, annotation].forEach((controller: Controller) => {\n if (controller) {\n controller.layout();\n }\n });\n}\n","/**\n * view 中缓存 scale 的类\n */\nimport { deepMix, each, get, isNumber, last } from '@antv/util';\nimport { Scale, Coordinate } from '../../dependents';\nimport { Data, LooseObject, ScaleOption, ViewCfg } from '../../interface';\nimport { createScaleByField, syncScale, getDefaultCategoryScaleRange } from '../../util/scale';\n\n/** @ignore */\ninterface ScaleMeta {\n readonly key: string;\n readonly scale: Scale;\n scaleDef: ScaleOption;\n syncKey?: string;\n}\n\n/** @ignore */\nexport class ScalePool {\n /** 所有的 scales */\n private scales = new Map();\n /** 需要同步的 scale 分组, key: scaleKeyArray */\n private syncScales = new Map();\n\n /**\n * 创建 scale\n * @param field\n * @param data\n * @param scaleDef\n * @param key\n */\n public createScale(field: string, data: Data, scaleDef: ScaleOption, key: string): Scale {\n let finalScaleDef = scaleDef;\n\n const cacheScaleMeta = this.getScaleMeta(key);\n if (data.length === 0 && cacheScaleMeta) {\n // 在更新过程中数据变为空,同时 key 对应的 scale 已存在则保持 scale 同类型\n const cacheScale = cacheScaleMeta.scale;\n const cacheScaleDef: LooseObject = {\n type: cacheScale.type,\n };\n if (cacheScale.isCategory) {\n // 如果是分类类型,保持 values\n cacheScaleDef.values = cacheScale.values;\n }\n finalScaleDef = deepMix(cacheScaleDef, cacheScaleMeta.scaleDef, scaleDef);\n }\n\n const scale = createScaleByField(field, data, finalScaleDef);\n\n // 缓存起来\n this.cacheScale(scale, scaleDef, key);\n\n return scale;\n }\n\n /**\n * 同步 scale\n */\n public sync(coordinate: Coordinate, theme: ViewCfg['theme']) {\n // 对于 syncScales 中每一个 syncKey 下面的 scale 数组进行同步处理\n this.syncScales.forEach((scaleKeys: string[], syncKey: string) => {\n // min, max, values, ranges\n let min = Number.MAX_SAFE_INTEGER;\n let max = Number.MIN_SAFE_INTEGER;\n const values = [];\n\n // 1. 遍历求得最大最小值,values 等\n each(scaleKeys, (key: string) => {\n const scale = this.getScale(key);\n\n max = isNumber(scale.max) ? Math.max(max, scale.max) : max;\n min = isNumber(scale.min) ? Math.min(min, scale.min) : min;\n\n // 去重\n each(scale.values, (v: any) => {\n if (!values.includes(v)) {\n values.push(v);\n }\n });\n });\n\n // 2. 同步\n each(scaleKeys, (key: string) => {\n const scale = this.getScale(key);\n\n if (scale.isContinuous) {\n scale.change({\n min,\n max,\n values,\n });\n } else if (scale.isCategory) {\n let range = scale.range;\n const cacheScaleMeta = this.getScaleMeta(key);\n\n // 存在 value 值,且用户没有配置 range 配置 to fix https://github.com/antvis/G2/issues/2996\n if (values && !get(cacheScaleMeta, ['scaleDef', 'range'])) {\n // 更新 range\n range = getDefaultCategoryScaleRange(\n deepMix({}, scale, {\n values,\n }),\n coordinate,\n theme\n );\n }\n scale.change({\n values,\n range,\n });\n }\n });\n });\n }\n\n /**\n * 缓存一个 scale\n * @param scale\n * @param scaleDef\n * @param key\n */\n private cacheScale(scale: Scale, scaleDef: ScaleOption, key: string) {\n // 1. 缓存到 scales\n\n let sm = this.getScaleMeta(key);\n // 存在则更新,同时检测类型是否一致\n if (sm && sm.scale.type === scale.type) {\n syncScale(sm.scale, scale);\n sm.scaleDef = scaleDef;\n // 更新 scaleDef\n } else {\n sm = {\n key,\n scale,\n scaleDef,\n };\n\n this.scales.set(key, sm);\n }\n\n // 2. 缓存到 syncScales,构造 Record 数据结构\n const syncKey = this.getSyncKey(sm);\n sm.syncKey = syncKey; // 设置 sync 同步的 key\n\n // 因为存在更新 scale 机制,所以在缓存之前,先从原 syncScales 中去除 sync 的缓存引用\n this.removeFromSyncScales(key);\n\n // 存在 sync 标记才进行 sync\n if (syncKey) {\n // 不存在这个 syncKey,则创建一个空数组\n let scaleKeys = this.syncScales.get(syncKey);\n if (!scaleKeys) {\n scaleKeys = [];\n this.syncScales.set(syncKey, scaleKeys);\n }\n scaleKeys.push(key);\n }\n }\n\n /**\n * 通过 key 获取 scale\n * @param key\n */\n public getScale(key: string): Scale {\n let scaleMeta = this.getScaleMeta(key);\n if (!scaleMeta) {\n const field = last(key.split('-'));\n const scaleKeys = this.syncScales.get(field);\n if (scaleKeys && scaleKeys.length) {\n scaleMeta = this.getScaleMeta(scaleKeys[0]);\n }\n }\n return scaleMeta && scaleMeta.scale;\n }\n\n /**\n * 在 view 销毁的时候,删除 scale 实例,防止内存泄露\n * @param key\n */\n public deleteScale(key: string) {\n const scaleMeta = this.getScaleMeta(key);\n if (scaleMeta) {\n const { syncKey } = scaleMeta;\n\n const scaleKeys = this.syncScales.get(syncKey);\n\n // 移除同步的关系\n if (scaleKeys && scaleKeys.length) {\n const idx = scaleKeys.indexOf(key);\n\n if (idx !== -1) {\n scaleKeys.splice(idx, 1);\n }\n }\n }\n\n // 删除 scale 实例\n this.scales.delete(key);\n }\n\n /**\n * 清空\n */\n public clear() {\n this.scales.clear();\n this.syncScales.clear();\n }\n\n /**\n * 删除 sync scale 引用\n * @param key\n */\n private removeFromSyncScales(key: string) {\n this.syncScales.forEach((scaleKeys: string[], syncKey: string) => {\n const idx = scaleKeys.indexOf(key);\n\n if (idx !== -1) {\n scaleKeys.splice(idx, 1);\n\n // 删除空数组值\n if (scaleKeys.length === 0) {\n this.syncScales.delete(syncKey);\n }\n\n return false; // 跳出循环\n }\n });\n }\n\n /**\n * get sync key\n * @param sm\n */\n private getSyncKey(sm: ScaleMeta): string {\n const { scale, scaleDef } = sm;\n const { field } = scale;\n const sync = get(scaleDef, ['sync']);\n\n // 如果 sync = true,则直接使用字段名作为 syncKey\n return sync === true ? field : sync === false ? undefined : sync;\n }\n\n /**\n * 通过 key 获取 scale\n * @param key\n */\n private getScaleMeta(key: string): ScaleMeta {\n return this.scales.get(key);\n }\n}\n","import { DIRECTION } from '../../constant';\nimport { BBox } from '../../dependents';\nimport { Padding } from '../../interface';\n\nexport type PaddingCalCtor = {\n readonly instance: (top?: number, right?: number, bottom?: number, left?: number) => PaddingCal;\n};\n\n/** @ignore */\nexport class PaddingCal {\n private top: number;\n private right: number;\n private bottom: number;\n private left: number;\n\n /**\n * 使用静态方法创建一个\n * @param top\n * @param right\n * @param bottom\n * @param left\n */\n public static instance(top: number = 0, right: number = 0, bottom: number = 0, left: number = 0) {\n return new PaddingCal(top, right, bottom, left);\n }\n\n /**\n * 初始的 padding 数据\n * @param top\n * @param right\n * @param bottom\n * @param left\n */\n constructor(top: number = 0, right: number = 0, bottom: number = 0, left: number = 0) {\n this.top = top;\n this.right = right;\n this.bottom = bottom;\n this.left = left;\n }\n\n /**\n * 取最大区间\n * @param padding\n */\n public max(padding: Padding): PaddingCal {\n const [top, right, bottom, left] = padding;\n\n this.top = Math.max(this.top, top);\n this.right = Math.max(this.right, right);\n this.bottom = Math.max(this.bottom, bottom);\n this.left = Math.max(this.left, left);\n\n return this;\n }\n\n /**\n * 四周增加 padding\n * @param padding\n */\n public shrink(padding: Padding): PaddingCal {\n const [top, right, bottom, left] = padding;\n\n this.top += top;\n this.right += right;\n this.bottom += bottom;\n this.left += left;\n\n return this;\n }\n\n /**\n * 在某一个方向增加 padding\n * @param bbox\n * @param direction\n */\n public inc(bbox: BBox, direction: DIRECTION): PaddingCal {\n const { width, height } = bbox;\n\n switch (direction) {\n case DIRECTION.TOP:\n case DIRECTION.TOP_LEFT:\n case DIRECTION.TOP_RIGHT:\n this.top += height;\n break;\n\n case DIRECTION.RIGHT:\n case DIRECTION.RIGHT_TOP:\n case DIRECTION.RIGHT_BOTTOM:\n this.right += width;\n break;\n\n case DIRECTION.BOTTOM:\n case DIRECTION.BOTTOM_LEFT:\n case DIRECTION.BOTTOM_RIGHT:\n this.bottom += height;\n break;\n\n case DIRECTION.LEFT:\n case DIRECTION.LEFT_TOP:\n case DIRECTION.LEFT_BOTTOM:\n this.left += width;\n break;\n default:\n break;\n }\n\n return this;\n }\n\n /**\n * 获得最终的 padding\n */\n public getPadding(): Padding {\n return [this.top, this.right, this.bottom, this.left];\n }\n\n /**\n * clone 一个 padding cal\n */\n public clone(): PaddingCal {\n return new PaddingCal(...this.getPadding());\n }\n}\n","import { each } from '@antv/util';\nimport { COMPONENT_TYPE } from '../../constant';\nimport { ComponentOption, Padding } from '../../interface';\nimport { BBox } from '../../util/bbox';\nimport { isAutoPadding, parsePadding } from '../../util/padding';\nimport View from '../view';\nimport { PaddingCal } from './padding-cal';\n\n/**\n * @ignore\n * 根据 view 中的组件,计算实际的 padding 数值\n * @param view\n */\nexport function calculatePadding(view: View): PaddingCal {\n const padding = view.padding;\n\n // 如果不是 auto padding,那么直接解析之后返回\n if (!isAutoPadding(padding)) {\n return new PaddingCal(...parsePadding(padding));\n }\n\n // 是 auto padding,根据组件的情况,来计算 padding\n const { viewBBox } = view;\n\n const paddingCal = new PaddingCal();\n\n const axisComponents = [];\n const paddingComponents = [];\n const otherComponents = [];\n\n each(view.getComponents(), (co: ComponentOption) => {\n const { type } = co;\n if (type === COMPONENT_TYPE.AXIS) {\n axisComponents.push(co);\n } else if ([COMPONENT_TYPE.LEGEND, COMPONENT_TYPE.SLIDER, COMPONENT_TYPE.SCROLLBAR].includes(type)) {\n paddingComponents.push(co);\n } else if (type !== COMPONENT_TYPE.GRID && type !== COMPONENT_TYPE.TOOLTIP) {\n otherComponents.push(co);\n }\n });\n\n // 进行坐标轴布局,应该是取 padding 的并集,而不是进行相加\n each(axisComponents, (co: ComponentOption) => {\n const { component } = co;\n const bboxObject = component.getLayoutBBox();\n const componentBBox = new BBox(bboxObject.x, bboxObject.y, bboxObject.width, bboxObject.height);\n\n const exceed = componentBBox.exceed(viewBBox);\n\n // 在对组件分组之后,先对 axis 进行处理,然后取最大的超出即可。\n paddingCal.max(exceed);\n });\n\n // 有 padding 的组件布局\n each(paddingComponents, (co: ComponentOption) => {\n const { component, direction } = co;\n const bboxObject = component.getLayoutBBox();\n const componentPadding: Padding = component.get('padding');\n const componentBBox = new BBox(bboxObject.x, bboxObject.y, bboxObject.width, bboxObject.height).expand(\n componentPadding\n );\n // 按照方向计算 padding\n paddingCal.inc(componentBBox, direction);\n });\n\n // 其他组件布局\n each(otherComponents, (co: ComponentOption) => {\n const { component, direction } = co;\n const bboxObject = component.getLayoutBBox();\n const componentBBox = new BBox(bboxObject.x, bboxObject.y, bboxObject.width, bboxObject.height);\n // 按照方向计算 padding\n paddingCal.inc(componentBBox, direction);\n });\n\n return paddingCal;\n}\n","import { PaddingCalCtor } from '../layout/padding-cal';\nimport { View } from '../view';\n\n/**\n * 默认的 syncViewPadding 逻辑\n * @param chart\n * @param views\n * @param PC: PaddingCalCtor\n */\nexport function defaultSyncViewPadding(chart: View, views: View[], PC: PaddingCalCtor) {\n const syncPadding = PC.instance();\n\n // 所有的 view 的 autoPadding 指向同一个引用\n views.forEach((v: View) => {\n v.autoPadding = syncPadding.max(v.autoPadding.getPadding());\n });\n}\n","import {\n clone,\n deepMix,\n each,\n filter,\n find,\n flatten,\n get,\n isBoolean,\n isFunction,\n isNil,\n isObject,\n isString,\n isUndefined,\n mix,\n remove,\n set,\n size,\n uniqueId,\n isEqual,\n isPlainObject,\n reduce,\n} from '@antv/util';\nimport { Attribute, Coordinate, Event as GEvent, GroupComponent, ICanvas, IGroup, IShape, Scale } from '../dependents';\nimport {\n AxisOption,\n ComponentOption,\n CoordinateCfg,\n CoordinateOption,\n Data,\n Datum,\n FacetCfgMap,\n FilterCondition,\n GeometryOption,\n LegendOption,\n LooseObject,\n Options,\n Point,\n Region,\n ScaleOption,\n TooltipOption,\n ViewCfg,\n ViewPadding,\n ViewAppendPadding,\n EventPayload,\n Padding,\n} from '../interface';\nimport { GROUP_Z_INDEX, LAYER, PLOT_EVENTS, VIEW_LIFE_CIRCLE } from '../constant';\nimport Base from '../base';\nimport { Facet, getFacet } from '../facet';\nimport Geometry from '../geometry/base';\nimport Element from '../geometry/element';\nimport { createInteraction, Interaction } from '../interaction';\nimport { getTheme } from '../theme';\nimport { BBox } from '../util/bbox';\nimport { getCoordinateClipCfg, isPointInCoordinate } from '../util/coordinate';\nimport { uniq } from '../util/helper';\nimport { findDataByPoint } from '../util/tooltip';\nimport { parsePadding } from '../util/padding';\nimport { getDefaultCategoryScaleRange } from '../util/scale';\nimport { createTheme } from '../theme/util';\nimport Chart from './chart';\nimport { getComponentController, getComponentControllerNames } from './controller';\nimport Annotation from './controller/annotation';\nimport { Controller } from './controller/base';\nimport CoordinateController from './controller/coordinate';\nimport Tooltip from './controller/tooltip';\nimport Slider from './controller/slider';\nimport Scrollbar from './controller/scrollbar';\nimport Axis from './controller/axis';\nimport Gesture from './controller/gesture';\nimport Legend from './controller/legend';\nimport Event from './event';\nimport defaultLayout, { Layout } from './layout';\nimport { ScalePool } from './util/scale-pool';\nimport { PaddingCal } from './layout/padding-cal';\nimport { calculatePadding } from './layout/auto';\nimport { defaultSyncViewPadding } from './util/sync-view-padding';\n\n/**\n * G2 视图 View 类\n */\nexport class View extends Base {\n /** view id,全局唯一。 */\n public id: string;\n /** 父级 view,如果没有父级,则为空。 */\n public parent: View;\n /** 所有的子 view。 */\n public views: View[] = [];\n /** 所有的 geometry 实例。 */\n public geometries: Geometry[] = [];\n /** 所有的组件 controllers。 */\n public controllers: Controller[] = [];\n /** 所有的 Interaction 实例。 */\n public interactions: Record = {};\n\n /** view 区域空间。 */\n public viewBBox: BBox;\n /** 坐标系的位置大小,ViewBBox - padding = coordinateBBox。 */\n public coordinateBBox: BBox;\n /** view 的 padding 大小,传入的配置(不是解析之后的值)。 */\n public padding: ViewPadding;\n /** padding的基础上增加的调整值 */\n public appendPadding: ViewAppendPadding;\n /** G.Canvas 实例。 */\n public canvas: ICanvas;\n /** 存储最终计算的 padding 结果 */\n public autoPadding: PaddingCal;\n\n /** 三层 Group 图形中的背景层。 */\n public backgroundGroup: IGroup;\n /** 三层 Group 图形中的中间层。 */\n public middleGroup: IGroup;\n /** 三层 Group 图形中的前景层。 */\n public foregroundGroup: IGroup;\n /** 是否对超出坐标系范围的 Geometry 进行剪切 */\n public limitInPlot: boolean = false;\n\n /**\n * 标记 view 的大小位置范围,均是 0 ~ 1 范围,便于开发者使用,起始点为左上角。\n */\n protected region: Region;\n /** 主题配置,存储当前主题配置。 */\n protected themeObject: LooseObject;\n\n // 配置信息存储\n protected options: Options = {\n data: [],\n animate: true, // 默认开启动画\n }; // 初始化为空\n\n /** 过滤之后的数据 */\n protected filteredData: Data;\n\n /** 配置开启的组件插件,默认为全局配置的组件。 */\n private usedControllers: string[] = getComponentControllerNames();\n\n /** 所有的 scales */\n private scalePool: ScalePool = new ScalePool();\n\n /** 布局函数 */\n protected layoutFunc: Layout = defaultLayout;\n /** 生成的坐标系实例,{@link https://github.com/antvis/coord/blob/master/src/coord/base.ts|Coordinate} */\n protected coordinateInstance: Coordinate;\n /** Coordinate 相关的控制器类,负责坐标系实例的创建、更新、变换等 */\n protected coordinateController: CoordinateController;\n /** 分面类实例 */\n protected facetInstance: Facet;\n\n /** 当前鼠标是否在 plot 内(CoordinateBBox) */\n private isPreMouseInPlot: boolean = false;\n /** 默认标识位,用于判定数据是否更新 */\n private isDataChanged: boolean = false;\n /** 用于判断坐标系范围是否发生变化的标志位 */\n private isCoordinateChanged: boolean = false;\n /** 从当前这个 view 创建的 scale key */\n private createdScaleKeys = new Map();\n /** 背景色样式的 shape */\n private backgroundStyleRectShape;\n /** 是否同步子 view 的 padding */\n private syncViewPadding;\n\n constructor(props: ViewCfg) {\n super({ visible: props.visible });\n\n const {\n id = uniqueId('view'),\n parent,\n canvas,\n backgroundGroup,\n middleGroup,\n foregroundGroup,\n region = { start: { x: 0, y: 0 }, end: { x: 1, y: 1 } },\n padding,\n appendPadding,\n theme,\n options,\n limitInPlot,\n syncViewPadding,\n } = props;\n\n this.parent = parent;\n this.canvas = canvas;\n this.backgroundGroup = backgroundGroup;\n this.middleGroup = middleGroup;\n this.foregroundGroup = foregroundGroup;\n this.region = region;\n this.padding = padding;\n this.appendPadding = appendPadding;\n // 接受父 view 传入的参数\n this.options = { ...this.options, ...options };\n this.limitInPlot = limitInPlot;\n this.id = id;\n this.syncViewPadding = syncViewPadding;\n\n // 初始化 theme\n this.themeObject = isObject(theme) ? deepMix({}, getTheme('default'), createTheme(theme)) : getTheme(theme);\n this.init();\n }\n\n /**\n * 设置 layout 布局函数\n * @param layout 布局函数\n * @returns void\n */\n public setLayout(layout: Layout) {\n this.layoutFunc = layout;\n }\n\n /**\n * 生命周期:初始化\n * @returns voids\n */\n public init() {\n // 计算画布的 viewBBox\n this.calculateViewBBox();\n\n // 事件委托机制\n this.initEvents();\n\n // 初始化组件 controller\n this.initComponentController();\n\n this.initOptions();\n }\n\n /**\n * 生命周期:渲染流程,渲染过程需要处理数据更新的情况。\n * render 函数仅仅会处理 view 和子 view。\n * @param isUpdate 是否触发更新流程。\n * @param params render 事件参数\n */\n public render(isUpdate: boolean = false, payload?: EventPayload) {\n this.emit(VIEW_LIFE_CIRCLE.BEFORE_RENDER, Event.fromData(this, VIEW_LIFE_CIRCLE.BEFORE_RENDER, payload));\n // 递归渲染\n this.paint(isUpdate);\n\n this.emit(VIEW_LIFE_CIRCLE.AFTER_RENDER, Event.fromData(this, VIEW_LIFE_CIRCLE.AFTER_RENDER, payload));\n\n if (this.visible === false) {\n // 用户在初始化的时候声明 visible: false\n this.changeVisible(false);\n }\n }\n\n /**\n * 生命周期:清空图表上所有的绘制内容,但是不销毁图表,chart 仍可使用。\n * @returns void\n */\n public clear() {\n this.emit(VIEW_LIFE_CIRCLE.BEFORE_CLEAR);\n // 1. 清空缓存和计算数据\n this.filteredData = [];\n this.coordinateInstance = undefined;\n this.isDataChanged = false; // 复位\n this.isCoordinateChanged = false; // 复位\n\n // 2. 清空 geometries\n const geometries = this.geometries;\n for (let i = 0; i < geometries.length; i++) {\n geometries[i].clear();\n // view 中使用 geometry 的时候,还需要清空它的容器,不然下一次 chart.geometry() 的时候,又创建了一个,导致泄露, #2799。\n geometries[i].container.remove(true);\n geometries[i].labelsContainer.remove(true);\n }\n this.geometries = [];\n\n // 3. 清空 controllers\n const controllers = this.controllers;\n for (let i = 0; i < controllers.length; i++) {\n if (controllers[i].name === 'annotation') {\n // 需要清空配置项\n (controllers[i] as Annotation).clear(true);\n } else {\n controllers[i].clear();\n }\n }\n\n // 4. 删除 scale 缓存\n this.createdScaleKeys.forEach((v: boolean, k: string) => {\n this.getRootView().scalePool.deleteScale(k);\n });\n this.createdScaleKeys.clear();\n\n // 递归处理子 view\n const views = this.views;\n for (let i = 0; i < views.length; i++) {\n views[i].clear();\n }\n\n this.emit(VIEW_LIFE_CIRCLE.AFTER_CLEAR);\n }\n\n /**\n * 生命周期:销毁,完全无法使用。\n * @returns void\n */\n public destroy() {\n // 销毁前事件,销毁之后已经没有意义了,所以不抛出事件\n this.emit(VIEW_LIFE_CIRCLE.BEFORE_DESTROY);\n const interactions = this.interactions;\n // 销毁 interactions\n each(interactions, (interaction) => {\n if (interaction) {\n // 有可能已经销毁,设置了 undefined\n interaction.destroy();\n }\n });\n\n this.clear();\n\n // 销毁 controller 中的组件\n const controllers = this.controllers;\n for (let i = 0, len = controllers.length; i < len; i++) {\n const controller = controllers[i];\n controller.destroy();\n }\n\n this.backgroundGroup.remove(true);\n this.middleGroup.remove(true);\n this.foregroundGroup.remove(true);\n\n super.destroy();\n }\n /* end 生命周期函数 */\n\n /**\n * 显示或者隐藏整个 view。\n * @param visible 是否可见\n * @returns View\n */\n public changeVisible(visible: boolean): View {\n super.changeVisible(visible);\n\n const geometries = this.geometries;\n for (let i = 0, len = geometries.length; i < len; i++) {\n const geometry = geometries[i];\n geometry.changeVisible(visible);\n }\n\n const controllers = this.controllers;\n for (let i = 0, len = controllers.length; i < len; i++) {\n const controller = controllers[i];\n controller.changeVisible(visible);\n }\n\n this.foregroundGroup.set('visible', visible);\n this.middleGroup.set('visible', visible);\n this.backgroundGroup.set('visible', visible);\n\n // group.set('visible', visible) 不会触发自动刷新\n this.getCanvas().draw();\n\n return this;\n }\n\n /**\n * 装载数据源。\n *\n * ```ts\n * view.data([{ city: '杭州', sale: 100 }, { city: '上海', sale: 110 } ]);\n * ```\n *\n * @param data 数据源,json 数组。\n * @returns View\n */\n public data(data: Data): View {\n set(this.options, 'data', data);\n this.isDataChanged = true;\n return this;\n }\n\n /**\n * @deprecated\n * This method will be removed at G2 V4.1. Replaced by {@link #data(data)}\n */\n public source(data: Data): View {\n console.warn('This method will be removed at G2 V4.1. Please use chart.data() instead.');\n return this.data(data);\n }\n\n /**\n * 设置数据筛选规则。\n *\n * ```ts\n * view.filter('city', (value: any, datum: Datum) => value !== '杭州');\n *\n * // 删除 'city' 字段对应的筛选规则。\n * view.filter('city', null);\n * ```\n *\n * @param field 数据字段\n * @param condition 筛选规则\n * @returns View\n */\n public filter(field: string, condition: FilterCondition | null): View {\n if (isFunction(condition)) {\n set(this.options, ['filters', field], condition);\n return this;\n }\n // condition 为空,则表示删除过滤条件\n if (!condition && get(this.options, ['filters', field])) {\n delete this.options.filters[field];\n }\n\n return this;\n }\n\n /**\n * 开启或者关闭坐标轴。\n *\n * ```ts\n * view.axis(false); // 不展示坐标轴\n * ```\n * @param field 坐标轴开关\n */\n public axis(field: boolean): View;\n /**\n * 对特定的某条坐标轴进行配置。\n *\n * @example\n * ```ts\n * view.axis('city', false); // 不展示 'city' 字段对应的坐标轴\n *\n * // 将 'city' 字段对应的坐标轴的标题隐藏\n * view.axis('city', {\n * title: null,\n * });\n * ```\n *\n * @param field 要配置的坐标轴对应的字段名称\n * @param axisOption 坐标轴具体配置,更详细的配置项可以参考:https://github.com/antvis/component#axis\n */\n public axis(field: string, axisOption: AxisOption): View;\n public axis(field: string | boolean, axisOption?: AxisOption): View {\n if (isBoolean(field)) {\n set(this.options, ['axes'], field);\n } else {\n set(this.options, ['axes', field], axisOption);\n }\n\n return this;\n }\n\n /**\n * 对图例进行整体配置。\n *\n * ```ts\n * view.legend(false); // 关闭图例\n *\n * view.legend({\n * position: 'right',\n * }); // 图例进行整体配置\n * ```\n * @param field\n * @returns View\n */\n public legend(field: LegendOption): View;\n /**\n * 对特定的图例进行配置。\n *\n * @example\n * ```ts\n * view.legend('city', false); // 关闭某个图例,通过数据字段名进行关联\n *\n * // 对特定的图例进行配置\n * view.legend('city', {\n * position: 'right',\n * });\n * ```\n *\n * @param field 图例对应的数据字段名称\n * @param legendOption 图例配置,更详细的配置项可以参考:https://github.com/antvis/component#axis\n * @returns View\n */\n public legend(field: string, legendOption: LegendOption): View;\n public legend(field: string | LegendOption, legendOption?: LegendOption): View {\n if (isBoolean(field)) {\n set(this.options, ['legends'], field);\n } else if (isString(field)) {\n set(this.options, ['legends', field], legendOption);\n if (isPlainObject(legendOption) && legendOption?.selected) {\n set(this.options, ['filters', field], (name: string) => {\n return legendOption?.selected[name] ?? true;\n });\n }\n } else {\n // 设置全局的 legend 配置\n set(this.options, ['legends'], field);\n }\n\n return this;\n }\n\n /**\n * 批量设置 scale 配置。\n *\n * ```ts\n * view.scale({\n * sale: {\n * min: 0,\n * max: 100,\n * }\n * });\n * ```\n * Scale 的详细配置项可以参考:https://github.com/antvis/scale#api\n * @returns View\n */\n public scale(field: Record): View;\n /**\n * 为特性的数据字段进行 scale 配置。\n *\n * ```ts\n * view.scale('sale', {\n * min: 0,\n * max: 100,\n * });\n * ```\n *\n * @returns View\n */\n public scale(field: string, scaleOption: ScaleOption): View;\n public scale(field: string | Record, scaleOption?: ScaleOption): View {\n if (isString(field)) {\n set(this.options, ['scales', field], scaleOption);\n } else if (isObject(field)) {\n each(field, (v: ScaleOption, k: string) => {\n set(this.options, ['scales', k], v);\n });\n }\n\n return this;\n }\n\n /**\n * tooltip 提示信息配置。\n *\n * ```ts\n * view.tooltip(false); // 关闭 tooltip\n *\n * view.tooltip({\n * shared: true\n * });\n * ```\n *\n * @param cfg Tooltip 配置,更详细的配置项参考:https://github.com/antvis/component#tooltip\n * @returns View\n */\n public tooltip(cfg: boolean | TooltipOption): View {\n set(this.options, 'tooltip', cfg);\n\n return this;\n }\n\n /**\n * 辅助标记配置。\n *\n * ```ts\n * view.annotation().line({\n * start: ['min', 85],\n * end: ['max', 85],\n * style: {\n * stroke: '#595959',\n * lineWidth: 1,\n * lineDash: [3, 3],\n * },\n * });\n * ```\n * 更详细的配置项:https://github.com/antvis/component#annotation\n * @returns [[Annotation]]\n */\n public annotation(): Annotation {\n return this.getController('annotation');\n }\n\n /**\n * @deprecated\n * This method will be removed at G2 V4.1. Replaced by {@link #guide()}\n */\n public guide(): Annotation {\n console.warn('This method will be removed at G2 V4.1. Please use chart.annotation() instead.');\n return this.annotation();\n }\n\n /**\n * 坐标系配置。\n *\n * @example\n * ```ts\n * view.coordinate({\n * type: 'polar',\n * cfg: {\n * radius: 0.85,\n * },\n * actions: [\n * [ 'transpose' ],\n * ],\n * });\n * ```\n *\n * @param option\n * @returns\n */\n public coordinate(option?: CoordinateOption): CoordinateController;\n /**\n * 声明坐标系类型,并进行配置。\n *\n * ```ts\n * // 直角坐标系,并进行转置变换\n * view.coordinate('rect').transpose();\n *\n * // 默认创建直角坐标系\n * view.coordinate();\n * ```\n *\n * @param type 坐标系类型\n * @param [coordinateCfg] 坐标系配置\n * @returns\n */\n public coordinate(type: string, coordinateCfg?: CoordinateCfg): CoordinateController;\n public coordinate(type: string | CoordinateOption, coordinateCfg?: CoordinateCfg): CoordinateController {\n // 提供语法糖,使用更简单\n if (isString(type)) {\n set(this.options, 'coordinate', { type, cfg: coordinateCfg } as CoordinateOption);\n } else {\n set(this.options, 'coordinate', type);\n }\n\n // 更新 coordinate 配置\n this.coordinateController.update(this.options.coordinate);\n\n return this.coordinateController;\n }\n\n /**\n * @deprecated\n * This method will be removed at G2 V4.1. Replaced by {@link #coordinate()}\n */\n public coord(type: string | CoordinateOption, coordinateCfg?: CoordinateCfg): CoordinateController {\n console.warn('This method will be removed at G2 V4.1. Please use chart.coordinate() instead.');\n // @ts-ignore\n return this.coordinate(type, coordinateCfg);\n }\n\n /**\n * view 分面绘制。\n *\n * ```ts\n * view.facet('rect', {\n * rowField: 'province',\n * columnField: 'category',\n * eachView: (innerView: View, facet?: FacetData) => {\n * innerView.line().position('city*sale');\n * },\n * });\n * ```\n *\n * @param type 分面类型\n * @param cfg 分面配置, [[FacetCfgMap]]\n * @returns View\n */\n public facet(type: T, cfg: FacetCfgMap[T]): View {\n // 先销毁掉之前的分面\n if (this.facetInstance) {\n this.facetInstance.destroy();\n }\n\n // 创建新的分面\n const Ctor = getFacet(type);\n\n if (!Ctor) {\n throw new Error(`facet '${type}' is not exist!`);\n }\n\n this.facetInstance = new Ctor(this, { ...cfg, type });\n\n return this;\n }\n\n /*\n * 开启或者关闭动画。\n *\n * ```ts\n * view.animate(false);\n * ```\n *\n * @param status 动画状态,true 表示开始,false 表示关闭\n * @returns View\n */\n public animate(status: boolean): View {\n set(this.options, 'animate', status);\n return this;\n }\n\n /**\n * 更新配置项,用于配置项式声明。\n * @param options 配置项\n */\n public updateOptions(options: Options) {\n this.clear(); // 清空\n mix(this.options, options);\n\n // 需要把已存在的 view 销毁,否则会重复创建\n // 目前针对配置项还没有特别好的 view 更新机制,为了不影响主流流程,所以在这里直接销毁\n this.views.forEach((view) => view.destroy());\n this.views = [];\n\n this.initOptions();\n // 初始化坐标系大小,保证 padding 计算正确\n this.coordinateBBox = this.viewBBox;\n return this;\n }\n\n /**\n * 往 `view.options` 属性中存储配置项。\n * @param name 属性名称\n * @param opt 属性值\n * @returns view\n */\n public option(name: string, opt: any): View {\n // 对于内置的 option,避免覆盖。\n // name 在原型上,说明可能是内置 API,存在 option 被覆盖的风险,不处理\n if (View.prototype[name]) {\n throw new Error(`Can't use built in variable name \"${name}\", please change another one.`);\n }\n\n // 存入到 option 中\n set(this.options, name, opt);\n return this;\n }\n\n /**\n * 设置主题。\n *\n * ```ts\n * view.theme('dark'); // 'dark' 需要事先通过 `registerTheme()` 接口注册完成\n *\n * view.theme({ defaultColor: 'red' });\n * ```\n *\n * @param theme 主题名或者主题配置\n * @returns View\n */\n public theme(theme: string | LooseObject): View {\n this.themeObject = isObject(theme) ? deepMix({}, this.themeObject, createTheme(theme)) : getTheme(theme);\n\n return this;\n }\n\n /* end 一系列传入配置的 API */\n\n /**\n * Call the interaction based on the interaction name\n *\n * ```ts\n * view.interaction('my-interaction', { extra: 'hello world' });\n * ```\n * 详细文档可以参考:https://g2.antv.vision/zh/docs/api/general/interaction\n * @param name interaction name\n * @param cfg interaction config\n * @returns\n */\n public interaction(name: string, cfg?: LooseObject): View {\n const existInteraction = this.interactions[name];\n // 存在则先销毁已有的\n if (existInteraction) {\n existInteraction.destroy();\n }\n\n // 新建交互实例\n const interaction = createInteraction(name, this, cfg);\n if (interaction) {\n interaction.init();\n this.interactions[name] = interaction;\n }\n return this;\n }\n\n /**\n * 移除当前 View 的 interaction\n * ```ts\n * view.removeInteraction('my-interaction');\n * ```\n * @param name interaction name\n */\n public removeInteraction(name: string) {\n const existInteraction = this.interactions[name];\n // 存在则先销毁已有的\n if (existInteraction) {\n existInteraction.destroy();\n this.interactions[name] = undefined;\n }\n }\n\n /**\n * 修改数据,数据更新逻辑,数据更新仅仅影响当前这一层的 view\n *\n * ```ts\n * view.changeData([{ city: '北京', sale: '200' }]);\n * ```\n *\n * @param data\n * @returns void\n */\n public changeData(data: Data) {\n this.isDataChanged = true;\n this.emit(VIEW_LIFE_CIRCLE.BEFORE_CHANGE_DATA, Event.fromData(this, VIEW_LIFE_CIRCLE.BEFORE_CHANGE_DATA, null));\n // 1. 保存数据\n this.data(data);\n\n // 2. 渲染\n this.paint(true);\n\n // 3. 遍历子 view 进行 change data\n const views = this.views;\n for (let i = 0, len = views.length; i < len; i++) {\n const view = views[i];\n // FIXME 子 view 有自己的数据的情况,该如何处理?\n view.changeData(data);\n }\n\n this.emit(VIEW_LIFE_CIRCLE.AFTER_CHANGE_DATA, Event.fromData(this, VIEW_LIFE_CIRCLE.AFTER_CHANGE_DATA, null));\n }\n\n /* View 管理相关的 API */\n\n /**\n * 创建子 view\n *\n * ```ts\n * const innerView = view.createView({\n * start: { x: 0, y: 0 },\n * end: { x: 0.5, y: 0.5 },\n * padding: 8,\n * });\n * ```\n *\n * @param cfg\n * @returns View\n */\n public createView(cfg?: Partial): View {\n // 将会在 4.1 版本中移除递归嵌套 view,仅仅只允许 chart - view 两层。\n // 这个 API 理论上用户量不多,所以暂时不发大版本,所以先暂时打一个 warning。\n if (this.parent && this.parent.parent) {\n // 存在 3 层 结构了\n console.warn('The view nesting recursive feature will be removed at G2 V4.1. Please avoid to use it.');\n }\n\n // 子 view 共享 options 配置数据\n const sharedOptions = {\n data: this.options.data,\n scales: clone(this.options.scales),\n axes: clone(this.options.axes),\n coordinate: clone(this.coordinateController.getOption()),\n tooltip: clone(this.options.tooltip),\n legends: clone(this.options.legends),\n animate: this.options.animate,\n visible: this.visible,\n };\n\n const v = new View({\n parent: this,\n canvas: this.canvas,\n // 子 view 共用三层 group\n backgroundGroup: this.backgroundGroup.addGroup({ zIndex: GROUP_Z_INDEX.BG }),\n middleGroup: this.middleGroup.addGroup({ zIndex: GROUP_Z_INDEX.MID }),\n foregroundGroup: this.foregroundGroup.addGroup({ zIndex: GROUP_Z_INDEX.FORE }),\n theme: this.themeObject,\n padding: this.padding,\n ...cfg,\n options: {\n ...sharedOptions,\n ...get(cfg, 'options', {}),\n },\n });\n\n this.views.push(v);\n\n return v;\n }\n\n /**\n * @deprecated\n * This method will be removed at G2 V4.1. Replaced by {@link #createView()}\n */\n public view(cfg?: Partial) {\n console.warn('This method will be removed at G2 V4.1. Please use chart.createView() instead.');\n return this.createView(cfg);\n }\n\n /**\n * 删除一个子 view\n * @param view\n * @return removedView\n */\n public removeView(view: View): View {\n const removedView = remove(this.views, (v: View) => v === view)[0];\n\n if (removedView) {\n removedView.destroy();\n }\n\n return removedView;\n }\n /* end View 管理相关的 API */\n\n // 一些 get 方法\n\n /**\n * 获取当前坐标系实例。\n * @returns [[Coordinate]]\n */\n public getCoordinate() {\n return this.coordinateInstance;\n }\n\n /**\n * 获取当前 view 的主题配置。\n * @returns themeObject\n */\n public getTheme(): LooseObject {\n return this.themeObject;\n }\n\n /**\n * 获得 x 轴字段的 scale 实例。\n * @returns view 中 Geometry 对于的 x scale\n */\n public getXScale(): Scale {\n // 拿第一个 Geometry 的 X scale\n // 隐藏逻辑:一个 view 中的 Geometry 必须 x 字段一致\n const g = this.geometries[0];\n return g ? g.getXScale() : null;\n }\n\n /**\n * 获取 y 轴字段的 scales 实例。\n * @returns view 中 Geometry 对于的 y scale 数组\n */\n public getYScales(): Scale[] {\n // 拿到所有的 Geometry 的 Y scale,然后去重\n const tmpMap = {};\n const yScales = [];\n this.geometries.forEach((g: Geometry) => {\n const yScale = g.getYScale();\n const field = yScale.field;\n if (!tmpMap[field]) {\n tmpMap[field] = true;\n yScales.push(yScale);\n }\n });\n return yScales;\n }\n\n /**\n * 获取 x 轴或者 y 轴对应的所有 scale 实例。\n * @param dimType x | y\n * @returns x 轴或者 y 轴对应的所有 scale 实例。\n */\n public getScalesByDim(dimType: 'x' | 'y'): Record {\n const geometries = this.geometries;\n const scales = {};\n\n for (let i = 0, len = geometries.length; i < len; i++) {\n const geometry = geometries[i];\n const scale = dimType === 'x' ? geometry.getXScale() : geometry.getYScale();\n if (scale && !scales[scale.field]) {\n scales[scale.field] = scale;\n }\n }\n\n return scales;\n }\n\n /**\n * 根据字段名去获取 scale 实例。\n * @param field 数据字段名称\n * @param key id\n */\n public getScale(field: string, key?: string): Scale {\n const defaultKey = key ? key : this.getScaleKey(field);\n // 调用根节点 view 的方法获取\n return this.getRootView().scalePool.getScale(defaultKey);\n }\n\n /**\n * @deprecated\n * This method will be removed at G2 V4.1. Please use `getScale`.\n */\n public getScaleByField(field: string, key?: string): Scale {\n return this.getScale(field, key);\n }\n\n /**\n * 返回所有配置信息。\n * @returns 所有的 view API 配置。\n */\n public getOptions(): Options {\n return this.options;\n }\n\n /**\n * 获取 view 的数据(过滤后的数据)。\n * @returns 处理过滤器之后的数据。\n */\n public getData() {\n return this.filteredData;\n }\n\n /**\n * 获取原始数据\n * @returns 传入 G2 的原始数据\n */\n public getOriginalData() {\n return this.options.data;\n }\n\n /**\n * 获取布局后的边距 padding\n * @returns\n */\n public getPadding(): Padding {\n return this.autoPadding.getPadding();\n }\n\n /**\n * 获取当前 view 有的 geometries\n * @returns\n */\n public getGeometries() {\n return this.geometries;\n }\n\n /**\n * 获取 view 中的所有 geome\n */\n public getElements(): Element[] {\n return reduce(\n this.geometries,\n (elements: Element[], geometry: Geometry) => {\n return elements.concat(geometry.getElements());\n },\n []\n );\n }\n\n /**\n * 根据一定的规则查找 Geometry 的 Elements。\n *\n * ```typescript\n * getElementsBy((element) => {\n * const data = element.getData();\n *\n * return data.a === 'a';\n * });\n * ```\n *\n * @param condition 定义查找规则的回调函数。\n * @returns\n */\n public getElementsBy(condition: (element: Element) => boolean): Element[] {\n return this.getElements().filter((el) => condition(el));\n }\n\n /**\n * 获得绘制的层级 group。\n * @param layer 层级名称。\n * @returns 对应层级的 Group。\n */\n public getLayer(layer: LAYER): IGroup {\n return layer === LAYER.BG\n ? this.backgroundGroup\n : layer === LAYER.MID\n ? this.middleGroup\n : layer === LAYER.FORE\n ? this.foregroundGroup\n : this.foregroundGroup;\n }\n\n /**\n * 对外暴露方法,判断一个点是否在绘图区域(即坐标系范围)内部。\n * @param point 坐标点\n */\n public isPointInPlot(point: Point): boolean {\n return isPointInCoordinate(this.getCoordinate(), point);\n }\n\n /**\n * 获得所有的 legend 对应的 attribute 实例。\n * @returns 维度字段的 Attribute 数组\n */\n public getLegendAttributes(): Attribute[] {\n return flatten(this.geometries.map((g: Geometry) => g.getGroupAttributes())) as unknown as Attribute[];\n }\n\n /**\n * 获取所有的分组字段的 scale 实例。\n * @returns 获得分组字段的 scale 实例数组。\n */\n public getGroupScales(): Scale[] {\n // 拿到所有的 Geometry 的 分组字段 scale,然后打平去重\n const scales = this.geometries.map((g: Geometry) => g.getGroupScales());\n return uniq(flatten(scales));\n }\n\n /**\n * 获取 G.Canvas 实例。\n * @returns G.Canvas 画布实例。\n */\n public getCanvas(): ICanvas {\n return (this.getRootView() as unknown as Chart).canvas;\n }\n\n /**\n * 获得根节点 view。\n */\n public getRootView(): View {\n let v = this as View;\n\n while (true) {\n if (v.parent) {\n v = v.parent;\n continue;\n }\n break;\n }\n return v;\n }\n\n /**\n * 获取该数据在可视化后,对应的画布坐标点。\n * @param data 原始数据记录\n * @returns 对应的画布坐标点\n */\n public getXY(data: Datum): Point {\n const coordinate = this.getCoordinate();\n const xScales = this.getScalesByDim('x');\n const yScales = this.getScalesByDim('y');\n let x;\n let y;\n\n each(data, (value, key) => {\n if (xScales[key]) {\n x = xScales[key].scale(value);\n }\n if (yScales[key]) {\n y = yScales[key].scale(value);\n }\n });\n\n if (!isNil(x) && !isNil(y)) {\n return coordinate.convert({ x, y });\n }\n }\n\n public getController(name: 'tooltip'): Tooltip;\n public getController(name: 'axis'): Axis;\n public getController(name: 'legend'): Legend;\n public getController(name: 'scrollbar'): Scrollbar;\n public getController(name: 'slider'): Slider;\n public getController(name: 'annotation'): Annotation;\n public getController(name: 'gestucre'): Gesture;\n public getController(name: string): Controller;\n /**\n * 获取 name 对应的 controller 实例\n * @param name\n */\n public getController(name: string): Controller {\n return find(this.controllers, (c: Controller) => c.name === name);\n }\n\n /**\n * 显示 point 坐标点对应的 tooltip。\n * @param point 画布坐标点\n * @returns View\n */\n public showTooltip(point: Point): View {\n const tooltip = this.getController('tooltip');\n if (tooltip) {\n tooltip.showTooltip(point);\n }\n return this;\n }\n\n /**\n * 隐藏 tooltip。\n * @returns View\n */\n public hideTooltip(): View {\n const tooltip = this.getController('tooltip');\n if (tooltip) {\n tooltip.hideTooltip();\n }\n return this;\n }\n\n /**\n * 将 tooltip 锁定到当前位置不能移动。\n * @returns View\n */\n public lockTooltip(): View {\n const tooltip = this.getController('tooltip');\n if (tooltip) {\n tooltip.lockTooltip();\n }\n return this;\n }\n\n /**\n * 将 tooltip 锁定解除。\n * @returns View\n */\n public unlockTooltip(): View {\n const tooltip = this.getController('tooltip');\n if (tooltip) {\n tooltip.unlockTooltip();\n }\n return this;\n }\n\n /**\n * 是否锁定 tooltip。\n * @returns 是否锁定\n */\n public isTooltipLocked() {\n const tooltip = this.getController('tooltip');\n return tooltip && tooltip.isTooltipLocked();\n }\n\n /**\n * 获取当前 point 对应的 tooltip 数据项。\n * @param point 坐标点\n * @returns tooltip 数据项\n */\n public getTooltipItems(point: Point) {\n const tooltip = this.getController('tooltip');\n\n return tooltip ? tooltip.getTooltipItems(point) : [];\n }\n\n /**\n * 获取逼近的点的数据集合\n * @param point 当前坐标点\n * @returns 数据\n */\n public getSnapRecords(point: Point) {\n const geometries = this.geometries;\n let rst = [];\n for (let i = 0, len = geometries.length; i < len; i++) {\n const geom = geometries[i];\n const dataArray = geom.dataArray;\n geom.sort(dataArray); // 先进行排序,便于 tooltip 查找\n let record;\n for (let j = 0, dataLen = dataArray.length; j < dataLen; j++) {\n const data = dataArray[j];\n record = findDataByPoint(point, data, geom);\n if (record) {\n rst.push(record);\n }\n }\n }\n\n // 同样递归处理子 views\n const views = this.views;\n for (let i = 0, len = views.length; i < len; i++) {\n const view = views[i];\n const snapRecords = view.getSnapRecords(point);\n rst = rst.concat(snapRecords);\n }\n\n return rst;\n }\n\n /**\n * 获取所有的 pure component 组件,用于布局。\n */\n public getComponents(): ComponentOption[] {\n let components = [];\n const controllers = this.controllers;\n for (let i = 0, len = controllers.length; i < len; i++) {\n const controller = controllers[i];\n components = components.concat(controller.getComponents());\n }\n\n return components;\n }\n\n /**\n * 将 data 数据进行过滤。\n * @param data\n * @returns 过滤之后的数据\n */\n public filterData(data: Data): Data {\n const { filters } = this.options;\n // 不存在 filters,则不需要进行数据过滤\n if (size(filters) === 0) {\n return data;\n }\n\n // 存在过滤器,则逐个执行过滤,过滤器之间是 与 的关系\n return filter(data, (datum: Datum, idx: number) => {\n // 所有的 filter 字段\n const fields = Object.keys(filters);\n\n // 所有的条件都通过,才算通过\n return fields.every((field: string) => {\n const condition = filters[field];\n\n // condition 返回 true,则保留\n return condition(datum[field], datum, idx);\n });\n });\n }\n\n /**\n * 对某一个字段进行过滤\n * @param field\n * @param data\n */\n public filterFieldData(field: string, data: Data): Data {\n const { filters } = this.options;\n const condition = get(filters, field);\n\n if (isUndefined(condition)) {\n return data;\n }\n return data.filter((datum: Datum, idx: number) => condition(datum[field], datum, idx));\n }\n\n /**\n * 调整 coordinate 的坐标范围。\n */\n public adjustCoordinate() {\n const { start: curStart, end: curEnd } = this.getCoordinate();\n const start = this.coordinateBBox.bl;\n const end = this.coordinateBBox.tr;\n\n // 在 defaultLayoutFn 中只会在 coordinateBBox 发生变化的时候会调用 adjustCoordinate(),所以不用担心被置位\n if (isEqual(curStart, start) && isEqual(curEnd, end)) {\n this.isCoordinateChanged = false;\n // 如果大小没有变化则不更新\n return;\n }\n this.isCoordinateChanged = true;\n this.coordinateInstance = this.coordinateController.adjust(start, end);\n }\n\n protected paint(isUpdate: boolean) {\n this.renderDataRecursive(isUpdate);\n\n // 处理 sync scale 的逻辑\n this.syncScale();\n\n this.emit(VIEW_LIFE_CIRCLE.BEFORE_PAINT);\n\n // 初始化图形、组件位置,计算 padding\n this.renderPaddingRecursive(isUpdate);\n // 布局图形、组件\n this.renderLayoutRecursive(isUpdate);\n // 背景色 shape\n this.renderBackgroundStyleShape();\n // 最终的绘制 render\n this.renderPaintRecursive(isUpdate);\n\n this.emit(VIEW_LIFE_CIRCLE.AFTER_PAINT);\n\n this.isDataChanged = false; // 渲染完毕复位\n }\n\n /**\n * 渲染背景样式的 shape。\n * 放到 view 中创建的原因是让使用 view 绘制图形的时候,也能够处理背景色\n */\n private renderBackgroundStyleShape() {\n // 只有根节点才处理\n if (this.parent) {\n return;\n }\n const background = get(this.themeObject, 'background');\n // 配置了背景色\n if (background) {\n // 1. 不存在则创建\n if (!this.backgroundStyleRectShape) {\n this.backgroundStyleRectShape = this.backgroundGroup.addShape('rect', {\n attrs: {},\n zIndex: -1,\n // 背景色 shape 不设置事件捕获\n capture: false,\n });\n this.backgroundStyleRectShape.toBack();\n }\n\n // 2. 有了 shape 之后设置背景,位置(更新的时候)\n const { x, y, width, height } = this.viewBBox;\n this.backgroundStyleRectShape.attr({\n fill: background,\n x,\n y,\n width,\n height,\n });\n } else {\n // 没有配置背景色\n if (this.backgroundStyleRectShape) {\n this.backgroundStyleRectShape.remove(true);\n this.backgroundStyleRectShape = undefined;\n }\n }\n }\n\n /**\n * 递归计算每个 view 的 padding 值,coordinateBBox 和 coordinateInstance\n * @param isUpdate\n */\n protected renderPaddingRecursive(isUpdate: boolean) {\n // 1. 子 view 大小相对 coordinateBBox,changeSize 的时候需要重新计算\n this.calculateViewBBox();\n // 2. 更新 coordinate\n this.adjustCoordinate();\n // 3. 初始化组件 component\n this.initComponents(isUpdate);\n // 4. 布局计算每隔 view 的 padding 值\n // 4.1. 自动加 auto padding -> absolute padding,并且增加 appendPadding\n this.autoPadding = calculatePadding(this).shrink(parsePadding(this.appendPadding));\n // 4.2. 计算出新的 coordinateBBox,更新 Coordinate\n // 这里必须保留,原因是后面子 view 的 viewBBox 或根据 parent 的 coordinateBBox\n this.coordinateBBox = this.viewBBox.shrink(this.autoPadding.getPadding());\n this.adjustCoordinate();\n\n // 刷新 tooltip (tooltip crosshairs 依赖 coordinate 位置)\n const tooltipController = this.controllers.find((c) => c.name === 'tooltip');\n tooltipController.update();\n\n // 同样递归处理子 views\n const views = this.views;\n for (let i = 0, len = views.length; i < len; i++) {\n const view = views[i];\n view.renderPaddingRecursive(isUpdate);\n }\n }\n\n /**\n * 递归处理 view 的布局,最终是计算各个 view 的 coordinateBBox 和 coordinateInstance\n * @param isUpdate\n */\n protected renderLayoutRecursive(isUpdate: boolean) {\n // 1. 同步子 view padding\n // 根据配置获取 padding\n const syncViewPaddingFn =\n this.syncViewPadding === true\n ? defaultSyncViewPadding\n : isFunction(this.syncViewPadding)\n ? this.syncViewPadding\n : undefined;\n\n if (syncViewPaddingFn) {\n syncViewPaddingFn(this, this.views, PaddingCal);\n // 同步 padding 之后,更新 coordinate\n this.views.forEach((v: View) => {\n v.coordinateBBox = v.viewBBox.shrink(v.autoPadding.getPadding());\n v.adjustCoordinate();\n });\n }\n\n // 3. 将 view 中的组件按照 view padding 移动到对应的位置\n this.doLayout();\n\n // 同样递归处理子 views\n const views = this.views;\n for (let i = 0, len = views.length; i < len; i++) {\n const view = views[i];\n view.renderLayoutRecursive(isUpdate);\n }\n }\n\n /**\n * 最终递归绘制组件和图形\n * @param isUpdate\n */\n protected renderPaintRecursive(isUpdate: boolean) {\n const middleGroup = this.middleGroup;\n if (this.limitInPlot) {\n const { type, attrs } = getCoordinateClipCfg(this.coordinateInstance);\n middleGroup.setClip({\n type,\n attrs,\n });\n } else {\n // 清除已有的 clip\n middleGroup.setClip(undefined);\n }\n\n // 1. 渲染几何标记\n this.paintGeometries(isUpdate);\n // 2. 绘制组件\n this.renderComponents(isUpdate);\n\n // 同样递归处理子 views\n const views = this.views;\n for (let i = 0, len = views.length; i < len; i++) {\n const view = views[i];\n view.renderPaintRecursive(isUpdate);\n }\n }\n\n // end Get 方法\n\n /**\n * 创建 scale,递归到顶层 view 去创建和缓存 scale\n * @param field\n * @param data\n * @param scaleDef\n * @param key\n */\n protected createScale(field: string, data: Data, scaleDef: ScaleOption, key: string): Scale {\n // 1. 合并 field 对应的 scaleDef,合并原则是底层覆盖顶层(就近原则)\n const currentScaleDef = get(this.options.scales, [field]);\n const mergedScaleDef = { ...currentScaleDef, ...scaleDef };\n\n // 2. 是否存在父 view,在则递归,否则创建\n if (this.parent) {\n return this.parent.createScale(field, data, mergedScaleDef, key);\n }\n\n // 3. 在根节点 view 通过 scalePool 创建\n return this.scalePool.createScale(field, data, mergedScaleDef, key);\n }\n\n /**\n * 递归渲染中的数据处理\n * @param isUpdate\n */\n private renderDataRecursive(isUpdate: boolean) {\n // 1. 处理数据\n this.doFilterData();\n // 2. 创建实例\n this.createCoordinate();\n // 3. 初始化 Geometry\n this.initGeometries(isUpdate);\n // 4. 处理分面逻辑,最终都是生成子 view 和 geometry\n this.renderFacet(isUpdate);\n\n // 同样递归处理子 views\n const views = this.views;\n for (let i = 0, len = views.length; i < len; i++) {\n const view = views[i];\n view.renderDataRecursive(isUpdate);\n }\n }\n\n /**\n * 计算 region,计算实际的像素范围坐标\n * @private\n */\n private calculateViewBBox() {\n let x;\n let y;\n let width;\n let height;\n\n if (this.parent) {\n const bbox = this.parent.coordinateBBox;\n // 存在 parent, 那么就是通过父容器大小计算\n x = bbox.x;\n y = bbox.y;\n width = bbox.width;\n height = bbox.height;\n } else {\n // 顶层容器,从 canvas 中取值 宽高\n x = 0;\n y = 0;\n width = this.canvas.get('width');\n height = this.canvas.get('height');\n }\n\n const { start, end } = this.region;\n\n // 根据 region 计算当前 view 的 bbox 大小。\n const viewBBox = new BBox(\n x + width * start.x,\n y + height * start.y,\n width * (end.x - start.x),\n height * (end.y - start.y)\n );\n\n if (!this.viewBBox || !this.viewBBox.isEqual(viewBBox)) {\n // viewBBox 发生变化的时候进行更新\n this.viewBBox = new BBox(\n x + width * start.x,\n y + height * start.y,\n width * (end.x - start.x),\n height * (end.y - start.y)\n );\n }\n\n // 初始的 coordinate bbox 大小\n this.coordinateBBox = this.viewBBox;\n }\n\n /**\n * 初始化事件机制:G 4.0 底层内置支持 name:event 的机制,那么只要所有组件都有自己的 name 即可。\n *\n * G2 的事件只是获取事件委托,然后在 view 嵌套结构中,形成事件冒泡机制。\n * 当前 view 只委托自己 view 中的 Component 和 Geometry 事件,并向上冒泡\n * @private\n */\n private initEvents() {\n // 三层 group 中的 shape 事件都会通过 G 冒泡上来的\n this.foregroundGroup.on('*', this.onDelegateEvents);\n this.middleGroup.on('*', this.onDelegateEvents);\n this.backgroundGroup.on('*', this.onDelegateEvents);\n\n this.canvas.on('*', this.onCanvasEvent);\n }\n\n private onCanvasEvent = (evt: GEvent): void => {\n const name = evt.name;\n if (!name.includes(':')) {\n // 非委托事件\n const e = this.createViewEvent(evt);\n // 处理 plot 事件\n this.doPlotEvent(e);\n this.emit(name, e);\n }\n };\n\n /**\n * 初始化插件\n */\n private initComponentController() {\n const usedControllers = this.usedControllers;\n for (let i = 0, len = usedControllers.length; i < len; i++) {\n const controllerName = usedControllers[i];\n const Ctor = getComponentController(controllerName);\n if (Ctor) {\n this.controllers.push(new Ctor(this));\n }\n }\n }\n\n private createViewEvent(evt: GEvent) {\n const { shape, name } = evt;\n\n const data = shape ? shape.get('origin') : null;\n // 事件在 view 嵌套中冒泡(暂不提供阻止冒泡的机制)\n const e = new Event(this, evt, data);\n e.type = name;\n return e;\n }\n /**\n * 触发事件之后\n * @param evt\n */\n private onDelegateEvents = (evt: GEvent): void => {\n // 阻止继续冒泡,防止重复事件触发\n // evt.preventDefault();\n const { name } = evt;\n if (!name.includes(':')) {\n return;\n }\n // 事件在 view 嵌套中冒泡(暂不提供阻止冒泡的机制)\n const e = this.createViewEvent(evt);\n\n // 包含有基本事件、组合事件\n this.emit(name, e);\n // const currentTarget = evt.currentTarget as IShape;\n // const inheritNames = currentTarget.get('inheritNames');\n // if (evt.delegateObject || inheritNames) {\n // const events = this.getEvents();\n // each(inheritNames, (subName) => {\n // const eventName = `${subName}:${type}`;\n // if (events[eventName]) {\n // this.emit(eventName, e);\n // }\n // });\n // }\n };\n\n /**\n * 处理 PLOT_EVENTS\n * plot event 需要处理所有的基础事件,并判断是否在画布中,然后再决定是否要 emit。\n * 对于 mouseenter、mouseleave 比较特殊,需要做一下数学比较。\n * @param e\n */\n private doPlotEvent(e: Event) {\n const { type, x, y } = e;\n\n const point = { x, y };\n\n const ALL_EVENTS = [\n 'mousedown',\n 'mouseup',\n 'mousemove',\n 'mouseleave',\n 'mousewheel',\n 'touchstart',\n 'touchmove',\n 'touchend',\n 'touchcancel',\n 'click',\n 'dblclick',\n 'contextmenu',\n ];\n\n if (ALL_EVENTS.includes(type)) {\n const currentInPlot = this.isPointInPlot(point);\n const newEvent = e.clone();\n\n if (currentInPlot) {\n const TYPE = `plot:${type}`; // 组合 plot 事件\n newEvent.type = TYPE;\n this.emit(TYPE, newEvent);\n if (type === 'mouseleave' || type === 'touchend') {\n // 在plot 内部却离开画布\n this.isPreMouseInPlot = false;\n }\n }\n\n // 对于 mouseenter, mouseleave 的计算处理\n if (type === 'mousemove' || type === 'touchmove') {\n if (this.isPreMouseInPlot && !currentInPlot) {\n if (type === 'mousemove') {\n newEvent.type = PLOT_EVENTS.MOUSE_LEAVE;\n this.emit(PLOT_EVENTS.MOUSE_LEAVE, newEvent);\n }\n newEvent.type = PLOT_EVENTS.LEAVE;\n this.emit(PLOT_EVENTS.LEAVE, newEvent);\n } else if (!this.isPreMouseInPlot && currentInPlot) {\n if (type === 'mousemove') {\n newEvent.type = PLOT_EVENTS.MOUSE_ENTER;\n this.emit(PLOT_EVENTS.MOUSE_ENTER, newEvent);\n }\n newEvent.type = PLOT_EVENTS.ENTER;\n this.emit(PLOT_EVENTS.ENTER, newEvent);\n }\n // 赋新的状态值\n this.isPreMouseInPlot = currentInPlot;\n } else if (type === 'mouseleave' || type === 'touchend') {\n // 可能不在 currentInPlot 中\n if (this.isPreMouseInPlot) {\n if (type === 'mouseleave') {\n newEvent.type = PLOT_EVENTS.MOUSE_LEAVE;\n this.emit(PLOT_EVENTS.MOUSE_LEAVE, newEvent);\n }\n newEvent.type = PLOT_EVENTS.LEAVE;\n this.emit(PLOT_EVENTS.LEAVE, newEvent);\n\n this.isPreMouseInPlot = false;\n }\n }\n }\n }\n\n // view 生命周期 —— 渲染流程\n\n /**\n * 处理筛选器,筛选数据\n * @private\n */\n private doFilterData() {\n const { data } = this.options;\n this.filteredData = this.filterData(data);\n }\n\n /**\n * 初始化 Geometries\n * @private\n */\n private initGeometries(isUpdate: boolean) {\n // 初始化图形的之前,先创建 / 更新 scales\n this.createOrUpdateScales();\n // 实例化 Geometry,然后 view 将所有的 scale 管理起来\n const coordinate = this.getCoordinate();\n const scaleDefs = get(this.options, 'scales', {});\n const geometries = this.geometries;\n for (let i = 0, len = geometries.length; i < len; i++) {\n const geometry = geometries[i];\n // 保持 scales 引用不要变化\n geometry.scales = this.getGeometryScales();\n const cfg = {\n coordinate, // 使用 coordinate 引用,可以保持 coordinate 的同步更新\n scaleDefs,\n data: this.filteredData,\n theme: this.themeObject,\n isDataChanged: this.isDataChanged,\n isCoordinateChanged: this.isCoordinateChanged,\n };\n\n if (isUpdate) {\n // 数据发生更新\n geometry.update(cfg);\n } else {\n geometry.init(cfg);\n }\n }\n\n // Geometry 初始化之后,生成了 scale,然后进行调整 scale 配置\n this.adjustScales();\n }\n\n /**\n * 根据 Geometry 的所有字段创建 scales\n * 如果存在,则更新,不存在则创建\n */\n private createOrUpdateScales() {\n const fields = this.getScaleFields();\n const groupedFields = this.getGroupedFields();\n\n const { data, scales = {} } = this.getOptions();\n const filteredData = this.filteredData;\n\n for (let i = 0, len = fields.length; i < len; i++) {\n const field = fields[i];\n const scaleDef = scales[field];\n\n // 调用方法,递归去创建\n const key = this.getScaleKey(field);\n this.createScale(\n field,\n // 分组字段的 scale 使用未过滤的数据创建\n groupedFields.includes(field) ? data : filteredData,\n scaleDef,\n key\n );\n\n // 缓存从当前 view 创建的 scale key\n this.createdScaleKeys.set(key, true);\n }\n }\n\n /**\n * 处理 scale 同步逻辑\n */\n private syncScale() {\n // 最终调用 root view 的\n this.getRootView().scalePool.sync(this.getCoordinate(), this.theme);\n }\n\n /**\n * 获得 Geometry 中的 scale 对象\n */\n private getGeometryScales(): Record {\n const fields = this.getScaleFields();\n\n const scales = {};\n for (let i = 0; i < fields.length; i++) {\n const field = fields[i];\n scales[field] = this.getScaleByField(field);\n }\n\n return scales;\n }\n\n private getScaleFields() {\n const fields = [];\n const tmpMap = new Map();\n const geometries = this.geometries;\n for (let i = 0; i < geometries.length; i++) {\n const geometry = geometries[i];\n const geometryScales = geometry.getScaleFields();\n uniq(geometryScales, fields, tmpMap);\n }\n return fields;\n }\n\n private getGroupedFields() {\n const fields = [];\n const tmpMap = new Map();\n const geometries = this.geometries;\n for (let i = 0; i < geometries.length; i++) {\n const geometry = geometries[i];\n const groupFields = geometry.getGroupFields();\n uniq(groupFields, fields, tmpMap);\n }\n return fields;\n }\n\n /**\n * 调整 scale 配置\n * @private\n */\n private adjustScales() {\n // 调整目前包括:\n // 分类 scale,调整 range 范围\n this.adjustCategoryScaleRange();\n }\n\n /**\n * 调整分类 scale 的 range,防止超出坐标系外面\n * @private\n */\n private adjustCategoryScaleRange() {\n const xyScales = [this.getXScale(), ...this.getYScales()].filter((e) => !!e);\n const coordinate = this.getCoordinate();\n const scaleOptions = this.options.scales;\n\n each(xyScales, (scale: Scale) => {\n const { field, values, isCategory, isIdentity } = scale;\n\n // 分类或者 identity 的 scale 才进行处理\n if (isCategory || isIdentity) {\n // 存在 value 值,且用户没有配置 range 配置\n if (values && !get(scaleOptions, [field, 'range'])) {\n // 更新 range\n scale.range = getDefaultCategoryScaleRange(scale, coordinate, this.theme);\n }\n }\n });\n }\n\n /**\n * 根据 options 配置、Geometry 字段配置,自动生成 components\n * @param isUpdate 是否是更新\n * @private\n */\n private initComponents(isUpdate: boolean) {\n // 先全部清空,然后 render\n const controllers = this.controllers;\n for (let i = 0; i < controllers.length; i++) {\n const controller = controllers[i];\n // 更新则走更新逻辑;否则清空载重绘\n if (isUpdate) {\n controller.update();\n } else {\n controller.clear();\n controller.render();\n }\n }\n }\n\n private doLayout() {\n this.layoutFunc(this);\n }\n\n /**\n * 创建坐标系\n * @private\n */\n private createCoordinate() {\n const start = this.coordinateBBox.bl;\n const end = this.coordinateBBox.tr;\n this.coordinateInstance = this.coordinateController.create(start, end);\n }\n\n /**\n * 根据 options 配置自动渲染 geometry\n * @private\n */\n private paintGeometries(isUpdate: boolean) {\n const doAnimation = this.options.animate;\n // geometry 的 paint 阶段\n const coordinate = this.getCoordinate();\n const canvasRegion = {\n x: this.viewBBox.x,\n y: this.viewBBox.y,\n minX: this.viewBBox.minX,\n minY: this.viewBBox.minY,\n maxX: this.viewBBox.maxX,\n maxY: this.viewBBox.maxY,\n width: this.viewBBox.width,\n height: this.viewBBox.height,\n };\n const geometries = this.geometries;\n for (let i = 0; i < geometries.length; i++) {\n const geometry = geometries[i];\n geometry.coordinate = coordinate;\n geometry.canvasRegion = canvasRegion;\n if (!doAnimation) {\n // 如果 view 不执行动画,那么 view 下所有的 geometry 都不执行动画\n geometry.animate(false);\n }\n geometry.paint(isUpdate);\n }\n }\n\n /**\n * 最后的绘制组件\n * @param isUpdate\n */\n private renderComponents(isUpdate: boolean) {\n const components = this.getComponents();\n // 先全部清空,然后 render\n for (let i = 0; i < components.length; i++) {\n const co = components[i];\n (co.component as GroupComponent).render();\n }\n }\n\n /**\n * 渲染分面,会在其中进行数据分面,然后进行子 view 创建\n * @param isUpdate\n */\n private renderFacet(isUpdate: boolean) {\n if (this.facetInstance) {\n if (isUpdate) {\n this.facetInstance.update();\n } else {\n this.facetInstance.clear();\n // 计算分面数据\n this.facetInstance.init();\n // 渲染组件和 views\n this.facetInstance.render();\n }\n }\n }\n\n private initOptions() {\n const {\n geometries = [],\n interactions = [],\n views = [],\n annotations = [],\n coordinate,\n events,\n facets,\n } = this.options;\n\n // 设置坐标系\n if (this.coordinateController) {\n // 更新 coordinate controller\n coordinate && this.coordinateController.update(coordinate);\n } else {\n // 创建 coordinate controller\n this.coordinateController = new CoordinateController(coordinate);\n }\n\n // 创建 geometry 实例\n for (let i = 0; i < geometries.length; i++) {\n const geometryOption = geometries[i];\n this.createGeometry(geometryOption);\n }\n\n // 创建 interactions 实例\n for (let j = 0; j < interactions.length; j++) {\n const interactionOption = interactions[j];\n const { type, cfg } = interactionOption;\n this.interaction(type, cfg);\n }\n\n // 创建 view 实例\n for (let k = 0; k < views.length; k++) {\n const viewOption = views[k];\n this.createView(viewOption);\n }\n\n // 设置 annotation\n const annotationComponent = this.getController('annotation');\n for (let l = 0; l < annotations.length; l++) {\n const annotationOption = annotations[l];\n annotationComponent.annotation(annotationOption);\n }\n\n // 设置 events\n if (events) {\n each(events, (eventCallback, eventName) => {\n this.on(eventName, eventCallback);\n });\n }\n\n if (facets) {\n each(facets, (facet) => {\n const { type, ...rest } = facet;\n\n this.facet(type, rest);\n });\n }\n }\n\n private createGeometry(geometryOption: GeometryOption) {\n const { type, cfg = {} } = geometryOption;\n if (this[type]) {\n const geometry = this[type](cfg);\n each(geometryOption, (v, k) => {\n if (isFunction(geometry[k])) {\n geometry[k](v);\n }\n });\n }\n }\n\n /**\n * scale key 的创建方式\n * @param field\n */\n private getScaleKey(field: string): string {\n return `${this.id}-${field}`;\n }\n}\n\n/**\n * 注册 geometry 组件\n * @param name\n * @param Ctor\n * @returns Geometry\n */\nexport function registerGeometry(name: string, Ctor: any) {\n // 语法糖,在 view API 上增加原型方法\n View.prototype[name.toLowerCase()] = function (cfg: any = {}) {\n const props = {\n /** 图形容器 */\n container: this.middleGroup.addGroup(),\n labelsContainer: this.foregroundGroup.addGroup(),\n ...cfg,\n };\n\n const geometry = new Ctor(props);\n this.geometries.push(geometry);\n\n return geometry;\n };\n}\n\nexport default View;\n","import { debounce, each, isString } from '@antv/util';\nimport { ChartCfg } from '../interface';\nimport { GROUP_Z_INDEX, VIEW_LIFE_CIRCLE } from '../constant';\nimport { getEngine } from '../engine';\nimport { createDom, getChartSize, removeDom, modifyCSS } from '../util/dom';\nimport View from './view';\nimport { AriaOption } from '../interface';\n\n/**\n * Chart 类,是使用 G2 进行绘图的入口。\n */\nexport default class Chart extends View {\n /** Chart 的 DOM 容器 */\n public ele: HTMLElement;\n\n /** 图表宽度 */\n public width: number;\n /** 图表高度 */\n public height: number;\n /** 是否开启局部刷新 */\n public localRefresh: boolean;\n /** 是否自适应 DOM 容器宽高,默认为 false,需要用户手动指定宽高 */\n public autoFit: boolean;\n /** 图表渲染引擎 */\n public renderer: 'canvas' | 'svg';\n\n private wrapperElement: HTMLElement;\n\n // @ts-ignore\n constructor(props: ChartCfg) {\n const {\n container,\n width,\n height,\n autoFit = false,\n padding,\n appendPadding,\n renderer = 'canvas',\n pixelRatio,\n localRefresh = true,\n visible = true,\n supportCSSTransform = false,\n defaultInteractions = ['tooltip', 'legend-filter', 'legend-active', 'continuous-filter', 'ellipsis-text', 'axis-description'],\n options,\n limitInPlot,\n theme,\n syncViewPadding,\n } = props;\n\n const ele: HTMLElement = isString(container) ? document.getElementById(container) : container;\n\n // 生成内部正式绘制的 div 元素\n const wrapperElement = createDom('
    ');\n ele.appendChild(wrapperElement);\n\n // if autoFit, use the container size, to avoid the graph render twice.\n const size = getChartSize(ele, autoFit, width, height);\n\n const G = getEngine(renderer);\n\n const canvas = new G.Canvas({\n container: wrapperElement,\n pixelRatio,\n localRefresh,\n supportCSSTransform,\n ...size,\n });\n\n // 调用 view 的创建\n super({\n parent: null,\n canvas,\n // create 3 group layers for views.\n backgroundGroup: canvas.addGroup({ zIndex: GROUP_Z_INDEX.BG }),\n middleGroup: canvas.addGroup({ zIndex: GROUP_Z_INDEX.MID }),\n foregroundGroup: canvas.addGroup({ zIndex: GROUP_Z_INDEX.FORE }),\n padding,\n appendPadding,\n visible,\n options,\n limitInPlot,\n theme,\n syncViewPadding,\n });\n\n this.ele = ele;\n this.canvas = canvas;\n this.width = size.width;\n this.height = size.height;\n this.autoFit = autoFit;\n this.localRefresh = localRefresh;\n this.renderer = renderer;\n this.wrapperElement = wrapperElement;\n\n // 自适应大小\n this.updateCanvasStyle();\n this.bindAutoFit();\n this.initDefaultInteractions(defaultInteractions);\n }\n\n private initDefaultInteractions(interactions) {\n each(interactions, (interaction) => {\n this.interaction(interaction);\n });\n }\n\n /**\n * 设置 WAI-ARIA 无障碍标签。如何根据图形语法自动生成 arial 内容?\n * @param ariaOption\n */\n public aria(ariaOption: AriaOption) {\n const ATTR = 'aria-label';\n if (ariaOption === false) {\n this.ele.removeAttribute(ATTR);\n } else {\n this.ele.setAttribute(ATTR, ariaOption.label);\n }\n }\n\n /**\n * 改变图表大小,同时重新渲染。\n * @param width 图表宽度\n * @param height 图表高度\n * @returns\n */\n public changeSize(width: number, height: number) {\n // 如果宽高一致,那么 changeSize 不执行任何操作\n if (this.width === width && this.height === height) {\n return this;\n }\n\n this.emit(VIEW_LIFE_CIRCLE.BEFORE_CHANGE_SIZE);\n\n this.width = width;\n this.height = height;\n this.canvas.changeSize(width, height);\n\n // 重新渲染\n this.render(true);\n\n this.emit(VIEW_LIFE_CIRCLE.AFTER_CHANGE_SIZE);\n\n return this;\n }\n\n /**\n * 清空图表,同时清除掉 aria 配置\n */\n public clear() {\n super.clear();\n\n this.aria(false);\n }\n\n /**\n * 销毁图表,同时解绑事件,销毁创建的 G.Canvas 实例。\n * @returns void\n */\n public destroy() {\n super.destroy();\n\n this.unbindAutoFit();\n this.canvas.destroy();\n\n removeDom(this.wrapperElement);\n this.wrapperElement = null;\n }\n\n /**\n * 显示或隐藏图表\n * @param visible 是否可见,true 表示显示,false 表示隐藏\n * @returns\n */\n public changeVisible(visible: boolean) {\n super.changeVisible(visible); // 需要更新 visible 变量\n this.wrapperElement.style.display = visible ? '' : 'none';\n\n return this;\n }\n\n /**\n * 自动根据容器大小 resize 画布\n */\n public forceFit() {\n // skip if already destroyed\n if (!this.destroyed) {\n // 注意第二参数用 true,意思是即时 autoFit = false,forceFit() 调用之后一样是适配容器\n const { width, height } = getChartSize(this.ele, true, this.width, this.height);\n this.changeSize(width, height);\n }\n }\n\n private updateCanvasStyle() {\n modifyCSS(this.canvas.get('el'), {\n display: 'inline-block',\n verticalAlign: 'middle',\n });\n }\n\n private bindAutoFit() {\n if (this.autoFit) {\n window.addEventListener('resize', this.onResize);\n }\n }\n\n private unbindAutoFit() {\n if (this.autoFit) {\n window.removeEventListener('resize', this.onResize);\n }\n }\n\n /**\n * when container size changed, change chart size props, and re-render.\n */\n private onResize = debounce(() => {\n this.forceFit();\n }, 300);\n}\n","import { each } from '@antv/util';\nimport { ComponentOption } from '../../interface';\nimport View from '../view';\n\n/** Component controller class type define */\nexport type ControllerCtor = new (view: View) => Controller;\n\n/**\n * Component Controller 规范需要定义的基类\n * 1. 规范的 option 输入\n * 2. 统一的信息获取 API\n * 3. 明确定义的组件事件(名称、数据)\n */\nexport abstract class Controller {\n /** 是否可见 */\n public visible: boolean = true;\n protected view: View;\n /** option 配置,不同组件有自己不同的配置结构 */\n protected option: O;\n /** 所有的 component */\n protected components: ComponentOption[] = [];\n\n constructor(view: View) {\n this.view = view;\n }\n\n public abstract get name(): string;\n\n /**\n * init the component\n */\n public abstract init();\n\n /**\n * render the components\n */\n public abstract render();\n\n /**\n * update the components\n */\n // public abstract update();\n\n /**\n * do layout\n */\n public abstract layout();\n\n /**\n * 组件的更新逻辑\n * - 根据字段为标识,为每一个组件生成一个 id,放到 option 中\n * - 更新的时候按照 id 去做 diff,然后对同的做处理\n * - 创建增加的\n * - 更新已有的\n * - 销毁删除的\n */\n public abstract update();\n\n /**\n * clear\n * @param includeOption 是否清空 option 配置项(used in annotation)\n */\n public clear(includeOption?: boolean) {\n // destroy all components\n each(this.components, (co: ComponentOption) => {\n co.component.destroy();\n });\n\n // clear all component instance\n this.components = [];\n }\n\n /**\n * destroy the component\n */\n public destroy() {\n this.clear();\n }\n\n /**\n * get all components\n * @returns components array\n */\n public getComponents(): ComponentOption[] {\n return this.components;\n }\n\n /**\n * change visibility of component\n * @param visible\n */\n public changeVisible(visible: boolean) {\n if (this.visible === visible) {\n return;\n }\n this.components.forEach((co: ComponentOption) => {\n if (visible) {\n co.component.show();\n } else {\n co.component.hide();\n }\n });\n this.visible = visible;\n }\n}\n","import { deepMix, find, get, isEqual, isFunction, mix, isString, isBoolean, flatten, isArray } from '@antv/util';\nimport { Crosshair, HtmlTooltip, IGroup } from '../../dependents';\nimport { Point, TooltipItem, TooltipOption } from '../../interface';\nimport { getAngleByPoint, getDistanceToCenter, getCoordinateClipCfg } from '../../util/coordinate';\nimport { polarToCartesian } from '../../util/graphics';\nimport { findItemsFromView } from '../../util/tooltip';\nimport { BBox } from '../../util/bbox';\nimport { Controller } from './base';\nimport Event from '../event';\nimport View from '../view';\n\n// Filter duplicates, use `name`, `color`, `value` and `title` property values as condition\nfunction uniq(items) {\n const uniqItems = [];\n for (let index = 0; index < items.length; index++) {\n const item = items[index];\n const result = find(uniqItems, (subItem) => {\n return (\n subItem.color === item.color &&\n subItem.name === item.name &&\n subItem.value === item.value &&\n subItem.title === item.title\n );\n });\n if (!result) {\n uniqItems.push(item);\n }\n }\n return uniqItems;\n}\n\n/** @ignore */\nexport default class Tooltip extends Controller {\n private tooltip;\n private tooltipMarkersGroup: IGroup;\n private tooltipCrosshairsGroup: IGroup;\n private xCrosshair;\n private yCrosshair;\n private guideGroup: IGroup;\n\n private isLocked: boolean = false;\n private items;\n private title: string;\n private point: Point;\n\n public get name(): string {\n return 'tooltip';\n }\n\n public init() { }\n\n private isVisible() {\n const option = this.view.getOptions().tooltip;\n return option !== false;\n }\n\n public render() { }\n\n /**\n * Shows tooltip\n * @param point\n */\n public showTooltip(point: Point) {\n this.point = point;\n if (!this.isVisible()) {\n // 如果设置 tooltip(false) 则始终不显示\n return;\n }\n const view = this.view;\n const items = this.getTooltipItems(point);\n if (!items.length) {\n // 无内容则不展示,同时 tooltip 需要隐藏\n this.hideTooltip();\n return;\n }\n const title = this.getTitle(items);\n const dataPoint = {\n x: items[0].x,\n y: items[0].y,\n }; // 数据点位置\n\n view.emit(\n 'tooltip:show',\n Event.fromData(view, 'tooltip:show', {\n items,\n title,\n ...point,\n })\n );\n\n const cfg = this.getTooltipCfg();\n const { follow, showMarkers, showCrosshairs, showContent, marker } = cfg;\n const lastItems = this.items;\n const lastTitle = this.title;\n if (!isEqual(lastTitle, title) || !isEqual(lastItems, items)) {\n // 内容发生变化了更新 tooltip\n view.emit(\n 'tooltip:change',\n Event.fromData(view, 'tooltip:change', {\n items,\n title,\n ...point,\n })\n );\n\n if (isFunction(showContent) ? showContent(items) : showContent) {\n // 展示 tooltip 内容框才渲染 tooltip\n if (!this.tooltip) {\n // 延迟生成\n this.renderTooltip();\n }\n this.tooltip.update(\n mix(\n {},\n cfg,\n {\n items: this.getItemsAfterProcess(items),\n title,\n },\n follow ? point : {}\n )\n );\n this.tooltip.show();\n }\n\n if (showMarkers) {\n // 展示 tooltipMarkers,tooltipMarkers 跟随数据\n this.renderTooltipMarkers(items, marker);\n }\n } else {\n // 内容未发生变化,则更新位置\n if (this.tooltip && follow) {\n this.tooltip.update(point);\n this.tooltip.show(); // tooltip 有可能被隐藏,需要保证显示状态\n }\n\n if (this.tooltipMarkersGroup) {\n this.tooltipMarkersGroup.show();\n }\n }\n\n this.items = items;\n this.title = title;\n\n if (showCrosshairs) {\n // 展示 tooltip 辅助线\n const isCrosshairsFollowCursor = get(cfg, ['crosshairs', 'follow'], false); // 辅助线是否要跟随鼠标\n this.renderCrosshairs(isCrosshairsFollowCursor ? point : dataPoint, cfg);\n }\n }\n\n public hideTooltip() {\n const { follow } = this.getTooltipCfg();\n if (!follow) {\n this.point = null;\n return;\n }\n // hide the tooltipMarkers\n const tooltipMarkersGroup = this.tooltipMarkersGroup;\n if (tooltipMarkersGroup) {\n tooltipMarkersGroup.hide();\n }\n\n // hide crosshairs\n const xCrosshair = this.xCrosshair;\n const yCrosshair = this.yCrosshair;\n if (xCrosshair) {\n xCrosshair.hide();\n }\n if (yCrosshair) {\n yCrosshair.hide();\n }\n\n const tooltip = this.tooltip;\n if (tooltip) {\n tooltip.hide();\n }\n\n this.view.emit('tooltip:hide', Event.fromData(this.view, 'tooltip:hide', {}));\n\n this.point = null;\n }\n\n /**\n * lockTooltip\n */\n public lockTooltip() {\n this.isLocked = true;\n if (this.tooltip) {\n // tooltip contianer 可捕获事件\n this.tooltip.setCapture(true);\n }\n }\n\n /**\n * unlockTooltip\n */\n public unlockTooltip() {\n this.isLocked = false;\n const cfg = this.getTooltipCfg();\n if (this.tooltip) {\n // 重置 capture 属性\n this.tooltip.setCapture(cfg.capture);\n }\n }\n\n /**\n * isTooltipLocked\n */\n public isTooltipLocked() {\n return this.isLocked;\n }\n\n public clear() {\n const { tooltip, xCrosshair, yCrosshair, tooltipMarkersGroup } = this;\n if (tooltip) {\n tooltip.hide();\n tooltip.clear();\n }\n\n if (xCrosshair) {\n xCrosshair.clear();\n }\n\n if (yCrosshair) {\n yCrosshair.clear();\n }\n\n if (tooltipMarkersGroup) {\n tooltipMarkersGroup.clear();\n }\n\n // 如果 customContent 不为空,就重新生成 tooltip\n if (tooltip?.get('customContent')) {\n this.tooltip.destroy();\n this.tooltip = null;\n }\n\n // title 和 items 需要清空, 否则 tooltip 内容会出现置空的情况\n // 即:需要走进 !isEqual(lastTitle, title) || !isEqual(lastItems, items) 的逻辑,更新 tooltip 的内容\n this.title = null;\n this.items = null;\n }\n\n public destroy() {\n if (this.tooltip) {\n this.tooltip.destroy();\n }\n if (this.xCrosshair) {\n this.xCrosshair.destroy();\n }\n if (this.yCrosshair) {\n this.yCrosshair.destroy();\n }\n\n if (this.guideGroup) {\n this.guideGroup.remove(true);\n }\n\n this.reset();\n }\n\n public reset() {\n this.items = null;\n this.title = null;\n this.tooltipMarkersGroup = null;\n this.tooltipCrosshairsGroup = null;\n this.xCrosshair = null;\n this.yCrosshair = null;\n this.tooltip = null;\n this.guideGroup = null;\n this.isLocked = false;\n this.point = null;\n }\n\n public changeVisible(visible: boolean) {\n if (this.visible === visible) {\n return;\n }\n const { tooltip, tooltipMarkersGroup, xCrosshair, yCrosshair } = this;\n if (visible) {\n if (tooltip) {\n tooltip.show();\n }\n if (tooltipMarkersGroup) {\n tooltipMarkersGroup.show();\n }\n if (xCrosshair) {\n xCrosshair.show();\n }\n if (yCrosshair) {\n yCrosshair.show();\n }\n } else {\n if (tooltip) {\n tooltip.hide();\n }\n if (tooltipMarkersGroup) {\n tooltipMarkersGroup.hide();\n }\n if (xCrosshair) {\n xCrosshair.hide();\n }\n if (yCrosshair) {\n yCrosshair.hide();\n }\n }\n this.visible = visible;\n }\n\n public getTooltipItems(point: Point) {\n let items = this.findItemsFromView(this.view, point);\n if (items.length) {\n // 三层\n items = flatten(items);\n for (const itemArr of items) {\n for (const item of itemArr) {\n const { x, y } = item.mappingData;\n item.x = isArray(x) ? x[x.length - 1] : x;\n item.y = isArray(y) ? y[y.length - 1] : y;\n }\n }\n\n const { shared } = this.getTooltipCfg();\n // shared: false 代表只显示当前拾取到的 shape 的数据,但是一个 view 会有多个 Geometry,所以有可能会拾取到多个 shape\n if (shared === false && items.length > 1) {\n let snapItem = items[0];\n let min = Math.abs(point.y - snapItem[0].y);\n for (const aItem of items) {\n const yDistance = Math.abs(point.y - aItem[0].y);\n if (yDistance <= min) {\n snapItem = aItem;\n min = yDistance;\n }\n }\n items = [snapItem];\n }\n\n return uniq(flatten(items));\n }\n\n return [];\n }\n\n public layout() { }\n\n public update() {\n if (this.point) {\n this.showTooltip(this.point);\n }\n\n if (this.tooltip) {\n // #2279 修复resize之后tooltip越界的问题\n // 确保tooltip已经创建的情况下\n const canvas = this.view.getCanvas();\n // TODO 逍为 tooltip 的区域不应该是 canvas,而应该是整个 特别是在图比较小的时候\n // 更新 region\n this.tooltip.set('region', {\n start: { x: 0, y: 0 },\n end: { x: canvas.get('width'), y: canvas.get('height') },\n });\n }\n }\n\n /**\n * 当前鼠标点是在 enter tooltip 中\n * @param point\n */\n public isCursorEntered(point: Point) {\n // 是可捕获的,并且点在 tooltip dom 上\n if (this.tooltip) {\n const el: HTMLElement = this.tooltip.getContainer();\n const capture = this.tooltip.get('capture');\n\n if (el && capture) {\n const { x, y, width, height } = el.getBoundingClientRect();\n return new BBox(x, y, width, height).isPointIn(point);\n }\n }\n\n return false;\n }\n\n // 获取 tooltip 配置,因为用户可能会通过 view.tooltip() 重新配置 tooltip,所以就不做缓存,每次直接读取\n public getTooltipCfg() {\n const view = this.view;\n const option = view.getOptions().tooltip;\n const processOption = this.processCustomContent(option);\n const theme = view.getTheme();\n const defaultCfg = get(theme, ['components', 'tooltip'], {});\n const enterable = get(processOption, 'enterable', defaultCfg.enterable);\n return deepMix({}, defaultCfg, processOption, {\n capture: enterable || this.isLocked ? true : false,\n });\n }\n\n // process customContent\n protected processCustomContent(option: TooltipOption) {\n if (isBoolean(option) || !get(option, 'customContent')) {\n return option;\n }\n const currentCustomContent = option.customContent;\n const customContent = (title: string, items: any[]) => {\n const content = currentCustomContent(title, items) || '';\n return isString(content) ? '
    ' + content + '
    ' : content;\n };\n return {\n ...option,\n customContent,\n };\n }\n\n private getTitle(items) {\n const title = items[0].title || items[0].name;\n this.title = title;\n\n return title;\n }\n\n private renderTooltip() {\n const canvas = this.view.getCanvas();\n const region = {\n start: { x: 0, y: 0 },\n end: { x: canvas.get('width'), y: canvas.get('height') },\n };\n\n const cfg = this.getTooltipCfg();\n const tooltip = new HtmlTooltip({\n parent: canvas.get('el').parentNode,\n region,\n ...cfg,\n visible: false,\n crosshairs: null,\n });\n\n tooltip.init();\n this.tooltip = tooltip;\n }\n\n private renderTooltipMarkers(items, marker) {\n const tooltipMarkersGroup = this.getTooltipMarkersGroup();\n const rootView = this.view.getRootView();\n const { limitInPlot } = rootView;\n for (const item of items) {\n const { x, y } = item;\n\n // 有裁剪就剪切\n if (limitInPlot || tooltipMarkersGroup?.getClip()) {\n const { type, attrs } = getCoordinateClipCfg(rootView.getCoordinate());\n tooltipMarkersGroup?.setClip({\n type,\n attrs,\n });\n } else {\n // 清除已有的 clip\n tooltipMarkersGroup?.setClip(undefined);\n }\n\n const theme = this.view.getTheme();\n const markerDefaultCfg = get(theme, ['components', 'tooltip', 'marker'], {});\n\n const attrs = {\n fill: item.color,\n symbol: 'circle',\n shadowColor: item.color,\n ...(isFunction(marker) ? { ...markerDefaultCfg, ...marker(item) } : marker),\n x,\n y,\n };\n\n tooltipMarkersGroup.addShape('marker', {\n attrs,\n });\n }\n }\n\n private renderCrosshairs(point: Point, cfg) {\n const crosshairsType = get(cfg, ['crosshairs', 'type'], 'x'); // 默认展示 x 轴上的辅助线\n if (crosshairsType === 'x') {\n if (this.yCrosshair) {\n this.yCrosshair.hide();\n }\n this.renderXCrosshairs(point, cfg);\n } else if (crosshairsType === 'y') {\n if (this.xCrosshair) {\n this.xCrosshair.hide();\n }\n this.renderYCrosshairs(point, cfg);\n } else if (crosshairsType === 'xy') {\n this.renderXCrosshairs(point, cfg);\n this.renderYCrosshairs(point, cfg);\n }\n }\n\n // 渲染 x 轴上的 tooltip 辅助线\n private renderXCrosshairs(point: Point, tooltipCfg) {\n const coordinate = this.getViewWithGeometry(this.view).getCoordinate();\n let start;\n let end;\n if (coordinate.isRect) {\n if (coordinate.isTransposed) {\n start = {\n x: coordinate.start.x,\n y: point.y,\n };\n end = {\n x: coordinate.end.x,\n y: point.y,\n };\n } else {\n start = {\n x: point.x,\n y: coordinate.end.y,\n };\n end = {\n x: point.x,\n y: coordinate.start.y,\n };\n }\n } else {\n // 极坐标下 x 轴上的 crosshairs 表现为半径\n const angle = getAngleByPoint(coordinate, point);\n const center = coordinate.getCenter();\n const radius = coordinate.getRadius();\n end = polarToCartesian(center.x, center.y, radius, angle);\n start = center;\n }\n\n const cfg = deepMix(\n {\n start,\n end,\n container: this.getTooltipCrosshairsGroup(),\n },\n get(tooltipCfg, 'crosshairs', {}),\n this.getCrosshairsText('x', point, tooltipCfg)\n );\n delete cfg.type; // 与 Crosshairs 组件的 type 冲突故删除\n\n let xCrosshair = this.xCrosshair;\n if (xCrosshair) {\n xCrosshair.update(cfg);\n } else {\n xCrosshair = new Crosshair.Line(cfg);\n xCrosshair.init();\n }\n xCrosshair.render();\n xCrosshair.show();\n this.xCrosshair = xCrosshair;\n }\n\n // 渲染 y 轴上的辅助线\n private renderYCrosshairs(point: Point, tooltipCfg) {\n const coordinate = this.getViewWithGeometry(this.view).getCoordinate();\n let cfg;\n let type;\n if (coordinate.isRect) {\n let start;\n let end;\n if (coordinate.isTransposed) {\n start = {\n x: point.x,\n y: coordinate.end.y,\n };\n end = {\n x: point.x,\n y: coordinate.start.y,\n };\n } else {\n start = {\n x: coordinate.start.x,\n y: point.y,\n };\n end = {\n x: coordinate.end.x,\n y: point.y,\n };\n }\n cfg = {\n start,\n end,\n };\n type = 'Line';\n } else {\n // 极坐标下 y 轴上的 crosshairs 表现为圆弧\n cfg = {\n center: coordinate.getCenter(),\n // @ts-ignore\n radius: getDistanceToCenter(coordinate, point),\n startAngle: coordinate.startAngle,\n endAngle: coordinate.endAngle,\n };\n type = 'Circle';\n }\n\n cfg = deepMix(\n {\n container: this.getTooltipCrosshairsGroup(),\n },\n cfg,\n get(tooltipCfg, 'crosshairs', {}),\n this.getCrosshairsText('y', point, tooltipCfg)\n );\n delete cfg.type; // 与 Crosshairs 组件的 type 冲突故删除\n\n let yCrosshair = this.yCrosshair;\n if (yCrosshair) {\n // 如果坐标系发生直角坐标系与极坐标的切换操作\n if (\n (coordinate.isRect && yCrosshair.get('type') === 'circle') ||\n (!coordinate.isRect && yCrosshair.get('type') === 'line')\n ) {\n yCrosshair = new Crosshair[type](cfg);\n yCrosshair.init();\n } else {\n yCrosshair.update(cfg);\n }\n } else {\n yCrosshair = new Crosshair[type](cfg);\n yCrosshair.init();\n }\n yCrosshair.render();\n yCrosshair.show();\n this.yCrosshair = yCrosshair;\n }\n\n private getCrosshairsText(type, point: Point, tooltipCfg) {\n let textCfg = get(tooltipCfg, ['crosshairs', 'text']);\n const follow = get(tooltipCfg, ['crosshairs', 'follow']);\n const items = this.items;\n\n if (textCfg) {\n const view = this.getViewWithGeometry(this.view);\n // 需要展示文本\n const firstItem = items[0];\n const xScale = view.getXScale();\n const yScale = view.getYScales()[0];\n let xValue;\n let yValue;\n if (follow) {\n // 如果需要跟随鼠标移动,就需要将当前鼠标坐标点转换为对应的数值\n const invertPoint = this.view.getCoordinate().invert(point);\n xValue = xScale.invert(invertPoint.x); // 转换为原始值\n yValue = yScale.invert(invertPoint.y); // 转换为原始值\n } else {\n xValue = firstItem.data[xScale.field];\n yValue = firstItem.data[yScale.field];\n }\n\n const content = type === 'x' ? xValue : yValue;\n if (isFunction(textCfg)) {\n textCfg = textCfg(type, content, items, point);\n } else {\n textCfg.content = content;\n }\n\n return {\n text: textCfg,\n };\n }\n }\n\n // 获取存储 tooltipMarkers 和 crosshairs 的容器\n private getGuideGroup() {\n if (!this.guideGroup) {\n const foregroundGroup = this.view.foregroundGroup;\n this.guideGroup = foregroundGroup.addGroup({\n name: 'tooltipGuide',\n capture: false,\n });\n }\n\n return this.guideGroup;\n }\n\n // 获取 tooltipMarkers 存储的容器\n private getTooltipMarkersGroup() {\n let tooltipMarkersGroup = this.tooltipMarkersGroup;\n if (tooltipMarkersGroup && !tooltipMarkersGroup.destroyed) {\n tooltipMarkersGroup.clear();\n tooltipMarkersGroup.show();\n } else {\n tooltipMarkersGroup = this.getGuideGroup().addGroup({\n name: 'tooltipMarkersGroup',\n });\n tooltipMarkersGroup.toFront();\n this.tooltipMarkersGroup = tooltipMarkersGroup;\n }\n return tooltipMarkersGroup;\n }\n\n // 获取 tooltip crosshairs 存储的容器\n private getTooltipCrosshairsGroup() {\n let tooltipCrosshairsGroup = this.tooltipCrosshairsGroup;\n if (!tooltipCrosshairsGroup) {\n tooltipCrosshairsGroup = this.getGuideGroup().addGroup({\n name: 'tooltipCrosshairsGroup',\n capture: false,\n });\n tooltipCrosshairsGroup.toBack();\n this.tooltipCrosshairsGroup = tooltipCrosshairsGroup;\n }\n return tooltipCrosshairsGroup;\n }\n\n private findItemsFromView(view: View, point: Point) {\n if (view.getOptions().tooltip === false) {\n // 如果 view 关闭了 tooltip\n return [];\n }\n\n const tooltipCfg = this.getTooltipCfg();\n let result = findItemsFromView(view, point, tooltipCfg);\n // 递归查找,并合并结果\n for (const childView of view.views) {\n result = result.concat(this.findItemsFromView(childView, point));\n }\n\n return result;\n }\n\n // FIXME: hack 方法\n // 因为 tooltip 的交互是挂载在 Chart 上,所以当chart 上没有绘制 Geometry 的时候,就查找不到数据,并且绘图区域同子 View 的区域不同\n private getViewWithGeometry(view) {\n if (view.geometries.length) {\n return view;\n }\n\n return find(view.views, (childView) => this.getViewWithGeometry(childView));\n }\n\n /**\n * 根据用户配置的 items 配置,来进行用户自定义的处理,并返回最终的 items\n * 默认不做任何处理\n */\n private getItemsAfterProcess(originalItems: TooltipItem[]): TooltipItem[] {\n const { customItems } = this.getTooltipCfg();\n const fn = customItems ? customItems : (v) => v;\n\n return fn(originalItems);\n }\n}\n","import { IGroup, IShape } from '../../dependents';\nimport { GAnimateCfg } from '../../interface';\nimport { AnimateExtraCfg } from '../interface';\n\n/** @ignore */\ninterface AnimationMap {\n [key: string]: Animation;\n}\n\ntype Animation = (element: IGroup | IShape, animateCfg: GAnimateCfg, cfg: AnimateExtraCfg) => void;\n\nconst ANIMATIONS_MAP: AnimationMap = {};\n\n/**\n * 根据名称获取对应的动画执行函数\n * @param type 动画函数名称\n */\nexport function getAnimation(type: string) {\n return ANIMATIONS_MAP[type.toLowerCase()];\n}\n\n/**\n * 注册动画执行函数\n * @param type 动画执行函数名称\n * @param animation 动画执行函数\n */\nexport function registerAnimation(type: string, animation: Animation) {\n ANIMATIONS_MAP[type.toLowerCase()] = animation;\n}\n","import { deepMix, get, isFunction } from '@antv/util';\nimport { FIELD_ORIGIN } from '../constant';\nimport { Coordinate, IGroup, IShape } from '../dependents';\nimport { AnimateCfg, Data, Datum, GAnimateCfg, Point } from '../interface';\nimport { AnimateExtraCfg } from './interface';\n\nimport { getAnimation } from './animation';\n\n// 默认的动画参数配置\nexport const DEFAULT_ANIMATE_CFG = {\n appear: {\n duration: 450,\n easing: 'easeQuadOut',\n }, // 初始入场动画配置\n update: {\n duration: 400,\n easing: 'easeQuadInOut',\n }, // 更新时发生变更的动画配置\n enter: {\n duration: 400,\n easing: 'easeQuadInOut',\n }, // 更新时新增元素的入场动画配置\n leave: {\n duration: 350,\n easing: 'easeQuadIn',\n }, // 更新时销毁动画配置\n};\n\n// 各个 Geometry 默认的动画执行函数\nconst GEOMETRY_ANIMATE_CFG = {\n interval: (coordinate: Coordinate) => {\n return {\n enter: {\n animation: coordinate.isRect ? (coordinate.isTransposed ? 'scale-in-x' : 'scale-in-y') : 'fade-in',\n },\n update: {\n animation: coordinate.isPolar && coordinate.isTransposed ? 'sector-path-update' : null,\n },\n leave: {\n animation: 'fade-out',\n },\n };\n },\n line: {\n enter: {\n animation: 'fade-in',\n },\n leave: {\n animation: 'fade-out',\n },\n },\n path: {\n enter: {\n animation: 'fade-in',\n },\n leave: {\n animation: 'fade-out',\n },\n },\n point: {\n appear: {\n animation: 'zoom-in',\n },\n enter: {\n animation: 'zoom-in',\n },\n leave: {\n animation: 'zoom-out',\n },\n },\n area: {\n enter: {\n animation: 'fade-in',\n },\n leave: {\n animation: 'fade-out',\n },\n },\n polygon: {\n enter: {\n animation: 'fade-in',\n },\n leave: {\n animation: 'fade-out',\n },\n },\n schema: {\n enter: {\n animation: 'fade-in',\n },\n leave: {\n animation: 'fade-out',\n },\n },\n edge: {\n enter: {\n animation: 'fade-in',\n },\n leave: {\n animation: 'fade-out',\n },\n },\n label: {\n appear: {\n animation: 'fade-in',\n delay: 450,\n },\n enter: {\n animation: 'fade-in',\n },\n update: {\n animation: 'position-update',\n },\n leave: {\n animation: 'fade-out',\n },\n },\n};\n\n// 各个 Geometry 默认的群组出场动画\nconst GEOMETRY_GROUP_APPEAR_ANIMATION = {\n line: () => {\n return {\n animation: 'wave-in',\n };\n },\n area: () => {\n return {\n animation: 'wave-in',\n };\n },\n path: () => {\n return {\n animation: 'fade-in',\n };\n },\n interval(coordinate: Coordinate) {\n let animation;\n\n if (coordinate.isRect) {\n animation = coordinate.isTransposed ? 'grow-in-x' : 'grow-in-y';\n } else {\n animation = 'grow-in-xy';\n if (coordinate.isPolar && coordinate.isTransposed) {\n // pie chart\n animation = 'wave-in';\n }\n }\n return {\n animation,\n };\n },\n schema: (coordinate) => {\n let animation;\n if (coordinate.isRect) {\n animation = coordinate.isTransposed ? 'grow-in-x' : 'grow-in-y';\n } else {\n animation = 'grow-in-xy';\n }\n return {\n animation,\n };\n },\n polygon: () => {\n return {\n animation: 'fade-in',\n duration: 500,\n };\n },\n edge: () => {\n return {\n animation: 'fade-in',\n };\n },\n};\n\n// 解析用户的动画配置\nfunction parseAnimateConfig(animateCfg: AnimateCfg, data: Data | Datum): GAnimateCfg {\n return {\n delay: isFunction(animateCfg.delay) ? animateCfg.delay(data) : animateCfg.delay,\n easing: isFunction(animateCfg.easing) ? animateCfg.easing(data) : animateCfg.easing,\n duration: isFunction(animateCfg.duration) ? animateCfg.duration(data) : animateCfg.duration,\n callback: animateCfg.callback,\n repeat: animateCfg.repeat,\n };\n}\n\n/**\n * @ignore\n * 获取 elementName 对应的动画配置,当声明了 `animateType`,则返回 `animateType` 对应的动画配置\n * @param elementName 元素名称\n * @param coordinate 做表弟类型\n * @param animateType 可选,动画类型\n */\nexport function getDefaultAnimateCfg(elementName: string, coordinate: Coordinate, animateType?: string) {\n let animateCfg = GEOMETRY_ANIMATE_CFG[elementName];\n\n if (animateCfg) {\n if (isFunction(animateCfg)) {\n animateCfg = animateCfg(coordinate);\n }\n animateCfg = deepMix({}, DEFAULT_ANIMATE_CFG, animateCfg);\n\n if (animateType) {\n return animateCfg[animateType];\n }\n }\n return animateCfg;\n}\n\n/**\n * @ignore\n * 工具函数\n * 根据用户传入的配置为 shape 执行动画\n * @param shape 执行动画的图形元素\n * @param animateCfg 动画配置\n * @param cfg 额外的信息\n */\nexport function doAnimate(shape: IGroup | IShape, animateCfg: AnimateCfg, cfg: AnimateExtraCfg) {\n const data = get(shape.get('origin'), 'data', FIELD_ORIGIN);\n const animation = animateCfg.animation; // 获取动画执行函数\n const parsedAnimateCfg = parseAnimateConfig(animateCfg, data);\n if (animation) {\n // 用户声明了动画执行函数\n const animateFunction = getAnimation(animation);\n if (animateFunction) {\n animateFunction(shape, parsedAnimateCfg, cfg);\n }\n } else {\n // 没有声明,则根据 toAttrs 做差值动画\n shape.animate(cfg.toAttrs, parsedAnimateCfg);\n }\n}\n\n/**\n * @ignore\n * 执行 Geometry 群组入场动画\n * @param container 执行群组动画的图形元素\n * @param animateCfg 动画配置\n * @param geometryType geometry 类型\n * @param coordinate 坐标系对象\n * @param minYPoint y 轴最小值对应的画布坐标点\n */\nexport function doGroupAppearAnimate(\n container: IGroup,\n animateCfg: AnimateCfg,\n geometryType: string,\n coordinate: Coordinate,\n minYPoint: Point\n) {\n if (GEOMETRY_GROUP_APPEAR_ANIMATION[geometryType]) {\n const defaultCfg = GEOMETRY_GROUP_APPEAR_ANIMATION[geometryType](coordinate);\n const animation = getAnimation(get(defaultCfg, 'animation', ''));\n if (animation) {\n const cfg = {\n ...DEFAULT_ANIMATE_CFG.appear,\n ...defaultCfg,\n ...animateCfg,\n };\n container.stopAnimate(); // 先结束当前 container 动画\n animation(container, cfg, {\n coordinate,\n minYPoint,\n toAttrs: null,\n });\n }\n }\n}\n","/**\n * Name of Background Shape\n */\nexport const BACKGROUND_SHAPE = 'element-background';\n","import { deepMix, each, get, isArray, isEmpty, isEqual, isFunction, isString } from '@antv/util';\n// 暂未发包\n// @ts-ignore\nimport { propagationDelegate } from '@antv/component';\nimport { doAnimate } from '../../animate';\nimport Base from '../../base';\nimport { BBox, IGroup, IShape } from '../../dependents';\nimport { AnimateOption, Datum, ShapeFactory, ShapeInfo, StateCfg } from '../../interface';\nimport { getReplaceAttrs } from '../../util/graphics';\nimport Geometry from '../base';\nimport { GEOMETRY_LIFE_CIRCLE } from '../../constant';\nimport { BACKGROUND_SHAPE } from '../shape/constant';\n\n/** Element 构造函数传入参数类型 */\ninterface ElementCfg {\n /** 用于创建各种 shape 的工厂对象 */\n shapeFactory: ShapeFactory;\n /** shape 容器 */\n container: IGroup;\n /** element 的索引 */\n elementIndex?: number;\n /** 虚拟 group,用户可以不传入 */\n offscreenGroup?: IGroup;\n /** 是否可见 */\n visible?: boolean;\n}\n\n/**\n * Element 图形元素。\n * 定义:在 G2 中,我们会将数据通过图形语法映射成不同的图形,比如点图,数据集中的每条数据会对应一个点,柱状图每条数据对应一个柱子,线图则是一组数据对应一条折线,Element 即一条/一组数据对应的图形元素,它代表一条数据或者一个数据集,在图形层面,它可以是单个 Shape 也可以是多个 Shape,我们称之为图形元素。\n */\nexport default class Element extends Base {\n /** 用于创建各种 shape 的工厂对象 */\n public shapeFactory: ShapeFactory;\n /** shape 容器 */\n public container: IGroup;\n /** element 索引 */\n public elementIndex: number;\n /** 最后创建的图形对象 */\n public shape: IShape | IGroup;\n /** shape 的动画配置 */\n public animate: AnimateOption | boolean;\n\n // 非构造函数属性,需要外部赋值\n /** element 对应的 Geometry 实例 */\n public geometry: Geometry;\n /** 保存 shape 对应的 label */\n public labelShape: IGroup[] = [];\n\n /** 绘制的 shape 类型 */\n private shapeType: string;\n\n /** shape 绘制需要的数据 */\n private model: ShapeInfo;\n /** 原始数据 */\n private data: Datum;\n // 存储当前开启的状态\n private states: string[] = [];\n private statesStyle;\n // 虚拟 Group\n private offscreenGroup: IGroup;\n\n constructor(cfg: ElementCfg) {\n super(cfg);\n\n const { shapeFactory, container, offscreenGroup, elementIndex, visible = true } = cfg;\n this.shapeFactory = shapeFactory;\n this.container = container;\n this.offscreenGroup = offscreenGroup;\n this.visible = visible;\n this.elementIndex = elementIndex;\n }\n\n /**\n * 绘制图形。\n * @param model 绘制数据。\n * @param isUpdate 可选,是否是更新发生后的绘制。\n */\n public draw(model: ShapeInfo, isUpdate: boolean = false) {\n this.model = model;\n this.data = model.data; // 存储原始数据\n this.shapeType = this.getShapeType(model);\n\n // 绘制图形\n this.drawShape(model, isUpdate);\n\n if (this.visible === false) {\n // 用户在初始化的时候声明 visible: false\n this.changeVisible(false);\n }\n }\n\n /**\n * 更新图形。\n * @param model 更新的绘制数据。\n */\n public update(model: ShapeInfo) {\n const { shapeFactory, shape } = this;\n if (!shape) {\n return;\n }\n\n // 更新数据\n this.model = model;\n this.data = model.data;\n this.shapeType = this.getShapeType(model);\n\n // step 1: 更新 shape 携带的信息\n this.setShapeInfo(shape, model);\n\n // step 2: 使用虚拟 Group 重新绘制 shape,然后更新当前 shape\n const offscreenGroup = this.getOffscreenGroup();\n const newShape = shapeFactory.drawShape(this.shapeType, model, offscreenGroup);\n // @ts-ignore\n newShape.cfg.data = this.data;\n // @ts-ignore\n newShape.cfg.origin = model;\n // label 需要使用\n newShape.cfg.element = this;\n\n // step 3: 同步 shape 样式\n this.syncShapeStyle(shape, newShape, this.getStates(), this.getAnimateCfg('update'));\n }\n\n /**\n * 销毁 element 实例。\n */\n public destroy() {\n const { shapeFactory, shape } = this;\n\n if (shape) {\n const animateCfg = this.getAnimateCfg('leave');\n if (animateCfg) {\n // 指定了动画配置则执行销毁动画\n doAnimate(shape, animateCfg, {\n coordinate: shapeFactory.coordinate,\n toAttrs: {\n ...shape.attr(),\n },\n });\n } else {\n // 否则直接销毁\n shape.remove(true);\n }\n }\n\n // reset\n this.states = [];\n this.shapeFactory = undefined;\n this.container = undefined;\n this.shape = undefined;\n this.animate = undefined;\n this.geometry = undefined;\n this.labelShape = [];\n this.model = undefined;\n this.data = undefined;\n this.offscreenGroup = undefined;\n this.statesStyle = undefined;\n\n super.destroy();\n }\n\n /**\n * 显示或者隐藏 element。\n * @param visible 是否可见。\n */\n public changeVisible(visible: boolean) {\n super.changeVisible(visible);\n\n if (visible) {\n if (this.shape) {\n this.shape.show();\n }\n if (this.labelShape) {\n this.labelShape.forEach((label: IGroup) => {\n label.show();\n });\n }\n } else {\n if (this.shape) {\n this.shape.hide();\n }\n if (this.labelShape) {\n this.labelShape.forEach((label: IGroup) => {\n label.hide();\n });\n }\n }\n }\n\n /**\n * 设置 Element 的状态。\n *\n * 目前 Element 开放三种状态:\n * 1. active\n * 2. selected\n * 3. inactive\n *\n * 这三种状态相互独立,可以进行叠加。\n *\n * 这三种状态的样式可在 [[Theme]] 主题中或者通过 `geometry.state()` 接口进行配置。\n *\n * ```ts\n * // 激活 active 状态\n * setState('active', true);\n * ```\n *\n * @param stateName 状态名\n * @param stateStatus 是否开启状态\n */\n public setState(stateName: string, stateStatus: boolean) {\n const { states, shapeFactory, model, shape, shapeType } = this;\n\n const index = states.indexOf(stateName);\n if (stateStatus) {\n // 开启状态\n if (index > -1) {\n // 该状态已经开启,则返回\n return;\n }\n states.push(stateName);\n if (stateName === 'active' || stateName === 'selected') {\n shape?.toFront();\n }\n } else {\n if (index === -1) {\n // 关闭状态,但是状态未设置过\n return;\n }\n states.splice(index, 1);\n if (stateName === 'active' || stateName === 'selected') {\n const { sortZIndex, zIndexReversed } = this.geometry;\n const idx = zIndexReversed ? this.geometry.elements.length - this.elementIndex : this.elementIndex;\n sortZIndex ? shape.setZIndex(idx) : shape.set('zIndex', idx);\n }\n }\n\n // 使用虚拟 group 重新绘制 shape,然后对这个 shape 应用状态样式后,更新当前 shape。\n const offscreenShape = shapeFactory.drawShape(shapeType, model, this.getOffscreenGroup());\n if (states.length) {\n // 应用当前状态\n this.syncShapeStyle(shape, offscreenShape, states, null);\n } else {\n // 如果没有状态,则需要恢复至原始状态\n this.syncShapeStyle(shape, offscreenShape, ['reset'], null);\n }\n\n offscreenShape.remove(true); // 销毁,减少内存占用\n\n const eventObject = {\n state: stateName,\n stateStatus,\n element: this,\n target: this.container,\n };\n this.container.emit('statechange', eventObject);\n // @ts-ignore\n propagationDelegate(this.shape, 'statechange', eventObject);\n }\n\n /**\n * 清空状量态,恢复至初始状态。\n */\n public clearStates() {\n const states = this.states;\n\n each(states, (state) => {\n this.setState(state, false);\n });\n\n this.states = [];\n }\n\n /**\n * 查询当前 Element 上是否已设置 `stateName` 对应的状态。\n * @param stateName 状态名称。\n * @returns true 表示存在,false 表示不存在。\n */\n public hasState(stateName: string): boolean {\n return this.states.includes(stateName);\n }\n\n /**\n * 获取当前 Element 上所有的状态。\n * @returns 当前 Element 上所有的状态数组。\n */\n public getStates(): string[] {\n return this.states;\n }\n\n /**\n * 获取 Element 对应的原始数据。\n * @returns 原始数据。\n */\n public getData(): Datum {\n return this.data;\n }\n\n /**\n * 获取 Element 对应的图形绘制数据。\n * @returns 图形绘制数据。\n */\n public getModel(): ShapeInfo {\n return this.model;\n }\n\n /**\n * 返回 Element 元素整体的 bbox,包含文本及文本连线(有的话)。\n * @returns 整体包围盒。\n */\n public getBBox(): BBox {\n const { shape, labelShape } = this;\n let bbox = {\n x: 0,\n y: 0,\n minX: 0,\n minY: 0,\n maxX: 0,\n maxY: 0,\n width: 0,\n height: 0,\n };\n if (shape) {\n bbox = shape.getCanvasBBox();\n }\n if (labelShape) {\n labelShape.forEach((label: IGroup) => {\n const labelBBox = label.getCanvasBBox();\n bbox.x = Math.min(labelBBox.x, bbox.x);\n bbox.y = Math.min(labelBBox.y, bbox.y);\n bbox.minX = Math.min(labelBBox.minX, bbox.minX);\n bbox.minY = Math.min(labelBBox.minY, bbox.minY);\n bbox.maxX = Math.max(labelBBox.maxX, bbox.maxX);\n bbox.maxY = Math.max(labelBBox.maxY, bbox.maxY);\n });\n }\n\n bbox.width = bbox.maxX - bbox.minX;\n bbox.height = bbox.maxY - bbox.minY;\n\n return bbox;\n }\n\n private getStatesStyle() {\n if (!this.statesStyle) {\n const { shapeType, geometry, shapeFactory } = this;\n const stateOption = geometry.stateOption;\n const defaultShapeType = shapeFactory.defaultShapeType;\n const stateTheme = shapeFactory.theme[shapeType] || shapeFactory.theme[defaultShapeType];\n this.statesStyle = deepMix({}, stateTheme, stateOption);\n }\n\n return this.statesStyle;\n }\n\n // 从主题中获取对应状态量的样式\n private getStateStyle(stateName: string, shapeKey?: string): StateCfg {\n const statesStyle = this.getStatesStyle();\n const stateCfg = get(statesStyle, [stateName, 'style'], {});\n const shapeStyle = stateCfg[shapeKey] || stateCfg;\n if (isFunction(shapeStyle)) {\n return shapeStyle(this);\n }\n\n return shapeStyle;\n }\n\n // 获取动画配置\n private getAnimateCfg(animateType: string) {\n const animate = this.animate;\n if (animate) {\n const cfg = animate[animateType];\n\n if (cfg) {\n // 增加动画的回调函数,如果外部传入了,则先执行外部,然后发射 geometry 的 animate 事件\n return {\n ...cfg,\n callback: () => {\n isFunction(cfg.callback) && cfg.callback();\n this.geometry?.emit(GEOMETRY_LIFE_CIRCLE.AFTER_DRAW_ANIMATE);\n },\n };\n }\n return cfg;\n }\n\n return null;\n }\n\n // 绘制图形\n private drawShape(model: ShapeInfo, isUpdate: boolean = false) {\n const { shapeFactory, container, shapeType } = this;\n\n // 自定义 shape 有可能返回空 shape\n this.shape = shapeFactory.drawShape(shapeType, model, container);\n\n if (this.shape) {\n this.setShapeInfo(this.shape, model); // 存储绘图数据\n // @ts-ignore\n const name = this.shape.cfg.name;\n // 附加 element 的 name, name 现在支持数组了,很好用了\n if (!name) {\n // 这个地方如果用户添加了 name, 则附加 name ,否则就添加自己的 name\n // @ts-ignore\n this.shape.cfg.name = ['element', this.shapeFactory.geometryType];\n } else if (isString(name)) {\n // @ts-ignore\n this.shape.cfg.name = ['element', name];\n }\n // 执行入场动画\n const animateType = isUpdate ? 'enter' : 'appear';\n const animateCfg = this.getAnimateCfg(animateType);\n if (animateCfg) {\n // 开始执行动画的生命周期\n this.geometry?.emit(GEOMETRY_LIFE_CIRCLE.BEFORE_DRAW_ANIMATE);\n\n doAnimate(this.shape, animateCfg, {\n coordinate: shapeFactory.coordinate,\n toAttrs: {\n ...this.shape.attr(),\n },\n });\n }\n }\n }\n\n // 获取虚拟 Group\n private getOffscreenGroup() {\n if (!this.offscreenGroup) {\n const GroupCtor = this.container.getGroupBase(); // 获取分组的构造函数\n this.offscreenGroup = new GroupCtor({});\n }\n\n return this.offscreenGroup;\n }\n\n // 设置 shape 上需要携带的信息\n private setShapeInfo(shape: IShape | IGroup, data: ShapeInfo) {\n // @ts-ignore\n shape.cfg.origin = data;\n // @ts-ignore\n shape.cfg.element = this;\n if (shape.isGroup()) {\n const children = shape.get('children');\n children.forEach((child) => {\n this.setShapeInfo(child, data);\n });\n }\n }\n\n // 更新当前 shape 的样式\n private syncShapeStyle(\n sourceShape: IGroup | IShape,\n targetShape: IGroup | IShape,\n states: string[] = [],\n animateCfg,\n index: number = 0\n ) {\n if (!sourceShape || !targetShape) {\n return;\n }\n // 所有的 shape 都需要同步 clip\n const clip = sourceShape.get('clipShape');\n const newClip = targetShape.get('clipShape');\n\n this.syncShapeStyle(clip, newClip, states, animateCfg);\n\n if (sourceShape.isGroup()) {\n const children = sourceShape.get('children');\n const newChildren = targetShape.get('children');\n for (let i = 0; i < children.length; i++) {\n this.syncShapeStyle(children[i], newChildren[i], states, animateCfg, index + i);\n }\n } else {\n if (!isEmpty(states) && !isEqual(states, ['reset'])) {\n let name = sourceShape.get('name');\n if (isArray(name)) {\n // 会附加 element 的 name\n name = name[1];\n }\n\n each(states, (state) => {\n // background shape 不进行状态样式设置\n if (targetShape.get('name') !== BACKGROUND_SHAPE) {\n const style = this.getStateStyle(state, name || index); // 如果用户没有设置 name,则默认根据索引值\n targetShape.attr(style);\n }\n });\n }\n const newAttrs = getReplaceAttrs(sourceShape as IShape, targetShape as IShape);\n\n if (this.animate) {\n if (animateCfg) {\n this.geometry?.emit(GEOMETRY_LIFE_CIRCLE.BEFORE_DRAW_ANIMATE);\n // 需要进行动画\n doAnimate(sourceShape, animateCfg, {\n coordinate: this.shapeFactory.coordinate,\n toAttrs: newAttrs,\n shapeModel: this.model,\n });\n } else if (!isEmpty(states)) {\n sourceShape.stopAnimate();\n sourceShape.animate(newAttrs, {\n duration: 300,\n });\n } else {\n sourceShape.attr(newAttrs);\n }\n } else {\n sourceShape.attr(newAttrs);\n }\n }\n }\n\n private getShapeType(model: ShapeInfo) {\n const shape = get(model, 'shape');\n return isArray(shape) ? shape[0] : shape;\n }\n}\n","import { BBox, IGroup, IShape } from '../../dependents';\nimport { LooseObject } from '../../interface';\nimport { GeometryLabelConstructor } from './base';\nimport { LabelItem } from './interface';\n\n/**\n * label 布局函数定义\n * @param items 存储每个 label 的详细信息\n * @param labels 所有的 labels 图形实例\n * @param shapes 所有 label 对应的图形元素实例\n * @param region 画布区域\n * @param cfg 用于存储各个布局函数开放给用户的配置数据\n */\ntype GeometryLabelsLayoutFn = (\n items: LabelItem[],\n labels: IGroup[],\n shapes: IShape[] | IGroup[],\n region: BBox,\n cfg?: LooseObject\n) => void;\n\nconst GEOMETRY_LABELS_MAP: Record = {};\nconst GEOMETRY_LABELS_LAYOUT_MAP: Record = {};\n\n/**\n * 获取 `type` 对应的 [[GeometryLabel]] 类\n * @param type\n * @returns\n */\nexport function getGeometryLabel(type: string): GeometryLabelConstructor {\n return GEOMETRY_LABELS_MAP[type.toLowerCase()];\n}\n\n/**\n * 注册定义的 GeometryLabel 类\n * @param type GeometryLabel 类型名称\n * @param ctor GeometryLabel 类\n */\nexport function registerGeometryLabel(type: string, ctor: GeometryLabelConstructor) {\n GEOMETRY_LABELS_MAP[type.toLowerCase()] = ctor;\n}\n\n/**\n * 获取 `type` 对应的 [[GeometryLabelsLayoutFn]] label 布局函数\n * @param type 布局函数名称\n * @returns\n */\nexport function getGeometryLabelLayout(type: string): GeometryLabelsLayoutFn {\n return GEOMETRY_LABELS_LAYOUT_MAP[type.toLowerCase()];\n}\n\n/**\n * 注册定义的 label 布局函数\n * @param type label 布局函数名称\n * @param layoutFn label 布局函数\n */\nexport function registerGeometryLabelLayout(type: string, layoutFn: GeometryLabelsLayoutFn) {\n GEOMETRY_LABELS_LAYOUT_MAP[type.toLowerCase()] = layoutFn;\n}\n","import { LooseObject } from '@antv/g-svg';\nimport { parsePathString } from '@antv/path-util';\nimport { deepMix, get, upperFirst } from '@antv/util';\nimport { IGroup, IShape, PathCommand } from '../../dependents';\nimport {\n Point,\n RegisterShape,\n RegisterShapeFactory,\n Shape,\n ShapeFactory,\n ShapeInfo,\n ShapeMarkerAttrs,\n ShapeMarkerCfg,\n ShapePoint,\n} from '../../interface';\n\nimport { convertNormalPath, convertPolarPath } from './util/path';\n\n/** ShapeFactory 基类 */\nconst ShapeFactoryBase = {\n /** 坐标系对象 */\n coordinate: null,\n /** 默认绘制的 Shape 类型 */\n defaultShapeType: null,\n /** 主题样式 */\n theme: null,\n /**\n * 获取 shape 绘制需要的关键点\n * @param shapeType shape 类型\n * @param shapePoint 每条数据映射后的坐标点以及 size 数值\n * @returns 图形关键点信息\n */\n getShapePoints(shapeType: string, shapePoint: ShapePoint) {\n const shape = this.getShape(shapeType);\n if (shape.getPoints) {\n return shape.getPoints(shapePoint);\n }\n\n return this.getDefaultPoints(shapePoint);\n },\n /**\n * 根据 shape 类型获取具体的 shape 实例\n * @param shapeType string shape 的类型\n * @returns\n */\n getShape(shapeType: string): Shape {\n const shape = this[shapeType] || this[this.defaultShapeType];\n shape.coordinate = this.coordinate;\n\n return shape;\n },\n /**\n * 获取 shape 的默认关键点\n * @override\n */\n getDefaultPoints() {\n return [];\n },\n /**\n * 获取 shape 的默认绘制样式 (内置的 shapeFactory 均有注册默认样式)\n */\n getDefaultStyle(geometryTheme: LooseObject): LooseObject {\n return get(geometryTheme, [this.defaultShapeType, 'default', 'style'], {});\n },\n /**\n * 获取 shape 对应的缩略图配置信息。\n * @param shapeType shape 类型\n * @param color 颜色\n * @param isInPolar 是否在极坐标系下\n * @returns 返回缩略图 marker 配置。\n */\n getMarker(shapeType: string, markerCfg: ShapeMarkerCfg): ShapeMarkerAttrs {\n let shape = this.getShape(shapeType);\n\n if (!shape.getMarker) {\n const defaultShapeType = this.defaultShapeType;\n shape = this.getShape(defaultShapeType);\n }\n\n const theme = this.theme;\n const shapeStyle = get(theme, [shapeType, 'default'], {});\n const markerStyle = shape.getMarker(markerCfg);\n\n return deepMix({}, shapeStyle, markerStyle);\n },\n /**\n * 绘制 shape\n * @override\n * @param shapeType 绘制的 shape 类型\n * @param cfg 绘制 shape 需要的信息\n * @param element Element 实例\n * @returns\n */\n drawShape(shapeType: string, cfg: ShapeInfo, container: IGroup): IShape | IGroup {\n const shape = this.getShape(shapeType);\n return shape.draw(cfg, container);\n },\n};\n\n/** Shape 基类 */\nconst ShapeBase = {\n /** 坐标系对象 */\n coordinate: null,\n /**\n * 将归一化的 path 转换成坐标系下的 path\n * @param path 归一化的路径\n * @returns\n */\n parsePath(path: string): PathCommand[] {\n const coordinate = this.coordinate;\n let parsedPath = parsePathString(path);\n if (coordinate.isPolar) {\n parsedPath = convertPolarPath(coordinate, parsedPath);\n } else {\n parsedPath = convertNormalPath(coordinate, parsedPath);\n }\n return parsedPath;\n },\n /**\n * 将归一化的坐标转换成画布坐标\n * @param point 归一化的坐标点数据\n * @returns\n */\n parsePoint(point: Point): Point {\n const coordinate = this.coordinate;\n return coordinate.convert(point);\n },\n /**\n * 0~1 points 转 画布 points\n * @param points 节点集合\n * @returns\n */\n parsePoints(points: Point[]): Point[] {\n const coordinate = this.coordinate;\n return points.map((point) => {\n return coordinate.convert(point);\n });\n },\n /**\n * 绘制 shape\n * @override\n */\n draw(cfg: ShapeInfo, container: IGroup) {},\n};\n\nconst ShapeFactoryMap = {};\n\n/**\n * 注册 ShapeFactory。\n * @param factoryName ShapeFactory 名称,对应 Geometry 几何标记名称。\n * @param cfg 注册 ShapeFactory 需要覆写定义的属性。\n * @returns 返回 ShapeFactory 对象。\n */\nexport function registerShapeFactory(factoryName: string, cfg: RegisterShapeFactory): ShapeFactory {\n const className = upperFirst(factoryName);\n const geomObj = {\n ...ShapeFactoryBase,\n ...cfg,\n geometryType: factoryName,\n };\n ShapeFactoryMap[className] = geomObj;\n return geomObj;\n}\n\n/**\n * 注册 Shape。\n * @param factoryName 对应的 ShapeFactory 名称。\n * @param shapeType 注册的 shape 名称。\n * @param cfg 注册 Shape 需要覆写定义的属性。\n * @returns shape 返回注册的 shape 对象。\n */\nexport function registerShape(factoryName: string, shapeType: string, cfg: RegisterShape): Shape {\n const className = upperFirst(factoryName);\n const factory = ShapeFactoryMap[className];\n const shapeObj = {\n ...ShapeBase,\n ...cfg,\n };\n factory[shapeType] = shapeObj;\n return shapeObj;\n}\n\n/**\n * 获取 factoryName 对应的 shapeFactory\n * @param factoryName\n * @returns shape factory\n */\nexport function getShapeFactory(factoryName: string): ShapeFactory {\n const className = upperFirst(factoryName);\n return ShapeFactoryMap[className];\n}\n","import { isEqual, some } from '@antv/util';\nimport { ShapeInfo } from '../../interface';\n\n/**\n * @ignore\n * Determines whether model is change\n * @param currentModel\n * @param preModel\n * @returns\n */\nexport function isModelChange(currentModel: ShapeInfo, preModel: ShapeInfo) {\n return some(\n ['color', 'shape', 'size', 'x', 'y', 'isInCircle', 'data', 'style', 'defaultStyle', 'points', 'mappingData'],\n (key: string) => {\n return !isEqual(currentModel[key], preModel[key]);\n }\n );\n}\n","import { isArray } from '@antv/util';\n\n/** @ignore */\nexport function parseFields(field: string | string[]): string[] {\n if (isArray(field)) {\n return field;\n }\n\n return field.split('*');\n}\n","/**\n * 对比当前元素和之前的元素,返回 added, updated, removed\n * @param keyItem 之前的元素的,按照 key-item 的 object 的形式存储\n * @param keys 现在的元素,按照 array 的形式存储\n * @returns 由 added, updated, removed array 构成的 object\n */\nexport function diff(keyItem: Record, keys: string[]) {\n const added = [];\n const updated = [];\n const removed = [];\n const keyIncluded = new Map();\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n if (keyItem[key]) updated.push(key);\n else added.push(key);\n keyIncluded.set(key, true);\n }\n\n Object.keys(keyItem).forEach((key) => {\n if (!keyIncluded.has(key)) removed.push(key);\n });\n\n return {\n added,\n updated,\n removed,\n };\n}\n","import { Adjust, getAdjust as getAdjustClass } from '@antv/adjust';\nimport { Attribute, getAttribute as getAttributeClass } from '@antv/attr';\nimport {\n clone,\n deepMix,\n each,\n flatten,\n get,\n isArray,\n isEmpty,\n isEqual,\n isFunction,\n isNil,\n isNumber,\n isObject,\n isPlainObject,\n isString,\n set,\n} from '@antv/util';\nimport { doGroupAppearAnimate, getDefaultAnimateCfg } from '../animate';\nimport Base from '../base';\nimport { FIELD_ORIGIN, GEOMETRY_LIFE_CIRCLE, GROUP_ATTRS } from '../constant';\nimport { BBox, Coordinate, IGroup, IShape, Scale } from '../dependents';\nimport {\n AdjustOption,\n AdjustType,\n AnimateOption,\n AttributeOption,\n ColorAttrCallback,\n Data,\n Datum,\n GeometryLabelCfg,\n GeometryTooltipOption,\n LabelCallback,\n LabelOption,\n LooseObject,\n MappingDatum,\n ScaleOption,\n ShapeAttrCallback,\n ShapeFactory,\n ShapeInfo,\n ShapeMarkerCfg,\n ShapeMarkerAttrs,\n ShapePoint,\n SizeAttrCallback,\n StateOption,\n StyleCallback,\n StyleOption,\n TooltipCallback,\n CustomOption,\n} from '../interface';\nimport { uniq } from '../util/helper';\nimport Element from './element';\nimport { getGeometryLabel } from './label';\nimport GeometryLabel from './label/base';\nimport { getShapeFactory } from './shape/base';\nimport { group } from './util/group-data';\nimport { isModelChange } from './util/is-model-change';\nimport { parseFields } from './util/parse-fields';\nimport { diff } from './util/diff';\nimport { inferScaleType } from '../util/scale';\nimport { getXDimensionLength } from '../util/coordinate';\n\n/** @ignore */\ninterface AttributeInstanceCfg {\n fields?: string[];\n callback?: (...args) => any;\n values?: string[] | number[];\n scales?: Scale[];\n}\ninterface DimValuesMapType {\n [dim: string]: number[];\n}\n/** @ignore */\ninterface AdjustInstanceCfg {\n type: AdjustType;\n adjustNames?: string[];\n xField?: string;\n yField?: string;\n\n dodgeBy?: string;\n marginRatio?: number;\n dodgeRatio?: number;\n\n size?: number;\n height?: number;\n reverseOrder?: boolean;\n\n /** 像素级柱间宽度,调整offset */\n intervalPadding?: number;\n dodgePadding?: number;\n /** x维度长度,计算归一化padding使用 */\n xDimensionLength?: number;\n /** 分组数,计算offset */\n groupNum?: number;\n /** 用户配置宽度 size */\n defaultSize?: number;\n /** 最大最小宽度约束 */\n maxColumnWidth?: number;\n minColumnWidth?: number;\n /** 柱宽比例 */\n columnWidthRatio?: number;\n /** 用户自定义的dimValuesMap */\n dimValuesMap?: DimValuesMapType;\n}\n\n/** geometry.init() 传入参数 */\nexport interface InitCfg {\n /** 坐标系 */\n coordinate?: Coordinate;\n /** 数据 */\n data?: Data;\n /** 主题对象 */\n theme?: LooseObject;\n /** 列定义 */\n scaleDefs?: Record;\n /** 因为数据使用的引用,所以需要有一个标识位标识数据是否发生了更新 */\n isDataChanged?: boolean;\n isCoordinateChanged?: boolean;\n}\n\n/** Geometry 构造函数参数 */\nexport interface GeometryCfg {\n /** Geometry shape 的容器。 */\n container: IGroup;\n /** 绘制的坐标系对象。 */\n coordinate?: Coordinate;\n /** 绘制数据。 */\n data?: Data;\n /** 需要的 scales。 */\n scales?: Record;\n /** 列定义 */\n scaleDefs?: Record;\n /** Geometry labels 的容器 */\n labelsContainer?: IGroup;\n /** 是否对数据进行排序 */\n sortable?: boolean;\n /** elements 的 zIndex 默认按顺序提升,通过 zIndexReversed 可以反序,从而数据越前,层级越高 */\n zIndexReversed?: boolean;\n /** 是否需要对 zIndex 进行 sort。因为耗时长,由具体场景自行决定 */\n sortZIndex?: boolean;\n /** 延迟渲染 Geometry 数据标签. 设置为 true 时,会在浏览器空闲时期被调用, 也可以指定具体 timeout 时间 */\n useDeferredLabel?: boolean | number;\n /** 是否可见 */\n visible?: boolean;\n /** 主题配置 */\n theme?: LooseObject;\n\n /** 组间距 */\n intervalPadding?: number;\n /** 组内间距 */\n dodgePadding?: number;\n /** 柱状图最大宽度 */\n maxColumnWidth?: number;\n /** 柱状图最小宽度 */\n minColumnWidth?: number;\n /** 默认宽度占比,interval类型和schema类型通用 */\n columnWidthRatio?: number;\n /** 玫瑰图占比 */\n roseWidthRatio?: number;\n /** 多层饼图/环图占比 */\n multiplePieWidthRatio?: number;\n}\n\n/**\n * Geometry 几何标记基类,主要负责数据到图形属性的映射以及绘制逻辑。\n */\nexport default class Geometry extends Base {\n /** Geometry 几何标记类型。 */\n public readonly type: string = 'base';\n /** ShapeFactory 对应的类型。 */\n public readonly shapeType: string;\n\n // 在创建 Geometry 实例时可以传入的属性\n /** Coordinate 坐标系实例。 */\n public coordinate: Coordinate;\n /** 用户绘制数据。 */\n public data: Data;\n /** 图形绘制容器。 */\n public readonly container: IGroup;\n /** label 绘制容器。 */\n public readonly labelsContainer: IGroup;\n /** 是否对数据进行排序,默认为 false。 */\n public sortable: boolean;\n /** 当前 Geometry 实例主题。 */\n public theme: LooseObject;\n /** 存储 geometry 需要的 scales,需要外部传入。 */\n public scales: Record;\n /** scale 定义,需要外部传入。 */\n public scaleDefs: Record;\n /** 画布区域,用于 label 布局。 */\n public canvasRegion: BBox;\n\n // 内部产生的属性\n /** Attribute map */\n public attributes: Record = {};\n /** Element map */\n public elements: Element[] = [];\n /**\n * 存储处理后的数据,\n * + init() 及 updateData() 逻辑后, 结构为 Data[];\n * + paint() 逻辑后,结构为 MappingDatum[][]。\n */\n public dataArray: MappingDatum[][];\n /** 存储 tooltip 配置信息。 */\n public tooltipOption: GeometryTooltipOption | boolean;\n /** 存储 label 配置信息。 */\n public labelOption: LabelOption | false;\n /** 状态量相关的配置项 */\n public stateOption: StateOption;\n /** 使用 key-value 结构存储 Element,key 为每个 Element 实例对应的唯一 ID */\n public elementsMap: Record = {};\n /** animate 配置项 */\n public animateOption: AnimateOption | boolean = true;\n /** 图形属性映射配置 */\n protected attributeOption: Record = {};\n /** adjust 配置项 */\n protected adjustOption: AdjustOption[];\n /** style 配置项 */\n protected styleOption: StyleOption;\n /** custom 自定义的配置项 */\n protected customOption: CustomOption;\n /** 每个 Geometry 对应的 Shape 工厂实例,用于创建各个 Shape */\n protected shapeFactory: ShapeFactory;\n /** 存储上一次渲染时的 element 映射表,用于更新逻辑 */\n protected lastElementsMap: Record = {};\n /** 是否生成多个点来绘制图形。 */\n protected generatePoints: boolean = false;\n /** 存储发生图形属性映射前的数据 */\n protected beforeMappingData: Data[] = null;\n /** 存储每个 shape 的默认 size,用于 Interval、Schema 几何标记 */\n protected defaultSize: number;\n\n // 用户通过 geometry 构造函数设置的主题\n private userTheme: LooseObject;\n private adjusts: Record = {};\n private lastAttributeOption;\n private idFields: string[] = [];\n private geometryLabel: GeometryLabel;\n\n // 柱状图间距相关配置\n /** 组间距 */\n protected intervalPadding: number;\n /** 组内间距 */\n protected dodgePadding: number;\n /** 柱状图最大宽度 */\n protected maxColumnWidth: number;\n /** 柱状图最小宽度 */\n protected minColumnWidth: number;\n /** 一般柱状图宽度占比 */\n protected columnWidthRatio: number;\n /** 玫瑰图占比 */\n protected roseWidthRatio: number;\n /** 多层饼图/环图占比 */\n protected multiplePieWidthRatio: number;\n /** elements 的 zIndex 默认按顺序提升,通过 zIndexReversed 可以反序,从而数据越前,层级越高 */\n public zIndexReversed?: boolean;\n /** 是否需要对 zIndex 进行 sort。因为耗时长,由具体场景自行决定 */\n public sortZIndex?: boolean;\n protected useDeferredLabel?: null | number;\n\n /** 虚拟 Group,用于图形更新 */\n private offscreenGroup: IGroup;\n private groupScales: Scale[];\n private hasSorted: boolean = false;\n protected isCoordinateChanged: boolean = false;\n\n /**\n * 创建 Geometry 实例。\n * @param cfg\n */\n constructor(cfg: GeometryCfg) {\n super(cfg);\n\n const {\n container,\n labelsContainer,\n coordinate,\n data,\n sortable = false,\n visible = true,\n theme,\n scales = {},\n scaleDefs = {},\n // 柱状图间隔与宽度相关配置\n intervalPadding,\n dodgePadding,\n maxColumnWidth,\n minColumnWidth,\n columnWidthRatio,\n roseWidthRatio,\n multiplePieWidthRatio,\n zIndexReversed,\n sortZIndex,\n useDeferredLabel,\n } = cfg;\n\n this.container = container;\n this.labelsContainer = labelsContainer;\n this.coordinate = coordinate;\n this.data = data;\n this.sortable = sortable;\n this.visible = visible;\n this.userTheme = theme;\n this.scales = scales;\n this.scaleDefs = scaleDefs;\n // 柱状图间隔与宽度相关配置\n this.intervalPadding = intervalPadding;\n this.dodgePadding = dodgePadding;\n this.maxColumnWidth = maxColumnWidth;\n this.minColumnWidth = minColumnWidth;\n this.columnWidthRatio = columnWidthRatio;\n this.roseWidthRatio = roseWidthRatio;\n this.multiplePieWidthRatio = multiplePieWidthRatio;\n this.zIndexReversed = zIndexReversed;\n this.sortZIndex = sortZIndex;\n this.useDeferredLabel = useDeferredLabel ? (typeof useDeferredLabel === 'number' ? useDeferredLabel : Infinity) : null;\n }\n\n /**\n * 配置 position 通道映射规则。\n *\n * @example\n * ```typescript\n * // 数据结构: [{ x: 'A', y: 10, color: 'red' }]\n * geometry.position('x*y');\n * geometry.position([ 'x', 'y' ]);\n * geometry.position({\n * fields: [ 'x', 'y' ],\n * });\n * ```\n *\n * @param cfg 映射规则\n * @returns\n */\n public position(cfg: string | string[] | AttributeOption): Geometry {\n let positionCfg = cfg;\n if (!isPlainObject(cfg)) {\n // 字符串字段或者数组字段\n positionCfg = {\n fields: parseFields(cfg),\n };\n }\n\n const fields = get(positionCfg, 'fields');\n if (fields.length === 1) {\n // 默认填充一维 1*xx\n fields.unshift('1');\n set(positionCfg, 'fields', fields);\n }\n set(this.attributeOption, 'position', positionCfg);\n\n return this;\n }\n\n /**\n * 配置 color 通道映射规则。\n *\n * @example\n * ```typescript\n * // data: [{ x: 'A', y: 10, color: 'red' }, { x: 'B', y: 30, color: 'yellow' }]\n * geometry.color({\n * fields: [ 'x' ],\n * values: [ '#1890ff', '#5AD8A6' ],\n * });\n * ```\n *\n * @param field 映射规则\n * @returns\n */\n public color(field: AttributeOption): Geometry;\n /**\n * @example\n * ```typescript\n * // data: [{ x: 'A', y: 10, color: 'red' }, { x: 'B', y: 30, color: 'yellow' }]\n *\n * // 使用 '#1890ff' 颜色渲染图形\n * geometry.color('#1890ff');\n *\n * // 根据 x 字段的数据值进行颜色的映射,这时候 G2 会在内部调用默认的回调函数,读取默认提供的颜色进行数据值到颜色值的映射。\n * geometry.color('x');\n *\n * // 将 'x' 字段的数据值映射至指定的颜色值 colors(可以是字符串也可以是数组),此时用于通常映射分类数据\n * geometry.color('x', [ '#1890ff', '#5AD8A6' ]);\n *\n * // 使用回调函数进行颜色值的自定义;可以使用多个字段使用、*号连接\n * geometry.color('x', (xVal) => {\n * if (xVal === 'a') {\n * return 'red';\n * }\n * return 'blue';\n * });\n *\n * // 指定颜色的渐变路径,用于映射连续的数据\n * geometry.color('x', '#BAE7FF-#1890FF-#0050B3');\n * ```\n *\n * @param field 参与颜色映射的数据字段,多个字段使用 '*' 连接符进行连接。\n * @param cfg Optional, color 映射规则。\n * @returns\n */\n public color(field: string, cfg?: string | string[] | ColorAttrCallback): Geometry;\n public color(field: AttributeOption | string, cfg?: string | string[] | ColorAttrCallback): Geometry {\n this.createAttrOption('color', field, cfg);\n\n return this;\n }\n\n /**\n * 配置 shape 通道映射规则。\n *\n * @example\n *\n * ```typescript\n * // data: [{ x: 'A', y: 10, color: 'red' }, { x: 'B', y: 30, color: 'yellow' }]\n * geometry.shape({\n * fields: [ 'x' ],\n * });\n * ```\n *\n * @param field 映射规则配置。\n * @returns\n */\n public shape(field: AttributeOption): Geometry;\n /**\n *\n * @example\n * ```typescript\n * // data: [{ x: 'A', y: 10, color: 'red' }, { x: 'B', y: 30, color: 'yellow' }]\n *\n * // 指定常量,将所有数据值映射到固定的 shape\n * geometry.shape('circle');\n *\n * // 将指定的字段映射到内置的 shapes 数组中\n * geometry.shape('x');\n *\n * // 将指定的字段映射到指定的 shapes 数组中\n * geometry.shape('x', [ 'circle', 'diamond', 'square' ]);\n *\n * // 使用回调函数获取 shape,用于个性化的 shape 定制,可以根据单个或者多个字段确定\n * geometry.shape('x', (xVal) => {\n * if (xVal === 'a') {\n * return 'circle';\n * }\n * return 'diamond';\n * });\n * ```\n *\n * @param field 参与 shape 映射的数据字段,多个字段使用 '*' 连接符进行连接。\n * @param cfg Optional, shape 映射规则。\n * @returns\n */\n public shape(field: string, cfg?: string[] | ShapeAttrCallback): Geometry;\n public shape(field: AttributeOption | string, cfg?: string[] | ShapeAttrCallback): Geometry {\n this.createAttrOption('shape', field, cfg);\n\n return this;\n }\n\n /**\n * 配置 size 通道映射规则。\n *\n * @example\n * ```typescript\n * // data: [{ x: 'A', y: 10, color: 'red' }, { x: 'B', y: 30, color: 'yellow' }]\n * geometry.size({\n * values: [ 10 ],\n * })\n * ```\n *\n * @param field 映射规则。\n * @returns\n */\n public size(field: AttributeOption): Geometry;\n /**\n *\n * @example\n * ```typescript\n * // data: [{ x: 'A', y: 10, color: 'red' }, { x: 'B', y: 30, color: 'yellow' }]\n *\n * // 直接指定像素大小\n * geometry.size(10);\n *\n * // 指定映射到 size 的字段,使用内置的默认大小范围为 [1, 10]\n * geometry.size('x');\n *\n * // 指定映射到 size 字段外,还提供了 size 的最大值和最小值范围\n * geometry.size('x', [ 5, 30 ]);\n *\n * // 使用回调函数映射 size,用于个性化的 size 定制,可以使用多个字段进行映射\n * geometry.size('x', (xVal) => {\n * if (xVal === 'a') {\n * return 10;\n * }\n * return 5;\n * });\n * ```\n *\n * @param field 参与 size 映射的数据字段,多个字段使用 '*' 连接符进行连接。\n * @param cfg Optional, size 映射规则\n * @returns\n */\n public size(field: number | string, cfg?: [number, number] | SizeAttrCallback): Geometry;\n public size(field: AttributeOption | number | string, cfg?: [number, number] | SizeAttrCallback): Geometry {\n this.createAttrOption('size', field, cfg);\n\n return this;\n }\n\n /**\n * 设置数据调整方式。G2 目前内置了四种类型:\n * 1. dodge\n * 2. stack\n * 3. symmetric\n * 4. jitter\n *\n *\n * **Tip**\n * + 对于 'dodge' 类型,可以额外进行如下属性的配置:\n * ```typescript\n * geometry.adjust('dodge', {\n * marginRatio: 0, // 取 0 到 1 范围的值(相对于每个柱子宽度),用于控制一个分组中柱子之间的间距\n * dodgeBy: 'x', // 该属性只对 'dodge' 类型生效,声明以哪个数据字段为分组依据\n * });\n * ```\n *\n * + 对于 'stack' 类型,可以额外进行如下属性的配置:\n * ```typescript\n * geometry.adjust('stack', {\n * reverseOrder: false, // 用于控制是否对数据进行反序操作\n * });\n * ```\n *\n * @example\n * ```typescript\n * geometry.adjust('stack');\n *\n * geometry.adjust({\n * type: 'stack',\n * reverseOrder: false,\n * });\n *\n * // 组合使用 adjust\n * geometry.adjust([ 'stack', 'dodge' ]);\n *\n * geometry.adjust([\n * { type: 'stack' },\n * { type: 'dodge', dodgeBy: 'x' },\n * ]);\n * ```\n *\n * @param adjustCfg 数据调整配置\n * @returns\n */\n public adjust(adjustCfg: string | string[] | AdjustOption | AdjustOption[]): Geometry {\n let adjusts: any = adjustCfg;\n if (isString(adjustCfg) || isPlainObject(adjustCfg)) {\n adjusts = [adjustCfg];\n }\n each(adjusts, (adjust, index) => {\n if (!isObject(adjust)) {\n adjusts[index] = { type: adjust };\n }\n });\n\n this.adjustOption = adjusts;\n return this;\n }\n\n /**\n * 图形样式配置。\n *\n * @example\n * ```typescript\n * // 配置图形样式\n * style({\n * lineWidth: 2,\n * stroke: '#1890ff',\n * });\n *\n * // 根据具体的数据进行详细配置\n * style({\n * fields: [ 'x', 'y' ], // 数据字段\n * callback: (xVal, yVal) => {\n * const style = { lineWidth: 2, stroke: '#1890ff' };\n * if (xVal === 'a') {\n * style.lineDash = [ 2, 2 ];\n * }\n * return style;\n * },\n * });\n * ```\n *\n * @param field 配置样式属性或者样式规则。\n * @returns\n */\n public style(field: StyleOption | LooseObject): Geometry;\n /**\n * @example\n * ```typescript\n * style('x*y', (xVal, yVal) => {\n * const style = { lineWidth: 2, stroke: '#1890ff' };\n * if (xVal === 'a') {\n * style.lineDash = [ 2, 2 ];\n * }\n * return style;\n * });\n * ```\n *\n * @param field 数据字段或者样式配置规则。\n * @param styleFunc Optional, 样式配置回调函数。\n * @returns\n */\n public style(field: string, styleFunc: StyleCallback): Geometry;\n public style(field: StyleOption | LooseObject | string, styleFunc?: StyleCallback): Geometry {\n if (isString(field)) {\n const fields = parseFields(field);\n this.styleOption = {\n fields,\n callback: styleFunc,\n };\n } else {\n const { fields, callback, cfg } = field as StyleOption;\n if (fields || callback || cfg) {\n this.styleOption = field;\n } else {\n this.styleOption = {\n cfg: field,\n };\n }\n }\n\n return this;\n }\n\n /**\n * 配置 Geometry 显示的 tooltip 内容。\n *\n * `tooltip(false)` 代表关闭 tooltip。\n * `tooltip(true)` 代表开启 tooltip。\n *\n * Geometry 默认允许 tooltip 展示,我们可以使用以下方法对 tooltip 的展示内容进行配置:\n *\n * @example\n * ```typescript\n * // data: [{x: 'a', y: 10}]\n * tooltip({\n * fields: [ 'x' ],\n * });\n * ```\n * ![](https://gw.alipayobjects.com/mdn/rms_2274c3/afts/img/A*268uQ50if60AAAAAAAAAAABkARQnAQ)\n *\n * ```typescript\n * tooltip({\n * fields: [ 'x', 'y' ],\n * });\n * ```\n * ![](https://gw.alipayobjects.com/mdn/rms_2274c3/afts/img/A*A_ujSa8QhtcAAAAAAAAAAABkARQnAQ)\n *\n * tooltip() 方法同样支持数据映射及回调用法:\n *\n * @example\n * ```typescript\n * chart.tooltip({\n * itemTpl: '
  • {x}: {y}
  • ',\n * });\n *\n * chart.line()\n * .position('x*y')\n * .tooltip({\n * fields: [ 'x', 'y' ],\n * callback: (x, y) => {\n * return {\n * x,\n * y,\n * };\n * },\n * });\n * ```\n *\n * 其返回的值必须为对象,该值中的属性同 chart.tooltip() 的 itemTpl 模板相对应,返回的变量可用于 itemTpl 的字符串模板。\n *\n * @param field tooltip 配置信息。\n * @returns\n */\n public tooltip(field: GeometryTooltipOption | boolean): Geometry;\n /**\n * @example\n * ```typescript\n * // data: [{x: 'a', y: 10}]\n *\n * // 等同于 tooltip({ fields: [ 'x' ] })\n * tooltip('x');\n *\n * // 等同于 tooltip({ fields: [ 'x', 'y' ] })\n * tooltip('x*y');\n *\n * // 等同于 tooltip({ fields: [ 'x', 'y' ], callback: (x, y) => { x, y } })\n * tooltip('x*y', (x, y) => {\n * return {\n * x,\n * y,\n * };\n * });\n * ```\n *\n * @param field 参与映射的字段。\n * @param cfg Optional, 回调函数\n * @returns\n */\n public tooltip(field: string, cfg?: TooltipCallback): Geometry;\n public tooltip(field: GeometryTooltipOption | boolean | string, cfg?: TooltipCallback): Geometry {\n if (isString(field)) {\n const fields = parseFields(field);\n this.tooltipOption = {\n fields,\n callback: cfg,\n };\n } else {\n this.tooltipOption = field;\n }\n\n return this;\n }\n\n /**\n * Geometry 动画配置。\n *\n * + `animate(false)` 关闭动画\n * + `animate(true)` 开启动画,默认开启。\n *\n * 我们将动画分为四个场景:\n * 1. appear: 图表第一次加载时的入场动画;\n * 2. enter: 图表绘制完成,发生更新后,产生的新图形的进场动画;\n * 3. update: 图表绘制完成,数据发生变更后,有状态变更的图形的更新动画;\n * 4. leave: 图表绘制完成,数据发生变更后,被销毁图形的销毁动画。\n *\n * @example\n * ```typescript\n * animate({\n * enter: {\n * duration: 1000, // enter 动画执行时间\n * },\n * leave: false, // 关闭 leave 销毁动画\n * });\n * ```\n *\n * @param cfg 动画配置\n * @returns\n */\n public animate(cfg: AnimateOption | boolean): Geometry {\n this.animateOption = cfg;\n return this;\n }\n\n /**\n * Geometry label 配置。\n *\n * @example\n * ```ts\n * // data: [ {x: 1, y: 2, z: 'a'}, {x: 2, y: 2, z: 'b'} ]\n * // 在每个图形上显示 z 字段对应的数值\n * label({\n * fields: [ 'z' ]\n * });\n *\n * label(false); // 不展示 label\n *\n * // 在每个图形上显示 x 字段对应的数值,同时配置文本颜色为红色\n * label('x', {\n * style: {\n * fill: 'red',\n * },\n * })\n *\n * // 以 type 类型的 label 渲染每个图形上显示 x 字段对应的数值,同时格式化文本内容\n * label('x', (xValue) => {\n * return {\n * content: xValue + '%',\n * };\n * }, {\n * type: 'base' // 声明 label 类型\n * })\n * ```\n *\n * @param field\n * @returns label\n */\n public label(field: LabelOption | false | string): Geometry;\n public label(field: string, secondParam: GeometryLabelCfg | LabelCallback): Geometry;\n public label(field: string, secondParam: LabelCallback, thirdParam: GeometryLabelCfg): Geometry;\n public label(\n field: string | LabelOption | false,\n secondParam?: GeometryLabelCfg | LabelCallback,\n thirdParam?: GeometryLabelCfg\n ): Geometry {\n if (isString(field)) {\n const labelOption: LabelOption = {};\n const fields = parseFields(field);\n labelOption.fields = fields;\n if (isFunction(secondParam)) {\n labelOption.callback = secondParam;\n } else if (isPlainObject(secondParam)) {\n labelOption.cfg = secondParam;\n }\n\n if (thirdParam) {\n labelOption.cfg = thirdParam;\n }\n this.labelOption = labelOption;\n } else {\n this.labelOption = field;\n }\n\n return this;\n }\n\n /**\n * 设置状态对应的样式。\n *\n * @example\n * ```ts\n * chart.interval().state({\n * selected: {\n * animate: { duration: 100, easing: 'easeLinear' },\n * style: {\n * lineWidth: 2,\n * stroke: '#000',\n * },\n * },\n * });\n * ```\n *\n * 如果图形 shape 是由多个 shape 组成,即为一个 G.Group 对象,那么针对 group 中的每个 shape,我们需要使用下列方式进行状态样式设置:\n * 如果我们为 group 中的每个 shape 设置了 'name' 属性(shape.set('name', 'xx')),则以 'name' 作为 key,否则默认以索引值(即 shape 的 添加顺序)为 key。\n *\n * ```ts\n * chart.interval().shape('groupShape').state({\n * selected: {\n * style: {\n * 0: { lineWidth: 2 },\n * 1: { fillOpacity: 1 },\n * }\n * }\n * });\n * ```\n *\n * @param cfg 状态样式\n */\n public state(cfg: StateOption) {\n this.stateOption = cfg;\n return this;\n }\n\n /**\n * 用于向 shape 中传入自定义的数据。目前可能仅仅可能用于在自定义 shape 的时候,像自定义 shape 中传入自定义的数据,方便实现自定义 shape 的配置能力。\n *\n * @example\n * ```ts\n * chart.interval().customInfo({ yourData: 'hello, g2!' });\n * ```\n *\n * 然后在自定义 shape 的时候,可以拿到这个信息。\n *\n * ```ts\n * registerShape('interval', 'your-shape', {\n * draw(shapeInfo, container) {\n * const { customInfo } = shapeInfo;\n * console.log(customInfo); // will log { yourData: 'hello, g2!' }.\n * }\n * });\n * ```\n *\n * @param cfg\n */\n public customInfo(cfg: any) {\n this.customOption = cfg;\n return this;\n }\n\n /**\n * 初始化 Geomtry 实例:\n * 创建 [[Attribute]] and [[Scale]] 实例,进行数据处理,包括分组、数值化以及数据调整。\n */\n public init(cfg: InitCfg = {}) {\n this.setCfg(cfg);\n this.initAttributes(); // 创建图形属性\n\n // 数据加工:分组 -> 数字化 -> adjust\n this.processData(this.data);\n\n // 调整 scale\n this.adjustScale();\n }\n\n /**\n * Geometry 更新。\n * @param [cfg] 更新的配置\n */\n public update(cfg: InitCfg = {}) {\n const { data, isDataChanged, isCoordinateChanged } = cfg;\n const { attributeOption, lastAttributeOption } = this;\n\n if (!isEqual(attributeOption, lastAttributeOption)) {\n // 映射发生改变,则重新创建图形属性\n this.init(cfg);\n } else if (data && (isDataChanged || !isEqual(data, this.data))) {\n // 数据发生变化\n this.setCfg(cfg);\n this.initAttributes(); // 创建图形属性\n this.processData(data); // 数据加工:分组 -> 数字化 -> adjust\n } else {\n // 有可能 coordinate 变化\n this.setCfg(cfg);\n }\n\n // 调整 scale\n this.adjustScale();\n this.isCoordinateChanged = isCoordinateChanged;\n }\n\n /**\n * 将原始数据映射至图形空间,同时创建图形对象。\n */\n public paint(isUpdate: boolean = false) {\n if (this.animateOption) {\n this.animateOption = deepMix({}, getDefaultAnimateCfg(this.type, this.coordinate), this.animateOption);\n }\n\n this.defaultSize = undefined;\n this.elementsMap = {};\n this.elements = [];\n const offscreenGroup = this.getOffscreenGroup();\n offscreenGroup.clear();\n\n const beforeMappingData = this.beforeMappingData;\n const dataArray = this.beforeMapping(beforeMappingData);\n\n this.dataArray = new Array(dataArray.length);\n for (let i = 0; i < dataArray.length; i++) {\n const data = dataArray[i];\n this.dataArray[i] = this.mapping(data);\n }\n this.updateElements(this.dataArray, isUpdate);\n this.lastElementsMap = this.elementsMap;\n\n if (this.canDoGroupAnimation(isUpdate)) {\n // 如果用户没有配置 appear.animation,就默认走整体动画\n const container = this.container;\n const type = this.type;\n const coordinate = this.coordinate;\n const animateCfg = get(this.animateOption, 'appear');\n const yScale = this.getYScale();\n const yMinPoint = coordinate.convert({\n x: 0,\n y: yScale.scale(this.getYMinValue()),\n });\n doGroupAppearAnimate(container, animateCfg, type, coordinate, yMinPoint);\n }\n\n // 添加 label\n if (this.labelOption) {\n const deferred = this.useDeferredLabel;\n const callback = (() => this.renderLabels(flatten(this.dataArray) as unknown as MappingDatum[], isUpdate)).bind(this);\n if (typeof deferred === 'number') {\n // Use `requestIdleCallback` to render labels in idle time (like react fiber)\n const timeout = (typeof deferred === 'number' && deferred !== Infinity) ? deferred : 0;\n if (!window.requestIdleCallback) {\n setTimeout(callback, timeout);\n } else {\n const options = timeout && timeout !== Infinity ? { timeout } : undefined;\n window.requestIdleCallback(callback, options);\n }\n } else {\n callback();\n }\n }\n\n // 缓存,用于更新\n this.lastAttributeOption = {\n ...this.attributeOption,\n };\n\n if (this.visible === false) {\n // 用户在初始化的时候声明 visible: false\n this.changeVisible(false);\n }\n }\n\n /**\n * 清空当前 Geometry,配置项仍保留,但是内部创建的对象全部清空。\n * @override\n */\n public clear() {\n const { container, geometryLabel, offscreenGroup } = this;\n if (container) {\n container.clear();\n }\n\n if (geometryLabel) {\n geometryLabel.clear();\n }\n\n if (offscreenGroup) {\n offscreenGroup.clear();\n }\n\n // 属性恢复至出厂状态\n this.scaleDefs = undefined;\n this.attributes = {};\n this.scales = {};\n this.elementsMap = {};\n this.lastElementsMap = {};\n this.elements = [];\n this.adjusts = {};\n this.dataArray = null;\n this.beforeMappingData = null;\n this.lastAttributeOption = undefined;\n this.defaultSize = undefined;\n this.idFields = [];\n this.groupScales = undefined;\n this.hasSorted = false;\n this.isCoordinateChanged = false;\n }\n\n /**\n * 销毁 Geometry 实例。\n */\n public destroy() {\n this.clear();\n const container = this.container;\n container.remove(true);\n\n if (this.offscreenGroup) {\n this.offscreenGroup.remove(true);\n this.offscreenGroup = null;\n }\n\n if (this.geometryLabel) {\n this.geometryLabel.destroy();\n this.geometryLabel = null;\n }\n this.theme = undefined;\n this.shapeFactory = undefined;\n\n super.destroy();\n }\n\n /**\n * 获取决定分组的图形属性对应的 scale 实例。\n * @returns\n */\n public getGroupScales(): Scale[] {\n return this.groupScales;\n }\n\n /**\n * 根据名字获取图形属性实例。\n */\n public getAttribute(name: string): Attribute {\n return this.attributes[name];\n }\n\n /** 获取 x 轴对应的 scale 实例。 */\n public getXScale(): Scale {\n return this.getAttribute('position').scales[0];\n }\n\n /** 获取 y 轴对应的 scale 实例。 */\n public getYScale(): Scale {\n return this.getAttribute('position').scales[1];\n }\n\n /**\n * 获取决定分组的图形属性实例。\n */\n public getGroupAttributes(): Attribute[] {\n const rst = [];\n each(this.attributes, (attr: Attribute) => {\n if (GROUP_ATTRS.includes(attr.type)) {\n rst.push(attr);\n }\n });\n return rst;\n }\n\n /** 获取图形属性默认的映射值。 */\n public getDefaultValue(attrName: string) {\n let value: any;\n const attr = this.getAttribute(attrName);\n if (attr && isEmpty(attr.scales)) {\n // 获取映射至常量的值\n value = attr.values[0];\n }\n return value;\n }\n\n /**\n * 获取该数据发生图形映射后对应的 Attribute 图形空间数据。\n * @param attr Attribute 图形属性实例。\n * @param obj 需要进行映射的原始数据。\n * @returns\n */\n public getAttributeValues(attr: Attribute, obj: Datum) {\n const params = [];\n const scales = attr.scales;\n for (let index = 0, length = scales.length; index < length; index++) {\n const scale = scales[index];\n const field = scale.field;\n if (scale.isIdentity) {\n params.push(scale.values);\n } else {\n params.push(obj[field]);\n }\n }\n\n return attr.mapping(...params);\n }\n\n /**\n * 获取对应的 adjust 实例\n * @param adjustType\n * @returns\n */\n public getAdjust(adjustType: string) {\n return this.adjusts[adjustType];\n }\n\n /**\n * 获得 coordinate 实例\n * @returns\n */\n public getCoordinate() {\n return this.coordinate;\n }\n\n public getData() {\n return this.data;\n }\n\n /**\n * 获取 shape 对应的 marker 样式。\n * @param shapeName shape 具体名字\n * @param cfg marker 信息\n * @returns\n */\n public getShapeMarker(shapeName: string, cfg: ShapeMarkerCfg): ShapeMarkerAttrs {\n const shapeFactory = this.getShapeFactory();\n return shapeFactory.getMarker(shapeName, cfg);\n }\n\n /**\n * 根据一定的规则查找 Geometry 的 Elements。\n *\n * ```typescript\n * getElementsBy((element) => {\n * const data = element.getData();\n *\n * return data.a === 'a';\n * });\n * ```\n *\n * @param condition 定义查找规则的回调函数。\n * @returns\n */\n public getElementsBy(condition: (element: Element) => boolean): Element[] {\n return this.elements.filter((element) => condition(element));\n }\n\n /**\n * 获取 Geometry 的所有 Elements。\n *\n * ```typescript\n * getElements();\n * ```\n */\n public getElements() {\n return this.elements;\n }\n\n /**\n * 获取数据对应的唯一 id。\n * @param data Element 对应的绘制数据\n * @returns\n */\n public getElementId(data: MappingDatum | MappingDatum[]) {\n data = isArray(data) ? data[0] : data;\n const originData = data[FIELD_ORIGIN];\n\n // 如果用户声明了使用哪些字段作为 id 值\n if (this.idFields.length) {\n let elementId = originData[this.idFields[0]];\n for (let index = 1; index < this.idFields.length; index++) {\n elementId += '-' + originData[this.idFields[index]];\n }\n\n return elementId;\n }\n\n const type = this.type;\n const xScale = this.getXScale();\n const yScale = this.getYScale();\n const xField = xScale.field || 'x';\n const yField = yScale.field || 'y';\n const yVal = originData[yField];\n let xVal;\n if (xScale.type === 'identity') {\n xVal = xScale.values[0];\n } else {\n xVal = originData[xField];\n }\n\n let id: string;\n if (type === 'interval' || type === 'schema') {\n id = `${xVal}`;\n } else if (type === 'line' || type === 'area' || type === 'path') {\n id = type;\n } else {\n id = `${xVal}-${yVal}`;\n }\n\n const groupScales = this.groupScales;\n\n for (let index = 0, length = groupScales.length; index < length; index++) {\n const groupScale = groupScales[index];\n const field = groupScale.field;\n id = `${id}-${originData[field]}`;\n }\n\n // 用户在进行 dodge 类型的 adjust 调整的时候设置了 dodgeBy 属性\n const dodgeAdjust = this.getAdjust('dodge');\n if (dodgeAdjust) {\n const dodgeBy = dodgeAdjust.dodgeBy;\n if (dodgeBy) {\n id = `${id}-${originData[dodgeBy]}`;\n }\n }\n\n if (this.getAdjust('jitter')) {\n id = `${id}-${data.x}-${data.y}`;\n }\n\n return id;\n }\n\n /**\n * 获取所有需要创建 scale 的字段名称。\n */\n public getScaleFields(): string[] {\n const fields = [];\n const tmpMap = new Map();\n const { attributeOption, labelOption, tooltipOption } = this;\n // 获取图形属性上的 fields\n for (const attributeType in attributeOption) {\n if (attributeOption.hasOwnProperty(attributeType)) {\n const eachOpt = attributeOption[attributeType];\n if (eachOpt.fields) {\n uniq(eachOpt.fields, fields, tmpMap);\n } else if (eachOpt.values) {\n // 考虑 size(10), shape('circle') 等场景\n uniq(eachOpt.values, fields, tmpMap);\n }\n }\n }\n // 获取 label 上的字段\n if (labelOption && labelOption.fields) {\n uniq(labelOption.fields, fields, tmpMap);\n }\n\n // 获取 tooltip 上的字段\n if (isObject(tooltipOption) && tooltipOption.fields) {\n uniq(tooltipOption.fields, fields, tmpMap);\n }\n\n return fields;\n }\n\n /**\n * 显示或者隐藏 geometry。\n * @param visible\n */\n public changeVisible(visible: boolean) {\n super.changeVisible(visible);\n const elements = this.elements;\n for (let index = 0, length = elements.length; index < length; index++) {\n const element = elements[index];\n element.changeVisible(visible);\n }\n if (visible) {\n if (this.container) {\n this.container.show();\n }\n if (this.labelsContainer) {\n this.labelsContainer.show();\n }\n } else {\n if (this.container) {\n this.container.hide();\n }\n if (this.labelsContainer) {\n this.labelsContainer.hide();\n }\n }\n }\n\n /**\n * 获得所有的字段\n */\n public getFields() {\n const uniqMap = new Map();\n const fields = [];\n\n Object.values(this.attributeOption).forEach((cfg) => {\n const fs = cfg?.fields || [];\n fs.forEach((f) => {\n if (!uniqMap.has(f)) {\n fields.push(f);\n }\n uniqMap.set(f, true);\n });\n }, []);\n\n return fields;\n }\n\n /**\n * 获取当前配置中的所有分组 & 分类的字段。\n * @return fields string[]\n */\n public getGroupFields(): string[] {\n const groupFields = [];\n const tmpMap = new Map(); // 用于去重过滤\n for (let index = 0, length = GROUP_ATTRS.length; index < length; index++) {\n const attributeName = GROUP_ATTRS[index];\n const cfg = this.attributeOption[attributeName];\n if (cfg && cfg.fields) {\n uniq(cfg.fields, groupFields, tmpMap);\n }\n }\n\n return groupFields;\n }\n\n /**\n * 获得图形的 x y 字段。\n */\n public getXYFields() {\n const [x, y] = this.attributeOption.position.fields;\n return [x, y];\n }\n\n /**\n * x 字段\n * @returns\n */\n public getXField(): string {\n return get(this.getXYFields(), [0]);\n }\n\n /**\n * y 字段\n * @returns\n */\n public getYField(): string {\n return get(this.getXYFields(), [1]);\n }\n\n /**\n * 获取该 Geometry 下所有生成的 shapes。\n * @returns shapes\n */\n public getShapes(): (IShape | IGroup)[] {\n return this.elements.map((element: Element) => element.shape);\n }\n\n /**\n * 获取虚拟 Group。\n * @returns\n */\n public getOffscreenGroup() {\n if (!this.offscreenGroup) {\n const GroupCtor = this.container.getGroupBase(); // 获取分组的构造函数\n this.offscreenGroup = new GroupCtor({});\n }\n return this.offscreenGroup;\n }\n\n // 对数据进行排序\n public sort(mappingArray: Data[]) {\n if (!this.hasSorted) {\n // 未发生过排序\n const xScale = this.getXScale();\n const xField = xScale.field;\n for (let index = 0; index < mappingArray.length; index++) {\n const itemArr = mappingArray[index];\n itemArr.sort((obj1: Datum, obj2: Datum) => {\n return xScale.translate(obj1[FIELD_ORIGIN][xField]) - xScale.translate(obj2[FIELD_ORIGIN][xField]);\n });\n }\n }\n\n this.hasSorted = true;\n }\n\n /**\n * 调整度量范围。主要针对发生层叠以及一些特殊需求的 Geometry,比如 Interval 下的柱状图 Y 轴默认从 0 开始。\n */\n protected adjustScale() {\n const yScale = this.getYScale();\n // 如果数据发生过 stack adjust,需要调整下 yScale 的数据范围\n if (yScale && this.getAdjust('stack')) {\n this.updateStackRange(yScale, this.beforeMappingData);\n }\n }\n\n /**\n * 获取当前 Geometry 对应的 Shape 工厂实例。\n */\n protected getShapeFactory() {\n const shapeType = this.shapeType;\n if (!getShapeFactory(shapeType)) {\n return;\n }\n if (!this.shapeFactory) {\n this.shapeFactory = clone(getShapeFactory(shapeType)); // 防止多个 view 共享一个 shapeFactory 实例,导致 coordinate 被篡改\n }\n // 因为这里缓存了 shapeFactory,但是外部可能会变更 coordinate,导致无法重新设置到 shapeFactory 中\n this.shapeFactory.coordinate = this.coordinate;\n // theme 原因同上\n this.shapeFactory.theme = this.theme.geometries[shapeType] || {};\n\n return this.shapeFactory;\n }\n\n /**\n * 获取每个 Shape 对应的关键点数据。\n * @param obj 经过分组 -> 数字化 -> adjust 调整后的数据记录\n * @returns\n */\n protected createShapePointsCfg(obj: Datum): S {\n const xScale = this.getXScale();\n const yScale = this.getYScale();\n const x = this.normalizeValues(obj[xScale.field], xScale);\n let y; // 存在没有 y 的情况\n\n if (yScale) {\n y = this.normalizeValues(obj[yScale.field], yScale);\n } else {\n y = obj.y ? obj.y : 0.1;\n }\n\n return {\n x,\n y,\n y0: yScale ? yScale.scale(this.getYMinValue()) : undefined,\n } as S;\n }\n\n /**\n * 创建 Element 实例。\n * @param mappingDatum Element 对应的绘制数据\n * @param [isUpdate] 是否处于更新阶段\n * @returns element 返回创建的 Element 实例\n */\n protected createElement(mappingDatum: MappingDatum, index: number, isUpdate: boolean = false): Element {\n const { container } = this;\n\n const shapeCfg = this.getDrawCfg(mappingDatum); // 获取绘制图形的配置信息\n const shapeFactory = this.getShapeFactory();\n\n const element = new Element({\n shapeFactory,\n container,\n offscreenGroup: this.getOffscreenGroup(),\n elementIndex: index,\n });\n element.animate = this.animateOption;\n element.geometry = this;\n element.draw(shapeCfg, isUpdate); // 绘制\n\n return element;\n }\n\n /**\n * 获取每条数据对应的图形绘制数据。\n * @param mappingDatum 映射后的数据\n * @returns draw cfg\n */\n protected getDrawCfg(mappingDatum: MappingDatum): ShapeInfo {\n const originData = mappingDatum[FIELD_ORIGIN]; // 原始数据\n const cfg: ShapeInfo = {\n mappingData: mappingDatum, // 映射后的数据\n data: originData, // 原始数据\n x: mappingDatum.x,\n y: mappingDatum.y,\n color: mappingDatum.color,\n size: mappingDatum.size,\n isInCircle: this.coordinate.isPolar,\n customInfo: this.customOption,\n };\n\n let shapeName = mappingDatum.shape;\n if (!shapeName && this.getShapeFactory()) {\n shapeName = this.getShapeFactory().defaultShapeType;\n }\n cfg.shape = shapeName;\n // 获取默认样式\n const theme = this.theme.geometries[this.shapeType];\n cfg.defaultStyle = get(theme, [shapeName, 'default'], {}).style;\n if (!cfg.defaultStyle && this.getShapeFactory()) {\n cfg.defaultStyle = this.getShapeFactory().getDefaultStyle(theme);\n }\n\n const styleOption = this.styleOption;\n if (styleOption) {\n cfg.style = this.getStyleCfg(styleOption, originData);\n }\n if (this.generatePoints) {\n cfg.points = mappingDatum.points;\n cfg.nextPoints = mappingDatum.nextPoints;\n }\n\n return cfg;\n }\n\n protected updateElements(mappingDataArray: MappingDatum[][], isUpdate: boolean = false): void {\n const keyDatum = new Map();\n const keys: string[] = [];\n\n // 用来保持 diff 元素之后 added, updated 的相对顺序\n const keyIndex = new Map();\n let index = 0;\n\n // 获得更新数据所有的 keys\n // 将更新的数据用 key 索引\n for (let i = 0; i < mappingDataArray.length; i++) {\n const mappingData = mappingDataArray[i];\n for (let j = 0; j < mappingData.length; j++) {\n const mappingDatum = mappingData[j];\n const key = this.getElementId(mappingDatum);\n const finalKey = keyDatum.has(key) ? `${key}-${i}-${j}` : key;\n keys.push(finalKey);\n keyDatum.set(finalKey, mappingDatum);\n keyIndex.set(finalKey, index);\n index++;\n }\n }\n\n this.elements = new Array(index);\n\n const { added, updated, removed } = diff(this.lastElementsMap, keys);\n\n // 新建 element\n for (const key of added) {\n const mappingDatum = keyDatum.get(key);\n const i = keyIndex.get(key);\n const element = this.createElement(mappingDatum, i, isUpdate);\n this.elements[i] = element;\n this.elementsMap[key] = element;\n if (element.shape) {\n element.shape.set('zIndex', this.zIndexReversed ? this.elements.length - i : i);\n }\n }\n\n // 更新 element\n for (const key of updated) {\n const element = this.lastElementsMap[key];\n const mappingDatum = keyDatum.get(key);\n const currentShapeCfg = this.getDrawCfg(mappingDatum);\n const preShapeCfg = element.getModel();\n const i = keyIndex.get(key);\n if (this.isCoordinateChanged || isModelChange(currentShapeCfg, preShapeCfg)) {\n element.animate = this.animateOption;\n // 通过绘制数据的变更来判断是否需要更新,因为用户有可能会修改图形属性映射\n element.update(currentShapeCfg); // 更新对应的 element\n }\n this.elements[i] = element;\n this.elementsMap[key] = element;\n if (element.shape) {\n element.shape.set('zIndex', this.zIndexReversed ? this.elements.length - i : i);\n }\n }\n\n // 全部 setZIndex 之后,再执行 sort\n if (this.container) {\n this.container.sort();\n }\n\n // 销毁被删除的 elements\n for (const key of removed) {\n const element = this.lastElementsMap[key];\n // 更新动画配置,用户有可能在更新之前有对动画进行配置操作\n element.animate = this.animateOption;\n element.destroy();\n }\n }\n\n /**\n * 获取渲染的 label 类型。\n */\n protected getLabelType(): string {\n const { labelOption, coordinate, type } = this;\n const { type: coordinateType, isTransposed } = coordinate;\n let labelType = get(labelOption, ['cfg', 'type']);\n if (!labelType) {\n // 用户未定义,则进行默认的逻辑\n if (coordinateType === 'polar') {\n // 极坐标下使用通用的极坐标文本,转置则使用饼图\n labelType = isTransposed ? 'pie' : 'polar';\n } else if (coordinateType === 'theta') {\n // theta 坐标系下使用饼图文本\n labelType = 'pie';\n } else if (type === 'interval' || type === 'polygon') {\n labelType = 'interval';\n } else {\n labelType = 'base';\n }\n }\n\n return labelType;\n }\n\n /**\n * 获取 Y 轴上的最小值。\n */\n protected getYMinValue(): number {\n const yScale = this.getYScale();\n const { min, max } = yScale;\n let value: number;\n\n if (min >= 0) {\n value = min;\n } else if (max <= 0) {\n // 当值全位于负区间时,需要保证 ymin 在区域内,不可为 0\n value = max;\n } else {\n value = 0;\n }\n return value;\n }\n\n // 创建图形属性相关的配置项\n protected createAttrOption(attrName: string, field: AttributeOption | string | number, cfg?) {\n if (isNil(field) || isObject(field)) {\n if (isObject(field) && isEqual(Object.keys(field), ['values'])) {\n // shape({ values: [ 'funnel' ] })\n set(this.attributeOption, attrName, {\n fields: field.values,\n });\n } else {\n set(this.attributeOption, attrName, field);\n }\n } else {\n const attrCfg: AttributeOption = {};\n if (isNumber(field)) {\n // size(3)\n attrCfg.values = [field];\n } else {\n attrCfg.fields = parseFields(field);\n }\n\n if (cfg) {\n if (isFunction(cfg)) {\n attrCfg.callback = cfg;\n } else {\n attrCfg.values = cfg;\n }\n }\n\n set(this.attributeOption, attrName, attrCfg);\n }\n }\n\n protected initAttributes() {\n const { attributes, attributeOption, theme, shapeType } = this;\n this.groupScales = [];\n const tmpMap = {};\n\n // 遍历每一个 attrOption,各自创建 Attribute 实例\n for (const attrType in attributeOption) {\n if (attributeOption.hasOwnProperty(attrType)) {\n const option: AttributeOption = attributeOption[attrType];\n if (!option) {\n return;\n }\n const attrCfg: AttributeInstanceCfg = {\n ...option,\n };\n const { callback, values, fields = [] } = attrCfg;\n\n // 获取每一个字段对应的 scale\n const scales = fields.map((field) => {\n const scale = this.scales[field];\n if (!tmpMap[field] && GROUP_ATTRS.includes(attrType)) {\n const inferedScaleType = inferScaleType(scale, get(this.scaleDefs, field), attrType, this.type);\n if (inferedScaleType === 'cat') {\n this.groupScales.push(scale);\n tmpMap[field] = true;\n }\n }\n return scale;\n });\n\n attrCfg.scales = scales;\n\n if (attrType !== 'position' && scales.length === 1 && scales[0].type === 'identity') {\n // 用户在图形通道上声明了常量字段 color('red'), size(5)\n attrCfg.values = scales[0].values;\n } else if (!callback && !values) {\n // 用户没有指定任何规则,则使用默认的映射规则\n if (attrType === 'size') {\n attrCfg.values = theme.sizes;\n } else if (attrType === 'shape') {\n attrCfg.values = theme.shapes[shapeType] || [];\n } else if (attrType === 'color') {\n if (scales.length) {\n // 根据数值个数使用对应的色板\n attrCfg.values = scales[0].values.length <= 10 ? theme.colors10 : theme.colors20;\n } else {\n attrCfg.values = theme.colors10;\n }\n }\n }\n const AttributeCtor = getAttributeClass(attrType);\n attributes[attrType] = new AttributeCtor(attrCfg);\n }\n }\n }\n\n // 处理数据:分组 -> 数字化 -> adjust 调整\n private processData(data: Data) {\n this.hasSorted = false;\n const { scales } = this.getAttribute('position');\n const categoryScales = scales.filter((scale: Scale) => scale.isCategory);\n\n const groupedArray = this.groupData(data); // 数据分组\n const beforeAdjust = [];\n for (let i = 0, len = groupedArray.length; i < len; i++) {\n const subData = groupedArray[i];\n const arr = [];\n for (let j = 0, subLen = subData.length; j < subLen; j++) {\n const originData = subData[j];\n const item = {};\n // tslint:disable-next-line: forin\n for (const k in originData) {\n item[k] = originData[k];\n }\n item[FIELD_ORIGIN] = originData;\n\n // 将分类数据翻译成数据, 仅对位置相关的度量进行数字化处理\n for (const scale of categoryScales) {\n const field = scale.field;\n item[field] = scale.translate(item[field]);\n }\n arr.push(item);\n }\n beforeAdjust.push(arr);\n }\n\n const dataArray = this.adjustData(beforeAdjust); // 进行 adjust 数据调整\n this.beforeMappingData = dataArray;\n\n return dataArray;\n }\n\n // 调整数据\n private adjustData(dataArray: Data[]): Data[] {\n const adjustOption = this.adjustOption;\n const { intervalPadding, dodgePadding, theme } = this;\n // 兼容theme配置\n const maxColumnWidth = this.maxColumnWidth || theme.maxColumnWidth;\n const minColumnWidth = this.minColumnWidth || theme.minColumnWidth;\n const columnWidthRatio = this.columnWidthRatio || theme.columnWidthRatio;\n let result = dataArray;\n\n if (adjustOption) {\n const xScale = this.getXScale();\n const yScale = this.getYScale();\n const xField = xScale.field;\n const yField = yScale ? yScale.field : null;\n const xDimensionLength = getXDimensionLength(this.coordinate);\n const groupNum = xScale.values.length;\n // 传入size计算相关参数,默认宽度、最大最小宽度约束\n const sizeAttr = this.getAttribute('size');\n let defaultSize;\n if (sizeAttr) {\n defaultSize = sizeAttr.values[0];\n }\n for (let i = 0, len = adjustOption.length; i < len; i++) {\n const adjust = adjustOption[i];\n const adjustCfg: AdjustInstanceCfg = {\n xField,\n yField,\n intervalPadding,\n dodgePadding,\n xDimensionLength,\n groupNum,\n defaultSize,\n maxColumnWidth,\n minColumnWidth,\n columnWidthRatio,\n ...adjust,\n };\n const type = adjust.type;\n if (type === 'dodge') {\n const adjustNames = [];\n if (xScale.isCategory || xScale.type === 'identity') {\n adjustNames.push('x');\n } else if (!yScale) {\n adjustNames.push('y');\n } else {\n throw new Error('dodge is not support linear attribute, please use category attribute!');\n }\n adjustCfg.adjustNames = adjustNames;\n // 每个分组内每条柱子的宽度占比,用户不可指定,用户需要通过 columnWidthRatio 指定\n // 兼容theme配置\n adjustCfg.dodgeRatio = columnWidthRatio;\n } else if (type === 'stack') {\n const coordinate = this.coordinate;\n if (!yScale) {\n // 一维的情况下获取高度和默认size\n adjustCfg.height = coordinate.getHeight();\n const size = this.getDefaultValue('size') || 3;\n adjustCfg.size = size;\n }\n // 不进行 transpose 时,用户又没有设置这个参数时,默认从上向下\n if (!coordinate.isTransposed && isNil(adjustCfg.reverseOrder)) {\n adjustCfg.reverseOrder = true;\n }\n }\n const adjustCtor = getAdjustClass(type);\n adjustCfg.dimValuesMap = {};\n //生成dimValuesMap\n if (xScale && xScale.values) {\n adjustCfg.dimValuesMap[xScale.field] = xScale.values.map((v) => xScale.translate(v));\n }\n const adjustInstance = new adjustCtor(adjustCfg);\n\n result = adjustInstance.process(result);\n\n this.adjusts[type] = adjustInstance;\n }\n }\n\n return result;\n }\n\n // 对数据进行分组\n private groupData(data: Data): Data[] {\n const groupScales = this.getGroupScales();\n const scaleDefs = this.scaleDefs;\n const appendConditions = {};\n const groupFields = [];\n for (let index = 0; index < groupScales.length; index++) {\n const scale = groupScales[index];\n const field = scale.field;\n groupFields.push(field);\n if (get(scaleDefs, [field, 'values'])) {\n // 用户通过 view.scale() 接口指定了 values 属性\n appendConditions[field] = scaleDefs[field].values;\n }\n }\n\n return group(data, groupFields, appendConditions);\n }\n\n // 更新发生层叠后的数据对应的度量范围\n private updateStackRange(scale: Scale, dataArray: Data[]) {\n const mergeArray = flatten(dataArray);\n const field = scale.field;\n let min = scale.min;\n let max = scale.max;\n for (let index = 0; index < mergeArray.length; index++) {\n const obj = mergeArray[index];\n const tmpMin = Math.min.apply(null, obj[field]);\n const tmpMax = Math.max.apply(null, obj[field]);\n if (tmpMin < min) {\n min = tmpMin;\n }\n if (tmpMax > max) {\n max = tmpMax;\n }\n }\n const scaleDefs = this.scaleDefs;\n const cfg: LooseObject = {};\n if (min < scale.min && !get(scaleDefs, [field, 'min'])) {\n // 用户如果在列定义中定义了 min,则以用户定义的为准\n cfg.min = min;\n }\n if (max > scale.max && !get(scaleDefs, [field, 'max'])) {\n // 用户如果在列定义中定义了 max\n cfg.max = max;\n }\n\n scale.change(cfg);\n }\n\n // 将数据映射至图形空间前的操作:排序以及关键点的生成\n private beforeMapping(beforeMappingData: Data[]) {\n // 当初加 clone 是因为 points 的引用关系,导致更新失败,可是现在貌似复现不出来了,所以暂时不进行 clone\n // const source = clone(beforeMappingData);\n const source = beforeMappingData;\n if (this.sortable) {\n this.sort(source);\n }\n if (this.generatePoints) {\n // 需要生成关键点\n for (let index = 0, length = source.length; index < length; index++) {\n const currentData = source[index];\n this.generateShapePoints(currentData);\n const nextData = source[index + 1];\n if (nextData) {\n this.generateShapePoints(nextData);\n currentData[0].nextPoints = nextData[0].points;\n }\n }\n }\n\n return source;\n }\n\n // 生成 shape 的关键点\n private generateShapePoints(data: Data) {\n const shapeFactory = this.getShapeFactory();\n const shapeAttr = this.getAttribute('shape');\n for (let index = 0; index < data.length; index++) {\n const obj = data[index];\n const cfg = this.createShapePointsCfg(obj);\n const shape = shapeAttr ? this.getAttributeValues(shapeAttr, obj) : null;\n const points = shapeFactory.getShapePoints(shape, cfg);\n obj.points = points;\n }\n }\n\n // 将数据归一化\n private normalizeValues(values, scale) {\n let rst = [];\n if (isArray(values)) {\n for (let index = 0; index < values.length; index++) {\n const value = values[index];\n rst.push(scale.scale(value));\n }\n } else {\n rst = scale.scale(values);\n }\n return rst;\n }\n\n // 将数据映射至图形空间\n private mapping(data: Data): MappingDatum[] {\n const attributes = this.attributes;\n const mappingData = [];\n for (let index = 0; index < data.length; index++) {\n const record = data[index];\n const newRecord: MappingDatum = {\n _origin: record[FIELD_ORIGIN],\n points: record.points,\n nextPoints: record.nextPoints,\n };\n for (const k in attributes) {\n if (attributes.hasOwnProperty(k)) {\n const attr = attributes[k];\n const names = attr.names;\n const values = this.getAttributeValues(attr, record);\n if (names.length > 1) {\n // position 之类的生成多个字段的属性\n for (let j = 0; j < values.length; j += 1) {\n const val = values[j];\n const name = names[j];\n newRecord[name] = isArray(val) && val.length === 1 ? val[0] : val; // 只有一个值时返回第一个属性值\n }\n } else {\n // values.length === 1 的判断是以下情况,获取用户设置的图形属性值\n // shape('a', ['dot', 'dash']), color('a', ['red', 'yellow'])\n newRecord[names[0]] = values.length === 1 ? values[0] : values;\n }\n }\n }\n\n this.convertPoint(newRecord); // 将 x、y 转换成画布坐标\n mappingData.push(newRecord);\n }\n\n return mappingData;\n }\n\n // 将归一化的坐标值转换成画布坐标\n private convertPoint(mappingRecord: MappingDatum) {\n const { x, y } = mappingRecord;\n\n let rstX;\n let rstY;\n let obj;\n const coordinate = this.coordinate;\n if (isArray(x) && isArray(y)) {\n rstX = [];\n rstY = [];\n for (let i = 0, j = 0, xLen = x.length, yLen = y.length; i < xLen && j < yLen; i += 1, j += 1) {\n obj = coordinate.convert({\n x: x[i],\n y: y[j],\n });\n rstX.push(obj.x);\n rstY.push(obj.y);\n }\n } else if (isArray(y)) {\n rstY = [];\n for (let index = 0; index < y.length; index++) {\n const yVal = y[index];\n obj = coordinate.convert({\n x: x as number,\n y: yVal,\n });\n if (rstX && rstX !== obj.x) {\n if (!isArray(rstX)) {\n rstX = [rstX];\n }\n rstX.push(obj.x);\n } else {\n rstX = obj.x;\n }\n rstY.push(obj.y);\n }\n } else if (isArray(x)) {\n rstX = [];\n for (let index = 0; index < x.length; index++) {\n const xVal = x[index];\n obj = coordinate.convert({\n x: xVal,\n y,\n });\n if (rstY && rstY !== obj.y) {\n if (!isArray(rstY)) {\n rstY = [rstY];\n }\n rstY.push(obj.y);\n } else {\n rstY = obj.y;\n }\n rstX.push(obj.x);\n }\n } else {\n const point = coordinate.convert({\n x,\n y,\n });\n rstX = point.x;\n rstY = point.y;\n }\n mappingRecord.x = rstX;\n mappingRecord.y = rstY;\n }\n\n // 获取 style 配置\n private getStyleCfg(styleOption: StyleOption, originData: Datum) {\n const { fields = [], callback, cfg } = styleOption;\n if (cfg) {\n // 用户直接配置样式属性\n return cfg;\n }\n\n const params = fields.map((field) => {\n return originData[field];\n });\n\n return callback(...params);\n }\n\n private setCfg(cfg: InitCfg) {\n const { coordinate, data, theme, scaleDefs } = cfg;\n if (coordinate) {\n this.coordinate = coordinate;\n }\n if (data) {\n this.data = data;\n }\n if (scaleDefs) {\n this.scaleDefs = scaleDefs;\n this.idFields = [];\n each(scaleDefs, (scaleDef, field) => {\n if (scaleDef && scaleDef.key) {\n this.idFields.push(field);\n }\n });\n }\n if (theme) {\n this.theme = this.userTheme ? deepMix({}, theme, this.userTheme) : theme; // 支持 geometry 层级的主题设置\n }\n }\n\n private async renderLabels(mappingArray: MappingDatum[], isUpdate: boolean = false) {\n let geometryLabel = this.geometryLabel;\n\n this.emit(GEOMETRY_LIFE_CIRCLE.BEFORE_RENDER_LABEL);\n\n if (!geometryLabel) {\n // 初次创建\n const labelType = this.getLabelType();\n const GeometryLabelsCtor = getGeometryLabel(labelType);\n geometryLabel = new GeometryLabelsCtor(this);\n this.geometryLabel = geometryLabel;\n }\n await geometryLabel.render(mappingArray, isUpdate);\n\n // 将 label 同 element 进行关联\n const labelsMap = geometryLabel.labelsRenderer.shapesMap;\n // Store labels for every element.\n const elementLabels = new Map>();\n each(labelsMap, (labelGroup: IGroup, labelGroupId: string) => {\n const labelChildren = labelGroup.getChildren() || [];\n for (let j = 0; j < labelChildren.length; j++) {\n const labelShape = labelChildren[j];\n const element = this.elementsMap[labelShape.get('elementId') || labelGroupId.split(' ')[0]];\n if (element) {\n labelShape.cfg.name = ['element', 'label'];\n labelShape.cfg.element = element;\n const labels = elementLabels.get(element) || new Set();\n labels.add(labelGroup);\n elementLabels.set(element, labels);\n }\n }\n });\n for (const [element, labels] of elementLabels.entries()) {\n element.labelShape = [...labels];\n }\n\n this.emit(GEOMETRY_LIFE_CIRCLE.AFTER_RENDER_LABEL);\n }\n /**\n * 是否需要进行群组入场动画\n * 规则:\n * 1. 如果发生更新,则不进行\n * 2. 如果用户关闭 geometry 动画,则不进行\n * 3. 如果用户关闭了 appear 动画,则不进行\n * 4. 如果用户配置了 appear.animation,则不进行\n */\n private canDoGroupAnimation(isUpdate: boolean) {\n return (\n !isUpdate &&\n this.animateOption &&\n (get(this.animateOption, 'appear') === undefined ||\n (get(this.animateOption, 'appear') && get(this.animateOption, ['appear', 'animation']) === undefined))\n );\n }\n}\n","import { groupToMap } from '@antv/util';\nimport { Data } from '../../interface';\n\n/** @ignore */\nexport function group(data: Data, fields: string[], appendConditions: Record = {}) {\n if (!fields) {\n return [data];\n }\n const groups = groupToMap(data, fields);\n const array = [];\n if (fields.length === 1 && appendConditions[fields[0]]) {\n const values = appendConditions[fields[0]];\n for (const value of values) {\n const arr = groups[`_${value}`];\n if (arr) {\n // 可能存在用户设置 values ,但是数据中没有对应的字段,则这时候 arr 就为 null\n array.push(arr);\n }\n }\n } else {\n for (const k in groups) {\n if (groups.hasOwnProperty(k)) {\n const eachGroup = groups[k];\n array.push(eachGroup);\n }\n }\n }\n\n return array;\n}\n","import { ext } from '@antv/matrix-util';\nimport { IElement, IGroup, IShape } from '../dependents';\n\nconst transform: (m: number[], actions: any[][]) => number[] = ext.transform;\n\nexport { transform };\n\n/**\n * 对元素进行平移操作。\n * @param element 进行变换的元素\n * @param x x 方向位移\n * @param y y 方向位移\n */\nexport function translate(element: IGroup | IShape, x: number, y: number) {\n const matrix = transform(element.getMatrix(), [['t', x, y]]);\n element.setMatrix(matrix);\n}\n\n/**\n * 获取元素旋转矩阵 (以元素的左上角为旋转点)\n * @param element 进行变换的元素\n * @param rotateRadian 旋转弧度\n */\nexport function getRotateMatrix(element: IElement, rotateRadian: number) {\n const { x, y } = element.attr();\n const matrix = transform(element.getMatrix(), [\n ['t', -x, -y],\n ['r', rotateRadian],\n ['t', x, y],\n ]);\n return matrix;\n}\n\n/**\n * 对元素进行旋转操作。\n * @param element 进行变换的元素\n * @param rotateRadian 旋转弧度\n */\nexport function rotate(element: IGroup | IShape, rotateRadian: number) {\n const matrix = getRotateMatrix(element, rotateRadian);\n element.setMatrix(matrix);\n}\n\n/**\n * 获取元矩阵。\n * @returns identity matrix\n */\nexport function getIdentityMatrix(): number[] {\n return [1, 0, 0, 0, 1, 0, 0, 0, 1];\n}\n\n/**\n * 围绕图形中心点进行缩放\n * @param element 进行缩放的图形元素\n * @param ratio 缩放比例\n */\nexport function zoom(element: IGroup | IShape, ratio: number) {\n const bbox = element.getBBox();\n const x = (bbox.minX + bbox.maxX) / 2;\n const y = (bbox.minY + bbox.maxY) / 2;\n element.applyToMatrix([x, y, 1]);\n\n const matrix = transform(element.getMatrix(), [\n ['t', -x, -y],\n ['s', ratio, ratio],\n ['t', x, y],\n ]);\n element.setMatrix(matrix);\n}\n","/**\n * @file utils of label\n */\n\nimport { isNil, isNumber, some } from '@antv/util';\nimport { IElement, IGroup, BBox } from '../../../dependents';\nimport { rotate } from '../../../util/transform';\n\n/**\n * 查找 Label Group 中的文本 shape 对象\n * @param label\n */\nexport function findLabelTextShape(label: IGroup): IElement {\n return label.find((el) => el.get('type') === 'text');\n}\n\n/**\n * 获取标签背景信息: box (无旋转) + rotation (旋转角度)\n */\nexport function getLabelBackgroundInfo(\n labelGroup: IGroup,\n labelItem: { rotate?: number;[key: string]: any },\n padding: number | number[] = [0, 0, 0, 0]\n): { x: number; y: number; width: number; height: number; rotation: number } {\n const content = labelGroup && labelGroup.getChildren()[0];\n if (content) {\n const labelShape = content.clone();\n\n // revert rotate\n if (labelItem?.rotate) {\n rotate(labelShape as IGroup, -labelItem.rotate);\n }\n\n // use `getCanvasBBox`, because if Shape is been translated, `getBBox` is not the actual box position\n const { x, y, width, height } = labelShape.getCanvasBBox();\n\n labelShape.destroy();\n\n let boxPadding = padding;\n if (isNil(boxPadding)) {\n boxPadding = [2, 2, 2, 2];\n } else if (isNumber(boxPadding)) {\n boxPadding = new Array(4).fill(boxPadding);\n }\n\n return {\n x: x - boxPadding[3],\n y: y - boxPadding[0],\n width: width + boxPadding[1] + boxPadding[3],\n height: height + boxPadding[0] + boxPadding[2],\n rotation: labelItem?.rotate || 0,\n };\n }\n\n return { x: 0, y: 0, width: 0, height: 0, rotation: 0 };\n}\n\n/**\n * 计算两个矩形之间的堆叠区域面积\n */\nexport function getOverlapArea(a: BBox, b: BBox, margin = 0) {\n const xOverlap = Math.max(\n 0,\n Math.min(a.x + a.width + margin, b.x + b.width + margin) - Math.max(a.x - margin, b.x - margin)\n );\n const yOverlap = Math.max(\n 0,\n Math.min(a.y + a.height + margin, b.y + b.height + margin) - Math.max(a.y - margin, b.y - margin)\n );\n\n return xOverlap * yOverlap;\n}\n\n/** 检测是否和已布局的堆叠 */\nexport function checkShapeOverlap(cur: IElement, dones: IElement[]) {\n const box = cur.getBBox();\n return some(dones, (done) => {\n const target = done.getBBox();\n return getOverlapArea(box, target, 2) > 0;\n });\n}\n","import { Coordinate } from '@antv/coord';\nimport { IGroup, IShape } from '@antv/g-base';\nimport { each, get, isArray } from '@antv/util';\nimport { doAnimate } from '../animate';\nimport { getReplaceAttrs } from '../util/graphics';\n\n/** label 的必要配置 */\ntype Cfg = {\n data: any;\n origin: any;\n animateCfg: any;\n coordinate: Coordinate;\n};\n\n/**\n * @desc 更新 label (目前没有根据 id 索引,还是会存在一点小问题的,只能根据 idx 索引)\n * @done shape 属性更新\n * @done shape delete\n * @done shape append\n *\n * @param fromShape old labelShape\n * @param toShape new labelShape\n * @param cfg\n */\nexport function updateLabel(fromShape: IGroup, toShape: IGroup, cfg: Cfg): void {\n const { data, origin, animateCfg, coordinate } = cfg;\n const updateAnimateCfg = get(animateCfg, 'update');\n\n fromShape.set('data', data);\n fromShape.set('origin', origin);\n fromShape.set('animateCfg', animateCfg);\n fromShape.set('coordinate', coordinate);\n fromShape.set('visible', toShape.get('visible'));\n\n (fromShape.getChildren() || []).forEach((fromChild, idx) => {\n const toChild = toShape.getChildByIndex(idx) as IShape;\n if (!toChild) {\n fromShape.removeChild(fromChild);\n fromChild.remove(true);\n } else {\n fromChild.set('data', data);\n fromChild.set('origin', origin);\n fromChild.set('animateCfg', animateCfg);\n fromChild.set('coordinate', coordinate);\n\n const newAttrs = getReplaceAttrs(fromChild as IShape, toChild);\n if (updateAnimateCfg) {\n doAnimate(fromChild as IShape, updateAnimateCfg, {\n toAttrs: newAttrs,\n coordinate,\n });\n } else {\n fromChild.attr(newAttrs);\n }\n if (toChild.isGroup()) {\n updateLabel(fromChild as any, toChild as any, cfg);\n }\n }\n });\n\n // append\n each(toShape.getChildren(), (child, idx) => {\n if (isArray(fromShape.getChildren()) && idx >= fromShape.getCount()) {\n if (!child.destroyed) {\n fromShape.add(child);\n }\n }\n });\n}\n","import { deepMix, each, get, isArray, isNull } from '@antv/util';\nimport { BBox, Coordinate, IGroup, IShape } from '../dependents';\nimport { LabelItem } from '../geometry/label/interface';\nimport { AnimateOption, GeometryLabelLayoutCfg } from '../interface';\nimport { doAnimate } from '../animate';\nimport { getGeometryLabelLayout } from '../geometry/label';\nimport { getLabelBackgroundInfo } from '../geometry/label/util';\nimport { polarToCartesian } from '../util/graphics';\nimport { rotate, translate } from '../util/transform';\nimport { FIELD_ORIGIN } from '../constant';\nimport { updateLabel } from './update-label';\n\n/**\n * Labels 实例创建时,传入构造函数的参数定义\n */\nexport interface LabelsGroupCfg {\n /** label 容器 */\n container: IGroup;\n /** label 布局配置 */\n layout?: GeometryLabelLayoutCfg | GeometryLabelLayoutCfg[];\n}\n\n/**\n * Geometry labels 渲染组件\n */\nexport default class Labels {\n /** 用于指定 labels 布局的类型 */\n public layout: GeometryLabelLayoutCfg | GeometryLabelLayoutCfg[];\n /** 图形容器 */\n public container: IGroup;\n /** 动画配置 */\n public animate: AnimateOption | false;\n /** label 绘制的区域 */\n public region: BBox;\n\n /** 存储当前 shape 的映射表,键值为 shape id */\n public shapesMap: Record = {};\n\n constructor(cfg: LabelsGroupCfg) {\n const { layout, container } = cfg;\n\n this.layout = layout;\n this.container = container;\n }\n /**\n * 渲染文本\n */\n public async render(items: LabelItem[], shapes: Record, isUpdate: boolean = false) {\n const shapesMap = {};\n const offscreenGroup = this.createOffscreenGroup(); // 创建虚拟分组\n if (items.length) {\n // 如果 items 空的话就不进行绘制调整操作\n // step 1: 在虚拟 group 中创建 shapes\n for (const item of items) {\n if (item) {\n shapesMap[item.id] = this.renderLabel(item, offscreenGroup);\n }\n }\n // [todo] Move layout into Worker.\n // step 2: 根据布局,调整 labels\n await this.doLayout(items, shapes, shapesMap);\n\n // step 3.1: 绘制 labelLine\n this.renderLabelLine(items, shapesMap);\n // step 3.2: 绘制 labelBackground\n this.renderLabelBackground(items, shapesMap);\n // step 4: 根据用户设置的偏移量调整 label\n this.adjustLabel(items, shapesMap);\n }\n\n // 进行添加、更新、销毁操作\n const lastShapesMap = this.shapesMap;\n each(shapesMap, (shape, id) => {\n if (shape.destroyed) {\n // label 在布局调整环节被删除了(doLayout)\n delete shapesMap[id];\n } else {\n if (lastShapesMap[id]) {\n // 图形发生更新\n const data = shape.get('data');\n const origin = shape.get('origin');\n const coordinate = shape.get('coordinate');\n const currentAnimateCfg = shape.get('animateCfg');\n\n const currentShape = lastShapesMap[id]; // 已经在渲染树上的 shape\n updateLabel(currentShape, shapesMap[id], {\n data,\n origin,\n animateCfg: currentAnimateCfg,\n coordinate,\n });\n\n shapesMap[id] = currentShape; // 保存引用\n } else {\n // 新生成的 shape\n // If container has been destroyed, no need to render labels.\n if (this.container.destroyed) return;\n this.container.add(shape);\n const animateCfg = get(shape.get('animateCfg'), isUpdate ? 'enter' : 'appear');\n if (animateCfg) {\n doAnimate(shape, animateCfg, {\n toAttrs: {\n ...shape.attr(),\n },\n coordinate: shape.get('coordinate'),\n });\n }\n }\n delete lastShapesMap[id];\n }\n });\n\n // 移除\n each(lastShapesMap, (deleteShape) => {\n const animateCfg = get(deleteShape.get('animateCfg'), 'leave');\n if (animateCfg) {\n doAnimate(deleteShape, animateCfg, {\n toAttrs: null,\n coordinate: deleteShape.get('coordinate'),\n });\n } else {\n deleteShape.remove(true); // 移除\n }\n });\n\n this.shapesMap = shapesMap;\n offscreenGroup.destroy();\n }\n\n /** 清除当前 labels */\n public clear() {\n this.container.clear();\n this.shapesMap = {};\n }\n\n /** 销毁 */\n public destroy() {\n this.container.destroy();\n this.shapesMap = null;\n }\n\n private renderLabel(cfg: LabelItem, container: IGroup): IGroup {\n const { id, elementId, data, mappingData, coordinate, animate, content, capture } = cfg;\n const shapeAppendCfg = {\n id,\n elementId,\n capture,\n data,\n origin: {\n ...mappingData,\n data: mappingData[FIELD_ORIGIN],\n },\n coordinate,\n };\n const labelGroup = container.addGroup({\n name: 'label',\n // 如果 this.animate === false 或者 cfg.animate === false/null 则不进行动画,否则进行动画配置的合并\n animateCfg:\n this.animate === false || animate === null || animate === false ? false : deepMix({}, this.animate, animate),\n ...shapeAppendCfg,\n });\n let labelShape;\n if ((content.isGroup && content.isGroup()) || (content.isShape && content.isShape())) {\n // 如果 content 是 Group 或者 Shape,根据 textAlign 调整位置后,直接将其加入 labelGroup\n const { width, height } = content.getCanvasBBox();\n const textAlign = get(cfg, 'textAlign', 'left');\n\n let x = cfg.x;\n const y = cfg.y - height / 2;\n\n if (textAlign === 'center') {\n x = x - width / 2;\n } else if (textAlign === 'right' || textAlign === 'end') {\n x = x - width;\n }\n\n translate(content, x, y); // 将 label 平移至 x, y 指定的位置\n labelShape = content;\n labelGroup.add(content);\n } else {\n const fill = get(cfg, ['style', 'fill']);\n labelShape = labelGroup.addShape('text', {\n attrs: {\n x: cfg.x,\n y: cfg.y,\n textAlign: cfg.textAlign,\n textBaseline: get(cfg, 'textBaseline', 'middle'),\n text: cfg.content,\n ...cfg.style,\n fill: isNull(fill) ? cfg.color : fill,\n },\n ...shapeAppendCfg,\n });\n }\n\n if (cfg.rotate) {\n rotate(labelShape, cfg.rotate);\n }\n return labelGroup;\n }\n\n // 根据type对label布局\n private async doLayout(items: LabelItem[], shapes: Record, shapesMap: Record) {\n if (this.layout) {\n const layouts = isArray(this.layout) ? this.layout : [this.layout];\n await Promise.all(layouts.map((layout: GeometryLabelLayoutCfg) => {\n const layoutFn = getGeometryLabelLayout(get(layout, 'type', ''));\n if (!layoutFn) return;\n\n const labelShapes = [];\n const geometryShapes = [];\n each(shapesMap, (labelShape, id) => {\n labelShapes.push(labelShape);\n geometryShapes.push(shapes[labelShape.get('elementId')]);\n });\n // [todo] Refactor more layout into Worker.\n return layoutFn(items, labelShapes, geometryShapes, this.region, layout.cfg);\n }));\n }\n }\n\n private renderLabelLine(labelItems: LabelItem[], shapesMap) {\n each(labelItems, (labelItem) => {\n const coordinate: Coordinate = get(labelItem, 'coordinate');\n if (!labelItem || !coordinate) {\n return;\n }\n const center = coordinate.getCenter();\n const radius = coordinate.getRadius();\n if (!labelItem.labelLine) {\n // labelLine: null | false,关闭 label 对应的 labelLine\n return;\n }\n const labelLineCfg = get(labelItem, 'labelLine', {});\n const id = labelItem.id;\n let path = labelLineCfg.path;\n if (!path) {\n const start = polarToCartesian(center.x, center.y, radius, labelItem.angle);\n path = [\n ['M', start.x, start.y],\n ['L', labelItem.x, labelItem.y],\n ];\n }\n const labelGroup = shapesMap[id];\n if (!labelGroup.destroyed) {\n labelGroup.addShape('path', {\n capture: false, // labelLine 默认不参与事件捕获\n attrs: {\n path,\n stroke: labelItem.color ? labelItem.color : get(labelItem, ['style', 'fill'], '#000'),\n fill: null,\n ...labelLineCfg.style,\n },\n id,\n origin: labelItem.mappingData,\n data: labelItem.data,\n coordinate: labelItem.coordinate,\n });\n }\n });\n }\n\n /**\n * 绘制标签背景\n * @param labelItems\n */\n private renderLabelBackground(labelItems: LabelItem[], shapesMap) {\n each(labelItems, (labelItem) => {\n const coordinate: Coordinate = get(labelItem, 'coordinate');\n const background: LabelItem['background'] = get(labelItem, 'background');\n if (!background || !coordinate) {\n return;\n }\n\n const id = labelItem.id;\n const labelGroup = shapesMap[id];\n if (!labelGroup.destroyed) {\n const labelContentShape = labelGroup.getChildren()[0];\n if (labelContentShape) {\n const { rotation, ...box } = getLabelBackgroundInfo(labelGroup, labelItem, background.padding);\n const backgroundShape = labelGroup.addShape('rect', {\n attrs: {\n ...box,\n ...(background.style || {}),\n },\n id,\n origin: labelItem.mappingData,\n data: labelItem.data,\n coordinate: labelItem.coordinate,\n });\n backgroundShape.setZIndex(-1);\n\n if (rotation) {\n const matrix = labelContentShape.getMatrix();\n backgroundShape.setMatrix(matrix);\n }\n }\n }\n });\n }\n\n private createOffscreenGroup() {\n const container = this.container;\n const GroupClass = container.getGroupBase(); // 获取分组的构造函数\n const newGroup = new GroupClass({});\n return newGroup;\n }\n\n private adjustLabel(items: LabelItem[], shapesMap) {\n each(items, (item) => {\n if (item) {\n const id = item.id;\n const labelGroup = shapesMap[id];\n if (!labelGroup.destroyed) {\n // fix: 如果说开发者的 label content 是一个 group,此处的偏移无法对 整个 content group 生效;场景类似 饼图 spider label 是一个含 2 个 textShape 的 gorup\n const labelShapes = labelGroup.findAll((ele) => ele.get('type') !== 'path');\n each(labelShapes, (labelShape) => {\n if (labelShape) {\n if (item.offsetX) {\n labelShape.attr('x', labelShape.attr('x') + item.offsetX);\n }\n if (item.offsetY) {\n labelShape.attr('y', labelShape.attr('y') + item.offsetY);\n }\n }\n });\n }\n }\n });\n }\n}\n","import { deepMix, each, get, isArray, isFunction, isNil, isNumber, isString, isUndefined } from '@antv/util';\n\nimport { FIELD_ORIGIN } from '../../constant';\nimport { Scale } from '../../dependents';\nimport { Datum, LabelOption, MappingDatum, Point } from '../../interface';\nimport { LabelCfg, LabelItem, LabelPointCfg, TextAlign } from './interface';\n\nimport { getDefaultAnimateCfg } from '../../animate';\nimport { getPolygonCentroid } from '../../util/graphics';\n\nimport Labels from '../../component/labels';\nimport Geometry from '../base';\nimport Element from '../element';\n\nexport type GeometryLabelConstructor = new (cfg: any) => GeometryLabel;\n\nfunction avg(arr: number[]) {\n let sum = 0;\n each(arr, (value: number) => {\n sum += value;\n });\n return sum / arr.length;\n}\n\n/**\n * Geometry Label 基类,用于生成 Geometry 下所有 label 的配置项信息\n */\nexport default class GeometryLabel {\n /** geometry 实例 */\n public readonly geometry: Geometry;\n public labelsRenderer: Labels;\n /** 默认的布局 */\n public defaultLayout: string;\n\n constructor(geometry: Geometry) {\n this.geometry = geometry;\n }\n\n public getLabelItems(mapppingArray: MappingDatum[]): LabelItem[] {\n const items = [];\n const labelCfgs = this.getLabelCfgs(mapppingArray);\n // 获取 label 相关的 x,y 的值,获取具体的 x, y,防止存在数组\n each(mapppingArray, (mappingData: MappingDatum, index: number) => {\n const labelCfg = labelCfgs[index];\n if (!labelCfg || isNil(mappingData.x) || isNil(mappingData.y)) {\n items.push(null);\n return;\n }\n\n const labelContent = !isArray(labelCfg.content) ? [labelCfg.content] : labelCfg.content;\n labelCfg.content = labelContent;\n const total = labelContent.length;\n each(labelContent, (content, subIndex) => {\n if (isNil(content) || content === '') {\n items.push(null);\n return;\n }\n\n const item = {\n ...labelCfg,\n ...this.getLabelPoint(labelCfg, mappingData, subIndex),\n };\n if (!item.textAlign) {\n item.textAlign = this.getLabelAlign(item, subIndex, total);\n }\n\n if (item.offset <= 0) {\n item.labelLine = null;\n }\n\n items.push(item);\n });\n });\n return items;\n }\n\n public async render(mappingArray: MappingDatum[], isUpdate: boolean = false) {\n const labelItems = this.getLabelItems(mappingArray);\n const labelsRenderer = this.getLabelsRenderer();\n const shapes = this.getGeometryShapes();\n // 渲染文本\n await labelsRenderer.render(labelItems, shapes, isUpdate);\n }\n\n public clear() {\n const labelsRenderer = this.labelsRenderer;\n if (labelsRenderer) {\n labelsRenderer.clear();\n }\n }\n\n public destroy() {\n const labelsRenderer = this.labelsRenderer;\n if (labelsRenderer) {\n labelsRenderer.destroy();\n }\n this.labelsRenderer = null;\n }\n\n // geometry 更新之后,对应的 Coordinate 也会更新,为了获取到最新鲜的 Coordinate,故使用方法获取\n public getCoordinate() {\n return this.geometry.coordinate;\n }\n\n /**\n * 获取 label 的默认配置\n */\n protected getDefaultLabelCfg(offset?: number, position?: string) {\n const geometry = this.geometry;\n const { type, theme } = geometry;\n\n if (\n type === 'polygon' ||\n (type === 'interval' && position === 'middle') ||\n (offset < 0 && !['line', 'point', 'path'].includes(type))\n ) {\n // polygon 或者 (interval 且 middle) 或者 offset 小于 0 时,文本展示在图形内部,将其颜色设置为 白色\n return get(theme, 'innerLabels', {});\n }\n\n return get(theme, 'labels', {});\n }\n\n /**\n * 获取当前 label 的最终配置\n * @param labelCfg\n */\n protected getThemedLabelCfg(labelCfg: LabelCfg) {\n const geometry = this.geometry;\n const defaultLabelCfg = this.getDefaultLabelCfg();\n const { type, theme } = geometry;\n let themedLabelCfg;\n\n if (type === 'polygon' || (labelCfg.offset < 0 && !['line', 'point', 'path'].includes(type))) {\n // polygon 或者 offset 小于 0 时,文本展示在图形内部,将其颜色设置为 白色\n themedLabelCfg = deepMix({}, defaultLabelCfg, theme.innerLabels, labelCfg);\n } else {\n themedLabelCfg = deepMix({}, defaultLabelCfg, theme.labels, labelCfg);\n }\n\n return themedLabelCfg;\n }\n\n /**\n * 设置 label 位置\n * @param labelPointCfg\n * @param mappingData\n * @param index\n * @param position\n */\n protected setLabelPosition(\n labelPointCfg: LabelPointCfg,\n mappingData: MappingDatum,\n index: number,\n position: string\n ) {}\n\n /**\n * @desc 获取 label offset\n */\n protected getLabelOffset(offset: number | string): number {\n const coordinate = this.getCoordinate();\n const vector = this.getOffsetVector(offset);\n return coordinate.isTransposed ? vector[0] : vector[1];\n }\n\n /**\n * 获取每个 label 的偏移量 (矢量)\n * @param labelCfg\n * @param index\n * @param total\n * @return {Point} offsetPoint\n */\n protected getLabelOffsetPoint(labelCfg: LabelCfg, index: number, total: number): Point {\n const offset = labelCfg.offset;\n const coordinate = this.getCoordinate();\n const transposed = coordinate.isTransposed;\n const dim = transposed ? 'x' : 'y';\n const factor = transposed ? 1 : -1; // y 方向上越大,像素的坐标越小,所以transposed时将系数变成\n const offsetPoint = {\n x: 0,\n y: 0,\n };\n if (index > 0 || total === 1) {\n // 判断是否小于0\n offsetPoint[dim] = offset * factor;\n } else {\n offsetPoint[dim] = offset * factor * -1;\n }\n return offsetPoint;\n }\n\n /**\n * 获取每个 label 的位置\n * @param labelCfg\n * @param mappingData\n * @param index\n * @returns label point\n */\n protected getLabelPoint(labelCfg: LabelCfg, mappingData: MappingDatum, index: number): LabelPointCfg {\n const coordinate = this.getCoordinate();\n const total = labelCfg.content.length;\n\n function getDimValue(value: number | number[], idx: number, isAvg = false) {\n let v = value;\n if (isArray(v)) {\n if (labelCfg.content.length === 1) {\n if (isAvg) {\n v = avg(v);\n } else {\n // 如果仅一个 label,多个 y, 取最后一个 y\n if (v.length <= 2) {\n v = v[(value as number[]).length - 1];\n } else {\n v = avg(v);\n }\n }\n } else {\n v = v[idx];\n }\n }\n return v;\n }\n\n const label = {\n content: labelCfg.content[index],\n x: 0,\n y: 0,\n start: { x: 0, y: 0 },\n color: '#fff',\n };\n const shape = isArray(mappingData.shape) ? mappingData.shape[0] : mappingData.shape;\n const isFunnel = shape === 'funnel' || shape === 'pyramid';\n\n // 多边形场景,多用于地图\n if (this.geometry.type === 'polygon') {\n const centroid = getPolygonCentroid(mappingData.x, mappingData.y);\n label.x = centroid[0];\n label.y = centroid[1];\n } else if (this.geometry.type === 'interval' && !isFunnel) {\n // 对直方图的label X 方向的位置居中\n label.x = getDimValue(mappingData.x, index, true);\n label.y = getDimValue(mappingData.y, index);\n } else {\n label.x = getDimValue(mappingData.x, index);\n label.y = getDimValue(mappingData.y, index);\n }\n\n // 处理漏斗图文本位置\n if (isFunnel) {\n const nextPoints = get(mappingData, 'nextPoints');\n const points = get(mappingData, 'points');\n if (nextPoints) {\n // 非漏斗图底部\n const point1 = coordinate.convert(points[1] as Point);\n const point2 = coordinate.convert(nextPoints[1] as Point);\n label.x = (point1.x + point2.x) / 2;\n label.y = (point1.y + point2.y) / 2;\n } else if (shape === 'pyramid') {\n const point1 = coordinate.convert(points[1] as Point);\n const point2 = coordinate.convert(points[2] as Point);\n label.x = (point1.x + point2.x) / 2;\n label.y = (point1.y + point2.y) / 2;\n }\n }\n\n if (labelCfg.position) {\n // 如果 label 支持 position 属性\n this.setLabelPosition(label, mappingData, index, labelCfg.position);\n }\n const offsetPoint = this.getLabelOffsetPoint(labelCfg, index, total);\n label.start = { x: label.x, y: label.y };\n label.x += offsetPoint.x;\n label.y += offsetPoint.y;\n label.color = mappingData.color;\n return label;\n }\n\n /**\n * 获取文本的对齐方式\n * @param item\n * @param index\n * @param total\n * @returns\n */\n protected getLabelAlign(item: LabelItem, index: number, total: number): TextAlign {\n let align: TextAlign = 'center';\n const coordinate = this.getCoordinate();\n if (coordinate.isTransposed) {\n const offset = item.offset;\n if (offset < 0) {\n align = 'right';\n } else if (offset === 0) {\n align = 'center';\n } else {\n align = 'left';\n }\n if (total > 1 && index === 0) {\n if (align === 'right') {\n align = 'left';\n } else if (align === 'left') {\n align = 'right';\n }\n }\n }\n return align;\n }\n\n /**\n * 获取每一个 label 的唯一 id\n * @param mappingData label 对应的图形的绘制数据\n */\n protected getLabelId(mappingData: MappingDatum) {\n const geometry = this.geometry;\n const type = geometry.type;\n const xScale = geometry.getXScale();\n const yScale = geometry.getYScale();\n const origin = mappingData[FIELD_ORIGIN]; // 原始数据\n\n let labelId = geometry.getElementId(mappingData);\n if (type === 'line' || type === 'area') {\n // 折线图以及区域图,一条线会对应一组数据,即多个 labels,为了区分这些 labels,需要在 line id 的前提下加上 x 字段值\n labelId += ` ${origin[xScale.field]}`;\n } else if (type === 'path') {\n // path 路径图,无序,有可能存在相同 x 不同 y 的情况,需要通过 x y 来确定唯一 id\n labelId += ` ${origin[xScale.field]}-${origin[yScale.field]}`;\n }\n\n return labelId;\n }\n\n // 获取 labels 组件\n private getLabelsRenderer() {\n const { labelsContainer, labelOption, canvasRegion, animateOption } = this.geometry;\n const coordinate = this.geometry.coordinate;\n\n let labelsRenderer = this.labelsRenderer;\n if (!labelsRenderer) {\n labelsRenderer = new Labels({\n container: labelsContainer,\n layout: get(labelOption, ['cfg', 'layout'], {\n type: this.defaultLayout,\n }),\n });\n this.labelsRenderer = labelsRenderer;\n }\n labelsRenderer.region = canvasRegion;\n // 设置动画配置,如果 geometry 的动画关闭了,那么 label 的动画也会关闭\n labelsRenderer.animate = animateOption ? getDefaultAnimateCfg('label', coordinate) : false;\n\n return labelsRenderer;\n }\n\n private getLabelCfgs(mapppingArray: MappingDatum[]): LabelCfg[] {\n const geometry = this.geometry;\n const { labelOption, scales, coordinate } = geometry;\n const { fields, callback, cfg } = labelOption as LabelOption;\n const labelScales = fields.map((field: string) => {\n return scales[field];\n });\n\n const labelCfgs: LabelCfg[] = [];\n each(mapppingArray, (mappingData: MappingDatum, index: number) => {\n const origin = mappingData[FIELD_ORIGIN]; // 原始数据\n const originText = this.getLabelText(origin, labelScales);\n let callbackCfg;\n if (callback) {\n // 当同时配置了 callback 和 cfg 时,以 callback 为准\n const originValues = fields.map((field: string) => origin[field]);\n callbackCfg = callback(...originValues);\n if (isNil(callbackCfg)) {\n labelCfgs.push(null);\n return;\n }\n }\n\n let labelCfg = {\n id: this.getLabelId(mappingData), // 进行 ID 标记\n elementId: this.geometry.getElementId(mappingData), // label 对应 Element 的 ID\n data: origin, // 存储原始数据\n mappingData, // 存储映射后的数据,\n coordinate, // 坐标系\n ...cfg,\n ...callbackCfg,\n };\n\n if (isFunction(labelCfg.position)) {\n labelCfg.position = labelCfg.position(origin, mappingData, index);\n }\n\n const offset = this.getLabelOffset(labelCfg.offset || 0);\n // defaultCfg 需要判断 innerLabels & labels\n const defaultLabelCfg = this.getDefaultLabelCfg(offset, labelCfg.position);\n // labelCfg priority: defaultCfg < cfg < callbackCfg\n labelCfg = deepMix({}, defaultLabelCfg, labelCfg);\n // 获取最终的 offset\n labelCfg.offset = this.getLabelOffset(labelCfg.offset || 0);\n\n const content = labelCfg.content;\n if (isFunction(content)) {\n labelCfg.content = content(origin, mappingData, index);\n } else if (isUndefined(content)) {\n // 用户未配置 content,则默认为映射的第一个字段的值\n labelCfg.content = originText[0];\n }\n\n labelCfgs.push(labelCfg);\n });\n\n return labelCfgs;\n }\n\n private getLabelText(origin: Datum, scales: Scale[]) {\n const labelTexts = [];\n each(scales, (scale: Scale) => {\n let value = origin[scale.field];\n if (isArray(value)) {\n value = value.map((subVal) => {\n return scale.getText(subVal);\n });\n } else {\n value = scale.getText(value);\n }\n\n if (isNil(value) || value === '') {\n labelTexts.push(null);\n } else {\n labelTexts.push(value);\n }\n });\n return labelTexts;\n }\n\n private getOffsetVector(offset: number | string = 0) {\n const coordinate = this.getCoordinate();\n let actualOffset = 0;\n if (isNumber(offset)) {\n actualOffset = offset;\n }\n // 如果 x,y 翻转,则偏移 x,否则偏移 y\n return coordinate.isTransposed ? coordinate.applyMatrix(actualOffset, 0) : coordinate.applyMatrix(0, actualOffset);\n }\n\n private getGeometryShapes() {\n const geometry = this.geometry;\n const shapes = {};\n each(geometry.elementsMap, (element: Element, id: string) => {\n shapes[id] = element.shape;\n });\n // 因为有可能 shape 还在进行动画,导致 shape.getBBox() 获取到的值不是最终态,所以需要从 offscreenGroup 获取\n each(geometry.getOffscreenGroup().getChildren(), (child) => {\n const id = geometry.getElementId(child.get('origin').mappingData);\n shapes[id] = child;\n });\n\n return shapes;\n }\n}\n","import { Attribute } from '../dependents';\n\n/**\n * @ignore\n * get the mapping value by attribute, if mapping value is nil, return def\n * @param attr\n * @param value\n * @param def\n * @returns get mapping value\n */\nexport function getMappingValue(attr: Attribute, value: any, def: string): string {\n if (!attr) {\n return def;\n }\n\n let r;\n // 多参数映射,阻止程序报错\n if (attr.callback && attr.callback.length > 1) {\n const restArgs = Array(attr.callback.length - 1).fill('');\n r = attr.mapping(value, ...restArgs).join('');\n } else {\n r = attr.mapping(value).join('');\n }\n\n return r || def;\n}\n","/** @ignore */\nexport const MarkerSymbols = {\n hexagon: (x: number, y: number, r: number) => {\n const diffX = (r / 2) * Math.sqrt(3);\n return [\n ['M', x, y - r],\n ['L', x + diffX, y - r / 2],\n ['L', x + diffX, y + r / 2],\n ['L', x, y + r],\n ['L', x - diffX, y + r / 2],\n ['L', x - diffX, y - r / 2],\n ['Z'],\n ];\n },\n bowtie: (x: number, y: number, r: number) => {\n const diffY = r - 1.5;\n return [['M', x - r, y - diffY], ['L', x + r, y + diffY], ['L', x + r, y - diffY], ['L', x - r, y + diffY], ['Z']];\n },\n cross: (x: number, y: number, r: number) => {\n return [\n ['M', x - r, y - r],\n ['L', x + r, y + r],\n ['M', x + r, y - r],\n ['L', x - r, y + r],\n ];\n },\n tick: (x: number, y: number, r: number) => {\n return [\n ['M', x - r / 2, y - r],\n ['L', x + r / 2, y - r],\n ['M', x, y - r],\n ['L', x, y + r],\n ['M', x - r / 2, y + r],\n ['L', x + r / 2, y + r],\n ];\n },\n plus: (x: number, y: number, r: number) => {\n return [\n ['M', x - r, y],\n ['L', x + r, y],\n ['M', x, y - r],\n ['L', x, y + r],\n ];\n },\n hyphen: (x: number, y: number, r: number) => {\n return [\n ['M', x - r, y],\n ['L', x + r, y],\n ];\n },\n line: (x: number, y: number, r: number) => {\n return [\n ['M', x, y - r],\n ['L', x, y + r],\n ];\n },\n};\n","import { LegendMarkerCfg } from '@antv/component';\nimport { deepMix, isString, each, get, isFunction } from '@antv/util';\nimport View from '../chart/view';\nimport { DIRECTION } from '../constant';\nimport { Attribute, ShapeAttrs, Tick } from '../dependents';\nimport Geometry from '../geometry/base';\nimport { LegendCfg, LegendItem, MarkerCfg } from '../interface';\nimport { getMappingValue } from './attr';\nimport { omit } from './helper';\nimport { MarkerSymbols } from './marker';\n\n/** 线条形 marker symbol */\nconst STROKES_SYMBOLS = ['line', 'cross', 'tick', 'plus', 'hyphen'];\n\n/**\n * 处理用户配置的 marker style\n * @param markerStyle\n * @param userMarker.style\n * @returns {ShapeAttrs} newStyle\n */\nfunction handleUserMarkerStyle(markerStyle: ShapeAttrs, style: MarkerCfg['style']): ShapeAttrs {\n if (isFunction(style)) {\n return style(markerStyle);\n }\n return deepMix({}, markerStyle, style);\n}\n\n/**\n * 根据 marker 是否为线条形 symbol, 来调整下样式\n * @param symbol\n * @param style\n * @param color\n */\nfunction adpatorMarkerStyle(marker: LegendMarkerCfg, color: string): void {\n const symbol = marker.symbol;\n if (isString(symbol) && STROKES_SYMBOLS.indexOf(symbol) !== -1) {\n const markerStyle = get(marker, 'style', {});\n const lineWidth = get(markerStyle, 'lineWidth', 1);\n const stroke = markerStyle.stroke || markerStyle.fill || color;\n marker.style = deepMix({}, marker.style, { lineWidth, stroke, fill: null });\n }\n}\n\n/**\n * 设置 marker 的 symbol,将 字符串的 symbol 转换为真正的绘制命令\n * @param marker\n */\nfunction setMarkerSymbol(marker: LegendMarkerCfg): void {\n const symbol = marker.symbol;\n if (isString(symbol) && MarkerSymbols[symbol]) {\n marker.symbol = MarkerSymbols[symbol];\n }\n}\n\n/**\n * @ignore\n * get the legend layout from direction\n * @param direction\n * @returns layout 'horizontal' | 'vertical'\n */\nexport function getLegendLayout(direction: DIRECTION): 'vertical' | 'horizontal' {\n return direction.startsWith(DIRECTION.LEFT) || direction.startsWith(DIRECTION.RIGHT) ? 'vertical' : 'horizontal';\n}\n\n/** item of @antv/component legend */\ntype ComponentLegendItem = Omit & {\n marker: any;\n};\n\n/**\n * @ignore\n * get the legend items\n * @param view\n * @param geometry\n * @param attr\n * @param themeMarker\n * @param markerCfg\n * @returns legend items\n */\nexport function getLegendItems(\n view: View,\n geometry: Geometry,\n attr: Attribute,\n themeMarker: object,\n userMarker: LegendCfg['marker']\n): ComponentLegendItem[] {\n const scale = attr.getScale(attr.type);\n if (scale.isCategory) {\n const field = scale.field;\n const colorAttr = geometry.getAttribute('color');\n const shapeAttr = geometry.getAttribute('shape');\n const defaultColor = view.getTheme().defaultColor;\n const isInPolar = geometry.coordinate.isPolar;\n\n return scale.getTicks().map((tick: Tick, index: number) => {\n const { text, value: scaleValue } = tick;\n const name = text;\n const value = scale.invert(scaleValue);\n\n // 通过过滤图例项的数据,来看是否 unchecked\n let unchecked = view.filterFieldData(field, [{ [field]: value }]).length === 0;\n each(view.views, (subView) => {\n if (!subView.filterFieldData(field, [{ [field]: value }]).length) {\n unchecked = true;\n }\n });\n\n // @ts-ignore\n const color = getMappingValue(colorAttr, value, defaultColor);\n const shape = getMappingValue(shapeAttr, value, 'point');\n let marker = geometry.getShapeMarker(shape, {\n color,\n isInPolar,\n });\n\n let markerCfg = userMarker;\n if (isFunction(markerCfg)) {\n markerCfg = markerCfg(name, index, { name, value, ...deepMix({}, themeMarker, marker) });\n }\n\n // the marker configure order should be ensure\n marker = deepMix({}, themeMarker, marker, omit({ ...markerCfg }, ['style']));\n adpatorMarkerStyle(marker, color);\n if (markerCfg && markerCfg.style) {\n // handle user's style settings\n marker.style = handleUserMarkerStyle(marker.style, markerCfg.style);\n }\n setMarkerSymbol(marker);\n\n return { id: value, name, value, marker, unchecked };\n });\n }\n return [];\n}\n\n/**\n *\n * @ignore\n * custom legend 的 items 获取\n * @param themeMarker\n * @param userMarker\n * @param customItems\n */\nexport function getCustomLegendItems(themeMarker: object, userMarker: object, customItems: LegendItem[]) {\n // 如果有自定义的 item,那么就直接使用,并合并主题的 marker 配置\n return customItems.map((item: LegendItem, index: number) => {\n let markerCfg = userMarker;\n if (isFunction(markerCfg)) {\n markerCfg = markerCfg(item.name, index, deepMix({}, themeMarker, item));\n }\n\n const itemMarker = isFunction(item.marker)\n ? item.marker(item.name, index, deepMix({}, themeMarker, item))\n : item.marker;\n\n const marker = deepMix({}, themeMarker, markerCfg, itemMarker);\n setMarkerSymbol(marker);\n\n item.marker = marker;\n return item;\n });\n}\n\n/**\n * get the legend cfg from theme, will mix the common cfg of legend theme\n *\n * @param theme view theme object\n * @param direction legend direction\n * @returns legend theme cfg\n */\nexport function getLegendThemeCfg(theme: object, direction: string): object {\n const legendTheme = get(theme, ['components', 'legend'], {});\n return deepMix({}, get(legendTheme, ['common'], {}), deepMix({}, get(legendTheme, [direction], {})));\n}\n","import { isArray } from '@antv/util';\nimport { PathCommand } from '../../../dependents';\nimport { Point, RangePoint, ShapeVertices } from '../../../interface';\nimport { getSplinePath } from './path';\n\nfunction isValueEmpty(value) {\n if (value) {\n return false;\n }\n return value === null || value === undefined || isNaN(value);\n}\n\nfunction isYNil(point: Point[] | RangePoint) {\n if (isArray(point)) {\n // 特殊处理 area 的关键点数据,其关键点结构为 [{x: 0, y: 1}, {x: 0, y: 2}]\n return isValueEmpty(point[1].y);\n }\n const value = point.y;\n return isArray(value) ? isValueEmpty(value[0]) : isValueEmpty(value);\n}\n\n/**\n * @ignore\n * 分割数据,用于处理在一组点数据中,y 对应的数值存在 null/undefined/NaN 的情况\n * 应用于折线图、区域图以及路径图\n *\n * ```typescript\n * // return [[{x: 1, y: 2}, {x: 3, y: 3}]]\n * getPathPoints([{x: 1, y: 2}, {x: 2, y: null}, {x: 3, y: 3}], true);\n * // return [[{x: 1, y: 2}], [{x: 3, y: 3}]]\n * getPathPoints([{x: 1, y: 2}, {x: 2, y: null}, {x: 3, y: 3}], false);\n * // return [[[{ x: 1, y: 10 }, { x: 2, y: 2 }], [{ x: 9, y: 34 }, { x: 1, y: 1 }]]]\n * getPathPoints([\n * [{ x: 1, y: 10 }, { x: 2, y: 2 }],\n * [{ x: 4, y: 2 }, { x: 8, y: NaN }],\n * [{ x: 9, y: 34 }, { x: 1, y: 1 }],\n * ], true);\n * ```\n *\n * @param points 要进行处理点集合\n * @param connectNulls 是否连接空值数据\n * @param showSinglePoint 是否展示孤立点\n * @returns 返回处理后的点集合\n */\nexport function getPathPoints(points: ShapeVertices, connectNulls: boolean = false, showSinglePoint: boolean = true) {\n if (!points.length || (points.length === 1 && !showSinglePoint)) {\n // 空或者只有一个点并配置不展示时\n return [];\n }\n\n if (connectNulls) {\n // 即 y 值为空的场景\n const filtered = [];\n for (let i = 0, len = points.length; i < len; i++) {\n const point = points[i];\n if (!isYNil(point)) {\n filtered.push(point);\n }\n }\n return [filtered];\n }\n\n const result = [];\n let tmp = [];\n for (let i = 0, len = points.length; i < len; i++) {\n const point = points[i];\n if (isYNil(point)) {\n if (tmp.length) {\n if (!(tmp.length === 1 && !showSinglePoint)) {\n // 如果前段数据只有一个字段并且不需要展示时则不加入\n result.push(tmp);\n }\n tmp = [];\n }\n } else {\n tmp.push(point);\n }\n }\n\n if (tmp.length) {\n result.push(tmp);\n }\n return result;\n}\n\n/**\n * 获取小提琴图的边界 path\n * @param points\n * @returns\n */\nexport function getViolinPath(points: ShapeVertices): PathCommand[] {\n const path = [];\n for (let i = 0; i < points.length; i++) {\n const point = points[i] as Point;\n if (point) {\n const action = i === 0 ? 'M' : 'L';\n path.push([action, point.x, point.y]);\n }\n }\n const first = points[0] as Point;\n if (first) {\n path.push(['L', first.x, first.y]);\n path.push(['z']);\n }\n return path;\n}\n\n/**\n * 获取小提琴图 平滑的边界 path\n * @param points\n * @returns\n */\nexport function getSmoothViolinPath(points: ShapeVertices): PathCommand[] {\n const half = points.length / 2;\n const leftPoints = [];\n const rightPoints = [];\n for (let i = 0; i < points.length; i++) {\n if (i < half) {\n leftPoints.push(points[i]);\n } else {\n rightPoints.push(points[i]);\n }\n }\n const leftPath = getSplinePath(leftPoints, false);\n const rightPath = getSplinePath(rightPoints, false);\n if (rightPoints.length) {\n leftPath.push(['L', rightPoints[0].x, rightPoints[0].y]);\n }\n rightPath.shift();\n const path = leftPath.concat(rightPath);\n if (leftPoints.length) {\n path.push(['L', leftPoints[0].x, leftPoints[0].y]);\n }\n path.push(['z']);\n return path;\n}\n","import { deepMix, isNil, get } from '@antv/util';\nimport { ShapeInfo } from '../../../interface';\n\n/**\n * @ignore\n * 获取 Shape 的图形属性\n * @param cfg\n * @param isStroke 是否需要描边\n * @param isFill 是否需要填充\n * @param [sizeName] 可选,表示图形大小的属性,lineWidth 或者 r\n * @returns\n */\nexport function getStyle(cfg: ShapeInfo, isStroke: boolean, isFill: boolean, sizeName: string = '') {\n const { style = {}, defaultStyle, color, size } = cfg;\n const attrs = {\n ...defaultStyle,\n ...style,\n };\n if (color) {\n if (isStroke) {\n if (!style.stroke) {\n // 如果用户在 style() 中配置了 stroke,则以用户配置的为准\n attrs.stroke = color;\n }\n }\n\n if (isFill) {\n if (!style.fill) {\n // 如果用户在 style() 中配置了 fill\n attrs.fill = color;\n }\n }\n }\n if (sizeName && isNil(style[sizeName]) && !isNil(size)) {\n // 如果用户在 style() 中配置了 lineWidth 或者 r 属性\n attrs[sizeName] = size;\n }\n\n return attrs;\n}\n\n/**\n * 获取 矩形背景 的样式\n * @param cfg\n */\nexport function getBackgroundRectStyle(cfg?: ShapeInfo) {\n return deepMix(\n {},\n {\n // 默认背景色,copy from active-region\n fill: '#CCD6EC',\n fillOpacity: 0.3,\n },\n get(cfg, ['background', 'style'])\n );\n}\n","import { isArray } from '@antv/util';\nimport { Point, RangePoint } from '../../../interface';\n\n/**\n * @ignore\n * 拆分点数据\n * @example\n * // result: [{x: 20, y: 20}, {x: 20, y: 30}]\n * splitPoints({x: 20,y: [20, 30]});\n * @example\n * // result: [{x: 20, y: 20}, {x: 30, y: 30}]\n * splitPoints({x: [20, 30],y: [20, 30]});\n * @param obj\n */\nexport function splitPoints(obj: RangePoint): Point[] {\n // y 有可能是数组,对应原始数据中 y 为一个区间数据,如 [19, 30],为了统一也将 x 转换为数组\n const x = obj.x;\n const y = isArray(obj.y) ? obj.y : [obj.y];\n\n return y.map((eachY, index) => {\n return {\n x: isArray(x) ? x[index] : x,\n y: eachY,\n };\n });\n}\n","import { ShapeMarkerCfg } from '../../../interface';\n\nconst LineSymbols = {\n line: (x: number, y: number, r: number) => {\n return [\n ['M', x - r, y],\n ['L', x + r, y],\n ];\n },\n dot: (x: number, y: number, r: number) => {\n return [\n ['M', x - r, y],\n ['L', x + r, y],\n ];\n },\n dash: (x: number, y: number, r: number) => {\n return [\n ['M', x - r, y],\n ['L', x + r, y],\n ];\n },\n smooth: (x: number, y: number, r: number) => {\n return [\n ['M', x - r, y],\n ['A', r / 2, r / 2, 0, 1, 1, x, y],\n ['A', r / 2, r / 2, 0, 1, 0, x + r, y],\n ];\n },\n hv: (x: number, y: number, r: number) => {\n return [\n ['M', x - r - 1, y - 2.5],\n ['L', x, y - 2.5],\n ['L', x, y + 2.5],\n ['L', x + r + 1, y + 2.5],\n ];\n },\n vh: (x: number, y: number, r: number) => {\n return [\n ['M', x - r - 1, y + 2.5],\n ['L', x, y + 2.5],\n ['L', x, y - 2.5],\n ['L', x + r + 1, y - 2.5],\n ];\n },\n hvh: (x: number, y: number, r: number) => {\n return [\n ['M', x - (r + 1), y + 2.5],\n ['L', x - r / 2, y + 2.5],\n ['L', x - r / 2, y - 2.5],\n ['L', x + r / 2, y - 2.5],\n ['L', x + r / 2, y + 2.5],\n ['L', x + r + 1, y + 2.5],\n ];\n },\n vhv: (x: number, y: number) => {\n // 宽 13px,高 8px\n return [\n ['M', x - 5, y + 2.5],\n ['L', x - 5, y],\n ['L', x, y],\n ['L', x, y - 3],\n ['L', x, y + 3],\n ['L', x + 6.5, y + 3],\n ];\n },\n};\n\n/**\n * Gets line marker\n * @ignore\n * @param markerCfg\n * @param shapeType\n * @returns 返回 Line 的 marker 配置\n */\nexport function getLineMarker(markerCfg: ShapeMarkerCfg, shapeType: string) {\n const { color } = markerCfg;\n return {\n symbol: LineSymbols[shapeType],\n style: {\n lineWidth: 2,\n r: 6,\n stroke: color,\n },\n };\n}\n","import { each, isArray } from '@antv/util';\nimport { IGroup, ShapeAttrs } from '../../../dependents';\nimport { Point, Position, RangePoint, ShapeInfo, ShapeMarkerCfg } from '../../../interface';\n\nimport { registerShape, registerShapeFactory } from '../base';\nimport { getPathPoints } from '../util/get-path-points';\nimport { getStyle } from '../util/get-style';\nimport { getLinePath, getSplinePath } from '../util/path';\nimport { splitPoints } from '../util/split-points';\nimport { getLineMarker } from './util';\n\nfunction getShapeAttrs(cfg: ShapeInfo, smooth?: boolean, constraint?: Position[]) {\n const { isStack, connectNulls, isInCircle, showSinglePoint } = cfg;\n const shapeAttrs = getStyle(cfg, true, false, 'lineWidth');\n\n const points = getPathPoints(cfg.points, connectNulls, showSinglePoint); // 根据 connectNulls 值处理 points\n let path = [];\n for (let i = 0, len = points.length; i < len; i++) {\n const eachLinePoints = points[i];\n path = path.concat(getPath(eachLinePoints, isInCircle, isStack, smooth, constraint, shapeAttrs));\n }\n shapeAttrs.path = path;\n\n return shapeAttrs;\n}\n\n// 单条 path\nfunction getSinglePath(\n points: Point[],\n isInCircle: boolean,\n smooth?: boolean,\n constraint?: Position[],\n style?: ShapeAttrs\n) {\n if (points.length === 1) {\n // 只有一个点时\n return [\n ['M', points[0].x, points[0].y - style.lineWidth / 2],\n ['L', points[0].x, points[0].y],\n ['L', points[0].x, points[0].y + style.lineWidth / 2],\n ];\n }\n\n let path;\n if (!smooth) {\n path = getLinePath(points, false);\n if (isInCircle) {\n path.push(['Z']);\n }\n } else {\n // 直角坐标系下绘制曲线时限制最大值、最小值\n if (isInCircle && points.length) {\n points.push({ x: points[0].x, y: points[0].y });\n }\n path = getSplinePath(points, false, constraint);\n }\n\n return path;\n}\n\nfunction getRangePath(\n points: RangePoint[],\n isInCircle: boolean,\n isStack?: boolean,\n smooth?: boolean,\n constraint?: Position[],\n style?: ShapeAttrs\n) {\n const topPoints = [];\n const bottomPoints = [];\n each(points, (point: RangePoint) => {\n const result = splitPoints(point);\n topPoints.push(result[1]); // 上边\n bottomPoints.push(result[0]); // 底边\n });\n\n const topPath = getSinglePath(topPoints, isInCircle, smooth, constraint, style);\n const bottomPath = getSinglePath(bottomPoints, isInCircle, smooth, constraint, style);\n if (isStack) {\n return topPath;\n }\n return topPath.concat(bottomPath);\n}\n\n/**\n * 获取折线图 path\n */\nexport function getPath(\n points: Point[] | RangePoint[],\n isInCircle: boolean,\n isStack?: boolean,\n smooth?: boolean,\n constraint?: Position[],\n style?: ShapeAttrs\n) {\n if (points.length) {\n const first = points[0];\n\n return isArray(first.y)\n ? getRangePath(points as RangePoint[], isInCircle, isStack, smooth, constraint, style)\n : getSinglePath(points as Point[], isInCircle, smooth, constraint, style);\n }\n return [];\n}\n\nconst LineShapeFactory = registerShapeFactory('line', {\n defaultShapeType: 'line',\n});\n\n// 这里因为代码公用,所以直接全部注册\n// 'line' 默认折线;'dot' 点线 ···;'dash' 断线 - - -\neach(['line', 'dot', 'dash', 'smooth'], (shapeType) => {\n registerShape('line', shapeType, {\n draw(cfg: ShapeInfo, container: IGroup) {\n const smooth = shapeType === 'smooth';\n let constraint;\n if (smooth) {\n const { start, end } = this.coordinate;\n constraint = [\n [start.x, end.y],\n [end.x, start.y],\n ];\n }\n\n const attrs = getShapeAttrs(cfg, smooth, constraint);\n const shape = container.addShape({\n type: 'path',\n attrs,\n name: 'line',\n capture: !smooth,\n });\n\n return shape;\n },\n getMarker(markerCfg: ShapeMarkerCfg) {\n return getLineMarker(markerCfg, shapeType);\n },\n });\n});\n\nexport default LineShapeFactory;\n","/* G2 的一个壳子,不包含 Geometry,由开发者自己定义和引入 */\n\nexport const VERSION = '4.2.11';\n\n// 核心基类导出\nexport { Chart, View, Event } from './chart'; // Chart, View 类\nexport { Controller as ComponentController } from './chart/controller/base'; // G2 组件基类\nexport { default as TooltipController } from './chart/controller/tooltip'; // G2 tooltip 组件基类\nexport { default as Geometry } from './geometry/base'; // Geometry 基类\nexport { default as Element } from './geometry/element'; // Element 类\nexport { default as GeometryLabel } from './geometry/label/base'; // Geometry Label 基类\nexport { Interaction, Action } from './interaction'; // Interaction, Action 基类\nexport { Facet } from './facet'; // Facet 基类\nexport { default as InteractionAction } from './interaction/action/base'; // Interaction Action 基类\n\n// 注册 ComponentController\nexport { registerComponentController } from './chart';\n\n// 注册 Geometry\nexport { registerGeometry } from './chart';\n\n// 注册 Geometry Shape\nexport { registerShape, registerShapeFactory, getShapeFactory } from './geometry/shape/base';\n\n// 注册 Geometry label 以及 Geometry Label 布局函数\nexport {\n registerGeometryLabel,\n registerGeometryLabelLayout,\n getGeometryLabel,\n getGeometryLabelLayout,\n} from './geometry/label';\n\n// 注册 interaction\nexport { getInteraction, registerInteraction, registerAction, getActionClass } from './interaction';\n\n// 注册 facet\nexport { getFacet, registerFacet } from './facet';\n\n// 注册主题\nexport { getTheme, registerTheme } from './theme';\n\n// G engine 管理相关\nexport { registerEngine, getEngine } from './engine';\n\n// 注册动画函数\nexport { registerAnimation, getAnimation } from './animate/animation';\n\nexport { LAYER, DIRECTION } from './constant';\n\n// 因为 typescript 部分版本不支持 export * as 语法。\nimport * as Types from './interface';\nexport type { Types };\n\nexport { IGroup, ShapeAttrs, Coordinate, Scale, ScaleConfig } from './dependents';\n\n// 一些工具方法导出\nimport { getMappingValue } from './util/attr';\nimport { getLegendItems } from './util/legend';\nimport { getAngle, getSectorPath, polarToCartesian } from './util/graphics';\nimport { rotate, transform, translate, zoom } from './util/transform';\nimport { getTooltipItems } from './util/tooltip';\nimport { getDelegationObject } from './interaction/action/util';\nimport { getPathPoints } from './geometry/shape/util/get-path-points';\nimport { getPath } from './geometry/shape/line';\n\nexport const Util = {\n getLegendItems,\n translate,\n rotate,\n zoom,\n transform,\n getAngle,\n getSectorPath,\n polarToCartesian,\n getDelegationObject,\n getTooltipItems,\n getMappingValue,\n // shape 的一些操作方法\n getPath,\n getPathPoints,\n};\n","import { StyleSheetCfg } from '../../interface';\n\nconst WHITE_COLORS = {\n 100: '#000',\n 95: '#0D0D0D',\n 85: '#262626',\n 65: '#595959',\n 45: '#8C8C8C',\n 25: '#BFBFBF',\n 15: '#D9D9D9',\n 6: '#F0F0F0',\n};\n\nconst BLACK_COLORS = {\n 100: '#FFFFFF',\n 95: '#F2F2F2',\n 85: '#D9D9D9',\n 65: '#A6A6A6',\n 45: '#737373',\n 25: '#404040',\n 15: '#262626',\n 6: '#0F0F0F',\n};\n\nconst QUALITATIVE_10 = [\n '#5B8FF9',\n '#5AD8A6',\n '#5D7092',\n '#F6BD16',\n '#E86452',\n '#6DC8EC',\n '#945FB9',\n '#FF9845',\n '#1E9493',\n '#FF99C3',\n];\n\nconst QUALITATIVE_20 = [\n '#5B8FF9',\n '#CDDDFD',\n '#5AD8A6',\n '#CDF3E4',\n '#5D7092',\n '#CED4DE',\n '#F6BD16',\n '#FCEBB9',\n '#E86452',\n '#F8D0CB',\n '#6DC8EC',\n '#D3EEF9',\n '#945FB9',\n '#DECFEA',\n '#FF9845',\n '#FFE0C7',\n '#1E9493',\n '#BBDEDE',\n '#FF99C3',\n '#FFE0ED',\n];\n\n/** 单色顺序色板 */\nconst SINGLE_SEQUENCE = [\n '#B8E1FF',\n '#9AC5FF',\n '#7DAAFF',\n '#5B8FF9',\n '#3D76DD',\n '#085EC0',\n '#0047A5',\n '#00318A',\n '#001D70',\n];\n\nexport const createDarkStyleSheet = (cfg: StyleSheetCfg = {}) => {\n const { paletteQualitative10 = QUALITATIVE_10, paletteQualitative20 = QUALITATIVE_20 } = cfg;\n const { brandColor = paletteQualitative10[0] } = cfg;\n\n const token = {\n /** 图表背景色 */\n backgroundColor: '#141414',\n /** 主题色 */\n brandColor,\n /** 图表辅助色 */\n subColor: 'rgba(255,255,255,0.05)',\n /** 分类色板 1,在数据量小于等于 10 时使用 */\n paletteQualitative10,\n /** 分类色板 2,在数据量大于 10 时使用 */\n paletteQualitative20,\n /** 语义色 */\n paletteSemanticRed: '#F4664A',\n /** 语义色 */\n paletteSemanticGreen: '#30BF78',\n /** 语义色 */\n paletteSemanticYellow: '#FAAD14',\n /** (单色)顺序色板 */\n paletteSequence: SINGLE_SEQUENCE,\n /** 字体 */\n fontFamily: `\"Segoe UI\", Roboto, \"Helvetica Neue\", Arial,\n \"Noto Sans\", sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\",\n \"Noto Color Emoji\"`,\n\n // -------------------- 坐标轴 --------------------\n /** 坐标轴线颜色 */\n axisLineBorderColor: BLACK_COLORS[25],\n /** 坐标轴线粗细 */\n axisLineBorder: 1,\n /** 坐标轴线 lineDash 设置 */\n axisLineDash: null,\n\n /** 坐标轴标题颜色 */\n axisTitleTextFillColor: BLACK_COLORS[65],\n /** 坐标轴标题文本字体大小 */\n axisTitleTextFontSize: 12,\n /** 坐标轴标题文本行高 */\n axisTitleTextLineHeight: 12,\n /** 坐标轴标题文本字体粗细 */\n axisTitleTextFontWeight: 'normal',\n /** 坐标轴标题距离坐标轴文本的间距 */\n axisTitleSpacing: 12,\n /** 坐标轴标题详细说明icon颜色 */\n axisDescriptionIconFillColor: WHITE_COLORS[85],\n\n /** 坐标轴刻度线颜色 */\n axisTickLineBorderColor: BLACK_COLORS[25],\n /** 坐标轴刻度线长度 */\n axisTickLineLength: 4,\n /** 坐标轴刻度线粗细 */\n axisTickLineBorder: 1,\n\n /** 坐标轴次刻度线颜色 */\n axisSubTickLineBorderColor: BLACK_COLORS[15],\n /** 坐标轴次刻度线长度 */\n axisSubTickLineLength: 2,\n /** 坐标轴次刻度线粗细 */\n axisSubTickLineBorder: 1,\n\n /** 坐标轴刻度文本颜色 */\n axisLabelFillColor: BLACK_COLORS[45],\n /** 坐标轴刻度文本字体大小 */\n axisLabelFontSize: 12,\n /** 坐标轴刻度文本行高 */\n axisLabelLineHeight: 12,\n /** 坐标轴刻度文本字体粗细 */\n axisLabelFontWeight: 'normal',\n /** 坐标轴刻度文本距离坐标轴线的间距 */\n axisLabelOffset: 8,\n\n /** 坐标轴网格线颜色 */\n axisGridBorderColor: BLACK_COLORS[15],\n /** 坐标轴网格线粗细 */\n axisGridBorder: 1,\n /** 坐标轴网格线虚线设置 */\n axisGridLineDash: null,\n\n // -------------------- 图例 --------------------\n /** 图例标题颜色 */\n legendTitleTextFillColor: BLACK_COLORS[45],\n /** 图例标题文本字体大小 */\n legendTitleTextFontSize: 12,\n /** 图例标题文本行高 */\n legendTitleTextLineHeight: 21,\n /** 图例标题文本字体粗细 */\n legendTitleTextFontWeight: 'normal',\n\n /** 图例 marker 颜色 */\n legendMarkerColor: QUALITATIVE_10[0],\n /** 图例 marker 距离图例文本的间距 */\n legendMarkerSpacing: 8,\n /** 图例 marker 默认半径大小 */\n legendMarkerSize: 4,\n /** 图例 'circle' marker 半径 */\n legendCircleMarkerSize: 4,\n /** 图例 'square' marker 半径 */\n legendSquareMarkerSize: 4,\n /** 图例 'line' marker 半径 */\n legendLineMarkerSize: 5,\n\n /** 图例项文本颜色 */\n legendItemNameFillColor: BLACK_COLORS[65],\n /** 图例项文本字体大小 */\n legendItemNameFontSize: 12,\n /** 图例项文本行高 */\n legendItemNameLineHeight: 12,\n /** 图例项粗细 */\n legendItemNameFontWeight: 'normal',\n /** 图例项之间的水平间距 */\n legendItemSpacing: 24,\n /** 图例项垂直方向的间隔 */\n legendItemMarginBottom: 12,\n /** 图例与图表绘图区域的偏移距离 */\n legendSpacing: 16,\n /** 图例与图表绘图区域的偏移距离 */\n legendPadding: [8, 8, 8, 8],\n /** 水平布局的图例与绘图区域偏移距离 */\n legendHorizontalPadding: [8, 0, 8, 0],\n /** 垂直布局的图例与绘图区域偏移距离 */\n legendVerticalPadding: [0, 8, 0, 8],\n\n // 图例分页器\n /** 图例分页器 marker 大小 */\n legendPageNavigatorMarkerSize: 12,\n /** 图例分页器 marker 填充色 */\n legendPageNavigatorMarkerInactiveFillColor: BLACK_COLORS[45],\n /** 图例分页器 marker 填充色透明度 */\n legendPageNavigatorMarkerInactiveFillOpacity: 0.45,\n /** 图例分页器 marker 激活状态填充色 */\n legendPageNavigatorMarkerFillColor: BLACK_COLORS[45],\n /** 图例分页器 marker 激活状态填充色透明度 */\n legendPageNavigatorMarkerFillOpacity: 1,\n /** 图例分页器文本颜色 */\n legendPageNavigatorTextFillColor: BLACK_COLORS[65],\n /** 图例分页器文本字体大小 */\n legendPageNavigatorTextFontSize: 12,\n\n /** 连续图例滑块填充色 */\n sliderRailFillColor: BLACK_COLORS[15],\n /** 连续图例滑块边框粗细 */\n sliderRailBorder: 0,\n /** 连续图例滑块边框颜色 */\n sliderRailBorderColor: null,\n /** 连续图例滑块宽度 */\n sliderRailWidth: 100,\n /** 连续图例滑块高度 */\n sliderRailHeight: 12,\n\n /** 连续图例文本颜色 */\n sliderLabelTextFillColor: BLACK_COLORS[45],\n /** 连续图例文本字体大小 */\n sliderLabelTextFontSize: 12,\n /** 连续图例文本行高 */\n sliderLabelTextLineHeight: 12,\n /** 连续图例文本字体粗细 */\n sliderLabelTextFontWeight: 'normal',\n\n /** 连续图例滑块颜色 */\n sliderHandlerFillColor: WHITE_COLORS[6],\n /** 连续图例滑块宽度 */\n sliderHandlerWidth: 10,\n /** 连续图例滑块高度 */\n sliderHandlerHeight: 14,\n /** 连续图例滑块边框粗细 */\n sliderHandlerBorder: 1,\n /** 连续图例滑块边框颜色 */\n sliderHandlerBorderColor: WHITE_COLORS[25],\n\n // -------------------- Annotation,图形标注 --------------------\n /** arc 图形标注描边颜色 */\n annotationArcBorderColor: BLACK_COLORS[15],\n /** arc 图形标注粗细 */\n annotationArcBorder: 1,\n\n /** line 图形标注颜色 */\n annotationLineBorderColor: BLACK_COLORS[25],\n /** line 图形标注粗细 */\n annotationLineBorder: 1,\n /** lube 图形标注的虚线间隔 */\n annotationLineDash: null,\n\n /** text 图形标注文本颜色 */\n annotationTextFillColor: BLACK_COLORS[65],\n /** text 图形标注文本字体大小 */\n annotationTextFontSize: 12,\n /** text 图形标注文本行高 */\n annotationTextLineHeight: 12,\n /** text 图形标注文本字体粗细 */\n annotationTextFontWeight: 'normal',\n /** text 图形标注文本边框颜色 */\n annotationTextBorderColor: null,\n /** text 图形标注文本边框粗细 */\n annotationTextBorder: 0,\n\n /** region 图形标注填充颜色 */\n annotationRegionFillColor: BLACK_COLORS[100],\n /** region 图形标注填充颜色透明色 */\n annotationRegionFillOpacity: 0.06,\n /** region 图形标注描边粗细 */\n annotationRegionBorder: 0,\n /** region 图形标注描边颜色 */\n annotationRegionBorderColor: null,\n\n /** dataMarker 图形标注线的长度 */\n annotationDataMarkerLineLength: 16,\n\n // -------------------- Tooltip --------------------\n /** tooltip crosshairs 辅助线颜色 */\n tooltipCrosshairsBorderColor: BLACK_COLORS[25],\n /** tooltip crosshairs 辅助线粗细 */\n tooltipCrosshairsBorder: 1,\n /** tooltip crosshairs 辅助线虚线间隔 */\n tooltipCrosshairsLineDash: null,\n\n /** tooltip 内容框背景色 */\n tooltipContainerFillColor: '#1f1f1f',\n tooltipContainerFillOpacity: 0.95,\n /** tooltip 内容框阴影 */\n tooltipContainerShadow: '0px 2px 4px rgba(0,0,0,.5)',\n /** tooltip 内容框圆角 */\n tooltipContainerBorderRadius: 3,\n\n /** tooltip 文本颜色 */\n tooltipTextFillColor: BLACK_COLORS[65],\n /** tooltip 文本字体大小 */\n tooltipTextFontSize: 12,\n /** tooltip 文本行高 */\n tooltipTextLineHeight: 12,\n /** tooltip 文本字体粗细 */\n tooltipTextFontWeight: 'bold',\n\n // -------------------- Geometry labels --------------------\n /** Geometry label 文本颜色 */\n labelFillColor: BLACK_COLORS[65],\n labelFillColorDark: '#2c3542',\n labelFillColorLight: '#ffffff',\n /** Geometry label 文本字体大小 */\n labelFontSize: 12,\n /** Geometry label 文本行高 */\n labelLineHeight: 12,\n /** Geometry label 文本字体粗细 */\n labelFontWeight: 'normal',\n /** Geometry label 文本描边颜色 */\n labelBorderColor: null,\n /** Geometry label 文本描边粗细 */\n labelBorder: 0,\n\n /** Geometry innerLabel 文本颜色 */\n innerLabelFillColor: WHITE_COLORS[100],\n /** Geometry innerLabel 文本字体大小 */\n innerLabelFontSize: 12,\n /** Geometry innerLabel 文本行高 */\n innerLabelLineHeight: 12,\n /** Geometry innerLabel 文本字体粗细 */\n innerLabelFontWeight: 'normal',\n /** Geometry innerLabel 文本描边颜色 */\n innerLabelBorderColor: null,\n /** Geometry innerLabel 文本描边粗细 */\n innerLabelBorder: 0,\n\n /** Geometry label 文本颜色 */\n overflowLabelFillColor: BLACK_COLORS[65],\n overflowLabelFillColorDark: '#2c3542',\n overflowLabelFillColorLight: '#ffffff',\n /** Geometry label 文本字体大小 */\n overflowLabelFontSize: 12,\n /** Geometry label 文本行高 */\n overflowLabelLineHeight: 12,\n /** Geometry label 文本字体粗细 */\n overflowLabelFontWeight: 'normal',\n /** Geometry label 文本描边颜色 */\n overflowLabelBorderColor: WHITE_COLORS[100],\n /** Geometry label 文本描边粗细 */\n overflowLabelBorder: 1,\n\n /** Geometry label 文本连接线粗细 */\n labelLineBorder: 1,\n /** Geometry label 文本连接线颜色 */\n labelLineBorderColor: BLACK_COLORS[25],\n\n // -------------------- Slider 组件样式--------------------\n /** slider 滑道高度 */\n cSliderRailHieght: 16,\n /** slider 滑道背景色 */\n cSliderBackgroundFillColor: '#416180',\n /** slider 滑道背景色透明度 */\n cSliderBackgroundFillOpacity: 0.05,\n /** slider 滑道前景色 */\n cSliderForegroundFillColor: '#5B8FF9',\n /** slider 滑道前景色透明度 */\n cSliderForegroundFillOpacity: 0.15,\n // slider handlerStyle 手柄样式\n /** slider 手柄高度 */\n cSliderHandlerHeight: 24,\n /** Slider 手柄宽度 */\n cSliderHandlerWidth: 10,\n /** Slider 手柄背景色 */\n cSliderHandlerFillColor: '#F7F7F7',\n /** Slider 手柄背景色透明度 */\n cSliderHandlerFillOpacity: 1,\n /** Slider 手柄高亮背景色 */\n cSliderHandlerHighlightFillColor: '#FFF',\n /** Slider 手柄边框色 */\n cSliderHandlerBorderColor: '#BFBFBF',\n /** Slider 手柄边框粗细 */\n cSliderHandlerBorder: 1,\n /** Slider 手柄边框圆角 */\n cSliderHandlerBorderRadius: 2,\n // slider textStyle 字体标签样式\n /** Slider 字体标签颜色 */\n cSliderTextFillColor: '#fff',\n /** Slider 字体标签透明度 */\n cSliderTextFillOpacity: 0.45,\n /** Slider 字体标签大小 */\n cSliderTextFontSize: 12,\n /** Slider 字体标签行高 */\n cSliderTextLineHeight: 12,\n /** Slider 字体标签字重 */\n cSliderTextFontWeight: 'normal',\n /** Slider 字体标签描边色 */\n cSliderTextBorderColor: null,\n /** Slider 字体标签描边粗细 */\n cSliderTextBorder: 0,\n\n // -------------------- Scrollbar 组件样式--------------------\n /** 滚动条 滚道填充色 */\n scrollbarTrackFillColor: 'rgba(255,255,255,0.65)',\n /** 滚动条 滑块填充色 */\n scrollbarThumbFillColor: 'rgba(0,0,0,0.35)',\n /** 滚动条 滑块高亮填充色 */\n scrollbarThumbHighlightFillColor: 'rgba(0,0,0,0.45)',\n\n // -------------------- Geometry 图形样式--------------------\n /** 点图填充颜色 */\n pointFillColor: QUALITATIVE_10[0],\n /** 点图填充颜色透明度 */\n pointFillOpacity: 0.95,\n /** 点图大小 */\n pointSize: 4,\n /** 点图描边粗细 */\n pointBorder: 1,\n /** 点图描边颜色 */\n pointBorderColor: WHITE_COLORS[100],\n /** 点图描边透明度 */\n pointBorderOpacity: 1,\n\n /** 点图 active 状态下描边颜色 */\n pointActiveBorderColor: BLACK_COLORS[100],\n\n /** 点图 selected 状态下描边粗细 */\n pointSelectedBorder: 2,\n /** 点图 selected 状态下描边颜色 */\n pointSelectedBorderColor: BLACK_COLORS[100],\n\n /** 点图 inactive 状态下填充颜色透明度 */\n pointInactiveFillOpacity: 0.3,\n /** 点图 inactive 状态下描边透明度 */\n pointInactiveBorderOpacity: 0.3,\n\n /** 空心点图大小 */\n hollowPointSize: 4,\n /** 空心点图描边粗细 */\n hollowPointBorder: 1,\n /** 空心点图描边颜色 */\n hollowPointBorderColor: QUALITATIVE_10[0],\n /** 空心点图描边透明度 */\n hollowPointBorderOpacity: 0.95,\n hollowPointFillColor: WHITE_COLORS[100],\n\n /** 空心点图 active 状态下描边粗细 */\n hollowPointActiveBorder: 1,\n /** 空心点图 active 状态下描边颜色 */\n hollowPointActiveBorderColor: BLACK_COLORS[100],\n /** 空心点图 active 状态下描边透明度 */\n hollowPointActiveBorderOpacity: 1,\n\n /** 空心点图 selected 状态下描边粗细 */\n hollowPointSelectedBorder: 2,\n /** 空心点图 selected 状态下描边颜色 */\n hollowPointSelectedBorderColor: BLACK_COLORS[100],\n /** 空心点图 selected 状态下描边透明度 */\n hollowPointSelectedBorderOpacity: 1,\n\n /** 空心点图 inactive 状态下描边透明度 */\n hollowPointInactiveBorderOpacity: 0.3,\n\n /** 线图粗细 */\n lineBorder: 2,\n /** 线图颜色 */\n lineBorderColor: QUALITATIVE_10[0],\n /** 线图透明度 */\n lineBorderOpacity: 1,\n\n /** 线图 Active 状态下粗细 */\n lineActiveBorder: 3,\n\n /** 线图 selected 状态下粗细 */\n lineSelectedBorder: 3,\n\n /** 线图 inactive 状态下透明度 */\n lineInactiveBorderOpacity: 0.3,\n\n /** area 填充颜色 */\n areaFillColor: QUALITATIVE_10[0],\n /** area 填充透明度 */\n areaFillOpacity: 0.25,\n\n /** area 在 active 状态下的填充透明度 */\n areaActiveFillColor: QUALITATIVE_10[0],\n areaActiveFillOpacity: 0.5,\n\n /** area 在 selected 状态下的填充透明度 */\n areaSelectedFillColor: QUALITATIVE_10[0],\n areaSelectedFillOpacity: 0.5,\n\n /** area inactive 状态下填充透明度 */\n areaInactiveFillOpacity: 0.3,\n\n /** hollowArea 颜色 */\n hollowAreaBorderColor: QUALITATIVE_10[0],\n /** hollowArea 边框粗细 */\n hollowAreaBorder: 2,\n /** hollowArea 边框透明度 */\n hollowAreaBorderOpacity: 1,\n\n /** hollowArea active 状态下的边框粗细 */\n hollowAreaActiveBorder: 3,\n hollowAreaActiveBorderColor: BLACK_COLORS[100],\n\n /** hollowArea selected 状态下的边框粗细 */\n hollowAreaSelectedBorder: 3,\n hollowAreaSelectedBorderColor: BLACK_COLORS[100],\n\n /** hollowArea inactive 状态下的边框透明度 */\n hollowAreaInactiveBorderOpacity: 0.3,\n\n /** interval 填充颜色 */\n intervalFillColor: QUALITATIVE_10[0],\n /** interval 填充透明度 */\n intervalFillOpacity: 0.95,\n\n /** interval active 状态下边框粗细 */\n intervalActiveBorder: 1,\n /** interval active 状态下边框颜色 */\n intervalActiveBorderColor: BLACK_COLORS[100],\n intervalActiveBorderOpacity: 1,\n\n /** interval selected 状态下边框粗细 */\n intervalSelectedBorder: 2,\n /** interval selected 状态下边框颜色 */\n intervalSelectedBorderColor: BLACK_COLORS[100],\n /** interval selected 状态下边框透明度 */\n intervalSelectedBorderOpacity: 1,\n\n /** interval inactive 状态下边框透明度 */\n intervalInactiveBorderOpacity: 0.3,\n /** interval inactive 状态下填充透明度 */\n intervalInactiveFillOpacity: 0.3,\n\n /** interval 边框粗细 */\n hollowIntervalBorder: 2,\n /** hollowInterval 边框颜色 */\n hollowIntervalBorderColor: QUALITATIVE_10[0],\n /** hollowInterval 边框透明度 */\n hollowIntervalBorderOpacity: 1,\n hollowIntervalFillColor: WHITE_COLORS[100],\n\n /** hollowInterval active 状态下边框粗细 */\n hollowIntervalActiveBorder: 2,\n /** hollowInterval active 状态下边框颜色 */\n hollowIntervalActiveBorderColor: BLACK_COLORS[100],\n\n /** hollowInterval selected 状态下边框粗细 */\n hollowIntervalSelectedBorder: 3,\n /** hollowInterval selected 状态下边框颜色 */\n hollowIntervalSelectedBorderColor: BLACK_COLORS[100],\n /** hollowInterval selected 状态下边框透明度 */\n hollowIntervalSelectedBorderOpacity: 1,\n\n /** hollowInterval inactive 状态下边框透明度 */\n hollowIntervalInactiveBorderOpacity: 0.3,\n };\n\n return { ...token, ...cfg };\n};\n\nexport const antvDark = createDarkStyleSheet();\n","export function getPixelRatio() {\n return window ? window.devicePixelRatio : 1;\n}\n\n/**\n * 两点之间的距离\n * @param {number} x1 起始点 x\n * @param {number} y1 起始点 y\n * @param {number} x2 结束点 x\n * @param {number} y2 结束点 y\n */\nexport function distance(x1: number, y1: number, x2: number, y2: number) {\n const dx = x1 - x2;\n const dy = y1 - y2;\n return Math.sqrt(dx * dx + dy * dy);\n}\n\n/**\n * 是否在包围盒内\n * @param {number} minX 包围盒开始的点 x\n * @param {number} minY 包围盒开始的点 y\n * @param {number} width 宽度\n * @param {number} height 高度\n * @param {[type]} x 检测点的 x\n * @param {[type]} y 监测点的 y\n */\nexport function inBox(minX: number, minY: number, width: number, height: number, x, y) {\n return x >= minX && x <= minX + width && y >= minY && y <= minY + height;\n}\n\nexport function intersectRect(box1, box2) {\n return !(box2.minX > box1.maxX || box2.maxX < box1.minX || box2.minY > box1.maxY || box2.maxY < box1.minY);\n}\n\n// 合并两个区域\nexport function mergeRegion(region1, region2) {\n if (!region1 || !region2) {\n return region1 || region2;\n }\n return {\n minX: Math.min(region1.minX, region2.minX),\n minY: Math.min(region1.minY, region2.minY),\n maxX: Math.max(region1.maxX, region2.maxX),\n maxY: Math.max(region1.maxY, region2.maxY),\n };\n}\n\n/**\n * 判断两个点是否重合,点坐标的格式为 [x, y]\n * @param {Array} point1 第一个点\n * @param {Array} point2 第二个点\n */\nexport function isSamePoint(point1, point2) {\n return point1[0] === point2[0] && point1[1] === point2[1];\n}\n\nexport {\n isNil,\n isString,\n isFunction,\n isArray,\n each,\n toRadian,\n mod,\n isNumberEqual,\n requestAnimationFrame,\n clearAnimationFrame,\n} from '@antv/util';\n","import { IElement } from '@antv/g-base';\nimport { isString, each, isArray } from './util';\n\nconst regexLG = /^l\\s*\\(\\s*([\\d.]+)\\s*\\)\\s*(.*)/i;\nconst regexRG = /^r\\s*\\(\\s*([\\d.]+)\\s*,\\s*([\\d.]+)\\s*,\\s*([\\d.]+)\\s*\\)\\s*(.*)/i;\nconst regexPR = /^p\\s*\\(\\s*([axyn])\\s*\\)\\s*(.*)/i;\nconst regexColorStop = /[\\d.]+:(#[^\\s]+|[^\\)]+\\))/gi;\n\nfunction addStop(steps, gradient) {\n const arr: string[] = steps.match(regexColorStop);\n each(arr, (item) => {\n const itemArr = item.split(':');\n gradient.addColorStop(itemArr[0], itemArr[1]);\n });\n}\n/**\n * 将边和填充设置的颜色转换成线性渐变对象\n * @param {CanvasRenderingContext2D} context canvas 上下文\n * @param {IElement} element 图形元素\n * @param {string} gradientStr 颜色\n * @returns {any} 渐变对象\n */\nexport function parseLineGradient(context: CanvasRenderingContext2D, element: IElement, gradientStr: string) {\n const arr = regexLG.exec(gradientStr);\n const angle = (parseFloat(arr[1]) % 360) * (Math.PI / 180);\n const steps = arr[2];\n const box = element.getBBox();\n let start;\n let end;\n\n if (angle >= 0 && angle < (1 / 2) * Math.PI) {\n start = {\n x: box.minX,\n y: box.minY,\n };\n end = {\n x: box.maxX,\n y: box.maxY,\n };\n } else if ((1 / 2) * Math.PI <= angle && angle < Math.PI) {\n start = {\n x: box.maxX,\n y: box.minY,\n };\n end = {\n x: box.minX,\n y: box.maxY,\n };\n } else if (Math.PI <= angle && angle < (3 / 2) * Math.PI) {\n start = {\n x: box.maxX,\n y: box.maxY,\n };\n end = {\n x: box.minX,\n y: box.minY,\n };\n } else {\n start = {\n x: box.minX,\n y: box.maxY,\n };\n end = {\n x: box.maxX,\n y: box.minY,\n };\n }\n\n const tanTheta = Math.tan(angle);\n const tanTheta2 = tanTheta * tanTheta;\n\n const x = (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.x;\n const y = (tanTheta * (end.x - start.x + tanTheta * (end.y - start.y))) / (tanTheta2 + 1) + start.y;\n const gradient = context.createLinearGradient(start.x, start.y, x, y);\n addStop(steps, gradient);\n return gradient;\n}\n\n/**\n * 将边和填充设置的颜色转换成圆形渐变对象\n * @param {CanvasRenderingContext2D} context canvas 上下文\n * @param {IElement} element 图形元素\n * @param {string} gradientStr 颜色\n * @returns {any} 渐变对象\n */\nexport function parseRadialGradient(context: CanvasRenderingContext2D, element: IElement, gradientStr: string) {\n const arr = regexRG.exec(gradientStr);\n const fx = parseFloat(arr[1]);\n const fy = parseFloat(arr[2]);\n const fr = parseFloat(arr[3]);\n const steps = arr[4];\n // 环半径为0时,默认无渐变,取渐变序列的最后一个颜色\n if (fr === 0) {\n const colors = steps.match(regexColorStop);\n return colors[colors.length - 1].split(':')[1];\n }\n const box = element.getBBox();\n const width = box.maxX - box.minX;\n const height = box.maxY - box.minY;\n const r = Math.sqrt(width * width + height * height) / 2;\n const gradient = context.createRadialGradient(\n box.minX + width * fx,\n box.minY + height * fy,\n 0,\n box.minX + width / 2,\n box.minY + height / 2,\n fr * r\n );\n addStop(steps, gradient);\n return gradient;\n}\n\n/**\n * 边和填充设置的颜色转换成 pattern\n * @param {CanvasRenderingContext2D} context canvas 上下文\n * @param {IElement} element 图形元素\n * @param {string} patternStr 生成 pattern 的字符串\n */\nexport function parsePattern(context: CanvasRenderingContext2D, element: IElement, patternStr: string) {\n // 在转换过程中进行了缓存\n if (element.get('patternSource') && element.get('patternSource') === patternStr) {\n return element.get('pattern');\n }\n let pattern;\n let img;\n const arr = regexPR.exec(patternStr);\n let repeat = arr[1];\n const source = arr[2];\n\n // Function to be called when pattern loads\n function onload() {\n // Create pattern\n pattern = context.createPattern(img, repeat);\n element.set('pattern', pattern); // be a cache\n element.set('patternSource', patternStr);\n }\n\n switch (repeat) {\n case 'a':\n repeat = 'repeat';\n break;\n case 'x':\n repeat = 'repeat-x';\n break;\n case 'y':\n repeat = 'repeat-y';\n break;\n case 'n':\n repeat = 'no-repeat';\n break;\n default:\n repeat = 'no-repeat';\n }\n\n img = new Image();\n // If source URL is not a data URL\n if (!source.match(/^data:/i)) {\n // Set crossOrigin for this image\n img.crossOrigin = 'Anonymous';\n }\n img.src = source;\n\n if (img.complete) {\n onload();\n } else {\n img.onload = onload;\n // Fix onload() bug in IE9\n img.src = img.src;\n }\n\n return pattern;\n}\n\nexport function parseStyle(context: CanvasRenderingContext2D, element: IElement, color: string | CanvasPattern) {\n const bbox = element.getBBox();\n if (isNaN(bbox.x) || isNaN(bbox.y) || isNaN(bbox.width) || isNaN(bbox.height)) {\n return color;\n }\n\n if (isString(color)) {\n if (color[1] === '(' || color[2] === '(') {\n if (color[0] === 'l') {\n // regexLG.test(color)\n return parseLineGradient(context, element, color);\n }\n if (color[0] === 'r') {\n // regexRG.test(color)\n return parseRadialGradient(context, element, color);\n }\n if (color[0] === 'p') {\n // regexPR.test(color)\n return parsePattern(context, element, color);\n }\n }\n return color;\n }\n\n if (color instanceof CanvasPattern) {\n return color;\n }\n}\n\nexport function parseRadius(radius) {\n let r1 = 0;\n let r2 = 0;\n let r3 = 0;\n let r4 = 0;\n if (isArray(radius)) {\n if (radius.length === 1) {\n r1 = r2 = r3 = r4 = radius[0];\n } else if (radius.length === 2) {\n r1 = r3 = radius[0];\n r2 = r4 = radius[1];\n } else if (radius.length === 3) {\n r1 = radius[0];\n r2 = r4 = radius[1];\n r3 = radius[2];\n } else {\n r1 = radius[0];\n r2 = radius[1];\n r3 = radius[2];\n r4 = radius[3];\n }\n } else {\n r1 = r2 = r3 = r4 = radius;\n }\n return [r1, r2, r3, r4];\n}\n","import { mod, toRadian, isSamePoint } from './util';\n\n// 向量长度\nfunction vMag(v) {\n return Math.sqrt(v[0] * v[0] + v[1] * v[1]);\n}\n\n// u.v/|u||v|,计算夹角的余弦值\nfunction vRatio(u, v) {\n // 当存在一个向量的长度为 0 时,夹角也为 0,即夹角的余弦值为 1\n return vMag(u) * vMag(v) ? (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v)) : 1;\n}\n\n// 向量角度\nfunction vAngle(u, v) {\n return (u[0] * v[1] < u[1] * v[0] ? -1 : 1) * Math.acos(vRatio(u, v));\n}\n\n// A 0:rx 1:ry 2:x-axis-rotation 3:large-arc-flag 4:sweep-flag 5: x 6: y\nexport default function getArcParams(startPoint, params) {\n let rx = params[1];\n let ry = params[2];\n const xRotation = mod(toRadian(params[3]), Math.PI * 2);\n const arcFlag = params[4];\n const sweepFlag = params[5];\n // 弧形起点坐标\n const x1 = startPoint[0];\n const y1 = startPoint[1];\n // 弧形终点坐标\n const x2 = params[6];\n const y2 = params[7];\n const xp = (Math.cos(xRotation) * (x1 - x2)) / 2.0 + (Math.sin(xRotation) * (y1 - y2)) / 2.0;\n const yp = (-1 * Math.sin(xRotation) * (x1 - x2)) / 2.0 + (Math.cos(xRotation) * (y1 - y2)) / 2.0;\n const lambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry);\n\n if (lambda > 1) {\n rx *= Math.sqrt(lambda);\n ry *= Math.sqrt(lambda);\n }\n const diff = rx * rx * (yp * yp) + ry * ry * (xp * xp);\n\n let f = diff ? Math.sqrt((rx * rx * (ry * ry) - diff) / diff) : 1;\n\n if (arcFlag === sweepFlag) {\n f *= -1;\n }\n if (isNaN(f)) {\n f = 0;\n }\n\n // 旋转前的起点坐标,且当长半轴和短半轴的长度为 0 时,坐标按 (0, 0) 处理\n const cxp = ry ? (f * rx * yp) / ry : 0;\n const cyp = rx ? (f * -ry * xp) / rx : 0;\n\n // 椭圆圆心坐标\n const cx = (x1 + x2) / 2.0 + Math.cos(xRotation) * cxp - Math.sin(xRotation) * cyp;\n const cy = (y1 + y2) / 2.0 + Math.sin(xRotation) * cxp + Math.cos(xRotation) * cyp;\n\n // 起始点的单位向量\n const u = [(xp - cxp) / rx, (yp - cyp) / ry];\n // 终止点的单位向量\n const v = [(-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry];\n // 计算起始点和圆心的连线,与 x 轴正方向的夹角\n const theta = vAngle([1, 0], u);\n\n // 计算圆弧起始点和终止点与椭圆圆心连线的夹角\n let dTheta = vAngle(u, v);\n\n if (vRatio(u, v) <= -1) {\n dTheta = Math.PI;\n }\n if (vRatio(u, v) >= 1) {\n dTheta = 0;\n }\n if (sweepFlag === 0 && dTheta > 0) {\n dTheta = dTheta - 2 * Math.PI;\n }\n if (sweepFlag === 1 && dTheta < 0) {\n dTheta = dTheta + 2 * Math.PI;\n }\n return {\n cx,\n cy,\n // 弧形的起点和终点相同时,长轴和短轴的长度按 0 处理\n rx: isSamePoint(startPoint, [x2, y2]) ? 0 : rx,\n ry: isSamePoint(startPoint, [x2, y2]) ? 0 : ry,\n startAngle: theta,\n endAngle: theta + dTheta,\n xRotation,\n arcFlag,\n sweepFlag,\n };\n}\n","import { Path } from '../shape';\n\nconst { sin, cos, atan2, PI } = Math;\n\nfunction _addDefaultArrow(shape, attrs, x1, y1, x2, y2, isStart) {\n const { stroke, lineWidth } = attrs;\n const x = x1 - x2;\n const y = y1 - y2;\n const rad = atan2(y, x);\n const arrowShape = new Path({\n type: 'path',\n canvas: shape.get('canvas'),\n isArrowShape: true,\n attrs: {\n // 默认箭头的边长为 10,夹角为 60 度\n path: `M${10 * cos(PI / 6)},${10 * sin(PI / 6)} L0,0 L${10 * cos(PI / 6)},-${10 * sin(PI / 6)}`,\n // 使用 shape stroke 值\n stroke,\n lineWidth,\n },\n });\n arrowShape.translate(x2, y2);\n arrowShape.rotateAtPoint(x2, y2, rad);\n shape.set(isStart ? 'startArrowShape' : 'endArrowShape', arrowShape);\n}\n\n/**\n * 箭头 path 的设置要求\n * 1. 箭头顶点坐标需要为 (0, 0)\n * 2. 箭头夹角的中心分割线需要与 X 轴正方向对齐\n */\nfunction _addCustomizedArrow(shape, attrs, x1, y1, x2, y2, isStart) {\n const { startArrow, endArrow, stroke, lineWidth } = attrs;\n const arrowAttrs = isStart ? startArrow : endArrow;\n const { d, fill: arrowFill, stroke: arrowStroke, lineWidth: arrowLineWidth, ...restAttrs } = arrowAttrs;\n const x = x1 - x2;\n const y = y1 - y2;\n const rad = atan2(y, x);\n\n if (d) {\n x2 = x2 - cos(rad) * d;\n y2 = y2 - sin(rad) * d;\n }\n\n const arrowShape = new Path({\n type: 'path',\n canvas: shape.get('canvas'),\n isArrowShape: true,\n attrs: {\n ...restAttrs,\n // 支持单独设置箭头的 stroke 和 lineWidth,若为空则使用 shape 的值\n stroke: arrowStroke || stroke,\n lineWidth: arrowLineWidth || lineWidth,\n // 箭头是否填充需要手动设置,不会继承自 shape 的值\n fill: arrowFill,\n },\n });\n\n arrowShape.translate(x2, y2);\n arrowShape.rotateAtPoint(x2, y2, rad);\n shape.set(isStart ? 'startArrowShape' : 'endArrowShape', arrowShape);\n}\n\n/**\n * 如果自定义箭头并且有 d 需要做偏移,如果直接画,线条会超出箭头尖端,因此需要根据箭头偏移 d, 返回线需要缩短的距离\n * |----------------\n * |<|--------------\n * |\n * @param {number} x1 起始点 x\n * @param {number} y1 起始点 y\n * @param {number} x2 箭头作用点 x\n * @param {number} y2 箭头作用点 y\n * @param {number} d 箭头沿线条方向的偏移距离\n * @return {{dx: number, dy: number}} 返回线条偏移距离\n */\nexport function getShortenOffset(x1, y1, x2, y2, d) {\n const rad = atan2(y2 - y1, x2 - x1);\n return {\n dx: cos(rad) * d,\n dy: sin(rad) * d,\n };\n}\n\n/**\n * 绘制起始箭头\n * @param {IShape} shape 图形\n * @param {ShapeAttrs} attrs shape 的绘图属性\n * @param {number} x1 起始点 x\n * @param {number} y1 起始点 y\n * @param {number} x2 箭头作用点 x\n * @param {number} y2 箭头作用点 y\n */\nexport function addStartArrow(shape, attrs, x1, y1, x2, y2) {\n if (typeof attrs.startArrow === 'object') {\n _addCustomizedArrow(shape, attrs, x1, y1, x2, y2, true);\n } else if (attrs.startArrow) {\n _addDefaultArrow(shape, attrs, x1, y1, x2, y2, true);\n } else {\n shape.set('startArrowShape', null);\n }\n}\n\n/**\n * 绘制结束箭头\n * @param {IShape} shape 图形\n * @param {ShapeAttrs} attrs shape 的绘图属性\n * @param {number} x1 起始点 x\n * @param {number} y1 起始点 y\n * @param {number} x2 箭头作用点 x\n * @param {number} y2 箭头作用点 y\n */\nexport function addEndArrow(shape, attrs, x1, y1, x2, y2) {\n if (typeof attrs.endArrow === 'object') {\n _addCustomizedArrow(shape, attrs, x1, y1, x2, y2, false);\n } else if (attrs.endArrow) {\n _addDefaultArrow(shape, attrs, x1, y1, x2, y2, false);\n } else {\n shape.set('startArrowShape', null);\n }\n}\n","import { each, isArray, max, min } from '@antv/util';\nimport { IElement } from '../interfaces';\nimport { Region } from '../types';\nimport { parseStyle } from './parse';\nimport getArcParams from './arc-params';\nimport { mergeRegion, intersectRect } from './util';\nimport * as ArrowUtil from '../util/arrow';\n\nconst SHAPE_ATTRS_MAP = {\n fill: 'fillStyle',\n stroke: 'strokeStyle',\n opacity: 'globalAlpha',\n};\n\nexport function applyAttrsToContext(context: CanvasRenderingContext2D, element: IElement) {\n const attrs = element.attr();\n for (const k in attrs) {\n let v = attrs[k];\n // 转换一下不与 canvas 兼容的属性名\n const name = SHAPE_ATTRS_MAP[k] ? SHAPE_ATTRS_MAP[k] : k;\n if (name === 'matrix' && v) {\n // 设置矩阵\n context.transform(v[0], v[1], v[3], v[4], v[6], v[7]);\n } else if (name === 'lineDash' && context.setLineDash) {\n // 设置虚线,只支持数组形式,非数组形式不做任何操作\n isArray(v) && context.setLineDash(v);\n } else {\n if (name === 'strokeStyle' || name === 'fillStyle') {\n // 如果存在渐变、pattern 这个开销有些大\n // 可以考虑缓存机制,通过 hasUpdate 来避免一些运算\n v = parseStyle(context, element, v);\n } else if (name === 'globalAlpha') {\n // opacity 效果可以叠加,子元素的 opacity 需要与父元素 opacity 相乘\n v = v * context.globalAlpha;\n }\n context[name] = v;\n }\n }\n}\n\nexport function drawChildren(context: CanvasRenderingContext2D, children: IElement[], region?: Region) {\n for (let i = 0; i < children.length; i++) {\n const child = children[i] as IElement;\n if (child.cfg.visible) {\n child.draw(context, region);\n } else {\n child.skipDraw();\n }\n }\n}\n\n// 这个地方的逻辑比较复杂,简单画了一张图:https://www.yuque.com/antv/ou292n/pcgt5g#OW1QE\nexport function checkRefresh(canvas, children: IElement[], region: Region) {\n const refreshElements = canvas.get('refreshElements');\n // 先遍历需要刷新的元素,将这些元素的父元素也设置 refresh\n each(refreshElements, (el) => {\n if (el !== canvas) {\n let parent = el.cfg.parent;\n while (parent && parent !== canvas && !parent.cfg.refresh) {\n parent.cfg.refresh = true;\n parent = parent.cfg.parent;\n }\n }\n });\n if (refreshElements[0] === canvas) {\n setChildrenRefresh(children, region);\n } else {\n // 检查所有子元素是否可以刷新\n checkChildrenRefresh(children, region);\n }\n}\n// 检查所有的子元素是否应该更新\nexport function checkChildrenRefresh(children: IElement[], region: Region) {\n for (let i = 0; i < children.length; i++) {\n const child = children[i] as IElement;\n if (child.cfg.visible) {\n // 先判断 hasChanged,因为它的优先级判断应该高于 refresh\n if (child.cfg.hasChanged) {\n // 如果节点发生了 change,则需要级联设置子元素的 refresh\n child.cfg.refresh = true;\n if (child.isGroup()) {\n setChildrenRefresh(child.cfg.children, region);\n }\n } else if (child.cfg.refresh) {\n // 如果当前图形/分组 refresh = true,说明其子节点存在 changed\n if (child.isGroup()) {\n checkChildrenRefresh(child.cfg.children, region);\n }\n } else {\n // 这个分支说明此次局部刷新,所有的节点和父元素没有发生变化,仅需要检查包围盒(缓存)是否相交即可\n const refresh = checkElementRefresh(child, region);\n child.cfg.refresh = refresh;\n if (refresh && child.isGroup()) {\n // 如果需要刷新,说明子元素也需要刷新,继续进行判定\n checkChildrenRefresh(child.cfg.children, region);\n }\n }\n }\n }\n}\n\n// 由于对改变的图形放入 refreshElements 时做了优化,判定父元素 changed 时不加入\n// 那么有可能会出现 elements 都为空,所以最终 group\nexport function clearChanged(elements: IElement[]) {\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n el.cfg.hasChanged = false;\n // 级联清理\n if (el.isGroup() && !el.destroyed) {\n clearChanged(el.cfg.children);\n }\n }\n}\n\n// 当某个父元素发生改变时,调用这个方法级联设置 refresh\nfunction setChildrenRefresh(children: IElement[], region: Region) {\n for (let i = 0; i < children.length; i++) {\n const child = children[i] as IElement;\n if (!child.cfg.visible) {\n continue;\n }\n // let refresh = true;\n // 获取缓存的 bbox,如果这个 bbox 还存在则说明父元素不是矩阵发生了改变\n // const bbox = child.cfg.canvasBBox;\n // if (bbox) {\n // // 如果这时候\n // refresh = intersectRect(bbox, region);\n // }\n child.cfg.refresh = true;\n // 如果需要刷新当前节点,所有的子元素设置 refresh\n if (child.isGroup()) {\n setChildrenRefresh(child.get('children'), region);\n }\n }\n}\n\nfunction checkElementRefresh(shape: IElement, region: Region): boolean {\n const bbox = shape.cfg.cacheCanvasBBox;\n const isAllow = shape.cfg.isInView && bbox && intersectRect(bbox, region);\n return isAllow;\n}\n\n// 绘制 path\nexport function drawPath(shape, context, attrs, arcParamsCache) {\n const { path, startArrow, endArrow } = attrs;\n if (!path) {\n return;\n }\n let currentPoint = [0, 0]; // 当前图形\n let startMovePoint = [0, 0]; // 开始 M 的点,可能会有多个\n let distance = {\n dx: 0,\n dy: 0,\n };\n context.beginPath();\n for (let i = 0; i < path.length; i++) {\n const params = path[i];\n const command = params[0];\n if (i === 0 && startArrow && startArrow.d) {\n const tangent = shape.getStartTangent();\n distance = ArrowUtil.getShortenOffset(tangent[0][0], tangent[0][1], tangent[1][0], tangent[1][1], startArrow.d);\n } else if (i === path.length - 2 && path[i + 1][0] === 'Z' && endArrow && endArrow.d) {\n // 为了防止结尾为 Z 的 segment 缩短不起效,需要取最后两个 segment 特殊处理\n const lastPath = path[i + 1];\n if (lastPath[0] === 'Z') {\n const tangent = shape.getEndTangent();\n distance = ArrowUtil.getShortenOffset(tangent[0][0], tangent[0][1], tangent[1][0], tangent[1][1], endArrow.d);\n }\n } else if (i === path.length - 1 && endArrow && endArrow.d) {\n if (path[0] !== 'Z') {\n const tangent = shape.getEndTangent();\n distance = ArrowUtil.getShortenOffset(tangent[0][0], tangent[0][1], tangent[1][0], tangent[1][1], endArrow.d);\n }\n }\n\n const { dx, dy } = distance;\n // V,H,S,T 都在前面被转换成标准形式\n switch (command) {\n case 'M':\n context.moveTo(params[1] - dx, params[2] - dy);\n startMovePoint = [params[1], params[2]];\n break;\n case 'L':\n context.lineTo(params[1] - dx, params[2] - dy);\n break;\n case 'Q':\n context.quadraticCurveTo(params[1], params[2], params[3] - dx, params[4] - dy);\n break;\n case 'C':\n context.bezierCurveTo(params[1], params[2], params[3], params[4], params[5] - dx, params[6] - dy);\n break;\n case 'A': {\n let arcParams;\n // 为了加速绘制,可以提供参数的缓存,各个图形自己缓存\n if (arcParamsCache) {\n arcParams = arcParamsCache[i];\n if (!arcParams) {\n arcParams = getArcParams(currentPoint, params);\n arcParamsCache[i] = arcParams;\n }\n } else {\n arcParams = getArcParams(currentPoint, params);\n }\n const { cx, cy, rx, ry, startAngle, endAngle, xRotation, sweepFlag } = arcParams;\n // 直接使用椭圆的 api\n if (context.ellipse) {\n context.ellipse(cx, cy, rx, ry, xRotation, startAngle, endAngle, 1 - sweepFlag);\n } else {\n const r = rx > ry ? rx : ry;\n const scaleX = rx > ry ? 1 : rx / ry;\n const scaleY = rx > ry ? ry / rx : 1;\n context.translate(cx, cy);\n context.rotate(xRotation);\n context.scale(scaleX, scaleY);\n context.arc(0, 0, r, startAngle, endAngle, 1 - sweepFlag);\n context.scale(1 / scaleX, 1 / scaleY);\n context.rotate(-xRotation);\n context.translate(-cx, -cy);\n }\n break;\n }\n case 'Z':\n context.closePath();\n break;\n default:\n break;\n }\n\n // 有了 Z 后,当前节点从开始 M 的点开始\n if (command === 'Z') {\n currentPoint = startMovePoint;\n } else {\n const len = params.length;\n currentPoint = [params[len - 2], params[len - 1]];\n }\n }\n}\n\n// 刷新图形元素(Shape 或者 Group)\nexport function refreshElement(element, changeType) {\n const canvas = element.get('canvas');\n // 只有存在于 canvas 上时生效\n if (canvas) {\n if (changeType === 'remove') {\n // 一旦 remove,则无法在 element 上拿到包围盒\n // destroy 后所有属性都拿不到,所以需要暂存一下\n // 这是一段 hack 的代码\n element._cacheCanvasBBox = element.get('cacheCanvasBBox');\n }\n // 防止反复刷新\n if (!element.get('hasChanged')) {\n // 但是始终要标记为 hasChanged,便于后面进行局部渲染\n element.set('hasChanged', true);\n\n // 本来只有局部渲染模式下,才需要记录更新的元素队列\n // if (canvas.get('localRefresh')) {\n // canvas.refreshElement(element, changeType, canvas);\n // }\n // 但对于 https://github.com/antvis/g/issues/422 的场景,全局渲染的模式下也需要记录更新的元素队列\n // 如果当前元素的父元素发生了改变,可以不放入队列,这句话大概能够提升 15% 的初次渲染性能\n if (!(element.cfg.parent && element.cfg.parent.get('hasChanged'))) {\n canvas.refreshElement(element, changeType, canvas);\n if (canvas.get('autoDraw')) {\n canvas.draw();\n }\n }\n }\n }\n}\n\nexport function getRefreshRegion(element): Region | undefined {\n let region;\n if (!element.destroyed) {\n const cacheBox = element.get('cacheCanvasBBox');\n const validCache = cacheBox && !!(cacheBox.width && cacheBox.height);\n const bbox = element.getCanvasBBox();\n const validBBox = bbox && !!(bbox.width && bbox.height);\n // 是否是有效 bbox 判定,一些 NaN 或者 宽高为 0 的情况过滤掉\n if (validCache && validBBox) {\n region = mergeRegion(cacheBox, bbox);\n } else if (validCache) {\n region = cacheBox;\n } else if (validBBox) {\n region = bbox;\n }\n } else {\n // 因为元素已经销毁所以无法获取到缓存的包围盒\n region = element['_cacheCanvasBBox'];\n }\n return region;\n}\n\nexport function getMergedRegion(elements): Region {\n if (!elements.length) {\n return null;\n }\n const minXArr = [];\n const minYArr = [];\n const maxXArr = [];\n const maxYArr = [];\n each(elements, (el: IElement) => {\n const region = getRefreshRegion(el);\n if (region) {\n minXArr.push(region.minX);\n minYArr.push(region.minY);\n maxXArr.push(region.maxX);\n maxYArr.push(region.maxY);\n }\n });\n return {\n minX: min(minXArr),\n minY: min(minYArr),\n maxX: max(maxXArr),\n maxY: max(maxYArr),\n };\n}\n\nexport function mergeView(region, viewRegion) {\n if (!region || !viewRegion) {\n return null;\n }\n // 不相交,则直接返回 null\n if (!intersectRect(region, viewRegion)) {\n return null;\n }\n return {\n minX: Math.max(region.minX, viewRegion.minX),\n minY: Math.max(region.minY, viewRegion.minY),\n maxX: Math.min(region.maxX, viewRegion.maxX),\n maxY: Math.min(region.maxY, viewRegion.maxY),\n };\n}\n","import { AbstractGroup } from '@antv/g-base';\nimport { ChangeType } from '@antv/g-base';\nimport { IElement } from './interfaces';\nimport { Region } from './types';\nimport ShapeBase from './shape/base';\nimport * as Shape from './shape';\nimport { applyAttrsToContext, drawChildren, refreshElement } from './util/draw';\nimport { each, max, min } from '@antv/util';\nimport { intersectRect } from './util/util';\n\nclass Group extends AbstractGroup {\n /**\n * 一些方法调用会引起画布变化\n * @param {ChangeType} changeType 改变的类型\n */\n onCanvasChange(changeType: ChangeType) {\n refreshElement(this, changeType);\n }\n\n getShapeBase() {\n return Shape;\n }\n\n getGroupBase() {\n return Group;\n }\n\n // 同 shape 中的方法重复了\n _applyClip(context, clip: ShapeBase) {\n if (clip) {\n context.save();\n // 将 clip 的属性挂载到 context 上\n applyAttrsToContext(context, clip);\n // 绘制 clip 路径\n clip.createPath(context);\n context.restore();\n // 裁剪\n context.clip();\n clip._afterDraw();\n }\n }\n\n // 这个方法以前直接使用的 getCanvasBBox,由于 group 上没有缓存,所以每次重新计算,导致性能开销比较大\n // 大概能够节省全局渲染 15-20% 的性能,如果不在这里加缓存优化后 10W 个节点无法达到 5-6 ms,大概能够 30-40ms\n private cacheCanvasBBox() {\n const children = this.cfg.children;\n const xArr = [];\n const yArr = [];\n each(children, (child) => {\n const bbox = child.cfg.cacheCanvasBBox;\n // isInview 的判定是一旦图形或者分组渲染就要计算是否在视图内,\n // 这个判定 10W 个图形下差不多能够节省 5-6 ms 的开销\n if (bbox && child.cfg.isInView) {\n xArr.push(bbox.minX, bbox.maxX);\n yArr.push(bbox.minY, bbox.maxY);\n }\n });\n let bbox = null;\n if (xArr.length) {\n const minX = min(xArr);\n const maxX = max(xArr);\n const minY = min(yArr);\n const maxY = max(yArr);\n bbox = {\n minX,\n minY,\n x: minX,\n y: minY,\n maxX,\n maxY,\n width: maxX - minX,\n height: maxY - minY,\n };\n const canvas = this.cfg.canvas;\n if (canvas) {\n const viewRange = canvas.getViewRange();\n // 如果这个地方判定 isInView == false 设置 bbox 为 false 的话,拾取的性能会更高\n // 但是目前 10W 图形的拾取在 2-5ms 内,这个优化意义不大,可以后期观察再看\n this.set('isInView', intersectRect(bbox, viewRange));\n }\n } else {\n this.set('isInView', false);\n }\n\n this.set('cacheCanvasBBox', bbox);\n }\n\n draw(context: CanvasRenderingContext2D, region?: Region) {\n const children = this.cfg.children as IElement[];\n const allowDraw = region ? this.cfg.refresh : true; // 局部刷新需要判定\n // 这个地方需要判定,在 G6 的场景每个 group 都有 transform 的场景下性能会开销非常大\n // 通过 refresh 的判定,可以不刷新没有发生过变化的分组,不在视窗内的分组等等\n // 如果想进一步提升局部渲染性能,可以进一步优化 refresh 的判定,依然有潜力\n if (children.length && allowDraw) {\n context.save();\n // group 上的矩阵和属性也会应用到上下文上\n // 先将 attrs 应用到上下文中,再设置 clip。因为 clip 应该被当前元素的 matrix 所影响\n applyAttrsToContext(context, this);\n this._applyClip(context, this.getClip() as ShapeBase);\n drawChildren(context, children, region);\n context.restore();\n this.cacheCanvasBBox();\n }\n // 这里的成本比较大,如果不绘制则不再\n // this.set('cacheCanvasBBox', this.getCanvasBBox());\n this.cfg.refresh = null;\n // 绘制后,消除更新标记\n this.set('hasChanged', false);\n }\n // 绘制时被跳过,一般发生在分组隐藏时\n skipDraw() {\n this.set('cacheCanvasBBox', null);\n this.set('hasChanged', false);\n }\n}\n\nexport default Group;\n","import { AbstractShape } from '@antv/g-base';\nimport { ChangeType, BBox } from '@antv/g-base';\nimport { isNil, intersectRect } from '../util/util';\nimport { applyAttrsToContext, refreshElement } from '../util/draw';\nimport { getBBoxMethod } from '@antv/g-base';\nimport { Region } from '../types';\nimport * as Shape from './index';\nimport Group from '../group';\n\nclass ShapeBase extends AbstractShape {\n getDefaultAttrs() {\n const attrs = super.getDefaultAttrs();\n // 设置默认值\n return {\n ...attrs,\n lineWidth: 1,\n lineAppendWidth: 0,\n strokeOpacity: 1,\n fillOpacity: 1,\n };\n }\n\n getShapeBase() {\n return Shape;\n }\n\n getGroupBase() {\n return Group;\n }\n\n /**\n * 一些方法调用会引起画布变化\n * @param {ChangeType} changeType 改变的类型\n */\n onCanvasChange(changeType: ChangeType) {\n refreshElement(this, changeType);\n }\n\n calculateBBox(): BBox {\n const type = this.get('type');\n const lineWidth = this.getHitLineWidth();\n // const attrs = this.attr();\n const bboxMethod = getBBoxMethod(type);\n const box = bboxMethod(this);\n const halfLineWidth = lineWidth / 2;\n const minX = box.x - halfLineWidth;\n const minY = box.y - halfLineWidth;\n const maxX = box.x + box.width + halfLineWidth;\n const maxY = box.y + box.height + halfLineWidth;\n return {\n x: minX,\n minX,\n y: minY,\n minY,\n width: box.width + lineWidth,\n height: box.height + lineWidth,\n maxX,\n maxY,\n };\n }\n\n isFill() {\n return !!this.attrs['fill'] || this.isClipShape();\n }\n\n isStroke() {\n return !!this.attrs['stroke'];\n }\n\n // 同 shape 中的方法重复了\n _applyClip(context, clip: ShapeBase) {\n if (clip) {\n context.save();\n // 将 clip 的属性挂载到 context 上\n applyAttrsToContext(context, clip);\n // 绘制 clip 路径\n clip.createPath(context);\n context.restore();\n // 裁剪\n context.clip();\n clip._afterDraw();\n }\n }\n\n // 绘制图形时需要考虑 region 限制\n draw(context: CanvasRenderingContext2D, region?: Region) {\n const clip = this.cfg.clipShape;\n // 如果指定了 region,同时不允许刷新时,直接返回\n if (region) {\n if (this.cfg.refresh === false) {\n // this._afterDraw();\n this.set('hasChanged', false);\n return;\n }\n // 是否相交需要考虑 clip 的包围盒\n const bbox = this.getCanvasBBox();\n if (!intersectRect(region, bbox)) {\n // 图形的包围盒与重绘区域不相交时,也需要清除标记\n this.set('hasChanged', false);\n // 存在多种情形需要更新 cacheCanvasBBox 和 isInview 的判定\n // 1. 之前图形在视窗内,但是现在不再视窗内\n // 2. 如果当前的图形以及父元素都没有发生过变化,refresh = false 不会走到这里,所以这里的图形都是父元素发生变化,但是没有在视图内的元素\n if (this.cfg.isInView) {\n this._afterDraw();\n }\n return;\n }\n }\n context.save();\n // 先将 attrs 应用到上下文中,再设置 clip。因为 clip 应该被当前元素的 matrix 所影响\n applyAttrsToContext(context, this);\n this._applyClip(context, clip as ShapeBase);\n this.drawPath(context);\n context.restore();\n this._afterDraw();\n }\n\n private getCanvasViewBox() {\n const canvas = this.cfg.canvas;\n if (canvas) {\n // @ts-ignore\n return canvas.getViewRange();\n }\n return null;\n }\n\n cacheCanvasBBox() {\n const canvasBBox = this.getCanvasViewBox();\n // 绘制的时候缓存包围盒\n if (canvasBBox) {\n const bbox = this.getCanvasBBox();\n const isInView = intersectRect(bbox, canvasBBox);\n this.set('isInView', isInView);\n // 不再视窗内 cacheCanvasBBox 设置成 null,会提升局部渲染的性能,\n // 因为在局部渲染影响的包围盒计算时不考虑这个图形的包围盒\n // 父元素 cacheCanvasBBox 计算的时候也不计算\n if (isInView) {\n this.set('cacheCanvasBBox', bbox);\n } else {\n this.set('cacheCanvasBBox', null);\n }\n }\n }\n\n _afterDraw() {\n this.cacheCanvasBBox();\n // 绘制后消除标记\n this.set('hasChanged', false);\n this.set('refresh', null);\n }\n\n skipDraw() {\n this.set('cacheCanvasBBox', null);\n this.set('isInView', null);\n this.set('hasChanged', false);\n }\n\n /**\n * 绘制图形的路径\n * @param {CanvasRenderingContext2D} context 上下文\n */\n drawPath(context: CanvasRenderingContext2D) {\n this.createPath(context);\n this.strokeAndFill(context);\n this.afterDrawPath(context);\n }\n\n /**\n * @protected\n * 填充图形\n * @param {CanvasRenderingContext2D} context context 上下文\n */\n fill(context: CanvasRenderingContext2D) {\n context.fill();\n }\n\n /**\n * @protected\n * 绘制图形边框\n * @param {CanvasRenderingContext2D} context context 上下文\n */\n stroke(context: CanvasRenderingContext2D) {\n context.stroke();\n }\n\n // 绘制或者填充\n strokeAndFill(context) {\n const { lineWidth, opacity, strokeOpacity, fillOpacity } = this.attrs;\n\n if (this.isFill()) {\n if (!isNil(fillOpacity) && fillOpacity !== 1) {\n context.globalAlpha = fillOpacity;\n this.fill(context);\n context.globalAlpha = opacity;\n } else {\n this.fill(context);\n }\n }\n\n if (this.isStroke()) {\n if (lineWidth > 0) {\n if (!isNil(strokeOpacity) && strokeOpacity !== 1) {\n context.globalAlpha = strokeOpacity;\n }\n this.stroke(context);\n }\n }\n this.afterDrawPath(context);\n }\n\n /**\n * @protected\n * 绘制图形的路径\n * @param {CanvasRenderingContext2D} context 上下文\n */\n createPath(context: CanvasRenderingContext2D) {}\n\n /**\n * 绘制完成 path 后的操作\n * @param {CanvasRenderingContext2D} context 上下文\n */\n afterDrawPath(context: CanvasRenderingContext2D) {}\n\n isInShape(refX: number, refY: number): boolean {\n // return HitUtil.isHitShape(this, refX, refY);\n const isStroke = this.isStroke();\n const isFill = this.isFill();\n const lineWidth = this.getHitLineWidth();\n return this.isInStrokeOrPath(refX, refY, isStroke, isFill, lineWidth);\n }\n\n // 之所以不拆成 isInStroke 和 isInPath 在于两者存在一些共同的计算\n isInStrokeOrPath(x, y, isStroke, isFill, lineWidth) {\n return false;\n }\n\n /**\n * 获取线拾取的宽度\n * @returns {number} 线的拾取宽度\n */\n getHitLineWidth() {\n if (!this.isStroke()) {\n return 0;\n }\n const attrs = this.attrs;\n return attrs['lineWidth'] + attrs['lineAppendWidth'];\n }\n}\n\nexport default ShapeBase;\n","/**\n * @fileoverview 圆\n * @author dxq613@gmail.com\n */\n\nimport ShapeBase from './base';\nimport { distance } from '../util/util';\n\nclass Circle extends ShapeBase {\n getDefaultAttrs() {\n const attrs = super.getDefaultAttrs();\n return {\n ...attrs,\n x: 0,\n y: 0,\n r: 0,\n };\n }\n\n isInStrokeOrPath(x, y, isStroke, isFill, lineWidth) {\n const attrs = this.attr();\n const cx = attrs.x;\n const cy = attrs.y;\n const r = attrs.r;\n const halfLineWidth = lineWidth / 2;\n const absDistance = distance(cx, cy, x, y);\n // 直接用距离,如果同时存在边和填充时,可以减少两次计算\n if (isFill && isStroke) {\n return absDistance <= r + halfLineWidth;\n }\n if (isFill) {\n return absDistance <= r;\n }\n if (isStroke) {\n return absDistance >= r - halfLineWidth && absDistance <= r + halfLineWidth;\n }\n return false;\n }\n\n createPath(context) {\n const attrs = this.attr();\n const cx = attrs.x;\n const cy = attrs.y;\n const r = attrs.r;\n context.beginPath();\n context.arc(cx, cy, r, 0, Math.PI * 2, false);\n context.closePath();\n }\n}\n\nexport default Circle;\n","/**\n * @fileoverview 椭圆\n * @author dxq613@gmail.com\n */\n\nimport ShapeBase from './base';\n\n// 根据椭圆公式计算 x*x/rx*rx + y*y/ry*ry;\nfunction ellipseDistance(squareX, squareY, rx, ry) {\n return squareX / (rx * rx) + squareY / (ry * ry);\n}\n\nclass Ellipse extends ShapeBase {\n getDefaultAttrs() {\n const attrs = super.getDefaultAttrs();\n return {\n ...attrs,\n x: 0,\n y: 0,\n rx: 0,\n ry: 0,\n };\n }\n\n isInStrokeOrPath(x, y, isStroke, isFill, lineWidth) {\n const attrs = this.attr();\n const halfLineWith = lineWidth / 2;\n const cx = attrs.x;\n const cy = attrs.y;\n const { rx, ry } = attrs;\n const squareX = (x - cx) * (x - cx);\n const squareY = (y - cy) * (y - cy);\n // 使用椭圆的公式: x*x/rx*rx + y*y/ry*ry = 1;\n if (isFill && isStroke) {\n return ellipseDistance(squareX, squareY, rx + halfLineWith, ry + halfLineWith) <= 1;\n }\n if (isFill) {\n return ellipseDistance(squareX, squareY, rx, ry) <= 1;\n }\n if (isStroke) {\n return (\n ellipseDistance(squareX, squareY, rx - halfLineWith, ry - halfLineWith) >= 1 &&\n ellipseDistance(squareX, squareY, rx + halfLineWith, ry + halfLineWith) <= 1\n );\n }\n return false;\n }\n\n createPath(context) {\n const attrs = this.attr();\n const cx = attrs.x;\n const cy = attrs.y;\n const rx = attrs.rx;\n const ry = attrs.ry;\n context.beginPath();\n // 兼容逻辑\n if (context.ellipse) {\n context.ellipse(cx, cy, rx, ry, 0, 0, Math.PI * 2, false);\n } else {\n // 如果不支持,则使用圆来绘制,进行变形\n const r = rx > ry ? rx : ry;\n const scaleX = rx > ry ? 1 : rx / ry;\n const scaleY = rx > ry ? ry / rx : 1;\n context.save();\n context.translate(cx, cy);\n context.scale(scaleX, scaleY);\n context.arc(0, 0, r, 0, Math.PI * 2);\n context.restore();\n context.closePath();\n }\n }\n}\n\nexport default Ellipse;\n","/**\n * @fileoverview 图片\n * @author dxq613@gmail.com\n */\n\nimport ShapeBase from './base';\nimport { isString, isNil } from '../util/util';\nfunction isCanvas(dom) {\n return dom instanceof HTMLElement && isString(dom.nodeName) && dom.nodeName.toUpperCase() === 'CANVAS';\n}\n\nclass ImageShape extends ShapeBase {\n getDefaultAttrs() {\n const attrs = super.getDefaultAttrs();\n return {\n ...attrs,\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n };\n }\n\n initAttrs(attrs) {\n this._setImage(attrs.img);\n }\n\n // image 不计算 stroke\n isStroke() {\n return false;\n }\n\n // 仅仅使用包围盒检测来进行拾取\n // 所以不需要复写 isInStrokeOrPath 的方法\n isOnlyHitBox() {\n return true;\n }\n\n _afterLoading() {\n if (this.get('toDraw') === true) {\n const canvas = this.get('canvas');\n if (canvas) {\n // 这段应该改成局部渲染\n canvas.draw();\n } else {\n // 这种方式如果发生遮挡会出现问题\n this.createPath(this.get('context'));\n }\n }\n }\n\n _setImage(img) {\n const attrs = this.attrs;\n if (isString(img)) {\n const image = new Image();\n image.onload = () => {\n // 图片未加载完,则已经被销毁\n if (this.destroyed) {\n return false;\n }\n // 缓存原始地址,可以做对比,防止重复加载图片\n // 如果考虑到在加载过程中可能替换 img 属性,则情况更加复杂\n // this.set('imgSrc', img);\n // 这里会循环调用 _setImage 方法,但不会再走这个分支\n this.attr('img', image);\n this.set('loading', false);\n this._afterLoading();\n const callback = this.get('callback');\n if (callback) {\n callback.call(this);\n }\n };\n // 设置跨域\n image.crossOrigin = 'Anonymous';\n\n image.src = img;\n // loading 过程中不绘制\n this.set('loading', true);\n } else if (img instanceof Image) {\n // 如果是一个 image 对象,则设置宽高\n if (!attrs.width) {\n attrs.width = img.width;\n }\n if (!attrs.height) {\n attrs.height = img.height;\n }\n } else if (isCanvas(img)) {\n // 如果设置了 canvas 对象\n if (!attrs.width) {\n attrs.width = Number(img.getAttribute('width'));\n }\n\n if (!attrs.height) {\n attrs.height, Number(img.getAttribute('height'));\n }\n }\n }\n\n onAttrChange(name: string, value: any, originValue: any) {\n super.onAttrChange(name, value, originValue);\n // 如果加载的已经是当前图片,则不再处理\n if (name === 'img') {\n // 可以加缓冲,&& this.get('imgSrc') !== value\n this._setImage(value);\n }\n }\n\n createPath(context: CanvasRenderingContext2D) {\n // 正在加载则不绘制\n if (this.get('loading')) {\n this.set('toDraw', true); // 加载完成后绘制\n this.set('context', context);\n return;\n }\n const attrs = this.attr();\n const { x, y, width, height, sx, sy, swidth, sheight } = attrs;\n\n const img = attrs.img;\n if (img instanceof Image || isCanvas(img)) {\n if (!isNil(sx) && !isNil(sy) && !isNil(swidth) && !isNil(sheight)) {\n context.drawImage(img, sx, sy, swidth, sheight, x, y, width, height);\n } else {\n context.drawImage(img, x, y, width, height);\n }\n }\n }\n}\n\nexport default ImageShape;\n","import { Line as LineUtil } from '@antv/g-math';\n\nexport default function inLine(x1, y1, x2, y2, lineWidth, x, y) {\n const minX = Math.min(x1, x2);\n const maxX = Math.max(x1, x2);\n const minY = Math.min(y1, y2);\n const maxY = Math.max(y1, y2);\n const halfWidth = lineWidth / 2;\n // 因为目前的方案是计算点到直线的距离,而有可能会在延长线上,所以要先判断是否在包围盒内\n // 这种方案会在水平或者竖直的情况下载线的延长线上有半 lineWidth 的误差\n if (!(x >= minX - halfWidth && x <= maxX + halfWidth && y >= minY - halfWidth && y <= maxY + halfWidth)) {\n return false;\n }\n // 因为已经计算了包围盒,所以仅需要计算到直线的距离即可,可以显著提升性能\n return LineUtil.pointToLine(x1, y1, x2, y2, x, y) <= lineWidth / 2;\n}\n","/**\n * @fileoverview 线\n * @author dxq613@gmail.com\n */\nimport { Line as LineUtil } from '@antv/g-math';\nimport ShapeBase from './base';\nimport inLine from '../util/in-stroke/line';\nimport * as ArrowUtil from '../util/arrow';\n\nclass Line extends ShapeBase {\n getDefaultAttrs() {\n const attrs = super.getDefaultAttrs();\n return {\n ...attrs,\n x1: 0,\n y1: 0,\n x2: 0,\n y2: 0,\n startArrow: false,\n endArrow: false,\n };\n }\n\n initAttrs(attrs) {\n this.setArrow();\n }\n\n // 更新属性时,检测是否更改了箭头\n onAttrChange(name: string, value: any, originValue: any) {\n super.onAttrChange(name, value, originValue);\n // 由于箭头的绘制依赖于 line 的诸多 attrs,因此这里不再对每个 attr 进行判断,attr 每次变化都会影响箭头的更新\n this.setArrow();\n }\n\n setArrow() {\n const attrs = this.attr();\n const { x1, y1, x2, y2, startArrow, endArrow } = attrs;\n if (startArrow) {\n ArrowUtil.addStartArrow(this, attrs, x2, y2, x1, y1);\n }\n if (endArrow) {\n ArrowUtil.addEndArrow(this, attrs, x1, y1, x2, y2);\n }\n }\n\n isInStrokeOrPath(x, y, isStroke, isFill, lineWidth) {\n if (!isStroke || !lineWidth) {\n return false;\n }\n const { x1, y1, x2, y2 } = this.attr();\n return inLine(x1, y1, x2, y2, lineWidth, x, y);\n }\n\n createPath(context) {\n const attrs = this.attr();\n const { x1, y1, x2, y2, startArrow, endArrow } = attrs;\n let startArrowDistance = {\n dx: 0,\n dy: 0,\n };\n let endArrowDistance = {\n dx: 0,\n dy: 0,\n };\n\n if (startArrow && startArrow.d) {\n startArrowDistance = ArrowUtil.getShortenOffset(x1, y1, x2, y2, attrs.startArrow.d);\n }\n if (endArrow && endArrow.d) {\n endArrowDistance = ArrowUtil.getShortenOffset(x1, y1, x2, y2, attrs.endArrow.d);\n }\n\n context.beginPath();\n // 如果自定义箭头,线条相应缩进\n context.moveTo(x1 + startArrowDistance.dx, y1 + startArrowDistance.dy);\n context.lineTo(x2 - endArrowDistance.dx, y2 - endArrowDistance.dy);\n }\n\n afterDrawPath(context) {\n const startArrowShape = this.get('startArrowShape');\n const endArrowShape = this.get('endArrowShape');\n if (startArrowShape) {\n startArrowShape.draw(context);\n }\n if (endArrowShape) {\n endArrowShape.draw(context);\n }\n }\n\n /**\n * Get length of line\n * @return {number} length\n */\n getTotalLength() {\n const { x1, y1, x2, y2 } = this.attr();\n return LineUtil.length(x1, y1, x2, y2);\n }\n\n /**\n * Get point according to ratio\n * @param {number} ratio\n * @return {Point} point\n */\n getPoint(ratio: number) {\n const { x1, y1, x2, y2 } = this.attr();\n return LineUtil.pointAt(x1, y1, x2, y2, ratio);\n }\n}\n\nexport default Line;\n","import { each, isArray, isString } from '@antv/util';\n\nconst regexTags = /[MLHVQTCSAZ]([^MLHVQTCSAZ]*)/ig;\nconst regexDot = /[^\\s\\,]+/ig;\n\nfunction parsePath(p: string): string[] {\n let path = p || [] as string | string[];\n if (isArray(path)) {\n return path;\n }\n\n if (isString(path)) {\n path = path.match(regexTags);\n each(path, (item, index) => {\n // @ts-ignore\n item = item.match(regexDot);\n if (item[0].length > 1) {\n const tag = item[0].charAt(0);\n // @ts-ignore\n item.splice(1, 0, item[0].substr(1));\n // @ts-ignore\n item[0] = tag;\n }\n // @ts-ignore\n each(item, function (sub, i) {\n if (!isNaN(sub)) {\n // @ts-ignore\n item[i] = +sub;\n }\n });\n // @ts-ignore\n path[index] = item;\n });\n return path;\n }\n}\n\nexport default parsePath;\n","import { isArray } from '@antv/util';\n\nconst SPACES = '\\x09\\x0a\\x0b\\x0c\\x0d\\x20\\xa0\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\u2028\\u2029';\nconst PATH_COMMAND = new RegExp('([a-z])[' + SPACES + ',]*((-?\\\\d*\\\\.?\\\\d*(?:e[\\\\-+]?\\\\d+)?[' + SPACES + ']*,?[' + SPACES + ']*)+)', 'ig');\nconst PATH_VALUES = new RegExp('(-?\\\\d*\\\\.?\\\\d*(?:e[\\\\-+]?\\\\d+)?)[' + SPACES + ']*,?[' + SPACES + ']*', 'ig');\n\n// Parses given path string into an array of arrays of path segments\nexport default function parsePathString(pathString: string) {\n if (!pathString) {\n return null;\n }\n\n if (isArray(pathString)) {\n return pathString;\n }\n const paramCounts = {\n a: 7,\n c: 6,\n o: 2,\n h: 1,\n l: 2,\n m: 2,\n r: 4,\n q: 4,\n s: 4,\n t: 2,\n v: 1,\n u: 3,\n z: 0,\n };\n const data = [];\n\n String(pathString).replace(PATH_COMMAND, function (a, b, c) {\n const params = [];\n let name = b.toLowerCase();\n c.replace(PATH_VALUES, function (a, b) {\n b && params.push(+b);\n });\n if (name === 'm' && params.length > 2) {\n data.push([ b ].concat(params.splice(0, 2)));\n name = 'l';\n b = b === 'm' ? 'l' : 'L';\n }\n if (name === 'o' && params.length === 1) {\n data.push([ b, params[0] ]);\n }\n if (name === 'r') {\n data.push([ b ].concat(params));\n } else {\n while (params.length >= paramCounts[name]) {\n data.push([ b ].concat(params.splice(0, paramCounts[name])));\n if (!paramCounts[name]) {\n break;\n }\n }\n }\n return '';\n });\n\n return data;\n}\n","import parsePathString from './parse-path-string';\nconst REGEX_MD = /[a-z]/;\n\nfunction toSymmetry(p, c) { // 点对称\n return [\n c[0] + (c[0] - p[0]),\n c[1] + (c[1] - p[1]),\n ];\n}\n\nexport default function pathToAbsolute(pathString: string) {\n const pathArray = parsePathString(pathString);\n\n if (!pathArray || !pathArray.length) {\n return [\n [ 'M', 0, 0 ],\n ];\n }\n let needProcess = false; // 如果存在小写的命令或者 V,H,T,S 则需要处理\n for (let i = 0; i < pathArray.length; i++) {\n const cmd = pathArray[i][0];\n // 如果存在相对位置的命令,则中断返回\n if (REGEX_MD.test(cmd) || [ 'V', 'H', 'T', 'S' ].indexOf(cmd) >= 0) {\n needProcess = true;\n break;\n }\n }\n // 如果不存在相对命令,则直接返回\n // 如果在业务上都写绝对路径,这种方式最快,仅做了一次检测\n if (!needProcess) {\n return pathArray;\n }\n\n const res = [];\n let x = 0;\n let y = 0;\n let mx = 0;\n let my = 0;\n let start = 0;\n let pa0;\n let dots;\n const first = pathArray[0];\n if (first[0] === 'M' || first[0] === 'm') {\n x = +first[1];\n y = +first[2];\n mx = x;\n my = y;\n start++;\n res[0] = [ 'M', x, y ];\n }\n\n for (let i = start, ii = pathArray.length; i < ii; i++) {\n const pa = pathArray[i];\n const preParams = res[i - 1]; // 取前一个已经处理后的节点,否则会出现问题\n let r = [];\n const cmd = pa[0];\n const upCmd = cmd.toUpperCase();\n if (cmd !== upCmd) {\n r[0] = upCmd;\n switch (upCmd) {\n case 'A':\n r[1] = pa[1];\n r[2] = pa[2];\n r[3] = pa[3];\n r[4] = pa[4];\n r[5] = pa[5];\n r[6] = +pa[6] + x;\n r[7] = +pa[7] + y;\n break;\n case 'V':\n r[1] = +pa[1] + y;\n break;\n case 'H':\n r[1] = +pa[1] + x;\n break;\n case 'M':\n mx = +pa[1] + x;\n my = +pa[2] + y;\n r[1] = mx;\n r[2] = my;\n break; // for lint\n default:\n for (let j = 1, jj = pa.length; j < jj; j++) {\n r[j] = +pa[j] + ((j % 2) ? x : y);\n }\n }\n } else { // 如果本来已经大写,则不处理\n r = pathArray[i];\n }\n // 需要在外面统一做,同时处理 V,H,S,T 等特殊指令\n switch (upCmd) {\n case 'Z':\n x = +mx;\n y = +my;\n break;\n case 'H':\n x = r[1];\n r = [ 'L', x, y ];\n break;\n case 'V':\n y = r[1];\n r = [ 'L', x, y ];\n break;\n case 'T':\n x = r[1];\n y = r[2];\n // 以 x, y 为中心的,上一个控制点的对称点\n // 需要假设上一个节点的命令为 Q\n const symetricT = toSymmetry([ preParams[1], preParams[2] ], [ preParams[3], preParams[4] ]);\n r = [ 'Q', symetricT[0], symetricT[1], x, y ];\n break;\n case 'S':\n x = r[r.length - 2];\n y = r[r.length - 1];\n // 以 x,y 为中心,取上一个控制点,\n // 需要假设上一个线段为 C 或者 S\n const length = preParams.length;\n const symetricS = toSymmetry(\n [ preParams[length - 4], preParams[length - 3] ],\n [ preParams[length - 2], preParams[length - 1] ]);\n r = [ 'C', symetricS[0], symetricS[1], r[1], r[2], x, y ];\n break;\n case 'M':\n mx = r[r.length - 2];\n my = r[r.length - 1];\n break; // for lint\n default:\n x = r[r.length - 2];\n y = r[r.length - 1];\n }\n res.push(r);\n }\n\n return res;\n}\n","const TAU = Math.PI * 2\n\nconst mapToEllipse = ({ x, y }: { x: number, y: number }, rx: number, ry: number, cosphi: number, sinphi: number, centerx: number, centery: number) => {\n x *= rx\n y *= ry\n\n const xp = cosphi * x - sinphi * y\n const yp = sinphi * x + cosphi * y\n\n return {\n x: xp + centerx,\n y: yp + centery\n }\n}\n\nconst approxUnitArc = (ang1: number, ang2: number) => {\n // If 90 degree circular arc, use a constant\n // as derived from http://spencermortensen.com/articles/bezier-circle\n const a = ang2 === 1.5707963267948966\n ? 0.551915024494\n : ang2 === -1.5707963267948966\n ? -0.551915024494\n : 4 / 3 * Math.tan(ang2 / 4)\n\n const x1 = Math.cos(ang1)\n const y1 = Math.sin(ang1)\n const x2 = Math.cos(ang1 + ang2)\n const y2 = Math.sin(ang1 + ang2)\n\n return [\n {\n x: x1 - y1 * a,\n y: y1 + x1 * a\n },\n {\n x: x2 + y2 * a,\n y: y2 - x2 * a\n },\n {\n x: x2,\n y: y2\n }\n ]\n}\n\nconst vectorAngle = (ux: number, uy: number, vx: number, vy: number) => {\n const sign = (ux * vy - uy * vx < 0) ? -1 : 1\n\n let dot = ux * vx + uy * vy\n\n if (dot > 1) {\n dot = 1\n }\n\n if (dot < -1) {\n dot = -1\n }\n\n return sign * Math.acos(dot)\n}\n\nconst getArcCenter = (\n px: any,\n py: any,\n cx: any,\n cy: any,\n rx: number,\n ry: number,\n largeArcFlag: number,\n sweepFlag: number,\n sinphi: number,\n cosphi: number,\n pxp: number,\n pyp: number\n) => {\n const rxsq = Math.pow(rx, 2)\n const rysq = Math.pow(ry, 2)\n const pxpsq = Math.pow(pxp, 2)\n const pypsq = Math.pow(pyp, 2)\n\n let radicant = (rxsq * rysq) - (rxsq * pypsq) - (rysq * pxpsq)\n\n if (radicant < 0) {\n radicant = 0\n }\n\n radicant /= (rxsq * pypsq) + (rysq * pxpsq)\n radicant = Math.sqrt(radicant) * (largeArcFlag === sweepFlag ? -1 : 1)\n\n const centerxp = radicant * rx / ry * pyp\n const centeryp = radicant * -ry / rx * pxp\n\n const centerx = cosphi * centerxp - sinphi * centeryp + (px + cx) / 2\n const centery = sinphi * centerxp + cosphi * centeryp + (py + cy) / 2\n\n const vx1 = (pxp - centerxp) / rx\n const vy1 = (pyp - centeryp) / ry\n const vx2 = (-pxp - centerxp) / rx\n const vy2 = (-pyp - centeryp) / ry\n\n let ang1 = vectorAngle(1, 0, vx1, vy1)\n let ang2 = vectorAngle(vx1, vy1, vx2, vy2)\n\n if (sweepFlag === 0 && ang2 > 0) {\n ang2 -= TAU\n }\n\n if (sweepFlag === 1 && ang2 < 0) {\n ang2 += TAU\n }\n\n return [ centerx, centery, ang1, ang2 ]\n}\n\nconst arcToBezier = ({\n px,\n py,\n cx,\n cy,\n rx,\n ry,\n xAxisRotation = 0,\n largeArcFlag = 0,\n sweepFlag = 0\n}) => {\n const curves = []\n\n if (rx === 0 || ry === 0) {\n return [{ x1: 0, y1: 0, x2: 0, y2: 0, x: cx, y: cy }];\n }\n\n const sinphi = Math.sin(xAxisRotation * TAU / 360)\n const cosphi = Math.cos(xAxisRotation * TAU / 360)\n\n const pxp = cosphi * (px - cx) / 2 + sinphi * (py - cy) / 2\n const pyp = -sinphi * (px - cx) / 2 + cosphi * (py - cy) / 2\n\n if (pxp === 0 && pyp === 0) {\n return [{ x1: 0, y1: 0, x2: 0, y2: 0, x: cx, y: cy }];\n }\n\n rx = Math.abs(rx)\n ry = Math.abs(ry)\n\n const lambda =\n Math.pow(pxp, 2) / Math.pow(rx, 2) +\n Math.pow(pyp, 2) / Math.pow(ry, 2)\n\n if (lambda > 1) {\n rx *= Math.sqrt(lambda)\n ry *= Math.sqrt(lambda)\n }\n\n let [ centerx, centery, ang1, ang2 ] = getArcCenter(\n px,\n py,\n cx,\n cy,\n rx,\n ry,\n largeArcFlag,\n sweepFlag,\n sinphi,\n cosphi,\n pxp,\n pyp\n )\n\n // If 'ang2' == 90.0000000001, then `ratio` will evaluate to\n // 1.0000000001. This causes `segments` to be greater than one, which is an\n // unecessary split, and adds extra points to the bezier curve. To alleviate\n // this issue, we round to 1.0 when the ratio is close to 1.0.\n let ratio = Math.abs(ang2) / (TAU / 4)\n if (Math.abs(1.0 - ratio) < 0.0000001) {\n ratio = 1.0\n }\n\n const segments = Math.max(Math.ceil(ratio), 1)\n\n ang2 /= segments\n\n for (let i = 0; i < segments; i++) {\n curves.push(approxUnitArc(ang1, ang2))\n ang1 += ang2\n }\n\n return curves.map(curve => {\n const { x: x1, y: y1 } = mapToEllipse(curve[ 0 ], rx, ry, cosphi, sinphi, centerx, centery)\n const { x: x2, y: y2 } = mapToEllipse(curve[ 1 ], rx, ry, cosphi, sinphi, centerx, centery)\n const { x, y } = mapToEllipse(curve[ 2 ], rx, ry, cosphi, sinphi, centerx, centery)\n\n return { x1, y1, x2, y2, x, y }\n })\n}\n\nexport function arcToCubic(x1: number, y1: number, rx: number, ry: number, angle: number, LAF: number, SF: number, x2: number, y2: number) {\n const curves = arcToBezier({\n px: x1,\n py: y1,\n cx: x2,\n cy: y2,\n rx,\n ry,\n xAxisRotation: angle,\n largeArcFlag: LAF,\n sweepFlag: SF,\n });\n\n return curves.reduce((prev, cur) => {\n const { x1, y1, x2, y2, x, y } = cur;\n prev.push(x1, y1, x2, y2, x, y);\n return prev;\n }, [] as number[]);\n}\n","import { mod, toRadian } from '@antv/util';\n\n// 向量长度\nfunction vMag(v) {\n return Math.sqrt(v[0] * v[0] + v[1] * v[1]);\n}\n\n// u.v/|u||v|,计算夹角的余弦值\nfunction vRatio(u, v) {\n // 当存在一个向量的长度为 0 时,夹角也为 0,即夹角的余弦值为 1\n return vMag(u) * vMag(v) ? (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v)) : 1;\n}\n\n// 向量角度\nfunction vAngle(u, v) {\n return (u[0] * v[1] < u[1] * v[0] ? -1 : 1) * Math.acos(vRatio(u, v));\n}\n\n/**\n * 判断两个点是否重合,点坐标的格式为 [x, y]\n * @param {Array} point1 第一个点\n * @param {Array} point2 第二个点\n */\nexport function isSamePoint(point1, point2) {\n return point1[0] === point2[0] && point1[1] === point2[1];\n}\n\n// A 0:rx 1:ry 2:x-axis-rotation 3:large-arc-flag 4:sweep-flag 5: x 6: y\nexport default function getArcParams(startPoint, params) {\n let rx = params[1];\n let ry = params[2];\n const xRotation = mod(toRadian(params[3]), Math.PI * 2);\n const arcFlag = params[4];\n const sweepFlag = params[5];\n // 弧形起点坐标\n const x1 = startPoint[0];\n const y1 = startPoint[1];\n // 弧形终点坐标\n const x2 = params[6];\n const y2 = params[7];\n const xp = (Math.cos(xRotation) * (x1 - x2)) / 2.0 + (Math.sin(xRotation) * (y1 - y2)) / 2.0;\n const yp = (-1 * Math.sin(xRotation) * (x1 - x2)) / 2.0 + (Math.cos(xRotation) * (y1 - y2)) / 2.0;\n const lambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry);\n\n if (lambda > 1) {\n rx *= Math.sqrt(lambda);\n ry *= Math.sqrt(lambda);\n }\n const diff = rx * rx * (yp * yp) + ry * ry * (xp * xp);\n\n let f = diff ? Math.sqrt((rx * rx * (ry * ry) - diff) / diff) : 1;\n\n if (arcFlag === sweepFlag) {\n f *= -1;\n }\n if (isNaN(f)) {\n f = 0;\n }\n\n // 旋转前的起点坐标,且当长半轴和短半轴的长度为 0 时,坐标按 (0, 0) 处理\n const cxp = ry ? (f * rx * yp) / ry : 0;\n const cyp = rx ? (f * -ry * xp) / rx : 0;\n\n // 椭圆圆心坐标\n const cx = (x1 + x2) / 2.0 + Math.cos(xRotation) * cxp - Math.sin(xRotation) * cyp;\n const cy = (y1 + y2) / 2.0 + Math.sin(xRotation) * cxp + Math.cos(xRotation) * cyp;\n\n // 起始点的单位向量\n const u = [ (xp - cxp) / rx, (yp - cyp) / ry ];\n // 终止点的单位向量\n const v = [ (-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry ];\n // 计算起始点和圆心的连线,与 x 轴正方向的夹角\n const theta = vAngle([ 1, 0 ], u);\n\n // 计算圆弧起始点和终止点与椭圆圆心连线的夹角\n let dTheta = vAngle(u, v);\n\n if (vRatio(u, v) <= -1) {\n dTheta = Math.PI;\n }\n if (vRatio(u, v) >= 1) {\n dTheta = 0;\n }\n if (sweepFlag === 0 && dTheta > 0) {\n dTheta = dTheta - 2 * Math.PI;\n }\n if (sweepFlag === 1 && dTheta < 0) {\n dTheta = dTheta + 2 * Math.PI;\n }\n return {\n cx,\n cy,\n // 弧形的起点和终点相同时,长轴和短轴的长度按 0 处理\n rx: isSamePoint(startPoint, [ x2, y2 ]) ? 0 : rx,\n ry: isSamePoint(startPoint, [ x2, y2 ]) ? 0 : ry,\n startAngle: theta,\n endAngle: theta + dTheta,\n xRotation,\n arcFlag,\n sweepFlag,\n };\n}\n","import getArcParams from './get-arc-params';\nimport { isSamePoint } from './get-arc-params';\nimport parsePath from './parse-path';\n\n// 点对称\nfunction toSymmetry(point, center) {\n return [ center[0] + (center[0] - point[0]), center[1] + (center[1] - point[1]) ];\n}\n\nexport default function getSegments(path) {\n path = parsePath(path);\n const segments = [];\n let currentPoint = null; // 当前图形\n let nextParams = null; // 下一节点的 path 参数\n let startMovePoint = null; // 开始 M 的点,可能会有多个\n let lastStartMovePointIndex = 0; // 最近一个开始点 M 的索引\n const count = path.length;\n for (let i = 0; i < count; i++) {\n const params = path[i];\n nextParams = path[i + 1];\n const command = params[0];\n // 数学定义上的参数,便于后面的计算\n const segment = {\n command,\n prePoint: currentPoint,\n params,\n startTangent: null,\n endTangent: null,\n };\n switch (command) {\n case 'M':\n startMovePoint = [ params[1], params[2] ];\n lastStartMovePointIndex = i;\n break;\n case 'A':\n const arcParams = getArcParams(currentPoint, params);\n segment['arcParams'] = arcParams;\n break;\n default:\n break;\n }\n if (command === 'Z') {\n // 有了 Z 后,当前节点从开始 M 的点开始\n currentPoint = startMovePoint;\n // 如果当前点的命令为 Z,相当于当前点为最近一个 M 点,则下一个点直接指向最近一个 M 点的下一个点\n nextParams = path[lastStartMovePointIndex + 1];\n } else {\n const len = params.length;\n currentPoint = [ params[len - 2], params[len - 1] ];\n }\n if (nextParams && nextParams[0] === 'Z') {\n // 如果下一个点的命令为 Z,则下一个点直接指向最近一个 M 点\n nextParams = path[lastStartMovePointIndex];\n if (segments[lastStartMovePointIndex]) {\n // 如果下一个点的命令为 Z,则最近一个 M 点的前一个点为当前点\n segments[lastStartMovePointIndex].prePoint = currentPoint;\n }\n }\n segment['currentPoint'] = currentPoint;\n // 如果当前点与最近一个 M 点相同,则最近一个 M 点的前一个点为当前点的前一个点\n if (\n segments[lastStartMovePointIndex] &&\n isSamePoint(currentPoint, segments[lastStartMovePointIndex].currentPoint)\n ) {\n segments[lastStartMovePointIndex].prePoint = segment.prePoint;\n }\n const nextPoint = nextParams ? [ nextParams[nextParams.length - 2], nextParams[nextParams.length - 1] ] : null;\n segment['nextPoint'] = nextPoint;\n // Add startTangent and endTangent\n const { prePoint } = segment;\n if ([ 'L', 'H', 'V' ].includes(command)) {\n segment.startTangent = [ prePoint[0] - currentPoint[0], prePoint[1] - currentPoint[1] ];\n segment.endTangent = [ currentPoint[0] - prePoint[0], currentPoint[1] - prePoint[1] ];\n } else if (command === 'Q') {\n // 二次贝塞尔曲线只有一个控制点\n const cp = [ params[1], params[2] ];\n // 二次贝塞尔曲线的终点为 currentPoint\n segment.startTangent = [ prePoint[0] - cp[0], prePoint[1] - cp[1] ];\n segment.endTangent = [ currentPoint[0] - cp[0], currentPoint[1] - cp[1] ];\n } else if (command === 'T') {\n const preSegment = segments[i - 1];\n const cp = toSymmetry(preSegment.currentPoint, prePoint);\n if (preSegment.command === 'Q') {\n segment.command = 'Q';\n segment.startTangent = [ prePoint[0] - cp[0], prePoint[1] - cp[1] ];\n segment.endTangent = [ currentPoint[0] - cp[0], currentPoint[1] - cp[1] ];\n } else {\n segment.command = 'TL';\n segment.startTangent = [ prePoint[0] - currentPoint[0], prePoint[1] - currentPoint[1] ];\n segment.endTangent = [ currentPoint[0] - prePoint[0], currentPoint[1] - prePoint[1] ];\n }\n } else if (command === 'C') {\n // 三次贝塞尔曲线有两个控制点\n const cp1 = [ params[1], params[2] ];\n const cp2 = [ params[3], params[4] ];\n segment.startTangent = [ prePoint[0] - cp1[0], prePoint[1] - cp1[1] ];\n segment.endTangent = [ currentPoint[0] - cp2[0], currentPoint[1] - cp2[1] ];\n\n // horizontal line, eg. ['C', 100, 100, 100, 100, 200, 200]\n if (segment.startTangent[0] === 0 && segment.startTangent[1] === 0) {\n segment.startTangent = [cp1[0] - cp2[0], cp1[1] - cp2[1]];\n }\n if (segment.endTangent[0] === 0 && segment.endTangent[1] === 0) {\n segment.endTangent = [cp2[0] - cp1[0], cp2[1] - cp1[1]];\n }\n } else if (command === 'S') {\n const preSegment = segments[i - 1];\n const cp1 = toSymmetry(preSegment.currentPoint, prePoint);\n const cp2 = [ params[1], params[2] ];\n if (preSegment.command === 'C') {\n segment.command = 'C'; // 将 S 命令变换为 C 命令\n segment.startTangent = [ prePoint[0] - cp1[0], prePoint[1] - cp1[1] ];\n segment.endTangent = [ currentPoint[0] - cp2[0], currentPoint[1] - cp2[1] ];\n } else {\n segment.command = 'SQ'; // 将 S 命令变换为 SQ 命令\n segment.startTangent = [ prePoint[0] - cp2[0], prePoint[1] - cp2[1] ];\n segment.endTangent = [ currentPoint[0] - cp2[0], currentPoint[1] - cp2[1] ];\n }\n } else if (command === 'A') {\n let d = 0.001;\n const {\n cx = 0,\n cy = 0,\n rx = 0,\n ry = 0,\n sweepFlag = 0,\n startAngle = 0,\n endAngle = 0,\n } = segment['arcParams'] || {};\n if (sweepFlag === 0) {\n d *= -1;\n }\n const dx1 = rx * Math.cos(startAngle - d) + cx;\n const dy1 = ry * Math.sin(startAngle - d) + cy;\n segment.startTangent = [ dx1 - startMovePoint[0], dy1 - startMovePoint[1] ];\n const dx2 = rx * Math.cos(startAngle + endAngle + d) + cx;\n const dy2 = ry * Math.sin(startAngle + endAngle - d) + cy;\n segment.endTangent = [ prePoint[0] - dx2, prePoint[1] - dy2 ];\n }\n segments.push(segment);\n }\n return segments;\n}\n","/**\n * @fileoverview Marker\n * @author dxq613@gmail.com\n */\n\nimport { isNil } from '@antv/util';\nimport { path2Absolute } from '@antv/path-util';\nimport ShapeBase from './base';\nimport { isFunction } from '../util/util';\nimport { drawPath } from '../util/draw';\n\nconst Symbols = {\n // 圆\n circle(x, y, r) {\n return [\n ['M', x - r, y],\n ['A', r, r, 0, 1, 0, x + r, y],\n ['A', r, r, 0, 1, 0, x - r, y],\n ];\n },\n // 正方形\n square(x, y, r) {\n return [['M', x - r, y - r], ['L', x + r, y - r], ['L', x + r, y + r], ['L', x - r, y + r], ['Z']];\n },\n // 菱形\n diamond(x, y, r) {\n return [['M', x - r, y], ['L', x, y - r], ['L', x + r, y], ['L', x, y + r], ['Z']];\n },\n // 三角形\n triangle(x, y, r) {\n const diffY = r * Math.sin((1 / 3) * Math.PI);\n return [['M', x - r, y + diffY], ['L', x, y - diffY], ['L', x + r, y + diffY], ['Z']];\n },\n // 倒三角形\n 'triangle-down'(x, y, r) {\n const diffY = r * Math.sin((1 / 3) * Math.PI);\n return [['M', x - r, y - diffY], ['L', x + r, y - diffY], ['L', x, y + diffY], ['Z']];\n },\n};\n\nclass Marker extends ShapeBase {\n initAttrs(attrs) {\n this._resetParamsCache();\n }\n\n // 重置绘制 path 存储的缓存\n _resetParamsCache() {\n // 为了加速 path 的绘制、拾取和计算,这个地方可以缓存很多东西\n // 这些缓存都是第一次需要时计算和存储,虽然增加了复杂度,但是频繁调用的方法,性能有很大提升\n this.set('paramsCache', {}); // 清理缓存\n }\n\n // 更新属性时,检测是否更改了 path\n onAttrChange(name: string, value: any, originValue: any) {\n super.onAttrChange(name, value, originValue);\n if (['symbol', 'x', 'y', 'r', 'radius'].indexOf(name) !== -1) {\n // path 相关属性更改时,清理缓存\n this._resetParamsCache();\n }\n }\n\n // 仅仅使用包围盒检测来进行拾取\n // 所以不需要复写 isInStrokeOrPath 的方法\n isOnlyHitBox() {\n return true;\n }\n\n _getR(attrs) {\n // 兼容 r 和 radius 两种写法,推荐使用 r\n return isNil(attrs.r) ? attrs.radius : attrs.r;\n }\n\n _getPath() {\n const attrs = this.attr();\n const { x, y } = attrs;\n const symbol = attrs.symbol || 'circle';\n const r = this._getR(attrs);\n let method;\n let path;\n if (isFunction(symbol)) {\n method = symbol;\n path = method(x, y, r);\n // 将 path 转成绝对路径\n path = path2Absolute(path);\n } else {\n // 内置 symbol 的 path 都是绝对路径,直接绘制即可,不需要对 path 进行特殊处理\n method = Marker.Symbols[symbol];\n\n if (!method) {\n console.warn(`${symbol} marker is not supported.`);\n return null;\n }\n\n path = method(x, y, r);\n }\n\n return path;\n }\n\n createPath(context) {\n const path = this._getPath();\n const paramsCache = this.get('paramsCache');\n drawPath(this, context, { path }, paramsCache);\n }\n\n static Symbols = Symbols;\n}\n\nexport default Marker;\n","import { getOffScreenContext } from '@antv/g-base';\n\nexport default function isPointInPath(shape, x, y) {\n const ctx = getOffScreenContext();\n shape.createPath(ctx);\n return ctx.isPointInPath(x, y);\n}\n","/**\n * @fileoverview 判断点是否在多边形内\n * @author dxq613@gmail.com\n */\n\n// 多边形的射线检测,参考:https://blog.csdn.net/WilliamSun0122/article/details/77994526\nconst tolerance = 1e-6;\n// 三态函数,判断两个double在eps精度下的大小关系\nfunction dcmp(x) {\n if (Math.abs(x) < tolerance) {\n return 0;\n }\n\n return x < 0 ? -1 : 1;\n}\n\n// 判断点Q是否在p1和p2的线段上\nfunction onSegment(p1, p2, q) {\n if (\n (q[0] - p1[0]) * (p2[1] - p1[1]) === (p2[0] - p1[0]) * (q[1] - p1[1]) &&\n Math.min(p1[0], p2[0]) <= q[0] &&\n q[0] <= Math.max(p1[0], p2[0]) &&\n Math.min(p1[1], p2[1]) <= q[1] &&\n q[1] <= Math.max(p1[1], p2[1])\n ) {\n return true;\n }\n return false;\n}\n\n// 判断点P在多边形内-射线法\nexport default function isInPolygon(points, x, y) {\n let isHit = false;\n const n = points.length;\n if (n <= 2) {\n // svg 中点小于 3 个时,不显示,也无法被拾取\n return false;\n }\n for (let i = 0; i < n; i++) {\n const p1 = points[i];\n const p2 = points[(i + 1) % n];\n if (onSegment(p1, p2, [x, y])) {\n // 点在多边形一条边上\n return true;\n }\n // 前一个判断min(p1[1],p2[1]) 0 !== dcmp(p2[1] - y) > 0 &&\n dcmp(x - ((y - p1[1]) * (p1[0] - p2[0])) / (p1[1] - p2[1]) - p1[0]) < 0\n ) {\n isHit = !isHit;\n }\n }\n return isHit;\n}\n","import { distance } from '../util';\nexport default function arc(cx, cy, r, startAngle, endAngle, lineWidth, x, y) {\n const angle = (Math.atan2(y - cy, x - cx) + Math.PI * 2) % (Math.PI * 2); // 转换到 0 - 2 * Math.PI 之间\n if (angle < startAngle || angle > endAngle) {\n return false;\n }\n const point = {\n x: cx + r * Math.cos(angle),\n y: cy + r * Math.sin(angle),\n };\n return distance(point.x, point.y, x, y) <= lineWidth / 2;\n}\n","/**\n * @fileoverview path 的一些工具\n * @author dxq613@gmail.com\n */\nimport { PathUtil } from '@antv/g-base';\nimport { Quad as QuadUtil } from '@antv/g-math';\nimport { Cubic as CubicUtil } from '@antv/g-math';\nimport { ext } from '@antv/matrix-util';\nimport * as vec3 from 'gl-matrix/vec3';\nimport { inBox } from './util';\nimport inLine from './in-stroke/line';\nimport inArc from './in-stroke/arc';\n\nconst { transform } = ext;\n\nfunction hasArc(path) {\n let hasArc = false;\n const count = path.length;\n for (let i = 0; i < count; i++) {\n const params = path[i];\n const cmd = params[0];\n if (cmd === 'C' || cmd === 'A' || cmd === 'Q') {\n hasArc = true;\n break;\n }\n }\n return hasArc;\n}\n\nfunction isPointInStroke(segments, lineWidth, x, y, length) {\n let isHit = false;\n const halfWidth = lineWidth / 2;\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i];\n const { currentPoint, params, prePoint, box } = segment;\n // 如果在前面已经生成过包围盒,直接按照包围盒计算\n if (box && !inBox(box.x - halfWidth, box.y - halfWidth, box.width + lineWidth, box.height + lineWidth, x, y)) {\n continue;\n }\n switch (segment.command) {\n // L 和 Z 都是直线, M 不进行拾取\n case 'L':\n case 'Z':\n isHit = inLine(prePoint[0], prePoint[1], currentPoint[0], currentPoint[1], lineWidth, x, y);\n break;\n case 'Q':\n const qDistance = QuadUtil.pointDistance(\n prePoint[0],\n prePoint[1],\n params[1],\n params[2],\n params[3],\n params[4],\n x,\n y\n );\n isHit = qDistance <= lineWidth / 2;\n break;\n case 'C':\n const cDistance = CubicUtil.pointDistance(\n prePoint[0], // 上一段结束位置, 即 C 的起始点\n prePoint[1],\n params[1], // 'C' 的参数,1、2 为第一个控制点,3、4 为第二个控制点,5、6 为结束点\n params[2],\n params[3],\n params[4],\n params[5],\n params[6],\n x,\n y,\n length\n );\n isHit = cDistance <= lineWidth / 2;\n break;\n case 'A':\n // 计算点到椭圆圆弧的距离,暂时使用近似算法,后面可以改成切割法求最近距离\n const arcParams = segment.arcParams;\n const { cx, cy, rx, ry, startAngle, endAngle, xRotation } = arcParams;\n const p = [x, y, 1];\n const r = rx > ry ? rx : ry;\n const scaleX = rx > ry ? 1 : rx / ry;\n const scaleY = rx > ry ? ry / rx : 1;\n const m = transform(null, [\n ['t', -cx, -cy],\n ['r', -xRotation],\n ['s', 1 / scaleX, 1 / scaleY],\n ]);\n vec3.transformMat3(p, p, m);\n isHit = inArc(0, 0, r, startAngle, endAngle, lineWidth, p[0], p[1]);\n break;\n default:\n break;\n }\n if (isHit) {\n break;\n }\n }\n return isHit;\n}\n\n/**\n * 提取出内部的闭合多边形和非闭合的多边形,假设 path 不存在圆弧\n * @param {Array} path 路径\n * @returns {Array} 点的集合\n */\nfunction extractPolygons(path) {\n const count = path.length;\n const polygons = [];\n const polylines = [];\n let points = []; // 防止第一个命令不是 'M'\n for (let i = 0; i < count; i++) {\n const params = path[i];\n const cmd = params[0];\n if (cmd === 'M') {\n // 遇到 'M' 判定是否是新数组,新数组中没有点\n if (points.length) {\n // 如果存在点,则说明没有遇到 'Z',开始了一个新的多边形\n polylines.push(points);\n points = []; // 创建新的点\n }\n points.push([params[1], params[2]]);\n } else if (cmd === 'Z') {\n if (points.length) {\n // 存在点\n polygons.push(points);\n points = []; // 开始新的点集合\n }\n // 如果不存在点,同时 'Z',则说明是错误,不处理\n } else {\n points.push([params[1], params[2]]);\n }\n }\n // 说明 points 未放入 polygons 或者 polyline\n // 仅当只有一个 M,没有 Z 时会发生这种情况\n if (points.length > 0) {\n polylines.push(points);\n }\n return {\n polygons,\n polylines,\n };\n}\n\nexport default {\n hasArc,\n extractPolygons,\n isPointInStroke,\n ...PathUtil,\n};\n","/**\n * @fileoverview path\n * @author dxq613@gmail.com\n */\nimport { Point } from '@antv/g-base';\nimport { Cubic as CubicUtil } from '@antv/g-math';\nimport { each, isNil } from '@antv/util';\nimport ShapeBase from './base';\nimport { path2Absolute, path2Segments } from '@antv/path-util';\nimport { drawPath } from '../util/draw';\nimport isPointInPath from '../util/in-path/point-in-path';\nimport isInPolygon from '../util/in-path/polygon';\nimport PathUtil from '../util/path';\nimport * as ArrowUtil from '../util/arrow';\n\n// 是否在多个多边形内部\nfunction isInPolygons(polygons, x, y) {\n let isHit = false;\n for (let i = 0; i < polygons.length; i++) {\n const points = polygons[i];\n isHit = isInPolygon(points, x, y);\n if (isHit) {\n break;\n }\n }\n return isHit;\n}\n\nclass Path extends ShapeBase {\n getDefaultAttrs() {\n const attrs = super.getDefaultAttrs();\n return {\n ...attrs,\n startArrow: false,\n endArrow: false,\n };\n }\n\n initAttrs(attrs) {\n this._setPathArr(attrs.path);\n this.setArrow();\n }\n\n // 更新属性时,检测是否更改了 path\n onAttrChange(name: string, value: any, originValue: any) {\n super.onAttrChange(name, value, originValue);\n if (name === 'path') {\n this._setPathArr(value);\n }\n // 由于箭头的绘制依赖于 line 的诸多 attrs,因此这里不再对每个 attr 进行判断,attr 每次变化都会影响箭头的更新\n this.setArrow();\n }\n\n // 将 path 转换成绝对路径\n _setPathArr(path) {\n // 转换 path 的格式\n this.attrs.path = path2Absolute(path);\n const hasArc = PathUtil.hasArc(path);\n // 为了加速 path 的绘制、拾取和计算,这个地方可以缓存很多东西\n // 这些缓存都是第一次需要时计算和存储,虽然增加了复杂度,但是频繁调用的方法,性能有很大提升\n this.set('hasArc', hasArc);\n this.set('paramsCache', {}); // 清理缓存\n this.set('segments', null); // 延迟生成 path,在动画场景下可能不会有拾取\n this.set('curve', null);\n this.set('tCache', null);\n this.set('totalLength', null);\n }\n\n getSegments() {\n let segments = this.get('segements');\n if (!segments) {\n segments = path2Segments(this.attr('path'));\n this.set('segments', segments);\n }\n return segments;\n }\n\n setArrow() {\n const attrs = this.attr();\n const { startArrow, endArrow } = attrs;\n\n if (startArrow) {\n const tangent = this.getStartTangent();\n ArrowUtil.addStartArrow(this, attrs, tangent[0][0], tangent[0][1], tangent[1][0], tangent[1][1]);\n }\n if (endArrow) {\n const tangent = this.getEndTangent();\n ArrowUtil.addEndArrow(this, attrs, tangent[0][0], tangent[0][1], tangent[1][0], tangent[1][1]);\n }\n }\n\n isInStrokeOrPath(x, y, isStroke, isFill, lineWidth) {\n const segments = this.getSegments();\n const hasArc = this.get('hasArc');\n let isHit = false;\n if (isStroke) {\n const length = this.getTotalLength();\n isHit = PathUtil.isPointInStroke(segments, lineWidth, x, y, length);\n }\n if (!isHit && isFill) {\n if (hasArc) {\n // 存在曲线时,暂时使用 canvas 的 api 计算,后续可以进行多边形切割\n isHit = isPointInPath(this, x, y);\n } else {\n const path = this.attr('path');\n const extractResutl = PathUtil.extractPolygons(path);\n // 提取出来的多边形包含闭合的和非闭合的,在这里统一按照多边形处理\n isHit = isInPolygons(extractResutl.polygons, x, y) || isInPolygons(extractResutl.polylines, x, y);\n }\n }\n return isHit;\n }\n\n createPath(context) {\n const attrs = this.attr();\n const paramsCache = this.get('paramsCache'); // 由于计算圆弧的参数成本很大,所以要缓存\n drawPath(this, context, attrs, paramsCache);\n }\n\n afterDrawPath(context: CanvasRenderingContext2D) {\n const startArrowShape = this.get('startArrowShape');\n const endArrowShape = this.get('endArrowShape');\n if (startArrowShape) {\n startArrowShape.draw(context);\n }\n if (endArrowShape) {\n endArrowShape.draw(context);\n }\n }\n\n /**\n * Get total length of path\n * @return {number} length\n */\n getTotalLength() {\n const totalLength = this.get('totalLength');\n if (!isNil(totalLength)) {\n return totalLength;\n }\n this._calculateCurve();\n this._setTcache();\n return this.get('totalLength');\n }\n\n /**\n * Get point according to ratio\n * @param {number} ratio\n * @return {Point} point\n */\n getPoint(ratio: number): Point {\n let tCache = this.get('tCache');\n if (!tCache) {\n this._calculateCurve();\n this._setTcache();\n tCache = this.get('tCache');\n }\n\n let subt;\n let index;\n\n const curve = this.get('curve');\n if (!tCache || tCache.length === 0) {\n if (curve) {\n return {\n x: curve[0][1],\n y: curve[0][2],\n };\n }\n return null;\n }\n each(tCache, (v, i) => {\n if (ratio >= v[0] && ratio <= v[1]) {\n subt = (ratio - v[0]) / (v[1] - v[0]);\n index = i;\n }\n });\n\n const seg = curve[index];\n if (isNil(seg) || isNil(index)) {\n return null;\n }\n const l = seg.length;\n const nextSeg = curve[index + 1];\n return CubicUtil.pointAt(\n seg[l - 2],\n seg[l - 1],\n nextSeg[1],\n nextSeg[2],\n nextSeg[3],\n nextSeg[4],\n nextSeg[5],\n nextSeg[6],\n subt\n );\n }\n\n _calculateCurve() {\n const { path } = this.attr();\n this.set('curve', PathUtil.pathToCurve(path));\n }\n\n _setTcache() {\n let totalLength = 0;\n let tempLength = 0;\n // 每段 curve 对应起止点的长度比例列表,形如: [[0, 0.25], [0.25, 0.6]. [0.6, 0.9], [0.9, 1]]\n const tCache = [];\n let segmentT;\n let segmentL;\n let segmentN;\n let l;\n const curve = this.get('curve');\n\n if (!curve) {\n return;\n }\n\n each(curve, (segment, i) => {\n segmentN = curve[i + 1];\n l = segment.length;\n if (segmentN) {\n totalLength +=\n CubicUtil.length(\n segment[l - 2],\n segment[l - 1],\n segmentN[1],\n segmentN[2],\n segmentN[3],\n segmentN[4],\n segmentN[5],\n segmentN[6]\n ) || 0;\n }\n });\n this.set('totalLength', totalLength);\n\n if (totalLength === 0) {\n this.set('tCache', []);\n return;\n }\n\n each(curve, (segment, i) => {\n segmentN = curve[i + 1];\n l = segment.length;\n if (segmentN) {\n segmentT = [];\n segmentT[0] = tempLength / totalLength;\n segmentL = CubicUtil.length(\n segment[l - 2],\n segment[l - 1],\n segmentN[1],\n segmentN[2],\n segmentN[3],\n segmentN[4],\n segmentN[5],\n segmentN[6]\n );\n // 当 path 不连续时,segmentL 可能为空,为空时需要作为 0 处理\n tempLength += segmentL || 0;\n segmentT[1] = tempLength / totalLength;\n tCache.push(segmentT);\n }\n });\n this.set('tCache', tCache);\n }\n\n /**\n * Get start tangent vector\n * @return {Array}\n */\n getStartTangent(): number[][] {\n const segments = this.getSegments();\n let result;\n if (segments.length > 1) {\n const startPoint = segments[0].currentPoint;\n const endPoint = segments[1].currentPoint;\n const tangent = segments[1].startTangent;\n result = [];\n if (tangent) {\n result.push([startPoint[0] - tangent[0], startPoint[1] - tangent[1]]);\n result.push([startPoint[0], startPoint[1]]);\n } else {\n result.push([endPoint[0], endPoint[1]]);\n result.push([startPoint[0], startPoint[1]]);\n }\n }\n return result;\n }\n\n /**\n * Get end tangent vector\n * @return {Array}\n */\n getEndTangent(): number[][] {\n const segments = this.getSegments();\n const length = segments.length;\n let result;\n if (length > 1) {\n const startPoint = segments[length - 2].currentPoint;\n const endPoint = segments[length - 1].currentPoint;\n const tangent = segments[length - 1].endTangent;\n result = [];\n if (tangent) {\n result.push([endPoint[0] - tangent[0], endPoint[1] - tangent[1]]);\n result.push([endPoint[0], endPoint[1]]);\n } else {\n result.push([startPoint[0], startPoint[1]]);\n result.push([endPoint[0], endPoint[1]]);\n }\n }\n return result;\n }\n}\n\nexport default Path;\n","import inLine from './line';\n\nexport default function inPolyline(points: any[], lineWidth: number, x: number, y: number, isClose: boolean) {\n const count = points.length;\n if (count < 2) {\n return false;\n }\n for (let i = 0; i < count - 1; i++) {\n const x1 = points[i][0];\n const y1 = points[i][1];\n const x2 = points[i + 1][0];\n const y2 = points[i + 1][1];\n\n if (inLine(x1, y1, x2, y2, lineWidth, x, y)) {\n return true;\n }\n }\n\n // 如果封闭,则计算起始点和结束点的边\n if (isClose) {\n const first = points[0];\n const last = points[count - 1];\n if (inLine(first[0], first[1], last[0], last[1], lineWidth, x, y)) {\n return true;\n }\n }\n\n return false;\n}\n","/**\n * @fileoverview 多边形\n * @author dxq613@gmail.com\n */\n\nimport ShapeBase from './base';\nimport inPolyline from '../util/in-stroke/polyline';\nimport isInPolygon from '../util/in-path/polygon';\n\nclass Polygon extends ShapeBase {\n isInStrokeOrPath(x, y, isStroke, isFill, lineWidth) {\n const { points } = this.attr();\n let isHit = false;\n if (isStroke) {\n isHit = inPolyline(points, lineWidth, x, y, true);\n }\n if (!isHit && isFill) {\n isHit = isInPolygon(points, x, y); // isPointInPath(shape, x, y);\n }\n return isHit;\n }\n\n createPath(context) {\n const attrs = this.attr();\n const points = attrs.points;\n if (points.length < 2) {\n return;\n }\n context.beginPath();\n for (let i = 0; i < points.length; i++) {\n const point = points[i];\n if (i === 0) {\n context.moveTo(point[0], point[1]);\n } else {\n context.lineTo(point[0], point[1]);\n }\n }\n context.closePath();\n }\n}\n\nexport default Polygon;\n","/**\n * @fileoverview 多边形\n * @author dxq613@gmail.com\n */\nimport { Point } from '@antv/g-base';\nimport { Line as LineUtil } from '@antv/g-math';\nimport { Polyline as PolylineUtil } from '@antv/g-math';\nimport { each, isNil } from '@antv/util';\nimport ShapeBase from './base';\nimport inPolyline from '../util/in-stroke/polyline';\nimport * as ArrowUtil from '../util/arrow';\n\nclass PolyLine extends ShapeBase {\n getDefaultAttrs() {\n const attrs = super.getDefaultAttrs();\n return {\n ...attrs,\n startArrow: false,\n endArrow: false,\n };\n }\n\n initAttrs(attrs) {\n this.setArrow();\n }\n\n // 更新属性时,检测是否更改了 points\n onAttrChange(name: string, value: any, originValue: any) {\n super.onAttrChange(name, value, originValue);\n this.setArrow();\n if (['points'].indexOf(name) !== -1) {\n this._resetCache();\n }\n }\n\n _resetCache() {\n this.set('totalLength', null);\n this.set('tCache', null);\n }\n\n setArrow() {\n const attrs = this.attr();\n const { points, startArrow, endArrow } = this.attrs;\n const length = points.length;\n const x1 = points[0][0];\n const y1 = points[0][1];\n const x2 = points[length - 1][0];\n const y2 = points[length - 1][1];\n\n if (startArrow) {\n ArrowUtil.addStartArrow(this, attrs, points[1][0], points[1][1], x1, y1);\n }\n if (endArrow) {\n ArrowUtil.addEndArrow(this, attrs, points[length - 2][0], points[length - 2][1], x2, y2);\n }\n }\n\n // 不允许 fill\n isFill() {\n return false;\n }\n\n isInStrokeOrPath(x, y, isStroke, isFill, lineWidth) {\n // 没有设置 stroke 不能被拾取, 没有线宽不能被拾取\n if (!isStroke || !lineWidth) {\n return false;\n }\n const { points } = this.attr();\n return inPolyline(points, lineWidth, x, y, false);\n }\n\n // 始终填充\n isStroke() {\n return true;\n }\n\n createPath(context) {\n const { points, startArrow, endArrow } = this.attr();\n const length = points.length;\n if (points.length < 2) {\n return;\n }\n let x1 = points[0][0];\n let y1 = points[0][1];\n let x2 = points[length - 1][0];\n let y2 = points[length - 1][1];\n // 如果定义了箭头,并且是自定义箭头,线条相应缩进\n if (startArrow && startArrow.d) {\n const distance = ArrowUtil.getShortenOffset(x1, y1, points[1][0], points[1][1], startArrow.d);\n x1 += distance.dx;\n y1 += distance.dy;\n }\n if (endArrow && endArrow.d) {\n const distance = ArrowUtil.getShortenOffset(points[length - 2][0], points[length - 2][1], x2, y2, endArrow.d);\n x2 -= distance.dx;\n y2 -= distance.dy;\n }\n\n context.beginPath();\n context.moveTo(x1, y1);\n for (let i = 0; i < length - 1; i++) {\n const point = points[i];\n context.lineTo(point[0], point[1]);\n }\n context.lineTo(x2, y2);\n }\n\n afterDrawPath(context: CanvasRenderingContext2D) {\n const startArrowShape = this.get('startArrowShape');\n const endArrowShape = this.get('endArrowShape');\n if (startArrowShape) {\n startArrowShape.draw(context);\n }\n if (endArrowShape) {\n endArrowShape.draw(context);\n }\n }\n\n /**\n * Get length of polyline\n * @return {number} length\n */\n getTotalLength() {\n const { points } = this.attr();\n // get totalLength from cache\n const totalLength = this.get('totalLength');\n if (!isNil(totalLength)) {\n return totalLength;\n }\n this.set('totalLength', PolylineUtil.length(points));\n return this.get('totalLength');\n }\n\n /**\n * Get point according to ratio\n * @param {number} ratio\n * @return {Point} point\n */\n getPoint(ratio: number): Point {\n const { points } = this.attr();\n // get tCache from cache\n let tCache = this.get('tCache');\n if (!tCache) {\n this._setTcache();\n tCache = this.get('tCache');\n }\n\n let subt;\n let index;\n each(tCache, (v, i) => {\n if (ratio >= v[0] && ratio <= v[1]) {\n subt = (ratio - v[0]) / (v[1] - v[0]);\n index = i;\n }\n });\n return LineUtil.pointAt(points[index][0], points[index][1], points[index + 1][0], points[index + 1][1], subt);\n }\n\n _setTcache() {\n const { points } = this.attr();\n if (!points || points.length === 0) {\n return;\n }\n\n const totalLength = this.getTotalLength();\n if (totalLength <= 0) {\n return;\n }\n\n let tempLength = 0;\n const tCache = [];\n let segmentT;\n let segmentL;\n\n each(points, (p, i) => {\n if (points[i + 1]) {\n segmentT = [];\n segmentT[0] = tempLength / totalLength;\n segmentL = LineUtil.length(p[0], p[1], points[i + 1][0], points[i + 1][1]);\n tempLength += segmentL;\n segmentT[1] = tempLength / totalLength;\n tCache.push(segmentT);\n }\n });\n this.set('tCache', tCache);\n }\n\n /**\n * Get start tangent vector\n * @return {Array}\n */\n getStartTangent(): number[][] {\n const { points } = this.attr();\n const result = [];\n result.push([points[1][0], points[1][1]]);\n result.push([points[0][0], points[0][1]]);\n return result;\n }\n\n /**\n * Get end tangent vector\n * @return {Array}\n */\n getEndTangent(): number[][] {\n const { points } = this.attr();\n const l = points.length - 1;\n const result = [];\n result.push([points[l - 1][0], points[l - 1][1]]);\n result.push([points[l][0], points[l][1]]);\n return result;\n }\n}\n\nexport default PolyLine;\n","/**\n * @fileoverview 矩形\n * @author dxq613@gmail.com\n */\n\nimport ShapeBase from './base';\nimport { parseRadius } from '../util/parse';\nimport { inBox } from '../util/util';\nimport inRect from '../util/in-stroke/rect';\nimport inRectWithRadius from '../util/in-stroke/rect-radius';\nimport isPointInPath from '../util/in-path/point-in-path';\n\nclass Rect extends ShapeBase {\n getDefaultAttrs() {\n const attrs = super.getDefaultAttrs();\n return {\n ...attrs,\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n radius: 0,\n };\n }\n\n isInStrokeOrPath(x, y, isStroke, isFill, lineWidth) {\n const attrs = this.attr();\n const minX = attrs.x;\n const minY = attrs.y;\n const width = attrs.width;\n const height = attrs.height;\n const radius = attrs.radius;\n // 无圆角时的策略\n if (!radius) {\n const halfWidth = lineWidth / 2;\n // 同时填充和带有边框\n if (isFill && isStroke) {\n return inBox(minX - halfWidth, minY - halfWidth, width + halfWidth, height + halfWidth, x, y);\n }\n // 仅填充\n if (isFill) {\n return inBox(minX, minY, width, height, x, y);\n }\n if (isStroke) {\n return inRect(minX, minY, width, height, lineWidth, x, y);\n }\n } else {\n let isHit = false;\n if (isStroke) {\n isHit = inRectWithRadius(minX, minY, width, height, radius, lineWidth, x, y);\n }\n // 仅填充时带有圆角的矩形直接通过图形拾取\n // 以后可以改成纯数学的近似拾取,将圆弧切割成多边形\n if (!isHit && isFill) {\n isHit = isPointInPath(this, x, y);\n }\n return isHit;\n }\n }\n\n createPath(context) {\n const attrs = this.attr();\n const x = attrs.x;\n const y = attrs.y;\n const width = attrs.width;\n const height = attrs.height;\n const radius = attrs.radius;\n\n context.beginPath();\n if (radius === 0) {\n // 改成原生的rect方法\n context.rect(x, y, width, height);\n } else {\n const [r1, r2, r3, r4] = parseRadius(radius);\n context.moveTo(x + r1, y);\n context.lineTo(x + width - r2, y);\n r2 !== 0 && context.arc(x + width - r2, y + r2, r2, -Math.PI / 2, 0);\n context.lineTo(x + width, y + height - r3);\n r3 !== 0 && context.arc(x + width - r3, y + height - r3, r3, 0, Math.PI / 2);\n context.lineTo(x + r4, y + height);\n r4 !== 0 && context.arc(x + r4, y + height - r4, r4, Math.PI / 2, Math.PI);\n context.lineTo(x, y + r1);\n r1 !== 0 && context.arc(x + r1, y + r1, r1, Math.PI, Math.PI * 1.5);\n context.closePath();\n }\n }\n}\n\nexport default Rect;\n","import inLine from './line';\nimport inArc from './arc';\n\nexport default function rectWithRadius(minX, minY, width, height, radius, lineWidth, x, y) {\n const halfWidth = lineWidth / 2;\n return (\n inLine(minX + radius, minY, minX + width - radius, minY, lineWidth, x, y) ||\n inLine(minX + width, minY + radius, minX + width, minY + height - radius, lineWidth, x, y) ||\n inLine(minX + width - radius, minY + height, minX + radius, minY + height, lineWidth, x, y) ||\n inLine(minX, minY + height - radius, minX, minY + radius, lineWidth, x, y) ||\n inArc(minX + width - radius, minY + radius, radius, 1.5 * Math.PI, 2 * Math.PI, lineWidth, x, y) ||\n inArc(minX + width - radius, minY + height - radius, radius, 0, 0.5 * Math.PI, lineWidth, x, y) ||\n inArc(minX + radius, minY + height - radius, radius, 0.5 * Math.PI, Math.PI, lineWidth, x, y) ||\n inArc(minX + radius, minY + radius, radius, Math.PI, 1.5 * Math.PI, lineWidth, x, y)\n );\n}\n","import { inBox } from '../util';\n\nexport default function inRect(minX, minY, width, height, lineWidth, x, y) {\n const halfWidth = lineWidth / 2;\n // 将四个边看做矩形来检测,比边的检测算法要快\n return (\n inBox(minX - halfWidth, minY - halfWidth, width, lineWidth, x, y) || // 上边\n inBox(minX + width - halfWidth, minY - halfWidth, lineWidth, height, x, y) || // 右边\n inBox(minX + halfWidth, minY + height - halfWidth, width, lineWidth, x, y) || // 下边\n inBox(minX - halfWidth, minY + halfWidth, lineWidth, height, x, y)\n ); // 左边\n}\n","/**\n * @fileoverview 文本\n * @author dxq613@gmail.com\n */\n\nimport ShapeBase from './base';\nimport { isNil, isString, each } from '../util/util';\nimport { getTextHeight, assembleFont } from '@antv/g-base';\nclass Text extends ShapeBase {\n // 默认文本属性\n getDefaultAttrs() {\n const attrs = super.getDefaultAttrs();\n return {\n ...attrs,\n x: 0,\n y: 0,\n text: null,\n fontSize: 12,\n fontFamily: 'sans-serif',\n fontStyle: 'normal',\n fontWeight: 'normal',\n fontVariant: 'normal',\n textAlign: 'start',\n textBaseline: 'bottom',\n };\n }\n\n // 仅仅使用包围盒检测来进行拾取\n isOnlyHitBox() {\n return true;\n }\n\n // 初始化时组合 font,同时判断 text 是否换行\n initAttrs(attrs) {\n this._assembleFont();\n if (attrs.text) {\n this._setText(attrs.text);\n }\n }\n // 组装字体\n _assembleFont() {\n const attrs = this.attrs;\n attrs.font = assembleFont(attrs);\n }\n\n // 如果文本换行,则缓存数组\n _setText(text) {\n let textArr = null;\n if (isString(text) && text.indexOf('\\n') !== -1) {\n textArr = text.split('\\n');\n }\n this.set('textArr', textArr);\n }\n\n // 更新属性时,检测是否更改了 font、text\n onAttrChange(name: string, value: any, originValue: any) {\n super.onAttrChange(name, value, originValue);\n if (name.startsWith('font')) {\n this._assembleFont();\n }\n if (name === 'text') {\n this._setText(value);\n }\n }\n\n // 这个方法在 text 时没有可以做的事情,如果要支持文字背景时可以考虑\n // createPath(context) {\n\n // }\n\n // 如果文本多行,需要获取文本间距\n _getSpaceingY() {\n const attrs = this.attrs;\n const lineHeight = attrs.lineHeight;\n const fontSize = attrs.fontSize * 1;\n return lineHeight ? lineHeight - fontSize : fontSize * 0.14;\n }\n\n // 绘制文本,考虑多行的场景\n _drawTextArr(context, textArr, isFill) {\n const attrs = this.attrs;\n const textBaseline = attrs.textBaseline;\n const x = attrs.x;\n const y = attrs.y;\n const fontSize = attrs.fontSize * 1;\n const spaceingY = this._getSpaceingY();\n const height = getTextHeight(attrs.text, attrs.fontSize, attrs.lineHeight);\n let subY;\n each(textArr, (subText, index: number) => {\n subY = y + index * (spaceingY + fontSize) - height + fontSize; // bottom;\n if (textBaseline === 'middle') subY += height - fontSize - (height - fontSize) / 2;\n if (textBaseline === 'top') subY += height - fontSize;\n if (!isNil(subText)) {\n if (isFill) {\n context.fillText(subText, x, subY);\n } else {\n context.strokeText(subText, x, subY);\n }\n }\n });\n }\n\n // 绘制文本,同时考虑填充和绘制边框\n _drawText(context, isFill) {\n const attrs = this.attr();\n const x = attrs.x;\n const y = attrs.y;\n const textArr = this.get('textArr');\n if (textArr) {\n this._drawTextArr(context, textArr, isFill);\n } else {\n const text = attrs.text;\n if (!isNil(text)) {\n if (isFill) {\n context.fillText(text, x, y);\n } else {\n context.strokeText(text, x, y);\n }\n }\n }\n }\n\n // 复写绘制和填充的逻辑:对于文本,应该先绘制边框,再进行填充\n strokeAndFill(context) {\n const { lineWidth, opacity, strokeOpacity, fillOpacity } = this.attrs;\n\n if (this.isStroke()) {\n if (lineWidth > 0) {\n if (!isNil(strokeOpacity) && strokeOpacity !== 1) {\n context.globalAlpha = opacity;\n }\n this.stroke(context);\n }\n }\n\n if (this.isFill()) {\n if (!isNil(fillOpacity) && fillOpacity !== 1) {\n context.globalAlpha = fillOpacity;\n this.fill(context);\n context.globalAlpha = opacity;\n } else {\n this.fill(context);\n }\n }\n\n this.afterDrawPath(context);\n }\n\n // 复写填充逻辑\n fill(context) {\n this._drawText(context, true);\n }\n\n // 复写绘制边框的逻辑\n stroke(context) {\n this._drawText(context, false);\n }\n}\n\nexport default Text;\n","import { IContainer, IElement, IGroup, IShape, isAllowCapture, multiplyVec2, invert } from '@antv/g-base';\n\nfunction invertFromMatrix(v: number[], matrix: number[]): number[] {\n if (matrix) {\n const invertMatrix = invert(matrix);\n return multiplyVec2(invertMatrix, v);\n }\n return v;\n}\n\nfunction getRefXY(element: IElement, x: number, y: number) {\n // @ts-ignore\n const totalMatrix = element.getTotalMatrix();\n if (totalMatrix) {\n const [refX, refY] = invertFromMatrix([x, y, 1], totalMatrix);\n return [refX, refY];\n }\n return [x, y];\n}\n\n// 拾取前的检测,只有通过检测才能继续拾取\nfunction preTest(element: IElement, x: number, y: number) {\n // @ts-ignore\n if (element.isCanvas && element.isCanvas()) {\n return true;\n }\n // 不允许被拾取,则返回 null\n // @ts-ignore\n if (!isAllowCapture(element) || element.cfg.isInView === false) {\n return false;\n }\n\n if (element.cfg.clipShape) {\n // 如果存在 clip\n const [refX, refY] = getRefXY(element, x, y);\n if (element.isClipped(refX, refY)) {\n return false;\n }\n }\n // @ts-ignore ,这个地方调用过于频繁\n const bbox = element.cfg.cacheCanvasBBox || element.getCanvasBBox();\n // 如果没有缓存 bbox,则说明不可见\n // 注释掉的这段可能会加速拾取,上面的语句改写成 const bbox = element.cfg.cacheCanvasBBox;\n // 这时候的拾取假设图形/分组在上一次绘制都在视窗内,但是上面已经判定了 isInView 所以意义不大\n // 现在还调用 element.getCanvasBBox(); 一个很大的原因是便于单元测试\n // if (!bbox) {\n // return false;\n // }\n if (!(x >= bbox.minX && x <= bbox.maxX && y >= bbox.minY && y <= bbox.maxY)) {\n return false;\n }\n return true;\n}\n\n// 这个方法复写了 g-base 的 getShape\nexport function getShape(container: IContainer, x: number, y: number) {\n // 没有通过检测,则返回 null\n if (!preTest(container, x, y)) {\n return null;\n }\n let shape = null;\n const children = container.getChildren();\n const count = children.length;\n for (let i = count - 1; i >= 0; i--) {\n const child = children[i];\n if (child.isGroup()) {\n shape = getShape(child as IGroup, x, y);\n } else if (preTest(child, x, y)) {\n const curShape = child as IShape;\n const [refX, refY] = getRefXY(child, x, y);\n // @ts-ignore\n if (curShape.isInShape(refX, refY)) {\n shape = child;\n }\n }\n if (shape) {\n break;\n }\n }\n return shape;\n}\n","import { AbstractCanvas } from '@antv/g-base';\nimport { ChangeType } from '@antv/g-base';\nimport { IElement } from './interfaces';\nimport { getShape } from './util/hit';\nimport * as Shape from './shape';\nimport Group from './group';\nimport { each, getPixelRatio, requestAnimationFrame, clearAnimationFrame } from './util/util';\nimport { applyAttrsToContext, drawChildren, getMergedRegion, mergeView, checkRefresh, clearChanged } from './util/draw';\n\nclass Canvas extends AbstractCanvas {\n getDefaultCfg() {\n const cfg = super.getDefaultCfg();\n // 设置渲染引擎为 canvas,只读属性\n cfg['renderer'] = 'canvas';\n // 是否自动绘制,不需要用户调用 draw 方法\n cfg['autoDraw'] = true;\n // 是否允许局部刷新图表\n cfg['localRefresh'] = true;\n cfg['refreshElements'] = [];\n // 是否在视图内自动裁剪\n cfg['clipView'] = true;\n // 是否使用快速拾取的方案,默认为 false,上层可以打开\n cfg['quickHit'] = false;\n return cfg;\n }\n\n /**\n * 一些方法调用会引起画布变化\n * @param {ChangeType} changeType 改变的类型\n */\n onCanvasChange(changeType: ChangeType) {\n /**\n * 触发画布更新的三种 changeType\n * 1. attr: 修改画布的绘图属性\n * 2. sort: 画布排序,图形的层次会发生变化\n * 3. changeSize: 改变画布大小\n */\n if (changeType === 'attr' || changeType === 'sort' || changeType === 'changeSize') {\n this.set('refreshElements', [this]);\n this.draw();\n }\n }\n\n getShapeBase() {\n return Shape;\n }\n\n getGroupBase() {\n return Group;\n }\n /**\n * 获取屏幕像素比\n */\n getPixelRatio() {\n const pixelRatio = this.get('pixelRatio') || getPixelRatio();\n // 不足 1 的取 1,超出 1 的取整\n return pixelRatio >= 1 ? Math.ceil(pixelRatio) : 1;\n }\n\n getViewRange() {\n return {\n minX: 0,\n minY: 0,\n maxX: this.cfg.width,\n maxY: this.cfg.height,\n };\n }\n\n // 复写基类的方法生成标签\n createDom(): HTMLElement {\n const element = document.createElement('canvas');\n const context = element.getContext('2d');\n // 缓存 context 对象\n this.set('context', context);\n return element;\n }\n setDOMSize(width: number, height: number) {\n super.setDOMSize(width, height);\n const context = this.get('context');\n const el = this.get('el');\n const pixelRatio = this.getPixelRatio();\n el.width = pixelRatio * width;\n el.height = pixelRatio * height;\n // 设置 canvas 元素的宽度和高度,会重置缩放,因此 context.scale 需要在每次设置宽、高后调用\n if (pixelRatio > 1) {\n context.scale(pixelRatio, pixelRatio);\n }\n }\n // 复写基类方法\n clear() {\n super.clear();\n this._clearFrame(); // 需要清理掉延迟绘制的帧\n const context = this.get('context');\n const element = this.get('el');\n context.clearRect(0, 0, element.width, element.height);\n }\n\n getShape(x: number, y: number) {\n let shape;\n if (this.get('quickHit')) {\n shape = getShape(this, x, y);\n } else {\n shape = super.getShape(x, y, null);\n }\n return shape;\n }\n // 对绘制区域边缘取整,避免浮点数问题\n _getRefreshRegion() {\n const elements = this.get('refreshElements');\n const viewRegion = this.getViewRange();\n let region;\n // 如果是当前画布整体发生了变化,则直接重绘整个画布\n if (elements.length && elements[0] === this) {\n region = viewRegion;\n } else {\n region = getMergedRegion(elements);\n if (region) {\n region.minX = Math.floor(region.minX);\n region.minY = Math.floor(region.minY);\n region.maxX = Math.ceil(region.maxX);\n region.maxY = Math.ceil(region.maxY);\n region.maxY += 1; // 在很多环境下字体的高低会不一致,附加一像素,避免残影\n const clipView = this.get('clipView');\n // 自动裁剪不在 view 内的区域\n if (clipView) {\n region = mergeView(region, viewRegion);\n }\n }\n }\n return region;\n }\n\n /**\n * 刷新图形元素,这里仅仅是放入队列,下次绘制时进行绘制\n * @param {IElement} element 图形元素\n */\n refreshElement(element: IElement) {\n const refreshElements = this.get('refreshElements');\n refreshElements.push(element);\n // if (this.get('autoDraw')) {\n // this._startDraw();\n // }\n }\n // 清理还在进行的绘制\n _clearFrame() {\n const drawFrame = this.get('drawFrame');\n if (drawFrame) {\n // 如果全部渲染时,存在局部渲染,则抛弃掉局部渲染\n clearAnimationFrame(drawFrame);\n this.set('drawFrame', null);\n this.set('refreshElements', []);\n }\n }\n\n // 手工调用绘制接口\n draw() {\n const drawFrame = this.get('drawFrame');\n if (this.get('autoDraw') && drawFrame) {\n return;\n }\n this._startDraw();\n }\n // 绘制所有图形\n _drawAll() {\n const context = this.get('context');\n const element = this.get('el');\n const children = this.getChildren() as IElement[];\n context.clearRect(0, 0, element.width, element.height);\n applyAttrsToContext(context, this);\n drawChildren(context, children);\n // 对于 https://github.com/antvis/g/issues/422 的场景,全局渲染的模式下也会记录更新的元素队列,因此全局渲染完后也需要置空\n this.set('refreshElements', []);\n }\n // 绘制局部\n _drawRegion() {\n const context = this.get('context');\n const refreshElements = this.get('refreshElements');\n const children = this.getChildren() as IElement[];\n const region = this._getRefreshRegion();\n // 需要注意可能没有 region 的场景\n // 一般发生在设置了 localRefresh ,在没有图形发生变化的情况下,用户调用了 draw\n if (region) {\n // 清理指定区域\n context.clearRect(region.minX, region.minY, region.maxX - region.minX, region.maxY - region.minY);\n // 保存上下文,设置 clip\n context.save();\n context.beginPath();\n context.rect(region.minX, region.minY, region.maxX - region.minX, region.maxY - region.minY);\n context.clip();\n applyAttrsToContext(context, this);\n // 确认更新的元素,这个优化可以提升 10 倍左右的性能,10W 个带有 group 的节点,局部渲染会从 90ms 下降到 5-6 ms\n checkRefresh(this, children, region);\n // 绘制子元素\n drawChildren(context, children, region);\n context.restore();\n } else if (refreshElements.length) {\n // 防止发生改变的 elements 没有 region 的场景,这会发生在多个情况下\n // 1. 空的 group\n // 2. 所有 elements 没有在绘图区域\n // 3. group 下面的 elements 隐藏掉\n // 如果不进行清理 hasChanged 的状态会不正确\n clearChanged(refreshElements);\n }\n each(refreshElements, (element) => {\n if (element.get('hasChanged')) {\n // 在视窗外的 Group 元素会加入到更新队列里,但实际却没有执行 draw() 逻辑,也就没有清除 hasChanged 标记\n // 即已经重绘完、但 hasChanged 标记没有清除的元素,需要统一清除掉。主要是 Group 存在问题,具体原因待排查\n element.set('hasChanged', false);\n }\n });\n this.set('refreshElements', []);\n }\n\n // 触发绘制\n _startDraw() {\n let drawFrame = this.get('drawFrame');\n let drawFrameCallback = this.get('drawFrameCallback');\n if (!drawFrame) {\n drawFrame = requestAnimationFrame(() => {\n if (this.get('localRefresh')) {\n this._drawRegion();\n } else {\n this._drawAll();\n }\n this.set('drawFrame', null);\n if (drawFrameCallback) {\n drawFrameCallback();\n }\n });\n this.set('drawFrame', drawFrame);\n }\n }\n\n skipDraw() {}\n\n removeDom() {\n const el = this.get('el');\n // 需要清理 canvas 画布内容,否则ios下 创建的canvas垃圾未回收,导致Total canvas memory use exceeds问题\n // 相关问题列表\n // https://stackoverflow.com/questions/52532614/total-canvas-memory-use-exceeds-the-maximum-limit-safari-12\n // https://github.com/openlayers/openlayers/issues/9291\n el.width = 0;\n el.height = 0;\n el.parentNode.removeChild(el);\n }\n}\n\nexport default Canvas;\n","import * as Shape from './shape';\nexport * from '@antv/g-base';\nexport { IElement } from './interfaces';\nexport { Region } from './types';\nexport { default as Canvas } from './canvas';\nexport { default as Group } from './group';\nexport { Shape };\nexport { default as getArcParams } from './util/arc-params';\n\nexport const version = '0.5.12';\n","export const SHAPE_TO_TAGS = {\n rect: 'path',\n circle: 'circle',\n line: 'line',\n path: 'path',\n marker: 'path',\n text: 'text',\n polyline: 'polyline',\n polygon: 'polygon',\n image: 'image',\n ellipse: 'ellipse',\n dom: 'foreignObject',\n};\n\nexport const SVG_ATTR_MAP = {\n opacity: 'opacity',\n fillStyle: 'fill',\n fill: 'fill',\n fillOpacity: 'fill-opacity',\n strokeStyle: 'stroke',\n strokeOpacity: 'stroke-opacity',\n stroke: 'stroke',\n x: 'x',\n y: 'y',\n r: 'r',\n rx: 'rx',\n ry: 'ry',\n width: 'width',\n height: 'height',\n x1: 'x1',\n x2: 'x2',\n y1: 'y1',\n y2: 'y2',\n lineCap: 'stroke-linecap',\n lineJoin: 'stroke-linejoin',\n lineWidth: 'stroke-width',\n lineDash: 'stroke-dasharray',\n lineDashOffset: 'stroke-dashoffset',\n miterLimit: 'stroke-miterlimit',\n font: 'font',\n fontSize: 'font-size',\n fontStyle: 'font-style',\n fontVariant: 'font-variant',\n fontWeight: 'font-weight',\n fontFamily: 'font-family',\n startArrow: 'marker-start',\n endArrow: 'marker-end',\n path: 'd',\n class: 'class',\n id: 'id',\n style: 'style',\n preserveAspectRatio: 'preserveAspectRatio',\n};\n\nexport const EVENTS = [\n 'click',\n 'mousedown',\n 'mouseup',\n 'dblclick',\n 'contextmenu',\n 'mouseenter',\n 'mouseleave',\n 'mouseover',\n 'mouseout',\n 'mousemove',\n 'wheel',\n];\n","import { toArray } from '@antv/util';\nimport { IShape, IGroup, IElement } from '../interfaces';\nimport { SHAPE_TO_TAGS } from '../constant';\n\n/**\n * 创建并返回图形的 svg 元素\n * @param type svg类型\n */\nexport function createSVGElement(type: string): SVGElement {\n return document.createElementNS('http://www.w3.org/2000/svg', type);\n}\n\n/**\n * 创建并返回图形的 dom 元素\n * @param {IShape} shape 图形\n * @return {SVGElement}\n */\nexport function createDom(shape: IShape) {\n const type = SHAPE_TO_TAGS[shape.type];\n const parent = shape.getParent();\n if (!type) {\n throw new Error(`the type ${shape.type} is not supported by svg`);\n }\n const element = createSVGElement(type);\n if (shape.get('id')) {\n element.id = shape.get('id');\n }\n shape.set('el', element);\n shape.set('attrs', {});\n // 对于 defs 下的 dom 节点,parent 为空,通过 context 统一挂载到 defs 节点下\n if (parent) {\n let parentNode = parent.get('el');\n if (parentNode) {\n parentNode.appendChild(element);\n } else {\n // parentNode maybe null for group\n parentNode = (parent as IGroup).createDom();\n parent.set('el', parentNode);\n parentNode.appendChild(element);\n }\n }\n return element;\n}\n\n/**\n * 对 dom 元素进行排序\n * @param {IElement} element 元素\n * @param {sorter} function 排序函数\n */\nexport function sortDom(element: IElement, sorter: (a: IElement, b: IElement) => number) {\n const el = element.get('el');\n const childList = toArray(el.children).sort(sorter);\n // create empty fragment\n const fragment = document.createDocumentFragment();\n childList.forEach((child) => {\n fragment.appendChild(child);\n });\n el.appendChild(fragment);\n}\n\n/**\n * 将 dom 元素移动到父元素下的指定位置\n * @param {SVGElement} element dom 元素\n * @param {number} targetIndex 目标位置(从 0 开始)\n */\nexport function moveTo(element: SVGElement, targetIndex: number) {\n const parentNode = element.parentNode;\n const siblings = Array.from(parentNode.childNodes).filter(\n // 要求为元素节点,且不能为 defs 节点\n (node: Node) => node.nodeType === 1 && node.nodeName.toLowerCase() !== 'defs'\n );\n // 获取目标节点\n const target = siblings[targetIndex];\n const currentIndex = siblings.indexOf(element);\n // 如果目标节点存在\n if (target) {\n // 当前索引 > 目标索引,直接插入到目标节点之前即可\n if (currentIndex > targetIndex) {\n parentNode.insertBefore(element, target);\n } else if (currentIndex < targetIndex) {\n // 当前索引 < 目标索引\n // 获取目标节点的下一个节点\n const targetNext = siblings[targetIndex + 1];\n // 如果目标节点的下一个节点存在,插入到该节点之前\n if (targetNext) {\n parentNode.insertBefore(element, targetNext);\n } else {\n // 如果该节点不存在,则追加到末尾\n parentNode.appendChild(element);\n }\n }\n } else {\n parentNode.appendChild(element);\n }\n}\n","import { createDom } from './dom';\n\nexport function setShadow(model, context) {\n const el = model.cfg.el;\n const attrs = model.attr();\n const cfg = {\n dx: attrs.shadowOffsetX,\n dy: attrs.shadowOffsetY,\n blur: attrs.shadowBlur,\n color: attrs.shadowColor,\n };\n if (!cfg.dx && !cfg.dy && !cfg.blur && !cfg.color) {\n el.removeAttribute('filter');\n } else {\n let id = context.find('filter', cfg);\n if (!id) {\n id = context.addShadow(cfg);\n }\n el.setAttribute('filter', `url(#${id})`);\n }\n}\n\nexport function setTransform(model) {\n const { matrix } = model.attr();\n if (matrix) {\n const el = model.cfg.el;\n let transform: any = [];\n for (let i = 0; i < 9; i += 3) {\n transform.push(`${matrix[i]},${matrix[i + 1]}`);\n }\n transform = transform.join(',');\n if (transform.indexOf('NaN') === -1) {\n el.setAttribute('transform', `matrix(${transform})`);\n } else {\n console.warn('invalid matrix:', matrix);\n }\n }\n}\n\nexport function setClip(model, context) {\n const clip = model.getClip();\n const el = model.get('el');\n if (!clip) {\n el.removeAttribute('clip-path');\n } else if (clip && !el.hasAttribute('clip-path')) {\n createDom(clip);\n clip.createPath(context);\n const id = context.addClip(clip);\n el.setAttribute('clip-path', `url(#${id})`);\n }\n}\n","import { ChangeType } from '@antv/g-base';\nimport { IElement } from '../interfaces';\nimport { setTransform, setClip } from './svg';\nimport { sortDom, moveTo } from './dom';\nimport Defs from '../defs';\n\nexport function drawChildren(context: Defs, children: IElement[]) {\n children.forEach((child) => {\n child.draw(context);\n });\n}\n\n/**\n * 更新元素,包括 group 和 shape\n * @param {IElement} element SVG 元素\n * @param {ChangeType} changeType 更新类型\n */\nexport function refreshElement(element: IElement, changeType: ChangeType) {\n // 对于还没有挂载到画布下的元素,canvas 可能为空\n const canvas = element.get('canvas');\n // 只有挂载到画布下,才对元素进行实际渲染\n if (canvas && canvas.get('autoDraw')) {\n const context = canvas.get('context');\n const parent = element.getParent();\n const parentChildren = parent ? parent.getChildren() : [canvas];\n const el = element.get('el');\n if (changeType === 'remove') {\n const isClipShape = element.get('isClipShape');\n // 对于 clip,不仅需要将 clipShape 对于的 SVG 元素删除,还需要将上层的 clipPath 元素也删除\n if (isClipShape) {\n const clipPathEl = el && el.parentNode;\n const defsEl = clipPathEl && clipPathEl.parentNode;\n if (clipPathEl && defsEl) {\n defsEl.removeChild(clipPathEl);\n }\n } else if (el && el.parentNode) {\n el.parentNode.removeChild(el);\n }\n } else if (changeType === 'show') {\n el.setAttribute('visibility', 'visible');\n } else if (changeType === 'hide') {\n el.setAttribute('visibility', 'hidden');\n } else if (changeType === 'zIndex') {\n moveTo(el, parentChildren.indexOf(element));\n } else if (changeType === 'sort') {\n const children = element.get('children');\n if (children && children.length) {\n sortDom(element, (a: IElement, b: IElement) => {\n return children.indexOf(a) - children.indexOf(b) ? 1 : 0;\n });\n }\n } else if (changeType === 'clear') {\n // el maybe null for group\n if (el) {\n el.innerHTML = '';\n }\n } else if (changeType === 'matrix') {\n setTransform(element);\n } else if (changeType === 'clip') {\n setClip(element, context);\n } else if (changeType === 'attr') {\n // 已在 afterAttrsChange 进行了处理,此处 do nothing\n } else if (changeType === 'add') {\n element.draw(context);\n }\n }\n}\n","import { AbstractGroup } from '@antv/g-base';\nimport { ChangeType } from '@antv/g-base';\nimport { each } from '@antv/util';\nimport { IElement, IGroup } from './interfaces';\nimport * as Shape from './shape';\nimport Defs from './defs';\nimport { drawChildren, refreshElement } from './util/draw';\nimport { setClip, setTransform } from './util/svg';\nimport { SVG_ATTR_MAP } from './constant';\nimport { createSVGElement } from './util/dom';\n\nclass Group extends AbstractGroup {\n // SVG 中分组对应实体标签 \n isEntityGroup() {\n return true;\n }\n\n createDom() {\n const element = createSVGElement('g');\n this.set('el', element);\n const parent = this.getParent();\n if (parent) {\n let parentNode = parent.get('el');\n if (parentNode) {\n parentNode.appendChild(element);\n } else {\n // parentNode maybe null for group\n parentNode = (parent as IGroup).createDom();\n parent.set('el', parentNode);\n parentNode.appendChild(element);\n }\n }\n return element;\n }\n\n // 覆盖基类的 afterAttrsChange 方法\n afterAttrsChange(targetAttrs) {\n super.afterAttrsChange(targetAttrs);\n const canvas = this.get('canvas');\n // 只有挂载到画布下,才对元素进行实际渲染\n if (canvas && canvas.get('autoDraw')) {\n const context = canvas.get('context');\n this.createPath(context, targetAttrs);\n }\n }\n\n /**\n * 一些方法调用会引起画布变化\n * @param {ChangeType} changeType 改变的类型\n */\n onCanvasChange(changeType: ChangeType) {\n refreshElement(this, changeType);\n }\n\n getShapeBase() {\n return Shape;\n }\n\n getGroupBase() {\n return Group;\n }\n\n draw(context: Defs) {\n const children = this.getChildren() as IElement[];\n const el = this.get('el');\n if (this.get('destroyed')) {\n if (el) {\n el.parentNode.removeChild(el);\n }\n } else {\n if (!el) {\n this.createDom();\n }\n setClip(this, context);\n this.createPath(context);\n if (children.length) {\n drawChildren(context, children);\n }\n }\n }\n\n /**\n * 绘制分组的路径\n * @param {Defs} context 上下文\n * @param {ShapeAttrs} targetAttrs 渲染的目标属性\n */\n createPath(context: Defs, targetAttrs?) {\n const attrs = this.attr();\n const el = this.get('el');\n each(targetAttrs || attrs, (value, attr) => {\n if (SVG_ATTR_MAP[attr]) {\n el.setAttribute(SVG_ATTR_MAP[attr], value);\n }\n });\n setTransform(this);\n }\n}\n\nexport default Group;\n","import { AbstractShape } from '@antv/g-base';\nimport { ShapeAttrs, ChangeType, BBox } from '@antv/g-base';\nimport { IShape } from '../interfaces';\nimport Defs from '../defs';\nimport { setShadow, setTransform, setClip } from '../util/svg';\nimport { createDom } from '../util/dom';\nimport { refreshElement } from '../util/draw';\nimport { SVG_ATTR_MAP } from '../constant';\nimport * as Shape from './index';\nimport Group from '../group';\nimport { getBBoxMethod } from '@antv/g-base';\n\nclass ShapeBase extends AbstractShape implements IShape {\n type: string = 'svg';\n canFill: boolean = false;\n canStroke: boolean = false;\n\n getDefaultAttrs() {\n const attrs = super.getDefaultAttrs();\n // 设置默认值\n return {\n ...attrs,\n lineWidth: 1,\n lineAppendWidth: 0,\n strokeOpacity: 1,\n fillOpacity: 1,\n };\n }\n\n // 覆盖基类的 afterAttrsChange 方法\n afterAttrsChange(targetAttrs: ShapeAttrs) {\n super.afterAttrsChange(targetAttrs);\n const canvas = this.get('canvas');\n // 只有挂载到画布下,才对元素进行实际渲染\n if (canvas && canvas.get('autoDraw')) {\n const context = canvas.get('context');\n this.draw(context, targetAttrs);\n }\n }\n\n getShapeBase() {\n return Shape;\n }\n\n getGroupBase() {\n return Group;\n }\n\n /**\n * 一些方法调用会引起画布变化\n * @param {ChangeType} changeType 改变的类型\n */\n onCanvasChange(changeType: ChangeType) {\n refreshElement(this, changeType);\n }\n\n calculateBBox(): BBox {\n const el = this.get('el');\n let bbox = null;\n // 包围盒计算依赖于绘制,如果还没有生成对应的 Dom 元素,则包围盒的长宽均为 0\n if (el) {\n bbox = el.getBBox();\n } else {\n const bboxMethod = getBBoxMethod(this.get('type'));\n if (bboxMethod) {\n bbox = bboxMethod(this);\n }\n }\n if (bbox) {\n const { x, y, width, height } = bbox;\n const lineWidth = this.getHitLineWidth();\n const halfWidth = lineWidth / 2;\n const minX = x - halfWidth;\n const minY = y - halfWidth;\n const maxX = x + width + halfWidth;\n const maxY = y + height + halfWidth;\n return {\n x: minX,\n y: minY,\n minX,\n minY,\n maxX,\n maxY,\n width: width + lineWidth,\n height: height + lineWidth,\n };\n }\n return {\n x: 0,\n y: 0,\n minX: 0,\n minY: 0,\n maxX: 0,\n maxY: 0,\n width: 0,\n height: 0,\n };\n }\n\n isFill() {\n const { fill, fillStyle } = this.attr();\n return (fill || fillStyle || this.isClipShape()) && this.canFill;\n }\n\n isStroke() {\n const { stroke, strokeStyle } = this.attr();\n return (stroke || strokeStyle) && this.canStroke;\n }\n\n draw(context, targetAttrs) {\n const el = this.get('el');\n if (this.get('destroyed')) {\n if (el) {\n el.parentNode.removeChild(el);\n }\n } else {\n if (!el) {\n createDom(this);\n }\n setClip(this, context);\n this.createPath(context, targetAttrs);\n this.shadow(context, targetAttrs);\n this.strokeAndFill(context, targetAttrs);\n this.transform(targetAttrs);\n }\n }\n\n /**\n * @protected\n * 绘制图形的路径\n * @param {Defs} context 上下文\n * @param {ShapeAttrs} targetAttrs 渲染的目标属性\n */\n createPath(context: Defs, targetAttrs?: ShapeAttrs) {}\n\n // stroke and fill\n strokeAndFill(context, targetAttrs?) {\n const attrs = targetAttrs || this.attr();\n const { fill, fillStyle, stroke, strokeStyle, fillOpacity, strokeOpacity, lineWidth } = attrs;\n const el = this.get('el');\n\n if (this.canFill) {\n // 初次渲染和更新渲染的逻辑有所不同: 初次渲染值为空时,需要设置为 none,否则就会是黑色,而更新渲染则不需要\n if (!targetAttrs) {\n this._setColor(context, 'fill', fill || fillStyle);\n } else if ('fill' in attrs) {\n this._setColor(context, 'fill', fill);\n } else if ('fillStyle' in attrs) {\n // compatible with fillStyle\n this._setColor(context, 'fill', fillStyle);\n }\n if (fillOpacity) {\n el.setAttribute(SVG_ATTR_MAP['fillOpacity'], fillOpacity);\n }\n }\n\n if (this.canStroke && lineWidth > 0) {\n if (!targetAttrs) {\n this._setColor(context, 'stroke', stroke || strokeStyle);\n } else if ('stroke' in attrs) {\n this._setColor(context, 'stroke', stroke);\n } else if ('strokeStyle' in attrs) {\n // compatible with strokeStyle\n this._setColor(context, 'stroke', strokeStyle);\n }\n if (strokeOpacity) {\n el.setAttribute(SVG_ATTR_MAP['strokeOpacity'], strokeOpacity);\n }\n if (lineWidth) {\n el.setAttribute(SVG_ATTR_MAP['lineWidth'], lineWidth);\n }\n }\n }\n\n _setColor(context, attr, value) {\n const el = this.get('el');\n if (!value) {\n // need to set `none` to avoid default value\n el.setAttribute(SVG_ATTR_MAP[attr], 'none');\n return;\n }\n value = value.trim();\n if (/^[r,R,L,l]{1}[\\s]*\\(/.test(value)) {\n let id = context.find('gradient', value);\n if (!id) {\n id = context.addGradient(value);\n }\n el.setAttribute(SVG_ATTR_MAP[attr], `url(#${id})`);\n } else if (/^[p,P]{1}[\\s]*\\(/.test(value)) {\n let id = context.find('pattern', value);\n if (!id) {\n id = context.addPattern(value);\n }\n el.setAttribute(SVG_ATTR_MAP[attr], `url(#${id})`);\n } else {\n el.setAttribute(SVG_ATTR_MAP[attr], value);\n }\n }\n\n shadow(context, targetAttrs?) {\n const attrs = this.attr();\n const { shadowOffsetX, shadowOffsetY, shadowBlur, shadowColor } = targetAttrs || attrs;\n if (shadowOffsetX || shadowOffsetY || shadowBlur || shadowColor) {\n setShadow(this, context);\n }\n }\n\n transform(targetAttrs?) {\n const attrs = this.attr();\n const { matrix } = targetAttrs || attrs;\n if (matrix) {\n setTransform(this);\n }\n }\n\n isInShape(refX: number, refY: number): boolean {\n return this.isPointInPath(refX, refY);\n }\n\n isPointInPath(refX: number, refY: number): boolean {\n const el = this.get('el');\n const canvas = this.get('canvas');\n const bbox = canvas.get('el').getBoundingClientRect();\n const clientX = refX + bbox.left;\n const clientY = refY + bbox.top;\n const element = document.elementFromPoint(clientX, clientY);\n if (element && element.isEqualNode(el)) {\n return true;\n }\n return false;\n }\n\n /**\n * 获取线拾取的宽度\n * @returns {number} 线的拾取宽度\n */\n getHitLineWidth() {\n const { lineWidth, lineAppendWidth } = this.attrs;\n if (this.isStroke()) {\n return lineWidth + lineAppendWidth;\n }\n return 0;\n }\n}\n\nexport default ShapeBase;\n","/**\n * @fileoverview circle\n * @author dengfuping_develop@163.com\n */\n\nimport { each } from '@antv/util';\nimport { SVG_ATTR_MAP } from '../constant';\nimport ShapeBase from './base';\n\nclass Circle extends ShapeBase {\n type: string = 'circle';\n canFill: boolean = true;\n canStroke: boolean = true;\n\n getDefaultAttrs() {\n const attrs = super.getDefaultAttrs();\n return {\n ...attrs,\n x: 0,\n y: 0,\n r: 0,\n };\n }\n\n createPath(context, targetAttrs) {\n const attrs = this.attr();\n const el = this.get('el');\n each(targetAttrs || attrs, (value, attr) => {\n // 圆和椭圆的点坐标属性不是 x, y,而是 cx, cy\n if (attr === 'x' || attr === 'y') {\n el.setAttribute(`c${attr}`, value);\n } else if (SVG_ATTR_MAP[attr]) {\n el.setAttribute(SVG_ATTR_MAP[attr], value);\n }\n });\n }\n}\n\nexport default Circle;\n","/**\n * @fileoverview dom\n * @author dengfuping_develop@163.com\n */\n\nimport { each } from '@antv/util';\nimport { SVG_ATTR_MAP } from '../constant';\nimport ShapeBase from './base';\n\nclass Dom extends ShapeBase {\n type: string = 'dom';\n canFill: boolean = false;\n canStroke: boolean = false;\n\n createPath(context, targetAttrs) {\n const attrs = this.attr();\n const el = this.get('el');\n each(targetAttrs || attrs, (value, attr) => {\n if (SVG_ATTR_MAP[attr]) {\n el.setAttribute(SVG_ATTR_MAP[attr], value);\n }\n });\n if (typeof attrs['html'] === 'function') {\n const element = attrs['html'].call(this, attrs);\n if (element instanceof Element || element instanceof HTMLDocument) {\n const children = el.childNodes;\n for (let i = children.length - 1; i >= 0; i--) {\n el.removeChild(children[i]);\n }\n el.appendChild(element); // append to el if it's an element\n } else {\n el.innerHTML = element; // set innerHTML\n }\n } else {\n el.innerHTML = attrs['html']; // set innerHTML\n }\n }\n}\n\nexport default Dom;\n","/**\n * @fileoverview ellipse\n * @author dengfuping_develop@163.com\n */\n\nimport { each } from '@antv/util';\nimport { SVG_ATTR_MAP } from '../constant';\nimport ShapeBase from './base';\n\nclass Ellipse extends ShapeBase {\n type: string = 'ellipse';\n canFill: boolean = true;\n canStroke: boolean = true;\n\n getDefaultAttrs() {\n const attrs = super.getDefaultAttrs();\n return {\n ...attrs,\n x: 0,\n y: 0,\n rx: 0,\n ry: 0,\n };\n }\n\n createPath(context, targetAttrs) {\n const attrs = this.attr();\n const el = this.get('el');\n each(targetAttrs || attrs, (value, attr) => {\n // 圆和椭圆的点坐标属性不是 x, y,而是 cx, cy\n if (attr === 'x' || attr === 'y') {\n el.setAttribute(`c${attr}`, value);\n } else if (SVG_ATTR_MAP[attr]) {\n el.setAttribute(SVG_ATTR_MAP[attr], value);\n }\n });\n }\n}\n\nexport default Ellipse;\n","/**\n * @fileoverview image\n * @author dengfuping_develop@163.com\n */\n\nimport { each, isString } from '@antv/util';\nimport { SVG_ATTR_MAP } from '../constant';\nimport ShapeBase from './base';\n\nclass Image extends ShapeBase {\n type: string = 'image';\n canFill: boolean = false;\n canStroke: boolean = false;\n\n getDefaultAttrs() {\n const attrs = super.getDefaultAttrs();\n return {\n ...attrs,\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n };\n }\n\n createPath(context, targetAttrs) {\n const attrs = this.attr();\n const el = this.get('el');\n each(targetAttrs || attrs, (value, attr) => {\n if (attr === 'img') {\n this._setImage(attrs.img);\n } else if (SVG_ATTR_MAP[attr]) {\n el.setAttribute(SVG_ATTR_MAP[attr], value);\n }\n });\n }\n\n setAttr(name: string, value: any) {\n this.attrs[name] = value;\n if (name === 'img') {\n this._setImage(value);\n }\n }\n\n _setImage(img) {\n const attrs = this.attr();\n const el = this.get('el');\n if (isString(img)) {\n el.setAttribute('href', img);\n } else if (img instanceof (window as any).Image) {\n if (!attrs.width) {\n el.setAttribute('width', img.width);\n this.attr('width', img.width);\n }\n if (!attrs.height) {\n el.setAttribute('height', img.height);\n this.attr('height', img.height);\n }\n el.setAttribute('href', img.src);\n } else if (img instanceof HTMLElement && isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {\n // @ts-ignore\n el.setAttribute('href', img.toDataURL());\n } else if (img instanceof ImageData) {\n const canvas = document.createElement('canvas');\n canvas.setAttribute('width', `${img.width}`);\n canvas.setAttribute('height', `${img.height}`);\n canvas.getContext('2d').putImageData(img, 0, 0);\n if (!attrs.width) {\n el.setAttribute('width', `${img.width}`);\n this.attr('width', img.width);\n }\n if (!attrs.height) {\n el.setAttribute('height', `${img.height}`);\n this.attr('height', img.height);\n }\n el.setAttribute('href', canvas.toDataURL());\n }\n }\n}\n\nexport default Image;\n","/**\n * @fileoverview line\n * @author dengfuping_develop@163.com\n */\nimport { Line as LineUtil } from '@antv/g-math';\nimport { each, isObject } from '@antv/util';\nimport { SVG_ATTR_MAP } from '../constant';\nimport ShapeBase from './base';\n\nclass Line extends ShapeBase {\n type: string = 'line';\n canFill: boolean = false;\n canStroke: boolean = true;\n\n getDefaultAttrs() {\n const attrs = super.getDefaultAttrs();\n return {\n ...attrs,\n x1: 0,\n y1: 0,\n x2: 0,\n y2: 0,\n startArrow: false,\n endArrow: false,\n };\n }\n\n createPath(context, targetAttrs) {\n const attrs = this.attr();\n const el = this.get('el');\n each(targetAttrs || attrs, (value, attr) => {\n if (attr === 'startArrow' || attr === 'endArrow') {\n if (value) {\n const id = isObject(value)\n ? context.addArrow(attrs, SVG_ATTR_MAP[attr])\n : context.getDefaultArrow(attrs, SVG_ATTR_MAP[attr]);\n el.setAttribute(SVG_ATTR_MAP[attr], `url(#${id})`);\n } else {\n el.removeAttribute(SVG_ATTR_MAP[attr]);\n }\n } else if (SVG_ATTR_MAP[attr]) {\n el.setAttribute(SVG_ATTR_MAP[attr], value);\n }\n });\n }\n\n /**\n * Use math calculation to get length of line\n * @return {number} length\n */\n getTotalLength() {\n const { x1, y1, x2, y2 } = this.attr();\n return LineUtil.length(x1, y1, x2, y2);\n }\n\n /**\n * Use math calculation to get point according to ratio as same sa Canvas version\n * @param {number} ratio\n * @return {Point} point\n */\n getPoint(ratio: number) {\n const { x1, y1, x2, y2 } = this.attr();\n return LineUtil.pointAt(x1, y1, x2, y2, ratio);\n }\n}\n\nexport default Line;\n","const Symbols = {\n // 圆\n circle(x: number, y: number, r: number): any[] {\n return [\n ['M', x, y],\n ['m', -r, 0],\n ['a', r, r, 0, 1, 0, r * 2, 0],\n ['a', r, r, 0, 1, 0, -r * 2, 0],\n ];\n },\n // 正方形\n square(x: number, y: number, r: number): any[] {\n return [['M', x - r, y - r], ['L', x + r, y - r], ['L', x + r, y + r], ['L', x - r, y + r], ['Z']];\n },\n // 菱形\n diamond(x: number, y: number, r: number): any[] {\n return [['M', x - r, y], ['L', x, y - r], ['L', x + r, y], ['L', x, y + r], ['Z']];\n },\n // 三角形\n triangle(x: number, y: number, r: number): any[] {\n const diffY = r * Math.sin((1 / 3) * Math.PI);\n return [['M', x - r, y + diffY], ['L', x, y - diffY], ['L', x + r, y + diffY], ['z']];\n },\n // 倒三角形\n triangleDown(x: number, y: number, r: number): any[] {\n const diffY = r * Math.sin((1 / 3) * Math.PI);\n return [['M', x - r, y - diffY], ['L', x + r, y - diffY], ['L', x, y + diffY], ['Z']];\n },\n};\n\nexport type SymbolFunc = (x: number, y: number, r: number) => any[];\n\nexport default {\n get(type: string): SymbolFunc {\n return Symbols[type];\n },\n\n register(type: string, func: SymbolFunc) {\n Symbols[type] = func;\n },\n\n remove(type: string) {\n delete Symbols[type];\n },\n\n getAll() {\n return Symbols;\n },\n};\n","/**\n * @fileoverview marker\n * @author dengfuping_develop@163.com\n */\n\nimport { isArray, isFunction } from '@antv/util';\nimport ShapeBase from '../base';\nimport symbolsFactory from './symbols';\n\nclass Marker extends ShapeBase {\n type: string = 'marker';\n canFill: boolean = true;\n canStroke: boolean = true;\n\n // 作为其静态属性\n public static symbolsFactory = symbolsFactory;\n\n createPath(context) {\n const el = this.get('el');\n el.setAttribute('d', this._assembleMarker());\n }\n\n _assembleMarker() {\n const d = this._getPath();\n if (isArray(d)) {\n return d\n .map((path) => {\n return path.join(' ');\n })\n .join('');\n }\n return d;\n }\n\n _getPath(): any[] {\n const attrs = this.attr();\n const { x, y } = attrs;\n // 兼容 r 和 radius 两种写法,推荐使用 r\n const r = attrs.r || attrs.radius;\n const symbol = attrs.symbol || 'circle';\n let method;\n if (isFunction(symbol)) {\n method = symbol;\n } else {\n method = symbolsFactory.get(symbol);\n }\n\n if (!method) {\n console.warn(`${method} symbol is not exist.`);\n return null;\n }\n return method(x, y, r);\n }\n}\n\nexport default Marker;\n","/**\n * @fileoverview path\n * @author dengfuping_develop@163.com\n */\nimport { Point } from '@antv/g-base';\nimport { each, isArray, isObject } from '@antv/util';\nimport { SVG_ATTR_MAP } from '../constant';\nimport ShapeBase from './base';\n\nclass Path extends ShapeBase {\n type: string = 'path';\n canFill: boolean = true;\n canStroke: boolean = true;\n\n getDefaultAttrs() {\n const attrs = super.getDefaultAttrs();\n return {\n ...attrs,\n startArrow: false,\n endArrow: false,\n };\n }\n\n createPath(context, targetAttrs) {\n const attrs = this.attr();\n const el = this.get('el');\n each(targetAttrs || attrs, (value, attr) => {\n if (attr === 'path' && isArray(value)) {\n el.setAttribute('d', this._formatPath(value));\n } else if (attr === 'startArrow' || attr === 'endArrow') {\n if (value) {\n const id = isObject(value)\n ? context.addArrow(attrs, SVG_ATTR_MAP[attr])\n : context.getDefaultArrow(attrs, SVG_ATTR_MAP[attr]);\n el.setAttribute(SVG_ATTR_MAP[attr], `url(#${id})`);\n } else {\n el.removeAttribute(SVG_ATTR_MAP[attr]);\n }\n } else if (SVG_ATTR_MAP[attr]) {\n el.setAttribute(SVG_ATTR_MAP[attr], value);\n }\n });\n }\n\n _formatPath(value) {\n const newValue = value\n .map((path) => {\n return path.join(' ');\n })\n .join('');\n if (~newValue.indexOf('NaN')) {\n return '';\n }\n return newValue;\n }\n\n /**\n * Get total length of path\n * 尽管通过浏览器的 SVGPathElement.getTotalLength() 接口获取的 path 长度,\n * 与 Canvas 版本通过数学计算的方式得到的长度有一些细微差异,但最大误差在个位数像素,精度上可以能接受\n * @return {number} length\n */\n getTotalLength() {\n const el = this.get('el');\n return el ? el.getTotalLength() : null;\n }\n\n /**\n * Get point according to ratio\n * @param {number} ratio\n * @return {Point} point\n */\n getPoint(ratio: number): Point {\n const el = this.get('el');\n const totalLength = this.getTotalLength();\n // @see https://github.com/antvis/g/issues/634\n if (totalLength === 0) {\n return null;\n }\n const point = el ? el.getPointAtLength(ratio * totalLength) : null;\n return point\n ? {\n x: point.x,\n y: point.y,\n }\n : null;\n }\n}\n\nexport default Path;\n","/**\n * @fileoverview polygon\n * @author dengfuping_develop@163.com\n */\nimport { each, isArray } from '@antv/util';\nimport { SVG_ATTR_MAP } from '../constant';\nimport ShapeBase from './base';\n\nclass Polygon extends ShapeBase {\n type: string = 'polygon';\n canFill: boolean = true;\n canStroke: boolean = true;\n\n createPath(context, targetAttrs) {\n const attrs = this.attr();\n const el = this.get('el');\n each(targetAttrs || attrs, (value, attr) => {\n if (attr === 'points' && isArray(value) && value.length >= 2) {\n el.setAttribute('points', value.map((point) => `${point[0]},${point[1]}`).join(' '));\n } else if (SVG_ATTR_MAP[attr]) {\n el.setAttribute(SVG_ATTR_MAP[attr], value);\n }\n });\n }\n}\n\nexport default Polygon;\n","/**\n * @fileoverview polyline\n * @author dengfuping_develop@163.com\n */\nimport { Point } from '@antv/g-base';\nimport { Polyline as PolylineUtil } from '@antv/g-math';\nimport { Line as LineUtil } from '@antv/g-math';\nimport { each, isArray, isNil } from '@antv/util';\nimport { SVG_ATTR_MAP } from '../constant';\nimport ShapeBase from './base';\n\nclass Polyline extends ShapeBase {\n type: string = 'polyline';\n canFill: boolean = true;\n canStroke: boolean = true;\n\n getDefaultAttrs() {\n const attrs = super.getDefaultAttrs();\n return {\n ...attrs,\n startArrow: false,\n endArrow: false,\n };\n }\n\n // 更新属性时,检测是否更改了 points\n onAttrChange(name: string, value: any, originValue: any) {\n super.onAttrChange(name, value, originValue);\n if (['points'].indexOf(name) !== -1) {\n this._resetCache();\n }\n }\n\n _resetCache() {\n this.set('totalLength', null);\n this.set('tCache', null);\n }\n\n createPath(context, targetAttrs) {\n const attrs = this.attr();\n const el = this.get('el');\n each(targetAttrs || attrs, (value, attr) => {\n if (attr === 'points' && isArray(value) && value.length >= 2) {\n el.setAttribute('points', value.map((point) => `${point[0]},${point[1]}`).join(' '));\n } else if (SVG_ATTR_MAP[attr]) {\n el.setAttribute(SVG_ATTR_MAP[attr], value);\n }\n });\n }\n\n /**\n * Get length of polyline\n * @return {number} length\n */\n getTotalLength() {\n const { points } = this.attr();\n // get totalLength from cache\n const totalLength = this.get('totalLength');\n if (!isNil(totalLength)) {\n return totalLength;\n }\n this.set('totalLength', PolylineUtil.length(points));\n return this.get('totalLength');\n }\n\n /**\n * Get point according to ratio\n * @param {number} ratio\n * @return {Point} point\n */\n getPoint(ratio: number): Point {\n const { points } = this.attr();\n // get tCache from cache\n let tCache = this.get('tCache');\n if (!tCache) {\n this._setTcache();\n tCache = this.get('tCache');\n }\n\n let subt;\n let index;\n each(tCache, (v, i) => {\n if (ratio >= v[0] && ratio <= v[1]) {\n subt = (ratio - v[0]) / (v[1] - v[0]);\n index = i;\n }\n });\n return LineUtil.pointAt(points[index][0], points[index][1], points[index + 1][0], points[index + 1][1], subt);\n }\n\n _setTcache() {\n const { points } = this.attr();\n if (!points || points.length === 0) {\n return;\n }\n\n const totalLength = this.getTotalLength();\n if (totalLength <= 0) {\n return;\n }\n\n let tempLength = 0;\n const tCache = [];\n let segmentT;\n let segmentL;\n\n each(points, (p, i) => {\n if (points[i + 1]) {\n segmentT = [];\n segmentT[0] = tempLength / totalLength;\n segmentL = LineUtil.length(p[0], p[1], points[i + 1][0], points[i + 1][1]);\n tempLength += segmentL;\n segmentT[1] = tempLength / totalLength;\n tCache.push(segmentT);\n }\n });\n this.set('tCache', tCache);\n }\n\n /**\n * Get start tangent vector\n * @return {Array}\n */\n getStartTangent(): number[][] {\n const { points } = this.attr();\n const result = [];\n result.push([points[1][0], points[1][1]]);\n result.push([points[0][0], points[0][1]]);\n return result;\n }\n\n /**\n * Get end tangent vector\n * @return {Array}\n */\n getEndTangent(): number[][] {\n const { points } = this.attr();\n const l = points.length - 1;\n const result = [];\n result.push([points[l - 1][0], points[l - 1][1]]);\n result.push([points[l][0], points[l][1]]);\n return result;\n }\n}\n\nexport default Polyline;\n","/**\n * @fileoverview rect\n * @author dengfuping_develop@163.com\n */\n\nimport { each, isArray } from '@antv/util';\nimport ShapeBase from './base';\nimport { SVG_ATTR_MAP } from '../constant';\nimport { parseRadius } from '../util/format';\n\nclass Rect extends ShapeBase {\n type: string = 'rect';\n canFill: boolean = true;\n canStroke: boolean = true;\n\n getDefaultAttrs() {\n const attrs = super.getDefaultAttrs();\n return {\n ...attrs,\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n radius: 0,\n };\n }\n\n createPath(context, targetAttrs) {\n const attrs = this.attr();\n const el = this.get('el');\n // 加上状态量,用来标记 path 是否已组装\n let completed = false;\n // 和组装 path 相关的绘图属性\n const pathRelatedAttrs = ['x', 'y', 'width', 'height', 'radius'];\n each(targetAttrs || attrs, (value, attr) => {\n if (pathRelatedAttrs.indexOf(attr) !== -1 && !completed) {\n el.setAttribute('d', this._assembleRect(attrs));\n completed = true;\n } else if (pathRelatedAttrs.indexOf(attr) === -1 && SVG_ATTR_MAP[attr]) {\n el.setAttribute(SVG_ATTR_MAP[attr], value);\n }\n });\n }\n\n _assembleRect(attrs) {\n const x = attrs.x;\n const y = attrs.y;\n const w = attrs.width;\n const h = attrs.height;\n const radius = attrs.radius;\n\n if (!radius) {\n return `M ${x},${y} l ${w},0 l 0,${h} l${-w} 0 z`;\n }\n const r = parseRadius(radius);\n if (isArray(radius)) {\n if (radius.length === 1) {\n r.r1 = r.r2 = r.r3 = r.r4 = radius[0];\n } else if (radius.length === 2) {\n r.r1 = r.r3 = radius[0];\n r.r2 = r.r4 = radius[1];\n } else if (radius.length === 3) {\n r.r1 = radius[0];\n r.r2 = r.r4 = radius[1];\n r.r3 = radius[2];\n } else {\n r.r1 = radius[0];\n r.r2 = radius[1];\n r.r3 = radius[2];\n r.r4 = radius[3];\n }\n } else {\n r.r1 = r.r2 = r.r3 = r.r4 = radius;\n }\n const d = [\n [`M ${x + r.r1},${y}`],\n [`l ${w - r.r1 - r.r2},0`],\n [`a ${r.r2},${r.r2},0,0,1,${r.r2},${r.r2}`],\n [`l 0,${h - r.r2 - r.r3}`],\n [`a ${r.r3},${r.r3},0,0,1,${-r.r3},${r.r3}`],\n [`l ${r.r3 + r.r4 - w},0`],\n [`a ${r.r4},${r.r4},0,0,1,${-r.r4},${-r.r4}`],\n [`l 0,${r.r4 + r.r1 - h}`],\n [`a ${r.r1},${r.r1},0,0,1,${r.r1},${-r.r1}`],\n ['z'],\n ];\n return d.join(' ');\n }\n}\n\nexport default Rect;\n","import { each, isArray, isString } from '@antv/util';\n\nconst regexTags = /[MLHVQTCSAZ]([^MLHVQTCSAZ]*)/gi;\nconst regexDot = /[^\\s,]+/gi;\n\nexport function parseRadius(radius) {\n let r1 = 0;\n let r2 = 0;\n let r3 = 0;\n let r4 = 0;\n if (isArray(radius)) {\n if (radius.length === 1) {\n r1 = r2 = r3 = r4 = radius[0];\n } else if (radius.length === 2) {\n r1 = r3 = radius[0];\n r2 = r4 = radius[1];\n } else if (radius.length === 3) {\n r1 = radius[0];\n r2 = r4 = radius[1];\n r3 = radius[2];\n } else {\n r1 = radius[0];\n r2 = radius[1];\n r3 = radius[2];\n r4 = radius[3];\n }\n } else {\n r1 = r2 = r3 = r4 = radius;\n }\n return {\n r1,\n r2,\n r3,\n r4,\n };\n}\n\nexport function parsePath(path) {\n path = path || [];\n if (isArray(path)) {\n return path;\n }\n\n if (isString(path)) {\n path = path.match(regexTags);\n each(path, (item, index) => {\n item = item.match(regexDot);\n if (item[0].length > 1) {\n const tag = item[0].charAt(0);\n item.splice(1, 0, item[0].substr(1));\n item[0] = tag;\n }\n each(item, (sub, i) => {\n if (!isNaN(sub)) {\n item[i] = +sub;\n }\n });\n path[index] = item;\n });\n return path;\n }\n}\n","/**\n * @fileoverview text\n * @author dengfuping_develop@163.com\n */\n\nimport { each } from '@antv/util';\nimport { detect } from 'detect-browser';\nimport { setTransform } from '../util/svg';\nimport { SVG_ATTR_MAP } from '../constant';\nimport ShapeBase from './base';\n\nconst LETTER_SPACING = 0.3;\n\nconst BASELINE_MAP = {\n top: 'before-edge',\n middle: 'central',\n bottom: 'after-edge',\n alphabetic: 'baseline',\n hanging: 'hanging',\n};\n\n// for FireFox\nconst BASELINE_MAP_FOR_FIREFOX = {\n top: 'text-before-edge',\n middle: 'central',\n bottom: 'text-after-edge',\n alphabetic: 'alphabetic',\n hanging: 'hanging',\n};\n\nconst ANCHOR_MAP = {\n left: 'left',\n start: 'left',\n center: 'middle',\n right: 'end',\n end: 'end',\n};\n\nclass Text extends ShapeBase {\n type: string = 'text';\n canFill: boolean = true;\n canStroke: boolean = true;\n\n getDefaultAttrs() {\n const attrs = super.getDefaultAttrs();\n return {\n ...attrs,\n x: 0,\n y: 0,\n text: null,\n fontSize: 12,\n fontFamily: 'sans-serif',\n fontStyle: 'normal',\n fontWeight: 'normal',\n fontVariant: 'normal',\n textAlign: 'start',\n textBaseline: 'bottom',\n };\n }\n\n createPath(context, targetAttrs) {\n const attrs = this.attr();\n const el = this.get('el');\n this._setFont();\n each(targetAttrs || attrs, (value, attr) => {\n if (attr === 'text') {\n this._setText(`${value}`);\n } else if (attr === 'matrix' && value) {\n setTransform(this);\n } else if (SVG_ATTR_MAP[attr]) {\n el.setAttribute(SVG_ATTR_MAP[attr], value);\n }\n });\n el.setAttribute('paint-order', 'stroke');\n el.setAttribute('style', 'stroke-linecap:butt; stroke-linejoin:miter;');\n }\n\n _setFont() {\n const el = this.get('el');\n const { textBaseline, textAlign } = this.attr();\n\n const browser = detect();\n if (browser && browser.name === 'firefox') {\n // compatible with FireFox browser, ref: https://github.com/antvis/g/issues/119\n el.setAttribute('dominant-baseline', BASELINE_MAP_FOR_FIREFOX[textBaseline] || 'alphabetic');\n } else {\n el.setAttribute('alignment-baseline', BASELINE_MAP[textBaseline] || 'baseline');\n }\n\n el.setAttribute('text-anchor', ANCHOR_MAP[textAlign] || 'left');\n }\n\n _setText(text) {\n const el = this.get('el');\n const { x, textBaseline: baseline = 'bottom' } = this.attr();\n if (!text) {\n el.innerHTML = '';\n } else if (~text.indexOf('\\n')) {\n const textArr = text.split('\\n');\n const textLen = textArr.length - 1;\n let arr = '';\n each(textArr, (segment, i: number) => {\n if (i === 0) {\n if (baseline === 'alphabetic') {\n arr += `${segment}`;\n } else if (baseline === 'top') {\n arr += `${segment}`;\n } else if (baseline === 'middle') {\n arr += `${segment}`;\n } else if (baseline === 'bottom') {\n arr += `${segment}`;\n } else if (baseline === 'hanging') {\n arr += `${segment}`;\n }\n } else {\n arr += `${segment}`;\n }\n });\n el.innerHTML = arr;\n } else {\n el.innerHTML = text;\n }\n }\n}\n\nexport default Text;\n","/**\n * @fileoverview gradient\n * @author dengfuping_develop@163.com\n */\n\nimport { each, mod, toRadian, uniqueId } from '@antv/util';\nimport { createSVGElement } from '../util/dom';\n\nconst regexLG = /^l\\s*\\(\\s*([\\d.]+)\\s*\\)\\s*(.*)/i;\nconst regexRG = /^r\\s*\\(\\s*([\\d.]+)\\s*,\\s*([\\d.]+)\\s*,\\s*([\\d.]+)\\s*\\)\\s*(.*)/i;\nconst regexColorStop = /[\\d.]+:(#[^\\s]+|[^)]+\\))/gi;\n\nfunction addStop(steps) {\n const arr = steps.match(regexColorStop);\n if (!arr) {\n return '';\n }\n let stops = '';\n arr.sort((a, b) => {\n a = a.split(':');\n b = b.split(':');\n return Number(a[0]) - Number(b[0]);\n });\n each(arr, (item: any) => {\n item = item.split(':');\n stops += ``;\n });\n return stops;\n}\n\nfunction parseLineGradient(color, el) {\n const arr = regexLG.exec(color);\n const angle = mod(toRadian(parseFloat(arr[1])), Math.PI * 2);\n const steps = arr[2];\n let start;\n let end;\n\n if (angle >= 0 && angle < 0.5 * Math.PI) {\n start = {\n x: 0,\n y: 0,\n };\n end = {\n x: 1,\n y: 1,\n };\n } else if (0.5 * Math.PI <= angle && angle < Math.PI) {\n start = {\n x: 1,\n y: 0,\n };\n end = {\n x: 0,\n y: 1,\n };\n } else if (Math.PI <= angle && angle < 1.5 * Math.PI) {\n start = {\n x: 1,\n y: 1,\n };\n end = {\n x: 0,\n y: 0,\n };\n } else {\n start = {\n x: 0,\n y: 1,\n };\n end = {\n x: 1,\n y: 0,\n };\n }\n\n const tanTheta = Math.tan(angle);\n const tanTheta2 = tanTheta * tanTheta;\n\n const x = (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.x;\n const y = (tanTheta * (end.x - start.x + tanTheta * (end.y - start.y))) / (tanTheta2 + 1) + start.y;\n el.setAttribute('x1', start.x);\n el.setAttribute('y1', start.y);\n el.setAttribute('x2', x);\n el.setAttribute('y2', y);\n el.innerHTML = addStop(steps);\n}\n\nfunction parseRadialGradient(color, self) {\n const arr = regexRG.exec(color);\n const cx = parseFloat(arr[1]);\n const cy = parseFloat(arr[2]);\n const r = parseFloat(arr[3]);\n const steps = arr[4];\n self.setAttribute('cx', cx);\n self.setAttribute('cy', cy);\n self.setAttribute('r', r);\n self.innerHTML = addStop(steps);\n}\n\nclass Gradient {\n el: SVGGradientElement;\n id: string;\n cfg: {\n [key: string]: any;\n } = {};\n\n constructor(cfg) {\n let el = null;\n const id = uniqueId('gradient_');\n if (cfg.toLowerCase()[0] === 'l') {\n el = createSVGElement('linearGradient');\n parseLineGradient(cfg, el);\n } else {\n el = createSVGElement('radialGradient');\n parseRadialGradient(cfg, el);\n }\n el.setAttribute('id', id);\n this.el = el;\n this.id = id;\n this.cfg = cfg;\n return this;\n }\n\n match(type, attr) {\n return this.cfg === attr;\n }\n}\n\nexport default Gradient;\n","/**\n * @fileoverview shadow\n * @author dengfuping_develop@163.com\n */\n\nimport { each, uniqueId } from '@antv/util';\nimport { createSVGElement } from '../util/dom';\n\nconst ATTR_MAP = {\n shadowColor: 'color',\n shadowOpacity: 'opacity',\n shadowBlur: 'blur',\n shadowOffsetX: 'dx',\n shadowOffsetY: 'dy',\n};\n\nconst SHADOW_DIMENSION = {\n x: '-40%',\n y: '-40%',\n width: '200%',\n height: '200%',\n};\n\nclass Shadow {\n type: string = 'filter';\n id: string;\n el: SVGFilterElement;\n cfg: {\n [key: string]: any;\n } = {};\n\n constructor(cfg) {\n this.type = 'filter';\n const el = createSVGElement('filter') as SVGFilterElement;\n // expand the filter region to fill in shadows\n each(SHADOW_DIMENSION, (v, k) => {\n el.setAttribute(k, v);\n });\n this.el = el;\n this.id = uniqueId('filter_');\n this.el.id = this.id;\n this.cfg = cfg;\n this._parseShadow(cfg, el);\n return this;\n }\n\n match(type, cfg) {\n if (this.type !== type) {\n return false;\n }\n let flag = true;\n const config = this.cfg;\n each(Object.keys(config), (attr) => {\n if (config[attr] !== cfg[attr]) {\n flag = false;\n return false;\n }\n });\n return flag;\n }\n\n update(name, value) {\n const config = this.cfg;\n config[ATTR_MAP[name]] = value;\n this._parseShadow(config, this.el);\n return this;\n }\n\n _parseShadow(config, el) {\n const child = ``;\n el.innerHTML = child;\n }\n}\n\nexport default Shadow;\n","/**\n * @fileoverview arrow\n * @author dengfuping_develop@163.com\n */\n\nimport { isArray, uniqueId } from '@antv/util';\nimport { createSVGElement } from '../util/dom';\n\nclass Arrow {\n id: string;\n el: SVGMarkerElement;\n child: SVGPathElement | any; // TODO G.Shape, not any\n stroke: string;\n cfg: {\n [key: string]: any;\n } = {};\n\n constructor(attrs, type) {\n const el = createSVGElement('marker') as SVGMarkerElement;\n const id = uniqueId('marker_');\n el.setAttribute('id', id);\n const shape = createSVGElement('path');\n shape.setAttribute('stroke', attrs.stroke || 'none');\n shape.setAttribute('fill', attrs.fill || 'none');\n el.appendChild(shape);\n el.setAttribute('overflow', 'visible');\n el.setAttribute('orient', 'auto-start-reverse');\n this.el = el;\n this.child = shape;\n this.id = id;\n const cfg = attrs[type === 'marker-start' ? 'startArrow' : 'endArrow'];\n this.stroke = attrs.stroke || '#000';\n if (cfg === true) {\n this._setDefaultPath(type, shape);\n } else {\n this.cfg = cfg; // when arrow config exists\n this._setMarker(attrs.lineWidth, shape);\n }\n return this;\n }\n\n match() {\n return false;\n }\n\n _setDefaultPath(type, el) {\n const parent = this.el;\n // 默认箭头的边长为 10,夹角为 60 度\n el.setAttribute('d', `M0,0 L${10 * Math.cos(Math.PI / 6)},5 L0,10`);\n parent.setAttribute('refX', `${10 * Math.cos(Math.PI / 6)}`);\n parent.setAttribute('refY', `${5}`);\n }\n\n _setMarker(r, el) {\n const parent = this.el;\n let path = this.cfg.path;\n const d = this.cfg.d;\n\n if (isArray(path)) {\n path = path\n .map((segment) => {\n return segment.join(' ');\n })\n .join('');\n }\n el.setAttribute('d', path);\n parent.appendChild(el);\n if (d) {\n parent.setAttribute('refX', `${d / r}`);\n }\n }\n\n update(fill) {\n const child = this.child;\n if (child.attr) {\n child.attr('fill', fill);\n } else {\n child.setAttribute('fill', fill);\n }\n }\n}\n\nexport default Arrow;\n","/**\n * @fileoverview clip\n * @author dengfuping_develop@163.com\n */\n\nimport { uniqueId } from '@antv/util';\nimport { createSVGElement } from '../util/dom';\n\nclass Clip {\n type: string = 'clip';\n id: string;\n el: SVGClipPathElement;\n cfg: {\n [key: string]: any;\n } = {};\n\n constructor(cfg) {\n const el = createSVGElement('clipPath') as SVGClipPathElement;\n this.el = el;\n this.id = uniqueId('clip_');\n el.id = this.id;\n const shapeEl = cfg.cfg.el;\n el.appendChild(shapeEl);\n this.cfg = cfg;\n return this;\n }\n\n match() {\n return false;\n }\n\n remove() {\n const el = this.el;\n el.parentNode.removeChild(el);\n }\n}\n\nexport default Clip;\n","/**\n * @fileoverview pattern\n * @author dengfuping_develop@163.com\n */\n\nimport { uniqueId } from '@antv/util';\nimport { createSVGElement } from '../util/dom';\n\nconst regexPR = /^p\\s*\\(\\s*([axyn])\\s*\\)\\s*(.*)/i;\n\nclass Pattern {\n el: SVGPatternElement;\n id: string;\n cfg: {\n [key: string]: any;\n } = {};\n\n constructor(cfg) {\n const el = createSVGElement('pattern') as SVGPatternElement;\n el.setAttribute('patternUnits', 'userSpaceOnUse');\n const child = createSVGElement('image');\n el.appendChild(child);\n const id = uniqueId('pattern_');\n el.id = id;\n this.el = el;\n this.id = id;\n this.cfg = cfg;\n const arr = regexPR.exec(cfg);\n const source = arr[2];\n child.setAttribute('href', source);\n const img = new Image();\n if (!source.match(/^data:/i)) {\n img.crossOrigin = 'Anonymous';\n }\n img.src = source;\n function onload() {\n el.setAttribute('width', `${img.width}`);\n el.setAttribute('height', `${img.height}`);\n }\n if (img.complete) {\n onload();\n } else {\n img.onload = onload;\n // Fix onload() bug in IE9\n img.src = img.src;\n }\n\n return this;\n }\n\n match(type, attr) {\n return this.cfg === attr;\n }\n}\n\nexport default Pattern;\n","/**\n * @fileoverview defs\n * @author dengfuping_develop@163.com\n */\n\nimport { uniqueId } from '@antv/util';\nimport Gradient from './gradient';\nimport Shadow from './shadow';\nimport Arrow from './arrow';\nimport Clip from './clip';\nimport Pattern from './pattern';\nimport { createSVGElement } from '../util/dom';\n\nclass Defs {\n id: string;\n defaultArrow: {};\n children: any[];\n el: SVGDefsElement;\n canvas: SVGSVGElement;\n\n constructor(canvas) {\n const el = createSVGElement('defs') as SVGDefsElement;\n const id = uniqueId('defs_');\n el.id = id;\n canvas.appendChild(el);\n this.children = [];\n this.defaultArrow = {};\n this.el = el;\n this.canvas = canvas;\n }\n\n find(type, attr) {\n const children = this.children;\n let result = null;\n for (let i = 0; i < children.length; i++) {\n if (children[i].match(type, attr)) {\n result = children[i].id;\n break;\n }\n }\n return result;\n }\n\n findById(id) {\n const children = this.children;\n let flag = null;\n for (let i = 0; i < children.length; i++) {\n if (children[i].id === id) {\n flag = children[i];\n break;\n }\n }\n return flag;\n }\n\n add(item) {\n this.children.push(item);\n item.canvas = this.canvas;\n item.parent = this;\n }\n\n getDefaultArrow(attrs, name) {\n const stroke = attrs.stroke || attrs.strokeStyle;\n if (this.defaultArrow[stroke]) {\n return this.defaultArrow[stroke].id;\n }\n const arrow = new Arrow(attrs, name);\n this.defaultArrow[stroke] = arrow;\n this.el.appendChild(arrow.el);\n this.add(arrow);\n return arrow.id;\n }\n\n addGradient(cfg) {\n const gradient = new Gradient(cfg);\n this.el.appendChild(gradient.el);\n this.add(gradient);\n return gradient.id;\n }\n\n addArrow(attrs, name) {\n const arrow = new Arrow(attrs, name);\n this.el.appendChild(arrow.el);\n this.add(arrow);\n return arrow.id;\n }\n\n addShadow(cfg) {\n const shadow = new Shadow(cfg);\n this.el.appendChild(shadow.el);\n this.add(shadow);\n return shadow.id;\n }\n\n addPattern(cfg) {\n const pattern = new Pattern(cfg);\n this.el.appendChild(pattern.el);\n this.add(pattern);\n return pattern.id;\n }\n\n addClip(cfg) {\n const clip = new Clip(cfg);\n this.el.appendChild(clip.el);\n this.add(clip);\n return clip.id;\n }\n}\n\nexport default Defs;\n","import { AbstractCanvas, IShape } from '@antv/g-base';\nimport { ChangeType } from '@antv/g-base';\nimport { IElement } from './interfaces';\nimport { SHAPE_TO_TAGS } from './constant';\nimport { drawChildren } from './util/draw';\nimport { setTransform, setClip } from './util/svg';\nimport { sortDom, createSVGElement } from './util/dom';\nimport * as Shape from './shape';\nimport Group from './group';\nimport Defs from './defs';\n\nclass Canvas extends AbstractCanvas {\n constructor(cfg) {\n super({\n ...cfg,\n autoDraw: true,\n // 设置渲染引擎为 canvas,只读属性\n renderer: 'svg',\n });\n }\n\n getShapeBase() {\n return Shape;\n }\n\n getGroupBase() {\n return Group;\n }\n\n // 覆盖 Container 中通过遍历的方式获取 shape 对象的逻辑,直接走 SVG 的 dom 拾取即可\n getShape(x: number, y: number, ev: Event): IShape {\n let target = ev.target || ev.srcElement;\n if (!SHAPE_TO_TAGS[target.tagName]) {\n let parent = target.parentNode;\n while (parent && !SHAPE_TO_TAGS[parent.tagName]) {\n parent = parent.parentNode;\n }\n target = parent;\n }\n return this.find((child) => child.get('el') === target) as IShape;\n }\n\n // 复写基类的方法生成标签\n createDom() {\n const element = createSVGElement('svg') as SVGSVGElement;\n const context = new Defs(element);\n element.setAttribute('width', `${this.get('width')}`);\n element.setAttribute('height', `${this.get('height')}`);\n // 缓存 context 对象\n this.set('context', context);\n return element;\n }\n\n /**\n * 一些方法调用会引起画布变化\n * @param {ChangeType} changeType 改变的类型\n */\n onCanvasChange(changeType: ChangeType) {\n const context = this.get('context');\n const el = this.get('el');\n if (changeType === 'sort') {\n const children = this.get('children');\n if (children && children.length) {\n sortDom(this, (a: IElement, b: IElement) => {\n return children.indexOf(a) - children.indexOf(b) ? 1 : 0;\n });\n }\n } else if (changeType === 'clear') {\n // el maybe null for canvas\n if (el) {\n // 清空 SVG 元素\n el.innerHTML = '';\n const defsEl = context.el;\n // 清空 defs 元素\n defsEl.innerHTML = '';\n // 将清空后的 defs 元素挂载到 el 下\n el.appendChild(defsEl);\n }\n } else if (changeType === 'matrix') {\n setTransform(this);\n } else if (changeType === 'clip') {\n setClip(this, context);\n } else if (changeType === 'changeSize') {\n el.setAttribute('width', `${this.get('width')}`);\n el.setAttribute('height', `${this.get('height')}`);\n }\n }\n\n // 复写基类的 draw 方法\n draw() {\n const context = this.get('context');\n const children = this.getChildren() as IElement[];\n setClip(this, context);\n if (children.length) {\n drawChildren(context, children);\n }\n }\n}\n\nexport default Canvas;\n","import * as Shape from './shape';\n\nexport * from '@antv/g-base';\nexport { IElement, IGroup, IShape } from './interfaces';\nexport { default as Canvas } from './canvas';\nexport { default as Group } from './group';\nexport { Shape };\n\nexport const version = '0.5.6';\n","import { FIELD_ORIGIN } from '../constant';\nimport { MappingDatum, ShapeInfo } from '../interface';\nimport Geometry, { GeometryCfg } from './base';\nimport Element from './element';\n/** 引入对应的 ShapeFactory */\nimport './shape/line';\nimport { isModelChange } from './util/is-model-change';\nimport { diff } from './util/diff';\n\n/** Path 构造函数参数类型 */\nexport interface PathCfg extends GeometryCfg {\n /** 是否连接空值 */\n connectNulls?: boolean;\n /** 单个孤立数据点是否展示 */\n showSinglePoint?: boolean;\n}\n\n/**\n * Path 几何标记。\n * 用于绘制路径图等。\n */\nexport default class Path extends Geometry {\n public readonly type: string = 'path';\n public readonly shapeType: string = 'line';\n /** 是否连接空值 */\n public connectNulls: boolean;\n /** 单个孤立数据点是否展示 */\n public showSinglePoint: boolean;\n\n constructor(cfg: PathCfg) {\n super(cfg);\n\n const { connectNulls = false, showSinglePoint = true } = cfg;\n this.connectNulls = connectNulls;\n this.showSinglePoint = showSinglePoint;\n }\n\n /**\n * 创建所有的 Element 实例,对于 Path、Line、Area,一组数据对应一个 Element。\n * @param mappingData\n * @param [isUpdate]\n * @returns elements\n */\n protected updateElements(mappingDataArray: MappingDatum[][], isUpdate: boolean = false) {\n // Path 的每个 element 对应一组数据\n const keyData = new Map();\n const keyIndex = new Map();\n const keys: string[] = [];\n\n let index = 0;\n for (let i = 0; i < mappingDataArray.length; i++) {\n const mappingData = mappingDataArray[i];\n const key = this.getElementId(mappingData);\n keys.push(key);\n keyData.set(key, mappingData);\n keyIndex.set(key, index);\n index++;\n }\n\n this.elements = new Array(index);\n\n const { added, updated, removed } = diff(this.lastElementsMap, keys);\n\n for (const key of added) {\n const mappingData = keyData.get(key);\n const shapeFactory = this.getShapeFactory();\n const shapeCfg = this.getShapeInfo(mappingData);\n const i = keyIndex.get(key);\n const element = new Element({\n shapeFactory,\n container: this.container,\n offscreenGroup: this.getOffscreenGroup(),\n elementIndex: i,\n });\n element.geometry = this;\n element.animate = this.animateOption;\n element.draw(shapeCfg, isUpdate); // 绘制 shape\n this.elementsMap[key] = element;\n this.elements[i] = element;\n }\n\n for (const key of updated) {\n const mappingData = keyData.get(key);\n const element = this.lastElementsMap[key];\n const i = keyIndex.get(key);\n const shapeCfg = this.getShapeInfo(mappingData);\n const preShapeCfg = element.getModel();\n if (this.isCoordinateChanged || isModelChange(preShapeCfg, shapeCfg)) {\n element.animate = this.animateOption;\n // 通过绘制数据的变更来判断是否需要更新,因为用户有可能会修改图形属性映射\n element.update(shapeCfg); // 更新对应的 element\n }\n this.elementsMap[key] = element;\n this.elements[i] = element;\n }\n\n for (const key of removed) {\n const element = this.lastElementsMap[key];\n // 更新动画配置,用户有可能在更新之前有对动画进行配置操作\n element.animate = this.animateOption;\n element.destroy();\n }\n }\n\n /**\n * 获取组成一条线(一组数据)的所有点以及数据\n * @param mappingData 映射后的数组\n */\n protected getPointsAndData(mappingData: MappingDatum[]) {\n const points = [];\n const data = [];\n\n for (let i = 0, len = mappingData.length; i < len; i++) {\n const obj = mappingData[i];\n points.push({\n x: obj.x,\n y: obj.y,\n });\n data.push(obj[FIELD_ORIGIN]);\n }\n\n return {\n points,\n data,\n };\n }\n\n private getShapeInfo(mappingData: MappingDatum[]): ShapeInfo {\n const shapeCfg = this.getDrawCfg(mappingData[0]);\n const { points, data } = this.getPointsAndData(mappingData);\n shapeCfg.mappingData = mappingData;\n shapeCfg.data = data;\n shapeCfg.isStack = !!this.getAdjust('stack');\n shapeCfg.points = points;\n shapeCfg.connectNulls = this.connectNulls;\n shapeCfg.showSinglePoint = this.showSinglePoint;\n\n return shapeCfg;\n }\n}\n","import { each } from '@antv/util';\nimport { Coordinate, PathCommand } from '../../../dependents';\nimport { Point, Position, Shape, ShapeInfo } from '../../../interface';\n\nimport { getPathPoints } from '../util/get-path-points';\nimport { getStyle } from '../util/get-style';\nimport { getLinePath, getSplinePath } from '../util/path';\n\nfunction getPath(\n points: Point[],\n isInCircle: boolean,\n smooth: boolean,\n registeredShape: Shape,\n constraint?: Position[]\n): PathCommand[] {\n let path = [];\n\n if (points.length) {\n const topLinePoints = []; // area 区域上部分\n let bottomLinePoints = []; // area 区域下部分\n for (let i = 0, len = points.length; i < len; i++) {\n const point = points[i];\n topLinePoints.push(point[1]);\n bottomLinePoints.push(point[0]);\n }\n bottomLinePoints = bottomLinePoints.reverse();\n\n each([topLinePoints, bottomLinePoints], (pointsData, index) => {\n let subPath = [];\n const parsedPoints = registeredShape.parsePoints(pointsData);\n const p1 = parsedPoints[0];\n\n if (topLinePoints.length === 1 && bottomLinePoints.length === 1) {\n // 都只有一个点,绘制一条竖线\n subPath =\n index === 0\n ? [\n ['M', p1.x - 0.5, p1.y],\n ['L', p1.x + 0.5, p1.y],\n ]\n : [\n ['L', p1.x + 0.5, p1.y],\n ['L', p1.x - 0.5, p1.y],\n ];\n } else {\n if (isInCircle) {\n parsedPoints.push({ x: p1.x, y: p1.y });\n }\n if (smooth) {\n subPath = getSplinePath(parsedPoints, false, constraint);\n } else {\n subPath = getLinePath(parsedPoints, false);\n }\n if (index > 0) {\n subPath[0][0] = 'L';\n }\n }\n\n path = path.concat(subPath);\n });\n\n path.push(['Z']);\n }\n\n return path;\n}\n\n/**\n * @ignore\n * Gets shape attrs\n * @param cfg\n * @param isStroke\n * @param smooth\n * @param registeredShape\n * @param [constraint]\n * @returns\n */\nexport function getShapeAttrs(\n cfg: ShapeInfo,\n isStroke: boolean,\n smooth: boolean,\n registeredShape: Shape,\n constraint?: Position[]\n) {\n const attrs = getStyle(cfg, isStroke, !isStroke, 'lineWidth');\n const { connectNulls, isInCircle, points, showSinglePoint } = cfg;\n const pathPoints = getPathPoints(points, connectNulls, showSinglePoint); // 根据 connectNulls 配置获取图形关键点\n\n let path = [];\n for (let i = 0, len = pathPoints.length; i < len; i++) {\n const eachPoints = pathPoints[i];\n path = path.concat(getPath(eachPoints, isInCircle, smooth, registeredShape, constraint));\n }\n attrs.path = path;\n\n return attrs;\n}\n\n/**\n * @ignore\n * Gets constraint\n * @param coordinate\n * @returns constraint\n */\nexport function getConstraint(coordinate: Coordinate): Position[] {\n const { start, end } = coordinate;\n return [\n [start.x, end.y],\n [end.x, start.y],\n ];\n}\n","import { isArray } from '@antv/util';\nimport { IGroup } from '../../../dependents';\nimport { Point, ShapeInfo, ShapeMarkerCfg, ShapePoint } from '../../../interface';\nimport { registerShape, registerShapeFactory } from '../base';\nimport { getShapeAttrs } from './util';\n\nconst AreaShapeFactory = registerShapeFactory('area', {\n defaultShapeType: 'area',\n getDefaultPoints(pointInfo: ShapePoint): Point[] {\n // area 基本标记的绘制需要获取上下两边的顶点\n const { x, y0 } = pointInfo;\n const y = isArray(pointInfo.y) ? pointInfo.y : [y0, pointInfo.y];\n\n return y.map((yItem: number) => {\n return {\n x: x as number,\n y: yItem,\n };\n });\n },\n});\n\n// Area 几何标记默认的 shape:填充的区域图\nregisterShape('area', 'area', {\n draw(cfg: ShapeInfo, container: IGroup) {\n const attrs = getShapeAttrs(cfg, false, false, this);\n const shape = container.addShape({\n type: 'path',\n attrs,\n name: 'area',\n });\n\n return shape;\n },\n getMarker(markerCfg: ShapeMarkerCfg) {\n const { color } = markerCfg;\n return {\n symbol: (x: number, y: number, r: number = 5.5) => {\n return [['M', x - r, y - 4], ['L', x + r, y - 4], ['L', x + r, y + 4], ['L', x - r, y + 4], ['Z']];\n },\n style: {\n r: 5,\n fill: color,\n fillOpacity: 1,\n },\n };\n },\n});\n\nexport default AreaShapeFactory;\n","import { FIELD_ORIGIN } from '../constant';\nimport { MappingDatum } from '../interface';\nimport Path, { PathCfg } from './path';\nimport './shape/area';\n\n/** Area 几何标记构造函数参数 */\nexport interface AreaCfg extends PathCfg {\n /**\n * 面积图是否从 0 基准线开始填充。\n * 1. 默认值为 `true`,表现如下:\n * ![image](https://gw.alipayobjects.com/zos/rmsportal/ZQqwUCczalrKqGgagOVp.png)\n * 2. 当值为 `false` 时,表现如下:\n * ![image](https://gw.alipayobjects.com/zos/rmsportal/yPswkaXvUpCYOdhocGwB.png)\n */\n startOnZero?: boolean;\n}\n\n/**\n * Area 几何标记类。\n * 常用于绘制面积图。\n */\nexport default class Area extends Path {\n public readonly type: string = 'area';\n public readonly shapeType: string = 'area';\n /** 生成图形关键点 */\n public readonly generatePoints: boolean = true;\n /**\n * 面积图是否从 0 基准线开始填充。\n * 1. 默认值为 `true`,表现如下:\n * ![image](https://gw.alipayobjects.com/zos/rmsportal/ZQqwUCczalrKqGgagOVp.png)\n * 2. 当值为 `false` 时,表现如下:\n * ![image](https://gw.alipayobjects.com/zos/rmsportal/yPswkaXvUpCYOdhocGwB.png)\n */\n public readonly startOnZero: boolean = true;\n\n constructor(cfg: AreaCfg) {\n super(cfg);\n\n const { startOnZero = true, sortable = false, showSinglePoint = false } = cfg;\n this.startOnZero = startOnZero; // 默认为 true\n this.sortable = sortable; // 关闭默认的 X 轴数据排序\n this.showSinglePoint = showSinglePoint;\n }\n\n /**\n * 获取图形绘制的关键点以及数据\n * @param mappingData 映射后的数据\n */\n protected getPointsAndData(mappingData: MappingDatum[]) {\n const points = [];\n const data = [];\n\n for (let i = 0, len = mappingData.length; i < len; i++) {\n const obj = mappingData[i];\n points.push(obj.points);\n data.push(obj[FIELD_ORIGIN]);\n }\n\n return {\n points,\n data,\n };\n }\n\n /**\n * 获取 Y 轴上的最小值\n * @returns y 字段最小值\n */\n protected getYMinValue(): number {\n if (this.startOnZero) {\n return super.getYMinValue();\n }\n const yScale = this.getYScale();\n return yScale.min;\n }\n}\n","import { IGroup } from '../../../dependents';\nimport { Point, ShapeInfo, ShapeMarkerCfg, ShapePoint } from '../../../interface';\n\nimport { registerShape, registerShapeFactory } from '../base';\nimport { getStyle } from '../util/get-style';\nimport { getLinePath } from '../util/path';\nimport { splitPoints } from '../util/split-points';\n\nconst EdgeShapeFactory = registerShapeFactory('edge', {\n defaultShapeType: 'line',\n getDefaultPoints(pointInfo: ShapePoint): Point[] {\n return splitPoints(pointInfo);\n },\n});\n\nregisterShape('edge', 'line', {\n draw(cfg: ShapeInfo, container: IGroup) {\n const style = getStyle(cfg, true, false, 'lineWidth');\n const path = getLinePath(this.parsePoints(cfg.points), this.coordinate.isPolar);\n return container.addShape('path', {\n attrs: {\n ...style,\n path,\n },\n });\n },\n getMarker(markerCfg: ShapeMarkerCfg) {\n return {\n symbol: 'circle',\n style: {\n r: 4.5,\n fill: markerCfg.color,\n },\n };\n },\n});\n\nexport default EdgeShapeFactory;\n","import Geometry from './base';\nimport './shape/edge';\n\n/**\n * Edge 几何标记,用于绘制关系图中的**边**图形,如:\n * 1. 流程图\n * 2. 树\n * 3. 弧长连接图\n * 4. 和弦图\n * 5. 桑基图\n */\nexport default class Edge extends Geometry {\n public readonly type: string = 'edge';\n public readonly shapeType: string = 'edge';\n protected generatePoints: boolean = true;\n}\n","import ColorUtil from '@antv/color-util';\nimport { get, isNumber } from '@antv/util';\nimport { FIELD_ORIGIN } from '../constant';\nimport { Color, IShape } from '../dependents';\nimport { Data, Datum, MappingDatum, ShapeInfo, AttributeOption, ColorAttrCallback } from '../interface';\nimport Geometry from './base';\n\n/**\n * 用于绘制热力图。\n */\nexport default class Heatmap extends Geometry {\n public readonly type: string = 'heatmap';\n\n private paletteCache: Record = {};\n private grayScaleBlurredCanvas: HTMLCanvasElement;\n private shadowCanvas: HTMLCanvasElement;\n private imageShape: IShape;\n\n protected updateElements(mappingDataArray: MappingDatum[][], isUpdate: boolean = false) {\n for (let i = 0; i < mappingDataArray.length; i++) {\n const mappingData = mappingDataArray[i];\n const range = this.prepareRange(mappingData);\n const radius = this.prepareSize();\n\n let blur = get(this.styleOption, ['cfg', 'shadowBlur']);\n if (!isNumber(blur)) {\n blur = radius / 2;\n }\n\n this.prepareGreyScaleBlurredCircle(radius, blur);\n this.drawWithRange(mappingData, range, radius, blur);\n }\n }\n\n /** 热力图暂时不支持 callback 回调(文档需要说明下) */\n public color(field: AttributeOption | string, cfg?: string | string[] | ColorAttrCallback): Geometry {\n this.createAttrOption('color', field, typeof cfg !== 'function' ? cfg : '');\n\n return this;\n }\n\n /**\n * clear\n */\n public clear() {\n super.clear();\n this.clearShadowCanvasCtx();\n this.paletteCache = {};\n }\n\n private prepareRange(data: MappingDatum[]) {\n const colorAttr = this.getAttribute('color');\n const colorField = colorAttr.getFields()[0];\n\n let min = Infinity;\n let max = -Infinity;\n data.forEach((row) => {\n const value = row[FIELD_ORIGIN][colorField];\n if (value > max) {\n max = value;\n }\n if (value < min) {\n min = value;\n }\n });\n\n if (min === max) {\n min = max - 1;\n }\n\n return [min, max];\n }\n\n private prepareSize() {\n let radius = this.getDefaultValue('size');\n if (!isNumber(radius)) {\n radius = this.getDefaultSize();\n }\n\n return radius;\n }\n\n private prepareGreyScaleBlurredCircle(radius: number, blur: number) {\n const grayScaleBlurredCanvas = this.getGrayScaleBlurredCanvas();\n const r2 = radius + blur;\n const ctx = grayScaleBlurredCanvas.getContext('2d');\n grayScaleBlurredCanvas.width = grayScaleBlurredCanvas.height = r2 * 2;\n ctx.clearRect(0, 0, grayScaleBlurredCanvas.width, grayScaleBlurredCanvas.height);\n ctx.shadowOffsetX = ctx.shadowOffsetY = r2 * 2;\n ctx.shadowBlur = blur;\n ctx.shadowColor = 'black';\n\n ctx.beginPath();\n ctx.arc(-r2, -r2, radius, 0, Math.PI * 2, true);\n ctx.closePath();\n ctx.fill();\n }\n\n private drawWithRange(data: MappingDatum[], range: number[], radius: number, blur: number) {\n // canvas size\n const { start, end } = this.coordinate;\n const width = this.coordinate.getWidth();\n const height = this.coordinate.getHeight();\n\n // value, range, etc\n const colorAttr = this.getAttribute('color');\n const valueField = colorAttr.getFields()[0];\n\n // prepare shadow canvas context\n this.clearShadowCanvasCtx();\n const ctx = this.getShadowCanvasCtx();\n // filter data\n if (range) {\n data = data.filter((row) => {\n return row[FIELD_ORIGIN][valueField] <= range[1] && row[FIELD_ORIGIN][valueField] >= range[0];\n });\n }\n\n // step1. draw points with shadow\n const scale = this.scales[valueField];\n for (const obj of data) {\n const { x, y } = this.getDrawCfg(obj);\n const alpha = scale.scale(obj[FIELD_ORIGIN][valueField]);\n this.drawGrayScaleBlurredCircle((x as number) - start.x, (y as number) - end.y, radius + blur, alpha, ctx);\n }\n\n // step2. convert pixels\n const colored = ctx.getImageData(0, 0, width, height);\n this.clearShadowCanvasCtx();\n this.colorize(colored);\n ctx.putImageData(colored, 0, 0);\n const imageShape = this.getImageShape();\n imageShape.attr('x', start.x);\n imageShape.attr('y', end.y);\n imageShape.attr('width', width);\n imageShape.attr('height', height);\n imageShape.attr('img', ctx.canvas);\n imageShape.set('origin', this.getShapeInfo(data)); // 存储绘图信息数据\n }\n\n private getDefaultSize() {\n const position = this.getAttribute('position');\n const coordinate = this.coordinate;\n return Math.min(\n coordinate.getWidth() / (position.scales[0].ticks.length * 4),\n coordinate.getHeight() / (position.scales[1].ticks.length * 4)\n );\n }\n\n private clearShadowCanvasCtx() {\n const ctx = this.getShadowCanvasCtx();\n ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);\n }\n\n private getShadowCanvasCtx() {\n let canvas = this.shadowCanvas;\n if (!canvas) {\n canvas = document.createElement('canvas');\n this.shadowCanvas = canvas;\n }\n canvas.width = this.coordinate.getWidth();\n canvas.height = this.coordinate.getHeight();\n return canvas.getContext('2d');\n }\n\n private getGrayScaleBlurredCanvas() {\n if (!this.grayScaleBlurredCanvas) {\n this.grayScaleBlurredCanvas = document.createElement('canvas');\n }\n\n return this.grayScaleBlurredCanvas;\n }\n\n private drawGrayScaleBlurredCircle(x: number, y: number, r: number, alpha: number, ctx: CanvasRenderingContext2D) {\n const grayScaleBlurredCanvas = this.getGrayScaleBlurredCanvas();\n ctx.globalAlpha = alpha;\n ctx.drawImage(grayScaleBlurredCanvas, x - r, y - r);\n }\n\n private colorize(img: ImageData) {\n const colorAttr = this.getAttribute('color') as Color;\n const pixels = img.data;\n const paletteCache = this.paletteCache;\n for (let i = 3; i < pixels.length; i += 4) {\n const alpha = pixels[i]; // get gradient color from opacity value\n if (isNumber(alpha)) {\n const palette = paletteCache[alpha] ? paletteCache[alpha] : ColorUtil.rgb2arr(colorAttr.gradient(alpha / 256));\n pixels[i - 3] = palette[0];\n pixels[i - 2] = palette[1];\n pixels[i - 1] = palette[2];\n pixels[i] = alpha;\n }\n }\n }\n\n private getImageShape() {\n let imageShape = this.imageShape;\n if (imageShape) {\n return imageShape;\n }\n const container = this.container;\n imageShape = container.addShape({\n type: 'image',\n attrs: {},\n });\n this.imageShape = imageShape;\n return imageShape;\n }\n\n private getShapeInfo(mappingData: MappingDatum[]): ShapeInfo {\n const shapeCfg = this.getDrawCfg(mappingData[0]);\n\n const data = mappingData.map((obj: Datum) => {\n return obj[FIELD_ORIGIN];\n });\n\n return {\n ...shapeCfg,\n mappingData,\n data,\n };\n }\n}\n","import { Coordinate } from '@antv/coord';\nimport { isArray, isNil, get } from '@antv/util';\nimport { getAngle, getSectorPath } from '../../../util/graphics';\nimport { PathCommand } from '../../../dependents';\nimport { Point, ShapeInfo, ShapePoint } from '../../../interface';\n\n/**\n * @ignore\n * 根据数据点生成矩形的四个关键点\n * @param pointInfo 数据点信息\n * @param [isPyramid] 是否为尖底漏斗图\n * @returns rect points 返回矩形四个顶点信息\n */\nexport function getRectPoints(pointInfo: ShapePoint): Point[] {\n const { x, y, y0, size } = pointInfo;\n // 有 4 种情况,\n // 1. x, y 都不是数组\n // 2. y是数组,x不是\n // 3. x是数组,y不是\n // 4. x, y 都是数组\n let yMin;\n let yMax;\n if (isArray(y)) {\n [yMin, yMax] = y;\n } else {\n yMin = y0;\n yMax = y;\n }\n\n let xMin;\n let xMax;\n if (isArray(x)) {\n [xMin, xMax] = x;\n } else {\n xMin = x - size / 2;\n xMax = x + size / 2;\n }\n\n const points = [\n { x: xMin, y: yMin },\n { x: xMin, y: yMax },\n ];\n\n // 矩形的四个关键点,结构如下(左下角顺时针连接)\n // 1 ---- 2\n // | |\n // 0 ---- 3\n points.push({ x: xMax, y: yMax }, { x: xMax, y: yMin });\n\n return points;\n}\n\n/**\n * @ignore\n * 根据矩形关键点绘制 path\n * @param points 关键点数组\n * @param isClosed path 是否需要闭合\n * @returns 返回矩形的 path\n */\nexport function getRectPath(points: Point[], isClosed: boolean = true): PathCommand[] {\n const path = [];\n const firstPoint = points[0];\n path.push(['M', firstPoint.x, firstPoint.y]);\n for (let i = 1, len = points.length; i < len; i++) {\n path.push(['L', points[i].x, points[i].y]);\n }\n // 对于 shape=\"line\" path 不应该闭合,否则会造成 lineCap 绘图属性失效\n if (isClosed) {\n path.push(['L', firstPoint.x, firstPoint.y]); // 需要闭合\n path.push(['z']);\n }\n return path;\n}\n\n/**\n * 处理 rect path 的 radius\n * @returns 返回矩形 path 的四个角的 arc 半径\n */\nexport function parseRadius(radius: number | number[], minLength: number): number[] {\n let r1 = 0;\n let r2 = 0;\n let r3 = 0;\n let r4 = 0;\n if (isArray(radius)) {\n if (radius.length === 1) {\n r1 = r2 = r3 = r4 = radius[0];\n } else if (radius.length === 2) {\n r1 = r3 = radius[0];\n r2 = r4 = radius[1];\n } else if (radius.length === 3) {\n r1 = radius[0];\n r2 = r4 = radius[1];\n r3 = radius[2];\n } else {\n r1 = radius[0];\n r2 = radius[1];\n r3 = radius[2];\n r4 = radius[3];\n }\n } else {\n r1 = r2 = r3 = r4 = radius;\n }\n\n // 处理 边界值\n if (r1 + r2 > minLength) {\n r1 = r1 ? minLength / (1 + r2 / r1) : 0;\n r2 = minLength - r1;\n }\n\n if (r3 + r4 > minLength) {\n r3 = r3 ? minLength / (1 + r4 / r3) : 0;\n r4 = minLength - r3;\n }\n\n return [r1 || 0, r2 || 0, r3 || 0, r4 || 0];\n}\n\n/**\n * 获取 interval 矩形背景的 path\n * @param cfg 关键点的信息\n * @param points 已转化为画布坐标的 4 个关键点\n * @param coordinate 坐标系\n * @returns 返回矩形背景的 path\n */\nexport function getBackgroundRectPath(cfg: ShapeInfo, points: Point[], coordinate: Coordinate): PathCommand[] {\n let path = [];\n if (coordinate.isRect) {\n const p0 = coordinate.isTransposed\n ? { x: coordinate.start.x, y: points[0].y }\n : { x: points[0].x, y: coordinate.start.y };\n const p1 = coordinate.isTransposed\n ? { x: coordinate.end.x, y: points[2].y }\n : { x: points[3].x, y: coordinate.end.y };\n\n // corner radius of background shape works only in 笛卡尔坐标系\n const radius = get(cfg, ['background', 'style', 'radius']);\n if (radius) {\n const width = coordinate.isTransposed ? Math.abs(points[0].y - points[2].y) : points[2].x - points[1].x;\n const height = coordinate.isTransposed ? coordinate.getWidth() : coordinate.getHeight();\n const [r1, r2, r3, r4] = parseRadius(radius, Math.min(width, height));\n\n // 同时存在 坐标系是否发生转置 和 y 镜像的时候\n const isReflectYTransposed = (coordinate.isTransposed && coordinate.isReflect('y'));\n const bump = isReflectYTransposed ? 0 : 1;\n const opposite = (r: number) => isReflectYTransposed ? -r : r;\n\n path.push(['M', p0.x, p1.y + opposite(r1)]);\n r1 !== 0 && path.push(['A', r1, r1, 0, 0, bump, p0.x + r1, p1.y]);\n path.push(['L', p1.x - r2, p1.y]);\n r2 !== 0 && path.push(['A', r2, r2, 0, 0, bump, p1.x, p1.y + opposite(r2)]);\n path.push(['L', p1.x, p0.y - opposite(r3)]);\n r3 !== 0 && path.push(['A', r3, r3, 0, 0, bump, p1.x - r3, p0.y]);\n path.push(['L', p0.x + r4, p0.y]);\n r4 !== 0 && path.push(['A', r4, r4, 0, 0, bump, p0.x, p0.y - opposite(r4)]);\n } else {\n path.push(['M', p0.x, p0.y]);\n path.push(['L', p1.x, p0.y]);\n path.push(['L', p1.x, p1.y]);\n path.push(['L', p0.x, p1.y]);\n path.push(['L', p0.x, p0.y]);\n }\n\n path.push(['z']);\n }\n\n if (coordinate.isPolar) {\n const center = coordinate.getCenter();\n const { startAngle, endAngle } = getAngle(cfg, coordinate);\n if (coordinate.type !== 'theta' && !coordinate.isTransposed) {\n // 获取扇形 path\n path = getSectorPath(center.x, center.y, coordinate.getRadius(), startAngle, endAngle);\n } else {\n const pow = (v) => Math.pow(v, 2);\n const r1 = Math.sqrt(pow(center.x - points[0].x) + pow(center.y - points[0].y));\n const r2 = Math.sqrt(pow(center.x - points[2].x) + pow(center.y - points[2].y));\n // 获取扇形 path(其实是一个圆环,从 coordinate 的起始角度到结束角度)\n path = getSectorPath(center.x, center.y, r1, coordinate.startAngle, coordinate.endAngle, r2);\n }\n }\n return path;\n}\n\n/**\n * @ignore\n * 根据矩形关键点绘制 path\n * @param points 关键点数组\n * @param lineCap 'round'圆角样式\n * @param coor 坐标\n * @returns 返回矩形的 path\n */\nexport function getIntervalRectPath(points: Point[], lineCap: CanvasLineCap, coor: Coordinate): PathCommand[] {\n const width = coor.getWidth();\n const height = coor.getHeight();\n const isRect = coor.type === 'rect';\n let path = [];\n const r = (points[2].x - points[1].x) / 2;\n const ry = coor.isTransposed ? (r * height) / width : (r * width) / height;\n if (lineCap === 'round') {\n if (isRect) {\n path.push(['M', points[0].x, points[0].y + ry]);\n path.push(['L', points[1].x, points[1].y - ry]);\n path.push(['A', r, r, 0, 0, 1, points[2].x, points[2].y - ry]);\n path.push(['L', points[3].x, points[3].y + ry]);\n path.push(['A', r, r, 0, 0, 1, points[0].x, points[0].y + ry]);\n } else {\n path.push(['M', points[0].x, points[0].y]);\n path.push(['L', points[1].x, points[1].y]);\n path.push(['A', r, r, 0, 0, 1, points[2].x, points[2].y]);\n path.push(['L', points[3].x, points[3].y]);\n path.push(['A', r, r, 0, 0, 1, points[0].x, points[0].y]);\n }\n path.push(['z']);\n } else {\n path = getRectPath(points);\n }\n return path;\n}\n\n/**\n * @ignore\n * 根据 funnel 关键点绘制漏斗图的 path\n * @param points 图形关键点信息\n * @param nextPoints 下一个数据的图形关键点信息\n * @param isPyramid 是否为尖底漏斗图\n * @returns 返回漏斗图的图形 path\n */\nexport function getFunnelPath(points: Point[], nextPoints: Point[], isPyramid: boolean) {\n const path = [];\n if (!isNil(nextPoints)) {\n path.push(\n ['M', points[0].x, points[0].y],\n ['L', points[1].x, points[1].y],\n ['L', nextPoints[1].x, nextPoints[1].y],\n ['L', nextPoints[0].x, nextPoints[0].y],\n ['Z']\n );\n } else if (isPyramid) {\n // 金字塔最底部\n path.push(\n ['M', points[0].x, points[0].y],\n ['L', points[1].x, points[1].y],\n ['L', (points[2].x + points[3].x) / 2, (points[2].y + points[3].y) / 2],\n ['Z']\n );\n } else {\n // 漏斗图最底部\n path.push(\n ['M', points[0].x, points[0].y],\n ['L', points[1].x, points[1].y],\n ['L', points[2].x, points[2].y],\n ['L', points[3].x, points[3].y],\n ['Z']\n );\n }\n\n return path;\n}\n\n/**\n * 交换两个对象\n */\nfunction swap(p0: T, p1: T) {\n return [p1, p0];\n}\n\n/**\n * 获取 倒角 矩形\n * - 目前只适用于笛卡尔坐标系下\n */\nexport function getRectWithCornerRadius(points: Point[], coordinate: Coordinate, radius?: number | number[]) {\n // 获取 四个关键点\n let [p0, p1, p2, p3] = [...points];\n let [r1, r2, r3, r4] = typeof radius === 'number' ? Array(4).fill(radius) : radius;\n\n if (coordinate.isTransposed) {\n [p1, p3] = swap(p1, p3);\n }\n\n /**\n * 存在镜像\n */\n if (coordinate.isReflect('y')) {\n [p0, p1] = swap(p0, p1);\n [p2, p3] = swap(p2, p3);\n }\n if (coordinate.isReflect('x')) {\n [p0, p3] = swap(p0, p3);\n [p1, p2] = swap(p1, p2);\n }\n\n const path = [];\n\n\n /**\n * p1 → p2\n * ↑ ↓\n * p0 ← p3\n *\n * 负数的情况,关键点会变成下面的形式\n *\n * p0 ← p3 p2 ← p1\n * ↓ ↑ ↓ ↑\n * p1 → p2 --> (转置下) p3 → p0\n */\n const abs = v => Math.abs(v);\n [r1, r2, r3, r4] = parseRadius([r1, r2, r3, r4], Math.min(abs(p3.x - p0.x), abs(p1.y - p0.y))).map(d => abs(d));\n\n if (coordinate.isTransposed) {\n [r1, r2, r3, r4] = [r4, r1, r2, r3]\n }\n\n if (p0.y < p1.y /** 负数情况 */) {\n path.push(['M', p3.x, p3.y + r3]);\n r3 !== 0 && path.push(['A', r3, r3, 0, 0, 0, p3.x - r3, p3.y]);\n path.push(['L', p0.x + r4, p0.y]);\n r4 !== 0 && path.push(['A', r4, r4, 0, 0, 0, p0.x, p0.y + r4]);\n path.push(['L', p1.x, p1.y - r1]);\n r1 !== 0 && path.push(['A', r1, r1, 0, 0, 0/** 逆时针 */, p1.x + r1, p1.y]);\n path.push(['L', p2.x - r2, p2.y]);\n r2 !== 0 && path.push(['A', r2, r2, 0, 0, 0, p2.x, p2.y - r2]);\n path.push(['L', p3.x, p3.y + r3]);\n path.push(['z']);\n } else if (p3.x < p0.x) {\n path.push(['M', p2.x + r2, p2.y]);\n r2 !== 0 && path.push(['A', r2, r2, 0, 0, 0, p2.x, p2.y + r2]);\n path.push(['L', p3.x, p3.y - r3]);\n r3 !== 0 && path.push(['A', r3, r3, 0, 0, 0, p3.x + r3, p3.y]);\n path.push(['L', p0.x - r4, p0.y]);\n r4 !== 0 && path.push(['A', r4, r4, 0, 0, 0, p0.x, p0.y - r4]);\n path.push(['L', p1.x, p1.y + r1]);\n r1 !== 0 && path.push(['A', r1, r1, 0, 0, 0, p1.x - r1, p1.y]);\n path.push(['L', p2.x + r2, p2.y]);\n path.push(['z']);\n } else {\n path.push(['M', p1.x, p1.y + r1]);\n r1 !== 0 && path.push(['A', r1, r1, 0, 0, 1, p1.x + r1, p1.y]);\n path.push(['L', p2.x - r2, p2.y]);\n r2 !== 0 && path.push(['A', r2, r2, 0, 0, 1, p2.x, p2.y + r2]);\n path.push(['L', p3.x, p3.y - r3]);\n r3 !== 0 && path.push(['A', r3, r3, 0, 0, 1, p3.x - r3, p3.y]);\n path.push(['L', p0.x + r4, p0.y]);\n r4 !== 0 && path.push(['A', r4, r4, 0, 0, 1, p0.x, p0.y - r4]);\n path.push(['L', p1.x, p1.y + r1]);\n path.push(['z']);\n }\n\n return path;\n}\n","import { IGroup } from '../../../dependents';\nimport { Point, ShapeInfo, ShapeMarkerCfg, ShapePoint } from '../../../interface';\n\nimport { registerShape, registerShapeFactory } from '../base';\nimport { BACKGROUND_SHAPE } from '../constant';\nimport { getBackgroundRectStyle, getStyle } from '../util/get-style';\nimport { getBackgroundRectPath, getIntervalRectPath, getRectPoints, getRectWithCornerRadius } from './util';\n\n/** Interval 的 shape 工厂 */\nconst IntervalShapeFactory = registerShapeFactory('interval', {\n defaultShapeType: 'rect',\n getDefaultPoints(pointInfo: ShapePoint): Point[] {\n return getRectPoints(pointInfo);\n },\n});\n\n/** Inerval 默认 shape,填充的矩形 */\nregisterShape('interval', 'rect', {\n draw(cfg: ShapeInfo, container: IGroup) {\n const style = getStyle(cfg, false, true);\n let group = container;\n\n const backgroundCfg = cfg?.background;\n if (backgroundCfg) {\n group = container.addGroup({\n name: 'interval-group',\n });\n const backgroundStyle = getBackgroundRectStyle(cfg);\n const backgroundPath = getBackgroundRectPath(cfg, this.parsePoints(cfg.points) as Point[], this.coordinate);\n group.addShape('path', {\n attrs: {\n ...backgroundStyle,\n path: backgroundPath,\n },\n capture: false,\n zIndex: -1,\n name: BACKGROUND_SHAPE,\n });\n }\n\n let path;\n if (style.radius && this.coordinate.isRect) {\n path = getRectWithCornerRadius(this.parsePoints(cfg.points), this.coordinate, style.radius);\n } else {\n path = this.parsePath(getIntervalRectPath(cfg.points as Point[], style.lineCap, this.coordinate));\n }\n\n const shape = group.addShape('path', {\n attrs: {\n ...style,\n path,\n },\n name: 'interval',\n });\n\n return backgroundCfg ? group : shape;\n },\n getMarker(markerCfg: ShapeMarkerCfg) {\n const { color, isInPolar } = markerCfg;\n if (isInPolar) {\n return {\n symbol: 'circle',\n style: {\n r: 4.5,\n fill: color,\n },\n };\n }\n\n return {\n symbol: 'square',\n style: {\n r: 4,\n fill: color,\n },\n };\n },\n});\n\nexport default IntervalShapeFactory;\n","import { flatten, isString, valuesOfKey, isNil } from '@antv/util';\nimport { getXDimensionLength } from '../../util/coordinate';\n\n// 已经排序后的数据查找距离最小的\nfunction findMinDistance(arr, scale) {\n const count = arr.length;\n let sourceArr = arr;\n if (isString(sourceArr[0])) {\n // 日期类型的 values 经常上文本类型,所以需要转换一下\n sourceArr = arr.map((v: string) => {\n return scale.translate(v);\n });\n }\n let distance = sourceArr[1] - sourceArr[0];\n for (let i = 2; i < count; i++) {\n const tmp = sourceArr[i] - sourceArr[i - 1];\n if (distance > tmp) {\n distance = tmp;\n }\n }\n return distance;\n}\n\nfunction getDodgeCount(dataArray, dodgeBy) {\n if (dodgeBy) {\n const mergeData = flatten(dataArray);\n const values = valuesOfKey(mergeData, dodgeBy);\n return values.length;\n }\n\n return dataArray.length;\n}\n\n/** @ignore */\nexport function getDefaultSize(geometry): number {\n const theme = geometry.theme;\n const coordinate = geometry.coordinate;\n const xScale = geometry.getXScale();\n const xValues = xScale.values;\n const dataArray = geometry.beforeMappingData;\n let count: number = xValues.length;\n const xDimensionLength = getXDimensionLength(geometry.coordinate);\n // 获取柱宽相关配置项\n const { intervalPadding, dodgePadding } = geometry;\n // 兼容theme配置\n const maxColumnWidth = geometry.maxColumnWidth || theme.maxColumnWidth;\n const minColumnWidth = geometry.minColumnWidth || theme.minColumnWidth;\n const columnWidthRatio = geometry.columnWidthRatio || theme.columnWidthRatio;\n const multiplePieWidthRatio = geometry.multiplePieWidthRatio || theme.multiplePieWidthRatio;\n const roseWidthRatio = geometry.roseWidthRatio || theme.roseWidthRatio;\n\n // 线性情况下count值\n if (xScale.isLinear && xValues.length > 1) {\n // Linear 类型用户有可能设置了 min, max 范围所以需要根据数据最小区间计算 count\n xValues.sort();\n const interval = findMinDistance(xValues, xScale);\n count = (xScale.max - xScale.min) / interval;\n if (xValues.length > count) {\n count = xValues.length;\n }\n }\n\n const range = xScale.range;\n let normalizedSize = 1 / count;\n let wr = 1;\n if (coordinate.isPolar) {\n // 极坐标场景\n if (coordinate.isTransposed && count > 1) {\n // 极坐标下多层环图\n wr = multiplePieWidthRatio;\n } else {\n wr = roseWidthRatio;\n }\n } else {\n // 非极坐标场景\n if (xScale.isLinear) {\n normalizedSize *= range[1] - range[0];\n }\n wr = columnWidthRatio;\n }\n\n // 基础柱状图\n if (!isNil(intervalPadding) && intervalPadding >= 0) {\n // 配置组间距情况\n const normalizedIntervalPadding = intervalPadding / xDimensionLength;\n normalizedSize = (1 - (count - 1) * normalizedIntervalPadding) / count;\n } else {\n // 默认情况\n normalizedSize *= wr;\n }\n // 分组柱状图\n if (geometry.getAdjust('dodge')) {\n const dodgeAdjust = geometry.getAdjust('dodge');\n const dodgeBy = dodgeAdjust.dodgeBy;\n const dodgeCount = getDodgeCount(dataArray, dodgeBy);\n if (!isNil(dodgePadding) && dodgePadding >= 0) {\n // 仅配置组内间距情况\n const normalizedDodgePadding = dodgePadding / xDimensionLength;\n normalizedSize = (normalizedSize - normalizedDodgePadding * (dodgeCount - 1)) / dodgeCount;\n } else if (!isNil(intervalPadding) && intervalPadding >= 0) {\n // 设置组间距但未设置组内间距情况,避免组间距过小导致图形重叠,需乘以wr\n normalizedSize *= wr;\n normalizedSize = normalizedSize / dodgeCount;\n } else {\n // 组间距和组内间距均未配置\n normalizedSize = normalizedSize / dodgeCount;\n }\n normalizedSize = normalizedSize >= 0 ? normalizedSize : 0;\n }\n\n // 最大和最小限制\n if (!isNil(maxColumnWidth) && maxColumnWidth >= 0) {\n const normalizedMaxColumnWidth = maxColumnWidth / xDimensionLength;\n if (normalizedSize > normalizedMaxColumnWidth) {\n normalizedSize = normalizedMaxColumnWidth;\n }\n }\n\n // \bminColumnWidth可能设置为0\n if (!isNil(minColumnWidth) && minColumnWidth >= 0) {\n const normalizedMinColumnWidth = minColumnWidth / xDimensionLength;\n if (normalizedSize < normalizedMinColumnWidth) {\n normalizedSize = normalizedMinColumnWidth;\n }\n }\n\n return normalizedSize;\n}\n","import { get } from '@antv/util';\nimport { Datum, MappingDatum, ShapeInfo, LooseObject } from '../interface';\nimport { ShapeAttrs } from '../dependents';\nimport { getXDimensionLength } from '../util/coordinate';\nimport Geometry, { GeometryCfg } from './base';\n/** 引入对应的 ShapeFactory */\nimport './shape/interval';\nimport { getDefaultSize } from './util/shape-size';\nimport { getMaxScale } from '../util/scale';\n\n/** Path 构造函数参数类型 */\nexport interface IntervalCfg extends GeometryCfg {\n /** shape 背景,只对 Interval Geometry 生效,目前只对 interval-rect shape 生效。 */\n background?: { style?: ShapeAttrs };\n}\n\n/**\n * Interval 几何标记。\n * 用于绘制柱状图、饼图、条形图、玫瑰图等。\n */\nexport default class Interval extends Geometry {\n public readonly type: string = 'interval';\n public readonly shapeType: string = 'interval';\n /** shape 背景。目前只对 interval-rect shape 生效。 */\n protected background?: { style?: ShapeAttrs };\n protected generatePoints: boolean = true;\n\n constructor(cfg: IntervalCfg) {\n super(cfg);\n\n const { background } = cfg;\n this.background = background;\n }\n\n /**\n * 获取每条数据的 Shape 绘制信息\n * @param obj 经过分组 -> 数字化 -> adjust 调整后的数据记录\n * @returns\n */\n protected createShapePointsCfg(obj: Datum) {\n const cfg = super.createShapePointsCfg(obj);\n\n // 计算每个 shape 的 size\n let size;\n const sizeAttr = this.getAttribute('size');\n if (sizeAttr) {\n size = this.getAttributeValues(sizeAttr, obj)[0];\n // 归一化\n const coordinate = this.coordinate;\n const coordinateWidth = getXDimensionLength(coordinate);\n size = size / coordinateWidth;\n } else {\n if (!this.defaultSize) {\n this.defaultSize = getDefaultSize(this);\n }\n size = this.defaultSize;\n }\n cfg.size = size;\n\n return cfg;\n }\n\n /**\n * 调整 y 轴的 scale 范围。\n * 对于 Y 轴为数值轴柱状图,默认从 0 开始 生长。\n */\n protected adjustScale() {\n super.adjustScale();\n const yScale = this.getYScale();\n // 特殊逻辑:饼图需要填充满整个空间\n if (this.coordinate.type === 'theta') {\n yScale.change({\n nice: false,\n min: 0,\n // 发生过 stack 调整,yScale 的 max 被调整过,this.updateStackRange()\n max: getMaxScale(yScale),\n });\n } else {\n // 柱状图数值轴默认从 0 开始\n const scaleDefs = this.scaleDefs;\n const { field, min, max, type } = yScale;\n if (type !== 'time') {\n // time 类型不做调整\n // 柱状图的 Y 轴要从 0 开始生长,但是如果用户设置了则以用户的为准\n if (min > 0 && !get(scaleDefs, [field, 'min'])) {\n yScale.change({\n min: 0,\n });\n }\n // 柱当柱状图全为负值时也需要从 0 开始生长,但是如果用户设置了则以用户的为准\n if (max <= 0 && !get(scaleDefs, [field, 'max'])) {\n yScale.change({\n max: 0,\n });\n }\n }\n }\n }\n\n /**\n * @override\n */\n protected getDrawCfg(mappingData: MappingDatum): ShapeInfo {\n const shapeCfg = super.getDrawCfg(mappingData);\n shapeCfg.background = this.background;\n\n return shapeCfg;\n }\n}\n","import Path, { PathCfg } from './path';\n/** 引入 Path 对应的 ShapeFactory */\nimport './shape/line';\n\n/**\n * Line 几何标记。\n * 常用于折线图的绘制。\n */\nexport default class Line extends Path {\n public type: string = 'line';\n\n constructor(cfg: PathCfg) {\n super(cfg);\n\n const { sortable = false } = cfg; // 关闭默认的 X 轴数据排序\n this.sortable = sortable;\n }\n}\n","import { IGroup, IShape } from '../../../dependents';\nimport { ShapeInfo } from '../../../interface';\nimport { MarkerSymbols } from '../../../util/marker';\nimport { getStyle } from '../util/get-style';\n\nexport const SHAPES = ['circle', 'square', 'bowtie', 'diamond', 'hexagon', 'triangle', 'triangle-down'];\nexport const HOLLOW_SHAPES = ['cross', 'tick', 'plus', 'hyphen', 'line'];\n\n/**\n * @ignore\n * Draws points\n * @param shape\n * @param cfg\n * @param container\n * @param shapeName\n * @param isStroke\n * @returns points\n */\nexport function drawPoints(\n shape,\n cfg: ShapeInfo,\n container: IGroup,\n shapeName: string,\n isStroke: boolean\n): IShape | IGroup {\n const style = getStyle(cfg, isStroke, !isStroke, 'r');\n const points = shape.parsePoints(cfg.points);\n let pointPosition = points[0];\n if (cfg.isStack) {\n pointPosition = points[1];\n } else if (points.length > 1) {\n const group = container.addGroup();\n for (const point of points) {\n group.addShape({\n type: 'marker',\n attrs: {\n ...style,\n symbol: MarkerSymbols[shapeName] || shapeName,\n ...point,\n },\n });\n }\n return group;\n }\n\n return container.addShape({\n type: 'marker',\n attrs: {\n ...style,\n symbol: MarkerSymbols[shapeName] || shapeName,\n ...pointPosition,\n },\n });\n}\n","import { each } from '@antv/util';\nimport { IGroup } from '../../../dependents';\nimport { Point, ShapeInfo, ShapeMarkerCfg, ShapePoint } from '../../../interface';\n\nimport { MarkerSymbols } from '../../../util/marker';\nimport { registerShape, registerShapeFactory } from '../base';\nimport { splitPoints } from '../util/split-points';\nimport { drawPoints, SHAPES } from './util';\n\nconst PointShapeFactory = registerShapeFactory('point', {\n defaultShapeType: 'hollow-circle',\n getDefaultPoints(pointInfo: ShapePoint): Point[] {\n return splitPoints(pointInfo);\n },\n});\n\neach(SHAPES, (shapeName: string) => {\n // 添加该 shape 对应的 hollow-shape\n registerShape('point', `hollow-${shapeName}`, {\n draw(cfg: ShapeInfo, container: IGroup) {\n return drawPoints(this, cfg, container, shapeName, true);\n },\n getMarker(markerCfg: ShapeMarkerCfg) {\n const { color } = markerCfg;\n return {\n symbol: MarkerSymbols[shapeName] || shapeName,\n style: {\n r: 4.5,\n stroke: color,\n fill: null,\n },\n };\n },\n });\n});\n\nexport default PointShapeFactory;\n","import { MappingDatum, ShapeInfo } from '../interface';\nimport Geometry from './base';\n/** 引入 Point 对应的 ShapeFactory */\nimport './shape/point';\n\n/**\n * Point 几何标记。\n * 常用于绘制点图。\n */\nexport default class Point extends Geometry {\n public readonly type: string = 'point';\n public readonly shapeType: string = 'point';\n protected generatePoints: boolean = true;\n\n /**\n * 获取一个点的绘制信息。\n * @param mappingDatum\n * @returns draw cfg\n */\n protected getDrawCfg(mappingDatum: MappingDatum): ShapeInfo {\n const shapeCfg = super.getDrawCfg(mappingDatum);\n\n return {\n ...shapeCfg,\n isStack: !!this.getAdjust('stack'), // 层叠点图\n };\n }\n}\n","import { each, isEmpty, isEqual, last } from '@antv/util';\nimport { IGroup } from '../../../dependents';\nimport { ShapeInfo, ShapeMarkerCfg, ShapePoint } from '../../../interface';\n\nimport { registerShape, registerShapeFactory } from '../base';\nimport { getStyle } from '../util/get-style';\n\nfunction getPath(points: any[]) {\n let flag: any = points[0];\n let i = 1;\n\n const path = [['M', flag.x, flag.y]];\n\n while (i < points.length) {\n const c: any = points[i];\n if (c.x !== points[i - 1].x || c.y !== points[i - 1].y) {\n path.push(['L', c.x, c.y]);\n if (c.x === flag.x && c.y === flag.y && i < points.length - 1) {\n flag = points[i + 1];\n path.push(['Z']);\n path.push(['M', flag.x, flag.y]);\n i++;\n }\n }\n i++;\n }\n\n if (!isEqual(last(path), flag)) {\n path.push(['L', flag.x, flag.y]);\n }\n\n path.push(['Z']);\n\n return path;\n}\n\nconst PolygonShapeFactory = registerShapeFactory('polygon', {\n defaultShapeType: 'polygon',\n getDefaultPoints(pointInfo: ShapePoint) {\n const points = [];\n each(pointInfo.x as number[], (subX, index) => {\n const subY = pointInfo.y[index];\n points.push({\n x: subX,\n y: subY,\n });\n });\n return points;\n },\n});\n\nregisterShape('polygon', 'polygon', {\n draw(cfg: ShapeInfo, container: IGroup) {\n if (!isEmpty(cfg.points)) {\n const shapeAttrs = getStyle(cfg, true, true);\n const path = this.parsePath(getPath(cfg.points));\n return container.addShape('path', {\n attrs: {\n ...shapeAttrs,\n path,\n },\n name: 'polygon',\n });\n }\n },\n getMarker(markerCfg: ShapeMarkerCfg) {\n const { color } = markerCfg;\n return {\n symbol: 'square',\n style: {\n r: 4,\n fill: color,\n },\n };\n },\n});\n\nexport default PolygonShapeFactory;\n","import { isArray } from '@antv/util';\nimport { Datum } from '../interface';\nimport Geometry from './base';\n/** 引入 Path 对应的 ShapeFactory */\nimport './shape/polygon';\n\n/**\n * Polygon 几何标记。\n * 常用于绘制色块图、日历图等。\n */\nexport default class Polygon extends Geometry {\n public readonly type: string = 'polygon';\n public readonly shapeType: string = 'polygon';\n protected generatePoints: boolean = true;\n\n /**\n * 获取 Shape 的关键点数据。\n * @param obj\n * @returns\n */\n protected createShapePointsCfg(obj: Datum) {\n const cfg: any = super.createShapePointsCfg(obj);\n let x = cfg.x;\n let y = cfg.y;\n let temp;\n // x y 都是数组时,不做处理\n if (!(isArray(x) && isArray(y))) {\n const xScale = this.getXScale();\n const yScale = this.getYScale();\n const xCount = xScale.values.length;\n const yCount = yScale.values.length;\n const xOffset = (0.5 * 1) / xCount;\n const yOffset = (0.5 * 1) / yCount;\n\n if (xScale.isCategory && yScale.isCategory) {\n // 如果x,y都是分类\n x = [x - xOffset, x - xOffset, x + xOffset, x + xOffset];\n y = [y - yOffset, y + yOffset, y + yOffset, y - yOffset];\n } else if (isArray(x)) {\n // x 是数组\n temp = x;\n x = [temp[0], temp[0], temp[1], temp[1]];\n y = [y - yOffset / 2, y + yOffset / 2, y + yOffset / 2, y - yOffset / 2];\n } else if (isArray(y)) {\n // y 是数组\n temp = y;\n y = [temp[0], temp[1], temp[1], temp[0]];\n x = [x - xOffset / 2, x - xOffset / 2, x + xOffset / 2, x + xOffset / 2];\n }\n cfg.x = x;\n cfg.y = y;\n }\n return cfg;\n }\n}\n","import { LooseObject } from '../interface';\nimport { getXDimensionLength } from '../util/coordinate';\nimport Geometry from './base';\n/** 引入对应的 ShapeFactory */\nimport './shape/schema';\nimport { getDefaultSize } from './util/shape-size';\n\n/**\n * Schema 几何标记,用于一些自定义图形的绘制,比如箱型图、股票图等。\n */\nexport default class Schema extends Geometry {\n public readonly type: string = 'schema';\n public readonly shapeType: string = 'schema';\n protected generatePoints: boolean = true;\n\n /**\n * 获取 Shape 的关键点数据。\n * @param record\n * @returns\n */\n protected createShapePointsCfg(record: LooseObject) {\n const cfg = super.createShapePointsCfg(record);\n\n // 计算每个 shape 的 size\n let size;\n const sizeAttr = this.getAttribute('size');\n if (sizeAttr) {\n size = this.getAttributeValues(sizeAttr, record)[0];\n // 归一化\n const coordinate = this.coordinate;\n const coordinateWidth = getXDimensionLength(coordinate);\n size = size / coordinateWidth;\n } else {\n if (!this.defaultSize) {\n this.defaultSize = getDefaultSize(this);\n }\n size = this.defaultSize;\n }\n cfg.size = size;\n\n return cfg;\n }\n}\n","import { registerShapeFactory } from '../base';\n\nconst SchemaShapeFactory = registerShapeFactory('schema', {\n defaultShapeType: '', // 'schema' is for some custom shapes, so will not specify defaultShapeType\n});\n\nexport default SchemaShapeFactory;\n","import { each, max, map, isArray } from '@antv/util';\nimport { IGroup } from '../../../dependents';\nimport { ShapeInfo, ShapeMarkerCfg, ViolinShapePoint } from '../../../interface';\nimport { registerShape, registerShapeFactory } from '../base';\nimport { getViolinPath } from '../util/get-path-points';\nimport { getStyle } from '../util/get-style';\n\nfunction normalizeSize(arr: number[]) {\n if (!isArray(arr)) {\n return [];\n }\n const maxValue = max(arr);\n return map(arr, (num) => num / maxValue);\n}\n\nconst ViolinShapeFactory = registerShapeFactory('violin', {\n defaultShapeType: 'violin',\n getDefaultPoints(pointInfo: ViolinShapePoint) {\n const radius = pointInfo.size / 2;\n const points = [];\n const sizeArr = normalizeSize(pointInfo._size);\n\n each(pointInfo.y as number[], (y, index) => {\n const offset = sizeArr[index] * radius;\n const isMin = index === 0;\n const isMax = index === (pointInfo.y as number[]).length - 1;\n points.push({\n isMin,\n isMax,\n x: (pointInfo.x as number) - offset,\n y,\n });\n points.unshift({\n isMin,\n isMax,\n x: (pointInfo.x as number) + offset,\n y,\n });\n });\n return points;\n },\n});\n\nregisterShape('violin', 'violin', {\n draw(cfg: ShapeInfo, container: IGroup) {\n const shapeAttrs = getStyle(cfg, true, true);\n const path = this.parsePath(getViolinPath(cfg.points));\n return container.addShape('path', {\n attrs: {\n ...shapeAttrs,\n path,\n },\n name: 'violin',\n });\n },\n getMarker(markerCfg: ShapeMarkerCfg) {\n const { color } = markerCfg;\n\n return {\n symbol: 'circle',\n style: {\n r: 4,\n fill: color,\n },\n };\n },\n});\n\nexport default ViolinShapeFactory;\n","import { get } from '@antv/util';\nimport { FIELD_ORIGIN } from '../constant';\nimport { Datum, ViolinShapePoint } from '../interface';\nimport { getXDimensionLength } from '../util/coordinate';\nimport { getDefaultSize } from './util/shape-size';\nimport Geometry from './base';\n/** 引入 Path 对应的 ShapeFactory */\nimport './shape/violin';\n\n/**\n * Violin 几何标记。\n * 用于绘制小提琴图。\n */\nexport default class Violin extends Geometry {\n public readonly type: string = 'violin';\n public readonly shapeType: string = 'violin';\n protected generatePoints: boolean = true;\n /** size 私有映射字段 */\n private _sizeField: string;\n\n /**\n * 获取 Shape 的关键点数据。\n * @param record\n * @returns\n */\n protected createShapePointsCfg(record: Datum) {\n const cfg = super.createShapePointsCfg(record);\n\n // 计算每个 shape 的 size\n let size;\n const sizeAttr = this.getAttribute('size');\n if (sizeAttr) {\n size = this.getAttributeValues(sizeAttr, record)[0];\n // 归一化\n const coordinate = this.coordinate;\n const coordinateWidth = getXDimensionLength(coordinate);\n size = size / coordinateWidth;\n } else {\n if (!this.defaultSize) {\n this.defaultSize = getDefaultSize(this);\n }\n size = this.defaultSize;\n }\n cfg.size = size;\n cfg._size = get(record[FIELD_ORIGIN], [this._sizeField]);\n return cfg;\n }\n\n /**\n * @override\n */\n protected initAttributes() {\n const { attributeOption } = this;\n const sizeField = attributeOption.size\n ? attributeOption.size.fields[0]\n : this._sizeField\n ? this._sizeField\n : 'size';\n this._sizeField = sizeField;\n // fixme 干啥要删掉\n delete attributeOption.size;\n super.initAttributes();\n }\n}\n","import { each } from '@antv/util';\nimport { Point } from '../../../interface';\n\n/**\n * @ignore\n * Gets cpath\n * @param from\n * @param to\n * @returns\n */\nexport function getCPath(from: Point, to: Point) {\n return ['C', (from.x * 1) / 2 + (to.x * 1) / 2, from.y, (from.x * 1) / 2 + (to.x * 1) / 2, to.y, to.x, to.y];\n}\n\n/**\n * @ignore\n * Gets qpath\n * @param to\n * @param center\n * @returns\n */\nexport function getQPath(to: Point, center: Point) {\n const points = [];\n points.push({\n x: center.x,\n y: center.y,\n });\n points.push(to);\n\n const sub = ['Q'];\n each(points, (point) => {\n sub.push(point.x, point.y);\n });\n\n return sub;\n}\n","import { IGroup } from '../../../dependents';\nimport { ShapeInfo, ShapeMarkerCfg } from '../../../interface';\nimport { registerShape } from '../base';\nimport { getShapeAttrs } from './util';\n\n/**\n * 描边但不填充的区域图\n */\nregisterShape('area', 'line', {\n draw(cfg: ShapeInfo, container: IGroup) {\n const attrs = getShapeAttrs(cfg, true, false, this);\n const shape = container.addShape({\n type: 'path',\n attrs,\n name: 'area',\n });\n\n return shape;\n },\n getMarker(markerCfg: ShapeMarkerCfg) {\n const { color } = markerCfg;\n return {\n symbol: (x: number, y: number, r: number = 5.5) => {\n return [['M', x - r, y - 4], ['L', x + r, y - 4], ['L', x + r, y + 4], ['L', x - r, y + 4], ['Z']];\n },\n style: {\n r: 5,\n stroke: color,\n fill: null,\n },\n };\n },\n});\n","import { IGroup } from '../../../dependents';\nimport { ShapeInfo, ShapeMarkerCfg } from '../../../interface';\n\nimport { registerShape } from '../base';\nimport { getConstraint, getShapeAttrs } from './util';\n\n/**\n * 填充的平滑曲面图\n */\nregisterShape('area', 'smooth', {\n draw(cfg: ShapeInfo, container: IGroup) {\n const coordinate = this.coordinate;\n const attrs = getShapeAttrs(cfg, false, true, this, getConstraint(coordinate));\n const shape = container.addShape({\n type: 'path',\n attrs,\n name: 'area',\n });\n\n return shape;\n },\n getMarker(markerCfg: ShapeMarkerCfg) {\n const { color } = markerCfg;\n return {\n symbol: (x: number, y: number, r: number = 5.5) => {\n return [['M', x - r, y - 4], ['L', x + r, y - 4], ['L', x + r, y + 4], ['L', x - r, y + 4], ['Z']];\n },\n style: {\n r: 5,\n fill: color,\n fillOpacity: 1,\n },\n };\n },\n});\n","import { IGroup } from '../../../dependents';\nimport { ShapeInfo, ShapeMarkerCfg } from '../../../interface';\n\nimport { registerShape } from '../base';\nimport { getConstraint, getShapeAttrs } from './util';\n\n/** 描边的平滑曲面图 */\nregisterShape('area', 'smooth-line', {\n draw(cfg: ShapeInfo, container: IGroup) {\n const coordinate = this.coordinate;\n const attrs = getShapeAttrs(cfg, true, true, this, getConstraint(coordinate));\n const shape = container.addShape({\n type: 'path',\n attrs,\n name: 'area',\n });\n\n return shape;\n },\n getMarker(markerCfg: ShapeMarkerCfg) {\n const { color } = markerCfg;\n return {\n symbol: (x: number, y: number, r: number = 5.5) => {\n return [['M', x - r, y - 4], ['L', x + r, y - 4], ['L', x + r, y + 4], ['L', x - r, y + 4], ['Z']];\n },\n style: {\n r: 5,\n stroke: color,\n fill: null,\n },\n };\n },\n});\n","import { IGroup } from '../../../dependents';\nimport { Point, ShapeInfo, ShapeMarkerCfg } from '../../../interface';\n\nimport { getArcPath } from '../../../util/graphics';\nimport { registerShape } from '../base';\nimport { getStyle } from '../util/get-style';\nimport { getCPath, getQPath } from './util';\n\nfunction getArcShapePath(from: Point, to: Point, center: Point) {\n const sub = getQPath(to, center);\n const path = [['M', from.x, from.y]];\n path.push(sub);\n return path;\n}\n\nfunction getArcShapeWeightPath(points: Point[], center: Point) {\n const arc1 = getQPath(points[1], center);\n const arc2 = getQPath(points[3], center);\n const path = [['M', points[0].x, points[0].y]];\n path.push(arc2);\n path.push(['L', points[3].x, points[3].y]);\n path.push(['L', points[2].x, points[2].y]);\n path.push(arc1);\n path.push(['L', points[1].x, points[1].y]);\n path.push(['L', points[0].x, points[0].y]);\n path.push(['Z']);\n return path;\n}\n\n// 弧线包括笛卡尔坐标系下的半圆弧线、极坐标系下以圆心为控制点的二阶曲线、笛卡尔坐标系下带权重的三阶曲线、极坐标系下带权重的以圆心为控制点的二阶曲线\nregisterShape('edge', 'arc', {\n draw(cfg: ShapeInfo, container: IGroup) {\n const style = getStyle(cfg, true, false, 'lineWidth');\n\n let points = cfg.points as Point[];\n const type = points.length > 2 ? 'weight' : 'normal';\n let path;\n if (cfg.isInCircle) {\n const center = { x: 0, y: 1 };\n if (type === 'normal') {\n path = getArcShapePath(points[0], points[1], center);\n } else {\n style.fill = style.stroke;\n path = getArcShapeWeightPath(points, center);\n }\n path = this.parsePath(path);\n\n return container.addShape('path', {\n attrs: {\n ...style,\n path,\n },\n });\n } else {\n if (type === 'normal') {\n points = this.parsePoints(points);\n path = getArcPath(\n (points[1].x + points[0].x) / 2,\n points[0].y,\n Math.abs(points[1].x - points[0].x) / 2,\n Math.PI,\n Math.PI * 2\n );\n return container.addShape('path', {\n attrs: {\n ...style,\n path,\n },\n });\n } else {\n const c1 = getCPath(points[1], points[3]);\n const c2 = getCPath(points[2], points[0]);\n\n path = [\n ['M', points[0].x, points[0].y],\n ['L', points[1].x, points[1].y],\n c1,\n ['L', points[3].x, points[3].y],\n ['L', points[2].x, points[2].y],\n c2,\n ['Z'],\n ];\n path = this.parsePath(path);\n style.fill = style.stroke;\n\n return container.addShape('path', {\n attrs: {\n ...style,\n path,\n },\n });\n }\n }\n },\n getMarker(markerCfg: ShapeMarkerCfg) {\n return {\n symbol: 'circle',\n style: {\n r: 4.5,\n fill: markerCfg.color,\n },\n };\n },\n});\n","import { IGroup } from '../../../dependents';\nimport { Point, ShapeInfo, ShapeMarkerCfg } from '../../../interface';\n\nimport { registerShape } from '../base';\nimport { getStyle } from '../util/get-style';\nimport { getCPath } from './util';\n\nfunction getSmoothPath(from: Point, to: Point) {\n const sub = getCPath(from, to);\n const path = [['M', from.x, from.y]];\n\n path.push(sub);\n return path;\n}\n\nregisterShape('edge', 'smooth', {\n draw(cfg: ShapeInfo, container: IGroup) {\n const style = getStyle(cfg, true, false, 'lineWidth');\n const points = cfg.points;\n const path = this.parsePath(getSmoothPath(points[0] as Point, points[1] as Point));\n return container.addShape('path', {\n attrs: {\n ...style,\n path,\n },\n });\n },\n getMarker(markerCfg: ShapeMarkerCfg) {\n return {\n symbol: 'circle',\n style: {\n r: 4.5,\n fill: markerCfg.color,\n },\n };\n },\n});\n","import { each } from '@antv/util';\nimport { IGroup } from '../../../dependents';\nimport { Point, ShapeInfo, ShapeMarkerCfg } from '../../../interface';\n\nimport { registerShape } from '../base';\nimport { getStyle } from '../util/get-style';\n\nconst CORNER_PERCENT = 1 / 3;\n\nfunction getVHVPath(from: Point, to: Point) {\n const points = [];\n points.push({\n x: from.x,\n y: from.y * (1 - CORNER_PERCENT) + to.y * CORNER_PERCENT,\n });\n points.push({\n x: to.x,\n y: from.y * (1 - CORNER_PERCENT) + to.y * CORNER_PERCENT,\n });\n points.push(to);\n\n const path = [['M', from.x, from.y]];\n each(points, (point) => {\n path.push(['L', point.x, point.y]);\n });\n\n return path;\n}\n\nregisterShape('edge', 'vhv', {\n draw(cfg: ShapeInfo, container: IGroup) {\n const style = getStyle(cfg, true, false, 'lineWidth');\n const points = cfg.points;\n const path = this.parsePath(getVHVPath(points[0] as Point, points[1] as Point));\n return container.addShape('path', {\n attrs: {\n ...style,\n path,\n },\n });\n },\n getMarker(markerCfg: ShapeMarkerCfg) {\n return {\n symbol: 'circle',\n style: {\n r: 4.5,\n fill: markerCfg.color,\n },\n };\n },\n});\n","import { IGroup } from '../../../dependents';\nimport { Point, ShapeInfo, ShapeMarkerCfg, ShapePoint } from '../../../interface';\n\nimport { registerShape } from '../base';\nimport { getStyle } from '../util/get-style';\nimport { getFunnelPath, getRectPoints } from './util';\n\n/** 漏斗图 */\nregisterShape('interval', 'funnel', {\n getPoints(shapePoint: ShapePoint) {\n shapePoint.size = shapePoint.size * 2; // 漏斗图的 size 是柱状图的两倍\n return getRectPoints(shapePoint);\n },\n draw(cfg: ShapeInfo, container: IGroup) {\n const style = getStyle(cfg, false, true);\n const path = this.parsePath(getFunnelPath(cfg.points as Point[], cfg.nextPoints as Point[], false));\n const shape = container.addShape('path', {\n attrs: {\n ...style,\n path,\n },\n name: 'interval',\n });\n return shape;\n },\n getMarker(markerCfg: ShapeMarkerCfg) {\n const { color } = markerCfg;\n return {\n symbol: 'square',\n style: {\n r: 4,\n fill: color,\n },\n };\n },\n});\n","import { IGroup } from '../../../dependents';\nimport { Point, ShapeInfo, ShapeMarkerCfg } from '../../../interface';\n\nimport { registerShape } from '../base';\nimport { BACKGROUND_SHAPE } from '../constant';\nimport { getBackgroundRectStyle, getStyle } from '../util/get-style';\nimport { getBackgroundRectPath, getRectPath } from './util';\n\n/** 描边柱状图 */\nregisterShape('interval', 'hollow-rect', {\n draw(cfg: ShapeInfo, container: IGroup) {\n const style = getStyle(cfg, true, false);\n let group = container;\n const backgroundCfg = cfg?.background;\n if (backgroundCfg) {\n group = container.addGroup();\n const backgroundStyle = getBackgroundRectStyle(cfg);\n const backgroundPath = getBackgroundRectPath(cfg, this.parsePoints(cfg.points) as Point[], this.coordinate);\n group.addShape('path', {\n attrs: {\n ...backgroundStyle,\n path: backgroundPath,\n },\n capture: false,\n zIndex: -1,\n name: BACKGROUND_SHAPE,\n });\n }\n\n const path = this.parsePath(getRectPath(cfg.points as Point[]));\n const shape = group.addShape('path', {\n attrs: {\n ...style,\n path,\n },\n name: 'interval',\n });\n\n return backgroundCfg ? group : shape;\n },\n getMarker(markerCfg: ShapeMarkerCfg) {\n const { color, isInPolar } = markerCfg;\n if (isInPolar) {\n return {\n symbol: 'circle',\n style: {\n r: 4.5,\n stroke: color,\n fill: null,\n },\n };\n }\n\n return {\n symbol: 'square',\n style: {\n r: 4,\n stroke: color,\n fill: null,\n },\n };\n },\n});\n","import { isArray } from '@antv/util';\nimport { IGroup } from '../../../dependents';\nimport { Point, ShapeInfo, ShapeMarkerCfg, ShapePoint } from '../../../interface';\n\nimport { registerShape } from '../base';\nimport { getStyle } from '../util/get-style';\nimport { getRectPath } from './util';\nimport { omit } from '../../../util/helper';\n\n// 根据数据点生成 Line 的两个关键点\nfunction getLinePoints(pointInfo: ShapePoint): Point[] {\n const { x, y, y0 } = pointInfo;\n\n if (isArray(y)) {\n return y.map((yItem, idx) => {\n return {\n x: isArray(x) ? x[idx] : x,\n y: yItem,\n };\n });\n }\n\n // 起始点从 y0 开始\n return [\n { x: x as number, y: y0 },\n { x: x as number, y },\n ];\n}\n\nregisterShape('interval', 'line', {\n getPoints(shapePoint: ShapePoint) {\n return getLinePoints(shapePoint);\n },\n draw(cfg: ShapeInfo, container: IGroup) {\n const style = getStyle(cfg, true, false, 'lineWidth');\n const newStyle = omit({ ...style }, ['fill']);\n const path = this.parsePath(getRectPath(cfg.points as Point[], false));\n const shape = container.addShape('path', {\n attrs: {\n ...newStyle,\n path,\n },\n name: 'interval',\n });\n\n return shape;\n },\n getMarker(markerCfg: ShapeMarkerCfg) {\n const { color } = markerCfg;\n return {\n symbol: (x: number, y: number, r: number) => {\n return [\n ['M', x, y - r],\n ['L', x, y + r],\n ];\n },\n style: {\n r: 5,\n stroke: color,\n },\n };\n },\n});\n","import { IGroup } from '../../../dependents';\nimport { Point, ShapeInfo, ShapeMarkerCfg, ShapePoint } from '../../../interface';\n\nimport { registerShape } from '../base';\nimport { getStyle } from '../util/get-style';\nimport { getFunnelPath, getRectPoints } from './util';\n\n/** 金字塔图,尖底漏斗图 */\nregisterShape('interval', 'pyramid', {\n getPoints(shapePoint: ShapePoint) {\n shapePoint.size = shapePoint.size * 2; // 漏斗图的 size 是柱状图的两倍\n return getRectPoints(shapePoint);\n },\n draw(cfg: ShapeInfo, container: IGroup) {\n const style = getStyle(cfg, false, true);\n const path = this.parsePath(getFunnelPath(cfg.points as Point[], cfg.nextPoints as Point[], true));\n const shape = container.addShape('path', {\n attrs: {\n ...style,\n path,\n },\n name: 'interval',\n });\n\n return shape;\n },\n getMarker(markerCfg: ShapeMarkerCfg) {\n const { color } = markerCfg;\n return {\n symbol: 'square',\n style: {\n r: 4,\n fill: color,\n },\n };\n },\n});\n","import { isArray } from '@antv/util';\nimport { IGroup } from '../../../dependents';\nimport { Point, ShapeInfo, ShapeMarkerCfg, ShapePoint } from '../../../interface';\n\nimport { registerShape } from '../base';\nimport { getStyle } from '../util/get-style';\n\n// 根据数据点生成 tick shape 的 6 个关键点\nfunction getTickPoints(pointInfo: ShapePoint): Point[] {\n const { x, y, y0, size } = pointInfo;\n let yMin;\n let yMax;\n if (isArray(y)) {\n [yMin, yMax] = y;\n } else {\n yMin = y0;\n yMax = y;\n }\n\n const xMax = (x as number) + size / 2;\n const xMin = (x as number) - size / 2;\n\n // tick 关键点顺序\n // 4 - 1 - 5\n // |\n // 2 - 0 - 3\n return [\n { x: x as number, y: yMin },\n { x: x as number, y: yMax },\n { x: xMin, y: yMin },\n { x: xMax, y: yMin },\n { x: xMin, y: yMax },\n { x: xMax, y: yMax },\n ];\n}\n\n// 根据 tick 关键点绘制 path\nfunction getTickPath(points: Point[]) {\n return [\n ['M', points[0].x, points[0].y],\n ['L', points[1].x, points[1].y],\n ['M', points[2].x, points[2].y],\n ['L', points[3].x, points[3].y],\n ['M', points[4].x, points[4].y],\n ['L', points[5].x, points[5].y],\n ];\n}\n\n/** I 形状柱状图,常用于 error bar chart */\nregisterShape('interval', 'tick', {\n getPoints(shapePoint: ShapePoint) {\n return getTickPoints(shapePoint);\n },\n draw(cfg: ShapeInfo, container: IGroup) {\n const style = getStyle(cfg, true, false);\n const path = this.parsePath(getTickPath(cfg.points as Point[]));\n const shape = container.addShape('path', {\n attrs: {\n ...style,\n path,\n },\n name: 'interval',\n });\n\n return shape;\n },\n getMarker(markerCfg: ShapeMarkerCfg) {\n const { color } = markerCfg;\n return {\n symbol: (x: number, y: number, r: number) => {\n return [\n ['M', x - r / 2, y - r],\n ['L', x + r / 2, y - r],\n ['M', x, y - r],\n ['L', x, y + r],\n ['M', x - r / 2, y + r],\n ['L', x + r / 2, y + r],\n ];\n },\n style: {\n r: 5,\n stroke: color,\n },\n };\n },\n});\n","import { each } from '@antv/util';\nimport { IGroup } from '../../../dependents';\nimport { Point, ShapeInfo, ShapeMarkerCfg } from '../../../interface';\n\nimport { registerShape } from '../base';\nimport { getPathPoints } from '../util/get-path-points';\nimport { getStyle } from '../util/get-style';\nimport { getLineMarker } from './util';\n\nconst interpolateCallback = (point: Point, nextPoint: Point, shapeType: string) => {\n const x = point.x as number;\n const y = point.y as number;\n const nextX = nextPoint.x as number;\n const nextY = nextPoint.y as number;\n let result;\n\n switch (shapeType) {\n case 'hv':\n result = [{ x: nextX, y }];\n break;\n case 'vh':\n result = [{ x, y: nextY }];\n break;\n case 'hvh':\n const middleX = (nextX + x) / 2;\n result = [\n { x: middleX, y },\n { x: middleX, y: nextY },\n ];\n break;\n case 'vhv':\n const middleY = (y + nextY) / 2;\n result = [\n { x, y: middleY },\n { x: nextX, y: middleY },\n ];\n break;\n default:\n break;\n }\n\n return result;\n};\n\nfunction getInterpolatePoints(points: Point[], shapeType: string) {\n let result = [];\n each(points, (point: Point, index) => {\n const nextPoint = points[index + 1];\n result.push(point);\n if (nextPoint) {\n const interpolatePoint = interpolateCallback(point, nextPoint, shapeType);\n result = result.concat(interpolatePoint);\n }\n });\n return result;\n}\n\n// 插值的图形path,不考虑null\nfunction getInterpolatePath(points: Point[]) {\n return points.map((point, index) => {\n return index === 0 ? ['M', point.x, point.y] : ['L', point.x, point.y];\n });\n}\n\n// 插值的图形\nfunction getInterpolateShapeAttrs(cfg: ShapeInfo, shapeType: string) {\n const points = getPathPoints(cfg.points, cfg.connectNulls, cfg.showSinglePoint); // 根据 connectNulls 值处理 points\n let path = [];\n each(points, (eachLinePoints) => {\n const interpolatePoints = getInterpolatePoints(eachLinePoints, shapeType);\n path = path.concat(getInterpolatePath(interpolatePoints));\n });\n\n return {\n ...getStyle(cfg, true, false, 'lineWidth'),\n path,\n };\n}\n\n// step line\neach(['hv', 'vh', 'hvh', 'vhv'], (shapeType) => {\n registerShape('line', shapeType, {\n draw(cfg: ShapeInfo, container: IGroup) {\n const attrs = getInterpolateShapeAttrs(cfg, shapeType);\n const shape = container.addShape({\n type: 'path',\n attrs,\n name: 'line',\n });\n\n return shape;\n },\n getMarker(markerCfg: ShapeMarkerCfg) {\n return getLineMarker(markerCfg, shapeType);\n },\n });\n});\n","import { isArray, isNil } from '@antv/util';\nimport { IGroup, PathCommand } from '../../../dependents';\nimport { Point, ShapeInfo, ShapeMarkerCfg, ShapePoint } from '../../../interface';\n\nimport { registerShape } from '../base';\nimport { getStyle } from '../util/get-style';\n\nfunction parseValue(value: number[]) {\n const array = !isArray(value) ? [value] : value;\n\n const min = array[0]; // 最小值\n const max = array[array.length - 1]; // 最大值\n const min1 = array.length > 1 ? array[1] : min;\n const max1 = array.length > 3 ? array[3] : max;\n const median = array.length > 2 ? array[2] : min1;\n\n return {\n min, // 最小值\n max, // 最大值\n min1,\n max1,\n median,\n };\n}\n\nfunction getBoxPoints(x: number | number[], y: number | number[], size: number): Point[] {\n const halfSize = size / 2;\n let pointsArray;\n if (isArray(y)) {\n // 2维\n const { min, max, median, min1, max1 } = parseValue(y);\n const minX = (x as number) - halfSize;\n const maxX = (x as number) + halfSize;\n pointsArray = [\n [minX, max],\n [maxX, max],\n [x as number, max],\n [x as number, max1],\n [minX, min1],\n [minX, max1],\n [maxX, max1],\n [maxX, min1],\n [x as number, min1],\n [x as number, min],\n [minX, min],\n [maxX, min],\n [minX, median],\n [maxX, median],\n ];\n } else {\n // 只有一个维度\n y = isNil(y) ? 0.5 : y;\n const { min, max, median, min1, max1 } = parseValue(x as number[]);\n const minY = y - halfSize;\n const maxY = y + halfSize;\n pointsArray = [\n [min, minY],\n [min, maxY],\n [min, y],\n [min1, y],\n [min1, minY],\n [min1, maxY],\n [max1, maxY],\n [max1, minY],\n [max1, y],\n [max, y],\n [max, minY],\n [max, maxY],\n [median, minY],\n [median, maxY],\n ];\n }\n\n return pointsArray.map((arr) => {\n return {\n x: arr[0],\n y: arr[1],\n };\n });\n}\n\nfunction getBoxPath(points): PathCommand[] {\n return [\n ['M', points[0].x, points[0].y],\n ['L', points[1].x, points[1].y],\n ['M', points[2].x, points[2].y],\n ['L', points[3].x, points[3].y],\n ['M', points[4].x, points[4].y],\n ['L', points[5].x, points[5].y],\n ['L', points[6].x, points[6].y],\n ['L', points[7].x, points[7].y],\n ['L', points[4].x, points[4].y], // 封闭 z\n ['Z'],\n ['M', points[8].x, points[8].y],\n ['L', points[9].x, points[9].y],\n ['M', points[10].x, points[10].y],\n ['L', points[11].x, points[11].y],\n ['M', points[12].x, points[12].y],\n ['L', points[13].x, points[13].y],\n ];\n}\n\n// box shape\nregisterShape('schema', 'box', {\n getPoints(shapePoint: ShapePoint) {\n const { x, y, size } = shapePoint;\n return getBoxPoints(x as number, y as number[], size);\n },\n draw(cfg: ShapeInfo, container: IGroup) {\n const style = getStyle(cfg, true, false);\n const path = this.parsePath(getBoxPath(cfg.points));\n const shape = container.addShape('path', {\n attrs: {\n ...style,\n path,\n name: 'schema',\n },\n });\n\n return shape;\n },\n getMarker(markerCfg: ShapeMarkerCfg) {\n const { color } = markerCfg;\n return {\n symbol(x: number, y: number, r: number) {\n const yValues = [y - 6, y - 3, y, y + 3, y + 6];\n const points = getBoxPoints(x, yValues, r);\n return [\n ['M', points[0].x + 1, points[0].y],\n ['L', points[1].x - 1, points[1].y],\n ['M', points[2].x, points[2].y],\n ['L', points[3].x, points[3].y],\n ['M', points[4].x, points[4].y],\n ['L', points[5].x, points[5].y],\n ['L', points[6].x, points[6].y],\n ['L', points[7].x, points[7].y],\n ['L', points[4].x, points[4].y],\n ['Z'],\n ['M', points[8].x, points[8].y],\n ['L', points[9].x, points[9].y],\n ['M', points[10].x + 1, points[10].y],\n ['L', points[11].x - 1, points[11].y],\n ['M', points[12].x, points[12].y],\n ['L', points[13].x, points[13].y],\n ];\n },\n style: {\n r: 6,\n lineWidth: 1,\n stroke: color,\n },\n };\n },\n});\n","import { isArray } from '@antv/util';\nimport { IGroup, PathCommand } from '../../../dependents';\nimport { Point, ShapeInfo, ShapeMarkerCfg, ShapePoint } from '../../../interface';\n\nimport { padEnd } from '../../../util/helper';\nimport { registerShape } from '../base';\nimport { getStyle } from '../util/get-style';\n\nfunction getCandleYValues(value: number | number[]) {\n const array = !isArray(value) ? [value] : value;\n // 从大到小排序\n const sorted = array.sort((a, b) => b - a);\n return padEnd(sorted, 4, sorted[sorted.length - 1]);\n}\n\n// get candle shape's key points\nfunction getCandlePoints(x: number, y: number[], size: number): Point[] {\n const yValues = getCandleYValues(y);\n return [\n { x, y: yValues[0] },\n { x, y: yValues[1] },\n { x: x - size / 2, y: yValues[2] },\n { x: x - size / 2, y: yValues[1] },\n { x: x + size / 2, y: yValues[1] },\n { x: x + size / 2, y: yValues[2] },\n { x, y: yValues[2] },\n { x, y: yValues[3] },\n ];\n}\n\nfunction getCandlePath(points): PathCommand[] {\n return [\n ['M', points[0].x, points[0].y],\n ['L', points[1].x, points[1].y],\n ['M', points[2].x, points[2].y],\n ['L', points[3].x, points[3].y],\n ['L', points[4].x, points[4].y],\n ['L', points[5].x, points[5].y],\n ['Z'],\n ['M', points[6].x, points[6].y],\n ['L', points[7].x, points[7].y],\n ];\n}\n\n// k line shape\nregisterShape('schema', 'candle', {\n getPoints(shapePoint: ShapePoint) {\n const { x, y, size } = shapePoint;\n return getCandlePoints(x as number, y as number[], size);\n },\n draw(cfg: ShapeInfo, container: IGroup) {\n const style = getStyle(cfg, true, true);\n const path = this.parsePath(getCandlePath(cfg.points));\n const shape = container.addShape('path', {\n attrs: {\n ...style,\n path,\n name: 'schema',\n },\n });\n\n return shape;\n },\n getMarker(markerCfg: ShapeMarkerCfg) {\n const { color } = markerCfg;\n return {\n symbol(x: number, y: number, r: number) {\n const yValues = [y + 7.5, y + 3, y - 3, y - 7.5];\n const points = getCandlePoints(x, yValues, r);\n return [\n ['M', points[0].x, points[0].y],\n ['L', points[1].x, points[1].y],\n ['M', points[2].x, points[2].y],\n ['L', points[3].x, points[3].y],\n ['L', points[4].x, points[4].y],\n ['L', points[5].x, points[5].y],\n ['Z'],\n ['M', points[6].x, points[6].y],\n ['L', points[7].x, points[7].y],\n ];\n },\n style: {\n lineWidth: 1,\n stroke: color,\n fill: color,\n r: 6,\n },\n };\n },\n});\n","import { isEmpty, clamp } from '@antv/util';\nimport { IGroup } from '../../../dependents';\nimport { ShapeInfo, ShapeMarkerCfg } from '../../../interface';\n\nimport { registerShape } from '../base';\nimport { getStyle } from '../util/get-style';\n\nfunction getRectAttrs(points: any[], size: number) {\n const width = Math.abs(points[0].x - points[2].x);\n const height = Math.abs(points[0].y - points[2].y);\n\n let len = Math.min(width, height);\n if (size) {\n len = clamp(size, 0, Math.min(width, height));\n }\n len = len / 2;\n const centerX = (points[0].x + points[2].x) / 2;\n const centerY = (points[0].y + points[2].y) / 2;\n\n return {\n x: centerX - len,\n y: centerY - len,\n width: len * 2,\n height: len * 2,\n };\n}\n\nregisterShape('polygon', 'square', {\n draw(cfg: ShapeInfo, container: IGroup) {\n if (!isEmpty(cfg.points)) {\n const shapeAttrs = getStyle(cfg, true, true);\n const points = this.parsePoints(cfg.points); // 转换为画布坐标\n return container.addShape('rect', {\n attrs: {\n ...shapeAttrs,\n ...getRectAttrs(points, cfg.size), // 获取 rect 绘图信息\n },\n name: 'polygon',\n });\n }\n },\n getMarker(markerCfg: ShapeMarkerCfg) {\n const { color } = markerCfg;\n return {\n symbol: 'square',\n style: {\n r: 4,\n fill: color,\n },\n };\n },\n});\n","import { each } from '@antv/util';\nimport { IGroup } from '../../../dependents';\nimport { ShapeInfo, ShapeMarkerCfg } from '../../../interface';\n\nimport { MarkerSymbols } from '../../../util/marker';\nimport { registerShape } from '../base';\nimport { drawPoints, HOLLOW_SHAPES } from './util';\n\n// 添加 hollowShape\neach(HOLLOW_SHAPES, (shapeName: string) => {\n registerShape('point', shapeName, {\n draw(cfg: ShapeInfo, container: IGroup) {\n return drawPoints(this, cfg, container, shapeName, true);\n },\n getMarker(markerCfg: ShapeMarkerCfg) {\n const { color } = markerCfg;\n return {\n symbol: MarkerSymbols[shapeName],\n style: {\n r: 4.5,\n stroke: color,\n fill: null,\n },\n };\n },\n });\n});\n","import { IGroup } from '../../../dependents';\nimport { ShapeInfo, ShapeMarkerCfg } from '../../../interface';\n\nimport { registerShape } from '../base';\nimport { getStyle } from '../util/get-style';\n\nregisterShape('point', 'image', {\n draw(cfg: ShapeInfo, container: IGroup) {\n const { r: size } = getStyle(cfg, false, false, 'r');\n const points = this.parsePoints(cfg.points);\n let pointPosition = points[0];\n if (cfg.isStack) {\n pointPosition = points[1];\n } else if (points.length > 1) {\n const group = container.addGroup();\n for (const point of points) {\n group.addShape('image', {\n attrs: {\n x: (point.x as number) - size / 2,\n y: (point.y as number) - size,\n width: size,\n height: size,\n img: cfg.shape[1],\n },\n });\n }\n\n return group;\n }\n\n return container.addShape('image', {\n attrs: {\n x: (pointPosition.x as number) - size / 2,\n y: (pointPosition.y as number) - size,\n width: size,\n height: size,\n img: cfg.shape[1],\n },\n });\n },\n getMarker(markerCfg: ShapeMarkerCfg) {\n const { color } = markerCfg;\n return {\n symbol: 'circle',\n style: {\n r: 4.5,\n fill: color,\n },\n };\n },\n});\n","import { each } from '@antv/util';\nimport { IGroup } from '../../../dependents';\nimport { ShapeInfo, ShapeMarkerCfg } from '../../../interface';\n\nimport { MarkerSymbols } from '../../../util/marker';\nimport { registerShape } from '../base';\nimport { drawPoints, SHAPES } from './util';\n\n// 所有的 SHAPES 都注册一下\neach(SHAPES, (shapeName: string) => {\n registerShape('point', shapeName, {\n draw(cfg: ShapeInfo, container: IGroup) {\n return drawPoints(this, cfg, container, shapeName, false);\n },\n getMarker(markerCfg: ShapeMarkerCfg) {\n const { color } = markerCfg;\n return {\n symbol: MarkerSymbols[shapeName] || shapeName,\n style: {\n r: 4.5,\n fill: color,\n },\n };\n },\n });\n});\n","import { IGroup } from '../../../dependents';\nimport { ShapeInfo, ShapeMarkerCfg } from '../../../interface';\nimport { registerShape } from '../base';\nimport { getSmoothViolinPath } from '../util/get-path-points';\nimport { getStyle } from '../util/get-style';\n\n/**\n * 平滑边界的小提琴图\n */\nregisterShape('violin', 'smooth', {\n draw(cfg: ShapeInfo, container: IGroup) {\n const attrs = getStyle(cfg, true, true);\n const path = this.parsePath(getSmoothViolinPath(cfg.points));\n return container.addShape('path', {\n attrs: {\n ...attrs,\n path,\n },\n });\n },\n getMarker(markerCfg: ShapeMarkerCfg) {\n const { color } = markerCfg;\n return {\n symbol: 'circle',\n style: {\n stroke: null,\n r: 4,\n fill: color,\n },\n };\n },\n});\n","import { IGroup, Point } from '../../../dependents';\nimport { ShapeInfo, ShapeMarkerCfg } from '../../../interface';\nimport { registerShape } from '../base';\nimport { getSmoothViolinPath, getViolinPath } from '../util/get-path-points';\nimport { getStyle } from '../util/get-style';\n\n/**\n * 空心小提琴图\n */\nregisterShape('violin', 'hollow', {\n draw(cfg: ShapeInfo, container: IGroup) {\n const attrs = getStyle(cfg, true, false);\n const path = this.parsePath(getViolinPath(cfg.points));\n return container.addShape('path', {\n attrs: {\n ...attrs,\n path,\n },\n });\n },\n getMarker(markerCfg: ShapeMarkerCfg) {\n const { color } = markerCfg;\n return {\n symbol: 'circle',\n style: {\n r: 4,\n fill: null,\n stroke: color,\n },\n };\n },\n});\n\n/**\n * 平滑边界的空心小提琴图\n */\nregisterShape('violin', 'hollow-smooth', {\n draw(cfg: ShapeInfo, container: IGroup) {\n const attrs = getStyle(cfg, true, false);\n const path = this.parsePath(getSmoothViolinPath(cfg.points));\n return container.addShape('path', {\n attrs: {\n ...attrs,\n path,\n },\n });\n },\n getMarker(markerCfg: ShapeMarkerCfg) {\n const { color } = markerCfg;\n return {\n symbol: 'circle',\n style: {\n r: 4,\n fill: null,\n stroke: color,\n },\n };\n },\n});\n","import { get, deepMix, isArray } from '@antv/util';\nimport { Writeable } from '../../util/types';\nimport { MappingDatum, Point } from '../../interface';\nimport GeometryLabel from './base';\nimport { LabelCfg, LabelItem, LabelPointCfg, TextAlign } from './interface';\n\n/**\n * 柱状图 label\n */\nexport default class IntervalLabel extends GeometryLabel {\n /**\n * 获取 interval label 的方向,取决于 value 的值是正还是负\n * @param labelCfg\n */\n private getLabelValueDir(mappingData: MappingDatum) {\n // points 中的 x/y 和 transpose 无关\n const dim = 'y';\n const { points } = mappingData;\n\n return points[0][dim] <= points[2][dim] ? 1 : -1;\n }\n\n /**\n * 重载:根据 interval 值的正负来调整 label 偏移量\n * @param labelCfg\n * @param index\n * @param total\n */\n protected getLabelOffsetPoint(labelCfg: LabelCfg, index: number, total: number, position?: string) {\n let point = super.getLabelOffsetPoint(labelCfg, index, total);\n const coordinate = this.getCoordinate();\n const transposed = coordinate.isTransposed;\n const dim = transposed ? 'x' : 'y';\n const dir = this.getLabelValueDir(labelCfg.mappingData);\n point = { ...point, [dim]: point[dim] * dir };\n\n if (coordinate.isReflect('x')) {\n point = {\n ...point,\n x: point.x * -1,\n };\n }\n if (coordinate.isReflect('y')) {\n point = {\n ...point,\n y: point.y * -1,\n };\n }\n\n return point;\n }\n\n /**\n * 重载:定制 interval label 的默认主题配置\n * @param labelCfg\n */\n protected getThemedLabelCfg(labelCfg: LabelCfg) {\n const geometry = this.geometry;\n const defaultLabelCfg = this.getDefaultLabelCfg();\n const { theme } = geometry;\n\n // 如果 interval label position 设置为 middle,则将主题中的 offset 覆盖为 0\n return deepMix({}, defaultLabelCfg, theme.labels, labelCfg.position === 'middle' ? { offset: 0 } : {}, labelCfg);\n }\n\n protected setLabelPosition(\n labelPointCfg: Writeable,\n mappingData: MappingDatum,\n index: number,\n position: string\n ) {\n const coordinate = this.getCoordinate();\n const transposed = coordinate.isTransposed;\n const shapePoints = mappingData.points as Point[];\n const point0 = coordinate.convert(shapePoints[0]);\n const point2 = coordinate.convert(shapePoints[2]);\n const dir = this.getLabelValueDir(mappingData);\n\n let top;\n let right;\n let bottom;\n let left;\n\n const shape = isArray(mappingData.shape) ? mappingData.shape[0] : mappingData.shape;\n if (shape === 'funnel' || shape === 'pyramid') {\n // 处理漏斗图\n const nextPoints = get(mappingData, 'nextPoints');\n const points = get(mappingData, 'points');\n if (nextPoints) {\n // 非漏斗图底部\n const p0 = coordinate.convert(points[0] as Point);\n const p1 = coordinate.convert(points[1] as Point);\n const nextP0 = coordinate.convert(nextPoints[0] as Point);\n const nextP1 = coordinate.convert(nextPoints[1] as Point);\n\n // TODO: 使用包围盒的计算方法\n if (transposed) {\n top = Math.min(nextP0.y, p0.y);\n bottom = Math.max(nextP0.y, p0.y);\n right = (p1.x + nextP1.x) / 2;\n left = (p0.x + nextP0.x) / 2;\n } else {\n top = Math.min((p1.y + nextP1.y) / 2, (p0.y + nextP0.y) / 2);\n bottom = Math.max((p1.y + nextP1.y) / 2, (p0.y + nextP0.y) / 2);\n right = nextP1.x;\n left = p0.x;\n }\n } else {\n top = Math.min(point2.y, point0.y);\n bottom = Math.max(point2.y, point0.y);\n right = point2.x;\n left = point0.x;\n }\n } else {\n top = Math.min(point2.y, point0.y);\n bottom = Math.max(point2.y, point0.y);\n right = point2.x;\n left = point0.x;\n }\n\n switch (position) {\n case 'right':\n labelPointCfg.x = right;\n labelPointCfg.y = (top + bottom) / 2;\n labelPointCfg.textAlign = get(labelPointCfg, 'textAlign', dir > 0 ? 'left' : 'right');\n break;\n case 'left':\n labelPointCfg.x = left;\n labelPointCfg.y = (top + bottom) / 2;\n labelPointCfg.textAlign = get(labelPointCfg, 'textAlign', dir > 0 ? 'left' : 'right');\n break;\n case 'bottom':\n if (transposed) {\n labelPointCfg.x = (right + left) / 2;\n }\n labelPointCfg.y = bottom;\n labelPointCfg.textAlign = get(labelPointCfg, 'textAlign', 'center');\n labelPointCfg.textBaseline = get(labelPointCfg, 'textBaseline', dir > 0 ? 'bottom' : 'top');\n break;\n case 'middle':\n if (transposed) {\n labelPointCfg.x = (right + left) / 2;\n }\n labelPointCfg.y = (top + bottom) / 2;\n labelPointCfg.textAlign = get(labelPointCfg, 'textAlign', 'center');\n labelPointCfg.textBaseline = get(labelPointCfg, 'textBaseline', 'middle');\n break;\n case 'top':\n if (transposed) {\n labelPointCfg.x = (right + left) / 2;\n }\n labelPointCfg.y = top;\n labelPointCfg.textAlign = get(labelPointCfg, 'textAlign', 'center');\n labelPointCfg.textBaseline = get(labelPointCfg, 'textBaseline', dir > 0 ? 'bottom' : 'top');\n break;\n default:\n break;\n }\n }\n}\n","import { each, get, isArray, map, isNumber, isString } from '@antv/util';\nimport { MappingDatum, Point } from '../../interface';\nimport { getDistanceToCenter } from '../../util/coordinate';\nimport { getAngleByPoint } from '../../util/coordinate';\nimport GeometryLabel from './base';\nimport { LabelCfg, LabelItem, PolarLabelItem, LabelPointCfg, Writeable } from './interface';\n\nconst HALF_PI = Math.PI / 2;\n\n/**\n * 极坐标下的图形 label\n */\nexport default class PolarLabel extends GeometryLabel {\n /**\n * @override\n * @desc 获取 label offset\n * polar & theta coordinate support「string」type, should transform to 「number」\n */\n protected getLabelOffset(offset: number | string): number {\n const coordinate = this.getCoordinate();\n let actualOffset = 0;\n if (isNumber(offset)) {\n actualOffset = offset;\n } else if (isString(offset) && offset.indexOf('%') !== -1) {\n let r = coordinate.getRadius();\n if (coordinate.innerRadius > 0) {\n r = r * (1 - coordinate.innerRadius);\n }\n actualOffset = parseFloat(offset) * 0.01 * r;\n }\n\n return actualOffset;\n }\n\n /**\n * @override\n * 获取 labelItems, 增加切片 percent\n * @param mapppingArray\n */\n public getLabelItems(mapppingArray: MappingDatum[]): PolarLabelItem[] {\n const items = super.getLabelItems(mapppingArray);\n const yScale = this.geometry.getYScale();\n\n return map(items, (item) => {\n if (item && yScale) {\n const percent = yScale.scale(get(item.data, yScale.field));\n return { ...item, percent };\n }\n return item;\n });\n }\n /**\n * @override\n * 获取文本的对齐方式\n * @param point\n */\n protected getLabelAlign(point: LabelItem) {\n const coordinate = this.getCoordinate();\n let align;\n if (point.labelEmit) {\n align = point.angle <= Math.PI / 2 && point.angle >= -Math.PI / 2 ? 'left' : 'right';\n } else if (!coordinate.isTransposed) {\n align = 'center';\n } else {\n const center = coordinate.getCenter();\n const offset = point.offset;\n if (Math.abs(point.x - center.x) < 1) {\n align = 'center';\n } else if (point.angle > Math.PI || point.angle <= 0) {\n align = offset > 0 ? 'left' : 'right';\n } else {\n align = offset > 0 ? 'right' : 'left';\n }\n }\n return align;\n }\n\n /**\n * @override\n * 获取 label 的位置\n * @param labelCfg\n * @param mappingData\n * @param index\n */\n protected getLabelPoint(labelCfg: LabelCfg, mappingData: MappingDatum, index: number): LabelPointCfg {\n let factor = 1;\n let arcPoint;\n const content = labelCfg.content[index];\n if (this.isToMiddle(mappingData)) {\n arcPoint = this.getMiddlePoint(mappingData.points as Point[]);\n } else {\n if (labelCfg.content.length === 1 && index === 0) {\n index = 1;\n } else if (index === 0) {\n factor = -1;\n }\n arcPoint = this.getArcPoint(mappingData, index);\n }\n\n const offset = labelCfg.offset * factor;\n const middleAngle = this.getPointAngle(arcPoint);\n const isLabelEmit = labelCfg.labelEmit;\n const labelPositionCfg: Writeable = this.getCirclePoint(middleAngle, offset, arcPoint, isLabelEmit);\n if (labelPositionCfg.r === 0) {\n // 如果文本位置位于圆心,则不展示\n labelPositionCfg.content = '';\n } else {\n labelPositionCfg.content = content;\n labelPositionCfg.angle = middleAngle;\n labelPositionCfg.color = mappingData.color;\n }\n\n labelPositionCfg.rotate = labelCfg.autoRotate\n ? this.getLabelRotate(middleAngle, offset, isLabelEmit)\n : labelCfg.rotate;\n labelPositionCfg.start = {\n x: arcPoint.x,\n y: arcPoint.y,\n };\n return labelPositionCfg;\n }\n\n /**\n * 获取圆弧的位置\n */\n protected getArcPoint(mappingData: MappingDatum, index: number = 0): Point {\n if (!isArray(mappingData.x) && !isArray(mappingData.y)) {\n return {\n x: mappingData.x,\n y: mappingData.y,\n };\n }\n\n return {\n x: isArray(mappingData.x) ? mappingData.x[index] : mappingData.x,\n y: isArray(mappingData.y) ? mappingData.y[index] : mappingData.y,\n };\n }\n\n /**\n * 计算坐标线点在极坐标系下角度\n * @param point\n */\n protected getPointAngle(point: Point): number {\n return getAngleByPoint(this.getCoordinate(), point);\n }\n\n /**\n * 获取坐标点与圆心形成的圆的位置信息\n * @param angle\n * @param offset\n * @param point\n * @param isLabelEmit\n */\n protected getCirclePoint(angle: number, offset: number, point: Point, isLabelEmit: boolean) {\n const coordinate = this.getCoordinate();\n const center = coordinate.getCenter();\n let r = getDistanceToCenter(coordinate, point);\n if (r === 0) {\n return {\n ...center,\n r,\n };\n }\n\n let labelAngle = angle;\n if (coordinate.isTransposed && r > offset && !isLabelEmit) {\n const appendAngle = Math.asin(offset / (2 * r));\n labelAngle = angle + appendAngle * 2;\n } else {\n r = r + offset;\n }\n\n return {\n x: center.x + r * Math.cos(labelAngle),\n y: center.y + r * Math.sin(labelAngle),\n r,\n };\n }\n\n /**\n * 获取 label 的旋转角度\n * @param angle\n * @param offset\n * @param isLabelEmit\n */\n protected getLabelRotate(angle: number, offset: number, isLabelEmit: boolean) {\n let rotate = angle + HALF_PI;\n if (isLabelEmit) {\n rotate -= HALF_PI;\n }\n if (rotate) {\n if (rotate > HALF_PI) {\n rotate = rotate - Math.PI;\n } else if (rotate < -HALF_PI) {\n rotate = rotate + Math.PI;\n }\n }\n return rotate;\n }\n\n // 获取中心的位置\n private getMiddlePoint(points: Point[]) {\n const coordinate = this.getCoordinate();\n const count = points.length;\n let middlePoint = {\n x: 0,\n y: 0,\n };\n each(points, (point: Point) => {\n middlePoint.x += point.x;\n middlePoint.y += point.y;\n });\n middlePoint.x /= count;\n middlePoint.y /= count;\n\n middlePoint = coordinate.convert(middlePoint);\n return middlePoint;\n }\n\n // 是否居中\n private isToMiddle(mappingData: MappingDatum) {\n return (mappingData.x as number[]).length > 2;\n }\n}\n","import { deepMix, get, isArray } from '@antv/util';\nimport { getAngleByPoint } from '../../util/coordinate';\nimport { polarToCartesian } from '../../util/graphics';\nimport { LabelItem } from './interface';\nimport PolarLabel from './polar';\n\n/**\n * 饼图 label\n */\nexport default class PieLabel extends PolarLabel {\n public defaultLayout = 'distribute';\n\n protected getDefaultLabelCfg(offset?: number, position?: string) {\n const cfg = super.getDefaultLabelCfg(offset, position);\n return deepMix({}, cfg, get(this.geometry.theme, 'pieLabels', {}));\n }\n\n /** @override */\n protected getLabelOffset(offset: string | number): number {\n return super.getLabelOffset(offset) || 0;\n }\n\n protected getLabelRotate(angle: number, offset: number, isLabelLimit: boolean) {\n let rotate;\n if (offset < 0) {\n rotate = angle;\n if (rotate > Math.PI / 2) {\n rotate = rotate - Math.PI;\n }\n if (rotate < -Math.PI / 2) {\n rotate = rotate + Math.PI;\n }\n }\n return rotate;\n }\n\n protected getLabelAlign(point: LabelItem) {\n const coordinate = this.getCoordinate();\n const center = coordinate.getCenter();\n\n let align;\n if (point.angle <= Math.PI / 2 && point.x >= center.x) {\n align = 'left';\n } else {\n align = 'right';\n }\n if (point.offset <= 0) {\n if (align === 'right') {\n align = 'left';\n } else {\n align = 'right';\n }\n }\n return align;\n }\n\n protected getArcPoint(point) {\n return point;\n }\n\n protected getPointAngle(point) {\n const coordinate = this.getCoordinate();\n const startPoint = {\n x: isArray(point.x) ? point.x[0] : point.x,\n y: point.y[0],\n };\n const endPoint = {\n x: isArray(point.x) ? point.x[1] : point.x,\n y: point.y[1],\n };\n let angle;\n const startAngle = getAngleByPoint(coordinate, startPoint);\n if (point.points && point.points[0].y === point.points[1].y) {\n angle = startAngle;\n } else {\n let endAngle = getAngleByPoint(coordinate, endPoint);\n if (startAngle >= endAngle) {\n // 100% pie slice\n endAngle = endAngle + Math.PI * 2;\n }\n angle = startAngle + (endAngle - startAngle) / 2;\n }\n return angle;\n }\n\n /** @override */\n protected getCirclePoint(angle: number, offset: number) {\n const coordinate = this.getCoordinate();\n const center = coordinate.getCenter();\n const r = coordinate.getRadius() + offset;\n return {\n ...polarToCartesian(center.x, center.y, r, angle),\n angle,\n r,\n };\n }\n}\n","import { PolarLabelItem } from '../../interface';\n\n/**\n * 碰撞检测算法\n */\nexport function antiCollision(\n items: PolarLabelItem[],\n labelHeight: number,\n plotRange: { minY: number; maxY: number; minX: number; maxX: number }\n) {\n const labels = items.filter((item) => !item.invisible);\n\n // sorted by y, mutable\n labels.sort((a, b) => a.y - b.y);\n // adjust y position of labels to avoid overlapping\n let overlapping = true;\n const startY = plotRange.minY;\n const endY = plotRange.maxY;\n let totalHeight = Math.abs(startY - endY);\n let i;\n\n let maxY = 0;\n let minY = Number.MIN_VALUE;\n const boxes = labels.map((label) => {\n if (label.y > maxY) {\n maxY = label.y;\n }\n if (label.y < minY) {\n minY = label.y;\n }\n return {\n content: label.content,\n size: labelHeight,\n targets: [label.y - startY],\n pos: null,\n };\n });\n\n minY -= startY;\n if (maxY - startY > totalHeight) {\n totalHeight = maxY - startY;\n }\n\n while (overlapping) {\n /* eslint no-loop-func: 0 */\n boxes.forEach((box) => {\n const target = (Math.min.apply(minY, box.targets) + Math.max.apply(minY, box.targets)) / 2;\n box.pos = Math.min(Math.max(minY, target - box.size / 2), totalHeight - box.size);\n box.pos = Math.max(0, box.pos);\n });\n\n // detect overlapping and join boxes\n overlapping = false;\n i = boxes.length;\n while (i--) {\n if (i > 0) {\n const previousBox = boxes[i - 1];\n const box = boxes[i];\n if (previousBox.pos + previousBox.size > box.pos) {\n // overlapping\n previousBox.size += box.size;\n previousBox.targets = previousBox.targets.concat(box.targets);\n\n // overflow, shift up\n if (previousBox.pos + previousBox.size > totalHeight) {\n previousBox.pos = totalHeight - previousBox.size;\n }\n boxes.splice(i, 1); // removing box\n overlapping = true;\n }\n }\n }\n }\n\n i = 0;\n // step 4: normalize y and adjust x\n boxes.forEach((b) => {\n let posInCompositeBox = startY + labelHeight / 2; // middle of the label\n b.targets.forEach(() => {\n labels[i].y = b.pos + posInCompositeBox;\n posInCompositeBox += labelHeight;\n i++;\n });\n });\n}\n","import { Coordinate } from '@antv/coord';\nimport { BBox, IGroup, IShape, IElement } from '@antv/g-base';\nimport { isObject, each, get, groupBy, isNil, filter } from '@antv/util';\nimport { polarToCartesian } from '../../../../util/graphics';\nimport { PolarLabelItem } from '../../interface';\nimport { antiCollision } from './util';\n\n/** label text和line距离 4px */\nconst MARGIN = 4;\n\n/**\n * 配置 labelline\n * @param item PolarLabelItem\n */\nfunction drawLabelline(item: any /** PolarLabelItem */, coordinate: Coordinate) {\n /** 坐标圆心 */\n const center = coordinate.getCenter();\n /** 圆半径 */\n const radius = coordinate.getRadius();\n\n if (item && item.labelLine) {\n const { angle, offset: labelOffset } = item;\n // 贴近圆周\n const startPoint = polarToCartesian(center.x, center.y, radius, angle);\n const itemX = item.x + get(item, 'offsetX', 0) * (Math.cos(angle) > 0 ? 1 : -1);\n const itemY = item.y + get(item, 'offsetY', 0) * (Math.sin(angle) > 0 ? 1 : -1);\n\n const endPoint = {\n x: itemX - Math.cos(angle) * MARGIN,\n y: itemY - Math.sin(angle) * MARGIN,\n };\n\n const smoothConnector = item.labelLine.smooth;\n const path = [];\n const dx = endPoint.x - center.x;\n const dy = endPoint.y - center.y;\n let endAngle = Math.atan(dy / dx);\n // 第三象限 & 第四象限\n if (dx < 0) {\n endAngle += Math.PI;\n }\n\n // 默认 smooth, undefined 也为 smooth\n if (smoothConnector === false) {\n if (!isObject(item.labelLine)) {\n // labelLine: true\n item.labelLine = {};\n }\n\n // 表示弧线的方向,0 表示从起点到终点沿逆时针画弧, 1 表示顺时针\n let sweepFlag = 0;\n\n // 第一象限\n if ((angle < 0 && angle > -Math.PI / 2) || angle > Math.PI * 1.5) {\n if (endPoint.y > startPoint.y) {\n sweepFlag = 1;\n }\n }\n\n // 第二象限\n if (angle >= 0 && angle < Math.PI / 2) {\n if (endPoint.y > startPoint.y) {\n sweepFlag = 1;\n }\n }\n\n // 第三象限\n if (angle >= Math.PI / 2 && angle < Math.PI) {\n if (startPoint.y > endPoint.y) {\n sweepFlag = 1;\n }\n }\n\n // 第四象限\n if (angle < -Math.PI / 2 || (angle >= Math.PI && angle < Math.PI * 1.5)) {\n if (startPoint.y > endPoint.y) {\n sweepFlag = 1;\n }\n }\n\n const distance = labelOffset / 2 > 4 ? 4 : Math.max(labelOffset / 2 - 1, 0);\n const breakPoint = polarToCartesian(center.x, center.y, radius + distance, angle);\n // 圆弧的结束点\n const breakPoint3 = polarToCartesian(center.x, center.y, radius + labelOffset / 2, endAngle);\n\n /**\n * @example\n * M 100 100 L100 90 A 50 50 0 0 0 150 50\n * 移动至 (100, 100), 连接到 (100, 90), 以 (50, 50) 为圆心,绘制圆弧至 (150, 50);\n * A 命令的第 4 个参数 large-arc-flag, 决定弧线是大于还是小于 180 度: 0 表示小角度弧,1 表示大角\n * 第 5 个参数: 是否顺时针绘制\n */\n // 默认小弧\n const largeArcFlag = 0;\n // step1: 移动至起点\n path.push(`M ${startPoint.x} ${startPoint.y}`);\n // step2: 连接拐点\n path.push(`L ${breakPoint.x} ${breakPoint.y}`);\n // step3: 绘制圆弧 至 结束点\n path.push(`A ${center.x} ${center.y} 0 ${largeArcFlag} ${sweepFlag} ${breakPoint3.x} ${breakPoint3.y}`);\n // step4: 连接结束点\n path.push(`L ${endPoint.x} ${endPoint.y}`);\n } else {\n const breakPoint = polarToCartesian(\n center.x,\n center.y,\n radius + (labelOffset / 2 > 4 ? 4 : Math.max(labelOffset / 2 - 1, 0)),\n angle\n );\n // G2 旧的拉线\n // path.push('Q', `${breakPoint.x}`, `${breakPoint.y}`, `${endPoint.x}`, `${endPoint.y}`);\n const xSign = startPoint.x < center.x ? 1 : -1;\n // step1: 连接结束点\n path.push(`M ${endPoint.x} ${endPoint.y}`);\n const slope1 = (startPoint.y - center.y) / (startPoint.x - center.x);\n const slope2 = (endPoint.y - center.y) / (endPoint.x - center.x);\n if (Math.abs(slope1 - slope2) > Math.pow(Math.E, -16)) {\n // step2: 绘制 curve line (起点 & 结合点与圆心的斜率不等时, 由于存在误差, 使用近似处理)\n path.push(\n ...[\n 'C',\n endPoint.x + xSign * 4,\n endPoint.y,\n 2 * breakPoint.x - startPoint.x,\n 2 * breakPoint.y - startPoint.y,\n startPoint.x,\n startPoint.y,\n ]\n );\n }\n // step3: 连接至起点\n path.push(`L ${startPoint.x} ${startPoint.y}`);\n }\n item.labelLine.path = path.join(' ');\n }\n}\n\n/**\n * 饼图 outer-label 布局, 适用于 type = pie 且 label offset > 0 的标签\n */\nexport function pieOuterLabelLayout(\n originalItems: PolarLabelItem[],\n labels: IGroup[],\n shapes: IShape[] | IGroup[],\n region: BBox\n) {\n const items = filter(originalItems, (item) => !isNil(item));\n /** 坐标系 */\n const coordinate = labels[0] && labels[0].get('coordinate');\n if (!coordinate) {\n return;\n }\n\n /** 坐标圆心 */\n const center = coordinate.getCenter();\n /** 圆半径 */\n const radius = coordinate.getRadius();\n /** label shapes */\n const labelsMap: Record = {};\n for (const labelShape of labels) {\n labelsMap[labelShape.get('id')] = labelShape;\n }\n\n // note labelHeight 可以控制 label 的行高\n const labelHeight: number = get(items[0], 'labelHeight', 14);\n const labelOffset: number = get(items[0], 'offset', 0);\n\n if (labelOffset <= 0) {\n return;\n }\n\n const LEFT_HALF_KEY = 'left';\n const RIGHT_HALF_KEY = 'right';\n // step 1: separate labels\n const separateLabels = groupBy(items, (item) => (item.x < center.x ? LEFT_HALF_KEY : RIGHT_HALF_KEY));\n\n const { start, end } = coordinate;\n // step2: calculate totalHeight\n const totalHeight = Math.min((radius + labelOffset + labelHeight) * 2, coordinate.getHeight());\n const totalR = totalHeight / 2;\n\n /** labels 容器的范围(后续根据组件的布局设计进行调整) */\n const labelsContainerRange = {\n minX: start.x,\n maxX: end.x,\n minY: center.y - totalR,\n maxY: center.y + totalR,\n };\n\n // step 3: antiCollision\n each(separateLabels, (half, key) => {\n const maxLabelsCountForOneSide = Math.floor(totalHeight / labelHeight);\n if (half.length > maxLabelsCountForOneSide) {\n half.sort((a, b) => {\n // sort by percentage DESC\n return b.percent - a.percent;\n });\n\n each(half, (labelItem: PolarLabelItem, idx) => {\n if (idx + 1 > maxLabelsCountForOneSide) {\n labelsMap[labelItem.id].set('visible', false);\n labelItem.invisible = true;\n }\n });\n }\n antiCollision(half, labelHeight, labelsContainerRange);\n });\n\n each(separateLabels, (half: PolarLabelItem[], key: string) => {\n each(half, (item: PolarLabelItem) => {\n const isRight = key === RIGHT_HALF_KEY;\n const labelShape = labelsMap[item.id];\n\n // because group could not effect content-shape, should set content-shape position manually\n const content = labelShape.getChildByIndex(0) as IElement;\n\n // textShape 发生过调整\n if (content) {\n const r = radius + labelOffset;\n // (x - cx)^2 + (y - cy)^2 = totalR^2\n const dy = item.y - center.y;\n\n const rPow2 = Math.pow(r, 2);\n const dyPow2 = Math.pow(dy, 2);\n const dxPow2 = rPow2 - dyPow2 > 0 ? rPow2 - dyPow2 : 0;\n const dx = Math.sqrt(dxPow2);\n\n const dx_offset = Math.abs(Math.cos(item.angle) * r);\n if (!isRight) {\n // left\n item.x = center.x - Math.max(dx, dx_offset);\n } else {\n // right\n item.x = center.x + Math.max(dx, dx_offset);\n }\n }\n\n // adjust labelShape\n if (content) {\n content.attr('y', item.y);\n content.attr('x', item.x);\n }\n\n drawLabelline(item, coordinate);\n });\n });\n}\n","import { BBox, IGroup, IShape } from '@antv/g-base';\nimport { each, get, isNil, deepMix, groupBy } from '@antv/util';\nimport { polarToCartesian } from '../../../../util/graphics';\nimport { LabelItem, PolarLabelItem } from '../../interface';\nimport { antiCollision } from './util';\nimport { translate } from '../../../../util/transform';\nimport { Coordinate } from '@antv/coord';\n\n/** 拐点偏移量, 暂不可配置 */\nconst INFLECTION_OFFSET = 4;\n/** 标签偏移量, distance between label and edge: offsetX */\nconst LABEL_OFFSET_X = 4;\n/** 标签与牵引线的偏移量 */\nconst LABEL_TEXT_LINE_OFFSET = 4;\n\nfunction drawLabelline(item: PolarLabelItem, coordinate: Coordinate, inRight: boolean) {\n /** 坐标圆心 */\n const center = coordinate.getCenter();\n /** 圆半径 */\n const radius = coordinate.getRadius();\n const startPoint = {\n x: item.x - (inRight ? LABEL_TEXT_LINE_OFFSET : -LABEL_TEXT_LINE_OFFSET),\n y: item.y,\n };\n const inflectionPoint = polarToCartesian(center.x, center.y, radius + INFLECTION_OFFSET, item.angle);\n const p1 = { x: startPoint.x, y: startPoint.y };\n const p2 = { x: inflectionPoint.x, y: inflectionPoint.y };\n\n const endPoint = polarToCartesian(center.x, center.y, radius, item.angle);\n let path = '';\n\n // 文本被调整下去了,则添加拐点连接线\n if (startPoint.y !== inflectionPoint.y) {\n const offset = inRight ? 4 : -4;\n p1.y = startPoint.y;\n\n /** 是否在第一象限 */\n if (item.angle < 0 && item.angle >= -Math.PI / 2) {\n p1.x = Math.max(inflectionPoint.x, startPoint.x - offset);\n if (startPoint.y < inflectionPoint.y) {\n p2.y = p1.y;\n } else {\n p2.y = inflectionPoint.y;\n p2.x = Math.max(p2.x, p1.x - offset);\n }\n }\n /** 是否在 第二象限 */\n if (item.angle > 0 && item.angle < Math.PI / 2) {\n p1.x = Math.max(inflectionPoint.x, startPoint.x - offset);\n if (startPoint.y > inflectionPoint.y) {\n p2.y = p1.y;\n } else {\n p2.y = inflectionPoint.y;\n p2.x = Math.max(p2.x, p1.x - offset);\n }\n }\n /** 是否在 第三象限 */\n if (item.angle > Math.PI / 2) {\n p1.x = Math.min(inflectionPoint.x, startPoint.x - offset);\n if (startPoint.y > inflectionPoint.y) {\n p2.y = p1.y;\n } else {\n p2.y = inflectionPoint.y;\n p2.x = Math.min(p2.x, p1.x - offset);\n }\n }\n /** 是否在 第四象限 */\n if (item.angle < -Math.PI / 2) {\n p1.x = Math.min(inflectionPoint.x, startPoint.x - offset);\n if (startPoint.y < inflectionPoint.y) {\n p2.y = p1.y;\n } else {\n p2.y = inflectionPoint.y;\n p2.x = Math.min(p2.x, p1.x - offset);\n }\n }\n }\n\n path = [\n `M ${startPoint.x},${startPoint.y}`,\n `L ${p1.x},${p1.y}`,\n `L ${p2.x},${p2.y}`,\n `L ${inflectionPoint.x},${inflectionPoint.y}`,\n `L ${endPoint.x},${endPoint.y}`,\n ].join(' ');\n item.labelLine = deepMix({}, item.labelLine, { path });\n}\n\n/**\n * 饼图标签 spider 布局, 只适用于 pie-spider 的标签类型\n * region 应该是 labelsRenderer 容器的范围限制(便于后续组件间布局)\n */\nexport function pieSpiderLabelLayout(items: LabelItem[], labels: IGroup[], shapes: IShape[] | IGroup[], region: BBox) {\n /** 坐标系 */\n const coordinate = labels[0] && labels[0].get('coordinate');\n if (!coordinate) {\n return;\n }\n\n /** 坐标圆心 */\n const center = coordinate.getCenter();\n /** 圆半径 */\n const radius = coordinate.getRadius();\n /** label shapes */\n const labelsMap: Record = {};\n for (const labelShape of labels) {\n labelsMap[labelShape.get('id')] = labelShape;\n }\n\n const labelHeight: number = get(items[0], 'labelHeight', 14);\n const labelOffset: number = Math.max(get(items[0], 'offset', 0), INFLECTION_OFFSET);\n\n // step 1: adjust items to spider\n each(items, (item) => {\n if (!item) return;\n const label = get(labelsMap, [item.id]);\n if (!label) return;\n\n const inRight = item.x > center.x || (item.x === center.x && item.y > center.y);\n const offsetX = !isNil(item.offsetX) ? item.offsetX : LABEL_OFFSET_X;\n const inflectionPoint = polarToCartesian(center.x, center.y, radius + INFLECTION_OFFSET, item.angle);\n\n const totalOffset = labelOffset + offsetX;\n item.x = center.x + (inRight ? 1 : -1) * (radius + totalOffset);\n item.y = inflectionPoint.y;\n });\n\n const { start, end } = coordinate;\n const LEFT_HALF_KEY = 'left';\n const RIGHT_HALF_KEY = 'right';\n // step 1: separate labels\n const separateLabels = groupBy(items, (item) => (item.x < center.x ? LEFT_HALF_KEY : RIGHT_HALF_KEY));\n\n // step2: calculate totalHeight\n let totalHeight = (radius + labelOffset) * 2 + labelHeight;\n\n each(separateLabels, (half: PolarLabelItem[]) => {\n const halfHeight = half.length * labelHeight;\n if (halfHeight > totalHeight) {\n totalHeight = Math.min(halfHeight, Math.abs(start.y - end.y));\n }\n });\n\n /** labels 容器的范围(后续根据组件的布局设计进行调整) */\n const labelsContainerRange = {\n minX: start.x,\n maxX: end.x,\n minY: center.y - totalHeight / 2,\n maxY: center.y + totalHeight / 2,\n };\n\n // step 3: antiCollision\n each(separateLabels, (half, key) => {\n const maxLabelsCountForOneSide = totalHeight / labelHeight;\n if (half.length > maxLabelsCountForOneSide) {\n half.sort((a, b) => {\n // sort by percentage DESC\n return b.percent - a.percent;\n });\n\n each(half, (labelItem: PolarLabelItem, idx) => {\n if (idx > maxLabelsCountForOneSide) {\n labelsMap[labelItem.id].set('visible', false);\n labelItem.invisible = true;\n }\n });\n }\n antiCollision(half, labelHeight, labelsContainerRange);\n });\n\n const startY = labelsContainerRange.minY;\n const endY = labelsContainerRange.maxY;\n\n // step4: applyTo labels and adjust labelLines\n each(separateLabels, (half, key) => {\n const inRight = key === RIGHT_HALF_KEY;\n\n each(half, (item) => {\n const label: IGroup = get(labelsMap, item && [item.id]);\n if (!label) {\n return;\n }\n // out of range, hidden\n if (item.y < startY || item.y > endY) {\n label.set('visible', false);\n return;\n }\n\n const labelContent = label.getChildByIndex(0);\n const box = labelContent.getCanvasBBox();\n const originalPos = { x: inRight ? box.x : box.maxX, y: box.y + box.height / 2 /** vertical-align: middle */ };\n\n translate(labelContent as any, item.x - originalPos.x /** 从 pos.x 移动到 item.x */, item.y - originalPos.y);\n\n // adjust labelLines\n if (item.labelLine) {\n drawLabelline(item, coordinate, inRight);\n }\n });\n });\n}\n","import { each } from '@antv/util';\nimport { BBox, IGroup, IShape } from '../../../dependents';\nimport { LabelItem } from '../interface';\n\nconst MAX_TIMES = 100;\n\n/** @ignore */\ninterface Bitmap {\n [key: number]: {\n [key: number]: boolean;\n };\n}\n\n/** @ignore */\ninterface GreedyCfg {\n readonly xGap?: number;\n readonly yGap?: number;\n}\n\n/**\n * @ignore\n * Greedy 贪婪算法\n */\nclass Greedy {\n public readonly xGap: number;\n /** optimizing for text overlapping detection: use a min text height as gap */\n public readonly yGap: number;\n\n private bitmap: Bitmap = {};\n\n constructor(cfg: GreedyCfg = {}) {\n const { xGap = 1, yGap = 8 } = cfg;\n this.xGap = xGap;\n this.yGap = yGap;\n }\n\n public hasGap(bbox: BBox): boolean {\n let hasGap = true;\n const bitmap = this.bitmap;\n const minX = Math.round(bbox.minX);\n const maxX = Math.round(bbox.maxX);\n const minY = Math.round(bbox.minY);\n const maxY = Math.round(bbox.maxY);\n for (let i = minX; i <= maxX; i += 1) {\n if (!bitmap[i]) {\n bitmap[i] = {};\n continue;\n }\n if (i === minX || i === maxX) {\n for (let j = minY; j <= maxY; j++) {\n if (bitmap[i][j]) {\n hasGap = false;\n break;\n }\n }\n } else {\n if (bitmap[i][minY] || bitmap[i][maxY]) {\n hasGap = false;\n break;\n }\n }\n }\n return hasGap;\n }\n\n public fillGap(bbox: BBox): void {\n const bitmap = this.bitmap;\n const minX = Math.round(bbox.minX);\n const maxX = Math.round(bbox.maxX);\n const minY = Math.round(bbox.minY);\n const maxY = Math.round(bbox.maxY);\n // filling grid\n for (let i = minX; i <= maxX; i += 1) {\n if (!bitmap[i]) {\n bitmap[i] = {};\n }\n }\n for (let i = minX; i <= maxX; i += this.xGap) {\n for (let j = minY; j <= maxY; j += this.yGap) {\n bitmap[i][j] = true;\n }\n bitmap[i][maxY] = true;\n }\n\n // filling y edges\n if (this.yGap !== 1) {\n for (let i = minY; i <= maxY; i += 1) {\n bitmap[minX][i] = true;\n bitmap[maxX][i] = true;\n }\n }\n\n // filling x edges\n if (this.xGap !== 1) {\n for (let i = minX; i <= maxX; i += 1) {\n bitmap[i][minY] = true;\n bitmap[i][maxY] = true;\n }\n }\n }\n\n public destroy(): void {\n this.bitmap = {};\n }\n}\n\nfunction spiralFill(label: IShape, greedy: Greedy, maxTimes: number = MAX_TIMES) {\n const dt = -1;\n const { x, y } = label.attr();\n const bbox = label.getCanvasBBox();\n const maxDelta = Math.sqrt(bbox.width * bbox.width + bbox.height * bbox.height);\n let dxdy;\n let t = -dt;\n let dx = 0;\n let dy = 0;\n const f = (param: number) => {\n const nt = param * 0.1;\n return [nt * Math.cos(nt), nt * Math.sin(nt)];\n };\n\n if (greedy.hasGap(bbox)) {\n greedy.fillGap(bbox);\n return true;\n }\n let canFill = false;\n let times = 0;\n const accessedCache = {};\n while (Math.min(Math.abs(dx), Math.abs(dy)) < maxDelta && times < maxTimes) {\n dxdy = f((t += dt));\n dx = ~~dxdy[0];\n dy = ~~dxdy[1];\n if ((!dx && !dy) || accessedCache[`${dx}-${dy}`]) {\n continue;\n }\n label.attr({ x: x + dx, y: y + dy });\n if (dx + dy < 0) {\n label.attr('textAlign', 'right');\n }\n times++;\n if (greedy.hasGap(label.getCanvasBBox())) {\n greedy.fillGap(label.getCanvasBBox());\n canFill = true;\n accessedCache[`${dx}-${dy}`] = true;\n break;\n }\n }\n return canFill;\n}\n\n/*\n * 根据如下规则尝试放置label\n * 5\n * ------------------\n * | 1 | 0 |\n * 8 —————————4———————— 7\n * | 2 | 3 |\n * ——————————————————\n * 6\n */\nfunction adjustLabelPosition(label: IShape, x: number, y: number, index: number) {\n const { width, height } = label.getCanvasBBox();\n const attrs = {\n x,\n y,\n textAlign: 'center',\n };\n switch (index) {\n case 0:\n attrs.y -= height + 1;\n attrs.x += 1;\n attrs.textAlign = 'left';\n break;\n case 1:\n attrs.y -= height + 1;\n attrs.x -= 1;\n attrs.textAlign = 'right';\n break;\n case 2:\n attrs.y += height + 1;\n attrs.x -= 1;\n attrs.textAlign = 'right';\n break;\n case 3:\n attrs.y += height + 1;\n attrs.x += 1;\n attrs.textAlign = 'left';\n break;\n case 5:\n attrs.y -= height * 2 + 2;\n break;\n case 6:\n attrs.y += height * 2 + 2;\n break;\n case 7:\n attrs.x += width + 1;\n attrs.textAlign = 'left';\n break;\n case 8:\n attrs.x -= width + 1;\n attrs.textAlign = 'right';\n break;\n default:\n break;\n }\n label.attr(attrs);\n return label.getCanvasBBox();\n}\n\n/**\n * @ignore\n * label 防遮挡布局:在不改变 label 位置的情况下对相互重叠的 label 进行调整。\n * 不同于 'overlap' 类型的布局,该布局不会对 label 的位置进行偏移调整。\n * @param labels 参与布局调整的 label 数组集合\n */\nexport function fixedOverlap(items: LabelItem[], labels: IGroup[], shapes: IShape[] | IGroup[], region: BBox) {\n const greedy = new Greedy();\n each(labels, (label: IGroup) => {\n const labelShape = label.find((shape) => shape.get('type') === 'text') as IShape;\n if (!spiralFill(labelShape, greedy)) {\n label.remove(true);\n }\n });\n greedy.destroy();\n}\n\n/**\n * @ignore\n * label 防遮挡布局:为了防止 label 之间相互覆盖同时保证尽可能多 的 label 展示,通过尝试将 label 向**四周偏移**来剔除放不下的 label\n * @param labels 参与布局调整的 label 数组集合\n */\nexport function overlap(items: LabelItem[], labels: IGroup[], shapes: IShape[] | IGroup[], region: BBox) {\n const greedy = new Greedy();\n each(labels, (label: IGroup) => {\n const labelShape = label.find((shape) => shape.get('type') === 'text') as IShape;\n const { x, y } = labelShape.attr();\n let canFill = false;\n for (let i = 0; i <= 8; i++) {\n const bbox = adjustLabelPosition(labelShape, x, y, i);\n if (greedy.hasGap(bbox)) {\n greedy.fillGap(bbox);\n canFill = true;\n break;\n }\n }\n if (!canFill) {\n label.remove(true);\n }\n });\n\n greedy.destroy();\n}\n","import { isNumber } from '@antv/util';\nimport { Point } from '../dependents';\n\ntype Vec2 = [number, number];\n\ntype Item = {\n x: number;\n y: number;\n width: number;\n height: number;\n rotation?: number;\n visible?: boolean;\n};\n/**\n * 定义投影对象\n */\ntype Projection = { min: number; max: number };\n\nfunction dot(a, b) {\n return (a[0] || 0) * (b[0] || 0) + (a[1] || 0) * (b[1] || 0) + (a[2] || 0) * (b[2] || 0);\n}\n\n/**\n * @private\n * 1. 获取投影轴\n */\nfunction getAxes(points: Point[] /** 多边形的关键点 */): Vec2[] {\n // 目前先处理 平行矩形 的场景, 其他多边形不处理\n if (points.length > 4) {\n return [];\n }\n // 获取向量\n const vector = (start: Point, end: Point): Vec2 => {\n return [end.x - start.x, end.y - start.y];\n };\n\n // 由于 矩形的平行原理,所以只有 2 条投影轴: A -> B, B -> C\n const AB = vector(points[0], points[1]);\n const BC = vector(points[1], points[2]);\n\n return [AB, BC];\n}\n\n/**\n * @private\n * 绕指定点顺时针旋转后的点坐标\n * 默认绕原点旋转\n */\nfunction rotateAtPoint(point: Point, deg = 0, origin = { x: 0, y: 0 }): Point {\n const { x, y } = point;\n return {\n x: (x - origin.x) * Math.cos(-deg) + (y - origin.y) * Math.sin(-deg) + origin.x,\n y: (origin.x - x) * Math.sin(-deg) + (y - origin.y) * Math.cos(-deg) + origin.y,\n };\n}\n\n/**\n * @private\n * 转化为顶点坐标数组\n *\n * @param {Object} box\n */\nfunction getRectPoints(box: Item): Point[] {\n const points = [\n { x: box.x, y: box.y },\n { x: box.x + box.width, y: box.y },\n { x: box.x + box.width, y: box.y + box.height },\n { x: box.x, y: box.y + box.height },\n ];\n\n const rotation = box.rotation;\n if (rotation) {\n return [\n rotateAtPoint(points[0], rotation, points[0]),\n rotateAtPoint(points[1], rotation, points[0]),\n rotateAtPoint(points[2], rotation, points[0]),\n rotateAtPoint(points[3], rotation, points[0]),\n ];\n }\n\n return points;\n}\n\n/**\n * @private\n * 2. 获取多边形在投影轴上的投影\n *\n * 向量的点积的其中一个几何含义是:一个向量在平行于另一个向量方向上的投影的数值乘积。\n * 由于投影轴是单位向量(长度为1),投影的长度为 x1 * x2 + y1 * y2\n */\nfunction getProjection(points: Point[] /** 多边形的关键点 */, axis: Vec2): Projection {\n // 目前先处理矩形的场景\n if (points.length > 4) {\n return { min: 0, max: 0 };\n }\n\n const scalars = [];\n points.forEach((point) => {\n scalars.push(dot([point.x, point.y], axis));\n });\n\n return { min: Math.min(...scalars), max: Math.max(...scalars) };\n}\n\nfunction isProjectionOverlap(projection1: Projection, projection2: Projection): boolean {\n return projection1.max > projection2.min && projection1.min < projection2.max;\n}\n\nfunction isValidNumber(d: number) {\n return typeof d === 'number' && !Number.isNaN(d) && d !== Infinity && d !== -Infinity;\n}\n\nfunction isValidBox(box: Item) {\n return ['x', 'y', 'width', 'height'].every(attr => isValidNumber(box[attr]))\n}\n\n/**\n * 快速判断两个无旋转矩形是否遮挡\n */\nexport function isIntersectRect(box1: Item, box2: Item, margin: number = 0): boolean {\n return !(\n box2.x > box1.x + box1.width + margin ||\n box2.x + box2.width < box1.x - margin ||\n box2.y > box1.y + box1.height + margin ||\n box2.y + box2.height < box1.y - margin\n );\n}\n\n/**\n * detect whether two shape is intersected, useful when shape is been rotated\n * 判断两个矩形是否重叠(相交和包含, 是否旋转)\n *\n * - 原理: 分离轴定律\n */\nexport function intersect(box1: Item, box2: Item, margin: number = 0) {\n // 如果两个 box 中有一个是不合法的 box,也就是不会被渲染出来的,那么它们就不相交。\n if (!isValidBox(box1) || !isValidBox(box2)) return false;\n\n // 如果两个矩形没有旋转,使用快速判断\n if (!box1.rotation && !box2.rotation) {\n return isIntersectRect(box1, box2, margin);\n }\n\n // 分别获取 4 个关键点\n const rect1Points = getRectPoints(box1);\n const rect2Points = getRectPoints(box2);\n\n // 获取所有投影轴\n const axes = getAxes(rect1Points).concat(getAxes(rect2Points));\n\n for (let i = 0; i < axes.length; i++) {\n const axis = axes[i];\n const projection1 = getProjection(rect1Points, axis);\n const projection2 = getProjection(rect2Points, axis);\n\n // 判断投影轴上的投影是否存在重叠,若检测到存在间隙则立刻退出判断,消除不必要的运算。\n if (!isProjectionOverlap(projection1, projection2)) {\n return false;\n }\n }\n\n return true;\n}\n","import { isFunction } from '@antv/util';\n\nclass MyWorker {\n queue: any[] = [];\n worker: Worker;\n\n constructor(url) {\n this.worker = new Worker(url);\n this.worker.onmessage = (e: MessageEvent) => {\n this.queue.shift()?.resolve(e);\n };\n this.worker.onmessageerror = (e: MessageEvent) => {\n console.warn('[AntV G2] Web worker is not available');\n this.queue.shift()?.reject(e);\n };\n }\n\n post(params, onError?: () => any): Promise {\n return new Promise((resolve, reject) => {\n this.queue.push({ resolve, reject });\n try {\n this.worker.postMessage(params);\n } catch (e) {\n console.warn('[AntV G2] Web worker is not available');\n isFunction(onError) && onError();\n }\n });\n }\n\n destroy() {\n this.worker.terminate();\n }\n}\n\nexport function createWorker(f: any) {\n if (typeof window === 'undefined') return;\n\n let blob;\n try {\n blob = new Blob([f.toString()], { type: 'application/javascript' });\n } catch (e) {\n // @ts-ignore\n blob = new window.BlobBuilder();\n blob.append(f.toString());\n blob = blob.getBlob();\n }\n\n return new MyWorker(URL.createObjectURL(blob));\n}\n","const onmessage = function (e) {\n type Item = {\n x: number;\n y: number;\n width: number;\n height: number;\n rotation?: number;\n visible?: boolean;\n };\n\n // Copy from src/util/collision-detect.ts\n function generateUtils() {\n type Vec2 = [number, number];\n\n type Point = { x: number; y: number };\n\n /**\n * 定义投影对象\n */\n type Projection = { min: number; max: number };\n\n function dot(a, b) {\n return (a[0] || 0) * (b[0] || 0) + (a[1] || 0) * (b[1] || 0) + (a[2] || 0) * (b[2] || 0);\n }\n /**\n * 1. 获取投影轴\n */\n function getAxes(points: Point[] /** 多边形的关键点 */): Vec2[] {\n // 目前先处理 平行矩形 的场景, 其他多边形不处理\n if (points.length > 4) {\n return [];\n }\n // 获取向量\n const vector = (start: Point, end: Point): Vec2 => {\n return [end.x - start.x, end.y - start.y];\n };\n\n // 由于 矩形的平行原理,所以只有 2 条投影轴: A -> B, B -> C\n const AB = vector(points[0], points[1]);\n const BC = vector(points[1], points[2]);\n\n return [AB, BC];\n }\n\n /**\n * 绕指定点顺时针旋转后的点坐标\n * 默认绕原点旋转\n */\n function rotateAtPoint(point: Point, deg = 0, origin = { x: 0, y: 0 }): Point {\n const { x, y } = point;\n return {\n x: (x - origin.x) * Math.cos(-deg) + (y - origin.y) * Math.sin(-deg) + origin.x,\n y: (origin.x - x) * Math.sin(-deg) + (y - origin.y) * Math.cos(-deg) + origin.y,\n };\n }\n\n /**\n * @private\n * 转化为顶点坐标数组\n *\n * @param {Object} box\n */\n function getRectPoints(box: Item): Point[] {\n const points = [\n { x: box.x, y: box.y },\n { x: box.x + box.width, y: box.y },\n { x: box.x + box.width, y: box.y + box.height },\n { x: box.x, y: box.y + box.height },\n ];\n\n const rotation = box.rotation;\n if (rotation) {\n return [\n rotateAtPoint(points[0], rotation, points[0]),\n rotateAtPoint(points[1], rotation, points[0]),\n rotateAtPoint(points[2], rotation, points[0]),\n rotateAtPoint(points[3], rotation, points[0]),\n ];\n }\n\n return points;\n }\n\n /**\n * 2. 获取多边形在投影轴上的投影\n *\n * 向量的点积的其中一个几何含义是:一个向量在平行于另一个向量方向上的投影的数值乘积。\n * 由于投影轴是单位向量(长度为1),投影的长度为 x1 * x2 + y1 * y2\n */\n function getProjection(points: Point[] /** 多边形的关键点 */, axis: Vec2): Projection {\n // 目前先处理矩形的场景\n if (points.length > 4) {\n return { min: 0, max: 0 };\n }\n\n const scalars = [];\n points.forEach((point) => {\n scalars.push(dot([point.x, point.y], axis));\n });\n\n return { min: Math.min.apply(null, scalars), max: Math.max.apply(null, scalars) };\n }\n\n function isProjectionOverlap(projection1: Projection, projection2: Projection): boolean {\n return projection1.max > projection2.min && projection1.min < projection2.max;\n }\n\n function isValidNumber(d: number) {\n return typeof d === 'number' && !Number.isNaN(d) && d !== Infinity && d !== -Infinity;\n }\n\n function isValidBox(box: Item) {\n return ['x', 'y', 'width', 'height'].every(attr => isValidNumber(box[attr]))\n }\n\n function isIntersectRect(box1: Item, box2: Item, margin: number = 0): boolean {\n return !(\n box2.x > box1.x + box1.width + margin ||\n box2.x + box2.width < box1.x - margin ||\n box2.y > box1.y + box1.height + margin ||\n box2.y + box2.height < box1.y - margin\n );\n }\n function intersect(box1: Item, box2: Item, margin: number = 0) {\n if (!isValidBox(box1) || !isValidBox(box2)) return false;\n\n // Quick detect, if rotation is null or zero.\n if (!box1.rotation && !box2.rotation) {\n return isIntersectRect(box1, box2, margin);\n }\n\n // 分别获取 4 个关键点\n const rect1Points = getRectPoints(box1);\n const rect2Points = getRectPoints(box2);\n\n // 获取所有投影轴\n const axes = getAxes(rect1Points).concat(getAxes(rect2Points));\n\n for (let i = 0; i < axes.length; i++) {\n const axis = axes[i];\n const projection1 = getProjection(rect1Points, axis);\n const projection2 = getProjection(rect2Points, axis);\n\n if (!isProjectionOverlap(projection1, projection2)) return false;\n }\n\n return true;\n }\n return { intersect }\n }\n const { intersect } = generateUtils();\n\n // Label layouts.\n function hideOverlap(items: Item[]) {\n const boxes = items.slice();\n for (let i = 0; i < boxes.length; i++) {\n const box1 = boxes[i];\n if (box1.visible) {\n for (let j = i + 1; j < boxes.length; j++) {\n const box2 = boxes[j];\n if (box1 !== box2 && box2.visible) {\n if (intersect(box1, box2)) {\n box2.visible = false;\n }\n }\n }\n }\n }\n return boxes;\n }\n\n const methods = {\n 'hide-overlap': hideOverlap,\n }\n\n // Main\n try {\n const eventData = JSON.parse(e.data);\n if (!eventData || !eventData.type || !methods[eventData.type]) return;\n\n const { type, items } = eventData;\n const result = methods[type](items);\n self.postMessage(result);\n } catch (e) {\n throw e;\n }\n}\n\nconst code = `\n self.onmessage = ${onmessage.toString()}\n`\nexport { code };\n","import { get, each } from '@antv/util';\nimport { BBox, IGroup, IShape } from '../../../dependents';\nimport { intersect } from '../../../util/collision-detect';\nimport { LabelItem } from '../interface';\nimport { getLabelBackgroundInfo } from '../util';\nimport { createWorker } from '../util/createWorker';\nimport { code as layoutCode } from './worker/hide-overlap';\n\ntype Item = {\n x: number;\n y: number;\n width: number;\n height: number;\n rotation?: number;\n visible?: boolean;\n};\n\nconst layout = (items: Item[]): Item[] => {\n const boxes = items.slice();\n for (let i = 0; i < boxes.length; i++) {\n const box1 = boxes[i];\n if (box1.visible) {\n for (let j = i + 1; j < boxes.length; j++) {\n const box2 = boxes[j];\n if (box1 !== box2 && box2.visible) {\n if (intersect(box1, box2)) {\n box2.visible = false;\n }\n }\n }\n }\n }\n return boxes;\n};\n\nconst cache: Map = new Map();\nconst worker = createWorker(layoutCode);\n\n/**\n * label 防遮挡布局:在不改变 label 位置的情况下对相互重叠的 label 进行隐藏(非移除)\n * 不同于 'overlap' 类型的布局,该布局不会对 label 的位置进行偏移调整。\n * @param labels 参与布局调整的 label 数组集合\n */\nexport async function hideOverlap(\n labelItems: LabelItem[],\n labels: IGroup[],\n shapes: IShape[] | IGroup[],\n region: BBox\n) {\n const boxes = labels.map((d, idx) => ({\n ...getLabelBackgroundInfo(d, labelItems[idx], get(labelItems[idx], 'background.padding')),\n visible: true,\n }));\n const memoKey = JSON.stringify(boxes);\n const cb = (items: Item[]) => {\n cache.set(memoKey, items);\n each(items, ({ visible }, idx) => {\n const labelShape = labels[idx];\n if (visible) {\n labelShape?.show();\n } else {\n labelShape?.hide();\n }\n });\n return items;\n };\n if (cache.get(memoKey)) {\n cb(cache.get(memoKey));\n } else if (worker) {\n // Do layout in worker.\n try {\n const params = JSON.stringify({ type: 'hide-overlap', items: boxes });\n const res = await worker.post(params, () => cb(layout(boxes)));\n cb(Array.isArray(res.data) ? res.data : []);\n } catch (e) {\n console.error(e);\n cb(layout(boxes));\n }\n } else {\n // Normal layout in main thread.\n cb(layout(boxes));\n }\n}\n","import colorUtil from '@antv/color-util';\n\n// 内置的一些特殊设置\nconst preset = {\n '#5B8FF9': true,\n};\n\n// 根据YIQ亮度判断指定颜色取反色是不是白色\n// http://24ways.org/2010/calculating-color-contrast\n// http://www.w3.org/TR/AERT#color-contrast\nexport const isContrastColorWhite = (color: string): boolean => {\n const rgb = colorUtil.toRGB(color).toUpperCase();\n if (preset[rgb]) {\n return preset[rgb];\n }\n\n const [r, g, b] = colorUtil.rgb2arr(rgb);\n const isDark = (r * 299 + g * 587 + b * 114) / 1000 < 128;\n\n return isDark;\n};\n","let ctx: CanvasRenderingContext2D;\n\n/**\n * 获取 canvas context\n */\nexport function getCanvasContext() {\n if (!ctx) {\n ctx = document.createElement('canvas').getContext('2d');\n }\n\n return ctx;\n}\n","import { IElement, IGroup, IShape } from '../../../../dependents';\nimport { BBox } from '../../../../util/bbox';\nimport Geometry from '../../../base';\nimport Element from '../../../element';\nimport { LabelItem } from '../../interface';\nimport { findLabelTextShape } from '../../util';\n\nfunction shouldInShapeSingle(geometry: Geometry, label: IGroup, shape: IElement): boolean {\n const coordinate = geometry.coordinate;\n const textShape = findLabelTextShape(label);\n const textBBox = BBox.fromObject(textShape.getCanvasBBox());\n const shapeBBox = BBox.fromObject(shape.getBBox());\n\n return coordinate.isTransposed ? shapeBBox.height >= textBBox.height : shapeBBox.width >= textBBox.width;\n}\n\nfunction shouldInShape(geometry: Geometry, labels: IGroup[], shapes: IShape[] | IGroup[]): boolean {\n const isStack = !!geometry.getAdjust('stack');\n\n return (\n isStack ||\n labels.every((label: IGroup, index: number) => {\n const shape = shapes[index];\n return shouldInShapeSingle(geometry, label, shape);\n })\n );\n}\n\nfunction moveInShape(geometry: Geometry, label: IGroup, shape: IElement): void {\n const coordinate = geometry.coordinate;\n const shapeBBox = BBox.fromObject(shape.getBBox());\n const textShape = findLabelTextShape(label);\n\n if (coordinate.isTransposed) {\n // 水平方向:条形图系列\n textShape.attr({\n x: shapeBBox.minX + shapeBBox.width / 2,\n textAlign: 'center',\n });\n } else {\n // 垂直方向:柱形图系列\n textShape.attr({\n y: shapeBBox.minY + shapeBBox.height / 2,\n textBaseline: 'middle',\n });\n }\n}\n\n/**\n * 适用于 interval geometry 的数据标签位置自动调整布局方法\n * @param items\n * @param labels\n * @param shapes\n */\nexport function intervalAdjustPosition(items: LabelItem[], labels: IGroup[], shapes: IShape[] | IGroup[]) {\n if (shapes.length === 0) {\n return;\n }\n const element: Element = shapes[0]?.get('element');\n const geometry: Geometry = element?.geometry;\n if (!geometry || geometry.type !== 'interval') {\n return;\n }\n\n const inShape = shouldInShape(geometry, labels, shapes);\n if (inShape) {\n shapes.forEach((shape: IShape | IGroup, index: number) => {\n const label = labels[index];\n moveInShape(geometry, label, shape);\n });\n }\n}\n","import { groupBy, keys, map } from '@antv/util';\nimport { IElement, IGroup, IShape, BBox } from '../../../../dependents';\nimport Geometry from '../../../base';\nimport Element from '../../../element';\nimport { LabelItem } from '../../interface';\nimport { findLabelTextShape } from '../../util';\n\n/**\n * point-adjust-position layout 的配置类型\n */\nexport interface PointAdjustPositionLayoutCfg {\n offset?: number;\n}\n\n/**\n * 对同一组(相同 xField )的 Label 进行排序:第一个、最后一个、其他...\n * @param geometry\n * @param labels\n */\nfunction sortLabels(geometry: Geometry, labels: IGroup[]) {\n const yField = geometry.getXYFields()[1];\n const result: IGroup[] = [];\n const sortedLabels = labels.sort((left, right) => left.get('data')[yField] - left.get('data')[yField]);\n\n if (sortedLabels.length > 0) {\n result.push(sortedLabels.shift());\n }\n if (sortedLabels.length > 0) {\n result.push(sortedLabels.pop());\n }\n result.push(...sortedLabels);\n\n return result;\n}\n\nfunction hasSome(dones: IGroup[], current: IGroup, compare: (left: IGroup, right: IGroup) => boolean): boolean {\n return dones.some((done) => compare(done, current));\n}\n\n/**\n * 计算两个矩形之间的堆叠区域面积\n */\nfunction getOverlapArea(a: BBox, b: BBox, margin = 0) {\n const xOverlap = Math.max(\n 0,\n Math.min(a.x + a.width + margin, b.x + b.width + margin) - Math.max(a.x - margin, b.x - margin)\n );\n const yOverlap = Math.max(\n 0,\n Math.min(a.y + a.height + margin, b.y + b.height + margin) - Math.max(a.y - margin, b.y - margin)\n );\n\n return xOverlap * yOverlap;\n}\n\n/**\n * 判断新添加的 Label 是否和已存在的发生重叠\n * @param dones\n * @param current\n */\nfunction checkShapeOverlap(dones: IGroup[], current: IGroup): boolean {\n return hasSome(dones, current, (left, right) => {\n const leftText = findLabelTextShape(left);\n const rightText = findLabelTextShape(right);\n\n return getOverlapArea(leftText.getCanvasBBox(), rightText.getCanvasBBox(), 2) > 0;\n });\n}\n/**\n * 适用于 point geometry 的数据标签位置自动调整布局方法\n * @param items\n * @param labels\n * @param shapes\n * @param region\n * @param cfg\n */\nexport function pointAdjustPosition(\n items: LabelItem[],\n labels: IGroup[],\n shapes: IShape[] | IGroup[],\n region: BBox,\n cfg: PointAdjustPositionLayoutCfg\n): void {\n if (shapes.length === 0) {\n return;\n }\n\n const element: Element = shapes[0]?.get('element');\n const geometry: Geometry = element?.geometry;\n if (!geometry || geometry.type !== 'point') {\n return;\n }\n const [xField, yField] = geometry.getXYFields();\n const groupedLabels = groupBy(labels, (label) => label.get('data')[xField]);\n const dones: IGroup[] = [];\n const offset = (cfg && cfg.offset) || items[0]?.offset || 12;\n\n map(keys(groupedLabels).reverse(), (xValue) => {\n const sortedCollections = sortLabels(geometry, groupedLabels[xValue]);\n while (sortedCollections.length) {\n const current = sortedCollections.shift();\n const textShape = findLabelTextShape(current);\n if (\n hasSome(\n dones,\n current,\n (left, right) =>\n left.get('data')[xField] === right.get('data')[xField] &&\n left.get('data')[yField] === right.get('data')[yField]\n )\n ) {\n // 重复位置,直接隐藏\n textShape.set('visible', false);\n continue;\n }\n const upFail = checkShapeOverlap(dones, current);\n let downFail: boolean = false;\n if (upFail) {\n textShape.attr('y', textShape.attr('y') + 2 * offset);\n downFail = checkShapeOverlap(dones, current);\n }\n if (downFail) {\n textShape.set('visible', false);\n continue;\n }\n dones.push(current);\n }\n });\n}\n","import { groupBy, keys, map } from '@antv/util';\nimport { IGroup, IShape, BBox } from '../../../../dependents';\nimport Geometry from '../../../base';\nimport Element from '../../../element';\nimport { LabelItem } from '../../interface';\nimport { findLabelTextShape } from '../../util';\n\n/**\n * point-adjust-position layout 的配置类型\n */\nexport interface PointAdjustPositionLayoutCfg {\n offset?: number;\n}\n\n/**\n * 对同一组(相同 xField )的 Label 进行排序:第一个、最后一个、其他...\n * @param geometry\n * @param labels\n */\nfunction sortLabels(geometry: Geometry, labels: IGroup[]) {\n const yField = geometry.getXYFields()[1];\n const result: IGroup[] = [];\n const sortedLabels = labels.sort((left, right) => left.get('data')[yField] - left.get('data')[yField]);\n\n if (sortedLabels.length > 0) {\n result.push(sortedLabels.shift());\n }\n if (sortedLabels.length > 0) {\n result.push(sortedLabels.pop());\n }\n result.push(...sortedLabels);\n\n return result;\n}\n\nfunction hasSome(dones: IGroup[], current: IGroup, compare: (left: IGroup, right: IGroup) => boolean): boolean {\n return dones.some((done) => compare(done, current));\n}\n\n/**\n * 计算两个矩形之间的堆叠区域面积\n */\nfunction getOverlapArea(a: BBox, b: BBox, margin = 0) {\n const xOverlap = Math.max(\n 0,\n Math.min(a.x + a.width + margin, b.x + b.width + margin) - Math.max(a.x - margin, b.x - margin)\n );\n const yOverlap = Math.max(\n 0,\n Math.min(a.y + a.height + margin, b.y + b.height + margin) - Math.max(a.y - margin, b.y - margin)\n );\n\n return xOverlap * yOverlap;\n}\n\n/**\n * 判断新添加的 Label 是否和已存在的发生重叠\n * @param dones\n * @param current\n */\nfunction checkShapeOverlap(dones: IGroup[], current: IGroup): boolean {\n return hasSome(dones, current, (left, right) => {\n const leftText = findLabelTextShape(left);\n const rightText = findLabelTextShape(right);\n\n return getOverlapArea(leftText.getCanvasBBox(), rightText.getCanvasBBox(), 2) > 0;\n });\n}\n/**\n * 适用于 point geometry 的数据标签位置自动调整布局方法\n * @param items\n * @param labels\n * @param shapes\n * @param region\n * @param cfg\n */\nexport function pathAdjustPosition(\n items: LabelItem[],\n labels: IGroup[],\n shapes: IShape[] | IGroup[],\n region: BBox,\n cfg: PointAdjustPositionLayoutCfg\n): void {\n if (shapes.length === 0) {\n return;\n }\n\n const element: Element = shapes[0]?.get('element');\n const geometry: Geometry = element?.geometry;\n if (!geometry || ['path', 'line', 'area'].indexOf(geometry.type) < 0) {\n return;\n }\n const [xField, yField] = geometry.getXYFields();\n const groupedLabels = groupBy(labels, (label) => label.get('data')[xField]);\n const dones: IGroup[] = [];\n const offset = (cfg && cfg.offset) || items[0]?.offset || 12;\n\n map(keys(groupedLabels).reverse(), (xValue) => {\n const sortedCollections = sortLabels(geometry, groupedLabels[xValue]);\n while (sortedCollections.length) {\n const current = sortedCollections.shift();\n const textShape = findLabelTextShape(current);\n if (\n hasSome(\n dones,\n current,\n (left, right) =>\n left.get('data')[xField] === right.get('data')[xField] &&\n left.get('data')[yField] === right.get('data')[yField]\n )\n ) {\n // 重复位置,直接隐藏\n textShape.set('visible', false);\n continue;\n }\n const upFail = checkShapeOverlap(dones, current);\n let downFail: boolean = false;\n if (upFail) {\n textShape.attr('y', textShape.attr('y') + 2 * offset);\n downFail = checkShapeOverlap(dones, current);\n }\n if (downFail) {\n textShape.set('visible', false);\n continue;\n }\n dones.push(current);\n }\n });\n}\n","import { isString, memoize, values, toString } from '@antv/util';\nimport * as CSS from 'csstype';\nimport { getCanvasContext } from './context';\n\ntype FontFace = CSS.Properties;\n\ntype Font = Pick & {\n fontSize?: number;\n};\n\n/**\n * 计算文本在画布中的宽度\n */\nexport const measureTextWidth = memoize(\n (text: any, font: Font = {}): number => {\n const { fontSize, fontFamily, fontWeight, fontStyle, fontVariant } = font;\n const ctx = getCanvasContext();\n ctx!.font = [fontStyle, fontVariant, fontWeight, `${fontSize}px`, fontFamily].join(' ');\n return ctx!.measureText(isString(text) ? text : '').width;\n },\n (text: any, font: Font = {}) => [text, ...values(font)].join('')\n);\n\n/**\n * 获取文本的 ... 文本。\n * 算法(减少每次 measureText 的长度,measureText 的性能跟字符串时间相关):\n * 1. 先通过 STEP 逐步计算,找到最后一个小于 maxWidth 的字符串\n * 2. 然后对最后这个字符串二分计算\n * @param text 需要计算的文本, 由于历史原因 除了支持string,还支持空值,number和数组等\n * @param maxWidth\n * @param font\n */\nexport const getEllipsisText = (text: any, maxWidth: number, font?: Font) => {\n const STEP = 16; // 每次 16,调参工程师\n const DOT_WIDTH = measureTextWidth('...', font);\n\n let leftText;\n\n if (!isString(text)) {\n leftText = toString(text);\n } else {\n leftText = text;\n }\n\n let leftWidth = maxWidth;\n\n const r = []; // 最终的分段字符串\n let currentText;\n let currentWidth;\n\n if (measureTextWidth(text, font) <= maxWidth) {\n return text;\n }\n\n // 首先通过 step 计算,找出最大的未超出长度的\n while (true) {\n // 更新字符串\n currentText = leftText.substr(0, STEP);\n\n // 计算宽度\n currentWidth = measureTextWidth(currentText, font);\n\n // 超出剩余宽度,则停止\n if (currentWidth + DOT_WIDTH > leftWidth) {\n if (currentWidth > leftWidth) {\n break;\n }\n }\n\n r.push(currentText);\n\n // 没有超出,则计算剩余宽度\n leftWidth -= currentWidth;\n leftText = leftText.substr(STEP);\n\n // 字符串整体没有超出\n if (!leftText) {\n return r.join('');\n }\n }\n\n // 最下的最后一个 STEP,使用 1 递增(用二分效果更高)\n while (true) {\n // 更新字符串\n currentText = leftText.substr(0, 1);\n\n // 计算宽度\n currentWidth = measureTextWidth(currentText, font);\n\n // 超出剩余宽度,则停止\n if (currentWidth + DOT_WIDTH > leftWidth) {\n break;\n }\n\n r.push(currentText);\n // 没有超出,则计算剩余宽度\n leftWidth -= currentWidth;\n leftText = leftText.substr(1);\n\n if (!leftText) {\n return r.join('');\n }\n }\n\n return `${r.join('')}...`;\n};\n","import { ext } from '@antv/matrix-util';\nimport { Coordinate, IGroup, IShape } from '../../dependents';\nimport { GAnimateCfg, Point } from '../../interface';\n\n/**\n * @ignore\n * 对图形元素进行矩阵变换,同时返回变换前的图形矩阵\n * @param shape 进行矩阵变换的图形\n * @param vector 矩阵变换的中心点\n * @param direct 矩阵变换的类型\n */\nexport function transformShape(shape: IShape | IGroup, vector: [number, number], direct: string): number[] {\n let scaledMatrix;\n\n const [x, y] = vector;\n shape.applyToMatrix([x, y, 1]);\n if (direct === 'x') {\n shape.setMatrix(\n ext.transform(shape.getMatrix(), [\n ['t', -x, -y],\n ['s', 0.01, 1],\n ['t', x, y],\n ])\n );\n scaledMatrix = ext.transform(shape.getMatrix(), [\n ['t', -x, -y],\n ['s', 100, 1],\n ['t', x, y],\n ]);\n } else if (direct === 'y') {\n shape.setMatrix(\n ext.transform(shape.getMatrix(), [\n ['t', -x, -y],\n ['s', 1, 0.01],\n ['t', x, y],\n ])\n );\n scaledMatrix = ext.transform(shape.getMatrix(), [\n ['t', -x, -y],\n ['s', 1, 100],\n ['t', x, y],\n ]);\n } else if (direct === 'xy') {\n shape.setMatrix(\n ext.transform(shape.getMatrix(), [\n ['t', -x, -y],\n ['s', 0.01, 0.01],\n ['t', x, y],\n ])\n );\n scaledMatrix = ext.transform(shape.getMatrix(), [\n ['t', -x, -y],\n ['s', 100, 100],\n ['t', x, y],\n ]);\n }\n return scaledMatrix;\n}\n\n/**\n * 对图形元素进行剪切动画\n * @param element 进行动画的图形元素\n * @param animateCfg 动画配置\n * @param coordinate 当前坐标系\n * @param yMinPoint y 轴的最小值对应的图形坐标点\n * @param type 剪切动画的类型\n */\nexport function doScaleAnimate(\n element: IGroup | IShape,\n animateCfg: GAnimateCfg,\n coordinate: Coordinate,\n yMinPoint: Point,\n type: string\n) {\n const { start, end } = coordinate;\n const width = coordinate.getWidth();\n const height = coordinate.getHeight();\n let x: number;\n let y: number;\n\n if (type === 'y') {\n x = start.x + width / 2;\n y = yMinPoint.y < start.y ? yMinPoint.y : start.y;\n } else if (type === 'x') {\n x = yMinPoint.x > start.x ? yMinPoint.x : start.x;\n y = start.y + height / 2;\n } else if (type === 'xy') {\n if (coordinate.isPolar) {\n x = coordinate.getCenter().x;\n y = coordinate.getCenter().y;\n } else {\n x = (start.x + end.x) / 2;\n y = (start.y + end.y) / 2;\n }\n }\n\n const endMatrix = transformShape(element, [x, y], type);\n element.animate(\n {\n matrix: endMatrix,\n },\n animateCfg\n );\n}\n","import { getArcParams } from '@antv/g-canvas';\nimport { isNumberEqual, isEqual, isFunction } from '@antv/util';\n\nimport { IShape, PathCommand } from '../../dependents';\nimport { GAnimateCfg } from '../../interface';\nimport { AnimateExtraCfg } from '../interface';\n\nimport { getArcPath, getSectorPath } from '../../util/graphics';\n\nfunction getAngle(startPoint: number[], arcPath: PathCommand) {\n let { startAngle, endAngle } = getArcParams(startPoint, arcPath);\n\n if (!isNumberEqual(startAngle, -Math.PI * 0.5) && startAngle < -Math.PI * 0.5) {\n startAngle += Math.PI * 2;\n }\n if (!isNumberEqual(endAngle, -Math.PI * 0.5) && endAngle < -Math.PI * 0.5) {\n endAngle += Math.PI * 2;\n }\n\n if (arcPath[5] === 0) {\n // 逆时针,需要将 startAngle 和 endAngle 转置,因为 G2 极坐标系为顺时针方向\n [startAngle, endAngle] = [endAngle, startAngle];\n }\n\n if (isNumberEqual(startAngle, Math.PI * 1.5)) {\n startAngle = Math.PI * -0.5;\n }\n\n // 当 startAngle, endAngle 接近相等时,不进行 endAngle = Math.PI * 1.5 防止变化从整个圆开始\n if (isNumberEqual(endAngle, Math.PI * -0.5) && !isNumberEqual(startAngle, endAngle)) {\n endAngle = Math.PI * 1.5;\n }\n\n return {\n startAngle,\n endAngle,\n };\n}\n\nfunction getArcStartPoint(path: PathCommand) {\n let startPoint;\n if (path[0] === 'M' || path[0] === 'L') {\n startPoint = [path[1], path[2]];\n } else if (path[0] === 'a' || path[0] === 'A' || path[0] === 'C') {\n startPoint = [path[path.length - 2], path[path.length - 1]];\n }\n\n return startPoint;\n}\n\n/**\n * path 存在以下情况\n * 1. 饼图不为整圆的 path,命令为 M, L, A, L, Z\n * 2. 饼图为整圆的 path,命令为 M, M, A, A, M, Z\n * 3. 环图不为整圆的 path,命令为 M, A, L, A, L, Z\n * 4. 环图为整圆的 path,命令为 M, A, A, M, A, A, M, Z\n * 5. radial-line, 不为整圆时的 path, 命令为 M, A, A, Z\n * 6. radial-line, 为整圆时的 path,命令为 M, A, A, A, A, Z\n * @param path theta 坐标系下圆弧的 path 命令\n */\nexport function getArcInfo(path: PathCommand[]) {\n let startAngle;\n let endAngle;\n\n const arcPaths = path.filter((command) => {\n return command[0] === 'A' || command[0] === 'a';\n });\n\n if (arcPaths.length === 0) {\n return {\n startAngle: 0,\n endAngle: 0,\n radius: 0,\n innerRadius: 0,\n };\n }\n\n const firstArcPathCommand = arcPaths[0];\n const lastArcPathCommand = arcPaths.length > 1 ? arcPaths[1] : arcPaths[0];\n const firstIndex = path.indexOf(firstArcPathCommand);\n const lastIndex = path.indexOf(lastArcPathCommand);\n const firstStartPoint = getArcStartPoint(path[firstIndex - 1]);\n const lastStartPoint = getArcStartPoint(path[lastIndex - 1]);\n\n const { startAngle: firstStartAngle, endAngle: firstEndAngle } = getAngle(firstStartPoint, firstArcPathCommand);\n const { startAngle: lastStartAngle, endAngle: lastEndAngle } = getAngle(lastStartPoint, lastArcPathCommand);\n\n if (isNumberEqual(firstStartAngle, lastStartAngle) && isNumberEqual(firstEndAngle, lastEndAngle)) {\n startAngle = firstStartAngle;\n endAngle = firstEndAngle;\n } else {\n startAngle = Math.min(firstStartAngle, lastStartAngle);\n endAngle = Math.max(firstEndAngle, lastEndAngle);\n }\n\n let radius = firstArcPathCommand[1];\n let innerRadius = arcPaths[arcPaths.length - 1][1];\n if (radius < innerRadius) {\n [radius, innerRadius] = [innerRadius, radius];\n } else if (radius === innerRadius) {\n innerRadius = 0;\n }\n\n return {\n startAngle,\n endAngle,\n radius,\n innerRadius,\n };\n}\n\n/**\n * @ignore\n * 饼图更新动画\n * @param shape 文本图形\n * @param animateCfg\n * @param cfg\n */\nexport function sectorPathUpdate(shape: IShape, animateCfg: GAnimateCfg, cfg: AnimateExtraCfg) {\n const { toAttrs, coordinate } = cfg;\n const path = (toAttrs as { path: PathCommand[] }).path || [];\n const pathCommands = path.map((command) => command[0]);\n\n if (path.length < 1) return;\n\n const { startAngle: curStartAngle, endAngle: curEndAngle, radius, innerRadius } = getArcInfo(path);\n const { startAngle: preStartAngle, endAngle: preEndAngle } = getArcInfo(shape.attr('path'));\n\n const center = coordinate.getCenter();\n const diffStartAngle = curStartAngle - preStartAngle;\n const diffEndAngle = curEndAngle - preEndAngle;\n // 没有 diff 时直接返回最终 attrs,不需要额外动画\n if (diffStartAngle === 0 && diffEndAngle === 0) {\n shape.attr(toAttrs);\n return;\n }\n\n shape.animate(\n (ratio) => {\n const onFrameStartAngle = preStartAngle + ratio * diffStartAngle;\n const onFrameEndAngle = preEndAngle + ratio * diffEndAngle;\n return {\n ...toAttrs,\n path:\n // hack, 兼容 /examples/bar/basic/demo/radial-line.ts 动画\n isEqual(pathCommands, ['M', 'A', 'A', 'Z'])\n ? getArcPath(center.x, center.y, radius, onFrameStartAngle, onFrameEndAngle)\n : getSectorPath(center.x, center.y, radius, onFrameStartAngle, onFrameEndAngle, innerRadius),\n };\n },\n {\n ...animateCfg,\n callback: () => {\n // 将 path 保持原始态,否则会影响 setState() 的动画\n shape.attr('path', path);\n isFunction(animateCfg.callback) && animateCfg.callback();\n },\n }\n );\n}\n","import { ext } from '@antv/matrix-util';\nimport { each, isFunction } from '@antv/util';\nimport { IGroup, IShape } from '../../dependents';\nimport { GAnimateCfg } from '../../interface';\nimport { AnimateExtraCfg } from '../interface';\n\nfunction doShapeZoom(shape: IShape | IGroup, animateCfg: GAnimateCfg, type: 'zoomIn' | 'zoomOut') {\n if (shape.isGroup()) {\n each((shape as IGroup).getChildren(), (child) => {\n doShapeZoom(child, animateCfg, type);\n });\n } else {\n const bbox = shape.getBBox();\n const x = (bbox.minX + bbox.maxX) / 2;\n const y = (bbox.minY + bbox.maxY) / 2;\n shape.applyToMatrix([x, y, 1]);\n\n if (type === 'zoomIn') {\n // 放大\n const matrix = ext.transform(shape.getMatrix(), [\n ['t', -x, -y],\n ['s', 0.01, 0.01],\n ['t', x, y],\n ]);\n shape.setMatrix(matrix);\n shape.animate(\n {\n matrix: ext.transform(shape.getMatrix(), [\n ['t', -x, -y],\n ['s', 100, 100],\n ['t', x, y],\n ]),\n },\n animateCfg\n );\n } else {\n shape.animate(\n {\n matrix: ext.transform(shape.getMatrix(), [\n ['t', -x, -y],\n ['s', 0.01, 0.01],\n ['t', x, y],\n ]),\n },\n {\n ...animateCfg,\n callback: () => {\n shape.remove(true);\n isFunction(animateCfg.callback) && animateCfg.callback();\n },\n }\n );\n }\n }\n}\n\n/**\n * @ignore\n * 单个 shape 动画\n * shape 以自身中心点逐渐放大的进入动画\n * @param shape 参与动画的图形元素\n * @param animateCfg 动画配置\n * @param cfg 额外信息\n */\nexport function zoomIn(shape: IShape | IGroup, animateCfg: GAnimateCfg, cfg: AnimateExtraCfg) {\n doShapeZoom(shape, animateCfg, 'zoomIn');\n}\n\n/**\n * @ignore\n * 单个 shape 动画\n * 消失动画,shape 以自身为中心点的逐渐缩小\n * @param shape 参与动画的图形元素\n * @param animateCfg 动画配置\n * @param cfg 额外信息\n */\nexport function zoomOut(shape: IShape | IGroup, animateCfg: GAnimateCfg, cfg: AnimateExtraCfg) {\n doShapeZoom(shape, animateCfg, 'zoomOut');\n}\n","import { DIRECTION } from '../constant';\nimport { Point } from '../dependents';\nimport { FacetTitle } from '../interface';\n\n/**\n * @ignore\n * 获取 facet title 的最佳默认配置,防止\n */\nexport function getFactTitleConfig(direction: DIRECTION): FacetTitle {\n if ([DIRECTION.TOP, DIRECTION.BOTTOM].includes(direction)) {\n return {\n offsetX: 0,\n offsetY: direction === DIRECTION.TOP ? -8 : 8,\n style: {\n textAlign: 'center',\n textBaseline: direction === DIRECTION.TOP ? 'bottom' : 'top',\n },\n };\n }\n\n if ([DIRECTION.LEFT, DIRECTION.RIGHT].includes(direction)) {\n return {\n offsetX: direction === DIRECTION.LEFT ? -8 : 8,\n offsetY: 0,\n style: {\n textAlign: direction === DIRECTION.LEFT ? 'right' : 'left',\n textBaseline: 'middle',\n rotate: Math.PI / 2, // 文本阅读习惯从上往下\n },\n };\n }\n\n return {};\n}\n\n/**\n * @ignore\n * 根据角度,获取 ○ 上的点\n * @param center\n * @param r\n * @param angle\n */\nexport function getAnglePoint(center: Point, r: number, angle: number): Point {\n return {\n x: center.x + r * Math.cos(angle),\n y: center.y + r * Math.sin(angle),\n };\n}\n","import { deepMix, each, filter, get } from '@antv/util';\nimport { AxisCfg, CircleCfg, CircleData, Datum } from '../interface';\n\nimport View from '../chart/view';\nimport { DIRECTION } from '../constant';\nimport { getAnglePoint, getFactTitleConfig } from '../util/facet';\nimport { Facet } from './facet';\n\n/**\n * @ignore\n * 镜像分面\n */\nexport default class Circle extends Facet {\n protected getDefaultCfg() {\n return deepMix({}, super.getDefaultCfg(), {\n type: 'circle',\n showTitle: true,\n title: super.getDefaultTitleCfg(),\n });\n }\n\n public render() {\n super.render();\n\n if (this.cfg.showTitle) {\n this.renderTitle();\n }\n }\n\n /**\n * 根据总数和当前索引,计算分面的 region\n * @param count\n * @param index\n */\n protected getRegion(count: number, index: number) {\n const r = 1 / 2; // 画布半径\n // 画布圆心\n const center = { x: 0.5, y: 0.5 };\n // 每隔分面间隔的弧度\n const avgAngle = (Math.PI * 2) / count;\n\n // 当前分面所在的弧度\n const angle = (-1 * Math.PI) / 2 + avgAngle * index;\n // TODO 没看懂\n const facetR = r / (1 + 1 / Math.sin(avgAngle / 2));\n // 分面的中心点\n const middle = getAnglePoint(center, r - facetR, angle);\n const startAngle = (Math.PI * 5) / 4; // 右上角\n const endAngle = (Math.PI * 1) / 4; // 左下角\n\n return {\n start: getAnglePoint(middle, facetR, startAngle),\n end: getAnglePoint(middle, facetR, endAngle),\n };\n }\n\n protected afterEachView(view: View, facet: CircleData) {\n this.processAxis(view, facet);\n }\n\n protected beforeEachView(view: View, facet: CircleData) {}\n\n protected generateFacets(data: Datum[]): CircleData[] {\n const { fields, type } = this.cfg;\n const [field] = fields;\n if (!field) {\n throw new Error('No `fields` specified!');\n }\n\n const values = this.getFieldValues(data, field);\n const count = values.length;\n\n const rst = [];\n values.forEach((value: any, index: number) => {\n const conditions = [{ field, value, values }];\n const facetData = filter(data, this.getFacetDataFilter(conditions));\n\n const facet: CircleData = {\n type,\n data: facetData,\n region: this.getRegion(count, index),\n\n columnValue: value,\n columnField: field,\n columnIndex: index,\n columnValuesLength: count,\n\n rowValue: null,\n rowField: null,\n rowIndex: 0,\n rowValuesLength: 1,\n };\n rst.push(facet);\n });\n return rst;\n }\n\n protected getXAxisOption(x: string, axes: any, option: AxisCfg, facet: CircleData): object {\n // 不做任何处理\n return option;\n }\n\n /**\n * 设置 y 坐标轴的文本、title 是否显示\n * @param y\n * @param axes\n * @param option\n * @param facet\n */\n protected getYAxisOption(y: string, axes: any, option: AxisCfg, facet: CircleData): object {\n // 不做任何处理\n return option;\n }\n\n /**\n * facet title\n */\n private renderTitle() {\n each(this.facets, (facet: CircleData) => {\n const { columnValue, view } = facet;\n const formatter = get(this.cfg.title, 'formatter');\n\n const config = deepMix(\n {\n position: ['50%', '0%'] as [string, string],\n content: formatter ? formatter(columnValue) : columnValue,\n },\n getFactTitleConfig(DIRECTION.TOP),\n this.cfg.title\n );\n\n view.annotation().text(config);\n });\n }\n}\n","import { deepMix, each, filter, get } from '@antv/util';\nimport { DIRECTION } from '../constant';\nimport { AxisCfg, Datum, ListCfg, ListData } from '../interface';\n\nimport View from '../chart/view';\nimport { getFactTitleConfig } from '../util/facet';\nimport { Facet } from './facet';\n\n/**\n * @ignore\n * 镜像分面\n */\nexport default class List extends Facet {\n protected getDefaultCfg() {\n return deepMix({}, super.getDefaultCfg(), {\n type: 'list',\n cols: null, // 默认显示一列\n showTitle: true,\n title: super.getDefaultTitleCfg(),\n });\n }\n\n public render() {\n super.render();\n\n if (this.cfg.showTitle) {\n this.renderTitle();\n }\n }\n\n protected afterEachView(view: View, facet: ListData) {\n this.processAxis(view, facet);\n }\n\n protected beforeEachView(view: View, facet: ListData) {}\n\n protected generateFacets(data: Datum[]): ListData[] {\n const { fields } = this.cfg;\n let { cols } = this.cfg;\n\n const [columnField] = fields;\n if (!columnField) {\n throw new Error('No `fields` specified!');\n }\n\n const colValues = this.getFieldValues(data, columnField);\n\n const count = colValues.length;\n cols = cols || count; // 每行有几列数据\n\n // 总共有几行\n const rows = this.getPageCount(count, cols);\n const rst = [];\n\n colValues.forEach((val, index) => {\n // 当前 index 在那个行列\n const { row, col } = this.getRowCol(index, cols);\n\n const conditions = [{ field: columnField, value: val, values: colValues }];\n\n const facetData = filter(data, this.getFacetDataFilter(conditions));\n\n const facet: ListData = {\n type: this.cfg.type,\n data: facetData,\n region: this.getRegion(rows, cols, col, row),\n\n columnValue: val,\n rowValue: val,\n columnField,\n rowField: null,\n columnIndex: col,\n rowIndex: row,\n columnValuesLength: cols,\n rowValuesLength: rows,\n\n total: count,\n };\n\n rst.push(facet);\n });\n\n return rst;\n }\n\n /**\n * 设置 x 坐标轴的文本、title 是否显示\n * @param x\n * @param axes\n * @param option\n * @param facet\n */\n protected getXAxisOption(x: string, axes: any, option: AxisCfg, facet: ListData): object {\n // 当是最后一行或者下面没有 view 时文本不显示\n if (\n facet.rowIndex !== facet.rowValuesLength - 1 &&\n facet.columnValuesLength * facet.rowIndex + facet.columnIndex + 1 + facet.columnValuesLength <= facet.total\n ) {\n return {\n ...option,\n label: null,\n title: null,\n };\n }\n return option;\n }\n\n /**\n * 设置 y 坐标轴的文本、title 是否显示\n * @param y\n * @param axes\n * @param option\n * @param facet\n */\n protected getYAxisOption(y: string, axes: any, option: AxisCfg, facet: ListData): object {\n if (facet.columnIndex !== 0) {\n return {\n ...option,\n title: null,\n label: null,\n };\n }\n return option;\n }\n\n /**\n * facet title\n */\n private renderTitle() {\n each(this.facets, (facet: ListData) => {\n const { columnValue, view } = facet;\n const formatter = get(this.cfg.title, 'formatter');\n\n const config = deepMix(\n {\n position: ['50%', '0%'] as [string, string],\n content: formatter ? formatter(columnValue) : columnValue,\n },\n getFactTitleConfig(DIRECTION.TOP),\n this.cfg.title\n );\n\n view.annotation().text(config);\n });\n }\n\n /**\n * 计算分页数\n * @param total\n * @param pageSize\n */\n private getPageCount(total: number, pageSize: number): number {\n return Math.floor((total + pageSize - 1) / pageSize);\n }\n\n /**\n * 索引值在哪一页\n * @param index\n * @param pageSize\n */\n private getRowCol(index: number, pageSize: number) {\n const row = Math.floor(index / pageSize);\n const col = index % pageSize;\n\n return { row, col };\n }\n}\n","import { deepMix, each, get } from '@antv/util';\nimport { DIRECTION } from '../constant';\nimport { AxisCfg, Datum, MatrixCfg, MatrixData } from '../interface';\n\nimport View from '../chart/view';\nimport { getFactTitleConfig } from '../util/facet';\nimport { Facet } from './facet';\n\n/**\n * @ignore\n * 镜像分面\n */\nexport default class Matrix extends Facet {\n protected getDefaultCfg() {\n return deepMix({}, super.getDefaultCfg(), {\n type: 'matrix',\n showTitle: false,\n columnTitle: {\n ...super.getDefaultTitleCfg(),\n },\n rowTitle: {\n ...super.getDefaultTitleCfg(),\n },\n });\n }\n\n public render() {\n super.render();\n\n if (this.cfg.showTitle) {\n this.renderTitle();\n }\n }\n\n protected afterEachView(view: View, facet: MatrixData) {\n this.processAxis(view, facet);\n }\n\n protected beforeEachView(view: View, facet: MatrixData) {}\n\n protected generateFacets(data: Datum[]): MatrixData[] {\n const { fields, type } = this.cfg;\n\n // 矩阵中行列相等,等于指定的字段个数\n const rowValuesLength = fields.length;\n const columnValuesLength = rowValuesLength;\n\n const rst = [];\n for (let i = 0; i < columnValuesLength; i++) {\n const columnField = fields[i];\n for (let j = 0; j < rowValuesLength; j++) {\n const rowField = fields[j];\n\n const facet: MatrixData = {\n type,\n data,\n region: this.getRegion(rowValuesLength, columnValuesLength, i, j),\n\n columnValue: columnField,\n rowValue: rowField,\n columnField,\n rowField,\n columnIndex: i,\n rowIndex: j,\n columnValuesLength,\n rowValuesLength,\n };\n rst.push(facet);\n }\n }\n return rst;\n }\n\n /**\n * 设置 x 坐标轴的文本、title 是否显示\n * @param x\n * @param axes\n * @param option\n * @param facet\n */\n protected getXAxisOption(x: string, axes: any, option: AxisCfg, facet: MatrixData): object {\n // 最后一行显示\n if (facet.rowIndex !== facet.rowValuesLength - 1) {\n return {\n ...option,\n label: null,\n title: null,\n };\n }\n return option;\n }\n\n /**\n * 设置 y 坐标轴的文本、title 是否显示\n * @param y\n * @param axes\n * @param option\n * @param facet\n */\n protected getYAxisOption(y: string, axes: any, option: AxisCfg, facet: MatrixData): object {\n // 第一列显示\n if (facet.columnIndex !== 0) {\n return {\n ...option,\n title: null,\n label: null,\n };\n }\n return option;\n }\n\n /**\n * facet title\n */\n private renderTitle() {\n each(this.facets, (facet: MatrixData, facetIndex: number) => {\n const { columnIndex, rowIndex, columnValuesLength, rowValuesLength, columnValue, rowValue, view } = facet;\n\n // top\n if (rowIndex === 0) {\n const formatter = get(this.cfg.columnTitle, 'formatter');\n const config = deepMix(\n {\n position: ['50%', '0%'] as [string, string],\n content: formatter ? formatter(columnValue) : columnValue,\n },\n getFactTitleConfig(DIRECTION.TOP),\n this.cfg.columnTitle\n );\n\n view.annotation().text(config);\n }\n // right\n if (columnIndex === columnValuesLength - 1) {\n const formatter = get(this.cfg.rowTitle, 'formatter');\n const config = deepMix(\n {\n position: ['100%', '50%'] as [string, string],\n content: formatter ? formatter(rowValue) : rowValue,\n },\n getFactTitleConfig(DIRECTION.RIGHT),\n this.cfg.rowTitle\n );\n\n view.annotation().text(config);\n }\n });\n }\n}\n","import { deepMix, each, filter, get } from '@antv/util';\nimport { DIRECTION } from '../constant';\nimport { AxisCfg, Datum, MirrorCfg, MirrorData } from '../interface';\n\nimport View from '../chart/view';\nimport { getFactTitleConfig } from '../util/facet';\nimport { Facet } from './facet';\n\n/**\n * @ignore\n * 镜像分面\n */\nexport default class Mirror extends Facet {\n protected getDefaultCfg() {\n return deepMix({}, super.getDefaultCfg(), {\n type: 'mirror',\n showTitle: true,\n title: super.getDefaultTitleCfg(),\n transpose: false,\n });\n }\n\n public render() {\n super.render();\n\n if (this.cfg.showTitle) {\n this.renderTitle();\n }\n }\n\n protected beforeEachView(view: View, facet: MirrorData) {\n // 做一下坐标系转化\n if (this.cfg.transpose) {\n if (facet.columnIndex % 2 === 0) {\n view.coordinate().transpose().reflect('x');\n } else {\n view.coordinate().transpose();\n }\n } else {\n if (facet.rowIndex % 2 !== 0) {\n view.coordinate().reflect('y');\n }\n }\n }\n\n protected afterEachView(view: View, facet: MirrorData) {\n this.processAxis(view, facet);\n }\n\n protected generateFacets(data: Datum[]): MirrorData[] {\n const [f] = this.cfg.fields;\n\n const rst = [];\n let columnValuesLength = 1;\n let rowValuesLength = 1;\n\n let columnValues: string[] = [''];\n let rowValues: string[] = [''];\n\n let columnField;\n let rowField;\n\n if (this.cfg.transpose) {\n columnField = f;\n columnValues = this.getFieldValues(data, columnField).slice(0, 2); // 镜像最多两个\n columnValuesLength = columnValues.length;\n } else {\n rowField = f;\n rowValues = this.getFieldValues(data, rowField).slice(0, 2); // 镜像最多两个\n rowValuesLength = rowValues.length;\n }\n\n // 获取每个维度对应的数据配置片段\n columnValues.forEach((xVal, xIndex) => {\n rowValues.forEach((yVal, yIndex) => {\n const conditions = [\n { field: columnField, value: xVal, values: columnValues },\n { field: rowField, value: yVal, values: rowValues },\n ];\n\n const facetData = filter(data, this.getFacetDataFilter(conditions));\n\n const facet: MirrorData = {\n type: this.cfg.type,\n data: facetData,\n region: this.getRegion(rowValuesLength, columnValuesLength, xIndex, yIndex),\n\n columnValue: xVal,\n rowValue: yVal,\n columnField,\n rowField,\n columnIndex: xIndex,\n rowIndex: yIndex,\n columnValuesLength,\n rowValuesLength,\n };\n rst.push(facet);\n });\n });\n\n return rst;\n }\n\n /**\n * 设置 x 坐标轴的文本、title 是否显示\n * @param x\n * @param axes\n * @param option\n * @param facet\n */\n protected getXAxisOption(x: string, axes: any, option: AxisCfg, facet: MirrorData): object {\n // 非最后一行\n // 当是最后一行或者下面没有 view 时文本不显示\n if (facet.columnIndex === 1 || facet.rowIndex === 1) {\n return {\n ...option,\n label: null,\n title: null,\n };\n }\n\n return option;\n }\n\n /**\n * 设置 y 坐标轴的文本、title 是否显示\n * @param y\n * @param axes\n * @param option\n * @param facet\n */\n protected getYAxisOption(y: string, axes: any, option: AxisCfg, facet: MirrorData): object {\n // do nothing\n return option;\n }\n\n private renderTitle() {\n each(this.facets, (facet: MirrorData, facetIndex: number) => {\n const { columnValue, rowValue, view } = facet;\n const formatter = get(this.cfg.title, 'formatter');\n\n if (this.cfg.transpose) {\n const config = deepMix(\n {\n position: ['50%', '0%'] as [string, string],\n content: formatter ? formatter(columnValue) : columnValue,\n },\n getFactTitleConfig(DIRECTION.TOP),\n this.cfg.title\n );\n\n view.annotation().text(config);\n } else {\n const config = deepMix(\n {\n position: ['100%', '50%'] as [string, string],\n content: formatter ? formatter(rowValue) : rowValue,\n },\n getFactTitleConfig(DIRECTION.RIGHT),\n this.cfg.title\n );\n\n view.annotation().text(config);\n }\n });\n }\n}\n","import { deepMix, each, filter, get } from '@antv/util';\nimport { DIRECTION } from '../constant';\nimport { AxisCfg, Datum, RectCfg, RectData } from '../interface';\n\nimport View from '../chart/view';\nimport { getFactTitleConfig } from '../util/facet';\nimport { Facet } from './facet';\n\n/**\n * @ignore\n * 矩阵分面\n */\nexport default class Rect extends Facet {\n protected afterEachView(view: View, facet: RectData) {\n this.processAxis(view, facet);\n }\n\n protected beforeEachView(view: View, facet: RectData) {\n // do nothing\n }\n\n protected getDefaultCfg() {\n return deepMix({}, super.getDefaultCfg(), {\n type: 'rect',\n columnTitle: {\n ...super.getDefaultTitleCfg(),\n },\n rowTitle: {\n ...super.getDefaultTitleCfg(),\n },\n });\n }\n\n public render() {\n super.render();\n\n if (this.cfg.showTitle) {\n this.renderTitle();\n }\n }\n\n /**\n * 生成矩阵分面的分面数据\n * @param data\n */\n protected generateFacets(data: Datum[]): RectData[] {\n const [columnField, rowField] = this.cfg.fields;\n\n const rst = [];\n let columnValuesLength = 1;\n let rowValuesLength = 1;\n\n let columnValues: string[] = [''];\n let rowValues: string[] = [''];\n\n if (columnField) {\n columnValues = this.getFieldValues(data, columnField);\n columnValuesLength = columnValues.length;\n }\n if (rowField) {\n rowValues = this.getFieldValues(data, rowField);\n rowValuesLength = rowValues.length;\n }\n\n // 获取每个维度对应的数据配置片段\n columnValues.forEach((xVal, xIndex) => {\n rowValues.forEach((yVal, yIndex) => {\n const conditions = [\n { field: columnField, value: xVal, values: columnValues },\n { field: rowField, value: yVal, values: rowValues },\n ];\n const facetData = filter(data, this.getFacetDataFilter(conditions));\n\n const facet: RectData = {\n type: this.cfg.type,\n data: facetData,\n region: this.getRegion(rowValuesLength, columnValuesLength, xIndex, yIndex),\n\n columnValue: xVal,\n rowValue: yVal,\n columnField,\n rowField,\n columnIndex: xIndex,\n rowIndex: yIndex,\n columnValuesLength,\n rowValuesLength,\n };\n rst.push(facet);\n });\n });\n\n return rst;\n }\n\n private renderTitle(): void {\n each(this.facets, (facet: RectData, facetIndex: number) => {\n const { columnIndex, rowIndex, columnValuesLength, columnValue, rowValue, view } = facet;\n\n // top\n if (rowIndex === 0) {\n const formatter = get(this.cfg.columnTitle, 'formatter');\n const config = deepMix(\n {\n position: ['50%', '0%'] as [string, string],\n content: formatter ? formatter(columnValue) : columnValue,\n },\n getFactTitleConfig(DIRECTION.TOP),\n this.cfg.columnTitle\n );\n\n view.annotation().text(config);\n }\n // right\n if (columnIndex === columnValuesLength - 1) {\n const formatter = get(this.cfg.rowTitle, 'formatter');\n const config = deepMix(\n {\n position: ['100%', '50%'] as [string, string],\n content: formatter ? formatter(rowValue) : rowValue,\n },\n getFactTitleConfig(DIRECTION.RIGHT),\n this.cfg.rowTitle\n );\n\n view.annotation().text(config);\n }\n });\n }\n\n /**\n * 设置 x 坐标轴的文本、title 是否显示\n * @param x\n * @param axes\n * @param option\n * @param facet\n */\n protected getXAxisOption(x: string, axes: any, option: AxisCfg, facet: RectData): object {\n // 非最后一行\n if (facet.rowIndex !== facet.rowValuesLength - 1) {\n return {\n ...option,\n title: null,\n label: null,\n };\n } else if (facet.columnIndex !== Math.floor((facet.columnValuesLength - 1) / 2)) {\n // 不是中间列\n return {\n ...option,\n title: null,\n };\n }\n return option;\n }\n\n /**\n * 设置 y 坐标轴的文本、title 是否显示\n * @param y\n * @param axes\n * @param option\n * @param facet\n */\n protected getYAxisOption(y: string, axes: any, option: AxisCfg, facet: RectData): object {\n if (facet.columnIndex !== 0) {\n return {\n ...option,\n title: null,\n label: null,\n };\n } else if (facet.rowIndex !== Math.floor((facet.rowValuesLength - 1) / 2)) {\n return {\n ...option,\n title: null,\n };\n }\n return option;\n }\n}\n","/**\n * Create By Bruce Too\n * On 2020-02-10\n */\nimport { assign, deepMix, each, get } from '@antv/util';\nimport View from '../chart/view';\nimport { DIRECTION, VIEW_LIFE_CIRCLE } from '../constant';\nimport { AxisCfg, Condition, Datum, TreeCfg, TreeData } from '../interface';\nimport { getFactTitleConfig } from '../util/facet';\nimport { Facet } from './facet';\n\n/**\n * @ignore\n * Tree Facet\n */\nexport default class Tree extends Facet {\n protected afterEachView(view: View, facet: TreeData) {\n this.processAxis(view, facet);\n }\n\n protected beforeEachView(view: View, facet: TreeData) {}\n\n public init() {\n super.init();\n this.view.on(VIEW_LIFE_CIRCLE.AFTER_RENDER, this.afterChartRender);\n }\n\n protected getDefaultCfg() {\n return deepMix({}, super.getDefaultCfg(), {\n type: 'tree',\n line: {\n style: {\n lineWidth: 1,\n stroke: '#ddd',\n },\n smooth: false,\n },\n showTitle: true,\n title: super.getDefaultTitleCfg(),\n });\n }\n\n protected generateFacets(data: Datum[]): TreeData[] {\n const fields = this.cfg.fields;\n if (!fields.length) {\n throw new Error('Please specify for the fields for rootFacet!');\n }\n const rst = [];\n const rootFacet: TreeData = {\n type: this.cfg.type,\n data,\n region: null,\n rowValuesLength: this.getRows(),\n columnValuesLength: 1,\n rowIndex: 0,\n columnIndex: 0,\n rowField: '',\n columnField: '',\n rowValue: '',\n columnValue: '',\n };\n rst.push(rootFacet);\n rootFacet.children = this.getChildFacets(data, 1, rst);\n this.setRegion(rst);\n return rst;\n }\n\n private setRegion(facets: TreeData[]) {\n this.forceColIndex(facets);\n facets.forEach((facet) => {\n // @ts-ignore 允许调整\n facet.region = this.getRegion(facet.rowValuesLength, facet.columnValuesLength, facet.columnIndex, facet.rowIndex);\n });\n }\n\n protected getRegion(rows: number, cols: number, xIndex: number, yIndex: number) {\n const xWidth = 1 / cols; // x轴方向的每个分面的偏移\n const yWidth = 1 / rows; // y轴方向的每个分面的偏移\n\n const start = {\n x: xWidth * xIndex,\n y: yWidth * yIndex,\n };\n\n const end = {\n x: start.x + xWidth,\n y: start.y + (yWidth * 2) / 3, // 预留1/3的空隙,方便添加连接线\n };\n return {\n start,\n end,\n };\n }\n\n private forceColIndex(facets: TreeData[]) {\n const leafs: TreeData[] = [];\n let index = 0;\n facets.forEach((facet) => {\n if (this.isLeaf(facet)) {\n leafs.push(facet);\n // @ts-ignore 允许调整\n facet.columnIndex = index;\n index++;\n }\n });\n\n leafs.forEach((facet) => {\n // @ts-ignore\n facet.columnValuesLength = leafs.length;\n });\n const maxLevel = this.cfg.fields.length;\n for (let i = maxLevel - 1; i >= 0; i--) {\n const levelFacets = this.getFacetsByLevel(facets, i);\n // var yIndex = maxLevel - i;\n for (const facet of levelFacets) {\n if (!this.isLeaf(facet)) {\n facet.originColIndex = facet.columnIndex;\n // @ts-ignore\n facet.columnIndex = this.getRegionIndex(facet.children);\n // @ts-ignore\n facet.columnValuesLength = leafs.length;\n }\n }\n }\n }\n\n // get facet use level\n private getFacetsByLevel(facets: TreeData[], level: number) {\n const rst: TreeData[] = [];\n facets.forEach((facet) => {\n if (facet.rowIndex === level) {\n rst.push(facet);\n }\n });\n return rst;\n }\n\n // if the facet has children , make it's column index in the middle of it's children\n private getRegionIndex(children: TreeData[]) {\n const first = children[0];\n const last = children[children.length - 1];\n return (last.columnIndex - first.columnIndex) / 2 + first.columnIndex;\n }\n\n // is a leaf without children\n private isLeaf(facet: TreeData) {\n return !facet.children || !facet.children.length;\n }\n\n private getRows() {\n return this.cfg.fields.length + 1;\n }\n\n // get child\n private getChildFacets(data: Datum[], level: number, arr: TreeData[]) {\n // [ 'grade', 'class' ]\n const fields = this.cfg.fields;\n const length = fields.length;\n if (length < level) {\n return;\n }\n const rst = [];\n // get fist level except root node\n const field = fields[level - 1];\n // get field value\n const values = this.getFieldValues(data, field);\n values.forEach((value, index) => {\n const conditions = [{ field, value, values } as Condition];\n const subData = data.filter(this.getFacetDataFilter(conditions));\n if (subData.length) {\n const facet: TreeData = {\n type: this.cfg.type,\n data: subData,\n region: null,\n columnValue: value,\n rowValue: '',\n columnField: field,\n rowField: '',\n columnIndex: index,\n rowValuesLength: this.getRows(),\n columnValuesLength: 1,\n rowIndex: level,\n children: this.getChildFacets(subData, level + 1, arr),\n };\n rst.push(facet);\n arr.push(facet);\n }\n });\n return rst;\n }\n\n public render() {\n super.render();\n if (this.cfg.showTitle) {\n this.renderTitle();\n }\n }\n\n private afterChartRender = () => {\n if (this.facets && this.cfg.line) {\n this.container.clear();\n this.drawLines(this.facets);\n }\n };\n\n private renderTitle() {\n each(this.facets, (facet: TreeData) => {\n const { columnValue, view } = facet;\n const formatter = get(this.cfg.title, 'formatter');\n\n const config = deepMix(\n {\n position: ['50%', '0%'] as [string, string],\n content: formatter ? formatter(columnValue) : columnValue,\n },\n getFactTitleConfig(DIRECTION.TOP),\n this.cfg.title\n );\n\n view.annotation().text(config);\n });\n }\n\n private drawLines(facets: TreeData[]) {\n facets.forEach((facet) => {\n if (!this.isLeaf(facet)) {\n const children = facet.children;\n this.addFacetLines(facet, children);\n }\n });\n }\n\n // add lines with it's children\n private addFacetLines(facet: TreeData, children: TreeData[]) {\n const view = facet.view;\n const region = view.coordinateBBox;\n // top, right, bottom, left\n const start = {\n x: region.x + region.width / 2,\n y: region.y + region.height,\n };\n\n children.forEach((subFacet) => {\n const subRegion = subFacet.view.coordinateBBox;\n const end = {\n x: subRegion.bl.x + (subRegion.tr.x - subRegion.bl.x) / 2,\n y: subRegion.tr.y,\n };\n\n const middle1 = {\n x: start.x,\n y: start.y + (end.y - start.y) / 2,\n };\n const middle2 = {\n x: end.x,\n y: middle1.y,\n };\n this.drawLine([start, middle1, middle2, end]);\n });\n }\n\n private getPath(points) {\n const path = [];\n const smooth = this.cfg.line.smooth;\n if (smooth) {\n path.push(['M', points[0].x, points[0].y]);\n path.push(['C', points[1].x, points[1].y, points[2].x, points[2].y, points[3].x, points[3].y]);\n } else {\n points.forEach((point, index) => {\n if (index === 0) {\n path.push(['M', point.x, point.y]);\n } else {\n path.push(['L', point.x, point.y]);\n }\n });\n }\n\n return path;\n }\n\n // draw line width points\n private drawLine(points) {\n const path = this.getPath(points);\n const line = this.cfg.line.style;\n this.container.addShape('path', {\n attrs: assign(\n {\n // @ts-ignore\n path,\n },\n line\n ),\n });\n }\n\n protected getXAxisOption(x: string, axes: any, option: AxisCfg, facet: TreeData): object {\n if (facet.rowIndex !== facet.rowValuesLength - 1) {\n return {\n ...option,\n title: null,\n label: null,\n };\n }\n return option;\n }\n\n protected getYAxisOption(y: string, axes: any, option: AxisCfg, facet: TreeData): object {\n if (facet.originColIndex !== 0 && facet.columnIndex !== 0) {\n return {\n ...option,\n title: null,\n label: null,\n };\n }\n return option;\n }\n}\n","import { reduce, isNumber } from '@antv/util';\n\n/**\n * 获得中位数\n * @param array\n */\nexport function getMedian(array: number[]) {\n const arr = [...array];\n // 先排序\n arr.sort((a: number, b: number) => {\n return a - b;\n });\n\n const len = arr.length;\n\n // median\n // 0\n if (len === 0) {\n return 0;\n }\n\n // 奇数\n if (len % 2 === 1) {\n return arr[(len - 1) / 2];\n }\n\n // 偶数\n return (arr[len / 2] + arr[len / 2 - 1]) / 2;\n}\n\n/**\n * 获得平均值\n * @param array\n */\nexport function getMean(array: number[]) {\n const sum = reduce(\n array,\n (r: number, num: number) => {\n return (r += isNaN(num) || !isNumber(num) ? 0 : num);\n },\n 0\n );\n\n return array.length === 0 ? 0 : sum / array.length;\n}\n","import { getMedian, getMean } from './stat';\nimport { Scale } from '../dependents';\n\n/**\n * parse the value position\n * @param val\n * @param scale\n */\nexport function getNormalizedValue(val: number | string, scale: Scale) {\n if (!scale) {\n return null;\n }\n let scaled: number;\n\n switch (val) {\n case 'start':\n return 0;\n case 'center':\n return 0.5;\n case 'end':\n return 1;\n case 'median': {\n scaled = scale.isCategory ? getMedian(scale.values.map((_, idx: number) => idx)) : getMedian(scale.values);\n break;\n }\n case 'mean': {\n scaled = scale.isCategory ? (scale.values.length - 1) / 2 : getMean(scale.values);\n break;\n }\n case 'min':\n scaled = scale.isCategory ? 0 : scale[val];\n break;\n case 'max':\n scaled = scale.isCategory ? scale.values.length - 1 : scale[val];\n break;\n default:\n scaled = val as number;\n break;\n }\n\n return scale.scale(scaled);\n}\n","import {\n contains,\n deepMix,\n each,\n get,\n isArray,\n isFunction,\n isNil,\n isString,\n keys,\n upperFirst,\n find,\n includes,\n} from '@antv/util';\nimport { Annotation as AnnotationComponent, IElement, IGroup } from '../../dependents';\nimport {\n AnnotationBaseOption as BaseOption,\n AnnotationPosition as Position,\n ArcOption,\n ComponentOption,\n ShapeAnnotationOption,\n Data,\n DataMarkerOption,\n DataRegionOption,\n Datum,\n HtmlAnnotationOption,\n ImageOption,\n LineOption,\n Point,\n RegionFilterOption,\n RegionOption,\n RegionPositionBaseOption,\n TextOption,\n} from '../../interface';\n\nimport { DEFAULT_ANIMATE_CFG } from '../../animate/';\nimport { COMPONENT_TYPE, DIRECTION, GEOMETRY_LIFE_CIRCLE, LAYER, VIEW_LIFE_CIRCLE } from '../../constant';\n\nimport Geometry from '../../geometry/base';\nimport Element from '../../geometry/element';\nimport { getAngleByPoint, getDistanceToCenter } from '../../util/coordinate';\nimport { omit } from '../../util/helper';\nimport { getNormalizedValue } from '../../util/annotation';\nimport View from '../view';\nimport { Controller } from './base';\nimport { Scale } from '@antv/attr';\n\n/** 需要在图形绘制完成后才渲染的辅助组件类型列表 */\nconst ANNOTATIONS_AFTER_RENDER = ['regionFilter', 'shape'];\n\n/**\n * Annotation controller, 主要作用:\n * 1. 创建 Annotation: line、text、arc ...\n * 2. 生命周期: init、layout、render、clear、destroy\n */\nexport default class Annotation extends Controller {\n private foregroundContainer: IGroup;\n private backgroundContainer: IGroup;\n\n /* 组件更新的 cache,组件配置 object : 组件 */\n private cache = new Map();\n\n constructor(view: View) {\n super(view);\n\n this.foregroundContainer = this.view.getLayer(LAYER.FORE).addGroup();\n this.backgroundContainer = this.view.getLayer(LAYER.BG).addGroup();\n\n this.option = [];\n }\n\n public get name(): string {\n return 'annotation';\n }\n\n public init() { }\n\n /**\n * 因为 annotation 需要依赖坐标系信息,所以 render 阶段为空方法,实际的创建逻辑都在 layout 中\n */\n public layout() {\n this.update();\n }\n\n // 因为 Annotation 不参与布局,但是渲染的位置依赖于坐标系,所以可以将绘制阶段延迟到 layout() 进行\n public render() { }\n\n /**\n * 更新\n */\n public update() {\n // 1. 先处理需要在图形渲染之后的辅助组件 需要在 Geometry 完成之后,拿到图形信息\n this.onAfterRender(() => {\n const updated = new Map();\n // 先看是否有 regionFilter/shape 要更新\n each(this.option, (option: BaseOption) => {\n if (includes(ANNOTATIONS_AFTER_RENDER, option.type)) {\n const co = this.updateOrCreate(option);\n // 存储已经处理过的\n if (co) {\n updated.set(this.getCacheKey(option), co);\n }\n }\n });\n\n // 处理完成之后,更新 cache\n // 处理完成之后,销毁删除的\n this.cache = this.syncCache(updated);\n });\n\n // 2. 处理非 regionFilter\n const updateCache = new Map();\n each(this.option, (option: BaseOption) => {\n if (!includes(ANNOTATIONS_AFTER_RENDER, option.type)) {\n const co = this.updateOrCreate(option);\n // 存储已经处理过的\n if (co) {\n updateCache.set(this.getCacheKey(option), co);\n }\n }\n });\n this.cache = this.syncCache(updateCache);\n }\n\n /**\n * 清空\n * @param includeOption 是否清空 option 配置项\n */\n public clear(includeOption = false) {\n super.clear();\n\n this.clearComponents();\n this.foregroundContainer.clear();\n this.backgroundContainer.clear();\n\n // clear all option\n if (includeOption) {\n this.option = [];\n }\n }\n\n public destroy() {\n this.clear(true);\n\n this.foregroundContainer.remove(true);\n this.backgroundContainer.remove(true);\n }\n\n /**\n * 复写基类的方法\n */\n public getComponents(): ComponentOption[] {\n const co = [];\n\n this.cache.forEach((value: ComponentOption) => {\n co.push(value);\n });\n\n return co;\n }\n\n /**\n * 清除当前的组件\n */\n private clearComponents() {\n this.getComponents().forEach((co) => {\n co.component.destroy();\n });\n\n this.cache.clear();\n }\n\n /**\n * region filter 比较特殊的渲染时机\n * @param doWhat\n */\n private onAfterRender(doWhat: () => void) {\n let done = false;\n if (this.view.getOptions().animate) {\n this.view.geometries.forEach((g: Geometry) => {\n // 如果 geometry 开启,则监听\n if (g.animateOption) {\n g.once(GEOMETRY_LIFE_CIRCLE.AFTER_DRAW_ANIMATE, () => {\n doWhat();\n });\n done = true;\n }\n });\n }\n\n if (!done) {\n this.view.getRootView().once(VIEW_LIFE_CIRCLE.AFTER_RENDER, () => {\n doWhat();\n });\n }\n }\n\n private createAnnotation(option: BaseOption) {\n const { type } = option;\n\n const Ctor = AnnotationComponent[upperFirst(type)];\n if (Ctor) {\n const theme = this.getAnnotationTheme(type);\n const cfg = this.getAnnotationCfg(type, option, theme);\n // 不创建\n if (!cfg) {\n return null;\n }\n const annotation = new Ctor(cfg);\n\n return {\n component: annotation,\n layer: this.isTop(cfg) ? LAYER.FORE : LAYER.BG,\n direction: DIRECTION.NONE,\n type: COMPONENT_TYPE.ANNOTATION,\n extra: option,\n };\n }\n }\n\n // APIs for creating annotation component\n public annotation(option: any) {\n this.option.push(option);\n }\n\n /**\n * 创建 Arc\n * @param option\n * @returns AnnotationController\n */\n public arc(option: ArcOption) {\n this.annotation({\n type: 'arc',\n ...option,\n });\n\n return this;\n }\n\n /**\n * 创建 image\n * @param option\n * @returns AnnotationController\n */\n public image(option: ImageOption) {\n this.annotation({\n type: 'image',\n ...option,\n });\n\n return this;\n }\n\n /**\n * 创建 Line\n * @param option\n * @returns AnnotationController\n */\n public line(option: LineOption) {\n this.annotation({\n type: 'line',\n ...option,\n });\n\n return this;\n }\n\n /**\n * 创建 Region\n * @param option\n * @returns AnnotationController\n */\n public region(option: RegionOption) {\n this.annotation({\n type: 'region',\n ...option,\n });\n\n return this;\n }\n\n /**\n * 创建 Text\n * @param option\n * @returns AnnotationController\n */\n public text(option: TextOption) {\n this.annotation({\n type: 'text',\n ...option,\n });\n\n return this;\n }\n\n /**\n * 创建 DataMarker\n * @param option\n * @returns AnnotationController\n */\n public dataMarker(option: DataMarkerOption) {\n this.annotation({\n type: 'dataMarker',\n ...option,\n });\n\n return this;\n }\n\n /**\n * 创建 DataRegion\n * @param option\n * @returns AnnotationController\n */\n public dataRegion(option: DataRegionOption) {\n this.annotation({\n type: 'dataRegion',\n ...option,\n });\n }\n\n /**\n * 创建 RegionFilter\n * @param option\n * @returns AnnotationController\n */\n public regionFilter(option: RegionFilterOption) {\n this.annotation({\n type: 'regionFilter',\n ...option,\n });\n }\n\n /**\n * 创建 ShapeAnnotation\n * @param option\n */\n public shape(option: ShapeAnnotationOption) {\n this.annotation({\n type: 'shape',\n ...option,\n });\n }\n\n /**\n * 创建 HtmlAnnotation\n * @param option\n */\n public html(option: HtmlAnnotationOption) {\n this.annotation({\n type: 'html',\n ...option,\n });\n }\n // end API\n\n /**\n * parse the point position to [x, y]\n * @param p Position\n * @returns { x, y }\n */\n private parsePosition(\n p:\n | [string | number, string | number]\n | Datum\n | ((xScale: Scale, yScale: Scale) => [string | number, string | number] | number | Datum)\n ): Point {\n const xScale = this.view.getXScale();\n // 转成 object\n const yScales = this.view.getScalesByDim('y');\n\n const position: Position = isFunction(p) ? p.call(null, xScale, yScales) : p;\n\n let x = 0;\n let y = 0;\n\n // 入参是 [24, 24] 这类时\n if (isArray(position)) {\n const [xPos, yPos] = position;\n // 如果数据格式是 ['50%', '50%'] 的格式\n // fix: 原始数据中可能会包含 'xxx5%xxx' 这样的数据,需要判断下 https://github.com/antvis/f2/issues/590\n // @ts-ignore\n if (isString(xPos) && xPos.indexOf('%') !== -1 && !isNaN(xPos.slice(0, -1))) {\n return this.parsePercentPosition(position as [string, string]);\n }\n\n x = getNormalizedValue(xPos, xScale);\n y = getNormalizedValue(yPos, Object.values(yScales)[0]);\n } else if (!isNil(position)) {\n // 入参是 object 结构,数据点\n for (const key of keys(position)) {\n const value = position[key];\n if (key === xScale.field) {\n x = getNormalizedValue(value, xScale);\n }\n if (yScales[key]) {\n y = getNormalizedValue(value, yScales[key]);\n }\n }\n }\n\n if (isNaN(x) || isNaN(y)) {\n return null;\n }\n\n return this.view.getCoordinate().convert({ x, y });\n }\n\n /**\n * parse all the points between start and end\n * @param start\n * @param end\n * @return Point[]\n */\n private getRegionPoints(start: Position | Data, end: Position | Data): Point[] {\n const xScale = this.view.getXScale();\n const yScales = this.view.getScalesByDim('y');\n const yScale = Object.values(yScales)[0];\n const xField = xScale.field;\n const viewData = this.view.getData();\n const startXValue = isArray(start) ? start[0] : start[xField];\n const endXValue = isArray(end) ? end[0] : end[xField];\n const arr = [];\n\n let startIndex;\n each(viewData, (item, idx) => {\n if (item[xField] === startXValue) {\n startIndex = idx;\n }\n if (idx >= startIndex) {\n const point = this.parsePosition([item[xField], item[yScale.field]]);\n if (point) {\n arr.push(point);\n }\n }\n if (item[xField] === endXValue) {\n return false;\n }\n });\n\n return arr;\n }\n\n /**\n * parse percent position\n * @param position\n */\n private parsePercentPosition(position: [string, string]): Point {\n const xPercent = parseFloat(position[0]) / 100;\n const yPercent = parseFloat(position[1]) / 100;\n const coordinate = this.view.getCoordinate();\n const { start, end } = coordinate;\n\n const topLeft = {\n x: Math.min(start.x, end.x),\n y: Math.min(start.y, end.y),\n };\n const x = coordinate.getWidth() * xPercent + topLeft.x;\n const y = coordinate.getHeight() * yPercent + topLeft.y;\n return { x, y };\n }\n\n /**\n * get coordinate bbox\n */\n private getCoordinateBBox() {\n const coordinate = this.view.getCoordinate();\n const { start, end } = coordinate;\n\n const width = coordinate.getWidth();\n const height = coordinate.getHeight();\n const topLeft = {\n x: Math.min(start.x, end.x),\n y: Math.min(start.y, end.y),\n };\n\n return {\n x: topLeft.x,\n y: topLeft.y,\n minX: topLeft.x,\n minY: topLeft.y,\n maxX: topLeft.x + width,\n maxY: topLeft.y + height,\n width,\n height,\n };\n }\n\n /**\n * get annotation component config by different type\n * @param type\n * @param option 用户的配置\n * @param theme\n */\n private getAnnotationCfg(type: string, option: any, theme: object): object | null {\n const coordinate = this.view.getCoordinate();\n const canvas = this.view.getCanvas();\n let o = {};\n\n if (isNil(option)) {\n return null;\n }\n const { start, end, position } = option;\n const sp = this.parsePosition(start);\n const ep = this.parsePosition(end);\n const textPoint = this.parsePosition(position);\n if (['arc', 'image', 'line', 'region', 'regionFilter'].includes(type) && (!sp || !ep)) {\n return null;\n } else if (['text', 'dataMarker', 'html'].includes(type) && !textPoint) {\n return null;\n }\n\n if (type === 'arc') {\n const { start, end, ...rest } = option as ArcOption;\n const startAngle = getAngleByPoint(coordinate, sp);\n let endAngle = getAngleByPoint(coordinate, ep);\n if (startAngle > endAngle) {\n endAngle = Math.PI * 2 + endAngle;\n }\n\n o = {\n ...rest,\n center: coordinate.getCenter(),\n radius: getDistanceToCenter(coordinate, sp),\n startAngle,\n endAngle,\n };\n } else if (type === 'image') {\n const { start, end, ...rest } = option as ImageOption;\n o = {\n ...rest,\n start: sp,\n end: ep,\n src: option.src,\n };\n } else if (type === 'line') {\n const { start, end, ...rest } = option as LineOption;\n o = {\n ...rest,\n start: sp,\n end: ep,\n text: get(option, 'text', null),\n };\n } else if (type === 'region') {\n const { start, end, ...rest } = option as RegionPositionBaseOption;\n o = {\n ...rest,\n start: sp,\n end: ep,\n };\n } else if (type === 'text') {\n const filteredData = this.view.getData();\n const { position, content, ...rest } = option as TextOption;\n let textContent = content;\n if (isFunction(content)) {\n textContent = content(filteredData);\n }\n o = {\n ...textPoint,\n ...rest,\n content: textContent,\n };\n } else if (type === 'dataMarker') {\n const { position, point, line, text, autoAdjust, direction, ...rest } = option as DataMarkerOption;\n o = {\n ...rest,\n ...textPoint,\n coordinateBBox: this.getCoordinateBBox(),\n point,\n line,\n text,\n autoAdjust,\n direction,\n };\n } else if (type === 'dataRegion') {\n const { start, end, region, text, lineLength, ...rest } = option as DataRegionOption;\n o = {\n ...rest,\n points: this.getRegionPoints(start, end),\n region,\n text,\n lineLength,\n };\n } else if (type === 'regionFilter') {\n const { start, end, apply, color, ...rest } = option as RegionFilterOption;\n const geometries: Geometry[] = this.view.geometries;\n const shapes = [];\n const addShapes = (item?: IElement) => {\n if (!item) {\n return;\n }\n if (item.isGroup()) {\n (item as IGroup).getChildren().forEach((child) => addShapes(child));\n } else {\n shapes.push(item);\n }\n };\n each(geometries, (geom: Geometry) => {\n if (apply) {\n if (contains(apply, geom.type)) {\n each(geom.elements, (elem: Element) => {\n addShapes(elem.shape);\n });\n }\n } else {\n each(geom.elements, (elem: Element) => {\n addShapes(elem.shape);\n });\n }\n });\n o = {\n ...rest,\n color,\n shapes,\n start: sp,\n end: ep,\n };\n } else if (type === 'shape') {\n const { render, ...restOptions } = option as ShapeAnnotationOption;\n const wrappedRender = (container: IGroup) => {\n if (isFunction(option.render)) {\n return render(container, this.view, { parsePosition: this.parsePosition.bind(this) });\n }\n };\n o = {\n ...restOptions,\n render: wrappedRender,\n };\n } else if (type === 'html') {\n const { html, position, ...restOptions } = option as HtmlAnnotationOption;\n const wrappedHtml = (container: HTMLElement) => {\n if (isFunction(html)) {\n return html(container, this.view);\n }\n return html;\n };\n o = {\n ...restOptions,\n ...textPoint,\n // html 组件需要指定 parent\n parent: canvas.get('el').parentNode,\n html: wrappedHtml,\n };\n }\n // 合并主题,用户配置优先级高于默认主题\n const cfg = deepMix({}, theme, {\n ...o,\n top: option.top,\n style: option.style,\n offsetX: option.offsetX,\n offsetY: option.offsetY,\n });\n if (type !== 'html') {\n // html 类型不使用 G container\n cfg.container = this.getComponentContainer(cfg);\n }\n cfg.animate = this.view.getOptions().animate && cfg.animate && get(option, 'animate', cfg.animate); // 如果 view 关闭动画,则不执行\n cfg.animateOption = deepMix({}, DEFAULT_ANIMATE_CFG, cfg.animateOption, option.animateOption);\n\n return cfg;\n }\n\n /**\n * is annotation render on top\n * @param option\n * @return whethe on top\n */\n private isTop(option: any): boolean {\n return get(option, 'top', true);\n }\n\n /**\n * get the container by option.top\n * default is on top\n * @param option\n * @returns the container\n */\n private getComponentContainer(option: any) {\n return this.isTop(option) ? this.foregroundContainer : this.backgroundContainer;\n }\n\n private getAnnotationTheme(type: string) {\n return get(this.view.getTheme(), ['components', 'annotation', type], {});\n }\n\n /**\n * 创建或者更新 annotation\n * @param option\n */\n private updateOrCreate(option: BaseOption) {\n // 拿到缓存的内容\n let co = this.cache.get(this.getCacheKey(option));\n\n // 存在则更新,不存在在创建\n if (co) {\n const { type } = option;\n const theme = this.getAnnotationTheme(type);\n const cfg = this.getAnnotationCfg(type, option, theme);\n\n // 忽略掉一些配置\n if (cfg) {\n omit(cfg, ['container']);\n }\n co.component.update({ ...(cfg || {}), visible: !!cfg });\n // 对于 regionFilter/shape,因为生命周期的原因,需要额外 render\n if (includes(ANNOTATIONS_AFTER_RENDER, option.type)) {\n co.component.render();\n }\n } else {\n // 不存在,创建\n co = this.createAnnotation(option);\n if (co) {\n co.component.init();\n // Note:regionFilter/shape 特殊处理,regionFilter/shape 需要取到 Geometry 中的 Shape,需要在 view render 之后处理\n // 其他组件使用外层的统一 render 逻辑\n if (includes(ANNOTATIONS_AFTER_RENDER, option.type)) {\n co.component.render();\n }\n }\n }\n return co;\n }\n\n /**\n * 更新缓存,以及销毁组件\n * @param updated 更新或者创建的组件\n */\n private syncCache(updated: Map) {\n const newCache = new Map(this.cache); // clone 一份\n\n // 将 update 更新到 cache\n updated.forEach((co: ComponentOption, key: BaseOption) => {\n newCache.set(key, co);\n });\n\n // 另外和 options 进行对比,删除\n newCache.forEach((co: ComponentOption, key: BaseOption) => {\n // option 中已经找不到,那么就是删除的\n if (\n !find(this.option, (option: BaseOption) => {\n return key === this.getCacheKey(option);\n })\n ) {\n co.component.destroy();\n newCache.delete(key);\n }\n });\n\n return newCache;\n }\n\n /**\n * 获得缓存组件的 key\n * @param option\n */\n private getCacheKey(option: BaseOption) {\n // 如果存在 id,则使用 id string,否则直接使用 option 引用作为 key\n return option;\n // 后续扩展 id 用\n // const id = get(option, 'id');\n // return id ? id : option;\n }\n}\n","import { deepMix, get, map } from '@antv/util';\nimport { DIRECTION } from '../constant';\nimport { Coordinate, Scale, Tick } from '../dependents';\n\n/**\n * @ignore\n * get the grid theme by type, will mix the common cfg of axis\n * @param theme\n * @param direction\n * @returns theme object\n */\nexport function getGridThemeCfg(theme: object, direction: DIRECTION | 'common'): object {\n const axisTheme = deepMix(\n {},\n get(theme, ['components', 'axis', 'common']),\n get(theme, ['components', 'axis', direction])\n );\n return get(axisTheme, ['grid'], {});\n}\n\n/**\n * @ignore\n * get axis grid items\n * @param coordinate\n * @param scale\n * @param dim\n * @return items\n */\nexport function getLineGridItems(coordinate: Coordinate, scale: Scale, dim: string, alignTick?: boolean) {\n const items = [];\n const ticks = scale.getTicks();\n if (coordinate.isPolar) {\n // 补全 ticks\n ticks.push({\n value: 1,\n text: '',\n tickValue: '',\n });\n }\n ticks.reduce((preTick: Tick, currentTick: Tick, currentIndex) => {\n const currentValue = currentTick.value;\n if (alignTick) {\n items.push({\n points: [\n coordinate.convert(dim === 'y' ? { x: 0, y: currentValue } : { x: currentValue, y: 0 }),\n coordinate.convert(dim === 'y' ? { x: 1, y: currentValue } : { x: currentValue, y: 1 }),\n ],\n });\n } else {\n if (currentIndex) {\n const preValue = preTick.value;\n const middleValue = (preValue + currentValue) / 2;\n items.push({\n points: [\n coordinate.convert(dim === 'y' ? { x: 0, y: middleValue } : { x: middleValue, y: 0 }),\n coordinate.convert(dim === 'y' ? { x: 1, y: middleValue } : { x: middleValue, y: 1 }),\n ],\n });\n }\n }\n return currentTick;\n }, ticks[0]);\n return items;\n}\n\n/**\n * @ignore\n * get\n * @param coordinate\n * @param xScale\n * @param yScale\n * @param dim\n * @returns items\n */\nexport function getCircleGridItems(\n coordinate: Coordinate,\n xScale: Scale,\n yScale: Scale,\n alignTick: boolean,\n dim: string\n) {\n const count = xScale.values.length;\n const items = [];\n const ticks = yScale.getTicks();\n\n ticks.reduce((preTick: Tick, currentTick: Tick) => {\n const preValue = preTick ? preTick.value : currentTick.value; // 只有一项数据时取当前值\n const currentValue = currentTick.value;\n const middleValue = (preValue + currentValue) / 2;\n if (dim === 'x') {\n // 如果是 x 轴作为半径轴,那么只需要取圆弧收尾两个即可\n items.push({\n points: [\n coordinate.convert({\n x: alignTick ? currentValue : middleValue,\n y: 0,\n }),\n coordinate.convert({\n x: alignTick ? currentValue : middleValue,\n y: 1,\n }),\n ],\n });\n } else {\n items.push({\n points: map(Array(count + 1), (__: any, idx: number) => {\n return coordinate.convert({\n x: idx / count,\n y: alignTick ? currentValue : middleValue,\n });\n }),\n });\n }\n\n return currentTick;\n }, ticks[0]);\n return items;\n}\n\n/**\n * @ignore\n * show grid or not\n * @param axisTheme\n * @param axisOption\n */\nexport function showGrid(axisTheme: any, axisOption: any): boolean {\n const userGrid = get(axisOption, 'grid');\n if (userGrid === null) {\n return false;\n }\n\n const themeGrid = get(axisTheme, 'grid');\n\n return !(userGrid === undefined && themeGrid === null);\n}\n","import { deepMix, each, get, isUndefined } from '@antv/util';\nimport { DIRECTION, COMPONENT_TYPE, LAYER } from '../../constant';\nimport { CircleAxis, CircleGrid, IGroup, LineAxis, LineGrid, Scale } from '../../dependents';\nimport { AxisCfg, AxisOption, ComponentOption } from '../../interface';\n\nimport { DEFAULT_ANIMATE_CFG } from '../../animate/';\n\nimport {\n getAxisDirection,\n getAxisFactorByRegion,\n getAxisRegion,\n getAxisThemeCfg,\n getAxisTitleOptions,\n getAxisTitleText,\n getCircleAxisCenterRadius,\n isVertical,\n} from '../../util/axis';\nimport { getAxisOption } from '../../util/axis';\nimport { getCircleGridItems, getGridThemeCfg, getLineGridItems, showGrid } from '../../util/grid';\nimport { omit } from '../../util/helper';\nimport View from '../view';\nimport { Controller } from './base';\n\ntype Option = Record | boolean;\n\ntype Cache = Map;\n\n// update 组件的时候,忽略的数据更新\nconst OMIT_CFG = ['container'];\n\n// 坐标轴默认动画配置\nconst AXIS_DEFAULT_ANIMATE_CFG = {\n ...DEFAULT_ANIMATE_CFG,\n appear: null,\n};\n\n/**\n * @ignore\n * G2 Axis controller, will:\n * - create component\n * - axis\n * - grid\n * - life circle\n */\nexport default class Axis extends Controller