@bigbinary/neeto-molecules 0.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 (183) hide show
  1. package/README.md +60 -0
  2. package/dist/BrowserSupport.cjs.js +1727 -0
  3. package/dist/BrowserSupport.cjs.js.map +1 -0
  4. package/dist/BrowserSupport.js +1721 -0
  5. package/dist/BrowserSupport.js.map +1 -0
  6. package/dist/Columns.cjs.js +191 -0
  7. package/dist/Columns.cjs.js.map +1 -0
  8. package/dist/Columns.js +184 -0
  9. package/dist/Columns.js.map +1 -0
  10. package/dist/Container.cjs.js +1277 -0
  11. package/dist/Container.cjs.js.map +1 -0
  12. package/dist/Container.js +1271 -0
  13. package/dist/Container.js.map +1 -0
  14. package/dist/CopyToClipboardButton.cjs.js +78 -0
  15. package/dist/CopyToClipboardButton.cjs.js.map +1 -0
  16. package/dist/CopyToClipboardButton.js +72 -0
  17. package/dist/CopyToClipboardButton.js.map +1 -0
  18. package/dist/CustomDomain.cjs.js +680 -0
  19. package/dist/CustomDomain.cjs.js.map +1 -0
  20. package/dist/CustomDomain.js +654 -0
  21. package/dist/CustomDomain.js.map +1 -0
  22. package/dist/CustomDomainDashboard.cjs.js +2306 -0
  23. package/dist/CustomDomainDashboard.cjs.js.map +1 -0
  24. package/dist/CustomDomainDashboard.js +2279 -0
  25. package/dist/CustomDomainDashboard.js.map +1 -0
  26. package/dist/DateFormat.cjs.js +51 -0
  27. package/dist/DateFormat.cjs.js.map +1 -0
  28. package/dist/DateFormat.js +45 -0
  29. package/dist/DateFormat.js.map +1 -0
  30. package/dist/DateRangeFilter.cjs.js +236 -0
  31. package/dist/DateRangeFilter.cjs.js.map +1 -0
  32. package/dist/DateRangeFilter.js +229 -0
  33. package/dist/DateRangeFilter.js.map +1 -0
  34. package/dist/DynamicVariables.cjs.js +112 -0
  35. package/dist/DynamicVariables.cjs.js.map +1 -0
  36. package/dist/DynamicVariables.js +106 -0
  37. package/dist/DynamicVariables.js.map +1 -0
  38. package/dist/EmailPreview.cjs.js +102 -0
  39. package/dist/EmailPreview.cjs.js.map +1 -0
  40. package/dist/EmailPreview.js +96 -0
  41. package/dist/EmailPreview.js.map +1 -0
  42. package/dist/ErrorPage.cjs.js +208 -0
  43. package/dist/ErrorPage.cjs.js.map +1 -0
  44. package/dist/ErrorPage.js +184 -0
  45. package/dist/ErrorPage.js.map +1 -0
  46. package/dist/Header.cjs.js +219 -0
  47. package/dist/Header.cjs.js.map +1 -0
  48. package/dist/Header.js +213 -0
  49. package/dist/Header.js.map +1 -0
  50. package/dist/IconPicker.cjs.js +1307 -0
  51. package/dist/IconPicker.cjs.js.map +1 -0
  52. package/dist/IconPicker.js +1301 -0
  53. package/dist/IconPicker.js.map +1 -0
  54. package/dist/IntegrationCard.cjs.js +75 -0
  55. package/dist/IntegrationCard.cjs.js.map +1 -0
  56. package/dist/IntegrationCard.js +69 -0
  57. package/dist/IntegrationCard.js.map +1 -0
  58. package/dist/IntegrationDisconnectAlert.cjs.js +81 -0
  59. package/dist/IntegrationDisconnectAlert.cjs.js.map +1 -0
  60. package/dist/IntegrationDisconnectAlert.js +75 -0
  61. package/dist/IntegrationDisconnectAlert.js.map +1 -0
  62. package/dist/IntegrationWalkthroughModal.cjs.js +42 -0
  63. package/dist/IntegrationWalkthroughModal.cjs.js.map +1 -0
  64. package/dist/IntegrationWalkthroughModal.js +36 -0
  65. package/dist/IntegrationWalkthroughModal.js.map +1 -0
  66. package/dist/IpRestriction.cjs.js +3764 -0
  67. package/dist/IpRestriction.cjs.js.map +1 -0
  68. package/dist/IpRestriction.js +3738 -0
  69. package/dist/IpRestriction.js.map +1 -0
  70. package/dist/KeyboardShortcuts.cjs.js +2242 -0
  71. package/dist/KeyboardShortcuts.cjs.js.map +1 -0
  72. package/dist/KeyboardShortcuts.js +2235 -0
  73. package/dist/KeyboardShortcuts.js.map +1 -0
  74. package/dist/LoginPage.cjs.js +618 -0
  75. package/dist/LoginPage.cjs.js.map +1 -0
  76. package/dist/LoginPage.js +593 -0
  77. package/dist/LoginPage.js.map +1 -0
  78. package/dist/MenuBar.cjs.js +31044 -0
  79. package/dist/MenuBar.cjs.js.map +1 -0
  80. package/dist/MenuBar.js +31038 -0
  81. package/dist/MenuBar.js.map +1 -0
  82. package/dist/NeetoWidget.cjs.js +3369 -0
  83. package/dist/NeetoWidget.cjs.js.map +1 -0
  84. package/dist/NeetoWidget.js +3343 -0
  85. package/dist/NeetoWidget.js.map +1 -0
  86. package/dist/PageLoader.cjs.js +158 -0
  87. package/dist/PageLoader.cjs.js.map +1 -0
  88. package/dist/PageLoader.js +134 -0
  89. package/dist/PageLoader.js.map +1 -0
  90. package/dist/PhoneNumber.cjs.js +7021 -0
  91. package/dist/PhoneNumber.cjs.js.map +1 -0
  92. package/dist/PhoneNumber.js +6989 -0
  93. package/dist/PhoneNumber.js.map +1 -0
  94. package/dist/PublishBlock.cjs.js +189 -0
  95. package/dist/PublishBlock.cjs.js.map +1 -0
  96. package/dist/PublishBlock.js +183 -0
  97. package/dist/PublishBlock.js.map +1 -0
  98. package/dist/Rename.cjs.js +306 -0
  99. package/dist/Rename.cjs.js.map +1 -0
  100. package/dist/Rename.js +300 -0
  101. package/dist/Rename.js.map +1 -0
  102. package/dist/ResponsiveDevicePicker.cjs.js +260 -0
  103. package/dist/ResponsiveDevicePicker.cjs.js.map +1 -0
  104. package/dist/ResponsiveDevicePicker.js +254 -0
  105. package/dist/ResponsiveDevicePicker.js.map +1 -0
  106. package/dist/Schedule.cjs.js +952 -0
  107. package/dist/Schedule.cjs.js.map +1 -0
  108. package/dist/Schedule.js +921 -0
  109. package/dist/Schedule.js.map +1 -0
  110. package/dist/Scrollable.cjs.js +184 -0
  111. package/dist/Scrollable.cjs.js.map +1 -0
  112. package/dist/Scrollable.js +178 -0
  113. package/dist/Scrollable.js.map +1 -0
  114. package/dist/ShareViaEmail.cjs.js +2992 -0
  115. package/dist/ShareViaEmail.cjs.js.map +1 -0
  116. package/dist/ShareViaEmail.js +2966 -0
  117. package/dist/ShareViaEmail.js.map +1 -0
  118. package/dist/ShareViaLink.cjs.js +1385 -0
  119. package/dist/ShareViaLink.cjs.js.map +1 -0
  120. package/dist/ShareViaLink.js +1360 -0
  121. package/dist/ShareViaLink.js.map +1 -0
  122. package/dist/Sidebar.cjs.js +32222 -0
  123. package/dist/Sidebar.cjs.js.map +1 -0
  124. package/dist/Sidebar.js +32196 -0
  125. package/dist/Sidebar.js.map +1 -0
  126. package/dist/SubHeader.cjs.js +272 -0
  127. package/dist/SubHeader.cjs.js.map +1 -0
  128. package/dist/SubHeader.js +265 -0
  129. package/dist/SubHeader.js.map +1 -0
  130. package/dist/TableWrapper.cjs.js +87 -0
  131. package/dist/TableWrapper.cjs.js.map +1 -0
  132. package/dist/TableWrapper.js +81 -0
  133. package/dist/TableWrapper.js.map +1 -0
  134. package/dist/ThemeSidebar.cjs.js +13618 -0
  135. package/dist/ThemeSidebar.cjs.js.map +1 -0
  136. package/dist/ThemeSidebar.js +13593 -0
  137. package/dist/ThemeSidebar.js.map +1 -0
  138. package/dist/TimeFormat.cjs.js +53 -0
  139. package/dist/TimeFormat.cjs.js.map +1 -0
  140. package/dist/TimeFormat.js +47 -0
  141. package/dist/TimeFormat.js.map +1 -0
  142. package/dist/TimezoneMismatchModal.cjs.js +176 -0
  143. package/dist/TimezoneMismatchModal.cjs.js.map +1 -0
  144. package/dist/TimezoneMismatchModal.js +168 -0
  145. package/dist/TimezoneMismatchModal.js.map +1 -0
  146. package/package.json +185 -0
  147. package/src/translations/en.json +449 -0
  148. package/types/BrowserSupport.d.ts +86 -0
  149. package/types/Columns.d.ts +53 -0
  150. package/types/Container.d.ts +35 -0
  151. package/types/CopyToClipboardButton.d.ts +21 -0
  152. package/types/CustomDomain.d.ts +19 -0
  153. package/types/CustomDomainDashboard.d.ts +33 -0
  154. package/types/DateFormat.d.ts +18 -0
  155. package/types/DateRangeFilter.d.ts +52 -0
  156. package/types/DynamicVariables.d.ts +45 -0
  157. package/types/EmailPreview.d.ts +41 -0
  158. package/types/ErrorPage.d.ts +15 -0
  159. package/types/Header.d.ts +30 -0
  160. package/types/IconPicker.d.ts +43 -0
  161. package/types/IntegrationCard.d.ts +45 -0
  162. package/types/IntegrationDisconnectAlert.d.ts +37 -0
  163. package/types/IntegrationWalkthroughModal.d.ts +31 -0
  164. package/types/IpRestriction.d.ts +23 -0
  165. package/types/KeyboardShortcuts.d.ts +147 -0
  166. package/types/LoginPage.d.ts +43 -0
  167. package/types/MenuBar.d.ts +125 -0
  168. package/types/NeetoWidget.d.ts +41 -0
  169. package/types/PageLoader.d.ts +38 -0
  170. package/types/PhoneNumber.d.ts +106 -0
  171. package/types/PublishBlock.d.ts +84 -0
  172. package/types/Rename.d.ts +60 -0
  173. package/types/ResponsiveDevicePicker.d.ts +30 -0
  174. package/types/Schedule.d.ts +132 -0
  175. package/types/Scrollable.d.ts +28 -0
  176. package/types/ShareViaEmail.d.ts +99 -0
  177. package/types/ShareViaLink.d.ts +117 -0
  178. package/types/Sidebar.d.ts +63 -0
  179. package/types/SubHeader.d.ts +97 -0
  180. package/types/TableWrapper.d.ts +38 -0
  181. package/types/TimeFormat.d.ts +17 -0
  182. package/types/TimezoneMismatchModal.d.ts +39 -0
  183. package/types/themeSidebar.d.ts +80 -0
