@ubnt/store.core 9.6.0-alpha.13 → 9.6.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/CHANGELOG.md +1 -41
  2. package/lib/assets/close2.svg +2 -3
  3. package/lib/assets/close3.svg +3 -2
  4. package/lib/assets/pause.svg +3 -3
  5. package/lib/assets/pause2.svg +3 -3
  6. package/lib/assets/ucCast.jpg +0 -0
  7. package/lib/assets/ucCastPro.jpg +0 -0
  8. package/lib/components/FeaturesSection_deprecated/FeaturesSection.js +1 -1
  9. package/lib/components/FeaturesSection_deprecated/FeaturesSection.mjs +1 -1
  10. package/lib/components/FeaturesSection_deprecated/assets/close.svg.js +1 -1
  11. package/lib/components/FeaturesSection_deprecated/assets/close.svg.mjs +2 -2
  12. package/lib/components/Header/ProHeader/ProHeader.js +8 -6
  13. package/lib/components/Header/ProHeader/ProHeader.js.map +1 -1
  14. package/lib/components/Header/ProHeader/ProHeader.mjs +9 -7
  15. package/lib/components/Header/ProHeader/ProHeader.mjs.map +1 -1
  16. package/lib/components/Header/ProHeader/ProHeader.styles.d.ts +32 -0
  17. package/lib/components/Header/ProHeader/ProHeader.styles.js +32 -0
  18. package/lib/components/Header/ProHeader/ProHeader.styles.js.map +1 -1
  19. package/lib/components/Header/ProHeader/ProHeader.styles.mjs +31 -2
  20. package/lib/components/Header/ProHeader/ProHeader.styles.mjs.map +1 -1
  21. package/lib/components/MicrositeVideoSlideshow/MicrositeVideoSlideshow.js +1 -1
  22. package/lib/components/MicrositeVideoSlideshow/MicrositeVideoSlideshow.mjs +1 -1
  23. package/lib/components/MicrositeVideoSlideshow/assets/pause.svg.js +1 -1
  24. package/lib/components/MicrositeVideoSlideshow/assets/pause.svg.mjs +2 -2
  25. package/lib/components/ModelCompareV3/ModelCompareV3.types.d.ts +1 -3
  26. package/lib/components/ModelCompareV3/data/{ProfessionalAV.d.ts → DisplayCast.d.ts} +1 -1
  27. package/lib/components/ModelCompareV3/data/DisplayCast.js +23 -0
  28. package/lib/components/ModelCompareV3/data/DisplayCast.js.map +1 -0
  29. package/lib/components/ModelCompareV3/data/{ProfessionalAV.mjs → DisplayCast.mjs} +7 -10
  30. package/lib/components/ModelCompareV3/data/DisplayCast.mjs.map +1 -0
  31. package/lib/components/ModelCompareV3/data/index.d.ts +1 -1
  32. package/lib/components/ModelCompareV3/data/index.js +3 -3
  33. package/lib/components/ModelCompareV3/data/index.js.map +1 -1
  34. package/lib/components/ModelCompareV3/data/index.mjs +3 -3
  35. package/lib/components/ModelCompareV3/data/index.mjs.map +1 -1
  36. package/lib/components/ModelCompareV3/data/products/ucCast.js +3 -17
  37. package/lib/components/ModelCompareV3/data/products/ucCast.js.map +1 -1
  38. package/lib/components/ModelCompareV3/data/products/ucCast.mjs +4 -18
  39. package/lib/components/ModelCompareV3/data/products/ucCast.mjs.map +1 -1
  40. package/lib/components/ModelCompareV3/data/products/ucCastPro.js +3 -18
  41. package/lib/components/ModelCompareV3/data/products/ucCastPro.js.map +1 -1
  42. package/lib/components/ModelCompareV3/data/products/ucCastPro.mjs +4 -19
  43. package/lib/components/ModelCompareV3/data/products/ucCastPro.mjs.map +1 -1
  44. package/lib/components/ModelCompareV3/data/properties/index.d.ts +0 -1
  45. package/lib/components/ModelCompareV3/data/properties/index.js +0 -2
  46. package/lib/components/ModelCompareV3/data/properties/index.js.map +1 -1
  47. package/lib/components/ModelCompareV3/data/properties/index.mjs +0 -1
  48. package/lib/components/ModelCompareV3/data/properties/index.mjs.map +1 -1
  49. package/lib/components/ModelCompareV3/translations/en.json.js +27 -37
  50. package/lib/components/ModelCompareV3/translations/en.json.js.map +1 -1
  51. package/lib/components/ModelCompareV3/translations/en.json.mjs +27 -37
  52. package/lib/components/ModelCompareV3/translations/en.json.mjs.map +1 -1
  53. package/lib/components/ModelCompareV3/translations/useModelCompareTranslation.d.ts +2 -2
  54. package/lib/components/ScrollWrapper/ScrollWrapper.js +7 -6
  55. package/lib/components/ScrollWrapper/ScrollWrapper.js.map +1 -1
  56. package/lib/components/ScrollWrapper/ScrollWrapper.mjs +7 -6
  57. package/lib/components/ScrollWrapper/ScrollWrapper.mjs.map +1 -1
  58. package/lib/components/VideoPlayerNew/VideoPlayer.js +2 -2
  59. package/lib/components/VideoPlayerNew/VideoPlayer.mjs +2 -2
  60. package/lib/components/VideoPlayerNew/assets/close.svg.js +1 -1
  61. package/lib/components/VideoPlayerNew/assets/close.svg.mjs +2 -2
  62. package/lib/components/VideoPlayerNew/assets/pause.svg.js +1 -1
  63. package/lib/components/VideoPlayerNew/assets/pause.svg.mjs +2 -2
  64. package/lib/contexts/MenuContext/mapping.js +2 -17
  65. package/lib/contexts/MenuContext/mapping.js.map +1 -1
  66. package/lib/contexts/MenuContext/mapping.mjs +2 -17
  67. package/lib/contexts/MenuContext/mapping.mjs.map +1 -1
  68. package/lib/utils/money/allocators/index.d.ts +0 -1
  69. package/lib/utils/money/allocators/index.js +0 -2
  70. package/lib/utils/money/allocators/index.js.map +1 -1
  71. package/lib/utils/money/allocators/index.mjs +0 -1
  72. package/lib/utils/money/allocators/index.mjs.map +1 -1
  73. package/lib/utils/money/exchangeRate.d.ts +1 -1
  74. package/lib/utils/money/exchangeRate.js.map +1 -1
  75. package/lib/utils/money/exchangeRate.mjs.map +1 -1
  76. package/lib/utils/money/types.d.ts +5 -19
  77. package/package.json +1 -1
  78. package/lib/assets/android.svg +0 -3
  79. package/lib/assets/connectDisplay.jpg +0 -0
  80. package/lib/components/ModelCompareV3/assets/ProfessionalAV/connectDisplay.jpg.js +0 -27
  81. package/lib/components/ModelCompareV3/assets/ProfessionalAV/connectDisplay.jpg.js.map +0 -1
  82. package/lib/components/ModelCompareV3/assets/ProfessionalAV/connectDisplay.jpg.mjs +0 -3
  83. package/lib/components/ModelCompareV3/assets/ProfessionalAV/connectDisplay.jpg.mjs.map +0 -1
  84. package/lib/components/ModelCompareV3/assets/android.svg.js +0 -27
  85. package/lib/components/ModelCompareV3/assets/android.svg.js.map +0 -1
  86. package/lib/components/ModelCompareV3/assets/android.svg.mjs +0 -3
  87. package/lib/components/ModelCompareV3/assets/android.svg.mjs.map +0 -1
  88. package/lib/components/ModelCompareV3/data/ProfessionalAV.js +0 -26
  89. package/lib/components/ModelCompareV3/data/ProfessionalAV.js.map +0 -1
  90. package/lib/components/ModelCompareV3/data/ProfessionalAV.mjs.map +0 -1
  91. package/lib/components/ModelCompareV3/data/products/connectDisplay.d.ts +0 -2
  92. package/lib/components/ModelCompareV3/data/products/connectDisplay.js +0 -105
  93. package/lib/components/ModelCompareV3/data/products/connectDisplay.js.map +0 -1
  94. package/lib/components/ModelCompareV3/data/products/connectDisplay.mjs +0 -97
  95. package/lib/components/ModelCompareV3/data/products/connectDisplay.mjs.map +0 -1
  96. package/lib/components/ModelCompareV3/data/properties/androidAppMode.d.ts +0 -2
  97. package/lib/components/ModelCompareV3/data/properties/androidAppMode.js +0 -19
  98. package/lib/components/ModelCompareV3/data/properties/androidAppMode.js.map +0 -1
  99. package/lib/components/ModelCompareV3/data/properties/androidAppMode.mjs +0 -11
  100. package/lib/components/ModelCompareV3/data/properties/androidAppMode.mjs.map +0 -1
  101. package/lib/components/Tooltip/Tooltip.d.ts +0 -2
  102. package/lib/components/Tooltip/Tooltip.js +0 -52
  103. package/lib/components/Tooltip/Tooltip.js.map +0 -1
  104. package/lib/components/Tooltip/Tooltip.mjs +0 -50
  105. package/lib/components/Tooltip/Tooltip.mjs.map +0 -1
  106. package/lib/components/Tooltip/Tooltip.styles.d.ts +0 -33
  107. package/lib/components/Tooltip/Tooltip.styles.js +0 -50
  108. package/lib/components/Tooltip/Tooltip.styles.js.map +0 -1
  109. package/lib/components/Tooltip/Tooltip.styles.mjs +0 -39
  110. package/lib/components/Tooltip/Tooltip.styles.mjs.map +0 -1
  111. package/lib/components/Tooltip/index.d.ts +0 -1
  112. package/lib/components/Tooltip/index.js +0 -6
  113. package/lib/components/Tooltip/index.js.map +0 -1
  114. package/lib/components/Tooltip/index.mjs +0 -3
  115. package/lib/components/Tooltip/index.mjs.map +0 -1
  116. package/lib/utils/money/allocators/productAmount.d.ts +0 -13
  117. package/lib/utils/money/allocators/productAmount.js +0 -110
  118. package/lib/utils/money/allocators/productAmount.js.map +0 -1
  119. package/lib/utils/money/allocators/productAmount.mjs +0 -108
  120. package/lib/utils/money/allocators/productAmount.mjs.map +0 -1
  121. /package/lib/components/ModelCompareV3/assets/{ProfessionalAV → DisplayCast}/ucCast.jpg.js +0 -0
  122. /package/lib/components/ModelCompareV3/assets/{ProfessionalAV → DisplayCast}/ucCast.jpg.js.map +0 -0
  123. /package/lib/components/ModelCompareV3/assets/{ProfessionalAV → DisplayCast}/ucCast.jpg.mjs +0 -0
  124. /package/lib/components/ModelCompareV3/assets/{ProfessionalAV → DisplayCast}/ucCast.jpg.mjs.map +0 -0
  125. /package/lib/components/ModelCompareV3/assets/{ProfessionalAV → DisplayCast}/ucCastPro.jpg.js +0 -0
  126. /package/lib/components/ModelCompareV3/assets/{ProfessionalAV → DisplayCast}/ucCastPro.jpg.js.map +0 -0
  127. /package/lib/components/ModelCompareV3/assets/{ProfessionalAV → DisplayCast}/ucCastPro.jpg.mjs +0 -0
  128. /package/lib/components/ModelCompareV3/assets/{ProfessionalAV → DisplayCast}/ucCastPro.jpg.mjs.map +0 -0
