@oanda/labs-spread-cost-calculator-widget 1.0.1

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 (129) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/codegen.ts +15 -0
  3. package/dist/main/SpreadCostCalculatorWidget/Main.js +115 -0
  4. package/dist/main/SpreadCostCalculatorWidget/Main.js.map +1 -0
  5. package/dist/main/SpreadCostCalculatorWidget/SpreadCostCalculatorWidget.js +54 -0
  6. package/dist/main/SpreadCostCalculatorWidget/SpreadCostCalculatorWidget.js.map +1 -0
  7. package/dist/main/SpreadCostCalculatorWidget/ValidationWrapper.js +46 -0
  8. package/dist/main/SpreadCostCalculatorWidget/ValidationWrapper.js.map +1 -0
  9. package/dist/main/SpreadCostCalculatorWidget/constant.js +8 -0
  10. package/dist/main/SpreadCostCalculatorWidget/constant.js.map +1 -0
  11. package/dist/main/SpreadCostCalculatorWidget/index.js +28 -0
  12. package/dist/main/SpreadCostCalculatorWidget/index.js.map +1 -0
  13. package/dist/main/SpreadCostCalculatorWidget/render.js +51 -0
  14. package/dist/main/SpreadCostCalculatorWidget/render.js.map +1 -0
  15. package/dist/main/SpreadCostCalculatorWidget/types.js +6 -0
  16. package/dist/main/SpreadCostCalculatorWidget/types.js.map +1 -0
  17. package/dist/main/SpreadCostCalculatorWidget/useCalculateSpread.js +24 -0
  18. package/dist/main/SpreadCostCalculatorWidget/useCalculateSpread.js.map +1 -0
  19. package/dist/main/SpreadCostCalculatorWidget/useInstrumentChange.js +51 -0
  20. package/dist/main/SpreadCostCalculatorWidget/useInstrumentChange.js.map +1 -0
  21. package/dist/main/SpreadCostCalculatorWidget/utils.js +17 -0
  22. package/dist/main/SpreadCostCalculatorWidget/utils.js.map +1 -0
  23. package/dist/main/gql/types/fragment-masking.js +23 -0
  24. package/dist/main/gql/types/fragment-masking.js.map +1 -0
  25. package/dist/main/gql/types/gql.js +16 -0
  26. package/dist/main/gql/types/gql.js.map +1 -0
  27. package/dist/main/gql/types/graphql.js +223 -0
  28. package/dist/main/gql/types/graphql.js.map +1 -0
  29. package/dist/main/gql/types/index.js +28 -0
  30. package/dist/main/gql/types/index.js.map +1 -0
  31. package/dist/main/gql/validateInstruments.js +16 -0
  32. package/dist/main/gql/validateInstruments.js.map +1 -0
  33. package/dist/main/index.js +28 -0
  34. package/dist/main/index.js.map +1 -0
  35. package/dist/main/translations/index.js +27 -0
  36. package/dist/main/translations/index.js.map +1 -0
  37. package/dist/main/translations/sources/en.json +11 -0
  38. package/dist/main/translations/sources/es.json +11 -0
  39. package/dist/main/translations/sources/th.json +11 -0
  40. package/dist/main/translations/sources/zh_TW.json +11 -0
  41. package/dist/main/translations/translations.js +8 -0
  42. package/dist/main/translations/translations.js.map +1 -0
  43. package/dist/module/SpreadCostCalculatorWidget/Main.js +107 -0
  44. package/dist/module/SpreadCostCalculatorWidget/Main.js.map +1 -0
  45. package/dist/module/SpreadCostCalculatorWidget/SpreadCostCalculatorWidget.js +46 -0
  46. package/dist/module/SpreadCostCalculatorWidget/SpreadCostCalculatorWidget.js.map +1 -0
  47. package/dist/module/SpreadCostCalculatorWidget/ValidationWrapper.js +38 -0
  48. package/dist/module/SpreadCostCalculatorWidget/ValidationWrapper.js.map +1 -0
  49. package/dist/module/SpreadCostCalculatorWidget/constant.js +2 -0
  50. package/dist/module/SpreadCostCalculatorWidget/constant.js.map +1 -0
  51. package/dist/module/SpreadCostCalculatorWidget/index.js +3 -0
  52. package/dist/module/SpreadCostCalculatorWidget/index.js.map +1 -0
  53. package/dist/module/SpreadCostCalculatorWidget/render.js +48 -0
  54. package/dist/module/SpreadCostCalculatorWidget/render.js.map +1 -0
  55. package/dist/module/SpreadCostCalculatorWidget/types.js +2 -0
  56. package/dist/module/SpreadCostCalculatorWidget/types.js.map +1 -0
  57. package/dist/module/SpreadCostCalculatorWidget/useCalculateSpread.js +17 -0
  58. package/dist/module/SpreadCostCalculatorWidget/useCalculateSpread.js.map +1 -0
  59. package/dist/module/SpreadCostCalculatorWidget/useInstrumentChange.js +44 -0
  60. package/dist/module/SpreadCostCalculatorWidget/useInstrumentChange.js.map +1 -0
  61. package/dist/module/SpreadCostCalculatorWidget/utils.js +10 -0
  62. package/dist/module/SpreadCostCalculatorWidget/utils.js.map +1 -0
  63. package/dist/module/gql/types/fragment-masking.js +15 -0
  64. package/dist/module/gql/types/fragment-masking.js.map +1 -0
  65. package/dist/module/gql/types/gql.js +8 -0
  66. package/dist/module/gql/types/gql.js.map +1 -0
  67. package/dist/module/gql/types/graphql.js +217 -0
  68. package/dist/module/gql/types/graphql.js.map +1 -0
  69. package/dist/module/gql/types/index.js +3 -0
  70. package/dist/module/gql/types/index.js.map +1 -0
  71. package/dist/module/gql/validateInstruments.js +10 -0
  72. package/dist/module/gql/validateInstruments.js.map +1 -0
  73. package/dist/module/index.js +3 -0
  74. package/dist/module/index.js.map +1 -0
  75. package/dist/module/translations/index.js +20 -0
  76. package/dist/module/translations/index.js.map +1 -0
  77. package/dist/module/translations/sources/en.json +11 -0
  78. package/dist/module/translations/sources/es.json +11 -0
  79. package/dist/module/translations/sources/th.json +11 -0
  80. package/dist/module/translations/sources/zh_TW.json +11 -0
  81. package/dist/module/translations/translations.js +2 -0
  82. package/dist/module/translations/translations.js.map +1 -0
  83. package/dist/types/SpreadCostCalculatorWidget/Main.d.ts +4 -0
  84. package/dist/types/SpreadCostCalculatorWidget/SpreadCostCalculatorWidget.d.ts +4 -0
  85. package/dist/types/SpreadCostCalculatorWidget/ValidationWrapper.d.ts +4 -0
  86. package/dist/types/SpreadCostCalculatorWidget/constant.d.ts +1 -0
  87. package/dist/types/SpreadCostCalculatorWidget/index.d.ts +2 -0
  88. package/dist/types/SpreadCostCalculatorWidget/render.d.ts +1 -0
  89. package/dist/types/SpreadCostCalculatorWidget/types.d.ts +20 -0
  90. package/dist/types/SpreadCostCalculatorWidget/useCalculateSpread.d.ts +8 -0
  91. package/dist/types/SpreadCostCalculatorWidget/useInstrumentChange.d.ts +12 -0
  92. package/dist/types/SpreadCostCalculatorWidget/utils.d.ts +2 -0
  93. package/dist/types/gql/types/fragment-masking.d.ts +15 -0
  94. package/dist/types/gql/types/gql.d.ts +37 -0
  95. package/dist/types/gql/types/graphql.d.ts +389 -0
  96. package/dist/types/gql/types/index.d.ts +2 -0
  97. package/dist/types/gql/validateInstruments.d.ts +1 -0
  98. package/dist/types/index.d.ts +2 -0
  99. package/dist/types/translations/index.d.ts +4 -0
  100. package/dist/types/translations/translations.d.ts +1 -0
  101. package/index.ts +1 -0
  102. package/lokalise.config.json +18 -0
  103. package/package.json +26 -0
  104. package/src/SpreadCostCalculatorWidget/Main.tsx +138 -0
  105. package/src/SpreadCostCalculatorWidget/SpreadCostCalculatorWidget.tsx +52 -0
  106. package/src/SpreadCostCalculatorWidget/ValidationWrapper.tsx +51 -0
  107. package/src/SpreadCostCalculatorWidget/constant.ts +1 -0
  108. package/src/SpreadCostCalculatorWidget/index.ts +2 -0
  109. package/src/SpreadCostCalculatorWidget/render.tsx +60 -0
  110. package/src/SpreadCostCalculatorWidget/types.ts +27 -0
  111. package/src/SpreadCostCalculatorWidget/useCalculateSpread.ts +38 -0
  112. package/src/SpreadCostCalculatorWidget/useInstrumentChange.ts +47 -0
  113. package/src/SpreadCostCalculatorWidget/utils.ts +12 -0
  114. package/src/gql/types/fragment-masking.ts +66 -0
  115. package/src/gql/types/gql.ts +42 -0
  116. package/src/gql/types/graphql.ts +430 -0
  117. package/src/gql/types/index.ts +2 -0
  118. package/src/gql/validateInstruments.ts +10 -0
  119. package/src/index.ts +2 -0
  120. package/src/translations/index.ts +17 -0
  121. package/src/translations/sources/en.json +11 -0
  122. package/src/translations/sources/es.json +11 -0
  123. package/src/translations/sources/th.json +11 -0
  124. package/src/translations/sources/zh_TW.json +11 -0
  125. package/src/translations/translations.ts +1 -0
  126. package/test/SpreadCostCalculator.test.tsx +31 -0
  127. package/test/useCalculateSpread.test.tsx +131 -0
  128. package/test/useInstrumentChange.test.tsx +54 -0
  129. package/tsconfig.types.json +12 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## 1.0.1 (2024-11-19)