@@ -0,0 +1,3369 @@
1
+ 'use strict';
2
+
3
+ var ramda = require('ramda');
4
+ var React = require('react');
5
+ var neetoIcons = require('@bigbinary/neeto-icons');
6
+ var neetoui = require('@bigbinary/neetoui');
7
+ var reactI18next = require('react-i18next');
8
+ var reactQuery = require('react-query');
9
+ var pure = require('@bigbinary/neeto-commons-frontend/pure');
10
+ var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
11
+ var utils = require('@bigbinary/neeto-commons-frontend/utils');
12
+ var formik = require('formik');
13
+ var formik$1 = require('@bigbinary/neetoui/formik');
14
+ var i18next = require('i18next');
15
+ var yup = require('yup');
16
+
17
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
18
+
19
+ function _interopNamespace(e) {
20
+ if (e && e.__esModule) return e;
21
+ var n = Object.create(null);
22
+ if (e) {
23
+ Object.keys(e).forEach(function (k) {
24
+ if (k !== 'default') {
25
+ var d = Object.getOwnPropertyDescriptor(e, k);
26
+ Object.defineProperty(n, k, d.get ? d : {
27
+ enumerable: true,
28
+ get: function () { return e[k]; }
29
+ });
30
+ }
31
+ });
32
+ }
33
+ n["default"] = e;
34
+ return Object.freeze(n);
35
+ }
36
+
37
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
38
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
39
+ var i18next__default = /*#__PURE__*/_interopDefaultLegacy(i18next);
40
+ var yup__namespace = /*#__PURE__*/_interopNamespace(yup);
41
+
42
+ function _typeof$1(obj) {
43
+ "@babel/helpers - typeof";
44
+
45
+ return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
46
+ return typeof obj;
47
+ } : function (obj) {
48
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
49
+ }, _typeof$1(obj);
50
+ }
51
+
52
+ function _toPrimitive(input, hint) {
53
+ if (_typeof$1(input) !== "object" || input === null) return input;
54
+ var prim = input[Symbol.toPrimitive];
55
+ if (prim !== undefined) {
56
+ var res = prim.call(input, hint || "default");
57
+ if (_typeof$1(res) !== "object") return res;
58
+ throw new TypeError("@@toPrimitive must return a primitive value.");
59
+ }
60
+ return (hint === "string" ? String : Number)(input);
61
+ }
62
+
63
+ function _toPropertyKey(arg) {
64
+ var key = _toPrimitive(arg, "string");
65
+ return _typeof$1(key) === "symbol" ? key : String(key);
66
+ }
67
+
68
+ function _defineProperty(obj, key, value) {
69
+ key = _toPropertyKey(key);
70
+ if (key in obj) {
71
+ Object.defineProperty(obj, key, {
72
+ value: value,
73
+ enumerable: true,
74
+ configurable: true,
75
+ writable: true
76
+ });
77
+ } else {
78
+ obj[key] = value;
79
+ }
80
+ return obj;
81
+ }
82
+
83
+ var _SAMPLE_USER_IDENTITY;
84
+ var NEETO_WIDGET_USER_IDENTITY_KEY = "NeetoWidgetUserIdentity";
85
+ var SESSION_CONTEXT_KEY = "NeetoReplayWidgetSessionContext";
86
+ var INSTALLATION_HELP_EMAIL = "support@neeto.com";
87
+ var SAMPLE_CONTEXT_CODE_STRING = "window.".concat(SESSION_CONTEXT_KEY, " = {\n key1: \"value\",\n key2: [\"array\", \"of\", \"values\"],\n /* More key-value pairs */\n}");
88
+ var WIDGET_TYPES = {
89
+ changelog: "changelog",
90
+ chat: "chat",
91
+ replay: "replay"
92
+ };
93
+ var WIDGET_TYPES_VALUES = ramda.values(WIDGET_TYPES);
94
+ var QUERY_KEYS = {
95
+ apiKey: "neetoWidgetApiKey",
96
+ configuration: "neetoWidgetConfiguration"
97
+ };
98
+ var DEFAULT_QUERY_STALE_TIME = 60 * 60 * 1000; // 1 hour in milliseconds
99
+
100
+ var EMAIL_TYPES = {
101
+ embedCode: "embedCode",
102
+ userIdentity: "userIdentity",
103
+ sessionContext: "sessionContext",
104
+ "null": ""
105
+ };
106
+ var RAILS_ENV = {
107
+ production: "production",
108
+ staging: "staging",
109
+ development: "development"
110
+ };
111
+ var NEETO_WIDGET_SCRIPT_URL = {
112
+ staging: "https://d13nryxs46eypn.cloudfront.net/neeto-widget-staging.js",
113
+ production: "https://d13nryxs46eypn.cloudfront.net/neeto-widget.js"
114
+ };
115
+ var AVAILABLE_FRAMEWORK_OPTIONS = Object.freeze({
116
+ rails: "rails",
117
+ django: "django",
118
+ php: "php"
119
+ });
120
+ var FRAMEWORK_SELECT_OPTIONS = [{
121
+ label: "Ruby(Rails)",
122
+ value: AVAILABLE_FRAMEWORK_OPTIONS.rails
123
+ }, {
124
+ label: "Python(Django)",
125
+ value: AVAILABLE_FRAMEWORK_OPTIONS.django
126
+ }, {
127
+ label: "PHP",
128
+ value: AVAILABLE_FRAMEWORK_OPTIONS.php
129
+ }];
130
+ var SAMPLE_USER_IDENTITY_CODE_STRING = (_SAMPLE_USER_IDENTITY = {}, _defineProperty(_SAMPLE_USER_IDENTITY, AVAILABLE_FRAMEWORK_OPTIONS.rails, "window.".concat(NEETO_WIDGET_USER_IDENTITY_KEY, " = {\n user_identifier: \"<%= current_user.id %>\", // User identifier\"\n name: \"<%= current_user.name %>\", // Full name\n email: \"<%= current_user.email %>\", // Email address\n started_at: \"<%= current_user.created_at.to_i %>\" // Signup date as a Unix timestamp ,\n}")), _defineProperty(_SAMPLE_USER_IDENTITY, AVAILABLE_FRAMEWORK_OPTIONS.django, "window.".concat(NEETO_WIDGET_USER_IDENTITY_KEY, " = {\n user_identifier: \"{{ request.user.id|escapejs }}\", // User identifier\n name: \"{{ request.user.name|escapejs }}\", // Full name\n email: \"{{ request.user.email|escapejs }}\", // Email address\n started_at: \"{{ request.user.created_at|date:'U' }}\" // Signup date as a Unix timestamp\"\n}")), _defineProperty(_SAMPLE_USER_IDENTITY, AVAILABLE_FRAMEWORK_OPTIONS.php, "window.".concat(NEETO_WIDGET_USER_IDENTITY_KEY, " = {\n user_identifier: <?php echo json_encode($current_user->id) ?>, // User identifier\n name: <?php echo json_encode($current_user->name) ?>, // Full name\n email: <?php echo json_encode($current_user->email) ?>, // Email address\n started_at: <?php echo strtotime($current_user->created_at) ?> // Signup date as a Unix timestamp\" ,\n}")), _SAMPLE_USER_IDENTITY);
131
+ var WIDGET_CONFIG_URL = "api/widget/v1/neeto_widget_tokens";
132
+ var EMBED_CODE_EMAIL_URL = "api/widget/v1/email_snippets";
133
+ var CHAT_WIDGET_KB_BASE_URL = "https://help.neetochat.com";
134
+ var CHANGELOG_WIDGET_KB_BASE_URL = "https://help.neetochangelog.com";
135
+ var REPLAY_WIDGET_KB_BASE_URL = "https://help.neetoreplay.com";
136
+ var NEETO_REPLAY_CONFIGURE_URL = "".concat(REPLAY_WIDGET_KB_BASE_URL, "/articles/configure-widget");
137
+ var NEETO_CHAT_USER_IDENTITY_URL = "".concat(CHAT_WIDGET_KB_BASE_URL, "/articles/info-about-logged-in-users");
138
+ var WIDGET_KB_HELP_URL = {
139
+ changelog: "".concat(CHANGELOG_WIDGET_KB_BASE_URL, "/categories/widget-installation-usage"),
140
+ chat: "".concat(CHAT_WIDGET_KB_BASE_URL, "/categories/installation"),
141
+ replay: "".concat(REPLAY_WIDGET_KB_BASE_URL, "/categories/widget-installation-usage")
142
+ };
143
+
144
+ function _extends$1() {
145
+ _extends$1 = Object.assign ? Object.assign.bind() : function (target) {
146
+ for (var i = 1; i < arguments.length; i++) {
147
+ var source = arguments[i];
148
+ for (var key in source) {
149
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
150
+ target[key] = source[key];
151
+ }
152
+ }
153
+ }
154
+ return target;
155
+ };
156
+ return _extends$1.apply(this, arguments);
157
+ }
158
+
159
+ function _arrayWithHoles(arr) {
160
+ if (Array.isArray(arr)) return arr;
161
+ }
162
+
163
+ function _iterableToArrayLimit(arr, i) {
164
+ var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
165
+ if (null != _i) {
166
+ var _s,
167
+ _e,
168
+ _x,
169
+ _r,
170
+ _arr = [],
171
+ _n = !0,
172
+ _d = !1;
173
+ try {
174
+ if (_x = (_i = _i.call(arr)).next, 0 === i) {
175
+ if (Object(_i) !== _i) return;
176
+ _n = !1;
177
+ } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
178
+ } catch (err) {
179
+ _d = !0, _e = err;
180
+ } finally {
181
+ try {
182
+ if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
183
+ } finally {
184
+ if (_d) throw _e;
185
+ }
186
+ }
187
+ return _arr;
188
+ }
189
+ }
190
+
191
+ function _arrayLikeToArray(arr, len) {
192
+ if (len == null || len > arr.length) len = arr.length;
193
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
194
+ return arr2;
195
+ }
196
+
197
+ function _unsupportedIterableToArray(o, minLen) {
198
+ if (!o) return;
199
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
200
+ var n = Object.prototype.toString.call(o).slice(8, -1);
201
+ if (n === "Object" && o.constructor) n = o.constructor.name;
202
+ if (n === "Map" || n === "Set") return Array.from(o);
203
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
204
+ }
205
+
206
+ function _nonIterableRest() {
207
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
208
+ }
209
+
210
+ function _slicedToArray(arr, i) {
211
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
212
+ }
213
+
214
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
215
+
216
+ var classnames$1 = {exports: {}};
217
+
218
+ /*!
219
+ Copyright (c) 2018 Jed Watson.
220
+ Licensed under the MIT License (MIT), see
221
+ http://jedwatson.github.io/classnames
222
+ */
223
+
224
+ (function (module) {
225
+ /* global define */
226
+
227
+ (function () {
228
+
229
+ var hasOwn = {}.hasOwnProperty;
230
+
231
+ function classNames() {
232
+ var classes = [];
233
+
234
+ for (var i = 0; i < arguments.length; i++) {
235
+ var arg = arguments[i];
236
+ if (!arg) continue;
237
+
238
+ var argType = typeof arg;
239
+
240
+ if (argType === 'string' || argType === 'number') {
241
+ classes.push(arg);
242
+ } else if (Array.isArray(arg)) {
243
+ if (arg.length) {
244
+ var inner = classNames.apply(null, arg);
245
+ if (inner) {
246
+ classes.push(inner);
247
+ }
248
+ }
249
+ } else if (argType === 'object') {
250
+ if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
251
+ classes.push(arg.toString());
252
+ continue;
253
+ }
254
+
255
+ for (var key in arg) {
256
+ if (hasOwn.call(arg, key) && arg[key]) {
257
+ classes.push(key);
258
+ }
259
+ }
260
+ }
261
+ }
262
+
263
+ return classes.join(' ');
264
+ }
265
+
266
+ if (module.exports) {
267
+ classNames.default = classNames;
268
+ module.exports = classNames;
269
+ } else {
270
+ window.classNames = classNames;
271
+ }
272
+ }());
273
+ } (classnames$1));
274
+
275
+ var classnames = classnames$1.exports;
276
+
277
+ function _objectWithoutPropertiesLoose(source, excluded) {
278
+ if (source == null) return {};
279
+ var target = {};
280
+ var sourceKeys = Object.keys(source);
281
+ var key, i;
282
+ for (i = 0; i < sourceKeys.length; i++) {
283
+ key = sourceKeys[i];
284
+ if (excluded.indexOf(key) >= 0) continue;
285
+ target[key] = source[key];
286
+ }
287
+ return target;
288
+ }
289
+
290
+ function _objectWithoutProperties(source, excluded) {
291
+ if (source == null) return {};
292
+ var target = _objectWithoutPropertiesLoose(source, excluded);
293
+ var key, i;
294
+ if (Object.getOwnPropertySymbols) {
295
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
296
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
297
+ key = sourceSymbolKeys[i];
298
+ if (excluded.indexOf(key) >= 0) continue;
299
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
300
+ target[key] = source[key];
301
+ }
302
+ }
303
+ return target;
304
+ }
305
+
306
+ var _path, _path2, _g, _defs;
307
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
308
+ var SvgNeeto = function SvgNeeto(props) {
309
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends({
310
+ width: 50,
311
+ height: 50,
312
+ viewBox: "0 0 415 415",
313
+ fill: "none",
314
+ xmlns: "http://www.w3.org/2000/svg"
315
+ }, props), _path || (_path = /*#__PURE__*/React__namespace.createElement("path", {
316
+ d: "M414.989 207.495C414.989 92.899 322.091 0 207.495 0H0v414.989h414.989V207.495Z",
317
+ fill: "#0043AC"
318
+ })), /*#__PURE__*/React__namespace.createElement("mask", {
319
+ id: "neeto_svg__a",
320
+ style: {
321
+ maskType: "alpha"
322
+ },
323
+ maskUnits: "userSpaceOnUse",
324
+ x: 0,
325
+ y: 0,
326
+ width: 415,
327
+ height: 415
328
+ }, _path2 || (_path2 = /*#__PURE__*/React__namespace.createElement("path", {
329
+ d: "M414.989 207.495C414.989 92.899 322.091 0 207.495 0H0v414.989h414.989V207.495Z",
330
+ fill: "#0043AC"
331
+ }))), _g || (_g = /*#__PURE__*/React__namespace.createElement("g", {
332
+ mask: "url(#neeto_svg__a)"
333
+ }, /*#__PURE__*/React__namespace.createElement("path", {
334
+ d: "M233.747 348.74c88.579 101.145 172.015 116.411 202.661 111.401v32.491H-8.032V230.487c43.685-2.726 153.2 17.108 241.779 118.253Z",
335
+ fill: "url(#neeto_svg__b)"
336
+ }))), _defs || (_defs = /*#__PURE__*/React__namespace.createElement("defs", null, /*#__PURE__*/React__namespace.createElement("radialGradient", {
337
+ id: "neeto_svg__b",
338
+ cx: 0,
339
+ cy: 0,
340
+ r: 1,
341
+ gradientUnits: "userSpaceOnUse",
342
+ gradientTransform: "rotate(47.118 -220.556 214.818) scale(427.964 725.049)"
343
+ }, /*#__PURE__*/React__namespace.createElement("stop", {
344
+ stopColor: "#0043AC"
345
+ }), /*#__PURE__*/React__namespace.createElement("stop", {
346
+ offset: 1,
347
+ stopColor: "#3DB1CA",
348
+ stopOpacity: 0.8
349
+ })))));
350
+ };
351
+
352
+ var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
353
+
354
+ var css$1 = ".neeto-molecules-pageloader__wrapper{height:100%;position:relative;width:100%}.neeto-molecules-pageloader__wrapper .neeto-molecules-pageloader{height:100%;left:0;position:absolute;top:0;width:100%}.neeto-molecules-pageloader__wrapper .neeto-molecules-pageloader__content{height:66px;margin-bottom:16px;overflow:hidden;padding:8px;position:relative;width:66px}.neeto-molecules-pageloader__wrapper .neeto-molecules-pageloader__text{color:rgb(var(--neeto-ui-gray-800));font-size:1.25rem;line-height:1.75rem;margin-bottom:4rem;text-align:center}.neeto-molecules-pageloader__spinner{display:flex;gap:2px;height:25px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}.neeto-molecules-pageloader__spinner>div{animation:neeto-ui-stretch-delay 1.2s ease-in-out infinite;background-color:#fff;border-radius:2px;display:inline-flex;height:100%;width:2px}.neeto-molecules-pageloader__spinner .neeto-molecules-pageloader__rect2{animation-delay:-1.1s}.neeto-molecules-pageloader__spinner .neeto-molecules-pageloader__rect3{animation-delay:-1s}.neeto-molecules-pageloader__spinner .neeto-molecules-pageloader__rect4{animation-delay:-.9s}.neeto-molecules-pageloader__spinner .neeto-molecules-pageloader__rect5{animation-delay:-.8s}@keyframes neeto-ui-stretch-delay{0%,40%,to{transform:scaleY(.4);-webkit-transform:scaleY(.4)}20%{transform:scaleY(1);-webkit-transform:scaleY(1)}}";
355
+ n(css$1,{});
356
+
357
+ var _excluded = ["text"];
358
+ var PageLoader = function PageLoader(_ref) {
359
+ var _ref$text = _ref.text,
360
+ text = _ref$text === void 0 ? "" : _ref$text,
361
+ otherProps = _objectWithoutProperties(_ref, _excluded);
362
+ return /*#__PURE__*/React__default["default"].createElement("div", _extends$1({
363
+ className: "neeto-molecules-pageloader__wrapper"
364
+ }, otherProps), /*#__PURE__*/React__default["default"].createElement("div", {
365
+ className: "neeto-molecules-pageloader neeto-ui-flex neeto-ui-flex-col neeto-ui-items-center neeto-ui-justify-center"
366
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
367
+ className: "neeto-molecules-pageloader__content neeto-ui-flex neeto-ui-flex-shrink-0 neeto-ui-items-center neeto-ui-justify-center"
368
+ }, /*#__PURE__*/React__default["default"].createElement(SvgNeeto, {
369
+ className: "neeto-molecules-pageloader__logo",
370
+ size: 50
371
+ }), /*#__PURE__*/React__default["default"].createElement("div", {
372
+ className: "neeto-molecules-pageloader__spinner"
373
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
374
+ className: "neeto-molecules-pageloader__rect1"
375
+ }), /*#__PURE__*/React__default["default"].createElement("div", {
376
+ className: "neeto-molecules-pageloader__rect2"
377
+ }), /*#__PURE__*/React__default["default"].createElement("div", {
378
+ className: "neeto-molecules-pageloader__rect3"
379
+ }), /*#__PURE__*/React__default["default"].createElement("div", {
380
+ className: "neeto-molecules-pageloader__rect4"
381
+ }), /*#__PURE__*/React__default["default"].createElement("div", {
382
+ className: "neeto-molecules-pageloader__rect5"
383
+ }))), text && /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
384
+ style: "h5",
385
+ weight: "semibold"
386
+ }, text)));
387
+ };
388
+ var PageLoader$1 = /*#__PURE__*/React__default["default"].memo(PageLoader);
389
+
390
+ var prism = {exports: {}};
391
+
392
+ (function (module) {
393
+ /* **********************************************
394
+ Begin prism-core.js
395
+ ********************************************** */
396
+
397
+ /// <reference lib="WebWorker"/>
398
+
399
+ var _self = (typeof window !== 'undefined')
400
+ ? window // if in browser
401
+ : (
402
+ (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
403
+ ? self // if in worker
404
+ : {} // if in node js
405
+ );
406
+
407
+ /**
408
+ * Prism: Lightweight, robust, elegant syntax highlighting
409
+ *
410
+ * @license MIT <https://opensource.org/licenses/MIT>
411
+ * @author Lea Verou <https://lea.verou.me>
412
+ * @namespace
413
+ * @public
414
+ */
415
+ var Prism = (function (_self) {
416
+
417
+ // Private helper vars
418
+ var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i;
419
+ var uniqueId = 0;
420
+
421
+ // The grammar object for plaintext
422
+ var plainTextGrammar = {};
423
+
424
+
425
+ var _ = {
426
+ /**
427
+ * By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
428
+ * current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
429
+ * additional languages or plugins yourself.
430
+ *
431
+ * By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
432
+ *
433
+ * You obviously have to change this value before the automatic highlighting started. To do this, you can add an
434
+ * empty Prism object into the global scope before loading the Prism script like this:
435
+ *
436
+ * ```js
437
+ * window.Prism = window.Prism || {};
438
+ * Prism.manual = true;
439
+ * // add a new <script> to load Prism's script
440
+ * ```
441
+ *
442
+ * @default false
443
+ * @type {boolean}
444
+ * @memberof Prism
445
+ * @public
446
+ */
447
+ manual: _self.Prism && _self.Prism.manual,
448
+ /**
449
+ * By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
450
+ * `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your
451
+ * own worker, you don't want it to do this.
452
+ *
453
+ * By setting this value to `true`, Prism will not add its own listeners to the worker.
454
+ *
455
+ * You obviously have to change this value before Prism executes. To do this, you can add an
456
+ * empty Prism object into the global scope before loading the Prism script like this:
457
+ *
458
+ * ```js
459
+ * window.Prism = window.Prism || {};
460
+ * Prism.disableWorkerMessageHandler = true;
461
+ * // Load Prism's script
462
+ * ```
463
+ *
464
+ * @default false
465
+ * @type {boolean}
466
+ * @memberof Prism
467
+ * @public
468
+ */
469
+ disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
470
+
471
+ /**
472
+ * A namespace for utility methods.
473
+ *
474
+ * All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
475
+ * change or disappear at any time.
476
+ *
477
+ * @namespace
478
+ * @memberof Prism
479
+ */
480
+ util: {
481
+ encode: function encode(tokens) {
482
+ if (tokens instanceof Token) {
483
+ return new Token(tokens.type, encode(tokens.content), tokens.alias);
484
+ } else if (Array.isArray(tokens)) {
485
+ return tokens.map(encode);
486
+ } else {
487
+ return tokens.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\u00a0/g, ' ');
488
+ }
489
+ },
490
+
491
+ /**
492
+ * Returns the name of the type of the given value.
493
+ *
494
+ * @param {any} o
495
+ * @returns {string}
496
+ * @example
497
+ * type(null) === 'Null'
498
+ * type(undefined) === 'Undefined'
499
+ * type(123) === 'Number'
500
+ * type('foo') === 'String'
501
+ * type(true) === 'Boolean'
502
+ * type([1, 2]) === 'Array'
503
+ * type({}) === 'Object'
504
+ * type(String) === 'Function'
505
+ * type(/abc+/) === 'RegExp'
506
+ */
507
+ type: function (o) {
508
+ return Object.prototype.toString.call(o).slice(8, -1);
509
+ },
510
+
511
+ /**
512
+ * Returns a unique number for the given object. Later calls will still return the same number.
513
+ *
514
+ * @param {Object} obj
515
+ * @returns {number}
516
+ */
517
+ objId: function (obj) {
518
+ if (!obj['__id']) {
519
+ Object.defineProperty(obj, '__id', { value: ++uniqueId });
520
+ }
521
+ return obj['__id'];
522
+ },
523
+
524
+ /**
525
+ * Creates a deep clone of the given object.
526
+ *
527
+ * The main intended use of this function is to clone language definitions.
528
+ *
529
+ * @param {T} o
530
+ * @param {Record<number, any>} [visited]
531
+ * @returns {T}
532
+ * @template T
533
+ */
534
+ clone: function deepClone(o, visited) {
535
+ visited = visited || {};
536
+
537
+ var clone; var id;
538
+ switch (_.util.type(o)) {
539
+ case 'Object':
540
+ id = _.util.objId(o);
541
+ if (visited[id]) {
542
+ return visited[id];
543
+ }
544
+ clone = /** @type {Record<string, any>} */ ({});
545
+ visited[id] = clone;
546
+
547
+ for (var key in o) {
548
+ if (o.hasOwnProperty(key)) {
549
+ clone[key] = deepClone(o[key], visited);
550
+ }
551
+ }
552
+
553
+ return /** @type {any} */ (clone);
554
+
555
+ case 'Array':
556
+ id = _.util.objId(o);
557
+ if (visited[id]) {
558
+ return visited[id];
559
+ }
560
+ clone = [];
561
+ visited[id] = clone;
562
+
563
+ (/** @type {Array} */(/** @type {any} */(o))).forEach(function (v, i) {
564
+ clone[i] = deepClone(v, visited);
565
+ });
566
+
567
+ return /** @type {any} */ (clone);
568
+
569
+ default:
570
+ return o;
571
+ }
572
+ },
573
+
574
+ /**
575
+ * Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
576
+ *
577
+ * If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
578
+ *
579
+ * @param {Element} element
580
+ * @returns {string}
581
+ */
582
+ getLanguage: function (element) {
583
+ while (element) {
584
+ var m = lang.exec(element.className);
585
+ if (m) {
586
+ return m[1].toLowerCase();
587
+ }
588
+ element = element.parentElement;
589
+ }
590
+ return 'none';
591
+ },
592
+
593
+ /**
594
+ * Sets the Prism `language-xxxx` class of the given element.
595
+ *
596
+ * @param {Element} element
597
+ * @param {string} language
598
+ * @returns {void}
599
+ */
600
+ setLanguage: function (element, language) {
601
+ // remove all `language-xxxx` classes
602
+ // (this might leave behind a leading space)
603
+ element.className = element.className.replace(RegExp(lang, 'gi'), '');
604
+
605
+ // add the new `language-xxxx` class
606
+ // (using `classList` will automatically clean up spaces for us)
607
+ element.classList.add('language-' + language);
608
+ },
609
+
610
+ /**
611
+ * Returns the script element that is currently executing.
612
+ *
613
+ * This does __not__ work for line script element.
614
+ *
615
+ * @returns {HTMLScriptElement | null}
616
+ */
617
+ currentScript: function () {
618
+ if (typeof document === 'undefined') {
619
+ return null;
620
+ }
621
+ if ('currentScript' in document && 1 < 2 /* hack to trip TS' flow analysis */) {
622
+ return /** @type {any} */ (document.currentScript);
623
+ }
624
+
625
+ // IE11 workaround
626
+ // we'll get the src of the current script by parsing IE11's error stack trace
627
+ // this will not work for inline scripts
628
+
629
+ try {
630
+ throw new Error();
631
+ } catch (err) {
632
+ // Get file src url from stack. Specifically works with the format of stack traces in IE.
633
+ // A stack will look like this:
634
+ //
635
+ // Error
636
+ // at _.util.currentScript (http://localhost/components/prism-core.js:119:5)
637
+ // at Global code (http://localhost/components/prism-core.js:606:1)
638
+
639
+ var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) || [])[1];
640
+ if (src) {
641
+ var scripts = document.getElementsByTagName('script');
642
+ for (var i in scripts) {
643
+ if (scripts[i].src == src) {
644
+ return scripts[i];
645
+ }
646
+ }
647
+ }
648
+ return null;
649
+ }
650
+ },
651
+
652
+ /**
653
+ * Returns whether a given class is active for `element`.
654
+ *
655
+ * The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated
656
+ * if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the
657
+ * given class is just the given class with a `no-` prefix.
658
+ *
659
+ * Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is
660
+ * closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its
661
+ * ancestors have the given class or the negated version of it, then the default activation will be returned.
662
+ *
663
+ * In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated
664
+ * version of it, the class is considered active.
665
+ *
666
+ * @param {Element} element
667
+ * @param {string} className
668
+ * @param {boolean} [defaultActivation=false]
669
+ * @returns {boolean}
670
+ */
671
+ isActive: function (element, className, defaultActivation) {
672
+ var no = 'no-' + className;
673
+
674
+ while (element) {
675
+ var classList = element.classList;
676
+ if (classList.contains(className)) {
677
+ return true;
678
+ }
679
+ if (classList.contains(no)) {
680
+ return false;
681
+ }
682
+ element = element.parentElement;
683
+ }
684
+ return !!defaultActivation;
685
+ }
686
+ },
687
+
688
+ /**
689
+ * This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
690
+ *
691
+ * @namespace
692
+ * @memberof Prism
693
+ * @public
694
+ */
695
+ languages: {
696
+ /**
697
+ * The grammar for plain, unformatted text.
698
+ */
699
+ plain: plainTextGrammar,
700
+ plaintext: plainTextGrammar,
701
+ text: plainTextGrammar,
702
+ txt: plainTextGrammar,
703
+
704
+ /**
705
+ * Creates a deep copy of the language with the given id and appends the given tokens.
706
+ *
707
+ * If a token in `redef` also appears in the copied language, then the existing token in the copied language
708
+ * will be overwritten at its original position.
709
+ *
710
+ * ## Best practices
711
+ *
712
+ * Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
713
+ * doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
714
+ * understand the language definition because, normally, the order of tokens matters in Prism grammars.
715
+ *
716
+ * Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
717
+ * Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
718
+ *
719
+ * @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
720
+ * @param {Grammar} redef The new tokens to append.
721
+ * @returns {Grammar} The new language created.
722
+ * @public
723
+ * @example
724
+ * Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
725
+ * // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
726
+ * // at its original position
727
+ * 'comment': { ... },
728
+ * // CSS doesn't have a 'color' token, so this token will be appended
729
+ * 'color': /\b(?:red|green|blue)\b/
730
+ * });
731
+ */
732
+ extend: function (id, redef) {
733
+ var lang = _.util.clone(_.languages[id]);
734
+
735
+ for (var key in redef) {
736
+ lang[key] = redef[key];
737
+ }
738
+
739
+ return lang;
740
+ },
741
+
742
+ /**
743
+ * Inserts tokens _before_ another token in a language definition or any other grammar.
744
+ *
745
+ * ## Usage
746
+ *
747
+ * This helper method makes it easy to modify existing languages. For example, the CSS language definition
748
+ * not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
749
+ * in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
750
+ * appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
751
+ * this:
752
+ *
753
+ * ```js
754
+ * Prism.languages.markup.style = {
755
+ * // token
756
+ * };
757
+ * ```
758
+ *
759
+ * then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
760
+ * before existing tokens. For the CSS example above, you would use it like this:
761
+ *
762
+ * ```js
763
+ * Prism.languages.insertBefore('markup', 'cdata', {
764
+ * 'style': {
765
+ * // token
766
+ * }
767
+ * });
768
+ * ```
769
+ *
770
+ * ## Special cases
771
+ *
772
+ * If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
773
+ * will be ignored.
774
+ *
775
+ * This behavior can be used to insert tokens after `before`:
776
+ *
777
+ * ```js
778
+ * Prism.languages.insertBefore('markup', 'comment', {
779
+ * 'comment': Prism.languages.markup.comment,
780
+ * // tokens after 'comment'
781
+ * });
782
+ * ```
783
+ *
784
+ * ## Limitations
785
+ *
786
+ * The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
787
+ * properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
788
+ * differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
789
+ * deleting properties which is necessary to insert at arbitrary positions.
790
+ *
791
+ * To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
792
+ * Instead, it will create a new object and replace all references to the target object with the new one. This
793
+ * can be done without temporarily deleting properties, so the iteration order is well-defined.
794
+ *
795
+ * However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
796
+ * you hold the target object in a variable, then the value of the variable will not change.
797
+ *
798
+ * ```js
799
+ * var oldMarkup = Prism.languages.markup;
800
+ * var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
801
+ *
802
+ * assert(oldMarkup !== Prism.languages.markup);
803
+ * assert(newMarkup === Prism.languages.markup);
804
+ * ```
805
+ *
806
+ * @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
807
+ * object to be modified.
808
+ * @param {string} before The key to insert before.
809
+ * @param {Grammar} insert An object containing the key-value pairs to be inserted.
810
+ * @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
811
+ * object to be modified.
812
+ *
813
+ * Defaults to `Prism.languages`.
814
+ * @returns {Grammar} The new grammar object.
815
+ * @public
816
+ */
817
+ insertBefore: function (inside, before, insert, root) {
818
+ root = root || /** @type {any} */ (_.languages);
819
+ var grammar = root[inside];
820
+ /** @type {Grammar} */
821
+ var ret = {};
822
+
823
+ for (var token in grammar) {
824
+ if (grammar.hasOwnProperty(token)) {
825
+
826
+ if (token == before) {
827
+ for (var newToken in insert) {
828
+ if (insert.hasOwnProperty(newToken)) {
829
+ ret[newToken] = insert[newToken];
830
+ }
831
+ }
832
+ }
833
+
834
+ // Do not insert token which also occur in insert. See #1525
835
+ if (!insert.hasOwnProperty(token)) {
836
+ ret[token] = grammar[token];
837
+ }
838
+ }
839
+ }
840
+
841
+ var old = root[inside];
842
+ root[inside] = ret;
843
+
844
+ // Update references in other language definitions
845
+ _.languages.DFS(_.languages, function (key, value) {
846
+ if (value === old && key != inside) {
847
+ this[key] = ret;
848
+ }
849
+ });
850
+
851
+ return ret;
852
+ },
853
+
854
+ // Traverse a language definition with Depth First Search
855
+ DFS: function DFS(o, callback, type, visited) {
856
+ visited = visited || {};
857
+
858
+ var objId = _.util.objId;
859
+
860
+ for (var i in o) {
861
+ if (o.hasOwnProperty(i)) {
862
+ callback.call(o, i, o[i], type || i);
863
+
864
+ var property = o[i];
865
+ var propertyType = _.util.type(property);
866
+
867
+ if (propertyType === 'Object' && !visited[objId(property)]) {
868
+ visited[objId(property)] = true;
869
+ DFS(property, callback, null, visited);
870
+ } else if (propertyType === 'Array' && !visited[objId(property)]) {
871
+ visited[objId(property)] = true;
872
+ DFS(property, callback, i, visited);
873
+ }
874
+ }
875
+ }
876
+ }
877
+ },
878
+
879
+ plugins: {},
880
+
881
+ /**
882
+ * This is the most high-level function in Prism’s API.
883
+ * It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
884
+ * each one of them.
885
+ *
886
+ * This is equivalent to `Prism.highlightAllUnder(document, async, callback)`.
887
+ *
888
+ * @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}.
889
+ * @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}.
890
+ * @memberof Prism
891
+ * @public
892
+ */
893
+ highlightAll: function (async, callback) {
894
+ _.highlightAllUnder(document, async, callback);
895
+ },
896
+
897
+ /**
898
+ * Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
899
+ * {@link Prism.highlightElement} on each one of them.
900
+ *
901
+ * The following hooks will be run:
902
+ * 1. `before-highlightall`
903
+ * 2. `before-all-elements-highlight`
904
+ * 3. All hooks of {@link Prism.highlightElement} for each element.
905
+ *
906
+ * @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
907
+ * @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers.
908
+ * @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done.
909
+ * @memberof Prism
910
+ * @public
911
+ */
912
+ highlightAllUnder: function (container, async, callback) {
913
+ var env = {
914
+ callback: callback,
915
+ container: container,
916
+ selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
917
+ };
918
+
919
+ _.hooks.run('before-highlightall', env);
920
+
921
+ env.elements = Array.prototype.slice.apply(env.container.querySelectorAll(env.selector));
922
+
923
+ _.hooks.run('before-all-elements-highlight', env);
924
+
925
+ for (var i = 0, element; (element = env.elements[i++]);) {
926
+ _.highlightElement(element, async === true, env.callback);
927
+ }
928
+ },
929
+
930
+ /**
931
+ * Highlights the code inside a single element.
932
+ *
933
+ * The following hooks will be run:
934
+ * 1. `before-sanity-check`
935
+ * 2. `before-highlight`
936
+ * 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`.
937
+ * 4. `before-insert`
938
+ * 5. `after-highlight`
939
+ * 6. `complete`
940
+ *
941
+ * Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for
942
+ * the element's language.
943
+ *
944
+ * @param {Element} element The element containing the code.
945
+ * It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.
946
+ * @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers
947
+ * to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is
948
+ * [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).
949
+ *
950
+ * Note: All language definitions required to highlight the code must be included in the main `prism.js` file for
951
+ * asynchronous highlighting to work. You can build your own bundle on the
952
+ * [Download page](https://prismjs.com/download.html).
953
+ * @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done.
954
+ * Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
955
+ * @memberof Prism
956
+ * @public
957
+ */
958
+ highlightElement: function (element, async, callback) {
959
+ // Find language
960
+ var language = _.util.getLanguage(element);
961
+ var grammar = _.languages[language];
962
+
963
+ // Set language on the element, if not present
964
+ _.util.setLanguage(element, language);
965
+
966
+ // Set language on the parent, for styling
967
+ var parent = element.parentElement;
968
+ if (parent && parent.nodeName.toLowerCase() === 'pre') {
969
+ _.util.setLanguage(parent, language);
970
+ }
971
+
972
+ var code = element.textContent;
973
+
974
+ var env = {
975
+ element: element,
976
+ language: language,
977
+ grammar: grammar,
978
+ code: code
979
+ };
980
+
981
+ function insertHighlightedCode(highlightedCode) {
982
+ env.highlightedCode = highlightedCode;
983
+
984
+ _.hooks.run('before-insert', env);
985
+
986
+ env.element.innerHTML = env.highlightedCode;
987
+
988
+ _.hooks.run('after-highlight', env);
989
+ _.hooks.run('complete', env);
990
+ callback && callback.call(env.element);
991
+ }
992
+
993
+ _.hooks.run('before-sanity-check', env);
994
+
995
+ // plugins may change/add the parent/element
996
+ parent = env.element.parentElement;
997
+ if (parent && parent.nodeName.toLowerCase() === 'pre' && !parent.hasAttribute('tabindex')) {
998
+ parent.setAttribute('tabindex', '0');
999
+ }
1000
+
1001
+ if (!env.code) {
1002
+ _.hooks.run('complete', env);
1003
+ callback && callback.call(env.element);
1004
+ return;
1005
+ }
1006
+
1007
+ _.hooks.run('before-highlight', env);
1008
+
1009
+ if (!env.grammar) {
1010
+ insertHighlightedCode(_.util.encode(env.code));
1011
+ return;
1012
+ }
1013
+
1014
+ if (async && _self.Worker) {
1015
+ var worker = new Worker(_.filename);
1016
+
1017
+ worker.onmessage = function (evt) {
1018
+ insertHighlightedCode(evt.data);
1019
+ };
1020
+
1021
+ worker.postMessage(JSON.stringify({
1022
+ language: env.language,
1023
+ code: env.code,
1024
+ immediateClose: true
1025
+ }));
1026
+ } else {
1027
+ insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
1028
+ }
1029
+ },
1030
+
1031
+ /**
1032
+ * Low-level function, only use if you know what you’re doing. It accepts a string of text as input
1033
+ * and the language definitions to use, and returns a string with the HTML produced.
1034
+ *
1035
+ * The following hooks will be run:
1036
+ * 1. `before-tokenize`
1037
+ * 2. `after-tokenize`
1038
+ * 3. `wrap`: On each {@link Token}.
1039
+ *
1040
+ * @param {string} text A string with the code to be highlighted.
1041
+ * @param {Grammar} grammar An object containing the tokens to use.
1042
+ *
1043
+ * Usually a language definition like `Prism.languages.markup`.
1044
+ * @param {string} language The name of the language definition passed to `grammar`.
1045
+ * @returns {string} The highlighted HTML.
1046
+ * @memberof Prism
1047
+ * @public
1048
+ * @example
1049
+ * Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
1050
+ */
1051
+ highlight: function (text, grammar, language) {
1052
+ var env = {
1053
+ code: text,
1054
+ grammar: grammar,
1055
+ language: language
1056
+ };
1057
+ _.hooks.run('before-tokenize', env);
1058
+ if (!env.grammar) {
1059
+ throw new Error('The language "' + env.language + '" has no grammar.');
1060
+ }
1061
+ env.tokens = _.tokenize(env.code, env.grammar);
1062
+ _.hooks.run('after-tokenize', env);
1063
+ return Token.stringify(_.util.encode(env.tokens), env.language);
1064
+ },
1065
+
1066
+ /**
1067
+ * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
1068
+ * and the language definitions to use, and returns an array with the tokenized code.
1069
+ *
1070
+ * When the language definition includes nested tokens, the function is called recursively on each of these tokens.
1071
+ *
1072
+ * This method could be useful in other contexts as well, as a very crude parser.
1073
+ *
1074
+ * @param {string} text A string with the code to be highlighted.
1075
+ * @param {Grammar} grammar An object containing the tokens to use.
1076
+ *
1077
+ * Usually a language definition like `Prism.languages.markup`.
1078
+ * @returns {TokenStream} An array of strings and tokens, a token stream.
1079
+ * @memberof Prism
1080
+ * @public
1081
+ * @example
1082
+ * let code = `var foo = 0;`;
1083
+ * let tokens = Prism.tokenize(code, Prism.languages.javascript);
1084
+ * tokens.forEach(token => {
1085
+ * if (token instanceof Prism.Token && token.type === 'number') {
1086
+ * console.log(`Found numeric literal: ${token.content}`);
1087
+ * }
1088
+ * });
1089
+ */
1090
+ tokenize: function (text, grammar) {
1091
+ var rest = grammar.rest;
1092
+ if (rest) {
1093
+ for (var token in rest) {
1094
+ grammar[token] = rest[token];
1095
+ }
1096
+
1097
+ delete grammar.rest;
1098
+ }
1099
+
1100
+ var tokenList = new LinkedList();
1101
+ addAfter(tokenList, tokenList.head, text);
1102
+
1103
+ matchGrammar(text, tokenList, grammar, tokenList.head, 0);
1104
+
1105
+ return toArray(tokenList);
1106
+ },
1107
+
1108
+ /**
1109
+ * @namespace
1110
+ * @memberof Prism
1111
+ * @public
1112
+ */
1113
+ hooks: {
1114
+ all: {},
1115
+
1116
+ /**
1117
+ * Adds the given callback to the list of callbacks for the given hook.
1118
+ *
1119
+ * The callback will be invoked when the hook it is registered for is run.
1120
+ * Hooks are usually directly run by a highlight function but you can also run hooks yourself.
1121
+ *
1122
+ * One callback function can be registered to multiple hooks and the same hook multiple times.
1123
+ *
1124
+ * @param {string} name The name of the hook.
1125
+ * @param {HookCallback} callback The callback function which is given environment variables.
1126
+ * @public
1127
+ */
1128
+ add: function (name, callback) {
1129
+ var hooks = _.hooks.all;
1130
+
1131
+ hooks[name] = hooks[name] || [];
1132
+
1133
+ hooks[name].push(callback);
1134
+ },
1135
+
1136
+ /**
1137
+ * Runs a hook invoking all registered callbacks with the given environment variables.
1138
+ *
1139
+ * Callbacks will be invoked synchronously and in the order in which they were registered.
1140
+ *
1141
+ * @param {string} name The name of the hook.
1142
+ * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
1143
+ * @public
1144
+ */
1145
+ run: function (name, env) {
1146
+ var callbacks = _.hooks.all[name];
1147
+
1148
+ if (!callbacks || !callbacks.length) {
1149
+ return;
1150
+ }
1151
+
1152
+ for (var i = 0, callback; (callback = callbacks[i++]);) {
1153
+ callback(env);
1154
+ }
1155
+ }
1156
+ },
1157
+
1158
+ Token: Token
1159
+ };
1160
+ _self.Prism = _;
1161
+
1162
+
1163
+ // Typescript note:
1164
+ // The following can be used to import the Token type in JSDoc:
1165
+ //
1166
+ // @typedef {InstanceType<import("./prism-core")["Token"]>} Token
1167
+
1168
+ /**
1169
+ * Creates a new token.
1170
+ *
1171
+ * @param {string} type See {@link Token#type type}
1172
+ * @param {string | TokenStream} content See {@link Token#content content}
1173
+ * @param {string|string[]} [alias] The alias(es) of the token.
1174
+ * @param {string} [matchedStr=""] A copy of the full string this token was created from.
1175
+ * @class
1176
+ * @global
1177
+ * @public
1178
+ */
1179
+ function Token(type, content, alias, matchedStr) {
1180
+ /**
1181
+ * The type of the token.
1182
+ *
1183
+ * This is usually the key of a pattern in a {@link Grammar}.
1184
+ *
1185
+ * @type {string}
1186
+ * @see GrammarToken
1187
+ * @public
1188
+ */
1189
+ this.type = type;
1190
+ /**
1191
+ * The strings or tokens contained by this token.
1192
+ *
1193
+ * This will be a token stream if the pattern matched also defined an `inside` grammar.
1194
+ *
1195
+ * @type {string | TokenStream}
1196
+ * @public
1197
+ */
1198
+ this.content = content;
1199
+ /**
1200
+ * The alias(es) of the token.
1201
+ *
1202
+ * @type {string|string[]}
1203
+ * @see GrammarToken
1204
+ * @public
1205
+ */
1206
+ this.alias = alias;
1207
+ // Copy of the full string this token was created from
1208
+ this.length = (matchedStr || '').length | 0;
1209
+ }
1210
+
1211
+ /**
1212
+ * A token stream is an array of strings and {@link Token Token} objects.
1213
+ *
1214
+ * Token streams have to fulfill a few properties that are assumed by most functions (mostly internal ones) that process
1215
+ * them.
1216
+ *
1217
+ * 1. No adjacent strings.
1218
+ * 2. No empty strings.
1219
+ *
1220
+ * The only exception here is the token stream that only contains the empty string and nothing else.
1221
+ *
1222
+ * @typedef {Array<string | Token>} TokenStream
1223
+ * @global
1224
+ * @public
1225
+ */
1226
+
1227
+ /**
1228
+ * Converts the given token or token stream to an HTML representation.
1229
+ *
1230
+ * The following hooks will be run:
1231
+ * 1. `wrap`: On each {@link Token}.
1232
+ *
1233
+ * @param {string | Token | TokenStream} o The token or token stream to be converted.
1234
+ * @param {string} language The name of current language.
1235
+ * @returns {string} The HTML representation of the token or token stream.
1236
+ * @memberof Token
1237
+ * @static
1238
+ */
1239
+ Token.stringify = function stringify(o, language) {
1240
+ if (typeof o == 'string') {
1241
+ return o;
1242
+ }
1243
+ if (Array.isArray(o)) {
1244
+ var s = '';
1245
+ o.forEach(function (e) {
1246
+ s += stringify(e, language);
1247
+ });
1248
+ return s;
1249
+ }
1250
+
1251
+ var env = {
1252
+ type: o.type,
1253
+ content: stringify(o.content, language),
1254
+ tag: 'span',
1255
+ classes: ['token', o.type],
1256
+ attributes: {},
1257
+ language: language
1258
+ };
1259
+
1260
+ var aliases = o.alias;
1261
+ if (aliases) {
1262
+ if (Array.isArray(aliases)) {
1263
+ Array.prototype.push.apply(env.classes, aliases);
1264
+ } else {
1265
+ env.classes.push(aliases);
1266
+ }
1267
+ }
1268
+
1269
+ _.hooks.run('wrap', env);
1270
+
1271
+ var attributes = '';
1272
+ for (var name in env.attributes) {
1273
+ attributes += ' ' + name + '="' + (env.attributes[name] || '').replace(/"/g, '&quot;') + '"';
1274
+ }
1275
+
1276
+ return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + attributes + '>' + env.content + '</' + env.tag + '>';
1277
+ };
1278
+
1279
+ /**
1280
+ * @param {RegExp} pattern
1281
+ * @param {number} pos
1282
+ * @param {string} text
1283
+ * @param {boolean} lookbehind
1284
+ * @returns {RegExpExecArray | null}
1285
+ */
1286
+ function matchPattern(pattern, pos, text, lookbehind) {
1287
+ pattern.lastIndex = pos;
1288
+ var match = pattern.exec(text);
1289
+ if (match && lookbehind && match[1]) {
1290
+ // change the match to remove the text matched by the Prism lookbehind group
1291
+ var lookbehindLength = match[1].length;
1292
+ match.index += lookbehindLength;
1293
+ match[0] = match[0].slice(lookbehindLength);
1294
+ }
1295
+ return match;
1296
+ }
1297
+
1298
+ /**
1299
+ * @param {string} text
1300
+ * @param {LinkedList<string | Token>} tokenList
1301
+ * @param {any} grammar
1302
+ * @param {LinkedListNode<string | Token>} startNode
1303
+ * @param {number} startPos
1304
+ * @param {RematchOptions} [rematch]
1305
+ * @returns {void}
1306
+ * @private
1307
+ *
1308
+ * @typedef RematchOptions
1309
+ * @property {string} cause
1310
+ * @property {number} reach
1311
+ */
1312
+ function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
1313
+ for (var token in grammar) {
1314
+ if (!grammar.hasOwnProperty(token) || !grammar[token]) {
1315
+ continue;
1316
+ }
1317
+
1318
+ var patterns = grammar[token];
1319
+ patterns = Array.isArray(patterns) ? patterns : [patterns];
1320
+
1321
+ for (var j = 0; j < patterns.length; ++j) {
1322
+ if (rematch && rematch.cause == token + ',' + j) {
1323
+ return;
1324
+ }
1325
+
1326
+ var patternObj = patterns[j];
1327
+ var inside = patternObj.inside;
1328
+ var lookbehind = !!patternObj.lookbehind;
1329
+ var greedy = !!patternObj.greedy;
1330
+ var alias = patternObj.alias;
1331
+
1332
+ if (greedy && !patternObj.pattern.global) {
1333
+ // Without the global flag, lastIndex won't work
1334
+ var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
1335
+ patternObj.pattern = RegExp(patternObj.pattern.source, flags + 'g');
1336
+ }
1337
+
1338
+ /** @type {RegExp} */
1339
+ var pattern = patternObj.pattern || patternObj;
1340
+
1341
+ for ( // iterate the token list and keep track of the current token/string position
1342
+ var currentNode = startNode.next, pos = startPos;
1343
+ currentNode !== tokenList.tail;
1344
+ pos += currentNode.value.length, currentNode = currentNode.next
1345
+ ) {
1346
+
1347
+ if (rematch && pos >= rematch.reach) {
1348
+ break;
1349
+ }
1350
+
1351
+ var str = currentNode.value;
1352
+
1353
+ if (tokenList.length > text.length) {
1354
+ // Something went terribly wrong, ABORT, ABORT!
1355
+ return;
1356
+ }
1357
+
1358
+ if (str instanceof Token) {
1359
+ continue;
1360
+ }
1361
+
1362
+ var removeCount = 1; // this is the to parameter of removeBetween
1363
+ var match;
1364
+
1365
+ if (greedy) {
1366
+ match = matchPattern(pattern, pos, text, lookbehind);
1367
+ if (!match || match.index >= text.length) {
1368
+ break;
1369
+ }
1370
+
1371
+ var from = match.index;
1372
+ var to = match.index + match[0].length;
1373
+ var p = pos;
1374
+
1375
+ // find the node that contains the match
1376
+ p += currentNode.value.length;
1377
+ while (from >= p) {
1378
+ currentNode = currentNode.next;
1379
+ p += currentNode.value.length;
1380
+ }
1381
+ // adjust pos (and p)
1382
+ p -= currentNode.value.length;
1383
+ pos = p;
1384
+
1385
+ // the current node is a Token, then the match starts inside another Token, which is invalid
1386
+ if (currentNode.value instanceof Token) {
1387
+ continue;
1388
+ }
1389
+
1390
+ // find the last node which is affected by this match
1391
+ for (
1392
+ var k = currentNode;
1393
+ k !== tokenList.tail && (p < to || typeof k.value === 'string');
1394
+ k = k.next
1395
+ ) {
1396
+ removeCount++;
1397
+ p += k.value.length;
1398
+ }
1399
+ removeCount--;
1400
+
1401
+ // replace with the new match
1402
+ str = text.slice(pos, p);
1403
+ match.index -= pos;
1404
+ } else {
1405
+ match = matchPattern(pattern, 0, str, lookbehind);
1406
+ if (!match) {
1407
+ continue;
1408
+ }
1409
+ }
1410
+
1411
+ // eslint-disable-next-line no-redeclare
1412
+ var from = match.index;
1413
+ var matchStr = match[0];
1414
+ var before = str.slice(0, from);
1415
+ var after = str.slice(from + matchStr.length);
1416
+
1417
+ var reach = pos + str.length;
1418
+ if (rematch && reach > rematch.reach) {
1419
+ rematch.reach = reach;
1420
+ }
1421
+
1422
+ var removeFrom = currentNode.prev;
1423
+
1424
+ if (before) {
1425
+ removeFrom = addAfter(tokenList, removeFrom, before);
1426
+ pos += before.length;
1427
+ }
1428
+
1429
+ removeRange(tokenList, removeFrom, removeCount);
1430
+
1431
+ var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr);
1432
+ currentNode = addAfter(tokenList, removeFrom, wrapped);
1433
+
1434
+ if (after) {
1435
+ addAfter(tokenList, currentNode, after);
1436
+ }
1437
+
1438
+ if (removeCount > 1) {
1439
+ // at least one Token object was removed, so we have to do some rematching
1440
+ // this can only happen if the current pattern is greedy
1441
+
1442
+ /** @type {RematchOptions} */
1443
+ var nestedRematch = {
1444
+ cause: token + ',' + j,
1445
+ reach: reach
1446
+ };
1447
+ matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch);
1448
+
1449
+ // the reach might have been extended because of the rematching
1450
+ if (rematch && nestedRematch.reach > rematch.reach) {
1451
+ rematch.reach = nestedRematch.reach;
1452
+ }
1453
+ }
1454
+ }
1455
+ }
1456
+ }
1457
+ }
1458
+
1459
+ /**
1460
+ * @typedef LinkedListNode
1461
+ * @property {T} value
1462
+ * @property {LinkedListNode<T> | null} prev The previous node.
1463
+ * @property {LinkedListNode<T> | null} next The next node.
1464
+ * @template T
1465
+ * @private
1466
+ */
1467
+
1468
+ /**
1469
+ * @template T
1470
+ * @private
1471
+ */
1472
+ function LinkedList() {
1473
+ /** @type {LinkedListNode<T>} */
1474
+ var head = { value: null, prev: null, next: null };
1475
+ /** @type {LinkedListNode<T>} */
1476
+ var tail = { value: null, prev: head, next: null };
1477
+ head.next = tail;
1478
+
1479
+ /** @type {LinkedListNode<T>} */
1480
+ this.head = head;
1481
+ /** @type {LinkedListNode<T>} */
1482
+ this.tail = tail;
1483
+ this.length = 0;
1484
+ }
1485
+
1486
+ /**
1487
+ * Adds a new node with the given value to the list.
1488
+ *
1489
+ * @param {LinkedList<T>} list
1490
+ * @param {LinkedListNode<T>} node
1491
+ * @param {T} value
1492
+ * @returns {LinkedListNode<T>} The added node.
1493
+ * @template T
1494
+ */
1495
+ function addAfter(list, node, value) {
1496
+ // assumes that node != list.tail && values.length >= 0
1497
+ var next = node.next;
1498
+
1499
+ var newNode = { value: value, prev: node, next: next };
1500
+ node.next = newNode;
1501
+ next.prev = newNode;
1502
+ list.length++;
1503
+
1504
+ return newNode;
1505
+ }
1506
+ /**
1507
+ * Removes `count` nodes after the given node. The given node will not be removed.
1508
+ *
1509
+ * @param {LinkedList<T>} list
1510
+ * @param {LinkedListNode<T>} node
1511
+ * @param {number} count
1512
+ * @template T
1513
+ */
1514
+ function removeRange(list, node, count) {
1515
+ var next = node.next;
1516
+ for (var i = 0; i < count && next !== list.tail; i++) {
1517
+ next = next.next;
1518
+ }
1519
+ node.next = next;
1520
+ next.prev = node;
1521
+ list.length -= i;
1522
+ }
1523
+ /**
1524
+ * @param {LinkedList<T>} list
1525
+ * @returns {T[]}
1526
+ * @template T
1527
+ */
1528
+ function toArray(list) {
1529
+ var array = [];
1530
+ var node = list.head.next;
1531
+ while (node !== list.tail) {
1532
+ array.push(node.value);
1533
+ node = node.next;
1534
+ }
1535
+ return array;
1536
+ }
1537
+
1538
+
1539
+ if (!_self.document) {
1540
+ if (!_self.addEventListener) {
1541
+ // in Node.js
1542
+ return _;
1543
+ }
1544
+
1545
+ if (!_.disableWorkerMessageHandler) {
1546
+ // In worker
1547
+ _self.addEventListener('message', function (evt) {
1548
+ var message = JSON.parse(evt.data);
1549
+ var lang = message.language;
1550
+ var code = message.code;
1551
+ var immediateClose = message.immediateClose;
1552
+
1553
+ _self.postMessage(_.highlight(code, _.languages[lang], lang));
1554
+ if (immediateClose) {
1555
+ _self.close();
1556
+ }
1557
+ }, false);
1558
+ }
1559
+
1560
+ return _;
1561
+ }
1562
+
1563
+ // Get current script and highlight
1564
+ var script = _.util.currentScript();
1565
+
1566
+ if (script) {
1567
+ _.filename = script.src;
1568
+
1569
+ if (script.hasAttribute('data-manual')) {
1570
+ _.manual = true;
1571
+ }
1572
+ }
1573
+
1574
+ function highlightAutomaticallyCallback() {
1575
+ if (!_.manual) {
1576
+ _.highlightAll();
1577
+ }
1578
+ }
1579
+
1580
+ if (!_.manual) {
1581
+ // If the document state is "loading", then we'll use DOMContentLoaded.
1582
+ // If the document state is "interactive" and the prism.js script is deferred, then we'll also use the
1583
+ // DOMContentLoaded event because there might be some plugins or languages which have also been deferred and they
1584
+ // might take longer one animation frame to execute which can create a race condition where only some plugins have
1585
+ // been loaded when Prism.highlightAll() is executed, depending on how fast resources are loaded.
1586
+ // See https://github.com/PrismJS/prism/issues/2102
1587
+ var readyState = document.readyState;
1588
+ if (readyState === 'loading' || readyState === 'interactive' && script && script.defer) {
1589
+ document.addEventListener('DOMContentLoaded', highlightAutomaticallyCallback);
1590
+ } else {
1591
+ if (window.requestAnimationFrame) {
1592
+ window.requestAnimationFrame(highlightAutomaticallyCallback);
1593
+ } else {
1594
+ window.setTimeout(highlightAutomaticallyCallback, 16);
1595
+ }
1596
+ }
1597
+ }
1598
+
1599
+ return _;
1600
+
1601
+ }(_self));
1602
+
1603
+ if (module.exports) {
1604
+ module.exports = Prism;
1605
+ }
1606
+
1607
+ // hack for components to work correctly in node.js
1608
+ if (typeof commonjsGlobal !== 'undefined') {
1609
+ commonjsGlobal.Prism = Prism;
1610
+ }
1611
+
1612
+ // some additional documentation/types
1613
+
1614
+ /**
1615
+ * The expansion of a simple `RegExp` literal to support additional properties.
1616
+ *
1617
+ * @typedef GrammarToken
1618
+ * @property {RegExp} pattern The regular expression of the token.
1619
+ * @property {boolean} [lookbehind=false] If `true`, then the first capturing group of `pattern` will (effectively)
1620
+ * behave as a lookbehind group meaning that the captured text will not be part of the matched text of the new token.
1621
+ * @property {boolean} [greedy=false] Whether the token is greedy.
1622
+ * @property {string|string[]} [alias] An optional alias or list of aliases.
1623
+ * @property {Grammar} [inside] The nested grammar of this token.
1624
+ *
1625
+ * The `inside` grammar will be used to tokenize the text value of each token of this kind.
1626
+ *
1627
+ * This can be used to make nested and even recursive language definitions.
1628
+ *
1629
+ * Note: This can cause infinite recursion. Be careful when you embed different languages or even the same language into
1630
+ * each another.
1631
+ * @global
1632
+ * @public
1633
+ */
1634
+
1635
+ /**
1636
+ * @typedef Grammar
1637
+ * @type {Object<string, RegExp | GrammarToken | Array<RegExp | GrammarToken>>}
1638
+ * @property {Grammar} [rest] An optional grammar object that will be appended to this grammar.
1639
+ * @global
1640
+ * @public
1641
+ */
1642
+
1643
+ /**
1644
+ * A function which will invoked after an element was successfully highlighted.
1645
+ *
1646
+ * @callback HighlightCallback
1647
+ * @param {Element} element The element successfully highlighted.
1648
+ * @returns {void}
1649
+ * @global
1650
+ * @public
1651
+ */
1652
+
1653
+ /**
1654
+ * @callback HookCallback
1655
+ * @param {Object<string, any>} env The environment variables of the hook.
1656
+ * @returns {void}
1657
+ * @global
1658
+ * @public
1659
+ */
1660
+
1661
+
1662
+ /* **********************************************
1663
+ Begin prism-markup.js
1664
+ ********************************************** */
1665
+
1666
+ Prism.languages.markup = {
1667
+ 'comment': {
1668
+ pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
1669
+ greedy: true
1670
+ },
1671
+ 'prolog': {
1672
+ pattern: /<\?[\s\S]+?\?>/,
1673
+ greedy: true
1674
+ },
1675
+ 'doctype': {
1676
+ // https://www.w3.org/TR/xml/#NT-doctypedecl
1677
+ pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
1678
+ greedy: true,
1679
+ inside: {
1680
+ 'internal-subset': {
1681
+ pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
1682
+ lookbehind: true,
1683
+ greedy: true,
1684
+ inside: null // see below
1685
+ },
1686
+ 'string': {
1687
+ pattern: /"[^"]*"|'[^']*'/,
1688
+ greedy: true
1689
+ },
1690
+ 'punctuation': /^<!|>$|[[\]]/,
1691
+ 'doctype-tag': /^DOCTYPE/i,
1692
+ 'name': /[^\s<>'"]+/
1693
+ }
1694
+ },
1695
+ 'cdata': {
1696
+ pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
1697
+ greedy: true
1698
+ },
1699
+ 'tag': {
1700
+ pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
1701
+ greedy: true,
1702
+ inside: {
1703
+ 'tag': {
1704
+ pattern: /^<\/?[^\s>\/]+/,
1705
+ inside: {
1706
+ 'punctuation': /^<\/?/,
1707
+ 'namespace': /^[^\s>\/:]+:/
1708
+ }
1709
+ },
1710
+ 'special-attr': [],
1711
+ 'attr-value': {
1712
+ pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
1713
+ inside: {
1714
+ 'punctuation': [
1715
+ {
1716
+ pattern: /^=/,
1717
+ alias: 'attr-equals'
1718
+ },
1719
+ {
1720
+ pattern: /^(\s*)["']|["']$/,
1721
+ lookbehind: true
1722
+ }
1723
+ ]
1724
+ }
1725
+ },
1726
+ 'punctuation': /\/?>/,
1727
+ 'attr-name': {
1728
+ pattern: /[^\s>\/]+/,
1729
+ inside: {
1730
+ 'namespace': /^[^\s>\/:]+:/
1731
+ }
1732
+ }
1733
+
1734
+ }
1735
+ },
1736
+ 'entity': [
1737
+ {
1738
+ pattern: /&[\da-z]{1,8};/i,
1739
+ alias: 'named-entity'
1740
+ },
1741
+ /&#x?[\da-f]{1,8};/i
1742
+ ]
1743
+ };
1744
+
1745
+ Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] =
1746
+ Prism.languages.markup['entity'];
1747
+ Prism.languages.markup['doctype'].inside['internal-subset'].inside = Prism.languages.markup;
1748
+
1749
+ // Plugin to make entity title show the real entity, idea by Roman Komarov
1750
+ Prism.hooks.add('wrap', function (env) {
1751
+
1752
+ if (env.type === 'entity') {
1753
+ env.attributes['title'] = env.content.replace(/&amp;/, '&');
1754
+ }
1755
+ });
1756
+
1757
+ Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
1758
+ /**
1759
+ * Adds an inlined language to markup.
1760
+ *
1761
+ * An example of an inlined language is CSS with `<style>` tags.
1762
+ *
1763
+ * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
1764
+ * case insensitive.
1765
+ * @param {string} lang The language key.
1766
+ * @example
1767
+ * addInlined('style', 'css');
1768
+ */
1769
+ value: function addInlined(tagName, lang) {
1770
+ var includedCdataInside = {};
1771
+ includedCdataInside['language-' + lang] = {
1772
+ pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
1773
+ lookbehind: true,
1774
+ inside: Prism.languages[lang]
1775
+ };
1776
+ includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i;
1777
+
1778
+ var inside = {
1779
+ 'included-cdata': {
1780
+ pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
1781
+ inside: includedCdataInside
1782
+ }
1783
+ };
1784
+ inside['language-' + lang] = {
1785
+ pattern: /[\s\S]+/,
1786
+ inside: Prism.languages[lang]
1787
+ };
1788
+
1789
+ var def = {};
1790
+ def[tagName] = {
1791
+ pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () { return tagName; }), 'i'),
1792
+ lookbehind: true,
1793
+ greedy: true,
1794
+ inside: inside
1795
+ };
1796
+
1797
+ Prism.languages.insertBefore('markup', 'cdata', def);
1798
+ }
1799
+ });
1800
+ Object.defineProperty(Prism.languages.markup.tag, 'addAttribute', {
1801
+ /**
1802
+ * Adds an pattern to highlight languages embedded in HTML attributes.
1803
+ *
1804
+ * An example of an inlined language is CSS with `style` attributes.
1805
+ *
1806
+ * @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as
1807
+ * case insensitive.
1808
+ * @param {string} lang The language key.
1809
+ * @example
1810
+ * addAttribute('style', 'css');
1811
+ */
1812
+ value: function (attrName, lang) {
1813
+ Prism.languages.markup.tag.inside['special-attr'].push({
1814
+ pattern: RegExp(
1815
+ /(^|["'\s])/.source + '(?:' + attrName + ')' + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
1816
+ 'i'
1817
+ ),
1818
+ lookbehind: true,
1819
+ inside: {
1820
+ 'attr-name': /^[^\s=]+/,
1821
+ 'attr-value': {
1822
+ pattern: /=[\s\S]+/,
1823
+ inside: {
1824
+ 'value': {
1825
+ pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
1826
+ lookbehind: true,
1827
+ alias: [lang, 'language-' + lang],
1828
+ inside: Prism.languages[lang]
1829
+ },
1830
+ 'punctuation': [
1831
+ {
1832
+ pattern: /^=/,
1833
+ alias: 'attr-equals'
1834
+ },
1835
+ /"|'/
1836
+ ]
1837
+ }
1838
+ }
1839
+ }
1840
+ });
1841
+ }
1842
+ });
1843
+
1844
+ Prism.languages.html = Prism.languages.markup;
1845
+ Prism.languages.mathml = Prism.languages.markup;
1846
+ Prism.languages.svg = Prism.languages.markup;
1847
+
1848
+ Prism.languages.xml = Prism.languages.extend('markup', {});
1849
+ Prism.languages.ssml = Prism.languages.xml;
1850
+ Prism.languages.atom = Prism.languages.xml;
1851
+ Prism.languages.rss = Prism.languages.xml;
1852
+
1853
+
1854
+ /* **********************************************
1855
+ Begin prism-css.js
1856
+ ********************************************** */
1857
+
1858
+ (function (Prism) {
1859
+
1860
+ var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
1861
+
1862
+ Prism.languages.css = {
1863
+ 'comment': /\/\*[\s\S]*?\*\//,
1864
+ 'atrule': {
1865
+ pattern: RegExp('@[\\w-](?:' + /[^;{\s"']|\s+(?!\s)/.source + '|' + string.source + ')*?' + /(?:;|(?=\s*\{))/.source),
1866
+ inside: {
1867
+ 'rule': /^@[\w-]+/,
1868
+ 'selector-function-argument': {
1869
+ pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
1870
+ lookbehind: true,
1871
+ alias: 'selector'
1872
+ },
1873
+ 'keyword': {
1874
+ pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
1875
+ lookbehind: true
1876
+ }
1877
+ // See rest below
1878
+ }
1879
+ },
1880
+ 'url': {
1881
+ // https://drafts.csswg.org/css-values-3/#urls
1882
+ pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'),
1883
+ greedy: true,
1884
+ inside: {
1885
+ 'function': /^url/i,
1886
+ 'punctuation': /^\(|\)$/,
1887
+ 'string': {
1888
+ pattern: RegExp('^' + string.source + '$'),
1889
+ alias: 'url'
1890
+ }
1891
+ }
1892
+ },
1893
+ 'selector': {
1894
+ pattern: RegExp('(^|[{}\\s])[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + string.source + ')*(?=\\s*\\{)'),
1895
+ lookbehind: true
1896
+ },
1897
+ 'string': {
1898
+ pattern: string,
1899
+ greedy: true
1900
+ },
1901
+ 'property': {
1902
+ pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
1903
+ lookbehind: true
1904
+ },
1905
+ 'important': /!important\b/i,
1906
+ 'function': {
1907
+ pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
1908
+ lookbehind: true
1909
+ },
1910
+ 'punctuation': /[(){};:,]/
1911
+ };
1912
+
1913
+ Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
1914
+
1915
+ var markup = Prism.languages.markup;
1916
+ if (markup) {
1917
+ markup.tag.addInlined('style', 'css');
1918
+ markup.tag.addAttribute('style', 'css');
1919
+ }
1920
+
1921
+ }(Prism));
1922
+
1923
+
1924
+ /* **********************************************
1925
+ Begin prism-clike.js
1926
+ ********************************************** */
1927
+
1928
+ Prism.languages.clike = {
1929
+ 'comment': [
1930
+ {
1931
+ pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
1932
+ lookbehind: true,
1933
+ greedy: true
1934
+ },
1935
+ {
1936
+ pattern: /(^|[^\\:])\/\/.*/,
1937
+ lookbehind: true,
1938
+ greedy: true
1939
+ }
1940
+ ],
1941
+ 'string': {
1942
+ pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
1943
+ greedy: true
1944
+ },
1945
+ 'class-name': {
1946
+ pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
1947
+ lookbehind: true,
1948
+ inside: {
1949
+ 'punctuation': /[.\\]/
1950
+ }
1951
+ },
1952
+ 'keyword': /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
1953
+ 'boolean': /\b(?:false|true)\b/,
1954
+ 'function': /\b\w+(?=\()/,
1955
+ 'number': /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
1956
+ 'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
1957
+ 'punctuation': /[{}[\];(),.:]/
1958
+ };
1959
+
1960
+
1961
+ /* **********************************************
1962
+ Begin prism-javascript.js
1963
+ ********************************************** */
1964
+
1965
+ Prism.languages.javascript = Prism.languages.extend('clike', {
1966
+ 'class-name': [
1967
+ Prism.languages.clike['class-name'],
1968
+ {
1969
+ pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
1970
+ lookbehind: true
1971
+ }
1972
+ ],
1973
+ 'keyword': [
1974
+ {
1975
+ pattern: /((?:^|\})\s*)catch\b/,
1976
+ lookbehind: true
1977
+ },
1978
+ {
1979
+ pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
1980
+ lookbehind: true
1981
+ },
1982
+ ],
1983
+ // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
1984
+ 'function': /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
1985
+ 'number': {
1986
+ pattern: RegExp(
1987
+ /(^|[^\w$])/.source +
1988
+ '(?:' +
1989
+ (
1990
+ // constant
1991
+ /NaN|Infinity/.source +
1992
+ '|' +
1993
+ // binary integer
1994
+ /0[bB][01]+(?:_[01]+)*n?/.source +
1995
+ '|' +
1996
+ // octal integer
1997
+ /0[oO][0-7]+(?:_[0-7]+)*n?/.source +
1998
+ '|' +
1999
+ // hexadecimal integer
2000
+ /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source +
2001
+ '|' +
2002
+ // decimal bigint
2003
+ /\d+(?:_\d+)*n/.source +
2004
+ '|' +
2005
+ // decimal number (integer or float) but no bigint
2006
+ /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source
2007
+ ) +
2008
+ ')' +
2009
+ /(?![\w$])/.source
2010
+ ),
2011
+ lookbehind: true
2012
+ },
2013
+ 'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
2014
+ });
2015
+
2016
+ Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
2017
+
2018
+ Prism.languages.insertBefore('javascript', 'keyword', {
2019
+ 'regex': {
2020
+ pattern: RegExp(
2021
+ // lookbehind
2022
+ // eslint-disable-next-line regexp/no-dupe-characters-character-class
2023
+ /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source +
2024
+ // Regex pattern:
2025
+ // There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
2026
+ // classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
2027
+ // with the only syntax, so we have to define 2 different regex patterns.
2028
+ /\//.source +
2029
+ '(?:' +
2030
+ /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source +
2031
+ '|' +
2032
+ // `v` flag syntax. This supports 3 levels of nested character classes.
2033
+ /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source +
2034
+ ')' +
2035
+ // lookahead
2036
+ /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
2037
+ ),
2038
+ lookbehind: true,
2039
+ greedy: true,
2040
+ inside: {
2041
+ 'regex-source': {
2042
+ pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
2043
+ lookbehind: true,
2044
+ alias: 'language-regex',
2045
+ inside: Prism.languages.regex
2046
+ },
2047
+ 'regex-delimiter': /^\/|\/$/,
2048
+ 'regex-flags': /^[a-z]+$/,
2049
+ }
2050
+ },
2051
+ // This must be declared before keyword because we use "function" inside the look-forward
2052
+ 'function-variable': {
2053
+ pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
2054
+ alias: 'function'
2055
+ },
2056
+ 'parameter': [
2057
+ {
2058
+ pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
2059
+ lookbehind: true,
2060
+ inside: Prism.languages.javascript
2061
+ },
2062
+ {
2063
+ pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
2064
+ lookbehind: true,
2065
+ inside: Prism.languages.javascript
2066
+ },
2067
+ {
2068
+ pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
2069
+ lookbehind: true,
2070
+ inside: Prism.languages.javascript
2071
+ },
2072
+ {
2073
+ pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,
2074
+ lookbehind: true,
2075
+ inside: Prism.languages.javascript
2076
+ }
2077
+ ],
2078
+ 'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
2079
+ });
2080
+
2081
+ Prism.languages.insertBefore('javascript', 'string', {
2082
+ 'hashbang': {
2083
+ pattern: /^#!.*/,
2084
+ greedy: true,
2085
+ alias: 'comment'
2086
+ },
2087
+ 'template-string': {
2088
+ pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
2089
+ greedy: true,
2090
+ inside: {
2091
+ 'template-punctuation': {
2092
+ pattern: /^`|`$/,
2093
+ alias: 'string'
2094
+ },
2095
+ 'interpolation': {
2096
+ pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
2097
+ lookbehind: true,
2098
+ inside: {
2099
+ 'interpolation-punctuation': {
2100
+ pattern: /^\$\{|\}$/,
2101
+ alias: 'punctuation'
2102
+ },
2103
+ rest: Prism.languages.javascript
2104
+ }
2105
+ },
2106
+ 'string': /[\s\S]+/
2107
+ }
2108
+ },
2109
+ 'string-property': {
2110
+ pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
2111
+ lookbehind: true,
2112
+ greedy: true,
2113
+ alias: 'property'
2114
+ }
2115
+ });
2116
+
2117
+ Prism.languages.insertBefore('javascript', 'operator', {
2118
+ 'literal-property': {
2119
+ pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
2120
+ lookbehind: true,
2121
+ alias: 'property'
2122
+ },
2123
+ });
2124
+
2125
+ if (Prism.languages.markup) {
2126
+ Prism.languages.markup.tag.addInlined('script', 'javascript');
2127
+
2128
+ // add attribute support for all DOM events.
2129
+ // https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events
2130
+ Prism.languages.markup.tag.addAttribute(
2131
+ /on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,
2132
+ 'javascript'
2133
+ );
2134
+ }
2135
+
2136
+ Prism.languages.js = Prism.languages.javascript;
2137
+
2138
+
2139
+ /* **********************************************
2140
+ Begin prism-file-highlight.js
2141
+ ********************************************** */
2142
+
2143
+ (function () {
2144
+
2145
+ if (typeof Prism === 'undefined' || typeof document === 'undefined') {
2146
+ return;
2147
+ }
2148
+
2149
+ // https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill
2150
+ if (!Element.prototype.matches) {
2151
+ Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
2152
+ }
2153
+
2154
+ var LOADING_MESSAGE = 'Loading…';
2155
+ var FAILURE_MESSAGE = function (status, message) {
2156
+ return '✖ Error ' + status + ' while fetching file: ' + message;
2157
+ };
2158
+ var FAILURE_EMPTY_MESSAGE = '✖ Error: File does not exist or is empty';
2159
+
2160
+ var EXTENSIONS = {
2161
+ 'js': 'javascript',
2162
+ 'py': 'python',
2163
+ 'rb': 'ruby',
2164
+ 'ps1': 'powershell',
2165
+ 'psm1': 'powershell',
2166
+ 'sh': 'bash',
2167
+ 'bat': 'batch',
2168
+ 'h': 'c',
2169
+ 'tex': 'latex'
2170
+ };
2171
+
2172
+ var STATUS_ATTR = 'data-src-status';
2173
+ var STATUS_LOADING = 'loading';
2174
+ var STATUS_LOADED = 'loaded';
2175
+ var STATUS_FAILED = 'failed';
2176
+
2177
+ var SELECTOR = 'pre[data-src]:not([' + STATUS_ATTR + '="' + STATUS_LOADED + '"])'
2178
+ + ':not([' + STATUS_ATTR + '="' + STATUS_LOADING + '"])';
2179
+
2180
+ /**
2181
+ * Loads the given file.
2182
+ *
2183
+ * @param {string} src The URL or path of the source file to load.
2184
+ * @param {(result: string) => void} success
2185
+ * @param {(reason: string) => void} error
2186
+ */
2187
+ function loadFile(src, success, error) {
2188
+ var xhr = new XMLHttpRequest();
2189
+ xhr.open('GET', src, true);
2190
+ xhr.onreadystatechange = function () {
2191
+ if (xhr.readyState == 4) {
2192
+ if (xhr.status < 400 && xhr.responseText) {
2193
+ success(xhr.responseText);
2194
+ } else {
2195
+ if (xhr.status >= 400) {
2196
+ error(FAILURE_MESSAGE(xhr.status, xhr.statusText));
2197
+ } else {
2198
+ error(FAILURE_EMPTY_MESSAGE);
2199
+ }
2200
+ }
2201
+ }
2202
+ };
2203
+ xhr.send(null);
2204
+ }
2205
+
2206
+ /**
2207
+ * Parses the given range.
2208
+ *
2209
+ * This returns a range with inclusive ends.
2210
+ *
2211
+ * @param {string | null | undefined} range
2212
+ * @returns {[number, number | undefined] | undefined}
2213
+ */
2214
+ function parseRange(range) {
2215
+ var m = /^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(range || '');
2216
+ if (m) {
2217
+ var start = Number(m[1]);
2218
+ var comma = m[2];
2219
+ var end = m[3];
2220
+
2221
+ if (!comma) {
2222
+ return [start, start];
2223
+ }
2224
+ if (!end) {
2225
+ return [start, undefined];
2226
+ }
2227
+ return [start, Number(end)];
2228
+ }
2229
+ return undefined;
2230
+ }
2231
+
2232
+ Prism.hooks.add('before-highlightall', function (env) {
2233
+ env.selector += ', ' + SELECTOR;
2234
+ });
2235
+
2236
+ Prism.hooks.add('before-sanity-check', function (env) {
2237
+ var pre = /** @type {HTMLPreElement} */ (env.element);
2238
+ if (pre.matches(SELECTOR)) {
2239
+ env.code = ''; // fast-path the whole thing and go to complete
2240
+
2241
+ pre.setAttribute(STATUS_ATTR, STATUS_LOADING); // mark as loading
2242
+
2243
+ // add code element with loading message
2244
+ var code = pre.appendChild(document.createElement('CODE'));
2245
+ code.textContent = LOADING_MESSAGE;
2246
+
2247
+ var src = pre.getAttribute('data-src');
2248
+
2249
+ var language = env.language;
2250
+ if (language === 'none') {
2251
+ // the language might be 'none' because there is no language set;
2252
+ // in this case, we want to use the extension as the language
2253
+ var extension = (/\.(\w+)$/.exec(src) || [, 'none'])[1];
2254
+ language = EXTENSIONS[extension] || extension;
2255
+ }
2256
+
2257
+ // set language classes
2258
+ Prism.util.setLanguage(code, language);
2259
+ Prism.util.setLanguage(pre, language);
2260
+
2261
+ // preload the language
2262
+ var autoloader = Prism.plugins.autoloader;
2263
+ if (autoloader) {
2264
+ autoloader.loadLanguages(language);
2265
+ }
2266
+
2267
+ // load file
2268
+ loadFile(
2269
+ src,
2270
+ function (text) {
2271
+ // mark as loaded
2272
+ pre.setAttribute(STATUS_ATTR, STATUS_LOADED);
2273
+
2274
+ // handle data-range
2275
+ var range = parseRange(pre.getAttribute('data-range'));
2276
+ if (range) {
2277
+ var lines = text.split(/\r\n?|\n/g);
2278
+
2279
+ // the range is one-based and inclusive on both ends
2280
+ var start = range[0];
2281
+ var end = range[1] == null ? lines.length : range[1];
2282
+
2283
+ if (start < 0) { start += lines.length; }
2284
+ start = Math.max(0, Math.min(start - 1, lines.length));
2285
+ if (end < 0) { end += lines.length; }
2286
+ end = Math.max(0, Math.min(end, lines.length));
2287
+
2288
+ text = lines.slice(start, end).join('\n');
2289
+
2290
+ // add data-start for line numbers
2291
+ if (!pre.hasAttribute('data-start')) {
2292
+ pre.setAttribute('data-start', String(start + 1));
2293
+ }
2294
+ }
2295
+
2296
+ // highlight code
2297
+ code.textContent = text;
2298
+ Prism.highlightElement(code);
2299
+ },
2300
+ function (error) {
2301
+ // mark as failed
2302
+ pre.setAttribute(STATUS_ATTR, STATUS_FAILED);
2303
+
2304
+ code.textContent = error;
2305
+ }
2306
+ );
2307
+ }
2308
+ });
2309
+
2310
+ Prism.plugins.fileHighlight = {
2311
+ /**
2312
+ * Executes the File Highlight plugin for all matching `pre` elements under the given container.
2313
+ *
2314
+ * Note: Elements which are already loaded or currently loading will not be touched by this method.
2315
+ *
2316
+ * @param {ParentNode} [container=document]
2317
+ */
2318
+ highlight: function highlight(container) {
2319
+ var elements = (container || document).querySelectorAll(SELECTOR);
2320
+
2321
+ for (var i = 0, element; (element = elements[i++]);) {
2322
+ Prism.highlightElement(element);
2323
+ }
2324
+ }
2325
+ };
2326
+
2327
+ var logged = false;
2328
+ /** @deprecated Use `Prism.plugins.fileHighlight.highlight` instead. */
2329
+ Prism.fileHighlight = function () {
2330
+ if (!logged) {
2331
+ console.warn('Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead.');
2332
+ logged = true;
2333
+ }
2334
+ Prism.plugins.fileHighlight.highlight.apply(this, arguments);
2335
+ };
2336
+
2337
+ }());
2338
+ } (prism));
2339
+
2340
+ var Prism = prism.exports;
2341
+
2342
+ var css = "code[class*=language-],pre[class*=language-]{word-wrap:normal;background:none;color:#ccc;font-family:Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace;font-size:1em;-webkit-hyphens:none;hyphens:none;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;text-align:left;white-space:pre;word-break:normal;word-spacing:normal}pre[class*=language-]{margin:.5em 0;overflow:auto;padding:1em}:not(pre)>code[class*=language-],pre[class*=language-]{background:#2d2d2d}:not(pre)>code[class*=language-]{border-radius:.3em;padding:.1em;white-space:normal}.token.block-comment,.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#999}.token.punctuation{color:#ccc}.token.attr-name,.token.deleted,.token.namespace,.token.tag{color:#e2777a}.token.function-name{color:#6196cc}.token.boolean,.token.function,.token.number{color:#f08d49}.token.class-name,.token.constant,.token.property,.token.symbol{color:#f8c555}.token.atrule,.token.builtin,.token.important,.token.keyword,.token.selector{color:#cc99cd}.token.attr-value,.token.char,.token.regex,.token.string,.token.variable{color:#7ec699}.token.entity,.token.operator,.token.url{color:#67cdcc}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}.token.inserted{color:green}";
2343
+ n(css,{});
2344
+
2345
+ var SyntaxHighlighter = function SyntaxHighlighter(_ref) {
2346
+ var className = _ref.className,
2347
+ code = _ref.code,
2348
+ language = _ref.language;
2349
+ React.useEffect(function () {
2350
+ Prism.highlightAll();
2351
+ }, [code]);
2352
+ return /*#__PURE__*/React__default["default"].createElement("pre", {
2353
+ className: className
2354
+ }, /*#__PURE__*/React__default["default"].createElement("code", {
2355
+ className: "language-".concat(language)
2356
+ }, code));
2357
+ };
2358
+ var SyntaxHighlighter$1 = /*#__PURE__*/React__default["default"].memo(SyntaxHighlighter);
2359
+
2360
+ var CodeBlock = function CodeBlock(_ref) {
2361
+ var _ref$title = _ref.title,
2362
+ title = _ref$title === void 0 ? /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement(reactI18next.Trans, {
2363
+ i18nKey: "neetoMolecules.codeblock.codeSnippet"
2364
+ })) : _ref$title,
2365
+ codeString = _ref.codeString,
2366
+ _ref$showCopyButton = _ref.showCopyButton,
2367
+ showCopyButton = _ref$showCopyButton === void 0 ? true : _ref$showCopyButton,
2368
+ _ref$className = _ref.className,
2369
+ className = _ref$className === void 0 ? "" : _ref$className,
2370
+ _ref$sendViaEmail = _ref.sendViaEmail,
2371
+ sendViaEmail = _ref$sendViaEmail === void 0 ? undefined : _ref$sendViaEmail,
2372
+ _ref$frameworkProps = _ref.frameworkProps,
2373
+ frameworkProps = _ref$frameworkProps === void 0 ? {} : _ref$frameworkProps;
2374
+ var _useState = React.useState(false),
2375
+ _useState2 = _slicedToArray(_useState, 2),
2376
+ isCopied = _useState2[0],
2377
+ setIsCopied = _useState2[1];
2378
+ var _useTranslation = reactI18next.useTranslation(),
2379
+ t = _useTranslation.t;
2380
+ var _ref2 = frameworkProps !== null && frameworkProps !== void 0 ? frameworkProps : {},
2381
+ selectedFramework = _ref2.selectedFramework,
2382
+ setSelectedFramework = _ref2.setSelectedFramework;
2383
+ React.useEffect(function () {
2384
+ if (!isCopied) return undefined;
2385
+ var timer = setTimeout(function () {
2386
+ return setIsCopied(false);
2387
+ }, 1000);
2388
+ return function () {
2389
+ return clearTimeout(timer);
2390
+ };
2391
+ }, [isCopied]);
2392
+ return /*#__PURE__*/React__default["default"].createElement("div", {
2393
+ className: classnames(["relative", className])
2394
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
2395
+ className: "neeto-ui-bg-primary-100 neeto-ui-rounded-lg flex w-full flex-wrap items-center justify-between gap-2 rounded-b-none p-3"
2396
+ }, title && /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
2397
+ className: "m-0 flex-shrink-0",
2398
+ "data-cy": "code-block-title-text",
2399
+ style: "h4"
2400
+ }, title), selectedFramework && /*#__PURE__*/React__default["default"].createElement(neetoui.Select, {
2401
+ className: "w-40",
2402
+ "data-testid": "framework-select",
2403
+ options: FRAMEWORK_SELECT_OPTIONS,
2404
+ value: selectedFramework,
2405
+ onChange: setSelectedFramework
2406
+ }), /*#__PURE__*/React__default["default"].createElement("div", {
2407
+ className: "ml-auto flex flex-shrink-0 items-center justify-end gap-2"
2408
+ }, sendViaEmail ? /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
2409
+ style: "text",
2410
+ label: t("neetoMolecules.widget.installation.snippet.sendViaEmail"),
2411
+ onClick: sendViaEmail
2412
+ }) : null, showCopyButton && /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
2413
+ icon: isCopied ? neetoIcons.Check : neetoIcons.Copy,
2414
+ style: "primary",
2415
+ label: isCopied ? t("neetoMolecules.widget.installation.snippet.copied") : t("neetoMolecules.widget.installation.snippet.copy"),
2416
+ onClick: function onClick() {
2417
+ return utils.copyToClipboard(codeString);
2418
+ }
2419
+ }))), /*#__PURE__*/React__default["default"].createElement(SyntaxHighlighter$1, {
2420
+ className: "neeto-ui-bg-gray-800 neeto-ui-rounded-lg m-0 rounded-t-none",
2421
+ code: codeString,
2422
+ language: "javascript"
2423
+ }));
2424
+ };
2425
+
2426
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2427
+ try {
2428
+ var info = gen[key](arg);
2429
+ var value = info.value;
2430
+ } catch (error) {
2431
+ reject(error);
2432
+ return;
2433
+ }
2434
+ if (info.done) {
2435
+ resolve(value);
2436
+ } else {
2437
+ Promise.resolve(value).then(_next, _throw);
2438
+ }
2439
+ }
2440
+ function _asyncToGenerator(fn) {
2441
+ return function () {
2442
+ var self = this,
2443
+ args = arguments;
2444
+ return new Promise(function (resolve, reject) {
2445
+ var gen = fn.apply(self, args);
2446
+ function _next(value) {
2447
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
2448
+ }
2449
+ function _throw(err) {
2450
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
2451
+ }
2452
+ _next(undefined);
2453
+ });
2454
+ };
2455
+ }
2456
+
2457
+ var regeneratorRuntime$1 = {exports: {}};
2458
+
2459
+ var _typeof = {exports: {}};
2460
+
2461
+ (function (module) {
2462
+ function _typeof(obj) {
2463
+ "@babel/helpers - typeof";
2464
+
2465
+ return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
2466
+ return typeof obj;
2467
+ } : function (obj) {
2468
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
2469
+ }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
2470
+ }
2471
+ module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
2472
+ } (_typeof));
2473
+
2474
+ (function (module) {
2475
+ var _typeof$1 = _typeof.exports["default"];
2476
+ function _regeneratorRuntime() {
2477
+ module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
2478
+ return exports;
2479
+ }, module.exports.__esModule = true, module.exports["default"] = module.exports;
2480
+ var exports = {},
2481
+ Op = Object.prototype,
2482
+ hasOwn = Op.hasOwnProperty,
2483
+ defineProperty = Object.defineProperty || function (obj, key, desc) {
2484
+ obj[key] = desc.value;
2485
+ },
2486
+ $Symbol = "function" == typeof Symbol ? Symbol : {},
2487
+ iteratorSymbol = $Symbol.iterator || "@@iterator",
2488
+ asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
2489
+ toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
2490
+ function define(obj, key, value) {
2491
+ return Object.defineProperty(obj, key, {
2492
+ value: value,
2493
+ enumerable: !0,
2494
+ configurable: !0,
2495
+ writable: !0
2496
+ }), obj[key];
2497
+ }
2498
+ try {
2499
+ define({}, "");
2500
+ } catch (err) {
2501
+ define = function define(obj, key, value) {
2502
+ return obj[key] = value;
2503
+ };
2504
+ }
2505
+ function wrap(innerFn, outerFn, self, tryLocsList) {
2506
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
2507
+ generator = Object.create(protoGenerator.prototype),
2508
+ context = new Context(tryLocsList || []);
2509
+ return defineProperty(generator, "_invoke", {
2510
+ value: makeInvokeMethod(innerFn, self, context)
2511
+ }), generator;
2512
+ }
2513
+ function tryCatch(fn, obj, arg) {
2514
+ try {
2515
+ return {
2516
+ type: "normal",
2517
+ arg: fn.call(obj, arg)
2518
+ };
2519
+ } catch (err) {
2520
+ return {
2521
+ type: "throw",
2522
+ arg: err
2523
+ };
2524
+ }
2525
+ }
2526
+ exports.wrap = wrap;
2527
+ var ContinueSentinel = {};
2528
+ function Generator() {}
2529
+ function GeneratorFunction() {}
2530
+ function GeneratorFunctionPrototype() {}
2531
+ var IteratorPrototype = {};
2532
+ define(IteratorPrototype, iteratorSymbol, function () {
2533
+ return this;
2534
+ });
2535
+ var getProto = Object.getPrototypeOf,
2536
+ NativeIteratorPrototype = getProto && getProto(getProto(values([])));
2537
+ NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
2538
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
2539
+ function defineIteratorMethods(prototype) {
2540
+ ["next", "throw", "return"].forEach(function (method) {
2541
+ define(prototype, method, function (arg) {
2542
+ return this._invoke(method, arg);
2543
+ });
2544
+ });
2545
+ }
2546
+ function AsyncIterator(generator, PromiseImpl) {
2547
+ function invoke(method, arg, resolve, reject) {
2548
+ var record = tryCatch(generator[method], generator, arg);
2549
+ if ("throw" !== record.type) {
2550
+ var result = record.arg,
2551
+ value = result.value;
2552
+ return value && "object" == _typeof$1(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
2553
+ invoke("next", value, resolve, reject);
2554
+ }, function (err) {
2555
+ invoke("throw", err, resolve, reject);
2556
+ }) : PromiseImpl.resolve(value).then(function (unwrapped) {
2557
+ result.value = unwrapped, resolve(result);
2558
+ }, function (error) {
2559
+ return invoke("throw", error, resolve, reject);
2560
+ });
2561
+ }
2562
+ reject(record.arg);
2563
+ }
2564
+ var previousPromise;
2565
+ defineProperty(this, "_invoke", {
2566
+ value: function value(method, arg) {
2567
+ function callInvokeWithMethodAndArg() {
2568
+ return new PromiseImpl(function (resolve, reject) {
2569
+ invoke(method, arg, resolve, reject);
2570
+ });
2571
+ }
2572
+ return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
2573
+ }
2574
+ });
2575
+ }
2576
+ function makeInvokeMethod(innerFn, self, context) {
2577
+ var state = "suspendedStart";
2578
+ return function (method, arg) {
2579
+ if ("executing" === state) throw new Error("Generator is already running");
2580
+ if ("completed" === state) {
2581
+ if ("throw" === method) throw arg;
2582
+ return doneResult();
2583
+ }
2584
+ for (context.method = method, context.arg = arg;;) {
2585
+ var delegate = context.delegate;
2586
+ if (delegate) {
2587
+ var delegateResult = maybeInvokeDelegate(delegate, context);
2588
+ if (delegateResult) {
2589
+ if (delegateResult === ContinueSentinel) continue;
2590
+ return delegateResult;
2591
+ }
2592
+ }
2593
+ if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
2594
+ if ("suspendedStart" === state) throw state = "completed", context.arg;
2595
+ context.dispatchException(context.arg);
2596
+ } else "return" === context.method && context.abrupt("return", context.arg);
2597
+ state = "executing";
2598
+ var record = tryCatch(innerFn, self, context);
2599
+ if ("normal" === record.type) {
2600
+ if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
2601
+ return {
2602
+ value: record.arg,
2603
+ done: context.done
2604
+ };
2605
+ }
2606
+ "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
2607
+ }
2608
+ };
2609
+ }
2610
+ function maybeInvokeDelegate(delegate, context) {
2611
+ var methodName = context.method,
2612
+ method = delegate.iterator[methodName];
2613
+ if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
2614
+ var record = tryCatch(method, delegate.iterator, context.arg);
2615
+ if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
2616
+ var info = record.arg;
2617
+ return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
2618
+ }
2619
+ function pushTryEntry(locs) {
2620
+ var entry = {
2621
+ tryLoc: locs[0]
2622
+ };
2623
+ 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
2624
+ }
2625
+ function resetTryEntry(entry) {
2626
+ var record = entry.completion || {};
2627
+ record.type = "normal", delete record.arg, entry.completion = record;
2628
+ }
2629
+ function Context(tryLocsList) {
2630
+ this.tryEntries = [{
2631
+ tryLoc: "root"
2632
+ }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
2633
+ }
2634
+ function values(iterable) {
2635
+ if (iterable) {
2636
+ var iteratorMethod = iterable[iteratorSymbol];
2637
+ if (iteratorMethod) return iteratorMethod.call(iterable);
2638
+ if ("function" == typeof iterable.next) return iterable;
2639
+ if (!isNaN(iterable.length)) {
2640
+ var i = -1,
2641
+ next = function next() {
2642
+ for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
2643
+ return next.value = undefined, next.done = !0, next;
2644
+ };
2645
+ return next.next = next;
2646
+ }
2647
+ }
2648
+ return {
2649
+ next: doneResult
2650
+ };
2651
+ }
2652
+ function doneResult() {
2653
+ return {
2654
+ value: undefined,
2655
+ done: !0
2656
+ };
2657
+ }
2658
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
2659
+ value: GeneratorFunctionPrototype,
2660
+ configurable: !0
2661
+ }), defineProperty(GeneratorFunctionPrototype, "constructor", {
2662
+ value: GeneratorFunction,
2663
+ configurable: !0
2664
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
2665
+ var ctor = "function" == typeof genFun && genFun.constructor;
2666
+ return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
2667
+ }, exports.mark = function (genFun) {
2668
+ return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
2669
+ }, exports.awrap = function (arg) {
2670
+ return {
2671
+ __await: arg
2672
+ };
2673
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
2674
+ return this;
2675
+ }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
2676
+ void 0 === PromiseImpl && (PromiseImpl = Promise);
2677
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
2678
+ return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
2679
+ return result.done ? result.value : iter.next();
2680
+ });
2681
+ }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
2682
+ return this;
2683
+ }), define(Gp, "toString", function () {
2684
+ return "[object Generator]";
2685
+ }), exports.keys = function (val) {
2686
+ var object = Object(val),
2687
+ keys = [];
2688
+ for (var key in object) keys.push(key);
2689
+ return keys.reverse(), function next() {
2690
+ for (; keys.length;) {
2691
+ var key = keys.pop();
2692
+ if (key in object) return next.value = key, next.done = !1, next;
2693
+ }
2694
+ return next.done = !0, next;
2695
+ };
2696
+ }, exports.values = values, Context.prototype = {
2697
+ constructor: Context,
2698
+ reset: function reset(skipTempReset) {
2699
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
2700
+ },
2701
+ stop: function stop() {
2702
+ this.done = !0;
2703
+ var rootRecord = this.tryEntries[0].completion;
2704
+ if ("throw" === rootRecord.type) throw rootRecord.arg;
2705
+ return this.rval;
2706
+ },
2707
+ dispatchException: function dispatchException(exception) {
2708
+ if (this.done) throw exception;
2709
+ var context = this;
2710
+ function handle(loc, caught) {
2711
+ return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
2712
+ }
2713
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
2714
+ var entry = this.tryEntries[i],
2715
+ record = entry.completion;
2716
+ if ("root" === entry.tryLoc) return handle("end");
2717
+ if (entry.tryLoc <= this.prev) {
2718
+ var hasCatch = hasOwn.call(entry, "catchLoc"),
2719
+ hasFinally = hasOwn.call(entry, "finallyLoc");
2720
+ if (hasCatch && hasFinally) {
2721
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
2722
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
2723
+ } else if (hasCatch) {
2724
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
2725
+ } else {
2726
+ if (!hasFinally) throw new Error("try statement without catch or finally");
2727
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
2728
+ }
2729
+ }
2730
+ }
2731
+ },
2732
+ abrupt: function abrupt(type, arg) {
2733
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
2734
+ var entry = this.tryEntries[i];
2735
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
2736
+ var finallyEntry = entry;
2737
+ break;
2738
+ }
2739
+ }
2740
+ finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
2741
+ var record = finallyEntry ? finallyEntry.completion : {};
2742
+ return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
2743
+ },
2744
+ complete: function complete(record, afterLoc) {
2745
+ if ("throw" === record.type) throw record.arg;
2746
+ return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
2747
+ },
2748
+ finish: function finish(finallyLoc) {
2749
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
2750
+ var entry = this.tryEntries[i];
2751
+ if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
2752
+ }
2753
+ },
2754
+ "catch": function _catch(tryLoc) {
2755
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
2756
+ var entry = this.tryEntries[i];
2757
+ if (entry.tryLoc === tryLoc) {
2758
+ var record = entry.completion;
2759
+ if ("throw" === record.type) {
2760
+ var thrown = record.arg;
2761
+ resetTryEntry(entry);
2762
+ }
2763
+ return thrown;
2764
+ }
2765
+ }
2766
+ throw new Error("illegal catch attempt");
2767
+ },
2768
+ delegateYield: function delegateYield(iterable, resultName, nextLoc) {
2769
+ return this.delegate = {
2770
+ iterator: values(iterable),
2771
+ resultName: resultName,
2772
+ nextLoc: nextLoc
2773
+ }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
2774
+ }
2775
+ }, exports;
2776
+ }
2777
+ module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
2778
+ } (regeneratorRuntime$1));
2779
+
2780
+ // TODO(Babel 8): Remove this file.
2781
+
2782
+ var runtime = regeneratorRuntime$1.exports();
2783
+ var regenerator = runtime;
2784
+
2785
+ // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
2786
+ try {
2787
+ regeneratorRuntime = runtime;
2788
+ } catch (accidentalStrictMode) {
2789
+ if (typeof globalThis === "object") {
2790
+ globalThis.regeneratorRuntime = runtime;
2791
+ } else {
2792
+ Function("r", "regeneratorRuntime = r")(runtime);
2793
+ }
2794
+ }
2795
+
2796
+ var buildEmbedWidgetScript = function buildEmbedWidgetScript() {
2797
+ var widgetScriptUrl = window.globalProps.railsEnv === RAILS_ENV.production ? NEETO_WIDGET_SCRIPT_URL.production : NEETO_WIDGET_SCRIPT_URL.staging;
2798
+ return "<script src=\"".concat(widgetScriptUrl, "\"></script>");
2799
+ };
2800
+ var indentAndFormat = function indentAndFormat(str) {
2801
+ var formatter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ramda.identity;
2802
+ return str.split("\n").map(formatter).join("\n ");
2803
+ };
2804
+ var getCommentedCommand = function getCommentedCommand(command, isEnabled) {
2805
+ return isEnabled ? command : "/// ".concat(command);
2806
+ };
2807
+ var embedWidgetEnvironment = function embedWidgetEnvironment() {
2808
+ switch (window.globalProps.railsEnv) {
2809
+ case RAILS_ENV.production:
2810
+ return "";
2811
+ case RAILS_ENV.development:
2812
+ return "environment: \"".concat(RAILS_ENV.development, "\",");
2813
+ case RAILS_ENV.staging:
2814
+ return "environment: \"".concat(RAILS_ENV.staging, "\",");
2815
+ default:
2816
+ return "/* Unidentified RAILS_ENV, */";
2817
+ }
2818
+ };
2819
+ var embedWidgetApiKey = function embedWidgetApiKey(apiKey) {
2820
+ return "apiKey: \"".concat(apiKey, "\",");
2821
+ };
2822
+ var addChangelogOptions = function addChangelogOptions() {
2823
+ return "neetoChangelogOptions: {\n elementId: \"neetochangelog-trigger\",\n},";
2824
+ };
2825
+ var wrapBlockInOnLoad = function wrapBlockInOnLoad(codeBlock) {
2826
+ return "window.addEventListener(\"load\", () => ".concat(codeBlock, ");");
2827
+ };
2828
+ var embedWidgetFunctionCall = function embedWidgetFunctionCall(enabledWidgets, apiKey) {
2829
+ return "embedNeetoWidget({\n ".concat(embedWidgetEnvironment(), "\n ").concat(indentAndFormat(embedWidgetApiKey(apiKey)), "\n ").concat(indentAndFormat(addChangelogOptions(), function (cmd) {
2830
+ return getCommentedCommand(cmd, enabledWidgets.changelog);
2831
+ }), "\n})");
2832
+ };
2833
+ var filterMarkedCommands = function filterMarkedCommands(queryString) {
2834
+ return queryString.split("\n").filter(function (line) {
2835
+ return !line.includes("///") && line.trim();
2836
+ }).join("\n");
2837
+ };
2838
+ var getSampleUserIdentity = function getSampleUserIdentity(enabledWidgets, selectedFramework) {
2839
+ var splitCodeLines = SAMPLE_USER_IDENTITY_CODE_STRING[selectedFramework].split("\n");
2840
+ return filterMarkedCommands(splitCodeLines.map(function (cmd) {
2841
+ var isEmailKey = cmd.includes("email");
2842
+ var isObjectStartLine = cmd === splitCodeLines[0];
2843
+ var isObjectEndLine = cmd === ramda.last(splitCodeLines);
2844
+ var isLineHidden = !isEmailKey && !isObjectStartLine && !isObjectEndLine;
2845
+ if (!enabledWidgets.chat && isLineHidden || !enabledWidgets.chat && !enabledWidgets.replay) {
2846
+ return null;
2847
+ }
2848
+ return cmd;
2849
+ }).join("\n"));
2850
+ };
2851
+ var sampleConsolidatedCodeString = function sampleConsolidatedCodeString(enabledWidgets, apiKey) {
2852
+ return filterMarkedCommands("".concat(buildEmbedWidgetScript(), "\n<script>\n ").concat(enabledWidgets.chat || enabledWidgets.replay ? "window.".concat(NEETO_WIDGET_USER_IDENTITY_KEY, " = {};") : "", "\n ").concat(enabledWidgets.replay ? "window.".concat(SESSION_CONTEXT_KEY, " = {};") : "", "\n\n ").concat(indentAndFormat(wrapBlockInOnLoad(embedWidgetFunctionCall(enabledWidgets, apiKey))), "\n</script>"));
2853
+ };
2854
+ var getEmailWidgetSnippetFormInitialValues = function getEmailWidgetSnippetFormInitialValues(subject) {
2855
+ return {
2856
+ emails: "",
2857
+ subject: subject
2858
+ };
2859
+ };
2860
+ var getSortedPrefixedWidgets = function getSortedPrefixedWidgets(widgets) {
2861
+ return widgets.sort().map(function (widget) {
2862
+ return "neeto".concat(pure.capitalize(widget));
2863
+ });
2864
+ };
2865
+ var getEmailWidgetSnippetValidationSchema = function getEmailWidgetSnippetValidationSchema() {
2866
+ return yup__namespace.object({
2867
+ emails: yup__namespace.array().required().label(i18next__default["default"].t("neetoMolecules.widget.email.fields.emails.label")),
2868
+ subject: yup__namespace.string().required().label(i18next__default["default"].t("neetoMolecules.widget.email.fields.subject.label"))
2869
+ });
2870
+ };
2871
+ var getWidgetApiKeyUrl = function getWidgetApiKeyUrl() {
2872
+ return "api/widget/v1/api_keys/".concat(window.globalProps.organization.subdomain);
2873
+ };
2874
+
2875
+ var _require = require("axios"),
2876
+ axios = _require["default"];
2877
+ var queryWidgetApiKey = function queryWidgetApiKey() {
2878
+ return axios.get(getWidgetApiKeyUrl(), {
2879
+ showToastr: false
2880
+ });
2881
+ };
2882
+ var emailWidgetSnippet = function emailWidgetSnippet(data) {
2883
+ return axios.post(EMBED_CODE_EMAIL_URL, data);
2884
+ };
2885
+ var fetchWidgetConfiguration = function fetchWidgetConfiguration() {
2886
+ return axios.get(WIDGET_CONFIG_URL);
2887
+ };
2888
+ var updateWidgetConfiguration = function updateWidgetConfiguration(_ref) {
2889
+ var id = _ref.id,
2890
+ payload = _ref.payload;
2891
+ return axios.put("".concat(WIDGET_CONFIG_URL, "/").concat(id), payload);
2892
+ };
2893
+
2894
+ var useEmailEmbedCode = function useEmailEmbedCode(onSuccess) {
2895
+ return reactQuery.useMutation(function (emailData) {
2896
+ return emailWidgetSnippet(emailData);
2897
+ }, {
2898
+ onSuccess: onSuccess
2899
+ });
2900
+ };
2901
+
2902
+ var CodeSnippet = function CodeSnippet(_ref) {
2903
+ var isPaneOpen = _ref.isPaneOpen,
2904
+ onClose = _ref.onClose,
2905
+ _ref$onSent = _ref.onSent,
2906
+ onSent = _ref$onSent === void 0 ? pure.noop : _ref$onSent,
2907
+ codeString = _ref.codeString,
2908
+ _ref$subject = _ref.subject,
2909
+ subject = _ref$subject === void 0 ? "" : _ref$subject,
2910
+ _ref$body = _ref.body,
2911
+ body = _ref$body === void 0 ? "" : _ref$body,
2912
+ _ref$emailType = _ref.emailType,
2913
+ emailType = _ref$emailType === void 0 ? EMAIL_TYPES.embedCode : _ref$emailType,
2914
+ _ref$enabledWidgets = _ref.enabledWidgets,
2915
+ enabledWidgets = _ref$enabledWidgets === void 0 ? {} : _ref$enabledWidgets;
2916
+ var _useTranslation = reactI18next.useTranslation(),
2917
+ t = _useTranslation.t;
2918
+ var _useState = React.useState(FRAMEWORK_SELECT_OPTIONS[0]),
2919
+ _useState2 = _slicedToArray(_useState, 2),
2920
+ selectedFramework = _useState2[0],
2921
+ setSelectedFramework = _useState2[1];
2922
+ var emailMutation = useEmailEmbedCode(onSent);
2923
+ var codeToDisplay = emailType === EMAIL_TYPES.userIdentity ? getSampleUserIdentity(enabledWidgets, selectedFramework.value) : codeString;
2924
+ var handleSubmit = /*#__PURE__*/function () {
2925
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(formData) {
2926
+ var _body$ref$current$inn, _body$ref;
2927
+ return regenerator.wrap(function _callee$(_context) {
2928
+ while (1) switch (_context.prev = _context.next) {
2929
+ case 0:
2930
+ if (!ramda.any(function (_ref3) {
2931
+ var valid = _ref3.valid;
2932
+ return !valid;
2933
+ }, formData.emails)) {
2934
+ _context.next = 3;
2935
+ break;
2936
+ }
2937
+ neetoui.Toastr.error(t("neetoMolecules.widget.email.fields.emails.invalidError"));
2938
+ return _context.abrupt("return");
2939
+ case 3:
2940
+ emailMutation.mutate({
2941
+ subject: formData.subject,
2942
+ emails: ramda.pluck("value", formData.emails),
2943
+ message: (_body$ref$current$inn = (_body$ref = body.ref) === null || _body$ref === void 0 ? void 0 : _body$ref.current.innerHTML) !== null && _body$ref$current$inn !== void 0 ? _body$ref$current$inn : body,
2944
+ snippet: codeToDisplay
2945
+ });
2946
+ case 4:
2947
+ case "end":
2948
+ return _context.stop();
2949
+ }
2950
+ }, _callee);
2951
+ }));
2952
+ return function handleSubmit(_x) {
2953
+ return _ref2.apply(this, arguments);
2954
+ };
2955
+ }();
2956
+ var renderCodeBlockProps = function renderCodeBlockProps() {
2957
+ var props = {
2958
+ codeString: codeToDisplay,
2959
+ showCopyButton: false,
2960
+ className: "neeto-ui-bg-primary-100 neeto-ui-rounded-lg"
2961
+ };
2962
+ if (emailType === EMAIL_TYPES.userIdentity) {
2963
+ props = ramda.assoc("frameworkProps", {
2964
+ selectedFramework: selectedFramework,
2965
+ setSelectedFramework: setSelectedFramework
2966
+ }, props);
2967
+ }
2968
+ return props;
2969
+ };
2970
+ return /*#__PURE__*/React__default["default"].createElement(neetoui.Pane, {
2971
+ isOpen: isPaneOpen,
2972
+ onClose: onClose
2973
+ }, /*#__PURE__*/React__default["default"].createElement(formik.Formik, {
2974
+ initialValues: getEmailWidgetSnippetFormInitialValues(subject),
2975
+ validationSchema: getEmailWidgetSnippetValidationSchema(),
2976
+ onSubmit: handleSubmit
2977
+ }, /*#__PURE__*/React__default["default"].createElement(formik.Form, null, /*#__PURE__*/React__default["default"].createElement(neetoui.Pane.Header, null, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
2978
+ style: "h2"
2979
+ }, t("neetoMolecules.widget.email.title"))), /*#__PURE__*/React__default["default"].createElement(neetoui.Pane.Body, null, /*#__PURE__*/React__default["default"].createElement("div", {
2980
+ className: "w-full space-y-4"
2981
+ }, /*#__PURE__*/React__default["default"].createElement(formik$1.MultiEmailInput, {
2982
+ required: true,
2983
+ label: t("neetoMolecules.widget.email.fields.emails.label"),
2984
+ name: "emails",
2985
+ placeholder: t("neetoMolecules.widget.email.fields.emails.placeholder")
2986
+ }), /*#__PURE__*/React__default["default"].createElement(formik$1.Input, {
2987
+ required: true,
2988
+ label: t("neetoMolecules.widget.email.fields.subject.label"),
2989
+ name: "subject",
2990
+ type: "text"
2991
+ }), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
2992
+ style: "body2"
2993
+ }, body), /*#__PURE__*/React__default["default"].createElement(CodeBlock, renderCodeBlockProps()))), /*#__PURE__*/React__default["default"].createElement(neetoui.Pane.Footer, {
2994
+ className: "gap-x-2"
2995
+ }, /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
2996
+ disabled: emailMutation.isLoading,
2997
+ label: t("neetoMolecules.widget.email.actions.send"),
2998
+ loading: emailMutation.isLoading,
2999
+ type: "submit"
3000
+ }), /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
3001
+ label: t("neetoMolecules.widget.email.actions.cancel"),
3002
+ style: "text",
3003
+ onClick: onClose
3004
+ })))));
3005
+ };
3006
+
3007
+ var useForceUpdate = function useForceUpdate() {
3008
+ // eslint-disable-next-line react/hook-use-state
3009
+ var _useState = React.useState(0),
3010
+ _useState2 = _slicedToArray(_useState, 2),
3011
+ setValue = _useState2[1];
3012
+ return function () {
3013
+ return setValue(function (value) {
3014
+ return value + 1;
3015
+ });
3016
+ };
3017
+ };
3018
+
3019
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3020
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3021
+ var useFetchApiKey = function useFetchApiKey() {
3022
+ return reactQuery.useQuery(QUERY_KEYS.apiKey, function () {
3023
+ if (window.globalProps.railsEnv === "heroku" || !process.env.ENABLE_SSO) {
3024
+ return Promise.resolve({
3025
+ widgetApiKey: "placeholder-api-key"
3026
+ });
3027
+ }
3028
+ return queryWidgetApiKey();
3029
+ }, {
3030
+ staleTime: DEFAULT_QUERY_STALE_TIME
3031
+ });
3032
+ };
3033
+ var useFetchConfigurations = function useFetchConfigurations() {
3034
+ return reactQuery.useQuery(QUERY_KEYS.configuration, fetchWidgetConfiguration, {
3035
+ staleTime: DEFAULT_QUERY_STALE_TIME
3036
+ });
3037
+ };
3038
+ var useUpdateConfigurations = function useUpdateConfigurations() {
3039
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3040
+ var queryClient = reactQuery.useQueryClient();
3041
+ return reactQuery.useMutation(updateWidgetConfiguration, _objectSpread(_objectSpread({}, options), {}, {
3042
+ onSuccess: function onSuccess() {
3043
+ return queryClient.invalidateQueries(QUERY_KEYS.configuration);
3044
+ }
3045
+ }));
3046
+ };
3047
+
3048
+ var SelectionTabs = function SelectionTabs(_ref) {
3049
+ var selectedWidgets = _ref.selectedWidgets,
3050
+ updateSelectedWidgets = _ref.updateSelectedWidgets,
3051
+ primarySelectedWidget = _ref.primarySelectedWidget;
3052
+ var formattedPrimaryWidget = pure.capitalize(WIDGET_TYPES_VALUES.includes(primarySelectedWidget) ? primarySelectedWidget : "");
3053
+ var renderSelectedTab = function renderSelectedTab() {
3054
+ return WIDGET_TYPES_VALUES.map(function (widget, index) {
3055
+ return primarySelectedWidget !== widget ? /*#__PURE__*/React__default["default"].createElement("div", {
3056
+ className: "flex items-center space-x-2",
3057
+ key: index
3058
+ }, /*#__PURE__*/React__default["default"].createElement(neetoui.Switch, {
3059
+ checked: selectedWidgets.includes(widget),
3060
+ onChange: function onChange() {
3061
+ return updateSelectedWidgets(widget);
3062
+ }
3063
+ }), /*#__PURE__*/React__default["default"].createElement(neetoui.Label, null, "neeto", pure.capitalize(widget))) : null;
3064
+ });
3065
+ };
3066
+ return /*#__PURE__*/React__default["default"].createElement("div", {
3067
+ className: "mb-4 flex w-full items-center justify-between gap-2"
3068
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
3069
+ className: "flex items-center space-x-2"
3070
+ }, pure.isNotEmpty(formattedPrimaryWidget) && /*#__PURE__*/React__default["default"].createElement(neetoui.Switch, {
3071
+ checked: selectedWidgets.includes(primarySelectedWidget),
3072
+ onChange: function onChange() {
3073
+ return updateSelectedWidgets(primarySelectedWidget);
3074
+ }
3075
+ }), /*#__PURE__*/React__default["default"].createElement("div", {
3076
+ className: "flex items-center space-x-1"
3077
+ }, /*#__PURE__*/React__default["default"].createElement(neetoui.Label, null, "neeto", formattedPrimaryWidget), /*#__PURE__*/React__default["default"].createElement("a", {
3078
+ href: WIDGET_KB_HELP_URL[primarySelectedWidget],
3079
+ rel: "noreferrer",
3080
+ target: "_blank"
3081
+ }, /*#__PURE__*/React__default["default"].createElement(neetoIcons.Info, {
3082
+ size: 16
3083
+ })))), /*#__PURE__*/React__default["default"].createElement("div", {
3084
+ className: "flex items-center justify-end gap-6"
3085
+ }, renderSelectedTab()));
3086
+ };
3087
+
3088
+ var EmbedCode = function EmbedCode(_ref) {
3089
+ var showSessionContext = _ref.showSessionContext,
3090
+ showUserIdentity = _ref.showUserIdentity,
3091
+ _ref$primaryApp = _ref.primaryApp,
3092
+ primaryApp = _ref$primaryApp === void 0 ? "" : _ref$primaryApp,
3093
+ _ref$maxWidth = _ref.maxWidth,
3094
+ maxWidth = _ref$maxWidth === void 0 ? "max-w-3xl" : _ref$maxWidth;
3095
+ var _useState = React.useState(EMAIL_TYPES["null"]),
3096
+ _useState2 = _slicedToArray(_useState, 2),
3097
+ emailType = _useState2[0],
3098
+ setEmailType = _useState2[1];
3099
+ var _useState3 = React.useState(FRAMEWORK_SELECT_OPTIONS[0]),
3100
+ _useState4 = _slicedToArray(_useState3, 2),
3101
+ selectedFramework = _useState4[0],
3102
+ setSelectedFramework = _useState4[1];
3103
+ var _useTranslation = reactI18next.useTranslation(),
3104
+ t = _useTranslation.t;
3105
+ var bodyRef = React.useRef();
3106
+ var forceUpdate = useForceUpdate();
3107
+ React.useEffect(function () {
3108
+ forceUpdate();
3109
+ }, []);
3110
+ var _useFetchApiKey = useFetchApiKey(),
3111
+ _useFetchApiKey$data = _useFetchApiKey.data,
3112
+ _useFetchApiKey$data2 = _useFetchApiKey$data === void 0 ? {} : _useFetchApiKey$data,
3113
+ _useFetchApiKey$data3 = _useFetchApiKey$data2.widgetApiKey,
3114
+ widgetApiKey = _useFetchApiKey$data3 === void 0 ? "" : _useFetchApiKey$data3,
3115
+ isLoadingApiKey = _useFetchApiKey.isLoading;
3116
+ var _useFetchConfiguratio = useFetchConfigurations(),
3117
+ _useFetchConfiguratio2 = _useFetchConfiguratio.data,
3118
+ _useFetchConfiguratio3 = _useFetchConfiguratio2 === void 0 ? {} : _useFetchConfiguratio2,
3119
+ _useFetchConfiguratio4 = _useFetchConfiguratio3.neetoWidgetTokens,
3120
+ neetoWidgetTokens = _useFetchConfiguratio4 === void 0 ? [] : _useFetchConfiguratio4,
3121
+ isLoadingConfigurations = _useFetchConfiguratio.isLoading;
3122
+ var _useUpdateConfigurati = useUpdateConfigurations(),
3123
+ updateWidgetConfiguration = _useUpdateConfigurati.mutate;
3124
+ var previousEmailType = reactUtils.usePrevious(emailType);
3125
+ var selectedWidgets = neetoWidgetTokens.filter(ramda.prop("enabled")).map(function (item) {
3126
+ return item.clientApplicationName.toLowerCase();
3127
+ });
3128
+ var enabledWidgets = ramda.fromPairs(selectedWidgets.map(function (widget) {
3129
+ return [widget, true];
3130
+ }));
3131
+ var shouldShowUserIdentity = showUserIdentity !== null && showUserIdentity !== void 0 ? showUserIdentity : enabledWidgets.chat || enabledWidgets.replay;
3132
+ var shouldShowSessionContext = showSessionContext !== null && showSessionContext !== void 0 ? showSessionContext : enabledWidgets.replay;
3133
+ var updateSelectedWidgets = function updateSelectedWidgets(widget) {
3134
+ var widgetId = neetoWidgetTokens.find(function (item) {
3135
+ return item.clientApplicationName.toLowerCase() === widget;
3136
+ }).id;
3137
+ var isEnabled = !selectedWidgets.includes(widget);
3138
+ updateWidgetConfiguration({
3139
+ id: widgetId,
3140
+ payload: {
3141
+ enabled: isEnabled
3142
+ }
3143
+ }, {
3144
+ onSuccess: function onSuccess() {
3145
+ var response = isEnabled ? "neetoMolecules.widget.installation.enabled" : "neetoMolecules.widget.installation.disabled";
3146
+ neetoui.Toastr.success(t(response, {
3147
+ productName: "neeto".concat(pure.capitalize(widget))
3148
+ }));
3149
+ }
3150
+ });
3151
+ };
3152
+ var getEmbedCodeString = function getEmbedCodeString() {
3153
+ if (pure.isNotEmpty(widgetApiKey)) {
3154
+ return sampleConsolidatedCodeString(enabledWidgets, widgetApiKey);
3155
+ }
3156
+ return "";
3157
+ };
3158
+ var getSnippetProps = function getSnippetProps(selectedEmailType) {
3159
+ switch (selectedEmailType) {
3160
+ case EMAIL_TYPES.embedCode:
3161
+ return {
3162
+ codeString: getEmbedCodeString(),
3163
+ subject: t("neetoMolecules.widget.email.fields.subject.values.embedCode"),
3164
+ body: /*#__PURE__*/React__default["default"].createElement("div", {
3165
+ ref: bodyRef
3166
+ }, /*#__PURE__*/React__default["default"].createElement(reactI18next.Trans, {
3167
+ i18nKey: "neetoMolecules.widget.email.body.values.embedCode",
3168
+ components: {
3169
+ p: /*#__PURE__*/React__default["default"].createElement("p", {
3170
+ style: {
3171
+ marginBottom: "8px"
3172
+ }
3173
+ }),
3174
+ mail: /*#__PURE__*/React__default["default"].createElement("a", {
3175
+ className: "neeto-ui-text-primary-800",
3176
+ href: "mailto:".concat(INSTALLATION_HELP_EMAIL),
3177
+ rel: "noreferrer",
3178
+ target: "_blank"
3179
+ })
3180
+ },
3181
+ values: {
3182
+ val: getSortedPrefixedWidgets(selectedWidgets),
3183
+ helpEmail: INSTALLATION_HELP_EMAIL
3184
+ }
3185
+ }))
3186
+ };
3187
+ case EMAIL_TYPES.userIdentity:
3188
+ return {
3189
+ emailType: EMAIL_TYPES.userIdentity,
3190
+ enabledWidgets: enabledWidgets,
3191
+ subject: t("neetoMolecules.widget.email.fields.subject.values.userIdentity"),
3192
+ body: /*#__PURE__*/React__default["default"].createElement("div", {
3193
+ ref: bodyRef
3194
+ }, /*#__PURE__*/React__default["default"].createElement(reactI18next.Trans, {
3195
+ i18nKey: "neetoMolecules.widget.email.body.values.userIdentity",
3196
+ components: {
3197
+ p: /*#__PURE__*/React__default["default"].createElement("p", {
3198
+ style: {
3199
+ marginBottom: "8px"
3200
+ }
3201
+ }),
3202
+ configureLink: /*#__PURE__*/React__default["default"].createElement("a", {
3203
+ className: "neeto-ui-text-primary-800",
3204
+ rel: "noreferrer",
3205
+ target: "_blank",
3206
+ href: enabledWidgets.chat ? NEETO_CHAT_USER_IDENTITY_URL : NEETO_REPLAY_CONFIGURE_URL
3207
+ })
3208
+ },
3209
+ values: {
3210
+ userIdentityKbUrl: enabledWidgets.chat ? NEETO_CHAT_USER_IDENTITY_URL : NEETO_REPLAY_CONFIGURE_URL
3211
+ }
3212
+ }))
3213
+ };
3214
+ case EMAIL_TYPES.sessionContext:
3215
+ return {
3216
+ codeString: SAMPLE_CONTEXT_CODE_STRING,
3217
+ subject: t("neetoMolecules.widget.email.fields.subject.values.sessionContext"),
3218
+ body: /*#__PURE__*/React__default["default"].createElement("div", {
3219
+ ref: bodyRef
3220
+ }, /*#__PURE__*/React__default["default"].createElement(reactI18next.Trans, {
3221
+ i18nKey: "neetoMolecules.widget.email.body.values.sessionContext",
3222
+ values: {
3223
+ sessionContextKbUrl: NEETO_REPLAY_CONFIGURE_URL
3224
+ },
3225
+ components: {
3226
+ p: /*#__PURE__*/React__default["default"].createElement("p", {
3227
+ style: {
3228
+ marginBottom: "8px"
3229
+ }
3230
+ }),
3231
+ configureLink: /*#__PURE__*/React__default["default"].createElement("a", {
3232
+ className: "neeto-ui-text-primary-800",
3233
+ href: NEETO_REPLAY_CONFIGURE_URL,
3234
+ rel: "noreferrer",
3235
+ target: "_blank"
3236
+ })
3237
+ }
3238
+ }))
3239
+ };
3240
+ case EMAIL_TYPES["null"]:
3241
+ return previousEmailType !== EMAIL_TYPES["null"] ? getSnippetProps(previousEmailType) : {};
3242
+ default:
3243
+ throw new Error(t("neetoMolecules.widget.email.invalidType"));
3244
+ }
3245
+ };
3246
+ var handleSendViaEmail = function handleSendViaEmail(selectedEmail) {
3247
+ if (ramda.isEmpty(selectedWidgets)) {
3248
+ neetoui.Toastr.error(t("neetoMolecules.widget.installation.snippet.disabledError"));
3249
+ return;
3250
+ }
3251
+ setEmailType(selectedEmail);
3252
+ };
3253
+ if (isLoadingApiKey || isLoadingConfigurations) {
3254
+ return /*#__PURE__*/React__default["default"].createElement("div", {
3255
+ className: "h-full w-full"
3256
+ }, /*#__PURE__*/React__default["default"].createElement(PageLoader$1, null));
3257
+ }
3258
+ return /*#__PURE__*/React__default["default"].createElement("div", {
3259
+ className: "mx-auto mb-10 w-full flex-col items-center justify-start"
3260
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
3261
+ className: classnames("mx-auto", maxWidth)
3262
+ }, /*#__PURE__*/React__default["default"].createElement(SelectionTabs, {
3263
+ primarySelectedWidget: primaryApp,
3264
+ selectedWidgets: selectedWidgets,
3265
+ updateSelectedWidgets: updateSelectedWidgets
3266
+ }), /*#__PURE__*/React__default["default"].createElement("div", {
3267
+ className: "mb-8 w-full flex-grow flex-col items-center justify-start"
3268
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
3269
+ className: "mx-auto mb-2 w-full",
3270
+ "data-testid": "embed-code-block"
3271
+ }, /*#__PURE__*/React__default["default"].createElement(CodeBlock, {
3272
+ className: "neeto-ui-bg-primary-100 neeto-ui-rounded-lg",
3273
+ codeString: getEmbedCodeString(),
3274
+ sendViaEmail: function sendViaEmail() {
3275
+ return handleSendViaEmail(EMAIL_TYPES.embedCode);
3276
+ },
3277
+ title: /*#__PURE__*/React__default["default"].createElement("div", null, t("neetoMolecules.widget.title.embedCode"))
3278
+ })), /*#__PURE__*/React__default["default"].createElement("div", {
3279
+ className: "w-full"
3280
+ }, /*#__PURE__*/React__default["default"].createElement(reactI18next.Trans, {
3281
+ values: {
3282
+ val: getSortedPrefixedWidgets(selectedWidgets)
3283
+ },
3284
+ components: {
3285
+ fontBold: /*#__PURE__*/React__default["default"].createElement("span", {
3286
+ className: "font-semibold"
3287
+ }),
3288
+ fontNormal: /*#__PURE__*/React__default["default"].createElement("span", {
3289
+ className: "font-normal"
3290
+ })
3291
+ },
3292
+ i18nKey: pure.isNotEmpty(selectedWidgets) ? "neetoMolecules.widget.installation.instructions.placement.selectedWidgets" : "neetoMolecules.widget.installation.instructions.placement.noneOfThese"
3293
+ }))), shouldShowUserIdentity ? /*#__PURE__*/React__default["default"].createElement("div", {
3294
+ className: "mb-8 w-full flex-grow flex-col items-center justify-start"
3295
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
3296
+ className: "mx-auto mb-2 w-full"
3297
+ }, /*#__PURE__*/React__default["default"].createElement(CodeBlock, {
3298
+ className: "neeto-ui-bg-primary-100 neeto-ui-rounded-lg",
3299
+ frameworkProps: {
3300
+ selectedFramework: selectedFramework,
3301
+ setSelectedFramework: setSelectedFramework
3302
+ },
3303
+ codeString: getSampleUserIdentity(enabledWidgets, selectedFramework.value),
3304
+ sendViaEmail: function sendViaEmail() {
3305
+ return handleSendViaEmail(EMAIL_TYPES.userIdentity);
3306
+ },
3307
+ title: /*#__PURE__*/React__default["default"].createElement("div", {
3308
+ className: "flex items-center justify-start"
3309
+ }, /*#__PURE__*/React__default["default"].createElement("div", null, t("neetoMolecules.widget.title.userIdentity")), /*#__PURE__*/React__default["default"].createElement("a", {
3310
+ className: "ml-1",
3311
+ rel: "noreferrer",
3312
+ target: "_blank",
3313
+ href: enabledWidgets.chat ? NEETO_CHAT_USER_IDENTITY_URL : NEETO_REPLAY_CONFIGURE_URL
3314
+ }, /*#__PURE__*/React__default["default"].createElement(neetoIcons.Info, {
3315
+ size: 16
3316
+ })))
3317
+ })), /*#__PURE__*/React__default["default"].createElement("div", {
3318
+ className: "w-full"
3319
+ }, t("neetoMolecules.widget.installation.instructions.userIdentity"))) : null, shouldShowSessionContext ? /*#__PURE__*/React__default["default"].createElement("div", {
3320
+ className: "w-full flex-grow flex-col items-center justify-start"
3321
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
3322
+ className: "mx-auto mb-2 w-full"
3323
+ }, /*#__PURE__*/React__default["default"].createElement(CodeBlock, {
3324
+ className: "neeto-ui-bg-primary-100 neeto-ui-rounded-lg",
3325
+ codeString: SAMPLE_CONTEXT_CODE_STRING,
3326
+ sendViaEmail: function sendViaEmail() {
3327
+ return handleSendViaEmail(EMAIL_TYPES.sessionContext);
3328
+ },
3329
+ title: /*#__PURE__*/React__default["default"].createElement("div", {
3330
+ className: "flex items-center justify-start"
3331
+ }, /*#__PURE__*/React__default["default"].createElement("div", null, t("neetoMolecules.widget.title.sessionContext")), /*#__PURE__*/React__default["default"].createElement("a", {
3332
+ className: "ml-1",
3333
+ href: NEETO_REPLAY_CONFIGURE_URL,
3334
+ rel: "noreferrer",
3335
+ target: "_blank"
3336
+ }, /*#__PURE__*/React__default["default"].createElement(neetoIcons.Info, {
3337
+ size: 16
3338
+ })))
3339
+ })), /*#__PURE__*/React__default["default"].createElement("div", {
3340
+ className: "w-full"
3341
+ }, t("neetoMolecules.widget.installation.instructions.sessionContext"))) : null), /*#__PURE__*/React__default["default"].createElement(CodeSnippet, _extends$1({
3342
+ isPaneOpen: !!emailType && pure.isNotEmpty(selectedWidgets),
3343
+ onClose: function onClose() {
3344
+ return setEmailType(EMAIL_TYPES["null"]);
3345
+ }
3346
+ }, getSnippetProps(emailType))));
3347
+ };
3348
+ var EmbedCode$1 = /*#__PURE__*/React__default["default"].memo(EmbedCode);
3349
+
3350
+ var queryClient = new reactQuery.QueryClient();
3351
+ var Main = function Main(props) {
3352
+ var _useTranslation = reactI18next.useTranslation(),
3353
+ t = _useTranslation.t;
3354
+ var shouldRenderEmbedCode = window.globalProps.ssoEnabled;
3355
+ return shouldRenderEmbedCode ? /*#__PURE__*/React__default["default"].createElement(reactQuery.QueryClientProvider, {
3356
+ client: queryClient
3357
+ }, /*#__PURE__*/React__default["default"].createElement(EmbedCode$1, props)) : /*#__PURE__*/React__default["default"].createElement(neetoui.Callout, {
3358
+ icon: neetoIcons.Info,
3359
+ style: "info"
3360
+ }, t("neetoMolecules.widget.developmentInfo"));
3361
+ };
3362
+
3363
+ var NeetoWidget = {
3364
+ EmbedCode: Main,
3365
+ WIDGET_TYPES: WIDGET_TYPES
3366
+ };
3367
+
3368
+ module.exports = NeetoWidget;
3369
+ //# sourceMappingURL=NeetoWidget.cjs.js.map