@@ -1,50 +0,0 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { useRef, useState, useEffect } from 'react';
3
- import { useWindowScroll, useClickAway } from 'react-use';
4
- import { TOOLTIP_CLASS_NAME, TOOLTIP_CLASS_NAME_HIDDEN, Tooltip as Tooltip$1, TooltipStyles } from './Tooltip.styles.mjs';
5
- "use strict";
6
- const Tooltip = props => {
7
- const tooltipRef = useRef(null);
8
- const {
9
- y: scrollY
10
- } = useWindowScroll();
11
- const {
12
- children,
13
- tooltipClassName
14
- } = props;
15
- const [isOpen, setIsOpen] = useState();
16
- const [isHidden, setIsHidden] = useState(true);
17
- useEffect(() => {
18
- if (isOpen) {
19
- setTimeout(() => {
20
- setIsHidden(false);
21
- }, 80);
22
- } else {
23
- setIsHidden(true);
24
- }
25
- }, [isOpen]);
26
- useEffect(() => {
27
- setIsOpen(false);
28
- scrollY;
29
- }, [scrollY]);
30
- useClickAway(tooltipRef, () => {
31
- if (isOpen) {
32
- setIsOpen(false);
33
- }
34
- });
35
- const classNameList = [TOOLTIP_CLASS_NAME, tooltipClassName];
36
- if (isHidden) {
37
- classNameList.push(TOOLTIP_CLASS_NAME_HIDDEN);
38
- }
39
- const tooltipClassNames = classNameList.join(" ");
40
- return /* @__PURE__ */jsxs(Tooltip$1, {
41
- ref: tooltipRef,
42
- isOpen,
43
- onClick: () => setIsOpen(!isOpen),
44
- ...props,
45
- tooltipClassName: tooltipClassNames,
46
- children: [/* @__PURE__ */jsx(TooltipStyles, {}), children]
47
- });
48
- };
49
- export { Tooltip };
50
- //# sourceMappingURL=Tooltip.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Tooltip.mjs","sources":["../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import type { TooltipProps } from \"@ubnt/ui-components/Tooltip\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { useClickAway, useWindowScroll } from \"react-use\";\n\nimport * as S from \"./Tooltip.styles\";\nimport {\n TOOLTIP_CLASS_NAME,\n TOOLTIP_CLASS_NAME_HIDDEN,\n} from \"./Tooltip.styles\";\n\nexport const Tooltip = (props: TooltipProps) => {\n const tooltipRef = useRef<HTMLDivElement>(null);\n const { y: scrollY } = useWindowScroll();\n\n const { children, tooltipClassName } = props;\n\n const [isOpen, setIsOpen] = useState<boolean>();\n\n const [isHidden, setIsHidden] = useState<boolean>(true);\n\n // Hide tooltip when isOpen changes from true to false for a short time\n // Fixes the issue when tooltip is shown on the right side for a short time and then moves to bottom\n useEffect(() => {\n if (isOpen) {\n setTimeout(() => {\n setIsHidden(false);\n }, 80);\n } else {\n setIsHidden(true);\n }\n }, [isOpen]);\n\n // Hide tooltip when scrolling\n useEffect(() => {\n setIsOpen(false);\n scrollY;\n }, [scrollY]);\n\n useClickAway(tooltipRef, () => {\n if (isOpen) {\n setIsOpen(false);\n }\n });\n\n const classNameList = [TOOLTIP_CLASS_NAME, tooltipClassName];\n\n if (isHidden) {\n classNameList.push(TOOLTIP_CLASS_NAME_HIDDEN);\n }\n const tooltipClassNames = classNameList.join(\" \");\n\n return (\n <S.Tooltip\n ref={tooltipRef}\n isOpen={isOpen}\n onClick={() => setIsOpen(!isOpen)}\n {...props}\n tooltipClassName={tooltipClassNames}\n >\n <S.TooltipStyles />\n {children}\n </S.Tooltip>\n );\n};\n"],"names":["Tooltip","props","tooltipRef","useRef","y","scrollY","useWindowScroll","children","tooltipClassName","isOpen","setIsOpen","useState","isHidden","setIsHidden","useEffect","setTimeout","useClickAway","classNameList","TOOLTIP_CLASS_NAME","push","TOOLTIP_CLASS_NAME_HIDDEN","tooltipClassNames","join","jsxs","S.Tooltip","ref","onClick","jsx","S.TooltipStyles"],"mappings":";;;;;AAUa,MAAAA,OAAA,GAAWC,KAAwB,IAAA;EACxC,MAAAC,UAAA,GAAaC,OAAuB,IAAI,CAAA;EAC9C,MAAM;IAAEC,CAAA,EAAGC;EAAQ,CAAA,GAAIC,eAAgB,CAAA,CAAA;EAEjC,MAAA;IAAEC,QAAU;IAAAC;EAAqB,CAAA,GAAAP,KAAA;EAEvC,MAAM,CAACQ,MAAA,EAAQC,SAAS,CAAA,GAAIC,QAAkB,CAAA,CAAA;EAE9C,MAAM,CAACC,QAAA,EAAUC,WAAW,CAAA,GAAIF,SAAkB,IAAI,CAAA;EAItDG,SAAA,CAAU,MAAM;IACd,IAAIL,MAAQ,EAAA;MACVM,UAAA,CAAW,MAAM;QACfF,WAAA,CAAY,KAAK,CAAA;SAChB,EAAE,CAAA;IAAA,CACA,MAAA;MACLA,WAAA,CAAY,IAAI,CAAA;IAClB;EAAA,CACF,EAAG,CAACJ,MAAM,CAAC,CAAA;EAGXK,SAAA,CAAU,MAAM;IACdJ,SAAA,CAAU,KAAK,CAAA;IACfL,OAAA;EAAA,CACF,EAAG,CAACA,OAAO,CAAC,CAAA;EAEZW,YAAA,CAAad,YAAY,MAAM;IAC7B,IAAIO,MAAQ,EAAA;MACVC,SAAA,CAAU,KAAK,CAAA;IACjB;EAAA,CACD,CAAA;EAEK,MAAAO,aAAA,GAAgB,CAACC,kBAAA,EAAoBV,gBAAgB,CAAA;EAE3D,IAAII,QAAU,EAAA;IACZK,aAAA,CAAcE,KAAKC,yBAAyB,CAAA;EAC9C;EACM,MAAAC,iBAAA,GAAoBJ,aAAc,CAAAK,IAAA,CAAK,GAAG,CAAA;EAG9C,sBAAAC,IAAA,CAACC,SAAE,EAAF;IACCC,GAAK,EAAAvB,UAAA;IACLO,MAAA;IACAiB,OAAS,EAAAA,CAAA,KAAMhB,SAAU,CAAA,CAACD,MAAM,CAAA;IAC/B,GAAGR,KAAA;IACJO,gBAAkB,EAAAa,iBAAA;IAElBd,QAAA,EAAA,CAAA,eAACoB,GAAA,CAAAC,eAAA,EAAgB,CAAA,EAChBrB,QAAA;EAAA,CAAA,CACH;AAEJ,CAAA;"}
@@ -1,33 +0,0 @@
1
- export declare const TOOLTIP_CLASS_NAME = "custom-tooltip";
2
- export declare const TOOLTIP_CLASS_NAME_HIDDEN = "custom-tooltip--hidden";
3
- export declare const Tooltip: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<{
4
- message?: import("react").ReactNode;
5
- tooltipMessageClassName?: string;
6
- messageProps?: Omit<import("@ubnt/ui-components").TextProps, "forwardedRef">;
7
- omitTextWrapper?: boolean;
8
- leftRightInset?: number;
9
- isHoverable?: boolean;
10
- } & {
11
- title?: import("react").ReactNode;
12
- description?: import("react").ReactNode;
13
- children?: import("react").ReactNode;
14
- isOpen?: boolean;
15
- disableHover?: boolean;
16
- isInteractive?: boolean;
17
- cursorType?: "default" | "pointer";
18
- width?: string | number;
19
- maxWidth?: string | number;
20
- position?: import("@ubnt/ui-components/Tooltip").VisualTooltipPosition | import("@ubnt/ui-components/Tooltip").TooltipPosition;
21
- motif?: import("@ubnt/ui-components").Motif;
22
- tooltipClassName?: string;
23
- offset?: number;
24
- delay?: number | import("@ubnt/ui-components").DelayOptions;
25
- autoPosition?: boolean | import("@ubnt/ui-components/Tooltip").TooltipPosition[];
26
- animate?: boolean;
27
- noWrap?: boolean;
28
- className?: string;
29
- style?: import("react").CSSProperties;
30
- portal?: boolean;
31
- onClick?: import("react").MouseEventHandler;
32
- } & Omit<import("react").HTMLAttributes<HTMLElement>, "title"> & import("react").RefAttributes<HTMLElement>>, import("styled-components").DefaultTheme, {}, never>;
33
- export declare const TooltipStyles: import("styled-components").GlobalStyleComponent<{}, import("styled-components").DefaultTheme>;
@@ -1,50 +0,0 @@
1
- 'use strict';
2
-
3
- var Tooltip$1 = require('@ubnt/ui-components/Tooltip');
4
- var styled = require('styled-components');
5
- var theme = require('../../constants/theme.js');
6
- function _interopDefault(e) {
7
- return e && e.__esModule ? e : {
8
- default: e
9
- };
10
- }
11
- var styled__default = /*#__PURE__*/_interopDefault(styled);
12
- "use strict";
13
- const TOOLTIP_CLASS_NAME = "custom-tooltip";
14
- const TOOLTIP_CLASS_NAME_HIDDEN = "custom-tooltip--hidden";
15
- const Tooltip = styled__default["default"](Tooltip$1.Tooltip)`
16
- display: flex;
17
- `;
18
- const TooltipStyles = styled.createGlobalStyle`
19
- .${TOOLTIP_CLASS_NAME} {
20
- white-space: nowrap;
21
- z-index: ${theme.theme.zIndex.header + 1}!important;
22
- border-radius: 8px;
23
- color: #808893;
24
- font-size: 14px;
25
- line-height: 20px;
26
- box-shadow: 0 0 1px 0 rgb(33 35 39 / 0.08), 0 12px 48px 0 rgb(33 35 39 / 0.12);
27
- background-color: #fff;
28
- padding: 16px;
29
-
30
- * {
31
- color: #808893;
32
- font-size: 14px;
33
- line-height: 20px;
34
- }
35
-
36
- &::before {
37
- background-color: #fff;
38
- box-shadow: -4px -4px 4px -4px rgb(33 35 39 / .08);
39
- }
40
- }
41
-
42
- .${TOOLTIP_CLASS_NAME_HIDDEN} {
43
- opacity: 0;
44
- }
45
- `;
46
- exports.TOOLTIP_CLASS_NAME = TOOLTIP_CLASS_NAME;
47
- exports.TOOLTIP_CLASS_NAME_HIDDEN = TOOLTIP_CLASS_NAME_HIDDEN;
48
- exports.Tooltip = Tooltip;
49
- exports.TooltipStyles = TooltipStyles;
50
- //# sourceMappingURL=Tooltip.styles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Tooltip.styles.js","sources":["../../../src/components/Tooltip/Tooltip.styles.tsx"],"sourcesContent":["import { Tooltip as BaseTooltip } from \"@ubnt/ui-components/Tooltip\";\nimport styled, { createGlobalStyle } from \"styled-components\";\n\nimport { theme } from \"../../constants/theme\";\n\nexport const TOOLTIP_CLASS_NAME = \"custom-tooltip\";\nexport const TOOLTIP_CLASS_NAME_HIDDEN = \"custom-tooltip--hidden\";\n\nexport const Tooltip = styled(BaseTooltip)`\n display: flex;\n`;\n\nexport const TooltipStyles = createGlobalStyle`\n .${TOOLTIP_CLASS_NAME} {\n white-space: nowrap;\n z-index: ${theme.zIndex.header + 1}!important;\n border-radius: 8px;\n color: #808893;\n font-size: 14px;\n line-height: 20px;\n box-shadow: 0 0 1px 0 rgb(33 35 39 / 0.08), 0 12px 48px 0 rgb(33 35 39 / 0.12);\n background-color: #fff;\n padding: 16px;\n\n * {\n color: #808893;\n font-size: 14px;\n line-height: 20px;\n }\n\n &::before {\n background-color: #fff;\n box-shadow: -4px -4px 4px -4px rgb(33 35 39 / .08);\n }\n }\n\n .${TOOLTIP_CLASS_NAME_HIDDEN} {\n opacity: 0;\n }\n`;\n"],"names":["TOOLTIP_CLASS_NAME","TOOLTIP_CLASS_NAME_HIDDEN","Tooltip","styled","BaseTooltip","TooltipStyles","createGlobalStyle","theme","zIndex","header"],"mappings":";;;;;;;;;;;;AAKO,MAAMA,kBAAqB,GAAA,gBAAA;AAC3B,MAAMC,yBAA4B,GAAA,wBAAA;AAE5B,MAAAC,OAAA,GAAUC,eAAAA,CAAAA,SAAAA,EAAOC,SAAAA,CAAAA,OAAW,CAAA;AAAA;AAAA,CAAA;AAIlC,MAAMC,aAAgB,GAAAC,MAAAA,CAAAA,iBAAA;AAAA,KACxBN,kBAAkB;AAAA;AAAA,eAERO,WAAA,CAAMC,MAAO,CAAAC,MAAA,GAAS,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAqBjCR,yBAAyB;AAAA;AAAA;AAAA,CAAA;;;;"}
@@ -1,39 +0,0 @@
1
- import { Tooltip as Tooltip$1 } from '@ubnt/ui-components/Tooltip';
2
- import styled, { createGlobalStyle } from 'styled-components';
3
- import { theme } from '../../constants/theme.mjs';
4
- "use strict";
5
- const TOOLTIP_CLASS_NAME = "custom-tooltip";
6
- const TOOLTIP_CLASS_NAME_HIDDEN = "custom-tooltip--hidden";
7
- const Tooltip = styled(Tooltip$1)`
8
- display: flex;
9
- `;
10
- const TooltipStyles = createGlobalStyle`
11
- .${TOOLTIP_CLASS_NAME} {
12
- white-space: nowrap;
13
- z-index: ${theme.zIndex.header + 1}!important;
14
- border-radius: 8px;
15
- color: #808893;
16
- font-size: 14px;
17
- line-height: 20px;
18
- box-shadow: 0 0 1px 0 rgb(33 35 39 / 0.08), 0 12px 48px 0 rgb(33 35 39 / 0.12);
19
- background-color: #fff;
20
- padding: 16px;
21
-
22
- * {
23
- color: #808893;
24
- font-size: 14px;
25
- line-height: 20px;
26
- }
27
-
28
- &::before {
29
- background-color: #fff;
30
- box-shadow: -4px -4px 4px -4px rgb(33 35 39 / .08);
31
- }
32
- }
33
-
34
- .${TOOLTIP_CLASS_NAME_HIDDEN} {
35
- opacity: 0;
36
- }
37
- `;
38
- export { TOOLTIP_CLASS_NAME, TOOLTIP_CLASS_NAME_HIDDEN, Tooltip, TooltipStyles };
39
- //# sourceMappingURL=Tooltip.styles.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Tooltip.styles.mjs","sources":["../../../src/components/Tooltip/Tooltip.styles.tsx"],"sourcesContent":["import { Tooltip as BaseTooltip } from \"@ubnt/ui-components/Tooltip\";\nimport styled, { createGlobalStyle } from \"styled-components\";\n\nimport { theme } from \"../../constants/theme\";\n\nexport const TOOLTIP_CLASS_NAME = \"custom-tooltip\";\nexport const TOOLTIP_CLASS_NAME_HIDDEN = \"custom-tooltip--hidden\";\n\nexport const Tooltip = styled(BaseTooltip)`\n display: flex;\n`;\n\nexport const TooltipStyles = createGlobalStyle`\n .${TOOLTIP_CLASS_NAME} {\n white-space: nowrap;\n z-index: ${theme.zIndex.header + 1}!important;\n border-radius: 8px;\n color: #808893;\n font-size: 14px;\n line-height: 20px;\n box-shadow: 0 0 1px 0 rgb(33 35 39 / 0.08), 0 12px 48px 0 rgb(33 35 39 / 0.12);\n background-color: #fff;\n padding: 16px;\n\n * {\n color: #808893;\n font-size: 14px;\n line-height: 20px;\n }\n\n &::before {\n background-color: #fff;\n box-shadow: -4px -4px 4px -4px rgb(33 35 39 / .08);\n }\n }\n\n .${TOOLTIP_CLASS_NAME_HIDDEN} {\n opacity: 0;\n }\n`;\n"],"names":["TOOLTIP_CLASS_NAME","TOOLTIP_CLASS_NAME_HIDDEN","Tooltip","styled","BaseTooltip","TooltipStyles","createGlobalStyle","theme","zIndex","header"],"mappings":";;;;AAKO,MAAMA,kBAAqB,GAAA,gBAAA;AAC3B,MAAMC,yBAA4B,GAAA,wBAAA;AAE5B,MAAAC,OAAA,GAAUC,OAAOC,SAAW,CAAA;AAAA;AAAA,CAAA;AAIlC,MAAMC,aAAgB,GAAAC,iBAAA;AAAA,KACxBN,kBAAkB;AAAA;AAAA,eAERO,KAAA,CAAMC,MAAO,CAAAC,MAAA,GAAS,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAqBjCR,yBAAyB;AAAA;AAAA;AAAA,CAAA;"}
@@ -1 +0,0 @@
1
- export { Tooltip } from "./Tooltip";
@@ -1,6 +0,0 @@
1
- 'use strict';
2
-
3
- var Tooltip = require('./Tooltip.js');
4
- "use strict";
5
- exports.Tooltip = Tooltip.Tooltip;
6
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,3 +0,0 @@
1
- export { Tooltip } from './Tooltip.mjs';
2
- "use strict";
3
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,13 +0,0 @@
1
- import type { FullLineItemSummary } from "../types";
2
- /**
3
- * Helper class to distribute a total amount for a product
4
- */
5
- export declare class ProductAmountAllocator {
6
- #private;
7
- /**
8
- * Remaining quantity to allocate
9
- */
10
- quantity: number;
11
- constructor(productSummary: FullLineItemSummary);
12
- allocateQty(quantity: number): FullLineItemSummary;
13
- }
@@ -1,110 +0,0 @@
1
- 'use strict';
2
-
3
- var misc = require('../misc.js');
4
- var fixedAmount = require('./fixedAmount.js');
5
- "use strict";
6
- var __defProp = Object.defineProperty;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
8
- enumerable: true,
9
- configurable: true,
10
- writable: true,
11
- value
12
- }) : obj[key] = value;
13
- var __publicField = (obj, key, value) => {
14
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
15
- return value;
16
- };
17
- var __accessCheck = (obj, member, msg) => {
18
- if (!member.has(obj)) throw TypeError("Cannot " + msg);
19
- };
20
- var __privateGet = (obj, member, getter) => {
21
- __accessCheck(obj, member, "read from private field");
22
- return getter ? getter.call(obj) : member.get(obj);
23
- };
24
- var __privateAdd = (obj, member, value) => {
25
- if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
26
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
27
- };
28
- var __privateSet = (obj, member, value, setter) => {
29
- __accessCheck(obj, member, "write to private field");
30
- setter ? setter.call(obj, value) : member.set(obj, value);
31
- return value;
32
- };
33
- var _itemPrice, _currency, _subtotal, _discountAmount, _taxableAmount, _tax, _total;
34
- class ProductAmountAllocator {
35
- constructor(productSummary) {
36
- // #############################################################################
37
- // Fixed values
38
- // #############################################################################
39
- __privateAdd(this, _itemPrice, void 0);
40
- __privateAdd(this, _currency, void 0);
41
- // #############################################################################
42
- /**
43
- * Remaining quantity to allocate
44
- */
45
- __publicField(this, "quantity");
46
- // #############################################################################
47
- // Specific amount allocators
48
- // #############################################################################
49
- __privateAdd(this, _subtotal, void 0);
50
- __privateAdd(this, _discountAmount, void 0);
51
- __privateAdd(this, _taxableAmount, void 0);
52
- __privateAdd(this, _tax, void 0);
53
- __privateAdd(this, _total, void 0);
54
- const currency = productSummary.currency;
55
- const priceForAllocation = productSummary.itemPrice * productSummary.quantity;
56
- __privateSet(this, _itemPrice, productSummary.itemPrice);
57
- __privateSet(this, _currency, currency);
58
- this.quantity = productSummary.quantity;
59
- __privateSet(this, _subtotal, new fixedAmount.FixedAmountAllocator({
60
- initialAllocateAmount: productSummary.subtotal,
61
- initialTotalAmount: priceForAllocation,
62
- currency
63
- }));
64
- __privateSet(this, _discountAmount, new fixedAmount.FixedAmountAllocator({
65
- initialAllocateAmount: productSummary.discountAmount,
66
- initialTotalAmount: priceForAllocation,
67
- currency
68
- }));
69
- __privateSet(this, _taxableAmount, new fixedAmount.FixedAmountAllocator({
70
- initialAllocateAmount: productSummary.taxableAmount,
71
- initialTotalAmount: priceForAllocation,
72
- currency
73
- }));
74
- __privateSet(this, _tax, new fixedAmount.FixedAmountAllocator({
75
- initialAllocateAmount: productSummary.tax,
76
- initialTotalAmount: priceForAllocation,
77
- currency
78
- }));
79
- __privateSet(this, _total, new fixedAmount.FixedAmountAllocator({
80
- initialAllocateAmount: productSummary.total,
81
- initialTotalAmount: priceForAllocation,
82
- currency
83
- }));
84
- }
85
- allocateQty(quantity) {
86
- let quantityNormalized = Math.max(quantity, 0);
87
- quantityNormalized = this.quantity - quantityNormalized >= 0 ? quantityNormalized : 0;
88
- this.quantity = Math.max(this.quantity - quantityNormalized, 0);
89
- const itemQuantityPrice = __privateGet(this, _itemPrice) * quantityNormalized;
90
- return {
91
- itemPrice: __privateGet(this, _itemPrice),
92
- currency: __privateGet(this, _currency),
93
- quantity: quantityNormalized,
94
- subtotal: misc.amount(__privateGet(this, _subtotal).allocate(itemQuantityPrice, __privateGet(this, _currency))),
95
- discountAmount: misc.amount(__privateGet(this, _discountAmount).allocate(itemQuantityPrice, __privateGet(this, _currency))),
96
- taxableAmount: misc.amount(__privateGet(this, _taxableAmount).allocate(itemQuantityPrice, __privateGet(this, _currency))),
97
- tax: misc.amount(__privateGet(this, _tax).allocate(itemQuantityPrice, __privateGet(this, _currency))),
98
- total: misc.amount(__privateGet(this, _total).allocate(itemQuantityPrice, __privateGet(this, _currency)))
99
- };
100
- }
101
- }
102
- _itemPrice = new WeakMap();
103
- _currency = new WeakMap();
104
- _subtotal = new WeakMap();
105
- _discountAmount = new WeakMap();
106
- _taxableAmount = new WeakMap();
107
- _tax = new WeakMap();
108
- _total = new WeakMap();
109
- exports.ProductAmountAllocator = ProductAmountAllocator;
110
- //# sourceMappingURL=productAmount.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"productAmount.js","sources":["../../../../src/utils/money/allocators/productAmount.ts"],"sourcesContent":["import type { Currency } from \"../../../types\";\nimport { amount } from \"../misc\";\nimport type { Cents, FullLineItemSummary } from \"../types\";\nimport { FixedAmountAllocator } from \"./fixedAmount\";\n\n/**\n * Helper class to distribute a total amount for a product\n */\nexport class ProductAmountAllocator {\n // #############################################################################\n // Fixed values\n // #############################################################################\n readonly #itemPrice: Cents;\n readonly #currency: Currency;\n // #############################################################################\n /**\n * Remaining quantity to allocate\n */\n quantity: number;\n // #############################################################################\n // Specific amount allocators\n // #############################################################################\n #subtotal: FixedAmountAllocator;\n #discountAmount: FixedAmountAllocator;\n #taxableAmount: FixedAmountAllocator;\n #tax: FixedAmountAllocator;\n #total: FixedAmountAllocator;\n\n constructor(productSummary: FullLineItemSummary) {\n const currency = productSummary.currency;\n\n /**\n * Somewhat hackish, just need a stable price that can easily divide later by quantity\n */\n const priceForAllocation =\n productSummary.itemPrice * productSummary.quantity;\n\n this.#itemPrice = productSummary.itemPrice;\n this.#currency = currency;\n this.quantity = productSummary.quantity;\n this.#subtotal = new FixedAmountAllocator({\n initialAllocateAmount: productSummary.subtotal,\n initialTotalAmount: priceForAllocation,\n currency,\n });\n this.#discountAmount = new FixedAmountAllocator({\n initialAllocateAmount: productSummary.discountAmount,\n initialTotalAmount: priceForAllocation,\n currency,\n });\n this.#taxableAmount = new FixedAmountAllocator({\n initialAllocateAmount: productSummary.taxableAmount,\n initialTotalAmount: priceForAllocation,\n currency,\n });\n this.#tax = new FixedAmountAllocator({\n initialAllocateAmount: productSummary.tax,\n initialTotalAmount: priceForAllocation,\n currency,\n });\n this.#total = new FixedAmountAllocator({\n initialAllocateAmount: productSummary.total,\n initialTotalAmount: priceForAllocation,\n currency,\n });\n }\n\n allocateQty(quantity: number): FullLineItemSummary {\n // Calculate remaining allocatable quantity\n let quantityNormalized = Math.max(quantity, 0);\n quantityNormalized =\n this.quantity - quantityNormalized >= 0 ? quantityNormalized : 0;\n\n // Adjust remaining qty\n this.quantity = Math.max(this.quantity - quantityNormalized, 0);\n\n // How big of a slice of the total price we need to allocate\n const itemQuantityPrice = this.#itemPrice * quantityNormalized;\n\n return {\n itemPrice: this.#itemPrice,\n currency: this.#currency,\n quantity: quantityNormalized,\n subtotal: amount(\n this.#subtotal.allocate(itemQuantityPrice, this.#currency),\n ),\n discountAmount: amount(\n this.#discountAmount.allocate(itemQuantityPrice, this.#currency),\n ),\n taxableAmount: amount(\n this.#taxableAmount.allocate(itemQuantityPrice, this.#currency),\n ),\n tax: amount(this.#tax.allocate(itemQuantityPrice, this.#currency)),\n total: amount(this.#total.allocate(itemQuantityPrice, this.#currency)),\n } satisfies FullLineItemSummary;\n }\n}\n"],"names":["_itemPrice","_currency","_subtotal","_discountAmount","_taxableAmount","_tax","_total","ProductAmountAllocator","constructor","productSummary","__privateAdd","__publicField","currency","priceForAllocation","itemPrice","quantity","__privateSet","FixedAmountAllocator","initialAllocateAmount","subtotal","initialTotalAmount","discountAmount","taxableAmount","tax","total","allocateQty","quantityNormalized","Math","max","itemQuantityPrice","__privateGet","amount","allocate","WeakMap"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,UAAA,EAAAC,SAAA,EAAAC,SAAA,EAAAC,eAAA,EAAAC,cAAA,EAAAC,IAAA,EAAAC,MAAA;AAQO,MAAMC,sBAAuB,CAAA;EAoBlCC,YAAYC,cAAqC,EAAA;IAhBjD;IAAA;IAAA;IAAAC,YAAA,CAAA,IAAA,EAASV,UAAT,EAAA,KAAA,CAAA,CAAA;IACAU,YAAA,CAAA,IAAA,EAAST,SAAT,EAAA,KAAA,CAAA,CAAA;IAKA;IAAA;AAAA;AAAA;IAAAU,aAAA,CAAA,IAAA,EAAA,UAAA,CAAA;IAIA;IAAA;IAAA;IAAAD,YAAA,CAAA,IAAA,EAAAR,SAAA,EAAA,KAAA,CAAA,CAAA;IACAQ,YAAA,CAAA,IAAA,EAAAP,eAAA,EAAA,KAAA,CAAA,CAAA;IACAO,YAAA,CAAA,IAAA,EAAAN,cAAA,EAAA,KAAA,CAAA,CAAA;IACAM,YAAA,CAAA,IAAA,EAAAL,IAAA,EAAA,KAAA,CAAA,CAAA;IACAK,YAAA,CAAA,IAAA,EAAAJ,MAAA,EAAA,KAAA,CAAA,CAAA;IAGE,MAAMM,WAAWH,cAAe,CAAAG,QAAA;IAK1B,MAAAC,kBAAA,GACJJ,cAAe,CAAAK,SAAA,GAAYL,cAAe,CAAAM,QAAA;I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A,GAAA,IAAA6B,OAAA,CAAA,CAAA;AACA5B,IAAA,GAAA,IAAA4B,OAAA,CAAA,CAAA;AACA3B,MAAA,GAAA,IAAA2B,OAAA,CAAA,CAAA;"}
@@ -1,108 +0,0 @@
1
- import { amount } from '../misc.mjs';
2
- import { FixedAmountAllocator } from './fixedAmount.mjs';
3
- "use strict";
4
- var __defProp = Object.defineProperty;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
6
- enumerable: true,
7
- configurable: true,
8
- writable: true,
9
- value
10
- }) : obj[key] = value;
11
- var __publicField = (obj, key, value) => {
12
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
13
- return value;
14
- };
15
- var __accessCheck = (obj, member, msg) => {
16
- if (!member.has(obj)) throw TypeError("Cannot " + msg);
17
- };
18
- var __privateGet = (obj, member, getter) => {
19
- __accessCheck(obj, member, "read from private field");
20
- return getter ? getter.call(obj) : member.get(obj);
21
- };
22
- var __privateAdd = (obj, member, value) => {
23
- if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
24
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
25
- };
26
- var __privateSet = (obj, member, value, setter) => {
27
- __accessCheck(obj, member, "write to private field");
28
- setter ? setter.call(obj, value) : member.set(obj, value);
29
- return value;
30
- };
31
- var _itemPrice, _currency, _subtotal, _discountAmount, _taxableAmount, _tax, _total;
32
- class ProductAmountAllocator {
33
- constructor(productSummary) {
34
- // #############################################################################
35
- // Fixed values
36
- // #############################################################################
37
- __privateAdd(this, _itemPrice, void 0);
38
- __privateAdd(this, _currency, void 0);
39
- // #############################################################################
40
- /**
41
- * Remaining quantity to allocate
42
- */
43
- __publicField(this, "quantity");
44
- // #############################################################################
45
- // Specific amount allocators
46
- // #############################################################################
47
- __privateAdd(this, _subtotal, void 0);
48
- __privateAdd(this, _discountAmount, void 0);
49
- __privateAdd(this, _taxableAmount, void 0);
50
- __privateAdd(this, _tax, void 0);
51
- __privateAdd(this, _total, void 0);
52
- const currency = productSummary.currency;
53
- const priceForAllocation = productSummary.itemPrice * productSummary.quantity;
54
- __privateSet(this, _itemPrice, productSummary.itemPrice);
55
- __privateSet(this, _currency, currency);
56
- this.quantity = productSummary.quantity;
57
- __privateSet(this, _subtotal, new FixedAmountAllocator({
58
- initialAllocateAmount: productSummary.subtotal,
59
- initialTotalAmount: priceForAllocation,
60
- currency
61
- }));
62
- __privateSet(this, _discountAmount, new FixedAmountAllocator({
63
- initialAllocateAmount: productSummary.discountAmount,
64
- initialTotalAmount: priceForAllocation,
65
- currency
66
- }));
67
- __privateSet(this, _taxableAmount, new FixedAmountAllocator({
68
- initialAllocateAmount: productSummary.taxableAmount,
69
- initialTotalAmount: priceForAllocation,
70
- currency
71
- }));
72
- __privateSet(this, _tax, new FixedAmountAllocator({
73
- initialAllocateAmount: productSummary.tax,
74
- initialTotalAmount: priceForAllocation,
75
- currency
76
- }));
77
- __privateSet(this, _total, new FixedAmountAllocator({
78
- initialAllocateAmount: productSummary.total,
79
- initialTotalAmount: priceForAllocation,
80
- currency
81
- }));
82
- }
83
- allocateQty(quantity) {
84
- let quantityNormalized = Math.max(quantity, 0);
85
- quantityNormalized = this.quantity - quantityNormalized >= 0 ? quantityNormalized : 0;
86
- this.quantity = Math.max(this.quantity - quantityNormalized, 0);
87
- const itemQuantityPrice = __privateGet(this, _itemPrice) * quantityNormalized;
88
- return {
89
- itemPrice: __privateGet(this, _itemPrice),
90
- currency: __privateGet(this, _currency),
91
- quantity: quantityNormalized,
92
- subtotal: amount(__privateGet(this, _subtotal).allocate(itemQuantityPrice, __privateGet(this, _currency))),
93
- discountAmount: amount(__privateGet(this, _discountAmount).allocate(itemQuantityPrice, __privateGet(this, _currency))),
94
- taxableAmount: amount(__privateGet(this, _taxableAmount).allocate(itemQuantityPrice, __privateGet(this, _currency))),
95
- tax: amount(__privateGet(this, _tax).allocate(itemQuantityPrice, __privateGet(this, _currency))),
96
- total: amount(__privateGet(this, _total).allocate(itemQuantityPrice, __privateGet(this, _currency)))
97
- };
98
- }
99
- }
100
- _itemPrice = new WeakMap();
101
- _currency = new WeakMap();
102
- _subtotal = new WeakMap();
103
- _discountAmount = new WeakMap();
104
- _taxableAmount = new WeakMap();
105
- _tax = new WeakMap();
106
- _total = new WeakMap();
107
- export { ProductAmountAllocator };
108
- //# sourceMappingURL=productAmount.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"productAmount.mjs","sources":["../../../../src/utils/money/allocators/productAmount.ts"],"sourcesContent":["import type { Currency } from \"../../../types\";\nimport { amount } from \"../misc\";\nimport type { Cents, FullLineItemSummary } from \"../types\";\nimport { FixedAmountAllocator } from \"./fixedAmount\";\n\n/**\n * Helper class to distribute a total amount for a product\n */\nexport class ProductAmountAllocator {\n // #############################################################################\n // Fixed values\n // #############################################################################\n readonly #itemPrice: Cents;\n readonly #currency: Currency;\n // #############################################################################\n /**\n * Remaining quantity to allocate\n */\n quantity: number;\n // #############################################################################\n // Specific amount allocators\n // #############################################################################\n #subtotal: FixedAmountAllocator;\n #discountAmount: FixedAmountAllocator;\n #taxableAmount: FixedAmountAllocator;\n #tax: FixedAmountAllocator;\n #total: FixedAmountAllocator;\n\n constructor(productSummary: FullLineItemSummary) {\n const currency = productSummary.currency;\n\n /**\n * Somewhat hackish, just need a stable price that can easily divide later by quantity\n */\n const priceForAllocation =\n productSummary.itemPrice * productSummary.quantity;\n\n this.#itemPrice = productSummary.itemPrice;\n this.#currency = currency;\n this.quantity = productSummary.quantity;\n this.#subtotal = new FixedAmountAllocator({\n initialAllocateAmount: productSummary.subtotal,\n initialTotalAmount: priceForAllocation,\n currency,\n });\n this.#discountAmount = new FixedAmountAllocator({\n initialAllocateAmount: productSummary.discountAmount,\n initialTotalAmount: priceForAllocation,\n currency,\n });\n this.#taxableAmount = new FixedAmountAllocator({\n initialAllocateAmount: productSummary.taxableAmount,\n initialTotalAmount: priceForAllocation,\n currency,\n });\n this.#tax = new FixedAmountAllocator({\n initialAllocateAmount: productSummary.tax,\n initialTotalAmount: priceForAllocation,\n currency,\n });\n this.#total = new FixedAmountAllocator({\n initialAllocateAmount: productSummary.total,\n initialTotalAmount: priceForAllocation,\n currency,\n });\n }\n\n allocateQty(quantity: number): FullLineItemSummary {\n // Calculate remaining allocatable quantity\n let quantityNormalized = Math.max(quantity, 0);\n quantityNormalized =\n this.quantity - quantityNormalized >= 0 ? quantityNormalized : 0;\n\n // Adjust remaining qty\n this.quantity = Math.max(this.quantity - quantityNormalized, 0);\n\n // How big of a slice of the total price we need to allocate\n const itemQuantityPrice = this.#itemPrice * quantityNormalized;\n\n return {\n itemPrice: this.#itemPrice,\n currency: this.#currency,\n quantity: quantityNormalized,\n subtotal: amount(\n this.#subtotal.allocate(itemQuantityPrice, this.#currency),\n ),\n discountAmount: amount(\n this.#discountAmount.allocate(itemQuantityPrice, this.#currency),\n ),\n taxableAmount: amount(\n this.#taxableAmount.allocate(itemQuantityPrice, this.#currency),\n ),\n tax: amount(this.#tax.allocate(itemQuantityPrice, this.#currency)),\n total: amount(this.#total.allocate(itemQuantityPrice, this.#currency)),\n } satisfies FullLineItemSummary;\n }\n}\n"],"names":["_itemPrice","_currency","_subtotal","_discountAmount","_taxableAmount","_tax","_total","ProductAmountAllocator","constructor","productSummary","__privateAdd","__publicField","currency","priceForAllocation","itemPrice","quantity","__privateSet","FixedAmountAllocator","initialAllocateAmount","subtotal","initialTotalAmount","discountAmount","taxableAmount","tax","total","allocateQty","quantityNormalized","Math","max","itemQuantityPrice","__privateGet","amount","allocate","WeakMap"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,UAAA,EAAAC,SAAA,EAAAC,SAAA,EAAAC,eAAA,EAAAC,cAAA,EAAAC,IAAA,EAAAC,MAAA;AAQO,MAAMC,sBAAuB,CAAA;EAoBlCC,YAAYC,cAAqC,EAAA;IAhBjD;IAAA;IAAA;IAAAC,YAAA,CAAA,IAAA,EAASV,UAAT,EAAA,KAAA,CAAA,CAAA;IACAU,YAAA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