@bigbinary/neeto-molecules 3.2.2 → 3.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/BrowserSupport.js +2 -1
  2. package/dist/BrowserSupport.js.map +1 -1
  3. package/dist/DownloadMobileAppCallout.js +2 -1
  4. package/dist/DownloadMobileAppCallout.js.map +1 -1
  5. package/dist/EmailForm.js +2 -1
  6. package/dist/EmailForm.js.map +1 -1
  7. package/dist/FloatingActionMenu.js +2 -1
  8. package/dist/FloatingActionMenu.js.map +1 -1
  9. package/dist/IconPicker.js +916 -4
  10. package/dist/IconPicker.js.map +1 -1
  11. package/dist/IpRestriction.js +3093 -7
  12. package/dist/IpRestriction.js.map +1 -1
  13. package/dist/KeyboardShortcuts.js +2 -1
  14. package/dist/KeyboardShortcuts.js.map +1 -1
  15. package/dist/MenuBar.js +1804 -12
  16. package/dist/MenuBar.js.map +1 -1
  17. package/dist/NeetoWidget.js +1957 -3
  18. package/dist/NeetoWidget.js.map +1 -1
  19. package/dist/PhoneNumber.js +12 -4
  20. package/dist/PhoneNumber.js.map +1 -1
  21. package/dist/SendToFields.js +1919 -1
  22. package/dist/SendToFields.js.map +1 -1
  23. package/dist/ShareViaEmail.js +2 -1
  24. package/dist/ShareViaEmail.js.map +1 -1
  25. package/dist/ShareViaLink.js +860 -2
  26. package/dist/ShareViaLink.js.map +1 -1
  27. package/dist/_commonjsHelpers-1c8beb5f.js +4 -0
  28. package/dist/_commonjsHelpers-1c8beb5f.js.map +1 -0
  29. package/dist/cjs/BrowserSupport.js +3 -3
  30. package/dist/cjs/BrowserSupport.js.map +1 -1
  31. package/dist/cjs/DownloadMobileAppCallout.js +3 -3
  32. package/dist/cjs/DownloadMobileAppCallout.js.map +1 -1
  33. package/dist/cjs/EmailForm.js +2 -1
  34. package/dist/cjs/EmailForm.js.map +1 -1
  35. package/dist/cjs/FloatingActionMenu.js +2 -1
  36. package/dist/cjs/FloatingActionMenu.js.map +1 -1
  37. package/dist/cjs/IconPicker.js +920 -5
  38. package/dist/cjs/IconPicker.js.map +1 -1
  39. package/dist/cjs/IpRestriction.js +3101 -15
  40. package/dist/cjs/IpRestriction.js.map +1 -1
  41. package/dist/cjs/KeyboardShortcuts.js +3 -3
  42. package/dist/cjs/KeyboardShortcuts.js.map +1 -1
  43. package/dist/cjs/MenuBar.js +1807 -10
  44. package/dist/cjs/MenuBar.js.map +1 -1
  45. package/dist/cjs/NeetoWidget.js +1958 -5
  46. package/dist/cjs/NeetoWidget.js.map +1 -1
  47. package/dist/cjs/PhoneNumber.js +12 -4
  48. package/dist/cjs/PhoneNumber.js.map +1 -1
  49. package/dist/cjs/SendToFields.js +1921 -3
  50. package/dist/cjs/SendToFields.js.map +1 -1
  51. package/dist/cjs/ShareViaEmail.js +2 -1
  52. package/dist/cjs/ShareViaEmail.js.map +1 -1
  53. package/dist/cjs/ShareViaLink.js +860 -3
  54. package/dist/cjs/ShareViaLink.js.map +1 -1
  55. package/dist/cjs/_commonjsHelpers-68cdf74f.js +6 -0
  56. package/dist/cjs/_commonjsHelpers-68cdf74f.js.map +1 -0
  57. package/dist/cjs/platform-628b3bd8.js +1252 -0
  58. package/dist/cjs/platform-628b3bd8.js.map +1 -0
  59. package/dist/platform-e221afea.js +1250 -0
  60. package/dist/platform-e221afea.js.map +1 -0
  61. package/package.json +14 -16
@@ -19,8 +19,8 @@ var Typography = require('@bigbinary/neetoui/Typography');
19
19
  var PageLoader = require('./PageLoader.js');
20
20
  var Select = require('@bigbinary/neetoui/Select');
21
21
  var CopyToClipboardButton = require('./CopyToClipboardButton.js');
22
- var Prism = require('prismjs');
23
- require('prismjs/themes/prism-tomorrow.css');
22
+ var _commonjsHelpers = require('./_commonjsHelpers-68cdf74f.js');
23
+ var injectCss = require('./inject-css-80a5faa3.js');
24
24
  var formik = require('formik');
25
25
  var Pane = require('@bigbinary/neetoui/Pane');
26
26
  var Input = require('@bigbinary/neetoui/formik/Input');
@@ -33,7 +33,6 @@ var withT = require('@bigbinary/neeto-commons-frontend/react-utils/withT');
33
33
  var Switch = require('@bigbinary/neetoui/Switch');
34
34
  var Tooltip = require('@bigbinary/neetoui/Tooltip');
35
35
  require('@babel/runtime/helpers/objectWithoutProperties');
36
- require('./inject-css-80a5faa3.js');
37
36
  require('@bigbinary/neeto-commons-frontend/utils/general');
38
37
  require('@bigbinary/neeto-icons/Copy');
39
38
  require('@bigbinary/neeto-icons/Check');
@@ -71,7 +70,6 @@ var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
71
70
  var Toastr__default = /*#__PURE__*/_interopDefaultLegacy(Toastr);
72
71
  var Typography__default = /*#__PURE__*/_interopDefaultLegacy(Typography);
73
72
  var Select__default = /*#__PURE__*/_interopDefaultLegacy(Select);
74
- var Prism__default = /*#__PURE__*/_interopDefaultLegacy(Prism);
75
73
  var Pane__default = /*#__PURE__*/_interopDefaultLegacy(Pane);
76
74
  var Input__default = /*#__PURE__*/_interopDefaultLegacy(Input);
77
75
  var MultiEmailInput__default = /*#__PURE__*/_interopDefaultLegacy(MultiEmailInput);
@@ -210,12 +208,1967 @@ var ChatWidgetBody = function ChatWidgetBody(_ref) {
210
208
  }));
211
209
  };
212
210
 
