-
-
Notifications
You must be signed in to change notification settings - Fork 285
/
editor.0a83627a.js
1168 lines (1161 loc) ยท 403 KB
/
editor.0a83627a.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
function e(e,t,n,o){Object.defineProperty(e,t,{get:n,set:o,enumerable:!0,configurable:!0})}function t(e){Object.defineProperty(e,"__esModule",{value:!0,configurable:!0})}var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},o={},a={},r=n.parcelRequire94c2;null==r&&((r=function(e){if(e in o)return o[e].exports;if(e in a){var t=a[e];delete a[e];var n={id:e,exports:{}};return o[e]=n,t.call(n.exports,n,n.exports),n.exports}var r=new Error("Cannot find module '"+e+"'");throw r.code="MODULE_NOT_FOUND",r}).register=function(e,t){a[e]=t},n.parcelRequire94c2=r),r.register("ko7kR",(function(t,n){var o,a;e(t.exports,"register",(()=>o),(e=>o=e)),e(t.exports,"resolve",(()=>a),(e=>a=e));var r={};o=function(e){for(var t=Object.keys(e),n=0;n<t.length;n++)r[t[n]]=e[t[n]]},a=function(e){var t=r[e];if(null==t)throw new Error("Could not resolve bundle with id "+e);return t}})),r("ko7kR").register(JSON.parse('{"QBgnr":"editor.0a83627a.js","1hW9p":"firebase-app.bead1f66.js","idnIw":"firebase-firestore.460b9b58.js","asIno":"arrow-up-circle-outline.3f146ffe.svg","1c0Rm":"document-text-outline.8d1e2333.svg","fUvXZ":"help-circle-outline.a023036a.svg","c9FOI":"vmsg.56bb9389.wasm","5Grpk":"editor.0c13a924.js"}'));var i=r("cNaMA");r("eS9BV");i=r("cNaMA"),i=r("cNaMA");function s(e){for(var t=arguments.length,n=Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];throw Error("[Immer] minified error nr: "+e+(n.length?" "+n.map((function(e){return"'"+e+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function l(e){return!!e&&!!e[Q]}function c(e){return!!e&&(function(e){if(!e||"object"!=typeof e)return!1;var t=Object.getPrototypeOf(e);return!t||t===Object.prototype}(e)||Array.isArray(e)||!!e[V]||!!e.constructor[V]||f(e)||_(e))}function d(e,t,n){void 0===n&&(n=!1),0===u(e)?(n?Object.keys:X)(e).forEach((function(o){n&&"symbol"==typeof o||t(o,e[o],e)})):e.forEach((function(n,o){return t(o,n,e)}))}function u(e){var t=e[Q];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:f(e)?2:_(e)?3:0}function p(e,t){return 2===u(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function m(e,t){return 2===u(e)?e.get(t):e[t]}function g(e,t,n){var o=u(e);2===o?e.set(t,n):3===o?(e.delete(t),e.add(n)):e[t]=n}function h(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function f(e){return W&&e instanceof Map}function _(e){return G&&e instanceof Set}function b(e){return e.o||e.t}function v(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=Y(e);delete t[Q];for(var n=X(t),o=0;o<n.length;o++){var a=n[o],r=t[a];!1===r.writable&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(t[a]={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[a]})}return Object.create(Object.getPrototypeOf(e),t)}function y(e,t){return void 0===t&&(t=!1),k(e)||l(e)||!c(e)||(u(e)>1&&(e.set=e.add=e.clear=e.delete=w),Object.freeze(e),t&&d(e,(function(e,t){return y(t,!0)}),!0)),e}function w(){s(2)}function k(e){return null==e||"object"!=typeof e||Object.isFrozen(e)}function E(e){var t=J[e];return t||s(18,e),t}function $(e,t){J[e]||(J[e]=t)}function x(){return q}function S(e,t){t&&(E("Patches"),e.u=[],e.s=[],e.v=t)}function N(e){C(e),e.p.forEach(M),e.p=null}function C(e){e===q&&(q=e.l)}function A(e){return q={p:[],l:q,h:e,m:!0,_:0}}function M(e){var t=e[Q];0===t.i||1===t.i?t.j():t.g=!0}function O(e,t){t._=t.p.length;var n=t.p[0],o=void 0!==e&&e!==n;return t.h.O||E("ES5").S(t,e,o),o?(n[Q].P&&(N(t),s(4)),c(e)&&(e=T(t,e),t.l||D(t,e)),t.u&&E("Patches").M(n[Q],e,t.u,t.s)):e=T(t,n,[]),N(t),t.u&&t.v(t.u,t.s),e!==Z?e:void 0}function T(e,t,n){if(k(t))return t;var o=t[Q];if(!o)return d(t,(function(a,r){return R(e,o,t,a,r,n)}),!0),t;if(o.A!==e)return t;if(!o.P)return D(e,o.t,!0),o.t;if(!o.I){o.I=!0,o.A._--;var a=4===o.i||5===o.i?o.o=v(o.k):o.o;d(3===o.i?new Set(a):a,(function(t,r){return R(e,o,a,t,r,n)})),D(e,a,!1),n&&e.u&&E("Patches").R(o,n,e.u,e.s)}return o.o}function R(e,t,n,o,a,r){if(l(a)){var i=T(e,a,r&&t&&3!==t.i&&!p(t.D,o)?r.concat(o):void 0);if(g(n,o,i),!l(i))return;e.m=!1}if(c(a)&&!k(a)){if(!e.h.N&&e._<1)return;T(e,a),t&&t.A.l||D(e,a)}}function D(e,t,n){void 0===n&&(n=!1),e.h.N&&e.m&&y(t,n)}function L(e,t){var n=e[Q];return(n?b(n):e)[t]}function I(e,t){if(t in e)for(var n=Object.getPrototypeOf(e);n;){var o=Object.getOwnPropertyDescriptor(n,t);if(o)return o;n=Object.getPrototypeOf(n)}}function P(e){e.P||(e.P=!0,e.l&&P(e.l))}function j(e){e.o||(e.o=v(e.t))}function B(e,t,n){var o=f(t)?E("MapSet").T(t,n):_(t)?E("MapSet").F(t,n):e.O?function(e,t){var n=Array.isArray(e),o={i:n?1:0,A:t?t.A:x(),P:!1,I:!1,D:{},l:t,t:e,k:null,o:null,j:null,C:!1},a=o,r=ee;n&&(a=[o],r=te);var i=Proxy.revocable(a,r),s=i.revoke,l=i.proxy;return o.k=l,o.j=s,l}(t,n):E("ES5").J(t,n);return(n?n.A:x()).p.push(o),o}function U(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return v(e)}function F(){function e(t){if(!c(t))return t;if(Array.isArray(t))return t.map(e);if(f(t))return new Map(Array.from(t.entries()).map((function(t){return[t[0],e(t[1])]})));if(_(t))return new Set(Array.from(t).map(e));var n=Object.create(Object.getPrototypeOf(t));for(var o in t)n[o]=e(t[o]);return n}function t(t){return l(t)?e(t):t}var n="add";$("Patches",{$:function(t,o){return o.forEach((function(o){for(var a=o.path,r=o.op,i=t,l=0;l<a.length-1;l++)"object"!=typeof(i=m(i,a[l]))&&s(15,a.join("/"));var c=u(i),d=e(o.value),p=a[a.length-1];switch(r){case"replace":switch(c){case 2:return i.set(p,d);case 3:s(16);default:return i[p]=d}case n:switch(c){case 1:return i.splice(p,0,d);case 2:return i.set(p,d);case 3:return i.add(d);default:return i[p]=d}case"remove":switch(c){case 1:return i.splice(p,1);case 2:return i.delete(p);case 3:return i.delete(o.value);default:return delete i[p]}default:s(17,r)}})),t},R:function(e,o,a,r){switch(e.i){case 0:case 4:case 2:return function(e,o,a,r){var i=e.t,s=e.o;d(e.D,(function(e,l){var c=m(i,e),d=m(s,e),u=l?p(i,e)?"replace":n:"remove";if(c!==d||"replace"!==u){var g=o.concat(e);a.push("remove"===u?{op:u,path:g}:{op:u,path:g,value:d}),r.push(u===n?{op:"remove",path:g}:"remove"===u?{op:n,path:g,value:t(c)}:{op:"replace",path:g,value:t(c)})}}))}(e,o,a,r);case 5:case 1:return function(e,o,a,r){var i=e.t,s=e.D,l=e.o;if(l.length<i.length){var c=[l,i];i=c[0],l=c[1];var d=[r,a];a=d[0],r=d[1]}for(var u=0;u<i.length;u++)if(s[u]&&l[u]!==i[u]){var p=o.concat([u]);a.push({op:"replace",path:p,value:t(l[u])}),r.push({op:"replace",path:p,value:t(i[u])})}for(var m=i.length;m<l.length;m++){var g=o.concat([m]);a.push({op:n,path:g,value:t(l[m])})}i.length<l.length&&r.push({op:"replace",path:o.concat(["length"]),value:i.length})}(e,o,a,r);case 3:return function(e,t,o,a){var r=e.t,i=e.o,s=0;r.forEach((function(e){if(!i.has(e)){var r=t.concat([s]);o.push({op:"remove",path:r,value:e}),a.unshift({op:n,path:r,value:e})}s++})),s=0,i.forEach((function(e){if(!r.has(e)){var i=t.concat([s]);o.push({op:n,path:i,value:e}),a.unshift({op:"remove",path:i,value:e})}s++}))}(e,o,a,r)}},M:function(e,t,n,o){n.push({op:"replace",path:[],value:t}),o.push({op:"replace",path:[],value:e.t})}})}var z,q,H="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),W="undefined"!=typeof Map,G="undefined"!=typeof Set,K="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,Z=H?Symbol.for("immer-nothing"):((z={})["immer-nothing"]=!0,z),V=H?Symbol.for("immer-draftable"):"__$immer_draftable",Q=H?Symbol.for("immer-state"):"__$immer_state",X=("undefined"!=typeof Symbol&&Symbol.iterator,"undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames),Y=Object.getOwnPropertyDescriptors||function(e){var t={};return X(e).forEach((function(n){t[n]=Object.getOwnPropertyDescriptor(e,n)})),t},J={},ee={get:function(e,t){if(t===Q)return e;var n=b(e);if(!p(n,t))return function(e,t,n){var o,a=I(t,n);return a?"value"in a?a.value:null===(o=a.get)||void 0===o?void 0:o.call(e.k):void 0}(e,n,t);var o=n[t];return e.I||!c(o)?o:o===L(e.t,t)?(j(e),e.o[t]=B(e.A.h,o,e)):o},has:function(e,t){return t in b(e)},ownKeys:function(e){return Reflect.ownKeys(b(e))},set:function(e,t,n){var o=I(b(e),t);if(null==o?void 0:o.set)return o.set.call(e.k,n),!0;if(!e.P){var a=L(b(e),t),r=null==a?void 0:a[Q];if(r&&r.t===n)return e.o[t]=n,e.D[t]=!1,!0;if(h(n,a)&&(void 0!==n||p(e.t,t)))return!0;j(e),P(e)}return e.o[t]=n,e.D[t]=!0,!0},deleteProperty:function(e,t){return void 0!==L(e.t,t)||t in e.t?(e.D[t]=!1,j(e),P(e)):delete e.D[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var n=b(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o?{writable:!0,configurable:1!==e.i||"length"!==t,enumerable:o.enumerable,value:n[t]}:o},defineProperty:function(){s(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){s(12)}},te={};d(ee,(function(e,t){te[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),te.deleteProperty=function(e,t){return ee.deleteProperty.call(this,e[0],t)},te.set=function(e,t,n){return ee.set.call(this,e[0],t,n,e[0])};var ne=function(){function e(e){this.O=K,this.N=!0,"boolean"==typeof(null==e?void 0:e.useProxies)&&this.setUseProxies(e.useProxies),"boolean"==typeof(null==e?void 0:e.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),this.produce=this.produce.bind(this),this.produceWithPatches=this.produceWithPatches.bind(this)}var t=e.prototype;return t.produce=function(e,t,n){if("function"==typeof e&&"function"!=typeof t){var o=t;t=e;var a=this;return function(e){var n=this;void 0===e&&(e=o);for(var r=arguments.length,i=Array(r>1?r-1:0),s=1;s<r;s++)i[s-1]=arguments[s];return a.produce(e,(function(e){var o;return(o=t).call.apply(o,[n,e].concat(i))}))}}var r;if("function"!=typeof t&&s(6),void 0!==n&&"function"!=typeof n&&s(7),c(e)){var i=A(this),l=B(this,e,void 0),d=!0;try{r=t(l),d=!1}finally{d?N(i):C(i)}return"undefined"!=typeof Promise&&r instanceof Promise?r.then((function(e){return S(i,n),O(e,i)}),(function(e){throw N(i),e})):(S(i,n),O(r,i))}if(!e||"object"!=typeof e){if((r=t(e))===Z)return;return void 0===r&&(r=e),this.N&&y(r,!0),r}s(21,e)},t.produceWithPatches=function(e,t){var n,o,a=this;return"function"==typeof e?function(t){for(var n=arguments.length,o=Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return a.produceWithPatches(t,(function(t){return e.apply(void 0,[t].concat(o))}))}:[this.produce(e,t,(function(e,t){n=e,o=t})),n,o]},t.createDraft=function(e){c(e)||s(8),l(e)&&(e=function(e){return l(e)||s(22,e),function e(t){if(!c(t))return t;var n,o=t[Q],a=u(t);if(o){if(!o.P&&(o.i<4||!E("ES5").K(o)))return o.t;o.I=!0,n=U(t,a),o.I=!1}else n=U(t,a);return d(n,(function(t,a){o&&m(o.t,t)===a||g(n,t,e(a))})),3===a?new Set(n):n}(e)}(e));var t=A(this),n=B(this,e,void 0);return n[Q].C=!0,C(t),n},t.finishDraft=function(e,t){var n=(e&&e[Q]).A;return S(n,t),O(void 0,n)},t.setAutoFreeze=function(e){this.N=e},t.setUseProxies=function(e){e&&!K&&s(20),this.O=e},t.applyPatches=function(e,t){var n;for(n=t.length-1;n>=0;n--){var o=t[n];if(0===o.path.length&&"replace"===o.op){e=o.value;break}}var a=E("Patches").$;return l(e)?a(e,t):this.produce(e,(function(e){return a(e,t.slice(n+1))}))},e}(),oe=new ne,ae=oe.produce,re=oe.produceWithPatches.bind(oe),ie=oe.setAutoFreeze.bind(oe),se=(oe.setUseProxies.bind(oe),oe.applyPatches.bind(oe)),le=(oe.createDraft.bind(oe),oe.finishDraft.bind(oe),ae);F(),ie(!1);var ce=r("9Ta4i"),de=r("4zMEb");de=r("4zMEb");let ue=async e=>e(),pe=null;r.register("ejMaj",(function(e,t){e.exports=import("./"+r("ko7kR").resolve("1hW9p")).then((()=>r("aFiVA")))})),r.register("eUkck",(function(e,t){e.exports=Promise.all([import("./"+r("ko7kR").resolve("1hW9p")),import("./"+r("ko7kR").resolve("idnIw"))]).then((()=>r("2rOxx")))}));const me=async()=>(null==pe&&(pe=ue((async()=>{let[{initializeApp:e},t]=await Promise.all([r("ejMaj"),r("eUkck")]),{getFirestore:n,addDoc:o,doc:a,collection:i}=t,s=i(n(e({apiKey:"AIzaSyC0DqEcaM8AZ6cvApXuNcNU2RgZZOj7F68",authDomain:"localhost",projectId:"pluto-feedback"})),"feedback");return console.log("๐ฅbase loaded"),async e=>{await o(s,e)}}))),await pe),ge=async()=>{try{const e=document.querySelector("form#feedback");e.addEventListener("submit",(t=>{const n=prompt("Would you like us to contact you?\n\nEmail: (leave blank to stay anonymous ๐)");t.preventDefault(),ue((async()=>{try{let o=await me();await de.timeout_promise(o({feedback:new FormData(t.target).get("opinion"),timestamp:Date.now(),email:n||""}),5e3);let a="Submitted. Thank you for your feedback! ๐";console.log(a),alert(a),e.querySelector("#opinion").value=""}catch(e){let t="Whoops, failed to send feedback ๐ข\nWe would really like to hear from you! Please got to https://github.com/fonsp/Pluto.jl/issues to report this failure:\n\n";console.error(t),console.error(e),alert(t+e)}}))})),e.addEventListener("focusin",(()=>{me()}))}catch(e){console.error("Something went wrong loading the feedback form:",e),document.querySelector("form#feedback").style.opacity=0;for(let e of"Oh noooooooooooooooooo...")document.querySelector("form#feedback input").value+=e,await new Promise((e=>setTimeout(e,200)))}};function he(e){return e.replace(/\r\n/g,"\n").split(/# โโโก \S+\n/).map((e=>e.trim())).filter((e=>""!==e))}function fe(e){const t=e.replace(/\r\n/g,"\n").split("julia> "),n=" ".repeat(prompt.length);return t.map((function(e){return(n+e).split("\n").filter((e=>e.startsWith(n))).map((e=>e.replace(n,""))).join("\n")})).map((e=>e.trim())).filter((e=>""!==e))}const _e=e=>{var t;return e.trim().startsWith("julia> ")?fe:(null===(t=e.match(/# โโโก ........-....-....-....-............/g))||void 0===t?void 0:t.length)?he:null};var be=r("2ZZ1r"),ve=(i=r("cNaMA"),r("aN0pg"));let ye=(i=r("cNaMA")).createContext(),we=i.createContext(null),ke=i.createContext(null);class Ee extends Set{constructor(e){super(),this.callback=e}delete(e){let t=super.delete(e);return t&&0===this.size&&this.callback(),t}}var $e=r("kjWx8");const xe=()=>"visible"===document.visibilityState?Promise.resolve():new Promise((e=>{const t=()=>{xe().then(e),document.removeEventListener("visibilitychange",t)};document.addEventListener("visibilitychange",t)})),Se=({any_code_differs:e,last_update_time:t,last_hot_reload_time:n,connected:o})=>{let a=i.useContext(ye);const[r,s]=i.useState(""),[l,c]=i.useState(""),d=i.useRef(null),u=i.useRef(null);i.useEffect((()=>(clearTimeout(null==d?void 0:d.current),e?s("ask_to_save"):Date.now()-t<1e3?(s("saved"),d.current=setTimeout((()=>{s("")}),1e3)):s(""),()=>clearTimeout(null==d?void 0:d.current))),[e]);const[p,m]=i.useState(!1);return i.useEffect((()=>{o&&setTimeout((()=>m(!0)),1e3)}),[o]),i.useEffect((()=>{if(console.log("Hottt",n,p),p)return c("reloaded_from_file"),console.log("set state"),xe().then((()=>{u.current=setTimeout((()=>{c(""),console.log("reset state")}),8e3)})),()=>clearTimeout(null==u?void 0:u.current)}),[n]),i.html`<preamble>
${"ask_to_save"===r?i.html`
<div id="saveall-container" class="overlay-button ${r}">
<button
onClick=${()=>{s("saving"),a.set_and_run_all_changed_remote_cells()}}
class=${ve.cl({runallchanged:!0})}
title="Save and run all changed cells"
>
<span class="only-on-hover"><b>Save all changes</b> </span>${$e.is_mac_keyboard?i.html`<kbd>โ S</kbd>`:i.html`<kbd>Ctrl</kbd>+<kbd>S</kbd>`}
</button>
</div>
`:"saved"===r||"saving"===r?i.html`
<div id="saveall-container" class="overlay-button ${r}">
<span><span class="only-on-hover">Saved </span><span class="saved-icon pluto-icon"></span></span>
</div>
`:"reloaded_from_file"===l?i.html`
<div id="saveall-container" class="overlay-button ${r}">
<span>File change detected, <b>notebook updated </b><span class="saved-icon pluto-icon"></span></span>
</div>
`:null}
</preamble>`};i=r("cNaMA"),ce=r("9Ta4i"),i=r("cNaMA"),i=r("cNaMA");var Ne={};t(Ne),e(Ne,"default",(()=>Et));var{entries:Ce,setPrototypeOf:Ae,isFrozen:Me,getPrototypeOf:Oe,getOwnPropertyDescriptor:Te}=Object,{freeze:Re,seal:De,create:Le}=Object,{apply:Ie,construct:Pe}=typeof Reflect<"u"&&Reflect;Ie||(Ie=function(e,t,n){return e.apply(t,n)}),Re||(Re=function(e){return e}),De||(De=function(e){return e}),Pe||(Pe=function(e,t){return new e(...t)});var je,Be=Qe(Array.prototype.forEach),Ue=Qe(Array.prototype.pop),Fe=Qe(Array.prototype.push),ze=Qe(String.prototype.toLowerCase),qe=Qe(String.prototype.toString),He=Qe(String.prototype.match),We=Qe(String.prototype.replace),Ge=Qe(String.prototype.indexOf),Ke=Qe(String.prototype.trim),Ze=Qe(RegExp.prototype.test),Ve=(je=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Pe(je,t)});function Qe(e){return function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),a=1;a<n;a++)o[a-1]=arguments[a];return Ie(e,t,o)}}function Xe(e,t,n){var o;n=null!==(o=n)&&void 0!==o?o:ze,Ae&&Ae(e,null);let a=t.length;for(;a--;){let o=t[a];if("string"==typeof o){let e=n(o);e!==o&&(Me(t)||(t[a]=e),o=e)}e[o]=!0}return e}function Ye(e){let t=Le(null);for(let[n,o]of Ce(e))t[n]=o;return t}function Je(e,t){for(;null!==e;){let n=Te(e,t);if(n){if(n.get)return Qe(n.get);if("function"==typeof n.value)return Qe(n.value)}e=Oe(e)}return function(e){return console.warn("fallback value for",e),null}}var et=Re(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),tt=Re(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),nt=Re(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),ot=Re(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),at=Re(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),rt=Re(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),it=Re(["#text"]),st=Re(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns","slot"]),lt=Re(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),ct=Re(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),dt=Re(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),ut=De(/\{\{[\w\W]*|[\w\W]*\}\}/gm),pt=De(/<%[\w\W]*|[\w\W]*%>/gm),mt=De(/\${[\w\W]*}/gm),gt=De(/^data-[\-\w.\u00B7-\uFFFF]/),ht=De(/^aria-[\-\w]+$/),ft=De(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),_t=De(/^(?:\w+script|data):/i),bt=De(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),vt=De(/^html$/i),yt=Object.freeze({__proto__:null,MUSTACHE_EXPR:ut,ERB_EXPR:pt,TMPLIT_EXPR:mt,DATA_ATTR:gt,ARIA_ATTR:ht,IS_ALLOWED_URI:ft,IS_SCRIPT_OR_DATA:_t,ATTR_WHITESPACE:bt,DOCTYPE_NAME:vt}),wt=()=>typeof window>"u"?null:window,kt=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null,o="data-tt-policy-suffix";t&&t.hasAttribute(o)&&(n=t.getAttribute(o));let a="dompurify"+(n?"#"+n:"");try{return e.createPolicy(a,{createHTML:e=>e,createScriptURL:e=>e})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}};var Et=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:wt(),n=t=>e(t);if(n.version="3.0.3",n.removed=[],!t||!t.document||9!==t.document.nodeType)return n.isSupported=!1,n;let o=t.document,a=o.currentScript,{document:r}=t,{DocumentFragment:i,HTMLTemplateElement:s,Node:l,Element:c,NodeFilter:d,NamedNodeMap:u=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:p,DOMParser:m,trustedTypes:g}=t,h=c.prototype,f=Je(h,"cloneNode"),_=Je(h,"nextSibling"),b=Je(h,"childNodes"),v=Je(h,"parentNode");if("function"==typeof s){let e=r.createElement("template");e.content&&e.content.ownerDocument&&(r=e.content.ownerDocument)}let y,w="",{implementation:k,createNodeIterator:E,createDocumentFragment:$,getElementsByTagName:x}=r,{importNode:S}=o,N={};n.isSupported="function"==typeof Ce&&"function"==typeof v&&k&&void 0!==k.createHTMLDocument;let C,A,{MUSTACHE_EXPR:M,ERB_EXPR:O,TMPLIT_EXPR:T,DATA_ATTR:R,ARIA_ATTR:D,IS_SCRIPT_OR_DATA:L,ATTR_WHITESPACE:I}=yt,{IS_ALLOWED_URI:P}=yt,j=null,B=Xe({},[...et,...tt,...nt,...at,...it]),U=null,F=Xe({},[...st,...lt,...ct,...dt]),z=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),q=null,H=null,W=!0,G=!0,K=!1,Z=!0,V=!1,Q=!1,X=!1,Y=!1,J=!1,ee=!1,te=!1,ne=!0,oe=!1,ae="user-content-",re=!0,ie=!1,se={},le=null,ce=Xe({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),de=null,ue=Xe({},["audio","video","img","source","image","track"]),pe=null,me=Xe({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ge="http://www.w3.org/1998/Math/MathML",he="http://www.w3.org/2000/svg",fe="http://www.w3.org/1999/xhtml",_e=fe,be=!1,ve=null,ye=Xe({},[ge,he,fe],qe),we=["application/xhtml+xml","text/html"],ke="text/html",Ee=null,$e=r.createElement("form"),xe=function(e){return e instanceof RegExp||e instanceof Function},Se=function(e){if(!Ee||Ee!==e){if((!e||"object"!=typeof e)&&(e={}),e=Ye(e),C=C=-1===we.indexOf(e.PARSER_MEDIA_TYPE)?ke:e.PARSER_MEDIA_TYPE,A="application/xhtml+xml"===C?qe:ze,j="ALLOWED_TAGS"in e?Xe({},e.ALLOWED_TAGS,A):B,U="ALLOWED_ATTR"in e?Xe({},e.ALLOWED_ATTR,A):F,ve="ALLOWED_NAMESPACES"in e?Xe({},e.ALLOWED_NAMESPACES,qe):ye,pe="ADD_URI_SAFE_ATTR"in e?Xe(Ye(me),e.ADD_URI_SAFE_ATTR,A):me,de="ADD_DATA_URI_TAGS"in e?Xe(Ye(ue),e.ADD_DATA_URI_TAGS,A):ue,le="FORBID_CONTENTS"in e?Xe({},e.FORBID_CONTENTS,A):ce,q="FORBID_TAGS"in e?Xe({},e.FORBID_TAGS,A):{},H="FORBID_ATTR"in e?Xe({},e.FORBID_ATTR,A):{},se="USE_PROFILES"in e&&e.USE_PROFILES,W=!1!==e.ALLOW_ARIA_ATTR,G=!1!==e.ALLOW_DATA_ATTR,K=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Z=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,V=e.SAFE_FOR_TEMPLATES||!1,Q=e.WHOLE_DOCUMENT||!1,J=e.RETURN_DOM||!1,ee=e.RETURN_DOM_FRAGMENT||!1,te=e.RETURN_TRUSTED_TYPE||!1,Y=e.FORCE_BODY||!1,ne=!1!==e.SANITIZE_DOM,oe=e.SANITIZE_NAMED_PROPS||!1,re=!1!==e.KEEP_CONTENT,ie=e.IN_PLACE||!1,P=e.ALLOWED_URI_REGEXP||ft,_e=e.NAMESPACE||fe,z=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&xe(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(z.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&xe(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(z.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(z.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),V&&(G=!1),ee&&(J=!0),se&&(j=Xe({},[...it]),U=[],!0===se.html&&(Xe(j,et),Xe(U,st)),!0===se.svg&&(Xe(j,tt),Xe(U,lt),Xe(U,dt)),!0===se.svgFilters&&(Xe(j,nt),Xe(U,lt),Xe(U,dt)),!0===se.mathMl&&(Xe(j,at),Xe(U,ct),Xe(U,dt))),e.ADD_TAGS&&(j===B&&(j=Ye(j)),Xe(j,e.ADD_TAGS,A)),e.ADD_ATTR&&(U===F&&(U=Ye(U)),Xe(U,e.ADD_ATTR,A)),e.ADD_URI_SAFE_ATTR&&Xe(pe,e.ADD_URI_SAFE_ATTR,A),e.FORBID_CONTENTS&&(le===ce&&(le=Ye(le)),Xe(le,e.FORBID_CONTENTS,A)),re&&(j["#text"]=!0),Q&&Xe(j,["html","head","body"]),j.table&&(Xe(j,["tbody"]),delete q.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw Ve('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw Ve('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');y=e.TRUSTED_TYPES_POLICY,w=y.createHTML("")}else void 0===y&&(y=kt(g,a)),null!==y&&"string"==typeof w&&(w=y.createHTML(""));Re&&Re(e),Ee=e}},Ne=Xe({},["mi","mo","mn","ms","mtext"]),Ae=Xe({},["foreignobject","desc","title","annotation-xml"]),Me=Xe({},["title","style","font","a","script"]),Oe=Xe({},tt);Xe(Oe,nt),Xe(Oe,ot);let Te=Xe({},at);Xe(Te,rt);let De=function(e){let t=v(e);(!t||!t.tagName)&&(t={namespaceURI:_e,tagName:"template"});let n=ze(e.tagName),o=ze(t.tagName);return!!ve[e.namespaceURI]&&(e.namespaceURI===he?t.namespaceURI===fe?"svg"===n:t.namespaceURI===ge?"svg"===n&&("annotation-xml"===o||Ne[o]):!!Oe[n]:e.namespaceURI===ge?t.namespaceURI===fe?"math"===n:t.namespaceURI===he?"math"===n&&Ae[o]:!!Te[n]:e.namespaceURI===fe?!(t.namespaceURI===he&&!Ae[o]||t.namespaceURI===ge&&!Ne[o])&&(!Te[n]&&(Me[n]||!Oe[n])):!("application/xhtml+xml"!==C||!ve[e.namespaceURI]))},Le=function(e){Fe(n.removed,{element:e});try{e.parentNode.removeChild(e)}catch{e.remove()}},Ie=function(e,t){try{Fe(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch{Fe(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!U[e])if(J||ee)try{Le(t)}catch{}else try{t.setAttribute(e,"")}catch{}},Pe=function(e){let t,n;if(Y)e="<remove></remove>"+e;else{let t=He(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===C&&_e===fe&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");let o=y?y.createHTML(e):e;if(_e===fe)try{t=(new m).parseFromString(o,C)}catch{}if(!t||!t.documentElement){t=k.createDocument(_e,"template",null);try{t.documentElement.innerHTML=be?w:o}catch{}}let a=t.body||t.documentElement;return e&&n&&a.insertBefore(r.createTextNode(n),a.childNodes[0]||null),_e===fe?x.call(t,Q?"html":"body")[0]:Q?t.documentElement:a},je=function(e){return E.call(e.ownerDocument||e,e,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT,null,!1)},Qe=function(e){return e instanceof p&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof u)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},ut=function(e){return"object"==typeof l?e instanceof l:e&&"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},pt=function(e,t,o){N[e]&&Be(N[e],(e=>{e.call(n,t,o,Ee)}))},mt=function(e){let t;if(pt("beforeSanitizeElements",e,null),Qe(e))return Le(e),!0;let o=A(e.nodeName);if(pt("uponSanitizeElement",e,{tagName:o,allowedTags:j}),e.hasChildNodes()&&!ut(e.firstElementChild)&&(!ut(e.content)||!ut(e.content.firstElementChild))&&Ze(/<[/\w]/g,e.innerHTML)&&Ze(/<[/\w]/g,e.textContent))return Le(e),!0;if(!j[o]||q[o]){if(!q[o]&&ht(o)&&(z.tagNameCheck instanceof RegExp&&Ze(z.tagNameCheck,o)||z.tagNameCheck instanceof Function&&z.tagNameCheck(o)))return!1;if(re&&!le[o]){let t=v(e)||e.parentNode,n=b(e)||e.childNodes;if(n&&t){for(let o=n.length-1;o>=0;--o)t.insertBefore(f(n[o],!0),_(e))}}return Le(e),!0}return e instanceof c&&!De(e)||("noscript"===o||"noembed"===o)&&Ze(/<\/no(script|embed)/i,e.innerHTML)?(Le(e),!0):(V&&3===e.nodeType&&(t=e.textContent,t=We(t,M," "),t=We(t,O," "),t=We(t,T," "),e.textContent!==t&&(Fe(n.removed,{element:e.cloneNode()}),e.textContent=t)),pt("afterSanitizeElements",e,null),!1)},gt=function(e,t,n){if(ne&&("id"===t||"name"===t)&&(n in r||n in $e))return!1;if((!G||H[t]||!Ze(R,t))&&(!W||!Ze(D,t)))if(!U[t]||H[t]){if(!(ht(e)&&(z.tagNameCheck instanceof RegExp&&Ze(z.tagNameCheck,e)||z.tagNameCheck instanceof Function&&z.tagNameCheck(e))&&(z.attributeNameCheck instanceof RegExp&&Ze(z.attributeNameCheck,t)||z.attributeNameCheck instanceof Function&&z.attributeNameCheck(t))||"is"===t&&z.allowCustomizedBuiltInElements&&(z.tagNameCheck instanceof RegExp&&Ze(z.tagNameCheck,n)||z.tagNameCheck instanceof Function&&z.tagNameCheck(n))))return!1}else if(!pe[t]&&!Ze(P,We(n,I,""))&&("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==Ge(n,"data:")||!de[e])&&(!K||Ze(L,We(n,I,"")))&&n)return!1;return!0},ht=function(e){return e.indexOf("-")>0},_t=function(e){let t,o,a,r;pt("beforeSanitizeAttributes",e,null);let{attributes:i}=e;if(!i)return;let s={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:U};for(r=i.length;r--;){t=i[r];let{name:l,namespaceURI:c}=t;if(o="value"===l?t.value:Ke(t.value),a=A(l),s.attrName=a,s.attrValue=o,s.keepAttr=!0,s.forceKeepAttr=void 0,pt("uponSanitizeAttribute",e,s),o=s.attrValue,s.forceKeepAttr||(Ie(l,e),!s.keepAttr))continue;if(!Z&&Ze(/\/>/i,o)){Ie(l,e);continue}V&&(o=We(o,M," "),o=We(o,O," "),o=We(o,T," "));let d=A(e.nodeName);if(gt(d,a,o)){if(oe&&("id"===a||"name"===a)&&(Ie(l,e),o=ae+o),y&&"object"==typeof g&&"function"==typeof g.getAttributeType&&!c)switch(g.getAttributeType(d,a)){case"TrustedHTML":o=y.createHTML(o);break;case"TrustedScriptURL":o=y.createScriptURL(o)}try{c?e.setAttributeNS(c,l,o):e.setAttribute(l,o),Ue(n.removed)}catch{}}}pt("afterSanitizeAttributes",e,null)},bt=function e(t){let n,o=je(t);for(pt("beforeSanitizeShadowDOM",t,null);n=o.nextNode();)pt("uponSanitizeShadowNode",n,null),!mt(n)&&(n.content instanceof i&&e(n.content),_t(n));pt("afterSanitizeShadowDOM",t,null)};return n.sanitize=function(e){let t,a,r,s,c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(be=!e,be&&(e="\x3c!--\x3e"),"string"!=typeof e&&!ut(e)){if("function"!=typeof e.toString)throw Ve("toString is not a function");if("string"!=typeof(e=e.toString()))throw Ve("dirty is not a string, aborting")}if(!n.isSupported)return e;if(X||Se(c),n.removed=[],"string"==typeof e&&(ie=!1),ie){if(e.nodeName){let t=A(e.nodeName);if(!j[t]||q[t])throw Ve("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof l)t=Pe("\x3c!----\x3e"),a=t.ownerDocument.importNode(e,!0),1===a.nodeType&&"BODY"===a.nodeName||"HTML"===a.nodeName?t=a:t.appendChild(a);else{if(!J&&!V&&!Q&&-1===e.indexOf("<"))return y&&te?y.createHTML(e):e;if(t=Pe(e),!t)return J?null:te?w:""}t&&Y&&Le(t.firstChild);let d=je(ie?e:t);for(;r=d.nextNode();)mt(r)||(r.content instanceof i&&bt(r.content),_t(r));if(ie)return e;if(J){if(ee)for(s=$.call(t.ownerDocument);t.firstChild;)s.appendChild(t.firstChild);else s=t;return(U.shadowroot||U.shadowrootmod)&&(s=S.call(o,s,!0)),s}let u=Q?t.outerHTML:t.innerHTML;return Q&&j["!doctype"]&&t.ownerDocument&&t.ownerDocument.doctype&&t.ownerDocument.doctype.name&&Ze(vt,t.ownerDocument.doctype.name)&&(u="<!DOCTYPE "+t.ownerDocument.doctype.name+">\n"+u),V&&(u=We(u,M," "),u=We(u,O," "),u=We(u,T," ")),y&&te?y.createHTML(u):u},n.setConfig=function(e){Se(e),X=!0},n.clearConfig=function(){Ee=null,X=!1},n.isValidAttribute=function(e,t,n){Ee||Se({});let o=A(e),a=A(t);return gt(o,a,n)},n.addHook=function(e,t){"function"==typeof t&&(N[e]=N[e]||[],Fe(N[e],t))},n.removeHook=function(e){if(N[e])return Ue(N[e])},n.removeHooks=function(e){N[e]&&(N[e]=[])},n.removeAllHooks=function(){N={}},n}(),$t=Et;r("hiQgq");i=r("cNaMA"),i=r("cNaMA"),ce=r("9Ta4i");var xt=r("2P6PH"),St=r("hiQgq");St=r("hiQgq");r("9Ta4i");St=r("hiQgq"),ce=r("9Ta4i");var Nt={};t(Nt),e(Nt,"default",(()=>Ct.default));var Ct={};e(Ct,"default",(()=>Gt),(e=>Gt=e));var At,Mt,Ot=Object.create,Tt=Object.defineProperty,Rt=Object.getOwnPropertyDescriptor,Dt=Object.getOwnPropertyNames,Lt=Object.getPrototypeOf,It=Object.prototype.hasOwnProperty,Pt=(e,t,n,o)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let a of Dt(t))!It.call(e,a)&&a!==n&&Tt(e,a,{get:()=>t[a],enumerable:!(o=Rt(t,a))||o.enumerable});return e},jt=(e,t,n)=>(n=null!=e?Ot(Lt(e)):{},Pt(!t&&e&&e.__esModule?n:Tt(n,"default",{value:e,enumerable:!0}),e)),Bt=(At=(e,t)=>{var n=Symbol("baseMap"),o=class{constructor(e){this.value=e}};function a(e){if(!Array.isArray(e))throw new TypeError("The keys parameter must be an array")}function r({[n]:e},t,o){for(let n of t){if(!e.has(n)){if(!o)return;e.set(n,new WeakMap)}e=e.get(n)}return e}t.exports=class extends WeakMap{constructor(){super(),this[n]=new WeakMap;let[e]=arguments;if(null!=e){if("function"!=typeof e[Symbol.iterator])throw new TypeError(typeof e+" is not iterable (cannot read property Symbol(Symbol.iterator))");for(let[t,n]of e)this.set(t,n)}}set(e,t){return a(e),r(this,e,!0).set(o,t),this}get(e){a(e);let t=r(this,e);return t?t.get(o):void 0}has(e){a(e);let t=r(this,e);return!!t&&t.has(o)}delete(e){a(e);let t=r(this,e);return!!t&&t.delete(o)}get[Symbol.toStringTag](){return"ManyKeysWeakMap"}}},()=>(Mt||At((Mt={exports:{}}).exports,Mt),Mt.exports)),Ut={};((e,t)=>{for(var n in t)Tt(e,n,{get:t[n],enumerable:!0})})(Ut,{default:()=>Gt});var Ft=jt(Bt());((e,t,n)=>{Pt(e,t,"default"),n&&Pt(n,t,"default")})(Ut,jt(Bt()));var zt,qt,{default:Ht,...Wt}=Ft,Gt=void 0!==Ht?Ht:Wt;zt=Nt,qt=Ct,Object.keys(qt).forEach((function(e){"default"===e||"__esModule"===e||zt.hasOwnProperty(e)||Object.defineProperty(zt,e,{enumerable:!0,get:function(){return qt[e]}})}));let Kt=e=>St.julia_andrey().language.parser.parse(e).topNode.firstChild;let Zt=(e,t=(e=>e),n=new Map)=>(...o)=>{let a=t(...o),r=n.get(a);if(null!=r)return r;{let t=e(...o);if(null==t)throw new Error("Memoized function returned undefined");return n.set(a,t),t}},Vt=(e,t=((...e)=>e))=>Zt(e,t,new Ct.default),Qt=e=>Zt(e,(e=>e),new WeakMap),Xt=function*(e){if(e.firstChild())try{do{yield e}while(e.nextSibling())}finally{e.parent()}},Yt=function*(e){if(e.firstChild){let t=e.firstChild;do{yield t}while(t=t.nextSibling)}},Jt=(e,t,n,o=!1)=>{if(o){console.group("Current haystack:",e?e.node.name:null),console.groupCollapsed("Details");try{console.log("template:",t),console.log("haystack_cursor:",e?e.node.toString():null),"node"in t?(console.log("template.node:",t.node),console.log("template.node.toString():",t.node.toString())):"pattern"in t&&console.log("template.pattern:",t.pattern)}finally{console.groupEnd()}}try{if("pattern"in t){let a=t.pattern;if("function"!=typeof a)throw new Error(`Unknown pattern "${a}"`);let r={};o&&(r={...n},console.groupCollapsed(`Matching against pattern: ${t.pattern.name}()`));let i=null;try{i=a(e,n,o)}finally{o&&console.groupEnd()}if(o)if(i){if(console.log("โ
because the pattern was happy! All hail the pattern!"),!ce.default.isEqual(n,r)){let e=ce.default.omit(n,Object.keys(r));console.log(" WE EVEN GOT NEW MATCHES SAY WHAAAAAAT:",e)}}else console.log("โ because... well, you should ask the pattern that!");return i}if(!("node"in t))throw console.log("template:",t),new Error("waaaah");{let{node:a,children:r}=t;if(o&&console.log(`Matching against node: ${t.node.name}`),!e)return"end"===a.name?(o&&console.log("โ
No node left to match, but it was the end anyway"),!0):(o&&console.log("โ because no cursor left to match against"),!1);if(e.type.isError)return o&&console.log("โ
because โ "),!0;if(e.name!==a.name)return o&&console.log(`โ because name mismatch "${e.name}" !== "${a.name}"`),!1;if(!e.firstChild()){if(0!==t.children.length){o&&console.log("Haystack node is empty, but template has children... lets see");for(let e of t.children)if(!Jt(null,e,n,o))return o&&console.log("โ because child template wasn't okay with having no children",e),!1;return o&&console.log("โ
All template children we're fine with having no children to check on"),!0}return o&&console.log("โ
Template also has no children, yayyy"),!0}try{let a=!1;for(let t of r){if(a){if(o&&console.log("Haystack is empty, but there are more children in template... lets see"),!Jt(null,t,n,o))return o&&console.log("โ template child did not accept null for an answer",t,e.toString()),!1;o&&console.log("๐๐ฝ This template child was fine with null");continue}for(;("Comment"===e.name||"BlockComment"===e.name)&&e.nextSibling(););if(!Jt(e,t,n,o))return o&&console.log("โ because a child mismatch",t,e.toString()),!1;a=!e.nextSibling()}if(o&&!a){let n=[];do{n.push(e.node)}while(e.nextSibling());for(let t of n)e.prevSibling();console.warn("We did match all the children of the template, but there are more in the haystack... Might want to actually not match this?",n,t)}return o&&console.log("โ
because all children match"),!0}finally{e.parent()}}}finally{o&&console.groupEnd()}};class en{constructor(e,t){let n=[],o=[];n.push(e[0]);for(let[a,r]of ce.default.zip(e.slice(1),t))if(r instanceof en){n[n.length-1]+=r.template[0];for(let[e,t]of ce.default.zip(r.template.slice(1),r.substitutions))o.push(t),n.push(e);n[n.length-1]+=a}else o.push(r),n.push(a);this.template=n,this.substitutions=o}}let tn=(e,t)=>{for(let n of t)if(e.from===n.from&&e.to===n.to){n.used=!0;let t=n.generator.next({name:e.name,from:e.from,to:e.to,node:e});if(t.done)return t.value;throw new Error("Template generator not done providing ast node")}return{name:e.name,from:e.from,to:e.to,children:Array.from(Yt(e)).map((e=>tn(e,t))),node:e}},nn=function*(e){try{if(e instanceof en){let t="",n=[];for(let[o,a]of ce.default.zip(e.template,e.substitutions))if(t+=o,a){let e=nn(a),o=fn(e.next());n.push({from:t.length,to:t.length+o.length,generator:e}),t+=o}let o=yield t,a=n.map((e=>({from:e.from+o.from,to:e.to+o.from,generator:e.generator,used:!1})));false;let r=tn(o.node,a),i=a.filter((e=>!e.used)).map((e=>({text:t.slice(e.from,e.to),from:e.from,to:e.to})));if(i.length>0)throw new Error(`Some substitutions not applied, this means it couldn't be matched to a AST position: ${JSON.stringify(i)}`);return r}if("function"==typeof e)return yield*e();throw console.log("julia_code_object:",e),new Error("Unknown substition type")}finally{}},on=Vt(((e,...t)=>new en(e,t))),an=new WeakMap,rn=(e,...t)=>{let n=an.get(e);if(null!=n){let{input:e,result:t}=n;return t}{let n=new en(e,t);return an.set(e,{input:t,result:n}),n}},sn=Qt((e=>{let t=nn(e),n=fn(t.next()),o=Kt(n),a=_n(t.next({from:0,to:n.length,name:o.name,node:o}));return{template_description:a,match(e,t=!1){if("node"in a&&a.node.name!==e.name)return;if(e.type.isError)return null;"cursor"in e&&(e=e.cursor());let n={};t&&console.groupCollapsed(`Starting a match at ${e.name}`);try{return Jt(e,a,n,t)?n:null}finally{t&&console.groupEnd()}}}})),ln=Qt((e=>{let t=nn(e),n=fn(t.next());return t.return(),n})),cn=(Qt((e=>Kt(ln(e)))),Qt((e=>St.Text.of([ln(e)]))),e=>{let t={},n=Zt((n=>Qt((o=>e(n,o===t?void 0:o)))));return(e,o=t)=>n(e)(o)});function*dn(){return yield"expression",{pattern:function(e,t,n=!1){return e?!e.type.is("keyword")||(n&&console.log("โ Keywords are not allowed!"),!1):(n&&console.log("โ I want anything!! YOU GIVE ME NULL???"),!1)}}}const un={any:dn,many:cn(((e,t=dn)=>function*(){let n=nn(t),o=yield fn(n.next()),a=null,r=null;return o.node.firstChild&&o.node.from===o.node.firstChild.from&&o.node.to===o.node.firstChild.to?(a=o.node,r=_n(n.next({...o,node:o.node.firstChild}))):r=_n(n.next(o)),{narrowed_node:a,sub_template:r,pattern:function(t,n,o=!1){if(!t)return o&&console.log("โ
Nothing to see here... I'm fine with that - many"),!0;if(a){if(t.name!==a.name)return o&&console.log("โ Tried to go in, but she wasn't my type - many"),t.prevSibling(),!0;t.firstChild()}try{let i=[];for(;;){if(t.type.isError)return t.prevSibling(),o&&console.log("โ I don't do errors - many"),!0;let e={};if(!Jt(t,r,e,o)){t.prevSibling();break}if(i.push({node:t.node,match:e}),!t.nextSibling())break}return null!=e&&(n[e]=i),!0}finally{a&&t.parent()}}}})),maybe:Qt((e=>function*(){let t=yield*nn(e);return{sub_template:t,pattern:function(e,n,o=!1){if(!e)return!0;if(e.type.isError)return!0;return!1===Jt(e,t,n,o)&&e.prevSibling(),!0}}})),anything_that_fits:Qt((e=>function*(){return yield*nn(e),{pattern:function(e,t,n=!1){return!0}}})),something_with_the_same_type_as:Qt((e=>function*(){let t=nn(e),n=fn(t.next()),o=yield n;return t.return(),{pattern:function(e,t,n=!1){return null!=e&&o.name===e.name}}})),as:cn(((e,t=dn)=>function*(){let n=yield*nn(t);return{sub_template:n,pattern:function(t,o,a=!1){let r=Jt(t,n,o,a);return!0===r&&(o[e]=null==t?void 0:t.node),null!=t&&r}}})),Identifier:function*(){return yield"identifier",{pattern:function(e,t,n=!1){return null!=e&&"Identifier"===gn(e)}}},Number:function*(){return yield"69",{pattern:function(e,t,n=!1){return null!=e&&"Number"===gn(e)}}},String:function*(){return yield'"A113"',{pattern:function(e,t,n=!1){return null!=e&&("StringWithoutInterpolation"===gn(e)||"TripleStringWithoutInterpolation"===gn(e))}}}};let pn=Vt(((e,t)=>{let n=nn(e),o=fn(n.next()),a=Kt(o),r=null;if(r=t.match(a)){let{content:e}=r,t=[];for(;e.firstChild&&e.firstChild.from==e.from&&e.firstChild.to==e.to;)t.push(e.type),e=e.firstChild;if(null==e)throw console.log("match:",r),new Error("No content match?");let o=_n(n.next({name:e.name,node:e,from:a.from,to:a.to}));return{possible_parents:t,template_description:o,match(e,n=!1){if(e.type.isError)return n&&console.log(`โ Short circuiting because haystack(${e.name}) is an error`),!1;"cursor"in e&&(e=e.cursor());let a=0;for(let o of t){if(e.type!==o)break;{let t=e.from,r=e.to;if(e.firstChild()){if(e.from!==t||e.to!==r){e.parent(),n&&console.log(`โ Was matching possible parent (${o}), but it wasn't filling?! That's weird.... ${e.toString()}`);for(let t=0;t<a;t++)e.parent();return!1}n&&console.log(`โ
Matched parent, going one level deeper (${o})`),a++}}}n&&console.groupCollapsed(`Starting a specific at match haystack(${e.name}) vs. template(${"node"in o?o.name:o.pattern.name})`);try{let t={};return Jt(e,o,t,n)?t:null}finally{for(let t=0;t<a;t++)e.parent();n&&console.groupEnd()}}}}throw console.log("meta_template:",t),console.log("template:",e),new Error("Template passed into `take_little_piece_of_template` doesn't match meta_template")})),mn=e=>e.firstChild&&e.firstChild.from===e.from&&e.firstChild.to===e.to?mn(e.firstChild):e,gn=e=>{let t=e.from,n=e.to;if(e.firstChild())try{if(e.from===t&&e.to===n)return gn(e)}finally{e.parent()}return e.name},hn=e=>t=>{let n=sn(e(un.as("content",t)));return pn(e(t),n)};let fn=e=>{if(e.done)throw new Error("Expected `yield`-d value, but got `return`");return e.value},_n=e=>{if(e.done)return e.value;throw new Error("Expected `yield`-d value, but got `return`")},bn=(e,t)=>{if(e===t)return e;let n=[...e.usages,...t.usages],o=new Map(e.definitions);for(let[e,n]of t.definitions)o.set(e,n);return{usages:n,definitions:o,locals:[...e.locals,...t.locals]}},vn=function*(e){for(let t of Xt(e))if("InterpolationExpression"===t.name)yield e;else if("QuoteExpression"===t.name||"QuoteStatement"===t.name)for(let e of vn(t))yield*vn(e);else yield*vn(t)},yn=e=>{let t=hn(e);return function(e,n=!1){return null==e?(e,...n)=>t(rn(e,...n)):function(o,...a){return t(rn(o,...a)).match(e,n)}}},wn=yn((e=>on`[i for i in i ${e}]`)),kn=yn((e=>on`${e} = nothing`)),En=yn((e=>on`function f(${e}) end`)),$n=yn((e=>on`f(${e})`)),xn=yn((e=>on`f(; ${e})`)),Sn=(e,t,n,o=!1)=>{let a=null;if(a=$n(e)`; ${un.many("named_args")}`){let{named_args:e=[]}=a;for(let{node:a}of e)n=Sn(a,t,n,o);return n}if(a=En(e)`${un.Identifier}`)return Ln(n,t,e);if(a=En(e)`${un.as("subject")}...`)return Nn(a.subject,t,n,null,o);if(a=En(e)`${un.as("name")} = ${un.as("value")}`){let{name:e,value:r}=a;return n=Nn(e,t,n,r.to,o),n=In(r.cursor(),t,n,o)}if((a=En(e)`${un.as("name")}::${un.as("type")}`)??(a=En(e)`${un.as("name")}:`)??(a=En(e)`::${un.as("type")}`)){let{name:e,type:r}=a;return e&&(n=Nn(e,t,n,r.to,o)),r&&(n=In(r.cursor(),t,n,o)),n}return n=Nn(e,t,n),o&&console.warn("UNKNOWN FUNCTION DEFINITION ARGUMENT:",e.toString()),n},Nn=(e,t,n,o=null,a=!1)=>{let r=null;a&&console.group("Explorering pattern:",e.toString());try{if(r=kn(e)`${un.Identifier}`)return a&&console.log("It's an identifier, adding it to the scope"),Ln(n,t,e,o);if(r=kn(e)`${un.as("object")}::${un.as("type")}`){let{object:e,type:o}=r;return n=In(o.cursor(),t,n,a),n=Ln(n,t,e)}if(r=kn(e)`${un.as("subject")}...`)return Nn(r.subject,t,n,o,a);if(r=En(e)`${un.as("name")} = ${un.as("value")}`){let{name:e,value:o}=r;return n=Nn(e,t,n,o.from,a),n=In(o.cursor(),t,n,a)}if(r=kn(e)`(; ${un.many("named_tuples")})`){let{named_tuples:e}=r;for(let r of e)n=Nn(r.node.cursor(),t,n,o,a);return n}if((r=kn(e)`${un.as("first")}, ${un.many("rest")}`)??(r=kn(e)`(${un.as("first")}, ${un.many("rest")})`)){for(let{node:e}of[{node:r.first},...r.rest??[]])n=Nn(e.cursor(),t,n,o,a);return n}if(r=An(e)`${un.as("prefix")}${un.as("string",un.String)}`){let{prefix:o,string:i}=r;if("var"===t.sliceString(o.from,o.to)){let o=t.sliceString(i.from+1,i.to-1);0!==o.length&&n.definitions.set(o,{from:e.from,to:e.to,valid_from:e.to})}else n=In("cursor"in e?e.cursor():e,t,n,a);return n}if(r=kn(e)`${un.as("object")}[${un.as("property")}]`){let{object:e,property:o}=r;return n=In(e.cursor(),t,n,a),o&&(n=In(o.cursor(),t,n,a)),n}if(r=kn(e)`${un.as("object")}.${un.as("property")}`){let{object:e,property:o}=r;return n=In(e.cursor(),t,n,a)}return a&&console.warn("UNKNOWN PATTERN:",e.toString(),t.sliceString(e.from,e.to)),n}finally{a&&console.groupEnd()}},Cn=function(e,t,n,o=!1){let a=null;if("Definition"!==e.name||!e.firstChild()){if("Identifier"===e.name)return{inner:Ln(n,t,e),outer:Ln(Tn(),t,e)};if(a=An(e)`${un.as("subject")}{ ${un.many("parameters")} }`){let{subject:e,parameters:o}=a,r=Tn();if(e){let o=Cn(e.cursor(),t,n);r=o.outer,n=o.inner}for(let{node:e}of o){let{inner:o}=Cn(e.cursor(),t,n);n=o}return{inner:n,outer:r}}if(a=An(e)`${un.as("subject")} <: ${un.maybe(un.as("type"))}`){let{subject:e,type:o}=a,r=Tn();return e&&({outer:r,inner:n}=Cn(e.cursor(),t,n)),o&&(n=In(o.cursor(),t,n)),{inner:n,outer:r}}return o&&console.warn(`Unknown thing in definition: "${t.sliceString(e.from,e.to)}", "${e.toString()}"`),{inner:n,outer:Tn()}}try{return Cn(e,t,n)}finally{e.parent()}},An=(Mn=sn,function(e,t=!1){return null==e?(e,...t)=>Mn(rn(e,...t)):function(n,...o){return Mn(rn(n,...o)).match(e,t)}});var Mn;let On=(e,t,n,o=!1)=>{let a=null,r=yn((e=>on`${e} x y z`));if(a=r(e)`${un.as("macro",rn`@${un.any}`)}`){let{macro:e}=a,o=t.sliceString(e.from,e.to);return n.usages.push({usage:e,definition:n.definitions.get(o)??null,name:o}),n}if(a=r(e)`${un.as("object")}.@${un.as("macro")}`){let{object:e}=a,o=t.sliceString(e.from,e.to);return n.usages.push({usage:e,definition:n.definitions.get(o)??null,name:o}),n}if(a=r(e)`@${un.as("object")}.${un.as("macro")}`){let{object:e}=a,o=t.sliceString(e.from,e.to);return n.usages.push({usage:e,definition:n.definitions.get(o)??null,name:o}),n}return o&&console.warn("Mwep mweeeep",e.toString()),n},Tn=()=>({usages:[],definitions:new Map,locals:[]}),Rn=e=>({usages:[],definitions:new Map(e.definitions),locals:[]}),Dn=(e,t,n)=>({usages:[...t.usages,...e.usages],definitions:t.definitions,locals:[]}),Ln=(e,t,n,o=null)=>(o=null===o?n.to:o,e.definitions.set(t.sliceString(n.from,n.to),{from:n.from,to:n.to,valid_from:o}),e),In=(e,t,n={usages:[],definitions:new Map,locals:[]},o=!1)=>{"cursor"in e&&(e=e.cursor());let a=null;if(o){console.group(`Explorer: ${e.name}`),console.groupCollapsed("Details");try{console.log(`Full tree: ${e.toString()}`),console.log("Full text:",t.sliceString(e.from,e.to)),console.log("scopestate:",n)}finally{console.groupEnd()}a=e.node}try{let a=null;if(e.type.is("keyword")||"SourceFile"===e.name||"BooleanLiteral"===e.name||"Character"===e.name||"String"===e.name||"Number"===e.name||"Comment"===e.name||"BinaryExpression"===e.name||"Operator"===e.name||"MacroArgumentList"===e.name||"ReturnStatement"===e.name||"BareTupleExpression"===e.name||"ParenthesizedExpression"===e.name||"Type"===e.name||"InterpolationExpression"===e.name||"SpreadExpression"===e.name||"CompoundExpression"===e.name||"ParameterizedIdentifier"===e.name||"TypeArgumentList"===e.name||"TernaryExpression"===e.name||"Coefficient"===e.name||"TripleString"===e.name||"RangeExpression"===e.name||"SubscriptExpression"===e.name||"UnaryExpression"===e.name||"ConstStatement"===e.name||"GlobalStatement"===e.name||"ContinueStatement"===e.name||"MatrixExpression"===e.name||"MatrixRow"===e.name||"ArrayExpression"===e.name){for(let a of Xt(e))n=In(a,t,n,o);return n}if("Identifier"===e.name||"MacroIdentifier"===e.name){let o=t.sliceString(e.from,e.to);return n.usages.push({name:o,usage:{from:e.from,to:e.to},definition:n.definitions.get(o)??null}),n}if(a=An(e)`:${un.any}`)return n;if(a=An(e)`${un.Number}`)return n;if(a=An(e)`${un.String}`)return n;if(a=An(e)`${un.as("object")}.${un.as("property")}`){let{object:e,property:r}=a;return e&&(n=In(e.cursor(),t,n,o)),n}if(a=An(e)`${un.as("assignee")} = ${un.maybe(un.as("value"))}`){let{assignee:e,value:r}=a;return r&&(n=In(r.cursor(),t,n,o)),e&&(n=Nn(e.cursor(),t,n,(null==r?void 0:r.to)??null,o)),n}if(a=An(e)`
${un.as("macro",un.anything_that_fits(rn`@macro`))}(${un.many("args")}) ${un.maybe(rn`do ${un.maybe(un.many("do_args"))}
${un.many("do_expressions")}
end`)}}
`){let{macro:r,args:i=[],do_args:s,do_expressions:l}=a;r&&On(r.cursor(),t,n,o);for(let{node:e}of i)if(a=$n(e)`${un.as("name")} = ${un.as("value")}`){let{name:e,value:r}=a;r&&(n=In(r.cursor(),t,n,o))}else n=In(e.cursor(),t,n,o);if(s&&l){let a=Rn(n),r=s.firstChild;if("Identifier"===r.name)a=Ln(a,t,r);else if("ArgumentList"===r.name)for(let e of Yt(r))a=Sn(e,t,a);else if("BareTupleExpression"===r.name)for(let e of Yt(r))a=Sn(e,t,a);else o&&console.warn("Unrecognized do args",r.toString());for(let{node:e}of l)a=In(e.cursor(),t,a,o);return Dn(a,n,e.to)}return n}if(a=An(e)`${un.as("macro",un.anything_that_fits(rn`@macro`))} ${un.many("args")}`){let{macro:e,args:r=[]}=a;e&&On(e.cursor(),t,n,o);for(let{node:e}of r)n=In(e.cursor(),t,n,o);return n}if((a=An(e)`
struct ${un.as("defined_as")}
${un.many("expressions")}
end
`)??(a=An(e)`
mutable struct ${un.as("defined_as")}
${un.many("expressions")}
end
`)){let{defined_as:r,expressions:i=[]}=a;r=mn(r);let s=Rn(n),l=Tn();r&&({inner:s,outer:l}=Cn(r.cursor(),t,s));for(let{node:n}of i)if("Identifier"===e.name);else if(a=An(n)`${un.as("subject")}::${un.as("type")}`){let{subject:e,type:n}=a;s=In(n.cursor(),t,s,o)}else if(a=An(n)`${un.as("assignee")} = ${un.as("value")}`){let{assignee:e,value:n}=a;if(a=An(e)`${un.as("subject")}::${un.as("type")}`){let{subject:e,type:n}=a;s=In(n.cursor(),t,s,o)}s=In(n.cursor(),t,s,o)}return n=Dn(s,n,e.to),n=bn(n,l)}if(a=An(e)`abstract type ${un.as("name")} end`){let{name:e}=a;if(e){let{outer:o}=Cn(e.cursor(),t,n);n=bn(n,o)}return n}if((a=An(e)`quote ${un.many("body")} end`)??(a=An(e)`:(${un.many("body")})`)){for(let a of function*(e){if("QuoteExpression"!==e.name&&"QuoteStatement"!==e.name)throw new Error("Expected QuotedExpression or QuoteStatement");yield*vn(e)}(e))n=In(a,t,n,o);return n}if(a=An(e)`
module ${un.as("name")}
${un.many("expressions")}
end
`){let{name:e,expressions:o=[]}=a;e&&(n=Ln(n,t,e));let r=Tn();for(let{node:e}of o)r=In(e.cursor(),t,r);n=bn(n,{usages:Array.from(r.usages).filter((e=>null!=e.definition)),definitions:new Map,locals:[]});for(let{node:e}of o)n=In(e.cursor(),t,n);return n}if(a=An(e)`${un.as("prefix")}${un.as("string",un.String)}`){let{prefix:o,string:r}=a,i=t.sliceString(o.from,o.to);if("var"===i){let o=t.sliceString(r.from+1,r.to-1);return 0!==o.length&&n.usages.push({name:o,usage:{from:e.from,to:e.to},definition:n.definitions.get(o)??null}),n}{let e=`@${i}_str`;n.usages.push({name:e,usage:{from:o.from,to:o.to},definition:n.definitions.get(e)??null})}return n}if(a=An(e)`${un.Number}${un.as("unit")}`)return In(a.unit.cursor(),t,n,o);if((a=An(e)`import ${un.any}: ${un.many("specifiers")}`)??(a=An(e)`using ${un.any}: ${un.many("specifiers")}`)){let{specifiers:e=[]}=a,r=yn((e=>on`import X: ${e}`));for(let{node:i}of e)if(a=r(i)`${un.as("name")} as ${un.as("alias")}`){let{alias:e}=a;n=Ln(n,t,e)}else if(a=r(i)`${un.as("name",un.Identifier)}`){let{name:e}=a;n=Ln(n,t,e)}else(a=r(i)`@${un.any}`)?n=Ln(n,t,i):o&&console.warn("Hmmmm, I don't know what to do with this selected import specifier:",i.toString());return n}if(a=An(e)`import ${un.many("specifiers")}`){let{specifiers:e=[]}=a,r=yn((e=>on`import ${e}`));for(let{node:i}of e)if(a=r(i)`${un.any} as ${un.as("alias")}`){let{alias:e}=a;n=Ln(n,t,e)}else if(a=r(i)`${un.as("package")}.${un.as("name",un.Identifier)}`)n=Ln(n,t,a.name);else if(a=r(i)`.${un.as("scoped")}`){let e=null;for(;e=r(a.scoped)`.${un.as("scoped")}`;)a=e;n=Ln(n,t,a.scoped)}else(a=r(i)`${un.as("name",un.Identifier)}`)?n=Ln(n,t,a.name):o&&console.warn("Hmmm, I don't know what to do with this import specifier:",i);return n}if(a=An(e)`using ${un.many()}`)return n;if(a=An(e)`
for ${un.many("bindings",un.something_with_the_same_type_as(rn`x in y`))};
${un.many("expressions")}
end
`){let r=hn((e=>on`for ${e}; x end`)),i=e=>(...t)=>r(rn(...t)).match(e),{bindings:s,expressions:l}=a,c=Rn(n);for(let{node:e}of s){let n=null;if((n=i(e)`${un.as("name")} in ${un.as("range")}`)??(n=i(e)`${un.as("name")} โ ${un.as("range")}`)??(n=i(e)`${un.as("name")} = ${un.as("range")}`)){let{name:e,range:a}=n;a&&(c=In(a.cursor(),t,c,o)),e&&(c=Nn(e,t,c,(null==a?void 0:a.to)??null,o))}else o&&console.warn("Unrecognized for loop binding",e.toString())}for(let{node:e}of l)c=In(e.cursor(),t,c,o);return Dn(c,n,e.to)}if((a=An(e)`
${un.as("callee")}(${un.many("args")}) ${un.maybe(rn`do ${un.maybe(un.many("do_args"))}
${un.many("do_expressions")}
end`)}
`)??(a=An(e)`
${un.as("callee")}.(${un.many("args")})
`)){let{callee:r,args:i=[],do_args:s=[],do_expressions:l=[]}=a;n=In(r.cursor(),t,n,o);for(let{node:a}of i){let r=null;if(r=$n(a)`; ${un.many("named_args")}`){let{named_args:e=[]}=r;for(let{node:a}of e){let e=null;if(e=xn(a)`${un.as("name")} = ${un.as("value")}`){let{name:a,value:r}=e;n=In(r.cursor(),t,n,o)}else n=In(a.cursor(),t,n,o)}}else if(r=$n(a)`${un.as("name")} = ${un.as("value")}`){let{name:e,value:a}=r;a&&(n=In(a.cursor(),t,n,o))}else{if(r=$n(a)`${un.as("result")} ${un.many("clauses",un.anything_that_fits(rn`for x = y`))}`){let{result:a,clauses:i}=r,s=Rn(n);for(let{node:e}of i){let n=null;if((n=wn(e)`for ${un.as("variable")} = ${un.maybe(un.as("value"))}`)??(n=wn(e)`for ${un.as("variable")} in ${un.maybe(un.as("value"))}`)??(n=wn(e)`for ${un.as("variable")} โ ${un.maybe(un.as("value"))}`)??(n=wn(e)`for ${un.as("variable")}`)){let{variable:e,value:a}=n;a&&(s=In(a.cursor(),t,s,o)),e&&(s=Nn(e,t,s))}else if(n=wn(e)`if ${un.maybe(un.as("if"))}`){let{if:e}=n;e&&(s=In(e.cursor(),t,s,o))}else o&&console.log("Hmmm, can't parse for binding",e)}return s=In(a.cursor(),t,s,o),Dn(s,n,e.to)}n=In(a.cursor(),t,n,o)}}let c=Rn(n);for(let{node:e}of s)c=Sn(e,t,c);for(let{node:e}of l)c=In(e.cursor(),t,c,o);return Dn(c,n,e.to)}if(a=An(e)`(${un.many("tuple_elements")},)`){let{tuple_elements:r=[]}=a,i=yn((e=>on`(${e},)`)),s=r.map((({node:t})=>null!=i(e)`${un.Identifier} = ${un.any}`));if(s.every((e=>!0===e))||s.every((e=>!1===e)))for(let{node:a}of r){let r=null;if(r=i(e)`${un.as("name")} = ${un.as("value")}`){let{name:e,value:a}=r;a&&(n=In(a.cursor(),t,n,o))}else n=In(a.cursor(),t,n,o)}else for(let{node:a}of r){let r=null;if(r=i(e)`${un.as("name")} = ${un.as("value")}`){let{name:e,value:a}=r;a&&(n=In(a.cursor(),t,n,o)),e&&(n=Ln(n,t,e,(null==a?void 0:a.to)??null))}else n=In(a.cursor(),t,n,o)}return n}if((a=An(e)`(${un.many("args")}) -> ${un.many("body")}`)??(a=An(e)`${un.as("arg")} -> ${un.many("body")}`)??(a=An(e)`${un.as("name")}(${un.many("args")})::${un.as("return_type")} = ${un.many("body")}`)??(a=An(e)`${un.as("name")}(${un.many("args")}) = ${un.many("body")}`)??(a=An(e)`${un.as("name")}(${un.many("args")}) = ${un.many("body",un.anything_that_fits(rn`x, y`))}`)??(a=An(e)`
function ${un.as("name")}(${un.many("args")})::${un.as("return_type")} where ${un.as("type_param")}
${un.many("body")}
end
`)??(a=An(e)`
function ${un.as("name")}(${un.many("args")}) where ${un.as("type_param")}
${un.many("body")}
end
`)??(a=An(e)`
function ${un.as("name")}(${un.many("args")})::${un.as("return_type")}
${un.many("body")}
end
`)??(a=An(e)`
function ${un.as("name")}(${un.many("args")})
${un.many("body")}
end
`)??(a=An(e)`
function ${un.as("name",un.Identifier)} end
`)??(a=An(e)`macro ${un.as("macro_name")} end`)??(a=An(e)`
macro ${un.as("macro_name")}(${un.many("args")})
${un.many("body")}
end
`)){let{name:r,macro_name:i,arg:s,args:l=[],return_type:c,type_param:d,body:u=[]}=a;s&&l.push({node:s}),r?n=Ln(n,t,r):i&&n.definitions.set(`@${t.sliceString(i.from,i.to)}`,{from:i.from,to:i.to,valid_from:i.to});let p=Rn(n);if(d){let e=yn((e=>on`function X() where ${e} end`)),n=yn((e=>on`function X() where {${e}} end`)),a=[{node:d}],r=e(d)`{${un.many("type_params")}}`;r&&(a=r.type_params);for(let{node:e}of a){let a=null;if(a=n(e)`${un.as("defined",un.Identifier)} <: ${un.as("parent_type")}`){let{defined:e,parent_type:n}=a;p=In(n,t,p,o),p=Ln(p,t,e)}else if(a=n(e)`${un.as("defined",un.Identifier)}`){let{defined:e}=a;p=Ln(p,t,e)}else o&&console.warn("Can't handle type param:",e)}}c&&(p=In(mn(c).cursor(),t,p,o));for(let{node:e}of l)p=Sn(e.cursor(),t,p,o);for(let{node:e}of u)p=In(e.cursor(),t,p,o);return Dn(p,n,e.to)}if(a=An(e)`
let ${un.many("assignments",rn`${un.as("assignee")} = ${un.as("value")}`)}
${un.many("body",un.any)}
end
`){let{assignments:r=[],body:i=[]}=a,s=Rn(n);for(let{match:{assignee:e,value:a}}of r)e&&(s=Nn(e,t,s,(null==a?void 0:a.to)??null,o)),a&&(n=In(a.cursor(),t,n,o));for(let{node:e}of i)s=In(e.cursor(),t,s,o);return Dn(s,n,e.to)}if((a=An(e)`[
${un.as("result")}
${un.many("clauses",un.anything_that_fits(rn`for x = y`))}
]`)??(a=An(e)`(${un.as("result")} ${un.many("clauses",un.anything_that_fits(rn`for x = y`))})`)){let{result:r,clauses:i}=a,s=Rn(n);for(let{node:e}of i){let n=null;if((n=wn(e)`for ${un.as("variable")} = ${un.maybe(un.as("value"))}`)??(n=wn(e)`for ${un.as("variable")} in ${un.maybe(un.as("value"))}`)??(n=wn(e)`for ${un.as("variable")} โ ${un.maybe(un.as("value"))}`)??(n=wn(e)`for ${un.as("variable")}`)){let{variable:e,value:a}=n;a&&(s=In(a.cursor(),t,s,o)),e&&(s=Nn(e,t,s))}else if(n=wn(e)`if ${un.maybe(un.as("if"))}`){let{if:e}=n;e&&(s=In(e.cursor(),t,s,o))}else o&&console.warn("Hmmm, can't parse for binding",e)}return s=In(r.cursor(),t,s,o),Dn(s,n,e.to)}o&&(console.groupCollapsed("Cycling through all children of",e.name),console.log("text:",t.sliceString(e.from,e.to)),console.groupEnd());for(let a of Xt(e))n=In(a,t,n,o);return n}finally{o&&console.groupEnd()}},Pn=St.StateField.define({create(e){try{let t=St.syntaxTree(e).cursor();return In(t,e.doc,void 0)}catch(e){return console.error("Something went wrong while parsing variables...",e),{usages:[],definitions:new Map,locals:[]}}},update(e,t){try{if(St.syntaxTree(t.state)!=St.syntaxTree(t.startState)){let e=St.syntaxTree(t.state).cursor();return In(e,t.state.doc)}return e}catch(e){return console.error("Something went wrong while parsing variables...",e),{usages:[],definitions:new Map,locals:[]}}}}),jn=e=>"SubscriptExpression"===e.name||"FieldExpression"===e.name?(e.firstChild(),jn(e)):"Identifier"===e.name?(e.firstChild(),e.node):null,Bn=["Identifier","FieldExpression","SubscriptExpression","MacroFieldExpression","MacroIdentifier","Operator","Definition","ParameterizedIdentifier"],Un=["import","export","try","catch","finally","quote","do","struct","mutable","module","baremodule","if","let"],Fn=e=>{if(Un.includes(e.name))return!0;if(Bn.includes(e.name)){if(e.firstChild()){do{if("Number"!==e.name&&"TypeArgumentList"!==e.name&&"FieldName"!==e.name&&"MacroName"!==e.name&&"MacroFieldName"!==e.name&&!Fn(e))return!1}while(e.nextSibling());return e.parent(),!0}return!0}return!1},zn=(e,t=!1)=>{let n=e.selection.main,o=e.field(Pn);if(n.from!==n.to)return e.doc.sliceString(n.from,n.to).trim();{let a=e.doc.lineAt(n.from).text;if("?"===a[0])return a.slice(1);let r=St.syntaxTree(e).cursor();t&&console.log("Full tree:",r.toString()),r.moveTo(n.to,-1);let i=0;do{t&&console.group(`Iteration #${i}`);try{if(t&&console.log("cursor",r.toString()),i>100){console.group("Infinite loop while checking docs"),console.log("Selection:",n,e.doc.sliceString(n.from,n.to).trim()),console.log("Current node:",r.name,e.doc.sliceString(r.from,r.to).trim()),console.groupEnd();break}i+=1;let a=r.node.cursor(),s=[];for(;a.parent();)s.push(a.name);let l=r.node.parent;if(null==l)break;t&&console.log("parents:",s);let c=s.indexOf("StructDefinition");if(-1!==c)if(s.includes("AssignmentExpression")&&s.indexOf("AssignmentExpression")<c);else if(s.includes("TypedExpression")&&s.indexOf("TypedExpression")<c);else{if(!(s.includes("SubtypedExpression")&&s.indexOf("SubtypedExpression")<c))return"struct"===r.name||"mutable"===r.name?(r.parent(),r.firstChild(),"struct"===r.name?"struct":"mutable"===r.name&&(r.nextSibling(),"struct"===r.name)?"mutable struct":void 0):void 0;{for(;"SubtypedExpression"!==(null==l?void 0:l.name);)l=l.parent;const t=l.lastChild;if(t.from<=r.from&&t.to>=r.to)return e.doc.sliceString(t.from,t.to)}}if("AbstractDefinition"===r.name)return"abstract type";if("CallExpression"===r.name)return r.firstChild(),Fn(r)?e.doc.sliceString(r.from,r.to):void 0;if(("Operator"===r.name||"โ "===r.name||"Identifier"===r.name)&&"QuoteExpression"===l.name&&"FieldExpression"===l.parent.name)return e.sliceDoc(l.parent.from,l.parent.to);if("ParameterizedIdentifier"===r.name)return r.firstChild(),Fn(r)?e.doc.sliceString(r.from,r.to):void 0;if("Identifier"===r.name&&"Prefix"===l.name)continue;if("PrefixedString"===r.name){return r.firstChild(),`${e.doc.sliceString(r.from,r.to)}"`}if("Identifier"===r.name&&"TypedExpression"===l.name)return r.parent(),r.lastChild(),Fn(r)?e.doc.sliceString(r.from,r.to):void 0;if("TypedExpression"===r.name)return r.lastChild(),Fn(r)?e.doc.sliceString(r.from,r.to):void 0;if("SpreadExpression"===r.name)return"...";if(l.to===r.to&&Bn.includes(r.name)&&Bn.includes(l.name))continue;if("Identifier"===r.name&&"NamedField"===l.name&&l.lastChild.from!=r.from&&l.lastChild.to!=r.to)continue;if("AssignmentExpression"===r.name){let t=r.node.firstChild.to,n=r.node.lastChild.from;return e.doc.sliceString(t,n).trim()}if("ArgumentList"===r.name)continue;if("Identifier"===r.name&&"ArgumentList"===l.name&&("FunctionAssignmentExpression"===l.parent.parent.name||"FunctionDefinition"===l.parent.name))continue;if("Identifier"===r.name&&"Symbol"===l.name)continue;if("FunctionDefinition"===r.name)return r.firstChild(),r.nextSibling(),Fn(r)?e.doc.sliceString(r.from,r.to):void 0;if("FunctionAssignmentExpression"===r.name)return r.firstChild(),Fn(r)?e.doc.sliceString(r.from,r.to):void 0;if("Identifier"===r.name&&"MacroIdentifier"===l.name)continue;if("MacroExpression"===r.name)return r.firstChild(),e.doc.sliceString(r.from,r.to);if("BinaryExpression"===r.name){let t=r.node.firstChild.to,n=r.node.lastChild.from;return e.doc.sliceString(t,n).trim()}if("TernaryExpression"===r.name)return"??:";if(Bn.includes(r.name)||Un.includes(r.name)){if(!Fn(r))return void console.log("NOT DOCS SEARCHABLE");let t=jn(r.node.cursor);if(null==t)return e.doc.sliceString(r.from,r.to);let n=o.usages.find((e=>e.usage.from===t.from&&e.usage.to===t.to));if(null==(null==n?void 0:n.definition))return e.doc.sliceString(r.from,r.to)}if("FunctionDefinition"===l.name)return;if("AssignmentExpression"===l.name)return}finally{t&&console.groupEnd()}}while(r.parent())}};St=r("hiQgq"),$e=r("kjWx8"),ce=r("9Ta4i");let qn=(e,{scopestate:t,global_definitions:n})=>St.Decoration.set(Hn(t.usages.map((({definition:e,usage:t,name:o})=>null==e?n[o]?St.Decoration.mark({tagName:"a",attributes:{title:`${$e.ctrl_or_cmd_name}-Click to jump to the definition of ${o}.`,"data-pluto-variable":o,href:`#${o}`}}).range(t.from,t.to):null:St.Decoration.mark({tagName:"a",attributes:{title:`${$e.ctrl_or_cmd_name}-Click to jump to the definition of ${o}.`,"data-cell-variable":o,"data-cell-variable-from":`${e.from}`,"data-cell-variable-to":`${e.to}`,href:"#"}}).range(t.from,t.to)))),!0);const Hn=e=>e.filter((e=>null!=e)),Wn=St.Facet.define({combine:e=>e[0],compare:ce.default.isEqual}),Gn=St.ViewPlugin.fromClass(class{constructor(e){let t=e.state.facet(Wn);this.decorations=qn(e.state,{scopestate:e.state.field(Pn),global_definitions:t})}update(e){let t=e.state.facet(Wn);(e.docChanged||e.viewportChanged||t!==e.startState.facet(Wn))&&(this.decorations=qn(e.state,{scopestate:e.state.field(Pn),global_definitions:t}))}},{decorations:e=>e.decorations,eventHandlers:{click:(e,t)=>{if(e.target instanceof Element){let o=e.target.closest("[data-pluto-variable]");if(o){var n;let a=o.getAttribute("data-pluto-variable");if(null==a)return!1;if(!$e.has_ctrl_or_cmd_pressed(e)&&!t.state.readOnly)return!1;e.preventDefault();let r=`[id='${encodeURI(a)}']`;null===(n=document.querySelector(r))||void 0===n||n.scrollIntoView({behavior:"smooth",block:"center"});let i=t.state.facet(Wn);if(i[a])return window.dispatchEvent(new CustomEvent("cell_focus",{detail:{cell_id:i[a],line:0,definition_of:a}})),!0}let a=e.target.closest("[data-cell-variable]");if(a){let n=a.getAttribute("data-cell-variable"),o=Number(a.getAttribute("data-cell-variable-from")),r=Number(a.getAttribute("data-cell-variable-to"));return null!=n&&null!=o&&null!=r&&(!(!$e.has_ctrl_or_cmd_pressed(e)&&!t.state.readOnly)&&(e.preventDefault(),t.dispatch({scrollIntoView:!0,selection:{anchor:o,head:r}}),t.focus(),!0))}}}}});St=r("hiQgq");r("9Ta4i");const Kn=(St=r("hiQgq")).htmlLanguage.parser,Zn=St.markdownLanguage.parser.configure(St.parseCode({htmlParser:Kn})),Vn=St.PostgreSQL.language.parser,Qn=St.sql({dialect:St.PostgreSQL}),Xn=St.pythonLanguage.parser,Yn=["md","mermaid","cm","markdown","mdx","mdl","markdownliteral"].flatMap((e=>[e,`@${e}`])),Jn=new Set(["TripleString","String","CommandString","TripleStringWithoutInterpolation","StringWithoutInterpolation","CommandStringWithoutInterpolation"]),eo=St.parseMixed(((e,t)=>{var n,o,a;if(!Jn.has(e.type.name))return null;const r="TripleString"===e.name||"TripleStringWithoutInterpolation"===e.name?3:1,i=e.from+r,s=Math.min(e.to-r,t.length);if(i>=s)return null;const l=(null===(n=e.node)||void 0===n?void 0:n.prevSibling)||(null===(o=e.node)||void 0===o||null===(a=o.parent)||void 0===a?void 0:a.prevSibling);if(null==l||"MacroIdentifier"!==l.name&&"Prefix"!==l.name)return null;const c="MacroIdentifier"===l.name,d=t.read(l.from,l.to);let u=null;if("@htl"===d||"html"===d)u=Kn;else if(Yn.includes(d))u=Zn;else if("@javascript"===d||"@js"===d||"js"===d||"javascript"===d)u=St.javascriptLanguage.parser;else if("py"===d||"pyr"===d||"python"===d||"@python"===d)u=Xn;else{if("sql"!==d)return null;u=Vn}let p=[];if(null!=e.node.firstChild){let t=i,n=e.node.firstChild.cursor();do{t!==n.from&&p.push({from:t,to:n.from}),t=n.to}while(n.nextSibling());t<s&&p.push({from:t,to:s})}else p=[{from:i,to:s}];return c&&(p=((e,t)=>e.flatMap((({from:e,to:n})=>{const o=t.read(e,n),a=[];let r=e;for(let{index:t}of o.matchAll(/\\\$/g)){let n=e+t;r!==n&&a.push({from:r,to:n}),r=n+1}return r!==n&&a.push({from:r,to:n}),a})))(p,t)),[...Yn].includes(d)?{parser:u,overlay:[{from:i,to:s}]}:{parser:u,overlay:p}})),to=e=>{const t=St.julia_andrey(e);return t.language.parser=t.language.parser.configure({wrap:eo}),t};St=r("hiQgq"),St=r("hiQgq"),ce=r("9Ta4i");r("2P6PH");St=r("hiQgq"),ve=r("aN0pg"),i=r("cNaMA"),ve=r("aN0pg"),i=r("cNaMA");var no=r("fUfdR");ve=r("aN0pg");let oo=({focus_on_open:e,desired_doc_query:t,on_update_doc_query:n,notebook:o,sanitize_html:a=!0})=>{let r=i.useContext(ye),s=i.useRef(null),[l,c]=i.useState({shown_query:null,searched_query:null,body:'<p>Welcome to the <b>Live docs</b>! Keep this little window open while you work on the notebook, and you will get documentation of everything you type!</p><p>You can also type a query above.</p><hr><p><em>Still stuck? Here are <a target="_blank" href="https://julialang.org/about/help/">some tips</a>.</em></p>',loading:!1}),d=e=>c(le((t=>e(t))));i.useEffect((()=>{l.loading||(null==t||/[^\s]/.test(t))&&l.searched_query!==t&&u(t)}),[t,l.loading,l.searched_query]),i.useLayoutEffect((()=>{e&&s.current&&(s.current.focus({preventScroll:!0}),s.current.select())}),[e,s.current]);let u=e=>{d((t=>{t.loading=!0,t.searched_query=e})),Promise.race([no.default.Promises.delay(2e3,!1),r.send("docs",{query:e.replace(/^\?/,"")},{notebook_id:o.notebook_id}).then((t=>"โ"!==t.message.status&&("๐"===t.message.status?(d((n=>{n.shown_query=e,n.body=t.message.doc})),!0):void 0)))]).then((()=>{d((e=>{e.loading=!1}))}))},p=i.useMemo((()=>i.html`<${Es} body=${ro(l.body)} sanitize_html=${a} sanitize_html_message=${!1} />`),[l.body,a]),m=!1===l.loading&&""!==l.searched_query&&l.searched_query!==l.shown_query;return i.html`
<div
class=${ve.cl({"live-docs-searchbox":!0,loading:l.loading,notfound:m})}
translate=${!1}
>
<input
title=${m?`"${l.searched_query}" not found`:""}
id="live-docs-search"
placeholder="Search docs..."
ref=${s}
onInput=${e=>n(e.target.value)}
value=${t}
type="search"
></input>
</div>
<section ref=${e=>null!=e&&ao(e,n)}>
<h1><code>${l.shown_query}</code></h1>
${p}
</section>
`};const ao=(e,t)=>{for(let t of e.querySelectorAll("code:not([class])"))$s(t,"julia");for(let n of e.querySelectorAll("a")){const e=n.getAttribute("href");if(null!=e&&e.startsWith("@ref")){const o=e.length>4?e.substr(5):n.textContent;n.onclick=e=>{t(o),e.preventDefault()}}}},ro=e=>e.replace(/Main\.var"workspace\#\d+"\./g,"").replace(/Main\.workspace\#\d+\./g,"").replace(/ in Main\.var"workspace\#\d+"/g,"").replace(/ in Main\.workspace\#\d+/g,"").replace(/#==#[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\:\d+/g,"");i=r("cNaMA"),ve=r("aN0pg"),ce=r("9Ta4i"),i=r("cNaMA");r("kjWx8");var io=r("1gqBQ");const so=({runtime:e,running:t,queued:n,code_differs:o,on_run:a,on_interrupt:r,set_cell_disabled:s,depends_on_disabled_cells:l,running_disabled:c,on_jump:d})=>{const u=a,p=co(t),m=null==p?null:1e6*p,g=(i.useContext(ye),t||n?"interrupt":c?"save":l&&!o?"jump":"run"),h={on_interrupt:r,on_save:u,on_jump:d,on_run:a};return i.html`
<pluto-runarea class=${g}>
<button onDblClick=${e=>{console.log(c),c&&io.open_pluto_popup({type:"info",source_element:e.target,body:i.html`${"This cell is disabled. "}
<a
href="#"
onClick=${e=>{s(!1),e.preventDefault(),window.dispatchEvent(new CustomEvent("close pluto popup"))}}
>Enable this cell</a
>
${" to run the code."}`})}} onClick=${h[`on_${g}`]} class="runcell" title=${{interrupt:"Interrupt (Ctrl + Q)",save:"Save code without running",jump:"This cell depends on a disabled cell",run:"Run cell (Shift + Enter)"}[g]}>
<span></span>
</button>
<span class="runtime">${lo(t?m??e:e)}</span>
</pluto-runarea>
`},lo=e=>{if(null==e)return"---";let t=e;const n=["n","ฮผ","m",""];let o=0;for(;o<n.length-1&&t>=1e3;)o+=1,t/=1e3;return t.toFixed(e<100||t>=100?0:1)+"ย "+n[o]+"s"},co=e=>{const[t,n]=i.useState(0),[o,a]=i.useState(0);return i.useEffect((()=>{let t;if(e){const e=+new Date;a(e),n(e),t=setInterval((()=>n(+new Date)),50)}return()=>{t&&clearInterval(t)}}),[e]),e?t-o:void 0},uo=(e,t=5)=>{const[n,o]=i.useState(e),a=i.useMemo((()=>ce.default.debounce(o,1e3*t)),[o]);return i.useEffect((()=>(e?(o(!0),a.cancel()):a(!1),()=>{})),[e]),n};ve=r("aN0pg"),i=r("cNaMA");const po=({total:e,done:t,busy:n})=>(e=Math.max(1,e),i.html`
<div
class=${ve.cl({"discrete-progress-bar":!0,small:e<8,mid:e>=8&&e<48,big:e>=48})}
data-total=${e}
>
${[...Array(e)].map(((e,o)=>i.html`<div
class=${ve.cl({done:o<t,busy:o>=t&&o<t+n})}
></div>`))}
</div>
`);var mo=AnsiUp=window.AnsiUp;i=r("cNaMA");const go=({value:e})=>{const t=i.useRef(null),n=i.useRef(Date.now());return i.useEffect((()=>{if(!t.current)return;t.current.style.cssText=`--animation-delay: -${(Date.now()-n.current)%1e3}ms`,t.current.innerHTML=(new mo).ansi_to_html(e).replaceAll("โ",'<span class="make-me-spin">โ</span>');const o=t.current.parentElement;o&&(o.scrollTop=1e5)}),[t.current,e]),e?i.html`<pkg-terminal
><div class="scroller" tabindex="0"><pre ref=${t} class="pkg-terminal"></pre></div
></pkg-terminal>`:null};i=r("cNaMA"),ve=r("aN0pg");let ho=({status:e})=>{const t=Object.values(e.subtasks).every($o),[n,o]=i.useState(!1);i.useEffect((()=>{if(n&&t){console.log("all done");let t=null,n=setTimeout((()=>{o(!1);let n=No(e);t=new Notification("Pluto: notebook ready",{tag:"notebook ready",body:`โ All ${n} steps completed`,lang:"en-US",dir:"ltr",icon:wc}),t.onclick=e=>{parent.focus(),window.focus(),null==t||t.close()}}),3e3);const a=()=>{"visible"===document.visibilityState&&(null==t||t.close())};return document.addEventListener("visibilitychange",a),document.body.addEventListener("click",a),()=>{null==t||t.close(),clearTimeout(n),document.removeEventListener("visibilitychange",a),document.body.removeEventListener("click",a)}}}),[t]);const a=Bo(!t,2500)||n;return i.html`
<div class=${ve.cl({visible:a,"notify-when-done":!0})} inert=${!a}>
<label
>${"Notify when done"}
<input
type="checkbox"
checked=${n}
disabled=${!a}
onInput=${e=>{e.target.checked?Notification.requestPermission().then((t=>{console.log(t),o("granted"===t),e.target.checked="granted"===t})):o(!1)}}
/></label>
</div>
`},fo=({status:e,notebook:t,backend_launch_logs:n,my_clock_is_ahead_by:o})=>i.html`
<section>
<${wo}
status_tree=${e}
path=${[]}
my_clock_is_ahead_by=${o}
nbpkg=${t.nbpkg}
backend_launch_logs=${n}
/>
<${ho} status=${e} />
</section>
`;const _o="\nworkspace\n\ncreate_process\ninit_process\n\n\npkg\n\nanalysis\nwaiting_for_others\nresolve\nremove\nadd\ninstantiate\ninstantiate1\ninstantiate2\ninstantiate3\nprecompile\n\nrun\n\n\nsaving\n\n".split("\n").map((e=>e.trim())).filter((e=>e.length>0)),bo=["saving"],vo={workspace:"Workspace setup",create_process:"Start Julia",init_process:"Initialize",pkg:"Package management",instantiate1:"instantiate",instantiate2:"instantiate",instantiate3:"instantiate",run:"Evaluating cells",evaluate:"Running code",registry_update:"Updating package registry",waiting_for_others:"Waiting for other notebooks to finish package operations",backend_launch:"Connecting to backend",backend_requesting:"Requesting a worker",backend_created:"Starting Pluto server",backend_responded:"Opening notebook file",backend_notebook_running:"Switching to live editing"},yo=e=>1e9*e,wo=({status_tree:e,path:t,my_clock_is_ahead_by:n,nbpkg:o,backend_launch_logs:a})=>{var r;if(null==e)return null;const s=t.reduce(((e,t)=>e.subtasks[t]),e);if(!s)return null;const[l,c]=i.useState(t.length<1),d=t.length>0&&xo(s),u=d&&$o(s),p=d&&!u,m=s.started_at??0,g=s.finished_at??0,h=(co(p)??0)/1e3,f=Date.now()/1e3,_=Math.max(h,f-m-("local"===s.timing?0:n));i.useEffect((()=>{if(p){let e=setTimeout((()=>{c(!0)}),Math.max(100,500-200*t.length));return()=>clearTimeout(e)}}),[p]),Mo((([e])=>{if(!e&&u){let e=setTimeout((()=>{c(!1)}),1800-200*t.length);return()=>clearTimeout(e)}}),[u]);const b=l?Object.values(s.subtasks).every((e=>ko(e.name)))&&Object.values(s.subtasks).length>0?(()=>{let e=Object.values(s.subtasks),t=e.reduce(((e,t)=>e+($o(t)?1:0)),0),n=e.reduce(((e,t)=>e+(So(t)?1:0)),0),o=e.length;return i.html`<${po} busy=${n} done=${t} total=${o} />`})():Object.entries(s.subtasks).sort(((e,t)=>Eo(e[1],t[1]))).map((([r,s])=>bo.includes(r)?null:i.html`<${wo}
key=${r}
status_tree=${e}
my_clock_is_ahead_by=${n}
path=${[...t,r]}
nbpkg=${o}
backend_launch_logs=${a}
/>`)):null;let v=null;if(d){let e=Co(s),t=No(s);e>1&&(v=i.html`<span class="subprogress-counter">${" "}(${t}/${e})</span>`)}const y=Object.values(s.subtasks).length>0;return 0===t.length?b:i.html`<pl-status
data-depth=${t.length}
class=${ve.cl({started:d,finished:u,busy:p,is_open:l,can_open:y})}
aria-expanded=${y?l:void 0}
>
<div
onClick=${e=>{c(!l)}}
>
<span class="status-icon"></span>
<span class="status-name">${(e=>{const t=vo[e];return null!=t?t:ko(e)?`Step ${e}`:e})(s.name)}${v}</span>
<span class="status-time">${u?lo(yo(g-m)):p?lo(yo(_)):null}</span>
</div>
${b}
${l&&"pkg"===s.name?i.html`<${go} value=${null==o||null===(r=o.terminal_outputs)||void 0===r?void 0:r.nbpkg_sync} />`:l&&"backend_launch"===s.name?i.html`<${go} value=${a} />`:void 0}
</pl-status>`},ko=e=>/^\d+$/.test(e),Eo=(e,t)=>{const n=_o.indexOf(e.name),o=_o.indexOf(t.name);if(-1===n&&-1===o)return null!=e.started_at||null!=t.started_at?(e.started_at??1/0)-(t.started_at??1/0):ko(e.name)&&ko(t.name)?parseInt(e.name)-parseInt(t.name):e.name.localeCompare(t.name);{let e=e=>-1===e?1/0:e;return e(n)-e(o)}},$o=e=>null!=e.finished_at,xo=e=>null!=e.started_at,So=e=>xo(e)&&!$o(e),No=e=>Object.values(e.subtasks).reduce(((e,t)=>e+No(t)),$o(e)?1:0),Co=e=>Object.values(e.subtasks).reduce(((e,t)=>e+Co(t)),1),Ao=(e,t,n,o={})=>({name:e,subtasks:o,timing:"local",started_at:i.useMemo((()=>t||n?Date.now()/1e3:null),[t||n]),finished_at:i.useMemo((()=>n?Date.now()/1e3:null),[n])}),Mo=(e,t)=>{const n=i.useRef(t);i.useEffect((()=>{let o=e(n.current);return n.current=t,o}),t)};i=r("cNaMA");de=r("4zMEb");var Oo=r("41Mhf");const To={wait_for_user:0,requesting:.4,created:.6,responded:.7,notebook_running:.9,ready:1},Ro=e=>e.endsWith("/")?e:e+"/",Do=e=>fetch(`https://stats.plutojl.org/count?p=/${e}&s=${screen.width},${screen.height},${devicePixelRatio}#skip_sw`,{cache:"no-cache"}).catch((()=>{})),Lo=async({setStatePromise:e,connect:t,launch_params:n})=>{try{Do("binder-start"),await e(le((e=>{e.backend_launch_phase=To.requesting,e.disable_ui=!1,e.notebook.status_tree=null})));const{binder_session_url:o,binder_session_token:a}=await((e,{on_log:t})=>new Promise(((n,o)=>{console.log("Starting binder connection to",e);try{let a=new EventSource(e);a.onerror=t=>{console.error("Binder error: Lost connection to "+e,t),a.close(),o(t)};let r=null,i="",s=e=>{console.log("Binder: ",e,` at ${(new Date).toLocaleTimeString()}`),i=`${i}${e}\n`,t(i)};a.onmessage=t=>{let i=JSON.parse(t.data);switch(i.phase&&i.phase!==r&&(r=i.phase.toLowerCase(),s(`\n\nโฑ๏ธ Binder subphase: ${r}\n`)),i.message&&s(i.message.replace("] ","]\n")),i.phase){case"failed":console.error("Binder error: Failed to build",e,i),a.close(),o(new Error(i));break;case"ready":a.close(),n({binder_session_url:Ro(i.url)+"pluto/",binder_session_token:i.token})}}}catch(e){console.error(e),o("Failed to open event source the mybinder.org. This probably means that the URL is invalid.")}})))(n.binder_url.replace("mybinder.org/v2/","mybinder.org/build/"),{on_log:t=>e(le((e=>{e.backend_launch_logs=t})))}),r=e=>Oo.with_query_params(e,{token:a});console.log("Binder URL:",r(o)),window.shutdown_binder=()=>{fetch(r(new URL("../api/shutdown",o)),{method:"POST"})},await e(le((e=>{e.backend_launch_phase=To.created,e.binder_session_url=o,e.binder_session_token=a}))),await fetch(r(o)),await e(le((e=>{e.backend_launch_phase=To.responded})));let i=async()=>{const e=r(Oo.with_query_params(new URL("notebookupload",o),{name:new URLSearchParams(window.location.search).get("name"),execution_allowed:"true"}));return console.log("downloading locally and uploading ",e,n.notebookfile),fetch(e,{method:"POST",body:await(await fetch(new Request(n.notebookfile,{integrity:n.notebookfile_integrity}))).arrayBuffer()})},s=async(e,t)=>{const n=Oo.with_query_params(new URL("open",o),{[e]:t});return console.log(`open ${e}:`,n),fetch(r(n),{method:"POST"})},l=(e,t)=>()=>s(e,t),c=n.notebookfile.startsWith("data:")?[i]:[l("path",n.notebookfile),l("url",new URL(n.notebookfile,window.location.href).href),i],d=new Response;for(let e of c)if(d=await e(),d.ok)break;if(!d.ok){let e=await d.blob();return void(window.location.href=URL.createObjectURL(e))}const u=await d.text(),p=r(Oo.with_query_params(new URL("edit",o),{id:u}));console.info("notebook_id:",u),await e(le((e=>{e.notebook.notebook_id=u,e.backend_launch_phase=To.notebook_running,e.refresh_target=p}))),console.log("Connecting WebSocket");const m=t(r(new URL("channels",de.ws_address_from_base(o))));await de.timeout_promise(m,2e4).catch((e=>{console.error("Failed to establish connection within 20 seconds. Navigating to the edit URL directly.",e),window.parent.location.href=p}))}catch(e){console.error("Failed to initialize binder!",e),alert("Something went wrong! ๐ฎ\n\nWe failed to initialize the binder connection. Please try again with a different browser, or come back later.")}};var Io=r("hrGZZ");const Po=e=>window.dispatchEvent(new CustomEvent("open_bottom_right_panel",{detail:e}));let jo=({desired_doc_query:e,on_update_doc_query:t,notebook:n,connected:o,backend_launch_phase:a,backend_launch_logs:r,sanitize_html:s=!0})=>{let l=i.useRef();const c=i.useRef(!1),[d,u]=i.useState(null),p=null==d;Io.useEventListener(window,"open_bottom_right_panel",(e=>{console.log(e.detail),c.current=!1,u(e.detail),"none"===window.getComputedStyle(l.current).display&&alert("This browser window is too small to show docs.\n\nMake the window bigger, or try zooming out.")}),[u]);const m=Uo(n,a),[g,h]=i.useMemo((()=>null==m?[0,0]:[Co(m)-1,No(m)-($o(m)?1:0)]),[m]),f=h<g,_=Bo(f,700),b=Bo(f,3e3),v=(({connected:e})=>{let t=i.useContext(ye);const[n,o]=i.useState(0);return i.useEffect((()=>{if(e){let e=async()=>{let e=()=>t.send("current_time").then((e=>e.message.time)),n=()=>Date.now()/1e3;for(let t=0;t<16;t++)await e();let a=await n(),r=await e(),i=await e(),s=(a+await n())/2-(r+i)/2;isNaN(s)||o(s)};e();let n=setInterval(e,6e4);return()=>clearInterval(n)}}),[e]),n})({connected:o});return i.html`
<aside id="helpbox-wrapper" ref=${l}>
<pluto-helpbox class=${ve.cl({hidden:p,[`helpbox-${d??p}`]:!0})}>
<header translate=${!1}>
<button
title="Live Docs: Search for Julia documentation, and get live documentation of everything you type."
class=${ve.cl({"helpbox-tab-key":!0,"helpbox-docs":!0,active:"docs"===d})}
onClick=${()=>{c.current=!0,u("docs"===d?null:"docs")}}
>
<span class="tabicon"></span>
<span class="tabname">Live Docs</span>
</button>
<button
title=${"Process status"}
class=${ve.cl({"helpbox-tab-key":!0,"helpbox-process":!0,active:"process"===d,busy:_,something_is_happening:f||!o})}
id="process-status-tab-button"
onClick=${()=>{u("process"===d?null:"process")}}
>
<span class="tabicon"></span>
<span class="tabname"
>${"process"!==d&&b?i.html`Status${" "}<span class="subprogress-counter">(${h}/${g})</span>`:"Status"}</span
>
</button>
${p?null:i.html`<button
class="helpbox-close"
title="Close panel"
onClick=${()=>{u(null)}}
>
<span></span>
</button>`}
</header>
${"docs"===d?i.html`<${oo}
focus_on_open=${c.current}
desired_doc_query=${e}
on_update_doc_query=${t}
notebook=${n}
sanitize_html=${s}
/>`:"process"===d?i.html`<${fo}
notebook=${n}
backend_launch_logs=${r}
my_clock_is_ahead_by=${v}
status=${m}
/>`:null}
</pluto-helpbox>
</aside>
`};const Bo=(e,t)=>{const[n,o]=i.useState(!1);return i.useEffect((()=>{if(e){let e=setTimeout((()=>{o(!0)}),t);return()=>clearTimeout(e)}o(!1)}),[e]),n},Uo=(e,t)=>{var n;const o=Fo(t);return null==t?e.status_tree:{name:"notebook",started_at:0,finished_at:null,subtasks:{...null===(n=e.status_tree)||void 0===n?void 0:n.subtasks,backend_launch:o}}},Fo=e=>{let t=e??-1;const n=Object.fromEntries(["requesting","created","responded","notebook_running"].map((e=>{let n=To[e],o=`backend_${e}`;return[o,Ao(o,t>=n,t>n)]})));return Ao("backend_launch",null!=e&&e>To.wait_for_user,e===To.ready,n)};let{autocompletion:zo,completionKeymap:qo,completionStatus:Ho,acceptCompletion:Wo}=St.autocomplete;const Go=(e,t)=>e.state.field(Ko).active.find((e=>e.source==t));let Ko=zo()[0];const Zo=St.StateEffect.define(),Vo=St.StateField.define({create:()=>!1,update(e,t){var n,o;for(let e of t.effects)if(e.is(Zo))return!0;return(null==(null===(n=t.startState.field(Ko,!1))||void 0===n?void 0:n.open)||null!=(null===(o=t.state.field(Ko,!1))||void 0===o?void 0:o.open))&&((null==t.startState.field(Ko,!1).open||t.startState.field(Ko,!1)===t.state.field(Ko,!1))&&e)}});const Qo=[{key:"Tab",run:e=>{if(Wo(e))return!0;if(e.state.readOnly)return!1;let t=e.state.selection.main,n=e.state.sliceDoc(t.from-1,t.from);return!!t.empty&&(!/^(\t| |\n|\=|\)|)$/.test(n)&&(e.dispatch({effects:Zo.of(10)}),St.autocomplete.startCompletion(e)))}},{key:"?",run:e=>{var t;return!!((null===(t=e.state.field(Ko,!1))||void 0===t?void 0:t.open)??!1)&&(Po("docs"),!0)}},{key:".",run:e=>(Wo(e),!1)}];let Xo=e=>St.EditorView.updateListener.of((t=>{let n=t.state.field(Ko,!1),o=null==n?void 0:n.open;if(null==o)return;let a=o.options[o.selected],r=a.completion.apply??a.completion.label;if("string"!=typeof r)return;const i=Go(t.view,a.source);if(!(null==i?void 0:i.from))return;const s=i.from,l=Math.min(i.to,t.state.doc.length);let c=t.state.update({changes:{from:s,to:l,insert:r}}),d=zn(c.state);null!=d&&e(d)}));let Yo=e=>async t=>{let n=t.state.sliceDoc(0,t.pos),o=await e({text:n});if(!o)return null;let{start:a,stop:r,results:i}=o,s=!function(e){const t=St.syntaxTree(e.state).resolve(e.pos);return null!=t&&("TripleString"===t.name||"String"===t.name)}(t);return{from:a,to:r,filter:!1,options:i.map((([e,t,n,o,a,r])=>({label:e,apply:r&&s?r:e,detail:r??void 0})))}},Jo=e=>/^[@a-zA-Z_][a-zA-Z0-9!_]*\"?$/.test(e)?null:":"===e?`:(${e})`:`:${e}`;const ea=function*(e,t,n){let o=0;for(let[a,{valid_from:r}]of e.entries())!t.has(a)&&r<n&&(yield{label:a,type:"c_Any",boost:99-o},o+=1)},ta=e=>{const t=Yo(e),n=(e=>async t=>{let n=t.state.sliceDoc(0,t.pos),o=(e=>e.matchBefore(/\.\:[^\s"'`()\[\].]*/))(t);o&&(n=n.slice(0,o.from+1)+n.slice(o.from+2));let a=await e({text:n});if(!a)return null;let{start:r,stop:i,results:s}=a;o&&(i+=1);const l=t.state.field(Pn).definitions,c=new Set;let d="."===n.slice(0,r).slice(-1);return{from:r,to:i,options:[...s.map((([e,t,n,o,a],r)=>{let i=d?Jo(e)??e:e;return l.has(e)&&c.add(e),{label:e,apply:i,type:ve.cl({c_notexported:!n,[`c_${t}`]:null!=t,[`completion_${a}`]:null!=a,c_from_notebook:o})??void 0,boost:50-r/s.length}})),...s.filter((([e])=>d&&null!=Jo(e))).map((([e,t,n],o)=>{let a=Jo(e)??"";return{label:a,apply:a,type:(n?"":"c_notexported ")+(null==t?"":"c_"+t),boost:-99-o/s.length,is_not_exported:!n}})),...Array.from(ea(l,c,t.pos))]}})(e);return e=>{let o=(e=>e.matchBefore(/\\[^\s"'.`]*/))(e)||(e=>e.matchBefore(/~\//))(e);return null===o?n(e):t(e)}},na=async e=>{const t=await St.autocomplete.completeAnyWord(e);return null===t?null:{from:t.from,options:t.options.map((({label:e},t)=>({label:e,apply:e,type:void 0,boost:0-t})))}};let oa=({request_autocomplete:e,on_update_doc_query:t})=>{let n=null,o=null;return[Vo,zo({activateOnTyping:!1,override:[ta((async t=>{if(ce.default.isEqual(t,n)){let e=await o;if(null!=e)return e}return n=t,o=e(t),await o})),na],defaultKeymap:!1,maxRenderedOptions:512,optionClass:e=>e.type??""}),St.EditorView.updateListener.of((e=>{let t=e.state.field(Ko,!1),n=e.state.field(Vo,!1);null!=(null==t?void 0:t.open)&&n&&"active"===Ho(e.state)&&1===t.open.options.length&&((e,t)=>{let n=t.completion.apply||t.completion.label,o=Go(e,t.source);(null==o?void 0:o.from)&&("string"==typeof n?e.dispatch({changes:{from:o.from,to:o.to,insert:n},selection:{anchor:o.from+n.length},userEvent:"input.complete"}):n(e,t.completion,o.from,o.to))})(e.view,t.open.options[0])})),St.EditorView.updateListener.of((e=>{for(let n of e.transactions){var t;let o=n.annotation(St.autocomplete.pickedCompletion);o&&"string"==typeof o.apply&&o.apply.endsWith("/")&&(null===(t=o.type)||void 0===t?void 0:t.match(/(^| )completion_path( |$)/))&&St.autocomplete.startCompletion(e.view)}})),Xo(t),St.keymap.of(Qo),St.keymap.of(qo)]};ce=r("9Ta4i"),St=r("hiQgq"),io=r("1gqBQ"),ce=r("9Ta4i"),i=r("cNaMA");const aa=e=>null==e?[null]:Object.entries(e).flat(),ra=({nbpkg:e,package_name:t,available_versions:n,is_disable_pkg:o})=>{let a="error",r="error",s=i.html`error`,l=!1;const c=(null==e?void 0:e.installed_versions[t])??null,d=(null==e?void 0:e.waiting_for_permission)??!1,u=!d&&(((null==e?void 0:e.busy_packages)??[]).includes(t)||!((null==e?void 0:e.instantiated)??1));if(o){const e=t;a="disable_pkg",r=`${e} disables Pluto's built-in package manager.`,s=i.html`<b>${e}</b> disables Pluto's built-in package manager.`}else null!=c||ce.default.isEqual(n,["stdlib"])?null==c||"stdlib"===c?(a="installed",r=`${t} is part of Julia's pre-installed 'standard library'.`,s=i.html`<b>${t}</b> is part of Julia's pre-installed <em>standard library</em>.`):d?(a="will_be_installed",r=`${t} (v${ce.default.last(n)}) will be installed when you run this notebook.`,s=i.html`<header><b>${t}</b> <pkg-version>v${ce.default.last(n)}</pkg-version></header>
will be installed when you run this notebook.`):u?(a="busy",r=`${t} (v${c}) is installing...`,s=i.html`<header><b>${t}</b> <pkg-version>v${c}</pkg-version></header>
is installing...`):(a="installed",r=`${t} (v${c}) is installed in the notebook.`,s=i.html`<header><b>${t}</b> <pkg-version>v${c}</pkg-version></header>
is installed in the notebook.`,m=n,l=!("stdlib"===(p=c)||!ce.default.isArray(m))&&ce.default.last(m)!==p):null!=n&&ce.default.isArray(n)&&(0===n.length?(a="not_found",r=`The package "${t}" could not be found in the registry. Did you make a typo?`,s=i.html`The package <em>"${t}"</em> could not be found in the registry.
<section><em>Did you make a typo?</em></section>`):(a="will_be_installed",r=`${t} (v${ce.default.last(n)}) will be installed in the notebook when you run this cell.`,s=i.html`<header><b>${t}</b> <pkg-version>v${ce.default.last(n)}</pkg-version></header>
will be installed in the notebook when you run this cell.`));var p,m;return{status:a,hint:s,hint_raw:r,available_versions:n,chosen_version:c,busy:u,offer_update:l}},ia=({package_name:e,pluto_actions:t,notebook_id:n,nbpkg:o})=>{const[a,r]=i.useState(null);i.useEffect((()=>{(t.get_avaible_versions({package_name:e,notebook_id:n})??Promise.resolve([])).then((e=>{r(e)}))}),[e]);const{status:s,hint_raw:l}=ra({nbpkg:o,package_name:e,is_disable_pkg:!1,available_versions:a});return i.html`
<pkg-status-mark
title=${l}
className=${"busy"===s?"busy":"installed"===s?"installed":"not_found"===s?"not_found":"will_be_installed"===s?"will_be_installed":""}
>
<button
onClick=${t=>{io.open_pluto_popup({type:"nbpkg",source_element:t.currentTarget.parentElement,package_name:e,is_disable_pkg:!1,should_focus:!0})}}
>
<span></span>
</button>
</pkg-status-mark>
`},sa=({package_name:e})=>{const{hint_raw:t}=ra({nbpkg:null,package_name:e,is_disable_pkg:!0,available_versions:null});return i.html`
<pkg-status-mark title=${t} class="disable_pkg">
<button
onClick=${t=>{io.open_pluto_popup({type:"nbpkg",source_element:t.currentTarget.parentElement,package_name:e,is_disable_pkg:!0,should_focus:!0})}}
>
<span></span>
</button>
</pkg-status-mark>
`};i=r("cNaMA"),i=r("cNaMA"),St=r("hiQgq");class la extends St.WidgetType{constructor(e){super(),this.element=e}eq(e){return!1}toDOM(){let e=document.createElement("span");return i.render(this.element,e),e}updateDOM(e){return i.render(this.element,e),!0}}const ca=["Pkg.activate","Pkg.API.activate","Pkg.develop","Pkg.API.develop","Pkg.add","Pkg.API.add","quickactivate","@quickactivate"];function da(e,{pluto_actions:t,notebook_id:n,nbpkg:o}){let a=new Set,r=e.visibleRanges.flatMap((({from:r,to:s})=>{let l=function({doc:e,tree:t,from:n,to:o}){let a=0,r=[];return function({tree:e,enter:t,leave:n,from:o=0,to:a=e.length}){let r=e.cursor();for(;;){let e=!1;if(r.from<=a&&r.to>=o&&(r.type.isAnonymous||!1!==t(r))){if(r.firstChild())continue;r.type.isAnonymous||(e=!0)}for(;e&&n&&n(r),e=r.type.isAnonymous,!r.nextSibling();){if(!r.parent())return;e=!0}}}({tree:t,from:n,to:o,enter:t=>{if("QuoteExpression"!==t.name&&"QuoteStatement"!==t.name||a++,"InterpolationExpression"===t.name&&a--,0!==a)return;if("CallExpression"===t.name||"MacroExpression"===t.name){let n=t.node.firstChild,o=e.sliceString(n.from,n.to);return void(ca.includes(o)&&r.push({type:"package_disabler",name:o,from:t.to,to:t.to}))}let n=hn((e=>on`import A, ${e}`)),o=e=>{let t=null;return(t=n(rn`${un.as("package")}.${un.any}`).match(e))?o(t.package):(t=n(rn`.${un.maybe(un.any)}`).match(e))?null:(t=n(rn`${un.Identifier}`).match(e))?e:void console.warn("Unknown nested import specifier: "+e.toString())},i=null;if((i=sn(rn`import ${un.as("specifier")}: ${un.many()}`).match(t))??(i=sn(rn`import ${un.as("specifier")}, ${un.many("specifiers")}`).match(t))??(i=sn(rn`using ${un.as("specifier")}: ${un.many()}`).match(t))??(i=sn(rn`using ${un.as("specifier")}, ${un.many("specifiers")}`).match(t))){let{specifier:a,specifiers:s=[]}=i;a&&(s=[{node:a},...s]);for(let{node:t}of s){t=mn(t);let a=null;if(a=n(rn`${un.as("package")} as ${un.maybe(un.any)}`).match(t)){let t=o(a.package);t&&r.push({type:"package",name:e.sliceString(t.from,t.to),from:t.to,to:t.to})}else if(a=n(rn`${un.as("package")}.${un.any}`).match(t)){let t=o(a.package);t&&r.push({type:"package",name:e.sliceString(t.from,t.to),from:t.to,to:t.to})}else if(a=n(rn`.${un.as("scoped")}`).match(t));else if(a=n(rn`${un.as("package")}`).match(t)){let t=o(a.package);t&&r.push({type:"package",name:e.sliceString(t.from,t.to),from:t.to,to:t.to})}else console.warn("Unknown import specifier: "+t.toString())}if(i=null,i=sn(rn`using ${un.as("specifier")}, ${un.many("specifiers")}`).match(t)){let{specifier:t}=i;t&&("\n"!==e.sliceString(t.to,t.to+1)&&""!==e.sliceString(t.to,t.to+1)||r.push({type:"implicit_using",name:e.sliceString(t.from,t.to),from:t.to,to:t.to}))}return!1}if("ImportStatement"===t.name)throw new Error("What")},leave:e=>{"QuoteExpression"!==e.name&&"QuoteStatement"!==e.name||a--,"InterpolationExpression"===e.name&&a++}}),r}({doc:e.state.doc,tree:St.syntaxTree(e.state),from:r,to:s});return l.map((e=>{if("package"===e.type){let{name:r}=e;if("Base"!==r&&"Core"!==r&&!a.has(r)){return a.add(r),St.Decoration.widget({widget:new la(i.html`
<${ia}
key=${r}
package_name=${r}
pluto_actions=${t}
notebook_id=${n}
nbpkg=${o}
/>
`),side:1}).range(e.to)}}else{if("package_disabler"===e.type){return St.Decoration.widget({widget:new la(i.html` <${sa} package_name=${e.name} /> `),side:1}).range(e.to)}if("implicit_using"===e.type&&"HypertextLiteral"===e.name){return St.Decoration.widget({widget:new la(i.html`<span style=${{position:"relative"}}>
<div
style=${{position:"absolute",display:"inline",left:0,whiteSpace:"nowrap",opacity:.3,pointerEvents:"none"}}
>
: @htl, @htl_str
</div>
</span>`),side:1}).range(e.to)}}}))})).filter((e=>null!=e));return St.Decoration.set(r,!0)}const ua=St.Facet.define({combine:e=>e[0],compare:ce.default.isEqual}),pa=({pluto_actions:e,notebook_id_ref:t})=>St.ViewPlugin.fromClass(class{update_decos(n){const o=da(n,{pluto_actions:e,notebook_id:t.current,nbpkg:n.state.facet(ua)});this.decorations=o}constructor(e){this.update_decos(e)}update(e){(e.docChanged||e.viewportChanged||e.state.facet(ua)!==e.startState.facet(ua))&&this.update_decos(e.view)}},{decorations:e=>e.decorations});ce=r("9Ta4i"),St=r("hiQgq"),i=r("cNaMA");const ma=St.StateEffect.define({}),ga=St.StateField.define({create:()=>({defaultCharacterWidth:null,measuredSpaceWidth:null,measuredTabWidth:null}),update(e,t){for(let e of t.effects)if(e.is(ma))return e.value;return e}});let ha=St.EditorView.updateListener.of((e=>{let t=e.view.defaultCharacterWidth,{defaultCharacterWidth:n,measuredSpaceWidth:o}=e.view.state.field(ga,!1);if(n!==t){let n,o;e.view.dispatch({effects:[ma.of({defaultCharacterWidth:t,measuredSpaceWidth:n,measuredTabWidth:o})]})}})),fa=St.StateField.define({create:()=>St.Decoration.none,update(e,t){let n=t.startState.field(ga,!1),o=n.measuredSpaceWidth??n.defaultCharacterWidth,{measuredSpaceWidth:a,defaultCharacterWidth:r}=t.state.field(ga,!1),s=a??r;if(null==s)return St.Decoration.none;if(!t.docChanged&&e!==St.Decoration.none&&o===s)return e;let l=[];for(let e of ce.default.range(0,t.state.doc.lines)){let n=t.state.doc.line(e+1);if(0===n.length)continue;let o=0;for(let e of n.text){if("\t"!==e)break;o++}const a=Math.min(o,12),r=4*a*s,c=St.Decoration.line({attributes:{style:`--indented: ${r}px;`,class:"awesome-wrapping-plugin-the-line"}});if(l.push(c.range(n.from,n.from)),0!==a&&l.push(St.Decoration.mark({class:"awesome-wrapping-plugin-the-tabs"}).range(n.from,n.from+a)),o>a)for(let e of ce.default.range(a,o))l.push(St.Decoration.replace({widget:new la(i.html`<span style=${{opacity:.2}}>โฅ </span>`),block:!1}).range(n.from+e,n.from+e+1))}return St.Decoration.set(l)},provide:e=>St.EditorView.decorations.from(e)}),_a=St.Decoration.mark({class:"indentation-so-dont-break"}),ba=(St.StateField.define({create:()=>St.Decoration.none,update(e,t){let n=[];for(const e of t.newDoc)for(const t of e.matchAll(/[^ \t]+([ \t]|$)+/g))null!=t.index&&0!==t.index&&n.push(_a.range(0+t.index,0+t.index+t[0].length));return St.Decoration.set(n,!0)},provide:e=>St.EditorView.decorations.from(e)}),[ga,ha,fa]);let va=(St=r("hiQgq")).autocomplete.autocompletion()[0],ya=St.EditorView.domEventHandlers({keydown:(e,t)=>{var n;let o=t.state.selection.main;if(!o.empty)return!1;if(!e.repeat)return!1;if("Backspace"===e.key&&0===t.state.doc.length)return!0;if("Delete"===e.key&&0===t.state.doc.length)return!0;let a=(null===(n=t.state.field(va,!1))||void 0===n?void 0:n.open)??!1;return"ArrowUp"!==e.key||a?"ArrowDown"!==e.key||a?"ArrowLeft"===e.key&&e.repeat?!!t.moveByChar(o,!1).eq(o):"ArrowRight"===e.key?!!t.moveByChar(o,!0).eq(o):void 0:!!t.moveVertically(t.state.selection.main,!0).eq(o):!!t.moveVertically(t.state.selection.main,!1).eq(o)}}),wa=({focus_on_neighbor:e})=>(({focus_on_neighbor:e})=>St.keymap.of([{key:"PageUp",run:()=>(e({cell_delta:-1,line:0,character:0}),!0)},{key:"PageDown",run:()=>(e({cell_delta:1,line:0,character:0}),!0)},{key:"ArrowLeft",run:t=>{let n=t.state.selection.main;return!!n.empty&&!!t.moveByChar(n,!1).eq(n)&&(e({cell_delta:-1,line:1/0,character:1/0}),!0)}},{key:"ArrowUp",run:t=>{let n=t.state.selection.main;return!!n.empty&&!!t.moveVertically(n,!1).eq(n)&&(e({cell_delta:-1,line:1/0,character:1/0}),!0)}},{key:"ArrowRight",run:t=>{let n=t.state.selection.main;return!!n.empty&&!!t.moveByChar(n,!0).eq(n)&&(e({cell_delta:1,line:0,character:0}),!0)}},{key:"ArrowDown",run:t=>{let n=t.state.selection.main;return!!n.empty&&!!t.moveVertically(n,!0).eq(n)&&(e({cell_delta:1,line:0,character:0}),!0)}}]))({focus_on_neighbor:e});St=r("hiQgq");let ka=({pluto_actions:e,cell_id:t})=>St.EditorView.domEventHandlers({paste:(n,o)=>{if(!o.hasFocus)return console.log("CodeMirror, why are you registring this paste? You aren't focused!"),!0;n.stopPropagation();const a=n.clipboardData.getData("text/plain"),r=_e(a);return null!=r&&(0===o.state.selection.main.from&&o.state.selection.main.to===o.state.doc.length?(e.add_deserialized_cells(a,t,r),e.confirm_delete_multiple("This Should Never Be Visible",[t]),!0):(o.state.selection.main.to===o.state.doc.length||0===o.state.selection.main.from)&&(e.add_deserialized_cells(a,t,r),!0))}});St=r("hiQgq"),St=r("hiQgq"),St=r("hiQgq");function Ea(e){var t,n,o;let a=e.parent.firstChild,r=e.parent.lastChild;if(!("end"===r.name))return null;let i=null===(t=e.parent.getChild("CatchClause"))||void 0===t?void 0:t.firstChild,s=null===(n=e.parent.getChild("TryElseClause"))||void 0===n?void 0:n.firstChild,l=null===(o=e.parent.getChild("FinallyClause"))||void 0===o?void 0:o.firstChild;return[{from:a.from,to:a.to},i&&{from:i.from,to:i.to},s&&{from:s.from,to:s.to},l&&{from:l.from,to:l.to},{from:r.from,to:r.to}].filter((e=>null!=e))}const $a=(St=r("hiQgq")).EditorView.baseTheme({".cm-matchingBracket":{backgroundColor:"#328c8252"},".cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),xa=St.Facet.define({combine:e=>St.combineConfig(e,{afterCursor:!0,brackets:"()[]{}",maxScanDistance:1e4})}),Sa=St.Decoration.mark({class:"cm-matchingBracket"}),Na=(St.Decoration.mark({class:"cm-nonmatchingBracket"}),[St.StateField.define({create:()=>St.Decoration.none,update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],o=t.state.facet(xa);for(let e of t.state.selection.ranges){if(!e.empty)continue;let a=Aa(t.state,e.head,-1,o)||e.head>0&&Aa(t.state,e.head-1,1,o)||o.afterCursor&&(Aa(t.state,e.head,1,o)||e.head<t.state.doc.length&&Aa(t.state,e.head+1,-1,o));if(!a)continue;let r=Sa;for(let e of a)n.push(r.range(e.from,e.to))}return St.Decoration.set(n,!0)},provide:e=>St.EditorView.decorations.from(e)}),$a]);function Ca(e={}){return[xa.of(e),Na]}function Aa(e,t,n,o={}){let a=o.maxScanDistance||1e4,r=o.brackets||"()[]{}",i=St.syntaxTree(e),s=i.resolveInner(t,n),l=function(e){var t,n;if("end"===e.name&&(e="IfStatement"===e.parent.name?null===(t=e.parent)||void 0===t||null===(n=t.firstChild)||void 0===n?void 0:n.firstChild:e.parent.firstChild),null==e)return[];if("mutable"===e.name||"struct"===e.name){"struct"===e.name&&(e=e.parent.firstChild);let t=e.parent.getChild("struct"),n=e.parent.lastChild;return"end"===n.name&&t?[{from:e.from,to:t.to},{from:n.from,to:n.to}]:null}if("struct"===e.name){let t=e.parent.lastChild;return"end"===t.name?[{from:e.from,to:e.to},{from:t.from,to:t.to}]:null}if("quote"===e.name){let t=e.parent.lastChild;return"end"===t.name?[{from:e.from,to:e.to},{from:t.from,to:t.to}]:null}if("begin"===e.name){let t=e.parent.lastChild;return"end"===t.name?[{from:e.from,to:e.to},{from:t.from,to:t.to}]:null}if("do"===e.name){let t=e.parent.lastChild;return"end"===t.name?[{from:e.from,to:e.to},{from:t.from,to:t.to}]:null}if("for"===e.name){let t=e.parent.lastChild;return"end"===t.name?[{from:e.from,to:e.to},{from:t.from,to:t.to}]:null}if("let"===e.name){let t=e.parent.lastChild;return"end"===t.name?[{from:e.from,to:e.to},{from:t.from,to:t.to}]:null}if("macro"===e.name){let t=e.parent.lastChild;return"end"===t.name?[{from:e.from,to:e.to},{from:t.from,to:t.to}]:null}if("function"===e.name){let t=e.parent.lastChild;return"end"===t.name?[{from:e.from,to:e.to},{from:t.from,to:t.to}]:null}if("while"===e.name){let t=e.parent.lastChild;return"end"===t.name?[{from:e.from,to:e.to},{from:t.from,to:t.to}]:null}if("type"===e.name&&(e=e.parent.firstChild),"abstract"===e.name||"primitive"===e.name){let t=e.parent.lastChild,n="end"===t.name,o=e.parent.getChild("type");return n&&o?[{from:e.from,to:o.to},{from:t.from,to:t.to}]:null}if("if"===e.name||"else"===e.name||"elseif"===e.name){"if"===e.name&&(e=e.parent);let t=!1;"else"===e.name&&(e=e.parent,t=!0),"elseif"===e.name&&(e=e.parent.parent);let n=e.parent.firstChild,o=e.parent.lastChild;if("end"!==o.name)return null;if(t&&"try"===n.name)return Ea(e);let a=[];a.push({from:n.from,to:n.to});for(let t of e.parent.getChildren("ElseifClause")){let e=t.firstChild;a.push({from:e.from,to:e.to})}for(let t of e.parent.getChildren("ElseClause")){let e=t.firstChild;a.push({from:e.from,to:e.to})}return a.push({from:o.from,to:o.to}),a}if("try"===e.name||"catch"===e.name||"finally"===e.name||"else"===e.name)return"catch"===e.name&&(e=e.parent),"finally"===e.name&&(e=e.parent),"else"===e.name&&(e=e.parent),"end"===e.parent.lastChild.name?Ea(e):null;if("module"===e.name||"baremodule"===e.name){let t=e.parent.lastChild;return"end"===t.name?[{from:e.from,to:e.to},{from:t.from,to:t.to}]:null}return null}(s);return l||function(e,t,n,o,a,r,i){let s=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),l=i.indexOf(s);if(l<0||l%2==0!=n>0)return null;let c={from:n<0?t-1:t,to:n>0?t+1:t},d=e.doc.iterRange(t,n>0?e.doc.length:0),u=0;for(let e=0;!d.next().done&&e<=r;){let r=d.value;n<0&&(e+=r.length);let s=t+e*n;for(let e=n>0?0:r.length-1,t=n>0?r.length:-1;e!=t;e+=n){let t=i.indexOf(r[e]);if(!(t<0||o.resolve(s+e,1).type!=a))if(t%2==0==n>0)u++;else{if(1==u)return t>>1==l>>1?[c,{from:s+e,to:s+e+1}]:null;u--}}n>0&&(e+=r.length)}return d.done?[c]:null}(e,t,n,i,s.type,a,r)}ve=r("aN0pg");const Ma=(St=r("hiQgq")).Decoration.line({attributes:{class:"cm-highlighted-line"}}),Oa=St.Decoration.mark({attributes:{class:"cm-highlighted-range"}});const Ta=St.Facet.define({combine:e=>e[0],compare:(e,t)=>e===t}),Ra=St.Facet.define({combine:e=>e[0],compare:(e,t)=>e===t}),Da=()=>St.ViewPlugin.fromClass(class{updateDecos(e){this.decorations=function(e){let t=e.state.facet(Ta);if(null==t||null==t||t<0||t>e.state.doc.lines)return St.Decoration.set([]);let n=e.state.doc.line(t);return St.Decoration.set([Ma.range(n.from,n.from)])}(e)}constructor(e){this.decorations=St.Decoration.set([]),this.updateDecos(e)}update(e){(e.docChanged||e.state.facet(Ta)!==e.startState.facet(Ta))&&this.updateDecos(e.view)}},{decorations:e=>e.decorations}),La=()=>St.ViewPlugin.fromClass(class{updateDecos(e){this.decorations=function(e){let t=e.state.facet(Ra);if(null==t)return St.Decoration.set([]);let{from:n,to:o}=t;return n<0||n==o?St.Decoration.set([]):St.Decoration.set([Oa.range(n,o)])}(e)}constructor(e){this.decorations=St.Decoration.set([]),this.updateDecos(e)}update(e){(e.docChanged||e.state.facet(Ra)!==e.startState.facet(Ra))&&this.updateDecos(e.view)}},{decorations:e=>e.decorations});St=r("hiQgq");function Ia(e,t){return({state:n,dispatch:o})=>{if(n.readOnly)return!1;let a=e(t,n.selection.ranges,n);return!!a&&(o(n.update(a)),!0)}}const Pa=Ia(za,0),ja=(Ia(za,1),Ia(za,2),Ia(Fa,0)),Ba=(Ia(Fa,1),Ia(Fa,2),[{key:"Mod-/",run:e=>{let t=Ua(e.state);return t.line?Pa(e):!!t.block&&ja(e)}},{key:"Alt-A",run:ja}]);function Ua(e,t=e.selection.main.head){let n=e.languageDataAt("commentTokens",t);return n.length?n[0]:{}}function Fa(e,t,n){let o=t.map((e=>Ua(n,e.from).block));if(!o.every((e=>e)))return null;let a=t.map(((e,t)=>function(e,{open:t,close:n},o,a){let r,i,s=e.sliceDoc(o-50,o),l=e.sliceDoc(a,a+50),c=/\s*$/.exec(s)[0].length,d=/^\s*/.exec(l)[0].length,u=s.length-c;if(s.slice(u-t.length,u)==t&&l.slice(d,d+n.length)==n)return{open:{pos:o-c,margin:c&&1},close:{pos:a+d,margin:d&&1}};a-o<=100?r=i=e.sliceDoc(o,a):(r=e.sliceDoc(o,o+50),i=e.sliceDoc(a-50,a));let p=/^\s*/.exec(r)[0].length,m=/\s*$/.exec(i)[0].length,g=i.length-m-n.length;return r.slice(p,p+t.length)==t&&i.slice(g,g+n.length)==n?{open:{pos:o+p+t.length,margin:/\s/.test(r.charAt(p+t.length))?1:0},close:{pos:a-m-n.length,margin:/\s/.test(i.charAt(g-1))?1:0}}:null}(n,o[t],e.from,e.to)));if(2!=e&&!a.every((e=>e))){let e=0;return n.changeByRange((t=>{let{open:n,close:r}=o[e++];if(a[e])return{range:t};let i=n.length+1;return{changes:[{from:t.from,insert:n+" "},{from:t.to,insert:" "+r}],range:St.EditorSelection.range(t.anchor+i,t.head+i)}}))}if(1!=e&&a.some((e=>e))){let e=[];for(let t,n=0;n<a.length;n++)if(t=a[n]){let a=o[n],{open:r,close:i}=t;e.push({from:r.pos-a.open.length,to:r.pos+r.margin},{from:i.pos-i.margin,to:i.pos+a.close.length})}return{changes:e}}return null}function za(e,t,n){let o=[],a=-1;for(let{from:e,to:r}of t){let t=Ua(n,e).line,i=t===Ua(n,r).line?t:null,s=o.length,l=1e9;for(let t=e;t<=r;){let s=n.doc.lineAt(t);if(s.from>a&&(e==r||r>s.from)){a=s.from;let e=i??Ua(n,t).line;if(!e)continue;let r=/^\s*/.exec(s.text)[0].length,c=r==s.length,d=s.text.slice(r,r+e.length)==e?r:-1;r<s.text.length&&r<l&&(l=r),o.push({line:s,comment:d,token:e,indent:r,empty:c,single:!1})}t=s.to+1}if(l<1e9)for(let e=s;e<o.length;e++)o[e].indent<o[e].line.text.length&&(o[e].indent=l);o.length==s+1&&(o[s].single=!0)}if(2!=e&&o.some((e=>e.comment<0&&(!e.empty||e.single)))){let e=[];for(let{line:t,token:n,indent:a,empty:r,single:i}of o)!i&&r||e.push({from:t.from+a,insert:n+" "});let t=n.changes(e);return{changes:t,selection:n.selection.map(t,1)}}if(1!=e&&o.some((e=>e.comment>=0))){let e=[];for(let{line:t,comment:n,token:a}of o)if(n>=0){let o=t.from+n,r=o+a.length;" "==t.text[r-t.from]&&r++,e.push({from:o,to:r})}return{changes:e}}return null}St=r("hiQgq");let qa={key:"Mod-d",run:({state:e,dispatch:t})=>{if(e.selection.main.empty){var n,o;let a=["Identifier","FieldName"],r=St.syntaxTree(e).cursorAt(e.selection.main.from,-1),i=St.syntaxTree(e).cursorAt(e.selection.main.from,1);for(let e of a){let n=r.name===e?r:i.name===e?i:null;if(n)return t({selection:{anchor:n.from,head:n.to}}),!0}let s=e.doc.lineAt(e.selection.main.from),l=e.selection.main.from-s.from,c=s.text.slice(0,l),d=s.text.slice(l),u=(null===(n=c.match(/(\w+)$/))||void 0===n?void 0:n[0])??"",p=(null===(o=d.match(/^(\w+)/))||void 0===o?void 0:o[0])??"";t({selection:{anchor:e.selection.main.from-u.length,head:e.selection.main.from+p.length}})}else St.selectNextOccurrence({state:e,dispatch:t});return!1},shift:({state:e,dispatch:t})=>{if(1===e.selection.ranges.length)return!1;let n=e.selection.ranges.at(e.selection.mainIndex-1),o=e.selection.ranges.filter((e=>e!==n)),a=o.indexOf(e.selection.main),r=(i=o,s=e.selection.mainIndex-1,i.slice(s,s+1)[0]);var i,s;return t({selection:St.EditorSelection.create(o,a),effects:null==r?[]:St.EditorView.scrollIntoView(r.from)}),!0},preventDefault:!0};de=r("4zMEb");var Ha=r("aTIpG");Io=r("hrGZZ"),St=r("hiQgq");const Wa="true"===window.localStorage.getItem("ENABLE_CM_MIXED_PARSER"),Ga="true"===window.localStorage.getItem("ENABLE_CM_SPELLCHECK");Wa&&console.log("YOU ENABLED THE CODEMIRROR MIXED LANGUAGE PARSER\nThanks! Awesome!\nPlease let us know if you find any bugs...\nIf enough people do this, we can make it the default parser.\n"),window.PLUTO_TOGGLE_CM_MIXED_PARSER=(e=!Wa)=>{window.localStorage.setItem("ENABLE_CM_MIXED_PARSER",String(e)),window.location.reload()},window.PLUTO_TOGGLE_CM_SPELLCHECK=(e=!Ga)=>{window.localStorage.setItem("ENABLE_CM_SPELLCHECK",String(e)),window.location.reload()};const Ka=St.HighlightStyle.define([{tag:St.tags.propertyName,color:"var(--cm-property-color)"},{tag:St.tags.unit,color:"var(--cm-tag-color)"},{tag:St.tags.literal,color:"var(--cm-builtin-color)",fontWeight:700},{tag:St.tags.macroName,color:"var(--cm-macro-color)",fontWeight:700},{tag:St.tags.special(St.tags.brace),color:"var(--cm-macro-color)",fontWeight:700},{tag:St.tags.standard(St.tags.variableName),color:"var(--cm-builtin-color)",fontWeight:700},{tag:St.tags.bool,color:"var(--cm-builtin-color)",fontWeight:700},{tag:St.tags.keyword,color:"var(--cm-keyword-color)"},{tag:St.tags.comment,color:"var(--cm-comment-color)",fontStyle:"italic"},{tag:St.tags.atom,color:"var(--cm-atom-color)"},{tag:St.tags.number,color:"var(--cm-number-color)"},{tag:St.tags.keyword,color:"var(--cm-keyword-color)"},{tag:St.tags.string,color:"var(--cm-string-color)"},{tag:St.tags.variableName,color:"var(--cm-var-color)",fontWeight:700},{tag:St.tags.typeName,color:"var(--cm-type-color)",fontStyle:"italic"},{tag:St.tags.typeOperator,color:"var(--cm-type-color)",fontStyle:"italic"},{tag:St.tags.bracket,color:"var(--cm-bracket-color)"},{tag:St.tags.brace,color:"var(--cm-bracket-color)"},{tag:St.tags.tagName,color:"var(--cm-tag-color)"},{tag:St.tags.link,color:"var(--cm-link-color)"},{tag:St.tags.invalid,color:"var(--cm-error-color)",background:"var(--cm-error-bg-color)"}],{all:{color:"var(--cm-editor-text-color)"},scope:St.julia_andrey().language}),Za=St.HighlightStyle.define([{tag:St.tags.propertyName,color:"var(--cm-property-color)"},{tag:St.tags.unit,color:"var(--cm-tag-color)"},{tag:St.tags.literal,color:"var(--cm-builtin-color)",fontWeight:700},{tag:St.tags.macroName,color:"var(--cm-macro-color)",fontWeight:700},{tag:St.tags.standard(St.tags.variableName),color:"var(--cm-builtin-color)",fontWeight:700},{tag:St.tags.bool,color:"var(--cm-builtin-color)",fontWeight:700},{tag:St.tags.keyword,color:"var(--cm-keyword-color)"},{tag:St.tags.atom,color:"var(--cm-atom-color)"},{tag:St.tags.number,color:"var(--cm-number-color)"},{tag:St.tags.keyword,color:"var(--cm-keyword-color)"},{tag:St.tags.string,color:"var(--cm-string-color)"},{tag:St.tags.variableName,color:"var(--cm-var-color)",fontWeight:700},{tag:St.tags.typeName,color:"var(--cm-type-color)",fontStyle:"italic"},{tag:St.tags.typeOperator,color:"var(--cm-type-color)",fontStyle:"italic"},{tag:St.tags.bracket,color:"var(--cm-bracket-color)"},{tag:St.tags.brace,color:"var(--cm-bracket-color)"},{tag:St.tags.tagName,color:"var(--cm-tag-color)"},{tag:St.tags.link,color:"var(--cm-link-color)"},{tag:St.tags.invalid,color:"var(--cm-error-color)",background:"var(--cm-error-bg-color)"},{tag:St.tags.comment,color:"var(--cm-comment-color)",fontStyle:"italic",filter:"none"}],{scope:St.javascriptLanguage,all:{color:"var(--cm-editor-text-color)",filter:"contrast(0.5)"}}),Va=St.HighlightStyle.define([{tag:St.tags.propertyName,color:"var(--cm-property-color)"},{tag:St.tags.unit,color:"var(--cm-tag-color)"},{tag:St.tags.literal,color:"var(--cm-builtin-color)",fontWeight:700},{tag:St.tags.macroName,color:"var(--cm-macro-color)",fontWeight:700},{tag:St.tags.standard(St.tags.variableName),color:"var(--cm-builtin-color)",fontWeight:700},{tag:St.tags.bool,color:"var(--cm-builtin-color)",fontWeight:700},{tag:St.tags.keyword,color:"var(--cm-keyword-color)"},{tag:St.tags.comment,color:"var(--cm-comment-color)",fontStyle:"italic"},{tag:St.tags.atom,color:"var(--cm-atom-color)"},{tag:St.tags.number,color:"var(--cm-number-color)"},{tag:St.tags.keyword,color:"var(--cm-keyword-color)"},{tag:St.tags.string,color:"var(--cm-string-color)"},{tag:St.tags.variableName,color:"var(--cm-var-color)",fontWeight:700},{tag:St.tags.typeName,color:"var(--cm-type-color)",fontStyle:"italic"},{tag:St.tags.typeOperator,color:"var(--cm-type-color)",fontStyle:"italic"},{tag:St.tags.bracket,color:"var(--cm-bracket-color)"},{tag:St.tags.brace,color:"var(--cm-bracket-color)"},{tag:St.tags.tagName,color:"var(--cm-tag-color)"},{tag:St.tags.link,color:"var(--cm-link-color)"},{tag:St.tags.invalid,color:"var(--cm-error-color)",background:"var(--cm-error-bg-color)"}],{scope:St.pythonLanguage,all:{color:"var(--cm-editor-text-color)",filter:"contrast(0.5)"}}),Qa=St.HighlightStyle.define([{tag:St.tags.propertyName,color:"var(--cm-css-accent-color)",fontWeight:700},{tag:St.tags.variableName,color:"var(--cm-css-accent-color)",fontWeight:700},{tag:St.tags.definitionOperator,color:"var(--cm-css-color)"},{tag:St.tags.keyword,color:"var(--cm-css-color)"},{tag:St.tags.modifier,color:"var(--cm-css-accent-color)"},{tag:St.tags.punctuation,opacity:.5},{tag:St.tags.literal,color:"var(--cm-css-color)"},{tag:St.tags.tagName,color:"var(--cm-css-color)",fontWeight:700},{tag:St.tags.className,color:"var(--cm-css-why-doesnt-codemirror-highlight-all-the-text-aaa)"},{tag:St.tags.constant(St.tags.className),color:"var(--cm-css-why-doesnt-codemirror-highlight-all-the-text-aaa)"},{tag:St.tags.comment,color:"var(--cm-comment-color)",fontStyle:"italic"}],{scope:St.cssLanguage,all:{color:"var(--cm-css-color)"}}),Xa=St.HighlightStyle.define([{tag:St.tags.tagName,color:"var(--cm-html-accent-color)",fontWeight:600},{tag:St.tags.attributeName,color:"var(--cm-html-accent-color)",fontWeight:600},{tag:St.tags.attributeValue,color:"var(--cm-html-accent-color)"},{tag:St.tags.angleBracket,color:"var(--cm-html-accent-color)",fontWeight:600,opacity:.7},{tag:St.tags.content,color:"var(--cm-html-color)",fontWeight:400},{tag:St.tags.documentMeta,color:"var(--cm-html-accent-color)"},{tag:St.tags.comment,color:"var(--cm-comment-color)",fontStyle:"italic"}],{scope:St.htmlLanguage,all:{color:"var(--cm-html-color)"}}),Ya=St.HighlightStyle.define([{tag:St.tags.content,color:"var(--cm-md-color)"},{tag:St.tags.quote,color:"var(--cm-md-color)"},{tag:St.tags.link,textDecoration:"underline"},{tag:St.tags.url,color:"var(--cm-md-color)",textDecoration:"none"},{tag:St.tags.emphasis,fontStyle:"italic"},{tag:St.tags.strong,fontWeight:"bolder"},{tag:St.tags.heading,color:"var(--cm-md-color)",fontWeight:700},{tag:St.tags.comment,color:"var(--cm-comment-color)",fontStyle:"italic"},{tag:St.tags.processingInstruction,color:"var(--cm-md-accent-color) !important",opacity:"0.5"},{tag:St.tags.monospace,color:"var(--cm-md-accent-color)"}],{scope:St.markdownLanguage,all:{color:"var(--cm-md-color)"}}),Ja=e=>e.state.doc.toString(),er=(e,t)=>e.dispatch({changes:{from:0,to:e.state.doc.length,insert:t}}),tr=(e,t,n,o)=>e.dispatch({changes:{from:n,to:o,insert:t}});let nr=(e,t)=>{let n=i.useRef(new St.Compartment),o=i.useRef(n.current.of(t));return i.useLayoutEffect((()=>{var o,a;null===(o=e.current)||void 0===o||null===(a=o.dispatch)||void 0===a||a.call(o,{effects:n.current.reconfigure(t)})}),[t]),o.current},or=(e,{line:t,ch:n})=>{let o=e.line(ce.default.clamp(t+1,1,e.lines)),a=ce.default.clamp(n,0,o.length);return o.from+a};const ar=({local_code:e,remote_code:t,disable_input:n,focus_after_creation:o,cm_forced_focus:a,set_cm_forced_focus:r,show_input:s,on_submit:l,on_delete:c,on_add_after:d,on_change:u,on_update_doc_query:p,on_focus_neighbor:m,on_line_heights:g,nbpkg:h,cell_id:f,notebook_id:_,any_logs:b,show_logs:v,set_show_logs:y,set_cell_disabled:w,cm_highlighted_line:k,cm_highlighted_range:E,metadata:$,global_definition_locations:x,cm_diagnostics:S})=>{let N=i.useContext(ye);const{disabled:C,skip_as_script:A}=$;let[M,O]=i.useState(null);if(M){const e=M;throw O(null),e}const T=i.useRef(_);T.current=_;const R=i.useRef(null),D=i.useRef(null),L=i.useRef(null);let I=nr(R,ua.of(h)),P=nr(R,Wn.of(x)),j=nr(R,Ta.of(k)),B=nr(R,Ra.of(E)),U=nr(R,St.EditorState.readOnly.of(n)),F=nr(R,i.useMemo((()=>St.EditorView.updateListener.of((e=>{e.docChanged&&u(e.state.doc.toString())}))),[u]));return i.useLayoutEffect((()=>{if(null==D.current)return;const t=e=>((async e=>{await e()})((async()=>{await d();e.state.doc.toString()!==L.current&&l()})),!0);let n=St.autocomplete.completionKeymap.find((e=>"Enter"===e.key));const a=()=>{const e=R.current,t=Ja(e),n=t.trim(),o=t.length-t.trimStart().length;if(console.table({value:t,trimmed:n,offset:o}),n.startsWith('md"')&&n.endsWith('"')){let t,a;if(n.startsWith('md"""')&&n.endsWith('"""')?(t=5,a=n.length-3):(t=3,a=n.length-1),t>=a||""==n.substring(t,a).trim())er(e,"");else{for(;/\s/.test(n[t]);)++t;for(;/\s/.test(n[a-1]);)--a;tr(e,"",a+o,e.state.doc.length),tr(e,"",0,t+o)}}else{let t='md"""\n',n='\n"""',o=e.state.selection.main;e.dispatch({changes:[{from:0,to:0,insert:t},{from:e.state.doc.length,to:e.state.doc.length,insert:n}],selection:0===o.from?{anchor:o.from+t.length,head:o.to+t.length}:void 0})}return!0},i=e=>!e.state.facet(St.EditorState.readOnly)&&(0===e.state.doc.length&&(m(f,1),c(),!0)),s=e=>!e.state.facet(St.EditorState.readOnly)&&(0===e.state.doc.length&&(m(f,-1,1/0,1/0),c(),!0)),u=(e,t)=>{if(e.state.facet(St.EditorState.readOnly))return!1;const n=e.state.selection.main,o=0===n.anchor&&n.head===e.state.doc.length;return console.log({all_is_selected:o}),o||1===e.state.doc.lines?(N.move_remote_cells([f],N.get_notebook().cell_order.indexOf(f)+(-1===t?-1:2)),requestIdleCallback((()=>{e.dispatch({selection:{anchor:0,head:e.state.doc.length},scrollIntoView:!0}),e.focus()})),!0):1===t?St.moveLineDown(e):St.moveLineUp(e)},h=[{key:"Shift-Enter",run:()=>(l(),!0)},{key:"Ctrl-Enter",mac:"Cmd-Enter",run:t},{key:"Ctrl-Enter",run:t},{key:"Tab",run:e=>{var t;if(e.state.readOnly)return!1;if(null==n||null===(t=n.run)||void 0===t?void 0:t.call(n,e))return!0;let o=e.state.selection.main;return o.empty?(e.dispatch({changes:{from:o.from,to:o.to,insert:"\t"},selection:St.EditorSelection.cursor(o.from+1)}),!0):St.indentMore(e)},shift:St.indentLess},{key:"Ctrl-m",mac:"Cmd-m",run:a},{key:"Ctrl-m",run:a},{key:"Ctrl-M",run:a},{key:"Delete",run:i},{key:"Ctrl-Delete",run:i},{key:"Backspace",run:s},{key:"Ctrl-Backspace",run:s},{key:"Alt-ArrowUp",run:e=>u(e,-1)},{key:"Alt-ArrowDown",run:e=>u(e,1)},qa];let _=!1;const b=St.EditorView.updateListener.of((e=>{if(e.view.hasFocus&&(e.docChanged||e.selectionSet)){let t=e.state;try{let e=zn(t,_);null!=e&&p(e)}finally{}}})),v=window.matchMedia("(prefers-color-scheme: dark)").matches,y=R.current=new St.EditorView({state:St.EditorState.create({doc:e,extensions:[St.EditorView.theme({},{dark:v}),I,j,B,P,U,Da(),La(),ya,pa({pluto_actions:N,notebook_id_ref:T}),Pn,St.syntaxHighlighting(Ka),St.syntaxHighlighting(Xa),St.syntaxHighlighting(Ya),St.syntaxHighlighting(Za),St.syntaxHighlighting(Va),St.syntaxHighlighting(Qa),St.lineNumbers(),St.highlightSpecialChars(),St.history(),St.drawSelection(),St.EditorState.allowMultipleSelections.of(!0),St.EditorView.clickAddsSelectionRange.of((e=>e.altKey&&!e.shiftKey)),St.indentOnInput(),St.EditorState.languageData.of(((e,t,n)=>[{closeBrackets:{brackets:["(","[","{"]}}])),St.closeBrackets(),St.rectangularSelection({eventFilter:e=>e.altKey&&e.shiftKey&&0==e.button}),St.highlightSelectionMatches(),Ca(),b,Ha.tab_help_plugin,St.EditorView.domEventHandlers({blur:(e,t)=>{document.activeElement===t.contentDOM||(setTimeout((()=>{t.dispatch({selection:{anchor:t.state.selection.main.head},scrollIntoView:!1}),t.contentDOM.blur()}),0),r(null))}}),ka({pluto_actions:N,cell_id:f}),St.EditorView.updateListener.of((e=>{e.docChanged&&e.state.doc.length>0&&"?"===e.state.sliceDoc(0,1)&&Po("docs")})),St.EditorState.tabSize.of(4),St.indentUnit.of("\t"),...Wa?[to(),St.markdown({defaultCodeLanguage:to()}),St.html(),St.javascript(),St.python(),Qn]:[St.julia_andrey()],Gn,oa({request_autocomplete:async({text:e})=>{let t=await de.timeout_promise(N.send("complete",{query:e},{notebook_id:T.current}),5e3).catch(console.warn);if(!t)return null;let{message:n}=t;return{start:xt.utf8index_to_ut16index(e,n.start),stop:xt.utf8index_to_ut16index(e,n.stop),results:n.results}},on_update_doc_query:p}),St.keymap.of(h),St.keymap.of(Ba),wa({focus_on_neighbor:({cell_delta:e,line:t,character:n})=>m(f,e,t,n)}),St.keymap.of([...St.closeBracketsKeymap,...St.defaultKeymap,...St.historyKeymap,...St.foldKeymap]),St.placeholder("Enter cell code..."),St.EditorView.contentAttributes.of({spellcheck:String(Ga)}),St.EditorView.lineWrapping,ba,St.EditorView.updateListener.of((e=>{e.docChanged&&e.view.dispatch(St.setDiagnostics(e.state,[]))})),F,St.EditorView.exceptionSink.of((e=>{O(e),console.error("EditorView exception!",e)}))]}),parent:D.current});y.dom.CodeMirror={getValue:()=>Ja(y),setValue:e=>er(y,e)},o&&setTimeout((()=>{let e=R.current;null!=e&&(e.dom.scrollIntoView({behavior:"smooth",block:"nearest"}),e.dispatch({selection:{anchor:e.state.doc.length,head:e.state.doc.length},effects:[Ha.LastFocusWasForcedEffect.of(!0)]}),e.focus())}));const w=D.current.querySelector("div.cm-content");if(w){const e=new ResizeObserver((()=>{const e=w.children,t=ce.default.map(e,(e=>e.offsetTop)),n=[...t.slice(1).map(((e,n)=>e-t[n])),15];g(n)}));return e.observe(w),()=>{e.unobserve(w)}}}),[]),i.useEffect((()=>{if(null==R.current)return;const e=R.current,t=S;e.dispatch(St.setDiagnostics(e.state,t))}),[S]),i.useEffect((()=>{if(null==R.current)return;const e=Ja(R.current)??"";null==L.current&&""===t&&""!==e||(L.current=t,e!==t&&er(R.current,t))}),[t]),i.useEffect((()=>{const e=R.current;if(null!=e)if(null==a)e.dispatch({selection:{anchor:e.state.selection.main.head,head:e.state.selection.main.head}});else{let n={anchor:or(e.state.doc,a[0]),head:or(e.state.doc,a[1])};if(null===(t=a[2])||void 0===t?void 0:t.definition_of){var t;let o=e.state.field(Pn),r=null==o?void 0:o.definitions.get(null===(t=a[2])||void 0===t?void 0:t.definition_of);r&&(n={anchor:r.from,head:r.to})}e.dom.scrollIntoView({behavior:"smooth",block:"nearest"}),e.focus(),e.dispatch({scrollIntoView:!0,selection:n,effects:[St.EditorView.scrollIntoView(St.EditorSelection.range(n.anchor,n.head),{yMargin:80}),Ha.LastFocusWasForcedEffect.of(!0)]})}}),[a]),i.html`
<pluto-input ref=${D} class="CodeMirror" translate=${!1}>
<${rr}
on_delete=${c}
cell_id=${f}
run_cell=${l}
skip_as_script=${A}
running_disabled=${C}
any_logs=${b}
show_logs=${v}
set_show_logs=${y}
set_cell_disabled=${w}
/>
</pluto-input>
`},rr=({on_delete:e,cell_id:t,run_cell:n,skip_as_script:o,running_disabled:a,any_logs:r,show_logs:s,set_show_logs:l,set_cell_disabled:c})=>{const d=i.useRef(null);let u=i.useContext(ye);const[p,m]=i.useState(!1),g=i.useRef(null),h=i.useRef(null),f=e=>{e&&(h.current=document.activeElement),m(e)};i.useLayoutEffect((()=>{var e,t,n;p?null===(t=null===(e=g.current)||void 0===e?void 0:e.querySelector("li"))||void 0===t||t.focus():h.current instanceof HTMLElement&&(null===(n=h.current)||void 0===n||n.focus())}),[p]);return Io.useEventListener(window,"keydown",(e=>{"Escape"===e.key&&f(!1)})),i.html` <button
onClick=${()=>f(!p)}
onfocusout=${e=>{var t;(null===(t=g.current)||void 0===t?void 0:t.matches(":focus-within"))&&e.relatedTarget!==g.current||f(!1)}}
class=${ve.cl({input_context_menu:!0,open:p})}
title="Actions"
ref=${g}
>
<span class="icon"></span>
${p?i.html`<ul onMouseenter=${()=>{d.current&&clearTimeout(d.current)}}>
<li tabindex="0" onClick=${e} title="Delete"><span class="delete ctx_icon" />Delete cell</li>
<li
tabindex="0"
onClick=${async e=>{const t=!a;await c(t)}}
title=${a?"Enable and run the cell":"Disable this cell, and all cells that depend on it"}
>
${a?i.html`<span class="enable_cell ctx_icon" />`:i.html`<span class="disable_cell ctx_icon" />`}
${a?i.html`<b>Enable cell</b>`:i.html`Disable cell`}
</li>
${r?i.html`<li tabindex="0" title="" onClick=${()=>l(!s)}>
${s?i.html`<span class="hide_logs ctx_icon" /><span>Hide logs</span>`:i.html`<span class="show_logs ctx_icon" /><span>Show logs</span>`}
</li>`:null}
${(()=>{var e;let n=u.get_notebook(),o=null==n||null===(e=n.cell_results)||void 0===e?void 0:e[t];return!!o&&!o.errored&&!o.queued&&"text/plain"===o.output.mime&&o.output.body})()?i.html`<li tabindex="0" title="Copy the output of this cell to the clipboard." onClick=${()=>{var e,n;let o=u.get_notebook(),a=(null==o||null===(e=o.cell_results)||void 0===e||null===(n=e[t])||void 0===n?void 0:n.output.body)??"";a&&navigator.clipboard.writeText(a).catch((e=>{alert("Error copying cell output")}))}}>
<span class="copy_output ctx_icon" />Copy output
</li>`:null}
<li
tabindex="0"
onClick=${async e=>{const n=!o;e.preventDefault(),await u.update_notebook((e=>{e.cell_inputs[t].metadata.skip_as_script=n}))}}
title=${o?"This cell is currently stored in the notebook file as a Julia comment. Click here to disable.":"Store this code in the notebook file as a Julia comment. This way, it will not run when the notebook runs as a script outside of Pluto."}
>
${o?i.html`<span class="skip_as_script ctx_icon" />`:i.html`<span class="run_as_script ctx_icon" />`}
${o?i.html`<b>Enable in file</b>`:i.html`Disable in file`}
</li>
</ul>`:i.html``}
</button>`},ir=({frame:e,cell_id:t})=>{const n=e.file.indexOf("#==#");if(-1!=n){const o=e.file.substr(n+4,36),a=i.html`<a
href="#"
onclick=${t=>{window.dispatchEvent(new CustomEvent("cell_focus",{detail:{cell_id:o,line:e.line-1}})),t.preventDefault()}}
>
${o==t?"Local":"Other"}: ${e.line}
</a>`;return i.html`<em>${a}</em>`}return i.html`<em title=${e.path}>${e.file}:${e.line}</em>`},sr=({frame:e})=>{const t=e.call.indexOf("(");return-1!=t?i.html`<mark><strong>${e.call.substr(0,t)}</strong>${e.call.substr(t)}</mark>`:i.html`<mark><strong>${e.call}</strong></mark>`},lr=e=>e.flatMap(((t,n)=>n===e.length-1?[t]:n===e.length-2?[t," and "]:[t,", "])),cr=({cell_id:e,diagnostics:t})=>(i.useEffect((()=>(window.dispatchEvent(new CustomEvent("cell_diagnostics",{detail:{cell_id:e,diagnostics:t}})),()=>window.dispatchEvent(new CustomEvent("cell_diagnostics",{detail:{cell_id:e,diagnostics:[]}})))),[t]),i.html`
<jlerror>
<header><p>Syntax error</p></header>
<section>
<ol>
${t.map((({message:t,from:n,to:o,line:a})=>i.html`<li onmouseenter=${()=>window.dispatchEvent(new CustomEvent("cell_highlight_range",{detail:{cell_id:e,from:n,to:o}}))}
onmouseleave=${()=>window.dispatchEvent(new CustomEvent("cell_highlight_range",{detail:{cell_id:e,from:null,to:null}}))}
>
${t}<span>@</span>
<${ir} frame=${{file:"#==#"+e,line:a}} cell_id=${e} />
</li>`))}
</ol>
</section>
</jlerror>
`),dr=({msg:e,stacktrace:t,cell_id:n})=>{var o;let a=i.useContext(ye);const r={pattern:/.?/,display:e=>e.split("\n").map((e=>i.html`<p>${e}</p>`))},s=[{pattern:/syntax: extra token after end of expression/,display:e=>{const t=i.html`<a
href="#"
onClick=${e=>{e.preventDefault(),a.wrap_remote_cell(n,"begin")}}
>Wrap all code in a <em>begin ... end</em> block.</a
>`;if(e.includes("\n\nBoundaries: ")){const o=JSON.parse(e.split("\n\nBoundaries: ")[1]).map((e=>e-1)),r=i.html`<p>
<a
href="#"
onClick=${e=>{e.preventDefault(),a.split_remote_cell(n,o,!0)}}
>Split this cell into ${o.length} cells</a
>, or
</p>`;return i.html`<p>Multiple expressions in one cell.</p>
<p>How would you like to fix it?</p>
<ul>
<li>${r}</li>
<li>${t}</li>
</ul>`}return i.html`<p>Multiple expressions in one cell.</p>
<p>${t}</p>`}},{pattern:/LoadError: cannot assign a value to variable workspace#\d+\..+ from module workspace#\d+/,display:()=>i.html`<p>Tried to reevaluate an <code>include</code> call, this is not supported. You might need to restart this notebook from the main menu.</p>
<p>
For a workaround, use the alternative version of <code>include</code> described here:
<a target="_blank" href="https://github.com/fonsp/Pluto.jl/issues/115#issuecomment-661722426">GH issue 115</a>
</p>
<p>In the future, <code>include</code> will be deprecated, and this will be the default.</p>`},{pattern:/MethodError: no method matching .*\nClosest candidates are:/,display:e=>e.split("\n").map((e=>i.html`<p style="white-space: nowrap;">${e}</p>`))},{pattern:/Cyclic references among (.*)\./,display:e=>e.split("\n").map((e=>{const t=e.match(/Cyclic references among (.*)\./);if(t){let e=t[1].split(/, | and /).map((e=>i.html`<a href="#${encodeURI(e)}">${e}</a>`));return i.html`<p>Cyclic references among${" "}${lr(e)}.</p>`}return i.html`<p>${e}</p>`}))},{pattern:/Multiple definitions for (.*)\./,display:e=>e.split("\n").map((e=>{const t=e.match(/Multiple definitions for (.*)\./);if(t){let e=t[1].split(/, | and /).map((e=>i.html`<a href="#" onclick=${t=>{const o=document.querySelector(`pluto-cell:not([id='${n}']) span[id='${encodeURI(e)}']`);t.preventDefault(),null==o||o.scrollIntoView()}}>${e}</a>`));return i.html`<p>Multiple definitions for${" "}${lr(e)}.</p>`}return i.html`<p>${e}</p>`}))},{pattern:/^syntax: (.*)$/,display:r.display,show_stacktrace:()=>!1},{pattern:/^UndefVarError: (.*) not defined\.?$/,display:e=>{const t=a.get_notebook(),o=ur(t,n),r=e.match(/UndefVarError: (.*) not defined/);let s=(null==r?void 0:r[1])??"";const l=Object.values((null==t?void 0:t.cell_dependencies)??{}).some((e=>Object.keys(e.downstream_cells_map).includes(s)));if(0===Object.keys(o).length||!l)return i.html`<p>${e}</p>`;const c=Object.keys(o).map((e=>i.html`<a href="#" onclick=${t=>{t.preventDefault();const n=document.querySelector(`pluto-cell[id='${o[e]}']`);null==n||n.scrollIntoView()}}>${e}</a>`));return i.html`<p><em>Another cell defining ${lr(c)} contains errors.</em></p>`},show_stacktrace:()=>{const e=ur(a.get_notebook(),n);return 0===Object.keys(e).length}},r],l=s.find((({pattern:t})=>t.test(e)))??r;return i.html`<jlerror>
<header>${l.display(e)}</header>
${0!=t.length&&((null===(o=l.show_stacktrace)||void 0===o?void 0:o.call(l))??1)?i.html`<section>
<ol>
${t.map((e=>i.html`<li>
<${sr} frame=${e} />
<span>@</span>
<${ir} frame=${e} cell_id=${n} />
${e.inlined?i.html`<span>[inlined]</span>`:null}
</li>`))}
</ol>
</section>`:null}
</jlerror>`},ur=(e,t,n=[])=>{var o;let a={};if(null!=e&&(null==e||null===(r=e.cell_results)||void 0===r||null===(o=r[t])||void 0===o?void 0:o.errored)){var r;Object.keys(null===(r=e.cell_dependencies[t])||void 0===r?void 0:r.upstream_cells_map).forEach((o=>{if(!n.includes(o)){var r;n.push(o);(null===(r=e.cell_dependencies[t])||void 0===r?void 0:r.upstream_cells_map[o]).forEach((r=>{let i=ur(e,r,n)??{};a={...a,...i},0===Object.keys(i).length&&e.cell_results[r].errored&&r!==t&&(a[o]=r)}))}}))}return a};i=r("cNaMA");const pr=({mime:e,body:t,cell_id:n,persist_js_state:o,sanitize_html:a=!0})=>{switch(e){case"image/png":case"image/jpg":case"image/jpeg":case"image/gif":case"image/bmp":case"image/svg+xml":return i.html`<${gs} mime=${e} body=${t} />`;case"text/plain":return i.html`<pre class="no-block">${t}</pre>`;case"application/vnd.pluto.tree+object":return i.html`<${fr} cell_id=${n} body=${t} persist_js_state=${o} sanitize_html=${a} />`;default:return hs({mime:e,body:t,cell_id:n,persist_js_state:o,sanitize_html:a,last_run_timestamp:null})}},mr=({on_click_more:e})=>{const[t,n]=i.useState(!1);return i.html`<pluto-tree-more
class=${t?"loading":""}
onclick=${o=>{t||!1!==e()&&n(!0)}}
>more</pluto-tree-more
>`},gr=({prefix:e,prefix_short:t})=>i.html`<pluto-tree-prefix><span class="long">${e}</span><span class="short">${t}</span></pluto-tree-prefix>`,hr=({pluto_actions:e,cell_id:t,node_ref:n,objectid:o,dim:a})=>{(e??n.current.closest("pluto-cell")._internal_pluto_actions).reshow_cell(t??n.current.closest("pluto-cell").id,o,a)},fr=({mime:e,body:t,cell_id:n,persist_js_state:o,sanitize_html:a=!0})=>{let r=i.useContext(ye);const s=i.useRef(null),l=e=>i.html`<${pr} cell_id=${n} mime=${e[1]} body=${e[0]} persist_js_state=${o} sanitize_html=${a} />`,c=i.html`<p-r><${mr} on_click_more=${()=>{if(null==s.current||null!=s.current.closest("pluto-tree.collapsed"))return!1;hr({pluto_actions:r,cell_id:n,node_ref:s,objectid:t.objectid,dim:1})}} /></p-r>`;let d=null;switch(t.type){case"Pair":const e=t.key_value;return i.html`<pluto-tree-pair class=${t.type}
><p-r><p-k>${l(e[0])}</p-k><p-v>${l(e[1])}</p-v></p-r></pluto-tree-pair
>`;case"circular":return i.html`<em>circular reference</em>`;case"Array":case"Set":case"Tuple":d=i.html`${gr(t)}<pluto-tree-items class=${t.type}
>${t.elements.map((e=>"more"===e?c:i.html`<p-r>${"Set"===t.type?"":i.html`<p-k>${e[0]}</p-k>`}<p-v>${l(e[1])}</p-v></p-r>`))}</pluto-tree-items
>`;break;case"Dict":d=i.html`${gr(t)}<pluto-tree-items class=${t.type}
>${t.elements.map((e=>"more"===e?c:i.html`<p-r><p-k>${l(e[0])}</p-k><p-v>${l(e[1])}</p-v></p-r>`))}</pluto-tree-items
>`;break;case"NamedTuple":d=i.html`${gr(t)}<pluto-tree-items class=${t.type}
>${t.elements.map((e=>"more"===e?c:i.html`<p-r><p-k>${e[0]}</p-k><p-v>${l(e[1])}</p-v></p-r>`))}</pluto-tree-items
>`;break;case"struct":d=i.html`${gr(t)}<pluto-tree-items class=${t.type}
>${t.elements.map((e=>i.html`<p-r><p-k>${e[0]}</p-k><p-v>${l(e[1])}</p-v></p-r>`))}</pluto-tree-items
>`}return i.html`<pluto-tree class="collapsed ${t.type}" onclick=${e=>{var t;let n=s.current;if(!n)return;if((null!=e.target.closest("pluto-tree-prefix")?e.target.closest("pluto-tree-prefix").parentElement:e.target)!==n&&!n.classList.contains("collapsed"))return;const o=null===(t=n.parentElement)||void 0===t?void 0:t.closest("pluto-tree");null!=o&&o.classList.contains("collapsed")||n.classList.toggle("collapsed")}} ref=${s}>${d}</pluto-tree>`},_r=({colspan:e=999})=>i.html`<thead>
<tr class="empty">
<td colspan=${e}>
<div>โ <small>(This table has no columns)</small></div>
</td>
</tr>
</thead>`,br=({colspan:e=999})=>i.html`<tr class="empty">
<td colspan=${e}>
<div>
<div>โ</div>
<small>(This table has no rows)</small>
</div>
</td>
</tr>`,vr=({mime:e,body:t,cell_id:n,persist_js_state:o})=>{var a,r,s,l,c;let d=i.useContext(ye);const u=i.useRef(null),p=e=>i.html`<${mr}
on_click_more=${()=>{hr({pluto_actions:d,cell_id:n,node_ref:u,objectid:t.objectid,dim:e})}}
/>`,m=3+((null==t||null===(a=t.schema)||void 0===a||null===(r=a.names)||void 0===r?void 0:r.length)??1),g=0===((null==t||null===(s=t.schema)||void 0===s||null===(l=s.names)||void 0===l?void 0:l.length)??0)?i.html`<${_r} colspan=${m} />`:i.html`<thead>
<tr class="schema-names">
${["",...t.schema.names].map((e=>i.html`<th>${"more"===e?p(2):e}</th>`))}
</tr>
<tr class="schema-types">
${["",...t.schema.types].map((e=>i.html`<th>${"more"===e?null:e}</th>`))}
</tr>
</thead>`,h=i.html`<tbody>
${0!==((null===(c=t.rows)||void 0===c?void 0:c.length)??0)?t.rows.map((e=>i.html`<tr>
${"more"===e?i.html`<td class="pluto-tree-more-td" colspan=${m}>${p(1)}</td>`:i.html`<th>${e[0]}</th>
${e[1].map((e=>{return i.html`<td>${"more"===e?null:(t=e,i.html`<${pr} cell_id=${n} mime=${t[1]} body=${t[0]} persist_js_state=${o} />`)}</td>`;var t}))}`}
</tr>`)):i.html`<${br} colspan=${m} />`}
</tbody>`;return i.html`<table class="pluto-table" ref=${u}>
${g}${h}
</table>`};io=r("1gqBQ"),ce=r("9Ta4i"),i=r("cNaMA"),no=r("fUfdR");function yr(e){if(!(e instanceof HTMLInputElement))return e instanceof HTMLSelectElement&&e.multiple?Array.from(e.selectedOptions,(e=>e.value)):e.value;switch(e.type){case"range":case"number":return e.valueAsNumber;case"date":return e.valueAsDate;case"checkbox":return e.checked;case"file":var t;return e.multiple?e.files:null===(t=e.files)||void 0===t?void 0:t[0];default:return e.value}}function wr(e){switch(e.type){case"button":case"submit":case"checkbox":return"click";case"file":return"change";default:return"input"}}const kr=(e,t)=>{if(!(e instanceof HTMLInputElement&&"file"===e.type))if(null!=t){if(e instanceof HTMLInputElement)switch(e.type){case"range":case"number":return void(e.valueAsNumber!==t&&(e.valueAsNumber=t));case"date":return void(null!=e.valueAsDate&&Number(e.valueAsDate)===Number(t)||(e.valueAsDate=t));case"checkbox":return void(e.checked!==t&&(e.checked=t));case"file":return}else if(e instanceof HTMLSelectElement&&e.multiple){for(let n of Array.from(e.options))n.selected=t.includes(n.value);return}e.value!==t&&(e.value=t)}else e.value=t},Er=(e,t)=>{e.forEach((e=>{let n=e.getAttribute("def");if(null!=n&&null!=e.firstElementChild&&null!=t[n]){let o=t[n].value;try{kr(e.firstElementChild,o)}catch(t){console.error("Error while setting input value",e.firstElementChild,"to value",o,": ",t)}}}))},$r=(e,t,n,o)=>{let a=!1;o.then((()=>{a=!0})),e.forEach((async e=>{const o=e.getAttribute("def"),r=e.firstElementChild;if(null!=o&&null!=r){var i;const e=yr(r);const s=Object.keys(n).includes(o)&&ce.default.isEqual(null===(i=n[o])||void 0===i?void 0:i.value,e)?null:t(o,e).catch(console.error);let l=!1;for(let e of function(e){return no.default.Generators.observe((function(t){var n=wr(e),o=yr(e);function a(){t(yr(e))}return e.addEventListener(n,a),void 0!==o&&t(o),function(){e.removeEventListener(n,a)}}))}(r)){if(a)break;if(!1===l){l=!0;continue}const n=await xr(await e);await s,await t(o,n).catch(console.error)}}}))},xr=async e=>e instanceof FileList?Promise.all(Array.from(e).map((e=>xr(e)))):e instanceof File?await new Promise((t=>{const n=new FileReader;n.onload=()=>t({name:e.name,type:e.type,data:new Uint8Array(n.result)}),n.onerror=()=>t({name:e.name,type:e.type,data:null}),n.readAsArrayBuffer(e)})):e;ve=r("aN0pg"),no=r("fUfdR");var Sr=r("h2NGW"),Nr=(St=r("hiQgq"),{exports:{}});function Cr(e){return e instanceof Map?e.clear=e.delete=e.set=()=>{throw Error("map is read-only")}:e instanceof Set&&(e.add=e.clear=e.delete=()=>{throw Error("set is read-only")}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach((t=>{var n=e[t];"object"!=typeof n||Object.isFrozen(n)||Cr(n)})),e}Nr.exports=Cr,Nr.exports.default=Cr;var Ar=Nr.exports;class Mr{constructor(e){void 0===e.data&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function Or(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Tr(e,...t){const n=Object.create(null);for(const t in e)n[t]=e[t];return t.forEach((e=>{for(const t in e)n[t]=e[t]})),n}const Rr=e=>!!e.kind;class Dr{constructor(e,t){this.buffer="",this.classPrefix=t.classPrefix,e.walk(this)}addText(e){this.buffer+=Or(e)}openNode(e){if(!Rr(e))return;let t=e.kind;t=e.sublanguage?"language-"+t:((e,{prefix:t})=>{if(e.includes(".")){const n=e.split(".");return[`${t}${n.shift()}`,...n.map(((e,t)=>`${e}${"_".repeat(t+1)}`))].join(" ")}return`${t}${e}`})(t,{prefix:this.classPrefix}),this.span(t)}closeNode(e){Rr(e)&&(this.buffer+="</span>")}value(){return this.buffer}span(e){this.buffer+=`<span class="${e}">`}}class Lr{constructor(){this.rootNode={children:[]},this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){const t={kind:e,children:[]};this.add(t),this.stack.push(t)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){return"string"==typeof t?e.addText(t):t.children&&(e.openNode(t),t.children.forEach((t=>this._walk(e,t))),e.closeNode(t)),e}static _collapse(e){"string"!=typeof e&&e.children&&(e.children.every((e=>"string"==typeof e))?e.children=[e.children.join("")]:e.children.forEach((e=>{Lr._collapse(e)})))}}class Ir extends Lr{constructor(e){super(),this.options=e}addKeyword(e,t){""!==e&&(this.openNode(t),this.addText(e),this.closeNode())}addText(e){""!==e&&this.add(e)}addSublanguage(e,t){const n=e.root;n.kind=t,n.sublanguage=!0,this.add(n)}toHTML(){return new Dr(this,this.options).value()}finalize(){return!0}}function Pr(e){return e?"string"==typeof e?e:e.source:null}function jr(e){return Fr("(?=",e,")")}function Br(e){return Fr("(?:",e,")*")}function Ur(e){return Fr("(?:",e,")?")}function Fr(...e){return e.map((e=>Pr(e))).join("")}function zr(...e){const t=(e=>{const t=e[e.length-1];return"object"==typeof t&&t.constructor===Object?(e.splice(e.length-1,1),t):{}})(e);return"("+(t.capture?"":"?:")+e.map((e=>Pr(e))).join("|")+")"}function qr(e){return RegExp(e.toString()+"|").exec("").length-1}const Hr=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function Wr(e,{joinWith:t}){let n=0;return e.map((e=>{n+=1;const t=n;let o=Pr(e),a="";for(;o.length>0;){const e=Hr.exec(o);if(!e){a+=o;break}a+=o.substring(0,e.index),o=o.substring(e.index+e[0].length),"\\"===e[0][0]&&e[1]?a+="\\"+(Number(e[1])+t):(a+=e[0],"("===e[0]&&n++)}return a})).map((e=>`(${e})`)).join(t)}const Gr={begin:"\\\\[\\s\\S]",relevance:0},Kr={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[Gr]},Zr={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[Gr]},Vr=(e,t,n={})=>{const o=Tr({scope:"comment",begin:e,end:t,contains:[]},n);o.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const a=zr("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return o.contains.push({begin:Fr(/[ ]+/,"(",a,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),o},Qr=Vr("//","$"),Xr=Vr("/\\*","\\*/"),Yr=Vr("#","$");var Jr=Object.freeze({__proto__:null,MATCH_NOTHING_RE:/\b\B/,IDENT_RE:"[a-zA-Z]\\w*",UNDERSCORE_IDENT_RE:"[a-zA-Z_]\\w*",NUMBER_RE:"\\b\\d+(\\.\\d+)?",C_NUMBER_RE:"(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",BINARY_NUMBER_RE:"\\b(0b[01]+)",RE_STARTERS_RE:"!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",SHEBANG:(e={})=>{const t=/^#![ ]*\//;return e.binary&&(e.begin=Fr(t,/.*\b/,e.binary,/\b.*/)),Tr({scope:"meta",begin:t,end:/$/,relevance:0,"on:begin":(e,t)=>{0!==e.index&&t.ignoreMatch()}},e)},BACKSLASH_ESCAPE:Gr,APOS_STRING_MODE:Kr,QUOTE_STRING_MODE:Zr,PHRASAL_WORDS_MODE:{begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},COMMENT:Vr,C_LINE_COMMENT_MODE:Qr,C_BLOCK_COMMENT_MODE:Xr,HASH_COMMENT_MODE:Yr,NUMBER_MODE:{scope:"number",begin:"\\b\\d+(\\.\\d+)?",relevance:0},C_NUMBER_MODE:{scope:"number",begin:"(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",relevance:0},BINARY_NUMBER_MODE:{scope:"number",begin:"\\b(0b[01]+)",relevance:0},REGEXP_MODE:{begin:/(?=\/[^/\n]*\/)/,contains:[{scope:"regexp",begin:/\//,end:/\/[gimuy]*/,illegal:/\n/,contains:[Gr,{begin:/\[/,end:/\]/,relevance:0,contains:[Gr]}]}]},TITLE_MODE:{scope:"title",begin:"[a-zA-Z]\\w*",relevance:0},UNDERSCORE_TITLE_MODE:{scope:"title",begin:"[a-zA-Z_]\\w*",relevance:0},METHOD_GUARD:{begin:"\\.\\s*[a-zA-Z_]\\w*",relevance:0},END_SAME_AS_BEGIN:e=>Object.assign(e,{"on:begin":(e,t)=>{t.data._beginMatch=e[1]},"on:end":(e,t)=>{t.data._beginMatch!==e[1]&&t.ignoreMatch()}})});function ei(e,t){"."===e.input[e.index-1]&&t.ignoreMatch()}function ti(e,t){void 0!==e.className&&(e.scope=e.className,delete e.className)}function ni(e,t){t&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",e.__beforeBegin=ei,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,void 0===e.relevance&&(e.relevance=0))}function oi(e,t){Array.isArray(e.illegal)&&(e.illegal=zr(...e.illegal))}function ai(e,t){if(e.match){if(e.begin||e.end)throw Error("begin & end are not supported with match");e.begin=e.match,delete e.match}}function ri(e,t){void 0===e.relevance&&(e.relevance=1)}const ii=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw Error("beforeMatch cannot be used with starts");const n=Object.assign({},e);Object.keys(e).forEach((t=>{delete e[t]})),e.keywords=n.keywords,e.begin=Fr(n.beforeMatch,jr(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},si=["of","and","for","in","not","or","if","then","parent","list","value"];function li(e,t,n="keyword"){const o=Object.create(null);function a(e,n){t&&(n=n.map((e=>e.toLowerCase()))),n.forEach((t=>{const n=t.split("|");o[n[0]]=[e,ci(n[0],n[1])]}))}return"string"==typeof e?a(n,e.split(" ")):Array.isArray(e)?a(n,e):Object.keys(e).forEach((n=>{Object.assign(o,li(e[n],t,n))})),o}function ci(e,t){return t?Number(t):(e=>si.includes(e.toLowerCase()))(e)?0:1}const di={},ui=e=>{console.error(e)},pi=(e,...t)=>{console.log("WARN: "+e,...t)},mi=(e,t)=>{di[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),di[`${e}/${t}`]=!0)},gi=Error();function hi(e,t,{key:n}){let o=0;const a=e[n],r={},i={};for(let e=1;e<=t.length;e++)i[e+o]=a[e],r[e+o]=!0,o+=qr(t[e-1]);e[n]=i,e[n]._emit=r,e[n]._multi=!0}function fi(e){(e=>{e.scope&&"object"==typeof e.scope&&null!==e.scope&&(e.beginScope=e.scope,delete e.scope)})(e),"string"==typeof e.beginScope&&(e.beginScope={_wrap:e.beginScope}),"string"==typeof e.endScope&&(e.endScope={_wrap:e.endScope}),(e=>{if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw ui("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),gi;if("object"!=typeof e.beginScope||null===e.beginScope)throw ui("beginScope must be object"),gi;hi(e,e.begin,{key:"beginScope"}),e.begin=Wr(e.begin,{joinWith:""})}})(e),(e=>{if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw ui("skip, excludeEnd, returnEnd not compatible with endScope: {}"),gi;if("object"!=typeof e.endScope||null===e.endScope)throw ui("endScope must be object"),gi;hi(e,e.end,{key:"endScope"}),e.end=Wr(e.end,{joinWith:""})}})(e)}function _i(e){function t(t,n){return RegExp(Pr(t),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(n?"g":""))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(e,t){t.position=this.position++,this.matchIndexes[this.matchAt]=t,this.regexes.push([t,e]),this.matchAt+=qr(e)+1}compile(){0===this.regexes.length&&(this.exec=()=>null);const e=this.regexes.map((e=>e[1]));this.matcherRe=t(Wr(e,{joinWith:"|"}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex;const t=this.matcherRe.exec(e);if(!t)return null;const n=t.findIndex(((e,t)=>t>0&&void 0!==e)),o=this.matchIndexes[n];return t.splice(0,n),Object.assign(t,o)}}class o{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){if(this.multiRegexes[e])return this.multiRegexes[e];const t=new n;return this.rules.slice(e).forEach((([e,n])=>t.addRule(e,n))),t.compile(),this.multiRegexes[e]=t,t}resumingScanAtSamePosition(){return 0!==this.regexIndex}considerAll(){this.regexIndex=0}addRule(e,t){this.rules.push([e,t]),"begin"===t.type&&this.count++}exec(e){const t=this.getMatcher(this.regexIndex);t.lastIndex=this.lastIndex;let n=t.exec(e);if(this.resumingScanAtSamePosition())if(n&&n.index===this.lastIndex);else{const t=this.getMatcher(0);t.lastIndex=this.lastIndex+1,n=t.exec(e)}return n&&(this.regexIndex+=n.position+1,this.regexIndex===this.count&&this.considerAll()),n}}if(e.compilerExtensions||(e.compilerExtensions=[]),e.contains&&e.contains.includes("self"))throw Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=Tr(e.classNameAliases||{}),function n(a,r){const i=a;if(a.isCompiled)return i;[ti,ai,fi,ii].forEach((e=>e(a,r))),e.compilerExtensions.forEach((e=>e(a,r))),a.__beforeBegin=null,[ni,oi,ri].forEach((e=>e(a,r))),a.isCompiled=!0;let s=null;return"object"==typeof a.keywords&&a.keywords.$pattern&&(a.keywords=Object.assign({},a.keywords),s=a.keywords.$pattern,delete a.keywords.$pattern),s=s||/\w+/,a.keywords&&(a.keywords=li(a.keywords,e.case_insensitive)),i.keywordPatternRe=t(s,!0),r&&(a.begin||(a.begin=/\B|\b/),i.beginRe=t(i.begin),a.end||a.endsWithParent||(a.end=/\B|\b/),a.end&&(i.endRe=t(i.end)),i.terminatorEnd=Pr(i.end)||"",a.endsWithParent&&r.terminatorEnd&&(i.terminatorEnd+=(a.end?"|":"")+r.terminatorEnd)),a.illegal&&(i.illegalRe=t(a.illegal)),a.contains||(a.contains=[]),a.contains=[].concat(...a.contains.map((e=>(e=>(e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map((t=>Tr(e,{variants:null},t)))),e.cachedVariants?e.cachedVariants:bi(e)?Tr(e,{starts:e.starts?Tr(e.starts):null}):Object.isFrozen(e)?Tr(e):e))("self"===e?a:e)))),a.contains.forEach((e=>{n(e,i)})),a.starts&&n(a.starts,r),i.matcher=(e=>{const t=new o;return e.contains.forEach((e=>t.addRule(e.begin,{rule:e,type:"begin"}))),e.terminatorEnd&&t.addRule(e.terminatorEnd,{type:"end"}),e.illegal&&t.addRule(e.illegal,{type:"illegal"}),t})(i),i}(e)}function bi(e){return!!e&&(e.endsWithParent||bi(e.starts))}class vi extends Error{constructor(e,t){super(e),this.name="HTMLInjectionError",this.html=t}}const yi=Or,wi=Tr,ki=Symbol("nomatch");var Ei=(e=>{const t=Object.create(null),n=Object.create(null),o=[];let a=!0;const r="Could not find the language '{}', did you forget to load/include a language module?",i={disableAutodetect:!0,name:"Plain text",contains:[]};let s={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:Ir};function l(e){return s.noHighlightRe.test(e)}function c(e,t,n){let o="",a="";"object"==typeof t?(o=e,n=t.ignoreIllegals,a=t.language):(mi("10.7.0","highlight(lang, code, ...args) has been deprecated."),mi("10.7.0","Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277"),a=e,o=t),void 0===n&&(n=!0);const r={code:o,language:a};b("before:highlight",r);const i=r.result?r.result:d(r.language,r.code,n);return i.code=r.code,b("after:highlight",i),i}function d(e,n,o,i){const l=Object.create(null);function c(){if(!$.keywords)return void S.addText(N);let e=0;$.keywordPatternRe.lastIndex=0;let t=$.keywordPatternRe.exec(N),n="";for(;t;){n+=N.substring(e,t.index);const a=w.case_insensitive?t[0].toLowerCase():t[0],r=(o=a,$.keywords[o]);if(r){const[e,o]=r;if(S.addText(n),n="",l[a]=(l[a]||0)+1,l[a]<=7&&(C+=o),e.startsWith("_"))n+=t[0];else{const n=w.classNameAliases[e]||e;S.addKeyword(t[0],n)}}else n+=t[0];e=$.keywordPatternRe.lastIndex,t=$.keywordPatternRe.exec(N)}var o;n+=N.substr(e),S.addText(n)}function p(){null!=$.subLanguage?(()=>{if(""===N)return;let e=null;if("string"==typeof $.subLanguage){if(!t[$.subLanguage])return void S.addText(N);e=d($.subLanguage,N,!0,x[$.subLanguage]),x[$.subLanguage]=e._top}else e=u(N,$.subLanguage.length?$.subLanguage:null);$.relevance>0&&(C+=e.relevance),S.addSublanguage(e._emitter,e.language)})():c(),N=""}function m(e,t){let n=1;for(;void 0!==t[n];){if(!e._emit[n]){n++;continue}const o=w.classNameAliases[e[n]]||e[n],a=t[n];o?S.addKeyword(a,o):(N=a,c(),N=""),n++}}function g(e,t){return e.scope&&"string"==typeof e.scope&&S.openNode(w.classNameAliases[e.scope]||e.scope),e.beginScope&&(e.beginScope._wrap?(S.addKeyword(N,w.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap),N=""):e.beginScope._multi&&(m(e.beginScope,t),N="")),$=Object.create(e,{parent:{value:$}}),$}function f(e,t,n){let o=((e,t)=>{const n=e&&e.exec(t);return n&&0===n.index})(e.endRe,n);if(o){if(e["on:end"]){const n=new Mr(e);e["on:end"](t,n),n.isMatchIgnored&&(o=!1)}if(o){for(;e.endsParent&&e.parent;)e=e.parent;return e}}if(e.endsWithParent)return f(e.parent,t,n)}function _(e){return 0===$.matcher.regexIndex?(N+=e[0],1):(O=!0,0)}function b(e){const t=e[0],o=n.substr(e.index),a=f($,e,o);if(!a)return ki;const r=$;$.endScope&&$.endScope._wrap?(p(),S.addKeyword(t,$.endScope._wrap)):$.endScope&&$.endScope._multi?(p(),m($.endScope,e)):r.skip?N+=t:(r.returnEnd||r.excludeEnd||(N+=t),p(),r.excludeEnd&&(N=t));do{$.scope&&S.closeNode(),$.skip||$.subLanguage||(C+=$.relevance),$=$.parent}while($!==a.parent);return a.starts&&g(a.starts,e),r.returnEnd?0:t.length}let v={};function y(t,r){const i=r&&r[0];if(N+=t,null==i)return p(),0;if("begin"===v.type&&"end"===r.type&&v.index===r.index&&""===i){if(N+=n.slice(r.index,r.index+1),!a){const t=Error(`0 width match regex (${e})`);throw t.languageName=e,t.badRule=v.rule,t}return 1}if(v=r,"begin"===r.type)return(e=>{const t=e[0],n=e.rule,o=new Mr(n),a=[n.__beforeBegin,n["on:begin"]];for(const n of a)if(n&&(n(e,o),o.isMatchIgnored))return _(t);return n.skip?N+=t:(n.excludeBegin&&(N+=t),p(),n.returnBegin||n.excludeBegin||(N=t)),g(n,e),n.returnBegin?0:t.length})(r);if("illegal"===r.type&&!o){const e=Error('Illegal lexeme "'+i+'" for mode "'+($.scope||"<unnamed>")+'"');throw e.mode=$,e}if("end"===r.type){const e=b(r);if(e!==ki)return e}if("illegal"===r.type&&""===i)return 1;if(M>1e5&&M>3*r.index)throw Error("potential infinite loop, way more iterations than matches");return N+=i,i.length}const w=h(e);if(!w)throw ui(r.replace("{}",e)),Error('Unknown language: "'+e+'"');const k=_i(w);let E="",$=i||k;const x={},S=new s.__emitter(s);(()=>{const e=[];for(let t=$;t!==w;t=t.parent)t.scope&&e.unshift(t.scope);e.forEach((e=>S.openNode(e)))})();let N="",C=0,A=0,M=0,O=!1;try{for($.matcher.considerAll();;){M++,O?O=!1:$.matcher.considerAll(),$.matcher.lastIndex=A;const e=$.matcher.exec(n);if(!e)break;const t=y(n.substring(A,e.index),e);A=e.index+t}return y(n.substr(A)),S.closeAllNodes(),S.finalize(),E=S.toHTML(),{language:e,value:E,relevance:C,illegal:!1,_emitter:S,_top:$}}catch(t){if(t.message&&t.message.includes("Illegal"))return{language:e,value:yi(n),illegal:!0,relevance:0,_illegalBy:{message:t.message,index:A,context:n.slice(A-100,A+100),mode:t.mode,resultSoFar:E},_emitter:S};if(a)return{language:e,value:yi(n),illegal:!1,relevance:0,errorRaised:t,_emitter:S,_top:$};throw t}}function u(e,n){n=n||s.languages||Object.keys(t);const o=(e=>{const t={value:yi(e),illegal:!1,relevance:0,_top:i,_emitter:new s.__emitter(s)};return t._emitter.addText(e),t})(e),a=n.filter(h).filter(_).map((t=>d(t,e,!1)));a.unshift(o);const r=a.sort(((e,t)=>{if(e.relevance!==t.relevance)return t.relevance-e.relevance;if(e.language&&t.language){if(h(e.language).supersetOf===t.language)return 1;if(h(t.language).supersetOf===e.language)return-1}return 0})),[l,c]=r,u=l;return u.secondBest=c,u}function p(e){let t=null;const o=(e=>{let t=e.className+" ";t+=e.parentNode?e.parentNode.className:"";const n=s.languageDetectRe.exec(t);if(n){const t=h(n[1]);return t||(pi(r.replace("{}",n[1])),pi("Falling back to no-highlight mode for this block.",e)),t?n[1]:"no-highlight"}return t.split(/\s+/).find((e=>l(e)||h(e)))})(e);if(l(o))return;if(b("before:highlightElement",{el:e,language:o}),e.children.length>0&&(s.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(e)),s.throwUnescapedHTML))throw new vi("One of your code blocks includes unescaped HTML.",e.innerHTML);t=e;const a=t.textContent,i=o?c(a,{language:o,ignoreIllegals:!0}):u(a);e.innerHTML=i.value,((e,t,o)=>{const a=t&&n[t]||o;e.classList.add("hljs"),e.classList.add("language-"+a)})(e,o,i.language),e.result={language:i.language,re:i.relevance,relevance:i.relevance},i.secondBest&&(e.secondBest={language:i.secondBest.language,relevance:i.secondBest.relevance}),b("after:highlightElement",{el:e,result:i,text:a})}let m=!1;function g(){"loading"!==document.readyState?document.querySelectorAll(s.cssSelector).forEach(p):m=!0}function h(e){return e=(e||"").toLowerCase(),t[e]||t[n[e]]}function f(e,{languageName:t}){"string"==typeof e&&(e=[e]),e.forEach((e=>{n[e.toLowerCase()]=t}))}function _(e){const t=h(e);return t&&!t.disableAutodetect}function b(e,t){const n=e;o.forEach((e=>{e[n]&&e[n](t)}))}"undefined"!=typeof window&&window.addEventListener&&window.addEventListener("DOMContentLoaded",(()=>{m&&g()}),!1),Object.assign(e,{highlight:c,highlightAuto:u,highlightAll:g,highlightElement:p,highlightBlock:e=>(mi("10.7.0","highlightBlock will be removed entirely in v12.0"),mi("10.7.0","Please use highlightElement now."),p(e)),configure:e=>{s=wi(s,e)},initHighlighting:()=>{g(),mi("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")},initHighlightingOnLoad:()=>{g(),mi("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")},registerLanguage:(n,o)=>{let r=null;try{r=o(e)}catch(e){if(ui("Language definition for '{}' could not be registered.".replace("{}",n)),!a)throw e;ui(e),r=i}r.name||(r.name=n),t[n]=r,r.rawDefinition=o.bind(null,e),r.aliases&&f(r.aliases,{languageName:n})},unregisterLanguage:e=>{delete t[e];for(const t of Object.keys(n))n[t]===e&&delete n[t]},listLanguages:()=>Object.keys(t),getLanguage:h,registerAliases:f,autoDetection:_,inherit:wi,addPlugin:e=>{(e=>{e["before:highlightBlock"]&&!e["before:highlightElement"]&&(e["before:highlightElement"]=t=>{e["before:highlightBlock"](Object.assign({block:t.el},t))}),e["after:highlightBlock"]&&!e["after:highlightElement"]&&(e["after:highlightElement"]=t=>{e["after:highlightBlock"](Object.assign({block:t.el},t))})})(e),o.push(e)}}),e.debugMode=()=>{a=!1},e.safeMode=()=>{a=!0},e.versionString="11.4.0",e.regex={concat:Fr,lookahead:jr,either:zr,optional:Ur,anyNumberOfTimes:Br};for(const e in Jr)"object"==typeof Jr[e]&&Ar(Jr[e]);return Object.assign(e,Jr),e})({});const $i=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z][A-Za-z0-9_-]*/}}),xi=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","p","q","quote","samp","section","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],Si=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"],Ni=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"],Ci=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"],Ai=["align-content","align-items","align-self","all","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","backface-visibility","background","background-attachment","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","content","content-visibility","counter-increment","counter-reset","cue","cue-after","cue-before","cursor","direction","display","empty-cells","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-size","font-size-adjust","font-smoothing","font-stretch","font-style","font-synthesis","font-variant","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","gap","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","isolation","justify-content","left","letter-spacing","line-break","line-height","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","max-height","max-width","min-height","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page-break-after","page-break-before","page-break-inside","pause","pause-after","pause-before","perspective","perspective-origin","pointer-events","position","quotes","resize","rest","rest-after","rest-before","right","row-gap","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","shape-image-threshold","shape-margin","shape-outside","speak","speak-as","src","tab-size","table-layout","text-align","text-align-all","text-align-last","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-transform","text-underline-position","top","transform","transform-box","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","z-index"].reverse(),Mi=Ni.concat(Ci);var Oi={className:"number",variants:[{begin:"(\\b([0-9](_*[0-9])*)((\\.([0-9](_*[0-9])*))|\\.)?|(\\.([0-9](_*[0-9])*)))[eE][+-]?([0-9](_*[0-9])*)[fFdD]?\\b"},{begin:"\\b([0-9](_*[0-9])*)((\\.([0-9](_*[0-9])*))[fFdD]?\\b|\\.([fFdD]\\b)?)"},{begin:"(\\.([0-9](_*[0-9])*))[fFdD]?\\b"},{begin:"\\b([0-9](_*[0-9])*)[fFdD]\\b"},{begin:"\\b0[xX](([0-9a-fA-F](_*[0-9a-fA-F])*)\\.?|([0-9a-fA-F](_*[0-9a-fA-F])*)?\\.([0-9a-fA-F](_*[0-9a-fA-F])*))[pP][+-]?([0-9](_*[0-9])*)[fFdD]?\\b"},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:"\\b0[xX]([0-9a-fA-F](_*[0-9a-fA-F])*)[lL]?\\b"},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function Ti(e,t,n){return-1===n?"":e.replace(t,(o=>Ti(e,t,n-1)))}const Ri=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends"],Di=["true","false","null","undefined","NaN","Infinity"],Li=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],Ii=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Pi=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],ji=["arguments","this","super","console","window","document","localStorage","module","global"],Bi=[].concat(Pi,Li,Ii);function Ui(e){const t=e.regex,n="[A-Za-z$_][0-9A-Za-z$_]*",o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(e,t)=>{const n=e[0].length+e.index,o=e.input[n];if("<"===o||","===o)return void t.ignoreMatch();let a;">"===o&&(((e,{after:t})=>{const n="</"+e[0].slice(1);return-1!==e.input.indexOf(n,t)})(e,{after:n})||t.ignoreMatch()),(a=e.input.substr(n).match(/^\s+extends\s+/))&&0===a.index&&t.ignoreMatch()}},a={$pattern:"[A-Za-z$_][0-9A-Za-z$_]*",keyword:Ri,literal:Di,built_in:Bi,"variable.language":ji},r="\\.([0-9](_?[0-9])*)",i="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",s={className:"number",variants:[{begin:`(\\b(${i})((${r})|\\.)?|(${r}))[eE][+-]?([0-9](_?[0-9])*)\\b`},{begin:`\\b(${i})\\b((${r})\\b|\\.)?|(${r})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},l={className:"subst",begin:"\\$\\{",end:"\\}",keywords:a,contains:[]},c={begin:"html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,l],subLanguage:"xml"}},d={begin:"css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,l],subLanguage:"css"}},u={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,l]},p={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:n+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},m=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,c,d,u,s];l.contains=m.concat({begin:/\{/,end:/\}/,keywords:a,contains:["self"].concat(m)});const g=[].concat(p,l.contains),h=g.concat([{begin:/\(/,end:/\)/,keywords:a,contains:["self"].concat(g)}]),f={className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:h},_={variants:[{match:[/class/,/\s+/,n,/\s+/,/extends/,/\s+/,t.concat(n,"(",t.concat(/\./,n),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,n],scope:{1:"keyword",3:"title.class"}}]},b={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...Li,...Ii]}},v={variants:[{match:[/function/,/\s+/,n,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[f],illegal:/%/},y={match:t.concat(/\b/,(w=[...Pi,"super"],t.concat("(?!",w.join("|"),")")),n,t.lookahead(/\(/)),className:"title.function",relevance:0};var w;const k={begin:t.concat(/\./,t.lookahead(t.concat(n,/(?![0-9A-Za-z$_(])/))),end:n,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},E={match:[/get|set/,/\s+/,n,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},f]},$="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",x={match:[/const|var|let/,/\s+/,n,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead($)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[f]};return{name:"Javascript",aliases:["js","jsx","mjs","cjs"],keywords:a,exports:{PARAMS_CONTAINS:h,CLASS_REFERENCE:b},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),{label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,c,d,u,p,s,b,{className:"attr",begin:n+t.lookahead(":"),relevance:0},x,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[p,e.REGEXP_MODE,{className:"function",begin:$,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:h}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:"<>",end:"</>"},{match:/<[A-Za-z0-9\\._:-]+\s*\/>/},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:"xml",contains:[{begin:o.begin,end:o.end,skip:!0,contains:["self"]}]}]},v,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[f,e.inherit(e.TITLE_MODE,{begin:n,className:"title.function"})]},{match:/\.\.\./,relevance:0},k,{match:"\\$"+n,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[f]},y,{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},_,E,{match:/\$[(.]/}]}}const Fi=e=>Fr(/\b/,e,/\w$/.test(e)?/\b/:/\B/),zi=["Protocol","Type"].map(Fi),qi=["init","self"].map(Fi),Hi=["Any","Self"],Wi=["actor","associatedtype","async","await",/as\?/,/as!/,"as","break","case","catch","class","continue","convenience","default","defer","deinit","didSet","do","dynamic","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","isolated","nonisolated","lazy","let","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],Gi=["false","nil","true"],Ki=["assignment","associativity","higherThan","left","lowerThan","none","right"],Zi=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warn_unqualified_access","#warning"],Vi=["abs","all","any","assert","assertionFailure","debugPrint","dump","fatalError","getVaList","isKnownUniquelyReferenced","max","min","numericCast","pointwiseMax","pointwiseMin","precondition","preconditionFailure","print","readLine","repeatElement","sequence","stride","swap","swift_unboxFromSwiftValueWithType","transcode","type","unsafeBitCast","unsafeDowncast","withExtendedLifetime","withUnsafeMutablePointer","withUnsafePointer","withVaList","withoutActuallyEscaping","zip"],Qi=zr(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),Xi=zr(Qi,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),Yi=Fr(Qi,Xi,"*"),Ji=zr(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),es=zr(Ji,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),ts=Fr(Ji,es,"*"),ns=Fr(/[A-Z]/,es,"*"),os=["autoclosure",Fr(/convention\(/,zr("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",Fr(/objc\(/,ts,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","testable","UIApplicationMain","unknown","usableFromInline"],as=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];var rs=Object.freeze({__proto__:null,grmr_bash:e=>{const t=e.regex,n={},o={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},o]});const a={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},r={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},i={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,a]};a.contains.push(i);const s={begin:/\$\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},l=e.SHEBANG({binary:"(fish|bash|zsh|sh|csh|ksh|tcsh|dash|scsh)",relevance:10}),c={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0};return{name:"Bash",aliases:["sh"],keywords:{$pattern:/\b[a-z._-]+\b/,keyword:["if","then","else","elif","fi","for","while","in","do","done","case","esac","function"],literal:["true","false"],built_in:["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset","alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","type","typeset","ulimit","unalias","set","shopt","autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp","chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"]},contains:[l,e.SHEBANG(),c,s,e.HASH_COMMENT_MODE,r,{match:/(\/[a-z._-]+)+/},i,{className:"",begin:/\\"/},{className:"string",begin:/'/,end:/'/},n]}},grmr_c:e=>{const t=e.regex,n=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),o="[a-zA-Z_]\\w*::",a="(decltype\\(auto\\)|"+t.optional(o)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",r={className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{match:/\batomic_[a-z]{3,6}\b/}]},i={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},s={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},l={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(i,{className:"string"}),{className:"string",begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},c={className:"title",begin:t.optional(o)+e.IDENT_RE,relevance:0},d=t.optional(o)+e.IDENT_RE+"\\s*\\(",u={keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal128","const","static","complex","bool","imaginary"],literal:"true false NULL",built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"},p=[l,r,n,e.C_BLOCK_COMMENT_MODE,s,i],m={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:u,contains:p.concat([{begin:/\(/,end:/\)/,keywords:u,contains:p.concat(["self"]),relevance:0}]),relevance:0},g={begin:"("+a+"[\\*&\\s]+)+"+d,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:u,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:"decltype\\(auto\\)",keywords:u,relevance:0},{begin:d,returnBegin:!0,contains:[e.inherit(c,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:u,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,i,s,r,{begin:/\(/,end:/\)/,keywords:u,relevance:0,contains:["self",n,e.C_BLOCK_COMMENT_MODE,i,s,r]}]},r,n,e.C_BLOCK_COMMENT_MODE,l]};return{name:"C",aliases:["h"],keywords:u,disableAutodetect:!0,illegal:"</",contains:[].concat(m,g,p,[l,{begin:e.IDENT_RE+"::",keywords:u},{className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{beginKeywords:"final class struct"},e.TITLE_MODE]}]),exports:{preprocessor:l,strings:i,keywords:u}}},grmr_cpp:e=>{const t=e.regex,n=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),o="[a-zA-Z_]\\w*::",a="(?!struct)(decltype\\(auto\\)|"+t.optional(o)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",r={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},i={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},s={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},l={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(i,{className:"string"}),{className:"string",begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},c={className:"title",begin:t.optional(o)+e.IDENT_RE,relevance:0},d=t.optional(o)+e.IDENT_RE+"\\s*\\(",u={type:["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],keyword:["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"]},p={className:"function.dispatch",relevance:0,keywords:{_hint:["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"]},begin:t.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,e.IDENT_RE,t.lookahead(/(<[^<>]+>|)\s*\(/))},m=[p,l,r,n,e.C_BLOCK_COMMENT_MODE,s,i],g={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:u,contains:m.concat([{begin:/\(/,end:/\)/,keywords:u,contains:m.concat(["self"]),relevance:0}]),relevance:0},h={className:"function",begin:"("+a+"[\\*&\\s]+)+"+d,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:u,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:"decltype\\(auto\\)",keywords:u,relevance:0},{begin:d,returnBegin:!0,contains:[c],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[i,s]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:u,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,i,s,r,{begin:/\(/,end:/\)/,keywords:u,relevance:0,contains:["self",n,e.C_BLOCK_COMMENT_MODE,i,s,r]}]},r,n,e.C_BLOCK_COMMENT_MODE,l]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:u,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(g,h,p,m,[l,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function)\\s*<(?!<)",end:">",keywords:u,contains:["self",r]},{begin:e.IDENT_RE+"::",keywords:u},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}},grmr_csharp:e=>{const t={keyword:["abstract","as","base","break","case","catch","class","const","continue","do","else","event","explicit","extern","finally","fixed","for","foreach","goto","if","implicit","in","interface","internal","is","lock","namespace","new","operator","out","override","params","private","protected","public","readonly","record","ref","return","sealed","sizeof","stackalloc","static","struct","switch","this","throw","try","typeof","unchecked","unsafe","using","virtual","void","volatile","while"].concat(["add","alias","and","ascending","async","await","by","descending","equals","from","get","global","group","init","into","join","let","nameof","not","notnull","on","or","orderby","partial","remove","select","set","unmanaged","value|0","var","when","where","with","yield"]),built_in:["bool","byte","char","decimal","delegate","double","dynamic","enum","float","int","long","nint","nuint","object","sbyte","short","string","ulong","uint","ushort"],literal:["default","false","null","true"]},n=e.inherit(e.TITLE_MODE,{begin:"[a-zA-Z](\\.?\\w)*"}),o={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},a={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}]},r=e.inherit(a,{illegal:/\n/}),i={className:"subst",begin:/\{/,end:/\}/,keywords:t},s=e.inherit(i,{illegal:/\n/}),l={className:"string",begin:/\$"/,end:'"',illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},e.BACKSLASH_ESCAPE,s]},c={className:"string",begin:/\$@"/,end:'"',contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},i]},d=e.inherit(c,{illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},s]});i.contains=[c,l,a,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,o,e.C_BLOCK_COMMENT_MODE],s.contains=[d,l,r,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,o,e.inherit(e.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];const u={variants:[c,l,a,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},p={begin:"<",end:">",contains:[{beginKeywords:"in out"},n]},m=e.IDENT_RE+"(<"+e.IDENT_RE+"(\\s*,\\s*"+e.IDENT_RE+")*>)?(\\[\\])?",g={begin:"@"+e.IDENT_RE,relevance:0};return{name:"C#",aliases:["cs","c#"],keywords:t,illegal:/::/,contains:[e.COMMENT("///","$",{returnBegin:!0,contains:[{className:"doctag",variants:[{begin:"///",relevance:0},{begin:"\x3c!--|--\x3e"},{begin:"</?",end:">"}]}]}),e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"meta",begin:"#",end:"$",keywords:{keyword:"if else elif endif define undef warning error line region endregion pragma checksum"}},u,o,{beginKeywords:"class interface",relevance:0,end:/[{;=]/,illegal:/[^\s:,]/,contains:[{beginKeywords:"where class"},n,p,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"namespace",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[n,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"record",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[n,p,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"meta",begin:"^\\s*\\[(?=[\\w])",excludeBegin:!0,end:"\\]",excludeEnd:!0,contains:[{className:"string",begin:/"/,end:/"/}]},{beginKeywords:"new return throw await else",relevance:0},{className:"function",begin:"("+m+"\\s+)+"+e.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,end:/\s*[{;=]/,excludeEnd:!0,keywords:t,contains:[{beginKeywords:"public private protected static internal protected abstract async extern override unsafe virtual new sealed partial",relevance:0},{begin:e.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,contains:[e.TITLE_MODE,p],relevance:0},{match:/\(\)/},{className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:t,relevance:0,contains:[u,o,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},g]}},grmr_css:e=>{const t=e.regex,n=$i(e),o=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,{begin:/-(webkit|moz|ms|o)-(?=[a-z])/},n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\.[a-zA-Z-][a-zA-Z0-9_-]*",relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+Ni.join("|")+")"},{begin:":(:)?("+Ci.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+Ai.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...o,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:/@-?\w[\w]*(-\w+)*/},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:"and or not only",attribute:Si.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...o,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+xi.join("|")+")\\b"}]}},grmr_diff:e=>{const t=e.regex;return{name:"Diff",aliases:["patch"],contains:[{className:"meta",relevance:10,match:t.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:"comment",variants:[{begin:t.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:"addition",begin:/^\+/,end:/$/},{className:"deletion",begin:/^-/,end:/$/},{className:"addition",begin:/^!/,end:/$/}]}},grmr_go:e=>{const t={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:t,illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"string",variants:[e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:"number",variants:[{begin:e.C_NUMBER_RE+"[i]",relevance:1},e.C_NUMBER_MODE]},{begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",excludeEnd:!0,contains:[e.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:t,illegal:/["']/}]}]}},grmr_ini:e=>{const t=e.regex,n={className:"number",relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:e.NUMBER_RE}]},o=e.COMMENT();o.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];const a={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},r={className:"literal",begin:/\bon|off|true|false|yes|no\b/},i={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},s={begin:/\[/,end:/\]/,contains:[o,r,a,i,n,"self"],relevance:0},l=t.either(/[A-Za-z0-9_-]+/,/"(\\"|[^"])*"/,/'[^']*'/);return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[o,{className:"section",begin:/\[+/,end:/\]+/},{begin:t.concat(l,"(\\s*\\.\\s*",l,")*",t.lookahead(/\s*=\s*[^#\s]/)),className:"attr",starts:{end:/$/,contains:[o,s,r,a,i,n]}}]}},grmr_java:e=>{e.regex;const t="[ร-สธa-zA-Z_$][ร-สธa-zA-Z_$0-9]*",n=t+Ti("(?:<"+t+"~~~(?:\\s*,\\s*"+t+"~~~)*>)?",/~~~/g,2),o={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},a={className:"meta",begin:"@"+t,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},r={className:"params",begin:/\(/,end:/\)/,keywords:o,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:o,illegal:/<\/|#/,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[e.BACKSLASH_ESCAPE]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,t],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[t,/\s+/,t,/\s+/,/=/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,t],className:{1:"keyword",3:"title.class"},contains:[r,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+n+"\\s+)",e.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:o,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:o,relevance:0,contains:[a,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,Oi,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},Oi,a]}},grmr_javascript:Ui,grmr_json:e=>({name:"JSON",contains:[{className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},{match:/[{}[\],:]/,className:"punctuation",relevance:0},e.QUOTE_STRING_MODE,{beginKeywords:"true false null"},e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}),grmr_kotlin:e=>{const t={keyword:"abstract as val var vararg get set class object open private protected public noinline crossinline dynamic final enum if else do while for when throw try catch finally import package is in fun override companion reified inline lateinit init interface annotation data sealed internal infix operator out by constructor super tailrec where const inner suspend typealias external expect actual",built_in:"Byte Short Char Int Long Boolean Float Double Void Unit Nothing",literal:"true false null"},n={className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"@"},o={className:"subst",begin:/\$\{/,end:/\}/,contains:[e.C_NUMBER_MODE]},a={className:"variable",begin:"\\$"+e.UNDERSCORE_IDENT_RE},r={className:"string",variants:[{begin:'"""',end:'"""(?=[^"])',contains:[a,o]},{begin:"'",end:"'",illegal:/\n/,contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"',illegal:/\n/,contains:[e.BACKSLASH_ESCAPE,a,o]}]};o.contains.push(r);const i={className:"meta",begin:"@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*"+e.UNDERSCORE_IDENT_RE+")?"},s={className:"meta",begin:"@"+e.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/,end:/\)/,contains:[e.inherit(r,{className:"string"})]}]},l=Oi,c=e.COMMENT("/\\*","\\*/",{contains:[e.C_BLOCK_COMMENT_MODE]}),d={variants:[{className:"type",begin:e.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,contains:[]}]},u=d;return u.variants[1].contains=[d],d.variants[1].contains=[u],{name:"Kotlin",aliases:["kt","kts"],keywords:t,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"}]}),e.C_LINE_COMMENT_MODE,c,{className:"keyword",begin:/\b(break|continue|return|this)\b/,starts:{contains:[{className:"symbol",begin:/@\w+/}]}},n,i,s,{className:"function",beginKeywords:"fun",end:"[(]|$",returnBegin:!0,excludeEnd:!0,keywords:t,relevance:5,contains:[{begin:e.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0,contains:[e.UNDERSCORE_TITLE_MODE]},{className:"type",begin:/</,end:/>/,keywords:"reified",relevance:0},{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:t,relevance:0,contains:[{begin:/:/,end:/[=,\/]/,endsWithParent:!0,contains:[d,e.C_LINE_COMMENT_MODE,c],relevance:0},e.C_LINE_COMMENT_MODE,c,i,s,r,e.C_NUMBER_MODE]},c]},{className:"class",beginKeywords:"class interface trait",end:/[:\{(]|$/,excludeEnd:!0,illegal:"extends implements",contains:[{beginKeywords:"public protected internal private constructor"},e.UNDERSCORE_TITLE_MODE,{className:"type",begin:/</,end:/>/,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:/[,:]\s*/,end:/[<\(,]|$/,excludeBegin:!0,returnEnd:!0},i,s]},r,{className:"meta",begin:"^#!/usr/bin/env",end:"$",illegal:"\n"},l]}},grmr_less:e=>{const t=$i(e),n=Mi,o="([\\w-]+|@\\{[\\w-]+\\})",a=[],r=[],i=e=>({className:"string",begin:"~?"+e+".*?"+e}),s=(e,t,n)=>({className:e,begin:t,relevance:n}),l={$pattern:/[a-z-]+/,keyword:"and or not only",attribute:Si.join(" ")},c={begin:"\\(",end:"\\)",contains:r,keywords:l,relevance:0};r.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,i("'"),i('"'),t.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},t.HEXCOLOR,c,s("variable","@@?[\\w-]+",10),s("variable","@\\{[\\w-]+\\}"),s("built_in","~?`[^`]*?`"),{className:"attribute",begin:"[\\w-]+\\s*:",end:":",returnBegin:!0,excludeEnd:!0},t.IMPORTANT);const d=r.concat({begin:/\{/,end:/\}/,contains:a}),u={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(r)},p={begin:o+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+Ai.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:r}}]},m={className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:l,returnEnd:!0,contains:r,relevance:0}},g={className:"variable",variants:[{begin:"@[\\w-]+\\s*:",relevance:15},{begin:"@[\\w-]+"}],starts:{end:"[;}]",returnEnd:!0,contains:d}},h={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:o,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:"[<='$\"]",relevance:0,contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,u,s("keyword","all\\b"),s("variable","@\\{[\\w-]+\\}"),{begin:"\\b("+xi.join("|")+")\\b",className:"selector-tag"},t.CSS_NUMBER_MODE,s("selector-tag",o,0),s("selector-id","#"+o),s("selector-class","\\."+o,0),s("selector-tag","&",0),t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+Ni.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+Ci.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:d},{begin:"!important"},t.FUNCTION_DISPATCH]},f={begin:`[\\w-]+:(:)?(${n.join("|")})`,returnBegin:!0,contains:[h]};return a.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,m,g,f,p,h),{name:"Less",case_insensitive:!0,illegal:"[=>'/<($\"]",contains:a}},grmr_lua:e=>{const t="\\[=*\\[",n="\\]=*\\]",o={begin:t,end:n,contains:["self"]},a=[e.COMMENT("--(?!\\[=*\\[)","$"),e.COMMENT("--\\[=*\\[",n,{contains:[o],relevance:10})];return{name:"Lua",keywords:{$pattern:e.UNDERSCORE_IDENT_RE,literal:"true false nil",keyword:"and break do else elseif end for goto if in local not or repeat return then until while",built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"},contains:a.concat([{className:"function",beginKeywords:"function",end:"\\)",contains:[e.inherit(e.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",begin:"\\(",endsWithParent:!0,contains:a}].concat(a)},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"string",begin:t,end:n,contains:[o],relevance:5}])}},grmr_makefile:e=>{const t={className:"variable",variants:[{begin:"\\$\\("+e.UNDERSCORE_IDENT_RE+"\\)",contains:[e.BACKSLASH_ESCAPE]},{begin:/\$[@%<?\^\+\*]/}]},n={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,t]},o={className:"variable",begin:/\$\([\w-]+\s/,end:/\)/,keywords:{built_in:"subst patsubst strip findstring filter filter-out sort word wordlist firstword lastword dir notdir suffix basename addsuffix addprefix join wildcard realpath abspath error warning shell origin flavor foreach if or and call eval file value"},contains:[t]},a={begin:"^"+e.UNDERSCORE_IDENT_RE+"\\s*(?=[:+?]?=)"},r={className:"section",begin:/^[^\s]+:/,end:/$/,contains:[t]};return{name:"Makefile",aliases:["mk","mak","make"],keywords:{$pattern:/[\w-]+/,keyword:"define endef undefine ifdef ifndef ifeq ifneq else endif include -include sinclude override export unexport private vpath"},contains:[e.HASH_COMMENT_MODE,t,n,o,a,{className:"meta",begin:/^\.PHONY:/,end:/$/,keywords:{$pattern:/[\.\w]+/,keyword:".PHONY"}},r]}},grmr_xml:e=>{const t=e.regex,n=t.concat(/[A-Z_]/,t.optional(/[A-Z0-9_.-]*:/),/[A-Z0-9_.-]*/),o={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},a={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},r=e.inherit(a,{begin:/\(/,end:/\)/}),i=e.inherit(e.APOS_STRING_MODE,{className:"string"}),s=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),l={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:/[A-Za-z0-9._:-]+/,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[o]},{begin:/'/,end:/'/,contains:[o]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[a,s,i,r,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[a,r,s,i]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},o,{className:"meta",begin:/<\?xml/,end:/\?>/,relevance:10},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[l],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[l],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:l}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}},grmr_markdown:e=>{const t={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},n={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:e.regex.concat(/\[.+?\]\(/,/[A-Za-z][A-Za-z0-9+.-]*/,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},o={className:"strong",contains:[],variants:[{begin:/_{2}/,end:/_{2}/},{begin:/\*{2}/,end:/\*{2}/}]},a={className:"emphasis",contains:[],variants:[{begin:/\*(?!\*)/,end:/\*/},{begin:/_(?!_)/,end:/_/,relevance:0}]};o.contains.push(a),a.contains.push(o);let r=[t,n];return o.contains=o.contains.concat(r),a.contains=a.contains.concat(r),r=r.concat(o,a),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:r},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:r}]}]},t,{className:"bullet",begin:"^[ \t]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},o,a,{className:"quote",begin:"^>\\s+",contains:r,end:"$"},{className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},{begin:"^[-\\*]{3,}",end:"$"},n,{begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]}]}},grmr_objectivec:e=>{const t=/[a-zA-Z@][a-zA-Z0-9_]*/,n={$pattern:t,keyword:["@interface","@class","@protocol","@implementation"]};return{name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"],keywords:{$pattern:t,keyword:["int","float","while","char","export","sizeof","typedef","const","struct","for","union","unsigned","long","volatile","static","bool","mutable","if","do","return","goto","void","enum","else","break","extern","asm","case","short","default","double","register","explicit","signed","typename","this","switch","continue","wchar_t","inline","readonly","assign","readwrite","self","@synchronized","id","typeof","nonatomic","super","unichar","IBOutlet","IBAction","strong","weak","copy","in","out","inout","bycopy","byref","oneway","__strong","__weak","__block","__autoreleasing","@private","@protected","@public","@try","@property","@end","@throw","@catch","@finally","@autoreleasepool","@synthesize","@dynamic","@selector","@optional","@required","@encode","@package","@import","@defs","@compatibility_alias","__bridge","__bridge_transfer","__bridge_retained","__bridge_retain","__covariant","__contravariant","__kindof","_Nonnull","_Nullable","_Null_unspecified","__FUNCTION__","__PRETTY_FUNCTION__","__attribute__","getter","setter","retain","unsafe_unretained","nonnull","nullable","null_unspecified","null_resettable","class","instancetype","NS_DESIGNATED_INITIALIZER","NS_UNAVAILABLE","NS_REQUIRES_SUPER","NS_RETURNS_INNER_POINTER","NS_INLINE","NS_AVAILABLE","NS_DEPRECATED","NS_ENUM","NS_OPTIONS","NS_SWIFT_UNAVAILABLE","NS_ASSUME_NONNULL_BEGIN","NS_ASSUME_NONNULL_END","NS_REFINED_FOR_SWIFT","NS_SWIFT_NAME","NS_SWIFT_NOTHROW","NS_DURING","NS_HANDLER","NS_ENDHANDLER","NS_VALUERETURN","NS_VOIDRETURN"],literal:["false","true","FALSE","TRUE","nil","YES","NO","NULL"],built_in:["BOOL","dispatch_once_t","dispatch_queue_t","dispatch_sync","dispatch_async","dispatch_once"]},illegal:"</",contains:[{className:"built_in",begin:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.C_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{className:"string",variants:[{begin:'@"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]}]},{className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),{className:"string",begin:/<.*?>/,end:/$/,illegal:"\\n"},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"class",begin:"("+n.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:n,contains:[e.UNDERSCORE_TITLE_MODE]},{begin:"\\."+e.UNDERSCORE_IDENT_RE,relevance:0}]}},grmr_perl:e=>{const t=e.regex,n=/[dualxmsipngr]{0,12}/,o={$pattern:/[\w.]+/,keyword:"abs accept alarm and atan2 bind binmode bless break caller chdir chmod chomp chop chown chr chroot close closedir connect continue cos crypt dbmclose dbmopen defined delete die do dump each else elsif endgrent endhostent endnetent endprotoent endpwent endservent eof eval exec exists exit exp fcntl fileno flock for foreach fork format formline getc getgrent getgrgid getgrnam gethostbyaddr gethostbyname gethostent getlogin getnetbyaddr getnetbyname getnetent getpeername getpgrp getpriority getprotobyname getprotobynumber getprotoent getpwent getpwnam getpwuid getservbyname getservbyport getservent getsockname getsockopt given glob gmtime goto grep gt hex if index int ioctl join keys kill last lc lcfirst length link listen local localtime log lstat lt ma map mkdir msgctl msgget msgrcv msgsnd my ne next no not oct open opendir or ord our pack package pipe pop pos print printf prototype push q|0 qq quotemeta qw qx rand read readdir readline readlink readpipe recv redo ref rename require reset return reverse rewinddir rindex rmdir say scalar seek seekdir select semctl semget semop send setgrent sethostent setnetent setpgrp setpriority setprotoent setpwent setservent setsockopt shift shmctl shmget shmread shmwrite shutdown sin sleep socket socketpair sort splice split sprintf sqrt srand stat state study sub substr symlink syscall sysopen sysread sysseek system syswrite tell telldir tie tied time times tr truncate uc ucfirst umask undef unless unlink unpack unshift untie until use utime values vec wait waitpid wantarray warn when while write x|0 xor y|0"},a={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:o},r={begin:/->\{/,end:/\}/},i={variants:[{begin:/\$\d/},{begin:t.concat(/[$%@](\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")},{begin:/[$%@][^\s\w{]/,relevance:0}]},s=[e.BACKSLASH_ESCAPE,a,i],l=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],c=(e,o,a="\\1")=>{const r="\\1"===a?a:t.concat(a,o);return t.concat(t.concat("(?:",e,")"),o,/(?:\\.|[^\\\/])*?/,r,/(?:\\.|[^\\\/])*?/,a,n)},d=(e,o,a)=>t.concat(t.concat("(?:",e,")"),o,/(?:\\.|[^\\\/])*?/,a,n),u=[i,e.HASH_COMMENT_MODE,e.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),r,{className:"string",contains:s,variants:[{begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[",end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*<",end:">",relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'",contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{begin:"-?\\w+\\s*=>",relevance:0}]},{className:"number",begin:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",relevance:0},{begin:"(\\/\\/|"+e.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",keywords:"split return print reverse grep",relevance:0,contains:[e.HASH_COMMENT_MODE,{className:"regexp",variants:[{begin:c("s|tr|y",t.either(...l,{capture:!0}))},{begin:c("s|tr|y","\\(","\\)")},{begin:c("s|tr|y","\\[","\\]")},{begin:c("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:d("(?:m|qr)?",/\//,/\//)},{begin:d("m|qr",t.either(...l,{capture:!0}),/\1/)},{begin:d("m|qr",/\(/,/\)/)},{begin:d("m|qr",/\[/,/\]/)},{begin:d("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return a.contains=u,r.contains=u,{name:"Perl",aliases:["pl","pm"],keywords:o,contains:u}},grmr_php:e=>{const t=e.regex,n="[a-zA-Z0-9_-รฟ]*(?![A-Za-z0-9])(?![$]))",o=t.concat("([a-zA-Z_\\x7f-\\xff]",n),a=t.concat("([A-Z]",n),r={scope:"variable",match:"\\$+"+o},i={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},s=e.inherit(e.APOS_STRING_MODE,{illegal:null}),l="[ \t\n]",c={scope:"string",variants:[e.inherit(e.QUOTE_STRING_MODE,{illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(i)}),s,e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*(\w+)\n/,end:/[ \t]*(\w+)\b/,contains:e.QUOTE_STRING_MODE.contains.concat(i)})]},d={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},u=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],p=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],m={keyword:u,literal:(e=>{const t=[];return["false","null","true"].forEach((e=>{t.push(e),e.toLowerCase()===e?t.push(e.toUpperCase()):t.push(e.toLowerCase())})),t})(),built_in:p},g=e=>e.map((e=>e.replace(/\|\d+$/,""))),h={variants:[{match:[/new/,t.concat(l,"+"),t.concat("(?!",g(p).join("\\b|"),"\\b)"),t.concat(/\\?/,o),t.concat(l,"*",/\(/)],scope:{1:"keyword",4:"title.class"}}]},f={relevance:0,match:[/\b/,t.concat("(?!fn\\b|function\\b|",g(u).join("\\b|"),"|",g(p).join("\\b|"),"\\b)"),o,t.concat(l,"*"),t.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"}},_=t.concat(o,"\\b(?!\\()"),b={variants:[{match:[t.concat(/::/,t.lookahead(/(?!class\b)/)),_],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[a,t.concat("::",t.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[a,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]};return{case_insensitive:!1,keywords:m,contains:[e.HASH_COMMENT_MODE,e.COMMENT("//","$"),e.COMMENT("/\\*","\\*/",{contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,keywords:"__halt_compiler",starts:{scope:"comment",end:e.MATCH_NOTHING_RE,contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},{scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?[=]?/},{begin:/\?>/}]},{scope:"variable.language",match:/\$this\b/},r,f,b,{match:[/const/,/\s/,o,/\s*=/],scope:{1:"keyword",3:"variable.constant"}},h,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},e.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:m,contains:["self",r,b,e.C_BLOCK_COMMENT_MODE,c,d]}]},{scope:"class",variants:[{beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,contains:[e.inherit(e.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{beginKeywords:"use",relevance:0,end:";",contains:[{match:/\b(as|const|function)\b/,scope:"keyword"},e.UNDERSCORE_TITLE_MODE]},c,d]}},grmr_php_template:e=>({name:"PHP template",subLanguage:"xml",contains:[{begin:/<\?(php|=)?/,end:/\?>/,subLanguage:"php",contains:[{begin:"/\\*",end:"\\*/",skip:!0},{begin:'b"',end:'"',skip:!0},{begin:"b'",end:"'",skip:!0},e.inherit(e.APOS_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0}),e.inherit(e.QUOTE_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0})]}]}),grmr_plaintext:e=>({name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}),grmr_python:e=>{const t=e.regex,n=/[\p{XID_Start}_]\p{XID_Continue}*/u,o=["and","as","assert","async","await","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],a={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:o,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},r={className:"meta",begin:/^(>>>|\.\.\.) /},i={className:"subst",begin:/\{/,end:/\}/,keywords:a,illegal:/#/},s={begin:/\{\{/,relevance:0},l={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,r],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,r],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,r,s,i]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,r,s,i]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,s,i]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,s,i]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},c="[0-9](_?[0-9])*",d=`(\\b(${c}))?\\.(${c})|\\b(${c})\\.`,u="\\b|"+o.join("|"),p={className:"number",relevance:0,variants:[{begin:`(\\b(${c})|(${d}))[eE][+-]?(${c})[jJ]?(?=${u})`},{begin:`(${d})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${u})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${u})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${u})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${u})`},{begin:`\\b(${c})[jJ](?=${u})`}]},m={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:a,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},g={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:["self",r,p,l,e.HASH_COMMENT_MODE]}]};return i.contains=[l,p,r],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:a,illegal:/(<\/|->|\?)|=>/,contains:[r,p,{begin:/\bself\b/},{beginKeywords:"if",relevance:0},l,m,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[g]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[p,g,l]}]}},grmr_python_repl:e=>({aliases:["pycon"],contains:[{className:"meta",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}),grmr_r:e=>{const t=e.regex,n=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,o=t.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),a=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,r=t.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:n,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[e.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:t.lookahead(t.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:n},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),e.HASH_COMMENT_MODE,{scope:"string",contains:[e.BACKSLASH_ESCAPE],variants:[e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[a,o]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,o]},{scope:{1:"punctuation",2:"number"},match:[r,o]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,o]}]},{scope:{3:"operator"},match:[n,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:a},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:r},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}},grmr_ruby:e=>{const t=e.regex,n="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",o={keyword:"and then defined module in return redo if BEGIN retry end for self when next until do begin unless END rescue else break undef not super class case require yield alias while ensure elsif or include attr_reader attr_writer attr_accessor __FILE__",built_in:"proc lambda",literal:"true false nil"},a={className:"doctag",begin:"@[A-Za-z]+"},r={begin:"#<",end:">"},i=[e.COMMENT("#","$",{contains:[a]}),e.COMMENT("^=begin","^=end",{contains:[a],relevance:10}),e.COMMENT("^__END__","\\n$")],s={className:"subst",begin:/#\{/,end:/\}/,keywords:o},l={className:"string",contains:[e.BACKSLASH_ESCAPE,s],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?</,end:/>/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:t.concat(/<<[-~]?'?/,t.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[e.BACKSLASH_ESCAPE,s]})]}]},c="[0-9](_?[0-9])*",d={className:"number",relevance:0,variants:[{begin:`\\b([1-9](_?[0-9])*|0)(\\.(${c}))?([eE][+-]?(${c})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},u={className:"params",begin:"\\(",end:"\\)",endsParent:!0,keywords:o},p=[l,{className:"class",beginKeywords:"class module",end:"$|;",illegal:/=/,contains:[e.inherit(e.TITLE_MODE,{begin:"[A-Za-z_]\\w*(::\\w+)*(\\?|!)?"}),{begin:"<\\s*",contains:[{begin:"("+e.IDENT_RE+"::)?"+e.IDENT_RE,relevance:0}]}].concat(i)},{className:"function",begin:t.concat(/def\s+/,t.lookahead(n+"\\s*(\\(|;|$)")),relevance:0,keywords:"def",end:"$|;",contains:[e.inherit(e.TITLE_MODE,{begin:n}),u].concat(i)},{begin:e.IDENT_RE+"::"},{className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[l,{begin:n}],relevance:0},d,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|/,end:/\|/,relevance:0,keywords:o},{begin:"("+e.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[e.BACKSLASH_ESCAPE,s],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(r,i),relevance:0}].concat(r,i);s.contains=p,u.contains=p;const m=[{begin:/^\s*=>/,starts:{end:"$",contains:p}},{className:"meta",begin:"^([>?]>|[\\w#]+\\(\\w+\\):\\d+:\\d+>|(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>)(?=[ ])",starts:{end:"$",contains:p}}];return i.unshift(r),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:o,illegal:/\/\*/,contains:[e.SHEBANG({binary:"ruby"})].concat(m).concat(i).concat(p)}},grmr_rust:e=>{const t=e.regex,n={className:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!let\b)/,e.IDENT_RE,t.lookahead(/\s*\(/))},o="([ui](8|16|32|64|128|size)|f(32|64))?",a=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","panic!","file!","format!","format_args!","include_bin!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"],keyword:["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","unsafe","unsized","use","virtual","where","while","yield"],literal:["true","false","Some","None","Ok","Err"],built_in:a},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'\\?(x\w{2}|u\w{4}|U\w{8}|.)'/}]},{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*/},{className:"number",variants:[{begin:"\\b0b([01_]+)"+o},{begin:"\\b0o([0-7_]+)"+o},{begin:"\\b0x([A-Fa-f0-9_]+)"+o},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+o}],relevance:0},{begin:[/fn/,/\s+/,e.UNDERSCORE_IDENT_RE],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,e.UNDERSCORE_IDENT_RE],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,e.UNDERSCORE_IDENT_RE,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,e.UNDERSCORE_IDENT_RE],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,e.UNDERSCORE_IDENT_RE],className:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:a}},{className:"punctuation",begin:"->"},n]}},grmr_scss:e=>{const t=$i(e),n=Ci,o=Ni,a="@[a-z-]+",r={className:"variable",begin:"(\\$[a-zA-Z-][a-zA-Z0-9_-]*)\\b"};return{name:"SCSS",case_insensitive:!0,illegal:"[=/|']",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,t.CSS_NUMBER_MODE,{className:"selector-id",begin:"#[A-Za-z0-9_-]+",relevance:0},{className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0},t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-tag",begin:"\\b("+xi.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+o.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+n.join("|")+")"},r,{begin:/\(/,end:/\)/,contains:[t.CSS_NUMBER_MODE]},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+Ai.join("|")+")\\b"},{begin:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{begin:/:/,end:/[;}{]/,contains:[t.BLOCK_COMMENT,r,t.HEXCOLOR,t.CSS_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.IMPORTANT]},{begin:"@(page|font-face)",keywords:{$pattern:a,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:"and or not only",attribute:Si.join(" ")},contains:[{begin:a,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},r,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.HEXCOLOR,t.CSS_NUMBER_MODE]},t.FUNCTION_DISPATCH]}},grmr_shell:e=>({name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}),grmr_sql:e=>{const t=e.regex,n=e.COMMENT("--","$"),o=["true","false","unknown"],a=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],r=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],i=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],s=r,l=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year","add","asc","collation","desc","final","first","last","view"].filter((e=>!r.includes(e))),c={begin:t.concat(/\b/,t.either(...s),/\s*\(/),relevance:0,keywords:{built_in:s}};return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:((e,{exceptions:t,when:n}={})=>{const o=n;return t=t||[],e.map((e=>e.match(/\|\d+$/)||t.includes(e)?e:o(e)?e+"|0":e))})(l,{when:e=>e.length<3}),literal:o,type:a,built_in:["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"]},contains:[{begin:t.either(...i),relevance:0,keywords:{$pattern:/[\w\.]+/,keyword:l.concat(i),literal:o,type:a}},{className:"type",begin:t.either("double precision","large object","with timezone","without timezone")},c,{className:"variable",begin:/@[a-z0-9]+/},{className:"string",variants:[{begin:/'/,end:/'/,contains:[{begin:/''/}]}]},{begin:/"/,end:/"/,contains:[{begin:/""/}]},e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,{className:"operator",begin:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0}]}},grmr_swift:e=>{const t={match:/\s+/,relevance:0},n=e.COMMENT("/\\*","\\*/",{contains:["self"]}),o=[e.C_LINE_COMMENT_MODE,n],a={match:[/\./,zr(...zi,...qi)],className:{2:"keyword"}},r={match:Fr(/\./,zr(...Wi)),relevance:0},i=Wi.filter((e=>"string"==typeof e)).concat(["_|0"]),s={variants:[{className:"keyword",match:zr(...Wi.filter((e=>"string"!=typeof e)).concat(Hi).map(Fi),...qi)}]},l={$pattern:zr(/\b\w+/,/#\w+/),keyword:i.concat(Zi),literal:Gi},c=[a,r,s],d=[{match:Fr(/\./,zr(...Vi)),relevance:0},{className:"built_in",match:Fr(/\b/,zr(...Vi),/(?=\()/)}],u={match:/->/,relevance:0},p=[u,{className:"operator",relevance:0,variants:[{match:Yi},{match:`\\.(\\.|${Xi})+`}]}],m="([0-9a-fA-F]_*)+",g={className:"number",relevance:0,variants:[{match:"\\b(([0-9]_*)+)(\\.(([0-9]_*)+))?([eE][+-]?(([0-9]_*)+))?\\b"},{match:`\\b0x(${m})(\\.(${m}))?([pP][+-]?(([0-9]_*)+))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},h=(e="")=>({className:"subst",variants:[{match:Fr(/\\/,e,/[0\\tnr"']/)},{match:Fr(/\\/,e,/u\{[0-9a-fA-F]{1,8}\}/)}]}),f=(e="")=>({className:"subst",match:Fr(/\\/,e,/[\t ]*(?:[\r\n]|\r\n)/)}),_=(e="")=>({className:"subst",label:"interpol",begin:Fr(/\\/,e,/\(/),end:/\)/}),b=(e="")=>({begin:Fr(e,/"""/),end:Fr(/"""/,e),contains:[h(e),f(e),_(e)]}),v=(e="")=>({begin:Fr(e,/"/),end:Fr(/"/,e),contains:[h(e),_(e)]}),y={className:"string",variants:[b(),b("#"),b("##"),b("###"),v(),v("#"),v("##"),v("###")]},w={match:Fr(/`/,ts,/`/)},k=[w,{className:"variable",match:/\$\d+/},{className:"variable",match:`\\$${es}+`}],E=[{match:/(@|#(un)?)available/,className:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:as,contains:[...p,g,y]}]}},{className:"keyword",match:Fr(/@/,zr(...os))},{className:"meta",match:Fr(/@/,ts)}],$={match:jr(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:Fr(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,es,"+")},{className:"type",match:ns,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:Fr(/\s+&\s+/,jr(ns)),relevance:0}]},x={begin:/</,end:/>/,keywords:l,contains:[...o,...c,...E,u,$]};$.contains.push(x);const S={begin:/\(/,end:/\)/,relevance:0,keywords:l,contains:["self",{match:Fr(ts,/\s*:/),keywords:"_|0",relevance:0},...o,...c,...d,...p,g,y,...k,...E,$]},N={begin:/</,end:/>/,contains:[...o,$]},C={begin:/\(/,end:/\)/,keywords:l,contains:[{begin:zr(jr(Fr(ts,/\s*:/)),jr(Fr(ts,/\s+/,ts,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:ts}]},...o,...c,...p,g,y,...E,$,S],endsParent:!0,illegal:/["']/},A={match:[/func/,/\s+/,zr(w.match,ts,Yi)],className:{1:"keyword",3:"title.function"},contains:[N,C,t],illegal:[/\[/,/%/]},M={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[N,C,t],illegal:/\[|%/},O={match:[/operator/,/\s+/,Yi],className:{1:"keyword",3:"title"}},T={begin:[/precedencegroup/,/\s+/,ns],className:{1:"keyword",3:"title"},contains:[$],keywords:[...Ki,...Gi],end:/}/};for(const e of y.variants){const t=e.contains.find((e=>"interpol"===e.label));t.keywords=l;const n=[...c,...d,...p,g,y,...k];t.contains=[...n,{begin:/\(/,end:/\)/,contains:["self",...n]}]}return{name:"Swift",keywords:l,contains:[...o,A,M,{beginKeywords:"struct protocol class extension enum actor",end:"\\{",excludeEnd:!0,keywords:l,contains:[e.inherit(e.TITLE_MODE,{className:"title.class",begin:/[A-Za-z$_][\u00C0-\u02B80-9A-Za-z$_]*/}),...c]},O,T,{beginKeywords:"import",end:/$/,contains:[...o],relevance:0},...c,...d,...p,g,y,...k,...E,$,S]}},grmr_typescript:e=>{const t=Ui(e),n=["any","void","number","boolean","string","object","never","enum"],o={beginKeywords:"namespace",end:/\{/,excludeEnd:!0,contains:[t.exports.CLASS_REFERENCE]},a={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:n},contains:[t.exports.CLASS_REFERENCE]},r={$pattern:"[A-Za-z$_][0-9A-Za-z$_]*",keyword:Ri.concat(["type","namespace","typedef","interface","public","private","protected","implements","declare","abstract","readonly"]),literal:Di,built_in:Bi.concat(n),"variable.language":ji},i={className:"meta",begin:"@[A-Za-z$_][0-9A-Za-z$_]*"},s=(e,t,n)=>{const o=e.contains.findIndex((e=>e.label===t));if(-1===o)throw Error("can not find mode to replace");e.contains.splice(o,1,n)};return Object.assign(t.keywords,r),t.exports.PARAMS_CONTAINS.push(i),t.contains=t.contains.concat([i,o,a]),s(t,"shebang",e.SHEBANG()),s(t,"use_strict",{className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/}),t.contains.find((e=>"func.def"===e.label)).relevance=0,Object.assign(t,{name:"TypeScript",aliases:["ts","tsx"]}),t},grmr_vbnet:e=>{const t=e.regex,n=/\d{1,2}\/\d{1,2}\/\d{4}/,o=/\d{4}-\d{1,2}-\d{1,2}/,a=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,r=/\d{1,2}(:\d{1,2}){1,2}/,i={className:"literal",variants:[{begin:t.concat(/# */,t.either(o,n),/ *#/)},{begin:t.concat(/# */,r,/ *#/)},{begin:t.concat(/# */,a,/ *#/)},{begin:t.concat(/# */,t.either(o,n),/ +/,t.either(a,r),/ *#/)}]},s=e.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),l=e.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]});return{name:"Visual Basic .NET",aliases:["vb"],case_insensitive:!0,classNameAliases:{label:"symbol"},keywords:{keyword:"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield",built_in:"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort",type:"boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort",literal:"true false nothing"},illegal:"//|\\{|\\}|endif|gosub|variant|wend|^\\$ ",contains:[{className:"string",begin:/"(""|[^/n])"C\b/},{className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},i,{className:"number",relevance:0,variants:[{begin:/\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/},{begin:/\b\d[\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\dA-F_]+((U?[SIL])|[%&])?/},{begin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},{className:"label",begin:/^\w+:/},s,l,{className:"meta",begin:/[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,end:/$/,keywords:{keyword:"const disable else elseif enable end externalsource if region then"},contains:[l]}]}},grmr_yaml:e=>{const t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",o={className:"string",relevance:0,variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,{className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]}]},a=e.inherit(o,{variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),r={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},i={begin:/\{/,end:/\}/,contains:[r],illegal:"\\n",relevance:0},s={begin:"\\[",end:"\\]",contains:[r],illegal:"\\n",relevance:0},l=[{className:"attr",variants:[{begin:"\\w[\\w :\\/.-]*:(?=[ \t]|$)"},{begin:'"\\w[\\w :\\/.-]*":(?=[ \t]|$)'},{begin:"'\\w[\\w :\\/.-]*':(?=[ \t]|$)"}]},{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},{className:"number",begin:"\\b[0-9]{4}(-[0-9][0-9]){0,2}([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?(\\.[0-9]*)?([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?\\b"},{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},i,s,o],c=[...l];return c.pop(),c.push(a),r.contains=c,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:l}}});const is=Ei;for(const e of Object.keys(rs)){const t=e.replace("grmr_","").replace("_","-");is.registerLanguage(t,rs[e])}
/*! `julia` grammar compiled for Highlight.js 11.4.0 */var ss=e=>{var t="[A-Za-z_\\u00A1-\\uFFFF][A-Za-z_0-9\\u00A1-\\uFFFF]*",n={$pattern:t,keyword:["baremodule","begin","break","catch","ccall","const","continue","do","else","elseif","end","export","false","finally","for","function","global","if","import","in","isa","let","local","macro","module","quote","return","true","try","using","where","while"],literal:["ARGS","C_NULL","DEPOT_PATH","ENDIAN_BOM","ENV","Inf","Inf16","Inf32","Inf64","InsertionSort","LOAD_PATH","MergeSort","NaN","NaN16","NaN32","NaN64","PROGRAM_FILE","QuickSort","RoundDown","RoundFromZero","RoundNearest","RoundNearestTiesAway","RoundNearestTiesUp","RoundToZero","RoundUp","VERSION|0","devnull","false","im","missing","nothing","pi","stderr","stdin","stdout","true","undef","ฯ","โฏ"],built_in:["AbstractArray","AbstractChannel","AbstractChar","AbstractDict","AbstractDisplay","AbstractFloat","AbstractIrrational","AbstractMatrix","AbstractRange","AbstractSet","AbstractString","AbstractUnitRange","AbstractVecOrMat","AbstractVector","Any","ArgumentError","Array","AssertionError","BigFloat","BigInt","BitArray","BitMatrix","BitSet","BitVector","Bool","BoundsError","CapturedException","CartesianIndex","CartesianIndices","Cchar","Cdouble","Cfloat","Channel","Char","Cint","Cintmax_t","Clong","Clonglong","Cmd","Colon","Complex","ComplexF16","ComplexF32","ComplexF64","CompositeException","Condition","Cptrdiff_t","Cshort","Csize_t","Cssize_t","Cstring","Cuchar","Cuint","Cuintmax_t","Culong","Culonglong","Cushort","Cvoid","Cwchar_t","Cwstring","DataType","DenseArray","DenseMatrix","DenseVecOrMat","DenseVector","Dict","DimensionMismatch","Dims","DivideError","DomainError","EOFError","Enum","ErrorException","Exception","ExponentialBackOff","Expr","Float16","Float32","Float64","Function","GlobalRef","HTML","IO","IOBuffer","IOContext","IOStream","IdDict","IndexCartesian","IndexLinear","IndexStyle","InexactError","InitError","Int","Int128","Int16","Int32","Int64","Int8","Integer","InterruptException","InvalidStateException","Irrational","KeyError","LinRange","LineNumberNode","LinearIndices","LoadError","MIME","Matrix","Method","MethodError","Missing","MissingException","Module","NTuple","NamedTuple","Nothing","Number","OrdinalRange","OutOfMemoryError","OverflowError","Pair","PartialQuickSort","PermutedDimsArray","Pipe","ProcessFailedException","Ptr","QuoteNode","Rational","RawFD","ReadOnlyMemoryError","Real","ReentrantLock","Ref","Regex","RegexMatch","RoundingMode","SegmentationFault","Set","Signed","Some","StackOverflowError","StepRange","StepRangeLen","StridedArray","StridedMatrix","StridedVecOrMat","StridedVector","String","StringIndexError","SubArray","SubString","SubstitutionString","Symbol","SystemError","Task","TaskFailedException","Text","TextDisplay","Timer","Tuple","Type","TypeError","TypeVar","UInt","UInt128","UInt16","UInt32","UInt64","UInt8","UndefInitializer","UndefKeywordError","UndefRefError","UndefVarError","Union","UnionAll","UnitRange","Unsigned","Val","Vararg","VecElement","VecOrMat","Vector","VersionNumber","WeakKeyDict","WeakRef"]},o={keywords:n,illegal:/<\//},a={className:"subst",begin:/\$\(/,end:/\)/,keywords:n},r={className:"variable",begin:"\\$"+t},i={className:"string",contains:[e.BACKSLASH_ESCAPE,a,r],variants:[{begin:/\w*"""/,end:/"""\w*/,relevance:10},{begin:/\w*"/,end:/"\w*/}]},s={className:"string",contains:[e.BACKSLASH_ESCAPE,a,r],begin:"`",end:"`"},l={className:"meta",begin:"@"+t};return o.name="Julia",o.contains=[{className:"number",begin:/(\b0x[\d_]*(\.[\d_]*)?|0x\.\d[\d_]*)p[-+]?\d+|\b0[box][a-fA-F0-9][a-fA-F0-9_]*|(\b\d[\d_]*(\.[\d_]*)?|\.\d[\d_]*)([eEfF][-+]?\d+)?/,relevance:0},{className:"string",begin:/'(.|\\[xXuU][a-zA-Z0-9]+)'/},i,s,l,{className:"comment",variants:[{begin:"#=",end:"=#",relevance:10},{begin:"#",end:"$"}]},e.HASH_COMMENT_MODE,{className:"keyword",begin:"\\b(((abstract|primitive)\\s+)type|(mutable\\s+)?struct)\\b"},{begin:/<:/}],a.contains=o.contains,o},ls=ss,cs=e=>({name:"Julia REPL",contains:[{className:"meta",begin:/^julia>/,relevance:10,starts:{end:/^(?![ ]{6})/,subLanguage:"julia"}}],aliases:["jldoctest"]});is.registerLanguage("julia",ls),is.registerLanguage("julia-repl",cs),window.hljs=is;var ds=is;St=r("hiQgq"),io=r("1gqBQ");r("9Ta4i");i=r("cNaMA");const us=({process_waiting_for_permission:e,risky_file_source:t,restart:n,warn_about_untrusted_code:o})=>i.html`
<div class="outline-frame safe-preview"></div>
${e?i.html`<div class="outline-frame-actions-container safe-preview">
<div class="safe-preview-info">
<span
>Safe preview
<button
onclick=${e=>{io.open_pluto_popup({type:"info",big:!0,should_focus:!0,body:i.html`
<h1>Safe preview</h1>
<p>You are reading and editing this file without running Julia code.</p>
<p>
${"When you are ready, you can "}<a
href="#"
onClick=${e=>{e.preventDefault(),n(!0),window.dispatchEvent(new CustomEvent("close pluto popup"))}}
>run this notebook</a
>.
</p>
${o?i.html`
<pluto-output class="rich_output"
><div class="markdown">
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>Are you sure that you trust this file?</p>
${null==t?null:i.html`<p><code>${t}</code></pre>`}
<p>A malicious notebook can steal passwords and data.</p>
</div>
</div></pluto-output
>
`:null}
`})}}
>
<span><span class="info-icon pluto-icon"></span></span>
</button>
</span>
</div>
</div>`:null}
`,ps=()=>i.html`<pluto-output class="rich_output"
><div class="safe-preview-output">
<span class="offline-icon pluto-icon"></span><span>${"Code not executed in "}<em>Safe preview</em></span>
</div></pluto-output
>`;class ms extends i.Component{constructor(){super(),this.state={output_changed_once:!1},this.old_height=0,this.resize_observer=new ResizeObserver((e=>{const t=this.base.offsetHeight;if(document.body.querySelector("pluto-cell:focus-within")){var n;const e=document.body.querySelectorAll("pluto-cell:focus-within ~ pluto-cell > pluto-output");"SUMMARY"===(null===(n=document.activeElement)||void 0===n?void 0:n.tagName)||0!==e.length&&Array.from(e).includes(this.base)||window.scrollBy(0,t-this.old_height)}this.old_height=t}))}shouldComponentUpdate({last_run_timestamp:e,sanitize_html:t}){return e!==this.props.last_run_timestamp||t!==this.props.sanitize_html}componentDidUpdate(e){this.props.last_run_timestamp!==e.last_run_timestamp&&this.setState({output_changed_once:!0})}componentDidMount(){this.resize_observer.observe(this.base)}componentWillUnmount(){this.resize_observer.unobserve(this.base)}render(){const e=this.props.errored||!this.props.body||"application/vnd.pluto.tree+object"!==this.props.mime&&"application/vnd.pluto.table+object"!==this.props.mime&&"text/plain"!==this.props.mime,t=!this.props.errored&&e;return i.html`
<pluto-output
class=${ve.cl({rich_output:e,scroll_y:"application/vnd.pluto.table+object"===this.props.mime||"text/plain"===this.props.mime})}
translate=${t}
mime=${this.props.mime}
aria-live=${this.state.output_changed_once?"polite":"off"}
aria-atomic="true"
aria-relevant="all"
aria-label=${null==this.props.rootassignee?"Result of unlabeled cell:":`Result of variable ${this.props.rootassignee}:`}
>
<assignee aria-hidden="true" translate=${!1}>${n=this.props.rootassignee,n&&n.startsWith("const ")?i.html`<span style="color: var(--cm-keyword-color)">const</span> ${n.slice(6)}`:n}</assignee>
<${hs} ...${this.props} />
</pluto-output>
`;var n}}let gs=({body:e,mime:t})=>{let n=i.useRef();return i.useLayoutEffect((()=>{let o=URL.createObjectURL(new Blob([e],{type:t}));return n.current.onload=n.current.onerror=()=>{n.current&&(n.current.style.display=null)},""===n.current.src&&(n.current.style.display="none"),n.current.type=t,n.current.src=o,()=>URL.revokeObjectURL(o)}),[e,t]),i.html`<img ref=${n} type=${t} src=${""} />`};const hs=({mime:e,body:t,cell_id:n,persist_js_state:o=!1,last_run_timestamp:a,sanitize_html:r=!0})=>{switch(r="false"!==r&&!1!==r,o="true"===o||!0===o,e){case"image/png":case"image/jpg":case"image/jpeg":case"image/gif":case"image/bmp":case"image/svg+xml":return i.html`<div><${gs} mime=${e} body=${t} /></div>`;case"text/html":return t.startsWith("<!DOCTYPE")||t.startsWith("<html")?r?null:i.html`<${fs} body=${t} />`:i.html`<${Es}
cell_id=${n}
body=${t}
persist_js_state=${o}
last_run_timestamp=${a}
sanitize_html=${r}
/>`;case"application/vnd.pluto.tree+object":return i.html`<div>
<${fr} cell_id=${n} body=${t} persist_js_state=${o} sanitize_html=${r} />
</div>`;case"application/vnd.pluto.table+object":return i.html`<${vr} cell_id=${n} body=${t} persist_js_state=${o} sanitize_html=${r} />`;case"application/vnd.pluto.parseerror+object":return i.html`<div><${cr} cell_id=${n} ...${t} /></div>`;case"application/vnd.pluto.stacktrace+object":return i.html`<div><${dr} cell_id=${n} ...${t} /></div>`;case"application/vnd.pluto.divelement+object":return(({cell_id:e,style:t,classname:n,children:o,persist_js_state:a=!1,sanitize_html:r=!0})=>i.html`<div style=${t} class=${n}>${o.map((t=>i.html`<${pr} cell_id=${e} mime=${t[1]} body=${t[0]} persist_js_state=${a} sanitize_html=${r} />`))}</div>`)({cell_id:n,...t,persist_js_state:o,sanitize_html:r});case"text/plain":return t?i.html`<div>
<pre class="no-block"><code>${t}</code></pre>
</div>`:i.html`<div></div>`;case null:case void 0:case"":return i.html``;default:return i.html`<pre title="Something went wrong displaying this object">๐</pre>`}};Sr.default(hs,"pluto-display",["mime","body","cell_id","persist_js_state","last_run_timestamp","sanitize_html"]);let fs=({body:e})=>{let t=i.useRef();return i.useLayoutEffect((()=>{let n=URL.createObjectURL(new Blob([e],{type:"text/html"}));return t.current.src=n,ws((async()=>{await new Promise((e=>t.current.addEventListener("load",(()=>e(null)))));let e=t.current.contentWindow.document,n=document.querySelector("#iframe-resizer-content-window-script"),o=e.createElement("script");o.src=n.src,o.crossOrigin="anonymous",e.head.appendChild(o),new Promise((e=>o.addEventListener("load",(()=>e(null))))),window.iFrameResize({checkOrigin:!1},t.current)})),()=>URL.revokeObjectURL(n)}),[e]),i.html`<iframe
style=${{width:"100%",border:"none"}}
src=""
ref=${t}
frameborder="0"
allow="accelerometer; ambient-light-sensor; autoplay; battery; camera; display-capture; document-domain; encrypted-media; execution-while-not-rendered; execution-while-out-of-viewport; fullscreen; geolocation; gyroscope; layout-animations; legacy-image-formats; magnetometer; microphone; midi; navigation-override; oversized-images; payment; picture-in-picture; publickey-credentials-get; sync-xhr; usb; wake-lock; screen-wake-lock; vr; web-share; xr-spatial-tracking"
allowfullscreen
></iframe>`},_s=async({environment:e,code:t})=>{const n=`"use strict"; return (async () => {${t}})()`;let{this:o,...a}=e,r=Object.keys(a),i=Object.values(a);return await Function(...r,n).bind(o)(...i)},bs=0,vs=async(e,t)=>{let n=document.createElement("script");for(let t of e.attributes)n.attributes.setNamedItem(t.cloneNode(!0));const o=`____FUNCTION_TO_RUN_INSIDE_SCRIPT_${bs}`;n.textContent=`{\n window.${o}.result = window.${o}.function_to_run(window.${o}.currentScript)\n }`,window[o]={function_to_run:t,currentScript:n,result:null};const a=e.parentNode;if(null==a)throw"Failed to execute script it has no parent in DOM.";a.replaceChild(n,e);let r=await window[o].result;return window[o]={function_to_run:t,result:null},{node:n,result:r}};const ys=e=>e instanceof Element&&e.nodeType===Node.ELEMENT_NODE;let ws=e=>e(),ks=e=>{try{const t=e.getAttribute("shadowroot"),n=e.parentElement.attachShadow({mode:t});n.appendChild(e.content),e.remove();return Array.from(n.querySelectorAll("script, template[shadowroot]")).flatMap((e=>"SCRIPT"===e.nodeName?[e]:"TEMPLATE"===e.nodeName?ks(e):void 0))}catch(t){return console.error("Couldn't attach declarative shadow dom to",e,"because of",t),[]}},Es=({body:e,className:t="",persist_js_state:n=!1,last_run_timestamp:o,sanitize_html:a=!0,sanitize_html_message:r=!0})=>{let s=i.useContext(ye),l=i.useContext(we),c=i.useContext(ke),d=i.useRef(new Map),u=i.useRef((()=>{})),p=i.useRef(null);return i.useLayoutEffect((()=>{p.current&&l&&Er(p.current.querySelectorAll("bond"),l)}),[e,n,s,l,a]),i.useLayoutEffect((()=>{const t=p.current;if(null==t)return;let o=new Promise((e=>{u.current=()=>{e(null)}}));document.createElement("p-dumpster").append(...t.childNodes);let m=a?$t.sanitize(e,{FORBID_TAGS:["style"],ADD_ATTR:["target"]}):e;if(t.innerHTML=m,r&&m!==e){const n=new DOMParser,o=n.parseFromString(e,"text/html");if(n.parseFromString(m,"text/html").documentElement.innerHTML!==o.documentElement.innerHTML){console.info("HTML sanitized",{body:e,html_content_to_set:m});let n=document.createElement("div");n.innerHTML='<div class="safe-preview-output">\n<span class="offline-icon pluto-icon"></span><span>Scripts and styles not rendered in <em>Safe preview</em></span>\n</div>',t.prepend(n)}}if(a)return;const g=[...Array.from(t.querySelectorAll("template[shadowroot]")).flatMap((e=>ks(e))),...Array.from(t.querySelectorAll("script"))];return ws((async()=>{try{var e;if(null==c||c.add(t),d.current=await(async({root_node:e,script_nodes:t,previous_results_map:n,invalidation:o,pluto_actions:a})=>{let r=new Map;for(let e of t)if(null!=e.src&&""!==e.src);else{let t=e.id,o=t?n.get(t):null;ys(o)&&(null===(s=e.parentElement)||void 0===s||s.insertBefore(o,e))}for(let l of t){if(bs+=1,null!=l.src&&""!==l.src){let e=Array.from(document.head.querySelectorAll("script")).find((e=>e.src===l.src));null==e&&(e=document.createElement("script"),e.referrerPolicy=l.referrerPolicy,e.crossOrigin=l.crossOrigin,e.integrity=l.integrity,e.noModule=l.noModule,e.nonce=l.nonce,e.type=l.type,e.src=l.src,e.pluto_is_loading_me=!0);let t=e;null!=t.pluto_is_loading_me&&(await new Promise((e=>{t.addEventListener("load",e),t.addEventListener("error",e),document.head.appendChild(t)})),t.pluto_is_loading_me=void 0)}else try{let t=l.innerText,c=l.id,d=c?n.get(c):null;if("module"===l.type&&console.warn("We don't (yet) fully support <script type=module> (loading modules with <script type=module src=...> is fine)."),""===l.type||"text/javascript"===l.type||"module"===l.type){var i;ys(d)&&(null===(i=l.parentElement)||void 0===i||i.insertBefore(d,l));const n=e.closest("pluto-cell");let{node:u,result:p}=await vs(l,(async e=>await _s({environment:{this:c?d:window,currentScript:e,invalidation:o,getPublishedObject:e=>n.getPublishedObject(e),getBoundElementValueLikePluto:yr,setBoundElementValueLikePluto:kr,getBoundElementEventNameLikePluto:wr,getNotebookMetadataExperimental:e=>{var t;return null===(t=a.get_notebook())||void 0===t?void 0:t.metadata[e]},setNotebookMetadataExperimental:(e,t)=>a.update_notebook((n=>{n.metadata[e]=t})),deleteNotebookMetadataExperimental:e=>a.update_notebook((t=>{delete t.metadata[e]})),...null==n?{}:{getCellMetadataExperimental:(e,{cell_id:t=null}={})=>{var o,r,i;return null===(o=a.get_notebook())||void 0===o||null===(r=o.cell_inputs)||void 0===r||null===(i=r[t??n.id])||void 0===i?void 0:i.metadata[e]},setCellMetadataExperimental:(e,t,{cell_id:o=null}={})=>a.update_notebook((a=>{a.cell_inputs[o??n.id].metadata[e]=t})),deleteCellMetadataExperimental:(e,{cell_id:t=null}={})=>a.update_notebook((o=>{delete o.cell_inputs[t??n.id].metadata[e]}))},...no.observablehq_for_cells},code:t})));var s;null!=c&&r.set(c,p),p!==d&&(ys(d)&&d.remove(),ys(p)&&(null===(s=u.parentElement)||void 0===s||s.insertBefore(p,u)))}}catch(e){console.error("Couldn't execute script:",l),console.error(e)}bs-=1}return r})({root_node:t,script_nodes:g,invalidation:o,previous_results_map:n?d.current:new Map,pluto_actions:s}),null!=s){const e=(e,t)=>{var n;return(null==s||null===(n=s.set_bond)||void 0===n?void 0:n.call(s,e,t))??Promise.resolve()},n=t.querySelectorAll("bond");Er(n,l??{}),$r(n,e,l??{},o),((e,t)=>{e.forEach((e=>{const n=e=>{e.target.closest(".bonds_disabled:where(.offer_binder, .offer_local)")&&io.open_pluto_popup({type:"info",source_element:e.target,body:i.html`${"You are viewing a static document. "}
<a
href="#"
onClick=${e=>{window.open_edit_or_run_popup(),e.preventDefault(),window.dispatchEvent(new CustomEvent("close pluto popup"))}}
>Run this notebook</a
>
${" to enable interactivity."}`})};e.addEventListener("click",n),t.then((()=>{e.removeEventListener("click",n)}))}))})(n,o)}if(null!=(null===(e=window.MathJax)||void 0===e?void 0:e.typeset))try{window.MathJax.typeset(t.querySelectorAll(".tex"))}catch(e){console.info("Failed to typeset TeX:"),console.info(e)}try{t.querySelectorAll("code").forEach((e=>{e.classList.forEach((t=>{if(t.startsWith("language-")&&!t.endsWith("undefined")){let n=t.substring(9);$s(e,n)}}))}))}catch(e){console.warn("Highlighting failed",e)}}finally{null==c||c.delete(t)}})),()=>{var e;null==c||c.delete(t),null===(e=u.current)||void 0===e||e.call(u)}}),[e,o,s,a]),i.html`<div class="raw-html-wrapper ${t}" ref=${p}></div>`};let $s=(e,t)=>{t="jl"===(t=t.toLowerCase())?"julia":t,0===e.children.length&&("htmlmixed"===t&&(e.classList.remove("language-htmlmixed"),e.classList.add("language-html")),ds.highlightElement(e))};r("9Ta4i");ve=r("aN0pg"),i=r("cNaMA"),i=r("cNaMA"),ve=r("aN0pg"),i=r("cNaMA"),ce=r("9Ta4i");const xs={current:null},Ss=()=>{const[e,t]=i.useState(null);return i.useEffect((()=>{(()=>{if(null!=xs.current)return xs.current;{const e=fetch("https://julia-loading-times-test.netlify.app/pkg_load_times.csv").then((e=>e.text())).then((e=>{const t=e.split("\n");return t[0].split(","),new Map(t.slice(1).map((e=>{let[t,...n]=e.split(",");return[t,{install:Number(n[0]),precompile:Number(n[1]),load:Number(n[2])}]})))})),t=fetch("https://julia-loading-times-test.netlify.app/top_packages_sorted_with_deps.txt").then((e=>e.text())).then((e=>new Map(e.split("\n").map((e=>{let[t,...n]=e.split(",");return[t,n]})))));return xs.current=Promise.all([e,t]).then((([e,t])=>({times:e,packages:t}))),xs.current}})().then(t)}),[]),e},Ns=(e,t,n=[])=>{const o=e.packages.get(t);if(null==o)return[];{const t=ce.default.union(n,o);return[...o,...ce.default.difference(o,n).flatMap((n=>Ns(e,n,t)))]}},Cs={install:2,load:1,precompile:.3};ce=r("9Ta4i"),i=r("cNaMA");r("kjWx8");var As=window.CustomEvent;function Ms(e,t){var n="on"+t.type.toLowerCase();return"function"==typeof e[n]&&e[n](t),e.dispatchEvent(t)}function Os(e){for(;e;){if("dialog"===e.localName)return e;e=e.parentElement?e.parentElement:e.parentNode?e.parentNode.host:null}return null}function Ts(e){for(;e&&e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;e&&e.blur&&e!==document.body&&e.blur()}function Rs(e,t){for(var n=0;n<e.length;++n)if(e[n]===t)return!0;return!1}function Ds(e){return!(!e||!e.hasAttribute("method"))&&"dialog"===e.getAttribute("method").toLowerCase()}function Ls(e){var t=["button","input","keygen","select","textarea"].map((function(e){return e+":not([disabled])"}));t.push('[tabindex]:not([disabled]):not([tabindex=""])');var n=e.querySelector(t.join(", "));if(!n&&"attachShadow"in Element.prototype)for(var o=e.querySelectorAll("*"),a=0;a<o.length&&!(o[a].tagName&&o[a].shadowRoot&&(n=Ls(o[a].shadowRoot)));a++);return n}function Is(e){return e.isConnected||document.body.contains(e)}function Ps(e){if(e.submitter)return e.submitter;var t=e.target;if(!(t instanceof HTMLFormElement))return null;var n=Us.formSubmitter;if(!n){var o=e.target;n=("getRootNode"in o&&o.getRootNode()||document).activeElement}return n&&n.form===t?n:null}function js(e){if(!e.defaultPrevented){var t=e.target,n=Us.imagemapUseValue,o=Ps(e);null===n&&o&&(n=o.value);var a=Os(t);a&&"dialog"===(o&&o.getAttribute("formmethod")||t.getAttribute("method"))&&(e.preventDefault(),null!=n?a.close(n):a.close())}}function Bs(e){if(this.dialog_=e,this.replacedStyleTop_=!1,this.openAsModal_=!1,e.hasAttribute("role")||e.setAttribute("role","dialog"),e.show=this.show.bind(this),e.showModal=this.showModal.bind(this),e.close=this.close.bind(this),e.addEventListener("submit",js,!1),"returnValue"in e||(e.returnValue=""),"MutationObserver"in window)new MutationObserver(this.maybeHideModal.bind(this)).observe(e,{attributes:!0,attributeFilter:["open"]});else{var t,n=!1,o=function(){n?this.downgradeModal():this.maybeHideModal(),n=!1}.bind(this),a=function(a){if(a.target===e){var r="DOMNodeRemoved";n|=a.type.substr(0,r.length)===r,window.clearTimeout(t),t=window.setTimeout(o,0)}};["DOMAttrModified","DOMNodeRemoved","DOMNodeRemovedFromDocument"].forEach((function(t){e.addEventListener(t,a)}))}Object.defineProperty(e,"open",{set:this.setOpen.bind(this),get:e.hasAttribute.bind(e,"open")}),this.backdrop_=document.createElement("div"),this.backdrop_.className="backdrop",this.backdrop_.addEventListener("mouseup",this.backdropMouseEvent_.bind(this)),this.backdrop_.addEventListener("mousedown",this.backdropMouseEvent_.bind(this)),this.backdrop_.addEventListener("click",this.backdropMouseEvent_.bind(this))}As&&"object"!=typeof As||((As=function(e,t){t=t||{};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,!!t.bubbles,!!t.cancelable,t.detail||null),n}).prototype=window.Event.prototype),Bs.prototype={get dialog(){return this.dialog_},maybeHideModal:function(){this.dialog_.hasAttribute("open")&&Is(this.dialog_)||this.downgradeModal()},downgradeModal:function(){this.openAsModal_&&(this.openAsModal_=!1,this.dialog_.style.zIndex="",this.replacedStyleTop_&&(this.dialog_.style.top="",this.replacedStyleTop_=!1),this.backdrop_.parentNode&&this.backdrop_.parentNode.removeChild(this.backdrop_),Us.dm.removeDialog(this))},setOpen:function(e){e?this.dialog_.hasAttribute("open")||this.dialog_.setAttribute("open",""):(this.dialog_.removeAttribute("open"),this.maybeHideModal())},backdropMouseEvent_:function(e){if(this.dialog_.hasAttribute("tabindex"))this.dialog_.focus();else{var t=document.createElement("div");this.dialog_.insertBefore(t,this.dialog_.firstChild),t.tabIndex=-1,t.focus(),this.dialog_.removeChild(t)}var n=document.createEvent("MouseEvents");n.initMouseEvent(e.type,e.bubbles,e.cancelable,window,e.detail,e.screenX,e.screenY,e.clientX,e.clientY,e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,e.relatedTarget),this.dialog_.dispatchEvent(n),e.stopPropagation()},focus_:function(){var e=this.dialog_.querySelector("[autofocus]:not([disabled])");!e&&this.dialog_.tabIndex>=0&&(e=this.dialog_),e||(e=Ls(this.dialog_)),Ts(document.activeElement),e&&e.focus()},updateZIndex:function(e,t){if(e<t)throw new Error("dialogZ should never be < backdropZ");this.dialog_.style.zIndex=e,this.backdrop_.style.zIndex=t},show:function(){this.dialog_.open||(this.setOpen(!0),this.focus_())},showModal:function(){if(this.dialog_.hasAttribute("open"))throw new Error("Failed to execute 'showModal' on dialog: The element is already open, and therefore cannot be opened modally.");if(!Is(this.dialog_))throw new Error("Failed to execute 'showModal' on dialog: The element is not in a Document.");if(!Us.dm.pushDialog(this))throw new Error("Failed to execute 'showModal' on dialog: There are too many open modal dialogs.");(function(e){for(;e&&e!==document.body;){var t=window.getComputedStyle(e),n=function(e,n){return!(void 0===t[e]||t[e]===n)};if(t.opacity<1||n("zIndex","auto")||n("transform","none")||n("mixBlendMode","normal")||n("filter","none")||n("perspective","none")||"isolate"===t.isolation||"fixed"===t.position||"touch"===t.webkitOverflowScrolling)return!0;e=e.parentElement}return!1})(this.dialog_.parentElement)&&console.warn("A dialog is being shown inside a stacking context. This may cause it to be unusable. For more information, see this link: https://github.com/GoogleChrome/dialog-polyfill/#stacking-context"),this.setOpen(!0),this.openAsModal_=!0,Us.needsCentering(this.dialog_)?(Us.reposition(this.dialog_),this.replacedStyleTop_=!0):this.replacedStyleTop_=!1,this.dialog_.parentNode.insertBefore(this.backdrop_,this.dialog_.nextSibling),this.focus_()},close:function(e){if(!this.dialog_.hasAttribute("open"))throw new Error("Failed to execute 'close' on dialog: The element does not have an 'open' attribute, and therefore cannot be closed.");this.setOpen(!1),void 0!==e&&(this.dialog_.returnValue=e);var t=new As("close",{bubbles:!1,cancelable:!1});Ms(this.dialog_,t)}};var Us={reposition:function(e){var t=document.body.scrollTop||document.documentElement.scrollTop,n=t+(window.innerHeight-e.offsetHeight)/2;e.style.top=Math.max(t,n)+"px"},isInlinePositionSetByStylesheet:function(e){for(var t=0;t<document.styleSheets.length;++t){var n=document.styleSheets[t],o=null;try{o=n.cssRules}catch(e){}if(o)for(var a=0;a<o.length;++a){var r=o[a],i=null;try{i=document.querySelectorAll(r.selectorText)}catch(e){}if(i&&Rs(i,e)){var s=r.style.getPropertyValue("top"),l=r.style.getPropertyValue("bottom");if(s&&"auto"!==s||l&&"auto"!==l)return!0}}}return!1},needsCentering:function(e){return"absolute"===window.getComputedStyle(e).position&&!("auto"!==e.style.top&&""!==e.style.top||"auto"!==e.style.bottom&&""!==e.style.bottom)&&!Us.isInlinePositionSetByStylesheet(e)},forceRegisterDialog:function(e){if((window.HTMLDialogElement||e.showModal)&&console.warn("This browser already supports <dialog>, the polyfill may not work correctly",e),"dialog"!==e.localName)throw new Error("Failed to register dialog: The element is not a dialog.");new Bs(e)},registerDialog:function(e){e.showModal||Us.forceRegisterDialog(e)},DialogManager:function(){this.pendingDialogStack=[];var e=this.checkDOM_.bind(this);this.overlay=document.createElement("div"),this.overlay.className="_dialog_overlay",this.overlay.addEventListener("click",function(t){this.forwardTab_=void 0,t.stopPropagation(),e([])}.bind(this)),this.handleKey_=this.handleKey_.bind(this),this.handleFocus_=this.handleFocus_.bind(this),this.zIndexLow_=1e5,this.zIndexHigh_=100150,this.forwardTab_=void 0,"MutationObserver"in window&&(this.mo_=new MutationObserver((function(t){var n=[];t.forEach((function(e){for(var t,o=0;t=e.removedNodes[o];++o)t instanceof Element&&("dialog"===t.localName&&n.push(t),n=n.concat(t.querySelectorAll("dialog")))})),n.length&&e(n)})))}};if(Us.DialogManager.prototype.blockDocument=function(){document.documentElement.addEventListener("focus",this.handleFocus_,!0),document.addEventListener("keydown",this.handleKey_),this.mo_&&this.mo_.observe(document,{childList:!0,subtree:!0})},Us.DialogManager.prototype.unblockDocument=function(){document.documentElement.removeEventListener("focus",this.handleFocus_,!0),document.removeEventListener("keydown",this.handleKey_),this.mo_&&this.mo_.disconnect()},Us.DialogManager.prototype.updateStacking=function(){for(var e,t=this.zIndexHigh_,n=0;e=this.pendingDialogStack[n];++n)e.updateZIndex(--t,--t),0===n&&(this.overlay.style.zIndex=--t);var o=this.pendingDialogStack[0];o?(o.dialog.parentNode||document.body).appendChild(this.overlay):this.overlay.parentNode&&this.overlay.parentNode.removeChild(this.overlay)},Us.DialogManager.prototype.containedByTopDialog_=function(e){for(;e=Os(e);){for(var t,n=0;t=this.pendingDialogStack[n];++n)if(t.dialog===e)return 0===n;e=e.parentElement}return!1},Us.DialogManager.prototype.handleFocus_=function(e){var t=e.composedPath?e.composedPath()[0]:e.target;if(!this.containedByTopDialog_(t)&&document.activeElement!==document.documentElement&&(e.preventDefault(),e.stopPropagation(),Ts(t),void 0!==this.forwardTab_)){var n=this.pendingDialogStack[0];return n.dialog.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_PRECEDING&&(this.forwardTab_?n.focus_():t!==document.documentElement&&document.documentElement.focus()),!1}},Us.DialogManager.prototype.handleKey_=function(e){if(this.forwardTab_=void 0,27===e.keyCode){e.preventDefault(),e.stopPropagation();var t=new As("cancel",{bubbles:!1,cancelable:!0}),n=this.pendingDialogStack[0];n&&Ms(n.dialog,t)&&n.dialog.close()}else 9===e.keyCode&&(this.forwardTab_=!e.shiftKey)},Us.DialogManager.prototype.checkDOM_=function(e){this.pendingDialogStack.slice().forEach((function(t){-1!==e.indexOf(t.dialog)?t.downgradeModal():t.maybeHideModal()}))},Us.DialogManager.prototype.pushDialog=function(e){var t=(this.zIndexHigh_-this.zIndexLow_)/2-1;return!(this.pendingDialogStack.length>=t||(1===this.pendingDialogStack.unshift(e)&&this.blockDocument(),this.updateStacking(),0))},Us.DialogManager.prototype.removeDialog=function(e){var t=this.pendingDialogStack.indexOf(e);-1!==t&&(this.pendingDialogStack.splice(t,1),0===this.pendingDialogStack.length&&this.unblockDocument(),this.updateStacking())},Us.dm=new Us.DialogManager,Us.formSubmitter=null,Us.imagemapUseValue=null,void 0===window.HTMLDialogElement){var Fs=document.createElement("form");if(Fs.setAttribute("method","dialog"),"dialog"!==Fs.method){var zs=Object.getOwnPropertyDescriptor(HTMLFormElement.prototype,"method");if(zs){var qs=zs.get;zs.get=function(){return Ds(this)?"dialog":qs.call(this)};var Hs=zs.set;zs.set=function(e){return"string"==typeof e&&"dialog"===e.toLowerCase()?this.setAttribute("method",e):Hs.call(this,e)},Object.defineProperty(HTMLFormElement.prototype,"method",zs)}}document.addEventListener("click",(function(e){if(Us.formSubmitter=null,Us.imagemapUseValue=null,!e.defaultPrevented){var t=e.target;if("composedPath"in e&&(t=e.composedPath().shift()||t),t&&Ds(t.form)){if(!("submit"===t.type&&["button","input"].indexOf(t.localName)>-1)){if("input"!==t.localName||"image"!==t.type)return;Us.imagemapUseValue=e.offsetX+","+e.offsetY}Os(t)&&(Us.formSubmitter=t)}}}),!1),document.addEventListener("submit",(function(e){var t=e.target;if(!Os(t)){var n=Ps(e);"dialog"===(n&&n.getAttribute("formmethod")||t.getAttribute("method"))&&e.preventDefault()}}));var Ws=HTMLFormElement.prototype.submit;HTMLFormElement.prototype.submit=function(){if(!Ds(this))return Ws.call(this);var e=Os(this);e&&e.close()}}var Gs=Us;i=r("cNaMA");const Ks=()=>{const e=i.useRef(null);return i.useLayoutEffect((()=>{null!=e.current&&Gs.registerDialog(e.current)}),[e.current]),i.useMemo((()=>[e,()=>{var t;return null===(t=e.current)||void 0===t?void 0:t.showModal()},()=>{var t;return null===(t=e.current)||void 0===t?void 0:t.close()},()=>{var t,n,o;return!0===(null===(t=e.current)||void 0===t?void 0:t.open)?null===(n=e.current)||void 0===n?void 0:n.close():null===(o=e.current)||void 0===o?void 0:o.showModal()}]),[e])},Zs=({show:e,start_local:t})=>(window.open_edit_or_run_popup=()=>{t()},i.html`<div class="edit_or_run">
<button
onClick=${e=>{e.stopPropagation(),e.preventDefault(),t()}}
>
<b>Edit</b> or <b>run</b> this notebook
</button>
</div>`),Vs=({offer_binder:e,start_binder:t,notebookfile:n,notebook:o})=>{const[a,r,s,l]=Ks(),[c,d]=i.useState(!1),u=i.useRef("");u.current=n??"",window.open_edit_or_run_popup=r,i.useEffect((()=>(window.start_binder=e?t:null,()=>{window.start_binder=null})),[t,e]);const p=u.current.startsWith("data:"),m=Qs(o);return i.html`<div class="edit_or_run">
<button
onClick=${e=>{l(),e.stopPropagation(),e.preventDefault()}}
>
<b>Edit</b> or <b>run</b> this notebook
</button>
<dialog ref=${a} class="binder_help_text">
<span onClick=${s} class="close"></span>
${e?i.html`
<p style="text-align: center;">
${"To be able to edit code and run cells, you need to run the notebook yourself. "}
<b>Where would you like to run the notebook?</b>
</p>
${null==m?null:i.html` <div class="expected_runtime_box">${"This notebook takes about "}<span>${m}</span>${" to run."}</div>`}
<h2 style="margin-top: 3em;">In the cloud <em>(experimental)</em></h2>
<div style="padding: 0 2rem;">
<button onClick=${t}>
<img src="https://cdn.jsdelivr.net/gh/jupyterhub/binderhub@0.2.0/binderhub/static/logo.svg" height="30" alt="binder" />
</button>
</div>
<p style="opacity: .5; margin: 20px 10px;">
<a target="_blank" href="https://mybinder.org/">Binder</a> is a free, open source service that runs scientific notebooks in the cloud!
It will take a while, usually 2-7 minutes to get a session.
</p>
<h2 style="margin-top: 4em;">On your computer</h2>
<p style="opacity: .5;">(Recommended if you want to store your changes.)</p>
`:null}
<ol style="padding: 0 2rem;">
<li>
<div>
${p?i.html`
<div class="command">Download the notebook:</div>
<div
onClick=${e=>{"A"===e.target.tagName||e.target.closest("div").firstElementChild.click()}}
class="download_div"
>
<a href=${u.current} target="_blank" download="notebook.jl">notebook.jl</a>
<span class="download_icon"></span>
</div>
`:i.html`
<div class="command">Copy the notebook URL:</div>
<div class="copy_div">
<input onClick=${e=>e.target.select()} value=${u.current} readonly />
<span
class=${"copy_icon "+(c?"success_copy":"")}
onClick=${async()=>{await navigator.clipboard.writeText(u.current),d(!0),setTimeout((()=>d(!1)),3e3)}}
/>
</div>
`}
</div>
</li>
<li>
<div class="command">Run Pluto</div>
<p>
${"(Also see: "}
<a target="_blank" href="https://computationalthinking.mit.edu/Spring21/installation/">How to install Julia and Pluto</a>)
</p>
<img src="https://user-images.githubusercontent.com/6933510/107865594-60864b00-6e68-11eb-9625-2d11fd608e7b.png" />
</li>
<li>
${p?i.html`
<div class="command">Open the notebook file</div>
<p>Type the saved filename in the <em>open</em> box.</p>
<img src="https://user-images.githubusercontent.com/6933510/119374043-65556900-bcb9-11eb-9026-149c1ba2d05b.png" />
`:i.html`
<div class="command">Paste URL in the <em>Open</em> box</div>
<video playsinline autoplay loop src="https://i.imgur.com/wf60p5c.mp4" />
`}
</li>
</ol>
</dialog>
</div>`},Qs=e=>{const t=(e=>{var t;return(((null===(t=e.nbpkg)||void 0===t?void 0:t.install_time_ns)??NaN)+ce.default.sum(Object.values(e.cell_results).map((e=>e.runtime??0))))/1e9})(e);if(isNaN(t))return null;const n=ce.default.round(15+1.5*t,-1);return Xs(n)},Xs=e=>{const t=e/60,n=Math.ceil(e),o=Math.round(t);return e<60?`${n} second${n>1?"s":""}`:`${o} minute${o>1?"s":""}`};var Ys;Io=r("hrGZZ");Ys=new URL(r("ko7kR").resolve("asIno"),import.meta.url).toString();const Js=new URL(Ys);var el;el=new URL(r("ko7kR").resolve("1c0Rm"),import.meta.url).toString();const tl=new URL(el);var nl;nl=new URL(r("ko7kR").resolve("fUvXZ"),import.meta.url).toString();const ol=new URL(nl),al=({notebook:e,disable_input:t})=>{const[n,o]=i.useState(null),a=i.useRef(null);a.current=n;const r=i.useRef(null),s=i.useRef(""),l=i.useCallback((e=>{const t=e.detail.source_element;if(r.current=t,null==t)s.current="top: 20%; left: 50%; transform: translate(-50%, -50%); position: fixed;";else{const e=t.getBoundingClientRect(),n=document.body.getBoundingClientRect();s.current=`top: ${.5*(e.top+e.bottom)-n.top}px; left: min(max(0px,100vw - 251px - 30px), ${e.right-n.left}px);`}o(e.detail)}),[o]),c=i.useCallback((()=>{o(null)}),[o]);Io.useEventListener(window,"open pluto popup",l,[l]),Io.useEventListener(window,"close pluto popup",c,[c]),Io.useEventListener(window,"pointerdown",(e=>{null!=a.current&&null!=e.target&&null==e.target.closest("pluto-popup")&&(null!=r.current&&r.current.contains(e.target)||c())}),[c]),Io.useEventListener(window,"keydown",(e=>{"Escape"===e.key&&c()}),[c]);const d=i.useRef(null);i.useLayoutEffect((()=>{var e;null!=n&&(console.log(n),!0===n.should_focus?(console.log((null===(e=u.current)||void 0===e?void 0:e.querySelector("a"))??u.current),requestAnimationFrame((()=>{var e,t,n;d.current=document.activeElement,null===(t=(null===(e=u.current)||void 0===e?void 0:e.querySelector("a"))??u.current)||void 0===t||null===(n=t.focus)||void 0===n||n.call(t)}))):d.current=null)}),[null!=n]);const u=i.useRef(null);Io.useEventListener(u.current,"focusout",(e=>{if(null!=a.current&&!0===a.current.should_focus){var t,n,o;if(null===(t=u.current)||void 0===t?void 0:t.matches(":focus-within"))return;if(null!=r.current&&(r.current.contains(e.relatedTarget)||r.current.matches(":focus-within")))return;c(),e.preventDefault(),null===(n=d.current)||void 0===n||null===(o=n.focus)||void 0===o||o.call(n)}}),[c]);const p=null==n?void 0:n.type;return i.html`<pluto-popup
class=${ve.cl({visible:null!=n,[p??""]:null!=p,big:!0===(null==n?void 0:n.big)})}
style="${s.current}"
ref=${u}
tabindex=${"0"}
>
${"nbpkg"===p?i.html`<${rl}
notebook=${e}
disable_input=${t}
recent_event=${n}
clear_recent_event=${()=>o(null)}
/>`:"info"===p||"warn"===p?i.html`<div>${null==n?void 0:n.body}</div>`:null}
</pluto-popup>
<div tabindex="0">
<!-- We need this dummy tabindexable element here so that the element_focused_before_popup mechanism works on static exports. When tabbing out of the popup, focus would otherwise leave the page altogether because it's the last focusable element in DOM. -->
</div>`},rl=({notebook:e,recent_event:t,clear_recent_event:n,disable_input:o})=>{var a,r,s,l,c,d,u;let p=i.useContext(ye);const[m,g]=i.useState(null);var h;i.useEffect((()=>{let n=!0;return null==t?g(null):"nbpkg"===(null==t?void 0:t.type)&&(p.get_avaible_versions({package_name:t.package_name,notebook_id:e.notebook_id})??Promise.resolve([])).then((o=>{n&&g(ra({nbpkg:e.nbpkg,package_name:t.package_name,is_disable_pkg:t.is_disable_pkg,available_versions:o}))})),()=>{n=!1}}),[t,...(h=e.nbpkg,null==h?[null]:Object.entries(h).flatMap((([e,t])=>"terminal_outputs"===e?[]:[t])))]),i.useEffect((()=>{var t;((null===(t=e.nbpkg)||void 0===t?void 0:t.enabled)??1)||n()}),[(null===(a=e.nbpkg)||void 0===a?void 0:a.enabled)??!0]);const[f,_]=i.useState(!1),b=null==(null===(r=e.nbpkg)||void 0===r?void 0:r.restart_required_msg)&&!((null===(s=e.nbpkg)||void 0===s?void 0:s.instantiated)??1),v=null!=t&&(((null===(l=e.nbpkg)||void 0===l?void 0:l.busy_packages)??[]).includes(t.package_name)||b),y=uo(v,2);i.useEffect((()=>{_(y)}),[y]);const w=null==(null===(c=e.nbpkg)||void 0===c?void 0:c.terminal_outputs)?"Loading...":(null===(d=e.nbpkg)||void 0===d?void 0:d.terminal_outputs[null==t?void 0:t.package_name])??"",k=(null==m?void 0:m.offer_update)??!1,E=Ss(),$=null==E||null==(null==t?void 0:t.package_name)?null:((e,t)=>{let n=t.flatMap((t=>Ns(e,t))),o=ce.default.uniq([...t,...n]).map((t=>e.times.get(t))).filter((e=>null!=e));console.log({packages:t,deps:n,times:o,z:ce.default.uniq([...t,...n])});let a=e=>e.reduce(((e,t)=>e+(null==t||isNaN(t)?0:t)),0);return{install:a(o.map(ce.default.property("install")))*Cs.install,precompile:a(o.map(ce.default.property("precompile")))*Cs.precompile,load:a(o.map(ce.default.property("load")))*Cs.load}})(E,[null==t?void 0:t.package_name]),x=null==$?0:$.install+$.load+$.precompile,S=null==$?0:$.load;return i.html`<pkg-popup
class=${ve.cl({busy:v,showterminal:f,showupdate:k})}
>
${(null==m?void 0:m.hint)??"Loading..."}
${("will_be_installed"===(null==m?void 0:m.status)||"busy"===(null==m?void 0:m.status))&&x>10?i.html`<div class="pkg-time-estimate">
Installation can take <strong>${Xs(x)}</strong>${". "}<br />${"Afterwards, it loads in "}
<strong>${Xs(S)}</strong>.
</div>`:null}
<div class="pkg-buttons">
${(null==t?void 0:t.is_disable_pkg)||o||(null===(u=e.nbpkg)||void 0===u?void 0:u.waiting_for_permission)?null:i.html`<a
class="pkg-update"
target="_blank"
title="Update packages"
style=${k?"":"opacity: .4;"}
href="#"
onClick=${t=>{v?alert("Pkg is currently busy with other packages... come back later!"):confirm("Would you like to check for updates and install them? A backup of the notebook file will be created.")&&(console.warn("Pkg.updating!"),p.send("pkg_update",{},{notebook_id:e.notebook_id})),t.preventDefault()}}
><img alt="โฌ๏ธ" src=${Js} width="17"
/></a>`}
<a
class="toggle-terminal"
target="_blank"
title="Show/hide Pkg terminal output"
style=${w?"":"display: none;"}
href="#"
onClick=${e=>{_(!f),e.preventDefault()}}
><img alt="๐" src=${tl} width="17"
/></a>
<a class="help" target="_blank" title="Go to help page" href="https://plutojl.org/pkg/"><img alt="โ" src=${ol} width="17" /></a>
</div>
<${go} value=${w??"Loading..."} />
</pkg-popup>`};io=r("1gqBQ");const il=e=>"LogLevel(-1)"==e.level&&void 0!==e.kwargs.find((e=>"progress"===e[0])),sl=e=>"LogLevel(-555)"==e.level,ll=({logs:e,line_heights:t,set_cm_highlighted_line:n,sanitize_html:o})=>{const a=e.filter(il).reduce(((e,t)=>({...e,[t.id]:t})),{}),r=e.reduce(((e,t)=>sl(t)?null===e?t:{...e,msg:[e.msg[0]+t.msg[0]]}:e),null),[s,l,c]=e.reduce((([e,t,n],o)=>{const i=il(o);if(i&&!e.has(o.id))return e.add(o.id),[e,t,[...n,a[o.id]]];if(!i){if(sl(o)&&!t)return[e,!0,[...n,r]];if(!sl(o))return[e,t,[...n,o]]}return[e,t,n]}),[new Set,!1,[]]),d=0===t[0];if(0===e.length)return null;const u=(e,t)=>i.html`<${dl}
set_cm_highlighted_line=${n}
level=${e.level}
msg=${e.msg}
kwargs=${e.kwargs}
sanitize_html=${o}
key=${t}
y=${d?0:e.line-1}
/> `;return i.html`
<pluto-logs-container>
<pluto-logs>
${c.length<=80?c.map(u):[...c.slice(0,60).map(u),i.html`<pluto-log-truncated>
${c.length-60-20} logs not shown...
</pluto-log-truncated>`,...c.slice(-20).map(((e,t)=>u(e,t+c.length-20)))]}
</pluto-logs>
</pluto-logs-container>
`},cl=({progress:e})=>{const t=i.useRef(null);return i.useLayoutEffect((()=>{t.current&&(t.current.style.backgroundSize=100*e+"% 100%")}),[t.current,e]),i.html`<pluto-progress-bar ref=${t}>${Math.ceil(100*e)}%</pluto-progress-bar>`},dl=({set_cm_highlighted_line:e,msg:t,kwargs:n,y:o,level:a,sanitize_html:r})=>{const s=il({level:a,kwargs:n}),l="LogLevel(-555)"===a;let c=null;s&&(c=n.find((e=>"progress"===e[0]))[1][0],c="nothing"===c?0:'"done"'===c?1:parseFloat(c),a="Progress"),l&&(a="Stdout");const d=e=>i.html`<${pr} cell_id=${"adsf"} mime=${e[1]} body=${e[0]} persist_js_state=${!1} sanitize_html=${r} />`;return i.useEffect((()=>()=>e(null)),[]),i.html`<pluto-log-dot-positioner
class=${ve.cl({[a]:!0})}
onMouseenter=${()=>s||e(o+1)}
onMouseleave=${()=>{e(null)}}
>
<pluto-log-icon></pluto-log-icon>
<pluto-log-dot class=${a}
>${s?i.html`<${cl} progress=${c} />`:l?i.html`<${ul}
body=${i.html`${"This text was written to the "}
<a href="https://en.wikipedia.org/wiki/Standard_streams" target="_blank">terminal stream</a>${" while running the cell. "}<span
style="opacity: .5"
>${"(It is not the "}<em>return value</em>${" of the cell.)"}</span
>`}
/>
<${pl} value=${t[0]} />`:i.html`${d(t)}${n.map((([e,t])=>i.html`<pluto-log-dot-kwarg><pluto-key>${e}</pluto-key><pluto-value>${d(t)}</pluto-value></pluto-log-dot-kwarg>`))}`}</pluto-log-dot
>
</pluto-log-dot-positioner>`},ul=({body:e})=>i.html`<a
class="stdout-info"
target="_blank"
title="Click for more info"
href="#"
onClick=${t=>{io.open_pluto_popup({type:"info",source_element:t.currentTarget,body:e}),t.preventDefault()}}
><img alt="โ" src=${ol} width="17"
/></a>`,pl=({value:e})=>{const t=i.useRef(null);return i.useEffect((()=>{t.current&&(t.current.innerHTML=(new mo).ansi_to_html(e))}),[t.current,e]),i.html`<pre ref=${t}></pre>`};ve=r("aN0pg"),io=r("1gqBQ"),Io=r("hrGZZ");const ml=(e,t,n)=>{const[o,a]=i.useState(!1),r=i.useRef(t);return r.current=t,i.useLayoutEffect((()=>{Object.assign(e.current,{getPublishedObject:e=>{if(!r.current.includes(e))throw`getPublishedObject: ${e} not found`;return n.get_published_object(e)},_internal_pluto_actions:n}),a(!0)})),o},gl=(e,t,n,o=new Set([]))=>{if(o.has(e))return null;if(o.add(e),n(e))return e;for(let a of((e,t)=>{var n,o;return Object.values((null==t||null===(n=t.cell_dependencies)||void 0===n||null===(o=n[e])||void 0===o?void 0:o.upstream_cells_map)||{}).flatMap((e=>e))})(e,t)){const e=gl(a,t,n,o);if(null!==e)return e}return null},hl=e=>(t,n)=>{var o;return null==n||null===(o=n.cell_inputs)||void 0===o?void 0:o[t].metadata[e]},fl=(e,t,n)=>()=>{const o=t.get_notebook()||{},a=gl(n,o,(t=>e(t,o)));null!==a&&window.dispatchEvent(new CustomEvent("cell_focus",{detail:{cell_id:a,line:0}}))},_l=({cell_input:{cell_id:e,code:t,code_folded:n,metadata:o},cell_result:{queued:a,running:r,runtime:s,errored:l,output:c,logs:d,published_object_keys:u,depends_on_disabled_cells:p,depends_on_skipped_cells:m},cell_dependencies:g,cell_input_local:h,notebook_id:f,selected:_,force_hide_input:b,focus_after_creation:v,is_process_ready:y,disable_input:w,process_waiting_for_permission:k,sanitize_html:E=!0,nbpkg:$,global_definition_locations:x,is_first_cell:S})=>{const{show_logs:N,disabled:C,skip_as_script:A}=o;let M=i.useContext(ye);const O=i.useCallback(((...e)=>M.set_doc_query(...e)),[M]),T=i.useCallback(((...e)=>M.focus_on_neighbor(...e)),[M]),R=i.useCallback((t=>M.set_local_cell(e,t)),[e,M]),D=i.useMemo((()=>Object.keys((null==g?void 0:g.downstream_cells_map)??{})),[g]),[L,I]=i.useState(0),P=i.useMemo((()=>e+L),[e,L]),[,j]=i.useErrorBoundary((e=>{console.log(`An error occured in the CodeMirror code, resetting CellInput component. See error below:\n\n${e}\n\n -------------- `),I(L+1),j()})),B=i.useMemo((()=>()=>I(L+1))),[U,F]=i.useState(null),[z,q]=i.useState(null),[H,W]=i.useState(null),[G,K]=i.useState([]);Io.useEventListener(window,"cell_diagnostics",(t=>{t.detail.cell_id===e&&K(t.detail.diagnostics)}),[e,K]),Io.useEventListener(window,"cell_highlight_range",(t=>{t.detail.cell_id==e&&null!=t.detail.from&&null!=t.detail.to?q({from:t.detail.from,to:t.detail.to}):q(null)}),[e]),Io.useEventListener(window,"cell_focus",i.useCallback((t=>{if(t.detail.cell_id===e&&null!=t.detail.line){const e=t.detail.ch;F(null==e?[{line:t.detail.line,ch:0},{line:t.detail.line,ch:1/0},{scroll:!0,definition_of:t.detail.definition_of}]:[{line:t.detail.line,ch:e},{line:t.detail.line,ch:e},{scroll:!0,definition_of:t.detail.definition_of}])}}),[]));const[Z,V]=i.useState(!1);i.useEffect((()=>{V(!1)}),[a,r,null==c?void 0:c.last_run_timestamp,p,C]);const Q=uo(r||a||Z),X=t!==((null==h?void 0:h.code)??t),Y=n&&null==U,J=0===((null==c?void 0:c.last_run_timestamp)??0),ee=k&&J;let te=!b&&(ee||l||X||!Y);const[ne,oe]=i.useState([15]),ae=i.useRef(null),re=i.useRef(w);re.current=w;const ie=i.useRef(!0);ie.current=!C&&!p,Io.useEventListener(window,"set_waiting_to_run_smart",(t=>{t.detail.cell_ids.includes(e)&&V(ie.current)}),[e,V]);const se=ml(ae,u,M),le=i.useCallback((()=>{M.confirm_delete_multiple("Delete",M.get_selected_cells(e,_))}),[M,_,e]),de=i.useCallback((()=>{re.current||M.set_and_run_multiple([e])}),[M,e]),ue=i.useCallback((t=>{re.current||(n&&null!=U&&M.fold_remote_cells([e],!1),R(t))}),[n,U,M,R]),pe=i.useCallback((()=>{M.add_remote_cell(e,"after")}),[M,e,_]),me=i.useCallback((()=>{M.fold_remote_cells(M.get_selected_cells(e,_),!n)}),[M,e,_,n]),ge=i.useCallback((()=>{M.set_and_run_multiple(M.get_selected_cells(e,_))}),[M,e,_]),he=i.useCallback((t=>M.update_notebook((n=>{n.cell_inputs[e].metadata.show_logs=t}))),[M,e]),fe=i.useCallback((async t=>{await M.update_notebook((n=>{n.cell_inputs[e].metadata.disabled=t})),await de()}),[M,e,de]),_e=i.useMemo((()=>!ce.default.isEmpty(d)),[d]),be=i.useCallback(fl(hl("skip_as_script"),M,e),[M,e]),we=i.useCallback(fl(hl("disabled"),M,e),[M,e]);return i.html`
<pluto-cell
key=${P}
ref=${ae}
class=${ve.cl({queued:a||Z&&y,internal_test_queued:!y&&(a||Z),running:r,activate_animation:Q,errored:l,selected:_,code_differs:X,code_folded:Y,skip_as_script:A,running_disabled:C,depends_on_disabled_cells:p,depends_on_skipped_cells:m,show_input:te,shrunk:Object.values(d).length>0,hooked_up:(null==c?void 0:c.has_pluto_hook_features)??!1,no_output_yet:J})}
id=${e}
>
${D.map((e=>i.html`<span id=${encodeURI(e)} />`))}
<button
onClick=${()=>{M.add_remote_cell(e,"before")}}
class="add_cell before"
title="Add cell (Ctrl + Enter)"
tabindex=${S?void 0:"-1"}
>
<span></span>
</button>
<pluto-shoulder draggable="true" title="Drag to move cell">
<button onClick=${me} class="foldcode" title="Show/hide code">
<span></span>
</button>
</pluto-shoulder>
<pluto-trafficlight></pluto-trafficlight>
${ee?i.html`<${ps} />`:se?i.html`<${ms} errored=${l} ...${c} sanitize_html=${E} cell_id=${e} />`:i.html``}
<${ar}
local_code=${(null==h?void 0:h.code)??t}
remote_code=${t}
cell_dependencies=${g}
global_definition_locations=${x}
disable_input=${w}
focus_after_creation=${v}
cm_forced_focus=${U}
set_cm_forced_focus=${F}
show_input=${te}
on_submit=${de}
on_delete=${le}
on_add_after=${pe}
on_change=${ue}
on_update_doc_query=${O}
on_focus_neighbor=${T}
on_line_heights=${oe}
nbpkg=${$}
cell_id=${e}
notebook_id=${f}
metadata=${o}
any_logs=${_e}
show_logs=${N}
set_show_logs=${he}
set_cell_disabled=${fe}
cm_highlighted_line=${H}
cm_highlighted_range=${z}
cm_diagnostics=${G}
onerror=${B}
/>
${N&&se?i.html`<${ll}
logs=${Object.values(d)}
line_heights=${ne}
set_cm_highlighted_line=${W}
sanitize_html=${E}
/>`:null}
<${so}
cell_id=${e}
running_disabled=${C}
depends_on_disabled_cells=${p}
on_run=${ge}
on_interrupt=${()=>{M.interrupt_remote(e)}}
set_cell_disabled=${fe}
runtime=${s}
running=${r}
code_differs=${X}
queued=${a}
on_jump=${we}
/>
<button
onClick=${()=>{M.add_remote_cell(e,"after")}}
class="add_cell after"
title="Add cell (Ctrl + Enter)"
>
<span></span>
</button>
${A?i.html`<div
class="skip_as_script_marker"
title=${"This cell is directly flagged as disabled in file. Click to know more!"}
onClick=${e=>{io.open_pluto_popup({type:"info",source_element:e.target,body:i.html`This cell is currently stored in the notebook file as a Julia <em>comment</em>, instead of <em>code</em>.<br />
This way, it will not run when the notebook runs as a script outside of Pluto.<br />
Use the context menu to enable it again`})}}
></div>`:m?i.html`<div
class="depends_on_skipped_marker"
title=${"This cell is indirectly flagged as disabled in file. Click to know more!"}
onClick=${e=>{io.open_pluto_popup({type:"info",source_element:e.target,body:i.html`This cell is currently stored in the notebook file as a Julia <em>comment</em>, instead of <em>code</em>.<br />
This way, it will not run when the notebook runs as a script outside of Pluto.<br />
An upstream cell is <b> indirectly</b> <em>disabling in file</em> this one; enable
<span onClick=${be} style="cursor: pointer; text-decoration: underline"> the upstream one</span> to affect
this cell.`})}}
></div>`:null}
</pluto-cell>
`},bl=({cell_input:{cell_id:e,metadata:t},cell_result:{logs:n,output:o,published_object_keys:a},hidden:r,sanitize_html:s=!0})=>{const l=i.useRef(null);let c=i.useContext(ye);const d=ml(l,a,c),{show_logs:u}=t;return i.html`
<pluto-cell ref=${l} id=${e} class=${r?"hidden-cell":"isolated-cell"}>
${d?i.html`<${ms} ...${o} sanitize_html=${s} cell_id=${e} />`:i.html``}
${u?i.html`<${ll} logs=${Object.values(n)} line_heights=${[15]} set_cm_highlighted_line=${()=>{}} />`:null}
</pluto-cell>
`};let vl=({cell_result:e,cell_input:t,cell_input_local:n,notebook_id:o,cell_dependencies:a,selected:r,focus_after_creation:s,force_hide_input:l,is_process_ready:c,disable_input:d,sanitize_html:u=!0,process_waiting_for_permission:p,show_logs:m,set_show_logs:g,nbpkg:h,global_definition_locations:f,is_first_cell:_})=>{const{body:b,last_run_timestamp:v,mime:y,persist_js_state:w,rootassignee:k}=(null==e?void 0:e.output)||{},{queued:E,running:$,runtime:x,errored:S,depends_on_disabled_cells:N,logs:C,depends_on_skipped_cells:A}=e||{},{cell_id:M,code:O,code_folded:T,metadata:R}=t||{};return i.useMemo((()=>i.html`
<${_l}
cell_result=${e}
cell_dependencies=${a}
cell_input=${t}
cell_input_local=${n}
notebook_id=${o}
selected=${r}
force_hide_input=${l}
focus_after_creation=${s}
is_process_ready=${c}
disable_input=${d}
process_waiting_for_permission=${p}
sanitize_html=${u}
nbpkg=${h}
global_definition_locations=${f}
is_first_cell=${_}
/>
`),[M,...Object.keys(R),...Object.values(R),N,A,E,$,x,S,b,v,y,w,k,C,O,T,n,o,a,r,l,s,c,d,p,u,...aa(h),f,_])};const yl=({notebook:e,cell_inputs_local:t,last_created_cell:n,selected_cells:o,is_initializing:a,is_process_ready:r,disable_input:s,process_waiting_for_permission:l,sanitize_html:c=!0})=>{let d=i.useContext(ye);i.useEffect((()=>{0!==e.cell_order.length||a||d.add_remote_cell_at(0)}),[a,e.cell_order.length]);const[u,p]=i.useState(!0);i.useEffect((()=>{u&&e.cell_order.length>0&&setTimeout((()=>{p(!1)}),e.cell_order.length>20?100:0)}),[u,e.cell_order.length]);let m=i.useMemo((()=>Object.fromEntries(Object.values((null==e?void 0:e.cell_dependencies)??{}).flatMap((e=>Object.keys(e.downstream_cells_map).map((t=>[t,e.cell_id])))))),[null==e?void 0:e.cell_dependencies]);return i.useLayoutEffect((()=>{let e=window.location.hash;if(e.length>1){let t=()=>{window.location.hash="#",window.location.hash=e};t(),requestIdleCallback(t)}}),[u]),i.html`
<pluto-notebook id=${e.notebook_id}>
${e.cell_order.filter(((e,t)=>!(u&&t>20))).map(((a,d)=>{var u;return i.html`<${vl}
key=${a}
cell_result=${e.cell_results[a]??{cell_id:a,queued:!0,running:!1,errored:!1,runtime:null,output:null,logs:[]}}
cell_input=${e.cell_inputs[a]}
cell_dependencies=${(null==e||null===(u=e.cell_dependencies)||void 0===u?void 0:u[a])??{}}
cell_input_local=${t[a]}
notebook_id=${e.notebook_id}
selected=${o.includes(a)}
focus_after_creation=${n===a}
force_hide_input=${!1}
is_process_ready=${r}
disable_input=${s}
process_waiting_for_permission=${l}
sanitize_html=${c}
nbpkg=${e.nbpkg}
global_definition_locations=${m}
is_first_cell=${0===d}
/>`}))}
${u&&e.cell_order.length>=20?i.html`<div style="font-family: system-ui; font-style: italic; text-align: center; padding: 5rem 1rem;">Loading...</div>`:null}
</pluto-notebook>
`};i=r("cNaMA"),ce=r("9Ta4i");class wl extends i.Component{constructor(){super(),this.dropee=null,this.dropped=null,this.cell_edges=[],this.pointer_position={pageX:0,pageY:0},this.precompute_cell_edges=()=>{const e=Array.from(document.querySelectorAll("pluto-notebook > pluto-cell"));this.cell_edges=e.map((e=>e.offsetTop)),this.cell_edges.push(El(e).offsetTop+El(e).scrollHeight)},this.getDropIndexOf=({pageX:e,pageY:t})=>{const n=this.cell_edges.map((e=>Math.abs(e-t-8)));return kl(n)},this.state={drag_start:!1,drag_target:!1,drop_index:0}}componentDidMount(){document.addEventListener("dragstart",(e=>{if(!e.dataTransfer)return;let t=e.target;var n;t.matches("pluto-shoulder")?(this.dropee=t.parentElement,e.dataTransfer.setData("text/pluto-cell",this.props.serialize_selected(null===(n=this.dropee)||void 0===n?void 0:n.id)),this.dropped=!1,this.precompute_cell_edges(),this.setState({drag_start:!0,drop_index:this.getDropIndexOf(e)}),this.props.set_scroller({up:!0,down:!0})):(this.setState({drag_start:!1,drag_target:!1}),this.props.set_scroller({up:!1,down:!1}),this.dropee=null)})),document.addEventListener("dragenter",(e=>{e.dataTransfer&&"text/pluto-cell"===e.dataTransfer.types[0]&&(this.state.drag_target||this.precompute_cell_edges(),this.lastenter=e.target,this.setState({drag_target:!0}),e.preventDefault())})),document.addEventListener("dragleave",(e=>{e.dataTransfer&&"text/pluto-cell"===e.dataTransfer.types[0]&&e.target===this.lastenter&&this.setState({drag_target:!1})}));const e=ce.default.throttle(this.precompute_cell_edges,4e3,{leading:!1,trailing:!0}),t=ce.default.throttle((()=>{this.setState({drop_index:this.getDropIndexOf(this.pointer_position)})}),300,{leading:!1,trailing:!0});document.addEventListener("dragover",(n=>{n.dataTransfer&&"text/pluto-cell"===n.dataTransfer.types[0]&&(this.pointer_position=n,e(),t(),this.state.drag_start&&(n.dataTransfer.dropEffect="move"),n.preventDefault())})),document.addEventListener("dragend",(e=>{t.flush(),this.setState({drag_start:!1,drag_target:!1}),this.props.set_scroller({up:!1,down:!1})})),document.addEventListener("drop",(e=>{if(e.dataTransfer&&"text/pluto-cell"===e.dataTransfer.types[0])if(this.setState({drag_target:!1}),this.dropped=!0,this.dropee&&this.state.drag_start){const t=this.getDropIndexOf(e),n=this.props.selected_cells.includes(this.dropee.id)?this.props.selected_cells:[this.dropee.id];this.props.actions.move_remote_cells(n,t)}else{const t=this.getDropIndexOf(e),n=e.dataTransfer.getData("text/pluto-cell");this.props.actions.add_deserialized_cells(n,t)}}))}render(){const e=this.state.drag_target?{display:"block",top:this.cell_edges[this.state.drop_index]+"px"}:{};return i.html`<dropruler style=${e}></dropruler>`}}const kl=e=>{let t,n=1/0,o=-1;for(let a=0;a<e.length;a++)t=e[a],t<n&&(o=a,n=t);return o},El=e=>e[e.length-1];i=r("cNaMA"),$e=r("kjWx8");const $l=({on_selection:e,set_scroller:t,cell_order:n})=>{const o=i.useRef(),a=i.useRef(!1),r=i.useRef(null),[s,l]=i.useState(null);return i.useEffect((()=>{const i=t=>{var n;const o=null===(n=t.target)||void 0===n?void 0:n.tagName;0!==t.button||!(e=>{var t;return null!=e.target&&e.target.closest("pluto-editor")===(null===(t=r.current)||void 0===t?void 0:t.closest("pluto-editor"))})(t)||"PLUTO-EDITOR"!==o&&"MAIN"!==o&&"PLUTO-NOTEBOOK"!==o&&"PREAMBLE"!==o||(e([]),l({start:{x:t.pageX,y:t.pageY},end:{x:t.pageX,y:t.pageY}}),a.current=!0)},c=n=>{a.current?(l(null),t({up:!1,down:!1}),a.current=!1):n.composedPath().some((e=>{const t=e.tagName;return"PLUTO-SHOULDER"===t||"BUTTON"===t}))||e([])};let d=(e=>{let t=null,n=!1;return(...o)=>{t=o,n||(window.requestAnimationFrame((()=>{e(...t),n=!1})),n=!0)}})((({pageX:n,pageY:o})=>{if(!a.current||null==s)return;let r={x:n,y:o};const i=Array.from(document.querySelectorAll("pluto-notebook > pluto-cell"));let c=Math.min(s.start.x,r.x),d=Math.min(s.start.y,r.y),u=Math.max(s.start.x,r.x),p=Math.max(s.start.y,r.y),m=i.filter((e=>{let t=(e=>{let t=0,n=0;do{t+=e.offsetTop||0,n+=e.offsetLeft||0,e=e.offsetParent}while(e);return{top:t,left:n}})(e),n=e.getBoundingClientRect(),o=t.left,a=t.top,r=t.left+n.width,i=t.top+n.height;return c<r&&u>o&&d<i&&p>a}));t({up:!0,down:!0}),e(m.map((e=>e.id))),l({start:s.start,end:r})}));const u=e=>{a.current&&d({pageX:o.current.clientX,pageY:o.current.clientY+document.documentElement.scrollTop})},p=e=>{o.current=e,a.current&&(d({pageX:e.pageX,pageY:e.pageY}),e.preventDefault())},m=e=>{a.current&&e.preventDefault()},g=t=>{var o,a;"a"===(null===(o=t.key)||void 0===o?void 0:o.toLowerCase())&&$e.has_ctrl_or_cmd_pressed(t)&&document.activeElement===document.body&&((null===(a=window.getSelection())||void 0===a?void 0:a.isCollapsed)??1)&&(e(n),t.preventDefault())};return document.addEventListener("mousedown",i),document.addEventListener("mouseup",c),document.addEventListener("mousemove",p),document.addEventListener("selectstart",m),document.addEventListener("keydown",g),document.addEventListener("scroll",u,{passive:!0}),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("mouseup",c),document.removeEventListener("mousemove",p),document.removeEventListener("selectstart",m),document.removeEventListener("keydown",g),document.removeEventListener("scroll",u,{passive:!0})}}),[s]),null==s?i.html`<span ref=${r}></span>`:i.html`
<pl-select-area
ref=${r}
style=${{position:"absolute",background:"rgba(40, 78, 189, 0.24)",zIndex:1e6,top:Math.min(s.start.y,s.end.y),left:Math.min(s.start.x,s.end.x),width:Math.abs(s.start.x-s.end.x),height:Math.abs(s.start.y-s.end.y)}}
></pl-select-area>
`};i=r("cNaMA"),ve=r("aN0pg"),Io=r("hrGZZ"),i=r("cNaMA");const xl=({active:e})=>{const t=i.useRef(),n=e=>{t.current={x:e.clientX,y:e.clientY}};return Io.useEventListener(window,"pointermove",n,[]),Io.useEventListener(window,"dragover",n,[]),i.useEffect((()=>{if(e.up||e.down){let n=null,o=!0;const a=r=>{if(o){null==n&&(n=r);const o=r-n;if(n=r,t.current){const n=t.current.y/window.innerHeight;e.up&&n<.3?window.scrollBy(0,-1200*(.3-n)/.3*o/1e3):e.down&&n>.7&&window.scrollBy(0,1200*(n-.7)/.3*o/1e3)}window.requestAnimationFrame(a)}};return window.requestAnimationFrame(a),()=>o=!1}}),[e.up,e.down]),null},Sl=e=>{var t;null===(t=document.getElementById(e))||void 0===t||t.scrollIntoView({block:"center",behavior:"smooth"})};io=r("1gqBQ");const Nl=({recently_deleted:e,on_click:t})=>{const[n,o]=i.useState(!0);i.useEffect((()=>{if(null!=e&&e.length>0){o(!1);const t=setTimeout((()=>{o(!0)}),8e3*Math.pow(e.length,1/3));return()=>{clearTimeout(t)}}}),[e]);let a=null==e?"":1===e.length?"Cell deleted":`${e.length} cells deleted`;return i.html`
<nav
id="undo_delete"
inert=${n}
class=${ve.cl({hidden:n})}
>
${a} (<a
href="#"
onClick=${e=>{e.preventDefault(),o(!0),t()}}
>UNDO</a
>)
</nav>
`},Cl=({notebook:e,recently_auto_disabled_cells:t})=>(i.useEffect((()=>{Object.entries(t).forEach((([e,t])=>{io.open_pluto_popup({type:"info",source_element:document.getElementById(t[0]),body:i.html`<a
href=${`#${e}`}
onClick=${t=>{Sl(e),t.preventDefault(),t.stopPropagation()}}
>Another cell</a
>${" has been disabled because it also defined "}<code class="auto_disabled_variable">${t[1]}</code>.`})}))}),[t]),null);i=r("cNaMA");const Al=()=>{const e=i.useRef(null),t=i.useRef(null),[n,o]=i.useState(!1),a=n=>{var a,r;const i=document.activeElement;if(null==i||i===document.body||i===e.current||i===t.current){if("ArrowLeft"===n.key||"PageUp"===n.key)null===(a=e.current)||void 0===a||a.click();else if("ArrowRight"===n.key||" "===n.key||"PageDown"===n.key)null===(r=t.current)||void 0===r||r.click();else{if("Escape"!==n.key)return;o(!1)}n.preventDefault()}},r=e=>{var t,n;const o=null===(n=null===(t=e.target)||void 0===t?void 0:t.closest("pluto-editor"))||void 0===n?void 0:n.querySelector("pluto-notebook");if(!o)return[];const a=window.innerHeight,r=Array.from(o.querySelectorAll("pluto-output h1, pluto-output h2")),i=r.map((e=>e.getBoundingClientRect())).map((e=>e.top+window.scrollY));i.push(o.getBoundingClientRect().bottom+window.scrollY);return r.map(((e,t)=>{if("H1"==e.tagName){const e=i[t+1]-i[t]-a;return i[t]-Math.max(0,(a-e)/2)}return i[t]-20}))},s=i.useRef(!1);return s.current=n,window.present=()=>{o(!s.current)},i.useLayoutEffect((()=>{if(document.body.classList.toggle("presentation",n),n)return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}}),[n]),i.html`
<nav id="slide_controls" inert=${!n}>
<button ref=${e} class="changeslide prev" title="Previous slide" onClick=${e=>{const t=r(e).reverse().find((e=>e<window.scrollY-10));t&&window.scrollTo(window.scrollX,t)}}><span></span></button>
<button ref=${t} class="changeslide next" title="Next slide" onClick=${e=>{const t=r(e).find((e=>e-10>window.scrollY));t&&window.scrollTo(window.scrollX,t)}}><span></span></button>
</nav>
`};Io=r("hrGZZ"),i=r("cNaMA");const Ml=({fill:e})=>i.html`
<svg
width="48"
height="48"
viewBox="0 0 48 48"
style="
height: .7em;
width: .7em;
margin-left: .3em;
margin-right: .2em;
"
>
<circle cx="24" cy="24" r="24" fill=${e}></circle>
</svg>
`,Ol=({fill:e})=>i.html`
<svg width="48" height="48" viewBox="0 0 48 48" style="height: .7em; width: .7em; margin-left: .3em; margin-right: .2em; margin-bottom: -.1em;">
<polygon points="24,0 48,40 0,40" fill=${e} stroke="none" />
</svg>
`,Tl=({fill:e})=>i.html`
<svg width="48" height="48" viewBox="0 0 48 48" style="height: .7em; width: .7em; margin-left: .3em; margin-right: .2em; margin-bottom: -.1em;">
<polygon points="0,0 0,40 40,40 40,0" fill=${e} stroke="none" />
</svg>
`,Rl=()=>{Array.from(document.querySelectorAll("bond")).some((e=>Array.from(e.querySelectorAll('input[type="password"]')).some((e=>{if(""!==(null==e?void 0:e.value))return e.scrollIntoView(),!0}))))&&alert("Warning: this notebook includes a password input with something typed in it. The contents of this password field will be included in the exported file in an unsafe way. \n\nClear the password field and export again to avoid this problem.")},Dl=({notebook_id:e,print_title:t,open:n,onClose:o,notebookfile_url:a,notebookexport_url:r,start_recording:s})=>{const l=!!window.plutoDesktop,c=(t,n)=>{var o;l&&(t.preventDefault(),null===(o=window.plutoDesktop)||void 0===o||o.fileSystem.exportNotebook(e,n))};let d=i.useRef("");Io.useEventListener(window,"beforeprint",(()=>{console.log("beforeprint"),d.current=document.title,document.title=t.replace(/\.jl$/,"").replace(/\.plutojl$/,"")}),[t]),Io.useEventListener(window,"afterprint",(()=>{document.title=d.current}),[t]);const u=i.useRef(null);return i.useLayoutEffect((()=>{var e,t;n?null===(e=u.current)||void 0===e||e.show():null===(t=u.current)||void 0===t||t.close()}),[n,u.current]),Io.useEventListener(u.current,"focusout",(()=>{var e;(null===(e=u.current)||void 0===e?void 0:e.matches(":focus-within"))||o()}),[o]),i.html`
<dialog id="export" inert=${!n} ref=${u}>
<div id="container">
<div class="export_title">export</div>
<!-- no "download" attribute here: we want the jl contents to be shown in a new tab -->
<a href=${a} target="_blank" class="export_card" onClick=${e=>c(e,0)}>
<header role="none"><${Ol} fill="#a270ba" /> Notebook file</header>
<section>Download a copy of the <b>.jl</b> script.</section>
</a>
<a
href=${r}
target="_blank"
class="export_card"
download=""
onClick=${e=>{Rl(),c(e,1)}}
>
<header role="none"><${Tl} fill="#E86F51" /> Static HTML</header>
<section>An <b>.html</b> file for your web page, or to share online.</section>
</a>
<a href="#" class="export_card" onClick=${()=>window.print()}>
<header role="none"><${Tl} fill="#619b3d" /> PDF</header>
<section>A static <b>.pdf</b> file for print or email.</section>
</a>
${i.html`
<div class="export_title">record</div>
<a
href="#"
onClick=${e=>{Rl(),s(),o(),e.preventDefault()}}
class="export_card"
>
<header role="none"><${Ml} fill="#E86F51" /> Record <em>(preview)</em></header>
<section>Capture the entire notebook, and any changes you make.</section>
</a>
`}
</div>
<div class="export_small_btns">
<button
title="Edit frontmatter"
class="toggle_frontmatter_edit"
onClick=${()=>{o(),window.dispatchEvent(new CustomEvent("open pluto frontmatter"))}}
>
<span></span>
</button>
<button
title="Start presentation"
class="toggle_presentation"
onClick=${()=>{o(),window.present()}}
>
<span></span>
</button>
<button title="Close" class="toggle_export" onClick=${()=>o()}>
<span></span>
</button>
</div>
</dialog>
`};xt=r("2P6PH"),$e=r("kjWx8");window.requestIdleCallback=window.requestIdleCallback||function(e){var t=Date.now();return setTimeout((function(){e({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-t))}})}),1)},window.cancelIdleCallback=window.cancelIdleCallback||function(e){clearTimeout(e)};let Ll=!1;var Il=r("jqrYR"),Pl=r("k9crH");ce=r("9Ta4i");const jl=e=>e.ok?e:Promise.reject(e),Bl=["get_published_object"],Ul=(e,t)=>new Set([...t].map((t=>((e,t)=>{var n;return null===(n=Object.values(e).find((e=>Object.keys(e.downstream_cells_map).includes(t))))||void 0===n?void 0:n.cell_id})(e,t)))),Fl=(e,t)=>{const n=new Set(t),o=[...t];for(;o.length>0;){const t=o.splice(0,1)[0];ce.default.flatten(Object.values(e[t].downstream_cells_map)).forEach((e=>{n.has(e)||(o.push(e),n.add(e))}))}return n},zl=({actions:e})=>Object.fromEntries(Object.entries(e).map((([e,t])=>[e,Bl.includes(e)?t:(...t)=>{console.info("Ignoring action",e,{args:t})}])));ce=r("9Ta4i"),i=r("cNaMA");const ql=({notebook:e,backend_launch_phase:t,status:n})=>{const[o,a]=i.useState([]),[r,s]=i.useState([]);i.useEffect((()=>{const t=Object.values(e.cell_results).filter((e=>e.running||e.queued)).map((e=>e.cell_id));s(t),0===t.length?a([]):a(ce.default.union(t,o))}),Object.values(e.cell_results).map((e=>e.running||e.queued)));let l=0===o.length?0:1-Math.max(0,r.length-.3)/o.length,c=n.loading&&n.binder,d=c?t??0:l;const u=(c||0!==o.length)&&1!==d,p=((e,t=500)=>{const[n,o]=i.useState(null);return i.useEffect((()=>{const n=setTimeout((()=>{o(e)}),t);return()=>clearTimeout(n)}),[e]),n})(u,500)??!1;p&&!c&&0===o.length&&(d=1);const m=c?"Loading binder...":`Running cells... (${o.length-r.length}/${o.length} done)`;return i.html`<loading-bar
class=${c?"slow":"fast"}
style=${`\n width: ${100*d}vw; \n opacity: ${u&&p?1:0}; \n ${u||p?"":"transition: none;"}\n pointer-events: ${u?"auto":"none"};\n cursor: ${!c&&u?"pointer":"auto"};\n `}
onClick=${t=>{if(!c){const t=Object.values(e.cell_results).find((e=>e.running))??Object.values(e.cell_results).find((e=>e.queued));t&&Sl(t.cell_id)}}}
aria-hidden="true"
title=${m}
></loading-bar>`};Io=r("hrGZZ"),i=r("cNaMA");const Hl=({environment_component:e,notebook_id:t})=>{const n=i.useRef(),[o,a]=i.useState({});Io.useEventListener(document,"eexperimental_add_node_non_cell_output",(e=>{try{const{name:t,node:o,order:r}=e.detail;n.current={...n.current,[t]:{node:o,order:r}},a(n.current)}catch(e){}}),[n,a]);let r=Object.values(o);return r.sort((({order:e},{order:t})=>e-t)),r=r.map((({node:e})=>e)),i.html`<div class="non-cell-output">
${e?i.html`<${e} notebook_id=${t} />`:null} ${r}
</div>`};ce=r("9Ta4i");function Wl(){function e(e,t){return new Promise(((n,o)=>{const a=new XMLHttpRequest;a.open("GET",e),a.responseType="arraybuffer",a.onload=()=>{n(WebAssembly.instantiate(a.response,t))},a.onerror=o,a.send()}))}let t=null,n=5242880;function o(e){const t=n;return n+=e,t}function a(e){postMessage({type:"internal-error",data:e})}let r=null,i=null,s=null;onmessage=n=>{const l=n.data;switch(l.type){case"init":const{wasmURL:n,shimURL:d}=l.data;Promise.resolve().then((()=>(self.WebAssembly&&!function(){const e=new Uint8Array([0,97,115,109,1,0,0,0,1,6,1,96,1,127,1,127,3,2,1,0,5,3,1,0,1,7,8,1,4,116,101,115,116,0,0,10,16,1,14,0,32,0,65,1,54,2,0,32,0,40,2,0,11]),t=new WebAssembly.Module(e);return 0!==new WebAssembly.Instance(t,{}).exports.test(4)}()&&delete self.WebAssembly,self.WebAssembly||importScripts(d),t=new WebAssembly.Memory({initial:256,maximum:256}),{memory:t,pow:Math.pow,exit:a,powf:Math.pow,exp:Math.exp,sqrtf:Math.sqrt,cos:Math.cos,log:Math.log,sin:Math.sin,sbrk:o}))).then((t=>function(t,n){if(!WebAssembly.instantiateStreaming)return e(t,n);const o=fetch(t,{credentials:"same-origin"});return WebAssembly.instantiateStreaming(o,n).catch((o=>{if(o.message&&o.message.indexOf("Argument 0 must be provided and must be a Response")>0)return e(t,n);throw o}))}(n,{env:t}))).then((e=>{r=e.instance.exports,postMessage({type:"init",data:null})})).catch((e=>{postMessage({type:"init-error",data:e.toString()})}));break;case"start":if(!function(e){if(i=r.vmsg_init(e),!i)return!1;const n=new Uint32Array(t.buffer,i,1)[0];return s=new Float32Array(t.buffer,n),!0}(l.data))return postMessage({type:"error",data:"vmsg_init"});break;case"data":if(c=l.data,s.set(c),!(r.vmsg_encode(i,c.length)>=0))return postMessage({type:"error",data:"vmsg_encode"});break;case"stop":const u=function(){if(r.vmsg_flush(i)<0)return null;const e=new Uint32Array(t.buffer,i+4,1)[0],n=new Uint32Array(t.buffer,i+8,1)[0],o=new Uint8Array(t.buffer,e,n),a=new Blob([o],{type:"audio/mpeg"});return r.vmsg_free(i),i=null,s=null,a}();if(!u)return postMessage({type:"error",data:"vmsg_flush"});postMessage({type:"stop",data:u})}var c}}class Gl{constructor(e={},t=null){this.wasmURL=new URL(e.wasmURL||"/static/js/vmsg.wasm",location).href,this.shimURL=new URL(e.shimURL||"/static/js/wasm-polyfill.js",location).href,this.onStop=t,this.pitch=e.pitch||0,this.stream=null,this.audioCtx=null,this.gainNode=null,this.pitchFX=null,this.encNode=null,this.worker=null,this.workerURL=null,this.blob=null,this.blobURL=null,this.resolve=null,this.reject=null,Object.seal(this)}close(){this.encNode&&this.encNode.disconnect(),this.encNode&&(this.encNode.onaudioprocess=null),this.stream&&this.stopTracks(),this.audioCtx&&this.audioCtx.close(),this.worker&&(this.worker.terminate(),this.worker=null),this.workerURL&&URL.revokeObjectURL(this.workerURL),this.blobURL&&URL.revokeObjectURL(this.blobURL)}initAudio(){return(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia?function(e){return navigator.mediaDevices.getUserMedia(e)}:function(e){const t=navigator.webkitGetUserMedia||navigator.mozGetUserMedia;return t?new Promise((function(n,o){t.call(navigator,e,n,o)})):Promise.reject(new Error("getUserMedia is not implemented in this browser"))})({audio:!0}).then((e=>{this.stream=e;const t=this.audioCtx=new(window.AudioContext||window.webkitAudioContext),n=t.createMediaStreamSource(e),o=this.gainNode=(t.createGain||t.createGainNode).call(t);o.gain.value=1,n.connect(o);const a=this.pitchFX=new Vl(t);a.setPitchOffset(this.pitch);const r=this.encNode=(t.createScriptProcessor||t.createJavaScriptNode).call(t,0,1,1);a.output.connect(r),o.connect(0===this.pitch?r:a.input)}))}initWorker(){if(this.worker)return Promise.resolve();const e=new Blob(["(",Wl.toString(),")()"],{type:"application/javascript"}),t=this.workerURL=URL.createObjectURL(e),n=this.worker=new Worker(t),{wasmURL:o,shimURL:a}=this;return n.postMessage({type:"init",data:{wasmURL:o,shimURL:a}}),new Promise(((e,t)=>{n.onmessage=n=>{const o=n.data;switch(o.type){case"init":e();break;case"init-error":this.close(),t(new Error(o.data));break;case"error":case"internal-error":this.close(),console.error("Worker error:",o.data),this.reject&&this.reject(o.data);break;case"stop":this.blob=o.data,this.blobURL=URL.createObjectURL(o.data),this.onStop&&this.onStop(),this.resolve&&this.resolve(this.blob)}}}))}init(){return this.initAudio().then(this.initWorker.bind(this))}startRecording(){if(!this.stream)throw new Error("missing audio initialization");if(!this.worker)throw new Error("missing worker initialization");this.blob=null,this.blobURL&&URL.revokeObjectURL(this.blobURL),this.blobURL=null,this.resolve=null,this.reject=null,this.worker.postMessage({type:"start",data:this.audioCtx.sampleRate}),this.encNode.onaudioprocess=e=>{const t=e.inputBuffer.getChannelData(0);this.worker.postMessage({type:"data",data:t})},this.encNode.connect(this.audioCtx.destination)}stopRecording(){if(!this.stream)throw new Error("missing audio initialization");if(!this.worker)throw new Error("missing worker initialization");return this.encNode.disconnect(),this.encNode.onaudioprocess=null,this.stopTracks(),this.audioCtx.close(),this.worker.postMessage({type:"stop",data:null}),new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}stopTracks(){this.stream.getTracks&&this.stream.getTracks().forEach((e=>e.stop()))}}var Kl=Gl;function Zl(e,t,n,o){for(var a=t*e.sampleRate,r=a+(t-2*n)*e.sampleRate,i=e.createBuffer(1,r,e.sampleRate),s=i.getChannelData(0),l=0;l<a;++l)s[l]=o?(a-l)/r:l/a;for(l=a;l<r;++l)s[l]=0;return i}function Vl(e){this.context=e;var t=(e.createGain||e.createGainNode).call(e),n=(e.createGain||e.createGainNode).call(e);this.input=t,this.output=n;var o=e.createBufferSource(),a=e.createBufferSource(),r=e.createBufferSource(),i=e.createBufferSource();this.shiftDownBuffer=Zl(e,.1,.05,!1),this.shiftUpBuffer=Zl(e,.1,.05,!0),o.buffer=this.shiftDownBuffer,a.buffer=this.shiftDownBuffer,r.buffer=this.shiftUpBuffer,i.buffer=this.shiftUpBuffer,o.loop=!0,a.loop=!0,r.loop=!0,i.loop=!0;var s=(e.createGain||e.createGainNode).call(e),l=(e.createGain||e.createGainNode).call(e),c=(e.createGain||e.createGainNode).call(e);c.gain.value=0;var d=(e.createGain||e.createGainNode).call(e);d.gain.value=0,o.connect(s),a.connect(l),r.connect(c),i.connect(d);var u=(e.createGain||e.createGainNode).call(e),p=(e.createGain||e.createGainNode).call(e),m=(e.createDelay||e.createDelayNode).call(e),g=(e.createDelay||e.createDelayNode).call(e);s.connect(u),l.connect(p),c.connect(u),d.connect(p),u.connect(m.delayTime),p.connect(g.delayTime);var h=e.createBufferSource(),f=e.createBufferSource(),_=function(e,t,n){for(var o=t*e.sampleRate,a=o+(t-2*n)*e.sampleRate,r=e.createBuffer(1,a,e.sampleRate),i=r.getChannelData(0),s=n*e.sampleRate,l=s,c=o-s,d=0;d<o;++d){var u;u=d<l?Math.sqrt(d/s):d>=c?Math.sqrt(1-(d-c)/s):1,i[d]=u}for(d=o;d<a;++d)i[d]=0;return r}(e,.1,.05);h.buffer=_,f.buffer=_,h.loop=!0,f.loop=!0;var b=(e.createGain||e.createGainNode).call(e),v=(e.createGain||e.createGainNode).call(e);b.gain.value=0,v.gain.value=0,h.connect(b.gain),f.connect(v.gain),t.connect(m),t.connect(g),m.connect(b),g.connect(v),b.connect(n),v.connect(n);var y=e.currentTime+.05,w=y+.1-.05;o.start(y),a.start(w),r.start(y),i.start(w),h.start(y),f.start(w),this.mod1=o,this.mod2=a,this.mod1Gain=s,this.mod2Gain=l,this.mod3Gain=c,this.mod4Gain=d,this.modGain1=u,this.modGain2=p,this.fade1=h,this.fade2=f,this.mix1=b,this.mix2=v,this.delay1=m,this.delay2=g,this.setDelay(.1)}Vl.prototype.setDelay=function(e){this.modGain1.gain.setTargetAtTime(.5*e,0,.01),this.modGain2.gain.setTargetAtTime(.5*e,0,.01)},Vl.prototype.setPitchOffset=function(e){e>0?(this.mod1Gain.gain.value=0,this.mod2Gain.gain.value=0,this.mod3Gain.gain.value=1,this.mod4Gain.gain.value=1):(this.mod1Gain.gain.value=1,this.mod2Gain.gain.value=1,this.mod3Gain.gain.value=0,this.mod4Gain.gain.value=0),this.setDelay(.1*Math.abs(e))};var Ql;Ql=new URL(r("ko7kR").resolve("c9FOI"),import.meta.url).toString();function Xl(e,t=44100){const n=e*t,o=window.AudioContext||window.webkitAudioContext||window.mozAudioContext;o||console.log("No Audio Context");const a=(new o).createBuffer(1,n,t);return URL.createObjectURL(function(e,t){let n,o,a=e.numberOfChannels,r=t*a*2+44,i=new ArrayBuffer(r),s=new DataView(i),l=[],c=0,d=0;for(p(1179011410),p(r-8),p(1163280727),p(544501094),p(16),u(1),u(a),p(e.sampleRate),p(2*e.sampleRate*a),u(2*a),u(16),p(1635017060),p(r-d-4),n=0;n<e.numberOfChannels;n++)l.push(e.getChannelData(n));for(;d<r;){for(n=0;n<a;n++)o=Math.max(-1,Math.min(1,l[n][c])),o=0|(.5+o<0?32768*o:32767*o),s.setInt16(d,o,!0),d+=2;c++}function u(e){s.setUint16(d,e,!0),d+=2}function p(e){s.setUint32(d,e,!0),d+=4}return new Blob([i],{type:"audio/wav"})}(a,n))}i=r("cNaMA"),ce=r("9Ta4i"),i=r("cNaMA");const Yl=({onPlay:e,src:t,loaded_recording:n,audio_element_ref:o})=>(i.useLayoutEffect((()=>{(async()=>{if(null==t){let e=e=>ce.default.last([[0,null],...e])[0],t=Math.max(e((await n).scrolls),e((await n).steps));t=Math.ceil(t+.1),console.log({fake_duration:t});let a=Xl(t);o.current.src=a}else o.current.src=t})()}),[]),i.html`<div class="recording-playback"><audio ref=${o} onPlay=${e} controls></audio></div>`);Il=r("jqrYR"),Pl=r("k9crH");const Jl=e=>e.ok?e:Promise.reject(e);const ec=({notebook_name:e,is_recording:t,recording_waiting_to_start:n,set_recording_states:o,patch_listeners:a,export_url:r})=>{let s=i.useRef(null),l=i.useRef(0);i.useEffect((()=>{let e=e=>{null!=s.current&&(s.current.steps=[...s.current.steps,[(Date.now()-l.current)/1e3,e]])};return a.push(e),()=>{a.splice(a.indexOf(e),1)}}),[]);const c=async({want_audio:e})=>{let t,n=null,a=async e=>{alert(`We were unable to activate your microphone. Make sure that it is connected, and that this site (${window.location.protocol+"//"+window.location.host}) has permission to use the microphone.`),console.warn("Failed to create audio recorder asdfasdf ",e),await u()};if(e)try{n=await(async()=>{const e=new Kl({wasmURL:new URL(Ql)});return{start:async()=>{await e.initAudio(),await e.initWorker(),e.startRecording()},stop:async()=>{const t=await e.stopRecording();return window.URL.createObjectURL(t)}}})(),t=n.start()}catch(e){return void await a(e)}let i=await(await fetch(r("notebookexport")).then(Jl)).text();i=i.replaceAll("https://cdn.jsdelivr.net/gh/fonsp/Pluto.jl@0.17.3/frontend/","https://cdn.jsdelivr.net/gh/fonsp/Pluto.jl@8d243df/frontend/");const c=()=>{if(null==s.current)return;let e=window.scrollY+window.innerHeight/2;const t=Array.from(document.querySelectorAll("pluto-notebook > pluto-cell"));let n="",o=0;t.forEach(((t,a)=>{let r=t.offsetTop;r<=e&&(n=t.id,o=(e-r)/t.offsetHeight)})),s.current.scrolls=[...s.current.scrolls,[(Date.now()-l.current)/1e3,{cell_id:n,relative_distance:o}]]},d=ce.default.debounce(c,500);try{await t}catch(e){return void await a(e)}s.current={initial_html:i,steps:[],scrolls:[],scroll_handler:d,audio_recorder:n},l.current=Date.now(),o({is_recording:!0,recording_waiting_to_start:!1}),c(),window.addEventListener("scroll",d,{passive:!0})};let d=i.useRef(e);d.current=ce.default.last(e.split("/")).replace(/\.jl$/,"").replace(/\.plutojl$/,"");const u=async()=>{if(null!=s.current){const{audio_recorder:e,initial_html:t,steps:n,scrolls:o,scroll_handler:a}=s.current;window.removeEventListener("scroll",a,{passive:!0});const r=await(null==e?void 0:e.stop()),i=null==r?null:await Il.blob_url_to_data_url(r),l='<meta name="pluto-insertion-spot-parameters">',c=t.replace(l,`\n <script>\n window.pluto_recording_url = "data:;base64,${await Il.base64_arraybuffer(Pl.pack({steps:n,scrolls:o}))}";\n window.pluto_recording_audio_url = ${null==i?null:`"${i}"`};\n <\/script>\n ${l}`);console.log(s.current);let u=document.createElement("a");u.setAttribute("href","data:text/html;charset=utf-8,"+encodeURIComponent(c)),u.setAttribute("download",`${d.current} recording.html`),u.style.display="none",document.body.appendChild(u),u.click(),document.body.removeChild(u)}l.current=0,s.current=null,o({is_recording:!1,recording_waiting_to_start:!1})};return i.html`
<div class="outline-frame recording"></div>
${n?i.html`<div class="outline-frame-actions-container">
<div class="overlay-button">
<button
onclick=${()=>{c({want_audio:!0})}}
>
<span><b>Start recording</b><span class="microphone-icon pluto-icon"></span></span>
</button>
</div>
<div class="overlay-button record-no-audio">
<button
onclick=${()=>{c({want_audio:!1})}}
>
<span><b>Start recording</b> (no audio)<span class="mute-icon pluto-icon"></span></span>
</button>
</div>
</div>`:t?i.html`<div class="outline-frame-actions-container">
<div class="overlay-button">
<button
onclick=${()=>{u()}}
>
<span><b>Stop recording</b><span class="stop-recording-icon pluto-icon"></span></span>
</button>
</div>
</div>`:null}
`};const tc=({launch_params:e,initializing:t,apply_notebook_patches:n,reset_notebook_state:o})=>{const{recording_url:a,recording_url_integrity:r,recording_audio_url:s}=e;let l=i.useMemo((()=>Promise.resolve().then((async()=>a?Pl.unpack(new Uint8Array(await(await fetch(new Request(a,{integrity:r??void 0})).then(Jl)).arrayBuffer())):null))),[a]),c=i.useRef(null);i.useEffect((()=>{l.then(console.log)}),[l]);let d=i.useRef(null),u=i.useRef(!1),p=i.useRef(0),[m,g]=i.useState(null),[h,f]=i.useState(!0),_=i.useRef(h);_.current=h;let b=i.useRef(!1),v=i.useRef(0),y=i.useRef(0);const w=(e,t=!0)=>{v.current=Date.now(),y.current=Date.now(),window.scrollTo({top:e,behavior:t?"smooth":"auto"})};let k=({cell_id:e,relative_distance:t},n=!0)=>{let o=(({cell_id:e,relative_distance:t})=>{let n=document.getElementById(e);if(n)return n.offsetTop+t*n.offsetHeight-window.innerHeight/2})({cell_id:e,relative_distance:t});null!=o&&(g(o),_.current&&w(o,n))};const E=i.useRef((()=>{}));E.current=async()=>{u.current=!0;const e=await l;c.current=c.current??e.steps.map((([e,t])=>[e,void 0]));const t=d.current;if(null==t)return;let o=t.currentTime,a=o>=p.current,r=a?ce.default.identity:ce.default.reverse,i=Math.min(p.current,o),s=Math.max(p.current,o),m=e.scrolls.filter((([e,t])=>i<e&&e<=s));if(m.length>0){var g;let e=null===(g=ce.default.last(r(m)))||void 0===g?void 0:g[1];e&&k(e)}let h=(a?e.steps:c.current).map(((e,t)=>[e,t])).filter((([[e,t],n])=>i<e&&e<=s)),f=[];for(let[[e,t],o]of r(h))f=await n(t,void 0,a),a&&(c.current[o]=[e,f]);p.current=o,t.paused?u.current=!1:requestAnimationFrame((()=>E.current()))};let $=i.useCallback((e=>{u.current||E.current()}),[u,E]);const x=["seeked","suspend","play","pause","ended","waiting"];i.useLayoutEffect((()=>{const e=d.current;if(e)return x.forEach((t=>{e.addEventListener(t,$)})),()=>{x.forEach((t=>{e.removeEventListener(t,$)}))}}),[d.current,$]),i.useEffect((()=>{t||null==a||l.then((e=>{let t=ce.default.first(null==e?void 0:e.scrolls);if(t){let e=new ResizeObserver((()=>{console.log("Scrolling back to first recorded scroll position..."),k(t[1],!1)})),n=history.scrollRestoration;history.scrollRestoration="manual",e.observe(document.body),setTimeout((()=>{history.scrollRestoration=n,e.disconnect()}),3e3),k(t[1],!1)}document.fonts.ready.then((()=>{console.info("Fonts loaded"),k(t[1],!1)}))}))}),[t]),i.useEffect((()=>{}),[t]),i.useEffect((()=>{if(!t&&null!=a){let e=e=>{let t=Date.now(),n=(t-v.current)/1e3,o=(t-y.current)/1e3,a=n<1&&(o===n||o<.2);a&&(y.current=t),a||_.current&&(console.warn("Manual scroll detected, no longer following playback scroll",{dt:n,smooth_dt:o,e:e}),null!=d.current&&(b.current=!d.current.paused,d.current.pause()),f(!1))};return document.fonts.ready.then((()=>{window.addEventListener("scroll",e,{passive:!0})})),()=>{window.removeEventListener("scroll",e,{passive:!0})}}}),[t,a]);let S=i.html`<div
style=${{opacity:h?0:1,top:`${m??0}px`}}
class="outline-frame playback"
></div>`;return i.html`
${a?i.html`${h?null:i.html` <div class="outline-frame-actions-container">
<div class="overlay-button playback">
<button
onclick=${()=>{w(m,!0),f(!0),b.current&&d.current&&d.current.play()}}
>
<span>Back to <b>recording</b> <span class="follow-recording-icon pluto-icon"></span></span>
</button>
</div>
</div>`}
${S} <${Yl} audio_element_ref=${d} src=${s} loaded_recording=${l} />`:null}
`};Io=r("hrGZZ");r("cNaMA");let nc=()=>(Io.useEventListener(document,"click",(e=>{if(e.defaultPrevented)return;const t=e.target.closest("a");if(t&&!t.hasAttribute("target")){new URL(t.href).origin!==window.location.origin&&(t.target="_blank")}}),[]),null);i=r("cNaMA"),$e=r("kjWx8"),ce=r("9Ta4i");class oc extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.tags=[]}addTag(e){if(e.length>0)if("true"==this.getAttribute("lowercase")&&(e=e.toLowerCase()),"true"==this.getAttribute("uppercase")&&(e=e.toUpperCase()),"true"==this.getAttribute("duplicates")||-1===this.tags.indexOf(e))this.tags.push(e),this.shadowRoot.querySelector("#tag-input").value="",this.dispatchEvent(new CustomEvent("input")),this.render();else{var t=this.shadowRoot.querySelector('[data-index="'+this.tags.indexOf(e)+'"]');t.className=t.className+" duplicate",setTimeout((function(){t.className=t.className.replace("duplicate","")}),500)}}get value(){return this.tags}set value(e){this.tags=Array.isArray(e)?e:[],this.render()}render(){this.clear(),this.tags.forEach(((e,t)=>{let n=document.createElement("div");n.className="tag";let o=document.createElement("div");o.className="remove",o.innerHTML="โ",o.addEventListener("click",(()=>{this.deleteTag(t)})),n.dataset.index=t,n.innerHTML=e,n.appendChild(o),this.shadowRoot.querySelector(".rebel-tag-input").appendChild(n)}))}clear(){var e=this.shadowRoot.querySelectorAll(".tag");if(e.length>0)for(var t=0;t<e.length;t++)this.shadowRoot.querySelector(".rebel-tag-input").removeChild(e[t])}empty(){this.clear(),this.tags=[]}deleteTag(e){var t=[];this.tags.forEach(((n,o)=>{o!==e&&t.push(n)})),this.value=t}connectedCallback(){this.shadowRoot.innerHTML='\n <style>\n .rebel-tag-input {\n font-family: sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif;\n font-size: 0.78em;\n max-width: 100%;\n display: flex;\n align-content: flex-start;\n flex-wrap: wrap;\n border-radius: 2px;\n padding: .1em;\n align-items: baseline;\n \n --bg: white;\n --tag-bg: #e6e6e6;\n --border: #CCC;\n \n background: var(--bg);\n border: solid 1px var(--border);\n \n }\n @media (prefers-color-scheme: dark) {\n .rebel-tag-input {\n --bg: #3b3b3b;\n --border: #808080;\n --tag-bg: #666;\n }\n }\n #tag-input {\n flex-grow: 1;\n display: inline-block;\n order: 200;\n border: none;\n margin: 0;\n font-size: inherit;\n font-family: inherit;\n background: transparent;\n }\n #tag-input:focus {\n outline: none;\n }\n .rebel-tag-input div.tag {\n display: inline-flex;\n /* flex-grow: 0; */\n margin: 0.2em 0.2em;\n padding: 0.2em;\n padding-left: 0.4em;\n gap: 0.3em;\n line-height: 1;\n background-color: var(--tag-bg);\n order: 100;\n border-radius: 1000px;\n position: relative;\n overflow: hidden;\n align-items: center;\n }\n .rebel-tag-input div.tag.duplicate {\n background-color: rgba(255, 64, 27, 0.71);\n transition: all 0.3s linear;\n }\n .rebel-tag-input div.tag:last-child {\n margin-right: 5px;\n }\n .rebel-tag-input div.tag .remove {\n background-color: rgb(199 199 199 / 71%);\n color: #7e7e7e;\n font-weight: 600;\n font-size: 0.8em;\n padding: 0.1em;\n cursor: pointer;\n border-radius: 100px;\n display: inline-flex;\n height: 1em;\n width: 1em;\n line-height: 1;\n text-align: center;\n align-items: center;\n justify-content: center;\n }\n .rebel-tag-input div.tag:hover .remove {\n }\n </style>\n <div class="rebel-tag-input">\n <input type="text" id="tag-input" placeholder="Enter tag..." />\n \x3c!-- Start Tag Elements --\x3e\n </div>\n ';let e=!1;this.shadowRoot.querySelector("#tag-input").addEventListener("input",(e=>{e.stopPropagation()})),this.shadowRoot.querySelector("#tag-input").addEventListener("keydown",(t=>{let n=this.shadowRoot.querySelector("#tag-input").value;13===t.keyCode?this.addTag(n):188===t.keyCode?(t.preventDefault(),this.addTag(n)):8===t.keyCode&&0===n.length&&(e?(this.deleteTag(this.tags.length-1),this.dispatchEvent(new CustomEvent("input")),e=!1):e=!0)})),this.shadowRoot.querySelector("#tag-input").addEventListener("blur",(()=>{let e=this.shadowRoot.querySelector("#tag-input").value;this.addTag(e)}))}}customElements.define("rbl-tag-input",oc);var ac=r("1Mxs0");Io=r("hrGZZ");const rc=({filename:e,remote_frontmatter:t,set_remote_frontmatter:n})=>{const[o,a]=i.useState(t??{});i.useEffect((()=>{a(t??{})}),[t]);const[r,s,l,c]=Ks(),d=i.useCallback((()=>{n(ic(o)??{}).then((()=>alert("Frontmatter synchronized โ\n\nThese parameters will be used in future exports."))),l()}),[ic,n,o,l]);Io.useEventListener(window,"open pluto frontmatter",s),Io.useEventListener(window,"keydown",(e=>{null!=r.current&&r.current.contains(e.target)&&"Enter"===e.key&&$e.has_ctrl_or_cmd_pressed(e)&&d()}),[r,d]);const u={title:null,description:null,date:null,tags:[],author:[{}],...o},p=([e,t])=>!(ce.default.isArray(t)&&"tags"!==lc(e)||ce.default.isPlainObject(t)),m=(e,t)=>i.html`
${Object.entries(e).filter(p).map((([e,n])=>{let o=`${t}${e}`,r=`fm-${o}`;return i.html`
<label for=${r}>${e}</label>
<${cc} type=${lc(e)} id=${r} value=${n} on_value=${(e=>t=>a(le((n=>{ce.default.set(n,e,t)}))))(o)} />
<button
class="deletefield"
title="Delete field"
aria-label="Delete field"
onClick=${()=>{a(le((e=>{ce.default.unset(e,o)})))}}
>
โ
</button>
`}))}
<button
class="addentry"
onClick=${()=>{const e=prompt("Field name:");e&&a(le((n=>{ce.default.set(n,`${t}${e}`,null)})))}}
>
Add entry +
</button>
`;return i.html`<dialog ref=${r} class="pluto-frontmatter">
<h1>Frontmatter</h1>
<p>
If you are publishing this notebook on the web, you can set the parameters below to provide HTML metadata. This is useful for search engines and
social media.
</p>
<div class="card-preview" aria-hidden="true">
<h2>Preview</h2>
<${ac.FeaturedCard}
entry=${{id:e.replace(/\.jl$/,""),hash:"xx",frontmatter:ic(o)??{}}}
disable_links=${!0}
/>
</div>
<div class="fm-table">
${m(u,"")}
${ce.default.isArray(u.author)?u.author.map(((e,t)=>{let n={name:null,url:null,...e};return i.html`
<fieldset class="fm-table">
<legend>Author ${t+1}</legend>
${m(n,`author[${t}].`)}
</fieldset>
`})):null}
${ce.default.isArray(u.author)?i.html`<button
class="addentry"
onClick=${()=>{a((e=>({...e,author:[...(null==e?void 0:e.author)??[],{}]})))}}
>
Add author +
</button>`:null}
</div>
<div class="final"><button onClick=${()=>{a(t??{}),l()}}>Cancel</button><button onClick=${d}>Save</button></div>
</dialog>`},ic=e=>{let t=ce.default.isPlainObject(e)?Object.fromEntries(Object.entries(e).map((([e,t])=>[e,ic(t)])).filter((([e,t])=>null!=t))):ce.default.isArray(e)?e.map(ic).filter((e=>null!=e)):e;return ce.default.isEmpty(t)?null:t},sc=["tags","date","license","url","color"],lc=e=>{for(const t of sc)if(e===t||e.endsWith(`_${t}`))return t;return"text"},cc=({value:e,on_value:t,type:n,id:o})=>{const a=i.useRef(null);i.useLayoutEffect((()=>{a.current&&(a.current.value=e)}),[a.current,e]),i.useLayoutEffect((()=>{if(!a.current)return;const e=e=>{a.current&&t(a.current.value)};return a.current.addEventListener("input",e),()=>{var t;null===(t=a.current)||void 0===t||t.removeEventListener("input",e)}}),[a.current]);const r="url"===n?"https://...":void 0;return"tags"===n?i.html`<rbl-tag-input id=${o} ref=${a} />`:"license"===n?uc({ref:a,id:o}):i.html`<input type=${n} id=${o} ref=${a} placeholder=${r} />`},dc=["AGPL-3.0","GPL-3.0","LGPL-3.0","MPL-2.0","Apache-2.0","MIT","BSL-1.0","Unlicense","CC-BY-4.0","CC-BY-SA-4.0","CC-BY-NC-4.0","CC-BY-NC-SA-4.0","CC-BY-ND-4.0","CC-BY-NC-ND-4.0","CC0-1.0"],uc=({ref:e,id:t})=>i.html`
<input ref=${e} id=${t} type="text" list="oss-licenses" />
<datalist id="oss-licenses">${dc.map((e=>i.html`<option>${e}</option>`))}</datalist>
`;i=r("cNaMA"),i=r("cNaMA"),de=r("4zMEb"),Oo=r("41Mhf");const pc=({editor:e,launch_params:t,status:n})=>{try{var o;const n=i.useMemo((()=>{var t,n,o;return null===window||void 0===window||null===(t=window.pluto_injected_environment)||void 0===t||null===(n=t.environment)||void 0===n||null===(o=n.call(t,{client:e.client,editor:e,imports:{immer:le,preact:i}}))||void 0===o?void 0:o.custom_run_or_edit}),[e.client,e]);if(null===window||void 0===window||null===(o=window.pluto_injected_environment)||void 0===o?void 0:o.provides_backend)return i.html`<${n} editor=${e} backend_phases=${To} launch_params=${t} />`}catch(e){}return null==n?null:n.offer_local?i.html`<${Zs}
start_local=${()=>(async({setStatePromise:e,connect:t,launch_params:n})=>{try{if(null==n.pluto_server_url||null==n.notebookfile)throw Error("Invalid launch parameters for starting locally.");await e(le((e=>{e.backend_launch_phase=To.responded,e.disable_ui=!1,e.notebook.status_tree=null})));const o=e=>String(e),a=new URL(n.pluto_server_url,window.location.href);let r;const i=await(await fetch(new Request(n.notebookfile,{integrity:n.notebookfile_integrity??void 0}))).arrayBuffer();if(r=await fetch(o(Oo.with_query_params(new URL("notebookupload",a),{name:new URLSearchParams(window.location.search).get("name"),clear_frontmatter:"yesplease",execution_allowed:"yepperz"})),{method:"POST",body:i}),!r.ok){let e=await r.blob();return void(window.location.href=URL.createObjectURL(e))}const s=await r.text(),l=Oo.with_query_params(new URL("edit",a),{id:s});console.info("notebook_id:",s),window.history.replaceState({},"",l),await e(le((e=>{e.notebook.notebook_id=s,e.backend_launch_phase=To.notebook_running}))),console.log("Connecting WebSocket");const c=t();await de.timeout_promise(c,2e4).catch((e=>{console.error("Failed to establish connection within 20 seconds. Navigating to the edit URL directly.",e),window.parent.location.href=o(l)}))}catch(e){console.error("Failed to initialize binder!",e),alert("Something went wrong! ๐ฎ\n\nWe failed to open this notebook. Please try again with a different browser, or come back later.")}})({setStatePromise:e.setStatePromise,connect:e.connect,launch_params:t})}
/>`:n.offer_binder?i.html`<${Vs}
offer_binder=${n.offer_binder}
start_binder=${()=>Lo({setStatePromise:e.setStatePromise,connect:e.connect,launch_params:t})}
notebookfile=${null==t.notebookfile?null:new URL(t.notebookfile,window.location.href).href}
notebook=${e.state.notebook}
/>`:null};var mc,gc=r("cpCG6"),hc=r("dYd4C");io=r("1gqBQ");const fc={disabled:!1,show_logs:!0,skip_as_script:!1},_c=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))),bc=({children:e})=>i.html`<main>${e}</main>`,vc=(e,t)=>{var n,o,a,r;return{disconnected:!(e.connected||e.initializing||e.static_preview),loading:null!=e.backend_launch_phase&&To.wait_for_user<e.backend_launch_phase&&e.backend_launch_phase<To.ready||e.initializing||e.moving_file,process_waiting_for_permission:e.notebook.process_status===hc.ProcessStatus.waiting_for_permission&&!e.initializing,process_restarting:e.notebook.process_status===hc.ProcessStatus.waiting_to_restart,process_dead:e.notebook.process_status===hc.ProcessStatus.no_process||e.notebook.process_status===hc.ProcessStatus.waiting_to_restart,nbpkg_restart_required:null!=(null===(n=e.notebook.nbpkg)||void 0===n?void 0:n.restart_required_msg),nbpkg_restart_recommended:null!=(null===(o=e.notebook.nbpkg)||void 0===o?void 0:o.restart_recommended_msg),nbpkg_disabled:!1===(null===(a=e.notebook.nbpkg)||void 0===a?void 0:a.enabled)||!0===(null===(r=e.notebook.nbpkg)||void 0===r?void 0:r.waiting_for_permission_but_probably_disabled),static_preview:e.static_preview,bonds_disabled:!(e.connected||e.initializing||null!=t.slider_server_url),offer_binder:e.backend_launch_phase===To.wait_for_user&&null!=t.binder_url,offer_local:e.backend_launch_phase===To.wait_for_user&&null!=t.pluto_server_url,binder:null!=t.binder_url&&null!=e.backend_launch_phase,code_differs:e.notebook.cell_order.some((t=>null!=e.cell_inputs_local[t]&&e.notebook.cell_inputs[t].code!==e.cell_inputs_local[t].code)),recording_waiting_to_start:e.recording_waiting_to_start,is_recording:e.is_recording,isolated_cell_view:null!=t.isolated_cell_ids&&t.isolated_cell_ids.length>0,sanitize_html:e.notebook.process_status===hc.ProcessStatus.waiting_for_permission}},yc=(null===(mc=document.head.querySelector("link[rel='pluto-logo-big']"))||void 0===mc?void 0:mc.getAttribute("href"))??"",wc=(null===(Nc=document.head.querySelector("link[rel='pluto-logo-small']"))||void 0===Nc?void 0:Nc.getAttribute("href"))??"";class kc extends i.Component{constructor(e){super(e);const{launch_params:t,initial_notebook_state:n}=this.props;this.state={notebook:n,cell_inputs_local:{},desired_doc_query:null,recently_deleted:[],recently_auto_disabled_cells:{},last_update_time:0,disable_ui:t.disable_ui,static_preview:null!=t.statefile,backend_launch_phase:null==t.notebookfile||null==t.binder_url&&null==t.pluto_server_url?null:To.wait_for_user,backend_launch_logs:null,binder_session_url:null,binder_session_token:null,refresh_target:null,connected:!1,initializing:!0,moving_file:!1,scroller:{up:!1,down:!1},export_menu_open:!1,last_created_cell:null,selected_cells:[],extended_components:{CustomHeader:null},is_recording:!1,recording_waiting_to_start:!1,slider_server:{connecting:!1,interactive:!1}},this.setStatePromise=e=>new Promise((t=>this.setState(e,t))),this.real_actions={get_notebook:()=>{var e;return(null===this||void 0===this||null===(e=this.state)||void 0===e?void 0:e.notebook)||{}},send:(e,...t)=>this.client.send(e,...t),get_published_object:e=>this.state.notebook.published_objects[e],update_notebook:(...e)=>this.update_notebook(...e),set_doc_query:e=>this.setState({desired_doc_query:e}),set_local_cell:(e,t)=>this.setStatePromise(le((n=>{n.cell_inputs_local[e]={code:t},n.selected_cells=[]}))),focus_on_neighbor:(e,t,n=(-1===t?1/0:-1),o=0)=>{const a=this.state.notebook.cell_order.indexOf(e)+t;a>=0&&a<this.state.notebook.cell_order.length&&window.dispatchEvent(new CustomEvent("cell_focus",{detail:{cell_id:this.state.notebook.cell_order[a],line:n,ch:o}}))},add_deserialized_cells:async(e,t,n=he)=>{let o,a=n(e).map((e=>({cell_id:_c(),code:e,code_folded:!1,metadata:{...fc}})));"number"==typeof t?o=t:(o=this.state.notebook.cell_order.indexOf(t),-1!==o&&(o+=1)),-1===o&&(o=this.state.notebook.cell_order.length),this.setState(le((e=>{var t;e.selected_cells=[];for(let t of a)e.cell_inputs_local[t.cell_id]=t;e.last_created_cell=null===(t=a[0])||void 0===t?void 0:t.cell_id}))),await p((e=>{for(const t of a)e.cell_inputs[t.cell_id]={...t,code:"",metadata:{...fc}};e.cell_order=[...e.cell_order.slice(0,o),...a.map((e=>e.cell_id)),...e.cell_order.slice(o,1/0)]}))},wrap_remote_cell:async(e,t="begin",n="end")=>{const o=`${t}\n\t${this.state.notebook.cell_inputs[e].code.replace(/\n/g,"\n\t")}\n${n}`;await this.setStatePromise(le((t=>{t.cell_inputs_local[e]={code:o}}))),await this.actions.set_and_run_multiple([e])},split_remote_cell:async(e,t,n=!1)=>{const o=this.state.notebook.cell_inputs[e].code,a=[0,...t],r=t.map(((e,t)=>xt.slice_utf8(o,a[t],e).trim())).filter((e=>""!==e)).map((e=>({cell_id:_c(),code:e,code_folded:!1,metadata:{...fc}})));this.setState(le((e=>{for(let t of r)e.cell_inputs_local[t.cell_id]=t}))),await p((t=>{delete t.cell_inputs[e];for(let e of r)t.cell_inputs[e.cell_id]=e;t.cell_order=t.cell_order.flatMap((t=>e===t?r.map((e=>e.cell_id)):[t]))})),n&&await this.actions.set_and_run_multiple(r.map((e=>e.cell_id)))},interrupt_remote:e=>{this.client.send("interrupt_all",{},{notebook_id:this.state.notebook.notebook_id},!1)},move_remote_cells:(e,t)=>p((n=>{t=Math.max(0,t);let o=n.cell_order.slice(0,t).filter((t=>!e.includes(t))),a=n.cell_order.slice(t,1/0).filter((t=>!e.includes(t)));n.cell_order=[...o,...e,...a]})),add_remote_cell_at:async(e,t="")=>{let n=_c();return this.setState({last_created_cell:n}),await p((o=>{o.cell_inputs[n]={cell_id:n,code:t,code_folded:!1,metadata:{...fc}},o.cell_order=[...o.cell_order.slice(0,e),n,...o.cell_order.slice(e,1/0)]})),await this.client.send("run_multiple_cells",{cells:[n]},{notebook_id:this.state.notebook.notebook_id}),n},add_remote_cell:async(e,t,n)=>{const o=this.state.notebook.cell_order.indexOf(e),a="before"==t?0:1;return await this.actions.add_remote_cell_at(o+a,n)},confirm_delete_multiple:async(e,t)=>{(t.length<=1||confirm(`${e} ${t.length} cells?`))&&(t.some((e=>this.state.notebook.cell_results[e].running||this.state.notebook.cell_results[e].queued))?confirm("This cell is still running - would you like to interrupt the notebook?")&&this.actions.interrupt_remote(t[0]):(this.setState({recently_deleted:t.map((e=>({index:this.state.notebook.cell_order.indexOf(e),cell:this.state.notebook.cell_inputs[e]}))),selected_cells:[]}),await p((e=>{for(let n of t)delete e.cell_inputs[n];e.cell_order=e.cell_order.filter((e=>!t.includes(e)))})),await this.client.send("run_multiple_cells",{cells:[]},{notebook_id:this.state.notebook.notebook_id})))},fold_remote_cells:async(e,t)=>{!t&&e.length>0&&this.setState({last_created_cell:e[e.length-1]}),await p((n=>{for(let o of e)n.cell_inputs[o].code_folded=t}))},set_and_run_all_changed_remote_cells:()=>{const e=this.state.notebook.cell_order.filter((e=>{var t;return null!=this.state.cell_inputs_local[e]&&this.state.notebook.cell_inputs[e].code!==(null===(t=this.state.cell_inputs_local[e])||void 0===t?void 0:t.code)}));return this.actions.set_and_run_multiple(e),e.length>0},set_and_run_multiple:async e=>{if(e.length>0){window.dispatchEvent(new CustomEvent("set_waiting_to_run_smart",{detail:{cell_ids:e}})),await p((t=>{for(let n of e)this.state.cell_inputs_local[n]&&(t.cell_inputs[n].code=this.state.cell_inputs_local[n].code)})),await this.setStatePromise(le((t=>{for(let n of e)null!=t.notebook.cell_results[n]&&(t.notebook.cell_results[n].queued=this.is_process_ready())})));const t=await this.client.send("run_multiple_cells",{cells:e},{notebook_id:this.state.notebook.notebook_id}),{disabled_cells:n}=t.message;Object.entries(n).length>0&&await this.setStatePromise({recently_auto_disabled_cells:n})}},set_bond:async(e,t)=>{await p((n=>{let o={value:t};n.bonds[e]=o}))},reshow_cell:(e,t,n)=>{this.client.send("reshow_cell",{objectid:t,dim:n,cell_id:e},{notebook_id:this.state.notebook.notebook_id},!1)},get_selected_cells:(e,t)=>t?this.state.selected_cells:[e],get_avaible_versions:async({package_name:e,notebook_id:t})=>{const{message:n}=await this.client.send("nbpkg_available_versions",{package_name:e},{notebook_id:t});return n.versions}},this.actions={...this.real_actions};const o=(e,n=null,o=!1)=>new Promise((a=>{if(0!==e.length){const r=e=>e.startsWith("status_tree");let s,l=[];this.setState(le((a=>{let c;try{o&&([c,s,l]=re(n??a.notebook,(t=>{se(t,e)}))),c=se(n??a.notebook,e)}catch(n){var d,u;const o=(null===(d=String(n).match(".*'(.*)'.*"))||void 0===d?void 0:d[1].replace(/\//gi,"."))??n,a=ce.default.get(this.state.notebook,o,"Not Found");console.log((null===(u=String(n).match(".*'(.*)'.*"))||void 0===u?void 0:u[1].replace(/\//gi,"."))??n,o,typeof o);const s=r(o);return(s?console.log:console.error)(`#######################**************************########################\nPlutoError: StateOutOfSync: Failed to apply patches.\nPlease report this: https://github.com/fonsp/Pluto.jl/issues adding the info below:\nfailing path: ${o}\nnotebook previous value: ${a}\npatch: ${JSON.stringify(null==e?void 0:e.find((({path:e})=>e.join("")===o)),null,1)}\n#######################**************************########################`,n),void(s?console.info("Safe to ignore this patch failure..."):this.state.connected?(console.error("Trying to recover: Refetching notebook..."),this.client.send("reset_shared_state",{},{notebook_id:this.state.notebook.notebook_id},!1)):this.state.static_preview&&null!=t.slider_server_url?io.open_pluto_popup({type:"warn",body:i.html`Something went wrong while updating the notebook state. Please refresh the page to try again.`}):(console.error("Trying to recover: reloading..."),window.parent.location.href=this.state.refresh_target??window.location.href))}let p=c.cell_order.filter((e=>null==c.cell_inputs[e]));0!==p.length&&(console.warn("cells_stuck_in_limbo:",p),c.cell_order=c.cell_order.filter((e=>null!=c.cell_inputs[e]))),this.on_patches_hook(e),a.notebook=c})),(()=>a(l)))}else a([])}));this.apply_notebook_patches=o;const a=(e,n)=>{if(this.state.notebook.notebook_id===e.notebook_id){const r=null!=t.binder_url;r&&console.debug("on_update",e,n);const i=e.message;if("notebook_diff"===e.type){var a;let e=Promise.resolve();(null==i||null===(a=i.response)||void 0===a?void 0:a.from_reset)?(console.log("Trying to reset state after failure"),e=o(i.patches,Rc({notebook_id:this.state.notebook.notebook_id})).catch((e=>{throw alert("Oopsie!! please refresh your browser and everything will be alright!"),e}))):0!==i.patches.length&&(e=o(i.patches));const t=()=>{var e;null!=(null==i||null===(e=i.response)||void 0===e?void 0:e.update_went_well)&&0===i.patches.length||(this.waiting_for_bond_to_trigger_execution=!1)};e.then(t).catch((e=>{throw t(),e})).then((()=>{this.send_queued_bond_changes()}))}else console.error("Received unknown update type!",e);r&&console.debug("on_update done")}},r=async e=>{Object.assign(this.client,e);try{const t=await gc.get_environment(e),{custom_editor_header_component:n,custom_non_cell_output:o}=t({client:e,editor:this,imports:{preact:i}});this.setState({extended_components:{...this.state.extended_components,CustomHeader:n,NonCellOutputComponents:o}})}catch(e){}window.version_info=this.client.version_info,window.kill_socket=this.client.kill,e.notebook_exists?(console.debug("Sending update_notebook request..."),await this.client.send("update_notebook",{updates:[]},{notebook_id:this.state.notebook.notebook_id},!1),console.debug("Received update_notebook request"),this.setState({initializing:!1,static_preview:!1,backend_launch_phase:null==this.state.backend_launch_phase?null:To.ready}),this.client.send("complete",{query:"sq"},{notebook_id:this.state.notebook.notebook_id}),this.client.send("complete",{query:"\\sq"},{notebook_id:this.state.notebook.notebook_id}),setTimeout(ge,2e3)):console.error("Notebook does not exist. Not connecting.")},s=(e,t)=>{this.setState({connected:e}),t&&io.open_pluto_popup({type:"warn",body:i.html`<p>A new server was started - this notebook session is no longer running.</p>
<p>Would you like to go back to the main menu?</p>
<br />
<a href="./">Go back</a>
<br />
<a
href="#"
onClick=${e=>{e.preventDefault(),window.dispatchEvent(new CustomEvent("close pluto popup"))}}
>Stay here</a
>`,should_focus:!1})},l=()=>(console.warn("Reconnected! Checking states"),!0);this.export_url=e=>null==this.state.binder_session_url?`./${e}?id=${this.state.notebook.notebook_id}`:`${this.state.binder_session_url}${e}?id=${this.state.notebook.notebook_id}&token=${this.state.binder_session_token}`,this.client={},this.connect=e=>de.create_pluto_connection({ws_address:e,on_unrequested_update:a,on_connection_status:s,on_reconnect:l,connect_metadata:{notebook_id:this.state.notebook.notebook_id}}).then(r),this.on_disable_ui=()=>{Ac(this.state.disable_ui),Object.assign(this.actions,this.state.disable_ui||null!=t.slider_server_url&&!this.state.connected?null!=t.slider_server_url?(({setStatePromise:e,launch_params:t,actions:n,get_original_state:o,get_current_state:a,apply_notebook_patches:r})=>{e(le((e=>{e.slider_server.connecting=!0})));const i=fetch(new Request(t.notebookfile,{integrity:t.notebookfile_integrity})).then(jl).then((e=>e.arrayBuffer())).then(Il.plutohash_arraybuffer);i.then((e=>console.log("Notebook file hash:",e)));const s=i.then((e=>fetch(Ro(t.slider_server_url)+"bondconnections/"+e))).then(jl).then((e=>e.arrayBuffer())).then((e=>Pl.unpack(new Uint8Array(e))));s.then((t=>{console.log("Bond connections:",t),e(le((e=>{e.slider_server.connecting=!1,e.slider_server.interactive=Object.keys(t).length>0})))}));const l={},c={current:new Set},d=Il.debounced_promises((async()=>{const n=Ro(t.slider_server_url),d=await i,u=await s,p=a().cell_dependencies,m=Ul(p,c.current),g=[...Fl(p,m)],h=async t=>await e(le((e=>{g.forEach((n=>e.notebook.cell_results[n][m.has(n)?"running":"queued"]=t))})));if(await h(!0),c.current.size>0){const e=new Set(c.current);c.current.forEach((t=>(u[t]??[]).forEach((t=>e.add(t))))),console.debug("Requesting bonds",c.current,e),c.current=new Set;const t=Object.fromEntries(ce.default.sortBy(Object.entries(l).filter((([t,n])=>e.has(t))),(([e,t])=>e))),i=Pl.pack(t),s=n+"staterequest/"+d+"/";let p=null;try{const e=!(a().metadata.sliderserver_force_post??!1)&&s.length+4*i.length/3+20<8e3?await fetch(s+await Il.base64url_arraybuffer(i),{method:"GET"}).then(jl):await fetch(s,{method:"POST",body:i}).then(jl);p=Pl.unpack(new Uint8Array(await e.arrayBuffer()));const{patches:t,ids_of_cells_that_ran:n}=p;await r(t,le((e=>{const t=o();n.forEach((n=>{e.cell_results[n]=t.cell_results[n]}))}))(a()))}catch(e){console.error(p,e)}finally{await h(!1)}}}));return{...zl({actions:n}),set_bond:async(t,n)=>{e(le((e=>{e.notebook.bonds[t]={value:n}}))),null!=l[t]&&ce.default.isEqual(l[t].value,n)||(l[t]={value:ce.default.cloneDeep(n)},c.current.add(t),await d())}}})({setStatePromise:this.setStatePromise,actions:this.actions,launch_params:t,apply_notebook_patches:o,get_original_state:()=>this.props.initial_notebook_state,get_current_state:()=>this.state.notebook}):zl({actions:this.actions}):this.real_actions)},this.on_disable_ui(),setInterval((()=>{var e;this.state.static_preview||"visible"!==document.visibilityState||Do(`editing/${(null===window||void 0===window||null===(e=window.version_info)||void 0===e?void 0:e.pluto)??this.state.notebook.pluto_version??"unknown"}${window.plutoDesktop?"-desktop":""}`)}),9e5),setInterval((()=>{this.state.static_preview||"visible"!==document.visibilityState||Ec(this.state.notebook.path)}),5e3),this.bonds_changes_to_apply_when_done=[],this.send_queued_bond_changes=()=>{if(this.notebook_is_idle()&&0!==this.bonds_changes_to_apply_when_done.length){let e=this.bonds_changes_to_apply_when_done;this.bonds_changes_to_apply_when_done=[],this.update_notebook((t=>{se(t,e)}))}},this.waiting_for_bond_to_trigger_execution=!1,this.pending_local_updates=0,this.js_init_set=new Ee((()=>{this.send_queued_bond_changes()})),document.body._js_init_set=this.js_init_set,this.notebook_is_idle=()=>!(this.waiting_for_bond_to_trigger_execution||this.pending_local_updates>0||Object.values(this.state.notebook.cell_results).some((e=>e.running||e.queued))||!ce.default.isEmpty(this.js_init_set)||!this.is_process_ready()),this.is_process_ready=()=>this.state.notebook.process_status===hc.ProcessStatus.starting||this.state.notebook.process_status===hc.ProcessStatus.ready;const c=e=>Object.entries(this.state.notebook.cell_dependencies).some((([t,n])=>{if(n.upstream_cells_map.hasOwnProperty(e)){return!this.state.notebook.cell_inputs[t].metadata.disabled}})),d=e=>"replace"===e.op&&e.path.length>=1&&c(e.path[1]);let u=Promise.resolve(),p=e=>{const t=u.then((async()=>{let[t,n,o]=re(this.state.notebook,(t=>{e(t)})),a=this.notebook_is_idle(),r=n.filter((e=>"bonds"===e.path[0]));a||(this.bonds_changes_to_apply_when_done=[...this.bonds_changes_to_apply_when_done,...r],n=n.filter((e=>"bonds"!==e.path[0])));for(let e of n)if(e.path.some((e=>"number"==typeof e)))throw new Error("This sounds like it is editing an array...");if(0!==n.length){a&&(this.waiting_for_bond_to_trigger_execution=this.waiting_for_bond_to_trigger_execution||r.some(d)),this.pending_local_updates++,this.on_patches_hook(n);try{await Promise.all([this.client.send("update_notebook",{updates:n},{notebook_id:this.state.notebook.notebook_id},!1).then((e=>{var t,n;if("๐"===(null===(t=e.message)||void 0===t||null===(n=t.response)||void 0===n?void 0:n.update_went_well))throw new Error(`Pluto update_notebook error: (from Julia: ${e.message.response.why_not})`)})),this.setStatePromise({notebook:t,last_update_time:Date.now()})])}finally{this.pending_local_updates--}}}));return u=t.catch(console.error),t};this.update_notebook=p,window.shutdownNotebook=this.close=()=>{this.client.send("shutdown_notebook",{keep_in_session:!1},{notebook_id:this.state.notebook.notebook_id},!1)},this.submit_file_change=async(e,t)=>{const n=this.state.notebook.path;if(n!==e){if(!this.state.notebook.in_temp_dir&&!confirm("Are you sure? Will move from\n\n"+n+"\n\nto\n\n"+e))throw new Error("Declined by user");this.setState({moving_file:!0});try{var o;await p((t=>{t.in_temp_dir=!1,t.path=e})),null===(o=document.activeElement)||void 0===o||o.blur()}catch(e){alert("Failed to move file:\n\n"+e.message)}finally{this.setState({moving_file:!1})}}},this.desktop_submit_file_change=async()=>{var e,t;this.setState({moving_file:!0}),null===(e=window.plutoDesktop)||void 0===e||e.ipcRenderer.once("PLUTO-MOVE-NOTEBOOK",(async e=>{var t;e&&await this.setStatePromise(le((t=>{t.notebook.in_temp_dir=!1,t.notebook.path=e}))),this.setState({moving_file:!1}),null===(t=document.activeElement)||void 0===t||t.blur()})),null===(t=window.plutoDesktop)||void 0===t||t.fileSystem.moveNotebook()},this.delete_selected=e=>{if(this.state.selected_cells.length>0)return this.actions.confirm_delete_multiple(e,this.state.selected_cells),!0},this.run_selected=()=>this.actions.set_and_run_multiple(this.state.selected_cells),this.move_selected=(e,t)=>{if(this.state.selected_cells.length>0){const n=this.state.selected_cells.map((e=>this.state.notebook.cell_order.indexOf(e))),o=(t>0?Math.max:Math.min)(...n)+(-1===t?-1:2);return e.preventDefault(),this.actions.move_remote_cells(this.state.selected_cells,o).then((()=>{var e;null===(e=document.getElementById((t>0?ce.default.last:ce.default.first)(this.state.selected_cells)??""))||void 0===e||e.scrollIntoView({block:"nearest"})}))}},this.serialize_selected=(e=null)=>{const t=null==e||this.state.selected_cells.includes(e)?this.state.selected_cells:[e];if(t.length)return t.map((e=>this.state.notebook.cell_inputs[e])).map((e=>`# โโโก ${e.cell_id}\n`+e.code+"\n")).join("\n")},this.patch_listeners=[],this.on_patches_hook=e=>{this.patch_listeners.forEach((t=>t(e)))};let m={current:!1};const g=e=>{e!==m.current&&(m.current=e,document.body.querySelectorAll("[data-pluto-variable], [data-cell-variable]").forEach((t=>{t.setAttribute("data-ctrl-down",e?"true":"false")})))};document.addEventListener("keyup",(e=>{g($e.has_ctrl_or_cmd_pressed(e))})),document.addEventListener("visibilitychange",(e=>{g(!1),setTimeout((()=>{g(!1)}),100)})),document.addEventListener("keydown",(e=>{var t,n;if(g($e.has_ctrl_or_cmd_pressed(e)),"q"===(null===(n=e.key)||void 0===n?void 0:n.toLowerCase())&&$e.has_ctrl_or_cmd_pressed(e))Object.values(this.state.notebook.cell_results).some((e=>e.running||e.queued))&&this.actions.interrupt_remote(),e.preventDefault();else if("s"===(null===(t=e.key)||void 0===t?void 0:t.toLowerCase())&&$e.has_ctrl_or_cmd_pressed(e)){this.actions.set_and_run_all_changed_remote_cells();e.preventDefault()}else"Backspace"===e.key||"Delete"===e.key?this.delete_selected("Delete")&&e.preventDefault():"Enter"===e.key&&e.shiftKey?this.run_selected():"ArrowUp"===e.key&&e.altKey?this.move_selected(e,-1):"ArrowDown"===e.key&&e.altKey?this.move_selected(e,1):"?"===e.key&&$e.has_ctrl_or_cmd_pressed(e)||"F1"===e.key?(alert(`Shortcuts ๐น\n\n โง${$e.and}Enter: run cell\n ${$e.ctrl_or_cmd_name}${$e.and}Enter: run cell and add cell below\n ${$e.ctrl_or_cmd_name}${$e.and}S: submit all changes\n Delete or Backspace: delete empty cell\n\n page up or fn${$e.and}โ: jump to cell above\n page down or fn${$e.and}โ: jump to cell below\n ${$e.alt_or_options_name}${$e.and}โ: move line/cell up\n ${$e.alt_or_options_name}${$e.and}โ: move line/cell down\n\n \n Select multiple cells by dragging a selection box from the space between cells.\n ${$e.ctrl_or_cmd_name}${$e.and}C: copy selected cells\n ${$e.ctrl_or_cmd_name}${$e.and}X: cut selected cells\n ${$e.ctrl_or_cmd_name}${$e.and}V: paste selected cells\n \n ${$e.control_name}${$e.and}M: toggle markdown\n ${$e.ctrl_or_cmd_name}${$e.and}Q: interrupt notebook\n\n The notebook file saves every time you run a cell.`),e.preventDefault()):"Escape"===e.key&&this.setState({recording_waiting_to_start:!1,selected_cells:[],export_menu_open:!1});this.state.disable_ui&&this.state.backend_launch_phase===To.wait_for_user&&("Enter"!==e.key&&1!==(null===(n=e.key)||void 0===n?void 0:n.length)||document.body.classList.contains("wiggle_binder")||(document.body.classList.add("wiggle_binder"),setTimeout((()=>{document.body.classList.remove("wiggle_binder")}),1e3)))})),document.addEventListener("copy",(e=>{if(!$e.in_textarea_or_input()){const t=this.serialize_selected();t&&navigator.clipboard.writeText(t).catch((t=>{console.error("Error copying cells",e,t),alert(`Error copying cells: ${t}`)}))}})),document.addEventListener("cut",(e=>{})),document.addEventListener("paste",(async e=>{var t;const n=null===(t=e.clipboardData)||void 0===t?void 0:t.getData("text/plain");if(n){const t=_e(n);null!=t&&(this.actions.add_deserialized_cells(n,-1,t),e.preventDefault())}})),window.addEventListener("beforeunload",(e=>{const t=this.state.notebook.cell_order.filter((e=>this.state.cell_inputs_local[e]&&this.state.notebook.cell_inputs[e].code!==this.state.cell_inputs_local[e].code))[0];null!=t?(window.dispatchEvent(new CustomEvent("cell_focus",{detail:{cell_id:t}})),console.log("Preventing unload"),e.stopImmediatePropagation(),e.preventDefault(),e.returnValue=""):(console.warn("unloading ๐ disconnecting websocket"),window.shutdown_binder)}))}componentDidMount(){const e=this.props.launch_params;var t;this.state.static_preview?(this.setState({initializing:!1}),Do(null!=e.pluto_server_url?`featured-view${null!=e.notebookfile?new URL(e.notebookfile).pathname:""}`:`article-view/${(null===window||void 0===window||null===(t=window.version_info)||void 0===t?void 0:t.pluto)??this.state.notebook.pluto_version??"unknown"}`)):this.connect(e.pluto_server_url?de.ws_address_from_base(e.pluto_server_url):void 0)}componentDidUpdate(e,t){var n,o,a,r,i,s,l,c;window.editor_state=this.state,window.editor_state_set=this.setStatePromise;const d=this.state;if((null==t||null===(u=t.notebook)||void 0===u?void 0:u.path)!==d.notebook.path&&Ec(d.notebook.path,null==t||null===(n=t.notebook)||void 0===n?void 0:n.path),(null==t||null===(o=t.notebook)||void 0===o?void 0:o.shortpath)!==d.notebook.shortpath&&(document.title="๐ "+d.notebook.shortpath+" โ Pluto.jl"),document.body._update_is_ongoing=this.pending_local_updates>0,this.send_queued_bond_changes(),t.backend_launch_phase!==this.state.backend_launch_phase&&null!=this.state.backend_launch_phase){var u;const e=null===(u=Object.entries(To).find((([e,t])=>t==this.state.backend_launch_phase)))||void 0===u?void 0:u[0];console.info(`Binder phase: ${e} at ${(new Date).toLocaleTimeString()}`)}t.disable_ui===this.state.disable_ui&&t.connected===this.state.connected||this.on_disable_ui(),this.state.initializing||(()=>{if(Ll)return;Ll=!0;const e=()=>console.warn("Pluto uses MathJax 3, but a MathJax 2 function was called.");window.MathJax={options:{ignoreHtmlClass:"no-MฮฑฮธJax",processHtmlClass:"tex"},startup:{typeset:!0,ready:()=>{window.MathJax.startup.defaultReady(),window.MathJax.Hub={Queue:function(){for(var e=0,t=arguments.length;e<t;e++){var n=window.MathJax.Callback(arguments[e]);window.MathJax.startup.promise=window.MathJax.startup.promise.then(n)}return window.MathJax.startup.promise},Typeset:function(e,t){var n=window.MathJax.typesetPromise(e);return t&&(n=n.then(t)),n},Register:{MessageHook:e,StartupHook:e,LoadHook:e},Config:e,Configured:e,setRenderer:e}}},tex:{inlineMath:[["$","$"],["\\(","\\)"]]},svg:{fontCache:"global"}},requestIdleCallback((()=>{console.log("Loading mathjax!!");const e=document.head.querySelector("#MathJax-script");e.setAttribute("src",e.getAttribute("not-the-src-yet"))}),{timeout:2e3})})(),(null===(a=t.notebook.nbpkg)||void 0===a?void 0:a.restart_recommended_msg)!==(null===(r=d.notebook.nbpkg)||void 0===r?void 0:r.restart_recommended_msg)&&console.warn(`New restart recommended message: ${null===(i=d.notebook.nbpkg)||void 0===i?void 0:i.restart_recommended_msg}`),(null===(s=t.notebook.nbpkg)||void 0===s?void 0:s.restart_required_msg)!==(null===(l=d.notebook.nbpkg)||void 0===l?void 0:l.restart_required_msg)&&console.warn(`New restart required message: ${null===(c=d.notebook.nbpkg)||void 0===c?void 0:c.restart_required_msg}`)}componentWillUpdate(e,t){this.cached_status=vc(t,this.props.launch_params),Object.entries(this.cached_status).forEach((([e,t])=>{document.body.classList.toggle(e,!0===t)}))}render(){var e,t,n,o,a,r,s,l;const{launch_params:c}=this.props;let{export_menu_open:d,notebook:u}=this.state;const p=this.cached_status??vc(this.state,c),m=(e=>{for(let[t,n]of Object.entries(e))if(n)return t})(p);if(p.isolated_cell_view)return i.html`
<${ye.Provider} value=${this.actions}>
<${we.Provider} value=${this.state.notebook.bonds}>
<${ke.Provider} value=${this.js_init_set}>
<${ql} notebook=${this.state.notebook} backend_launch_phase=${this.state.backend_launch_phase} status=${p}/>
<div style="width: 100%">
${this.state.notebook.cell_order.map(((e,t)=>{var n;return i.html`
<${bl}
cell_input=${u.cell_inputs[e]}
cell_result=${this.state.notebook.cell_results[e]}
hidden=${!(null===(n=c.isolated_cell_ids)||void 0===n?void 0:n.includes(e))}
sanitize_html=${p.sanitize_html}
/>
`}))}