7
+
8
+ **Note:** Version bump only for package @oanda/labs-spread-cost-calculator-widget
package/codegen.ts ADDED
@@ -0,0 +1,15 @@
1
+ import type { CodegenConfig } from '@graphql-codegen/cli';
2
+
3
+ const config: CodegenConfig = {
4
+ overwrite: true,
5
+ schema: 'https://labs-api.uat.oanda.com/graphql',
6
+ documents: 'src/**/*.ts',
7
+ generates: {
8
+ 'src/gql/types/': {
9
+ preset: 'client',
10
+ plugins: [],
11
+ },
12
+ },
13
+ };
14
+
15
+ export default config;
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Main = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _monoI18n = require("@oanda/mono-i18n");
9
+ var _labsWidgetCommon = require("@oanda/labs-widget-common");
10
+ var _useCalculateSpread = require("./useCalculateSpread");
11
+ var _utils = require("./utils");
12
+ var _useInstrumentChange = require("./useInstrumentChange");
13
+ var _constant = require("./constant");
14
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
+ const Main = _ref => {
17
+ let {
18
+ instruments
19
+ } = _ref;
20
+ const {
21
+ size
22
+ } = (0, _react.useContext)(_labsWidgetCommon.ThemeContext);
23
+ const isDesktop = size === _labsWidgetCommon.Size.DESKTOP;
24
+ const selectOptions = instruments.map(instrument => ({
25
+ id: instrument.name,
26
+ label: instrument.displayName
27
+ }));
28
+ const {
29
+ value: unitsTraded,
30
+ handleValueChange: onUnitChange,
31
+ increment: incrementTradedUnits,
32
+ decrement: decrementTradedUnits
33
+ } = (0, _labsWidgetCommon.useNumberFormat)({});
34
+ const {
35
+ value: spread,
36
+ handleValueChange: onSpreadChange,
37
+ increment: incrementSpread,
38
+ decrement: decrementSpread
39
+ } = (0, _labsWidgetCommon.useNumberFormat)({
40
+ step: 0.1
41
+ });
42
+ const {
43
+ selectedInstrument,
44
+ setSelectedInstrument,
45
+ pipLocation,
46
+ initialSpread,
47
+ loading,
48
+ error
49
+ } = (0, _useInstrumentChange.useInstrumentChange)({
50
+ initialInstrument: {
51
+ id: instruments[0].name,
52
+ label: instruments[0].displayName
53
+ }
54
+ });
55
+ (0, _react.useEffect)(() => {
56
+ onSpreadChange({
57
+ floatValue: initialSpread,
58
+ formattedValue: initialSpread?.toString() || '',
59
+ value: initialSpread?.toString() || ''
60
+ });
61
+ }, [initialSpread]);
62
+ const {
63
+ lang
64
+ } = (0, _monoI18n.useLocale)();
65
+ const spreadCost = (0, _useCalculateSpread.useCalculateSpread)({
66
+ spread,
67
+ unitsTraded,
68
+ pipLocation
69
+ });
70
+ return _react.default.createElement(_react.default.Fragment, null, error ? _react.default.createElement("div", {
71
+ className: "lw-flex lw-h-[300px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary"
72
+ }, _react.default.createElement(_labsWidgetCommon.ChartError, null)) : _react.default.createElement("div", {
73
+ "data-testid": "spread-cost-calculator",
74
+ className: "lw-mx-auto lw-flex lw-w-full lw-max-w-full lw-flex-col lw-content-center lw-justify-center lw-gap-8 lw-p-4"
75
+ }, _react.default.createElement("div", {
76
+ className: "lw-flex lw-flex-col lw-gap-2"
77
+ }, _react.default.createElement(_labsWidgetCommon.Label, {
78
+ htmlFor: lang('instrument'),
79
+ className: "lw-text-text-primary"
80
+ }, lang('instrument')), _react.default.createElement(_labsWidgetCommon.Select, {
81
+ searchPlaceholder: lang('search'),
82
+ options: selectOptions,
83
+ selectedOption: selectedInstrument,
84
+ className: "lw-grow-0",
85
+ setSelectedOption: setSelectedInstrument,
86
+ maxHeight: isDesktop ? 190 : 220
87
+ })), _react.default.createElement("div", {
88
+ className: "lw-flex lw-max-w-full lw-flex-col lw-content-center lw-justify-center lw-gap-3"
89
+ }, _react.default.createElement("div", {
90
+ className: (0, _labsWidgetCommon.cn)('lw-flex lw-max-w-full lw-flex-row lw-gap-3', !isDesktop && 'lw-flex-col lw-gap-8')
91
+ }, _react.default.createElement(_labsWidgetCommon.NumberInput, {
92
+ onValueChange: onUnitChange,
93
+ value: unitsTraded,
94
+ label: lang('units_traded'),
95
+ onIncrement: incrementTradedUnits,
96
+ onDecrement: decrementTradedUnits,
97
+ placeholder: lang('volume'),
98
+ disabled: loading,
99
+ withoutArrows: true
100
+ }), _react.default.createElement(_labsWidgetCommon.NumberInput, {
101
+ onValueChange: onSpreadChange,
102
+ value: spread,
103
+ label: lang('spread'),
104
+ onIncrement: incrementSpread,
105
+ onDecrement: decrementSpread,
106
+ placeholder: lang('pips'),
107
+ disabled: loading
108
+ })), _react.default.createElement("div", {
109
+ className: "lw-pt-4 lw-text-text-primary"
110
+ }, _react.default.createElement("div", null, lang('absolute_spread_cost')), _react.default.createElement("div", {
111
+ className: "lw-pt-2 lw-text-3xl lw-font-bold"
112
+ }, spreadCost ? `${spreadCost} ${(0, _utils.getInstrumentCurrency)(selectedInstrument.id)}` : _constant.CELL_EMPTY_VALUE)))));
113
+ };
114
+ exports.Main = Main;
115
+ //# sourceMappingURL=Main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Main.js","names":["_react","_interopRequireWildcard","require","_monoI18n","_labsWidgetCommon","_useCalculateSpread","_utils","_useInstrumentChange","_constant","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Main","_ref","instruments","size","useContext","ThemeContext","isDesktop","Size","DESKTOP","selectOptions","map","instrument","id","name","label","displayName","value","unitsTraded","handleValueChange","onUnitChange","increment","incrementTradedUnits","decrement","decrementTradedUnits","useNumberFormat","spread","onSpreadChange","incrementSpread","decrementSpread","step","selectedInstrument","setSelectedInstrument","pipLocation","initialSpread","loading","error","useInstrumentChange","initialInstrument","useEffect","floatValue","formattedValue","toString","lang","useLocale","spreadCost","useCalculateSpread","createElement","Fragment","className","ChartError","Label","htmlFor","Select","searchPlaceholder","options","selectedOption","setSelectedOption","maxHeight","cn","NumberInput","onValueChange","onIncrement","onDecrement","placeholder","disabled","withoutArrows","getInstrumentCurrency","CELL_EMPTY_VALUE","exports"],"sources":["../../../src/SpreadCostCalculatorWidget/Main.tsx"],"sourcesContent":["import React, {\n FC, useContext, useEffect,\n} from 'react';\nimport { useLocale } from '@oanda/mono-i18n';\nimport {\n ChartError,\n cn,\n Label,\n NumberInput,\n Select,\n Size,\n ThemeContext,\n useNumberFormat,\n} from '@oanda/labs-widget-common';\nimport { useCalculateSpread } from './useCalculateSpread';\nimport { getInstrumentCurrency } from './utils';\nimport { useInstrumentChange } from './useInstrumentChange';\nimport { MainProps } from './types';\nimport { CELL_EMPTY_VALUE } from './constant';\n\nconst Main: FC<MainProps> = ({\n instruments,\n}) => {\n const { size } = useContext(ThemeContext);\n const isDesktop = size === Size.DESKTOP;\n\n const selectOptions = instruments.map((instrument) => ({\n id: instrument.name,\n label: instrument.displayName,\n }));\n\n const {\n value: unitsTraded,\n handleValueChange: onUnitChange,\n increment: incrementTradedUnits,\n decrement: decrementTradedUnits,\n } = useNumberFormat({});\n\n const {\n value: spread,\n handleValueChange: onSpreadChange,\n increment: incrementSpread,\n decrement: decrementSpread,\n } = useNumberFormat({\n step: 0.1,\n });\n\n const {\n selectedInstrument,\n setSelectedInstrument,\n pipLocation,\n initialSpread,\n loading,\n error,\n } = useInstrumentChange({\n initialInstrument: {\n id: instruments[0].name,\n label: instruments[0].displayName,\n },\n });\n\n useEffect(() => {\n onSpreadChange({\n floatValue: initialSpread,\n formattedValue: initialSpread?.toString() || '',\n value: initialSpread?.toString() || '',\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [initialSpread]);\n\n const { lang } = useLocale();\n\n const spreadCost = useCalculateSpread({\n spread,\n unitsTraded,\n pipLocation,\n });\n\n return (\n <>\n {error ? (\n <div className=\"lw-flex lw-h-[300px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\n </div>\n ) : (\n <div\n data-testid=\"spread-cost-calculator\"\n className=\"lw-mx-auto lw-flex lw-w-full lw-max-w-full lw-flex-col lw-content-center lw-justify-center lw-gap-8 lw-p-4\"\n >\n <div className=\"lw-flex lw-flex-col lw-gap-2\">\n <Label htmlFor={lang('instrument')} className=\"lw-text-text-primary\">\n {lang('instrument')}\n </Label>\n <Select\n searchPlaceholder={lang('search')}\n options={selectOptions}\n selectedOption={selectedInstrument}\n className=\"lw-grow-0\"\n setSelectedOption={setSelectedInstrument}\n maxHeight={isDesktop ? 190 : 220}\n />\n </div>\n <div className=\"lw-flex lw-max-w-full lw-flex-col lw-content-center lw-justify-center lw-gap-3\">\n <div className={cn('lw-flex lw-max-w-full lw-flex-row lw-gap-3', !isDesktop && 'lw-flex-col lw-gap-8')}>\n <NumberInput\n onValueChange={onUnitChange}\n value={unitsTraded}\n label={lang('units_traded')}\n onIncrement={incrementTradedUnits}\n onDecrement={decrementTradedUnits}\n placeholder={lang('volume')}\n disabled={loading}\n withoutArrows\n />\n <NumberInput\n onValueChange={onSpreadChange}\n value={spread}\n label={lang('spread')}\n onIncrement={incrementSpread}\n onDecrement={decrementSpread}\n placeholder={lang('pips')}\n disabled={loading}\n />\n </div>\n <div className=\"lw-pt-4 lw-text-text-primary\">\n <div>{lang('absolute_spread_cost')}</div>\n <div className=\"lw-pt-2 lw-text-3xl lw-font-bold\">\n {spreadCost ? `${spreadCost} ${getInstrumentCurrency(selectedInstrument.id)}` : CELL_EMPTY_VALUE }\n </div>\n </div>\n </div>\n </div>\n )}\n </>\n );\n};\n\nexport { Main };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAGA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAUA,IAAAG,mBAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,oBAAA,GAAAL,OAAA;AAEA,IAAAM,SAAA,GAAAN,OAAA;AAA8C,SAAAO,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAT,wBAAAS,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MA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sB,CAAO,CAAC,EACzCvE,MAAA,CAAAe,OAAA,CAAA4D,aAAA;IAAKE,SAAS,EAAC;EAAkC,GAC9CJ,UAAU,GAAG,GAAGA,UAAU,IAAI,IAAAsB,4BAAqB,EAACpC,kBAAkB,CAAClB,EAAE,CAAC,EAAE,GAAGuD,0BAC7E,CACF,CACF,CACF,CAEP,CAAC;AAEP,CAAC;AAACC,OAAA,CAAApE,IAAA,GAAAA,IAAA","ignoreList":[]}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SpreadCostCalculatorWidget = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _client = require("@apollo/client");
9
+ var _labsWidgetCommon = require("@oanda/labs-widget-common");
10
+ var _labsLiveRatesTableWidget = require("@oanda/labs-live-rates-table-widget");
11
+ var _monoI18n = require("@oanda/mono-i18n");
12
+ var _translations = require("../translations");
13
+ var _ValidationWrapper = require("./ValidationWrapper");
14
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
+ const SpreadCostCalculatorWidget = _ref => {
17
+ let {
18
+ graphqlUrl,
19
+ liveRatesUrl,
20
+ theme,
21
+ locale,
22
+ isParamError,
23
+ removePadding,
24
+ division,
25
+ instruments
26
+ } = _ref;
27
+ const client = new _client.ApolloClient({
28
+ uri: graphqlUrl,
29
+ cache: new _client.InMemoryCache()
30
+ });
31
+ const divisionCode = division === _labsLiveRatesTableWidget.Division.Opt ? _labsLiveRatesTableWidget.Division.Ogm : division;
32
+ const dataSource = divisionCode === _labsLiveRatesTableWidget.Division.Ogm ? 'MT5' : 'V20';
33
+ return _react.default.createElement(_monoI18n.LocaleProvider, {
34
+ locale: (0, _labsWidgetCommon.getLocale)(locale),
35
+ translations: _translations.translations
36
+ }, _react.default.createElement(_labsWidgetCommon.LiveRatesProvider, {
37
+ url: liveRatesUrl,
38
+ options: {
39
+ divisionCode,
40
+ dataSource
41
+ }
42
+ }, _react.default.createElement(_client.ApolloProvider, {
43
+ client: client
44
+ }, _react.default.createElement(_react.Suspense, null, _react.default.createElement(_labsWidgetCommon.ThemeProvider, {
45
+ theme: theme,
46
+ removePadding: removePadding
47
+ }, _react.default.createElement(_ValidationWrapper.ValidationWrapper, {
48
+ instruments: instruments,
49
+ division: division,
50
+ isParamError: isParamError
51
+ }))))));
52
+ };
53
+ exports.SpreadCostCalculatorWidget = SpreadCostCalculatorWidget;
54
+ //# sourceMappingURL=SpreadCostCalculatorWidget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SpreadCostCalculatorWidget.js","names":["_react","_interopRequireWildcard","require","_client","_labsWidgetCommon","_labsLiveRatesTableWidget","_monoI18n","_translations","_ValidationWrapper","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","SpreadCostCalculatorWidget","_ref","graphqlUrl","liveRatesUrl","theme","locale","isParamError","removePadding","division","instruments","client","ApolloClient","uri","cache","InMemoryCache","divisionCode","Division","Opt","Ogm","dataSource","createElement","LocaleProvider","getLocale","translations","LiveRatesProvider","url","options","ApolloProvider","Suspense","ThemeProvider","ValidationWrapper","exports"],"sources":["../../../src/SpreadCostCalculatorWidget/SpreadCostCalculatorWidget.tsx"],"sourcesContent":["import React, { FC, Suspense } from 'react';\nimport { ApolloClient, ApolloProvider, InMemoryCache } from '@apollo/client';\nimport {\n getLocale, LiveRatesProvider, ThemeProvider,\n} from '@oanda/labs-widget-common';\nimport { Division } from '@oanda/labs-live-rates-table-widget';\nimport { LocaleProvider } from '@oanda/mono-i18n';\nimport { SpreadCostCalculatorWidgetConfig } from './types';\nimport { translations } from '../translations';\nimport { ValidationWrapper } from './ValidationWrapper';\n\nconst SpreadCostCalculatorWidget: FC<SpreadCostCalculatorWidgetConfig> = ({\n graphqlUrl,\n liveRatesUrl,\n theme,\n locale,\n isParamError,\n removePadding,\n division,\n instruments,\n}) => {\n const client = new ApolloClient({\n uri: graphqlUrl,\n cache: new InMemoryCache(),\n });\n\n const divisionCode = division === Division.Opt ? Division.Ogm : division;\n const dataSource = divisionCode === Division.Ogm ? 'MT5' : 'V20';\n\n return (\n <LocaleProvider locale={getLocale(locale)} translations={translations}>\n <LiveRatesProvider\n url={liveRatesUrl}\n options={{ divisionCode, dataSource }}\n >\n <ApolloProvider client={client}>\n <Suspense>\n <ThemeProvider theme={theme} removePadding={removePadding}>\n <ValidationWrapper\n instruments={instruments}\n division={division}\n isParamError={isParamError}\n />\n </ThemeProvider>\n </Suspense>\n </ApolloProvider>\n </LiveRatesProvider>\n </LocaleProvider>\n );\n};\n\nexport { SpreadCostCalculatorWidget };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAGA,IAAAG,yBAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAEA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,kBAAA,GAAAN,OAAA;AAAwD,SAAAO,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAA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CAAC;EAEF,MAAMC,YAAY,GAAGP,QAAQ,KAAKQ,kCAAQ,CAACC,GAAG,GAAGD,kCAAQ,CAACE,GAAG,GAAGV,QAAQ;EACxE,MAAMW,UAAU,GAAGJ,YAAY,KAAKC,kCAAQ,CAACE,GAAG,GAAG,KAAK,GAAG,KAAK;EAEhE,OACE/C,MAAA,CAAAe,OAAA,CAAAkC,aAAA,CAAC3C,SAAA,CAAA4C,cAAc;IAAChB,MAAM,EAAE,IAAAiB,2BAAS,EAACjB,MAAM,CAAE;IAACkB,YAAY,EAAEA;EAAa,GACpEpD,MAAA,CAAAe,OAAA,CAAAkC,aAAA,CAAC7C,iBAAA,CAAAiD,iBAAiB;IAChBC,GAAG,EAAEtB,YAAa;IAClBuB,OAAO,EAAE;MAAEX,YAAY;MAAEI;IAAW;EAAE,GAEtChD,MAAA,CAAAe,OAAA,CAAAkC,aAAA,CAAC9C,OAAA,CAAAqD,cAAc;IAACjB,MAAM,EAAEA;EAAO,GAC7BvC,MAAA,CAAAe,OAAA,CAAAkC,aAAA,CAACjD,MAAA,CAAAyD,QAAQ,QACPzD,MAAA,CAAAe,OAAA,CAAAkC,aAAA,CAAC7C,iBAAA,CAAAsD,aAAa;IAACzB,KAAK,EAAEA,KAAM;IAACG,aAAa,EAAEA;EAAc,GACxDpC,MAAA,CAAAe,OAAA,CAAAkC,aAAA,CAACzC,kBAAA,CAAAmD,iBAAiB;IAChBrB,WAAW,EAAEA,WAAY;IACzBD,QAAQ,EAAEA,QAAS;IACnBF,YAAY,EAAEA;EAAa,CAC5B,CACY,CACP,CACI,CACC,CACL,CAAC;AAErB,CAAC;AAACyB,OAAA,CAAA/B,0BAAA,GAAAA,0BAAA","ignoreList":[]}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ValidationWrapper = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _client = require("@apollo/client");
9
+ var _labsWidgetCommon = require("@oanda/labs-widget-common");
10
+ var _Main = require("./Main");
11
+ var _validateInstruments = require("../gql/validateInstruments");
12
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
+ const ValidationWrapper = _ref => {
15
+ let {
16
+ division,
17
+ instruments,
18
+ isParamError
19
+ } = _ref;
20
+ const {
21
+ size
22
+ } = (0, _react.useContext)(_labsWidgetCommon.ThemeContext);
23
+ const {
24
+ data,
25
+ error
26
+ } = (0, _client.useSuspenseQuery)(_validateInstruments.validateInstruments, {
27
+ variables: {
28
+ instruments,
29
+ division
30
+ },
31
+ fetchPolicy: 'network-only',
32
+ errorPolicy: 'all'
33
+ });
34
+ const instrumentsData = data?.mapInstrumentNames?.map(instrument => ({
35
+ name: instrument.name,
36
+ displayName: instrument.displayName
37
+ })) || [];
38
+ const showError = !!error || isParamError;
39
+ return _react.default.createElement(_react.default.Fragment, null, size && _react.default.createElement(_react.default.Fragment, null, showError ? _react.default.createElement("div", {
40
+ className: "lw-flex lw-h-[300px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary"
41
+ }, _react.default.createElement(_labsWidgetCommon.ChartError, null)) : _react.default.createElement(_Main.Main, {
42
+ instruments: instrumentsData
43
+ })));
44
+ };
45
+ exports.ValidationWrapper = ValidationWrapper;
46
+ //# sourceMappingURL=ValidationWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ValidationWrapper.js","names":["_react","_interopRequireWildcard","require","_client","_labsWidgetCommon","_Main","_validateInstruments","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ValidationWrapper","_ref","division","instruments","isParamError","size","useContext","ThemeContext","data","error","useSuspenseQuery","validateInstruments","variables","fetchPolicy","errorPolicy","instrumentsData","mapInstrumentNames","map","instrument","name","displayName","showError","createElement","Fragment","className","ChartError","Main","exports"],"sources":["../../../src/SpreadCostCalculatorWidget/ValidationWrapper.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useSuspenseQuery } from '@apollo/client';\nimport { ChartError, ThemeContext } from '@oanda/labs-widget-common';\nimport { Main } from './Main';\nimport { validateInstruments } from '../gql/validateInstruments';\nimport { ValidateInstrumentsQuery, ValidateInstrumentsQueryVariables } from '../gql/types/graphql';\nimport { ValidationWrapperProps } from './types';\n\nconst ValidationWrapper = ({\n division,\n instruments,\n isParamError,\n}: ValidationWrapperProps) => {\n const { size } = useContext(ThemeContext);\n const { data, error } = useSuspenseQuery<\n ValidateInstrumentsQuery,\n ValidateInstrumentsQueryVariables\n >(validateInstruments, {\n variables: {\n instruments,\n division,\n },\n fetchPolicy: 'network-only',\n errorPolicy: 'all',\n });\n\n const instrumentsData = data?.mapInstrumentNames?.map((instrument) => ({\n name: instrument!.name,\n displayName: instrument!.displayName,\n })) || [];\n\n const showError = !!error || isParamError;\n\n return (\n <>\n {size && (\n <>\n {showError ? (\n <div className=\"lw-flex lw-h-[300px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\n </div>\n ) : (\n <Main instruments={instrumentsData} />\n )}\n </>\n )}\n </>\n );\n};\n\nexport { ValidationWrapper };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA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 const CELL_EMPTY_VALUE = exports.CELL_EMPTY_VALUE = '\u2014';
8
+ //# sourceMappingURL=constant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constant.js","names":["CELL_EMPTY_VALUE","exports"],"sources":["../../../src/SpreadCostCalculatorWidget/constant.ts"],"sourcesContent":["export const CELL_EMPTY_VALUE = '\\u2014';\n"],"mappings":";;;;;;AAAO,MAAMA,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG,QAAQ","ignoreList":[]}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _Main = require("./Main");
7
+ Object.keys(_Main).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _Main[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _Main[key];
14
+ }
15
+ });
16
+ });
17
+ var _types = require("./types");
18
+ Object.keys(_types).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _types[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _types[key];
25
+ }
26
+ });
27
+ });
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_Main","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_types"],"sources":["../../../src/SpreadCostCalculatorWidget/index.ts"],"sourcesContent":["export * from './Main';\nexport * from './types';\n"],"mappings":";;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,KAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,KAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,KAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,MAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,MAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,MAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,MAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ var _react = _interopRequireDefault(require("react"));
4
+ var _client = require("react-dom/client");
5
+ var _labsWidgetCommon = require("@oanda/labs-widget-common");
6
+ var _SpreadCostCalculatorWidget = require("./SpreadCostCalculatorWidget");
7
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
8
+ const {
9
+ graphqlUrl,
10
+ liveRatesUrl
11
+ } = window.widgetsConfig || {};
12
+ const spreadCostCalculatorParamsElements = document.querySelectorAll('div[data-spread-cost-calculator-params]');
13
+ spreadCostCalculatorParamsElements.forEach(element => {
14
+ const root = (0, _client.createRoot)(element);
15
+ const params = element.getAttribute('data-spread-cost-calculator-params');
16
+ const mode = element.getAttribute('data-mode');
17
+ const {
18
+ locale,
19
+ instruments,
20
+ division
21
+ } = JSON.parse(params);
22
+ const isParamError = (0, _labsWidgetCommon.validateToolParams)({
23
+ locale,
24
+ graphqlUrl,
25
+ instruments,
26
+ division,
27
+ liveRatesUrl
28
+ }, [{
29
+ name: 'locale',
30
+ valueCheck: value => (0, _labsWidgetCommon.validateLocale)(value)
31
+ }, {
32
+ name: 'graphqlUrl'
33
+ }, {
34
+ name: 'liveRatesUrl'
35
+ }, {
36
+ name: 'division'
37
+ }, {
38
+ name: 'instruments',
39
+ valueCheck: value => value.length > 0 && value.length <= 10
40
+ }]);
41
+ root.render(_react.default.createElement(_SpreadCostCalculatorWidget.SpreadCostCalculatorWidget, {
42
+ division: division,
43
+ instruments: instruments,
44
+ liveRatesUrl: liveRatesUrl,
45
+ graphqlUrl: graphqlUrl,
46
+ locale: locale,
47
+ theme: mode,
48
+ isParamError: isParamError
49
+ }));
50
+ });
51
+ //# sourceMappingURL=render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.js","names":["_react","_interopRequireDefault","require","_client","_labsWidgetCommon","_SpreadCostCalculatorWidget","e","__esModule","default","graphqlUrl","liveRatesUrl","window","widgetsConfig","spreadCostCalculatorParamsElements","document","querySelectorAll","forEach","element","root","createRoot","params","getAttribute","mode","locale","instruments","division","JSON","parse","isParamError","validateToolParams","name","valueCheck","value","validateLocale","length","render","createElement","SpreadCostCalculatorWidget","theme"],"sources":["../../../src/SpreadCostCalculatorWidget/render.tsx"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { Theme, validateLocale, validateToolParams } from '@oanda/labs-widget-common';\nimport { SpreadCostCalculatorWidget } from './SpreadCostCalculatorWidget';\n\nconst {\n graphqlUrl,\n liveRatesUrl,\n} = window.widgetsConfig || {};\nconst spreadCostCalculatorParamsElements = document.querySelectorAll(\n 'div[data-spread-cost-calculator-params]',\n);\n\nspreadCostCalculatorParamsElements.forEach((element) => {\n const root = createRoot(element);\n const params = element.getAttribute('data-spread-cost-calculator-params');\n const mode = element.getAttribute('data-mode');\n const { locale, instruments, division } = JSON.parse(params as string);\n\n const isParamError = validateToolParams(\n {\n locale,\n graphqlUrl,\n instruments,\n division,\n liveRatesUrl,\n },\n [\n {\n name: 'locale',\n valueCheck: (value) => validateLocale(value),\n },\n {\n name: 'graphqlUrl',\n },\n {\n name: 'liveRatesUrl',\n },\n {\n name: 'division',\n },\n {\n name: 'instruments',\n valueCheck: (value) => (value as string[]).length > 0 && (value as string[]).length <= 10,\n },\n ],\n );\n\n root.render(\n <SpreadCostCalculatorWidget\n division={division}\n instruments={instruments}\n liveRatesUrl={liveRatesUrl}\n graphqlUrl={graphqlUrl}\n locale={locale}\n theme={mode as Theme}\n isParamError={isParamError}\n />,\n );\n});\n"],"mappings":";;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,2BAAA,GAAAH,OAAA;AAA0E,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE1E,MAAM;EACJG,UAAU;EACVC;AACF,CAAC,GAAGC,MAAM,CAACC,aAAa,IAAI,CAAC,CAAC;AAC9B,MAAMC,kCAAkC,GAAGC,QAAQ,CAACC,gBAAgB,CAClE,yCACF,CAAC;AAEDF,kCAAkC,CAACG,OAAO,CAAEC,OAAO,IAAK;EACtD,MAAMC,IAAI,GAAG,IAAAC,kBAAU,EAACF,OAAO,CAAC;EAChC,MAAMG,MAAM,GAAGH,OAAO,CAACI,YAAY,CAAC,oCAAoC,CAAC;EACzE,MAAMC,IAAI,GAAGL,OAAO,CAACI,YAAY,CAAC,WAAW,CAAC;EAC9C,MAAM;IAAEE,MAAM;IAAEC,WAAW;IAAEC;EAAS,CAAC,GAAGC,IAAI,CAACC,KAAK,CAACP,MAAgB,CAAC;EAEtE,MAAMQ,YAAY,GAAG,IAAAC,oCAAkB,EACrC;IACEN,MAAM;IACNd,UAAU;IACVe,WAAW;IACXC,QAAQ;IACRf;EACF,CAAC,EACD,CACE;IACEoB,IAAI,EAAE,QAAQ;IACdC,UAAU,EAAGC,KAAK,IAAK,IAAAC,gCAAc,EAACD,KAAK;EAC7C,CAAC,EACD;IACEF,IAAI,EAAE;EACR,CAAC,EACD;IACEA,IAAI,EAAE;EACR,CAAC,EACD;IACEA,IAAI,EAAE;EACR,CAAC,EACD;IACEA,IAAI,EAAE,aAAa;IACnBC,UAAU,EAAGC,KAAK,IAAMA,KAAK,CAAcE,MAAM,GAAG,CAAC,IAAKF,KAAK,CAAcE,MAAM,IAAI;EACzF,CAAC,CAEL,CAAC;EAEDhB,IAAI,CAACiB,MAAM,CACTnC,MAAA,CAAAQ,OAAA,CAAA4B,aAAA,CAAC/B,2BAAA,CAAAgC,0BAA0B;IACzBZ,QAAQ,EAAEA,QAAS;IACnBD,WAAW,EAAEA,WAAY;IACzBd,YAAY,EAAEA,YAAa;IAC3BD,UAAU,EAAEA,UAAW;IACvBc,MAAM,EAAEA,MAAO;IACfe,KAAK,EAAEhB,IAAc;IACrBM,YAAY,EAAEA;EAAa,CAC5B,CACH,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../src/SpreadCostCalculatorWidget/types.ts"],"sourcesContent":["import { WidgetWrapperProps } from '@oanda/labs-widget-common';\nimport { Division } from '../gql/types/graphql';\n\nexport type SpreadCostCalculatorWidgetConfig = Pick<\nWidgetWrapperProps,\n'locale' | 'theme' | 'isParamError' | 'removePadding'\n> & {\n graphqlUrl: string;\n liveRatesUrl: string;\n division: Division;\n instruments: string[];\n};\n\nexport type InstrumentResponse = {\n name: string;\n displayName: string;\n};\n\nexport type MainProps = {\n instruments: InstrumentResponse[];\n};\n\nexport interface ValidationWrapperProps {\n division: Division;\n instruments: string[];\n isParamError?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useCalculateSpread = void 0;
7
+ var _usehooksTs = require("usehooks-ts");
8
+ var _react = require("react");
9
+ const calculateAbsoluteSpreadCost = (unitsTraded, spread, pipLocation) => unitsTraded !== undefined && spread !== undefined && pipLocation !== undefined ? Math.ceil(unitsTraded * spread * Number((10 ** pipLocation).toFixed(Math.abs(pipLocation))) / 2 * 10000) / 10000 : undefined;
10
+ const useCalculateSpread = _ref => {
11
+ let {
12
+ spread,
13
+ unitsTraded,
14
+ pipLocation,
15
+ delay = 350
16
+ } = _ref;
17
+ const [debouncedValue, setValue] = (0, _usehooksTs.useDebounceValue)(undefined, delay);
18
+ (0, _react.useEffect)(() => {
19
+ setValue(calculateAbsoluteSpreadCost(unitsTraded, spread, pipLocation));
20
+ }, [spread, unitsTraded, pipLocation, setValue]);
21
+ return debouncedValue;
22
+ };
23
+ exports.useCalculateSpread = useCalculateSpread;
24
+ //# sourceMappingURL=useCalculateSpread.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCalculateSpread.js","names":["_usehooksTs","require","_react","calculateAbsoluteSpreadCost","unitsTraded","spread","pipLocation","undefined","Math","ceil","Number","toFixed","abs","useCalculateSpread","_ref","delay","debouncedValue","setValue","useDebounceValue","useEffect","exports"],"sources":["../../../src/SpreadCostCalculatorWidget/useCalculateSpread.ts"],"sourcesContent":["import { useDebounceValue } from 'usehooks-ts';\nimport { useEffect } from 'react';\nimport { Voidable } from '@oanda/labs-widget-common';\n\nexport type UseCalculateSpreadInput = {\n spread: Voidable<number>;\n unitsTraded: Voidable<number>;\n pipLocation: Voidable<number>;\n delay?: number;\n};\n\nconst calculateAbsoluteSpreadCost = (\n unitsTraded?: number,\n spread?: number,\n pipLocation?: number,\n): number | undefined => (unitsTraded !== undefined\n && spread !== undefined\n && pipLocation !== undefined\n ? Math.ceil(\n ((unitsTraded * spread * Number((10 ** pipLocation).toFixed(Math.abs(pipLocation)))) / 2)\n * 10000,\n ) / 10000\n : undefined);\n\nexport const useCalculateSpread = ({\n spread,\n unitsTraded,\n pipLocation,\n delay = 350,\n}: UseCalculateSpreadInput) => {\n const [debouncedValue, setValue] = useDebounceValue<undefined | number>(undefined, delay);\n\n useEffect(() => {\n setValue(calculateAbsoluteSpreadCost(unitsTraded, spread, pipLocation));\n }, [spread, unitsTraded, pipLocation, setValue]);\n\n return debouncedValue;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAUA,MAAME,2BAA2B,GAAGA,CAClCC,WAAoB,EACpBC,MAAe,EACfC,WAAoB,KACIF,WAAW,KAAKG,SAAS,IAC9CF,MAAM,KAAKE,SAAS,IACpBD,WAAW,KAAKC,SAAS,GAC1BC,IAAI,CAACC,IAAI,CACPL,WAAW,GAAGC,MAAM,GAAGK,MAAM,CAAC,CAAC,EAAE,IAAIJ,WAAW,EAAEK,OAAO,CAACH,IAAI,CAACI,GAAG,CAACN,WAAW,CAAC,CAAC,CAAC,GAAI,CAAC,GAChF,KACV,CAAC,GAAG,KAAK,GACPC,SAAU;AAEP,MAAMM,kBAAkB,GAAGC,IAAA,IAKH;EAAA,IALI;IACjCT,MAAM;IACND,WAAW;IACXE,WAAW;IACXS,KAAK,GAAG;EACe,CAAC,GAAAD,IAAA;EACxB,MAAM,CAACE,cAAc,EAAEC,QAAQ,CAAC,GAAG,IAAAC,4BAAgB,EAAqBX,SAAS,EAAEQ,KAAK,CAAC;EAEzF,IAAAI,gBAAS,EAAC,MAAM;IACdF,QAAQ,CAACd,2BAA2B,CAACC,WAAW,EAAEC,MAAM,EAAEC,WAAW,CAAC,CAAC;EACzE,CAAC,EAAE,CAACD,MAAM,EAAED,WAAW,EAAEE,WAAW,EAAEW,QAAQ,CAAC,CAAC;EAEhD,OAAOD,cAAc;AACvB,CAAC;AAACI,OAAA,CAAAP,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useInstrumentChange = void 0;
7
+ var _labsWidgetCommon = require("@oanda/labs-widget-common");
8
+ var _react = require("react");
9
+ const useInstrumentChange = _ref => {
10
+ let {
11
+ initialInstrument
12
+ } = _ref;
13
+ const {
14
+ target,
15
+ setQuery,
16
+ closeQuery
17
+ } = (0, _labsWidgetCommon.useLiveRatesQuery)();
18
+ const [loading, setLoading] = (0, _react.useState)(true);
19
+ const [selectedInstrument, setSelectedInstrument] = (0, _react.useState)(initialInstrument);
20
+ const [pipLocation, setPipLocation] = (0, _react.useState)(undefined);
21
+ const [initialSpread, setSpread] = (0, _react.useState)(undefined);
22
+ const {
23
+ update,
24
+ error,
25
+ connectionError
26
+ } = (0, _labsWidgetCommon.useLiveRatesMessage)(selectedInstrument.id, target);
27
+ (0, _react.useEffect)(() => {
28
+ if (selectedInstrument.id === update?.symbol) {
29
+ setPipLocation(update.pipLocation);
30
+ setSpread(update.spread);
31
+ setLoading(false);
32
+ closeQuery();
33
+ }
34
+ }, [update]);
35
+ (0, _react.useEffect)(() => {
36
+ setLoading(true);
37
+ setQuery({
38
+ instruments: [selectedInstrument.id]
39
+ });
40
+ }, [selectedInstrument.id]);
41
+ return {
42
+ selectedInstrument,
43
+ setSelectedInstrument,
44
+ pipLocation,
45
+ initialSpread,
46
+ loading,
47
+ error: !!error || !!connectionError
48
+ };
49
+ };
50
+ exports.useInstrumentChange = useInstrumentChange;
51
+ //# sourceMappingURL=useInstrumentChange.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useInstrumentChange.js","names":["_labsWidgetCommon","require","_react","useInstrumentChange","_ref","initialInstrument","target","setQuery","closeQuery","useLiveRatesQuery","loading","setLoading","useState","selectedInstrument","setSelectedInstrument","pipLocation","setPipLocation","undefined","initialSpread","setSpread","update","error","connectionError","useLiveRatesMessage","id","useEffect","symbol","spread","instruments","exports"],"sources":["../../../src/SpreadCostCalculatorWidget/useInstrumentChange.ts"],"sourcesContent":["import { SelectOption, useLiveRatesMessage, useLiveRatesQuery } from '@oanda/labs-widget-common';\nimport { useEffect, useState } from 'react';\n\nexport type UseInstrumentChangeInput = {\n initialInstrument: SelectOption;\n};\n\nexport const useInstrumentChange = ({\n initialInstrument,\n}: UseInstrumentChangeInput) => {\n const { target, setQuery, closeQuery } = useLiveRatesQuery();\n const [loading, setLoading] = useState(true);\n const [selectedInstrument, setSelectedInstrument] = useState(initialInstrument);\n const [pipLocation, setPipLocation] = useState<undefined | number>(undefined);\n const [initialSpread, setSpread] = useState<undefined | number>(undefined);\n\n const { update, error, connectionError } = useLiveRatesMessage(\n selectedInstrument.id,\n target,\n );\n\n useEffect(() => {\n if (selectedInstrument.id === update?.symbol) {\n setPipLocation(update.pipLocation);\n setSpread(update.spread);\n setLoading(false);\n closeQuery();\n }\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [update]);\n\n useEffect(() => {\n setLoading(true);\n setQuery({ instruments: [selectedInstrument.id] });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [selectedInstrument.id]);\n\n return {\n selectedInstrument,\n setSelectedInstrument,\n pipLocation,\n initialSpread,\n loading,\n error: !!error || !!connectionError,\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAMO,MAAME,mBAAmB,GAAGC,IAAA,IAEH;EAAA,IAFI;IAClCC;EACwB,CAAC,GAAAD,IAAA;EACzB,MAAM;IAAEE,MAAM;IAAEC,QAAQ;IAAEC;EAAW,CAAC,GAAG,IAAAC,mCAAiB,EAAC,CAAC;EAC5D,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAG,IAAAC,eAAQ,EAAC,IAAI,CAAC;EAC5C,MAAM,CAACC,kBAAkB,EAAEC,qBAAqB,CAAC,GAAG,IAAAF,eAAQ,EAACP,iBAAiB,CAAC;EAC/E,MAAM,CAACU,WAAW,EAAEC,cAAc,CAAC,GAAG,IAAAJ,eAAQ,EAAqBK,SAAS,CAAC;EAC7E,MAAM,CAACC,aAAa,EAAEC,SAAS,CAAC,GAAG,IAAAP,eAAQ,EAAqBK,SAAS,CAAC;EAE1E,MAAM;IAAEG,MAAM;IAAEC,KAAK;IAAEC;EAAgB,CAAC,GAAG,IAAAC,qCAAmB,EAC5DV,kBAAkB,CAACW,EAAE,EACrBlB,MACF,CAAC;EAED,IAAAmB,gBAAS,EAAC,MAAM;IACd,IAAIZ,kBAAkB,CAACW,EAAE,KAAKJ,MAAM,EAAEM,MAAM,EAAE;MAC5CV,cAAc,CAACI,MAAM,CAACL,WAAW,CAAC;MAClCI,SAAS,CAACC,MAAM,CAACO,MAAM,CAAC;MACxBhB,UAAU,CAAC,KAAK,CAAC;MACjBH,UAAU,CAAC,CAAC;IACd;EAGF,CAAC,EAAE,CAACY,MAAM,CAAC,CAAC;EAEZ,IAAAK,gBAAS,EAAC,MAAM;IACdd,UAAU,CAAC,IAAI,CAAC;IAChBJ,QAAQ,CAAC;MAAEqB,WAAW,EAAE,CAACf,kBAAkB,CAACW,EAAE;IAAE,CAAC,CAAC;EAEpD,CAAC,EAAE,CAACX,kBAAkB,CAACW,EAAE,CAAC,CAAC;EAE3B,OAAO;IACLX,kBAAkB;IAClBC,qBAAqB;IACrBC,WAAW;IACXG,aAAa;IACbR,OAAO;IACPW,KAAK,EAAE,CAAC,CAACA,KAAK,IAAI,CAAC,CAACC;EACtB,CAAC;AACH,CAAC;AAACO,OAAA,CAAA1B,mBAAA,GAAAA,mBAAA","ignoreList":[]}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getInstrumentCurrency = void 0;
7
+ const getInstrumentCurrency = instrument => {
8
+ if (typeof instrument === 'string') {
9
+ return instrument.split('_')[1] || ' ';
10
+ }
11
+ if (instrument?.name) {
12
+ return instrument.name.split('_')[1] || ' ';
13
+ }
14
+ return ' ';
15
+ };
16
+ exports.getInstrumentCurrency = getInstrumentCurrency;
17
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","names":["getInstrumentCurrency","instrument","split","name","exports"],"sources":["../../../src/SpreadCostCalculatorWidget/utils.ts"],"sourcesContent":["import { InstrumentResponse } from './types';\n\nexport const getInstrumentCurrency = (instrument: string | InstrumentResponse | null): string => {\n if (typeof instrument === 'string') {\n return instrument.split('_')[1] || ' ';\n }\n if (instrument?.name) {\n return instrument.name.split('_')[1] || ' ';\n }\n\n return ' ';\n};\n"],"mappings":";;;;;;AAEO,MAAMA,qBAAqB,GAAIC,UAA8C,IAAa;EAC/F,IAAI,OAAOA,UAAU,KAAK,QAAQ,EAAE;IAClC,OAAOA,UAAU,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG;EACxC;EACA,IAAID,UAAU,EAAEE,IAAI,EAAE;IACpB,OAAOF,UAAU,CAACE,IAAI,CAACD,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG;EAC7C;EAEA,OAAO,GAAG;AACZ,CAAC;AAACE,OAAA,CAAAJ,qBAAA,GAAAA,qBAAA","ignoreList":[]}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isFragmentReady = isFragmentReady;
7
+ exports.makeFragmentData = makeFragmentData;
8
+ exports.useFragment = useFragment;
9
+ function useFragment(_documentNode, fragmentType) {
10
+ return fragmentType;
11
+ }
12
+ function makeFragmentData(data, _fragment) {
13
+ return data;
14
+ }
15
+ function isFragmentReady(queryNode, fragmentNode, data) {
16
+ const deferredFields = queryNode.__meta__?.deferredFields;
17
+ if (!deferredFields) return true;
18
+ const fragDef = fragmentNode.definitions[0];
19
+ const fragName = fragDef?.name?.value;
20
+ const fields = fragName && deferredFields[fragName] || [];
21
+ return fields.length > 0 && fields.every(field => data && field in data);
22
+ }
23
+ //# sourceMappingURL=fragment-masking.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fragment-masking.js","names":["useFragment","_documentNode","fragmentType","makeFragmentData","data","_fragment","isFragmentReady","queryNode","fragmentNode","deferredFields","__meta__","fragDef","definitions","fragName","name","value","fields","length","every","field"],"sources":["../../../../src/gql/types/fragment-masking.ts"],"sourcesContent":["import { ResultOf, DocumentTypeDecoration, TypedDocumentNode } from '@graphql-typed-document-node/core';\nimport { FragmentDefinitionNode } from 'graphql';\nimport { Incremental } from './graphql';\n\n\nexport type FragmentType<TDocumentType extends DocumentTypeDecoration<any, any>> = TDocumentType extends DocumentTypeDecoration<\n infer TType,\n any\n>\n ? [TType] extends [{ ' $fragmentName'?: infer TKey }]\n ? TKey extends string\n ? { ' $fragmentRefs'?: { [key in TKey]: TType } }\n : never\n : never\n : never;\n\n// return non-nullable if `fragmentType` is non-nullable\nexport function useFragment<TType>(\n _documentNode: DocumentTypeDecoration<TType, any>,\n fragmentType: FragmentType<DocumentTypeDecoration<TType, any>>\n): TType;\n// return nullable if `fragmentType` is nullable\nexport function useFragment<TType>(\n _documentNode: DocumentTypeDecoration<TType, any>,\n fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | null | undefined\n): TType | null | undefined;\n// return array of non-nullable if `fragmentType` is array of non-nullable\nexport function useFragment<TType>(\n _documentNode: DocumentTypeDecoration<TType, any>,\n fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>\n): ReadonlyArray<TType>;\n// return array of nullable if `fragmentType` is array of nullable\nexport function useFragment<TType>(\n _documentNode: DocumentTypeDecoration<TType, any>,\n fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined\n): ReadonlyArray<TType> | null | undefined;\nexport function useFragment<TType>(\n _documentNode: DocumentTypeDecoration<TType, any>,\n fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined\n): TType | ReadonlyArray<TType> | null | undefined {\n return fragmentType as any;\n}\n\n\nexport function makeFragmentData<\n F extends DocumentTypeDecoration<any, any>,\n FT extends ResultOf<F>\n>(data: FT, _fragment: F): FragmentType<F> {\n return data as FragmentType<F>;\n}\nexport function isFragmentReady<TQuery, TFrag>(\n queryNode: DocumentTypeDecoration<TQuery, any>,\n fragmentNode: TypedDocumentNode<TFrag>,\n data: FragmentType<TypedDocumentNode<Incremental<TFrag>, any>> | null | undefined\n): data is FragmentType<typeof fragmentNode> {\n const deferredFields = (queryNode as { __meta__?: { deferredFields: Record<string, (keyof TFrag)[]> } }).__meta__\n ?.deferredFields;\n\n if (!deferredFields) return true;\n\n const fragDef = fragmentNode.definitions[0] as FragmentDefinitionNode | undefined;\n const fragName = fragDef?.name?.value;\n\n const fields = (fragName && deferredFields[fragName]) || [];\n return fields.length > 0 && fields.every(field => data && field in data);\n}\n"],"mappings":";;;;;;;;AAoCO,SAASA,WAAWA,CACzBC,aAAiD,EACjDC,YAAmJ,EAClG;EACjD,OAAOA,YAAY;AACrB;AAGO,SAASC,gBAAgBA,CAG9BC,IAAQ,EAAEC,SAAY,EAAmB;EACzC,OAAOD,IAAI;AACb;AACO,SAASE,eAAeA,CAC7BC,SAA8C,EAC9CC,YAAsC,EACtCJ,IAAiF,EACtC;EAC3C,MAAMK,cAAc,GAAIF,SAAS,CAAwEG,QAAQ,EAC7GD,cAAc;EAElB,IAAI,CAACA,cAAc,EAAE,OAAO,IAAI;EAEhC,MAAME,OAAO,GAAGH,YAAY,CAACI,WAAW,CAAC,CAAC,CAAuC;EACjF,MAAMC,QAAQ,GAAGF,OAAO,EAAEG,IAAI,EAAEC,KAAK;EAErC,MAAMC,MAAM,GAAIH,QAAQ,IAAIJ,cAAc,CAACI,QAAQ,CAAC,IAAK,EAAE;EAC3D,OAAOG,MAAM,CAACC,MAAM,GAAG,CAAC,IAAID,MAAM,CAACE,KAAK,CAACC,KAAK,IAAIf,IAAI,IAAIe,KAAK,IAAIf,IAAI,CAAC;AAC1E","ignoreList":[]}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.graphql = graphql;
7
+ var types = _interopRequireWildcard(require("./graphql"));
8
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
9
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
+ const documents = {
11
+ "\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n": types.ValidateInstrumentsDocument
12
+ };
13
+ function graphql(source) {
14
+ return documents[source] ?? {};
15
+ }
16
+ //# sourceMappingURL=gql.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gql.js","names":["types","_interopRequireWildcard","require","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","documents","ValidateInstrumentsDocument","graphql","source"],"sources":["../../../../src/gql/types/gql.ts"],"sourcesContent":["/* eslint-disable */\nimport * as types from './graphql';\nimport { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';\n\n/**\n * Map of all GraphQL operations in the project.\n *\n * This map has several performance disadvantages:\n * 1. It is not tree-shakeable, so it will include all operations in the project.\n * 2. It is not minifiable, so the string of a GraphQL query will be multiple times inside the bundle.\n * 3. It does not support dead code elimination, so it will add unused operations.\n *\n * Therefore it is highly recommended to use the babel or swc plugin for production.\n */\nconst documents = {\n \"\\n query validateInstruments($instruments: [String]!, $division: Division) {\\n mapInstrumentNames(instruments: $instruments, division: $division) {\\n name\\n displayName\\n }\\n }\\n\": types.ValidateInstrumentsDocument,\n};\n\n/**\n * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.\n *\n *\n * @example\n * ```ts\n * const query = graphql(`query GetUser($id: ID!) { user(id: $id) { name } }`);\n * ```\n *\n * The query argument is unknown!\n * Please regenerate the types.\n */\nexport function graphql(source: string): unknown;\n\n/**\n * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.\n */\nexport function graphql(source: \"\\n query validateInstruments($instruments: [String]!, $division: Division) {\\n mapInstrumentNames(instruments: $instruments, division: $division) {\\n name\\n displayName\\n }\\n }\\n\"): (typeof documents)[\"\\n query validateInstruments($instruments: [String]!, $division: Division) {\\n mapInstrumentNames(instruments: $instruments, division: $division) {\\n name\\n displayName\\n }\\n }\\n\"];\n\nexport function graphql(source: string) {\n return (documents as any)[source] ?? {};\n}\n\nexport type DocumentType<TDocumentNode extends DocumentNode<any, any>> = TDocumentNode extends DocumentNode< infer TType, any> ? TType : never;"],"mappings":";;;;;;AACA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAmC,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI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