211
+ var prism = {exports: {}};
212
+
213
+ (function (module) {
214
+ /* **********************************************
215
+ Begin prism-core.js
216
+ ********************************************** */
217
+
218
+ /// <reference lib="WebWorker"/>
219
+
220
+ var _self = (typeof window !== 'undefined')
221
+ ? window // if in browser
222
+ : (
223
+ (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
224
+ ? self // if in worker
225
+ : {} // if in node js
226
+ );
227
+
228
+ /**
229
+ * Prism: Lightweight, robust, elegant syntax highlighting
230
+ *
231
+ * @license MIT <https://opensource.org/licenses/MIT>
232
+ * @author Lea Verou <https://lea.verou.me>
233
+ * @namespace
234
+ * @public
235
+ */
236
+ var Prism = (function (_self) {
237
+
238
+ // Private helper vars
239
+ var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i;
240
+ var uniqueId = 0;
241
+
242
+ // The grammar object for plaintext
243
+ var plainTextGrammar = {};
244
+
245
+
246
+ var _ = {
247
+ /**
248
+ * By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
249
+ * current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
250
+ * additional languages or plugins yourself.
251
+ *
252
+ * By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
253
+ *
254
+ * You obviously have to change this value before the automatic highlighting started. To do this, you can add an
255
+ * empty Prism object into the global scope before loading the Prism script like this:
256
+ *
257
+ * ```js
258
+ * window.Prism = window.Prism || {};
259
+ * Prism.manual = true;
260
+ * // add a new <script> to load Prism's script
261
+ * ```
262
+ *
263
+ * @default false
264
+ * @type {boolean}
265
+ * @memberof Prism
266
+ * @public
267
+ */
268
+ manual: _self.Prism && _self.Prism.manual,
269
+ /**
270
+ * By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
271
+ * `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your
272
+ * own worker, you don't want it to do this.
273
+ *
274
+ * By setting this value to `true`, Prism will not add its own listeners to the worker.
275
+ *
276
+ * You obviously have to change this value before Prism executes. To do this, you can add an
277
+ * empty Prism object into the global scope before loading the Prism script like this:
278
+ *
279
+ * ```js
280
+ * window.Prism = window.Prism || {};
281
+ * Prism.disableWorkerMessageHandler = true;
282
+ * // Load Prism's script
283
+ * ```
284
+ *
285
+ * @default false
286
+ * @type {boolean}
287
+ * @memberof Prism
288
+ * @public
289
+ */
290
+ disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
291
+
292
+ /**
293
+ * A namespace for utility methods.
294
+ *
295
+ * All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
296
+ * change or disappear at any time.
297
+ *
298
+ * @namespace
299
+ * @memberof Prism
300
+ */
301
+ util: {
302
+ encode: function encode(tokens) {
303
+ if (tokens instanceof Token) {
304
+ return new Token(tokens.type, encode(tokens.content), tokens.alias);
305
+ } else if (Array.isArray(tokens)) {
306
+ return tokens.map(encode);
307
+ } else {
308
+ return tokens.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\u00a0/g, ' ');
309
+ }
310
+ },
311
+
312
+ /**
313
+ * Returns the name of the type of the given value.
314
+ *
315
+ * @param {any} o
316
+ * @returns {string}
317
+ * @example
318
+ * type(null) === 'Null'
319
+ * type(undefined) === 'Undefined'
320
+ * type(123) === 'Number'
321
+ * type('foo') === 'String'
322
+ * type(true) === 'Boolean'
323
+ * type([1, 2]) === 'Array'
324
+ * type({}) === 'Object'
325
+ * type(String) === 'Function'
326
+ * type(/abc+/) === 'RegExp'
327
+ */
328
+ type: function (o) {
329
+ return Object.prototype.toString.call(o).slice(8, -1);
330
+ },
331
+
332
+ /**
333
+ * Returns a unique number for the given object. Later calls will still return the same number.
334
+ *
335
+ * @param {Object} obj
336
+ * @returns {number}
337
+ */
338
+ objId: function (obj) {
339
+ if (!obj['__id']) {
340
+ Object.defineProperty(obj, '__id', { value: ++uniqueId });
341
+ }
342
+ return obj['__id'];
343
+ },
344
+
345
+ /**
346
+ * Creates a deep clone of the given object.
347
+ *
348
+ * The main intended use of this function is to clone language definitions.
349
+ *
350
+ * @param {T} o
351
+ * @param {Record<number, any>} [visited]
352
+ * @returns {T}
353
+ * @template T
354
+ */
355
+ clone: function deepClone(o, visited) {
356
+ visited = visited || {};
357
+
358
+ var clone; var id;
359
+ switch (_.util.type(o)) {
360
+ case 'Object':
361
+ id = _.util.objId(o);
362
+ if (visited[id]) {
363
+ return visited[id];
364
+ }
365
+ clone = /** @type {Record<string, any>} */ ({});
366
+ visited[id] = clone;
367
+
368
+ for (var key in o) {
369
+ if (o.hasOwnProperty(key)) {
370
+ clone[key] = deepClone(o[key], visited);
371
+ }
372
+ }
373
+
374
+ return /** @type {any} */ (clone);
375
+
376
+ case 'Array':
377
+ id = _.util.objId(o);
378
+ if (visited[id]) {
379
+ return visited[id];
380
+ }
381
+ clone = [];
382
+ visited[id] = clone;
383
+
384
+ (/** @type {Array} */(/** @type {any} */(o))).forEach(function (v, i) {
385
+ clone[i] = deepClone(v, visited);
386
+ });
387
+
388
+ return /** @type {any} */ (clone);
389
+
390
+ default:
391
+ return o;
392
+ }
393
+ },
394
+
395
+ /**
396
+ * Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
397
+ *
398
+ * If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
399
+ *
400
+ * @param {Element} element
401
+ * @returns {string}
402
+ */
403
+ getLanguage: function (element) {
404
+ while (element) {
405
+ var m = lang.exec(element.className);
406
+ if (m) {
407
+ return m[1].toLowerCase();
408
+ }
409
+ element = element.parentElement;
410
+ }
411
+ return 'none';
412
+ },
413
+
414
+ /**
415
+ * Sets the Prism `language-xxxx` class of the given element.
416
+ *
417
+ * @param {Element} element
418
+ * @param {string} language
419
+ * @returns {void}
420
+ */
421
+ setLanguage: function (element, language) {
422
+ // remove all `language-xxxx` classes
423
+ // (this might leave behind a leading space)
424
+ element.className = element.className.replace(RegExp(lang, 'gi'), '');
425
+
426
+ // add the new `language-xxxx` class
427
+ // (using `classList` will automatically clean up spaces for us)
428
+ element.classList.add('language-' + language);
429
+ },
430
+
431
+ /**
432
+ * Returns the script element that is currently executing.
433
+ *
434
+ * This does __not__ work for line script element.
435
+ *
436
+ * @returns {HTMLScriptElement | null}
437
+ */
438
+ currentScript: function () {
439
+ if (typeof document === 'undefined') {
440
+ return null;
441
+ }
442
+ if ('currentScript' in document && 1 < 2 /* hack to trip TS' flow analysis */) {
443
+ return /** @type {any} */ (document.currentScript);
444
+ }
445
+
446
+ // IE11 workaround
447
+ // we'll get the src of the current script by parsing IE11's error stack trace
448
+ // this will not work for inline scripts
449
+
450
+ try {
451
+ throw new Error();
452
+ } catch (err) {
453
+ // Get file src url from stack. Specifically works with the format of stack traces in IE.
454
+ // A stack will look like this:
455
+ //
456
+ // Error
457
+ // at _.util.currentScript (http://localhost/components/prism-core.js:119:5)
458
+ // at Global code (http://localhost/components/prism-core.js:606:1)
459
+
460
+ var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) || [])[1];
461
+ if (src) {
462
+ var scripts = document.getElementsByTagName('script');
463
+ for (var i in scripts) {
464
+ if (scripts[i].src == src) {
465
+ return scripts[i];
466
+ }
467
+ }
468
+ }
469
+ return null;
470
+ }
471
+ },
472
+
473
+ /**
474
+ * Returns whether a given class is active for `element`.
475
+ *
476
+ * The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated
477
+ * if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the
478
+ * given class is just the given class with a `no-` prefix.
479
+ *
480
+ * Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is
481
+ * closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its
482
+ * ancestors have the given class or the negated version of it, then the default activation will be returned.
483
+ *
484
+ * In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated
485
+ * version of it, the class is considered active.
486
+ *
487
+ * @param {Element} element
488
+ * @param {string} className
489
+ * @param {boolean} [defaultActivation=false]
490
+ * @returns {boolean}
491
+ */
492
+ isActive: function (element, className, defaultActivation) {
493
+ var no = 'no-' + className;
494
+
495
+ while (element) {
496
+ var classList = element.classList;
497
+ if (classList.contains(className)) {
498
+ return true;
499
+ }
500
+ if (classList.contains(no)) {
501
+ return false;
502
+ }
503
+ element = element.parentElement;
504
+ }
505
+ return !!defaultActivation;
506
+ }
507
+ },
508
+
509
+ /**
510
+ * This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
511
+ *
512
+ * @namespace
513
+ * @memberof Prism
514
+ * @public
515
+ */
516
+ languages: {
517
+ /**
518
+ * The grammar for plain, unformatted text.
519
+ */
520
+ plain: plainTextGrammar,
521
+ plaintext: plainTextGrammar,
522
+ text: plainTextGrammar,
523
+ txt: plainTextGrammar,
524
+
525
+ /**
526
+ * Creates a deep copy of the language with the given id and appends the given tokens.
527
+ *
528
+ * If a token in `redef` also appears in the copied language, then the existing token in the copied language
529
+ * will be overwritten at its original position.
530
+ *
531
+ * ## Best practices
532
+ *
533
+ * Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
534
+ * doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
535
+ * understand the language definition because, normally, the order of tokens matters in Prism grammars.
536
+ *
537
+ * Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
538
+ * Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
539
+ *
540
+ * @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
541
+ * @param {Grammar} redef The new tokens to append.
542
+ * @returns {Grammar} The new language created.
543
+ * @public
544
+ * @example
545
+ * Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
546
+ * // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
547
+ * // at its original position
548
+ * 'comment': { ... },
549
+ * // CSS doesn't have a 'color' token, so this token will be appended
550
+ * 'color': /\b(?:red|green|blue)\b/
551
+ * });
552
+ */
553
+ extend: function (id, redef) {
554
+ var lang = _.util.clone(_.languages[id]);
555
+
556
+ for (var key in redef) {
557
+ lang[key] = redef[key];
558
+ }
559
+
560
+ return lang;
561
+ },
562
+
563
+ /**
564
+ * Inserts tokens _before_ another token in a language definition or any other grammar.
565
+ *
566
+ * ## Usage
567
+ *
568
+ * This helper method makes it easy to modify existing languages. For example, the CSS language definition
569
+ * not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
570
+ * in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
571
+ * appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
572
+ * this:
573
+ *
574
+ * ```js
575
+ * Prism.languages.markup.style = {
576
+ * // token
577
+ * };
578
+ * ```
579
+ *
580
+ * then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
581
+ * before existing tokens. For the CSS example above, you would use it like this:
582
+ *
583
+ * ```js
584
+ * Prism.languages.insertBefore('markup', 'cdata', {
585
+ * 'style': {
586
+ * // token
587
+ * }
588
+ * });
589
+ * ```
590
+ *
591
+ * ## Special cases
592
+ *
593
+ * If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
594
+ * will be ignored.
595
+ *
596
+ * This behavior can be used to insert tokens after `before`:
597
+ *
598
+ * ```js
599
+ * Prism.languages.insertBefore('markup', 'comment', {
600
+ * 'comment': Prism.languages.markup.comment,
601
+ * // tokens after 'comment'
602
+ * });
603
+ * ```
604
+ *
605
+ * ## Limitations
606
+ *
607
+ * The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
608
+ * properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
609
+ * differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
610
+ * deleting properties which is necessary to insert at arbitrary positions.
611
+ *
612
+ * To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
613
+ * Instead, it will create a new object and replace all references to the target object with the new one. This
614
+ * can be done without temporarily deleting properties, so the iteration order is well-defined.
615
+ *
616
+ * However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
617
+ * you hold the target object in a variable, then the value of the variable will not change.
618
+ *
619
+ * ```js
620
+ * var oldMarkup = Prism.languages.markup;
621
+ * var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
622
+ *
623
+ * assert(oldMarkup !== Prism.languages.markup);
624
+ * assert(newMarkup === Prism.languages.markup);
625
+ * ```
626
+ *
627
+ * @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
628
+ * object to be modified.
629
+ * @param {string} before The key to insert before.
630
+ * @param {Grammar} insert An object containing the key-value pairs to be inserted.
631
+ * @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
632
+ * object to be modified.
633
+ *
634
+ * Defaults to `Prism.languages`.
635
+ * @returns {Grammar} The new grammar object.
636
+ * @public
637
+ */
638
+ insertBefore: function (inside, before, insert, root) {
639
+ root = root || /** @type {any} */ (_.languages);
640
+ var grammar = root[inside];
641
+ /** @type {Grammar} */
642
+ var ret = {};
643
+
644
+ for (var token in grammar) {
645
+ if (grammar.hasOwnProperty(token)) {
646
+
647
+ if (token == before) {
648
+ for (var newToken in insert) {
649
+ if (insert.hasOwnProperty(newToken)) {
650
+ ret[newToken] = insert[newToken];
651
+ }
652
+ }
653
+ }
654
+
655
+ // Do not insert token which also occur in insert. See #1525
656
+ if (!insert.hasOwnProperty(token)) {
657
+ ret[token] = grammar[token];
658
+ }
659
+ }
660
+ }
661
+
662
+ var old = root[inside];
663
+ root[inside] = ret;
664
+
665
+ // Update references in other language definitions
666
+ _.languages.DFS(_.languages, function (key, value) {
667
+ if (value === old && key != inside) {
668
+ this[key] = ret;
669
+ }
670
+ });
671
+
672
+ return ret;
673
+ },
674
+
675
+ // Traverse a language definition with Depth First Search
676
+ DFS: function DFS(o, callback, type, visited) {
677
+ visited = visited || {};
678
+
679
+ var objId = _.util.objId;
680
+
681
+ for (var i in o) {
682
+ if (o.hasOwnProperty(i)) {
683
+ callback.call(o, i, o[i], type || i);
684
+
685
+ var property = o[i];
686
+ var propertyType = _.util.type(property);
687
+
688
+ if (propertyType === 'Object' && !visited[objId(property)]) {
689
+ visited[objId(property)] = true;
690
+ DFS(property, callback, null, visited);
691
+ } else if (propertyType === 'Array' && !visited[objId(property)]) {
692
+ visited[objId(property)] = true;
693
+ DFS(property, callback, i, visited);
694
+ }
695
+ }
696
+ }
697
+ }
698
+ },
699
+
700
+ plugins: {},
701
+
702
+ /**
703
+ * This is the most high-level function in Prism’s API.
704
+ * It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
705
+ * each one of them.
706
+ *
707
+ * This is equivalent to `Prism.highlightAllUnder(document, async, callback)`.
708
+ *
709
+ * @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}.
710
+ * @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}.
711
+ * @memberof Prism
712
+ * @public
713
+ */
714
+ highlightAll: function (async, callback) {
715
+ _.highlightAllUnder(document, async, callback);
716
+ },
717
+
718
+ /**
719
+ * Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
720
+ * {@link Prism.highlightElement} on each one of them.
721
+ *
722
+ * The following hooks will be run:
723
+ * 1. `before-highlightall`
724
+ * 2. `before-all-elements-highlight`
725
+ * 3. All hooks of {@link Prism.highlightElement} for each element.
726
+ *
727
+ * @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
728
+ * @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers.
729
+ * @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done.
730
+ * @memberof Prism
731
+ * @public
732
+ */
733
+ highlightAllUnder: function (container, async, callback) {
734
+ var env = {
735
+ callback: callback,
736
+ container: container,
737
+ selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
738
+ };
739
+
740
+ _.hooks.run('before-highlightall', env);
741
+
742
+ env.elements = Array.prototype.slice.apply(env.container.querySelectorAll(env.selector));
743
+
744
+ _.hooks.run('before-all-elements-highlight', env);
745
+
746
+ for (var i = 0, element; (element = env.elements[i++]);) {
747
+ _.highlightElement(element, async === true, env.callback);
748
+ }
749
+ },
750
+
751
+ /**
752
+ * Highlights the code inside a single element.
753
+ *
754
+ * The following hooks will be run:
755
+ * 1. `before-sanity-check`
756
+ * 2. `before-highlight`
757
+ * 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`.
758
+ * 4. `before-insert`
759
+ * 5. `after-highlight`
760
+ * 6. `complete`
761
+ *
762
+ * Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for
763
+ * the element's language.
764
+ *
765
+ * @param {Element} element The element containing the code.
766
+ * It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.
767
+ * @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers
768
+ * to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is
769
+ * [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).
770
+ *
771
+ * Note: All language definitions required to highlight the code must be included in the main `prism.js` file for
772
+ * asynchronous highlighting to work. You can build your own bundle on the
773
+ * [Download page](https://prismjs.com/download.html).
774
+ * @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done.
775
+ * Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
776
+ * @memberof Prism
777
+ * @public
778
+ */
779
+ highlightElement: function (element, async, callback) {
780
+ // Find language
781
+ var language = _.util.getLanguage(element);
782
+ var grammar = _.languages[language];
783
+
784
+ // Set language on the element, if not present
785
+ _.util.setLanguage(element, language);
786
+
787
+ // Set language on the parent, for styling
788
+ var parent = element.parentElement;
789
+ if (parent && parent.nodeName.toLowerCase() === 'pre') {
790
+ _.util.setLanguage(parent, language);
791
+ }
792
+
793
+ var code = element.textContent;
794
+
795
+ var env = {
796
+ element: element,
797
+ language: language,
798
+ grammar: grammar,
799
+ code: code
800
+ };
801
+
802
+ function insertHighlightedCode(highlightedCode) {
803
+ env.highlightedCode = highlightedCode;
804
+
805
+ _.hooks.run('before-insert', env);
806
+
807
+ env.element.innerHTML = env.highlightedCode;
808
+
809
+ _.hooks.run('after-highlight', env);
810
+ _.hooks.run('complete', env);
811
+ callback && callback.call(env.element);
812
+ }
813
+
814
+ _.hooks.run('before-sanity-check', env);
815
+
816
+ // plugins may change/add the parent/element
817
+ parent = env.element.parentElement;
818
+ if (parent && parent.nodeName.toLowerCase() === 'pre' && !parent.hasAttribute('tabindex')) {
819
+ parent.setAttribute('tabindex', '0');
820
+ }
821
+
822
+ if (!env.code) {
823
+ _.hooks.run('complete', env);
824
+ callback && callback.call(env.element);
825
+ return;
826
+ }
827
+
828
+ _.hooks.run('before-highlight', env);
829
+
830
+ if (!env.grammar) {
831
+ insertHighlightedCode(_.util.encode(env.code));
832
+ return;
833
+ }
834
+
835
+ if (async && _self.Worker) {
836
+ var worker = new Worker(_.filename);
837
+
838
+ worker.onmessage = function (evt) {
839
+ insertHighlightedCode(evt.data);
840
+ };
841
+
842
+ worker.postMessage(JSON.stringify({
843
+ language: env.language,
844
+ code: env.code,
845
+ immediateClose: true
846
+ }));
847
+ } else {
848
+ insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
849
+ }
850
+ },
851
+
852
+ /**
853
+ * Low-level function, only use if you know what you’re doing. It accepts a string of text as input
854
+ * and the language definitions to use, and returns a string with the HTML produced.
855
+ *
856
+ * The following hooks will be run:
857
+ * 1. `before-tokenize`
858
+ * 2. `after-tokenize`
859
+ * 3. `wrap`: On each {@link Token}.
860
+ *
861
+ * @param {string} text A string with the code to be highlighted.
862
+ * @param {Grammar} grammar An object containing the tokens to use.
863
+ *
864
+ * Usually a language definition like `Prism.languages.markup`.
865
+ * @param {string} language The name of the language definition passed to `grammar`.
866
+ * @returns {string} The highlighted HTML.
867
+ * @memberof Prism
868
+ * @public
869
+ * @example
870
+ * Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
871
+ */
872
+ highlight: function (text, grammar, language) {
873
+ var env = {
874
+ code: text,
875
+ grammar: grammar,
876
+ language: language
877
+ };
878
+ _.hooks.run('before-tokenize', env);
879
+ if (!env.grammar) {
880
+ throw new Error('The language "' + env.language + '" has no grammar.');
881
+ }
882
+ env.tokens = _.tokenize(env.code, env.grammar);
883
+ _.hooks.run('after-tokenize', env);
884
+ return Token.stringify(_.util.encode(env.tokens), env.language);
885
+ },
886
+
887
+ /**
888
+ * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
889
+ * and the language definitions to use, and returns an array with the tokenized code.
890
+ *
891
+ * When the language definition includes nested tokens, the function is called recursively on each of these tokens.
892
+ *
893
+ * This method could be useful in other contexts as well, as a very crude parser.
894
+ *
895
+ * @param {string} text A string with the code to be highlighted.
896
+ * @param {Grammar} grammar An object containing the tokens to use.
897
+ *
898
+ * Usually a language definition like `Prism.languages.markup`.
899
+ * @returns {TokenStream} An array of strings and tokens, a token stream.
900
+ * @memberof Prism
901
+ * @public
902
+ * @example
903
+ * let code = `var foo = 0;`;
904
+ * let tokens = Prism.tokenize(code, Prism.languages.javascript);
905
+ * tokens.forEach(token => {
906
+ * if (token instanceof Prism.Token && token.type === 'number') {
907
+ * console.log(`Found numeric literal: ${token.content}`);
908
+ * }
909
+ * });
910
+ */
911
+ tokenize: function (text, grammar) {
912
+ var rest = grammar.rest;
913
+ if (rest) {
914
+ for (var token in rest) {
915
+ grammar[token] = rest[token];
916
+ }
917
+
918
+ delete grammar.rest;
919
+ }
920
+
921
+ var tokenList = new LinkedList();
922
+ addAfter(tokenList, tokenList.head, text);
923
+
924
+ matchGrammar(text, tokenList, grammar, tokenList.head, 0);
925
+
926
+ return toArray(tokenList);
927
+ },
928
+
929
+ /**
930
+ * @namespace
931
+ * @memberof Prism
932
+ * @public
933
+ */
934
+ hooks: {
935
+ all: {},
936
+
937
+ /**
938
+ * Adds the given callback to the list of callbacks for the given hook.
939
+ *
940
+ * The callback will be invoked when the hook it is registered for is run.
941
+ * Hooks are usually directly run by a highlight function but you can also run hooks yourself.
942
+ *
943
+ * One callback function can be registered to multiple hooks and the same hook multiple times.
944
+ *
945
+ * @param {string} name The name of the hook.
946
+ * @param {HookCallback} callback The callback function which is given environment variables.
947
+ * @public
948
+ */
949
+ add: function (name, callback) {
950
+ var hooks = _.hooks.all;
951
+
952
+ hooks[name] = hooks[name] || [];
953
+
954
+ hooks[name].push(callback);
955
+ },
956
+
957
+ /**
958
+ * Runs a hook invoking all registered callbacks with the given environment variables.
959
+ *
960
+ * Callbacks will be invoked synchronously and in the order in which they were registered.
961
+ *
962
+ * @param {string} name The name of the hook.
963
+ * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
964
+ * @public
965
+ */
966
+ run: function (name, env) {
967
+ var callbacks = _.hooks.all[name];
968
+
969
+ if (!callbacks || !callbacks.length) {
970
+ return;
971
+ }
972
+
973
+ for (var i = 0, callback; (callback = callbacks[i++]);) {
974
+ callback(env);
975
+ }
976
+ }
977
+ },
978
+
979
+ Token: Token
980
+ };
981
+ _self.Prism = _;
982
+
983
+
984
+ // Typescript note:
985
+ // The following can be used to import the Token type in JSDoc:
986
+ //
987
+ // @typedef {InstanceType<import("./prism-core")["Token"]>} Token
988
+
989
+ /**
990
+ * Creates a new token.
991
+ *
992
+ * @param {string} type See {@link Token#type type}
993
+ * @param {string | TokenStream} content See {@link Token#content content}
994
+ * @param {string|string[]} [alias] The alias(es) of the token.
995
+ * @param {string} [matchedStr=""] A copy of the full string this token was created from.
996
+ * @class
997
+ * @global
998
+ * @public
999
+ */
1000
+ function Token(type, content, alias, matchedStr) {
1001
+ /**
1002
+ * The type of the token.
1003
+ *
1004
+ * This is usually the key of a pattern in a {@link Grammar}.
1005
+ *
1006
+ * @type {string}
1007
+ * @see GrammarToken
1008
+ * @public
1009
+ */
1010
+ this.type = type;
1011
+ /**
1012
+ * The strings or tokens contained by this token.
1013
+ *
1014
+ * This will be a token stream if the pattern matched also defined an `inside` grammar.
1015
+ *
1016
+ * @type {string | TokenStream}
1017
+ * @public
1018
+ */
1019
+ this.content = content;
1020
+ /**
1021
+ * The alias(es) of the token.
1022
+ *
1023
+ * @type {string|string[]}
1024
+ * @see GrammarToken
1025
+ * @public
1026
+ */
1027
+ this.alias = alias;
1028
+ // Copy of the full string this token was created from
1029
+ this.length = (matchedStr || '').length | 0;
1030
+ }
1031
+
1032
+ /**
1033
+ * A token stream is an array of strings and {@link Token Token} objects.
1034
+ *
1035
+ * Token streams have to fulfill a few properties that are assumed by most functions (mostly internal ones) that process
1036
+ * them.
1037
+ *
1038
+ * 1. No adjacent strings.
1039
+ * 2. No empty strings.
1040
+ *
1041
+ * The only exception here is the token stream that only contains the empty string and nothing else.
1042
+ *
1043
+ * @typedef {Array<string | Token>} TokenStream
1044
+ * @global
1045
+ * @public
1046
+ */
1047
+
1048
+ /**
1049
+ * Converts the given token or token stream to an HTML representation.
1050
+ *
1051
+ * The following hooks will be run:
1052
+ * 1. `wrap`: On each {@link Token}.
1053
+ *
1054
+ * @param {string | Token | TokenStream} o The token or token stream to be converted.
1055
+ * @param {string} language The name of current language.
1056
+ * @returns {string} The HTML representation of the token or token stream.
1057
+ * @memberof Token
1058
+ * @static
1059
+ */
1060
+ Token.stringify = function stringify(o, language) {
1061
+ if (typeof o == 'string') {
1062
+ return o;
1063
+ }
1064
+ if (Array.isArray(o)) {
1065
+ var s = '';
1066
+ o.forEach(function (e) {
1067
+ s += stringify(e, language);
1068
+ });
1069
+ return s;
1070
+ }
1071
+
1072
+ var env = {
1073
+ type: o.type,
1074
+ content: stringify(o.content, language),
1075
+ tag: 'span',
1076
+ classes: ['token', o.type],
1077
+ attributes: {},
1078
+ language: language
1079
+ };
1080
+
1081
+ var aliases = o.alias;
1082
+ if (aliases) {
1083
+ if (Array.isArray(aliases)) {
1084
+ Array.prototype.push.apply(env.classes, aliases);
1085
+ } else {
1086
+ env.classes.push(aliases);
1087
+ }
1088
+ }
1089
+
1090
+ _.hooks.run('wrap', env);
1091
+
1092
+ var attributes = '';
1093
+ for (var name in env.attributes) {
1094
+ attributes += ' ' + name + '="' + (env.attributes[name] || '').replace(/"/g, '&quot;') + '"';
1095
+ }
1096
+
1097
+ return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + attributes + '>' + env.content + '</' + env.tag + '>';
1098
+ };
1099
+
1100
+ /**
1101
+ * @param {RegExp} pattern
1102
+ * @param {number} pos
1103
+ * @param {string} text
1104
+ * @param {boolean} lookbehind
1105
+ * @returns {RegExpExecArray | null}
1106
+ */
1107
+ function matchPattern(pattern, pos, text, lookbehind) {
1108
+ pattern.lastIndex = pos;
1109
+ var match = pattern.exec(text);
1110
+ if (match && lookbehind && match[1]) {
1111
+ // change the match to remove the text matched by the Prism lookbehind group
1112
+ var lookbehindLength = match[1].length;
1113
+ match.index += lookbehindLength;
1114
+ match[0] = match[0].slice(lookbehindLength);
1115
+ }
1116
+ return match;
1117
+ }
1118
+
1119
+ /**
1120
+ * @param {string} text
1121
+ * @param {LinkedList<string | Token>} tokenList
1122
+ * @param {any} grammar
1123
+ * @param {LinkedListNode<string | Token>} startNode
1124
+ * @param {number} startPos
1125
+ * @param {RematchOptions} [rematch]
1126
+ * @returns {void}
1127
+ * @private
1128
+ *
1129
+ * @typedef RematchOptions
1130
+ * @property {string} cause
1131
+ * @property {number} reach
1132
+ */
1133
+ function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
1134
+ for (var token in grammar) {
1135
+ if (!grammar.hasOwnProperty(token) || !grammar[token]) {
1136
+ continue;
1137
+ }
1138
+
1139
+ var patterns = grammar[token];
1140
+ patterns = Array.isArray(patterns) ? patterns : [patterns];
1141
+
1142
+ for (var j = 0; j < patterns.length; ++j) {
1143
+ if (rematch && rematch.cause == token + ',' + j) {
1144
+ return;
1145
+ }
1146
+
1147
+ var patternObj = patterns[j];
1148
+ var inside = patternObj.inside;
1149
+ var lookbehind = !!patternObj.lookbehind;
1150
+ var greedy = !!patternObj.greedy;
1151
+ var alias = patternObj.alias;
1152
+
1153
+ if (greedy && !patternObj.pattern.global) {
1154
+ // Without the global flag, lastIndex won't work
1155
+ var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
1156
+ patternObj.pattern = RegExp(patternObj.pattern.source, flags + 'g');
1157
+ }
1158
+
1159
+ /** @type {RegExp} */
1160
+ var pattern = patternObj.pattern || patternObj;
1161
+
1162
+ for ( // iterate the token list and keep track of the current token/string position
1163
+ var currentNode = startNode.next, pos = startPos;
1164
+ currentNode !== tokenList.tail;
1165
+ pos += currentNode.value.length, currentNode = currentNode.next
1166
+ ) {
1167
+
1168
+ if (rematch && pos >= rematch.reach) {
1169
+ break;
1170
+ }
1171
+
1172
+ var str = currentNode.value;
1173
+
1174
+ if (tokenList.length > text.length) {
1175
+ // Something went terribly wrong, ABORT, ABORT!
1176
+ return;
1177
+ }
1178
+
1179
+ if (str instanceof Token) {
1180
+ continue;
1181
+ }
1182
+
1183
+ var removeCount = 1; // this is the to parameter of removeBetween
1184
+ var match;
1185
+
1186
+ if (greedy) {
1187
+ match = matchPattern(pattern, pos, text, lookbehind);
1188
+ if (!match || match.index >= text.length) {
1189
+ break;
1190
+ }
1191
+
1192
+ var from = match.index;
1193
+ var to = match.index + match[0].length;
1194
+ var p = pos;
1195
+
1196
+ // find the node that contains the match
1197
+ p += currentNode.value.length;
1198
+ while (from >= p) {
1199
+ currentNode = currentNode.next;
1200
+ p += currentNode.value.length;
1201
+ }
1202
+ // adjust pos (and p)
1203
+ p -= currentNode.value.length;
1204
+ pos = p;
1205
+
1206
+ // the current node is a Token, then the match starts inside another Token, which is invalid
1207
+ if (currentNode.value instanceof Token) {
1208
+ continue;
1209
+ }
1210
+
1211
+ // find the last node which is affected by this match
1212
+ for (
1213
+ var k = currentNode;
1214
+ k !== tokenList.tail && (p < to || typeof k.value === 'string');
1215
+ k = k.next
1216
+ ) {
1217
+ removeCount++;
1218
+ p += k.value.length;
1219
+ }
1220
+ removeCount--;
1221
+
1222
+ // replace with the new match
1223
+ str = text.slice(pos, p);
1224
+ match.index -= pos;
1225
+ } else {
1226
+ match = matchPattern(pattern, 0, str, lookbehind);
1227
+ if (!match) {
1228
+ continue;
1229
+ }
1230
+ }
1231
+
1232
+ // eslint-disable-next-line no-redeclare
1233
+ var from = match.index;
1234
+ var matchStr = match[0];
1235
+ var before = str.slice(0, from);
1236
+ var after = str.slice(from + matchStr.length);
1237
+
1238
+ var reach = pos + str.length;
1239
+ if (rematch && reach > rematch.reach) {
1240
+ rematch.reach = reach;
1241
+ }
1242
+
1243
+ var removeFrom = currentNode.prev;
1244
+
1245
+ if (before) {
1246
+ removeFrom = addAfter(tokenList, removeFrom, before);
1247
+ pos += before.length;
1248
+ }
1249
+
1250
+ removeRange(tokenList, removeFrom, removeCount);
1251
+
1252
+ var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr);
1253
+ currentNode = addAfter(tokenList, removeFrom, wrapped);
1254
+
1255
+ if (after) {
1256
+ addAfter(tokenList, currentNode, after);
1257
+ }
1258
+
1259
+ if (removeCount > 1) {
1260
+ // at least one Token object was removed, so we have to do some rematching
1261
+ // this can only happen if the current pattern is greedy
1262
+
1263
+ /** @type {RematchOptions} */
1264
+ var nestedRematch = {
1265
+ cause: token + ',' + j,
1266
+ reach: reach
1267
+ };
1268
+ matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch);
1269
+
1270
+ // the reach might have been extended because of the rematching
1271
+ if (rematch && nestedRematch.reach > rematch.reach) {
1272
+ rematch.reach = nestedRematch.reach;
1273
+ }
1274
+ }
1275
+ }
1276
+ }
1277
+ }
1278
+ }
1279
+
1280
+ /**
1281
+ * @typedef LinkedListNode
1282
+ * @property {T} value
1283
+ * @property {LinkedListNode<T> | null} prev The previous node.
1284
+ * @property {LinkedListNode<T> | null} next The next node.
1285
+ * @template T
1286
+ * @private
1287
+ */
1288
+
1289
+ /**
1290
+ * @template T
1291
+ * @private
1292
+ */
1293
+ function LinkedList() {
1294
+ /** @type {LinkedListNode<T>} */
1295
+ var head = { value: null, prev: null, next: null };
1296
+ /** @type {LinkedListNode<T>} */
1297
+ var tail = { value: null, prev: head, next: null };
1298
+ head.next = tail;
1299
+
1300
+ /** @type {LinkedListNode<T>} */
1301
+ this.head = head;
1302
+ /** @type {LinkedListNode<T>} */
1303
+ this.tail = tail;
1304
+ this.length = 0;
1305
+ }
1306
+
1307
+ /**
1308
+ * Adds a new node with the given value to the list.
1309
+ *
1310
+ * @param {LinkedList<T>} list
1311
+ * @param {LinkedListNode<T>} node
1312
+ * @param {T} value
1313
+ * @returns {LinkedListNode<T>} The added node.
1314
+ * @template T
1315
+ */
1316
+ function addAfter(list, node, value) {
1317
+ // assumes that node != list.tail && values.length >= 0
1318
+ var next = node.next;
1319
+
1320
+ var newNode = { value: value, prev: node, next: next };
1321
+ node.next = newNode;
1322
+ next.prev = newNode;
1323
+ list.length++;
1324
+
1325
+ return newNode;
1326
+ }
1327
+ /**
1328
+ * Removes `count` nodes after the given node. The given node will not be removed.
1329
+ *
1330
+ * @param {LinkedList<T>} list
1331
+ * @param {LinkedListNode<T>} node
1332
+ * @param {number} count
1333
+ * @template T
1334
+ */
1335
+ function removeRange(list, node, count) {
1336
+ var next = node.next;
1337
+ for (var i = 0; i < count && next !== list.tail; i++) {
1338
+ next = next.next;
1339
+ }
1340
+ node.next = next;
1341
+ next.prev = node;
1342
+ list.length -= i;
1343
+ }
1344
+ /**
1345
+ * @param {LinkedList<T>} list
1346
+ * @returns {T[]}
1347
+ * @template T
1348
+ */
1349
+ function toArray(list) {
1350
+ var array = [];
1351
+ var node = list.head.next;
1352
+ while (node !== list.tail) {
1353
+ array.push(node.value);
1354
+ node = node.next;
1355
+ }
1356
+ return array;
1357
+ }
1358
+
1359
+
1360
+ if (!_self.document) {
1361
+ if (!_self.addEventListener) {
1362
+ // in Node.js
1363
+ return _;
1364
+ }
1365
+
1366
+ if (!_.disableWorkerMessageHandler) {
1367
+ // In worker
1368
+ _self.addEventListener('message', function (evt) {
1369
+ var message = JSON.parse(evt.data);
1370
+ var lang = message.language;
1371
+ var code = message.code;
1372
+ var immediateClose = message.immediateClose;
1373
+
1374
+ _self.postMessage(_.highlight(code, _.languages[lang], lang));
1375
+ if (immediateClose) {
1376
+ _self.close();
1377
+ }
1378
+ }, false);
1379
+ }
1380
+
1381
+ return _;
1382
+ }
1383
+
1384
+ // Get current script and highlight
1385
+ var script = _.util.currentScript();
1386
+
1387
+ if (script) {
1388
+ _.filename = script.src;
1389
+
1390
+ if (script.hasAttribute('data-manual')) {
1391
+ _.manual = true;
1392
+ }
1393
+ }
1394
+
1395
+ function highlightAutomaticallyCallback() {
1396
+ if (!_.manual) {
1397
+ _.highlightAll();
1398
+ }
1399
+ }
1400
+
1401
+ if (!_.manual) {
1402
+ // If the document state is "loading", then we'll use DOMContentLoaded.
1403
+ // If the document state is "interactive" and the prism.js script is deferred, then we'll also use the
1404
+ // DOMContentLoaded event because there might be some plugins or languages which have also been deferred and they
1405
+ // might take longer one animation frame to execute which can create a race condition where only some plugins have
1406
+ // been loaded when Prism.highlightAll() is executed, depending on how fast resources are loaded.
1407
+ // See https://github.com/PrismJS/prism/issues/2102
1408
+ var readyState = document.readyState;
1409
+ if (readyState === 'loading' || readyState === 'interactive' && script && script.defer) {
1410
+ document.addEventListener('DOMContentLoaded', highlightAutomaticallyCallback);
1411
+ } else {
1412
+ if (window.requestAnimationFrame) {
1413
+ window.requestAnimationFrame(highlightAutomaticallyCallback);
1414
+ } else {
1415
+ window.setTimeout(highlightAutomaticallyCallback, 16);
1416
+ }
1417
+ }
1418
+ }
1419
+
1420
+ return _;
1421
+
1422
+ }(_self));
1423
+
1424
+ if (module.exports) {
1425
+ module.exports = Prism;
1426
+ }
1427
+
1428
+ // hack for components to work correctly in node.js
1429
+ if (typeof _commonjsHelpers.commonjsGlobal !== 'undefined') {
1430
+ _commonjsHelpers.commonjsGlobal.Prism = Prism;
1431
+ }
1432
+
1433
+ // some additional documentation/types
1434
+
1435
+ /**
1436
+ * The expansion of a simple `RegExp` literal to support additional properties.
1437
+ *
1438
+ * @typedef GrammarToken
1439
+ * @property {RegExp} pattern The regular expression of the token.
1440
+ * @property {boolean} [lookbehind=false] If `true`, then the first capturing group of `pattern` will (effectively)
1441
+ * behave as a lookbehind group meaning that the captured text will not be part of the matched text of the new token.
1442
+ * @property {boolean} [greedy=false] Whether the token is greedy.
1443
+ * @property {string|string[]} [alias] An optional alias or list of aliases.
1444
+ * @property {Grammar} [inside] The nested grammar of this token.
1445
+ *
1446
+ * The `inside` grammar will be used to tokenize the text value of each token of this kind.
1447
+ *
1448
+ * This can be used to make nested and even recursive language definitions.
1449
+ *
1450
+ * Note: This can cause infinite recursion. Be careful when you embed different languages or even the same language into
1451
+ * each another.
1452
+ * @global
1453
+ * @public
1454
+ */
1455
+
1456
+ /**
1457
+ * @typedef Grammar
1458
+ * @type {Object<string, RegExp | GrammarToken | Array<RegExp | GrammarToken>>}
1459
+ * @property {Grammar} [rest] An optional grammar object that will be appended to this grammar.
1460
+ * @global
1461
+ * @public
1462
+ */
1463
+
1464
+ /**
1465
+ * A function which will invoked after an element was successfully highlighted.
1466
+ *
1467
+ * @callback HighlightCallback
1468
+ * @param {Element} element The element successfully highlighted.
1469
+ * @returns {void}
1470
+ * @global
1471
+ * @public
1472
+ */
1473
+
1474
+ /**
1475
+ * @callback HookCallback
1476
+ * @param {Object<string, any>} env The environment variables of the hook.
1477
+ * @returns {void}
1478
+ * @global
1479
+ * @public
1480
+ */
1481
+
1482
+
1483
+ /* **********************************************
1484
+ Begin prism-markup.js
1485
+ ********************************************** */
1486
+
1487
+ Prism.languages.markup = {
1488
+ 'comment': {
1489
+ pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
1490
+ greedy: true
1491
+ },
1492
+ 'prolog': {
1493
+ pattern: /<\?[\s\S]+?\?>/,
1494
+ greedy: true
1495
+ },
1496
+ 'doctype': {
1497
+ // https://www.w3.org/TR/xml/#NT-doctypedecl
1498
+ pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
1499
+ greedy: true,
1500
+ inside: {
1501
+ 'internal-subset': {
1502
+ pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
1503
+ lookbehind: true,
1504
+ greedy: true,
1505
+ inside: null // see below
1506
+ },
1507
+ 'string': {
1508
+ pattern: /"[^"]*"|'[^']*'/,
1509
+ greedy: true
1510
+ },
1511
+ 'punctuation': /^<!|>$|[[\]]/,
1512
+ 'doctype-tag': /^DOCTYPE/i,
1513
+ 'name': /[^\s<>'"]+/
1514
+ }
1515
+ },
1516
+ 'cdata': {
1517
+ pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
1518
+ greedy: true
1519
+ },
1520
+ 'tag': {
1521
+ pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
1522
+ greedy: true,
1523
+ inside: {
1524
+ 'tag': {
1525
+ pattern: /^<\/?[^\s>\/]+/,
1526
+ inside: {
1527
+ 'punctuation': /^<\/?/,
1528
+ 'namespace': /^[^\s>\/:]+:/
1529
+ }
1530
+ },
1531
+ 'special-attr': [],
1532
+ 'attr-value': {
1533
+ pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
1534
+ inside: {
1535
+ 'punctuation': [
1536
+ {
1537
+ pattern: /^=/,
1538
+ alias: 'attr-equals'
1539
+ },
1540
+ {
1541
+ pattern: /^(\s*)["']|["']$/,
1542
+ lookbehind: true
1543
+ }
1544
+ ]
1545
+ }
1546
+ },
1547
+ 'punctuation': /\/?>/,
1548
+ 'attr-name': {
1549
+ pattern: /[^\s>\/]+/,
1550
+ inside: {
1551
+ 'namespace': /^[^\s>\/:]+:/
1552
+ }
1553
+ }
1554
+
1555
+ }
1556
+ },
1557
+ 'entity': [
1558
+ {
1559
+ pattern: /&[\da-z]{1,8};/i,
1560
+ alias: 'named-entity'
1561
+ },
1562
+ /&#x?[\da-f]{1,8};/i
1563
+ ]
1564
+ };
1565
+
1566
+ Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] =
1567
+ Prism.languages.markup['entity'];
1568
+ Prism.languages.markup['doctype'].inside['internal-subset'].inside = Prism.languages.markup;
1569
+
1570
+ // Plugin to make entity title show the real entity, idea by Roman Komarov
1571
+ Prism.hooks.add('wrap', function (env) {
1572
+
1573
+ if (env.type === 'entity') {
1574
+ env.attributes['title'] = env.content.replace(/&amp;/, '&');
1575
+ }
1576
+ });
1577
+
1578
+ Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
1579
+ /**
1580
+ * Adds an inlined language to markup.
1581
+ *
1582
+ * An example of an inlined language is CSS with `<style>` tags.
1583
+ *
1584
+ * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
1585
+ * case insensitive.
1586
+ * @param {string} lang The language key.
1587
+ * @example
1588
+ * addInlined('style', 'css');
1589
+ */
1590
+ value: function addInlined(tagName, lang) {
1591
+ var includedCdataInside = {};
1592
+ includedCdataInside['language-' + lang] = {
1593
+ pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
1594
+ lookbehind: true,
1595
+ inside: Prism.languages[lang]
1596
+ };
1597
+ includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i;
1598
+
1599
+ var inside = {
1600
+ 'included-cdata': {
1601
+ pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
1602
+ inside: includedCdataInside
1603
+ }
1604
+ };
1605
+ inside['language-' + lang] = {
1606
+ pattern: /[\s\S]+/,
1607
+ inside: Prism.languages[lang]
1608
+ };
1609
+
1610
+ var def = {};
1611
+ def[tagName] = {
1612
+ pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () { return tagName; }), 'i'),
1613
+ lookbehind: true,
1614
+ greedy: true,
1615
+ inside: inside
1616
+ };
1617
+
1618
+ Prism.languages.insertBefore('markup', 'cdata', def);
1619
+ }
1620
+ });
1621
+ Object.defineProperty(Prism.languages.markup.tag, 'addAttribute', {
1622
+ /**
1623
+ * Adds an pattern to highlight languages embedded in HTML attributes.
1624
+ *
1625
+ * An example of an inlined language is CSS with `style` attributes.
1626
+ *
1627
+ * @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as
1628
+ * case insensitive.
1629
+ * @param {string} lang The language key.
1630
+ * @example
1631
+ * addAttribute('style', 'css');
1632
+ */
1633
+ value: function (attrName, lang) {
1634
+ Prism.languages.markup.tag.inside['special-attr'].push({
1635
+ pattern: RegExp(
1636
+ /(^|["'\s])/.source + '(?:' + attrName + ')' + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
1637
+ 'i'
1638
+ ),
1639
+ lookbehind: true,
1640
+ inside: {
1641
+ 'attr-name': /^[^\s=]+/,
1642
+ 'attr-value': {
1643
+ pattern: /=[\s\S]+/,
1644
+ inside: {
1645
+ 'value': {
1646
+ pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
1647
+ lookbehind: true,
1648
+ alias: [lang, 'language-' + lang],
1649
+ inside: Prism.languages[lang]
1650
+ },
1651
+ 'punctuation': [
1652
+ {
1653
+ pattern: /^=/,
1654
+ alias: 'attr-equals'
1655
+ },
1656
+ /"|'/
1657
+ ]
1658
+ }
1659
+ }
1660
+ }
1661
+ });
1662
+ }
1663
+ });
1664
+
1665
+ Prism.languages.html = Prism.languages.markup;
1666
+ Prism.languages.mathml = Prism.languages.markup;
1667
+ Prism.languages.svg = Prism.languages.markup;
1668
+
1669
+ Prism.languages.xml = Prism.languages.extend('markup', {});
1670
+ Prism.languages.ssml = Prism.languages.xml;
1671
+ Prism.languages.atom = Prism.languages.xml;
1672
+ Prism.languages.rss = Prism.languages.xml;
1673
+
1674
+
1675
+ /* **********************************************
1676
+ Begin prism-css.js
1677
+ ********************************************** */
1678
+
1679
+ (function (Prism) {
1680
+
1681
+ var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
1682
+
1683
+ Prism.languages.css = {
1684
+ 'comment': /\/\*[\s\S]*?\*\//,
1685
+ 'atrule': {
1686
+ pattern: RegExp('@[\\w-](?:' + /[^;{\s"']|\s+(?!\s)/.source + '|' + string.source + ')*?' + /(?:;|(?=\s*\{))/.source),
1687
+ inside: {
1688
+ 'rule': /^@[\w-]+/,
1689
+ 'selector-function-argument': {
1690
+ pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
1691
+ lookbehind: true,
1692
+ alias: 'selector'
1693
+ },
1694
+ 'keyword': {
1695
+ pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
1696
+ lookbehind: true
1697
+ }
1698
+ // See rest below
1699
+ }
1700
+ },
1701
+ 'url': {
1702
+ // https://drafts.csswg.org/css-values-3/#urls
1703
+ pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'),
1704
+ greedy: true,
1705
+ inside: {
1706
+ 'function': /^url/i,
1707
+ 'punctuation': /^\(|\)$/,
1708
+ 'string': {
1709
+ pattern: RegExp('^' + string.source + '$'),
1710
+ alias: 'url'
1711
+ }
1712
+ }
1713
+ },
1714
+ 'selector': {
1715
+ pattern: RegExp('(^|[{}\\s])[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + string.source + ')*(?=\\s*\\{)'),
1716
+ lookbehind: true
1717
+ },
1718
+ 'string': {
1719
+ pattern: string,
1720
+ greedy: true
1721
+ },
1722
+ 'property': {
1723
+ pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
1724
+ lookbehind: true
1725
+ },
1726
+ 'important': /!important\b/i,
1727
+ 'function': {
1728
+ pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
1729
+ lookbehind: true
1730
+ },
1731
+ 'punctuation': /[(){};:,]/
1732
+ };
1733
+
1734
+ Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
1735
+
1736
+ var markup = Prism.languages.markup;
1737
+ if (markup) {
1738
+ markup.tag.addInlined('style', 'css');
1739
+ markup.tag.addAttribute('style', 'css');
1740
+ }
1741
+
1742
+ }(Prism));
1743
+
1744
+
1745
+ /* **********************************************
1746
+ Begin prism-clike.js
1747
+ ********************************************** */
1748
+
1749
+ Prism.languages.clike = {
1750
+ 'comment': [
1751
+ {
1752
+ pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
1753
+ lookbehind: true,
1754
+ greedy: true
1755
+ },
1756
+ {
1757
+ pattern: /(^|[^\\:])\/\/.*/,
1758
+ lookbehind: true,
1759
+ greedy: true
1760
+ }
1761
+ ],
1762
+ 'string': {
1763
+ pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
1764
+ greedy: true
1765
+ },
1766
+ 'class-name': {
1767
+ pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
1768
+ lookbehind: true,
1769
+ inside: {
1770
+ 'punctuation': /[.\\]/
1771
+ }
1772
+ },
1773
+ 'keyword': /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
1774
+ 'boolean': /\b(?:false|true)\b/,
1775
+ 'function': /\b\w+(?=\()/,
1776
+ 'number': /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
1777
+ 'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
1778
+ 'punctuation': /[{}[\];(),.:]/
1779
+ };
1780
+
1781
+
1782
+ /* **********************************************
1783
+ Begin prism-javascript.js
1784
+ ********************************************** */
1785
+
1786
+ Prism.languages.javascript = Prism.languages.extend('clike', {
1787
+ 'class-name': [
1788
+ Prism.languages.clike['class-name'],
1789
+ {
1790
+ pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
1791
+ lookbehind: true
1792
+ }
1793
+ ],
1794
+ 'keyword': [
1795
+ {
1796
+ pattern: /((?:^|\})\s*)catch\b/,
1797
+ lookbehind: true
1798
+ },
1799
+ {
1800
+ 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/,
1801
+ lookbehind: true
1802
+ },
1803
+ ],
1804
+ // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
1805
+ 'function': /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
1806
+ 'number': {
1807
+ pattern: RegExp(
1808
+ /(^|[^\w$])/.source +
1809
+ '(?:' +
1810
+ (
1811
+ // constant
1812
+ /NaN|Infinity/.source +
1813
+ '|' +
1814
+ // binary integer
1815
+ /0[bB][01]+(?:_[01]+)*n?/.source +
1816
+ '|' +
1817
+ // octal integer
1818
+ /0[oO][0-7]+(?:_[0-7]+)*n?/.source +
1819
+ '|' +
1820
+ // hexadecimal integer
1821
+ /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source +
1822
+ '|' +
1823
+ // decimal bigint
1824
+ /\d+(?:_\d+)*n/.source +
1825
+ '|' +
1826
+ // decimal number (integer or float) but no bigint
1827
+ /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source
1828
+ ) +
1829
+ ')' +
1830
+ /(?![\w$])/.source
1831
+ ),
1832
+ lookbehind: true
1833
+ },
1834
+ 'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
1835
+ });
1836
+
1837
+ Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
1838
+
1839
+ Prism.languages.insertBefore('javascript', 'keyword', {
1840
+ 'regex': {
1841
+ pattern: RegExp(
1842
+ // lookbehind
1843
+ // eslint-disable-next-line regexp/no-dupe-characters-character-class
1844
+ /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source +
1845
+ // Regex pattern:
1846
+ // There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
1847
+ // classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
1848
+ // with the only syntax, so we have to define 2 different regex patterns.
1849
+ /\//.source +
1850
+ '(?:' +
1851
+ /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source +
1852
+ '|' +
1853
+ // `v` flag syntax. This supports 3 levels of nested character classes.
1854
+ /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source +
1855
+ ')' +
1856
+ // lookahead
1857
+ /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
1858
+ ),
1859
+ lookbehind: true,
1860
+ greedy: true,
1861
+ inside: {
1862
+ 'regex-source': {
1863
+ pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
1864
+ lookbehind: true,
1865
+ alias: 'language-regex',
1866
+ inside: Prism.languages.regex
1867
+ },
1868
+ 'regex-delimiter': /^\/|\/$/,
1869
+ 'regex-flags': /^[a-z]+$/,
1870
+ }
1871
+ },
1872
+ // This must be declared before keyword because we use "function" inside the look-forward
1873
+ 'function-variable': {
1874
+ 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*=>))/,
1875
+ alias: 'function'
1876
+ },
1877
+ 'parameter': [
1878
+ {
1879
+ pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
1880
+ lookbehind: true,
1881
+ inside: Prism.languages.javascript
1882
+ },
1883
+ {
1884
+ pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
1885
+ lookbehind: true,
1886
+ inside: Prism.languages.javascript
1887
+ },
1888
+ {
1889
+ pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
1890
+ lookbehind: true,
1891
+ inside: Prism.languages.javascript
1892
+ },
1893
+ {
1894
+ 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*\{)/,
1895
+ lookbehind: true,
1896
+ inside: Prism.languages.javascript
1897
+ }
1898
+ ],
1899
+ 'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
1900
+ });
1901
+
1902
+ Prism.languages.insertBefore('javascript', 'string', {
1903
+ 'hashbang': {
1904
+ pattern: /^#!.*/,
1905
+ greedy: true,
1906
+ alias: 'comment'
1907
+ },
1908
+ 'template-string': {
1909
+ pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
1910
+ greedy: true,
1911
+ inside: {
1912
+ 'template-punctuation': {
1913
+ pattern: /^`|`$/,
1914
+ alias: 'string'
1915
+ },
1916
+ 'interpolation': {
1917
+ pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
1918
+ lookbehind: true,
1919
+ inside: {
1920
+ 'interpolation-punctuation': {
1921
+ pattern: /^\$\{|\}$/,
1922
+ alias: 'punctuation'
1923
+ },
1924
+ rest: Prism.languages.javascript
1925
+ }
1926
+ },
1927
+ 'string': /[\s\S]+/
1928
+ }
1929
+ },
1930
+ 'string-property': {
1931
+ pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
1932
+ lookbehind: true,
1933
+ greedy: true,
1934
+ alias: 'property'
1935
+ }
1936
+ });
1937
+
1938
+ Prism.languages.insertBefore('javascript', 'operator', {
1939
+ 'literal-property': {
1940
+ pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
1941
+ lookbehind: true,
1942
+ alias: 'property'
1943
+ },
1944
+ });
1945
+
1946
+ if (Prism.languages.markup) {
1947
+ Prism.languages.markup.tag.addInlined('script', 'javascript');
1948
+
1949
+ // add attribute support for all DOM events.
1950
+ // https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events
1951
+ Prism.languages.markup.tag.addAttribute(
1952
+ /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,
1953
+ 'javascript'
1954
+ );
1955
+ }
1956
+
1957
+ Prism.languages.js = Prism.languages.javascript;
1958
+
1959
+
1960
+ /* **********************************************
1961
+ Begin prism-file-highlight.js
1962
+ ********************************************** */
1963
+
1964
+ (function () {
1965
+
1966
+ if (typeof Prism === 'undefined' || typeof document === 'undefined') {
1967
+ return;
1968
+ }
1969
+
1970
+ // https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill
1971
+ if (!Element.prototype.matches) {
1972
+ Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
1973
+ }
1974
+
1975
+ var LOADING_MESSAGE = 'Loading…';
1976
+ var FAILURE_MESSAGE = function (status, message) {
1977
+ return '✖ Error ' + status + ' while fetching file: ' + message;
1978
+ };
1979
+ var FAILURE_EMPTY_MESSAGE = '✖ Error: File does not exist or is empty';
1980
+
1981
+ var EXTENSIONS = {
1982
+ 'js': 'javascript',
1983
+ 'py': 'python',
1984
+ 'rb': 'ruby',
1985
+ 'ps1': 'powershell',
1986
+ 'psm1': 'powershell',
1987
+ 'sh': 'bash',
1988
+ 'bat': 'batch',
1989
+ 'h': 'c',
1990
+ 'tex': 'latex'
1991
+ };
1992
+
1993
+ var STATUS_ATTR = 'data-src-status';
1994
+ var STATUS_LOADING = 'loading';
1995
+ var STATUS_LOADED = 'loaded';
1996
+ var STATUS_FAILED = 'failed';
1997
+
1998
+ var SELECTOR = 'pre[data-src]:not([' + STATUS_ATTR + '="' + STATUS_LOADED + '"])'
1999
+ + ':not([' + STATUS_ATTR + '="' + STATUS_LOADING + '"])';
2000
+
2001
+ /**
2002
+ * Loads the given file.
2003
+ *
2004
+ * @param {string} src The URL or path of the source file to load.
2005
+ * @param {(result: string) => void} success
2006
+ * @param {(reason: string) => void} error
2007
+ */
2008
+ function loadFile(src, success, error) {
2009
+ var xhr = new XMLHttpRequest();
2010
+ xhr.open('GET', src, true);
2011
+ xhr.onreadystatechange = function () {
2012
+ if (xhr.readyState == 4) {
2013
+ if (xhr.status < 400 && xhr.responseText) {
2014
+ success(xhr.responseText);
2015
+ } else {
2016
+ if (xhr.status >= 400) {
2017
+ error(FAILURE_MESSAGE(xhr.status, xhr.statusText));
2018
+ } else {
2019
+ error(FAILURE_EMPTY_MESSAGE);
2020
+ }
2021
+ }
2022
+ }
2023
+ };
2024
+ xhr.send(null);
2025
+ }
2026
+
2027
+ /**
2028
+ * Parses the given range.
2029
+ *
2030
+ * This returns a range with inclusive ends.
2031
+ *
2032
+ * @param {string | null | undefined} range
2033
+ * @returns {[number, number | undefined] | undefined}
2034
+ */
2035
+ function parseRange(range) {
2036
+ var m = /^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(range || '');
2037
+ if (m) {
2038
+ var start = Number(m[1]);
2039
+ var comma = m[2];
2040
+ var end = m[3];
2041
+
2042
+ if (!comma) {
2043
+ return [start, start];
2044
+ }
2045
+ if (!end) {
2046
+ return [start, undefined];
2047
+ }
2048
+ return [start, Number(end)];
2049
+ }
2050
+ return undefined;
2051
+ }
2052
+
2053
+ Prism.hooks.add('before-highlightall', function (env) {
2054
+ env.selector += ', ' + SELECTOR;
2055
+ });
2056
+
2057
+ Prism.hooks.add('before-sanity-check', function (env) {
2058
+ var pre = /** @type {HTMLPreElement} */ (env.element);
2059
+ if (pre.matches(SELECTOR)) {
2060
+ env.code = ''; // fast-path the whole thing and go to complete
2061
+
2062
+ pre.setAttribute(STATUS_ATTR, STATUS_LOADING); // mark as loading
2063
+
2064
+ // add code element with loading message
2065
+ var code = pre.appendChild(document.createElement('CODE'));
2066
+ code.textContent = LOADING_MESSAGE;
2067
+
2068
+ var src = pre.getAttribute('data-src');
2069
+
2070
+ var language = env.language;
2071
+ if (language === 'none') {
2072
+ // the language might be 'none' because there is no language set;
2073
+ // in this case, we want to use the extension as the language
2074
+ var extension = (/\.(\w+)$/.exec(src) || [, 'none'])[1];
2075
+ language = EXTENSIONS[extension] || extension;
2076
+ }
2077
+
2078
+ // set language classes
2079
+ Prism.util.setLanguage(code, language);
2080
+ Prism.util.setLanguage(pre, language);
2081
+
2082
+ // preload the language
2083
+ var autoloader = Prism.plugins.autoloader;
2084
+ if (autoloader) {
2085
+ autoloader.loadLanguages(language);
2086
+ }
2087
+
2088
+ // load file
2089
+ loadFile(
2090
+ src,
2091
+ function (text) {
2092
+ // mark as loaded
2093
+ pre.setAttribute(STATUS_ATTR, STATUS_LOADED);
2094
+
2095
+ // handle data-range
2096
+ var range = parseRange(pre.getAttribute('data-range'));
2097
+ if (range) {
2098
+ var lines = text.split(/\r\n?|\n/g);
2099
+
2100
+ // the range is one-based and inclusive on both ends
2101
+ var start = range[0];
2102
+ var end = range[1] == null ? lines.length : range[1];
2103
+
2104
+ if (start < 0) { start += lines.length; }
2105
+ start = Math.max(0, Math.min(start - 1, lines.length));
2106
+ if (end < 0) { end += lines.length; }
2107
+ end = Math.max(0, Math.min(end, lines.length));
2108
+
2109
+ text = lines.slice(start, end).join('\n');
2110
+
2111
+ // add data-start for line numbers
2112
+ if (!pre.hasAttribute('data-start')) {
2113
+ pre.setAttribute('data-start', String(start + 1));
2114
+ }
2115
+ }
2116
+
2117
+ // highlight code
2118
+ code.textContent = text;
2119
+ Prism.highlightElement(code);
2120
+ },
2121
+ function (error) {
2122
+ // mark as failed
2123
+ pre.setAttribute(STATUS_ATTR, STATUS_FAILED);
2124
+
2125
+ code.textContent = error;
2126
+ }
2127
+ );
2128
+ }
2129
+ });
2130
+
2131
+ Prism.plugins.fileHighlight = {
2132
+ /**
2133
+ * Executes the File Highlight plugin for all matching `pre` elements under the given container.
2134
+ *
2135
+ * Note: Elements which are already loaded or currently loading will not be touched by this method.
2136
+ *
2137
+ * @param {ParentNode} [container=document]
2138
+ */
2139
+ highlight: function highlight(container) {
2140
+ var elements = (container || document).querySelectorAll(SELECTOR);
2141
+
2142
+ for (var i = 0, element; (element = elements[i++]);) {
2143
+ Prism.highlightElement(element);
2144
+ }
2145
+ }
2146
+ };
2147
+
2148
+ var logged = false;
2149
+ /** @deprecated Use `Prism.plugins.fileHighlight.highlight` instead. */
2150
+ Prism.fileHighlight = function () {
2151
+ if (!logged) {
2152
+ console.warn('Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead.');
2153
+ logged = true;
2154
+ }
2155
+ Prism.plugins.fileHighlight.highlight.apply(this, arguments);
2156
+ };
2157
+
2158
+ }());
2159
+ } (prism));
2160
+
2161
+ var Prism = prism.exports;
2162
+
2163
+ 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}";
2164
+ injectCss.n(css,{});
2165
+
213
2166
  var SyntaxHighlighter = function SyntaxHighlighter(_ref) {
214
2167
  var className = _ref.className,
215
2168
  code = _ref.code,
216
2169
  language = _ref.language;
217
2170
  React.useEffect(function () {
218
- Prism__default["default"].highlightAll();
2171
+ Prism.highlightAll();
219
2172
  }, [code]);
220
2173
  return /*#__PURE__*/React__default["default"].createElement("pre", {
221
2174
  className: className