@bigbinary/neeto-commons-frontend 3.4.6 → 3.4.8
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.
- package/cjs/initializers/index.js +2 -0
- package/cjs/initializers/index.js.map +1 -1
- package/cjs/initializers/mixpanel.js +28 -0
- package/cjs/initializers/mixpanel.js.map +1 -0
- package/cjs/utils/datetime.js +15 -11
- package/cjs/utils/datetime.js.map +1 -1
- package/initializers/index.js +2 -0
- package/initializers/index.js.map +1 -1
- package/initializers/mixpanel.js +21 -0
- package/initializers/mixpanel.js.map +1 -0
- package/initializers.d.ts +2 -0
- package/package.json +2 -1
- package/utils/datetime.js +14 -11
- package/utils/datetime.js.map +1 -1
|
@@ -25,6 +25,7 @@ var _axios = _interopRequireDefault(require("./axios"));
|
|
|
25
25
|
var _globalProps = _interopRequireDefault(require("./globalProps"));
|
|
26
26
|
var _i18n = _interopRequireWildcard(require("./i18n"));
|
|
27
27
|
var _logger = _interopRequireDefault(require("./logger"));
|
|
28
|
+
var _mixpanel = _interopRequireDefault(require("./mixpanel"));
|
|
28
29
|
var _reactDevTools = _interopRequireDefault(require("./reactDevTools"));
|
|
29
30
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
30
31
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -47,5 +48,6 @@ function initializeApplication(_ref) {
|
|
|
47
48
|
if (!(skip !== null && skip !== void 0 && skip.i18n)) (0, _i18n["default"])(translationResources);
|
|
48
49
|
if (!(skip !== null && skip !== void 0 && skip.logger)) (0, _logger["default"])();
|
|
49
50
|
if (process.env.NODE_ENV === "production") (0, _reactDevTools["default"])();
|
|
51
|
+
(0, _mixpanel["default"])(skip);
|
|
50
52
|
}
|
|
51
53
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_useDisplayErrorPage","_interopRequireDefault","require","_axios","_globalProps","_i18n","_interopRequireWildcard","_logger","_reactDevTools","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof3","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","globalProps","exports","initializeApplication","_ref","translationResources","skip","initializeGlobalProps","window","_typeof2","axios","initializeAxios","i18n","initializeI18n","logger","initializeLogger","process","env","NODE_ENV","disableReactDevTools"],"sources":["../../../src/initializers/index.js"],"sourcesContent":["// TODO: kept for backward compatibility.\nimport useDisplayErrorPage from \"react-utils/useDisplayErrorPage\";\n\nimport initializeAxios from \"./axios\";\nimport initializeGlobalProps from \"./globalProps\";\nimport initializeI18n, { taxonomies } from \"./i18n\";\nimport initializeLogger from \"./logger\";\nimport disableReactDevTools from \"./reactDevTools\";\n\n// eslint-disable-next-line import/no-mutable-exports\nlet globalProps = {};\n\nexport { globalProps, useDisplayErrorPage, taxonomies };\n\nexport default function initializeApplication({ translationResources, skip }) {\n if (!skip?.globalProps) {\n initializeGlobalProps();\n // eslint-disable-next-line @bigbinary/neeto/no-globalProps-reassignment\n globalProps = window.globalProps;\n }\n\n if (typeof skip?.axios === \"object\" || !skip?.axios) {\n initializeAxios(skip?.axios);\n }\n\n if (!skip?.i18n) initializeI18n(translationResources);\n\n if (!skip?.logger) initializeLogger();\n\n if (process.env.NODE_ENV === \"production\") disableReactDevTools();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,IAAAA,oBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,YAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,KAAA,GAAAC,uBAAA,CAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,
|
|
1
|
+
{"version":3,"file":"index.js","names":["_useDisplayErrorPage","_interopRequireDefault","require","_axios","_globalProps","_i18n","_interopRequireWildcard","_logger","_mixpanel","_reactDevTools","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof3","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","globalProps","exports","initializeApplication","_ref","translationResources","skip","initializeGlobalProps","window","_typeof2","axios","initializeAxios","i18n","initializeI18n","logger","initializeLogger","process","env","NODE_ENV","disableReactDevTools","initializeMixpanel"],"sources":["../../../src/initializers/index.js"],"sourcesContent":["// TODO: kept for backward compatibility.\nimport useDisplayErrorPage from \"react-utils/useDisplayErrorPage\";\n\nimport initializeAxios from \"./axios\";\nimport initializeGlobalProps from \"./globalProps\";\nimport initializeI18n, { taxonomies } from \"./i18n\";\nimport initializeLogger from \"./logger\";\nimport initializeMixpanel from \"./mixpanel\";\nimport disableReactDevTools from \"./reactDevTools\";\n\n// eslint-disable-next-line import/no-mutable-exports\nlet globalProps = {};\n\nexport { globalProps, useDisplayErrorPage, taxonomies };\n\nexport default function initializeApplication({ translationResources, skip }) {\n if (!skip?.globalProps) {\n initializeGlobalProps();\n // eslint-disable-next-line @bigbinary/neeto/no-globalProps-reassignment\n globalProps = window.globalProps;\n }\n\n if (typeof skip?.axios === \"object\" || !skip?.axios) {\n initializeAxios(skip?.axios);\n }\n\n if (!skip?.i18n) initializeI18n(translationResources);\n\n if (!skip?.logger) initializeLogger();\n\n if (process.env.NODE_ENV === \"production\") disableReactDevTools();\n\n initializeMixpanel(skip);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,IAAAA,oBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,YAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,KAAA,GAAAC,uBAAA,CAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,SAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,cAAA,GAAAR,sBAAA,CAAAC,OAAA;AAAmD,SAAAQ,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAL,wBAAAS,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,aAAAE,QAAA,CAAAF,GAAA,yBAAAA,GAAA,uCAAAA,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBA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AAoB,CAAC;EAErD,IAAI,EAACC,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEQ,MAAM,GAAE,IAAAC,kBAAgB,GAAE;EAErC,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE,IAAAC,yBAAoB,GAAE;EAEjE,IAAAC,oBAAkB,EAACd,IAAI,CAAC;AAC1B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = initializeMixpanel;
|
|
8
|
+
var _mixpanelBrowser = _interopRequireDefault(require("mixpanel-browser"));
|
|
9
|
+
function initializeMixpanel(skip) {
|
|
10
|
+
var _globalProps$user, _globalProps$organiza;
|
|
11
|
+
var analyticsId = "".concat((_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.email, "-").concat((_globalProps$organiza = globalProps.organization) === null || _globalProps$organiza === void 0 ? void 0 : _globalProps$organiza.subdomain);
|
|
12
|
+
if (globalProps.mixpanelProjectToken && !(skip !== null && skip !== void 0 && skip.mixpanel)) {
|
|
13
|
+
var _globalProps$user2, _globalProps$organiza2;
|
|
14
|
+
_mixpanelBrowser["default"].init(globalProps.mixpanelProjectToken);
|
|
15
|
+
_mixpanelBrowser["default"].people.set({
|
|
16
|
+
user: (_globalProps$user2 = globalProps.user) === null || _globalProps$user2 === void 0 ? void 0 : _globalProps$user2.email,
|
|
17
|
+
subdomain: (_globalProps$organiza2 = globalProps.organization) === null || _globalProps$organiza2 === void 0 ? void 0 : _globalProps$organiza2.subdomain
|
|
18
|
+
});
|
|
19
|
+
_mixpanelBrowser["default"].identify(analyticsId);
|
|
20
|
+
} else {
|
|
21
|
+
/*
|
|
22
|
+
We need to initialize mixpanel with a bogus token in development and test environment to
|
|
23
|
+
prevent mixpanel library from throwing an error when we use mixpanel.track() method in react components.
|
|
24
|
+
*/
|
|
25
|
+
_mixpanelBrowser["default"].init("TEST_TOKEN");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=mixpanel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mixpanel.js","names":["_mixpanelBrowser","_interopRequireDefault","require","initializeMixpanel","skip","_globalProps$user","_globalProps$organiza","analyticsId","concat","globalProps","user","email","organization","subdomain","mixpanelProjectToken","mixpanel","_globalProps$user2","_globalProps$organiza2","init","people","set","identify"],"sources":["../../../src/initializers/mixpanel.js"],"sourcesContent":["import mixpanel from \"mixpanel-browser\";\n\nexport default function initializeMixpanel(skip) {\n const analyticsId = `${globalProps.user?.email}-${globalProps.organization?.subdomain}`;\n\n if (globalProps.mixpanelProjectToken && !skip?.mixpanel) {\n mixpanel.init(globalProps.mixpanelProjectToken);\n mixpanel.people.set({\n user: globalProps.user?.email,\n subdomain: globalProps.organization?.subdomain,\n });\n mixpanel.identify(analyticsId);\n } else {\n /*\n We need to initialize mixpanel with a bogus token in development and test environment to\n prevent mixpanel library from throwing an error when we use mixpanel.track() method in react components.\n */\n mixpanel.init(\"TEST_TOKEN\");\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEe,SAASC,kBAAkBA,CAACC,IAAI,EAAE;EAAA,IAAAC,iBAAA,EAAAC,qBAAA;EAC/C,IAAMC,WAAW,MAAAC,MAAA,EAAAH,iBAAA,GAAMI,WAAW,CAACC,IAAI,cAAAL,iBAAA,uBAAhBA,iBAAA,CAAkBM,KAAK,OAAAH,MAAA,EAAAF,qBAAA,GAAIG,WAAW,CAACG,YAAY,cAAAN,qBAAA,uBAAxBA,qBAAA,CAA0BO,SAAS,CAAE;EAEvF,IAAIJ,WAAW,CAACK,oBAAoB,IAAI,EAACV,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEW,QAAQ,GAAE;IAAA,IAAAC,kBAAA,EAAAC,sBAAA;IACvDF,2BAAQ,CAACG,IAAI,CAACT,WAAW,CAACK,oBAAoB,CAAC;IAC/CC,2BAAQ,CAACI,MAAM,CAACC,GAAG,CAAC;MAClBV,IAAI,GAAAM,kBAAA,GAAEP,WAAW,CAACC,IAAI,cAAAM,kBAAA,uBAAhBA,kBAAA,CAAkBL,KAAK;MAC7BE,SAAS,GAAAI,sBAAA,GAAER,WAAW,CAACG,YAAY,cAAAK,sBAAA,uBAAxBA,sBAAA,CAA0BJ;IACvC,CAAC,CAAC;IACFE,2BAAQ,CAACM,QAAQ,CAACd,WAAW,CAAC;EAChC,CAAC,MAAM;IACL;AACJ;AACA;AACA;IACIQ,2BAAQ,CAACG,IAAI,CAAC,YAAY,CAAC;EAC7B;AACF"}
|
package/cjs/utils/datetime.js
CHANGED
|
@@ -6,10 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.timeFormat = exports.dateFormat = void 0;
|
|
8
8
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
9
|
+
var _localizedFormat = _interopRequireDefault(require("dayjs/plugin/localizedFormat"));
|
|
9
10
|
var _relativeTime = _interopRequireDefault(require("dayjs/plugin/relativeTime"));
|
|
10
11
|
var _updateLocale = _interopRequireDefault(require("dayjs/plugin/updateLocale"));
|
|
12
|
+
/* eslint-disable @bigbinary/neeto/use-standard-date-time-formats */
|
|
13
|
+
|
|
11
14
|
_dayjs["default"].extend(_relativeTime["default"]);
|
|
12
15
|
_dayjs["default"].extend(_updateLocale["default"]);
|
|
16
|
+
_dayjs["default"].extend(_localizedFormat["default"]);
|
|
13
17
|
var getDefaultFormat = function getDefaultFormat() {
|
|
14
18
|
var _globalProps$user$dat, _globalProps, _globalProps$user;
|
|
15
19
|
return (_globalProps$user$dat = (_globalProps = globalProps) === null || _globalProps === void 0 ? void 0 : (_globalProps$user = _globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.dateFormat) !== null && _globalProps$user$dat !== void 0 ? _globalProps$user$dat : "DD/MM/YYYY";
|
|
@@ -19,19 +23,19 @@ var timeFormat = {
|
|
|
19
23
|
return (0, _dayjs["default"])(time).fromNow();
|
|
20
24
|
},
|
|
21
25
|
time: function time(_time) {
|
|
22
|
-
return (0, _dayjs["default"])(_time).format("
|
|
26
|
+
return (0, _dayjs["default"])(_time).format("LT");
|
|
23
27
|
},
|
|
24
28
|
timeWithSeconds: function timeWithSeconds(time) {
|
|
25
|
-
return (0, _dayjs["default"])(time).format("
|
|
29
|
+
return (0, _dayjs["default"])(time).format("LTS");
|
|
26
30
|
},
|
|
27
31
|
date: function date(time) {
|
|
28
|
-
return (0, _dayjs["default"])(time).format("
|
|
32
|
+
return (0, _dayjs["default"])(time).format("ll");
|
|
29
33
|
},
|
|
30
34
|
dateWeek: function dateWeek(time) {
|
|
31
|
-
return (0, _dayjs["default"])(time).format("
|
|
35
|
+
return (0, _dayjs["default"])(time).format("ll ddd");
|
|
32
36
|
},
|
|
33
37
|
dateWeekDayExtended: function dateWeekDayExtended(time) {
|
|
34
|
-
return (0, _dayjs["default"])(time).format("
|
|
38
|
+
return (0, _dayjs["default"])(time).format("ll dddd");
|
|
35
39
|
},
|
|
36
40
|
dateWeekWithoutYear: function dateWeekWithoutYear(time) {
|
|
37
41
|
return (0, _dayjs["default"])(time).format("MMM D, ddd");
|
|
@@ -40,19 +44,19 @@ var timeFormat = {
|
|
|
40
44
|
return (0, _dayjs["default"])(time).format("MMM D, dddd");
|
|
41
45
|
},
|
|
42
46
|
dateTime: function dateTime(time) {
|
|
43
|
-
return (0, _dayjs["default"])(time).format("
|
|
47
|
+
return (0, _dayjs["default"])(time).format("ll LT");
|
|
44
48
|
},
|
|
45
49
|
dateTimeWithSeconds: function dateTimeWithSeconds(time) {
|
|
46
|
-
return (0, _dayjs["default"])(time).format("
|
|
50
|
+
return (0, _dayjs["default"])(time).format("ll LTS");
|
|
47
51
|
},
|
|
48
52
|
dateWeekTime: function dateWeekTime(time) {
|
|
49
|
-
return (0, _dayjs["default"])(time).format("
|
|
53
|
+
return (0, _dayjs["default"])(time).format("ll ddd LT");
|
|
50
54
|
},
|
|
51
55
|
dateWeekTimeDayExtended: function dateWeekTimeDayExtended(time) {
|
|
52
|
-
return (0, _dayjs["default"])(time).format("
|
|
56
|
+
return (0, _dayjs["default"])(time).format("ll dddd LT");
|
|
53
57
|
},
|
|
54
58
|
extended: function extended(time) {
|
|
55
|
-
var dateTime = (0, _dayjs["default"])(time).format("dddd
|
|
59
|
+
var dateTime = (0, _dayjs["default"])(time).format("dddd LL LT");
|
|
56
60
|
var fromNow = (0, _dayjs["default"])(time).fromNow();
|
|
57
61
|
return "".concat(dateTime, " (").concat(fromNow, ")");
|
|
58
62
|
},
|
|
@@ -60,7 +64,7 @@ var timeFormat = {
|
|
|
60
64
|
return (0, _dayjs["default"])(time).format(getDefaultFormat());
|
|
61
65
|
},
|
|
62
66
|
defaultWithTime: function defaultWithTime(time) {
|
|
63
|
-
return (0, _dayjs["default"])(time).format("".concat(getDefaultFormat(), "
|
|
67
|
+
return (0, _dayjs["default"])(time).format("".concat(getDefaultFormat(), " LTS"));
|
|
64
68
|
}
|
|
65
69
|
};
|
|
66
70
|
exports.timeFormat = timeFormat;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datetime.js","names":["_dayjs","_interopRequireDefault","require","_relativeTime","_updateLocale","dayjs","extend","relativeTime","updateLocale","getDefaultFormat","_globalProps$user$dat","_globalProps","_globalProps$user","globalProps","user","dateFormat","timeFormat","fromNow","time","format","timeWithSeconds","date","dateWeek","dateWeekDayExtended","dateWeekWithoutYear","dateWeekWithoutYearDayExtended","dateTime","dateTimeWithSeconds","dateWeekTime","dateWeekTimeDayExtended","extended","concat","_default","defaultWithTime","exports"],"sources":["../../../src/utils/datetime.js"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"datetime.js","names":["_dayjs","_interopRequireDefault","require","_localizedFormat","_relativeTime","_updateLocale","dayjs","extend","relativeTime","updateLocale","localizedFormat","getDefaultFormat","_globalProps$user$dat","_globalProps","_globalProps$user","globalProps","user","dateFormat","timeFormat","fromNow","time","format","timeWithSeconds","date","dateWeek","dateWeekDayExtended","dateWeekWithoutYear","dateWeekWithoutYearDayExtended","dateTime","dateTimeWithSeconds","dateWeekTime","dateWeekTimeDayExtended","extended","concat","_default","defaultWithTime","exports"],"sources":["../../../src/utils/datetime.js"],"sourcesContent":["/* eslint-disable @bigbinary/neeto/use-standard-date-time-formats */\nimport dayjs from \"dayjs\";\nimport localizedFormat from \"dayjs/plugin/localizedFormat\";\nimport relativeTime from \"dayjs/plugin/relativeTime\";\nimport updateLocale from \"dayjs/plugin/updateLocale\";\n\ndayjs.extend(relativeTime);\ndayjs.extend(updateLocale);\ndayjs.extend(localizedFormat);\n\nconst getDefaultFormat = () => globalProps?.user?.dateFormat ?? \"DD/MM/YYYY\";\n\nexport const timeFormat = {\n fromNow: time => dayjs(time).fromNow(),\n time: time => dayjs(time).format(\"LT\"),\n timeWithSeconds: time => dayjs(time).format(\"LTS\"),\n date: time => dayjs(time).format(\"ll\"),\n dateWeek: time => dayjs(time).format(\"ll ddd\"),\n dateWeekDayExtended: time => dayjs(time).format(\"ll dddd\"),\n dateWeekWithoutYear: time => dayjs(time).format(\"MMM D, ddd\"),\n dateWeekWithoutYearDayExtended: time => dayjs(time).format(\"MMM D, dddd\"),\n dateTime: time => dayjs(time).format(\"ll LT\"),\n dateTimeWithSeconds: time => dayjs(time).format(\"ll LTS\"),\n dateWeekTime: time => dayjs(time).format(\"ll ddd LT\"),\n dateWeekTimeDayExtended: time => dayjs(time).format(\"ll dddd LT\"),\n extended: time => {\n const dateTime = dayjs(time).format(\"dddd LL LT\");\n const fromNow = dayjs(time).fromNow();\n\n return `${dateTime} (${fromNow})`;\n },\n default: time => dayjs(time).format(getDefaultFormat()),\n defaultWithTime: time => dayjs(time).format(`${getDefaultF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AAAe,SAAAd,IAAI;IAAA,OAAI,IAAAd,iBAAK,EAACc,IAAI,CAAC,CAACC,MAAM,CAACV,gBAAgB,EAAE,CAAC;EAAA;EACvDwB,eAAe,EAAE,SAAAA,gBAAAf,IAAI;IAAA,OAAI,IAAAd,iBAAK,EAACc,IAAI,CAAC,CAACC,MAAM,IAAAY,MAAA,CAAItB,gBAAgB,EAAE,UAAO;EAAA;AAC1E,CAAC;AAACyB,OAAA,CAAAlB,UAAA,GAAAA,UAAA;AAEK,IAAMD,UAAU,GAAGC,UAAU;AAACkB,OAAA,CAAAnB,UAAA,GAAAA,UAAA"}
|
package/initializers/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import initializeAxios from "./axios";
|
|
|
5
5
|
import initializeGlobalProps from "./globalProps";
|
|
6
6
|
import initializeI18n, { taxonomies } from "./i18n";
|
|
7
7
|
import initializeLogger from "./logger";
|
|
8
|
+
import initializeMixpanel from "./mixpanel";
|
|
8
9
|
import disableReactDevTools from "./reactDevTools";
|
|
9
10
|
|
|
10
11
|
// eslint-disable-next-line import/no-mutable-exports
|
|
@@ -24,5 +25,6 @@ export default function initializeApplication(_ref) {
|
|
|
24
25
|
if (!(skip !== null && skip !== void 0 && skip.i18n)) initializeI18n(translationResources);
|
|
25
26
|
if (!(skip !== null && skip !== void 0 && skip.logger)) initializeLogger();
|
|
26
27
|
if (process.env.NODE_ENV === "production") disableReactDevTools();
|
|
28
|
+
initializeMixpanel(skip);
|
|
27
29
|
}
|
|
28
30
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useDisplayErrorPage","initializeAxios","initializeGlobalProps","initializeI18n","taxonomies","initializeLogger","disableReactDevTools","globalProps","initializeApplication","_ref","translationResources","skip","window","_typeof","axios","i18n","logger","process","env","NODE_ENV"],"sources":["../../src/initializers/index.js"],"sourcesContent":["// TODO: kept for backward compatibility.\nimport useDisplayErrorPage from \"react-utils/useDisplayErrorPage\";\n\nimport initializeAxios from \"./axios\";\nimport initializeGlobalProps from \"./globalProps\";\nimport initializeI18n, { taxonomies } from \"./i18n\";\nimport initializeLogger from \"./logger\";\nimport disableReactDevTools from \"./reactDevTools\";\n\n// eslint-disable-next-line import/no-mutable-exports\nlet globalProps = {};\n\nexport { globalProps, useDisplayErrorPage, taxonomies };\n\nexport default function initializeApplication({ translationResources, skip }) {\n if (!skip?.globalProps) {\n initializeGlobalProps();\n // eslint-disable-next-line @bigbinary/neeto/no-globalProps-reassignment\n globalProps = window.globalProps;\n }\n\n if (typeof skip?.axios === \"object\" || !skip?.axios) {\n initializeAxios(skip?.axios);\n }\n\n if (!skip?.i18n) initializeI18n(translationResources);\n\n if (!skip?.logger) initializeLogger();\n\n if (process.env.NODE_ENV === \"production\") disableReactDevTools();\n}\n"],"mappings":";AAAA;AACA,OAAOA,mBAAmB;AAE1B,OAAOC,eAAe;AACtB,OAAOC,qBAAqB;AAC5B,OAAOC,cAAc,IAAIC,UAAU;AACnC,OAAOC,gBAAgB;AACvB,OAAOC,oBAAoB;;AAE3B;AACA,IAAIC,WAAW,GAAG,CAAC,CAAC;AAEpB,SAASA,WAAW,
|
|
1
|
+
{"version":3,"file":"index.js","names":["useDisplayErrorPage","initializeAxios","initializeGlobalProps","initializeI18n","taxonomies","initializeLogger","initializeMixpanel","disableReactDevTools","globalProps","initializeApplication","_ref","translationResources","skip","window","_typeof","axios","i18n","logger","process","env","NODE_ENV"],"sources":["../../src/initializers/index.js"],"sourcesContent":["// TODO: kept for backward compatibility.\nimport useDisplayErrorPage from \"react-utils/useDisplayErrorPage\";\n\nimport initializeAxios from \"./axios\";\nimport initializeGlobalProps from \"./globalProps\";\nimport initializeI18n, { taxonomies } from \"./i18n\";\nimport initializeLogger from \"./logger\";\nimport initializeMixpanel from \"./mixpanel\";\nimport disableReactDevTools from \"./reactDevTools\";\n\n// eslint-disable-next-line import/no-mutable-exports\nlet globalProps = {};\n\nexport { globalProps, useDisplayErrorPage, taxonomies };\n\nexport default function initializeApplication({ translationResources, skip }) {\n if (!skip?.globalProps) {\n initializeGlobalProps();\n // eslint-disable-next-line @bigbinary/neeto/no-globalProps-reassignment\n globalProps = window.globalProps;\n }\n\n if (typeof skip?.axios === \"object\" || !skip?.axios) {\n initializeAxios(skip?.axios);\n }\n\n if (!skip?.i18n) initializeI18n(translationResources);\n\n if (!skip?.logger) initializeLogger();\n\n if (process.env.NODE_ENV === \"production\") disableReactDevTools();\n\n initializeMixpanel(skip);\n}\n"],"mappings":";AAAA;AACA,OAAOA,mBAAmB;AAE1B,OAAOC,eAAe;AACtB,OAAOC,qBAAqB;AAC5B,OAAOC,cAAc,IAAIC,UAAU;AACnC,OAAOC,gBAAgB;AACvB,OAAOC,kBAAkB;AACzB,OAAOC,oBAAoB;;AAE3B;AACA,IAAIC,WAAW,GAAG,CAAC,CAAC;AAEpB,SAASA,WAAW,EAAER,mBAAmB,EAAEI,UAAU;AAErD,eAAe,SAASK,qBAAqBA,CAAAC,IAAA,EAAiC;EAAA,IAA9BC,oBAAoB,GAAAD,IAAA,CAApBC,oBAAoB;IAAEC,IAAI,GAAAF,IAAA,CAAJE,IAAI;EACxE,IAAI,EAACA,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEJ,WAAW,GAAE;IACtBN,qBAAqB,EAAE;IACvB;IACAM,WAAW,GAAGK,MAAM,CAACL,WAAW;EAClC;EAEA,IAAIM,OAAA,CAAOF,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEG,KAAK,MAAK,QAAQ,IAAI,EAACH,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEG,KAAK,GAAE;IACnDd,eAAe,CAACW,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEG,KAAK,CAAC;EAC9B;EAEA,IAAI,EAACH,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEI,IAAI,GAAEb,cAAc,CAACQ,oBAAoB,CAAC;EAErD,IAAI,EAACC,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEK,MAAM,GAAEZ,gBAAgB,EAAE;EAErC,IAAIa,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAEb,oBAAoB,EAAE;EAEjED,kBAAkB,CAACM,IAAI,CAAC;AAC1B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import mixpanel from "mixpanel-browser";
|
|
2
|
+
export default function initializeMixpanel(skip) {
|
|
3
|
+
var _globalProps$user, _globalProps$organiza;
|
|
4
|
+
var analyticsId = "".concat((_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.email, "-").concat((_globalProps$organiza = globalProps.organization) === null || _globalProps$organiza === void 0 ? void 0 : _globalProps$organiza.subdomain);
|
|
5
|
+
if (globalProps.mixpanelProjectToken && !(skip !== null && skip !== void 0 && skip.mixpanel)) {
|
|
6
|
+
var _globalProps$user2, _globalProps$organiza2;
|
|
7
|
+
mixpanel.init(globalProps.mixpanelProjectToken);
|
|
8
|
+
mixpanel.people.set({
|
|
9
|
+
user: (_globalProps$user2 = globalProps.user) === null || _globalProps$user2 === void 0 ? void 0 : _globalProps$user2.email,
|
|
10
|
+
subdomain: (_globalProps$organiza2 = globalProps.organization) === null || _globalProps$organiza2 === void 0 ? void 0 : _globalProps$organiza2.subdomain
|
|
11
|
+
});
|
|
12
|
+
mixpanel.identify(analyticsId);
|
|
13
|
+
} else {
|
|
14
|
+
/*
|
|
15
|
+
We need to initialize mixpanel with a bogus token in development and test environment to
|
|
16
|
+
prevent mixpanel library from throwing an error when we use mixpanel.track() method in react components.
|
|
17
|
+
*/
|
|
18
|
+
mixpanel.init("TEST_TOKEN");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=mixpanel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mixpanel.js","names":["mixpanel","initializeMixpanel","skip","_globalProps$user","_globalProps$organiza","analyticsId","concat","globalProps","user","email","organization","subdomain","mixpanelProjectToken","_globalProps$user2","_globalProps$organiza2","init","people","set","identify"],"sources":["../../src/initializers/mixpanel.js"],"sourcesContent":["import mixpanel from \"mixpanel-browser\";\n\nexport default function initializeMixpanel(skip) {\n const analyticsId = `${globalProps.user?.email}-${globalProps.organization?.subdomain}`;\n\n if (globalProps.mixpanelProjectToken && !skip?.mixpanel) {\n mixpanel.init(globalProps.mixpanelProjectToken);\n mixpanel.people.set({\n user: globalProps.user?.email,\n subdomain: globalProps.organization?.subdomain,\n });\n mixpanel.identify(analyticsId);\n } else {\n /*\n We need to initialize mixpanel with a bogus token in development and test environment to\n prevent mixpanel library from throwing an error when we use mixpanel.track() method in react components.\n */\n mixpanel.init(\"TEST_TOKEN\");\n }\n}\n"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,kBAAkB;AAEvC,eAAe,SAASC,kBAAkBA,CAACC,IAAI,EAAE;EAAA,IAAAC,iBAAA,EAAAC,qBAAA;EAC/C,IAAMC,WAAW,MAAAC,MAAA,EAAAH,iBAAA,GAAMI,WAAW,CAACC,IAAI,cAAAL,iBAAA,uBAAhBA,iBAAA,CAAkBM,KAAK,OAAAH,MAAA,EAAAF,qBAAA,GAAIG,WAAW,CAACG,YAAY,cAAAN,qBAAA,uBAAxBA,qBAAA,CAA0BO,SAAS,CAAE;EAEvF,IAAIJ,WAAW,CAACK,oBAAoB,IAAI,EAACV,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEF,QAAQ,GAAE;IAAA,IAAAa,kBAAA,EAAAC,sBAAA;IACvDd,QAAQ,CAACe,IAAI,CAACR,WAAW,CAACK,oBAAoB,CAAC;IAC/CZ,QAAQ,CAACgB,MAAM,CAACC,GAAG,CAAC;MAClBT,IAAI,GAAAK,kBAAA,GAAEN,WAAW,CAACC,IAAI,cAAAK,kBAAA,uBAAhBA,kBAAA,CAAkBJ,KAAK;MAC7BE,SAAS,GAAAG,sBAAA,GAAEP,WAAW,CAACG,YAAY,cAAAI,sBAAA,uBAAxBA,sBAAA,CAA0BH;IACvC,CAAC,CAAC;IACFX,QAAQ,CAACkB,QAAQ,CAACb,WAAW,CAAC;EAChC,CAAC,MAAM;IACL;AACJ;AACA;AACA;IACIL,QAAQ,CAACe,IAAI,CAAC,YAAY,CAAC;EAC7B;AACF"}
|
package/initializers.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ type Configurations = {
|
|
|
9
9
|
globalProps: boolean;
|
|
10
10
|
i18n: boolean;
|
|
11
11
|
logger: boolean;
|
|
12
|
+
mixpanel: boolean;
|
|
12
13
|
axios: Skippable<{
|
|
13
14
|
baseURL: boolean;
|
|
14
15
|
authHeaders: boolean;
|
|
@@ -48,6 +49,7 @@ type GlobalPropsType = {
|
|
|
48
49
|
[key: string]: any;
|
|
49
50
|
};
|
|
50
51
|
authenticated: boolean;
|
|
52
|
+
mixpanelProjectToken: string;
|
|
51
53
|
permissions: string[];
|
|
52
54
|
endUserUploadedFileSizeLimitInMb: number;
|
|
53
55
|
[key: string]: any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigbinary/neeto-commons-frontend",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.8",
|
|
4
4
|
"description": "A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.",
|
|
5
5
|
"repository": "git@github.com:bigbinary/neeto-commons-frontend.git",
|
|
6
6
|
"author": "Amaljith K <amaljith.k@bigbinary.com>",
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
"dompurify": "3.0.3",
|
|
65
65
|
"i18next-browser-languagedetector": "^7.1.0",
|
|
66
66
|
"immer": "^10.0.2",
|
|
67
|
+
"mixpanel-browser": "^2.50.0",
|
|
67
68
|
"platform": "1.3.6",
|
|
68
69
|
"qs": "^6.11.0",
|
|
69
70
|
"util": "^0.12.5",
|
package/utils/datetime.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
/* eslint-disable @bigbinary/neeto/use-standard-date-time-formats */
|
|
1
2
|
import dayjs from "dayjs";
|
|
3
|
+
import localizedFormat from "dayjs/plugin/localizedFormat";
|
|
2
4
|
import relativeTime from "dayjs/plugin/relativeTime";
|
|
3
5
|
import updateLocale from "dayjs/plugin/updateLocale";
|
|
4
6
|
dayjs.extend(relativeTime);
|
|
5
7
|
dayjs.extend(updateLocale);
|
|
8
|
+
dayjs.extend(localizedFormat);
|
|
6
9
|
var getDefaultFormat = function getDefaultFormat() {
|
|
7
10
|
var _globalProps$user$dat, _globalProps, _globalProps$user;
|
|
8
11
|
return (_globalProps$user$dat = (_globalProps = globalProps) === null || _globalProps === void 0 ? void 0 : (_globalProps$user = _globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.dateFormat) !== null && _globalProps$user$dat !== void 0 ? _globalProps$user$dat : "DD/MM/YYYY";
|
|
@@ -12,19 +15,19 @@ export var timeFormat = {
|
|
|
12
15
|
return dayjs(time).fromNow();
|
|
13
16
|
},
|
|
14
17
|
time: function time(_time) {
|
|
15
|
-
return dayjs(_time).format("
|
|
18
|
+
return dayjs(_time).format("LT");
|
|
16
19
|
},
|
|
17
20
|
timeWithSeconds: function timeWithSeconds(time) {
|
|
18
|
-
return dayjs(time).format("
|
|
21
|
+
return dayjs(time).format("LTS");
|
|
19
22
|
},
|
|
20
23
|
date: function date(time) {
|
|
21
|
-
return dayjs(time).format("
|
|
24
|
+
return dayjs(time).format("ll");
|
|
22
25
|
},
|
|
23
26
|
dateWeek: function dateWeek(time) {
|
|
24
|
-
return dayjs(time).format("
|
|
27
|
+
return dayjs(time).format("ll ddd");
|
|
25
28
|
},
|
|
26
29
|
dateWeekDayExtended: function dateWeekDayExtended(time) {
|
|
27
|
-
return dayjs(time).format("
|
|
30
|
+
return dayjs(time).format("ll dddd");
|
|
28
31
|
},
|
|
29
32
|
dateWeekWithoutYear: function dateWeekWithoutYear(time) {
|
|
30
33
|
return dayjs(time).format("MMM D, ddd");
|
|
@@ -33,19 +36,19 @@ export var timeFormat = {
|
|
|
33
36
|
return dayjs(time).format("MMM D, dddd");
|
|
34
37
|
},
|
|
35
38
|
dateTime: function dateTime(time) {
|
|
36
|
-
return dayjs(time).format("
|
|
39
|
+
return dayjs(time).format("ll LT");
|
|
37
40
|
},
|
|
38
41
|
dateTimeWithSeconds: function dateTimeWithSeconds(time) {
|
|
39
|
-
return dayjs(time).format("
|
|
42
|
+
return dayjs(time).format("ll LTS");
|
|
40
43
|
},
|
|
41
44
|
dateWeekTime: function dateWeekTime(time) {
|
|
42
|
-
return dayjs(time).format("
|
|
45
|
+
return dayjs(time).format("ll ddd LT");
|
|
43
46
|
},
|
|
44
47
|
dateWeekTimeDayExtended: function dateWeekTimeDayExtended(time) {
|
|
45
|
-
return dayjs(time).format("
|
|
48
|
+
return dayjs(time).format("ll dddd LT");
|
|
46
49
|
},
|
|
47
50
|
extended: function extended(time) {
|
|
48
|
-
var dateTime = dayjs(time).format("dddd
|
|
51
|
+
var dateTime = dayjs(time).format("dddd LL LT");
|
|
49
52
|
var fromNow = dayjs(time).fromNow();
|
|
50
53
|
return "".concat(dateTime, " (").concat(fromNow, ")");
|
|
51
54
|
},
|
|
@@ -53,7 +56,7 @@ export var timeFormat = {
|
|
|
53
56
|
return dayjs(time).format(getDefaultFormat());
|
|
54
57
|
},
|
|
55
58
|
defaultWithTime: function defaultWithTime(time) {
|
|
56
|
-
return dayjs(time).format("".concat(getDefaultFormat(), "
|
|
59
|
+
return dayjs(time).format("".concat(getDefaultFormat(), " LTS"));
|
|
57
60
|
}
|
|
58
61
|
};
|
|
59
62
|
export var dateFormat = timeFormat;
|
package/utils/datetime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datetime.js","names":["dayjs","relativeTime","updateLocale","extend","getDefaultFormat","_globalProps$user$dat","_globalProps","_globalProps$user","globalProps","user","dateFormat","timeFormat","fromNow","time","format","timeWithSeconds","date","dateWeek","dateWeekDayExtended","dateWeekWithoutYear","dateWeekWithoutYearDayExtended","dateTime","dateTimeWithSeconds","dateWeekTime","dateWeekTimeDayExtended","extended","concat","_default","defaultWithTime"],"sources":["../../src/utils/datetime.js"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"datetime.js","names":["dayjs","localizedFormat","relativeTime","updateLocale","extend","getDefaultFormat","_globalProps$user$dat","_globalProps","_globalProps$user","globalProps","user","dateFormat","timeFormat","fromNow","time","format","timeWithSeconds","date","dateWeek","dateWeekDayExtended","dateWeekWithoutYear","dateWeekWithoutYearDayExtended","dateTime","dateTimeWithSeconds","dateWeekTime","dateWeekTimeDayExtended","extended","concat","_default","defaultWithTime"],"sources":["../../src/utils/datetime.js"],"sourcesContent":["/* eslint-disable @bigbinary/neeto/use-standard-date-time-formats */\nimport dayjs from \"dayjs\";\nimport localizedFormat from \"dayjs/plugin/localizedFormat\";\nimport relativeTime from \"dayjs/plugin/relativeTime\";\nimport updateLocale from \"dayjs/plugin/updateLocale\";\n\ndayjs.extend(relativeTime);\ndayjs.extend(updateLocale);\ndayjs.extend(localizedFormat);\n\nconst getDefaultFormat = () => globalProps?.user?.dateFormat ?? \"DD/MM/YYYY\";\n\nexport const timeFormat = {\n fromNow: time => dayjs(time).fromNow(),\n time: time => dayjs(time).format(\"LT\"),\n timeWithSeconds: time => dayjs(time).format(\"LTS\"),\n date: time => dayjs(time).format(\"ll\"),\n dateWeek: time => dayjs(time).format(\"ll ddd\"),\n dateWeekDayExtended: time => dayjs(time).format(\"ll dddd\"),\n dateWeekWithoutYear: time => dayjs(time).format(\"MMM D, ddd\"),\n dateWeekWithoutYearDayExtended: time => dayjs(time).format(\"MMM D, dddd\"),\n dateTime: time => dayjs(time).format(\"ll LT\"),\n dateTimeWithSeconds: time => dayjs(time).format(\"ll LTS\"),\n dateWeekTime: time => dayjs(time).format(\"ll ddd LT\"),\n dateWeekTimeDayExtended: time => dayjs(time).format(\"ll dddd LT\"),\n extended: time => {\n const dateTime = dayjs(time).format(\"dddd LL LT\");\n const fromNow = dayjs(time).fromNow();\n\n return `${dateTime} (${fromNow})`;\n },\n default: time => dayjs(time).format(getDefaultFormat()),\n defaultWithTime: time => dayjs(time).format(`${getDefaultFormat()} LTS`),\n};\n\nexport const dateFormat = timeFormat;\n"],"mappings":"AAAA;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,eAAe,MAAM,8BAA8B;AAC1D,OAAOC,YAAY,MAAM,2BAA2B;AACpD,OAAOC,YAAY,MAAM,2BAA2B;AAEpDH,KAAK,CAACI,MAAM,CAACF,YAAY,CAAC;AAC1BF,KAAK,CAACI,MAAM,CAACD,YAAY,CAAC;AAC1BH,KAAK,CAACI,MAAM,CAACH,eAAe,CAAC;AAE7B,IAAMI,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAA;EAAA,IAAAC,qBAAA,EAAAC,YAAA,EAAAC,iBAAA;EAAA,QAAAF,qBAAA,IAAAC,YAAA,GAASE,WAAW,cAAAF,YAAA,wBAAAC,iBAAA,GAAXD,YAAA,CAAaG,IAAI,cAAAF,iBAAA,uBAAjBA,iBAAA,CAAmBG,UAAU,cAAAL,qBAAA,cAAAA,qBAAA,GAAI,YAAY;AAAA;AAE5E,OAAO,IAAMM,UAAU,GAAG;EACxBC,OAAO,EAAE,SAAAA,QAAAC,IAAI;IAAA,OAAId,KAAK,CAACc,IAAI,CAAC,CAACD,OAAO,EAAE;EAAA;EACtCC,IAAI,EAAE,SAAAA,UAAI;IAAA,OAAId,KAAK,CAACc,KAAI,CAAC,CAACC,MAAM,CAAC,IAAI,CAAC;EAAA;EACtCC,eAAe,EAAE,SAAAA,gBAAAF,IAAI;IAAA,OAAId,KAAK,CAACc,IAAI,CAAC,CAACC,MAAM,CAAC,KAAK,CAAC;EAAA;EAClDE,IAAI,EAAE,SAAAA,KAAAH,IAAI;IAAA,OAAId,KAAK,CAACc,IAAI,CAAC,CAACC,MAAM,CAAC,IAAI,CAAC;EAAA;EACtCG,QAAQ,EAAE,SAAAA,SAAAJ,IAAI;IAAA,OAAId,KAAK,CAACc,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