MailChimp for WordPress - Version 4.1.0

Version Description

Download this release

Release Info

Developer DvanKooten
Plugin Icon 128x128 MailChimp for WordPress
Version 4.1.0
Comparing to
See all releases

Code changes from version 4.0.13 to 4.1.0

CHANGELOG.md CHANGED
@@ -1,6 +1,22 @@
1
  Changelog
2
  =========
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  #### 4.0.13 - February 8, 2017
5
 
6
  **Improvements**
1
  Changelog
2
  =========
3
 
4
+ #### 4.1.0 - March 14, 2017
5
+
6
+ **Improvements**
7
+
8
+ - Updated all JavaScript dependencies in the plugin.
9
+ - Failsafed filter hooks to prevent invalid variable types.
10
+ - Explain that greyed out integrations means that specific plugin is not activated.
11
+ - Conditional form elements now uses event delegation, so it works with forms in [Boxzilla pop-ups](https://boxzillaplugin.com/).
12
+ - Updated language files.
13
+
14
+ **Additions**
15
+
16
+ - Added support for Ninja Forms 3.
17
+ - Added `mc4wp_integration_show_checkbox` filter.
18
+
19
+
20
  #### 4.0.13 - February 8, 2017
21
 
22
  **Improvements**
assets/js/admin.js CHANGED
@@ -2,21 +2,22 @@
2
  'use strict';
3
 
4
  // dependencies
 
5
  var m = window.m = require('mithril');
6
  var EventEmitter = require('wolfy87-eventemitter');
7
 
8
  // vars
9
  var context = document.getElementById('mc4wp-admin');
10
  var events = new EventEmitter();
11
- var tabs = require ('./admin/tabs.js')(context);
12
  var helpers = require('./admin/helpers.js');
13
  var settings = require('./admin/settings.js')(context, helpers, events);
14
 
15
  // list fetcher
16
  var ListFetcher = require('./admin/list-fetcher.js');
17
  var mount = document.getElementById('mc4wp-list-fetcher');
18
- if( mount ) {
19
- m.mount(mount, new ListFetcher);
20
  }
21
 
22
  // expose some things
@@ -27,40 +28,41 @@ window.mc4wp.helpers = helpers;
27
  window.mc4wp.events = events;
28
  window.mc4wp.settings = settings;
29
  window.mc4wp.tabs = tabs;
 
30
  },{"./admin/helpers.js":2,"./admin/list-fetcher.js":3,"./admin/settings.js":4,"./admin/tabs.js":5,"mithril":7,"wolfy87-eventemitter":8}],2:[function(require,module,exports){
31
  'use strict';
32
 
33
  var helpers = {};
34
 
35
- helpers.toggleElement = function(selector) {
36
  var elements = document.querySelectorAll(selector);
37
- for( var i=0; i<elements.length;i++){
38
  var show = elements[i].clientHeight <= 0;
39
  elements[i].style.display = show ? '' : 'none';
40
  }
41
  };
42
 
43
- helpers.bindEventToElement = function(element,event,handler) {
44
- if ( element.addEventListener) {
45
  element.addEventListener(event, handler);
46
- } else if (element.attachEvent) {
47
  element.attachEvent('on' + event, handler);
48
  }
49
  };
50
 
51
- helpers.bindEventToElements = function( elements, event, handler ) {
52
- Array.prototype.forEach.call( elements, function(element) {
53
- helpers.bindEventToElement(element,event,handler);
54
  });
55
  };
56
 
57
-
58
  // polling
59
- helpers.debounce = function(func, wait, immediate) {
60
  var timeout;
61
- return function() {
62
- var context = this, args = arguments;
63
- var later = function() {
 
64
  timeout = null;
65
  if (!immediate) func.apply(context, args);
66
  };
@@ -71,31 +73,30 @@ helpers.debounce = function(func, wait, immediate) {
71
  };
72
  };
73
 
74
-
75
  /**
76
  * Showif.js
77
  */
78
- (function() {
79
  var showIfElements = document.querySelectorAll('[data-showif]');
80
 
81
  // dependent elements
82
- Array.prototype.forEach.call( showIfElements, function(element) {
83
- var config = JSON.parse( element.getAttribute('data-showif') );
84
- var parentElements = document.querySelectorAll('[name="'+ config.element +'"]');
85
  var inputs = element.querySelectorAll('input,select,textarea:not([readonly])');
86
  var hide = config.hide === undefined || config.hide;
87
 
88
  function toggleElement() {
89
 
90
  // do nothing with unchecked radio inputs
91
- if( this.getAttribute('type') === "radio" && ! this.checked ) {
92
  return;
93
  }
94
 
95
- var value = ( this.getAttribute("type") === "checkbox" ) ? this.checked : this.value;
96
- var conditionMet = ( value == config.value );
97
 
98
- if( hide ) {
99
  element.style.display = conditionMet ? '' : 'none';
100
  element.style.visibility = conditionMet ? '' : 'hidden';
101
  } else {
@@ -103,13 +104,13 @@ helpers.debounce = function(func, wait, immediate) {
103
  }
104
 
105
  // disable input fields to stop sending their values to server
106
- Array.prototype.forEach.call( inputs, function(inputElement) {
107
- conditionMet ? inputElement.removeAttribute('readonly') : inputElement.setAttribute('readonly','readonly');
108
  });
109
  }
110
 
111
  // find checked element and call toggleElement function
112
- Array.prototype.forEach.call( parentElements, function( parentElement ) {
113
  toggleElement.call(parentElement);
114
  });
115
 
@@ -119,6 +120,7 @@ helpers.debounce = function(func, wait, immediate) {
119
  })();
120
 
121
  module.exports = helpers;
 
122
  },{}],3:[function(require,module,exports){
123
  'use strict';
124
 
@@ -131,7 +133,7 @@ function ListFetcher() {
131
  this.done = false;
132
 
133
  // start fetching right away when no lists but api key given
134
- if( config.mailchimp.api_connected && config.mailchimp.lists.length == 0 ) {
135
  this.fetch();
136
  }
137
  }
@@ -144,9 +146,11 @@ ListFetcher.prototype.fetch = function (e) {
144
 
145
  $.post(ajaxurl, {
146
  action: "mc4wp_renew_mailchimp_lists"
147
- }).done(function(data) {
148
- if(data) {
149
- window.setTimeout(function() { window.location.reload(); }, 3000 );
 
 
150
  }
151
  }).always(function (data) {
152
  this.working = false;
@@ -160,43 +164,34 @@ ListFetcher.prototype.view = function () {
160
  return m('form', {
161
  method: "POST",
162
  onsubmit: this.fetch.bind(this)
163
- }, [
164
- m('p', [
165
- m('input', {
166
- type: "submit",
167
- value: this.working ? i18n.fetching_mailchimp_lists : i18n.renew_mailchimp_lists,
168
- className: "button",
169
- disabled: !!this.working
170
- }),
171
- m.trust(' &nbsp; '),
172
-
173
- this.working ? [
174
- m('span.mc4wp-loader', "Loading..."),
175
- m.trust(' &nbsp; '),
176
- m('em.help', i18n.fetching_mailchimp_lists_can_take_a_while)
177
- ]: '',
178
-
179
- this.done ? [
180
- m( 'em.help.green', i18n.fetching_mailchimp_lists_done )
181
- ] : ''
182
- ])
183
- ]);
184
  };
185
 
186
  module.exports = ListFetcher;
 
187
  },{}],4:[function(require,module,exports){
188
- var Settings = function(context, helpers, events ) {
 
 
 
 
189
  'use strict';
190
 
191
  // vars
 
192
  var form = context.querySelector('form');
193
  var listInputs = context.querySelectorAll('.mc4wp-list-input');
194
  var lists = mc4wp_vars.mailchimp.lists;
195
  var selectedLists = [];
196
 
197
  // functions
198
- function getSelectedListsWhere(searchKey,searchValue) {
199
- return selectedLists.filter(function(el) {
200
  return el[searchKey] === searchValue;
201
  });
202
  }
@@ -208,57 +203,57 @@ var Settings = function(context, helpers, events ) {
208
  function updateSelectedLists() {
209
  selectedLists = [];
210
 
211
- Array.prototype.forEach.call(listInputs, function(input) {
212
  // skip unchecked checkboxes
213
- if( typeof( input.checked ) === "boolean" && ! input.checked ) {
214
  return;
215
  }
216
 
217
- if( typeof( lists[ input.value ] ) === "object" ){
218
- selectedLists.push( lists[ input.value ] );
219
  }
220
  });
221
 
222
- events.trigger('selectedLists.change', [ selectedLists ]);
223
  return selectedLists;
224
  }
225
 
226
  function toggleVisibleLists() {
227
  var rows = document.querySelectorAll('.lists--only-selected > *');
228
- Array.prototype.forEach.call(rows, function(el) {
229
 
230
  var listId = el.getAttribute('data-list-id');
231
  var isSelected = getSelectedListsWhere('id', listId).length > 0;
232
 
233
- if( isSelected ) {
234
- el.setAttribute('class', el.getAttribute('class').replace('hidden',''));
235
  } else {
236
- el.setAttribute('class', el.getAttribute('class') + " hidden" );
237
  }
238
  });
239
  }
240
 
241
  events.on('selectedLists.change', toggleVisibleLists);
242
- helpers.bindEventToElements(listInputs,'change',updateSelectedLists);
243
 
244
  updateSelectedLists();
245
 
246
  return {
247
  getSelectedLists: getSelectedLists
248
- }
249
-
250
  };
251
 
252
  module.exports = Settings;
 
253
  },{}],5:[function(require,module,exports){
254
  'use strict';
255
 
256
  var URL = require('./url.js');
257
 
258
  // Tabs
259
- var Tabs = function(context) {
260
 
261
- // @todo last piece of jQuery... can we get rid of it?
262
  var $ = window.jQuery;
263
 
264
  var $context = $(context);
@@ -267,7 +262,7 @@ var Tabs = function(context) {
267
  var refererField = context.querySelector('input[name="_wp_http_referer"]');
268
  var tabs = [];
269
 
270
- $.each($tabs, function(i,t) {
271
  var id = t.id.substring(4);
272
  var title = $(t).find('h2').first().text();
273
 
@@ -276,14 +271,16 @@ var Tabs = function(context) {
276
  title: title,
277
  element: t,
278
  nav: context.querySelectorAll('.nav-tab-' + id),
279
- open: function() { return open(id); }
 
 
280
  });
281
  });
282
 
283
  function get(id) {
284
 
285
- for( var i=0; i<tabs.length; i++){
286
- if(tabs[i].id === id ) {
287
  return tabs[i];
288
  }
289
  }
@@ -291,17 +288,19 @@ var Tabs = function(context) {
291
  return undefined;
292
  }
293
 
294
- function open( tab, updateState ) {
295
 
296
  // make sure we have a tab object
297
- if(typeof(tab) === "string"){
298
  tab = get(tab);
299
  }
300
 
301
- if(!tab) { return false; }
 
 
302
 
303
  // should we update state?
304
- if( updateState == undefined ) {
305
  updateState = true;
306
  }
307
 
@@ -310,7 +309,7 @@ var Tabs = function(context) {
310
  $tabNavs.removeClass('nav-tab-active');
311
 
312
  // add `nav-tab-active` to this tab
313
- Array.prototype.forEach.call(tab.nav, function(nav) {
314
  nav.className += " nav-tab-active";
315
  nav.blur();
316
  });
@@ -320,11 +319,11 @@ var Tabs = function(context) {
320
  tab.element.className += " tab-active";
321
 
322
  // create new URL
323
- var url = URL.setParameter(window.location.href, "tab", tab.id );
324
 
325
  // update hash
326
- if( history.pushState && updateState ) {
327
- history.pushState( tab.id, '', url );
328
  }
329
 
330
  // update document title
@@ -334,13 +333,13 @@ var Tabs = function(context) {
334
  refererField.value = url;
335
 
336
  // if thickbox is open, close it.
337
- if( typeof(tb_remove) === "function" ) {
338
  tb_remove();
339
  }
340
 
341
  // refresh editor after switching tabs
342
- // TODO: decouple decouple decouple
343
- if( tab.id === 'fields' && window.mc4wp && window.mc4wp.forms && window.mc4wp.forms.editor ) {
344
  mc4wp.forms.editor.refresh();
345
  }
346
 
@@ -359,23 +358,25 @@ var Tabs = function(context) {
359
  var tabId = this.getAttribute('data-tab');
360
 
361
  // get from classname
362
- if( ! tabId ) {
363
  var match = this.className.match(/nav-tab-(\w+)?/);
364
- if( match ) {
365
  tabId = match[1];
366
  }
367
  }
368
 
369
  // get from href
370
- if( ! tabId ) {
371
- var urlParams = URL.parse( this.href );
372
- if( ! urlParams.tab ) { return; }
 
 
373
  tabId = urlParams.tab;
374
  }
375
 
376
- var opened = open( tabId );
377
 
378
- if( opened ) {
379
  e.preventDefault();
380
  e.returnValue = false;
381
  return false;
@@ -387,18 +388,20 @@ var Tabs = function(context) {
387
  function init() {
388
 
389
  // check for current tab
390
- if(! history.pushState) {
391
  return;
392
  }
393
 
394
  var activeTab = $tabs.filter(':visible').get(0);
395
- if( ! activeTab ) { return; }
 
 
396
  var tab = get(activeTab.id.substring(4));
397
- if(!tab) return;
398
 
399
  // check if tab is in html5 history
400
- if( history.replaceState && history.state === null) {
401
- history.replaceState( tab.id, '' );
402
  }
403
 
404
  // update document title
@@ -409,31 +412,31 @@ var Tabs = function(context) {
409
  $(document.body).on('click', '.tab-link', switchTab);
410
  init();
411
 
412
- if(window.addEventListener && history.pushState ) {
413
- window.addEventListener('popstate', function(e) {
414
- if(!e.state) return true;
415
  var tabId = e.state;
416
- return open(tabId,false);
417
  });
418
  }
419
 
420
  return {
421
- open: open,
422
  get: get
423
- }
424
-
425
  };
426
 
427
  module.exports = Tabs;
 
428
  },{"./url.js":6}],6:[function(require,module,exports){
429
  'use strict';
430
 
431
  var URL = {
432
- parse: function(url) {
433
  var query = {};
434
  var a = url.split('&');
435
  for (var i in a) {
436
- if(!a.hasOwnProperty(i)) {
437
  continue;
438
  }
439
  var b = a[i].split('=');
@@ -442,2264 +445,1196 @@ var URL = {
442
 
443
  return query;
444
  },
445
- build: function(data) {
446
  var ret = [];
447
- for (var d in data)
448
  ret.push(d + "=" + encodeURIComponent(data[d]));
449
- return ret.join("&");
450
  },
451
- setParameter: function( url, key, value ) {
452
- var data = URL.parse( url );
453
- data[ key ] = value;
454
- return URL.build( data );
455
  }
456
  };
457
 
458
  module.exports = URL;
 
459
  },{}],7:[function(require,module,exports){
460
- ;(function (global, factory) { // eslint-disable-line
461
- "use strict"
462
- /* eslint-disable no-undef */
463
- var m = factory(global)
464
- if (typeof module === "object" && module != null && module.exports) {
465
- module.exports = m
466
- } else if (typeof define === "function" && define.amd) {
467
- define(function () { return m })
468
- } else {
469
- global.m = m
470
- }
471
- /* eslint-enable no-undef */
472
- })(typeof window !== "undefined" ? window : this, function (global, undefined) { // eslint-disable-line
473
- "use strict"
474
-
475
- m.version = function () {
476
- return "v0.2.5"
477
- }
478
-
479
- var hasOwn = {}.hasOwnProperty
480
- var type = {}.toString
481
-
482
- function isFunction(object) {
483
- return typeof object === "function"
484
- }
485
-
486
- function isObject(object) {
487
- return type.call(object) === "[object Object]"
488
- }
489
-
490
- function isString(object) {
491
- return type.call(object) === "[object String]"
492
- }
493
-
494
- var isArray = Array.isArray || function (object) {
495
- return type.call(object) === "[object Array]"
496
- }
497
-
498
- function noop() {}
499
-
500
- var voidElements = {
501
- AREA: 1,
502
- BASE: 1,
503
- BR: 1,
504
- COL: 1,
505
- COMMAND: 1,
506
- EMBED: 1,
507
- HR: 1,
508
- IMG: 1,
509
- INPUT: 1,
510
- KEYGEN: 1,
511
- LINK: 1,
512
- META: 1,
513
- PARAM: 1,
514
- SOURCE: 1,
515
- TRACK: 1,
516
- WBR: 1
517
- }
518
-
519
- // caching commonly used variables
520
- var $document, $location, $requestAnimationFrame, $cancelAnimationFrame
521
-
522
- // self invoking function needed because of the way mocks work
523
- function initialize(mock) {
524
- $document = mock.document
525
- $location = mock.location
526
- $cancelAnimationFrame = mock.cancelAnimationFrame || mock.clearTimeout
527
- $requestAnimationFrame = mock.requestAnimationFrame || mock.setTimeout
528
- }
529
-
530
- // testing API
531
- m.deps = function (mock) {
532
- initialize(global = mock || window)
533
- return global
534
- }
535
-
536
- m.deps(global)
537
-
538
- /**
539
- * @typedef {String} Tag
540
- * A string that looks like -> div.classname#id[param=one][param2=two]
541
- * Which describes a DOM node
542
- */
543
-
544
- function parseTagAttrs(cell, tag) {
545
- var classes = []
546
- var parser = /(?:(^|#|\.)([^#\.\[\]]+))|(\[.+?\])/g
547
- var match
548
-
549
- while ((match = parser.exec(tag))) {
550
- if (match[1] === "" && match[2]) {
551
- cell.tag = match[2]
552
- } else if (match[1] === "#") {
553
- cell.attrs.id = match[2]
554
- } else if (match[1] === ".") {
555
- classes.push(match[2])
556
- } else if (match[3][0] === "[") {
557
- var pair = /\[(.+?)(?:=("|'|)(.*?)\2)?\]/.exec(match[3])
558
- cell.attrs[pair[1]] = pair[3] || ""
559
- }
560
- }
561
-
562
- return classes
563
- }
564
-
565
- function getVirtualChildren(args, hasAttrs) {
566
- var children = hasAttrs ? args.slice(1) : args
567
-
568
- if (children.length === 1 && isArray(children[0])) {
569
- return children[0]
570
- } else {
571
- return children
572
- }
573
- }
574
-
575
- function assignAttrs(target, attrs, classes) {
576
- var classAttr = "class" in attrs ? "class" : "className"
577
-
578
- for (var attrName in attrs) {
579
- if (hasOwn.call(attrs, attrName)) {
580
- if (attrName === classAttr &&
581
- attrs[attrName] != null &&
582
- attrs[attrName] !== "") {
583
- classes.push(attrs[attrName])
584
- // create key in correct iteration order
585
- target[attrName] = ""
586
- } else {
587
- target[attrName] = attrs[attrName]
588
- }
589
- }
590
- }
591
-
592
- if (classes.length) target[classAttr] = classes.join(" ")
593
- }
594
-
595
- /**
596
- *
597
- * @param {Tag} The DOM node tag
598
- * @param {Object=[]} optional key-value pairs to be mapped to DOM attrs
599
- * @param {...mNode=[]} Zero or more Mithril child nodes. Can be an array,
600
- * or splat (optional)
601
- */
602
- function m(tag, pairs) {
603
- var args = []
604
-
605
- for (var i = 1, length = arguments.length; i < length; i++) {
606
- args[i - 1] = arguments[i]
607
- }
608
-
609
- if (isObject(tag)) return parameterize(tag, args)
610
-
611
- if (!isString(tag)) {
612
- throw new Error("selector in m(selector, attrs, children) should " +
613
- "be a string")
614
- }
615
-
616
- var hasAttrs = pairs != null && isObject(pairs) &&
617
- !("tag" in pairs || "view" in pairs || "subtree" in pairs)
618
-
619
- var attrs = hasAttrs ? pairs : {}
620
- var cell = {
621
- tag: "div",
622
- attrs: {},
623
- children: getVirtualChildren(args, hasAttrs)
624
- }
625
-
626
- assignAttrs(cell.attrs, attrs, parseTagAttrs(cell, tag))
627
- return cell
628
- }
629
-
630
- function forEach(list, f) {
631
- for (var i = 0; i < list.length && !f(list[i], i++);) {
632
- // function called in condition
633
- }
634
- }
635
-
636
- function forKeys(list, f) {
637
- forEach(list, function (attrs, i) {
638
- return (attrs = attrs && attrs.attrs) &&
639
- attrs.key != null &&
640
- f(attrs, i)
641
- })
642
- }
643
- // This function was causing deopts in Chrome.
644
- function dataToString(data) {
645
- // data.toString() might throw or return null if data is the return
646
- // value of Console.log in some versions of Firefox (behavior depends on
647
- // version)
648
- try {
649
- if (data != null && data.toString() != null) return data
650
- } catch (e) {
651
- // silently ignore errors
652
- }
653
- return ""
654
- }
655
-
656
- // This function was causing deopts in Chrome.
657
- function injectTextNode(parentElement, first, index, data) {
658
- try {
659
- insertNode(parentElement, first, index)
660
- first.nodeValue = data
661
- } catch (e) {
662
- // IE erroneously throws error when appending an empty text node
663
- // after a null
664
- }
665
- }
666
-
667
- function flatten(list) {
668
- // recursively flatten array
669
- for (var i = 0; i < list.length; i++) {
670
- if (isArray(list[i])) {
671
- list = list.concat.apply([], list)
672
- // check current index again and flatten until there are no more
673
- // nested arrays at that index
674
- i--
675
- }
676
- }
677
- return list
678
- }
679
-
680
- function insertNode(parentElement, node, index) {
681
- parentElement.insertBefore(node,
682
- parentElement.childNodes[index] || null)
683
- }
684
-
685
- var DELETION = 1
686
- var INSERTION = 2
687
- var MOVE = 3
688
-
689
- function handleKeysDiffer(data, existing, cached, parentElement) {
690
- forKeys(data, function (key, i) {
691
- existing[key = key.key] = existing[key] ? {
692
- action: MOVE,
693
- index: i,
694
- from: existing[key].index,
695
- element: cached.nodes[existing[key].index] ||
696
- $document.createElement("div")
697
- } : {action: INSERTION, index: i}
698
- })
699
-
700
- var actions = []
701
- for (var prop in existing) {
702
- if (hasOwn.call(existing, prop)) {
703
- actions.push(existing[prop])
704
- }
705
- }
706
-
707
- var changes = actions.sort(sortChanges)
708
- var newCached = new Array(cached.length)
709
-
710
- newCached.nodes = cached.nodes.slice()
711
-
712
- forEach(changes, function (change) {
713
- var index = change.index
714
- if (change.action === DELETION) {
715
- clear(cached[index].nodes, cached[index])
716
- newCached.splice(index, 1)
717
- }
718
- if (change.action === INSERTION) {
719
- var dummy = $document.createElement("div")
720
- dummy.key = data[index].attrs.key
721
- insertNode(parentElement, dummy, index)
722
- newCached.splice(index, 0, {
723
- attrs: {key: data[index].attrs.key},
724
- nodes: [dummy]
725
- })
726
- newCached.nodes[index] = dummy
727
- }
728
-
729
- if (change.action === MOVE) {
730
- var changeElement = change.element
731
- var maybeChanged = parentElement.childNodes[index]
732
- if (maybeChanged !== changeElement && changeElement !== null) {
733
- parentElement.insertBefore(changeElement,
734
- maybeChanged || null)
735
- }
736
- newCached[index] = cached[change.from]
737
- newCached.nodes[index] = changeElement
738
- }
739
- })
740
-
741
- return newCached
742
- }
743
-
744
- function diffKeys(data, cached, existing, parentElement) {
745
- var keysDiffer = data.length !== cached.length
746
-
747
- if (!keysDiffer) {
748
- forKeys(data, function (attrs, i) {
749
- var cachedCell = cached[i]
750
- return keysDiffer = cachedCell &&
751
- cachedCell.attrs &&
752
- cachedCell.attrs.key !== attrs.key
753
- })
754
- }
755
-
756
- if (keysDiffer) {
757
- return handleKeysDiffer(data, existing, cached, parentElement)
758
- } else {
759
- return cached
760
- }
761
- }
762
-
763
- function diffArray(data, cached, nodes) {
764
- // diff the array itself
765
-
766
- // update the list of DOM nodes by collecting the nodes from each item
767
- forEach(data, function (_, i) {
768
- if (cached[i] != null) nodes.push.apply(nodes, cached[i].nodes)
769
- })
770
- // remove items from the end of the array if the new array is shorter
771
- // than the old one. if errors ever happen here, the issue is most
772
- // likely a bug in the construction of the `cached` data structure
773
- // somewhere earlier in the program
774
- forEach(cached.nodes, function (node, i) {
775
- if (node.parentNode != null && nodes.indexOf(node) < 0) {
776
- clear([node], [cached[i]])
777
- }
778
- })
779
-
780
- if (data.length < cached.length) cached.length = data.length
781
- cached.nodes = nodes
782
- }
783
-
784
- function buildArrayKeys(data) {
785
- var guid = 0
786
- forKeys(data, function () {
787
- forEach(data, function (attrs) {
788
- if ((attrs = attrs && attrs.attrs) && attrs.key == null) {
789
- attrs.key = "__mithril__" + guid++
790
- }
791
- })
792
- return 1
793
- })
794
- }
795
-
796
- function isDifferentEnough(data, cached, dataAttrKeys) {
797
- if (data.tag !== cached.tag) return true
798
-
799
- if (dataAttrKeys.sort().join() !==
800
- Object.keys(cached.attrs).sort().join()) {
801
- return true
802
- }
803
-
804
- if (data.attrs.id !== cached.attrs.id) {
805
- return true
806
- }
807
-
808
- if (data.attrs.key !== cached.attrs.key) {
809
- return true
810
- }
811
-
812
- if (m.redraw.strategy() === "all") {
813
- return !cached.configContext || cached.configContext.retain !== true
814
- }
815
-
816
- if (m.redraw.strategy() === "diff") {
817
- return cached.configContext && cached.configContext.retain === false
818
- }
819
-
820
- return false
821
- }
822
-
823
- function maybeRecreateObject(data, cached, dataAttrKeys) {
824
- // if an element is different enough from the one in cache, recreate it
825
- if (isDifferentEnough(data, cached, dataAttrKeys)) {
826
- if (cached.nodes.length) clear(cached.nodes)
827
-
828
- if (cached.configContext &&
829
- isFunction(cached.configContext.onunload)) {
830
- cached.configContext.onunload()
831
- }
832
-
833
- if (cached.controllers) {
834
- forEach(cached.controllers, function (controller) {
835
- if (controller.onunload) {
836
- controller.onunload({preventDefault: noop})
837
- }
838
- })
839
- }
840
- }
841
- }
842
-
843
- function getObjectNamespace(data, namespace) {
844
- if (data.attrs.xmlns) return data.attrs.xmlns
845
- if (data.tag === "svg") return "http://www.w3.org/2000/svg"
846
- if (data.tag === "math") return "http://www.w3.org/1998/Math/MathML"
847
- return namespace
848
- }
849
-
850
- var pendingRequests = 0
851
- m.startComputation = function () { pendingRequests++ }
852
- m.endComputation = function () {
853
- if (pendingRequests > 1) {
854
- pendingRequests--
855
- } else {
856
- pendingRequests = 0
857
- m.redraw()
858
- }
859
- }
860
-
861
- function unloadCachedControllers(cached, views, controllers) {
862
- if (controllers.length) {
863
- cached.views = views
864
- cached.controllers = controllers
865
- forEach(controllers, function (controller) {
866
- if (controller.onunload && controller.onunload.$old) {
867
- controller.onunload = controller.onunload.$old
868
- }
869
-
870
- if (pendingRequests && controller.onunload) {
871
- var onunload = controller.onunload
872
- controller.onunload = noop
873
- controller.onunload.$old = onunload
874
- }
875
- })
876
- }
877
- }
878
-
879
- function scheduleConfigsToBeCalled(configs, data, node, isNew, cached) {
880
- // schedule configs to be called. They are called after `build` finishes
881
- // running
882
- if (isFunction(data.attrs.config)) {
883
- var context = cached.configContext = cached.configContext || {}
884
-
885
- // bind
886
- configs.push(function () {
887
- return data.attrs.config.call(data, node, !isNew, context,
888
- cached)
889
- })
890
- }
891
- }
892
-
893
- function buildUpdatedNode(
894
- cached,
895
- data,
896
- editable,
897
- hasKeys,
898
- namespace,
899
- views,
900
- configs,
901
- controllers
902
- ) {
903
- var node = cached.nodes[0]
904
-
905
- if (hasKeys) {
906
- setAttributes(node, data.tag, data.attrs, cached.attrs, namespace)
907
- }
908
-
909
- cached.children = build(
910
- node,
911
- data.tag,
912
- undefined,
913
- undefined,
914
- data.children,
915
- cached.children,
916
- false,
917
- 0,
918
- data.attrs.contenteditable ? node : editable,
919
- namespace,
920
- configs
921
- )
922
-
923
- cached.nodes.intact = true
924
-
925
- if (controllers.length) {
926
- cached.views = views
927
- cached.controllers = controllers
928
- }
929
-
930
- return node
931
- }
932
-
933
- function handleNonexistentNodes(data, parentElement, index) {
934
- var nodes
935
- if (data.$trusted) {
936
- nodes = injectHTML(parentElement, index, data)
937
- } else {
938
- nodes = [$document.createTextNode(data)]
939
- if (!(parentElement.nodeName in voidElements)) {
940
- insertNode(parentElement, nodes[0], index)
941
- }
942
- }
943
-
944
- var cached
945
-
946
- if (typeof data === "string" ||
947
- typeof data === "number" ||
948
- typeof data === "boolean") {
949
- cached = new data.constructor(data)
950
- } else {
951
- cached = data
952
- }
953
-
954
- cached.nodes = nodes
955
- return cached
956
- }
957
-
958
- function reattachNodes(
959
- data,
960
- cached,
961
- parentElement,
962
- editable,
963
- index,
964
- parentTag
965
- ) {
966
- var nodes = cached.nodes
967
- if (!editable || editable !== $document.activeElement) {
968
- if (data.$trusted) {
969
- clear(nodes, cached)
970
- nodes = injectHTML(parentElement, index, data)
971
- } else if (parentTag === "textarea") {
972
- // <textarea> uses `value` instead of `nodeValue`.
973
- parentElement.value = data
974
- } else if (editable) {
975
- // contenteditable nodes use `innerHTML` instead of `nodeValue`.
976
- editable.innerHTML = data
977
- } else {
978
- // was a trusted string
979
- if (nodes[0].nodeType === 1 || nodes.length > 1 ||
980
- (nodes[0].nodeValue.trim &&
981
- !nodes[0].nodeValue.trim())) {
982
- clear(cached.nodes, cached)
983
- nodes = [$document.createTextNode(data)]
984
- }
985
-
986
- injectTextNode(parentElement, nodes[0], index, data)
987
- }
988
- }
989
- cached = new data.constructor(data)
990
- cached.nodes = nodes
991
- return cached
992
- }
993
-
994
- function handleTextNode(
995
- cached,
996
- data,
997
- index,
998
- parentElement,
999
- shouldReattach,
1000
- editable,
1001
- parentTag
1002
- ) {
1003
- if (!cached.nodes.length) {
1004
- return handleNonexistentNodes(data, parentElement, index)
1005
- } else if (cached.valueOf() !== data.valueOf() || shouldReattach) {
1006
- return reattachNodes(data, cached, parentElement, editable, index,
1007
- parentTag)
1008
- } else {
1009
- return (cached.nodes.intact = true, cached)
1010
- }
1011
- }
1012
-
1013
- function getSubArrayCount(item) {
1014
- if (item.$trusted) {
1015
- // fix offset of next element if item was a trusted string w/ more
1016
- // than one html element
1017
- // the first clause in the regexp matches elements
1018
- // the second clause (after the pipe) matches text nodes
1019
- var match = item.match(/<[^\/]|\>\s*[^<]/g)
1020
- if (match != null) return match.length
1021
- } else if (isArray(item)) {
1022
- return item.length
1023
- }
1024
- return 1
1025
- }
1026
-
1027
- function buildArray(
1028
- data,
1029
- cached,
1030
- parentElement,
1031
- index,
1032
- parentTag,
1033
- shouldReattach,
1034
- editable,
1035
- namespace,
1036
- configs
1037
- ) {
1038
- data = flatten(data)
1039
- var nodes = []
1040
- var intact = cached.length === data.length
1041
- var subArrayCount = 0
1042
-
1043
- // keys algorithm: sort elements without recreating them if keys are
1044
- // present
1045
- //
1046
- // 1) create a map of all existing keys, and mark all for deletion
1047
- // 2) add new keys to map and mark them for addition
1048
- // 3) if key exists in new list, change action from deletion to a move
1049
- // 4) for each key, handle its corresponding action as marked in
1050
- // previous steps
1051
-
1052
- var existing = {}
1053
- var shouldMaintainIdentities = false
1054
-
1055
- forKeys(cached, function (attrs, i) {
1056
- shouldMaintainIdentities = true
1057
- existing[cached[i].attrs.key] = {action: DELETION, index: i}
1058
- })
1059
-
1060
- buildArrayKeys(data)
1061
- if (shouldMaintainIdentities) {
1062
- cached = diffKeys(data, cached, existing, parentElement)
1063
- }
1064
- // end key algorithm
1065
-
1066
- var cacheCount = 0
1067
- // faster explicitly written
1068
- for (var i = 0, len = data.length; i < len; i++) {
1069
- // diff each item in the array
1070
- var item = build(
1071
- parentElement,
1072
- parentTag,
1073
- cached,
1074
- index,
1075
- data[i],
1076
- cached[cacheCount],
1077
- shouldReattach,
1078
- index + subArrayCount || subArrayCount,
1079
- editable,
1080
- namespace,
1081
- configs)
1082
-
1083
- if (item !== undefined) {
1084
- intact = intact && item.nodes.intact
1085
- subArrayCount += getSubArrayCount(item)
1086
- cached[cacheCount++] = item
1087
- }
1088
- }
1089
-
1090
- if (!intact) diffArray(data, cached, nodes)
1091
- return cached
1092
- }
1093
-
1094
- function makeCache(data, cached, index, parentIndex, parentCache) {
1095
- if (cached != null) {
1096
- if (type.call(cached) === type.call(data)) return cached
1097
-
1098
- if (parentCache && parentCache.nodes) {
1099
- var offset = index - parentIndex
1100
- var end = offset + (isArray(data) ? data : cached.nodes).length
1101
- clear(
1102
- parentCache.nodes.slice(offset, end),
1103
- parentCache.slice(offset, end))
1104
- } else if (cached.nodes) {
1105
- clear(cached.nodes, cached)
1106
- }
1107
- }
1108
-
1109
- cached = new data.constructor()
1110
- // if constructor creates a virtual dom element, use a blank object as
1111
- // the base cached node instead of copying the virtual el (#277)
1112
- if (cached.tag) cached = {}
1113
- cached.nodes = []
1114
- return cached
1115
- }
1116
-
1117
- function constructNode(data, namespace) {
1118
- if (data.attrs.is) {
1119
- if (namespace == null) {
1120
- return $document.createElement(data.tag, data.attrs.is)
1121
- } else {
1122
- return $document.createElementNS(namespace, data.tag,
1123
- data.attrs.is)
1124
- }
1125
- } else if (namespace == null) {
1126
- return $document.createElement(data.tag)
1127
- } else {
1128
- return $document.createElementNS(namespace, data.tag)
1129
- }
1130
- }
1131
-
1132
- function constructAttrs(data, node, namespace, hasKeys) {
1133
- if (hasKeys) {
1134
- return setAttributes(node, data.tag, data.attrs, {}, namespace)
1135
- } else {
1136
- return data.attrs
1137
- }
1138
- }
1139
-
1140
- function constructChildren(
1141
- data,
1142
- node,
1143
- cached,
1144
- editable,
1145
- namespace,
1146
- configs
1147
- ) {
1148
- if (data.children != null && data.children.length > 0) {
1149
- return build(
1150
- node,
1151
- data.tag,
1152
- undefined,
1153
- undefined,
1154
- data.children,
1155
- cached.children,
1156
- true,
1157
- 0,
1158
- data.attrs.contenteditable ? node : editable,
1159
- namespace,
1160
- configs)
1161
- } else {
1162
- return data.children
1163
- }
1164
- }
1165
-
1166
- function reconstructCached(
1167
- data,
1168
- attrs,
1169
- children,
1170
- node,
1171
- namespace,
1172
- views,
1173
- controllers
1174
- ) {
1175
- var cached = {
1176
- tag: data.tag,
1177
- attrs: attrs,
1178
- children: children,
1179
- nodes: [node]
1180
- }
1181
-
1182
- unloadCachedControllers(cached, views, controllers)
1183
-
1184
- if (cached.children && !cached.children.nodes) {
1185
- cached.children.nodes = []
1186
- }
1187
-
1188
- // edge case: setting value on <select> doesn't work before children
1189
- // exist, so set it again after children have been created
1190
- if (data.tag === "select" && "value" in data.attrs) {
1191
- setAttributes(node, data.tag, {value: data.attrs.value}, {},
1192
- namespace)
1193
- }
1194
-
1195
- return cached
1196
- }
1197
-
1198
- function getController(views, view, cachedControllers, controller) {
1199
- var controllerIndex
1200
-
1201
- if (m.redraw.strategy() === "diff" && views) {
1202
- controllerIndex = views.indexOf(view)
1203
- } else {
1204
- controllerIndex = -1
1205
- }
1206
-
1207
- if (controllerIndex > -1) {
1208
- return cachedControllers[controllerIndex]
1209
- } else if (isFunction(controller)) {
1210
- return new controller()
1211
- } else {
1212
- return {}
1213
- }
1214
- }
1215
-
1216
- var unloaders = []
1217
-
1218
- function updateLists(views, controllers, view, controller) {
1219
- if (controller.onunload != null &&
1220
- unloaders.map(function (u) { return u.handler })
1221
- .indexOf(controller.onunload) < 0) {
1222
- unloaders.push({
1223
- controller: controller,
1224
- handler: controller.onunload
1225
- })
1226
- }
1227
-
1228
- views.push(view)
1229
- controllers.push(controller)
1230
- }
1231
-
1232
- var forcing = false
1233
- function checkView(
1234
- data,
1235
- view,
1236
- cached,
1237
- cachedControllers,
1238
- controllers,
1239
- views
1240
- ) {
1241
- var controller = getController(
1242
- cached.views,
1243
- view,
1244
- cachedControllers,
1245
- data.controller)
1246
-
1247
- var key = data && data.attrs && data.attrs.key
1248
-
1249
- if (pendingRequests === 0 ||
1250
- forcing ||
1251
- cachedControllers &&
1252
- cachedControllers.indexOf(controller) > -1) {
1253
- data = data.view(controller)
1254
- } else {
1255
- data = {tag: "placeholder"}
1256
- }
1257
-
1258
- if (data.subtree === "retain") return data
1259
- data.attrs = data.attrs || {}
1260
- data.attrs.key = key
1261
- updateLists(views, controllers, view, controller)
1262
- return data
1263
- }
1264
-
1265
- function markViews(data, cached, views, controllers) {
1266
- var cachedControllers = cached && cached.controllers
1267
-
1268
- while (data.view != null) {
1269
- data = checkView(
1270
- data,
1271
- data.view.$original || data.view,
1272
- cached,
1273
- cachedControllers,
1274
- controllers,
1275
- views)
1276
- }
1277
-
1278
- return data
1279
- }
1280
-
1281
- function buildObject( // eslint-disable-line max-statements
1282
- data,
1283
- cached,
1284
- editable,
1285
- parentElement,
1286
- index,
1287
- shouldReattach,
1288
- namespace,
1289
- configs
1290
- ) {
1291
- var views = []
1292
- var controllers = []
1293
-
1294
- data = markViews(data, cached, views, controllers)
1295
-
1296
- if (data.subtree === "retain") return cached
1297
-
1298
- if (!data.tag && controllers.length) {
1299
- throw new Error("Component template must return a virtual " +
1300
- "element, not an array, string, etc.")
1301
- }
1302
-
1303
- data.attrs = data.attrs || {}
1304
- cached.attrs = cached.attrs || {}
1305
-
1306
- var dataAttrKeys = Object.keys(data.attrs)
1307
- var hasKeys = dataAttrKeys.length > ("key" in data.attrs ? 1 : 0)
1308
-
1309
- maybeRecreateObject(data, cached, dataAttrKeys)
1310
-
1311
- if (!isString(data.tag)) return
1312
-
1313
- var isNew = cached.nodes.length === 0
1314
-
1315
- namespace = getObjectNamespace(data, namespace)
1316
-
1317
- var node
1318
- if (isNew) {
1319
- node = constructNode(data, namespace)
1320
- // set attributes first, then create children
1321
- var attrs = constructAttrs(data, node, namespace, hasKeys)
1322
-
1323
- // add the node to its parent before attaching children to it
1324
- insertNode(parentElement, node, index)
1325
-
1326
- var children = constructChildren(data, node, cached, editable,
1327
- namespace, configs)
1328
-
1329
- cached = reconstructCached(
1330
- data,
1331
- attrs,
1332
- children,
1333
- node,
1334
- namespace,
1335
- views,
1336
- controllers)
1337
- } else {
1338
- node = buildUpdatedNode(
1339
- cached,
1340
- data,
1341
- editable,
1342
- hasKeys,
1343
- namespace,
1344
- views,
1345
- configs,
1346
- controllers)
1347
- }
1348
-
1349
- if (!isNew && shouldReattach === true && node != null) {
1350
- insertNode(parentElement, node, index)
1351
- }
1352
-
1353
- // The configs are called after `build` finishes running
1354
- scheduleConfigsToBeCalled(configs, data, node, isNew, cached)
1355
-
1356
- return cached
1357
- }
1358
-
1359
- function build(
1360
- parentElement,
1361
- parentTag,
1362
- parentCache,
1363
- parentIndex,
1364
- data,
1365
- cached,
1366
- shouldReattach,
1367
- index,
1368
- editable,
1369
- namespace,
1370
- configs
1371
- ) {
1372
- /*
1373
- * `build` is a recursive function that manages creation/diffing/removal
1374
- * of DOM elements based on comparison between `data` and `cached` the
1375
- * diff algorithm can be summarized as this:
1376
- *
1377
- * 1 - compare `data` and `cached`
1378
- * 2 - if they are different, copy `data` to `cached` and update the DOM
1379
- * based on what the difference is
1380
- * 3 - recursively apply this algorithm for every array and for the
1381
- * children of every virtual element
1382
- *
1383
- * The `cached` data structure is essentially the same as the previous
1384
- * redraw's `data` data structure, with a few additions:
1385
- * - `cached` always has a property called `nodes`, which is a list of
1386
- * DOM elements that correspond to the data represented by the
1387
- * respective virtual element
1388
- * - in order to support attaching `nodes` as a property of `cached`,
1389
- * `cached` is *always* a non-primitive object, i.e. if the data was
1390
- * a string, then cached is a String instance. If data was `null` or
1391
- * `undefined`, cached is `new String("")`
1392
- * - `cached also has a `configContext` property, which is the state
1393
- * storage object exposed by config(element, isInitialized, context)
1394
- * - when `cached` is an Object, it represents a virtual element; when
1395
- * it's an Array, it represents a list of elements; when it's a
1396
- * String, Number or Boolean, it represents a text node
1397
- *
1398
- * `parentElement` is a DOM element used for W3C DOM API calls
1399
- * `parentTag` is only used for handling a corner case for textarea
1400
- * values
1401
- * `parentCache` is used to remove nodes in some multi-node cases
1402
- * `parentIndex` and `index` are used to figure out the offset of nodes.
1403
- * They're artifacts from before arrays started being flattened and are
1404
- * likely refactorable
1405
- * `data` and `cached` are, respectively, the new and old nodes being
1406
- * diffed
1407
- * `shouldReattach` is a flag indicating whether a parent node was
1408
- * recreated (if so, and if this node is reused, then this node must
1409
- * reattach itself to the new parent)
1410
- * `editable` is a flag that indicates whether an ancestor is
1411
- * contenteditable
1412
- * `namespace` indicates the closest HTML namespace as it cascades down
1413
- * from an ancestor
1414
- * `configs` is a list of config functions to run after the topmost
1415
- * `build` call finishes running
1416
- *
1417
- * there's logic that relies on the assumption that null and undefined
1418
- * data are equivalent to empty strings
1419
- * - this prevents lifecycle surprises from procedural helpers that mix
1420
- * implicit and explicit return statements (e.g.
1421
- * function foo() {if (cond) return m("div")}
1422
- * - it simplifies diffing code
1423
- */
1424
- data = dataToString(data)
1425
- if (data.subtree === "retain") return cached
1426
- cached = makeCache(data, cached, index, parentIndex, parentCache)
1427
-
1428
- if (isArray(data)) {
1429
- return buildArray(
1430
- data,
1431
- cached,
1432
- parentElement,
1433
- index,
1434
- parentTag,
1435
- shouldReattach,
1436
- editable,
1437
- namespace,
1438
- configs)
1439
- } else if (data != null && isObject(data)) {
1440
- return buildObject(
1441
- data,
1442
- cached,
1443
- editable,
1444
- parentElement,
1445
- index,
1446
- shouldReattach,
1447
- namespace,
1448
- configs)
1449
- } else if (!isFunction(data)) {
1450
- return handleTextNode(
1451
- cached,
1452
- data,
1453
- index,
1454
- parentElement,
1455
- shouldReattach,
1456
- editable,
1457
- parentTag)
1458
- } else {
1459
- return cached
1460
- }
1461
- }
1462
-
1463
- function sortChanges(a, b) {
1464
- return a.action - b.action || a.index - b.index
1465
- }
1466
-
1467
- function copyStyleAttrs(node, dataAttr, cachedAttr) {
1468
- for (var rule in dataAttr) {
1469
- if (hasOwn.call(dataAttr, rule)) {
1470
- if (cachedAttr == null || cachedAttr[rule] !== dataAttr[rule]) {
1471
- node.style[rule] = dataAttr[rule]
1472
- }
1473
- }
1474
- }
1475
-
1476
- for (rule in cachedAttr) {
1477
- if (hasOwn.call(cachedAttr, rule)) {
1478
- if (!hasOwn.call(dataAttr, rule)) node.style[rule] = ""
1479
- }
1480
- }
1481
- }
1482
-
1483
- var shouldUseSetAttribute = {
1484
- list: 1,
1485
- style: 1,
1486
- form: 1,
1487
- type: 1,
1488
- width: 1,
1489
- height: 1
1490
- }
1491
-
1492
- function setSingleAttr(
1493
- node,
1494
- attrName,
1495
- dataAttr,
1496
- cachedAttr,
1497
- tag,
1498
- namespace
1499
- ) {
1500
- if (attrName === "config" || attrName === "key") {
1501
- // `config` isn't a real attribute, so ignore it
1502
- return true
1503
- } else if (isFunction(dataAttr) && attrName.slice(0, 2) === "on") {
1504
- // hook event handlers to the auto-redrawing system
1505
- node[attrName] = autoredraw(dataAttr, node)
1506
- } else if (attrName === "style" && dataAttr != null &&
1507
- isObject(dataAttr)) {
1508
- // handle `style: {...}`
1509
- copyStyleAttrs(node, dataAttr, cachedAttr)
1510
- } else if (namespace != null) {
1511
- // handle SVG
1512
- if (attrName === "href") {
1513
- node.setAttributeNS("http://www.w3.org/1999/xlink",
1514
- "href", dataAttr)
1515
- } else {
1516
- node.setAttribute(
1517
- attrName === "className" ? "class" : attrName,
1518
- dataAttr)
1519
- }
1520
- } else if (attrName in node && !shouldUseSetAttribute[attrName]) {
1521
- // handle cases that are properties (but ignore cases where we
1522
- // should use setAttribute instead)
1523
- //
1524
- // - list and form are typically used as strings, but are DOM
1525
- // element references in js
1526
- //
1527
- // - when using CSS selectors (e.g. `m("[style='']")`), style is
1528
- // used as a string, but it's an object in js
1529
- //
1530
- // #348 don't set the value if not needed - otherwise, cursor
1531
- // placement breaks in Chrome
1532
- try {
1533
- if (tag !== "input" || node[attrName] !== dataAttr) {
1534
- node[attrName] = dataAttr
1535
- }
1536
- } catch (e) {
1537
- node.setAttribute(attrName, dataAttr)
1538
- }
1539
- }
1540
- else node.setAttribute(attrName, dataAttr)
1541
- }
1542
-
1543
- function trySetAttr(
1544
- node,
1545
- attrName,
1546
- dataAttr,
1547
- cachedAttr,
1548
- cachedAttrs,
1549
- tag,
1550
- namespace
1551
- ) {
1552
- if (!(attrName in cachedAttrs) || (cachedAttr !== dataAttr) || ($document.activeElement === node)) {
1553
- cachedAttrs[attrName] = dataAttr
1554
- try {
1555
- return setSingleAttr(
1556
- node,
1557
- attrName,
1558
- dataAttr,
1559
- cachedAttr,
1560
- tag,
1561
- namespace)
1562
- } catch (e) {
1563
- // swallow IE's invalid argument errors to mimic HTML's
1564
- // fallback-to-doing-nothing-on-invalid-attributes behavior
1565
- if (e.message.indexOf("Invalid argument") < 0) throw e
1566
- }
1567
- } else if (attrName === "value" && tag === "input" &&
1568
- node.value !== dataAttr) {
1569
- // #348 dataAttr may not be a string, so use loose comparison
1570
- node.value = dataAttr
1571
- }
1572
- }
1573
-
1574
- function setAttributes(node, tag, dataAttrs, cachedAttrs, namespace) {
1575
- for (var attrName in dataAttrs) {
1576
- if (hasOwn.call(dataAttrs, attrName)) {
1577
- if (trySetAttr(
1578
- node,
1579
- attrName,
1580
- dataAttrs[attrName],
1581
- cachedAttrs[attrName],
1582
- cachedAttrs,
1583
- tag,
1584
- namespace)) {
1585
- continue
1586
- }
1587
- }
1588
- }
1589
- return cachedAttrs
1590
- }
1591
-
1592
- function clear(nodes, cached) {
1593
- for (var i = nodes.length - 1; i > -1; i--) {
1594
- if (nodes[i] && nodes[i].parentNode) {
1595
- try {
1596
- nodes[i].parentNode.removeChild(nodes[i])
1597
- } catch (e) {
1598
- /* eslint-disable max-len */
1599
- // ignore if this fails due to order of events (see
1600
- // http://stackoverflow.com/questions/21926083/failed-to-execute-removechild-on-node)
1601
- /* eslint-enable max-len */
1602
- }
1603
- cached = [].concat(cached)
1604
- if (cached[i]) unload(cached[i])
1605
- }
1606
- }
1607
- // release memory if nodes is an array. This check should fail if nodes
1608
- // is a NodeList (see loop above)
1609
- if (nodes.length) {
1610
- nodes.length = 0
1611
- }
1612
- }
1613
-
1614
- function unload(cached) {
1615
- if (cached.configContext && isFunction(cached.configContext.onunload)) {
1616
- cached.configContext.onunload()
1617
- cached.configContext.onunload = null
1618
- }
1619
- if (cached.controllers) {
1620
- forEach(cached.controllers, function (controller) {
1621
- if (isFunction(controller.onunload)) {
1622
- controller.onunload({preventDefault: noop})
1623
- }
1624
- })
1625
- }
1626
- if (cached.children) {
1627
- if (isArray(cached.children)) forEach(cached.children, unload)
1628
- else if (cached.children.tag) unload(cached.children)
1629
- }
1630
- }
1631
-
1632
- function appendTextFragment(parentElement, data) {
1633
- try {
1634
- parentElement.appendChild(
1635
- $document.createRange().createContextualFragment(data))
1636
- } catch (e) {
1637
- parentElement.insertAdjacentHTML("beforeend", data)
1638
- replaceScriptNodes(parentElement)
1639
- }
1640
- }
1641
-
1642
- // Replace script tags inside given DOM element with executable ones.
1643
- // Will also check children recursively and replace any found script
1644
- // tags in same manner.
1645
- function replaceScriptNodes(node) {
1646
- if (node.tagName === "SCRIPT") {
1647
- node.parentNode.replaceChild(buildExecutableNode(node), node)
1648
- } else {
1649
- var children = node.childNodes
1650
- if (children && children.length) {
1651
- for (var i = 0; i < children.length; i++) {
1652
- replaceScriptNodes(children[i])
1653
- }
1654
- }
1655
- }
1656
-
1657
- return node
1658
- }
1659
-
1660
- // Replace script element with one whose contents are executable.
1661
- function buildExecutableNode(node){
1662
- var scriptEl = document.createElement("script")
1663
- var attrs = node.attributes
1664
-
1665
- for (var i = 0; i < attrs.length; i++) {
1666
- scriptEl.setAttribute(attrs[i].name, attrs[i].value)
1667
- }
1668
-
1669
- scriptEl.text = node.innerHTML
1670
- return scriptEl
1671
- }
1672
-
1673
- function injectHTML(parentElement, index, data) {
1674
- var nextSibling = parentElement.childNodes[index]
1675
- if (nextSibling) {
1676
- var isElement = nextSibling.nodeType !== 1
1677
- var placeholder = $document.createElement("span")
1678
- if (isElement) {
1679
- parentElement.insertBefore(placeholder, nextSibling || null)
1680
- placeholder.insertAdjacentHTML("beforebegin", data)
1681
- parentElement.removeChild(placeholder)
1682
- } else {
1683
- nextSibling.insertAdjacentHTML("beforebegin", data)
1684
- }
1685
- } else {
1686
- appendTextFragment(parentElement, data)
1687
- }
1688
-
1689
- var nodes = []
1690
-
1691
- while (parentElement.childNodes[index] !== nextSibling) {
1692
- nodes.push(parentElement.childNodes[index])
1693
- index++
1694
- }
1695
-
1696
- return nodes
1697
- }
1698
-
1699
- function autoredraw(callback, object) {
1700
- return function (e) {
1701
- e = e || event
1702
- m.redraw.strategy("diff")
1703
- m.startComputation()
1704
- try {
1705
- return callback.call(object, e)
1706
- } finally {
1707
- endFirstComputation()
1708
- }
1709
- }
1710
- }
1711
-
1712
- var html
1713
- var documentNode = {
1714
- appendChild: function (node) {
1715
- if (html === undefined) html = $document.createElement("html")
1716
- if ($document.documentElement &&
1717
- $document.documentElement !== node) {
1718
- $document.replaceChild(node, $document.documentElement)
1719
- } else {
1720
- $document.appendChild(node)
1721
- }
1722
-
1723
- this.childNodes = $document.childNodes
1724
- },
1725
-
1726
- insertBefore: function (node) {
1727
- this.appendChild(node)
1728
- },
1729
-
1730
- childNodes: []
1731
- }
1732
-
1733
- var nodeCache = []
1734
- var cellCache = {}
1735
-
1736
- m.render = function (root, cell, forceRecreation) {
1737
- if (!root) {
1738
- throw new Error("Ensure the DOM element being passed to " +
1739
- "m.route/m.mount/m.render is not undefined.")
1740
- }
1741
- var configs = []
1742
- var id = getCellCacheKey(root)
1743
- var isDocumentRoot = root === $document
1744
- var node
1745
-
1746
- if (isDocumentRoot || root === $document.documentElement) {
1747
- node = documentNode
1748
- } else {
1749
- node = root
1750
- }
1751
-
1752
- if (isDocumentRoot && cell.tag !== "html") {
1753
- cell = {tag: "html", attrs: {}, children: cell}
1754
- }
1755
-
1756
- if (cellCache[id] === undefined) clear(node.childNodes)
1757
- if (forceRecreation === true) reset(root)
1758
-
1759
- cellCache[id] = build(
1760
- node,
1761
- null,
1762
- undefined,
1763
- undefined,
1764
- cell,
1765
- cellCache[id],
1766
- false,
1767
- 0,
1768
- null,
1769
- undefined,
1770
- configs)
1771
-
1772
- forEach(configs, function (config) { config() })
1773
- }
1774
-
1775
- function getCellCacheKey(element) {
1776
- var index = nodeCache.indexOf(element)
1777
- return index < 0 ? nodeCache.push(element) - 1 : index
1778
- }
1779
-
1780
- m.trust = function (value) {
1781
- value = new String(value) // eslint-disable-line no-new-wrappers
1782
- value.$trusted = true
1783
- return value
1784
- }
1785
-
1786
- function gettersetter(store) {
1787
- function prop() {
1788
- if (arguments.length) store = arguments[0]
1789
- return store
1790
- }
1791
-
1792
- prop.toJSON = function () {
1793
- return store
1794
- }
1795
-
1796
- return prop
1797
- }
1798
-
1799
- m.prop = function (store) {
1800
- if ((store != null && (isObject(store) || isFunction(store)) || ((typeof Promise !== "undefined") && (store instanceof Promise))) &&
1801
- isFunction(store.then)) {
1802
- return propify(store)
1803
- }
1804
-
1805
- return gettersetter(store)
1806
- }
1807
-
1808
- var roots = []
1809
- var components = []
1810
- var controllers = []
1811
- var lastRedrawId = null
1812
- var lastRedrawCallTime = 0
1813
- var computePreRedrawHook = null
1814
- var computePostRedrawHook = null
1815
- var topComponent
1816
- var FRAME_BUDGET = 16 // 60 frames per second = 1 call per 16 ms
1817
-
1818
- function parameterize(component, args) {
1819
- function controller() {
1820
- /* eslint-disable no-invalid-this */
1821
- return (component.controller || noop).apply(this, args) || this
1822
- /* eslint-enable no-invalid-this */
1823
- }
1824
-
1825
- if (component.controller) {
1826
- controller.prototype = component.controller.prototype
1827
- }
1828
-
1829
- function view(ctrl) {
1830
- var currentArgs = [ctrl].concat(args)
1831
- for (var i = 1; i < arguments.length; i++) {
1832
- currentArgs.push(arguments[i])
1833
- }
1834
-
1835
- return component.view.apply(component, currentArgs)
1836
- }
1837
-
1838
- view.$original = component.view
1839
- var output = {controller: controller, view: view}
1840
- if (args[0] && args[0].key != null) output.attrs = {key: args[0].key}
1841
- return output
1842
- }
1843
-
1844
- m.component = function (component) {
1845
- var args = new Array(arguments.length - 1)
1846
-
1847
- for (var i = 1; i < arguments.length; i++) {
1848
- args[i - 1] = arguments[i]
1849
- }
1850
-
1851
- return parameterize(component, args)
1852
- }
1853
-
1854
- function checkPrevented(component, root, index, isPrevented) {
1855
- if (!isPrevented) {
1856
- m.redraw.strategy("all")
1857
- m.startComputation()
1858
- roots[index] = root
1859
- var currentComponent
1860
-
1861
- if (component) {
1862
- currentComponent = topComponent = component
1863
- } else {
1864
- currentComponent = topComponent = component = {controller: noop}
1865
- }
1866
-
1867
- var controller = new (component.controller || noop)()
1868
-
1869
- // controllers may call m.mount recursively (via m.route redirects,
1870
- // for example)
1871
- // this conditional ensures only the last recursive m.mount call is
1872
- // applied
1873
- if (currentComponent === topComponent) {
1874
- controllers[index] = controller
1875
- components[index] = component
1876
- }
1877
- endFirstComputation()
1878
- if (component === null) {
1879
- removeRootElement(root, index)
1880
- }
1881
- return controllers[index]
1882
- } else if (component == null) {
1883
- removeRootElement(root, index)
1884
- }
1885
- }
1886
-
1887
- m.mount = m.module = function (root, component) {
1888
- if (!root) {
1889
- throw new Error("Please ensure the DOM element exists before " +
1890
- "rendering a template into it.")
1891
- }
1892
-
1893
- var index = roots.indexOf(root)
1894
- if (index < 0) index = roots.length
1895
-
1896
- var isPrevented = false
1897
- var event = {
1898
- preventDefault: function () {
1899
- isPrevented = true
1900
- computePreRedrawHook = computePostRedrawHook = null
1901
- }
1902
- }
1903
-
1904
- forEach(unloaders, function (unloader) {
1905
- unloader.handler.call(unloader.controller, event)
1906
- unloader.controller.onunload = null
1907
- })
1908
-
1909
- if (isPrevented) {
1910
- forEach(unloaders, function (unloader) {
1911
- unloader.controller.onunload = unloader.handler
1912
- })
1913
- } else {
1914
- unloaders = []
1915
- }
1916
-
1917
- if (controllers[index] && isFunction(controllers[index].onunload)) {
1918
- controllers[index].onunload(event)
1919
- }
1920
-
1921
- return checkPrevented(component, root, index, isPrevented)
1922
- }
1923
-
1924
- function removeRootElement(root, index) {
1925
- roots.splice(index, 1)
1926
- controllers.splice(index, 1)
1927
- components.splice(index, 1)
1928
- reset(root)
1929
- nodeCache.splice(getCellCacheKey(root), 1)
1930
- }
1931
-
1932
- var redrawing = false
1933
- m.redraw = function (force) {
1934
- if (redrawing) return
1935
- redrawing = true
1936
- if (force) forcing = true
1937
-
1938
- try {
1939
- // lastRedrawId is a positive number if a second redraw is requested
1940
- // before the next animation frame
1941
- // lastRedrawId is null if it's the first redraw and not an event
1942
- // handler
1943
- if (lastRedrawId && !force) {
1944
- // when setTimeout: only reschedule redraw if time between now
1945
- // and previous redraw is bigger than a frame, otherwise keep
1946
- // currently scheduled timeout
1947
- // when rAF: always reschedule redraw
1948
- if ($requestAnimationFrame === global.requestAnimationFrame ||
1949
- new Date() - lastRedrawCallTime > FRAME_BUDGET) {
1950
- if (lastRedrawId > 0) $cancelAnimationFrame(lastRedrawId)
1951
- lastRedrawId = $requestAnimationFrame(redraw, FRAME_BUDGET)
1952
- }
1953
- } else {
1954
- redraw()
1955
- lastRedrawId = $requestAnimationFrame(function () {
1956
- lastRedrawId = null
1957
- }, FRAME_BUDGET)
1958
- }
1959
- } finally {
1960
- redrawing = forcing = false
1961
- }
1962
- }
1963
-
1964
- m.redraw.strategy = m.prop()
1965
- function redraw() {
1966
- if (computePreRedrawHook) {
1967
- computePreRedrawHook()
1968
- computePreRedrawHook = null
1969
- }
1970
- forEach(roots, function (root, i) {
1971
- var component = components[i]
1972
- if (controllers[i]) {
1973
- var args = [controllers[i]]
1974
- m.render(root,
1975
- component.view ? component.view(controllers[i], args) : "")
1976
- }
1977
- })
1978
- // after rendering within a routed context, we need to scroll back to
1979
- // the top, and fetch the document title for history.pushState
1980
- if (computePostRedrawHook) {
1981
- computePostRedrawHook()
1982
- computePostRedrawHook = null
1983
- }
1984
- lastRedrawId = null
1985
- lastRedrawCallTime = new Date()
1986
- m.redraw.strategy("diff")
1987
- }
1988
-
1989
- function endFirstComputation() {
1990
- if (m.redraw.strategy() === "none") {
1991
- pendingRequests--
1992
- m.redraw.strategy("diff")
1993
- } else {
1994
- m.endComputation()
1995
- }
1996
- }
1997
-
1998
- m.withAttr = function (prop, withAttrCallback, callbackThis) {
1999
- return function (e) {
2000
- e = e || window.event
2001
- /* eslint-disable no-invalid-this */
2002
- var currentTarget = e.currentTarget || this
2003
- var _this = callbackThis || this
2004
- /* eslint-enable no-invalid-this */
2005
- var target = prop in currentTarget ?
2006
- currentTarget[prop] :
2007
- currentTarget.getAttribute(prop)
2008
- withAttrCallback.call(_this, target)
2009
- }
2010
- }
2011
-
2012
- // routing
2013
- var modes = {pathname: "", hash: "#", search: "?"}
2014
- var redirect = noop
2015
- var isDefaultRoute = false
2016
- var routeParams, currentRoute
2017
-
2018
- m.route = function (root, arg1, arg2, vdom) { // eslint-disable-line
2019
- // m.route()
2020
- if (arguments.length === 0) return currentRoute
2021
- // m.route(el, defaultRoute, routes)
2022
- if (arguments.length === 3 && isString(arg1)) {
2023
- redirect = function (source) {
2024
- var path = currentRoute = normalizeRoute(source)
2025
- if (!routeByValue(root, arg2, path)) {
2026
- if (isDefaultRoute) {
2027
- throw new Error("Ensure the default route matches " +
2028
- "one of the routes defined in m.route")
2029
- }
2030
-
2031
- isDefaultRoute = true
2032
- m.route(arg1, true)
2033
- isDefaultRoute = false
2034
- }
2035
- }
2036
-
2037
- var listener = m.route.mode === "hash" ?
2038
- "onhashchange" :
2039
- "onpopstate"
2040
-
2041
- global[listener] = function () {
2042
- var path = $location[m.route.mode]
2043
- if (m.route.mode === "pathname") path += $location.search
2044
- if (currentRoute !== normalizeRoute(path)) redirect(path)
2045
- }
2046
-
2047
- computePreRedrawHook = setScroll
2048
- global[listener]()
2049
-
2050
- return
2051
- }
2052
-
2053
- // config: m.route
2054
- if (root.addEventListener || root.attachEvent) {
2055
- var base = m.route.mode !== "pathname" ? $location.pathname : ""
2056
- root.href = base + modes[m.route.mode] + vdom.attrs.href
2057
- if (root.addEventListener) {
2058
- root.removeEventListener("click", routeUnobtrusive)
2059
- root.addEventListener("click", routeUnobtrusive)
2060
- } else {
2061
- root.detachEvent("onclick", routeUnobtrusive)
2062
- root.attachEvent("onclick", routeUnobtrusive)
2063
- }
2064
-
2065
- return
2066
- }
2067
- // m.route(route, params, shouldReplaceHistoryEntry)
2068
- if (isString(root)) {
2069
- var oldRoute = currentRoute
2070
- currentRoute = root
2071
-
2072
- var args = arg1 || {}
2073
- var queryIndex = currentRoute.indexOf("?")
2074
- var params
2075
-
2076
- if (queryIndex > -1) {
2077
- params = parseQueryString(currentRoute.slice(queryIndex + 1))
2078
- } else {
2079
- params = {}
2080
- }
2081
-
2082
- for (var i in args) {
2083
- if (hasOwn.call(args, i)) {
2084
- params[i] = args[i]
2085
- }
2086
- }
2087
-
2088
- var querystring = buildQueryString(params)
2089
- var currentPath
2090
-
2091
- if (queryIndex > -1) {
2092
- currentPath = currentRoute.slice(0, queryIndex)
2093
- } else {
2094
- currentPath = currentRoute
2095
- }
2096
-
2097
- if (querystring) {
2098
- currentRoute = currentPath +
2099
- (currentPath.indexOf("?") === -1 ? "?" : "&") +
2100
- querystring
2101
- }
2102
-
2103
- var replaceHistory =
2104
- (arguments.length === 3 ? arg2 : arg1) === true ||
2105
- oldRoute === root
2106
-
2107
- if (global.history.pushState) {
2108
- var method = replaceHistory ? "replaceState" : "pushState"
2109
- computePreRedrawHook = setScroll
2110
- computePostRedrawHook = function () {
2111
- try {
2112
- global.history[method](null, $document.title,
2113
- modes[m.route.mode] + currentRoute)
2114
- } catch (err) {
2115
- // In the event of a pushState or replaceState failure,
2116
- // fallback to a standard redirect. This is specifically
2117
- // to address a Safari security error when attempting to
2118
- // call pushState more than 100 times.
2119
- $location[m.route.mode] = currentRoute
2120
- }
2121
- }
2122
- redirect(modes[m.route.mode] + currentRoute)
2123
- } else {
2124
- $location[m.route.mode] = currentRoute
2125
- redirect(modes[m.route.mode] + currentRoute)
2126
- }
2127
- }
2128
- }
2129
-
2130
- m.route.param = function (key) {
2131
- if (!routeParams) {
2132
- throw new Error("You must call m.route(element, defaultRoute, " +
2133
- "routes) before calling m.route.param()")
2134
- }
2135
-
2136
- if (!key) {
2137
- return routeParams
2138
- }
2139
-
2140
- return routeParams[key]
2141
- }
2142
-
2143
- m.route.mode = "search"
2144
-
2145
- function normalizeRoute(route) {
2146
- return route.slice(modes[m.route.mode].length)
2147
- }
2148
-
2149
- function routeByValue(root, router, path) {
2150
- routeParams = {}
2151
-
2152
- var queryStart = path.indexOf("?")
2153
- if (queryStart !== -1) {
2154
- routeParams = parseQueryString(
2155
- path.substr(queryStart + 1, path.length))
2156
- path = path.substr(0, queryStart)
2157
- }
2158
-
2159
- // Get all routes and check if there's
2160
- // an exact match for the current path
2161
- var keys = Object.keys(router)
2162
- var index = keys.indexOf(path)
2163
-
2164
- if (index !== -1){
2165
- m.mount(root, router[keys [index]])
2166
- return true
2167
- }
2168
-
2169
- for (var route in router) {
2170
- if (hasOwn.call(router, route)) {
2171
- if (route === path) {
2172
- m.mount(root, router[route])
2173
- return true
2174
- }
2175
-
2176
- var matcher = new RegExp("^" + route
2177
- .replace(/:[^\/]+?\.{3}/g, "(.*?)")
2178
- .replace(/:[^\/]+/g, "([^\\/]+)") + "\/?$")
2179
-
2180
- if (matcher.test(path)) {
2181
- /* eslint-disable no-loop-func */
2182
- path.replace(matcher, function () {
2183
- var keys = route.match(/:[^\/]+/g) || []
2184
- var values = [].slice.call(arguments, 1, -2)
2185
- forEach(keys, function (key, i) {
2186
- routeParams[key.replace(/:|\./g, "")] =
2187
- decodeURIComponent(values[i])
2188
- })
2189
- m.mount(root, router[route])
2190
- })
2191
- /* eslint-enable no-loop-func */
2192
- return true
2193
- }
2194
- }
2195
- }
2196
- }
2197
-
2198
- function routeUnobtrusive(e) {
2199
- e = e || event
2200
- if (e.ctrlKey || e.metaKey || e.shiftKey || e.which === 2) return
2201
-
2202
- if (e.preventDefault) {
2203
- e.preventDefault()
2204
- } else {
2205
- e.returnValue = false
2206
- }
2207
-
2208
- var currentTarget = e.currentTarget || e.srcElement
2209
- var args
2210
-
2211
- if (m.route.mode === "pathname" && currentTarget.search) {
2212
- args = parseQueryString(currentTarget.search.slice(1))
2213
- } else {
2214
- args = {}
2215
- }
2216
-
2217
- while (currentTarget && !/a/i.test(currentTarget.nodeName)) {
2218
- currentTarget = currentTarget.parentNode
2219
- }
2220
-
2221
- // clear pendingRequests because we want an immediate route change
2222
- pendingRequests = 0
2223
- m.route(currentTarget[m.route.mode]
2224
- .slice(modes[m.route.mode].length), args)
2225
- }
2226
-
2227
- function setScroll() {
2228
- if (m.route.mode !== "hash" && $location.hash) {
2229
- $location.hash = $location.hash
2230
- } else {
2231
- global.scrollTo(0, 0)
2232
- }
2233
- }
2234
-
2235
- function buildQueryString(object, prefix) {
2236
- var duplicates = {}
2237
- var str = []
2238
-
2239
- for (var prop in object) {
2240
- if (hasOwn.call(object, prop)) {
2241
- var key = prefix ? prefix + "[" + prop + "]" : prop
2242
- var value = object[prop]
2243
-
2244
- if (value === null) {
2245
- str.push(encodeURIComponent(key))
2246
- } else if (isObject(value)) {
2247
- str.push(buildQueryString(value, key))
2248
- } else if (isArray(value)) {
2249
- var keys = []
2250
- duplicates[key] = duplicates[key] || {}
2251
- /* eslint-disable no-loop-func */
2252
- forEach(value, function (item) {
2253
- /* eslint-enable no-loop-func */
2254
- if (!duplicates[key][item]) {
2255
- duplicates[key][item] = true
2256
- keys.push(encodeURIComponent(key) + "=" +
2257
- encodeURIComponent(item))
2258
- }
2259
- })
2260
- str.push(keys.join("&"))
2261
- } else if (value !== undefined) {
2262
- str.push(encodeURIComponent(key) + "=" +
2263
- encodeURIComponent(value))
2264
- }
2265
- }
2266
- }
2267
-
2268
- return str.join("&")
2269
- }
2270
-
2271
- function parseQueryString(str) {
2272
- if (str === "" || str == null) return {}
2273
- if (str.charAt(0) === "?") str = str.slice(1)
2274
-
2275
- var pairs = str.split("&")
2276
- var params = {}
2277
-
2278
- forEach(pairs, function (string) {
2279
- var pair = string.split("=")
2280
- var key = decodeURIComponent(pair[0])
2281
- var value = pair.length === 2 ? decodeURIComponent(pair[1]) : null
2282
- if (params[key] != null) {
2283
- if (!isArray(params[key])) params[key] = [params[key]]
2284
- params[key].push(value)
2285
- }
2286
- else params[key] = value
2287
- })
2288
-
2289
- return params
2290
- }
2291
-
2292
- m.route.buildQueryString = buildQueryString
2293
- m.route.parseQueryString = parseQueryString
2294
-
2295
- function reset(root) {
2296
- var cacheKey = getCellCacheKey(root)
2297
- clear(root.childNodes, cellCache[cacheKey])
2298
- cellCache[cacheKey] = undefined
2299
- }
2300
-
2301
- m.deferred = function () {
2302
- var deferred = new Deferred()
2303
- deferred.promise = propify(deferred.promise)
2304
- return deferred
2305
- }
2306
-
2307
- function propify(promise, initialValue) {
2308
- var prop = m.prop(initialValue)
2309
- promise.then(prop)
2310
- prop.then = function (resolve, reject) {
2311
- return propify(promise.then(resolve, reject), initialValue)
2312
- }
2313
-
2314
- prop.catch = prop.then.bind(null, null)
2315
- return prop
2316
- }
2317
- // Promiz.mithril.js | Zolmeister | MIT
2318
- // a modified version of Promiz.js, which does not conform to Promises/A+
2319
- // for two reasons:
2320
- //
2321
- // 1) `then` callbacks are called synchronously (because setTimeout is too
2322
- // slow, and the setImmediate polyfill is too big
2323
- //
2324
- // 2) throwing subclasses of Error cause the error to be bubbled up instead
2325
- // of triggering rejection (because the spec does not account for the
2326
- // important use case of default browser error handling, i.e. message w/
2327
- // line number)
2328
-
2329
- var RESOLVING = 1
2330
- var REJECTING = 2
2331
- var RESOLVED = 3
2332
- var REJECTED = 4
2333
-
2334
- function Deferred(onSuccess, onFailure) {
2335
- var self = this
2336
- var state = 0
2337
- var promiseValue = 0
2338
- var next = []
2339
-
2340
- self.promise = {}
2341
-
2342
- self.resolve = function (value) {
2343
- if (!state) {
2344
- promiseValue = value
2345
- state = RESOLVING
2346
-
2347
- fire()
2348
- }
2349
-
2350
- return self
2351
- }
2352
-
2353
- self.reject = function (value) {
2354
- if (!state) {
2355
- promiseValue = value
2356
- state = REJECTING
2357
-
2358
- fire()
2359
- }
2360
-
2361
- return self
2362
- }
2363
-
2364
- self.promise.then = function (onSuccess, onFailure) {
2365
- var deferred = new Deferred(onSuccess, onFailure)
2366
-
2367
- if (state === RESOLVED) {
2368
- deferred.resolve(promiseValue)
2369
- } else if (state === REJECTED) {
2370
- deferred.reject(promiseValue)
2371
- } else {
2372
- next.push(deferred)
2373
- }
2374
-
2375
- return deferred.promise
2376
- }
2377
-
2378
- function finish(type) {
2379
- state = type || REJECTED
2380
- next.map(function (deferred) {
2381
- if (state === RESOLVED) {
2382
- deferred.resolve(promiseValue)
2383
- } else {
2384
- deferred.reject(promiseValue)
2385
- }
2386
- })
2387
- }
2388
-
2389
- function thennable(then, success, failure, notThennable) {
2390
- if (((promiseValue != null && isObject(promiseValue)) ||
2391
- isFunction(promiseValue)) && isFunction(then)) {
2392
- try {
2393
- // count protects against abuse calls from spec checker
2394
- var count = 0
2395
- then.call(promiseValue, function (value) {
2396
- if (count++) return
2397
- promiseValue = value
2398
- success()
2399
- }, function (value) {
2400
- if (count++) return
2401
- promiseValue = value
2402
- failure()
2403
- })
2404
- } catch (e) {
2405
- m.deferred.onerror(e)
2406
- promiseValue = e
2407
- failure()
2408
- }
2409
- } else {
2410
- notThennable()
2411
- }
2412
- }
2413
-
2414
- function fire() {
2415
- // check if it's a thenable
2416
- var then
2417
- try {
2418
- then = promiseValue && promiseValue.then
2419
- } catch (e) {
2420
- m.deferred.onerror(e)
2421
- promiseValue = e
2422
- state = REJECTING
2423
- return fire()
2424
- }
2425
-
2426
- if (state === REJECTING) {
2427
- m.deferred.onerror(promiseValue)
2428
- }
2429
-
2430
- thennable(then, function () {
2431
- state = RESOLVING
2432
- fire()
2433
- }, function () {
2434
- state = REJECTING
2435
- fire()
2436
- }, function () {
2437
- try {
2438
- if (state === RESOLVING && isFunction(onSuccess)) {
2439
- promiseValue = onSuccess(promiseValue)
2440
- } else if (state === REJECTING && isFunction(onFailure)) {
2441
- promiseValue = onFailure(promiseValue)
2442
- state = RESOLVING
2443
- }
2444
- } catch (e) {
2445
- m.deferred.onerror(e)
2446
- promiseValue = e
2447
- return finish()
2448
- }
2449
-
2450
- if (promiseValue === self) {
2451
- promiseValue = TypeError()
2452
- finish()
2453
- } else {
2454
- thennable(then, function () {
2455
- finish(RESOLVED)
2456
- }, finish, function () {
2457
- finish(state === RESOLVING && RESOLVED)
2458
- })
2459
- }
2460
- })
2461
- }
2462
- }
2463
-
2464
- m.deferred.onerror = function (e) {
2465
- if (type.call(e) === "[object Error]" &&
2466
- !/ Error/.test(e.constructor.toString())) {
2467
- pendingRequests = 0
2468
- throw e
2469
- }
2470
- }
2471
-
2472
- m.sync = function (args) {
2473
- var deferred = m.deferred()
2474
- var outstanding = args.length
2475
- var results = []
2476
- var method = "resolve"
2477
-
2478
- function synchronizer(pos, resolved) {
2479
- return function (value) {
2480
- results[pos] = value
2481
- if (!resolved) method = "reject"
2482
- if (--outstanding === 0) {
2483
- deferred.promise(results)
2484
- deferred[method](results)
2485
- }
2486
- return value
2487
- }
2488
- }
2489
-
2490
- if (args.length > 0) {
2491
- forEach(args, function (arg, i) {
2492
- arg.then(synchronizer(i, true), synchronizer(i, false))
2493
- })
2494
- } else {
2495
- deferred.resolve([])
2496
- }
2497
-
2498
- return deferred.promise
2499
- }
2500
-
2501
- function identity(value) { return value }
2502
-
2503
- function handleJsonp(options) {
2504
- var callbackKey = options.callbackName || "mithril_callback_" +
2505
- new Date().getTime() + "_" +
2506
- (Math.round(Math.random() * 1e16)).toString(36)
2507
-
2508
- var script = $document.createElement("script")
2509
-
2510
- global[callbackKey] = function (resp) {
2511
- script.parentNode.removeChild(script)
2512
- options.onload({
2513
- type: "load",
2514
- target: {
2515
- responseText: resp
2516
- }
2517
- })
2518
- global[callbackKey] = undefined
2519
- }
2520
-
2521
- script.onerror = function () {
2522
- script.parentNode.removeChild(script)
2523
-
2524
- options.onerror({
2525
- type: "error",
2526
- target: {
2527
- status: 500,
2528
- responseText: JSON.stringify({
2529
- error: "Error making jsonp request"
2530
- })
2531
- }
2532
- })
2533
- global[callbackKey] = undefined
2534
-
2535
- return false
2536
- }
2537
-
2538
- script.onload = function () {
2539
- return false
2540
- }
2541
-
2542
- script.src = options.url +
2543
- (options.url.indexOf("?") > 0 ? "&" : "?") +
2544
- (options.callbackKey ? options.callbackKey : "callback") +
2545
- "=" + callbackKey +
2546
- "&" + buildQueryString(options.data || {})
2547
-
2548
- $document.body.appendChild(script)
2549
- }
2550
-
2551
- function createXhr(options) {
2552
- var xhr = new global.XMLHttpRequest()
2553
- xhr.open(options.method, options.url, true, options.user,
2554
- options.password)
2555
-
2556
- xhr.onreadystatechange = function () {
2557
- if (xhr.readyState === 4) {
2558
- if (xhr.status >= 200 && xhr.status < 300) {
2559
- options.onload({type: "load", target: xhr})
2560
- } else {
2561
- options.onerror({type: "error", target: xhr})
2562
- }
2563
- }
2564
- }
2565
-
2566
- if (options.serialize === JSON.stringify &&
2567
- options.data &&
2568
- options.method !== "GET") {
2569
- xhr.setRequestHeader("Content-Type",
2570
- "application/json; charset=utf-8")
2571
- }
2572
-
2573
- if (options.deserialize === JSON.parse) {
2574
- xhr.setRequestHeader("Accept", "application/json, text/*")
2575
- }
2576
-
2577
- if (isFunction(options.config)) {
2578
- var maybeXhr = options.config(xhr, options)
2579
- if (maybeXhr != null) xhr = maybeXhr
2580
- }
2581
-
2582
- var data = options.method === "GET" || !options.data ? "" : options.data
2583
-
2584
- if (data && !isString(data) && data.constructor !== global.FormData) {
2585
- throw new Error("Request data should be either be a string or " +
2586
- "FormData. Check the `serialize` option in `m.request`")
2587
- }
2588
-
2589
- xhr.send(data)
2590
- return xhr
2591
- }
2592
-
2593
- function ajax(options) {
2594
- if (options.dataType && options.dataType.toLowerCase() === "jsonp") {
2595
- return handleJsonp(options)
2596
- } else {
2597
- return createXhr(options)
2598
- }
2599
- }
2600
-
2601
- function bindData(options, data, serialize) {
2602
- if (options.method === "GET" && options.dataType !== "jsonp") {
2603
- var prefix = options.url.indexOf("?") < 0 ? "?" : "&"
2604
- var querystring = buildQueryString(data)
2605
- options.url += (querystring ? prefix + querystring : "")
2606
- } else {
2607
- options.data = serialize(data)
2608
- }
2609
- }
2610
-
2611
- function parameterizeUrl(url, data) {
2612
- if (data) {
2613
- url = url.replace(/:[a-z]\w+/gi, function (token){
2614
- var key = token.slice(1)
2615
- var value = data[key] || token
2616
- delete data[key]
2617
- return value
2618
- })
2619
- }
2620
- return url
2621
- }
2622
-
2623
- m.request = function (options) {
2624
- if (options.background !== true) m.startComputation()
2625
- var deferred = new Deferred()
2626
- var isJSONP = options.dataType &&
2627
- options.dataType.toLowerCase() === "jsonp"
2628
-
2629
- var serialize, deserialize, extract
2630
-
2631
- if (isJSONP) {
2632
- serialize = options.serialize =
2633
- deserialize = options.deserialize = identity
2634
-
2635
- extract = function (jsonp) { return jsonp.responseText }
2636
- } else {
2637
- serialize = options.serialize = options.serialize || JSON.stringify
2638
-
2639
- deserialize = options.deserialize =
2640
- options.deserialize || JSON.parse
2641
- extract = options.extract || function (xhr) {
2642
- if (xhr.responseText.length || deserialize !== JSON.parse) {
2643
- return xhr.responseText
2644
- } else {
2645
- return null
2646
- }
2647
- }
2648
- }
2649
-
2650
- options.method = (options.method || "GET").toUpperCase()
2651
- options.url = parameterizeUrl(options.url, options.data)
2652
- bindData(options, options.data, serialize)
2653
- options.onload = options.onerror = function (ev) {
2654
- try {
2655
- ev = ev || event
2656
- var response = deserialize(extract(ev.target, options))
2657
- if (ev.type === "load") {
2658
- if (options.unwrapSuccess) {
2659
- response = options.unwrapSuccess(response, ev.target)
2660
- }
2661
-
2662
- if (isArray(response) && options.type) {
2663
- forEach(response, function (res, i) {
2664
- response[i] = new options.type(res)
2665
- })
2666
- } else if (options.type) {
2667
- response = new options.type(response)
2668
- }
2669
-
2670
- deferred.resolve(response)
2671
- } else {
2672
- if (options.unwrapError) {
2673
- response = options.unwrapError(response, ev.target)
2674
- }
2675
-
2676
- deferred.reject(response)
2677
- }
2678
- } catch (e) {
2679
- deferred.reject(e)
2680
- m.deferred.onerror(e)
2681
- } finally {
2682
- if (options.background !== true) m.endComputation()
2683
- }
2684
- }
2685
-
2686
- ajax(options)
2687
- deferred.promise = propify(deferred.promise, options.initialValue)
2688
- return deferred.promise
2689
- }
2690
-
2691
- return m
2692
- }); // eslint-disable-line
2693
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2694
  },{}],8:[function(require,module,exports){
2695
  /*!
2696
- * EventEmitter v4.2.11 - git.io/ee
2697
  * Unlicense - http://unlicense.org/
2698
  * Oliver Caldwell - http://oli.me.uk/
2699
  * @preserve
2700
  */
2701
 
2702
- ;(function () {
2703
  'use strict';
2704
 
2705
  /**
@@ -2712,7 +1647,6 @@ module.exports = URL;
2712
 
2713
  // Shortcuts to improve speed and size
2714
  var proto = EventEmitter.prototype;
2715
- var exports = this;
2716
  var originalGlobalValue = exports.EventEmitter;
2717
 
2718
  /**
@@ -2813,6 +1747,16 @@ module.exports = URL;
2813
  return response || listeners;
2814
  };
2815
 
 
 
 
 
 
 
 
 
 
 
2816
  /**
2817
  * Adds a listener function to the specified event.
2818
  * The listener will not be added if it is a duplicate.
@@ -2824,6 +1768,10 @@ module.exports = URL;
2824
  * @return {Object} Current instance of EventEmitter for chaining.
2825
  */
2826
  proto.addListener = function addListener(evt, listener) {
 
 
 
 
2827
  var listeners = this.getListenersAsObject(evt);
2828
  var listenerIsWrapped = typeof listener === 'object';
2829
  var key;
@@ -3062,9 +2010,8 @@ module.exports = URL;
3062
  for (key in listenersMap) {
3063
  if (listenersMap.hasOwnProperty(key)) {
3064
  listeners = listenersMap[key].slice(0);
3065
- i = listeners.length;
3066
 
3067
- while (i--) {
3068
  // If the listener returns true then it shall be removed from the event
3069
  // The function is executed either with a basic call or an apply if there is an args array
3070
  listener = listeners[i];
@@ -3165,7 +2112,7 @@ module.exports = URL;
3165
  else {
3166
  exports.EventEmitter = EventEmitter;
3167
  }
3168
- }.call(this));
3169
 
3170
  },{}]},{},[1]);
3171
  })();
2
  'use strict';
3
 
4
  // dependencies
5
+
6
  var m = window.m = require('mithril');
7
  var EventEmitter = require('wolfy87-eventemitter');
8
 
9
  // vars
10
  var context = document.getElementById('mc4wp-admin');
11
  var events = new EventEmitter();
12
+ var tabs = require('./admin/tabs.js')(context);
13
  var helpers = require('./admin/helpers.js');
14
  var settings = require('./admin/settings.js')(context, helpers, events);
15
 
16
  // list fetcher
17
  var ListFetcher = require('./admin/list-fetcher.js');
18
  var mount = document.getElementById('mc4wp-list-fetcher');
19
+ if (mount) {
20
+ m.mount(mount, new ListFetcher());
21
  }
22
 
23
  // expose some things
28
  window.mc4wp.events = events;
29
  window.mc4wp.settings = settings;
30
  window.mc4wp.tabs = tabs;
31
+
32
  },{"./admin/helpers.js":2,"./admin/list-fetcher.js":3,"./admin/settings.js":4,"./admin/tabs.js":5,"mithril":7,"wolfy87-eventemitter":8}],2:[function(require,module,exports){
33
  'use strict';
34
 
35
  var helpers = {};
36
 
37
+ helpers.toggleElement = function (selector) {
38
  var elements = document.querySelectorAll(selector);
39
+ for (var i = 0; i < elements.length; i++) {
40
  var show = elements[i].clientHeight <= 0;
41
  elements[i].style.display = show ? '' : 'none';
42
  }
43
  };
44
 
45
+ helpers.bindEventToElement = function (element, event, handler) {
46
+ if (element.addEventListener) {
47
  element.addEventListener(event, handler);
48
+ } else if (element.attachEvent) {
49
  element.attachEvent('on' + event, handler);
50
  }
51
  };
52
 
53
+ helpers.bindEventToElements = function (elements, event, handler) {
54
+ Array.prototype.forEach.call(elements, function (element) {
55
+ helpers.bindEventToElement(element, event, handler);
56
  });
57
  };
58
 
 
59
  // polling
60
+ helpers.debounce = function (func, wait, immediate) {
61
  var timeout;
62
+ return function () {
63
+ var context = this,
64
+ args = arguments;
65
+ var later = function later() {
66
  timeout = null;
67
  if (!immediate) func.apply(context, args);
68
  };
73
  };
74
  };
75
 
 
76
  /**
77
  * Showif.js
78
  */
79
+ (function () {
80
  var showIfElements = document.querySelectorAll('[data-showif]');
81
 
82
  // dependent elements
83
+ Array.prototype.forEach.call(showIfElements, function (element) {
84
+ var config = JSON.parse(element.getAttribute('data-showif'));
85
+ var parentElements = document.querySelectorAll('[name="' + config.element + '"]');
86
  var inputs = element.querySelectorAll('input,select,textarea:not([readonly])');
87
  var hide = config.hide === undefined || config.hide;
88
 
89
  function toggleElement() {
90
 
91
  // do nothing with unchecked radio inputs
92
+ if (this.getAttribute('type') === "radio" && !this.checked) {
93
  return;
94
  }
95
 
96
+ var value = this.getAttribute("type") === "checkbox" ? this.checked : this.value;
97
+ var conditionMet = value == config.value;
98
 
99
+ if (hide) {
100
  element.style.display = conditionMet ? '' : 'none';
101
  element.style.visibility = conditionMet ? '' : 'hidden';
102
  } else {
104
  }
105
 
106
  // disable input fields to stop sending their values to server
107
+ Array.prototype.forEach.call(inputs, function (inputElement) {
108
+ conditionMet ? inputElement.removeAttribute('readonly') : inputElement.setAttribute('readonly', 'readonly');
109
  });
110
  }
111
 
112
  // find checked element and call toggleElement function
113
+ Array.prototype.forEach.call(parentElements, function (parentElement) {
114
  toggleElement.call(parentElement);
115
  });
116
 
120
  })();
121
 
122
  module.exports = helpers;
123
+
124
  },{}],3:[function(require,module,exports){
125
  'use strict';
126
 
133
  this.done = false;
134
 
135
  // start fetching right away when no lists but api key given
136
+ if (config.mailchimp.api_connected && config.mailchimp.lists.length == 0) {
137
  this.fetch();
138
  }
139
  }
146
 
147
  $.post(ajaxurl, {
148
  action: "mc4wp_renew_mailchimp_lists"
149
+ }).done(function (data) {
150
+ if (data) {
151
+ window.setTimeout(function () {
152
+ window.location.reload();
153
+ }, 3000);
154
  }
155
  }).always(function (data) {
156
  this.working = false;
164
  return m('form', {
165
  method: "POST",
166
  onsubmit: this.fetch.bind(this)
167
+ }, [m('p', [m('input', {
168
+ type: "submit",
169
+ value: this.working ? i18n.fetching_mailchimp_lists : i18n.renew_mailchimp_lists,
170
+ className: "button",
171
+ disabled: !!this.working
172
+ }), m.trust(' &nbsp; '), this.working ? [m('span.mc4wp-loader', "Loading..."), m.trust(' &nbsp; '), m('em.help', i18n.fetching_mailchimp_lists_can_take_a_while)] : '', this.done ? [m('em.help.green', i18n.fetching_mailchimp_lists_done)] : ''])]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
  };
174
 
175
  module.exports = ListFetcher;
176
+
177
  },{}],4:[function(require,module,exports){
178
+ 'use strict';
179
+
180
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
181
+
182
+ var Settings = function Settings(context, helpers, events) {
183
  'use strict';
184
 
185
  // vars
186
+
187
  var form = context.querySelector('form');
188
  var listInputs = context.querySelectorAll('.mc4wp-list-input');
189
  var lists = mc4wp_vars.mailchimp.lists;
190
  var selectedLists = [];
191
 
192
  // functions
193
+ function getSelectedListsWhere(searchKey, searchValue) {
194
+ return selectedLists.filter(function (el) {
195
  return el[searchKey] === searchValue;
196
  });
197
  }
203
  function updateSelectedLists() {
204
  selectedLists = [];
205
 
206
+ Array.prototype.forEach.call(listInputs, function (input) {
207
  // skip unchecked checkboxes
208
+ if (typeof input.checked === "boolean" && !input.checked) {
209
  return;
210
  }
211
 
212
+ if (_typeof(lists[input.value]) === "object") {
213
+ selectedLists.push(lists[input.value]);
214
  }
215
  });
216
 
217
+ events.trigger('selectedLists.change', [selectedLists]);
218
  return selectedLists;
219
  }
220
 
221
  function toggleVisibleLists() {
222
  var rows = document.querySelectorAll('.lists--only-selected > *');
223
+ Array.prototype.forEach.call(rows, function (el) {
224
 
225
  var listId = el.getAttribute('data-list-id');
226
  var isSelected = getSelectedListsWhere('id', listId).length > 0;
227
 
228
+ if (isSelected) {
229
+ el.setAttribute('class', el.getAttribute('class').replace('hidden', ''));
230
  } else {
231
+ el.setAttribute('class', el.getAttribute('class') + " hidden");
232
  }
233
  });
234
  }
235
 
236
  events.on('selectedLists.change', toggleVisibleLists);
237
+ helpers.bindEventToElements(listInputs, 'change', updateSelectedLists);
238
 
239
  updateSelectedLists();
240
 
241
  return {
242
  getSelectedLists: getSelectedLists
243
+ };
 
244
  };
245
 
246
  module.exports = Settings;
247
+
248
  },{}],5:[function(require,module,exports){
249
  'use strict';
250
 
251
  var URL = require('./url.js');
252
 
253
  // Tabs
254
+ var Tabs = function Tabs(context) {
255
 
256
+ // TODO: last piece of jQuery... can we get rid of it?
257
  var $ = window.jQuery;
258
 
259
  var $context = $(context);
262
  var refererField = context.querySelector('input[name="_wp_http_referer"]');
263
  var tabs = [];
264
 
265
+ $.each($tabs, function (i, t) {
266
  var id = t.id.substring(4);
267
  var title = $(t).find('h2').first().text();
268
 
271
  title: title,
272
  element: t,
273
  nav: context.querySelectorAll('.nav-tab-' + id),
274
+ open: function open() {
275
+ return _open(id);
276
+ }
277
  });
278
  });
279
 
280
  function get(id) {
281
 
282
+ for (var i = 0; i < tabs.length; i++) {
283
+ if (tabs[i].id === id) {
284
  return tabs[i];
285
  }
286
  }
288
  return undefined;
289
  }
290
 
291
+ function _open(tab, updateState) {
292
 
293
  // make sure we have a tab object
294
+ if (typeof tab === "string") {
295
  tab = get(tab);
296
  }
297
 
298
+ if (!tab) {
299
+ return false;
300
+ }
301
 
302
  // should we update state?
303
+ if (updateState == undefined) {
304
  updateState = true;
305
  }
306
 
309
  $tabNavs.removeClass('nav-tab-active');
310
 
311
  // add `nav-tab-active` to this tab
312
+ Array.prototype.forEach.call(tab.nav, function (nav) {
313
  nav.className += " nav-tab-active";
314
  nav.blur();
315
  });
319
  tab.element.className += " tab-active";
320
 
321
  // create new URL
322
+ var url = URL.setParameter(window.location.href, "tab", tab.id);
323
 
324
  // update hash
325
+ if (history.pushState && updateState) {
326
+ history.pushState(tab.id, '', url);
327
  }
328
 
329
  // update document title
333
  refererField.value = url;
334
 
335
  // if thickbox is open, close it.
336
+ if (typeof tb_remove === "function") {
337
  tb_remove();
338
  }
339
 
340
  // refresh editor after switching tabs
341
+ // TODO: decouple this! law of demeter etc.
342
+ if (tab.id === 'fields' && window.mc4wp && window.mc4wp.forms && window.mc4wp.forms.editor) {
343
  mc4wp.forms.editor.refresh();
344
  }
345
 
358
  var tabId = this.getAttribute('data-tab');
359
 
360
  // get from classname
361
+ if (!tabId) {
362
  var match = this.className.match(/nav-tab-(\w+)?/);
363
+ if (match) {
364
  tabId = match[1];
365
  }
366
  }
367
 
368
  // get from href
369
+ if (!tabId) {
370
+ var urlParams = URL.parse(this.href);
371
+ if (!urlParams.tab) {
372
+ return;
373
+ }
374
  tabId = urlParams.tab;
375
  }
376
 
377
+ var opened = _open(tabId);
378
 
379
+ if (opened) {
380
  e.preventDefault();
381
  e.returnValue = false;
382
  return false;
388
  function init() {
389
 
390
  // check for current tab
391
+ if (!history.pushState) {
392
  return;
393
  }
394
 
395
  var activeTab = $tabs.filter(':visible').get(0);
396
+ if (!activeTab) {
397
+ return;
398
+ }
399
  var tab = get(activeTab.id.substring(4));
400
+ if (!tab) return;
401
 
402
  // check if tab is in html5 history
403
+ if (history.replaceState && history.state === null) {
404
+ history.replaceState(tab.id, '');
405
  }
406
 
407
  // update document title
412
  $(document.body).on('click', '.tab-link', switchTab);
413
  init();
414
 
415
+ if (window.addEventListener && history.pushState) {
416
+ window.addEventListener('popstate', function (e) {
417
+ if (!e.state) return true;
418
  var tabId = e.state;
419
+ return _open(tabId, false);
420
  });
421
  }
422
 
423
  return {
424
+ open: _open,
425
  get: get
426
+ };
 
427
  };
428
 
429
  module.exports = Tabs;
430
+
431
  },{"./url.js":6}],6:[function(require,module,exports){
432
  'use strict';
433
 
434
  var URL = {
435
+ parse: function parse(url) {
436
  var query = {};
437
  var a = url.split('&');
438
  for (var i in a) {
439
+ if (!a.hasOwnProperty(i)) {
440
  continue;
441
  }
442
  var b = a[i].split('=');
445
 
446
  return query;
447
  },
448
+ build: function build(data) {
449
  var ret = [];
450
+ for (var d in data) {
451
  ret.push(d + "=" + encodeURIComponent(data[d]));
452
+ }return ret.join("&");
453
  },
454
+ setParameter: function setParameter(url, key, value) {
455
+ var data = URL.parse(url);
456
+ data[key] = value;
457
+ return URL.build(data);
458
  }
459
  };
460
 
461
  module.exports = URL;
462
+
463
  },{}],7:[function(require,module,ex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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
466
 
467
+ function Vnode(tag, key, attrs0, children, text, dom) {
468
+ return {tag: tag, key: key, attrs: attrs0, children: children, text: text, dom: dom, domSize: undefined, state: {}, events: undefined, instance: undefined, skip: false}
469
+ }
470
+ Vnode.normalize = function(node) {
471
+ if (Array.isArray(node)) return Vnode("[", undefined, undefined, Vnode.normalizeChildren(node), undefined, undefined)
472
+ if (node != null && typeof node !== "object") return Vnode("#", undefined, undefined, node === false ? "" : node, undefined, undefined)
473
+ return node
474
+ }
475
+ Vnode.normalizeChildren = function normalizeChildren(children) {
476
+ for (var i = 0; i < children.length; i++) {
477
+ children[i] = Vnode.normalize(children[i])
478
+ }
479
+ return children
480
+ }
481
+ var selectorParser = /(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g
482
+ var selectorCache = {}
483
+ function hyperscript(selector) {
484
+ if (selector == null || typeof selector !== "string" && typeof selector.view !== "function") {
485
+ throw Error("The selector must be either a string or a component.");
486
+ }
487
+ if (typeof selector === "string" && selectorCache[selector] === undefined) {
488
+ var match, tag, classes = [], attributes = {}
489
+ while (match = selectorParser.exec(selector)) {
490
+ var type = match[1], value = match[2]
491
+ if (type === "" && value !== "") tag = value
492
+ else if (type === "#") attributes.id = value
493
+ else if (type === ".") classes.push(value)
494
+ else if (match[3][0] === "[") {
495
+ var attrValue = match[6]
496
+ if (attrValue) attrValue = attrValue.replace(/\\(["'])/g, "$1").replace(/\\\\/g, "\\")
497
+ if (match[4] === "class") classes.push(attrValue)
498
+ else attributes[match[4]] = attrValue || true
499
+ }
500
+ }
501
+ if (classes.length > 0) attributes.className = classes.join(" ")
502
+ selectorCache[selector] = function(attrs, children) {
503
+ var hasAttrs = false, childList, text
504
+ var className = attrs.className || attrs.class
505
+ for (var key in attributes) attrs[key] = attributes[key]
506
+ if (className !== undefined) {
507
+ if (attrs.class !== undefined) {
508
+ attrs.class = undefined
509
+ attrs.className = className
510
+ }
511
+ if (attributes.className !== undefined) attrs.className = attributes.className + " " + className
512
+ }
513
+ for (var key in attrs) {
514
+ if (key !== "key") {
515
+ hasAttrs = true
516
+ break
517
+ }
518
+ }
519
+ if (Array.isArray(children) && children.length == 1 && children[0] != null && children[0].tag === "#") text = children[0].children
520
+ else childList = children
521
+ return Vnode(tag || "div", attrs.key, hasAttrs ? attrs : undefined, childList, text, undefined)
522
+ }
523
+ }
524
+ var attrs, children, childrenIndex
525
+ if (arguments[1] == null || typeof arguments[1] === "object" && arguments[1].tag === undefined && !Array.isArray(arguments[1])) {
526
+ attrs = arguments[1]
527
+ childrenIndex = 2
528
+ }
529
+ else childrenIndex = 1
530
+ if (arguments.length === childrenIndex + 1) {
531
+ children = Array.isArray(arguments[childrenIndex]) ? arguments[childrenIndex] : [arguments[childrenIndex]]
532
+ }
533
+ else {
534
+ children = []
535
+ for (var i = childrenIndex; i < arguments.length; i++) children.push(arguments[i])
536
+ }
537
+ if (typeof selector === "string") return selectorCache[selector](attrs || {}, Vnode.normalizeChildren(children))
538
+ return Vnode(selector, attrs && attrs.key, attrs || {}, Vnode.normalizeChildren(children), undefined, undefined)
539
+ }
540
+ hyperscript.trust = function(html) {
541
+ if (html == null) html = ""
542
+ return Vnode("<", undefined, undefined, html, undefined, undefined)
543
+ }
544
+ hyperscript.fragment = function(attrs1, children) {
545
+ return Vnode("[", attrs1.key, attrs1, Vnode.normalizeChildren(children), undefined, undefined)
546
+ }
547
+ var m = hyperscript
548
+ /** @constructor */
549
+ var PromisePolyfill = function(executor) {
550
+ if (!(this instanceof PromisePolyfill)) throw new Error("Promise must be called with `new`")
551
+ if (typeof executor !== "function") throw new TypeError("executor must be a function")
552
+ var self = this, resolvers = [], rejectors = [], resolveCurrent = handler(resolvers, true), rejectCurrent = handler(rejectors, false)
553
+ var instance = self._instance = {resolvers: resolvers, rejectors: rejectors}
554
+ var callAsync = typeof setImmediate === "function" ? setImmediate : setTimeout
555
+ function handler(list, shouldAbsorb) {
556
+ return function execute(value) {
557
+ var then
558
+ try {
559
+ if (shouldAbsorb && value != null && (typeof value === "object" || typeof value === "function") && typeof (then = value.then) === "function") {
560
+ if (value === self) throw new TypeError("Promise can't be resolved w/ itself")
561
+ executeOnce(then.bind(value))
562
+ }
563
+ else {
564
+ callAsync(function() {
565
+ if (!shouldAbsorb && list.length === 0) console.error("Possible unhandled promise rejection:", value)
566
+ for (var i = 0; i < list.length; i++) list[i](value)
567
+ resolvers.length = 0, rejectors.length = 0
568
+ instance.state = shouldAbsorb
569
+ instance.retry = function() {execute(value)}
570
+ })
571
+ }
572
+ }
573
+ catch (e) {
574
+ rejectCurrent(e)
575
+ }
576
+ }
577
+ }
578
+ function executeOnce(then) {
579
+ var runs = 0
580
+ function run(fn) {
581
+ return function(value) {
582
+ if (runs++ > 0) return
583
+ fn(value)
584
+ }
585
+ }
586
+ var onerror = run(rejectCurrent)
587
+ try {then(run(resolveCurrent), onerror)} catch (e) {onerror(e)}
588
+ }
589
+ executeOnce(executor)
590
+ }
591
+ PromisePolyfill.prototype.then = function(onFulfilled, onRejection) {
592
+ var self = this, instance = self._instance
593
+ function handle(callback, list, next, state) {
594
+ list.push(function(value) {
595
+ if (typeof callback !== "function") next(value)
596
+ else try {resolveNext(callback(value))} catch (e) {if (rejectNext) rejectNext(e)}
597
+ })
598
+ if (typeof instance.retry === "function" && state === instance.state) instance.retry()
599
+ }
600
+ var resolveNext, rejectNext
601
+ var promise = new PromisePolyfill(function(resolve, reject) {resolveNext = resolve, rejectNext = reject})
602
+ handle(onFulfilled, instance.resolvers, resolveNext, true), handle(onRejection, instance.rejectors, rejectNext, false)
603
+ return promise
604
+ }
605
+ PromisePolyfill.prototype.catch = function(onRejection) {
606
+ return this.then(null, onRejection)
607
+ }
608
+ PromisePolyfill.resolve = function(value) {
609
+ if (value instanceof PromisePolyfill) return value
610
+ return new PromisePolyfill(function(resolve) {resolve(value)})
611
+ }
612
+ PromisePolyfill.reject = function(value) {
613
+ return new PromisePolyfill(function(resolve, reject) {reject(value)})
614
+ }
615
+ PromisePolyfill.all = function(list) {
616
+ return new PromisePolyfill(function(resolve, reject) {
617
+ var total = list.length, count = 0, values = []
618
+ if (list.length === 0) resolve([])
619
+ else for (var i = 0; i < list.length; i++) {
620
+ (function(i) {
621
+ function consume(value) {
622
+ count++
623
+ values[i] = value
624
+ if (count === total) resolve(values)
625
+ }
626
+ if (list[i] != null && (typeof list[i] === "object" || typeof list[i] === "function") && typeof list[i].then === "function") {
627
+ list[i].then(consume, reject)
628
+ }
629
+ else consume(list[i])
630
+ })(i)
631
+ }
632
+ })
633
+ }
634
+ PromisePolyfill.race = function(list) {
635
+ return new PromisePolyfill(function(resolve, reject) {
636
+ for (var i = 0; i < list.length; i++) {
637
+ list[i].then(resolve, reject)
638
+ }
639
+ })
640
+ }
641
+ if (typeof window !== "undefined") {
642
+ if (typeof window.Promise === "undefined") window.Promise = PromisePolyfill
643
+ var PromisePolyfill = window.Promise
644
+ } else if (typeof global !== "undefined") {
645
+ if (typeof global.Promise === "undefined") global.Promise = PromisePolyfill
646
+ var PromisePolyfill = global.Promise
647
+ } else {
648
+ }
649
+ var buildQueryString = function(object) {
650
+ if (Object.prototype.toString.call(object) !== "[object Object]") return ""
651
+ var args = []
652
+ for (var key0 in object) {
653
+ destructure(key0, object[key0])
654
+ }
655
+ return args.join("&")
656
+ function destructure(key0, value) {
657
+ if (Array.isArray(value)) {
658
+ for (var i = 0; i < value.length; i++) {
659
+ destructure(key0 + "[" + i + "]", value[i])
660
+ }
661
+ }
662
+ else if (Object.prototype.toString.call(value) === "[object Object]") {
663
+ for (var i in value) {
664
+ destructure(key0 + "[" + i + "]", value[i])
665
+ }
666
+ }
667
+ else args.push(encodeURIComponent(key0) + (value != null && value !== "" ? "=" + encodeURIComponent(value) : ""))
668
+ }
669
+ }
670
+ var _8 = function($window, Promise) {
671
+ var callbackCount = 0
672
+ var oncompletion
673
+ function setCompletionCallback(callback) {oncompletion = callback}
674
+ function finalizer() {
675
+ var count = 0
676
+ function complete() {if (--count === 0 && typeof oncompletion === "function") oncompletion()}
677
+ return function finalize(promise0) {
678
+ var then0 = promise0.then
679
+ promise0.then = function() {
680
+ count++
681
+ var next = then0.apply(promise0, arguments)
682
+ next.then(complete, function(e) {
683
+ complete()
684
+ if (count === 0) throw e
685
+ })
686
+ return finalize(next)
687
+ }
688
+ return promise0
689
+ }
690
+ }
691
+ function normalize(args, extra) {
692
+ if (typeof args === "string") {
693
+ var url = args
694
+ args = extra || {}
695
+ if (args.url == null) args.url = url
696
+ }
697
+ return args
698
+ }
699
+ function request(args, extra) {
700
+ var finalize = finalizer()
701
+ args = normalize(args, extra)
702
+ var promise0 = new Promise(function(resolve, reject) {
703
+ if (args.method == null) args.method = "GET"
704
+ args.method = args.method.toUpperCase()
705
+ var useBody = typeof args.useBody === "boolean" ? args.useBody : args.method !== "GET" && args.method !== "TRACE"
706
+ if (typeof args.serialize !== "function") args.serialize = typeof FormData !== "undefined" && args.data instanceof FormData ? function(value) {return value} : JSON.stringify
707
+ if (typeof args.deserialize !== "function") args.deserialize = deserialize
708
+ if (typeof args.extract !== "function") args.extract = extract
709
+ args.url = interpolate(args.url, args.data)
710
+ if (useBody) args.data = args.serialize(args.data)
711
+ else args.url = assemble(args.url, args.data)
712
+ var xhr = new $window.XMLHttpRequest()
713
+ xhr.open(args.method, args.url, typeof args.async === "boolean" ? args.async : true, typeof args.user === "string" ? args.user : undefined, typeof args.password === "string" ? args.password : undefined)
714
+ if (args.serialize === JSON.stringify && useBody) {
715
+ xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8")
716
+ }
717
+ if (args.deserialize === deserialize) {
718
+ xhr.setRequestHeader("Accept", "application/json, text/*")
719
+ }
720
+ if (args.withCredentials) xhr.withCredentials = args.withCredentials
721
+ for (var key in args.headers) if ({}.hasOwnProperty.call(args.headers, key)) {
722
+ xhr.setRequestHeader(key, args.headers[key])
723
+ }
724
+ if (typeof args.config === "function") xhr = args.config(xhr, args) || xhr
725
+ xhr.onreadystatechange = function() {
726
+ // Don't throw errors on xhr.abort(). XMLHttpRequests ends up in a state of
727
+ // xhr.status == 0 and xhr.readyState == 4 if aborted after open, but before completion.
728
+ if (xhr.status && xhr.readyState === 4) {
729
+ try {
730
+ var response = (args.extract !== extract) ? args.extract(xhr, args) : args.deserialize(args.extract(xhr, args))
731
+ if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304) {
732
+ resolve(cast(args.type, response))
733
+ }
734
+ else {
735
+ var error = new Error(xhr.responseText)
736
+ for (var key in response) error[key] = response[key]
737
+ reject(error)
738
+ }
739
+ }
740
+ catch (e) {
741
+ reject(e)
742
+ }
743
+ }
744
+ }
745
+ if (useBody && (args.data != null)) xhr.send(args.data)
746
+ else xhr.send()
747
+ })
748
+ return args.background === true ? promise0 : finalize(promise0)
749
+ }
750
+ function jsonp(args, extra) {
751
+ var finalize = finalizer()
752
+ args = normalize(args, extra)
753
+ var promise0 = new Promise(function(resolve, reject) {
754
+ var callbackName = args.callbackName || "_mithril_" + Math.round(Math.random() * 1e16) + "_" + callbackCount++
755
+ var script = $window.document.createElement("script")
756
+ $window[callbackName] = function(data) {
757
+ script.parentNode.removeChild(script)
758
+ resolve(cast(args.type, data))
759
+ delete $window[callbackName]
760
+ }
761
+ script.onerror = function() {
762
+ script.parentNode.removeChild(script)
763
+ reject(new Error("JSONP request failed"))
764
+ delete $window[callbackName]
765
+ }
766
+ if (args.data == null) args.data = {}
767
+ args.url = interpolate(args.url, args.data)
768
+ args.data[args.callbackKey || "callback"] = callbackName
769
+ script.src = assemble(args.url, args.data)
770
+ $window.document.documentElement.appendChild(script)
771
+ })
772
+ return args.background === true? promise0 : finalize(promise0)
773
+ }
774
+ function interpolate(url, data) {
775
+ if (data == null) return url
776
+ var tokens = url.match(/:[^\/]+/gi) || []
777
+ for (var i = 0; i < tokens.length; i++) {
778
+ var key = tokens[i].slice(1)
779
+ if (data[key] != null) {
780
+ url = url.replace(tokens[i], data[key])
781
+ }
782
+ }
783
+ return url
784
+ }
785
+ function assemble(url, data) {
786
+ var querystring = buildQueryString(data)
787
+ if (querystring !== "") {
788
+ var prefix = url.indexOf("?") < 0 ? "?" : "&"
789
+ url += prefix + querystring
790
+ }
791
+ return url
792
+ }
793
+ function deserialize(data) {
794
+ try {return data !== "" ? JSON.parse(data) : null}
795
+ catch (e) {throw new Error(data)}
796
+ }
797
+ function extract(xhr) {return xhr.responseText}
798
+ function cast(type0, data) {
799
+ if (typeof type0 === "function") {
800
+ if (Array.isArray(data)) {
801
+ for (var i = 0; i < data.length; i++) {
802
+ data[i] = new type0(data[i])
803
+ }
804
+ }
805
+ else return new type0(data)
806
+ }
807
+ return data
808
+ }
809
+ return {request: request, jsonp: jsonp, setCompletionCallback: setCompletionCallback}
810
+ }
811
+ var requestService = _8(window, PromisePolyfill)
812
+ var coreRenderer = function($window) {
813
+ var $doc = $window.document
814
+ var $emptyFragment = $doc.createDocumentFragment()
815
+ var onevent
816
+ function setEventCallback(callback) {return onevent = callback}
817
+ //create
818
+ function createNodes(parent, vnodes, start, end, hooks, nextSibling, ns) {
819
+ for (var i = start; i < end; i++) {
820
+ var vnode = vnodes[i]
821
+ if (vnode != null) {
822
+ createNode(parent, vnode, hooks, ns, nextSibling)
823
+ }
824
+ }
825
+ }
826
+ function createNode(parent, vnode, hooks, ns, nextSibling) {
827
+ var tag = vnode.tag
828
+ if (vnode.attrs != null) initLifecycle(vnode.attrs, vnode, hooks)
829
+ if (typeof tag === "string") {
830
+ switch (tag) {
831
+ case "#": return createText(parent, vnode, nextSibling)
832
+ case "<": return createHTML(parent, vnode, nextSibling)
833
+ case "[": return createFragment(parent, vnode, hooks, ns, nextSibling)
834
+ default: return createElement(parent, vnode, hooks, ns, nextSibling)
835
+ }
836
+ }
837
+ else return createComponent(parent, vnode, hooks, ns, nextSibling)
838
+ }
839
+ function createText(parent, vnode, nextSibling) {
840
+ vnode.dom = $doc.createTextNode(vnode.children)
841
+ insertNode(parent, vnode.dom, nextSibling)
842
+ return vnode.dom
843
+ }
844
+ function createHTML(parent, vnode, nextSibling) {
845
+ var match1 = vnode.children.match(/^\s*?<(\w+)/im) || []
846
+ var parent1 = {caption: "table", thead: "table", tbody: "table", tfoot: "table", tr: "tbody", th: "tr", td: "tr", colgroup: "table", col: "colgroup"}[match1[1]] || "div"
847
+ var temp = $doc.createElement(parent1)
848
+ temp.innerHTML = vnode.children
849
+ vnode.dom = temp.firstChild
850
+ vnode.domSize = temp.childNodes.length
851
+ var fragment = $doc.createDocumentFragment()
852
+ var child
853
+ while (child = temp.firstChild) {
854
+ fragment.appendChild(child)
855
+ }
856
+ insertNode(parent, fragment, nextSibling)
857
+ return fragment
858
+ }
859
+ function createFragment(parent, vnode, hooks, ns, nextSibling) {
860
+ var fragment = $doc.createDocumentFragment()
861
+ if (vnode.children != null) {
862
+ var children = vnode.children
863
+ createNodes(fragment, children, 0, children.length, hooks, null, ns)
864
+ }
865
+ vnode.dom = fragment.firstChild
866
+ vnode.domSize = fragment.childNodes.length
867
+ insertNode(parent, fragment, nextSibling)
868
+ return fragment
869
+ }
870
+ function createElement(parent, vnode, hooks, ns, nextSibling) {
871
+ var tag = vnode.tag
872
+ switch (vnode.tag) {
873
+ case "svg": ns = "http://www.w3.org/2000/svg"; break
874
+ case "math": ns = "http://www.w3.org/1998/Math/MathML"; break
875
+ }
876
+ var attrs2 = vnode.attrs
877
+ var is = attrs2 && attrs2.is
878
+ var element = ns ?
879
+ is ? $doc.createElementNS(ns, tag, {is: is}) : $doc.createElementNS(ns, tag) :
880
+ is ? $doc.createElement(tag, {is: is}) : $doc.createElement(tag)
881
+ vnode.dom = element
882
+ if (attrs2 != null) {
883
+ setAttrs(vnode, attrs2, ns)
884
+ }
885
+ insertNode(parent, element, nextSibling)
886
+ if (vnode.attrs != null && vnode.attrs.contenteditable != null) {
887
+ setContentEditable(vnode)
888
+ }
889
+ else {
890
+ if (vnode.text != null) {
891
+ if (vnode.text !== "") element.textContent = vnode.text
892
+ else vnode.children = [Vnode("#", undefined, undefined, vnode.text, undefined, undefined)]
893
+ }
894
+ if (vnode.children != null) {
895
+ var children = vnode.children
896
+ createNodes(element, children, 0, children.length, hooks, null, ns)
897
+ setLateAttrs(vnode)
898
+ }
899
+ }
900
+ return element
901
+ }
902
+ function createComponent(parent, vnode, hooks, ns, nextSibling) {
903
+ vnode.state = Object.create(vnode.tag)
904
+ var view = vnode.tag.view
905
+ if (view.reentrantLock != null) return $emptyFragment
906
+ view.reentrantLock = true
907
+ initLifecycle(vnode.tag, vnode, hooks)
908
+ vnode.instance = Vnode.normalize(view.call(vnode.state, vnode))
909
+ view.reentrantLock = null
910
+ if (vnode.instance != null) {
911
+ if (vnode.instance === vnode) throw Error("A view cannot return the vnode it received as arguments")
912
+ var element = createNode(parent, vnode.instance, hooks, ns, nextSibling)
913
+ vnode.dom = vnode.instance.dom
914
+ vnode.domSize = vnode.dom != null ? vnode.instance.domSize : 0
915
+ insertNode(parent, element, nextSibling)
916
+ return element
917
+ }
918
+ else {
919
+ vnode.domSize = 0
920
+ return $emptyFragment
921
+ }
922
+ }
923
+ //update
924
+ function updateNodes(parent, old, vnodes, recycling, hooks, nextSibling, ns) {
925
+ if (old === vnodes || old == null && vnodes == null) return
926
+ else if (old == null) createNodes(parent, vnodes, 0, vnodes.length, hooks, nextSibling, undefined)
927
+ else if (vnodes == null) removeNodes(old, 0, old.length, vnodes)
928
+ else {
929
+ if (old.length === vnodes.length) {
930
+ var isUnkeyed = false
931
+ for (var i = 0; i < vnodes.length; i++) {
932
+ if (vnodes[i] != null && old[i] != null) {
933
+ isUnkeyed = vnodes[i].key == null && old[i].key == null
934
+ break
935
+ }
936
+ }
937
+ if (isUnkeyed) {
938
+ for (var i = 0; i < old.length; i++) {
939
+ if (old[i] === vnodes[i]) continue
940
+ else if (old[i] == null && vnodes[i] != null) createNode(parent, vnodes[i], hooks, ns, getNextSibling(old, i + 1, nextSibling))
941
+ else if (vnodes[i] == null) removeNodes(old, i, i + 1, vnodes)
942
+ else updateNode(parent, old[i], vnodes[i], hooks, getNextSibling(old, i + 1, nextSibling), false, ns)
943
+ }
944
+ return
945
+ }
946
+ }
947
+ recycling = recycling || isRecyclable(old, vnodes)
948
+ if (recycling) old = old.concat(old.pool)
949
+
950
+ var oldStart = 0, start = 0, oldEnd = old.length - 1, end = vnodes.length - 1, map
951
+ while (oldEnd >= oldStart && end >= start) {
952
+ var o = old[oldStart], v = vnodes[start]
953
+ if (o === v && !recycling) oldStart++, start++
954
+ else if (o == null) oldStart++
955
+ else if (v == null) start++
956
+ else if (o.key === v.key) {
957
+ oldStart++, start++
958
+ updateNode(parent, o, v, hooks, getNextSibling(old, oldStart, nextSibling), recycling, ns)
959
+ if (recycling && o.tag === v.tag) insertNode(parent, toFragment(o), nextSibling)
960
+ }
961
+ else {
962
+ var o = old[oldEnd]
963
+ if (o === v && !recycling) oldEnd--, start++
964
+ else if (o == null) oldEnd--
965
+ else if (v == null) start++
966
+ else if (o.key === v.key) {
967
+ updateNode(parent, o, v, hooks, getNextSibling(old, oldEnd + 1, nextSibling), recycling, ns)
968
+ if (recycling || start < end) insertNode(parent, toFragment(o), getNextSibling(old, oldStart, nextSibling))
969
+ oldEnd--, start++
970
+ }
971
+ else break
972
+ }
973
+ }
974
+ while (oldEnd >= oldStart && end >= start) {
975
+ var o = old[oldEnd], v = vnodes[end]
976
+ if (o === v && !recycling) oldEnd--, end--
977
+ else if (o == null) oldEnd--
978
+ else if (v == null) end--
979
+ else if (o.key === v.key) {
980
+ updateNode(parent, o, v, hooks, getNextSibling(old, oldEnd + 1, nextSibling), recycling, ns)
981
+ if (recycling && o.tag === v.tag) insertNode(parent, toFragment(o), nextSibling)
982
+ if (o.dom != null) nextSibling = o.dom
983
+ oldEnd--, end--
984
+ }
985
+ else {
986
+ if (!map) map = getKeyMap(old, oldEnd)
987
+ if (v != null) {
988
+ var oldIndex = map[v.key]
989
+ if (oldIndex != null) {
990
+ var movable = old[oldIndex]
991
+ updateNode(parent, movable, v, hooks, getNextSibling(old, oldEnd + 1, nextSibling), recycling, ns)
992
+ insertNode(parent, toFragment(movable), nextSibling)
993
+ old[oldIndex].skip = true
994
+ if (movable.dom != null) nextSibling = movable.dom
995
+ }
996
+ else {
997
+ var dom = createNode(parent, v, hooks, undefined, nextSibling)
998
+ nextSibling = dom
999
+ }
1000
+ }
1001
+ end--
1002
+ }
1003
+ if (end < start) break
1004
+ }
1005
+ createNodes(parent, vnodes, start, end + 1, hooks, nextSibling, ns)
1006
+ removeNodes(old, oldStart, oldEnd + 1, vnodes)
1007
+ }
1008
+ }
1009
+ function updateNode(parent, old, vnode, hooks, nextSibling, recycling, ns) {
1010
+ var oldTag = old.tag, tag = vnode.tag
1011
+ if (oldTag === tag) {
1012
+ vnode.state = old.state
1013
+ vnode.events = old.events
1014
+ if (shouldUpdate(vnode, old)) return
1015
+ if (vnode.attrs != null) {
1016
+ updateLifecycle(vnode.attrs, vnode, hooks, recycling)
1017
+ }
1018
+ if (typeof oldTag === "string") {
1019
+ switch (oldTag) {
1020
+ case "#": updateText(old, vnode); break
1021
+ case "<": updateHTML(parent, old, vnode, nextSibling); break
1022
+ case "[": updateFragment(parent, old, vnode, recycling, hooks, nextSibling, ns); break
1023
+ default: updateElement(old, vnode, recycling, hooks, ns)
1024
+ }
1025
+ }
1026
+ else updateComponent(parent, old, vnode, hooks, nextSibling, recycling, ns)
1027
+ }
1028
+ else {
1029
+ removeNode(old, null)
1030
+ createNode(parent, vnode, hooks, ns, nextSibling)
1031
+ }
1032
+ }
1033
+ function updateText(old, vnode) {
1034
+ if (old.children.toString() !== vnode.children.toString()) {
1035
+ old.dom.nodeValue = vnode.children
1036
+ }
1037
+ vnode.dom = old.dom
1038
+ }
1039
+ function updateHTML(parent, old, vnode, nextSibling) {
1040
+ if (old.children !== vnode.children) {
1041
+ toFragment(old)
1042
+ createHTML(parent, vnode, nextSibling)
1043
+ }
1044
+ else vnode.dom = old.dom, vnode.domSize = old.domSize
1045
+ }
1046
+ function updateFragment(parent, old, vnode, recycling, hooks, nextSibling, ns) {
1047
+ updateNodes(parent, old.children, vnode.children, recycling, hooks, nextSibling, ns)
1048
+ var domSize = 0, children = vnode.children
1049
+ vnode.dom = null
1050
+ if (children != null) {
1051
+ for (var i = 0; i < children.length; i++) {
1052
+ var child = children[i]
1053
+ if (child != null && child.dom != null) {
1054
+ if (vnode.dom == null) vnode.dom = child.dom
1055
+ domSize += child.domSize || 1
1056
+ }
1057
+ }
1058
+ if (domSize !== 1) vnode.domSize = domSize
1059
+ }
1060
+ }
1061
+ function updateElement(old, vnode, recycling, hooks, ns) {
1062
+ var element = vnode.dom = old.dom
1063
+ switch (vnode.tag) {
1064
+ case "svg": ns = "http://www.w3.org/2000/svg"; break
1065
+ case "math": ns = "http://www.w3.org/1998/Math/MathML"; break
1066
+ }
1067
+ if (vnode.tag === "textarea") {
1068
+ if (vnode.attrs == null) vnode.attrs = {}
1069
+ if (vnode.text != null) {
1070
+ vnode.attrs.value = vnode.text //FIXME handle0 multiple children
1071
+ vnode.text = undefined
1072
+ }
1073
+ }
1074
+ updateAttrs(vnode, old.attrs, vnode.attrs, ns)
1075
+ if (vnode.attrs != null && vnode.attrs.contenteditable != null) {
1076
+ setContentEditable(vnode)
1077
+ }
1078
+ else if (old.text != null && vnode.text != null && vnode.text !== "") {
1079
+ if (old.text.toString() !== vnode.text.toString()) old.dom.firstChild.nodeValue = vnode.text
1080
+ }
1081
+ else {
1082
+ if (old.text != null) old.children = [Vnode("#", undefined, undefined, old.text, undefined, old.dom.firstChild)]
1083
+ if (vnode.text != null) vnode.children = [Vnode("#", undefined, undefined, vnode.text, undefined, undefined)]
1084
+ updateNodes(element, old.children, vnode.children, recycling, hooks, null, ns)
1085
+ }
1086
+ }
1087
+ function updateComponent(parent, old, vnode, hooks, nextSibling, recycling, ns) {
1088
+ vnode.instance = Vnode.normalize(vnode.tag.view.call(vnode.state, vnode))
1089
+ updateLifecycle(vnode.tag, vnode, hooks, recycling)
1090
+ if (vnode.instance != null) {
1091
+ if (old.instance == null) createNode(parent, vnode.instance, hooks, ns, nextSibling)
1092
+ else updateNode(parent, old.instance, vnode.instance, hooks, nextSibling, recycling, ns)
1093
+ vnode.dom = vnode.instance.dom
1094
+ vnode.domSize = vnode.instance.domSize
1095
+ }
1096
+ else if (old.instance != null) {
1097
+ removeNode(old.instance, null)
1098
+ vnode.dom = undefined
1099
+ vnode.domSize = 0
1100
+ }
1101
+ else {
1102
+ vnode.dom = old.dom
1103
+ vnode.domSize = old.domSize
1104
+ }
1105
+ }
1106
+ function isRecyclable(old, vnodes) {
1107
+ if (old.pool != null && Math.abs(old.pool.length - vnodes.length) <= Math.abs(old.length - vnodes.length)) {
1108
+ var oldChildrenLength = old[0] && old[0].children && old[0].children.length || 0
1109
+ var poolChildrenLength = old.pool[0] && old.pool[0].children && old.pool[0].children.length || 0
1110
+ var vnodesChildrenLength = vnodes[0] && vnodes[0].children && vnodes[0].children.length || 0
1111
+ if (Math.abs(poolChildrenLength - vnodesChildrenLength) <= Math.abs(oldChildrenLength - vnodesChildrenLength)) {
1112
+ return true
1113
+ }
1114
+ }
1115
+ return false
1116
+ }
1117
+ function getKeyMap(vnodes, end) {
1118
+ var map = {}, i = 0
1119
+ for (var i = 0; i < end; i++) {
1120
+ var vnode = vnodes[i]
1121
+ if (vnode != null) {
1122
+ var key2 = vnode.key
1123
+ if (key2 != null) map[key2] = i
1124
+ }
1125
+ }
1126
+ return map
1127
+ }
1128
+ function toFragment(vnode) {
1129
+ var count0 = vnode.domSize
1130
+ if (count0 != null || vnode.dom == null) {
1131
+ var fragment = $doc.createDocumentFragment()
1132
+ if (count0 > 0) {
1133
+ var dom = vnode.dom
1134
+ while (--count0) fragment.appendChild(dom.nextSibling)
1135
+ fragment.insertBefore(dom, fragment.firstChild)
1136
+ }
1137
+ return fragment
1138
+ }
1139
+ else return vnode.dom
1140
+ }
1141
+ function getNextSibling(vnodes, i, nextSibling) {
1142
+ for (; i < vnodes.length; i++) {
1143
+ if (vnodes[i] != null && vnodes[i].dom != null) return vnodes[i].dom
1144
+ }
1145
+ return nextSibling
1146
+ }
1147
+ function insertNode(parent, dom, nextSibling) {
1148
+ if (nextSibling && nextSibling.parentNode) parent.insertBefore(dom, nextSibling)
1149
+ else parent.appendChild(dom)
1150
+ }
1151
+ function setContentEditable(vnode) {
1152
+ var children = vnode.children
1153
+ if (children != null && children.length === 1 && children[0].tag === "<") {
1154
+ var content = children[0].children
1155
+ if (vnode.dom.innerHTML !== content) vnode.dom.innerHTML = content
1156
+ }
1157
+ else if (vnode.text != null || children != null && children.length !== 0) throw new Error("Child node of a contenteditable must be trusted")
1158
+ }
1159
+ //remove
1160
+ function removeNodes(vnodes, start, end, context) {
1161
+ for (var i = start; i < end; i++) {
1162
+ var vnode = vnodes[i]
1163
+ if (vnode != null) {
1164
+ if (vnode.skip) vnode.skip = false
1165
+ else removeNode(vnode, context)
1166
+ }
1167
+ }
1168
+ }
1169
+ function removeNode(vnode, context) {
1170
+ var expected = 1, called = 0
1171
+ if (vnode.attrs && vnode.attrs.onbeforeremove) {
1172
+ var result = vnode.attrs.onbeforeremove.call(vnode.state, vnode)
1173
+ if (result != null && typeof result.then === "function") {
1174
+ expected++
1175
+ result.then(continuation, continuation)
1176
+ }
1177
+ }
1178
+ if (typeof vnode.tag !== "string" && vnode.tag.onbeforeremove) {
1179
+ var result = vnode.tag.onbeforeremove.call(vnode.state, vnode)
1180
+ if (result != null && typeof result.then === "function") {
1181
+ expected++
1182
+ result.then(continuation, continuation)
1183
+ }
1184
+ }
1185
+ continuation()
1186
+ function continuation() {
1187
+ if (++called === expected) {
1188
+ onremove(vnode)
1189
+ if (vnode.dom) {
1190
+ var count0 = vnode.domSize || 1
1191
+ if (count0 > 1) {
1192
+ var dom = vnode.dom
1193
+ while (--count0) {
1194
+ removeNodeFromDOM(dom.nextSibling)
1195
+ }
1196
+ }
1197
+ removeNodeFromDOM(vnode.dom)
1198
+ if (context != null && vnode.domSize == null && !hasIntegrationMethods(vnode.attrs) && typeof vnode.tag === "string") { //TODO test custom elements
1199
+ if (!context.pool) context.pool = [vnode]
1200
+ else context.pool.push(vnode)
1201
+ }
1202
+ }
1203
+ }
1204
+ }
1205
+ }
1206
+ function removeNodeFromDOM(node) {
1207
+ var parent = node.parentNode
1208
+ if (parent != null) parent.removeChild(node)
1209
+ }
1210
+ function onremove(vnode) {
1211
+ if (vnode.attrs && vnode.attrs.onremove) vnode.attrs.onremove.call(vnode.state, vnode)
1212
+ if (typeof vnode.tag !== "string" && vnode.tag.onremove) vnode.tag.onremove.call(vnode.state, vnode)
1213
+ if (vnode.instance != null) onremove(vnode.instance)
1214
+ else {
1215
+ var children = vnode.children
1216
+ if (Array.isArray(children)) {
1217
+ for (var i = 0; i < children.length; i++) {
1218
+ var child = children[i]
1219
+ if (child != null) onremove(child)
1220
+ }
1221
+ }
1222
+ }
1223
+ }
1224
+ //attrs2
1225
+ function setAttrs(vnode, attrs2, ns) {
1226
+ for (var key2 in attrs2) {
1227
+ setAttr(vnode, key2, null, attrs2[key2], ns)
1228
+ }
1229
+ }
1230
+ function setAttr(vnode, key2, old, value, ns) {
1231
+ var element = vnode.dom
1232
+ if (key2 === "key" || key2 === "is" || (old === value && !isFormAttribute(vnode, key2)) && typeof value !== "object" || typeof value === "undefined" || isLifecycleMethod(key2)) return
1233
+ var nsLastIndex = key2.indexOf(":")
1234
+ if (nsLastIndex > -1 && key2.substr(0, nsLastIndex) === "xlink") {
1235
+ element.setAttributeNS("http://www.w3.org/1999/xlink", key2.slice(nsLastIndex + 1), value)
1236
+ }
1237
+ else if (key2[0] === "o" && key2[1] === "n" && typeof value === "function") updateEvent(vnode, key2, value)
1238
+ else if (key2 === "style") updateStyle(element, old, value)
1239
+ else if (key2 in element && !isAttribute(key2) && ns === undefined && !isCustomElement(vnode)) {
1240
+ //setting input[value] to same value by typing on focused element moves cursor to end in Chrome
1241
+ if (vnode.tag === "input" && key2 === "value" && vnode.dom.value === value && vnode.dom === $doc.activeElement) return
1242
+ //setting select[value] to same value while having select open blinks select dropdown in Chrome
1243
+ if (vnode.tag === "select" && key2 === "value" && vnode.dom.value === value && vnode.dom === $doc.activeElement) return
1244
+ //setting option[value] to same value while having select open blinks select dropdown in Chrome
1245
+ if (vnode.tag === "option" && key2 === "value" && vnode.dom.value === value) return
1246
+ element[key2] = value
1247
+ }
1248
+ else {
1249
+ if (typeof value === "boolean") {
1250
+ if (value) element.setAttribute(key2, "")
1251
+ else element.removeAttribute(key2)
1252
+ }
1253
+ else element.setAttribute(key2 === "className" ? "class" : key2, value)
1254
+ }
1255
+ }
1256
+ function setLateAttrs(vnode) {
1257
+ var attrs2 = vnode.attrs
1258
+ if (vnode.tag === "select" && attrs2 != null) {
1259
+ if ("value" in attrs2) setAttr(vnode, "value", null, attrs2.value, undefined)
1260
+ if ("selectedIndex" in attrs2) setAttr(vnode, "selectedIndex", null, attrs2.selectedIndex, undefined)
1261
+ }
1262
+ }
1263
+ function updateAttrs(vnode, old, attrs2, ns) {
1264
+ if (attrs2 != null) {
1265
+ for (var key2 in attrs2) {
1266
+ setAttr(vnode, key2, old && old[key2], attrs2[key2], ns)
1267
+ }
1268
+ }
1269
+ if (old != null) {
1270
+ for (var key2 in old) {
1271
+ if (attrs2 == null || !(key2 in attrs2)) {
1272
+ if (key2 === "className") key2 = "class"
1273
+ if (key2[0] === "o" && key2[1] === "n" && !isLifecycleMethod(key2)) updateEvent(vnode, key2, undefined)
1274
+ else if (key2 !== "key") vnode.dom.removeAttribute(key2)
1275
+ }
1276
+ }
1277
+ }
1278
+ }
1279
+ function isFormAttribute(vnode, attr) {
1280
+ return attr === "value" || attr === "checked" || attr === "selectedIndex" || attr === "selected" && vnode.dom === $doc.activeElement
1281
+ }
1282
+ function isLifecycleMethod(attr) {
1283
+ return attr === "oninit" || attr === "oncreate" || attr === "onupdate" || attr === "onremove" || attr === "onbeforeremove" || attr === "onbeforeupdate"
1284
+ }
1285
+ function isAttribute(attr) {
1286
+ return attr === "href" || attr === "list" || attr === "form" || attr === "width" || attr === "height"// || attr === "type"
1287
+ }
1288
+ function isCustomElement(vnode){
1289
+ return vnode.attrs.is || vnode.tag.indexOf("-") > -1
1290
+ }
1291
+ function hasIntegrationMethods(source) {
1292
+ return source != null && (source.oncreate || source.onupdate || source.onbeforeremove || source.onremove)
1293
+ }
1294
+ //style
1295
+ function updateStyle(element, old, style) {
1296
+ if (old === style) element.style.cssText = "", old = null
1297
+ if (style == null) element.style.cssText = ""
1298
+ else if (typeof style === "string") element.style.cssText = style
1299
+ else {
1300
+ if (typeof old === "string") element.style.cssText = ""
1301
+ for (var key2 in style) {
1302
+ element.style[key2] = style[key2]
1303
+ }
1304
+ if (old != null && typeof old !== "string") {
1305
+ for (var key2 in old) {
1306
+ if (!(key2 in style)) element.style[key2] = ""
1307
+ }
1308
+ }
1309
+ }
1310
+ }
1311
+ //event
1312
+ function updateEvent(vnode, key2, value) {
1313
+ var element = vnode.dom
1314
+ var callback = typeof onevent !== "function" ? value : function(e) {
1315
+ var result = value.call(element, e)
1316
+ onevent.call(element, e)
1317
+ return result
1318
+ }
1319
+ if (key2 in element) element[key2] = typeof value === "function" ? callback : null
1320
+ else {
1321
+ var eventName = key2.slice(2)
1322
+ if (vnode.events === undefined) vnode.events = {}
1323
+ if (vnode.events[key2] === callback) return
1324
+ if (vnode.events[key2] != null) element.removeEventListener(eventName, vnode.events[key2], false)
1325
+ if (typeof value === "function") {
1326
+ vnode.events[key2] = callback
1327
+ element.addEventListener(eventName, vnode.events[key2], false)
1328
+ }
1329
+ }
1330
+ }
1331
+ //lifecycle
1332
+ function initLifecycle(source, vnode, hooks) {
1333
+ if (typeof source.oninit === "function") source.oninit.call(vnode.state, vnode)
1334
+ if (typeof source.oncreate === "function") hooks.push(source.oncreate.bind(vnode.state, vnode))
1335
+ }
1336
+ function updateLifecycle(source, vnode, hooks, recycling) {
1337
+ if (recycling) initLifecycle(source, vnode, hooks)
1338
+ else if (typeof source.onupdate === "function") hooks.push(source.onupdate.bind(vnode.state, vnode))
1339
+ }
1340
+ function shouldUpdate(vnode, old) {
1341
+ var forceVnodeUpdate, forceComponentUpdate
1342
+ if (vnode.attrs != null && typeof vnode.attrs.onbeforeupdate === "function") forceVnodeUpdate = vnode.attrs.onbeforeupdate.call(vnode.state, vnode, old)
1343
+ if (typeof vnode.tag !== "string" && typeof vnode.tag.onbeforeupdate === "function") forceComponentUpdate = vnode.tag.onbeforeupdate.call(vnode.state, vnode, old)
1344
+ if (!(forceVnodeUpdate === undefined && forceComponentUpdate === undefined) && !forceVnodeUpdate && !forceComponentUpdate) {
1345
+ vnode.dom = old.dom
1346
+ vnode.domSize = old.domSize
1347
+ vnode.instance = old.instance
1348
+ return true
1349
+ }
1350
+ return false
1351
+ }
1352
+ function render(dom, vnodes) {
1353
+ if (!dom) throw new Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.")
1354
+ var hooks = []
1355
+ var active = $doc.activeElement
1356
+ // First time0 rendering into a node clears it out
1357
+ if (dom.vnodes == null) dom.textContent = ""
1358
+ if (!Array.isArray(vnodes)) vnodes = [vnodes]
1359
+ updateNodes(dom, dom.vnodes, Vnode.normalizeChildren(vnodes), false, hooks, null, undefined)
1360
+ dom.vnodes = vnodes
1361
+ for (var i = 0; i < hooks.length; i++) hooks[i]()
1362
+ if ($doc.activeElement !== active) active.focus()
1363
+ }
1364
+ return {render: render, setEventCallback: setEventCallback}
1365
+ }
1366
+ function throttle(callback) {
1367
+ //60fps translates to 16.6ms, round it down since setTimeout requires int
1368
+ var time = 16
1369
+ var last = 0, pending = null
1370
+ var timeout = typeof requestAnimationFrame === "function" ? requestAnimationFrame : setTimeout
1371
+ return function() {
1372
+ var now = Date.now()
1373
+ if (last === 0 || now - last >= time) {
1374
+ last = now
1375
+ callback()
1376
+ }
1377
+ else if (pending === null) {
1378
+ pending = timeout(function() {
1379
+ pending = null
1380
+ callback()
1381
+ last = Date.now()
1382
+ }, time - (now - last))
1383
+ }
1384
+ }
1385
+ }
1386
+ var _11 = function($window) {
1387
+ var renderService = coreRenderer($window)
1388
+ renderService.setEventCallback(function(e) {
1389
+ if (e.redraw !== false) redraw()
1390
+ })
1391
+ var callbacks = []
1392
+ function subscribe(key1, callback) {
1393
+ unsubscribe(key1)
1394
+ callbacks.push(key1, throttle(callback))
1395
+ }
1396
+ function unsubscribe(key1) {
1397
+ var index = callbacks.indexOf(key1)
1398
+ if (index > -1) callbacks.splice(index, 2)
1399
+ }
1400
+ function redraw() {
1401
+ for (var i = 1; i < callbacks.length; i += 2) {
1402
+ callbacks[i]()
1403
+ }
1404
+ }
1405
+ return {subscribe: subscribe, unsubscribe: unsubscribe, redraw: redraw, render: renderService.render}
1406
+ }
1407
+ var redrawService = _11(window)
1408
+ requestService.setCompletionCallback(redrawService.redraw)
1409
+ var _16 = function(redrawService0) {
1410
+ return function(root, component) {
1411
+ if (component === null) {
1412
+ redrawService0.render(root, [])
1413
+ redrawService0.unsubscribe(root)
1414
+ return
1415
+ }
1416
+
1417
+ if (component.view == null) throw new Error("m.mount(element, component) expects a component, not a vnode")
1418
+
1419
+ var run0 = function() {
1420
+ redrawService0.render(root, Vnode(component))
1421
+ }
1422
+ redrawService0.subscribe(root, run0)
1423
+ redrawService0.redraw()
1424
+ }
1425
+ }
1426
+ m.mount = _16(redrawService)
1427
+ var Promise = PromisePolyfill
1428
+ var parseQueryString = function(string) {
1429
+ if (string === "" || string == null) return {}
1430
+ if (string.charAt(0) === "?") string = string.slice(1)
1431
+ var entries = string.split("&"), data0 = {}, counters = {}
1432
+ for (var i = 0; i < entries.length; i++) {
1433
+ var entry = entries[i].split("=")
1434
+ var key5 = decodeURIComponent(entry[0])
1435
+ var value = entry.length === 2 ? decodeURIComponent(entry[1]) : ""
1436
+ if (value === "true") value = true
1437
+ else if (value === "false") value = false
1438
+ var levels = key5.split(/\]\[?|\[/)
1439
+ var cursor = data0
1440
+ if (key5.indexOf("[") > -1) levels.pop()
1441
+ for (var j = 0; j < levels.length; j++) {
1442
+ var level = levels[j], nextLevel = levels[j + 1]
1443
+ var isNumber = nextLevel == "" || !isNaN(parseInt(nextLevel, 10))
1444
+ var isValue = j === levels.length - 1
1445
+ if (level === "") {
1446
+ var key5 = levels.slice(0, j).join()
1447
+ if (counters[key5] == null) counters[key5] = 0
1448
+ level = counters[key5]++
1449
+ }
1450
+ if (cursor[level] == null) {
1451
+ cursor[level] = isValue ? value : isNumber ? [] : {}
1452
+ }
1453
+ cursor = cursor[level]
1454
+ }
1455
+ }
1456
+ return data0
1457
+ }
1458
+ var coreRouter = function($window) {
1459
+ var supportsPushState = typeof $window.history.pushState === "function"
1460
+ var callAsync0 = typeof setImmediate === "function" ? setImmediate : setTimeout
1461
+ function normalize1(fragment0) {
1462
+ var data = $window.location[fragment0].replace(/(?:%[a-f89][a-f0-9])+/gim, decodeURIComponent)
1463
+ if (fragment0 === "pathname" && data[0] !== "/") data = "/" + data
1464
+ return data
1465
+ }
1466
+ var asyncId
1467
+ function debounceAsync(callback0) {
1468
+ return function() {
1469
+ if (asyncId != null) return
1470
+ asyncId = callAsync0(function() {
1471
+ asyncId = null
1472
+ callback0()
1473
+ })
1474
+ }
1475
+ }
1476
+ function parsePath(path, queryData, hashData) {
1477
+ var queryIndex = path.indexOf("?")
1478
+ var hashIndex = path.indexOf("#")
1479
+ var pathEnd = queryIndex > -1 ? queryIndex : hashIndex > -1 ? hashIndex : path.length
1480
+ if (queryIndex > -1) {
1481
+ var queryEnd = hashIndex > -1 ? hashIndex : path.length
1482
+ var queryParams = parseQueryString(path.slice(queryIndex + 1, queryEnd))
1483
+ for (var key4 in queryParams) queryData[key4] = queryParams[key4]
1484
+ }
1485
+ if (hashIndex > -1) {
1486
+ var hashParams = parseQueryString(path.slice(hashIndex + 1))
1487
+ for (var key4 in hashParams) hashData[key4] = hashParams[key4]
1488
+ }
1489
+ return path.slice(0, pathEnd)
1490
+ }
1491
+ var router = {prefix: "#!"}
1492
+ router.getPath = function() {
1493
+ var type2 = router.prefix.charAt(0)
1494
+ switch (type2) {
1495
+ case "#": return normalize1("hash").slice(router.prefix.length)
1496
+ case "?": return normalize1("search").slice(router.prefix.length) + normalize1("hash")
1497
+ default: return normalize1("pathname").slice(router.prefix.length) + normalize1("search") + normalize1("hash")
1498
+ }
1499
+ }
1500
+ router.setPath = function(path, data, options) {
1501
+ var queryData = {}, hashData = {}
1502
+ path = parsePath(path, queryData, hashData)
1503
+ if (data != null) {
1504
+ for (var key4 in data) queryData[key4] = data[key4]
1505
+ path = path.replace(/:([^\/]+)/g, function(match2, token) {
1506
+ delete queryData[token]
1507
+ return data[token]
1508
+ })
1509
+ }
1510
+ var query = buildQueryString(queryData)
1511
+ if (query) path += "?" + query
1512
+ var hash = buildQueryString(hashData)
1513
+ if (hash) path += "#" + hash
1514
+ if (supportsPushState) {
1515
+ var state = options ? options.state : null
1516
+ var title = options ? options.title : null
1517
+ $window.onpopstate()
1518
+ if (options && options.replace) $window.history.replaceState(state, title, router.prefix + path)
1519
+ else $window.history.pushState(state, title, router.prefix + path)
1520
+ }
1521
+ else $window.location.href = router.prefix + path
1522
+ }
1523
+ router.defineRoutes = function(routes, resolve, reject) {
1524
+ function resolveRoute() {
1525
+ var path = router.getPath()
1526
+ var params = {}
1527
+ var pathname = parsePath(path, params, params)
1528
+ var state = $window.history.state
1529
+ if (state != null) {
1530
+ for (var k in state) params[k] = state[k]
1531
+ }
1532
+ for (var route0 in routes) {
1533
+ var matcher = new RegExp("^" + route0.replace(/:[^\/]+?\.{3}/g, "(.*?)").replace(/:[^\/]+/g, "([^\\/]+)") + "\/?$")
1534
+ if (matcher.test(pathname)) {
1535
+ pathname.replace(matcher, function() {
1536
+ var keys = route0.match(/:[^\/]+/g) || []
1537
+ var values = [].slice.call(arguments, 1, -2)
1538
+ for (var i = 0; i < keys.length; i++) {
1539
+ params[keys[i].replace(/:|\./g, "")] = decodeURIComponent(values[i])
1540
+ }
1541
+ resolve(routes[route0], params, path, route0)
1542
+ })
1543
+ return
1544
+ }
1545
+ }
1546
+ reject(path, params)
1547
+ }
1548
+ if (supportsPushState) $window.onpopstate = debounceAsync(resolveRoute)
1549
+ else if (router.prefix.charAt(0) === "#") $window.onhashchange = resolveRoute
1550
+ resolveRoute()
1551
+ }
1552
+ return router
1553
+ }
1554
+ var _20 = function($window, redrawService0) {
1555
+ var routeService = coreRouter($window)
1556
+ var identity = function(v) {return v}
1557
+ var render1, component, attrs3, currentPath, lastUpdate
1558
+ var route = function(root, defaultRoute, routes) {
1559
+ if (root == null) throw new Error("Ensure the DOM element that was passed to `m.route` is not undefined")
1560
+ var run1 = function() {
1561
+ if (render1 != null) redrawService0.render(root, render1(Vnode(component, attrs3.key, attrs3)))
1562
+ }
1563
+ var bail = function(path) {
1564
+ if (path !== defaultRoute) routeService.setPath(defaultRoute, null, {replace: true})
1565
+ else throw new Error("Could not resolve default route " + defaultRoute)
1566
+ }
1567
+ routeService.defineRoutes(routes, function(payload, params, path) {
1568
+ var update = lastUpdate = function(routeResolver, comp) {
1569
+ if (update !== lastUpdate) return
1570
+ component = comp != null && typeof comp.view === "function" ? comp : "div", attrs3 = params, currentPath = path, lastUpdate = null
1571
+ render1 = (routeResolver.render || identity).bind(routeResolver)
1572
+ run1()
1573
+ }
1574
+ if (payload.view) update({}, payload)
1575
+ else {
1576
+ if (payload.onmatch) {
1577
+ Promise.resolve(payload.onmatch(params, path)).then(function(resolved) {
1578
+ update(payload, resolved)
1579
+ }, bail)
1580
+ }
1581
+ else update(payload, "div")
1582
+ }
1583
+ }, bail)
1584
+ redrawService0.subscribe(root, run1)
1585
+ }
1586
+ route.set = function(path, data, options) {
1587
+ if (lastUpdate != null) options = {replace: true}
1588
+ lastUpdate = null
1589
+ routeService.setPath(path, data, options)
1590
+ }
1591
+ route.get = function() {return currentPath}
1592
+ route.prefix = function(prefix0) {routeService.prefix = prefix0}
1593
+ route.link = function(vnode1) {
1594
+ vnode1.dom.setAttribute("href", routeService.prefix + vnode1.attrs.href)
1595
+ vnode1.dom.onclick = function(e) {
1596
+ if (e.ctrlKey || e.metaKey || e.shiftKey || e.which === 2) return
1597
+ e.preventDefault()
1598
+ e.redraw = false
1599
+ var href = this.getAttribute("href")
1600
+ if (href.indexOf(routeService.prefix) === 0) href = href.slice(routeService.prefix.length)
1601
+ route.set(href, undefined, undefined)
1602
+ }
1603
+ }
1604
+ route.param = function(key3) {
1605
+ if(typeof attrs3 !== "undefined" && typeof key3 !== "undefined") return attrs3[key3]
1606
+ return attrs3
1607
+ }
1608
+ return route
1609
+ }
1610
+ m.route = _20(window, redrawService)
1611
+ m.withAttr = function(attrName, callback1, context) {
1612
+ return function(e) {
1613
+ callback1.call(context || this, attrName in e.currentTarget ? e.currentTarget[attrName] : e.currentTarget.getAttribute(attrName))
1614
+ }
1615
+ }
1616
+ var _28 = coreRenderer(window)
1617
+ m.render = _28.render
1618
+ m.redraw = redrawService.redraw
1619
+ m.request = requestService.request
1620
+ m.jsonp = requestService.jsonp
1621
+ m.parseQueryString = parseQueryString
1622
+ m.buildQueryString = buildQueryString
1623
+ m.version = "1.0.1"
1624
+ m.vnode = Vnode
1625
+ if (typeof module !== "undefined") module["exports"] = m
1626
+ else window.m = m
1627
+ }
1628
+ }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
1629
  },{}],8:[function(require,module,exports){
1630
  /*!
1631
+ * EventEmitter v5.1.0 - git.io/ee
1632
  * Unlicense - http://unlicense.org/
1633
  * Oliver Caldwell - http://oli.me.uk/
1634
  * @preserve
1635
  */
1636
 
1637
+ ;(function (exports) {
1638
  'use strict';
1639
 
1640
  /**
1647
 
1648
  // Shortcuts to improve speed and size
1649
  var proto = EventEmitter.prototype;
 
1650
  var originalGlobalValue = exports.EventEmitter;
1651
 
1652
  /**
1747
  return response || listeners;
1748
  };
1749
 
1750
+ function isValidListener (listener) {
1751
+ if (typeof listener === 'function' || listener instanceof RegExp) {
1752
+ return true
1753
+ } else if (listener && typeof listener === 'object') {
1754
+ return isValidListener(listener.listener)
1755
+ } else {
1756
+ return false
1757
+ }
1758
+ }
1759
+
1760
  /**
1761
  * Adds a listener function to the specified event.
1762
  * The listener will not be added if it is a duplicate.
1768
  * @return {Object} Current instance of EventEmitter for chaining.
1769
  */
1770
  proto.addListener = function addListener(evt, listener) {
1771
+ if (!isValidListener(listener)) {
1772
+ throw new TypeError('listener must be a function');
1773
+ }
1774
+
1775
  var listeners = this.getListenersAsObject(evt);
1776
  var listenerIsWrapped = typeof listener === 'object';
1777
  var key;
2010
  for (key in listenersMap) {
2011
  if (listenersMap.hasOwnProperty(key)) {
2012
  listeners = listenersMap[key].slice(0);
 
2013
 
2014
+ for (i = 0; i < listeners.length; i++) {
2015
  // If the listener returns true then it shall be removed from the event
2016
  // The function is executed either with a basic call or an apply if there is an args array
2017
  listener = listeners[i];
2112
  else {
2113
  exports.EventEmitter = EventEmitter;
2114
  }
2115
+ }(this || {}));
2116
 
2117
  },{}]},{},[1]);
2118
  })();
assets/js/admin.min.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(){var e=void 0,t=void 0;!function n(t,r,o){function i(u,l){if(!r[u]){if(!t[u]){var s="function"==typeof e&&e;if(!l&&s)return s(u,!0);if(a)return a(u,!0);var c=new Error("Cannot find module '"+u+"'");throw c.code="MODULE_NOT_FOUND",c}var f=r[u]={exports:{}};t[u][0].call(f.exports,function(e){var n=t[u][1][e];return i(n?n:e)},f,f.exports,n,t,r,o)}return r[u].exports}for(var a="function"==typeof e&&e,u=0;u<o.length;u++)i(o[u]);return i}({1:[function(e,t,n){"use strict";var r=window.m=e("mithril"),o=e("wolfy87-eventemitter"),i=document.getElementById("mc4wp-admin"),a=new o,u=e("./admin/tabs.js")(i),l=e("./admin/helpers.js"),s=e("./admin/settings.js")(i,l,a),c=e("./admin/list-fetcher.js"),f=document.getElementById("mc4wp-list-fetcher");f&&r.mount(f,new c),window.mc4wp=window.mc4wp||{},window.mc4wp.deps=window.mc4wp.deps||{},window.mc4wp.deps.mithril=r,window.mc4wp.helpers=l,window.mc4wp.events=a,window.mc4wp.settings=s,window.mc4wp.tabs=u},{"./admin/helpers.js":2,"./admin/list-fetcher.js":3,"./admin/settings.js":4,"./admin/tabs.js":5,mithril:7,"wolfy87-eventemitter":8}],2:[function(e,t,n){"use strict";var r={};r.toggleElement=function(e){for(var t=document.querySelectorAll(e),n=0;n<t.length;n++){var r=t[n].clientHeight<=0;t[n].style.display=r?"":"none"}},r.bindEventToElement=function(e,t,n){e.addEventListener?e.addEventListener(t,n):e.attachEvent&&e.attachEvent("on"+t,n)},r.bindEventToElements=function(e,t,n){Array.prototype.forEach.call(e,function(e){r.bindEventToElement(e,t,n)})},r.debounce=function(e,t,n){var r;return function(){var o=this,i=arguments,a=function(){r=null,n||e.apply(o,i)},u=n&&!r;clearTimeout(r),r=setTimeout(a,t),u&&e.apply(o,i)}},function(){var e=document.querySelectorAll("[data-showif]");Array.prototype.forEach.call(e,function(e){function t(){if("radio"!==this.getAttribute("type")||this.checked){var t="checkbox"===this.getAttribute("type")?this.checked:this.value,r=t==n.value;a?(e.style.display=r?"":"none",e.style.visibility=r?"":"hidden"):e.style.opacity=r?"":"0.4",Array.prototype.forEach.call(i,function(e){r?e.removeAttribute("readonly"):e.setAttribute("readonly","readonly")})}}var n=JSON.parse(e.getAttribute("data-showif")),o=document.querySelectorAll('[name="'+n.element+'"]'),i=e.querySelectorAll("input,select,textarea:not([readonly])"),a=void 0===n.hide||n.hide;Array.prototype.forEach.call(o,function(e){t.call(e)}),r.bindEventToElements(o,"change",t)})}(),t.exports=r},{}],3:[function(e,t,n){"use strict";function r(){this.working=!1,this.done=!1,i.mailchimp.api_connected&&0==i.mailchimp.lists.length&&this.fetch()}var o=window.jQuery,i=mc4wp_vars,a=i.i18n;r.prototype.fetch=function(e){e&&e.preventDefault(),this.working=!0,this.done=!1,o.post(ajaxurl,{action:"mc4wp_renew_mailchimp_lists"}).done(function(e){e&&window.setTimeout(function(){window.location.reload()},3e3)}).always(function(e){this.working=!1,this.done=!0,m.redraw()}.bind(this))},r.prototype.view=function(){return m("form",{method:"POST",onsubmit:this.fetch.bind(this)},[m("p",[m("input",{type:"submit",value:this.working?a.fetching_mailchimp_lists:a.renew_mailchimp_lists,className:"button",disabled:!!this.working}),m.trust(" &nbsp; "),this.working?[m("span.mc4wp-loader","Loading..."),m.trust(" &nbsp; "),m("em.help",a.fetching_mailchimp_lists_can_take_a_while)]:"",this.done?[m("em.help.green",a.fetching_mailchimp_lists_done)]:""])])},t.exports=r},{}],4:[function(e,t,n){var r=function(e,t,n){"use strict";function r(e,t){return s.filter(function(n){return n[e]===t})}function o(){return s}function i(){return s=[],Array.prototype.forEach.call(u,function(e){("boolean"!=typeof e.checked||e.checked)&&"object"==typeof l[e.value]&&s.push(l[e.value])}),n.trigger("selectedLists.change",[s]),s}function a(){var e=document.querySelectorAll(".lists--only-selected > *");Array.prototype.forEach.call(e,function(e){var t=e.getAttribute("data-list-id"),n=r("id",t).length>0;n?e.setAttribute("class",e.getAttribute("class").replace("hidden","")):e.setAttribute("class",e.getAttribute("class")+" hidden")})}var u=(e.querySelector("form"),e.querySelectorAll(".mc4wp-list-input")),l=mc4wp_vars.mailchimp.lists,s=[];return n.on("selectedLists.change",a),t.bindEventToElements(u,"change",i),i(),{getSelectedLists:o}};t.exports=r},{}],5:[function(e,t,n){"use strict";var r=e("./url.js"),o=function(e){function t(e){for(var t=0;t<d.length;t++)if(d[t].id===e)return d[t]}function n(e,n){if("string"==typeof e&&(e=t(e)),!e)return!1;void 0==n&&(n=!0),s.removeClass("tab-active").css("display","none"),c.removeClass("nav-tab-active"),Array.prototype.forEach.call(e.nav,function(e){e.className+=" nav-tab-active",e.blur()}),e.element.style.display="block",e.element.className+=" tab-active";var i=r.setParameter(window.location.href,"tab",e.id);return history.pushState&&n&&history.pushState(e.id,"",i),o(e),f.value=i,"function"==typeof tb_remove&&tb_remove(),"fields"===e.id&&window.mc4wp&&window.mc4wp.forms&&window.mc4wp.forms.editor&&mc4wp.forms.editor.refresh(),!0}function o(e){var t=document.title.split("-");document.title=document.title.replace(t[0],e.title+" ")}function i(e){e=e||window.event;var t=this.getAttribute("data-tab");if(!t){var o=this.className.match(/nav-tab-(\w+)?/);o&&(t=o[1])}if(!t){var i=r.parse(this.href);if(!i.tab)return;t=i.tab}var a=n(t);return!a||(e.preventDefault(),e.returnValue=!1,!1)}function a(){if(history.pushState){var e=s.filter(":visible").get(0);if(e){var n=t(e.id.substring(4));n&&(history.replaceState&&null===history.state&&history.replaceState(n.id,""),o(n))}}}var u=window.jQuery,l=u(e),s=l.find(".tab"),c=l.find(".nav-tab"),f=e.querySelector('input[name="_wp_http_referer"]'),d=[];return u.each(s,function(t,r){var o=r.id.substring(4),i=u(r).find("h2").first().text();d.push({id:o,title:i,element:r,nav:e.querySelectorAll(".nav-tab-"+o),open:function(){return n(o)}})}),c.click(i),u(document.body).on("click",".tab-link",i),a(),window.addEventListener&&history.pushState&&window.addEventListener("popstate",function(e){if(!e.state)return!0;var t=e.state;return n(t,!1)}),{open:n,get:t}};t.exports=o},{"./url.js":6}],6:[function(e,t,n){"use strict";var r={parse:function(e){var t={},n=e.split("&");for(var r in n)if(n.hasOwnProperty(r)){var o=n[r].split("=");t[decodeURIComponent(o[0])]=decodeURIComponent(o[1])}return t},build:function(e){var t=[];for(var n in e)t.push(n+"="+encodeURIComponent(e[n]));return t.join("&")},setParameter:function(e,t,n){var o=r.parse(e);return o[t]=n,r.build(o)}};t.exports=r},{}],7:[function(e,n,r){!function(e,r){"use strict";var o=r(e);"object"==typeof n&&null!=n&&n.exports?n.exports=o:"function"==typeof t&&t.amd?t(function(){return o}):e.m=o}("undefined"!=typeof window?window:this,function(e,t){"use strict";function n(e){return"function"==typeof e}function r(e){return"[object Object]"===Le.call(e)}function o(e){return"[object String]"===Le.call(e)}function i(){}function a(e){Ae=e.document,Ce=e.location,ke=e.cancelAnimationFrame||e.clearTimeout,Oe=e.requestAnimationFrame||e.setTimeout}function u(e,t){for(var n,r=[],o=/(?:(^|#|\.)([^#\.\[\]]+))|(\[.+?\])/g;n=o.exec(t);)if(""===n[1]&&n[2])e.tag=n[2];else if("#"===n[1])e.attrs.id=n[2];else if("."===n[1])r.push(n[2]);else if("["===n[3][0]){var i=/\[(.+?)(?:=("|'|)(.*?)\2)?\]/.exec(n[3]);e.attrs[i[1]]=i[3]||""}return r}function l(e,t){var n=t?e.slice(1):e;return 1===n.length&&Ne(n[0])?n[0]:n}function s(e,t,n){var r="class"in t?"class":"className";for(var o in t)je.call(t,o)&&(o===r&&null!=t[o]&&""!==t[o]?(n.push(t[o]),e[o]=""):e[o]=t[o]);n.length&&(e[r]=n.join(" "))}function c(e,t){for(var n=[],i=1,a=arguments.length;i<a;i++)n[i-1]=arguments[i];if(r(e))return re(e,n);if(!o(e))throw new Error("selector in m(selector, attrs, children) should be a string");var c=null!=t&&r(t)&&!("tag"in t||"view"in t||"subtree"in t),f=c?t:{},d={tag:"div",attrs:{},children:l(n,c)};return s(d.attrs,f,u(d,e)),d}function f(e,t){for(var n=0;n<e.length&&!t(e[n],n++););}function d(e,t){f(e,function(e,n){return(e=e&&e.attrs)&&null!=e.key&&t(e,n)})}function h(e){try{if(null!=e&&null!=e.toString())return e}catch(t){}return""}function p(e,t,n,r){try{m(e,t,n),t.nodeValue=r}catch(o){}}function v(e){for(var t=0;t<e.length;t++)Ne(e[t])&&(e=e.concat.apply([],e),t--);return e}function m(e,t,n){e.insertBefore(t,e.childNodes[n]||null)}function g(e,t,n,r){d(e,function(e,r){t[e=e.key]=t[e]?{action:Re,index:r,from:t[e].index,element:n.nodes[t[e].index]||Ae.createElement("div")}:{action:_e,index:r}});var o=[];for(var i in t)je.call(t,i)&&o.push(t[i]);var a=o.sort(H),u=new Array(n.length);return u.nodes=n.nodes.slice(),f(a,function(t){var o=t.index;if(t.action===Te&&(G(n[o].nodes,n[o]),u.splice(o,1)),t.action===_e){var i=Ae.createElement("div");i.key=e[o].attrs.key,m(r,i,o),u.splice(o,0,{attrs:{key:e[o].attrs.key},nodes:[i]}),u.nodes[o]=i}if(t.action===Re){var a=t.element,l=r.childNodes[o];l!==a&&null!==a&&r.insertBefore(a,l||null),u[o]=n[t.from],u.nodes[o]=a}}),u}function y(e,t,n,r){var o=e.length!==t.length;return o||d(e,function(e,n){var r=t[n];return o=r&&r.attrs&&r.attrs.key!==e.key}),o?g(e,n,t,r):t}function w(e,t,n){f(e,function(e,r){null!=t[r]&&n.push.apply(n,t[r].nodes)}),f(t.nodes,function(e,r){null!=e.parentNode&&n.indexOf(e)<0&&G([e],[t[r]])}),e.length<t.length&&(t.length=e.length),t.nodes=n}function b(e){var t=0;d(e,function(){return f(e,function(e){(e=e&&e.attrs)&&null==e.key&&(e.key="__mithril__"+t++)}),1})}function E(e,t,n){return e.tag!==t.tag||(n.sort().join()!==Object.keys(t.attrs).sort().join()||(e.attrs.id!==t.attrs.id||(e.attrs.key!==t.attrs.key||("all"===c.redraw.strategy()?!t.configContext||t.configContext.retain!==!0:"diff"===c.redraw.strategy()&&(t.configContext&&t.configContext.retain===!1)))))}function x(e,t,r){E(e,t,r)&&(t.nodes.length&&G(t.nodes),t.configContext&&n(t.configContext.onunload)&&t.configContext.onunload(),t.controllers&&f(t.controllers,function(e){e.onunload&&e.onunload({preventDefault:i})}))}function A(e,t){return e.attrs.xmlns?e.attrs.xmlns:"svg"===e.tag?"http://www.w3.org/2000/svg":"math"===e.tag?"http://www.w3.org/1998/Math/MathML":t}function C(e,t,n){n.length&&(e.views=t,e.controllers=n,f(n,function(e){if(e.onunload&&e.onunload.$old&&(e.onunload=e.onunload.$old),Me&&e.onunload){var t=e.onunload;e.onunload=i,e.onunload.$old=t}}))}function O(e,t,r,o,i){if(n(t.attrs.config)){var a=i.configContext=i.configContext||{};e.push(function(){return t.attrs.config.call(t,r,!o,a,i)})}}function k(e,n,r,o,i,a,u,l){var s=e.nodes[0];return o&&F(s,n.tag,n.attrs,e.attrs,i),e.children=B(s,n.tag,t,t,n.children,e.children,!1,0,n.attrs.contenteditable?s:r,i,u),e.nodes.intact=!0,l.length&&(e.views=a,e.controllers=l),s}function j(e,t,n){var r;e.$trusted?r=Z(t,n,e):(r=[Ae.createTextNode(e)],t.nodeName in Se||m(t,r[0],n));var o;return o="string"==typeof e||"number"==typeof e||"boolean"==typeof e?new e.constructor(e):e,o.nodes=r,o}function L(e,t,n,r,o,i){var a=t.nodes;return r&&r===Ae.activeElement||(e.$trusted?(G(a,t),a=Z(n,o,e)):"textarea"===i?n.value=e:r?r.innerHTML=e:((1===a[0].nodeType||a.length>1||a[0].nodeValue.trim&&!a[0].nodeValue.trim())&&(G(t.nodes,t),a=[Ae.createTextNode(e)]),p(n,a[0],o,e))),t=new e.constructor(e),t.nodes=a,t}function N(e,t,n,r,o,i,a){return e.nodes.length?e.valueOf()!==t.valueOf()||o?L(t,e,r,i,n,a):(e.nodes.intact=!0,e):j(t,r,n)}function S(e){if(e.$trusted){var t=e.match(/<[^\/]|\>\s*[^<]/g);if(null!=t)return t.length}else if(Ne(e))return e.length;return 1}function T(e,n,r,o,i,a,u,l,s){e=v(e);var c=[],f=n.length===e.length,h=0,p={},m=!1;d(n,function(e,t){m=!0,p[n[t].attrs.key]={action:Te,index:t}}),b(e),m&&(n=y(e,n,p,r));for(var g=0,E=0,x=e.length;E<x;E++){var A=B(r,i,n,o,e[E],n[g],a,o+h||h,u,l,s);A!==t&&(f=f&&A.nodes.intact,h+=S(A),n[g++]=A)}return f||w(e,n,c),n}function _(e,t,n,r,o){if(null!=t){if(Le.call(t)===Le.call(e))return t;if(o&&o.nodes){var i=n-r,a=i+(Ne(e)?e:t.nodes).length;G(o.nodes.slice(i,a),o.slice(i,a))}else t.nodes&&G(t.nodes,t)}return t=new e.constructor,t.tag&&(t={}),t.nodes=[],t}function R(e,t){return e.attrs.is?null==t?Ae.createElement(e.tag,e.attrs.is):Ae.createElementNS(t,e.tag,e.attrs.is):null==t?Ae.createElement(e.tag):Ae.createElementNS(t,e.tag)}function M(e,t,n,r){return r?F(t,e.tag,e.attrs,{},n):e.attrs}function q(e,n,r,o,i,a){return null!=e.children&&e.children.length>0?B(n,e.tag,t,t,e.children,r.children,!0,0,e.attrs.contenteditable?n:o,i,a):e.children}function D(e,t,n,r,o,i,a){var u={tag:e.tag,attrs:t,children:n,nodes:[r]};return C(u,i,a),u.children&&!u.children.nodes&&(u.children.nodes=[]),"select"===e.tag&&"value"in e.attrs&&F(r,e.tag,{value:e.attrs.value},{},o),u}function I(e,t,r,o){var i;return i="diff"===c.redraw.strategy()&&e?e.indexOf(t):-1,i>-1?r[i]:n(o)?new o:{}}function P(e,t,n,r){null!=r.onunload&&De.map(function(e){return e.handler}).indexOf(r.onunload)<0&&De.push({controller:r,handler:r.onunload}),e.push(n),t.push(r)}function U(e,t,n,r,o,i){var a=I(n.views,t,r,e.controller),u=e&&e.attrs&&e.attrs.key;return e=0===Me||Ie||r&&r.indexOf(a)>-1?e.view(a):{tag:"placeholder"},"retain"===e.subtree?e:(e.attrs=e.attrs||{},e.attrs.key=u,P(i,o,t,a),e)}function V(e,t,n,r){for(var o=t&&t.controllers;null!=e.view;)e=U(e,e.view.$original||e.view,t,o,r,n);return e}function z(e,t,n,r,i,a,u,l){var s=[],c=[];if(e=V(e,t,s,c),"retain"===e.subtree)return t;if(!e.tag&&c.length)throw new Error("Component template must return a virtual element, not an array, string, etc.");e.attrs=e.attrs||{},t.attrs=t.attrs||{};var f=Object.keys(e.attrs),d=f.length>("key"in e.attrs?1:0);if(x(e,t,f),o(e.tag)){var h=0===t.nodes.length;u=A(e,u);var p;if(h){p=R(e,u);var v=M(e,p,u,d);m(r,p,i);var g=q(e,p,t,n,u,l);t=D(e,v,g,p,u,s,c)}else p=k(t,e,n,d,u,s,l,c);return h||a!==!0||null==p||m(r,p,i),O(l,e,p,h,t),t}}function B(e,t,o,i,a,u,l,s,c,f,d){return a=h(a),"retain"===a.subtree?u:(u=_(a,u,s,i,o),Ne(a)?T(a,u,e,s,t,l,c,f,d):null!=a&&r(a)?z(a,u,c,e,s,l,f,d):n(a)?u:N(u,a,s,e,l,c,t))}function H(e,t){return e.action-t.action||e.index-t.index}function $(e,t,n){for(var r in t)je.call(t,r)&&(null!=n&&n[r]===t[r]||(e.style[r]=t[r]));for(r in n)je.call(n,r)&&(je.call(t,r)||(e.style[r]=""))}function J(e,t,o,i,a,u){if("config"===t||"key"===t)return!0;if(n(o)&&"on"===t.slice(0,2))e[t]=ee(o,e);else if("style"===t&&null!=o&&r(o))$(e,o,i);else if(null!=u)"href"===t?e.setAttributeNS("http://www.w3.org/1999/xlink","href",o):e.setAttribute("className"===t?"class":t,o);else if(t in e&&!Pe[t])try{"input"===a&&e[t]===o||(e[t]=o)}catch(l){e.setAttribute(t,o)}else e.setAttribute(t,o)}function K(e,t,n,r,o,i,a){if(t in o&&r===n&&Ae.activeElement!==e)"value"===t&&"input"===i&&e.value!==n&&(e.value=n);else{o[t]=n;try{return J(e,t,n,r,i,a)}catch(u){if(u.message.indexOf("Invalid argument")<0)throw u}}}function F(e,t,n,r,o){for(var i in n)!je.call(n,i)||!K(e,i,n[i],r[i],r,t,o);return r}function G(e,t){for(var n=e.length-1;n>-1;n--)if(e[n]&&e[n].parentNode){try{e[n].parentNode.removeChild(e[n])}catch(r){}t=[].concat(t),t[n]&&Q(t[n])}e.length&&(e.length=0)}function Q(e){e.configContext&&n(e.configContext.onunload)&&(e.configContext.onunload(),e.configContext.onunload=null),e.controllers&&f(e.controllers,function(e){n(e.onunload)&&e.onunload({preventDefault:i})}),e.children&&(Ne(e.children)?f(e.children,Q):e.children.tag&&Q(e.children))}function Y(e,t){try{e.appendChild(Ae.createRange().createContextualFragment(t))}catch(n){e.insertAdjacentHTML("beforeend",t),W(e)}}function W(e){if("SCRIPT"===e.tagName)e.parentNode.replaceChild(X(e),e);else{var t=e.childNodes;if(t&&t.length)for(var n=0;n<t.length;n++)W(t[n])}return e}function X(e){for(var t=document.createElement("script"),n=e.attributes,r=0;r<n.length;r++)t.setAttribute(n[r].name,n[r].value);return t.text=e.innerHTML,t}function Z(e,t,n){var r=e.childNodes[t];if(r){var o=1!==r.nodeType,i=Ae.createElement("span");o?(e.insertBefore(i,r||null),i.insertAdjacentHTML("beforebegin",n),e.removeChild(i)):r.insertAdjacentHTML("beforebegin",n)}else Y(e,n);for(var a=[];e.childNodes[t]!==r;)a.push(e.childNodes[t]),t++;return a}function ee(e,t){return function(n){n=n||event,c.redraw.strategy("diff"),c.startComputation();try{return e.call(t,n)}finally{ue()}}}function te(e){var t=Ve.indexOf(e);return t<0?Ve.push(e)-1:t}function ne(e){function t(){return arguments.length&&(e=arguments[0]),e}return t.toJSON=function(){return e},t}function re(e,t){function n(){return(e.controller||i).apply(this,t)||this}function r(n){for(var r=[n].concat(t),o=1;o<arguments.length;o++)r.push(arguments[o]);return e.view.apply(e,r)}e.controller&&(n.prototype=e.controller.prototype),r.$original=e.view;var o={controller:n,view:r};return t[0]&&null!=t[0].key&&(o.attrs={key:t[0].key}),o}function oe(e,t,n,r){if(!r){c.redraw.strategy("all"),c.startComputation(),He[n]=t;var o;o=Be=e?e:e={controller:i};var a=new(e.controller||i);return o===Be&&(Je[n]=a,$e[n]=e),ue(),null===e&&ie(t,n),Je[n]}null==e&&ie(t,n)}function ie(e,t){He.splice(t,1),Je.splice(t,1),$e.splice(t,1),pe(e),Ve.splice(te(e),1)}function ae(){Ge&&(Ge(),Ge=null),f(He,function(e,t){var n=$e[t];if(Je[t]){var r=[Je[t]];c.render(e,n.view?n.view(Je[t],r):"")}}),Qe&&(Qe(),Qe=null),Ke=null,Fe=new Date,c.redraw.strategy("diff")}function ue(){"none"===c.redraw.strategy()?(Me--,c.redraw.strategy("diff")):c.endComputation()}function le(e){return e.slice(et[c.route.mode].length)}function se(e,t,n){Xe={};var r=n.indexOf("?");r!==-1&&(Xe=he(n.substr(r+1,n.length)),n=n.substr(0,r));var o=Object.keys(t),i=o.indexOf(n);if(i!==-1)return c.mount(e,t[o[i]]),!0;for(var a in t)if(je.call(t,a)){if(a===n)return c.mount(e,t[a]),!0;var u=new RegExp("^"+a.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$");if(u.test(n))return n.replace(u,function(){var n=a.match(/:[^\/]+/g)||[],r=[].slice.call(arguments,1,-2);f(n,function(e,t){Xe[e.replace(/:|\./g,"")]=decodeURIComponent(r[t])}),c.mount(e,t[a])}),!0}}function ce(e){if(e=e||event,!(e.ctrlKey||e.metaKey||e.shiftKey||2===e.which)){e.preventDefault?e.preventDefault():e.returnValue=!1;var t,n=e.currentTarget||e.srcElement;for(t="pathname"===c.route.mode&&n.search?he(n.search.slice(1)):{};n&&!/a/i.test(n.nodeName);)n=n.parentNode;Me=0,c.route(n[c.route.mode].slice(et[c.route.mode].length),t)}}function fe(){"hash"!==c.route.mode&&Ce.hash?Ce.hash=Ce.hash:e.scrollTo(0,0)}function de(e,n){var o={},i=[];for(var a in e)if(je.call(e,a)){var u=n?n+"["+a+"]":a,l=e[a];if(null===l)i.push(encodeURIComponent(u));else if(r(l))i.push(de(l,u));else if(Ne(l)){var s=[];o[u]=o[u]||{},f(l,function(e){o[u][e]||(o[u][e]=!0,s.push(encodeURIComponent(u)+"="+encodeURIComponent(e)))}),i.push(s.join("&"))}else l!==t&&i.push(encodeURIComponent(u)+"="+encodeURIComponent(l))}return i.join("&")}function he(e){if(""===e||null==e)return{};"?"===e.charAt(0)&&(e=e.slice(1));var t=e.split("&"),n={};return f(t,function(e){var t=e.split("="),r=decodeURIComponent(t[0]),o=2===t.length?decodeURIComponent(t[1]):null;null!=n[r]?(Ne(n[r])||(n[r]=[n[r]]),n[r].push(o)):n[r]=o}),n}function pe(e){var n=te(e);G(e.childNodes,ze[n]),ze[n]=t}function ve(e,t){var n=c.prop(t);return e.then(n),n.then=function(n,r){return ve(e.then(n,r),t)},n["catch"]=n.then.bind(null,null),n}function me(e,t){function o(e){l=e||at,f.map(function(e){l===it?e.resolve(s):e.reject(s)})}function i(e,t,o,i){if((null!=s&&r(s)||n(s))&&n(e))try{var a=0;e.call(s,function(e){a++||(s=e,t())},function(e){a++||(s=e,o())})}catch(u){c.deferred.onerror(u),s=u,o()}else i()}function a(){var r;try{r=s&&s.then}catch(f){return c.deferred.onerror(f),s=f,l=ot,a()}l===ot&&c.deferred.onerror(s),i(r,function(){l=rt,a()},function(){l=ot,a()},function(){try{l===rt&&n(e)?s=e(s):l===ot&&n(t)&&(s=t(s),l=rt)}catch(a){return c.deferred.onerror(a),s=a,o()}s===u?(s=TypeError(),o()):i(r,function(){o(it)},o,function(){o(l===rt&&it)})})}var u=this,l=0,s=0,f=[];u.promise={},u.resolve=function(e){return l||(s=e,l=rt,a()),u},u.reject=function(e){return l||(s=e,l=ot,a()),u},u.promise.then=function(e,t){var n=new me(e,t);return l===it?n.resolve(s):l===at?n.reject(s):f.push(n),n.promise}}function ge(e){return e}function ye(n){var r=n.callbackName||"mithril_callback_"+(new Date).getTime()+"_"+Math.round(1e16*Math.random()).toString(36),o=Ae.createElement("script");e[r]=function(i){o.parentNode.removeChild(o),n.onload({type:"load",target:{responseText:i}}),e[r]=t},o.onerror=function(){return o.parentNode.removeChild(o),n.onerror({type:"error",target:{status:500,responseText:JSON.stringify({error:"Error making jsonp request"})}}),e[r]=t,!1},o.onload=function(){return!1},o.src=n.url+(n.url.indexOf("?")>0?"&":"?")+(n.callbackKey?n.callbackKey:"callback")+"="+r+"&"+de(n.data||{}),Ae.body.appendChild(o)}function we(t){var r=new e.XMLHttpRequest;if(r.open(t.method,t.url,!0,t.user,t.password),r.onreadystatechange=function(){4===r.readyState&&(r.status>=200&&r.status<300?t.onload({type:"load",target:r}):t.onerror({type:"error",target:r}))},t.serialize===JSON.stringify&&t.data&&"GET"!==t.method&&r.setRequestHeader("Content-Type","application/json; charset=utf-8"),t.deserialize===JSON.parse&&r.setRequestHeader("Accept","application/json, text/*"),n(t.config)){var i=t.config(r,t);null!=i&&(r=i)}var a="GET"!==t.method&&t.data?t.data:"";if(a&&!o(a)&&a.constructor!==e.FormData)throw new Error("Request data should be either be a string or FormData. Check the `serialize` option in `m.request`");return r.send(a),r}function be(e){return e.dataType&&"jsonp"===e.dataType.toLowerCase()?ye(e):we(e)}function Ee(e,t,n){if("GET"===e.method&&"jsonp"!==e.dataType){var r=e.url.indexOf("?")<0?"?":"&",o=de(t);e.url+=o?r+o:""}else e.data=n(t)}function xe(e,t){return t&&(e=e.replace(/:[a-z]\w+/gi,function(e){var n=e.slice(1),r=t[n]||e;return delete t[n],r})),e}c.version=function(){return"v0.2.5"};var Ae,Ce,Oe,ke,je={}.hasOwnProperty,Le={}.toString,Ne=Array.isArray||function(e){return"[object Array]"===Le.call(e)},Se={AREA:1,BASE:1,BR:1,COL:1,COMMAND:1,EMBED:1,HR:1,IMG:1,INPUT:1,KEYGEN:1,LINK:1,META:1,PARAM:1,SOURCE:1,TRACK:1,WBR:1};c.deps=function(t){return a(e=t||window),e},c.deps(e);var Te=1,_e=2,Re=3,Me=0;c.startComputation=function(){Me++},c.endComputation=function(){Me>1?Me--:(Me=0,c.redraw())};var qe,De=[],Ie=!1,Pe={list:1,style:1,form:1,type:1,width:1,height:1},Ue={appendChild:function(e){qe===t&&(qe=Ae.createElement("html")),Ae.documentElement&&Ae.documentElement!==e?Ae.replaceChild(e,Ae.documentElement):Ae.appendChild(e),this.childNodes=Ae.childNodes},insertBefore:function(e){this.appendChild(e)},childNodes:[]},Ve=[],ze={};c.render=function(e,n,r){if(!e)throw new Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");var o,i=[],a=te(e),u=e===Ae;o=u||e===Ae.documentElement?Ue:e,u&&"html"!==n.tag&&(n={tag:"html",attrs:{},children:n}),ze[a]===t&&G(o.childNodes),r===!0&&pe(e),ze[a]=B(o,null,t,t,n,ze[a],!1,0,null,t,i),f(i,function(e){e()})},c.trust=function(e){return e=new String(e),e.$trusted=!0,e},c.prop=function(e){return(null!=e&&(r(e)||n(e))||"undefined"!=typeof Promise&&e instanceof Promise)&&n(e.then)?ve(e):ne(e)};var Be,He=[],$e=[],Je=[],Ke=null,Fe=0,Ge=null,Qe=null,Ye=16;c.component=function(e){for(var t=new Array(arguments.length-1),n=1;n<arguments.length;n++)t[n-1]=arguments[n];return re(e,t)},c.mount=c.module=function(e,t){if(!e)throw new Error("Please ensure the DOM element exists before rendering a template into it.");var r=He.indexOf(e);r<0&&(r=He.length);var o=!1,i={preventDefault:function(){o=!0,Ge=Qe=null}};return f(De,function(e){e.handler.call(e.controller,i),e.controller.onunload=null}),o?f(De,function(e){e.controller.onunload=e.handler}):De=[],Je[r]&&n(Je[r].onunload)&&Je[r].onunload(i),oe(t,e,r,o)};var We=!1;c.redraw=function(t){if(!We){We=!0,t&&(Ie=!0);try{Ke&&!t?(Oe===e.requestAnimationFrame||new Date-Fe>Ye)&&(Ke>0&&ke(Ke),Ke=Oe(ae,Ye)):(ae(),Ke=Oe(function(){Ke=null},Ye))}finally{We=Ie=!1}}},c.redraw.strategy=c.prop(),c.withAttr=function(e,t,n){return function(r){r=r||window.event;var o=r.currentTarget||this,i=n||this,a=e in o?o[e]:o.getAttribute(e);t.call(i,a)}};var Xe,Ze,et={pathname:"",hash:"#",search:"?"},tt=i,nt=!1;c.route=function(t,n,r,i){if(0===arguments.length)return Ze;if(3===arguments.length&&o(n)){tt=function(e){var o=Ze=le(e);if(!se(t,r,o)){if(nt)throw new Error("Ensure the default route matches one of the routes defined in m.route");nt=!0,c.route(n,!0),nt=!1}};var a="hash"===c.route.mode?"onhashchange":"onpopstate";return e[a]=function(){var e=Ce[c.route.mode];"pathname"===c.route.mode&&(e+=Ce.search),Ze!==le(e)&&tt(e)},Ge=fe,void e[a]()}if(t.addEventListener||t.attachEvent){var u="pathname"!==c.route.mode?Ce.pathname:"";return t.href=u+et[c.route.mode]+i.attrs.href,void(t.addEventListener?(t.removeEventListener("click",ce),t.addEventListener("click",ce)):(t.detachEvent("onclick",ce),t.attachEvent("onclick",ce)))}if(o(t)){var l=Ze;Ze=t;var s,f=n||{},d=Ze.indexOf("?");s=d>-1?he(Ze.slice(d+1)):{};for(var h in f)je.call(f,h)&&(s[h]=f[h]);var p,v=de(s);p=d>-1?Ze.slice(0,d):Ze,v&&(Ze=p+(p.indexOf("?")===-1?"?":"&")+v);var m=(3===arguments.length?r:n)===!0||l===t;if(e.history.pushState){var g=m?"replaceState":"pushState";Ge=fe,Qe=function(){try{e.history[g](null,Ae.title,et[c.route.mode]+Ze)}catch(t){Ce[c.route.mode]=Ze}},tt(et[c.route.mode]+Ze)}else Ce[c.route.mode]=Ze,tt(et[c.route.mode]+Ze)}},c.route.param=function(e){if(!Xe)throw new Error("You must call m.route(element, defaultRoute, routes) before calling m.route.param()");return e?Xe[e]:Xe},c.route.mode="search",c.route.buildQueryString=de,c.route.parseQueryString=he,c.deferred=function(){var e=new me;return e.promise=ve(e.promise),e};var rt=1,ot=2,it=3,at=4;return c.deferred.onerror=function(e){if("[object Error]"===Le.call(e)&&!/ Error/.test(e.constructor.toString()))throw Me=0,e},c.sync=function(e){function t(e,t){return function(a){return o[e]=a,t||(i="reject"),0===--r&&(n.promise(o),n[i](o)),a}}var n=c.deferred(),r=e.length,o=[],i="resolve";return e.length>0?f(e,function(e,n){e.then(t(n,!0),t(n,!1))}):n.resolve([]),n.promise},c.request=function(e){e.background!==!0&&c.startComputation();var t,n,r,o=new me,i=e.dataType&&"jsonp"===e.dataType.toLowerCase();return i?(t=e.serialize=n=e.deserialize=ge,r=function(e){return e.responseText}):(t=e.serialize=e.serialize||JSON.stringify,n=e.deserialize=e.deserialize||JSON.parse,r=e.extract||function(e){return e.responseText.length||n!==JSON.parse?e.responseText:null}),e.method=(e.method||"GET").toUpperCase(),e.url=xe(e.url,e.data),Ee(e,e.data,t),e.onload=e.onerror=function(t){try{t=t||event;var i=n(r(t.target,e));"load"===t.type?(e.unwrapSuccess&&(i=e.unwrapSuccess(i,t.target)),Ne(i)&&e.type?f(i,function(t,n){i[n]=new e.type(t)}):e.type&&(i=new e.type(i)),o.resolve(i)):(e.unwrapError&&(i=e.unwrapError(i,t.target)),o.reject(i))}catch(a){o.reject(a),c.deferred.onerror(a)}finally{e.background!==!0&&c.endComputation()}},be(e),o.promise=ve(o.promise,e.initialValue),o.promise},c})},{}],8:[function(e,n,r){(function(){"use strict";function e(){}function r(e,t){for(var n=e.length;n--;)if(e[n].listener===t)return n;return-1}function o(e){return function(){return this[e].apply(this,arguments)}}var i=e.prototype,a=this,u=a.EventEmitter;i.getListeners=function(e){var t,n,r=this._getEvents();if(e instanceof RegExp){t={};for(n in r)r.hasOwnProperty(n)&&e.test(n)&&(t[n]=r[n])}else t=r[e]||(r[e]=[]);return t},i.flattenListeners=function(e){var t,n=[];for(t=0;t<e.length;t+=1)n.push(e[t].listener);return n},i.getListenersAsObject=function(e){var t,n=this.getListeners(e);return n instanceof Array&&(t={},t[e]=n),t||n},i.addListener=function(e,t){var n,o=this.getListenersAsObject(e),i="object"==typeof t;for(n in o)o.hasOwnProperty(n)&&r(o[n],t)===-1&&o[n].push(i?t:{listener:t,once:!1});return this},i.on=o("addListener"),i.addOnceListener=function(e,t){return this.addListener(e,{listener:t,once:!0})},i.once=o("addOnceListener"),i.defineEvent=function(e){return this.getListeners(e),this},i.defineEvents=function(e){for(var t=0;t<e.length;t+=1)this.defineEvent(e[t]);return this},i.removeListener=function(e,t){var n,o,i=this.getListenersAsObject(e);for(o in i)i.hasOwnProperty(o)&&(n=r(i[o],t),n!==-1&&i[o].splice(n,1));return this},i.off=o("removeListener"),i.addListeners=function(e,t){return this.manipulateListeners(!1,e,t)},i.removeListeners=function(e,t){return this.manipulateListeners(!0,e,t)},i.manipulateListeners=function(e,t,n){var r,o,i=e?this.removeListener:this.addListener,a=e?this.removeListeners:this.addListeners;if("object"!=typeof t||t instanceof RegExp)for(r=n.length;r--;)i.call(this,t,n[r]);else for(r in t)t.hasOwnProperty(r)&&(o=t[r])&&("function"==typeof o?i.call(this,r,o):a.call(this,r,o));return this},i.removeEvent=function(e){var t,n=typeof e,r=this._getEvents();if("string"===n)delete r[e];else if(e instanceof RegExp)for(t in r)r.hasOwnProperty(t)&&e.test(t)&&delete r[t];else delete this._events;return this},i.removeAllListeners=o("removeEvent"),i.emitEvent=function(e,t){var n,r,o,i,a,u=this.getListenersAsObject(e);for(i in u)if(u.hasOwnProperty(i))for(n=u[i].slice(0),o=n.length;o--;)r=n[o],r.once===!0&&this.removeListener(e,r.listener),a=r.listener.apply(this,t||[]),a===this._getOnceReturnValue()&&this.removeListener(e,r.listener);return this},i.trigger=o("emitEvent"),i.emit=function(e){var t=Array.prototype.slice.call(arguments,1);return this.emitEvent(e,t)},i.setOnceReturnValue=function(e){return this._onceReturnValue=e,this},i._getOnceReturnValue=function(){return!this.hasOwnProperty("_onceReturnValue")||this._onceReturnValue},i._getEvents=function(){return this._events||(this._events={})},e.noConflict=function(){return a.EventEmitter=u,e},"function"==typeof t&&t.amd?t(function(){return e}):"object"==typeof n&&n.exports?n.exports=e:a.EventEmitter=e}).call(this)},{}]},{},[1])}();
2
  //# sourceMappingURL=admin.min.js.map
1
+ !function(){var e=void 0,t=void 0;!function t(n,r,i){function o(l,s){if(!r[l]){if(!n[l]){var u="function"==typeof e&&e;if(!s&&u)return u(l,!0);if(a)return a(l,!0);var c=new Error("Cannot find module '"+l+"'");throw c.code="MODULE_NOT_FOUND",c}var f=r[l]={exports:{}};n[l][0].call(f.exports,function(e){var t=n[l][1][e];return o(t?t:e)},f,f.exports,t,n,r,i)}return r[l].exports}for(var a="function"==typeof e&&e,l=0;l<i.length;l++)o(i[l]);return o}({1:[function(e,t,n){"use strict";var r=window.m=e("mithril"),i=e("wolfy87-eventemitter"),o=document.getElementById("mc4wp-admin"),a=new i,l=e("./admin/tabs.js")(o),s=e("./admin/helpers.js"),u=e("./admin/settings.js")(o,s,a),c=e("./admin/list-fetcher.js"),f=document.getElementById("mc4wp-list-fetcher");f&&r.mount(f,new c),window.mc4wp=window.mc4wp||{},window.mc4wp.deps=window.mc4wp.deps||{},window.mc4wp.deps.mithril=r,window.mc4wp.helpers=s,window.mc4wp.events=a,window.mc4wp.settings=u,window.mc4wp.tabs=l},{"./admin/helpers.js":2,"./admin/list-fetcher.js":3,"./admin/settings.js":4,"./admin/tabs.js":5,mithril:7,"wolfy87-eventemitter":8}],2:[function(e,t,n){"use strict";var r={};r.toggleElement=function(e){for(var t=document.querySelectorAll(e),n=0;n<t.length;n++){var r=t[n].clientHeight<=0;t[n].style.display=r?"":"none"}},r.bindEventToElement=function(e,t,n){e.addEventListener?e.addEventListener(t,n):e.attachEvent&&e.attachEvent("on"+t,n)},r.bindEventToElements=function(e,t,n){Array.prototype.forEach.call(e,function(e){r.bindEventToElement(e,t,n)})},r.debounce=function(e,t,n){var r;return function(){var i=this,o=arguments,a=function(){r=null,n||e.apply(i,o)},l=n&&!r;clearTimeout(r),r=setTimeout(a,t),l&&e.apply(i,o)}},function(){var e=document.querySelectorAll("[data-showif]");Array.prototype.forEach.call(e,function(e){function t(){if("radio"!==this.getAttribute("type")||this.checked){var t="checkbox"===this.getAttribute("type")?this.checked:this.value,r=t==n.value;a?(e.style.display=r?"":"none",e.style.visibility=r?"":"hidden"):e.style.opacity=r?"":"0.4",Array.prototype.forEach.call(o,function(e){r?e.removeAttribute("readonly"):e.setAttribute("readonly","readonly")})}}var n=JSON.parse(e.getAttribute("data-showif")),i=document.querySelectorAll('[name="'+n.element+'"]'),o=e.querySelectorAll("input,select,textarea:not([readonly])"),a=void 0===n.hide||n.hide;Array.prototype.forEach.call(i,function(e){t.call(e)}),r.bindEventToElements(i,"change",t)})}(),t.exports=r},{}],3:[function(e,t,n){"use strict";function r(){this.working=!1,this.done=!1,o.mailchimp.api_connected&&0==o.mailchimp.lists.length&&this.fetch()}var i=window.jQuery,o=mc4wp_vars,a=o.i18n;r.prototype.fetch=function(e){e&&e.preventDefault(),this.working=!0,this.done=!1,i.post(ajaxurl,{action:"mc4wp_renew_mailchimp_lists"}).done(function(e){e&&window.setTimeout(function(){window.location.reload()},3e3)}).always(function(e){this.working=!1,this.done=!0,m.redraw()}.bind(this))},r.prototype.view=function(){return m("form",{method:"POST",onsubmit:this.fetch.bind(this)},[m("p",[m("input",{type:"submit",value:this.working?a.fetching_mailchimp_lists:a.renew_mailchimp_lists,className:"button",disabled:!!this.working}),m.trust(" &nbsp; "),this.working?[m("span.mc4wp-loader","Loading..."),m.trust(" &nbsp; "),m("em.help",a.fetching_mailchimp_lists_can_take_a_while)]:"",this.done?[m("em.help.green",a.fetching_mailchimp_lists_done)]:""])])},t.exports=r},{}],4:[function(e,t,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=function(e,t,n){function i(e,t){return c.filter(function(n){return n[e]===t})}function o(){return c}function a(){return c=[],Array.prototype.forEach.call(s,function(e){("boolean"!=typeof e.checked||e.checked)&&"object"===r(u[e.value])&&c.push(u[e.value])}),n.trigger("selectedLists.change",[c]),c}function l(){var e=document.querySelectorAll(".lists--only-selected > *");Array.prototype.forEach.call(e,function(e){i("id",e.getAttribute("data-list-id")).length>0?e.setAttribute("class",e.getAttribute("class").replace("hidden","")):e.setAttribute("class",e.getAttribute("class")+" hidden")})}var s=(e.querySelector("form"),e.querySelectorAll(".mc4wp-list-input")),u=mc4wp_vars.mailchimp.lists,c=[];return n.on("selectedLists.change",l),t.bindEventToElements(s,"change",a),a(),{getSelectedLists:o}};t.exports=i},{}],5:[function(e,t,n){"use strict";var r=e("./url.js"),i=function(e){function t(e){for(var t=0;t<f.length;t++)if(f[t].id===e)return f[t]}function n(e,n){if("string"==typeof e&&(e=t(e)),!e)return!1;void 0==n&&(n=!0),s.removeClass("tab-active").css("display","none"),u.removeClass("nav-tab-active"),Array.prototype.forEach.call(e.nav,function(e){e.className+=" nav-tab-active",e.blur()}),e.element.style.display="block",e.element.className+=" tab-active";var o=r.setParameter(window.location.href,"tab",e.id);return history.pushState&&n&&history.pushState(e.id,"",o),i(e),c.value=o,"function"==typeof tb_remove&&tb_remove(),"fields"===e.id&&window.mc4wp&&window.mc4wp.forms&&window.mc4wp.forms.editor&&mc4wp.forms.editor.refresh(),!0}function i(e){var t=document.title.split("-");document.title=document.title.replace(t[0],e.title+" ")}function o(e){e=e||window.event;var t=this.getAttribute("data-tab");if(!t){var i=this.className.match(/nav-tab-(\w+)?/);i&&(t=i[1])}if(!t){var o=r.parse(this.href);if(!o.tab)return;t=o.tab}return!n(t)||(e.preventDefault(),e.returnValue=!1,!1)}var a=window.jQuery,l=a(e),s=l.find(".tab"),u=l.find(".nav-tab"),c=e.querySelector('input[name="_wp_http_referer"]'),f=[];return a.each(s,function(t,r){var i=r.id.substring(4),o=a(r).find("h2").first().text();f.push({id:i,title:o,element:r,nav:e.querySelectorAll(".nav-tab-"+i),open:function(){return n(i)}})}),u.click(o),a(document.body).on("click",".tab-link",o),function(){if(history.pushState){var e=s.filter(":visible").get(0);if(e){var n=t(e.id.substring(4));n&&(history.replaceState&&null===history.state&&history.replaceState(n.id,""),i(n))}}}(),window.addEventListener&&history.pushState&&window.addEventListener("popstate",function(e){return!e.state||n(e.state,!1)}),{open:n,get:t}};t.exports=i},{"./url.js":6}],6:[function(e,t,n){"use strict";var r={parse:function(e){var t={},n=e.split("&");for(var r in n)if(n.hasOwnProperty(r)){var i=n[r].split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return t},build:function(e){var t=[];for(var n in e)t.push(n+"="+encodeURIComponent(e[n]));return t.join("&")},setParameter:function(e,t,n){var i=r.parse(e);return i[t]=n,r.build(i)}};t.exports=r},{}],7:[function(e,t,n){(function(e){new function(){function n(e,t,n,r,i,o){return{tag:e,key:t,attrs:n,children:r,text:i,dom:o,domSize:void 0,state:{},events:void 0,instance:void 0,skip:!1}}function r(e){if(null==e||"string"!=typeof e&&"function"!=typeof e.view)throw Error("The selector must be either a string or a component.");if("string"==typeof e&&void 0===a[e]){for(var t,r,i=[],l={};t=o.exec(e);){var s=t[1],u=t[2];if(""===s&&""!==u)r=u;else if("#"===s)l.id=u;else if("."===s)i.push(u);else if("["===t[3][0]){var c=t[6];c&&(c=c.replace(/\\(["'])/g,"$1").replace(/\\\\/g,"\\")),"class"===t[4]?i.push(c):l[t[4]]=c||!0}}i.length>0&&(l.className=i.join(" ")),a[e]=function(e,t){var i,o,a=!1,s=e.className||e.class;for(var u in l)e[u]=l[u];void 0!==s&&(void 0!==e.class&&(e.class=void 0,e.className=s),void 0!==l.className&&(e.className=l.className+" "+s));for(var u in e)if("key"!==u){a=!0;break}return Array.isArray(t)&&1==t.length&&null!=t[0]&&"#"===t[0].tag?o=t[0].children:i=t,n(r||"div",e.key,a?e:void 0,i,o,void 0)}}var f,d,v;if(null==arguments[1]||"object"==typeof arguments[1]&&void 0===arguments[1].tag&&!Array.isArray(arguments[1])?(f=arguments[1],v=2):v=1,arguments.length===v+1)d=Array.isArray(arguments[v])?arguments[v]:[arguments[v]];else{d=[];for(var h=v;h<arguments.length;h++)d.push(arguments[h])}return"string"==typeof e?a[e](f||{},n.normalizeChildren(d)):n(e,f&&f.key,f||{},n.normalizeChildren(d),void 0,void 0)}function i(e){var t=0,n=null,r="function"==typeof requestAnimationFrame?requestAnimationFrame:setTimeout;return function(){var i=Date.now();0===t||i-t>=16?(t=i,e()):null===n&&(n=r(function(){n=null,e(),t=Date.now()},16-(i-t)))}}n.normalize=function(e){return Array.isArray(e)?n("[",void 0,void 0,n.normalizeChildren(e),void 0,void 0):null!=e&&"object"!=typeof e?n("#",void 0,void 0,e===!1?"":e,void 0,void 0):e},n.normalizeChildren=function(e){for(var t=0;t<e.length;t++)e[t]=n.normalize(e[t]);return e};var o=/(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g,a={};r.trust=function(e){return null==e&&(e=""),n("<",void 0,void 0,e,void 0,void 0)},r.fragment=function(e,t){return n("[",e.key,e,n.normalizeChildren(t),void 0,void 0)};var l=r,s=function(e){function t(e,t){return function a(s){var f;try{if(!t||null==s||"object"!=typeof s&&"function"!=typeof s||"function"!=typeof(f=s.then))c(function(){t||0!==e.length||console.error("Possible unhandled promise rejection:",s);for(var n=0;n<e.length;n++)e[n](s);i.length=0,o.length=0,u.state=t,u.retry=function(){a(s)}});else{if(s===r)throw new TypeError("Promise can't be resolved w/ itself");n(f.bind(s))}}catch(e){l(e)}}}function n(e){function t(e){return function(t){n++>0||e(t)}}var n=0,r=t(l);try{e(t(a),r)}catch(e){r(e)}}if(!(this instanceof s))throw new Error("Promise must be called with `new`");if("function"!=typeof e)throw new TypeError("executor must be a function");var r=this,i=[],o=[],a=t(i,!0),l=t(o,!1),u=r._instance={resolvers:i,rejectors:o},c="function"==typeof setImmediate?setImmediate:setTimeout;n(e)};if(s.prototype.then=function(e,t){function n(e,t,n,o){t.push(function(t){if("function"!=typeof e)n(t);else try{r(e(t))}catch(e){i&&i(e)}}),"function"==typeof a.retry&&o===a.state&&a.retry()}var r,i,o=this,a=o._instance,l=new s(function(e,t){r=e,i=t});return n(e,a.resolvers,r,!0),n(t,a.rejectors,i,!1),l},s.prototype.catch=function(e){return this.then(null,e)},s.resolve=function(e){return e instanceof s?e:new s(function(t){t(e)})},s.reject=function(e){return new s(function(t,n){n(e)})},s.all=function(e){return new s(function(t,n){var r=e.length,i=0,o=[];if(0===e.length)t([]);else for(var a=0;a<e.length;a++)!function(a){function l(e){i++,o[a]=e,i===r&&t(o)}null==e[a]||"object"!=typeof e[a]&&"function"!=typeof e[a]||"function"!=typeof e[a].then?l(e[a]):e[a].then(l,n)}(a)})},s.race=function(e){return new s(function(t,n){for(var r=0;r<e.length;r++)e[r].then(t,n)})},"undefined"!=typeof window){void 0===window.Promise&&(window.Promise=s);var s=window.Promise}else if(void 0!==e){void 0===e.Promise&&(e.Promise=s);var s=e.Promise}var u=function(e){function t(e,r){if(Array.isArray(r))for(var i=0;i<r.length;i++)t(e+"["+i+"]",r[i]);else if("[object Object]"===Object.prototype.toString.call(r))for(var i in r)t(e+"["+i+"]",r[i]);else n.push(encodeURIComponent(e)+(null!=r&&""!==r?"="+encodeURIComponent(r):""))}if("[object Object]"!==Object.prototype.toString.call(e))return"";var n=[];for(var r in e)t(r,e[r]);return n.join("&")},c=function(e,t){function n(e){v=e}function r(){function e(){0==--t&&"function"==typeof v&&v()}var t=0;return function n(r){var i=r.then;return r.then=function(){t++;var o=i.apply(r,arguments);return o.then(e,function(n){if(e(),0===t)throw n}),n(o)},r}}function i(e,t){if("string"==typeof e){var n=e;e=t||{},null==e.url&&(e.url=n)}return e}function o(n,o){var a=r();n=i(n,o);var u=new t(function(t,r){null==n.method&&(n.method="GET"),n.method=n.method.toUpperCase();var i="boolean"==typeof n.useBody?n.useBody:"GET"!==n.method&&"TRACE"!==n.method;"function"!=typeof n.serialize&&(n.serialize="undefined"!=typeof FormData&&n.data instanceof FormData?function(e){return e}:JSON.stringify),"function"!=typeof n.deserialize&&(n.deserialize=c),"function"!=typeof n.extract&&(n.extract=f),n.url=l(n.url,n.data),i?n.data=n.serialize(n.data):n.url=s(n.url,n.data);var o=new e.XMLHttpRequest;o.open(n.method,n.url,"boolean"!=typeof n.async||n.async,"string"==typeof n.user?n.user:void 0,"string"==typeof n.password?n.password:void 0),n.serialize===JSON.stringify&&i&&o.setRequestHeader("Content-Type","application/json; charset=utf-8"),n.deserialize===c&&o.setRequestHeader("Accept","application/json, text/*"),n.withCredentials&&(o.withCredentials=n.withCredentials);for(var a in n.headers)({}).hasOwnProperty.call(n.headers,a)&&o.setRequestHeader(a,n.headers[a]);"function"==typeof n.config&&(o=n.config(o,n)||o),o.onreadystatechange=function(){if(o.status&&4===o.readyState)try{var e=n.extract!==f?n.extract(o,n):n.deserialize(n.extract(o,n));if(o.status>=200&&o.status<300||304===o.status)t(d(n.type,e));else{var i=new Error(o.responseText);for(var a in e)i[a]=e[a];r(i)}}catch(e){r(e)}},i&&null!=n.data?o.send(n.data):o.send()});return n.background===!0?u:a(u)}function a(n,o){var a=r();n=i(n,o);var u=new t(function(t,r){var i=n.callbackName||"_mithril_"+Math.round(1e16*Math.random())+"_"+h++,o=e.document.createElement("script");e[i]=function(r){o.parentNode.removeChild(o),t(d(n.type,r)),delete e[i]},o.onerror=function(){o.parentNode.removeChild(o),r(new Error("JSONP request failed")),delete e[i]},null==n.data&&(n.data={}),n.url=l(n.url,n.data),n.data[n.callbackKey||"callback"]=i,o.src=s(n.url,n.data),e.document.documentElement.appendChild(o)});return n.background===!0?u:a(u)}function l(e,t){if(null==t)return e;for(var n=e.match(/:[^\/]+/gi)||[],r=0;r<n.length;r++){var i=n[r].slice(1);null!=t[i]&&(e=e.replace(n[r],t[i]))}return e}function s(e,t){var n=u(t);if(""!==n){e+=(e.indexOf("?")<0?"?":"&")+n}return e}function c(e){try{return""!==e?JSON.parse(e):null}catch(t){throw new Error(e)}}function f(e){return e.responseText}function d(e,t){if("function"==typeof e){if(!Array.isArray(t))return new e(t);for(var n=0;n<t.length;n++)t[n]=new e(t[n])}return t}var v,h=0;return{request:o,jsonp:a,setCompletionCallback:n}}(window,s),f=function(e){function t(e){return V=e}function r(e,t,n,r,o,a,l){for(var s=n;s<r;s++){var u=t[s];null!=u&&i(e,u,o,l,a)}}function i(e,t,n,r,i){var c=t.tag;if(null!=t.attrs&&M(t.attrs,t,n),"string"!=typeof c)return u(e,t,n,r,i);switch(c){case"#":return o(e,t,i);case"<":return a(e,t,i);case"[":return l(e,t,n,r,i);default:return s(e,t,n,r,i)}}function o(e,t,n){return t.dom=H.createTextNode(t.children),x(e,t.dom,n),t.dom}function a(e,t,n){var r=t.children.match(/^\s*?<(\w+)/im)||[],i={caption:"table",thead:"table",tbody:"table",tfoot:"table",tr:"tbody",th:"tr",td:"tr",colgroup:"table",col:"colgroup"}[r[1]]||"div",o=H.createElement(i);o.innerHTML=t.children,t.dom=o.firstChild,t.domSize=o.childNodes.length;for(var a,l=H.createDocumentFragment();a=o.firstChild;)l.appendChild(a);return x(e,l,n),l}function l(e,t,n,i,o){var a=H.createDocumentFragment();if(null!=t.children){var l=t.children;r(a,l,0,l.length,n,null,i)}return t.dom=a.firstChild,t.domSize=a.childNodes.length,x(e,a,o),a}function s(e,t,i,o,a){var l=t.tag;switch(t.tag){case"svg":o="http://www.w3.org/2000/svg";break;case"math":o="http://www.w3.org/1998/Math/MathML"}var s=t.attrs,u=s&&s.is,c=o?u?H.createElementNS(o,l,{is:u}):H.createElementNS(o,l):u?H.createElement(l,{is:u}):H.createElement(l);if(t.dom=c,null!=s&&j(t,s,o),x(e,c,a),null!=t.attrs&&null!=t.attrs.contenteditable)E(t);else if(null!=t.text&&(""!==t.text?c.textContent=t.text:t.children=[n("#",void 0,void 0,t.text,void 0,void 0)]),null!=t.children){var f=t.children;r(c,f,0,f.length,i,null,o),O(t)}return c}function u(e,t,r,o,a){t.state=Object.create(t.tag);var l=t.tag.view;if(null!=l.reentrantLock)return B;if(l.reentrantLock=!0,M(t.tag,t,r),t.instance=n.normalize(l.call(t.state,t)),l.reentrantLock=null,null!=t.instance){if(t.instance===t)throw Error("A view cannot return the vnode it received as arguments");var s=i(e,t.instance,r,o,a);return t.dom=t.instance.dom,t.domSize=null!=t.dom?t.instance.domSize:0,x(e,s,a),s}return t.domSize=0,B}function c(e,t,n,o,a,l,s){if(t!==n&&(null!=t||null!=n))if(null==t)r(e,n,0,n.length,a,l,void 0);else if(null==n)A(t,0,t.length,n);else{if(t.length===n.length){for(var u=!1,c=0;c<n.length;c++)if(null!=n[c]&&null!=t[c]){u=null==n[c].key&&null==t[c].key;break}if(u){for(var c=0;c<t.length;c++)t[c]!==n[c]&&(null==t[c]&&null!=n[c]?i(e,n[c],a,s,b(t,c+1,l)):null==n[c]?A(t,c,c+1,n):f(e,t[c],n[c],a,b(t,c+1,l),!1,s));return}}o=o||y(t,n),o&&(t=t.concat(t.pool));for(var d,v=0,h=0,p=t.length-1,m=n.length-1;p>=v&&m>=h;){var E=t[v],k=n[h];if(E!==k||o)if(null==E)v++;else if(null==k)h++;else if(E.key===k.key)v++,h++,f(e,E,k,a,b(t,v,l),o,s),o&&E.tag===k.tag&&x(e,w(E),l);else{var E=t[p];if(E!==k||o)if(null==E)p--;else if(null==k)h++;else{if(E.key!==k.key)break;f(e,E,k,a,b(t,p+1,l),o,s),(o||h<m)&&x(e,w(E),b(t,v,l)),p--,h++}else p--,h++}else v++,h++}for(;p>=v&&m>=h;){var E=t[p],k=n[m];if(E!==k||o)if(null==E)p--;else if(null==k)m--;else if(E.key===k.key)f(e,E,k,a,b(t,p+1,l),o,s),o&&E.tag===k.tag&&x(e,w(E),l),null!=E.dom&&(l=E.dom),p--,m--;else{if(d||(d=g(t,p)),null!=k){var S=d[k.key];if(null!=S){var C=t[S];f(e,C,k,a,b(t,p+1,l),o,s),x(e,w(C),l),t[S].skip=!0,null!=C.dom&&(l=C.dom)}else{var j=i(e,k,a,void 0,l);l=j}}m--}else p--,m--;if(m<h)break}r(e,n,h,m+1,a,l,s),A(t,v,p+1,n)}}function f(e,t,n,r,o,a,l){var s=t.tag;if(s===n.tag){if(n.state=t.state,n.events=t.events,U(n,t))return;if(null!=n.attrs&&D(n.attrs,n,r,a),"string"==typeof s)switch(s){case"#":d(t,n);break;case"<":v(e,t,n,o);break;case"[":h(e,t,n,a,r,o,l);break;default:p(t,n,a,r,l)}else m(e,t,n,r,o,a,l)}else k(t,null),i(e,n,r,l,o)}function d(e,t){e.children.toString()!==t.children.toString()&&(e.dom.nodeValue=t.children),t.dom=e.dom}function v(e,t,n,r){t.children!==n.children?(w(t),a(e,n,r)):(n.dom=t.dom,n.domSize=t.domSize)}function h(e,t,n,r,i,o,a){c(e,t.children,n.children,r,i,o,a);var l=0,s=n.children;if(n.dom=null,null!=s){for(var u=0;u<s.length;u++){var f=s[u];null!=f&&null!=f.dom&&(null==n.dom&&(n.dom=f.dom),l+=f.domSize||1)}1!==l&&(n.domSize=l)}}function p(e,t,r,i,o){var a=t.dom=e.dom;switch(t.tag){case"svg":o="http://www.w3.org/2000/svg";break;case"math":o="http://www.w3.org/1998/Math/MathML"}"textarea"===t.tag&&(null==t.attrs&&(t.attrs={}),null!=t.text&&(t.attrs.value=t.text,t.text=void 0)),_(t,e.attrs,t.attrs,o),null!=t.attrs&&null!=t.attrs.contenteditable?E(t):null!=e.text&&null!=t.text&&""!==t.text?e.text.toString()!==t.text.toString()&&(e.dom.firstChild.nodeValue=t.text):(null!=e.text&&(e.children=[n("#",void 0,void 0,e.text,void 0,e.dom.firstChild)]),null!=t.text&&(t.children=[n("#",void 0,void 0,t.text,void 0,void 0)]),c(a,e.children,t.children,r,i,null,o))}function m(e,t,r,o,a,l,s){r.instance=n.normalize(r.tag.view.call(r.state,r)),D(r.tag,r,o,l),null!=r.instance?(null==t.instance?i(e,r.instance,o,s,a):f(e,t.instance,r.instance,o,a,l,s),r.dom=r.instance.dom,r.domSize=r.instance.domSize):null!=t.instance?(k(t.instance,null),r.dom=void 0,r.domSize=0):(r.dom=t.dom,r.domSize=t.domSize)}function y(e,t){if(null!=e.pool&&Math.abs(e.pool.length-t.length)<=Math.abs(e.length-t.length)){var n=e[0]&&e[0].children&&e[0].children.length||0,r=e.pool[0]&&e.pool[0].children&&e.pool[0].children.length||0,i=t[0]&&t[0].children&&t[0].children.length||0;if(Math.abs(r-i)<=Math.abs(n-i))return!0}return!1}function g(e,t){for(var n={},r=0,r=0;r<t;r++){var i=e[r];if(null!=i){var o=i.key;null!=o&&(n[o]=r)}}return n}function w(e){var t=e.domSize;if(null!=t||null==e.dom){var n=H.createDocumentFragment();if(t>0){for(var r=e.dom;--t;)n.appendChild(r.nextSibling);n.insertBefore(r,n.firstChild)}return n}return e.dom}function b(e,t,n){for(;t<e.length;t++)if(null!=e[t]&&null!=e[t].dom)return e[t].dom;return n}function x(e,t,n){n&&n.parentNode?e.insertBefore(t,n):e.appendChild(t)}function E(e){var t=e.children;if(null!=t&&1===t.length&&"<"===t[0].tag){var n=t[0].children;e.dom.innerHTML!==n&&(e.dom.innerHTML=n)}else if(null!=e.text||null!=t&&0!==t.length)throw new Error("Child node of a contenteditable must be trusted")}function A(e,t,n,r){for(var i=t;i<n;i++){var o=e[i];null!=o&&(o.skip?o.skip=!1:k(o,r))}}function k(e,t){function n(){if(++i===r&&(C(e),e.dom)){var n=e.domSize||1;if(n>1)for(var o=e.dom;--n;)S(o.nextSibling);S(e.dom),null==t||null!=e.domSize||R(e.attrs)||"string"!=typeof e.tag||(t.pool?t.pool.push(e):t.pool=[e])}}var r=1,i=0;if(e.attrs&&e.attrs.onbeforeremove){var o=e.attrs.onbeforeremove.call(e.state,e);null!=o&&"function"==typeof o.then&&(r++,o.then(n,n))}if("string"!=typeof e.tag&&e.tag.onbeforeremove){var o=e.tag.onbeforeremove.call(e.state,e);null!=o&&"function"==typeof o.then&&(r++,o.then(n,n))}n()}function S(e){var t=e.parentNode;null!=t&&t.removeChild(e)}function C(e){if(e.attrs&&e.attrs.onremove&&e.attrs.onremove.call(e.state,e),"string"!=typeof e.tag&&e.tag.onremove&&e.tag.onremove.call(e.state,e),null!=e.instance)C(e.instance);else{var t=e.children;if(Array.isArray(t))for(var n=0;n<t.length;n++){var r=t[n];null!=r&&C(r)}}}function j(e,t,n){for(var r in t)L(e,r,null,t[r],n)}function L(e,t,n,r,i){var o=e.dom;if("key"!==t&&"is"!==t&&(n!==r||z(e,t)||"object"==typeof r)&&void 0!==r&&!T(t)){var a=t.indexOf(":");if(a>-1&&"xlink"===t.substr(0,a))o.setAttributeNS("http://www.w3.org/1999/xlink",t.slice(a+1),r);else if("o"===t[0]&&"n"===t[1]&&"function"==typeof r)q(e,t,r);else if("style"===t)I(o,n,r);else if(t in o&&!N(t)&&void 0===i&&!P(e)){if("input"===e.tag&&"value"===t&&e.dom.value===r&&e.dom===H.activeElement)return;if("select"===e.tag&&"value"===t&&e.dom.value===r&&e.dom===H.activeElement)return;if("option"===e.tag&&"value"===t&&e.dom.value===r)return;o[t]=r}else"boolean"==typeof r?r?o.setAttribute(t,""):o.removeAttribute(t):o.setAttribute("className"===t?"class":t,r)}}function O(e){var t=e.attrs;"select"===e.tag&&null!=t&&("value"in t&&L(e,"value",null,t.value,void 0),"selectedIndex"in t&&L(e,"selectedIndex",null,t.selectedIndex,void 0))}function _(e,t,n,r){if(null!=n)for(var i in n)L(e,i,t&&t[i],n[i],r);if(null!=t)for(var i in t)null!=n&&i in n||("className"===i&&(i="class"),"o"!==i[0]||"n"!==i[1]||T(i)?"key"!==i&&e.dom.removeAttribute(i):q(e,i,void 0))}function z(e,t){return"value"===t||"checked"===t||"selectedIndex"===t||"selected"===t&&e.dom===H.activeElement}function T(e){return"oninit"===e||"oncreate"===e||"onupdate"===e||"onremove"===e||"onbeforeremove"===e||"onbeforeupdate"===e}function N(e){return"href"===e||"list"===e||"form"===e||"width"===e||"height"===e}function P(e){return e.attrs.is||e.tag.indexOf("-")>-1}function R(e){return null!=e&&(e.oncreate||e.onupdate||e.onbeforeremove||e.onremove)}function I(e,t,n){if(t===n&&(e.style.cssText="",t=null),null==n)e.style.cssText="";else if("string"==typeof n)e.style.cssText=n;else{"string"==typeof t&&(e.style.cssText="");for(var r in n)e.style[r]=n[r];if(null!=t&&"string"!=typeof t)for(var r in t)r in n||(e.style[r]="")}}function q(e,t,n){var r=e.dom,i="function"!=typeof V?n:function(e){var t=n.call(r,e);return V.call(r,e),t};if(t in r)r[t]="function"==typeof n?i:null;else{var o=t.slice(2);if(void 0===e.events&&(e.events={}),e.events[t]===i)return;null!=e.events[t]&&r.removeEventListener(o,e.events[t],!1),"function"==typeof n&&(e.events[t]=i,r.addEventListener(o,e.events[t],!1))}}function M(e,t,n){"function"==typeof e.oninit&&e.oninit.call(t.state,t),"function"==typeof e.oncreate&&n.push(e.oncreate.bind(t.state,t))}function D(e,t,n,r){r?M(e,t,n):"function"==typeof e.onupdate&&n.push(e.onupdate.bind(t.state,t))}function U(e,t){var n,r;return null!=e.attrs&&"function"==typeof e.attrs.onbeforeupdate&&(n=e.attrs.onbeforeupdate.call(e.state,e,t)),"string"!=typeof e.tag&&"function"==typeof e.tag.onbeforeupdate&&(r=e.tag.onbeforeupdate.call(e.state,e,t)),!(void 0===n&&void 0===r||n||r)&&(e.dom=t.dom,e.domSize=t.domSize,e.instance=t.instance,!0)}function F(e,t){if(!e)throw new Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");var r=[],i=H.activeElement;null==e.vnodes&&(e.textContent=""),Array.isArray(t)||(t=[t]),c(e,e.vnodes,n.normalizeChildren(t),!1,r,null,void 0),e.vnodes=t;for(var o=0;o<r.length;o++)r[o]();H.activeElement!==i&&i.focus()}var V,H=e.document,B=H.createDocumentFragment();return{render:F,setEventCallback:t}},d=function(e){function t(e,t){n(e),a.push(e,i(t))}function n(e){var t=a.indexOf(e);t>-1&&a.splice(t,2)}function r(){for(var e=1;e<a.length;e+=2)a[e]()}var o=f(e);o.setEventCallback(function(e){e.redraw!==!1&&r()});var a=[];return{subscribe:t,unsubscribe:n,redraw:r,render:o.render}}(window);c.setCompletionCallback(d.redraw);l.mount=function(e){return function(t,r){if(null===r)return e.render(t,[]),void e.unsubscribe(t);if(null==r.view)throw new Error("m.mount(element, component) expects a component, not a vnode");var i=function(){e.render(t,n(r))};e.subscribe(t,i),e.redraw()}}(d);var v=s,h=function(e){if(""===e||null==e)return{};"?"===e.charAt(0)&&(e=e.slice(1));for(var t=e.split("&"),n={},r={},i=0;i<t.length;i++){var o=t[i].split("="),a=decodeURIComponent(o[0]),l=2===o.length?decodeURIComponent(o[1]):"";"true"===l?l=!0:"false"===l&&(l=!1);var s=a.split(/\]\[?|\[/),u=n;a.indexOf("[")>-1&&s.pop();for(var c=0;c<s.length;c++){var f=s[c],d=s[c+1],v=""==d||!isNaN(parseInt(d,10)),h=c===s.length-1;if(""===f){var a=s.slice(0,c).join();null==r[a]&&(r[a]=0),f=r[a]++}null==u[f]&&(u[f]=h?l:v?[]:{}),u=u[f]}}return n},p=function(e){function t(t){var n=e.location[t].replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent);return"pathname"===t&&"/"!==n[0]&&(n="/"+n),n}function n(e){return function(){null==i&&(i=a(function(){i=null,e()}))}}function r(e,t,n){var r=e.indexOf("?"),i=e.indexOf("#"),o=r>-1?r:i>-1?i:e.length;if(r>-1){var a=i>-1?i:e.length,l=h(e.slice(r+1,a));for(var s in l)t[s]=l[s]}if(i>-1){var u=h(e.slice(i+1));for(var s in u)n[s]=u[s]}return e.slice(0,o)}var i,o="function"==typeof e.history.pushState,a="function"==typeof setImmediate?setImmediate:setTimeout,l={prefix:"#!"};return l.getPath=function(){switch(l.prefix.charAt(0)){case"#":return t("hash").slice(l.prefix.length);case"?":return t("search").slice(l.prefix.length)+t("hash");default:return t("pathname").slice(l.prefix.length)+t("search")+t("hash")}},l.setPath=function(t,n,i){var a={},s={};if(t=r(t,a,s),null!=n){for(var c in n)a[c]=n[c];t=t.replace(/:([^\/]+)/g,function(e,t){return delete a[t],n[t]})}var f=u(a);f&&(t+="?"+f);var d=u(s);if(d&&(t+="#"+d),o){var v=i?i.state:null,h=i?i.title:null;e.onpopstate(),i&&i.replace?e.history.replaceState(v,h,l.prefix+t):e.history.pushState(v,h,l.prefix+t)}else e.location.href=l.prefix+t},l.defineRoutes=function(t,i,a){function s(){var n=l.getPath(),o={},s=r(n,o,o),u=e.history.state;if(null!=u)for(var c in u)o[c]=u[c];for(var f in t){var d=new RegExp("^"+f.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$");if(d.test(s))return void s.replace(d,function(){for(var e=f.match(/:[^\/]+/g)||[],r=[].slice.call(arguments,1,-2),a=0;a<e.length;a++)o[e[a].replace(/:|\./g,"")]=decodeURIComponent(r[a]);i(t[f],o,n,f)})}a(n,o)}o?e.onpopstate=n(s):"#"===l.prefix.charAt(0)&&(e.onhashchange=s),s()},l};l.route=function(e,t){var r,i,o,a,l,s=p(e),u=function(e){return e},c=function(e,c,f){if(null==e)throw new Error("Ensure the DOM element that was passed to `m.route` is not undefined");var d=function(){null!=r&&t.render(e,r(n(i,o.key,o)))},h=function(e){if(e===c)throw new Error("Could not resolve default route "+c);s.setPath(c,null,{replace:!0})};s.defineRoutes(f,function(e,t,n){var s=l=function(e,c){s===l&&(i=null!=c&&"function"==typeof c.view?c:"div",o=t,a=n,l=null,r=(e.render||u).bind(e),d())};e.view?s({},e):e.onmatch?v.resolve(e.onmatch(t,n)).then(function(t){s(e,t)},h):s(e,"div")},h),t.subscribe(e,d)};return c.set=function(e,t,n){null!=l&&(n={replace:!0}),l=null,s.setPath(e,t,n)},c.get=function(){return a},c.prefix=function(e){s.prefix=e},c.link=function(e){e.dom.setAttribute("href",s.prefix+e.attrs.href),e.dom.onclick=function(e){if(!(e.ctrlKey||e.metaKey||e.shiftKey||2===e.which)){e.preventDefault(),e.redraw=!1;var t=this.getAttribute("href");0===t.indexOf(s.prefix)&&(t=t.slice(s.prefix.length)),c.set(t,void 0,void 0)}}},c.param=function(e){return void 0!==o&&void 0!==e?o[e]:o},c}(window,d),l.withAttr=function(e,t,n){return function(r){t.call(n||this,e in r.currentTarget?r.currentTarget[e]:r.currentTarget.getAttribute(e))}};var m=f(window);l.render=m.render,l.redraw=d.redraw,l.request=c.request,l.jsonp=c.jsonp,l.parseQueryString=h,l.buildQueryString=u,l.version="1.0.1",l.vnode=n,void 0!==t?t.exports=l:window.m=l}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],8:[function(e,n,r){!function(e){"use strict";function r(){}function i(e,t){for(var n=e.length;n--;)if(e[n].listener===t)return n;return-1}function o(e){return function(){return this[e].apply(this,arguments)}}function a(e){return"function"==typeof e||e instanceof RegExp||!(!e||"object"!=typeof e)&&a(e.listener)}var l=r.prototype,s=e.EventEmitter;l.getListeners=function(e){var t,n,r=this._getEvents();if(e instanceof RegExp){t={};for(n in r)r.hasOwnProperty(n)&&e.test(n)&&(t[n]=r[n])}else t=r[e]||(r[e]=[]);return t},l.flattenListeners=function(e){var t,n=[];for(t=0;t<e.length;t+=1)n.push(e[t].listener);return n},l.getListenersAsObject=function(e){var t,n=this.getListeners(e);return n instanceof Array&&(t={},t[e]=n),t||n},l.addListener=function(e,t){if(!a(t))throw new TypeError("listener must be a function");var n,r=this.getListenersAsObject(e),o="object"==typeof t;for(n in r)r.hasOwnProperty(n)&&i(r[n],t)===-1&&r[n].push(o?t:{listener:t,once:!1});return this},l.on=o("addListener"),l.addOnceListener=function(e,t){return this.addListener(e,{listener:t,once:!0})},l.once=o("addOnceListener"),l.defineEvent=function(e){return this.getListeners(e),this},l.defineEvents=function(e){for(var t=0;t<e.length;t+=1)this.defineEvent(e[t]);return this},l.removeListener=function(e,t){var n,r,o=this.getListenersAsObject(e);for(r in o)o.hasOwnProperty(r)&&(n=i(o[r],t))!==-1&&o[r].splice(n,1);return this},l.off=o("removeListener"),l.addListeners=function(e,t){return this.manipulateListeners(!1,e,t)},l.removeListeners=function(e,t){return this.manipulateListeners(!0,e,t)},l.manipulateListeners=function(e,t,n){var r,i,o=e?this.removeListener:this.addListener,a=e?this.removeListeners:this.addListeners;if("object"!=typeof t||t instanceof RegExp)for(r=n.length;r--;)o.call(this,t,n[r]);else for(r in t)t.hasOwnProperty(r)&&(i=t[r])&&("function"==typeof i?o.call(this,r,i):a.call(this,r,i));return this},l.removeEvent=function(e){var t,n=typeof e,r=this._getEvents();if("string"===n)delete r[e];else if(e instanceof RegExp)for(t in r)r.hasOwnProperty(t)&&e.test(t)&&delete r[t];else delete this._events;return this},l.removeAllListeners=o("removeEvent"),l.emitEvent=function(e,t){var n,r,i,o,a=this.getListenersAsObject(e);for(o in a)if(a.hasOwnProperty(o))for(n=a[o].slice(0),i=0;i<n.length;i++)r=n[i],r.once===!0&&this.removeListener(e,r.listener),r.listener.apply(this,t||[])===this._getOnceReturnValue()&&this.removeListener(e,r.listener);return this},l.trigger=o("emitEvent"),l.emit=function(e){var t=Array.prototype.slice.call(arguments,1);return this.emitEvent(e,t)},l.setOnceReturnValue=function(e){return this._onceReturnValue=e,this},l._getOnceReturnValue=function(){return!this.hasOwnProperty("_onceReturnValue")||this._onceReturnValue},l._getEvents=function(){return this._events||(this._events={})},r.noConflict=function(){return e.EventEmitter=s,r},"function"==typeof t&&t.amd?t(function(){return r}):"object"==typeof n&&n.exports?n.exports=r:e.EventEmitter=r}(this||{})},{}]},{},[1])}();
2
  //# sourceMappingURL=admin.min.js.map
assets/js/admin.min.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["admin.js"],"names":["require","undefined","define","e","t","n","r","s","o","u","a","i","f","Error","code","l","exports","call","length","1","module","m","window","EventEmitter","context","document","getElementById","events","tabs","helpers","settings","ListFetcher","mount","mc4wp","deps","mithril","./admin/helpers.js","./admin/list-fetcher.js","./admin/settings.js","./admin/tabs.js","wolfy87-eventemitter","2","toggleElement","selector","elements","querySelectorAll","show","clientHeight","style","display","bindEventToElement","element","event","handler","addEventListener","attachEvent","bindEventToElements","Array","prototype","forEach","debounce","func","wait","immediate","timeout","this","args","arguments","later","apply","callNow","clearTimeout","setTimeout","showIfElements","getAttribute","checked","value","conditionMet","config","hide","visibility","opacity","inputs","inputElement","removeAttribute","setAttribute","JSON","parse","parentElements","parentElement","3","working","done","mailchimp","api_connected","lists","fetch","$","jQuery","mc4wp_vars","i18n","preventDefault","post","ajaxurl","action","data","location","reload","always","redraw","bind","view","method","onsubmit","type","fetching_mailchimp_lists","renew_mailchimp_lists","className","disabled","trust","fetching_mailchimp_lists_can_take_a_while","fetching_mailchimp_lists_done","4","Settings","getSelectedListsWhere","searchKey","searchValue","selectedLists","filter","el","getSelectedLists","updateSelectedLists","listInputs","input","push","trigger","toggleVisibleLists","rows","listId","isSelected","replace","querySelector","on","5","URL","Tabs","get","id","open","tab","updateState","$tabs","removeClass","css","$tabNavs","nav","blur","url","setParameter","href","history","pushState","title","refererField","tb_remove","forms","editor","refresh","split","switchTab","tabId","match","urlParams","opened","returnValue","init","activeTab","substring","replaceState","state","$context","find","each","first","text","click","body","./url.js","6","query","hasOwnProperty","b","decodeURIComponent","build","ret","d","encodeURIComponent","join","key","7","global","factory","amd","isFunction","object","isObject","isString","noop","initialize","mock","$document","$location","$cancelAnimationFrame","cancelAnimationFrame","$requestAnimationFrame","requestAnimationFrame","parseTagAttrs","cell","tag","classes","parser","exec","attrs","pair","getVirtualChildren","hasAttrs","children","slice","isArray","assignAttrs","target","classAttr","attrName","hasOwn","pairs","parameterize","list","forKeys","dataToString","toString","injectTextNode","index","insertNode","nodeValue","flatten","concat","node","insertBefore","childNodes","handleKeysDiffer","existing","cached","MOVE","from","nodes","createElement","INSERTION","actions","prop","changes","sort","sortChanges","newCached","change","DELETION","clear","splice","dummy","changeElement","maybeChanged","diffKeys","keysDiffer","cachedCell","diffArray","_","parentNode","indexOf","buildArrayKeys","guid","isDifferentEnough","dataAttrKeys","Object","keys","strategy","configContext","retain","maybeRecreateObject","onunload","controllers","controller","getObjectNamespace","namespace","xmlns","unloadCachedControllers","views","$old","pendingRequests","scheduleConfigsToBeCalled","configs","isNew","buildUpdatedNode","editable","hasKeys","setAttributes","contenteditable","intact","handleNonexistentNodes","$trusted","injectHTML","createTextNode","nodeName","voidElements","constructor","reattachNodes","parentTag","activeElement","innerHTML","nodeType","trim","handleTextNode","shouldReattach","valueOf","getSubArrayCount","item","buildArray","subArrayCount","shouldMaintainIdentities","cacheCount","len","makeCache","parentIndex","parentCache","offset","end","constructNode","is","createElementNS","constructAttrs","constructChildren","reconstructCached","getController","cachedControllers","controllerIndex","updateLists","unloaders","map","checkView","forcing","subtree","markViews","$original","buildObject","copyStyleAttrs","dataAttr","cachedAttr","rule","setSingleAttr","autoredraw","setAttributeNS","shouldUseSetAttribute","trySetAttr","cachedAttrs","message","dataAttrs","removeChild","unload","appendTextFragment","appendChild","createRange","createContextualFragment","insertAdjacentHTML","replaceScriptNodes","tagName","replaceChild","buildExecutableNode","scriptEl","attributes","name","nextSibling","isElement","placeholder","callback","startComputation","endFirstComputation","getCellCacheKey","nodeCache","gettersetter","store","toJSON","component","ctrl","currentArgs","output","checkPrevented","root","isPrevented","roots","currentComponent","topComponent","components","removeRootElement","reset","computePreRedrawHook","render","computePostRedrawHook","lastRedrawId","lastRedrawCallTime","Date","endComputation","normalizeRoute","route","modes","mode","routeByValue","router","path","routeParams","queryStart","parseQueryString","substr","matcher","RegExp","test","values","routeUnobtrusive","ctrlKey","metaKey","shiftKey","which","currentTarget","srcElement","search","setScroll","hash","scrollTo","buildQueryString","prefix","duplicates","str","charAt","params","string","cacheKey","cellCache","propify","promise","initialValue","then","resolve","reject","Deferred","onSuccess","onFailure","finish","REJECTED","next","deferred","RESOLVED","promiseValue","thennable","success","failure","notThennable","count","onerror","fire","REJECTING","RESOLVING","self","TypeError","identity","handleJsonp","options","callbackKey","callbackName","getTime","Math","round","random","script","resp","onload","responseText","status","stringify","error","src","createXhr","xhr","XMLHttpRequest","user","password","onreadystatechange","readyState","serialize","setRequestHeader","deserialize","maybeXhr","FormData","send","ajax","dataType","toLowerCase","bindData","querystring","parameterizeUrl","token","version","AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR","html","form","width","height","documentNode","documentElement","forceRecreation","isDocumentRoot","String","Promise","FRAME_BUDGET","unloader","redrawing","force","withAttr","withAttrCallback","callbackThis","_this","currentRoute","pathname","redirect","isDefaultRoute","arg1","arg2","vdom","source","listener","base","removeEventListener","detachEvent","oldRoute","queryIndex","currentPath","replaceHistory","err","param","sync","synchronizer","pos","resolved","results","outstanding","arg","request","background","extract","isJSONP","jsonp","toUpperCase","ev","response","unwrapSuccess","res","unwrapError","8","indexOfListener","listeners","alias","proto","originalGlobalValue","getListeners","evt","_getEvents","flattenListeners","flatListeners","getListenersAsObject","addListener","listenerIsWrapped","once","addOnceListener","defineEvent","defineEvents","evts","removeListener","off","addListeners","manipulateListeners","removeListeners","remove","single","multiple","removeEvent","_events","removeAllListeners","emitEvent","listenersMap","_getOnceReturnValue","emit","setOnceReturnValue","_onceReturnValue","noConflict"],"mappings":"CAAA,WAAe,GAAIA,GAAUC,OAAeC,EAASD,QAAW,QAAUE,GAAEC,EAAEC,EAAEC,GAAG,QAASC,GAAEC,EAAEC,GAAG,IAAIJ,EAAEG,GAAG,CAAC,IAAIJ,EAAEI,GAAG,CAAC,GAAIE,GAAkB,kBAATV,IAAqBA,CAAQ,KAAIS,GAAGC,EAAE,MAAOA,GAAEF,GAAE,EAAI,IAAGG,EAAE,MAAOA,GAAEH,GAAE,EAAI,IAAII,GAAE,GAAIC,OAAM,uBAAuBL,EAAE,IAAK,MAAMI,GAAEE,KAAK,mBAAmBF,EAAE,GAAIG,GAAEV,EAAEG,IAAIQ,WAAYZ,GAAEI,GAAG,GAAGS,KAAKF,EAAEC,QAAQ,SAASb,GAAG,GAAIE,GAAED,EAAEI,GAAG,GAAGL,EAAG,OAAOI,GAAEF,EAAEA,EAAEF,IAAIY,EAAEA,EAAEC,QAAQb,EAAEC,EAAEC,EAAEC,GAAG,MAAOD,GAAEG,GAAGQ,QAAkD,IAAI,GAA1CL,GAAkB,kBAATX,IAAqBA,EAAgBQ,EAAE,EAAEA,EAAEF,EAAEY,OAAOV,IAAID,EAAED,EAAEE,GAAI,OAAOD,KAAKY,GAAG,SAASnB,EAAQoB,EAAOJ,GACvhB,YAGA,IAAIK,GAAIC,OAAOD,EAAIrB,EAAQ,WACvBuB,EAAevB,EAAQ,wBAGvBwB,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AM8B,mBAAqB,SAA4BxhB,GAEnD,MADAX,MAAKoiB,iBAAmBzhB,EACjBX,MAWXqgB,EAAM4B,oBAAsB,WACxB,OAAIjiB,KAAK6H,eAAe,qBACb7H,KAAKoiB,kBAapB/B,EAAMI,WAAa,WACf,MAAOzgB,MAAK6hB,UAAY7hB,KAAK6hB,aAQjCvkB,EAAa+kB,WAAa,WAEtB,MADAtlB,GAAQO,aAAegjB,EAChBhjB,GAIW,kBAAXrB,IAAyBA,EAAOwM,IACvCxM,EAAO,WACH,MAAOqB,KAGY,gBAAXH,IAAuBA,EAAOJ,QAC1CI,EAAOJ,QAAUO,EAGjBP,EAAQO,aAAeA,IAE7BN,KAAKgD,gBAEI","file":"admin.min.js","sourcesContent":["(function () { var require = undefined; var define = undefined; (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){\n'use strict';\n\n// dependencies\nvar m = window.m = require('mithril');\nvar EventEmitter = require('wolfy87-eventemitter');\n\n// vars\nvar context = document.getElementById('mc4wp-admin');\nvar events = new EventEmitter();\nvar tabs = require ('./admin/tabs.js')(context);\nvar helpers = require('./admin/helpers.js');\nvar settings = require('./admin/settings.js')(context, helpers, events);\n\n// list fetcher\nvar ListFetcher = require('./admin/list-fetcher.js');\nvar mount = document.getElementById('mc4wp-list-fetcher');\nif( mount ) {\n m.mount(mount, new ListFetcher);\n}\n\n// expose some things\nwindow.mc4wp = window.mc4wp || {};\nwindow.mc4wp.deps = window.mc4wp.deps || {};\nwindow.mc4wp.deps.mithril = m;\nwindow.mc4wp.helpers = helpers;\nwindow.mc4wp.events = events;\nwindow.mc4wp.settings = settings;\nwindow.mc4wp.tabs = tabs;\n},{\"./admin/helpers.js\":2,\"./admin/list-fetcher.js\":3,\"./admin/settings.js\":4,\"./admin/tabs.js\":5,\"mithril\":7,\"wolfy87-eventemitter\":8}],2:[function(require,module,exports){\n'use strict';\n\nvar helpers = {};\n\nhelpers.toggleElement = function(selector) {\n\tvar elements = document.querySelectorAll(selector);\n\tfor( var i=0; i<elements.length;i++){\n\t\tvar show = elements[i].clientHeight <= 0;\n\t\telements[i].style.display = show ? '' : 'none';\n\t}\n};\n\nhelpers.bindEventToElement = function(element,event,handler) {\n\tif ( element.addEventListener) {\n\t\telement.addEventListener(event, handler);\n\t} else if (element.attachEvent) {\n\t\telement.attachEvent('on' + event, handler);\n\t}\n};\n\nhelpers.bindEventToElements = function( elements, event, handler ) {\n\tArray.prototype.forEach.call( elements, function(element) {\n\t\thelpers.bindEventToElement(element,event,handler);\n\t});\n};\n\n\n// polling\nhelpers.debounce = function(func, wait, immediate) {\n\tvar timeout;\n\treturn function() {\n\t\tvar context = this, args = arguments;\n\t\tvar later = function() {\n\t\t\ttimeout = null;\n\t\t\tif (!immediate) func.apply(context, args);\n\t\t};\n\t\tvar callNow = immediate && !timeout;\n\t\tclearTimeout(timeout);\n\t\ttimeout = setTimeout(later, wait);\n\t\tif (callNow) func.apply(context, args);\n\t};\n};\n\n\n/**\n * Showif.js\n */\n(function() {\n\tvar showIfElements = document.querySelectorAll('[data-showif]');\n\n\t// dependent elements\n\tArray.prototype.forEach.call( showIfElements, function(element) {\n\t\tvar config = JSON.parse( element.getAttribute('data-showif') );\n\t\tvar parentElements = document.querySelectorAll('[name=\"'+ config.element +'\"]');\n\t\tvar inputs = element.querySelectorAll('input,select,textarea:not([readonly])');\n\t\tvar hide = config.hide === undefined || config.hide;\n\n\t\tfunction toggleElement() {\n\n\t\t\t// do nothing with unchecked radio inputs\n\t\t\tif( this.getAttribute('type') === \"radio\" && ! this.checked ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tvar value = ( this.getAttribute(\"type\") === \"checkbox\" ) ? this.checked : this.value;\n\t\t\tvar conditionMet = ( value == config.value );\n\n\t\t\tif( hide ) {\n\t\t\t\telement.style.display = conditionMet ? '' : 'none';\n\t\t\t\telement.style.visibility = conditionMet ? '' : 'hidden';\n\t\t\t} else {\n\t\t\t\telement.style.opacity = conditionMet ? '' : '0.4';\n\t\t\t}\n\n\t\t\t// disable input fields to stop sending their values to server\n\t\t\tArray.prototype.forEach.call( inputs, function(inputElement) {\n\t\t\t\tconditionMet ? inputElement.removeAttribute('readonly') : inputElement.setAttribute('readonly','readonly');\n\t\t\t});\n\t\t}\n\n\t\t// find checked element and call toggleElement function\n\t\tArray.prototype.forEach.call( parentElements, function( parentElement ) {\n\t\t\ttoggleElement.call(parentElement);\n\t\t});\n\n\t\t// bind on all changes\n\t\thelpers.bindEventToElements(parentElements, 'change', toggleElement);\n\t});\n})();\n\nmodule.exports = helpers;\n},{}],3:[function(require,module,exports){\n'use strict';\n\nvar $ = window.jQuery;\nvar config = mc4wp_vars;\nvar i18n = config.i18n;\n\nfunction ListFetcher() {\n this.working = false;\n this.done = false;\n\n // start fetching right away when no lists but api key given\n if( config.mailchimp.api_connected && config.mailchimp.lists.length == 0 ) {\n this.fetch();\n }\n}\n\nListFetcher.prototype.fetch = function (e) {\n e && e.preventDefault();\n\n this.working = true;\n this.done = false;\n\n $.post(ajaxurl, {\n action: \"mc4wp_renew_mailchimp_lists\"\n }).done(function(data) {\n if(data) {\n window.setTimeout(function() { window.location.reload(); }, 3000 );\n }\n }).always(function (data) {\n this.working = false;\n this.done = true;\n\n m.redraw();\n }.bind(this));\n};\n\nListFetcher.prototype.view = function () {\n return m('form', {\n method: \"POST\",\n onsubmit: this.fetch.bind(this)\n }, [\n m('p', [\n m('input', {\n type: \"submit\",\n value: this.working ? i18n.fetching_mailchimp_lists : i18n.renew_mailchimp_lists,\n className: \"button\",\n disabled: !!this.working\n }),\n m.trust(' &nbsp; '),\n\n this.working ? [\n m('span.mc4wp-loader', \"Loading...\"),\n m.trust(' &nbsp; '),\n m('em.help', i18n.fetching_mailchimp_lists_can_take_a_while)\n ]: '',\n\n this.done ? [\n m( 'em.help.green', i18n.fetching_mailchimp_lists_done )\n ] : ''\n ])\n ]);\n};\n\nmodule.exports = ListFetcher;\n},{}],4:[function(require,module,exports){\nvar Settings = function(context, helpers, events ) {\n\t'use strict';\n\n\t// vars\n\tvar form = context.querySelector('form');\n\tvar listInputs = context.querySelectorAll('.mc4wp-list-input');\n\tvar lists = mc4wp_vars.mailchimp.lists;\n\tvar selectedLists = [];\n\n\t// functions\n\tfunction getSelectedListsWhere(searchKey,searchValue) {\n\t\treturn selectedLists.filter(function(el) {\n\t\t\treturn el[searchKey] === searchValue;\n\t\t});\n\t}\n\n\tfunction getSelectedLists() {\n\t\treturn selectedLists;\n\t}\n\n\tfunction updateSelectedLists() {\n\t\tselectedLists = [];\n\n\t\tArray.prototype.forEach.call(listInputs, function(input) {\n\t\t\t// skip unchecked checkboxes\n\t\t\tif( typeof( input.checked ) === \"boolean\" && ! input.checked ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif( typeof( lists[ input.value ] ) === \"object\" ){\n\t\t\t\tselectedLists.push( lists[ input.value ] );\n\t\t\t}\n\t\t});\n\n\t\tevents.trigger('selectedLists.change', [ selectedLists ]);\n\t\treturn selectedLists;\n\t}\n\n\tfunction toggleVisibleLists() {\n\t\tvar rows = document.querySelectorAll('.lists--only-selected > *');\n\t\tArray.prototype.forEach.call(rows, function(el) {\n\n\t\t\tvar listId = el.getAttribute('data-list-id');\n\t\t\tvar isSelected = getSelectedListsWhere('id', listId).length > 0;\n\n\t\t\tif( isSelected ) {\n\t\t\t\tel.setAttribute('class', el.getAttribute('class').replace('hidden',''));\n\t\t\t} else {\n\t\t\t\tel.setAttribute('class', el.getAttribute('class') + \" hidden\" );\n\t\t\t}\n\t\t});\n\t}\n\n\tevents.on('selectedLists.change', toggleVisibleLists);\n\thelpers.bindEventToElements(listInputs,'change',updateSelectedLists);\n\n\tupdateSelectedLists();\n\n\treturn {\n\t\tgetSelectedLists: getSelectedLists\n\t}\n\n};\n\nmodule.exports = Settings;\n},{}],5:[function(require,module,exports){\n'use strict';\n\nvar URL = require('./url.js');\n\n// Tabs\nvar Tabs = function(context) {\n\n\t// @todo last piece of jQuery... can we get rid of it?\n\tvar $ = window.jQuery;\n\n\tvar $context = $(context);\n\tvar $tabs = $context.find('.tab');\n\tvar $tabNavs = $context.find('.nav-tab');\n\tvar refererField = context.querySelector('input[name=\"_wp_http_referer\"]');\n\tvar tabs = [];\n\n\t$.each($tabs, function(i,t) {\n\t\tvar id = t.id.substring(4);\n\t\tvar title = $(t).find('h2').first().text();\n\n\t\ttabs.push({\n\t\t\tid: id,\n\t\t\ttitle: title,\n\t\t\telement: t,\n\t\t\tnav: context.querySelectorAll('.nav-tab-' + id),\n\t\t\topen: function() { return open(id); }\n\t\t});\n\t});\n\n\tfunction get(id) {\n\n\t\tfor( var i=0; i<tabs.length; i++){\n\t\t\tif(tabs[i].id === id ) {\n\t\t\t\treturn tabs[i];\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tfunction open( tab, updateState ) {\n\n\t\t// make sure we have a tab object\n\t\tif(typeof(tab) === \"string\"){\n\t\t\ttab = get(tab);\n\t\t}\n\n\t\tif(!tab) { return false; }\n\n\t\t// should we update state?\n\t\tif( updateState == undefined ) {\n\t\t\tupdateState = true;\n\t\t}\n\n\t\t// hide all tabs & remove active class\n\t\t$tabs.removeClass('tab-active').css('display', 'none');\n\t\t$tabNavs.removeClass('nav-tab-active');\n\n\t\t// add `nav-tab-active` to this tab\n\t\tArray.prototype.forEach.call(tab.nav, function(nav) {\n\t\t\tnav.className += \" nav-tab-active\";\n\t\t\tnav.blur();\n\t\t});\n\n\t\t// show target tab\n\t\ttab.element.style.display = 'block';\n\t\ttab.element.className += \" tab-active\";\n\n\t\t// create new URL\n\t\tvar url = URL.setParameter(window.location.href, \"tab\", tab.id );\n\n\t\t// update hash\n\t\tif( history.pushState && updateState ) {\n\t\t\thistory.pushState( tab.id, '', url );\n\t\t}\n\n\t\t// update document title\n\t\ttitle(tab);\n\n\t\t// update referer field\n\t\trefererField.value = url;\n\n\t\t// if thickbox is open, close it.\n\t\tif( typeof(tb_remove) === \"function\" ) {\n\t\t\ttb_remove();\n\t\t}\n\n\t\t// refresh editor after switching tabs\n\t\t// TODO: decouple decouple decouple\n\t\tif( tab.id === 'fields' && window.mc4wp && window.mc4wp.forms && window.mc4wp.forms.editor ) {\n\t\t\tmc4wp.forms.editor.refresh();\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tfunction title(tab) {\n\t\tvar title = document.title.split('-');\n\t\tdocument.title = document.title.replace(title[0], tab.title + \" \");\n\t}\n\n\tfunction switchTab(e) {\n\t\te = e || window.event;\n\n\t\t// get from data attribute\n\t\tvar tabId = this.getAttribute('data-tab');\n\n\t\t// get from classname\n\t\tif( ! tabId ) {\n\t\t\tvar match = this.className.match(/nav-tab-(\\w+)?/);\n\t\t\tif( match ) {\n\t\t\t\ttabId = match[1];\n\t\t\t}\n\t\t}\n\n\t\t// get from href\n\t\tif( ! tabId ) {\n\t\t\tvar urlParams = URL.parse( this.href );\n\t\t\tif( ! urlParams.tab ) { return; }\n\t\t\ttabId = urlParams.tab;\n\t\t}\n\n\t\tvar opened = open( tabId );\n\n\t\tif( opened ) {\n\t\t\te.preventDefault();\n\t\t\te.returnValue = false;\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tfunction init() {\n\n\t\t// check for current tab\n\t\tif(! history.pushState) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar activeTab = $tabs.filter(':visible').get(0);\n\t\tif( ! activeTab ) { return; }\n\t\tvar tab = get(activeTab.id.substring(4));\n\t\tif(!tab) return;\n\n\t\t// check if tab is in html5 history\n\t\tif( history.replaceState && history.state === null) {\n\t\t\thistory.replaceState( tab.id, '' );\n\t\t}\n\n\t\t// update document title\n\t\ttitle(tab);\n\t}\n\n\t$tabNavs.click(switchTab);\n\t$(document.body).on('click', '.tab-link', switchTab);\n\tinit();\n\n\tif(window.addEventListener && history.pushState ) {\n\t\twindow.addEventListener('popstate', function(e) {\n\t\t\tif(!e.state) return true;\n\t\t\tvar tabId = e.state;\n\t\t\treturn open(tabId,false);\n\t\t});\n\t}\n\n\treturn {\n\t\topen: open,\n\t\tget: get\n\t}\n\n};\n\nmodule.exports = Tabs;\n},{\"./url.js\":6}],6:[function(require,module,exports){\n'use strict';\n\nvar URL = {\n\tparse: function(url) {\n\t\tvar query = {};\n\t\tvar a = url.split('&');\n\t\tfor (var i in a) {\n\t\t\tif(!a.hasOwnProperty(i)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tvar b = a[i].split('=');\n\t\t\tquery[decodeURIComponent(b[0])] = decodeURIComponent(b[1]);\n\t\t}\n\n\t\treturn query;\n\t},\n\tbuild: function(data) {\n\t\tvar ret = [];\n\t\tfor (var d in data)\n\t\t\tret.push(d + \"=\" + encodeURIComponent(data[d]));\n\t\treturn ret.join(\"&\");\n\t},\n\tsetParameter: function( url, key, value ) {\n\t\tvar data = URL.parse( url );\n\t\tdata[ key ] = value;\n\t\treturn URL.build( data );\n\t}\n};\n\nmodule.exports = URL;\n},{}],7:[function(require,module,exports){\n;(function (global, factory) { // eslint-disable-line\r\n\t\"use strict\"\r\n\t/* eslint-disable no-undef */\r\n\tvar m = factory(global)\r\n\tif (typeof module === \"object\" && module != null && module.exports) {\r\n\t\tmodule.exports = m\r\n\t} else if (typeof define === \"function\" && define.amd) {\r\n\t\tdefine(function () { return m })\r\n\t} else {\r\n\t\tglobal.m = m\r\n\t}\r\n\t/* eslint-enable no-undef */\r\n})(typeof window !== \"undefined\" ? window : this, function (global, undefined) { // eslint-disable-line\r\n\t\"use strict\"\r\n\r\n\tm.version = function () {\r\n\t\treturn \"v0.2.5\"\r\n\t}\r\n\r\n\tvar hasOwn = {}.hasOwnProperty\r\n\tvar type = {}.toString\r\n\r\n\tfunction isFunction(object) {\r\n\t\treturn typeof object === \"function\"\r\n\t}\r\n\r\n\tfunction isObject(object) {\r\n\t\treturn type.call(object) === \"[object Object]\"\r\n\t}\r\n\r\n\tfunction isString(object) {\r\n\t\treturn type.call(object) === \"[object String]\"\r\n\t}\r\n\r\n\tvar isArray = Array.isArray || function (object) {\r\n\t\treturn type.call(object) === \"[object Array]\"\r\n\t}\r\n\r\n\tfunction noop() {}\r\n\r\n\tvar voidElements = {\r\n\t\tAREA: 1,\r\n\t\tBASE: 1,\r\n\t\tBR: 1,\r\n\t\tCOL: 1,\r\n\t\tCOMMAND: 1,\r\n\t\tEMBED: 1,\r\n\t\tHR: 1,\r\n\t\tIMG: 1,\r\n\t\tINPUT: 1,\r\n\t\tKEYGEN: 1,\r\n\t\tLINK: 1,\r\n\t\tMETA: 1,\r\n\t\tPARAM: 1,\r\n\t\tSOURCE: 1,\r\n\t\tTRACK: 1,\r\n\t\tWBR: 1\r\n\t}\r\n\r\n\t// caching commonly used variables\r\n\tvar $document, $location, $requestAnimationFrame, $cancelAnimationFrame\r\n\r\n\t// self invoking function needed because of the way mocks work\r\n\tfunction initialize(mock) {\r\n\t\t$document = mock.document\r\n\t\t$location = mock.location\r\n\t\t$cancelAnimationFrame = mock.cancelAnimationFrame || mock.clearTimeout\r\n\t\t$requestAnimationFrame = mock.requestAnimationFrame || mock.setTimeout\r\n\t}\r\n\r\n\t// testing API\r\n\tm.deps = function (mock) {\r\n\t\tinitialize(global = mock || window)\r\n\t\treturn global\r\n\t}\r\n\r\n\tm.deps(global)\r\n\r\n\t/**\r\n\t * @typedef {String} Tag\r\n\t * A string that looks like -> div.classname#id[param=one][param2=two]\r\n\t * Which describes a DOM node\r\n\t */\r\n\r\n\tfunction parseTagAttrs(cell, tag) {\r\n\t\tvar classes = []\r\n\t\tvar parser = /(?:(^|#|\\.)([^#\\.\\[\\]]+))|(\\[.+?\\])/g\r\n\t\tvar match\r\n\r\n\t\twhile ((match = parser.exec(tag))) {\r\n\t\t\tif (match[1] === \"\" && match[2]) {\r\n\t\t\t\tcell.tag = match[2]\r\n\t\t\t} else if (match[1] === \"#\") {\r\n\t\t\t\tcell.attrs.id = match[2]\r\n\t\t\t} else if (match[1] === \".\") {\r\n\t\t\t\tclasses.push(match[2])\r\n\t\t\t} else if (match[3][0] === \"[\") {\r\n\t\t\t\tvar pair = /\\[(.+?)(?:=(\"|'|)(.*?)\\2)?\\]/.exec(match[3])\r\n\t\t\t\tcell.attrs[pair[1]] = pair[3] || \"\"\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn classes\r\n\t}\r\n\r\n\tfunction getVirtualChildren(args, hasAttrs) {\r\n\t\tvar children = hasAttrs ? args.slice(1) : args\r\n\r\n\t\tif (children.length === 1 && isArray(children[0])) {\r\n\t\t\treturn children[0]\r\n\t\t} else {\r\n\t\t\treturn children\r\n\t\t}\r\n\t}\r\n\r\n\tfunction assignAttrs(target, attrs, classes) {\r\n\t\tvar classAttr = \"class\" in attrs ? \"class\" : \"className\"\r\n\r\n\t\tfor (var attrName in attrs) {\r\n\t\t\tif (hasOwn.call(attrs, attrName)) {\r\n\t\t\t\tif (attrName === classAttr &&\r\n\t\t\t\t\t\tattrs[attrName] != null &&\r\n\t\t\t\t\t\tattrs[attrName] !== \"\") {\r\n\t\t\t\t\tclasses.push(attrs[attrName])\r\n\t\t\t\t\t// create key in correct iteration order\r\n\t\t\t\t\ttarget[attrName] = \"\"\r\n\t\t\t\t} else {\r\n\t\t\t\t\ttarget[attrName] = attrs[attrName]\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (classes.length) target[classAttr] = classes.join(\" \")\r\n\t}\r\n\r\n\t/**\r\n\t *\r\n\t * @param {Tag} The DOM node tag\r\n\t * @param {Object=[]} optional key-value pairs to be mapped to DOM attrs\r\n\t * @param {...mNode=[]} Zero or more Mithril child nodes. Can be an array,\r\n\t * or splat (optional)\r\n\t */\r\n\tfunction m(tag, pairs) {\r\n\t\tvar args = []\r\n\r\n\t\tfor (var i = 1, length = arguments.length; i < length; i++) {\r\n\t\t\targs[i - 1] = arguments[i]\r\n\t\t}\r\n\r\n\t\tif (isObject(tag)) return parameterize(tag, args)\r\n\r\n\t\tif (!isString(tag)) {\r\n\t\t\tthrow new Error(\"selector in m(selector, attrs, children) should \" +\r\n\t\t\t\t\"be a string\")\r\n\t\t}\r\n\r\n\t\tvar hasAttrs = pairs != null && isObject(pairs) &&\r\n\t\t\t!(\"tag\" in pairs || \"view\" in pairs || \"subtree\" in pairs)\r\n\r\n\t\tvar attrs = hasAttrs ? pairs : {}\r\n\t\tvar cell = {\r\n\t\t\ttag: \"div\",\r\n\t\t\tattrs: {},\r\n\t\t\tchildren: getVirtualChildren(args, hasAttrs)\r\n\t\t}\r\n\r\n\t\tassignAttrs(cell.attrs, attrs, parseTagAttrs(cell, tag))\r\n\t\treturn cell\r\n\t}\r\n\r\n\tfunction forEach(list, f) {\r\n\t\tfor (var i = 0; i < list.length && !f(list[i], i++);) {\r\n\t\t\t// function called in condition\r\n\t\t}\r\n\t}\r\n\r\n\tfunction forKeys(list, f) {\r\n\t\tforEach(list, function (attrs, i) {\r\n\t\t\treturn (attrs = attrs && attrs.attrs) &&\r\n\t\t\t\tattrs.key != null &&\r\n\t\t\t\tf(attrs, i)\r\n\t\t})\r\n\t}\r\n\t// This function was causing deopts in Chrome.\r\n\tfunction dataToString(data) {\r\n\t\t// data.toString() might throw or return null if data is the return\r\n\t\t// value of Console.log in some versions of Firefox (behavior depends on\r\n\t\t// version)\r\n\t\ttry {\r\n\t\t\tif (data != null && data.toString() != null) return data\r\n\t\t} catch (e) {\r\n\t\t\t// silently ignore errors\r\n\t\t}\r\n\t\treturn \"\"\r\n\t}\r\n\r\n\t// This function was causing deopts in Chrome.\r\n\tfunction injectTextNode(parentElement, first, index, data) {\r\n\t\ttry {\r\n\t\t\tinsertNode(parentElement, first, index)\r\n\t\t\tfirst.nodeValue = data\r\n\t\t} catch (e) {\r\n\t\t\t// IE erroneously throws error when appending an empty text node\r\n\t\t\t// after a null\r\n\t\t}\r\n\t}\r\n\r\n\tfunction flatten(list) {\r\n\t\t// recursively flatten array\r\n\t\tfor (var i = 0; i < list.length; i++) {\r\n\t\t\tif (isArray(list[i])) {\r\n\t\t\t\tlist = list.concat.apply([], list)\r\n\t\t\t\t// check current index again and flatten until there are no more\r\n\t\t\t\t// nested arrays at that index\r\n\t\t\t\ti--\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn list\r\n\t}\r\n\r\n\tfunction insertNode(parentElement, node, index) {\r\n\t\tparentElement.insertBefore(node,\r\n\t\t\tparentElement.childNodes[index] || null)\r\n\t}\r\n\r\n\tvar DELETION = 1\r\n\tvar INSERTION = 2\r\n\tvar MOVE = 3\r\n\r\n\tfunction handleKeysDiffer(data, existing, cached, parentElement) {\r\n\t\tforKeys(data, function (key, i) {\r\n\t\t\texisting[key = key.key] = existing[key] ? {\r\n\t\t\t\taction: MOVE,\r\n\t\t\t\tindex: i,\r\n\t\t\t\tfrom: existing[key].index,\r\n\t\t\t\telement: cached.nodes[existing[key].index] ||\r\n\t\t\t\t\t$document.createElement(\"div\")\r\n\t\t\t} : {action: INSERTION, index: i}\r\n\t\t})\r\n\r\n\t\tvar actions = []\r\n\t\tfor (var prop in existing) {\r\n\t\t\tif (hasOwn.call(existing, prop)) {\r\n\t\t\t\tactions.push(existing[prop])\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tvar changes = actions.sort(sortChanges)\r\n\t\tvar newCached = new Array(cached.length)\r\n\r\n\t\tnewCached.nodes = cached.nodes.slice()\r\n\r\n\t\tforEach(changes, function (change) {\r\n\t\t\tvar index = change.index\r\n\t\t\tif (change.action === DELETION) {\r\n\t\t\t\tclear(cached[index].nodes, cached[index])\r\n\t\t\t\tnewCached.splice(index, 1)\r\n\t\t\t}\r\n\t\t\tif (change.action === INSERTION) {\r\n\t\t\t\tvar dummy = $document.createElement(\"div\")\r\n\t\t\t\tdummy.key = data[index].attrs.key\r\n\t\t\t\tinsertNode(parentElement, dummy, index)\r\n\t\t\t\tnewCached.splice(index, 0, {\r\n\t\t\t\t\tattrs: {key: data[index].attrs.key},\r\n\t\t\t\t\tnodes: [dummy]\r\n\t\t\t\t})\r\n\t\t\t\tnewCached.nodes[index] = dummy\r\n\t\t\t}\r\n\r\n\t\t\tif (change.action === MOVE) {\r\n\t\t\t\tvar changeElement = change.element\r\n\t\t\t\tvar maybeChanged = parentElement.childNodes[index]\r\n\t\t\t\tif (maybeChanged !== changeElement && changeElement !== null) {\r\n\t\t\t\t\tparentElement.insertBefore(changeElement,\r\n\t\t\t\t\t\tmaybeChanged || null)\r\n\t\t\t\t}\r\n\t\t\t\tnewCached[index] = cached[change.from]\r\n\t\t\t\tnewCached.nodes[index] = changeElement\r\n\t\t\t}\r\n\t\t})\r\n\r\n\t\treturn newCached\r\n\t}\r\n\r\n\tfunction diffKeys(data, cached, existing, parentElement) {\r\n\t\tvar keysDiffer = data.length !== cached.length\r\n\r\n\t\tif (!keysDiffer) {\r\n\t\t\tforKeys(data, function (attrs, i) {\r\n\t\t\t\tvar cachedCell = cached[i]\r\n\t\t\t\treturn keysDiffer = cachedCell &&\r\n\t\t\t\t\tcachedCell.attrs &&\r\n\t\t\t\t\tcachedCell.attrs.key !== attrs.key\r\n\t\t\t})\r\n\t\t}\r\n\r\n\t\tif (keysDiffer) {\r\n\t\t\treturn handleKeysDiffer(data, existing, cached, parentElement)\r\n\t\t} else {\r\n\t\t\treturn cached\r\n\t\t}\r\n\t}\r\n\r\n\tfunction diffArray(data, cached, nodes) {\r\n\t\t// diff the array itself\r\n\r\n\t\t// update the list of DOM nodes by collecting the nodes from each item\r\n\t\tforEach(data, function (_, i) {\r\n\t\t\tif (cached[i] != null) nodes.push.apply(nodes, cached[i].nodes)\r\n\t\t})\r\n\t\t// remove items from the end of the array if the new array is shorter\r\n\t\t// than the old one. if errors ever happen here, the issue is most\r\n\t\t// likely a bug in the construction of the `cached` data structure\r\n\t\t// somewhere earlier in the program\r\n\t\tforEach(cached.nodes, function (node, i) {\r\n\t\t\tif (node.parentNode != null && nodes.indexOf(node) < 0) {\r\n\t\t\t\tclear([node], [cached[i]])\r\n\t\t\t}\r\n\t\t})\r\n\r\n\t\tif (data.length < cached.length) cached.length = data.length\r\n\t\tcached.nodes = nodes\r\n\t}\r\n\r\n\tfunction buildArrayKeys(data) {\r\n\t\tvar guid = 0\r\n\t\tforKeys(data, function () {\r\n\t\t\tforEach(data, function (attrs) {\r\n\t\t\t\tif ((attrs = attrs && attrs.attrs) && attrs.key == null) {\r\n\t\t\t\t\tattrs.key = \"__mithril__\" + guid++\r\n\t\t\t\t}\r\n\t\t\t})\r\n\t\t\treturn 1\r\n\t\t})\r\n\t}\r\n\r\n\tfunction isDifferentEnough(data, cached, dataAttrKeys) {\r\n\t\tif (data.tag !== cached.tag) return true\r\n\r\n\t\tif (dataAttrKeys.sort().join() !==\r\n\t\t\t\tObject.keys(cached.attrs).sort().join()) {\r\n\t\t\treturn true\r\n\t\t}\r\n\r\n\t\tif (data.attrs.id !== cached.attrs.id) {\r\n\t\t\treturn true\r\n\t\t}\r\n\r\n\t\tif (data.attrs.key !== cached.attrs.key) {\r\n\t\t\treturn true\r\n\t\t}\r\n\r\n\t\tif (m.redraw.strategy() === \"all\") {\r\n\t\t\treturn !cached.configContext || cached.configContext.retain !== true\r\n\t\t}\r\n\r\n\t\tif (m.redraw.strategy() === \"diff\") {\r\n\t\t\treturn cached.configContext && cached.configContext.retain === false\r\n\t\t}\r\n\r\n\t\treturn false\r\n\t}\r\n\r\n\tfunction maybeRecreateObject(data, cached, dataAttrKeys) {\r\n\t\t// if an element is different enough from the one in cache, recreate it\r\n\t\tif (isDifferentEnough(data, cached, dataAttrKeys)) {\r\n\t\t\tif (cached.nodes.length) clear(cached.nodes)\r\n\r\n\t\t\tif (cached.configContext &&\r\n\t\t\t\t\tisFunction(cached.configContext.onunload)) {\r\n\t\t\t\tcached.configContext.onunload()\r\n\t\t\t}\r\n\r\n\t\t\tif (cached.controllers) {\r\n\t\t\t\tforEach(cached.controllers, function (controller) {\r\n\t\t\t\t\tif (controller.onunload) {\r\n\t\t\t\t\t\tcontroller.onunload({preventDefault: noop})\r\n\t\t\t\t\t}\r\n\t\t\t\t})\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tfunction getObjectNamespace(data, namespace) {\r\n\t\tif (data.attrs.xmlns) return data.attrs.xmlns\r\n\t\tif (data.tag === \"svg\") return \"http://www.w3.org/2000/svg\"\r\n\t\tif (data.tag === \"math\") return \"http://www.w3.org/1998/Math/MathML\"\r\n\t\treturn namespace\r\n\t}\r\n\r\n\tvar pendingRequests = 0\r\n\tm.startComputation = function () { pendingRequests++ }\r\n\tm.endComputation = function () {\r\n\t\tif (pendingRequests > 1) {\r\n\t\t\tpendingRequests--\r\n\t\t} else {\r\n\t\t\tpendingRequests = 0\r\n\t\t\tm.redraw()\r\n\t\t}\r\n\t}\r\n\r\n\tfunction unloadCachedControllers(cached, views, controllers) {\r\n\t\tif (controllers.length) {\r\n\t\t\tcached.views = views\r\n\t\t\tcached.controllers = controllers\r\n\t\t\tforEach(controllers, function (controller) {\r\n\t\t\t\tif (controller.onunload && controller.onunload.$old) {\r\n\t\t\t\t\tcontroller.onunload = controller.onunload.$old\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (pendingRequests && controller.onunload) {\r\n\t\t\t\t\tvar onunload = controller.onunload\r\n\t\t\t\t\tcontroller.onunload = noop\r\n\t\t\t\t\tcontroller.onunload.$old = onunload\r\n\t\t\t\t}\r\n\t\t\t})\r\n\t\t}\r\n\t}\r\n\r\n\tfunction scheduleConfigsToBeCalled(configs, data, node, isNew, cached) {\r\n\t\t// schedule configs to be called. They are called after `build` finishes\r\n\t\t// running\r\n\t\tif (isFunction(data.attrs.config)) {\r\n\t\t\tvar context = cached.configContext = cached.configContext || {}\r\n\r\n\t\t\t// bind\r\n\t\t\tconfigs.push(function () {\r\n\t\t\t\treturn data.attrs.config.call(data, node, !isNew, context,\r\n\t\t\t\t\tcached)\r\n\t\t\t})\r\n\t\t}\r\n\t}\r\n\r\n\tfunction buildUpdatedNode(\r\n\t\tcached,\r\n\t\tdata,\r\n\t\teditable,\r\n\t\thasKeys,\r\n\t\tnamespace,\r\n\t\tviews,\r\n\t\tconfigs,\r\n\t\tcontrollers\r\n\t) {\r\n\t\tvar node = cached.nodes[0]\r\n\r\n\t\tif (hasKeys) {\r\n\t\t\tsetAttributes(node, data.tag, data.attrs, cached.attrs, namespace)\r\n\t\t}\r\n\r\n\t\tcached.children = build(\r\n\t\t\tnode,\r\n\t\t\tdata.tag,\r\n\t\t\tundefined,\r\n\t\t\tundefined,\r\n\t\t\tdata.children,\r\n\t\t\tcached.children,\r\n\t\t\tfalse,\r\n\t\t\t0,\r\n\t\t\tdata.attrs.contenteditable ? node : editable,\r\n\t\t\tnamespace,\r\n\t\t\tconfigs\r\n\t\t)\r\n\r\n\t\tcached.nodes.intact = true\r\n\r\n\t\tif (controllers.length) {\r\n\t\t\tcached.views = views\r\n\t\t\tcached.controllers = controllers\r\n\t\t}\r\n\r\n\t\treturn node\r\n\t}\r\n\r\n\tfunction handleNonexistentNodes(data, parentElement, index) {\r\n\t\tvar nodes\r\n\t\tif (data.$trusted) {\r\n\t\t\tnodes = injectHTML(parentElement, index, data)\r\n\t\t} else {\r\n\t\t\tnodes = [$document.createTextNode(data)]\r\n\t\t\tif (!(parentElement.nodeName in voidElements)) {\r\n\t\t\t\tinsertNode(parentElement, nodes[0], index)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tvar cached\r\n\r\n\t\tif (typeof data === \"string\" ||\r\n\t\t\t\ttypeof data === \"number\" ||\r\n\t\t\t\ttypeof data === \"boolean\") {\r\n\t\t\tcached = new data.constructor(data)\r\n\t\t} else {\r\n\t\t\tcached = data\r\n\t\t}\r\n\r\n\t\tcached.nodes = nodes\r\n\t\treturn cached\r\n\t}\r\n\r\n\tfunction reattachNodes(\r\n\t\tdata,\r\n\t\tcached,\r\n\t\tparentElement,\r\n\t\teditable,\r\n\t\tindex,\r\n\t\tparentTag\r\n\t) {\r\n\t\tvar nodes = cached.nodes\r\n\t\tif (!editable || editable !== $document.activeElement) {\r\n\t\t\tif (data.$trusted) {\r\n\t\t\t\tclear(nodes, cached)\r\n\t\t\t\tnodes = injectHTML(parentElement, index, data)\r\n\t\t\t} else if (parentTag === \"textarea\") {\r\n\t\t\t\t// <textarea> uses `value` instead of `nodeValue`.\r\n\t\t\t\tparentElement.value = data\r\n\t\t\t} else if (editable) {\r\n\t\t\t\t// contenteditable nodes use `innerHTML` instead of `nodeValue`.\r\n\t\t\t\teditable.innerHTML = data\r\n\t\t\t} else {\r\n\t\t\t\t// was a trusted string\r\n\t\t\t\tif (nodes[0].nodeType === 1 || nodes.length > 1 ||\r\n\t\t\t\t\t\t(nodes[0].nodeValue.trim &&\r\n\t\t\t\t\t\t\t!nodes[0].nodeValue.trim())) {\r\n\t\t\t\t\tclear(cached.nodes, cached)\r\n\t\t\t\t\tnodes = [$document.createTextNode(data)]\r\n\t\t\t\t}\r\n\r\n\t\t\t\tinjectTextNode(parentElement, nodes[0], index, data)\r\n\t\t\t}\r\n\t\t}\r\n\t\tcached = new data.constructor(data)\r\n\t\tcached.nodes = nodes\r\n\t\treturn cached\r\n\t}\r\n\r\n\tfunction handleTextNode(\r\n\t\tcached,\r\n\t\tdata,\r\n\t\tindex,\r\n\t\tparentElement,\r\n\t\tshouldReattach,\r\n\t\teditable,\r\n\t\tparentTag\r\n\t) {\r\n\t\tif (!cached.nodes.length) {\r\n\t\t\treturn handleNonexistentNodes(data, parentElement, index)\r\n\t\t} else if (cached.valueOf() !== data.valueOf() || shouldReattach) {\r\n\t\t\treturn reattachNodes(data, cached, parentElement, editable, index,\r\n\t\t\t\tparentTag)\r\n\t\t} else {\r\n\t\t\treturn (cached.nodes.intact = true, cached)\r\n\t\t}\r\n\t}\r\n\r\n\tfunction getSubArrayCount(item) {\r\n\t\tif (item.$trusted) {\r\n\t\t\t// fix offset of next element if item was a trusted string w/ more\r\n\t\t\t// than one html element\r\n\t\t\t// the first clause in the regexp matches elements\r\n\t\t\t// the second clause (after the pipe) matches text nodes\r\n\t\t\tvar match = item.match(/<[^\\/]|\\>\\s*[^<]/g)\r\n\t\t\tif (match != null) return match.length\r\n\t\t} else if (isArray(item)) {\r\n\t\t\treturn item.length\r\n\t\t}\r\n\t\treturn 1\r\n\t}\r\n\r\n\tfunction buildArray(\r\n\t\tdata,\r\n\t\tcached,\r\n\t\tparentElement,\r\n\t\tindex,\r\n\t\tparentTag,\r\n\t\tshouldReattach,\r\n\t\teditable,\r\n\t\tnamespace,\r\n\t\tconfigs\r\n\t) {\r\n\t\tdata = flatten(data)\r\n\t\tvar nodes = []\r\n\t\tvar intact = cached.length === data.length\r\n\t\tvar subArrayCount = 0\r\n\r\n\t\t// keys algorithm: sort elements without recreating them if keys are\r\n\t\t// present\r\n\t\t//\r\n\t\t// 1) create a map of all existing keys, and mark all for deletion\r\n\t\t// 2) add new keys to map and mark them for addition\r\n\t\t// 3) if key exists in new list, change action from deletion to a move\r\n\t\t// 4) for each key, handle its corresponding action as marked in\r\n\t\t// previous steps\r\n\r\n\t\tvar existing = {}\r\n\t\tvar shouldMaintainIdentities = false\r\n\r\n\t\tforKeys(cached, function (attrs, i) {\r\n\t\t\tshouldMaintainIdentities = true\r\n\t\t\texisting[cached[i].attrs.key] = {action: DELETION, index: i}\r\n\t\t})\r\n\r\n\t\tbuildArrayKeys(data)\r\n\t\tif (shouldMaintainIdentities) {\r\n\t\t\tcached = diffKeys(data, cached, existing, parentElement)\r\n\t\t}\r\n\t\t// end key algorithm\r\n\r\n\t\tvar cacheCount = 0\r\n\t\t// faster explicitly written\r\n\t\tfor (var i = 0, len = data.length; i < len; i++) {\r\n\t\t\t// diff each item in the array\r\n\t\t\tvar item = build(\r\n\t\t\t\tparentElement,\r\n\t\t\t\tparentTag,\r\n\t\t\t\tcached,\r\n\t\t\t\tindex,\r\n\t\t\t\tdata[i],\r\n\t\t\t\tcached[cacheCount],\r\n\t\t\t\tshouldReattach,\r\n\t\t\t\tindex + subArrayCount || subArrayCount,\r\n\t\t\t\teditable,\r\n\t\t\t\tnamespace,\r\n\t\t\t\tconfigs)\r\n\r\n\t\t\tif (item !== undefined) {\r\n\t\t\t\tintact = intact && item.nodes.intact\r\n\t\t\t\tsubArrayCount += getSubArrayCount(item)\r\n\t\t\t\tcached[cacheCount++] = item\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (!intact) diffArray(data, cached, nodes)\r\n\t\treturn cached\r\n\t}\r\n\r\n\tfunction makeCache(data, cached, index, parentIndex, parentCache) {\r\n\t\tif (cached != null) {\r\n\t\t\tif (type.call(cached) === type.call(data)) return cached\r\n\r\n\t\t\tif (parentCache && parentCache.nodes) {\r\n\t\t\t\tvar offset = index - parentIndex\r\n\t\t\t\tvar end = offset + (isArray(data) ? data : cached.nodes).length\r\n\t\t\t\tclear(\r\n\t\t\t\t\tparentCache.nodes.slice(offset, end),\r\n\t\t\t\t\tparentCache.slice(offset, end))\r\n\t\t\t} else if (cached.nodes) {\r\n\t\t\t\tclear(cached.nodes, cached)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tcached = new data.constructor()\r\n\t\t// if constructor creates a virtual dom element, use a blank object as\r\n\t\t// the base cached node instead of copying the virtual el (#277)\r\n\t\tif (cached.tag) cached = {}\r\n\t\tcached.nodes = []\r\n\t\treturn cached\r\n\t}\r\n\r\n\tfunction constructNode(data, namespace) {\r\n\t\tif (data.attrs.is) {\r\n\t\t\tif (namespace == null) {\r\n\t\t\t\treturn $document.createElement(data.tag, data.attrs.is)\r\n\t\t\t} else {\r\n\t\t\t\treturn $document.createElementNS(namespace, data.tag,\r\n\t\t\t\t\tdata.attrs.is)\r\n\t\t\t}\r\n\t\t} else if (namespace == null) {\r\n\t\t\treturn $document.createElement(data.tag)\r\n\t\t} else {\r\n\t\t\treturn $document.createElementNS(namespace, data.tag)\r\n\t\t}\r\n\t}\r\n\r\n\tfunction constructAttrs(data, node, namespace, hasKeys) {\r\n\t\tif (hasKeys) {\r\n\t\t\treturn setAttributes(node, data.tag, data.attrs, {}, namespace)\r\n\t\t} else {\r\n\t\t\treturn data.attrs\r\n\t\t}\r\n\t}\r\n\r\n\tfunction constructChildren(\r\n\t\tdata,\r\n\t\tnode,\r\n\t\tcached,\r\n\t\teditable,\r\n\t\tnamespace,\r\n\t\tconfigs\r\n\t) {\r\n\t\tif (data.children != null && data.children.length > 0) {\r\n\t\t\treturn build(\r\n\t\t\t\tnode,\r\n\t\t\t\tdata.tag,\r\n\t\t\t\tundefined,\r\n\t\t\t\tundefined,\r\n\t\t\t\tdata.children,\r\n\t\t\t\tcached.children,\r\n\t\t\t\ttrue,\r\n\t\t\t\t0,\r\n\t\t\t\tdata.attrs.contenteditable ? node : editable,\r\n\t\t\t\tnamespace,\r\n\t\t\t\tconfigs)\r\n\t\t} else {\r\n\t\t\treturn data.children\r\n\t\t}\r\n\t}\r\n\r\n\tfunction reconstructCached(\r\n\t\tdata,\r\n\t\tattrs,\r\n\t\tchildren,\r\n\t\tnode,\r\n\t\tnamespace,\r\n\t\tviews,\r\n\t\tcontrollers\r\n\t) {\r\n\t\tvar cached = {\r\n\t\t\ttag: data.tag,\r\n\t\t\tattrs: attrs,\r\n\t\t\tchildren: children,\r\n\t\t\tnodes: [node]\r\n\t\t}\r\n\r\n\t\tunloadCachedControllers(cached, views, controllers)\r\n\r\n\t\tif (cached.children && !cached.children.nodes) {\r\n\t\t\tcached.children.nodes = []\r\n\t\t}\r\n\r\n\t\t// edge case: setting value on <select> doesn't work before children\r\n\t\t// exist, so set it again after children have been created\r\n\t\tif (data.tag === \"select\" && \"value\" in data.attrs) {\r\n\t\t\tsetAttributes(node, data.tag, {value: data.attrs.value}, {},\r\n\t\t\t\tnamespace)\r\n\t\t}\r\n\r\n\t\treturn cached\r\n\t}\r\n\r\n\tfunction getController(views, view, cachedControllers, controller) {\r\n\t\tvar controllerIndex\r\n\r\n\t\tif (m.redraw.strategy() === \"diff\" && views) {\r\n\t\t\tcontrollerIndex = views.indexOf(view)\r\n\t\t} else {\r\n\t\t\tcontrollerIndex = -1\r\n\t\t}\r\n\r\n\t\tif (controllerIndex > -1) {\r\n\t\t\treturn cachedControllers[controllerIndex]\r\n\t\t} else if (isFunction(controller)) {\r\n\t\t\treturn new controller()\r\n\t\t} else {\r\n\t\t\treturn {}\r\n\t\t}\r\n\t}\r\n\r\n\tvar unloaders = []\r\n\r\n\tfunction updateLists(views, controllers, view, controller) {\r\n\t\tif (controller.onunload != null &&\r\n\t\t\t\tunloaders.map(function (u) { return u.handler })\r\n\t\t\t\t\t.indexOf(controller.onunload) < 0) {\r\n\t\t\tunloaders.push({\r\n\t\t\t\tcontroller: controller,\r\n\t\t\t\thandler: controller.onunload\r\n\t\t\t})\r\n\t\t}\r\n\r\n\t\tviews.push(view)\r\n\t\tcontrollers.push(controller)\r\n\t}\r\n\r\n\tvar forcing = false\r\n\tfunction checkView(\r\n\t\tdata,\r\n\t\tview,\r\n\t\tcached,\r\n\t\tcachedControllers,\r\n\t\tcontrollers,\r\n\t\tviews\r\n\t) {\r\n\t\tvar controller = getController(\r\n\t\t\tcached.views,\r\n\t\t\tview,\r\n\t\t\tcachedControllers,\r\n\t\t\tdata.controller)\r\n\r\n\t\tvar key = data && data.attrs && data.attrs.key\r\n\r\n\t\tif (pendingRequests === 0 ||\r\n\t\t\t\tforcing ||\r\n\t\t\t\tcachedControllers &&\r\n\t\t\t\t\tcachedControllers.indexOf(controller) > -1) {\r\n\t\t\tdata = data.view(controller)\r\n\t\t} else {\r\n\t\t\tdata = {tag: \"placeholder\"}\r\n\t\t}\r\n\r\n\t\tif (data.subtree === \"retain\") return data\r\n\t\tdata.attrs = data.attrs || {}\r\n\t\tdata.attrs.key = key\r\n\t\tupdateLists(views, controllers, view, controller)\r\n\t\treturn data\r\n\t}\r\n\r\n\tfunction markViews(data, cached, views, controllers) {\r\n\t\tvar cachedControllers = cached && cached.controllers\r\n\r\n\t\twhile (data.view != null) {\r\n\t\t\tdata = checkView(\r\n\t\t\t\tdata,\r\n\t\t\t\tdata.view.$original || data.view,\r\n\t\t\t\tcached,\r\n\t\t\t\tcachedControllers,\r\n\t\t\t\tcontrollers,\r\n\t\t\t\tviews)\r\n\t\t}\r\n\r\n\t\treturn data\r\n\t}\r\n\r\n\tfunction buildObject( // eslint-disable-line max-statements\r\n\t\tdata,\r\n\t\tcached,\r\n\t\teditable,\r\n\t\tparentElement,\r\n\t\tindex,\r\n\t\tshouldReattach,\r\n\t\tnamespace,\r\n\t\tconfigs\r\n\t) {\r\n\t\tvar views = []\r\n\t\tvar controllers = []\r\n\r\n\t\tdata = markViews(data, cached, views, controllers)\r\n\r\n\t\tif (data.subtree === \"retain\") return cached\r\n\r\n\t\tif (!data.tag && controllers.length) {\r\n\t\t\tthrow new Error(\"Component template must return a virtual \" +\r\n\t\t\t\t\"element, not an array, string, etc.\")\r\n\t\t}\r\n\r\n\t\tdata.attrs = data.attrs || {}\r\n\t\tcached.attrs = cached.attrs || {}\r\n\r\n\t\tvar dataAttrKeys = Object.keys(data.attrs)\r\n\t\tvar hasKeys = dataAttrKeys.length > (\"key\" in data.attrs ? 1 : 0)\r\n\r\n\t\tmaybeRecreateObject(data, cached, dataAttrKeys)\r\n\r\n\t\tif (!isString(data.tag)) return\r\n\r\n\t\tvar isNew = cached.nodes.length === 0\r\n\r\n\t\tnamespace = getObjectNamespace(data, namespace)\r\n\r\n\t\tvar node\r\n\t\tif (isNew) {\r\n\t\t\tnode = constructNode(data, namespace)\r\n\t\t\t// set attributes first, then create children\r\n\t\t\tvar attrs = constructAttrs(data, node, namespace, hasKeys)\r\n\r\n\t\t\t// add the node to its parent before attaching children to it\r\n\t\t\tinsertNode(parentElement, node, index)\r\n\r\n\t\t\tvar children = constructChildren(data, node, cached, editable,\r\n\t\t\t\tnamespace, configs)\r\n\r\n\t\t\tcached = reconstructCached(\r\n\t\t\t\tdata,\r\n\t\t\t\tattrs,\r\n\t\t\t\tchildren,\r\n\t\t\t\tnode,\r\n\t\t\t\tnamespace,\r\n\t\t\t\tviews,\r\n\t\t\t\tcontrollers)\r\n\t\t} else {\r\n\t\t\tnode = buildUpdatedNode(\r\n\t\t\t\tcached,\r\n\t\t\t\tdata,\r\n\t\t\t\teditable,\r\n\t\t\t\thasKeys,\r\n\t\t\t\tnamespace,\r\n\t\t\t\tviews,\r\n\t\t\t\tconfigs,\r\n\t\t\t\tcontrollers)\r\n\t\t}\r\n\r\n\t\tif (!isNew && shouldReattach === true && node != null) {\r\n\t\t\tinsertNode(parentElement, node, index)\r\n\t\t}\r\n\r\n\t\t// The configs are called after `build` finishes running\r\n\t\tscheduleConfigsToBeCalled(configs, data, node, isNew, cached)\r\n\r\n\t\treturn cached\r\n\t}\r\n\r\n\tfunction build(\r\n\t\tparentElement,\r\n\t\tparentTag,\r\n\t\tparentCache,\r\n\t\tparentIndex,\r\n\t\tdata,\r\n\t\tcached,\r\n\t\tshouldReattach,\r\n\t\tindex,\r\n\t\teditable,\r\n\t\tnamespace,\r\n\t\tconfigs\r\n\t) {\r\n\t\t/*\r\n\t\t * `build` is a recursive function that manages creation/diffing/removal\r\n\t\t * of DOM elements based on comparison between `data` and `cached` the\r\n\t\t * diff algorithm can be summarized as this:\r\n\t\t *\r\n\t\t * 1 - compare `data` and `cached`\r\n\t\t * 2 - if they are different, copy `data` to `cached` and update the DOM\r\n\t\t * based on what the difference is\r\n\t\t * 3 - recursively apply this algorithm for every array and for the\r\n\t\t * children of every virtual element\r\n\t\t *\r\n\t\t * The `cached` data structure is essentially the same as the previous\r\n\t\t * redraw's `data` data structure, with a few additions:\r\n\t\t * - `cached` always has a property called `nodes`, which is a list of\r\n\t\t * DOM elements that correspond to the data represented by the\r\n\t\t * respective virtual element\r\n\t\t * - in order to support attaching `nodes` as a property of `cached`,\r\n\t\t * `cached` is *always* a non-primitive object, i.e. if the data was\r\n\t\t * a string, then cached is a String instance. If data was `null` or\r\n\t\t * `undefined`, cached is `new String(\"\")`\r\n\t\t * - `cached also has a `configContext` property, which is the state\r\n\t\t * storage object exposed by config(element, isInitialized, context)\r\n\t\t * - when `cached` is an Object, it represents a virtual element; when\r\n\t\t * it's an Array, it represents a list of elements; when it's a\r\n\t\t * String, Number or Boolean, it represents a text node\r\n\t\t *\r\n\t\t * `parentElement` is a DOM element used for W3C DOM API calls\r\n\t\t * `parentTag` is only used for handling a corner case for textarea\r\n\t\t * values\r\n\t\t * `parentCache` is used to remove nodes in some multi-node cases\r\n\t\t * `parentIndex` and `index` are used to figure out the offset of nodes.\r\n\t\t * They're artifacts from before arrays started being flattened and are\r\n\t\t * likely refactorable\r\n\t\t * `data` and `cached` are, respectively, the new and old nodes being\r\n\t\t * diffed\r\n\t\t * `shouldReattach` is a flag indicating whether a parent node was\r\n\t\t * recreated (if so, and if this node is reused, then this node must\r\n\t\t * reattach itself to the new parent)\r\n\t\t * `editable` is a flag that indicates whether an ancestor is\r\n\t\t * contenteditable\r\n\t\t * `namespace` indicates the closest HTML namespace as it cascades down\r\n\t\t * from an ancestor\r\n\t\t * `configs` is a list of config functions to run after the topmost\r\n\t\t * `build` call finishes running\r\n\t\t *\r\n\t\t * there's logic that relies on the assumption that null and undefined\r\n\t\t * data are equivalent to empty strings\r\n\t\t * - this prevents lifecycle surprises from procedural helpers that mix\r\n\t\t * implicit and explicit return statements (e.g.\r\n\t\t * function foo() {if (cond) return m(\"div\")}\r\n\t\t * - it simplifies diffing code\r\n\t\t */\r\n\t\tdata = dataToString(data)\r\n\t\tif (data.subtree === \"retain\") return cached\r\n\t\tcached = makeCache(data, cached, index, parentIndex, parentCache)\r\n\r\n\t\tif (isArray(data)) {\r\n\t\t\treturn buildArray(\r\n\t\t\t\tdata,\r\n\t\t\t\tcached,\r\n\t\t\t\tparentElement,\r\n\t\t\t\tindex,\r\n\t\t\t\tparentTag,\r\n\t\t\t\tshouldReattach,\r\n\t\t\t\teditable,\r\n\t\t\t\tnamespace,\r\n\t\t\t\tconfigs)\r\n\t\t} else if (data != null && isObject(data)) {\r\n\t\t\treturn buildObject(\r\n\t\t\t\tdata,\r\n\t\t\t\tcached,\r\n\t\t\t\teditable,\r\n\t\t\t\tparentElement,\r\n\t\t\t\tindex,\r\n\t\t\t\tshouldReattach,\r\n\t\t\t\tnamespace,\r\n\t\t\t\tconfigs)\r\n\t\t} else if (!isFunction(data)) {\r\n\t\t\treturn handleTextNode(\r\n\t\t\t\tcached,\r\n\t\t\t\tdata,\r\n\t\t\t\tindex,\r\n\t\t\t\tparentElement,\r\n\t\t\t\tshouldReattach,\r\n\t\t\t\teditable,\r\n\t\t\t\tparentTag)\r\n\t\t} else {\r\n\t\t\treturn cached\r\n\t\t}\r\n\t}\r\n\r\n\tfunction sortChanges(a, b) {\r\n\t\treturn a.action - b.action || a.index - b.index\r\n\t}\r\n\r\n\tfunction copyStyleAttrs(node, dataAttr, cachedAttr) {\r\n\t\tfor (var rule in dataAttr) {\r\n\t\t\tif (hasOwn.call(dataAttr, rule)) {\r\n\t\t\t\tif (cachedAttr == null || cachedAttr[rule] !== dataAttr[rule]) {\r\n\t\t\t\t\tnode.style[rule] = dataAttr[rule]\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tfor (rule in cachedAttr) {\r\n\t\t\tif (hasOwn.call(cachedAttr, rule)) {\r\n\t\t\t\tif (!hasOwn.call(dataAttr, rule)) node.style[rule] = \"\"\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tvar shouldUseSetAttribute = {\r\n\t\tlist: 1,\r\n\t\tstyle: 1,\r\n\t\tform: 1,\r\n\t\ttype: 1,\r\n\t\twidth: 1,\r\n\t\theight: 1\r\n\t}\r\n\r\n\tfunction setSingleAttr(\r\n\t\tnode,\r\n\t\tattrName,\r\n\t\tdataAttr,\r\n\t\tcachedAttr,\r\n\t\ttag,\r\n\t\tnamespace\r\n\t) {\r\n\t\tif (attrName === \"config\" || attrName === \"key\") {\r\n\t\t\t// `config` isn't a real attribute, so ignore it\r\n\t\t\treturn true\r\n\t\t} else if (isFunction(dataAttr) && attrName.slice(0, 2) === \"on\") {\r\n\t\t\t// hook event handlers to the auto-redrawing system\r\n\t\t\tnode[attrName] = autoredraw(dataAttr, node)\r\n\t\t} else if (attrName === \"style\" && dataAttr != null &&\r\n\t\t\t\tisObject(dataAttr)) {\r\n\t\t\t// handle `style: {...}`\r\n\t\t\tcopyStyleAttrs(node, dataAttr, cachedAttr)\r\n\t\t} else if (namespace != null) {\r\n\t\t\t// handle SVG\r\n\t\t\tif (attrName === \"href\") {\r\n\t\t\t\tnode.setAttributeNS(\"http://www.w3.org/1999/xlink\",\r\n\t\t\t\t\t\"href\", dataAttr)\r\n\t\t\t} else {\r\n\t\t\t\tnode.setAttribute(\r\n\t\t\t\t\tattrName === \"className\" ? \"class\" : attrName,\r\n\t\t\t\t\tdataAttr)\r\n\t\t\t}\r\n\t\t} else if (attrName in node && !shouldUseSetAttribute[attrName]) {\r\n\t\t\t// handle cases that are properties (but ignore cases where we\r\n\t\t\t// should use setAttribute instead)\r\n\t\t\t//\r\n\t\t\t// - list and form are typically used as strings, but are DOM\r\n\t\t\t// element references in js\r\n\t\t\t//\r\n\t\t\t// - when using CSS selectors (e.g. `m(\"[style='']\")`), style is\r\n\t\t\t// used as a string, but it's an object in js\r\n\t\t\t//\r\n\t\t\t// #348 don't set the value if not needed - otherwise, cursor\r\n\t\t\t// placement breaks in Chrome\r\n\t\t\ttry {\r\n\t\t\t\tif (tag !== \"input\" || node[attrName] !== dataAttr) {\r\n\t\t\t\t\tnode[attrName] = dataAttr\r\n\t\t\t\t}\r\n\t\t\t} catch (e) {\r\n\t\t\t\tnode.setAttribute(attrName, dataAttr)\r\n\t\t\t}\r\n\t\t}\r\n\t\telse node.setAttribute(attrName, dataAttr)\r\n\t}\r\n\r\n\tfunction trySetAttr(\r\n\t\tnode,\r\n\t\tattrName,\r\n\t\tdataAttr,\r\n\t\tcachedAttr,\r\n\t\tcachedAttrs,\r\n\t\ttag,\r\n\t\tnamespace\r\n\t) {\r\n\t\tif (!(attrName in cachedAttrs) || (cachedAttr !== dataAttr) || ($document.activeElement === node)) {\r\n\t\t\tcachedAttrs[attrName] = dataAttr\r\n\t\t\ttry {\r\n\t\t\t\treturn setSingleAttr(\r\n\t\t\t\t\tnode,\r\n\t\t\t\t\tattrName,\r\n\t\t\t\t\tdataAttr,\r\n\t\t\t\t\tcachedAttr,\r\n\t\t\t\t\ttag,\r\n\t\t\t\t\tnamespace)\r\n\t\t\t} catch (e) {\r\n\t\t\t\t// swallow IE's invalid argument errors to mimic HTML's\r\n\t\t\t\t// fallback-to-doing-nothing-on-invalid-attributes behavior\r\n\t\t\t\tif (e.message.indexOf(\"Invalid argument\") < 0) throw e\r\n\t\t\t}\r\n\t\t} else if (attrName === \"value\" && tag === \"input\" &&\r\n\t\t\t\tnode.value !== dataAttr) {\r\n\t\t\t// #348 dataAttr may not be a string, so use loose comparison\r\n\t\t\tnode.value = dataAttr\r\n\t\t}\r\n\t}\r\n\r\n\tfunction setAttributes(node, tag, dataAttrs, cachedAttrs, namespace) {\r\n\t\tfor (var attrName in dataAttrs) {\r\n\t\t\tif (hasOwn.call(dataAttrs, attrName)) {\r\n\t\t\t\tif (trySetAttr(\r\n\t\t\t\t\t\tnode,\r\n\t\t\t\t\t\tattrName,\r\n\t\t\t\t\t\tdataAttrs[attrName],\r\n\t\t\t\t\t\tcachedAttrs[attrName],\r\n\t\t\t\t\t\tcachedAttrs,\r\n\t\t\t\t\t\ttag,\r\n\t\t\t\t\t\tnamespace)) {\r\n\t\t\t\t\tcontinue\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn cachedAttrs\r\n\t}\r\n\r\n\tfunction clear(nodes, cached) {\r\n\t\tfor (var i = nodes.length - 1; i > -1; i--) {\r\n\t\t\tif (nodes[i] && nodes[i].parentNode) {\r\n\t\t\t\ttry {\r\n\t\t\t\t\tnodes[i].parentNode.removeChild(nodes[i])\r\n\t\t\t\t} catch (e) {\r\n\t\t\t\t\t/* eslint-disable max-len */\r\n\t\t\t\t\t// ignore if this fails due to order of events (see\r\n\t\t\t\t\t// http://stackoverflow.com/questions/21926083/failed-to-execute-removechild-on-node)\r\n\t\t\t\t\t/* eslint-enable max-len */\r\n\t\t\t\t}\r\n\t\t\t\tcached = [].concat(cached)\r\n\t\t\t\tif (cached[i]) unload(cached[i])\r\n\t\t\t}\r\n\t\t}\r\n\t\t// release memory if nodes is an array. This check should fail if nodes\r\n\t\t// is a NodeList (see loop above)\r\n\t\tif (nodes.length) {\r\n\t\t\tnodes.length = 0\r\n\t\t}\r\n\t}\r\n\r\n\tfunction unload(cached) {\r\n\t\tif (cached.configContext && isFunction(cached.configContext.onunload)) {\r\n\t\t\tcached.configContext.onunload()\r\n\t\t\tcached.configContext.onunload = null\r\n\t\t}\r\n\t\tif (cached.controllers) {\r\n\t\t\tforEach(cached.controllers, function (controller) {\r\n\t\t\t\tif (isFunction(controller.onunload)) {\r\n\t\t\t\t\tcontroller.onunload({preventDefault: noop})\r\n\t\t\t\t}\r\n\t\t\t})\r\n\t\t}\r\n\t\tif (cached.children) {\r\n\t\t\tif (isArray(cached.children)) forEach(cached.children, unload)\r\n\t\t\telse if (cached.children.tag) unload(cached.children)\r\n\t\t}\r\n\t}\r\n\r\n\tfunction appendTextFragment(parentElement, data) {\r\n\t\ttry {\r\n\t\t\tparentElement.appendChild(\r\n\t\t\t\t$document.createRange().createContextualFragment(data))\r\n\t\t} catch (e) {\r\n\t\t\tparentElement.insertAdjacentHTML(\"beforeend\", data)\r\n\t\t\treplaceScriptNodes(parentElement)\r\n\t\t}\r\n\t}\r\n\r\n\t// Replace script tags inside given DOM element with executable ones.\r\n\t// Will also check children recursively and replace any found script\r\n\t// tags in same manner.\r\n\tfunction replaceScriptNodes(node) {\r\n\t\tif (node.tagName === \"SCRIPT\") {\r\n\t\t\tnode.parentNode.replaceChild(buildExecutableNode(node), node)\r\n\t\t} else {\r\n\t\t\tvar children = node.childNodes\r\n\t\t\tif (children && children.length) {\r\n\t\t\t\tfor (var i = 0; i < children.length; i++) {\r\n\t\t\t\t\treplaceScriptNodes(children[i])\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn node\r\n\t}\r\n\r\n\t// Replace script element with one whose contents are executable.\r\n\tfunction buildExecutableNode(node){\r\n\t\tvar scriptEl = document.createElement(\"script\")\r\n\t\tvar attrs = node.attributes\r\n\r\n\t\tfor (var i = 0; i < attrs.length; i++) {\r\n\t\t\tscriptEl.setAttribute(attrs[i].name, attrs[i].value)\r\n\t\t}\r\n\r\n\t\tscriptEl.text = node.innerHTML\r\n\t\treturn scriptEl\r\n\t}\r\n\r\n\tfunction injectHTML(parentElement, index, data) {\r\n\t\tvar nextSibling = parentElement.childNodes[index]\r\n\t\tif (nextSibling) {\r\n\t\t\tvar isElement = nextSibling.nodeType !== 1\r\n\t\t\tvar placeholder = $document.createElement(\"span\")\r\n\t\t\tif (isElement) {\r\n\t\t\t\tparentElement.insertBefore(placeholder, nextSibling || null)\r\n\t\t\t\tplaceholder.insertAdjacentHTML(\"beforebegin\", data)\r\n\t\t\t\tparentElement.removeChild(placeholder)\r\n\t\t\t} else {\r\n\t\t\t\tnextSibling.insertAdjacentHTML(\"beforebegin\", data)\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tappendTextFragment(parentElement, data)\r\n\t\t}\r\n\r\n\t\tvar nodes = []\r\n\r\n\t\twhile (parentElement.childNodes[index] !== nextSibling) {\r\n\t\t\tnodes.push(parentElement.childNodes[index])\r\n\t\t\tindex++\r\n\t\t}\r\n\r\n\t\treturn nodes\r\n\t}\r\n\r\n\tfunction autoredraw(callback, object) {\r\n\t\treturn function (e) {\r\n\t\t\te = e || event\r\n\t\t\tm.redraw.strategy(\"diff\")\r\n\t\t\tm.startComputation()\r\n\t\t\ttry {\r\n\t\t\t\treturn callback.call(object, e)\r\n\t\t\t} finally {\r\n\t\t\t\tendFirstComputation()\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tvar html\r\n\tvar documentNode = {\r\n\t\tappendChild: function (node) {\r\n\t\t\tif (html === undefined) html = $document.createElement(\"html\")\r\n\t\t\tif ($document.documentElement &&\r\n\t\t\t\t\t$document.documentElement !== node) {\r\n\t\t\t\t$document.replaceChild(node, $document.documentElement)\r\n\t\t\t} else {\r\n\t\t\t\t$document.appendChild(node)\r\n\t\t\t}\r\n\r\n\t\t\tthis.childNodes = $document.childNodes\r\n\t\t},\r\n\r\n\t\tinsertBefore: function (node) {\r\n\t\t\tthis.appendChild(node)\r\n\t\t},\r\n\r\n\t\tchildNodes: []\r\n\t}\r\n\r\n\tvar nodeCache = []\r\n\tvar cellCache = {}\r\n\r\n\tm.render = function (root, cell, forceRecreation) {\r\n\t\tif (!root) {\r\n\t\t\tthrow new Error(\"Ensure the DOM element being passed to \" +\r\n\t\t\t\t\"m.route/m.mount/m.render is not undefined.\")\r\n\t\t}\r\n\t\tvar configs = []\r\n\t\tvar id = getCellCacheKey(root)\r\n\t\tvar isDocumentRoot = root === $document\r\n\t\tvar node\r\n\r\n\t\tif (isDocumentRoot || root === $document.documentElement) {\r\n\t\t\tnode = documentNode\r\n\t\t} else {\r\n\t\t\tnode = root\r\n\t\t}\r\n\r\n\t\tif (isDocumentRoot && cell.tag !== \"html\") {\r\n\t\t\tcell = {tag: \"html\", attrs: {}, children: cell}\r\n\t\t}\r\n\r\n\t\tif (cellCache[id] === undefined) clear(node.childNodes)\r\n\t\tif (forceRecreation === true) reset(root)\r\n\r\n\t\tcellCache[id] = build(\r\n\t\t\tnode,\r\n\t\t\tnull,\r\n\t\t\tundefined,\r\n\t\t\tundefined,\r\n\t\t\tcell,\r\n\t\t\tcellCache[id],\r\n\t\t\tfalse,\r\n\t\t\t0,\r\n\t\t\tnull,\r\n\t\t\tundefined,\r\n\t\t\tconfigs)\r\n\r\n\t\tforEach(configs, function (config) { config() })\r\n\t}\r\n\r\n\tfunction getCellCacheKey(element) {\r\n\t\tvar index = nodeCache.indexOf(element)\r\n\t\treturn index < 0 ? nodeCache.push(element) - 1 : index\r\n\t}\r\n\r\n\tm.trust = function (value) {\r\n\t\tvalue = new String(value) // eslint-disable-line no-new-wrappers\r\n\t\tvalue.$trusted = true\r\n\t\treturn value\r\n\t}\r\n\r\n\tfunction gettersetter(store) {\r\n\t\tfunction prop() {\r\n\t\t\tif (arguments.length) store = arguments[0]\r\n\t\t\treturn store\r\n\t\t}\r\n\r\n\t\tprop.toJSON = function () {\r\n\t\t\treturn store\r\n\t\t}\r\n\r\n\t\treturn prop\r\n\t}\r\n\r\n\tm.prop = function (store) {\r\n\t\tif ((store != null && (isObject(store) || isFunction(store)) || ((typeof Promise !== \"undefined\") && (store instanceof Promise))) &&\r\n\t\t\t\tisFunction(store.then)) {\r\n\t\t\treturn propify(store)\r\n\t\t}\r\n\r\n\t\treturn gettersetter(store)\r\n\t}\r\n\r\n\tvar roots = []\r\n\tvar components = []\r\n\tvar controllers = []\r\n\tvar lastRedrawId = null\r\n\tvar lastRedrawCallTime = 0\r\n\tvar computePreRedrawHook = null\r\n\tvar computePostRedrawHook = null\r\n\tvar topComponent\r\n\tvar FRAME_BUDGET = 16 // 60 frames per second = 1 call per 16 ms\r\n\r\n\tfunction parameterize(component, args) {\r\n\t\tfunction controller() {\r\n\t\t\t/* eslint-disable no-invalid-this */\r\n\t\t\treturn (component.controller || noop).apply(this, args) || this\r\n\t\t\t/* eslint-enable no-invalid-this */\r\n\t\t}\r\n\r\n\t\tif (component.controller) {\r\n\t\t\tcontroller.prototype = component.controller.prototype\r\n\t\t}\r\n\r\n\t\tfunction view(ctrl) {\r\n\t\t\tvar currentArgs = [ctrl].concat(args)\r\n\t\t\tfor (var i = 1; i < arguments.length; i++) {\r\n\t\t\t\tcurrentArgs.push(arguments[i])\r\n\t\t\t}\r\n\r\n\t\t\treturn component.view.apply(component, currentArgs)\r\n\t\t}\r\n\r\n\t\tview.$original = component.view\r\n\t\tvar output = {controller: controller, view: view}\r\n\t\tif (args[0] && args[0].key != null) output.attrs = {key: args[0].key}\r\n\t\treturn output\r\n\t}\r\n\r\n\tm.component = function (component) {\r\n\t\tvar args = new Array(arguments.length - 1)\r\n\r\n\t\tfor (var i = 1; i < arguments.length; i++) {\r\n\t\t\targs[i - 1] = arguments[i]\r\n\t\t}\r\n\r\n\t\treturn parameterize(component, args)\r\n\t}\r\n\r\n\tfunction checkPrevented(component, root, index, isPrevented) {\r\n\t\tif (!isPrevented) {\r\n\t\t\tm.redraw.strategy(\"all\")\r\n\t\t\tm.startComputation()\r\n\t\t\troots[index] = root\r\n\t\t\tvar currentComponent\r\n\r\n\t\t\tif (component) {\r\n\t\t\t\tcurrentComponent = topComponent = component\r\n\t\t\t} else {\r\n\t\t\t\tcurrentComponent = topComponent = component = {controller: noop}\r\n\t\t\t}\r\n\r\n\t\t\tvar controller = new (component.controller || noop)()\r\n\r\n\t\t\t// controllers may call m.mount recursively (via m.route redirects,\r\n\t\t\t// for example)\r\n\t\t\t// this conditional ensures only the last recursive m.mount call is\r\n\t\t\t// applied\r\n\t\t\tif (currentComponent === topComponent) {\r\n\t\t\t\tcontrollers[index] = controller\r\n\t\t\t\tcomponents[index] = component\r\n\t\t\t}\r\n\t\t\tendFirstComputation()\r\n\t\t\tif (component === null) {\r\n\t\t\t\tremoveRootElement(root, index)\r\n\t\t\t}\r\n\t\t\treturn controllers[index]\r\n\t\t} else if (component == null) {\r\n\t\t\tremoveRootElement(root, index)\r\n\t\t}\r\n\t}\r\n\r\n\tm.mount = m.module = function (root, component) {\r\n\t\tif (!root) {\r\n\t\t\tthrow new Error(\"Please ensure the DOM element exists before \" +\r\n\t\t\t\t\"rendering a template into it.\")\r\n\t\t}\r\n\r\n\t\tvar index = roots.indexOf(root)\r\n\t\tif (index < 0) index = roots.length\r\n\r\n\t\tvar isPrevented = false\r\n\t\tvar event = {\r\n\t\t\tpreventDefault: function () {\r\n\t\t\t\tisPrevented = true\r\n\t\t\t\tcomputePreRedrawHook = computePostRedrawHook = null\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tforEach(unloaders, function (unloader) {\r\n\t\t\tunloader.handler.call(unloader.controller, event)\r\n\t\t\tunloader.controller.onunload = null\r\n\t\t})\r\n\r\n\t\tif (isPrevented) {\r\n\t\t\tforEach(unloaders, function (unloader) {\r\n\t\t\t\tunloader.controller.onunload = unloader.handler\r\n\t\t\t})\r\n\t\t} else {\r\n\t\t\tunloaders = []\r\n\t\t}\r\n\r\n\t\tif (controllers[index] && isFunction(controllers[index].onunload)) {\r\n\t\t\tcontrollers[index].onunload(event)\r\n\t\t}\r\n\r\n\t\treturn checkPrevented(component, root, index, isPrevented)\r\n\t}\r\n\r\n\tfunction removeRootElement(root, index) {\r\n\t\troots.splice(index, 1)\r\n\t\tcontrollers.splice(index, 1)\r\n\t\tcomponents.splice(index, 1)\r\n\t\treset(root)\r\n\t\tnodeCache.splice(getCellCacheKey(root), 1)\r\n\t}\r\n\r\n\tvar redrawing = false\r\n\tm.redraw = function (force) {\r\n\t\tif (redrawing) return\r\n\t\tredrawing = true\r\n\t\tif (force) forcing = true\r\n\r\n\t\ttry {\r\n\t\t\t// lastRedrawId is a positive number if a second redraw is requested\r\n\t\t\t// before the next animation frame\r\n\t\t\t// lastRedrawId is null if it's the first redraw and not an event\r\n\t\t\t// handler\r\n\t\t\tif (lastRedrawId && !force) {\r\n\t\t\t\t// when setTimeout: only reschedule redraw if time between now\r\n\t\t\t\t// and previous redraw is bigger than a frame, otherwise keep\r\n\t\t\t\t// currently scheduled timeout\r\n\t\t\t\t// when rAF: always reschedule redraw\r\n\t\t\t\tif ($requestAnimationFrame === global.requestAnimationFrame ||\r\n\t\t\t\t\t\tnew Date() - lastRedrawCallTime > FRAME_BUDGET) {\r\n\t\t\t\t\tif (lastRedrawId > 0) $cancelAnimationFrame(lastRedrawId)\r\n\t\t\t\t\tlastRedrawId = $requestAnimationFrame(redraw, FRAME_BUDGET)\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\tredraw()\r\n\t\t\t\tlastRedrawId = $requestAnimationFrame(function () {\r\n\t\t\t\t\tlastRedrawId = null\r\n\t\t\t\t}, FRAME_BUDGET)\r\n\t\t\t}\r\n\t\t} finally {\r\n\t\t\tredrawing = forcing = false\r\n\t\t}\r\n\t}\r\n\r\n\tm.redraw.strategy = m.prop()\r\n\tfunction redraw() {\r\n\t\tif (computePreRedrawHook) {\r\n\t\t\tcomputePreRedrawHook()\r\n\t\t\tcomputePreRedrawHook = null\r\n\t\t}\r\n\t\tforEach(roots, function (root, i) {\r\n\t\t\tvar component = components[i]\r\n\t\t\tif (controllers[i]) {\r\n\t\t\t\tvar args = [controllers[i]]\r\n\t\t\t\tm.render(root,\r\n\t\t\t\t\tcomponent.view ? component.view(controllers[i], args) : \"\")\r\n\t\t\t}\r\n\t\t})\r\n\t\t// after rendering within a routed context, we need to scroll back to\r\n\t\t// the top, and fetch the document title for history.pushState\r\n\t\tif (computePostRedrawHook) {\r\n\t\t\tcomputePostRedrawHook()\r\n\t\t\tcomputePostRedrawHook = null\r\n\t\t}\r\n\t\tlastRedrawId = null\r\n\t\tlastRedrawCallTime = new Date()\r\n\t\tm.redraw.strategy(\"diff\")\r\n\t}\r\n\r\n\tfunction endFirstComputation() {\r\n\t\tif (m.redraw.strategy() === \"none\") {\r\n\t\t\tpendingRequests--\r\n\t\t\tm.redraw.strategy(\"diff\")\r\n\t\t} else {\r\n\t\t\tm.endComputation()\r\n\t\t}\r\n\t}\r\n\r\n\tm.withAttr = function (prop, withAttrCallback, callbackThis) {\r\n\t\treturn function (e) {\r\n\t\t\te = e || window.event\r\n\t\t\t/* eslint-disable no-invalid-this */\r\n\t\t\tvar currentTarget = e.currentTarget || this\r\n\t\t\tvar _this = callbackThis || this\r\n\t\t\t/* eslint-enable no-invalid-this */\r\n\t\t\tvar target = prop in currentTarget ?\r\n\t\t\t\tcurrentTarget[prop] :\r\n\t\t\t\tcurrentTarget.getAttribute(prop)\r\n\t\t\twithAttrCallback.call(_this, target)\r\n\t\t}\r\n\t}\r\n\r\n\t// routing\r\n\tvar modes = {pathname: \"\", hash: \"#\", search: \"?\"}\r\n\tvar redirect = noop\r\n\tvar isDefaultRoute = false\r\n\tvar routeParams, currentRoute\r\n\r\n\tm.route = function (root, arg1, arg2, vdom) { // eslint-disable-line\r\n\t\t// m.route()\r\n\t\tif (arguments.length === 0) return currentRoute\r\n\t\t// m.route(el, defaultRoute, routes)\r\n\t\tif (arguments.length === 3 && isString(arg1)) {\r\n\t\t\tredirect = function (source) {\r\n\t\t\t\tvar path = currentRoute = normalizeRoute(source)\r\n\t\t\t\tif (!routeByValue(root, arg2, path)) {\r\n\t\t\t\t\tif (isDefaultRoute) {\r\n\t\t\t\t\t\tthrow new Error(\"Ensure the default route matches \" +\r\n\t\t\t\t\t\t\t\"one of the routes defined in m.route\")\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tisDefaultRoute = true\r\n\t\t\t\t\tm.route(arg1, true)\r\n\t\t\t\t\tisDefaultRoute = false\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tvar listener = m.route.mode === \"hash\" ?\r\n\t\t\t\t\"onhashchange\" :\r\n\t\t\t\t\"onpopstate\"\r\n\r\n\t\t\tglobal[listener] = function () {\r\n\t\t\t\tvar path = $location[m.route.mode]\r\n\t\t\t\tif (m.route.mode === \"pathname\") path += $location.search\r\n\t\t\t\tif (currentRoute !== normalizeRoute(path)) redirect(path)\r\n\t\t\t}\r\n\r\n\t\t\tcomputePreRedrawHook = setScroll\r\n\t\t\tglobal[listener]()\r\n\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\t// config: m.route\r\n\t\tif (root.addEventListener || root.attachEvent) {\r\n\t\t\tvar base = m.route.mode !== \"pathname\" ? $location.pathname : \"\"\r\n\t\t\troot.href = base + modes[m.route.mode] + vdom.attrs.href\r\n\t\t\tif (root.addEventListener) {\r\n\t\t\t\troot.removeEventListener(\"click\", routeUnobtrusive)\r\n\t\t\t\troot.addEventListener(\"click\", routeUnobtrusive)\r\n\t\t\t} else {\r\n\t\t\t\troot.detachEvent(\"onclick\", routeUnobtrusive)\r\n\t\t\t\troot.attachEvent(\"onclick\", routeUnobtrusive)\r\n\t\t\t}\r\n\r\n\t\t\treturn\r\n\t\t}\r\n\t\t// m.route(route, params, shouldReplaceHistoryEntry)\r\n\t\tif (isString(root)) {\r\n\t\t\tvar oldRoute = currentRoute\r\n\t\t\tcurrentRoute = root\r\n\r\n\t\t\tvar args = arg1 || {}\r\n\t\t\tvar queryIndex = currentRoute.indexOf(\"?\")\r\n\t\t\tvar params\r\n\r\n\t\t\tif (queryIndex > -1) {\r\n\t\t\t\tparams = parseQueryString(currentRoute.slice(queryIndex + 1))\r\n\t\t\t} else {\r\n\t\t\t\tparams = {}\r\n\t\t\t}\r\n\r\n\t\t\tfor (var i in args) {\r\n\t\t\t\tif (hasOwn.call(args, i)) {\r\n\t\t\t\t\tparams[i] = args[i]\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tvar querystring = buildQueryString(params)\r\n\t\t\tvar currentPath\r\n\r\n\t\t\tif (queryIndex > -1) {\r\n\t\t\t\tcurrentPath = currentRoute.slice(0, queryIndex)\r\n\t\t\t} else {\r\n\t\t\t\tcurrentPath = currentRoute\r\n\t\t\t}\r\n\r\n\t\t\tif (querystring) {\r\n\t\t\t\tcurrentRoute = currentPath +\r\n\t\t\t\t\t(currentPath.indexOf(\"?\") === -1 ? \"?\" : \"&\") +\r\n\t\t\t\t\tquerystring\r\n\t\t\t}\r\n\r\n\t\t\tvar replaceHistory =\r\n\t\t\t\t(arguments.length === 3 ? arg2 : arg1) === true ||\r\n\t\t\t\toldRoute === root\r\n\r\n\t\t\tif (global.history.pushState) {\r\n\t\t\t\tvar method = replaceHistory ? \"replaceState\" : \"pushState\"\r\n\t\t\t\tcomputePreRedrawHook = setScroll\r\n\t\t\t\tcomputePostRedrawHook = function () {\r\n\t\t\t\t\ttry {\r\n\t\t\t\t\t\tglobal.history[method](null, $document.title,\r\n\t\t\t\t\t\t\tmodes[m.route.mode] + currentRoute)\r\n\t\t\t\t\t} catch (err) {\r\n\t\t\t\t\t\t// In the event of a pushState or replaceState failure,\r\n\t\t\t\t\t\t// fallback to a standard redirect. This is specifically\r\n\t\t\t\t\t\t// to address a Safari security error when attempting to\r\n\t\t\t\t\t\t// call pushState more than 100 times.\r\n\t\t\t\t\t\t$location[m.route.mode] = currentRoute\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tredirect(modes[m.route.mode] + currentRoute)\r\n\t\t\t} else {\r\n\t\t\t\t$location[m.route.mode] = currentRoute\r\n\t\t\t\tredirect(modes[m.route.mode] + currentRoute)\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tm.route.param = function (key) {\r\n\t\tif (!routeParams) {\r\n\t\t\tthrow new Error(\"You must call m.route(element, defaultRoute, \" +\r\n\t\t\t\t\"routes) before calling m.route.param()\")\r\n\t\t}\r\n\r\n\t\tif (!key) {\r\n\t\t\treturn routeParams\r\n\t\t}\r\n\r\n\t\treturn routeParams[key]\r\n\t}\r\n\r\n\tm.route.mode = \"search\"\r\n\r\n\tfunction normalizeRoute(route) {\r\n\t\treturn route.slice(modes[m.route.mode].length)\r\n\t}\r\n\r\n\tfunction routeByValue(root, router, path) {\r\n\t\trouteParams = {}\r\n\r\n\t\tvar queryStart = path.indexOf(\"?\")\r\n\t\tif (queryStart !== -1) {\r\n\t\t\trouteParams = parseQueryString(\r\n\t\t\t\tpath.substr(queryStart + 1, path.length))\r\n\t\t\tpath = path.substr(0, queryStart)\r\n\t\t}\r\n\r\n\t\t// Get all routes and check if there's\r\n\t\t// an exact match for the current path\r\n\t\tvar keys = Object.keys(router)\r\n\t\tvar index = keys.indexOf(path)\r\n\r\n\t\tif (index !== -1){\r\n\t\t\tm.mount(root, router[keys [index]])\r\n\t\t\treturn true\r\n\t\t}\r\n\r\n\t\tfor (var route in router) {\r\n\t\t\tif (hasOwn.call(router, route)) {\r\n\t\t\t\tif (route === path) {\r\n\t\t\t\t\tm.mount(root, router[route])\r\n\t\t\t\t\treturn true\r\n\t\t\t\t}\r\n\r\n\t\t\t\tvar matcher = new RegExp(\"^\" + route\r\n\t\t\t\t\t.replace(/:[^\\/]+?\\.{3}/g, \"(.*?)\")\r\n\t\t\t\t\t.replace(/:[^\\/]+/g, \"([^\\\\/]+)\") + \"\\/?$\")\r\n\r\n\t\t\t\tif (matcher.test(path)) {\r\n\t\t\t\t\t/* eslint-disable no-loop-func */\r\n\t\t\t\t\tpath.replace(matcher, function () {\r\n\t\t\t\t\t\tvar keys = route.match(/:[^\\/]+/g) || []\r\n\t\t\t\t\t\tvar values = [].slice.call(arguments, 1, -2)\r\n\t\t\t\t\t\tforEach(keys, function (key, i) {\r\n\t\t\t\t\t\t\trouteParams[key.replace(/:|\\./g, \"\")] =\r\n\t\t\t\t\t\t\t\tdecodeURIComponent(values[i])\r\n\t\t\t\t\t\t})\r\n\t\t\t\t\t\tm.mount(root, router[route])\r\n\t\t\t\t\t})\r\n\t\t\t\t\t/* eslint-enable no-loop-func */\r\n\t\t\t\t\treturn true\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tfunction routeUnobtrusive(e) {\r\n\t\te = e || event\r\n\t\tif (e.ctrlKey || e.metaKey || e.shiftKey || e.which === 2) return\r\n\r\n\t\tif (e.preventDefault) {\r\n\t\t\te.preventDefault()\r\n\t\t} else {\r\n\t\t\te.returnValue = false\r\n\t\t}\r\n\r\n\t\tvar currentTarget = e.currentTarget || e.srcElement\r\n\t\tvar args\r\n\r\n\t\tif (m.route.mode === \"pathname\" && currentTarget.search) {\r\n\t\t\targs = parseQueryString(currentTarget.search.slice(1))\r\n\t\t} else {\r\n\t\t\targs = {}\r\n\t\t}\r\n\r\n\t\twhile (currentTarget && !/a/i.test(currentTarget.nodeName)) {\r\n\t\t\tcurrentTarget = currentTarget.parentNode\r\n\t\t}\r\n\r\n\t\t// clear pendingRequests because we want an immediate route change\r\n\t\tpendingRequests = 0\r\n\t\tm.route(currentTarget[m.route.mode]\r\n\t\t\t.slice(modes[m.route.mode].length), args)\r\n\t}\r\n\r\n\tfunction setScroll() {\r\n\t\tif (m.route.mode !== \"hash\" && $location.hash) {\r\n\t\t\t$location.hash = $location.hash\r\n\t\t} else {\r\n\t\t\tglobal.scrollTo(0, 0)\r\n\t\t}\r\n\t}\r\n\r\n\tfunction buildQueryString(object, prefix) {\r\n\t\tvar duplicates = {}\r\n\t\tvar str = []\r\n\r\n\t\tfor (var prop in object) {\r\n\t\t\tif (hasOwn.call(object, prop)) {\r\n\t\t\t\tvar key = prefix ? prefix + \"[\" + prop + \"]\" : prop\r\n\t\t\t\tvar value = object[prop]\r\n\r\n\t\t\t\tif (value === null) {\r\n\t\t\t\t\tstr.push(encodeURIComponent(key))\r\n\t\t\t\t} else if (isObject(value)) {\r\n\t\t\t\t\tstr.push(buildQueryString(value, key))\r\n\t\t\t\t} else if (isArray(value)) {\r\n\t\t\t\t\tvar keys = []\r\n\t\t\t\t\tduplicates[key] = duplicates[key] || {}\r\n\t\t\t\t\t/* eslint-disable no-loop-func */\r\n\t\t\t\t\tforEach(value, function (item) {\r\n\t\t\t\t\t\t/* eslint-enable no-loop-func */\r\n\t\t\t\t\t\tif (!duplicates[key][item]) {\r\n\t\t\t\t\t\t\tduplicates[key][item] = true\r\n\t\t\t\t\t\t\tkeys.push(encodeURIComponent(key) + \"=\" +\r\n\t\t\t\t\t\t\t\tencodeURIComponent(item))\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t})\r\n\t\t\t\t\tstr.push(keys.join(\"&\"))\r\n\t\t\t\t} else if (value !== undefined) {\r\n\t\t\t\t\tstr.push(encodeURIComponent(key) + \"=\" +\r\n\t\t\t\t\t\tencodeURIComponent(value))\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn str.join(\"&\")\r\n\t}\r\n\r\n\tfunction parseQueryString(str) {\r\n\t\tif (str === \"\" || str == null) return {}\r\n\t\tif (str.charAt(0) === \"?\") str = str.slice(1)\r\n\r\n\t\tvar pairs = str.split(\"&\")\r\n\t\tvar params = {}\r\n\r\n\t\tforEach(pairs, function (string) {\r\n\t\t\tvar pair = string.split(\"=\")\r\n\t\t\tvar key = decodeURIComponent(pair[0])\r\n\t\t\tvar value = pair.length === 2 ? decodeURIComponent(pair[1]) : null\r\n\t\t\tif (params[key] != null) {\r\n\t\t\t\tif (!isArray(params[key])) params[key] = [params[key]]\r\n\t\t\t\tparams[key].push(value)\r\n\t\t\t}\r\n\t\t\telse params[key] = value\r\n\t\t})\r\n\r\n\t\treturn params\r\n\t}\r\n\r\n\tm.route.buildQueryString = buildQueryString\r\n\tm.route.parseQueryString = parseQueryString\r\n\r\n\tfunction reset(root) {\r\n\t\tvar cacheKey = getCellCacheKey(root)\r\n\t\tclear(root.childNodes, cellCache[cacheKey])\r\n\t\tcellCache[cacheKey] = undefined\r\n\t}\r\n\r\n\tm.deferred = function () {\r\n\t\tvar deferred = new Deferred()\r\n\t\tdeferred.promise = propify(deferred.promise)\r\n\t\treturn deferred\r\n\t}\r\n\r\n\tfunction propify(promise, initialValue) {\r\n\t\tvar prop = m.prop(initialValue)\r\n\t\tpromise.then(prop)\r\n\t\tprop.then = function (resolve, reject) {\r\n\t\t\treturn propify(promise.then(resolve, reject), initialValue)\r\n\t\t}\r\n\r\n\t\tprop.catch = prop.then.bind(null, null)\r\n\t\treturn prop\r\n\t}\r\n\t// Promiz.mithril.js | Zolmeister | MIT\r\n\t// a modified version of Promiz.js, which does not conform to Promises/A+\r\n\t// for two reasons:\r\n\t//\r\n\t// 1) `then` callbacks are called synchronously (because setTimeout is too\r\n\t// slow, and the setImmediate polyfill is too big\r\n\t//\r\n\t// 2) throwing subclasses of Error cause the error to be bubbled up instead\r\n\t// of triggering rejection (because the spec does not account for the\r\n\t// important use case of default browser error handling, i.e. message w/\r\n\t// line number)\r\n\r\n\tvar RESOLVING = 1\r\n\tvar REJECTING = 2\r\n\tvar RESOLVED = 3\r\n\tvar REJECTED = 4\r\n\r\n\tfunction Deferred(onSuccess, onFailure) {\r\n\t\tvar self = this\r\n\t\tvar state = 0\r\n\t\tvar promiseValue = 0\r\n\t\tvar next = []\r\n\r\n\t\tself.promise = {}\r\n\r\n\t\tself.resolve = function (value) {\r\n\t\t\tif (!state) {\r\n\t\t\t\tpromiseValue = value\r\n\t\t\t\tstate = RESOLVING\r\n\r\n\t\t\t\tfire()\r\n\t\t\t}\r\n\r\n\t\t\treturn self\r\n\t\t}\r\n\r\n\t\tself.reject = function (value) {\r\n\t\t\tif (!state) {\r\n\t\t\t\tpromiseValue = value\r\n\t\t\t\tstate = REJECTING\r\n\r\n\t\t\t\tfire()\r\n\t\t\t}\r\n\r\n\t\t\treturn self\r\n\t\t}\r\n\r\n\t\tself.promise.then = function (onSuccess, onFailure) {\r\n\t\t\tvar deferred = new Deferred(onSuccess, onFailure)\r\n\r\n\t\t\tif (state === RESOLVED) {\r\n\t\t\t\tdeferred.resolve(promiseValue)\r\n\t\t\t} else if (state === REJECTED) {\r\n\t\t\t\tdeferred.reject(promiseValue)\r\n\t\t\t} else {\r\n\t\t\t\tnext.push(deferred)\r\n\t\t\t}\r\n\r\n\t\t\treturn deferred.promise\r\n\t\t}\r\n\r\n\t\tfunction finish(type) {\r\n\t\t\tstate = type || REJECTED\r\n\t\t\tnext.map(function (deferred) {\r\n\t\t\t\tif (state === RESOLVED) {\r\n\t\t\t\t\tdeferred.resolve(promiseValue)\r\n\t\t\t\t} else {\r\n\t\t\t\t\tdeferred.reject(promiseValue)\r\n\t\t\t\t}\r\n\t\t\t})\r\n\t\t}\r\n\r\n\t\tfunction thennable(then, success, failure, notThennable) {\r\n\t\t\tif (((promiseValue != null && isObject(promiseValue)) ||\r\n\t\t\t\t\tisFunction(promiseValue)) && isFunction(then)) {\r\n\t\t\t\ttry {\r\n\t\t\t\t\t// count protects against abuse calls from spec checker\r\n\t\t\t\t\tvar count = 0\r\n\t\t\t\t\tthen.call(promiseValue, function (value) {\r\n\t\t\t\t\t\tif (count++) return\r\n\t\t\t\t\t\tpromiseValue = value\r\n\t\t\t\t\t\tsuccess()\r\n\t\t\t\t\t}, function (value) {\r\n\t\t\t\t\t\tif (count++) return\r\n\t\t\t\t\t\tpromiseValue = value\r\n\t\t\t\t\t\tfailure()\r\n\t\t\t\t\t})\r\n\t\t\t\t} catch (e) {\r\n\t\t\t\t\tm.deferred.onerror(e)\r\n\t\t\t\t\tpromiseValue = e\r\n\t\t\t\t\tfailure()\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\tnotThennable()\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tfunction fire() {\r\n\t\t\t// check if it's a thenable\r\n\t\t\tvar then\r\n\t\t\ttry {\r\n\t\t\t\tthen = promiseValue && promiseValue.then\r\n\t\t\t} catch (e) {\r\n\t\t\t\tm.deferred.onerror(e)\r\n\t\t\t\tpromiseValue = e\r\n\t\t\t\tstate = REJECTING\r\n\t\t\t\treturn fire()\r\n\t\t\t}\r\n\r\n\t\t\tif (state === REJECTING) {\r\n\t\t\t\tm.deferred.onerror(promiseValue)\r\n\t\t\t}\r\n\r\n\t\t\tthennable(then, function () {\r\n\t\t\t\tstate = RESOLVING\r\n\t\t\t\tfire()\r\n\t\t\t}, function () {\r\n\t\t\t\tstate = REJECTING\r\n\t\t\t\tfire()\r\n\t\t\t}, function () {\r\n\t\t\t\ttry {\r\n\t\t\t\t\tif (state === RESOLVING && isFunction(onSuccess)) {\r\n\t\t\t\t\t\tpromiseValue = onSuccess(promiseValue)\r\n\t\t\t\t\t} else if (state === REJECTING && isFunction(onFailure)) {\r\n\t\t\t\t\t\tpromiseValue = onFailure(promiseValue)\r\n\t\t\t\t\t\tstate = RESOLVING\r\n\t\t\t\t\t}\r\n\t\t\t\t} catch (e) {\r\n\t\t\t\t\tm.deferred.onerror(e)\r\n\t\t\t\t\tpromiseValue = e\r\n\t\t\t\t\treturn finish()\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (promiseValue === self) {\r\n\t\t\t\t\tpromiseValue = TypeError()\r\n\t\t\t\t\tfinish()\r\n\t\t\t\t} else {\r\n\t\t\t\t\tthennable(then, function () {\r\n\t\t\t\t\t\tfinish(RESOLVED)\r\n\t\t\t\t\t}, finish, function () {\r\n\t\t\t\t\t\tfinish(state === RESOLVING && RESOLVED)\r\n\t\t\t\t\t})\r\n\t\t\t\t}\r\n\t\t\t})\r\n\t\t}\r\n\t}\r\n\r\n\tm.deferred.onerror = function (e) {\r\n\t\tif (type.call(e) === \"[object Error]\" &&\r\n\t\t\t\t!/ Error/.test(e.constructor.toString())) {\r\n\t\t\tpendingRequests = 0\r\n\t\t\tthrow e\r\n\t\t}\r\n\t}\r\n\r\n\tm.sync = function (args) {\r\n\t\tvar deferred = m.deferred()\r\n\t\tvar outstanding = args.length\r\n\t\tvar results = []\r\n\t\tvar method = \"resolve\"\r\n\r\n\t\tfunction synchronizer(pos, resolved) {\r\n\t\t\treturn function (value) {\r\n\t\t\t\tresults[pos] = value\r\n\t\t\t\tif (!resolved) method = \"reject\"\r\n\t\t\t\tif (--outstanding === 0) {\r\n\t\t\t\t\tdeferred.promise(results)\r\n\t\t\t\t\tdeferred[method](results)\r\n\t\t\t\t}\r\n\t\t\t\treturn value\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (args.length > 0) {\r\n\t\t\tforEach(args, function (arg, i) {\r\n\t\t\t\targ.then(synchronizer(i, true), synchronizer(i, false))\r\n\t\t\t})\r\n\t\t} else {\r\n\t\t\tdeferred.resolve([])\r\n\t\t}\r\n\r\n\t\treturn deferred.promise\r\n\t}\r\n\r\n\tfunction identity(value) { return value }\r\n\r\n\tfunction handleJsonp(options) {\r\n\t\tvar callbackKey = options.callbackName || \"mithril_callback_\" +\r\n\t\t\tnew Date().getTime() + \"_\" +\r\n\t\t\t(Math.round(Math.random() * 1e16)).toString(36)\r\n\r\n\t\tvar script = $document.createElement(\"script\")\r\n\r\n\t\tglobal[callbackKey] = function (resp) {\r\n\t\t\tscript.parentNode.removeChild(script)\r\n\t\t\toptions.onload({\r\n\t\t\t\ttype: \"load\",\r\n\t\t\t\ttarget: {\r\n\t\t\t\t\tresponseText: resp\r\n\t\t\t\t}\r\n\t\t\t})\r\n\t\t\tglobal[callbackKey] = undefined\r\n\t\t}\r\n\r\n\t\tscript.onerror = function () {\r\n\t\t\tscript.parentNode.removeChild(script)\r\n\r\n\t\t\toptions.onerror({\r\n\t\t\t\ttype: \"error\",\r\n\t\t\t\ttarget: {\r\n\t\t\t\t\tstatus: 500,\r\n\t\t\t\t\tresponseText: JSON.stringify({\r\n\t\t\t\t\t\terror: \"Error making jsonp request\"\r\n\t\t\t\t\t})\r\n\t\t\t\t}\r\n\t\t\t})\r\n\t\t\tglobal[callbackKey] = undefined\r\n\r\n\t\t\treturn false\r\n\t\t}\r\n\r\n\t\tscript.onload = function () {\r\n\t\t\treturn false\r\n\t\t}\r\n\r\n\t\tscript.src = options.url +\r\n\t\t\t(options.url.indexOf(\"?\") > 0 ? \"&\" : \"?\") +\r\n\t\t\t(options.callbackKey ? options.callbackKey : \"callback\") +\r\n\t\t\t\"=\" + callbackKey +\r\n\t\t\t\"&\" + buildQueryString(options.data || {})\r\n\r\n\t\t$document.body.appendChild(script)\r\n\t}\r\n\r\n\tfunction createXhr(options) {\r\n\t\tvar xhr = new global.XMLHttpRequest()\r\n\t\txhr.open(options.method, options.url, true, options.user,\r\n\t\t\toptions.password)\r\n\r\n\t\txhr.onreadystatechange = function () {\r\n\t\t\tif (xhr.readyState === 4) {\r\n\t\t\t\tif (xhr.status >= 200 && xhr.status < 300) {\r\n\t\t\t\t\toptions.onload({type: \"load\", target: xhr})\r\n\t\t\t\t} else {\r\n\t\t\t\t\toptions.onerror({type: \"error\", target: xhr})\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (options.serialize === JSON.stringify &&\r\n\t\t\t\toptions.data &&\r\n\t\t\t\toptions.method !== \"GET\") {\r\n\t\t\txhr.setRequestHeader(\"Content-Type\",\r\n\t\t\t\t\"application/json; charset=utf-8\")\r\n\t\t}\r\n\r\n\t\tif (options.deserialize === JSON.parse) {\r\n\t\t\txhr.setRequestHeader(\"Accept\", \"application/json, text/*\")\r\n\t\t}\r\n\r\n\t\tif (isFunction(options.config)) {\r\n\t\t\tvar maybeXhr = options.config(xhr, options)\r\n\t\t\tif (maybeXhr != null) xhr = maybeXhr\r\n\t\t}\r\n\r\n\t\tvar data = options.method === \"GET\" || !options.data ? \"\" : options.data\r\n\r\n\t\tif (data && !isString(data) && data.constructor !== global.FormData) {\r\n\t\t\tthrow new Error(\"Request data should be either be a string or \" +\r\n\t\t\t\t\"FormData. Check the `serialize` option in `m.request`\")\r\n\t\t}\r\n\r\n\t\txhr.send(data)\r\n\t\treturn xhr\r\n\t}\r\n\r\n\tfunction ajax(options) {\r\n\t\tif (options.dataType && options.dataType.toLowerCase() === \"jsonp\") {\r\n\t\t\treturn handleJsonp(options)\r\n\t\t} else {\r\n\t\t\treturn createXhr(options)\r\n\t\t}\r\n\t}\r\n\r\n\tfunction bindData(options, data, serialize) {\r\n\t\tif (options.method === \"GET\" && options.dataType !== \"jsonp\") {\r\n\t\t\tvar prefix = options.url.indexOf(\"?\") < 0 ? \"?\" : \"&\"\r\n\t\t\tvar querystring = buildQueryString(data)\r\n\t\t\toptions.url += (querystring ? prefix + querystring : \"\")\r\n\t\t} else {\r\n\t\t\toptions.data = serialize(data)\r\n\t\t}\r\n\t}\r\n\r\n\tfunction parameterizeUrl(url, data) {\r\n\t\tif (data) {\r\n\t\t\turl = url.replace(/:[a-z]\\w+/gi, function (token){\r\n\t\t\t\tvar key = token.slice(1)\r\n\t\t\t\tvar value = data[key] || token\r\n\t\t\t\tdelete data[key]\r\n\t\t\t\treturn value\r\n\t\t\t})\r\n\t\t}\r\n\t\treturn url\r\n\t}\r\n\r\n\tm.request = function (options) {\r\n\t\tif (options.background !== true) m.startComputation()\r\n\t\tvar deferred = new Deferred()\r\n\t\tvar isJSONP = options.dataType &&\r\n\t\t\toptions.dataType.toLowerCase() === \"jsonp\"\r\n\r\n\t\tvar serialize, deserialize, extract\r\n\r\n\t\tif (isJSONP) {\r\n\t\t\tserialize = options.serialize =\r\n\t\t\tdeserialize = options.deserialize = identity\r\n\r\n\t\t\textract = function (jsonp) { return jsonp.responseText }\r\n\t\t} else {\r\n\t\t\tserialize = options.serialize = options.serialize || JSON.stringify\r\n\r\n\t\t\tdeserialize = options.deserialize =\r\n\t\t\t\toptions.deserialize || JSON.parse\r\n\t\t\textract = options.extract || function (xhr) {\r\n\t\t\t\tif (xhr.responseText.length || deserialize !== JSON.parse) {\r\n\t\t\t\t\treturn xhr.responseText\r\n\t\t\t\t} else {\r\n\t\t\t\t\treturn null\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\toptions.method = (options.method || \"GET\").toUpperCase()\r\n\t\toptions.url = parameterizeUrl(options.url, options.data)\r\n\t\tbindData(options, options.data, serialize)\r\n\t\toptions.onload = options.onerror = function (ev) {\r\n\t\t\ttry {\r\n\t\t\t\tev = ev || event\r\n\t\t\t\tvar response = deserialize(extract(ev.target, options))\r\n\t\t\t\tif (ev.type === \"load\") {\r\n\t\t\t\t\tif (options.unwrapSuccess) {\r\n\t\t\t\t\t\tresponse = options.unwrapSuccess(response, ev.target)\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (isArray(response) && options.type) {\r\n\t\t\t\t\t\tforEach(response, function (res, i) {\r\n\t\t\t\t\t\t\tresponse[i] = new options.type(res)\r\n\t\t\t\t\t\t})\r\n\t\t\t\t\t} else if (options.type) {\r\n\t\t\t\t\t\tresponse = new options.type(response)\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tdeferred.resolve(response)\r\n\t\t\t\t} else {\r\n\t\t\t\t\tif (options.unwrapError) {\r\n\t\t\t\t\t\tresponse = options.unwrapError(response, ev.target)\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tdeferred.reject(response)\r\n\t\t\t\t}\r\n\t\t\t} catch (e) {\r\n\t\t\t\tdeferred.reject(e)\r\n\t\t\t\tm.deferred.onerror(e)\r\n\t\t\t} finally {\r\n\t\t\t\tif (options.background !== true) m.endComputation()\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tajax(options)\r\n\t\tdeferred.promise = propify(deferred.promise, options.initialValue)\r\n\t\treturn deferred.promise\r\n\t}\r\n\r\n\treturn m\r\n}); // eslint-disable-line\r\n\n},{}],8:[function(require,module,exports){\n/*!\n * EventEmitter v4.2.11 - git.io/ee\n * Unlicense - http://unlicense.org/\n * Oliver Caldwell - http://oli.me.uk/\n * @preserve\n */\n\n;(function () {\n 'use strict';\n\n /**\n * Class for managing events.\n * Can be extended to provide event functionality in other classes.\n *\n * @class EventEmitter Manages event registering and emitting.\n */\n function EventEmitter() {}\n\n // Shortcuts to improve speed and size\n var proto = EventEmitter.prototype;\n var exports = this;\n var originalGlobalValue = exports.EventEmitter;\n\n /**\n * Finds the index of the listener for the event in its storage array.\n *\n * @param {Function[]} listeners Array of listeners to search through.\n * @param {Function} listener Method to look for.\n * @return {Number} Index of the specified listener, -1 if not found\n * @api private\n */\n function indexOfListener(listeners, listener) {\n var i = listeners.length;\n while (i--) {\n if (listeners[i].listener === listener) {\n return i;\n }\n }\n\n return -1;\n }\n\n /**\n * Alias a method while keeping the context correct, to allow for overwriting of target method.\n *\n * @param {String} name The name of the target method.\n * @return {Function} The aliased method\n * @api private\n */\n function alias(name) {\n return function aliasClosure() {\n return this[name].apply(this, arguments);\n };\n }\n\n /**\n * Returns the listener array for the specified event.\n * Will initialise the event object and listener arrays if required.\n * Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them.\n * Each property in the object response is an array of listener functions.\n *\n * @param {String|RegExp} evt Name of the event to return the listeners from.\n * @return {Function[]|Object} All listener functions for the event.\n */\n proto.getListeners = function getListeners(evt) {\n var events = this._getEvents();\n var response;\n var key;\n\n // Return a concatenated array of all matching events if\n // the selector is a regular expression.\n if (evt instanceof RegExp) {\n response = {};\n for (key in events) {\n if (events.hasOwnProperty(key) && evt.test(key)) {\n response[key] = events[key];\n }\n }\n }\n else {\n response = events[evt] || (events[evt] = []);\n }\n\n return response;\n };\n\n /**\n * Takes a list of listener objects and flattens it into a list of listener functions.\n *\n * @param {Object[]} listeners Raw listener objects.\n * @return {Function[]} Just the listener functions.\n */\n proto.flattenListeners = function flattenListeners(listeners) {\n var flatListeners = [];\n var i;\n\n for (i = 0; i < listeners.length; i += 1) {\n flatListeners.push(listeners[i].listener);\n }\n\n return flatListeners;\n };\n\n /**\n * Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful.\n *\n * @param {String|RegExp} evt Name of the event to return the listeners from.\n * @return {Object} All listener functions for an event in an object.\n */\n proto.getListenersAsObject = function getListenersAsObject(evt) {\n var listeners = this.getListeners(evt);\n var response;\n\n if (listeners instanceof Array) {\n response = {};\n response[evt] = listeners;\n }\n\n return response || listeners;\n };\n\n /**\n * Adds a listener function to the specified event.\n * The listener will not be added if it is a duplicate.\n * If the listener returns true then it will be removed after it is called.\n * If you pass a regular expression as the event name then the listener will be added to all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to attach the listener to.\n * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.addListener = function addListener(evt, listener) {\n var listeners = this.getListenersAsObject(evt);\n var listenerIsWrapped = typeof listener === 'object';\n var key;\n\n for (key in listeners) {\n if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) {\n listeners[key].push(listenerIsWrapped ? listener : {\n listener: listener,\n once: false\n });\n }\n }\n\n return this;\n };\n\n /**\n * Alias of addListener\n */\n proto.on = alias('addListener');\n\n /**\n * Semi-alias of addListener. It will add a listener that will be\n * automatically removed after its first execution.\n *\n * @param {String|RegExp} evt Name of the event to attach the listener to.\n * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.addOnceListener = function addOnceListener(evt, listener) {\n return this.addListener(evt, {\n listener: listener,\n once: true\n });\n };\n\n /**\n * Alias of addOnceListener.\n */\n proto.once = alias('addOnceListener');\n\n /**\n * Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad.\n * You need to tell it what event names should be matched by a regex.\n *\n * @param {String} evt Name of the event to create.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.defineEvent = function defineEvent(evt) {\n this.getListeners(evt);\n return this;\n };\n\n /**\n * Uses defineEvent to define multiple events.\n *\n * @param {String[]} evts An array of event names to define.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.defineEvents = function defineEvents(evts) {\n for (var i = 0; i < evts.length; i += 1) {\n this.defineEvent(evts[i]);\n }\n return this;\n };\n\n /**\n * Removes a listener function from the specified event.\n * When passed a regular expression as the event name, it will remove the listener from all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to remove the listener from.\n * @param {Function} listener Method to remove from the event.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.removeListener = function removeListener(evt, listener) {\n var listeners = this.getListenersAsObject(evt);\n var index;\n var key;\n\n for (key in listeners) {\n if (listeners.hasOwnProperty(key)) {\n index = indexOfListener(listeners[key], listener);\n\n if (index !== -1) {\n listeners[key].splice(index, 1);\n }\n }\n }\n\n return this;\n };\n\n /**\n * Alias of removeListener\n */\n proto.off = alias('removeListener');\n\n /**\n * Adds listeners in bulk using the manipulateListeners method.\n * If you pass an object as the second argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added.\n * You can also pass it a regular expression to add the array of listeners to all events that match it.\n * Yeah, this function does quite a bit. That's probably a bad thing.\n *\n * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once.\n * @param {Function[]} [listeners] An optional array of listener functions to add.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.addListeners = function addListeners(evt, listeners) {\n // Pass through to manipulateListeners\n return this.manipulateListeners(false, evt, listeners);\n };\n\n /**\n * Removes listeners in bulk using the manipulateListeners method.\n * If you pass an object as the second argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.\n * You can also pass it an event name and an array of listeners to be removed.\n * You can also pass it a regular expression to remove the listeners from all events that match it.\n *\n * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once.\n * @param {Function[]} [listeners] An optional array of listener functions to remove.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.removeListeners = function removeListeners(evt, listeners) {\n // Pass through to manipulateListeners\n return this.manipulateListeners(true, evt, listeners);\n };\n\n /**\n * Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level.\n * The first argument will determine if the listeners are removed (true) or added (false).\n * If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.\n * You can also pass it an event name and an array of listeners to be added/removed.\n * You can also pass it a regular expression to manipulate the listeners of all events that match it.\n *\n * @param {Boolean} remove True if you want to remove listeners, false if you want to add.\n * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once.\n * @param {Function[]} [listeners] An optional array of listener functions to add/remove.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) {\n var i;\n var value;\n var single = remove ? this.removeListener : this.addListener;\n var multiple = remove ? this.removeListeners : this.addListeners;\n\n // If evt is an object then pass each of its properties to this method\n if (typeof evt === 'object' && !(evt instanceof RegExp)) {\n for (i in evt) {\n if (evt.hasOwnProperty(i) && (value = evt[i])) {\n // Pass the single listener straight through to the singular method\n if (typeof value === 'function') {\n single.call(this, i, value);\n }\n else {\n // Otherwise pass back to the multiple function\n multiple.call(this, i, value);\n }\n }\n }\n }\n else {\n // So evt must be a string\n // And listeners must be an array of listeners\n // Loop over it and pass each one to the multiple method\n i = listeners.length;\n while (i--) {\n single.call(this, evt, listeners[i]);\n }\n }\n\n return this;\n };\n\n /**\n * Removes all listeners from a specified event.\n * If you do not specify an event then all listeners will be removed.\n * That means every event will be emptied.\n * You can also pass a regex to remove all events that match it.\n *\n * @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.removeEvent = function removeEvent(evt) {\n var type = typeof evt;\n var events = this._getEvents();\n var key;\n\n // Remove different things depending on the state of evt\n if (type === 'string') {\n // Remove all listeners for the specified event\n delete events[evt];\n }\n else if (evt instanceof RegExp) {\n // Remove all events matching the regex.\n for (key in events) {\n if (events.hasOwnProperty(key) && evt.test(key)) {\n delete events[key];\n }\n }\n }\n else {\n // Remove all listeners in all events\n delete this._events;\n }\n\n return this;\n };\n\n /**\n * Alias of removeEvent.\n *\n * Added to mirror the node API.\n */\n proto.removeAllListeners = alias('removeEvent');\n\n /**\n * Emits an event of your choice.\n * When emitted, every listener attached to that event will be executed.\n * If you pass the optional argument array then those arguments will be passed to every listener upon execution.\n * Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.\n * So they will not arrive within the array on the other side, they will be separate.\n * You can also pass a regular expression to emit to all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to emit and execute listeners for.\n * @param {Array} [args] Optional array of arguments to be passed to each listener.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.emitEvent = function emitEvent(evt, args) {\n var listenersMap = this.getListenersAsObject(evt);\n var listeners;\n var listener;\n var i;\n var key;\n var response;\n\n for (key in listenersMap) {\n if (listenersMap.hasOwnProperty(key)) {\n listeners = listenersMap[key].slice(0);\n i = listeners.length;\n\n while (i--) {\n // If the listener returns true then it shall be removed from the event\n // The function is executed either with a basic call or an apply if there is an args array\n listener = listeners[i];\n\n if (listener.once === true) {\n this.removeListener(evt, listener.listener);\n }\n\n response = listener.listener.apply(this, args || []);\n\n if (response === this._getOnceReturnValue()) {\n this.removeListener(evt, listener.listener);\n }\n }\n }\n }\n\n return this;\n };\n\n /**\n * Alias of emitEvent\n */\n proto.trigger = alias('emitEvent');\n\n /**\n * Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on.\n * As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to emit and execute listeners for.\n * @param {...*} Optional additional arguments to be passed to each listener.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.emit = function emit(evt) {\n var args = Array.prototype.slice.call(arguments, 1);\n return this.emitEvent(evt, args);\n };\n\n /**\n * Sets the current value to check against when executing listeners. If a\n * listeners return value matches the one set here then it will be removed\n * after execution. This value defaults to true.\n *\n * @param {*} value The new value to check for when executing listeners.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.setOnceReturnValue = function setOnceReturnValue(value) {\n this._onceReturnValue = value;\n return this;\n };\n\n /**\n * Fetches the current value to check against when executing listeners. If\n * the listeners return value matches this one then it should be removed\n * automatically. It will return true by default.\n *\n * @return {*|Boolean} The current value to check for or the default, true.\n * @api private\n */\n proto._getOnceReturnValue = function _getOnceReturnValue() {\n if (this.hasOwnProperty('_onceReturnValue')) {\n return this._onceReturnValue;\n }\n else {\n return true;\n }\n };\n\n /**\n * Fetches the events object and creates one if required.\n *\n * @return {Object} The events storage object.\n * @api private\n */\n proto._getEvents = function _getEvents() {\n return this._events || (this._events = {});\n };\n\n /**\n * Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.\n *\n * @return {Function} Non conflicting EventEmitter class.\n */\n EventEmitter.noConflict = function noConflict() {\n exports.EventEmitter = originalGlobalValue;\n return EventEmitter;\n };\n\n // Expose the class either via AMD, CommonJS or the global object\n if (typeof define === 'function' && define.amd) {\n define(function () {\n return EventEmitter;\n });\n }\n else if (typeof module === 'object' && module.exports){\n module.exports = EventEmitter;\n }\n else {\n exports.EventEmitter = EventEmitter;\n }\n}.call(this));\n\n},{}]},{},[1]);\n })();"]}
1
+ {"version":3,"sources":["admin.js"],"names":["require","undefined","define","e","t","n","r","s","o","u","a","i","f","Error","code","l","exports","call","length","1","module","m","window","EventEmitter","context","document","getElementById","events","tabs","helpers","settings","ListFetcher","mount","mc4wp","deps","mithril","./admin/helpers.js","./admin/list-fetcher.js","./admin/settings.js","./admin/tabs.js","wolfy87-eventemitter","2","toggleElement","selector","elements","querySelectorAll","show","clientHeight","style","display","bindEventToElement","element","event","handler","addEventListener","attachEvent","bindEventToElements","Array","prototype","forEach","debounce","func","wait","immediate","timeout","this","args","arguments","later","apply","callNow","clearTimeout","setTimeout","showIfElements","getAttribute","checked","value","conditionMet","config","hide","visibility","opacity","inputs","inputElement","removeAttribute","setAttribute","JSON","parse","parentElements","parentElement","3","working","done","mailchimp","api_connected","lists","fetch","$","jQuery","mc4wp_vars","i18n","preventDefault","post","ajaxurl","action","data","location","reload","always","redraw","bind","view","method","onsubmit","type","fetching_mailchimp_lists","renew_mailchimp_lists","className","disabled","trust","fetching_mailchimp_lists_can_take_a_while","fetching_mailchimp_lists_done","4","_typeof","Symbol","iterator","obj","constructor","Settings","getSelectedListsWhere","searchKey","searchValue","selectedLists","filter","el","getSelectedLists","updateSelectedLists","listInputs","input","push","trigger","toggleVisibleLists","rows","replace","querySelector","on","5","URL","Tabs","get","id","_open","tab","updateState","$tabs","removeClass","css","$tabNavs","nav","blur","url","setParameter","href","history","pushState","title","refererField","tb_remove","forms","editor","refresh","split","switchTab","tabId","match","urlParams","returnValue","$context","find","each","substring","first","text","open","click","body","activeTab","replaceState","state","./url.js","6","query","hasOwnProperty","b","decodeURIComponent","build","ret","d","encodeURIComponent","join","key","7","global","Vnode","tag","attrs0","children","dom","attrs","domSize","instance","skip","hyperscript","selectorCache","classes","attributes","selectorParser","exec","attrValue","childList","hasAttrs","class","isArray","childrenIndex","normalizeChildren","throttle","callback","last","pending","requestAnimationFrame","now","Date","normalize","node","html","fragment","attrs1","PromisePolyfill","executor","list","shouldAbsorb","execute","then","callAsync","console","error","resolvers","rejectors","retry","self","TypeError","executeOnce","rejectCurrent","run","fn","runs","onerror","resolveCurrent","_instance","setImmediate","onFulfilled","onRejection","handle","next","resolveNext","rejectNext","promise","resolve","reject","catch","all","total","count","values","consume","race","Promise","buildQueryString","object","destructure","key0","Object","toString","requestService","$window","setCompletionCallback","oncompletion","finalizer","complete","finalize","promise0","then0","extra","request","toUpperCase","useBody","serialize","FormData","stringify","deserialize","extract","interpolate","assemble","xhr","XMLHttpRequest","async","user","password","setRequestHeader","withCredentials","headers","onreadystatechange","status","readyState","response","cast","responseText","send","background","jsonp","callbackName","Math","round","random","callbackCount","script","createElement","parentNode","removeChild","callbackKey","src","documentElement","appendChild","tokens","slice","querystring","indexOf","type0","coreRenderer","setEventCallback","onevent","createNodes","parent","vnodes","start","end","hooks","nextSibling","ns","vnode","createNode","initLifecycle","createComponent","createText","createHTML","createFragment","$doc","createTextNode","insertNode","match1","parent1","caption","thead","tbody","tfoot","tr","th","td","colgroup","col","temp","innerHTML","firstChild","childNodes","child","createDocumentFragment","attrs2","is","createElementNS","setAttrs","contenteditable","setContentEditable","textContent","setLateAttrs","create","reentrantLock","$emptyFragment","updateNodes","old","recycling","removeNodes","isUnkeyed","getNextSibling","updateNode","isRecyclable","concat","pool","map","oldStart","oldEnd","v","toFragment","getKeyMap","oldIndex","movable","oldTag","shouldUpdate","updateLifecycle","updateText","updateHTML","updateFragment","updateElement","updateComponent","removeNode","nodeValue","updateAttrs","abs","oldChildrenLength","poolChildrenLength","vnodesChildrenLength","key2","count0","insertBefore","content","continuation","called","expected","onremove","removeNodeFromDOM","hasIntegrationMethods","onbeforeremove","result","setAttr","isFormAttribute","isLifecycleMethod","nsLastIndex","substr","setAttributeNS","updateEvent","updateStyle","isAttribute","isCustomElement","activeElement","selectedIndex","attr","source","oncreate","onupdate","cssText","eventName","removeEventListener","oninit","forceVnodeUpdate","forceComponentUpdate","onbeforeupdate","render","active","focus","redrawService","subscribe","key1","unsubscribe","callbacks","index","splice","renderService","redrawService0","root","component","run0","parseQueryString","string","charAt","entries","data0","counters","entry","key5","levels","cursor","pop","j","level","nextLevel","isNumber","isNaN","parseInt","isValue","coreRouter","normalize1","fragment0","debounceAsync","callback0","asyncId","callAsync0","parsePath","path","queryData","hashData","queryIndex","hashIndex","pathEnd","queryEnd","queryParams","key4","hashParams","supportsPushState","router","prefix","getPath","setPath","options","match2","token","hash","onpopstate","defineRoutes","routes","resolveRoute","params","pathname","k","route0","matcher","RegExp","test","keys","onhashchange","route","render1","attrs3","currentPath","lastUpdate","routeService","identity","defaultRoute","run1","bail","payload","update","routeResolver","comp","onmatch","resolved","set","prefix0","link","vnode1","onclick","ctrlKey","metaKey","shiftKey","which","param","key3","withAttr","attrName","callback1","currentTarget","_28","version","8","indexOfListener","listeners","listener","alias","name","isValidListener","proto","originalGlobalValue","getListeners","evt","_getEvents","flattenListeners","flatListeners","getListenersAsObject","addListener","listenerIsWrapped","once","addOnceListener","defineEvent","defineEvents","evts","removeListener","off","addListeners","manipulateListeners","removeListeners","remove","single","multiple","removeEvent","_events","removeAllListeners","emitEvent","listenersMap","_getOnceReturnValue","emit","setOnceReturnValue","_onceReturnValue","noConflict","amd"],"mappings":"CAAA,WAAe,GAAIA,GAAUC,OAAeC,EAASD,QAAW,QAAUE,GAAEC,EAAEC,EAAEC,GAAG,QAASC,GAAEC,EAAEC,GAAG,IAAIJ,EAAEG,GAAG,CAAC,IAAIJ,EAAEI,GAAG,CAAC,GAAIE,GAAkB,kBAATV,IAAqBA,CAAQ,KAAIS,GAAGC,EAAE,MAAOA,GAAEF,GAAE,EAAI,IAAGG,EAAE,MAAOA,GAAEH,GAAE,EAAI,IAAII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,IAAQmX,EAAI9C,KAAKrU,UAChC7K,GAAO6K,cAMfvI,MAAK+gB,OAGhB,OAAO/gB,OAQXuf,EAAMyB,mBAAqB5B,EAAM,eAcjCG,EAAM0B,UAAY,SAAmBvB,EAAKzf,GACtC,GACIif,GACAC,EACAziB,EACA6L,EAJA2Y,EAAelhB,KAAK8f,qBAAqBJ,EAO7C,KAAKnX,IAAO2Y,GACR,GAAIA,EAAanZ,eAAeQ,GAG5B,IAFA2W,EAAYgC,EAAa3Y,GAAKsI,MAAM,GAE/BnU,EAAI,EAAGA,EAAIwiB,EAAUjiB,OAAQP,IAG9ByiB,EAAWD,EAAUxiB,GAEjByiB,EAASc,QAAS,GAClBjgB,KAAKsgB,eAAeZ,EAAKP,EAASA,UAG3BA,EAASA,SAAS/e,MAAMJ,KAAMC,SAExBD,KAAKmhB,uBAClBnhB,KAAKsgB,eAAeZ,EAAKP,EAASA,SAMlD,OAAOnf,OAMXuf,EAAM5a,QAAUya,EAAM,aAUtBG,EAAM6B,KAAO,SAAc1B,GACvB,GAAIzf,GAAOT,MAAMC,UAAUoR,MAAM7T,KAAKkD,UAAW,EACjD,OAAOF,MAAKihB,UAAUvB,EAAKzf,IAW/Bsf,EAAM8B,mBAAqB,SAA4B1gB,GAEnD,MADAX,MAAKshB,iBAAmB3gB,EACjBX,MAWXuf,EAAM4B,oBAAsB,WACxB,OAAInhB,KAAK+H,eAAe,qBACb/H,KAAKshB,kBAapB/B,EAAMI,WAAa,WACf,MAAO3f,MAAK+gB,UAAY/gB,KAAK+gB,aAQjCzjB,EAAaikB,WAAa,WAEtB,MADAxkB,GAAQO,aAAekiB,EAChBliB,GAIW,kBAAXrB,IAAyBA,EAAOulB,IACvCvlB,EAAO,WACH,MAAOqB,KAGY,gBAAXH,IAAuBA,EAAOJ,QAC1CI,EAAOJ,QAAUO,EAGjBP,EAAQO,aAAeA,GAE7B0C,oBAES","file":"admin.min.js","sourcesContent":["(function () { var require = undefined; var define = undefined; (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){\n'use strict';\n\n// dependencies\n\nvar m = window.m = require('mithril');\nvar EventEmitter = require('wolfy87-eventemitter');\n\n// vars\nvar context = document.getElementById('mc4wp-admin');\nvar events = new EventEmitter();\nvar tabs = require('./admin/tabs.js')(context);\nvar helpers = require('./admin/helpers.js');\nvar settings = require('./admin/settings.js')(context, helpers, events);\n\n// list fetcher\nvar ListFetcher = require('./admin/list-fetcher.js');\nvar mount = document.getElementById('mc4wp-list-fetcher');\nif (mount) {\n m.mount(mount, new ListFetcher());\n}\n\n// expose some things\nwindow.mc4wp = window.mc4wp || {};\nwindow.mc4wp.deps = window.mc4wp.deps || {};\nwindow.mc4wp.deps.mithril = m;\nwindow.mc4wp.helpers = helpers;\nwindow.mc4wp.events = events;\nwindow.mc4wp.settings = settings;\nwindow.mc4wp.tabs = tabs;\n\n},{\"./admin/helpers.js\":2,\"./admin/list-fetcher.js\":3,\"./admin/settings.js\":4,\"./admin/tabs.js\":5,\"mithril\":7,\"wolfy87-eventemitter\":8}],2:[function(require,module,exports){\n'use strict';\n\nvar helpers = {};\n\nhelpers.toggleElement = function (selector) {\n\tvar elements = document.querySelectorAll(selector);\n\tfor (var i = 0; i < elements.length; i++) {\n\t\tvar show = elements[i].clientHeight <= 0;\n\t\telements[i].style.display = show ? '' : 'none';\n\t}\n};\n\nhelpers.bindEventToElement = function (element, event, handler) {\n\tif (element.addEventListener) {\n\t\telement.addEventListener(event, handler);\n\t} else if (element.attachEvent) {\n\t\telement.attachEvent('on' + event, handler);\n\t}\n};\n\nhelpers.bindEventToElements = function (elements, event, handler) {\n\tArray.prototype.forEach.call(elements, function (element) {\n\t\thelpers.bindEventToElement(element, event, handler);\n\t});\n};\n\n// polling\nhelpers.debounce = function (func, wait, immediate) {\n\tvar timeout;\n\treturn function () {\n\t\tvar context = this,\n\t\t args = arguments;\n\t\tvar later = function later() {\n\t\t\ttimeout = null;\n\t\t\tif (!immediate) func.apply(context, args);\n\t\t};\n\t\tvar callNow = immediate && !timeout;\n\t\tclearTimeout(timeout);\n\t\ttimeout = setTimeout(later, wait);\n\t\tif (callNow) func.apply(context, args);\n\t};\n};\n\n/**\n * Showif.js\n */\n(function () {\n\tvar showIfElements = document.querySelectorAll('[data-showif]');\n\n\t// dependent elements\n\tArray.prototype.forEach.call(showIfElements, function (element) {\n\t\tvar config = JSON.parse(element.getAttribute('data-showif'));\n\t\tvar parentElements = document.querySelectorAll('[name=\"' + config.element + '\"]');\n\t\tvar inputs = element.querySelectorAll('input,select,textarea:not([readonly])');\n\t\tvar hide = config.hide === undefined || config.hide;\n\n\t\tfunction toggleElement() {\n\n\t\t\t// do nothing with unchecked radio inputs\n\t\t\tif (this.getAttribute('type') === \"radio\" && !this.checked) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tvar value = this.getAttribute(\"type\") === \"checkbox\" ? this.checked : this.value;\n\t\t\tvar conditionMet = value == config.value;\n\n\t\t\tif (hide) {\n\t\t\t\telement.style.display = conditionMet ? '' : 'none';\n\t\t\t\telement.style.visibility = conditionMet ? '' : 'hidden';\n\t\t\t} else {\n\t\t\t\telement.style.opacity = conditionMet ? '' : '0.4';\n\t\t\t}\n\n\t\t\t// disable input fields to stop sending their values to server\n\t\t\tArray.prototype.forEach.call(inputs, function (inputElement) {\n\t\t\t\tconditionMet ? inputElement.removeAttribute('readonly') : inputElement.setAttribute('readonly', 'readonly');\n\t\t\t});\n\t\t}\n\n\t\t// find checked element and call toggleElement function\n\t\tArray.prototype.forEach.call(parentElements, function (parentElement) {\n\t\t\ttoggleElement.call(parentElement);\n\t\t});\n\n\t\t// bind on all changes\n\t\thelpers.bindEventToElements(parentElements, 'change', toggleElement);\n\t});\n})();\n\nmodule.exports = helpers;\n\n},{}],3:[function(require,module,exports){\n'use strict';\n\nvar $ = window.jQuery;\nvar config = mc4wp_vars;\nvar i18n = config.i18n;\n\nfunction ListFetcher() {\n this.working = false;\n this.done = false;\n\n // start fetching right away when no lists but api key given\n if (config.mailchimp.api_connected && config.mailchimp.lists.length == 0) {\n this.fetch();\n }\n}\n\nListFetcher.prototype.fetch = function (e) {\n e && e.preventDefault();\n\n this.working = true;\n this.done = false;\n\n $.post(ajaxurl, {\n action: \"mc4wp_renew_mailchimp_lists\"\n }).done(function (data) {\n if (data) {\n window.setTimeout(function () {\n window.location.reload();\n }, 3000);\n }\n }).always(function (data) {\n this.working = false;\n this.done = true;\n\n m.redraw();\n }.bind(this));\n};\n\nListFetcher.prototype.view = function () {\n return m('form', {\n method: \"POST\",\n onsubmit: this.fetch.bind(this)\n }, [m('p', [m('input', {\n type: \"submit\",\n value: this.working ? i18n.fetching_mailchimp_lists : i18n.renew_mailchimp_lists,\n className: \"button\",\n disabled: !!this.working\n }), m.trust(' &nbsp; '), this.working ? [m('span.mc4wp-loader', \"Loading...\"), m.trust(' &nbsp; '), m('em.help', i18n.fetching_mailchimp_lists_can_take_a_while)] : '', this.done ? [m('em.help.green', i18n.fetching_mailchimp_lists_done)] : ''])]);\n};\n\nmodule.exports = ListFetcher;\n\n},{}],4:[function(require,module,exports){\n'use strict';\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\nvar Settings = function Settings(context, helpers, events) {\n\t'use strict';\n\n\t// vars\n\n\tvar form = context.querySelector('form');\n\tvar listInputs = context.querySelectorAll('.mc4wp-list-input');\n\tvar lists = mc4wp_vars.mailchimp.lists;\n\tvar selectedLists = [];\n\n\t// functions\n\tfunction getSelectedListsWhere(searchKey, searchValue) {\n\t\treturn selectedLists.filter(function (el) {\n\t\t\treturn el[searchKey] === searchValue;\n\t\t});\n\t}\n\n\tfunction getSelectedLists() {\n\t\treturn selectedLists;\n\t}\n\n\tfunction updateSelectedLists() {\n\t\tselectedLists = [];\n\n\t\tArray.prototype.forEach.call(listInputs, function (input) {\n\t\t\t// skip unchecked checkboxes\n\t\t\tif (typeof input.checked === \"boolean\" && !input.checked) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (_typeof(lists[input.value]) === \"object\") {\n\t\t\t\tselectedLists.push(lists[input.value]);\n\t\t\t}\n\t\t});\n\n\t\tevents.trigger('selectedLists.change', [selectedLists]);\n\t\treturn selectedLists;\n\t}\n\n\tfunction toggleVisibleLists() {\n\t\tvar rows = document.querySelectorAll('.lists--only-selected > *');\n\t\tArray.prototype.forEach.call(rows, function (el) {\n\n\t\t\tvar listId = el.getAttribute('data-list-id');\n\t\t\tvar isSelected = getSelectedListsWhere('id', listId).length > 0;\n\n\t\t\tif (isSelected) {\n\t\t\t\tel.setAttribute('class', el.getAttribute('class').replace('hidden', ''));\n\t\t\t} else {\n\t\t\t\tel.setAttribute('class', el.getAttribute('class') + \" hidden\");\n\t\t\t}\n\t\t});\n\t}\n\n\tevents.on('selectedLists.change', toggleVisibleLists);\n\thelpers.bindEventToElements(listInputs, 'change', updateSelectedLists);\n\n\tupdateSelectedLists();\n\n\treturn {\n\t\tgetSelectedLists: getSelectedLists\n\t};\n};\n\nmodule.exports = Settings;\n\n},{}],5:[function(require,module,exports){\n'use strict';\n\nvar URL = require('./url.js');\n\n// Tabs\nvar Tabs = function Tabs(context) {\n\n\t// TODO: last piece of jQuery... can we get rid of it?\n\tvar $ = window.jQuery;\n\n\tvar $context = $(context);\n\tvar $tabs = $context.find('.tab');\n\tvar $tabNavs = $context.find('.nav-tab');\n\tvar refererField = context.querySelector('input[name=\"_wp_http_referer\"]');\n\tvar tabs = [];\n\n\t$.each($tabs, function (i, t) {\n\t\tvar id = t.id.substring(4);\n\t\tvar title = $(t).find('h2').first().text();\n\n\t\ttabs.push({\n\t\t\tid: id,\n\t\t\ttitle: title,\n\t\t\telement: t,\n\t\t\tnav: context.querySelectorAll('.nav-tab-' + id),\n\t\t\topen: function open() {\n\t\t\t\treturn _open(id);\n\t\t\t}\n\t\t});\n\t});\n\n\tfunction get(id) {\n\n\t\tfor (var i = 0; i < tabs.length; i++) {\n\t\t\tif (tabs[i].id === id) {\n\t\t\t\treturn tabs[i];\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tfunction _open(tab, updateState) {\n\n\t\t// make sure we have a tab object\n\t\tif (typeof tab === \"string\") {\n\t\t\ttab = get(tab);\n\t\t}\n\n\t\tif (!tab) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// should we update state?\n\t\tif (updateState == undefined) {\n\t\t\tupdateState = true;\n\t\t}\n\n\t\t// hide all tabs & remove active class\n\t\t$tabs.removeClass('tab-active').css('display', 'none');\n\t\t$tabNavs.removeClass('nav-tab-active');\n\n\t\t// add `nav-tab-active` to this tab\n\t\tArray.prototype.forEach.call(tab.nav, function (nav) {\n\t\t\tnav.className += \" nav-tab-active\";\n\t\t\tnav.blur();\n\t\t});\n\n\t\t// show target tab\n\t\ttab.element.style.display = 'block';\n\t\ttab.element.className += \" tab-active\";\n\n\t\t// create new URL\n\t\tvar url = URL.setParameter(window.location.href, \"tab\", tab.id);\n\n\t\t// update hash\n\t\tif (history.pushState && updateState) {\n\t\t\thistory.pushState(tab.id, '', url);\n\t\t}\n\n\t\t// update document title\n\t\ttitle(tab);\n\n\t\t// update referer field\n\t\trefererField.value = url;\n\n\t\t// if thickbox is open, close it.\n\t\tif (typeof tb_remove === \"function\") {\n\t\t\ttb_remove();\n\t\t}\n\n\t\t// refresh editor after switching tabs\n\t\t// TODO: decouple this! law of demeter etc.\n\t\tif (tab.id === 'fields' && window.mc4wp && window.mc4wp.forms && window.mc4wp.forms.editor) {\n\t\t\tmc4wp.forms.editor.refresh();\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tfunction title(tab) {\n\t\tvar title = document.title.split('-');\n\t\tdocument.title = document.title.replace(title[0], tab.title + \" \");\n\t}\n\n\tfunction switchTab(e) {\n\t\te = e || window.event;\n\n\t\t// get from data attribute\n\t\tvar tabId = this.getAttribute('data-tab');\n\n\t\t// get from classname\n\t\tif (!tabId) {\n\t\t\tvar match = this.className.match(/nav-tab-(\\w+)?/);\n\t\t\tif (match) {\n\t\t\t\ttabId = match[1];\n\t\t\t}\n\t\t}\n\n\t\t// get from href\n\t\tif (!tabId) {\n\t\t\tvar urlParams = URL.parse(this.href);\n\t\t\tif (!urlParams.tab) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttabId = urlParams.tab;\n\t\t}\n\n\t\tvar opened = _open(tabId);\n\n\t\tif (opened) {\n\t\t\te.preventDefault();\n\t\t\te.returnValue = false;\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tfunction init() {\n\n\t\t// check for current tab\n\t\tif (!history.pushState) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar activeTab = $tabs.filter(':visible').get(0);\n\t\tif (!activeTab) {\n\t\t\treturn;\n\t\t}\n\t\tvar tab = get(activeTab.id.substring(4));\n\t\tif (!tab) return;\n\n\t\t// check if tab is in html5 history\n\t\tif (history.replaceState && history.state === null) {\n\t\t\thistory.replaceState(tab.id, '');\n\t\t}\n\n\t\t// update document title\n\t\ttitle(tab);\n\t}\n\n\t$tabNavs.click(switchTab);\n\t$(document.body).on('click', '.tab-link', switchTab);\n\tinit();\n\n\tif (window.addEventListener && history.pushState) {\n\t\twindow.addEventListener('popstate', function (e) {\n\t\t\tif (!e.state) return true;\n\t\t\tvar tabId = e.state;\n\t\t\treturn _open(tabId, false);\n\t\t});\n\t}\n\n\treturn {\n\t\topen: _open,\n\t\tget: get\n\t};\n};\n\nmodule.exports = Tabs;\n\n},{\"./url.js\":6}],6:[function(require,module,exports){\n'use strict';\n\nvar URL = {\n\tparse: function parse(url) {\n\t\tvar query = {};\n\t\tvar a = url.split('&');\n\t\tfor (var i in a) {\n\t\t\tif (!a.hasOwnProperty(i)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tvar b = a[i].split('=');\n\t\t\tquery[decodeURIComponent(b[0])] = decodeURIComponent(b[1]);\n\t\t}\n\n\t\treturn query;\n\t},\n\tbuild: function build(data) {\n\t\tvar ret = [];\n\t\tfor (var d in data) {\n\t\t\tret.push(d + \"=\" + encodeURIComponent(data[d]));\n\t\t}return ret.join(\"&\");\n\t},\n\tsetParameter: function setParameter(url, key, value) {\n\t\tvar data = URL.parse(url);\n\t\tdata[key] = value;\n\t\treturn URL.build(data);\n\t}\n};\n\nmodule.exports = URL;\n\n},{}],7:[function(require,module,exports){\n(function (global){\nnew function() {\n\nfunction Vnode(tag, key, attrs0, children, text, dom) {\n\treturn {tag: tag, key: key, attrs: attrs0, children: children, text: text, dom: dom, domSize: undefined, state: {}, events: undefined, instance: undefined, skip: false}\n}\nVnode.normalize = function(node) {\n\tif (Array.isArray(node)) return Vnode(\"[\", undefined, undefined, Vnode.normalizeChildren(node), undefined, undefined)\n\tif (node != null && typeof node !== \"object\") return Vnode(\"#\", undefined, undefined, node === false ? \"\" : node, undefined, undefined)\n\treturn node\n}\nVnode.normalizeChildren = function normalizeChildren(children) {\n\tfor (var i = 0; i < children.length; i++) {\n\t\tchildren[i] = Vnode.normalize(children[i])\n\t}\n\treturn children\n}\nvar selectorParser = /(?:(^|#|\\.)([^#\\.\\[\\]]+))|(\\[(.+?)(?:\\s*=\\s*(\"|'|)((?:\\\\[\"'\\]]|.)*?)\\5)?\\])/g\nvar selectorCache = {}\nfunction hyperscript(selector) {\n\tif (selector == null || typeof selector !== \"string\" && typeof selector.view !== \"function\") {\n\t\tthrow Error(\"The selector must be either a string or a component.\");\n\t}\n\tif (typeof selector === \"string\" && selectorCache[selector] === undefined) {\n\t\tvar match, tag, classes = [], attributes = {}\n\t\twhile (match = selectorParser.exec(selector)) {\n\t\t\tvar type = match[1], value = match[2]\n\t\t\tif (type === \"\" && value !== \"\") tag = value\n\t\t\telse if (type === \"#\") attributes.id = value\n\t\t\telse if (type === \".\") classes.push(value)\n\t\t\telse if (match[3][0] === \"[\") {\n\t\t\t\tvar attrValue = match[6]\n\t\t\t\tif (attrValue) attrValue = attrValue.replace(/\\\\([\"'])/g, \"$1\").replace(/\\\\\\\\/g, \"\\\\\")\n\t\t\t\tif (match[4] === \"class\") classes.push(attrValue)\n\t\t\t\telse attributes[match[4]] = attrValue || true\n\t\t\t}\n\t\t}\n\t\tif (classes.length > 0) attributes.className = classes.join(\" \")\n\t\tselectorCache[selector] = function(attrs, children) {\n\t\t\tvar hasAttrs = false, childList, text\n\t\t\tvar className = attrs.className || attrs.class\n\t\t\tfor (var key in attributes) attrs[key] = attributes[key]\n\t\t\tif (className !== undefined) {\n\t\t\t\tif (attrs.class !== undefined) {\n\t\t\t\t\tattrs.class = undefined\n\t\t\t\t\tattrs.className = className\n\t\t\t\t}\n\t\t\t\tif (attributes.className !== undefined) attrs.className = attributes.className + \" \" + className\n\t\t\t}\n\t\t\tfor (var key in attrs) {\n\t\t\t\tif (key !== \"key\") {\n\t\t\t\t\thasAttrs = true\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (Array.isArray(children) && children.length == 1 && children[0] != null && children[0].tag === \"#\") text = children[0].children\n\t\t\telse childList = children\n\t\t\treturn Vnode(tag || \"div\", attrs.key, hasAttrs ? attrs : undefined, childList, text, undefined)\n\t\t}\n\t}\n\tvar attrs, children, childrenIndex\n\tif (arguments[1] == null || typeof arguments[1] === \"object\" && arguments[1].tag === undefined && !Array.isArray(arguments[1])) {\n\t\tattrs = arguments[1]\n\t\tchildrenIndex = 2\n\t}\n\telse childrenIndex = 1\n\tif (arguments.length === childrenIndex + 1) {\n\t\tchildren = Array.isArray(arguments[childrenIndex]) ? arguments[childrenIndex] : [arguments[childrenIndex]]\n\t}\n\telse {\n\t\tchildren = []\n\t\tfor (var i = childrenIndex; i < arguments.length; i++) children.push(arguments[i])\n\t}\n\tif (typeof selector === \"string\") return selectorCache[selector](attrs || {}, Vnode.normalizeChildren(children))\n\treturn Vnode(selector, attrs && attrs.key, attrs || {}, Vnode.normalizeChildren(children), undefined, undefined)\n}\nhyperscript.trust = function(html) {\n\tif (html == null) html = \"\"\n\treturn Vnode(\"<\", undefined, undefined, html, undefined, undefined)\n}\nhyperscript.fragment = function(attrs1, children) {\n\treturn Vnode(\"[\", attrs1.key, attrs1, Vnode.normalizeChildren(children), undefined, undefined)\n}\nvar m = hyperscript\n/** @constructor */\nvar PromisePolyfill = function(executor) {\n\tif (!(this instanceof PromisePolyfill)) throw new Error(\"Promise must be called with `new`\")\n\tif (typeof executor !== \"function\") throw new TypeError(\"executor must be a function\")\n\tvar self = this, resolvers = [], rejectors = [], resolveCurrent = handler(resolvers, true), rejectCurrent = handler(rejectors, false)\n\tvar instance = self._instance = {resolvers: resolvers, rejectors: rejectors}\n\tvar callAsync = typeof setImmediate === \"function\" ? setImmediate : setTimeout\n\tfunction handler(list, shouldAbsorb) {\n\t\treturn function execute(value) {\n\t\t\tvar then\n\t\t\ttry {\n\t\t\t\tif (shouldAbsorb && value != null && (typeof value === \"object\" || typeof value === \"function\") && typeof (then = value.then) === \"function\") {\n\t\t\t\t\tif (value === self) throw new TypeError(\"Promise can't be resolved w/ itself\")\n\t\t\t\t\texecuteOnce(then.bind(value))\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tcallAsync(function() {\n\t\t\t\t\t\tif (!shouldAbsorb && list.length === 0) console.error(\"Possible unhandled promise rejection:\", value)\n\t\t\t\t\t\tfor (var i = 0; i < list.length; i++) list[i](value)\n\t\t\t\t\t\tresolvers.length = 0, rejectors.length = 0\n\t\t\t\t\t\tinstance.state = shouldAbsorb\n\t\t\t\t\t\tinstance.retry = function() {execute(value)}\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (e) {\n\t\t\t\trejectCurrent(e)\n\t\t\t}\n\t\t}\n\t}\n\tfunction executeOnce(then) {\n\t\tvar runs = 0\n\t\tfunction run(fn) {\n\t\t\treturn function(value) {\n\t\t\t\tif (runs++ > 0) return\n\t\t\t\tfn(value)\n\t\t\t}\n\t\t}\n\t\tvar onerror = run(rejectCurrent)\n\t\ttry {then(run(resolveCurrent), onerror)} catch (e) {onerror(e)}\n\t}\n\texecuteOnce(executor)\n}\nPromisePolyfill.prototype.then = function(onFulfilled, onRejection) {\n\tvar self = this, instance = self._instance\n\tfunction handle(callback, list, next, state) {\n\t\tlist.push(function(value) {\n\t\t\tif (typeof callback !== \"function\") next(value)\n\t\t\telse try {resolveNext(callback(value))} catch (e) {if (rejectNext) rejectNext(e)}\n\t\t})\n\t\tif (typeof instance.retry === \"function\" && state === instance.state) instance.retry()\n\t}\n\tvar resolveNext, rejectNext\n\tvar promise = new PromisePolyfill(function(resolve, reject) {resolveNext = resolve, rejectNext = reject})\n\thandle(onFulfilled, instance.resolvers, resolveNext, true), handle(onRejection, instance.rejectors, rejectNext, false)\n\treturn promise\n}\nPromisePolyfill.prototype.catch = function(onRejection) {\n\treturn this.then(null, onRejection)\n}\nPromisePolyfill.resolve = function(value) {\n\tif (value instanceof PromisePolyfill) return value\n\treturn new PromisePolyfill(function(resolve) {resolve(value)})\n}\nPromisePolyfill.reject = function(value) {\n\treturn new PromisePolyfill(function(resolve, reject) {reject(value)})\n}\nPromisePolyfill.all = function(list) {\n\treturn new PromisePolyfill(function(resolve, reject) {\n\t\tvar total = list.length, count = 0, values = []\n\t\tif (list.length === 0) resolve([])\n\t\telse for (var i = 0; i < list.length; i++) {\n\t\t\t(function(i) {\n\t\t\t\tfunction consume(value) {\n\t\t\t\t\tcount++\n\t\t\t\t\tvalues[i] = value\n\t\t\t\t\tif (count === total) resolve(values)\n\t\t\t\t}\n\t\t\t\tif (list[i] != null && (typeof list[i] === \"object\" || typeof list[i] === \"function\") && typeof list[i].then === \"function\") {\n\t\t\t\t\tlist[i].then(consume, reject)\n\t\t\t\t}\n\t\t\t\telse consume(list[i])\n\t\t\t})(i)\n\t\t}\n\t})\n}\nPromisePolyfill.race = function(list) {\n\treturn new PromisePolyfill(function(resolve, reject) {\n\t\tfor (var i = 0; i < list.length; i++) {\n\t\t\tlist[i].then(resolve, reject)\n\t\t}\n\t})\n}\nif (typeof window !== \"undefined\") {\n\tif (typeof window.Promise === \"undefined\") window.Promise = PromisePolyfill\n\tvar PromisePolyfill = window.Promise\n} else if (typeof global !== \"undefined\") {\n\tif (typeof global.Promise === \"undefined\") global.Promise = PromisePolyfill\n\tvar PromisePolyfill = global.Promise\n} else {\n}\nvar buildQueryString = function(object) {\n\tif (Object.prototype.toString.call(object) !== \"[object Object]\") return \"\"\n\tvar args = []\n\tfor (var key0 in object) {\n\t\tdestructure(key0, object[key0])\n\t}\n\treturn args.join(\"&\")\n\tfunction destructure(key0, value) {\n\t\tif (Array.isArray(value)) {\n\t\t\tfor (var i = 0; i < value.length; i++) {\n\t\t\t\tdestructure(key0 + \"[\" + i + \"]\", value[i])\n\t\t\t}\n\t\t}\n\t\telse if (Object.prototype.toString.call(value) === \"[object Object]\") {\n\t\t\tfor (var i in value) {\n\t\t\t\tdestructure(key0 + \"[\" + i + \"]\", value[i])\n\t\t\t}\n\t\t}\n\t\telse args.push(encodeURIComponent(key0) + (value != null && value !== \"\" ? \"=\" + encodeURIComponent(value) : \"\"))\n\t}\n}\nvar _8 = function($window, Promise) {\n\tvar callbackCount = 0\n\tvar oncompletion\n\tfunction setCompletionCallback(callback) {oncompletion = callback}\n\tfunction finalizer() {\n\t\tvar count = 0\n\t\tfunction complete() {if (--count === 0 && typeof oncompletion === \"function\") oncompletion()}\n\t\treturn function finalize(promise0) {\n\t\t\tvar then0 = promise0.then\n\t\t\tpromise0.then = function() {\n\t\t\t\tcount++\n\t\t\t\tvar next = then0.apply(promise0, arguments)\n\t\t\t\tnext.then(complete, function(e) {\n\t\t\t\t\tcomplete()\n\t\t\t\t\tif (count === 0) throw e\n\t\t\t\t})\n\t\t\t\treturn finalize(next)\n\t\t\t}\n\t\t\treturn promise0\n\t\t}\n\t}\n\tfunction normalize(args, extra) {\n\t\tif (typeof args === \"string\") {\n\t\t\tvar url = args\n\t\t\targs = extra || {}\n\t\t\tif (args.url == null) args.url = url\n\t\t}\n\t\treturn args\n\t}\n\tfunction request(args, extra) {\n\t\tvar finalize = finalizer()\n\t\targs = normalize(args, extra)\n\t\tvar promise0 = new Promise(function(resolve, reject) {\n\t\t\tif (args.method == null) args.method = \"GET\"\n\t\t\targs.method = args.method.toUpperCase()\n\t\t\tvar useBody = typeof args.useBody === \"boolean\" ? args.useBody : args.method !== \"GET\" && args.method !== \"TRACE\"\n\t\t\tif (typeof args.serialize !== \"function\") args.serialize = typeof FormData !== \"undefined\" && args.data instanceof FormData ? function(value) {return value} : JSON.stringify\n\t\t\tif (typeof args.deserialize !== \"function\") args.deserialize = deserialize\n\t\t\tif (typeof args.extract !== \"function\") args.extract = extract\n\t\t\targs.url = interpolate(args.url, args.data)\n\t\t\tif (useBody) args.data = args.serialize(args.data)\n\t\t\telse args.url = assemble(args.url, args.data)\n\t\t\tvar xhr = new $window.XMLHttpRequest()\n\t\t\txhr.open(args.method, args.url, typeof args.async === \"boolean\" ? args.async : true, typeof args.user === \"string\" ? args.user : undefined, typeof args.password === \"string\" ? args.password : undefined)\n\t\t\tif (args.serialize === JSON.stringify && useBody) {\n\t\t\t\txhr.setRequestHeader(\"Content-Type\", \"application/json; charset=utf-8\")\n\t\t\t}\n\t\t\tif (args.deserialize === deserialize) {\n\t\t\t\txhr.setRequestHeader(\"Accept\", \"application/json, text/*\")\n\t\t\t}\n\t\t\tif (args.withCredentials) xhr.withCredentials = args.withCredentials\n\t\t\tfor (var key in args.headers) if ({}.hasOwnProperty.call(args.headers, key)) {\n\t\t\t\txhr.setRequestHeader(key, args.headers[key])\n\t\t\t}\n\t\t\tif (typeof args.config === \"function\") xhr = args.config(xhr, args) || xhr\n\t\t\txhr.onreadystatechange = function() {\n\t\t\t\t// Don't throw errors on xhr.abort(). XMLHttpRequests ends up in a state of\n\t\t\t\t// xhr.status == 0 and xhr.readyState == 4 if aborted after open, but before completion.\n\t\t\t\tif (xhr.status && xhr.readyState === 4) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tvar response = (args.extract !== extract) ? args.extract(xhr, args) : args.deserialize(args.extract(xhr, args))\n\t\t\t\t\t\tif ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304) {\n\t\t\t\t\t\t\tresolve(cast(args.type, response))\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tvar error = new Error(xhr.responseText)\n\t\t\t\t\t\t\tfor (var key in response) error[key] = response[key]\n\t\t\t\t\t\t\treject(error)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcatch (e) {\n\t\t\t\t\t\treject(e)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (useBody && (args.data != null)) xhr.send(args.data)\n\t\t\telse xhr.send()\n\t\t})\n\t\treturn args.background === true ? promise0 : finalize(promise0)\n\t}\n\tfunction jsonp(args, extra) {\n\t\tvar finalize = finalizer()\n\t\targs = normalize(args, extra)\n\t\tvar promise0 = new Promise(function(resolve, reject) {\n\t\t\tvar callbackName = args.callbackName || \"_mithril_\" + Math.round(Math.random() * 1e16) + \"_\" + callbackCount++\n\t\t\tvar script = $window.document.createElement(\"script\")\n\t\t\t$window[callbackName] = function(data) {\n\t\t\t\tscript.parentNode.removeChild(script)\n\t\t\t\tresolve(cast(args.type, data))\n\t\t\t\tdelete $window[callbackName]\n\t\t\t}\n\t\t\tscript.onerror = function() {\n\t\t\t\tscript.parentNode.removeChild(script)\n\t\t\t\treject(new Error(\"JSONP request failed\"))\n\t\t\t\tdelete $window[callbackName]\n\t\t\t}\n\t\t\tif (args.data == null) args.data = {}\n\t\t\targs.url = interpolate(args.url, args.data)\n\t\t\targs.data[args.callbackKey || \"callback\"] = callbackName\n\t\t\tscript.src = assemble(args.url, args.data)\n\t\t\t$window.document.documentElement.appendChild(script)\n\t\t})\n\t\treturn args.background === true? promise0 : finalize(promise0)\n\t}\n\tfunction interpolate(url, data) {\n\t\tif (data == null) return url\n\t\tvar tokens = url.match(/:[^\\/]+/gi) || []\n\t\tfor (var i = 0; i < tokens.length; i++) {\n\t\t\tvar key = tokens[i].slice(1)\n\t\t\tif (data[key] != null) {\n\t\t\t\turl = url.replace(tokens[i], data[key])\n\t\t\t}\n\t\t}\n\t\treturn url\n\t}\n\tfunction assemble(url, data) {\n\t\tvar querystring = buildQueryString(data)\n\t\tif (querystring !== \"\") {\n\t\t\tvar prefix = url.indexOf(\"?\") < 0 ? \"?\" : \"&\"\n\t\t\turl += prefix + querystring\n\t\t}\n\t\treturn url\n\t}\n\tfunction deserialize(data) {\n\t\ttry {return data !== \"\" ? JSON.parse(data) : null}\n\t\tcatch (e) {throw new Error(data)}\n\t}\n\tfunction extract(xhr) {return xhr.responseText}\n\tfunction cast(type0, data) {\n\t\tif (typeof type0 === \"function\") {\n\t\t\tif (Array.isArray(data)) {\n\t\t\t\tfor (var i = 0; i < data.length; i++) {\n\t\t\t\t\tdata[i] = new type0(data[i])\n\t\t\t\t}\n\t\t\t}\n\t\t\telse return new type0(data)\n\t\t}\n\t\treturn data\n\t}\n\treturn {request: request, jsonp: jsonp, setCompletionCallback: setCompletionCallback}\n}\nvar requestService = _8(window, PromisePolyfill)\nvar coreRenderer = function($window) {\n\tvar $doc = $window.document\n\tvar $emptyFragment = $doc.createDocumentFragment()\n\tvar onevent\n\tfunction setEventCallback(callback) {return onevent = callback}\n\t//create\n\tfunction createNodes(parent, vnodes, start, end, hooks, nextSibling, ns) {\n\t\tfor (var i = start; i < end; i++) {\n\t\t\tvar vnode = vnodes[i]\n\t\t\tif (vnode != null) {\n\t\t\t\tcreateNode(parent, vnode, hooks, ns, nextSibling)\n\t\t\t}\n\t\t}\n\t}\n\tfunction createNode(parent, vnode, hooks, ns, nextSibling) {\n\t\tvar tag = vnode.tag\n\t\tif (vnode.attrs != null) initLifecycle(vnode.attrs, vnode, hooks)\n\t\tif (typeof tag === \"string\") {\n\t\t\tswitch (tag) {\n\t\t\t\tcase \"#\": return createText(parent, vnode, nextSibling)\n\t\t\t\tcase \"<\": return createHTML(parent, vnode, nextSibling)\n\t\t\t\tcase \"[\": return createFragment(parent, vnode, hooks, ns, nextSibling)\n\t\t\t\tdefault: return createElement(parent, vnode, hooks, ns, nextSibling)\n\t\t\t}\n\t\t}\n\t\telse return createComponent(parent, vnode, hooks, ns, nextSibling)\n\t}\n\tfunction createText(parent, vnode, nextSibling) {\n\t\tvnode.dom = $doc.createTextNode(vnode.children)\n\t\tinsertNode(parent, vnode.dom, nextSibling)\n\t\treturn vnode.dom\n\t}\n\tfunction createHTML(parent, vnode, nextSibling) {\n\t\tvar match1 = vnode.children.match(/^\\s*?<(\\w+)/im) || []\n\t\tvar parent1 = {caption: \"table\", thead: \"table\", tbody: \"table\", tfoot: \"table\", tr: \"tbody\", th: \"tr\", td: \"tr\", colgroup: \"table\", col: \"colgroup\"}[match1[1]] || \"div\"\n\t\tvar temp = $doc.createElement(parent1)\n\t\ttemp.innerHTML = vnode.children\n\t\tvnode.dom = temp.firstChild\n\t\tvnode.domSize = temp.childNodes.length\n\t\tvar fragment = $doc.createDocumentFragment()\n\t\tvar child\n\t\twhile (child = temp.firstChild) {\n\t\t\tfragment.appendChild(child)\n\t\t}\n\t\tinsertNode(parent, fragment, nextSibling)\n\t\treturn fragment\n\t}\n\tfunction createFragment(parent, vnode, hooks, ns, nextSibling) {\n\t\tvar fragment = $doc.createDocumentFragment()\n\t\tif (vnode.children != null) {\n\t\t\tvar children = vnode.children\n\t\t\tcreateNodes(fragment, children, 0, children.length, hooks, null, ns)\n\t\t}\n\t\tvnode.dom = fragment.firstChild\n\t\tvnode.domSize = fragment.childNodes.length\n\t\tinsertNode(parent, fragment, nextSibling)\n\t\treturn fragment\n\t}\n\tfunction createElement(parent, vnode, hooks, ns, nextSibling) {\n\t\tvar tag = vnode.tag\n\t\tswitch (vnode.tag) {\n\t\t\tcase \"svg\": ns = \"http://www.w3.org/2000/svg\"; break\n\t\t\tcase \"math\": ns = \"http://www.w3.org/1998/Math/MathML\"; break\n\t\t}\n\t\tvar attrs2 = vnode.attrs\n\t\tvar is = attrs2 && attrs2.is\n\t\tvar element = ns ?\n\t\t\tis ? $doc.createElementNS(ns, tag, {is: is}) : $doc.createElementNS(ns, tag) :\n\t\t\tis ? $doc.createElement(tag, {is: is}) : $doc.createElement(tag)\n\t\tvnode.dom = element\n\t\tif (attrs2 != null) {\n\t\t\tsetAttrs(vnode, attrs2, ns)\n\t\t}\n\t\tinsertNode(parent, element, nextSibling)\n\t\tif (vnode.attrs != null && vnode.attrs.contenteditable != null) {\n\t\t\tsetContentEditable(vnode)\n\t\t}\n\t\telse {\n\t\t\tif (vnode.text != null) {\n\t\t\t\tif (vnode.text !== \"\") element.textContent = vnode.text\n\t\t\t\telse vnode.children = [Vnode(\"#\", undefined, undefined, vnode.text, undefined, undefined)]\n\t\t\t}\n\t\t\tif (vnode.children != null) {\n\t\t\t\tvar children = vnode.children\n\t\t\t\tcreateNodes(element, children, 0, children.length, hooks, null, ns)\n\t\t\t\tsetLateAttrs(vnode)\n\t\t\t}\n\t\t}\n\t\treturn element\n\t}\n\tfunction createComponent(parent, vnode, hooks, ns, nextSibling) {\n\t\tvnode.state = Object.create(vnode.tag)\n\t\tvar view = vnode.tag.view\n\t\tif (view.reentrantLock != null) return $emptyFragment\n\t\tview.reentrantLock = true\n\t\tinitLifecycle(vnode.tag, vnode, hooks)\n\t\tvnode.instance = Vnode.normalize(view.call(vnode.state, vnode))\n\t\tview.reentrantLock = null\n\t\tif (vnode.instance != null) {\n\t\t\tif (vnode.instance === vnode) throw Error(\"A view cannot return the vnode it received as arguments\")\n\t\t\tvar element = createNode(parent, vnode.instance, hooks, ns, nextSibling)\n\t\t\tvnode.dom = vnode.instance.dom\n\t\t\tvnode.domSize = vnode.dom != null ? vnode.instance.domSize : 0\n\t\t\tinsertNode(parent, element, nextSibling)\n\t\t\treturn element\n\t\t}\n\t\telse {\n\t\t\tvnode.domSize = 0\n\t\t\treturn $emptyFragment\n\t\t}\n\t}\n\t//update\n\tfunction updateNodes(parent, old, vnodes, recycling, hooks, nextSibling, ns) {\n\t\tif (old === vnodes || old == null && vnodes == null) return\n\t\telse if (old == null) createNodes(parent, vnodes, 0, vnodes.length, hooks, nextSibling, undefined)\n\t\telse if (vnodes == null) removeNodes(old, 0, old.length, vnodes)\n\t\telse {\n\t\t\tif (old.length === vnodes.length) {\n\t\t\t\tvar isUnkeyed = false\n\t\t\t\tfor (var i = 0; i < vnodes.length; i++) {\n\t\t\t\t\tif (vnodes[i] != null && old[i] != null) {\n\t\t\t\t\t\tisUnkeyed = vnodes[i].key == null && old[i].key == null\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (isUnkeyed) {\n\t\t\t\t\tfor (var i = 0; i < old.length; i++) {\n\t\t\t\t\t\tif (old[i] === vnodes[i]) continue\n\t\t\t\t\t\telse if (old[i] == null && vnodes[i] != null) createNode(parent, vnodes[i], hooks, ns, getNextSibling(old, i + 1, nextSibling))\n\t\t\t\t\t\telse if (vnodes[i] == null) removeNodes(old, i, i + 1, vnodes)\n\t\t\t\t\t\telse updateNode(parent, old[i], vnodes[i], hooks, getNextSibling(old, i + 1, nextSibling), false, ns)\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\trecycling = recycling || isRecyclable(old, vnodes)\n\t\t\tif (recycling) old = old.concat(old.pool)\n\t\t\t\n\t\t\tvar oldStart = 0, start = 0, oldEnd = old.length - 1, end = vnodes.length - 1, map\n\t\t\twhile (oldEnd >= oldStart && end >= start) {\n\t\t\t\tvar o = old[oldStart], v = vnodes[start]\n\t\t\t\tif (o === v && !recycling) oldStart++, start++\n\t\t\t\telse if (o == null) oldStart++\n\t\t\t\telse if (v == null) start++\n\t\t\t\telse if (o.key === v.key) {\n\t\t\t\t\toldStart++, start++\n\t\t\t\t\tupdateNode(parent, o, v, hooks, getNextSibling(old, oldStart, nextSibling), recycling, ns)\n\t\t\t\t\tif (recycling && o.tag === v.tag) insertNode(parent, toFragment(o), nextSibling)\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tvar o = old[oldEnd]\n\t\t\t\t\tif (o === v && !recycling) oldEnd--, start++\n\t\t\t\t\telse if (o == null) oldEnd--\n\t\t\t\t\telse if (v == null) start++\n\t\t\t\t\telse if (o.key === v.key) {\n\t\t\t\t\t\tupdateNode(parent, o, v, hooks, getNextSibling(old, oldEnd + 1, nextSibling), recycling, ns)\n\t\t\t\t\t\tif (recycling || start < end) insertNode(parent, toFragment(o), getNextSibling(old, oldStart, nextSibling))\n\t\t\t\t\t\toldEnd--, start++\n\t\t\t\t\t}\n\t\t\t\t\telse break\n\t\t\t\t}\n\t\t\t}\n\t\t\twhile (oldEnd >= oldStart && end >= start) {\n\t\t\t\tvar o = old[oldEnd], v = vnodes[end]\n\t\t\t\tif (o === v && !recycling) oldEnd--, end--\n\t\t\t\telse if (o == null) oldEnd--\n\t\t\t\telse if (v == null) end--\n\t\t\t\telse if (o.key === v.key) {\n\t\t\t\t\tupdateNode(parent, o, v, hooks, getNextSibling(old, oldEnd + 1, nextSibling), recycling, ns)\n\t\t\t\t\tif (recycling && o.tag === v.tag) insertNode(parent, toFragment(o), nextSibling)\n\t\t\t\t\tif (o.dom != null) nextSibling = o.dom\n\t\t\t\t\toldEnd--, end--\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif (!map) map = getKeyMap(old, oldEnd)\n\t\t\t\t\tif (v != null) {\n\t\t\t\t\t\tvar oldIndex = map[v.key]\n\t\t\t\t\t\tif (oldIndex != null) {\n\t\t\t\t\t\t\tvar movable = old[oldIndex]\n\t\t\t\t\t\t\tupdateNode(parent, movable, v, hooks, getNextSibling(old, oldEnd + 1, nextSibling), recycling, ns)\n\t\t\t\t\t\t\tinsertNode(parent, toFragment(movable), nextSibling)\n\t\t\t\t\t\t\told[oldIndex].skip = true\n\t\t\t\t\t\t\tif (movable.dom != null) nextSibling = movable.dom\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tvar dom = createNode(parent, v, hooks, undefined, nextSibling)\n\t\t\t\t\t\t\tnextSibling = dom\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tend--\n\t\t\t\t}\n\t\t\t\tif (end < start) break\n\t\t\t}\n\t\t\tcreateNodes(parent, vnodes, start, end + 1, hooks, nextSibling, ns)\n\t\t\tremoveNodes(old, oldStart, oldEnd + 1, vnodes)\n\t\t}\n\t}\n\tfunction updateNode(parent, old, vnode, hooks, nextSibling, recycling, ns) {\n\t\tvar oldTag = old.tag, tag = vnode.tag\n\t\tif (oldTag === tag) {\n\t\t\tvnode.state = old.state\n\t\t\tvnode.events = old.events\n\t\t\tif (shouldUpdate(vnode, old)) return\n\t\t\tif (vnode.attrs != null) {\n\t\t\t\tupdateLifecycle(vnode.attrs, vnode, hooks, recycling)\n\t\t\t}\n\t\t\tif (typeof oldTag === \"string\") {\n\t\t\t\tswitch (oldTag) {\n\t\t\t\t\tcase \"#\": updateText(old, vnode); break\n\t\t\t\t\tcase \"<\": updateHTML(parent, old, vnode, nextSibling); break\n\t\t\t\t\tcase \"[\": updateFragment(parent, old, vnode, recycling, hooks, nextSibling, ns); break\n\t\t\t\t\tdefault: updateElement(old, vnode, recycling, hooks, ns)\n\t\t\t\t}\n\t\t\t}\n\t\t\telse updateComponent(parent, old, vnode, hooks, nextSibling, recycling, ns)\n\t\t}\n\t\telse {\n\t\t\tremoveNode(old, null)\n\t\t\tcreateNode(parent, vnode, hooks, ns, nextSibling)\n\t\t}\n\t}\n\tfunction updateText(old, vnode) {\n\t\tif (old.children.toString() !== vnode.children.toString()) {\n\t\t\told.dom.nodeValue = vnode.children\n\t\t}\n\t\tvnode.dom = old.dom\n\t}\n\tfunction updateHTML(parent, old, vnode, nextSibling) {\n\t\tif (old.children !== vnode.children) {\n\t\t\ttoFragment(old)\n\t\t\tcreateHTML(parent, vnode, nextSibling)\n\t\t}\n\t\telse vnode.dom = old.dom, vnode.domSize = old.domSize\n\t}\n\tfunction updateFragment(parent, old, vnode, recycling, hooks, nextSibling, ns) {\n\t\tupdateNodes(parent, old.children, vnode.children, recycling, hooks, nextSibling, ns)\n\t\tvar domSize = 0, children = vnode.children\n\t\tvnode.dom = null\n\t\tif (children != null) {\n\t\t\tfor (var i = 0; i < children.length; i++) {\n\t\t\t\tvar child = children[i]\n\t\t\t\tif (child != null && child.dom != null) {\n\t\t\t\t\tif (vnode.dom == null) vnode.dom = child.dom\n\t\t\t\t\tdomSize += child.domSize || 1\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (domSize !== 1) vnode.domSize = domSize\n\t\t}\n\t}\n\tfunction updateElement(old, vnode, recycling, hooks, ns) {\n\t\tvar element = vnode.dom = old.dom\n\t\tswitch (vnode.tag) {\n\t\t\tcase \"svg\": ns = \"http://www.w3.org/2000/svg\"; break\n\t\t\tcase \"math\": ns = \"http://www.w3.org/1998/Math/MathML\"; break\n\t\t}\n\t\tif (vnode.tag === \"textarea\") {\n\t\t\tif (vnode.attrs == null) vnode.attrs = {}\n\t\t\tif (vnode.text != null) {\n\t\t\t\tvnode.attrs.value = vnode.text //FIXME handle0 multiple children\n\t\t\t\tvnode.text = undefined\n\t\t\t}\n\t\t}\n\t\tupdateAttrs(vnode, old.attrs, vnode.attrs, ns)\n\t\tif (vnode.attrs != null && vnode.attrs.contenteditable != null) {\n\t\t\tsetContentEditable(vnode)\n\t\t}\n\t\telse if (old.text != null && vnode.text != null && vnode.text !== \"\") {\n\t\t\tif (old.text.toString() !== vnode.text.toString()) old.dom.firstChild.nodeValue = vnode.text\n\t\t}\n\t\telse {\n\t\t\tif (old.text != null) old.children = [Vnode(\"#\", undefined, undefined, old.text, undefined, old.dom.firstChild)]\n\t\t\tif (vnode.text != null) vnode.children = [Vnode(\"#\", undefined, undefined, vnode.text, undefined, undefined)]\n\t\t\tupdateNodes(element, old.children, vnode.children, recycling, hooks, null, ns)\n\t\t}\n\t}\n\tfunction updateComponent(parent, old, vnode, hooks, nextSibling, recycling, ns) {\n\t\tvnode.instance = Vnode.normalize(vnode.tag.view.call(vnode.state, vnode))\n\t\tupdateLifecycle(vnode.tag, vnode, hooks, recycling)\n\t\tif (vnode.instance != null) {\n\t\t\tif (old.instance == null) createNode(parent, vnode.instance, hooks, ns, nextSibling)\n\t\t\telse updateNode(parent, old.instance, vnode.instance, hooks, nextSibling, recycling, ns)\n\t\t\tvnode.dom = vnode.instance.dom\n\t\t\tvnode.domSize = vnode.instance.domSize\n\t\t}\n\t\telse if (old.instance != null) {\n\t\t\tremoveNode(old.instance, null)\n\t\t\tvnode.dom = undefined\n\t\t\tvnode.domSize = 0\n\t\t}\n\t\telse {\n\t\t\tvnode.dom = old.dom\n\t\t\tvnode.domSize = old.domSize\n\t\t}\n\t}\n\tfunction isRecyclable(old, vnodes) {\n\t\tif (old.pool != null && Math.abs(old.pool.length - vnodes.length) <= Math.abs(old.length - vnodes.length)) {\n\t\t\tvar oldChildrenLength = old[0] && old[0].children && old[0].children.length || 0\n\t\t\tvar poolChildrenLength = old.pool[0] && old.pool[0].children && old.pool[0].children.length || 0\n\t\t\tvar vnodesChildrenLength = vnodes[0] && vnodes[0].children && vnodes[0].children.length || 0\n\t\t\tif (Math.abs(poolChildrenLength - vnodesChildrenLength) <= Math.abs(oldChildrenLength - vnodesChildrenLength)) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t\treturn false\n\t}\n\tfunction getKeyMap(vnodes, end) {\n\t\tvar map = {}, i = 0\n\t\tfor (var i = 0; i < end; i++) {\n\t\t\tvar vnode = vnodes[i]\n\t\t\tif (vnode != null) {\n\t\t\t\tvar key2 = vnode.key\n\t\t\t\tif (key2 != null) map[key2] = i\n\t\t\t}\n\t\t}\n\t\treturn map\n\t}\n\tfunction toFragment(vnode) {\n\t\tvar count0 = vnode.domSize\n\t\tif (count0 != null || vnode.dom == null) {\n\t\t\tvar fragment = $doc.createDocumentFragment()\n\t\t\tif (count0 > 0) {\n\t\t\t\tvar dom = vnode.dom\n\t\t\t\twhile (--count0) fragment.appendChild(dom.nextSibling)\n\t\t\t\tfragment.insertBefore(dom, fragment.firstChild)\n\t\t\t}\n\t\t\treturn fragment\n\t\t}\n\t\telse return vnode.dom\n\t}\n\tfunction getNextSibling(vnodes, i, nextSibling) {\n\t\tfor (; i < vnodes.length; i++) {\n\t\t\tif (vnodes[i] != null && vnodes[i].dom != null) return vnodes[i].dom\n\t\t}\n\t\treturn nextSibling\n\t}\n\tfunction insertNode(parent, dom, nextSibling) {\n\t\tif (nextSibling && nextSibling.parentNode) parent.insertBefore(dom, nextSibling)\n\t\telse parent.appendChild(dom)\n\t}\n\tfunction setContentEditable(vnode) {\n\t\tvar children = vnode.children\n\t\tif (children != null && children.length === 1 && children[0].tag === \"<\") {\n\t\t\tvar content = children[0].children\n\t\t\tif (vnode.dom.innerHTML !== content) vnode.dom.innerHTML = content\n\t\t}\n\t\telse if (vnode.text != null || children != null && children.length !== 0) throw new Error(\"Child node of a contenteditable must be trusted\")\n\t}\n\t//remove\n\tfunction removeNodes(vnodes, start, end, context) {\n\t\tfor (var i = start; i < end; i++) {\n\t\t\tvar vnode = vnodes[i]\n\t\t\tif (vnode != null) {\n\t\t\t\tif (vnode.skip) vnode.skip = false\n\t\t\t\telse removeNode(vnode, context)\n\t\t\t}\n\t\t}\n\t}\n\tfunction removeNode(vnode, context) {\n\t\tvar expected = 1, called = 0\n\t\tif (vnode.attrs && vnode.attrs.onbeforeremove) {\n\t\t\tvar result = vnode.attrs.onbeforeremove.call(vnode.state, vnode)\n\t\t\tif (result != null && typeof result.then === \"function\") {\n\t\t\t\texpected++\n\t\t\t\tresult.then(continuation, continuation)\n\t\t\t}\n\t\t}\n\t\tif (typeof vnode.tag !== \"string\" && vnode.tag.onbeforeremove) {\n\t\t\tvar result = vnode.tag.onbeforeremove.call(vnode.state, vnode)\n\t\t\tif (result != null && typeof result.then === \"function\") {\n\t\t\t\texpected++\n\t\t\t\tresult.then(continuation, continuation)\n\t\t\t}\n\t\t}\n\t\tcontinuation()\n\t\tfunction continuation() {\n\t\t\tif (++called === expected) {\n\t\t\t\tonremove(vnode)\n\t\t\t\tif (vnode.dom) {\n\t\t\t\t\tvar count0 = vnode.domSize || 1\n\t\t\t\t\tif (count0 > 1) {\n\t\t\t\t\t\tvar dom = vnode.dom\n\t\t\t\t\t\twhile (--count0) {\n\t\t\t\t\t\t\tremoveNodeFromDOM(dom.nextSibling)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tremoveNodeFromDOM(vnode.dom)\n\t\t\t\t\tif (context != null && vnode.domSize == null && !hasIntegrationMethods(vnode.attrs) && typeof vnode.tag === \"string\") { //TODO test custom elements\n\t\t\t\t\t\tif (!context.pool) context.pool = [vnode]\n\t\t\t\t\t\telse context.pool.push(vnode)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfunction removeNodeFromDOM(node) {\n\t\tvar parent = node.parentNode\n\t\tif (parent != null) parent.removeChild(node)\n\t}\n\tfunction onremove(vnode) {\n\t\tif (vnode.attrs && vnode.attrs.onremove) vnode.attrs.onremove.call(vnode.state, vnode)\n\t\tif (typeof vnode.tag !== \"string\" && vnode.tag.onremove) vnode.tag.onremove.call(vnode.state, vnode)\n\t\tif (vnode.instance != null) onremove(vnode.instance)\n\t\telse {\n\t\t\tvar children = vnode.children\n\t\t\tif (Array.isArray(children)) {\n\t\t\t\tfor (var i = 0; i < children.length; i++) {\n\t\t\t\t\tvar child = children[i]\n\t\t\t\t\tif (child != null) onremove(child)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t//attrs2\n\tfunction setAttrs(vnode, attrs2, ns) {\n\t\tfor (var key2 in attrs2) {\n\t\t\tsetAttr(vnode, key2, null, attrs2[key2], ns)\n\t\t}\n\t}\n\tfunction setAttr(vnode, key2, old, value, ns) {\n\t\tvar element = vnode.dom\n\t\tif (key2 === \"key\" || key2 === \"is\" || (old === value && !isFormAttribute(vnode, key2)) && typeof value !== \"object\" || typeof value === \"undefined\" || isLifecycleMethod(key2)) return\n\t\tvar nsLastIndex = key2.indexOf(\":\")\n\t\tif (nsLastIndex > -1 && key2.substr(0, nsLastIndex) === \"xlink\") {\n\t\t\telement.setAttributeNS(\"http://www.w3.org/1999/xlink\", key2.slice(nsLastIndex + 1), value)\n\t\t}\n\t\telse if (key2[0] === \"o\" && key2[1] === \"n\" && typeof value === \"function\") updateEvent(vnode, key2, value)\n\t\telse if (key2 === \"style\") updateStyle(element, old, value)\n\t\telse if (key2 in element && !isAttribute(key2) && ns === undefined && !isCustomElement(vnode)) {\n\t\t\t//setting input[value] to same value by typing on focused element moves cursor to end in Chrome\n\t\t\tif (vnode.tag === \"input\" && key2 === \"value\" && vnode.dom.value === value && vnode.dom === $doc.activeElement) return\n\t\t\t//setting select[value] to same value while having select open blinks select dropdown in Chrome\n\t\t\tif (vnode.tag === \"select\" && key2 === \"value\" && vnode.dom.value === value && vnode.dom === $doc.activeElement) return\n\t\t\t//setting option[value] to same value while having select open blinks select dropdown in Chrome\n\t\t\tif (vnode.tag === \"option\" && key2 === \"value\" && vnode.dom.value === value) return\n\t\t\telement[key2] = value\n\t\t}\n\t\telse {\n\t\t\tif (typeof value === \"boolean\") {\n\t\t\t\tif (value) element.setAttribute(key2, \"\")\n\t\t\t\telse element.removeAttribute(key2)\n\t\t\t}\n\t\t\telse element.setAttribute(key2 === \"className\" ? \"class\" : key2, value)\n\t\t}\n\t}\n\tfunction setLateAttrs(vnode) {\n\t\tvar attrs2 = vnode.attrs\n\t\tif (vnode.tag === \"select\" && attrs2 != null) {\n\t\t\tif (\"value\" in attrs2) setAttr(vnode, \"value\", null, attrs2.value, undefined)\n\t\t\tif (\"selectedIndex\" in attrs2) setAttr(vnode, \"selectedIndex\", null, attrs2.selectedIndex, undefined)\n\t\t}\n\t}\n\tfunction updateAttrs(vnode, old, attrs2, ns) {\n\t\tif (attrs2 != null) {\n\t\t\tfor (var key2 in attrs2) {\n\t\t\t\tsetAttr(vnode, key2, old && old[key2], attrs2[key2], ns)\n\t\t\t}\n\t\t}\n\t\tif (old != null) {\n\t\t\tfor (var key2 in old) {\n\t\t\t\tif (attrs2 == null || !(key2 in attrs2)) {\n\t\t\t\t\tif (key2 === \"className\") key2 = \"class\"\n\t\t\t\t\tif (key2[0] === \"o\" && key2[1] === \"n\" && !isLifecycleMethod(key2)) updateEvent(vnode, key2, undefined)\n\t\t\t\t\telse if (key2 !== \"key\") vnode.dom.removeAttribute(key2)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfunction isFormAttribute(vnode, attr) {\n\t\treturn attr === \"value\" || attr === \"checked\" || attr === \"selectedIndex\" || attr === \"selected\" && vnode.dom === $doc.activeElement\n\t}\n\tfunction isLifecycleMethod(attr) {\n\t\treturn attr === \"oninit\" || attr === \"oncreate\" || attr === \"onupdate\" || attr === \"onremove\" || attr === \"onbeforeremove\" || attr === \"onbeforeupdate\"\n\t}\n\tfunction isAttribute(attr) {\n\t\treturn attr === \"href\" || attr === \"list\" || attr === \"form\" || attr === \"width\" || attr === \"height\"// || attr === \"type\"\n\t}\n\tfunction isCustomElement(vnode){\n\t\treturn vnode.attrs.is || vnode.tag.indexOf(\"-\") > -1\n\t}\n\tfunction hasIntegrationMethods(source) {\n\t\treturn source != null && (source.oncreate || source.onupdate || source.onbeforeremove || source.onremove)\n\t}\n\t//style\n\tfunction updateStyle(element, old, style) {\n\t\tif (old === style) element.style.cssText = \"\", old = null\n\t\tif (style == null) element.style.cssText = \"\"\n\t\telse if (typeof style === \"string\") element.style.cssText = style\n\t\telse {\n\t\t\tif (typeof old === \"string\") element.style.cssText = \"\"\n\t\t\tfor (var key2 in style) {\n\t\t\t\telement.style[key2] = style[key2]\n\t\t\t}\n\t\t\tif (old != null && typeof old !== \"string\") {\n\t\t\t\tfor (var key2 in old) {\n\t\t\t\t\tif (!(key2 in style)) element.style[key2] = \"\"\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t//event\n\tfunction updateEvent(vnode, key2, value) {\n\t\tvar element = vnode.dom\n\t\tvar callback = typeof onevent !== \"function\" ? value : function(e) {\n\t\t\tvar result = value.call(element, e)\n\t\t\tonevent.call(element, e)\n\t\t\treturn result\n\t\t}\n\t\tif (key2 in element) element[key2] = typeof value === \"function\" ? callback : null\n\t\telse {\n\t\t\tvar eventName = key2.slice(2)\n\t\t\tif (vnode.events === undefined) vnode.events = {}\n\t\t\tif (vnode.events[key2] === callback) return\n\t\t\tif (vnode.events[key2] != null) element.removeEventListener(eventName, vnode.events[key2], false)\n\t\t\tif (typeof value === \"function\") {\n\t\t\t\tvnode.events[key2] = callback\n\t\t\t\telement.addEventListener(eventName, vnode.events[key2], false)\n\t\t\t}\n\t\t}\n\t}\n\t//lifecycle\n\tfunction initLifecycle(source, vnode, hooks) {\n\t\tif (typeof source.oninit === \"function\") source.oninit.call(vnode.state, vnode)\n\t\tif (typeof source.oncreate === \"function\") hooks.push(source.oncreate.bind(vnode.state, vnode))\n\t}\n\tfunction updateLifecycle(source, vnode, hooks, recycling) {\n\t\tif (recycling) initLifecycle(source, vnode, hooks)\n\t\telse if (typeof source.onupdate === \"function\") hooks.push(source.onupdate.bind(vnode.state, vnode))\n\t}\n\tfunction shouldUpdate(vnode, old) {\n\t\tvar forceVnodeUpdate, forceComponentUpdate\n\t\tif (vnode.attrs != null && typeof vnode.attrs.onbeforeupdate === \"function\") forceVnodeUpdate = vnode.attrs.onbeforeupdate.call(vnode.state, vnode, old)\n\t\tif (typeof vnode.tag !== \"string\" && typeof vnode.tag.onbeforeupdate === \"function\") forceComponentUpdate = vnode.tag.onbeforeupdate.call(vnode.state, vnode, old)\n\t\tif (!(forceVnodeUpdate === undefined && forceComponentUpdate === undefined) && !forceVnodeUpdate && !forceComponentUpdate) {\n\t\t\tvnode.dom = old.dom\n\t\t\tvnode.domSize = old.domSize\n\t\t\tvnode.instance = old.instance\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\tfunction render(dom, vnodes) {\n\t\tif (!dom) throw new Error(\"Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.\")\n\t\tvar hooks = []\n\t\tvar active = $doc.activeElement\n\t\t// First time0 rendering into a node clears it out\n\t\tif (dom.vnodes == null) dom.textContent = \"\"\n\t\tif (!Array.isArray(vnodes)) vnodes = [vnodes]\n\t\tupdateNodes(dom, dom.vnodes, Vnode.normalizeChildren(vnodes), false, hooks, null, undefined)\n\t\tdom.vnodes = vnodes\n\t\tfor (var i = 0; i < hooks.length; i++) hooks[i]()\n\t\tif ($doc.activeElement !== active) active.focus()\n\t}\n\treturn {render: render, setEventCallback: setEventCallback}\n}\nfunction throttle(callback) {\n\t//60fps translates to 16.6ms, round it down since setTimeout requires int\n\tvar time = 16\n\tvar last = 0, pending = null\n\tvar timeout = typeof requestAnimationFrame === \"function\" ? requestAnimationFrame : setTimeout\n\treturn function() {\n\t\tvar now = Date.now()\n\t\tif (last === 0 || now - last >= time) {\n\t\t\tlast = now\n\t\t\tcallback()\n\t\t}\n\t\telse if (pending === null) {\n\t\t\tpending = timeout(function() {\n\t\t\t\tpending = null\n\t\t\t\tcallback()\n\t\t\t\tlast = Date.now()\n\t\t\t}, time - (now - last))\n\t\t}\n\t}\n}\nvar _11 = function($window) {\n\tvar renderService = coreRenderer($window)\n\trenderService.setEventCallback(function(e) {\n\t\tif (e.redraw !== false) redraw()\n\t})\n\tvar callbacks = []\n\tfunction subscribe(key1, callback) {\n\t\tunsubscribe(key1)\n\t\tcallbacks.push(key1, throttle(callback))\n\t}\n\tfunction unsubscribe(key1) {\n\t\tvar index = callbacks.indexOf(key1)\n\t\tif (index > -1) callbacks.splice(index, 2)\n\t}\n function redraw() {\n for (var i = 1; i < callbacks.length; i += 2) {\n callbacks[i]()\n }\n }\n\treturn {subscribe: subscribe, unsubscribe: unsubscribe, redraw: redraw, render: renderService.render}\n}\nvar redrawService = _11(window)\nrequestService.setCompletionCallback(redrawService.redraw)\nvar _16 = function(redrawService0) {\n\treturn function(root, component) {\n\t\tif (component === null) {\n\t\t\tredrawService0.render(root, [])\n\t\t\tredrawService0.unsubscribe(root)\n\t\t\treturn\n\t\t}\n\t\t\n\t\tif (component.view == null) throw new Error(\"m.mount(element, component) expects a component, not a vnode\")\n\t\t\n\t\tvar run0 = function() {\n\t\t\tredrawService0.render(root, Vnode(component))\n\t\t}\n\t\tredrawService0.subscribe(root, run0)\n\t\tredrawService0.redraw()\n\t}\n}\nm.mount = _16(redrawService)\nvar Promise = PromisePolyfill\nvar parseQueryString = function(string) {\n\tif (string === \"\" || string == null) return {}\n\tif (string.charAt(0) === \"?\") string = string.slice(1)\n\tvar entries = string.split(\"&\"), data0 = {}, counters = {}\n\tfor (var i = 0; i < entries.length; i++) {\n\t\tvar entry = entries[i].split(\"=\")\n\t\tvar key5 = decodeURIComponent(entry[0])\n\t\tvar value = entry.length === 2 ? decodeURIComponent(entry[1]) : \"\"\n\t\tif (value === \"true\") value = true\n\t\telse if (value === \"false\") value = false\n\t\tvar levels = key5.split(/\\]\\[?|\\[/)\n\t\tvar cursor = data0\n\t\tif (key5.indexOf(\"[\") > -1) levels.pop()\n\t\tfor (var j = 0; j < levels.length; j++) {\n\t\t\tvar level = levels[j], nextLevel = levels[j + 1]\n\t\t\tvar isNumber = nextLevel == \"\" || !isNaN(parseInt(nextLevel, 10))\n\t\t\tvar isValue = j === levels.length - 1\n\t\t\tif (level === \"\") {\n\t\t\t\tvar key5 = levels.slice(0, j).join()\n\t\t\t\tif (counters[key5] == null) counters[key5] = 0\n\t\t\t\tlevel = counters[key5]++\n\t\t\t}\n\t\t\tif (cursor[level] == null) {\n\t\t\t\tcursor[level] = isValue ? value : isNumber ? [] : {}\n\t\t\t}\n\t\t\tcursor = cursor[level]\n\t\t}\n\t}\n\treturn data0\n}\nvar coreRouter = function($window) {\n\tvar supportsPushState = typeof $window.history.pushState === \"function\"\n\tvar callAsync0 = typeof setImmediate === \"function\" ? setImmediate : setTimeout\n\tfunction normalize1(fragment0) {\n\t\tvar data = $window.location[fragment0].replace(/(?:%[a-f89][a-f0-9])+/gim, decodeURIComponent)\n\t\tif (fragment0 === \"pathname\" && data[0] !== \"/\") data = \"/\" + data\n\t\treturn data\n\t}\n\tvar asyncId\n\tfunction debounceAsync(callback0) {\n\t\treturn function() {\n\t\t\tif (asyncId != null) return\n\t\t\tasyncId = callAsync0(function() {\n\t\t\t\tasyncId = null\n\t\t\t\tcallback0()\n\t\t\t})\n\t\t}\n\t}\n\tfunction parsePath(path, queryData, hashData) {\n\t\tvar queryIndex = path.indexOf(\"?\")\n\t\tvar hashIndex = path.indexOf(\"#\")\n\t\tvar pathEnd = queryIndex > -1 ? queryIndex : hashIndex > -1 ? hashIndex : path.length\n\t\tif (queryIndex > -1) {\n\t\t\tvar queryEnd = hashIndex > -1 ? hashIndex : path.length\n\t\t\tvar queryParams = parseQueryString(path.slice(queryIndex + 1, queryEnd))\n\t\t\tfor (var key4 in queryParams) queryData[key4] = queryParams[key4]\n\t\t}\n\t\tif (hashIndex > -1) {\n\t\t\tvar hashParams = parseQueryString(path.slice(hashIndex + 1))\n\t\t\tfor (var key4 in hashParams) hashData[key4] = hashParams[key4]\n\t\t}\n\t\treturn path.slice(0, pathEnd)\n\t}\n\tvar router = {prefix: \"#!\"}\n\trouter.getPath = function() {\n\t\tvar type2 = router.prefix.charAt(0)\n\t\tswitch (type2) {\n\t\t\tcase \"#\": return normalize1(\"hash\").slice(router.prefix.length)\n\t\t\tcase \"?\": return normalize1(\"search\").slice(router.prefix.length) + normalize1(\"hash\")\n\t\t\tdefault: return normalize1(\"pathname\").slice(router.prefix.length) + normalize1(\"search\") + normalize1(\"hash\")\n\t\t}\n\t}\n\trouter.setPath = function(path, data, options) {\n\t\tvar queryData = {}, hashData = {}\n\t\tpath = parsePath(path, queryData, hashData)\n\t\tif (data != null) {\n\t\t\tfor (var key4 in data) queryData[key4] = data[key4]\n\t\t\tpath = path.replace(/:([^\\/]+)/g, function(match2, token) {\n\t\t\t\tdelete queryData[token]\n\t\t\t\treturn data[token]\n\t\t\t})\n\t\t}\n\t\tvar query = buildQueryString(queryData)\n\t\tif (query) path += \"?\" + query\n\t\tvar hash = buildQueryString(hashData)\n\t\tif (hash) path += \"#\" + hash\n\t\tif (supportsPushState) {\n\t\t\tvar state = options ? options.state : null\n\t\t\tvar title = options ? options.title : null\n\t\t\t$window.onpopstate()\n\t\t\tif (options && options.replace) $window.history.replaceState(state, title, router.prefix + path)\n\t\t\telse $window.history.pushState(state, title, router.prefix + path)\n\t\t}\n\t\telse $window.location.href = router.prefix + path\n\t}\n\trouter.defineRoutes = function(routes, resolve, reject) {\n\t\tfunction resolveRoute() {\n\t\t\tvar path = router.getPath()\n\t\t\tvar params = {}\n\t\t\tvar pathname = parsePath(path, params, params)\n\t\t\tvar state = $window.history.state\n\t\t\tif (state != null) {\n\t\t\t\tfor (var k in state) params[k] = state[k]\n\t\t\t}\n\t\t\tfor (var route0 in routes) {\n\t\t\t\tvar matcher = new RegExp(\"^\" + route0.replace(/:[^\\/]+?\\.{3}/g, \"(.*?)\").replace(/:[^\\/]+/g, \"([^\\\\/]+)\") + \"\\/?$\")\n\t\t\t\tif (matcher.test(pathname)) {\n\t\t\t\t\tpathname.replace(matcher, function() {\n\t\t\t\t\t\tvar keys = route0.match(/:[^\\/]+/g) || []\n\t\t\t\t\t\tvar values = [].slice.call(arguments, 1, -2)\n\t\t\t\t\t\tfor (var i = 0; i < keys.length; i++) {\n\t\t\t\t\t\t\tparams[keys[i].replace(/:|\\./g, \"\")] = decodeURIComponent(values[i])\n\t\t\t\t\t\t}\n\t\t\t\t\t\tresolve(routes[route0], params, path, route0)\n\t\t\t\t\t})\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\treject(path, params)\n\t\t}\n\t\tif (supportsPushState) $window.onpopstate = debounceAsync(resolveRoute)\n\t\telse if (router.prefix.charAt(0) === \"#\") $window.onhashchange = resolveRoute\n\t\tresolveRoute()\n\t}\n\treturn router\n}\nvar _20 = function($window, redrawService0) {\n\tvar routeService = coreRouter($window)\n\tvar identity = function(v) {return v}\n\tvar render1, component, attrs3, currentPath, lastUpdate\n\tvar route = function(root, defaultRoute, routes) {\n\t\tif (root == null) throw new Error(\"Ensure the DOM element that was passed to `m.route` is not undefined\")\n\t\tvar run1 = function() {\n\t\t\tif (render1 != null) redrawService0.render(root, render1(Vnode(component, attrs3.key, attrs3)))\n\t\t}\n\t\tvar bail = function(path) {\n\t\t\tif (path !== defaultRoute) routeService.setPath(defaultRoute, null, {replace: true})\n\t\t\telse throw new Error(\"Could not resolve default route \" + defaultRoute)\n\t\t}\n\t\trouteService.defineRoutes(routes, function(payload, params, path) {\n\t\t\tvar update = lastUpdate = function(routeResolver, comp) {\n\t\t\t\tif (update !== lastUpdate) return\n\t\t\t\tcomponent = comp != null && typeof comp.view === \"function\" ? comp : \"div\", attrs3 = params, currentPath = path, lastUpdate = null\n\t\t\t\trender1 = (routeResolver.render || identity).bind(routeResolver)\n\t\t\t\trun1()\n\t\t\t}\n\t\t\tif (payload.view) update({}, payload)\n\t\t\telse {\n\t\t\t\tif (payload.onmatch) {\n\t\t\t\t\tPromise.resolve(payload.onmatch(params, path)).then(function(resolved) {\n\t\t\t\t\t\tupdate(payload, resolved)\n\t\t\t\t\t}, bail)\n\t\t\t\t}\n\t\t\t\telse update(payload, \"div\")\n\t\t\t}\n\t\t}, bail)\n\t\tredrawService0.subscribe(root, run1)\n\t}\n\troute.set = function(path, data, options) {\n\t\tif (lastUpdate != null) options = {replace: true}\n\t\tlastUpdate = null\n\t\trouteService.setPath(path, data, options)\n\t}\n\troute.get = function() {return currentPath}\n\troute.prefix = function(prefix0) {routeService.prefix = prefix0}\n\troute.link = function(vnode1) {\n\t\tvnode1.dom.setAttribute(\"href\", routeService.prefix + vnode1.attrs.href)\n\t\tvnode1.dom.onclick = function(e) {\n\t\t\tif (e.ctrlKey || e.metaKey || e.shiftKey || e.which === 2) return\n\t\t\te.preventDefault()\n\t\t\te.redraw = false\n\t\t\tvar href = this.getAttribute(\"href\")\n\t\t\tif (href.indexOf(routeService.prefix) === 0) href = href.slice(routeService.prefix.length)\n\t\t\troute.set(href, undefined, undefined)\n\t\t}\n\t}\n\troute.param = function(key3) {\n\t\tif(typeof attrs3 !== \"undefined\" && typeof key3 !== \"undefined\") return attrs3[key3]\n\t\treturn attrs3\n\t}\n\treturn route\n}\nm.route = _20(window, redrawService)\nm.withAttr = function(attrName, callback1, context) {\n\treturn function(e) {\n\t\tcallback1.call(context || this, attrName in e.currentTarget ? e.currentTarget[attrName] : e.currentTarget.getAttribute(attrName))\n\t}\n}\nvar _28 = coreRenderer(window)\nm.render = _28.render\nm.redraw = redrawService.redraw\nm.request = requestService.request\nm.jsonp = requestService.jsonp\nm.parseQueryString = parseQueryString\nm.buildQueryString = buildQueryString\nm.version = \"1.0.1\"\nm.vnode = Vnode\nif (typeof module !== \"undefined\") module[\"exports\"] = m\nelse window.m = m\n}\n}).call(this,typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {})\n},{}],8:[function(require,module,exports){\n/*!\n * EventEmitter v5.1.0 - git.io/ee\n * Unlicense - http://unlicense.org/\n * Oliver Caldwell - http://oli.me.uk/\n * @preserve\n */\n\n;(function (exports) {\n 'use strict';\n\n /**\n * Class for managing events.\n * Can be extended to provide event functionality in other classes.\n *\n * @class EventEmitter Manages event registering and emitting.\n */\n function EventEmitter() {}\n\n // Shortcuts to improve speed and size\n var proto = EventEmitter.prototype;\n var originalGlobalValue = exports.EventEmitter;\n\n /**\n * Finds the index of the listener for the event in its storage array.\n *\n * @param {Function[]} listeners Array of listeners to search through.\n * @param {Function} listener Method to look for.\n * @return {Number} Index of the specified listener, -1 if not found\n * @api private\n */\n function indexOfListener(listeners, listener) {\n var i = listeners.length;\n while (i--) {\n if (listeners[i].listener === listener) {\n return i;\n }\n }\n\n return -1;\n }\n\n /**\n * Alias a method while keeping the context correct, to allow for overwriting of target method.\n *\n * @param {String} name The name of the target method.\n * @return {Function} The aliased method\n * @api private\n */\n function alias(name) {\n return function aliasClosure() {\n return this[name].apply(this, arguments);\n };\n }\n\n /**\n * Returns the listener array for the specified event.\n * Will initialise the event object and listener arrays if required.\n * Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them.\n * Each property in the object response is an array of listener functions.\n *\n * @param {String|RegExp} evt Name of the event to return the listeners from.\n * @return {Function[]|Object} All listener functions for the event.\n */\n proto.getListeners = function getListeners(evt) {\n var events = this._getEvents();\n var response;\n var key;\n\n // Return a concatenated array of all matching events if\n // the selector is a regular expression.\n if (evt instanceof RegExp) {\n response = {};\n for (key in events) {\n if (events.hasOwnProperty(key) && evt.test(key)) {\n response[key] = events[key];\n }\n }\n }\n else {\n response = events[evt] || (events[evt] = []);\n }\n\n return response;\n };\n\n /**\n * Takes a list of listener objects and flattens it into a list of listener functions.\n *\n * @param {Object[]} listeners Raw listener objects.\n * @return {Function[]} Just the listener functions.\n */\n proto.flattenListeners = function flattenListeners(listeners) {\n var flatListeners = [];\n var i;\n\n for (i = 0; i < listeners.length; i += 1) {\n flatListeners.push(listeners[i].listener);\n }\n\n return flatListeners;\n };\n\n /**\n * Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful.\n *\n * @param {String|RegExp} evt Name of the event to return the listeners from.\n * @return {Object} All listener functions for an event in an object.\n */\n proto.getListenersAsObject = function getListenersAsObject(evt) {\n var listeners = this.getListeners(evt);\n var response;\n\n if (listeners instanceof Array) {\n response = {};\n response[evt] = listeners;\n }\n\n return response || listeners;\n };\n\n function isValidListener (listener) {\n if (typeof listener === 'function' || listener instanceof RegExp) {\n return true\n } else if (listener && typeof listener === 'object') {\n return isValidListener(listener.listener)\n } else {\n return false\n }\n }\n\n /**\n * Adds a listener function to the specified event.\n * The listener will not be added if it is a duplicate.\n * If the listener returns true then it will be removed after it is called.\n * If you pass a regular expression as the event name then the listener will be added to all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to attach the listener to.\n * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.addListener = function addListener(evt, listener) {\n if (!isValidListener(listener)) {\n throw new TypeError('listener must be a function');\n }\n\n var listeners = this.getListenersAsObject(evt);\n var listenerIsWrapped = typeof listener === 'object';\n var key;\n\n for (key in listeners) {\n if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) {\n listeners[key].push(listenerIsWrapped ? listener : {\n listener: listener,\n once: false\n });\n }\n }\n\n return this;\n };\n\n /**\n * Alias of addListener\n */\n proto.on = alias('addListener');\n\n /**\n * Semi-alias of addListener. It will add a listener that will be\n * automatically removed after its first execution.\n *\n * @param {String|RegExp} evt Name of the event to attach the listener to.\n * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.addOnceListener = function addOnceListener(evt, listener) {\n return this.addListener(evt, {\n listener: listener,\n once: true\n });\n };\n\n /**\n * Alias of addOnceListener.\n */\n proto.once = alias('addOnceListener');\n\n /**\n * Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad.\n * You need to tell it what event names should be matched by a regex.\n *\n * @param {String} evt Name of the event to create.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.defineEvent = function defineEvent(evt) {\n this.getListeners(evt);\n return this;\n };\n\n /**\n * Uses defineEvent to define multiple events.\n *\n * @param {String[]} evts An array of event names to define.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.defineEvents = function defineEvents(evts) {\n for (var i = 0; i < evts.length; i += 1) {\n this.defineEvent(evts[i]);\n }\n return this;\n };\n\n /**\n * Removes a listener function from the specified event.\n * When passed a regular expression as the event name, it will remove the listener from all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to remove the listener from.\n * @param {Function} listener Method to remove from the event.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.removeListener = function removeListener(evt, listener) {\n var listeners = this.getListenersAsObject(evt);\n var index;\n var key;\n\n for (key in listeners) {\n if (listeners.hasOwnProperty(key)) {\n index = indexOfListener(listeners[key], listener);\n\n if (index !== -1) {\n listeners[key].splice(index, 1);\n }\n }\n }\n\n return this;\n };\n\n /**\n * Alias of removeListener\n */\n proto.off = alias('removeListener');\n\n /**\n * Adds listeners in bulk using the manipulateListeners method.\n * If you pass an object as the second argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added.\n * You can also pass it a regular expression to add the array of listeners to all events that match it.\n * Yeah, this function does quite a bit. That's probably a bad thing.\n *\n * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once.\n * @param {Function[]} [listeners] An optional array of listener functions to add.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.addListeners = function addListeners(evt, listeners) {\n // Pass through to manipulateListeners\n return this.manipulateListeners(false, evt, listeners);\n };\n\n /**\n * Removes listeners in bulk using the manipulateListeners method.\n * If you pass an object as the second argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.\n * You can also pass it an event name and an array of listeners to be removed.\n * You can also pass it a regular expression to remove the listeners from all events that match it.\n *\n * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once.\n * @param {Function[]} [listeners] An optional array of listener functions to remove.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.removeListeners = function removeListeners(evt, listeners) {\n // Pass through to manipulateListeners\n return this.manipulateListeners(true, evt, listeners);\n };\n\n /**\n * Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level.\n * The first argument will determine if the listeners are removed (true) or added (false).\n * If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.\n * You can also pass it an event name and an array of listeners to be added/removed.\n * You can also pass it a regular expression to manipulate the listeners of all events that match it.\n *\n * @param {Boolean} remove True if you want to remove listeners, false if you want to add.\n * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once.\n * @param {Function[]} [listeners] An optional array of listener functions to add/remove.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) {\n var i;\n var value;\n var single = remove ? this.removeListener : this.addListener;\n var multiple = remove ? this.removeListeners : this.addListeners;\n\n // If evt is an object then pass each of its properties to this method\n if (typeof evt === 'object' && !(evt instanceof RegExp)) {\n for (i in evt) {\n if (evt.hasOwnProperty(i) && (value = evt[i])) {\n // Pass the single listener straight through to the singular method\n if (typeof value === 'function') {\n single.call(this, i, value);\n }\n else {\n // Otherwise pass back to the multiple function\n multiple.call(this, i, value);\n }\n }\n }\n }\n else {\n // So evt must be a string\n // And listeners must be an array of listeners\n // Loop over it and pass each one to the multiple method\n i = listeners.length;\n while (i--) {\n single.call(this, evt, listeners[i]);\n }\n }\n\n return this;\n };\n\n /**\n * Removes all listeners from a specified event.\n * If you do not specify an event then all listeners will be removed.\n * That means every event will be emptied.\n * You can also pass a regex to remove all events that match it.\n *\n * @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.removeEvent = function removeEvent(evt) {\n var type = typeof evt;\n var events = this._getEvents();\n var key;\n\n // Remove different things depending on the state of evt\n if (type === 'string') {\n // Remove all listeners for the specified event\n delete events[evt];\n }\n else if (evt instanceof RegExp) {\n // Remove all events matching the regex.\n for (key in events) {\n if (events.hasOwnProperty(key) && evt.test(key)) {\n delete events[key];\n }\n }\n }\n else {\n // Remove all listeners in all events\n delete this._events;\n }\n\n return this;\n };\n\n /**\n * Alias of removeEvent.\n *\n * Added to mirror the node API.\n */\n proto.removeAllListeners = alias('removeEvent');\n\n /**\n * Emits an event of your choice.\n * When emitted, every listener attached to that event will be executed.\n * If you pass the optional argument array then those arguments will be passed to every listener upon execution.\n * Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.\n * So they will not arrive within the array on the other side, they will be separate.\n * You can also pass a regular expression to emit to all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to emit and execute listeners for.\n * @param {Array} [args] Optional array of arguments to be passed to each listener.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.emitEvent = function emitEvent(evt, args) {\n var listenersMap = this.getListenersAsObject(evt);\n var listeners;\n var listener;\n var i;\n var key;\n var response;\n\n for (key in listenersMap) {\n if (listenersMap.hasOwnProperty(key)) {\n listeners = listenersMap[key].slice(0);\n\n for (i = 0; i < listeners.length; i++) {\n // If the listener returns true then it shall be removed from the event\n // The function is executed either with a basic call or an apply if there is an args array\n listener = listeners[i];\n\n if (listener.once === true) {\n this.removeListener(evt, listener.listener);\n }\n\n response = listener.listener.apply(this, args || []);\n\n if (response === this._getOnceReturnValue()) {\n this.removeListener(evt, listener.listener);\n }\n }\n }\n }\n\n return this;\n };\n\n /**\n * Alias of emitEvent\n */\n proto.trigger = alias('emitEvent');\n\n /**\n * Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on.\n * As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to emit and execute listeners for.\n * @param {...*} Optional additional arguments to be passed to each listener.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.emit = function emit(evt) {\n var args = Array.prototype.slice.call(arguments, 1);\n return this.emitEvent(evt, args);\n };\n\n /**\n * Sets the current value to check against when executing listeners. If a\n * listeners return value matches the one set here then it will be removed\n * after execution. This value defaults to true.\n *\n * @param {*} value The new value to check for when executing listeners.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.setOnceReturnValue = function setOnceReturnValue(value) {\n this._onceReturnValue = value;\n return this;\n };\n\n /**\n * Fetches the current value to check against when executing listeners. If\n * the listeners return value matches this one then it should be removed\n * automatically. It will return true by default.\n *\n * @return {*|Boolean} The current value to check for or the default, true.\n * @api private\n */\n proto._getOnceReturnValue = function _getOnceReturnValue() {\n if (this.hasOwnProperty('_onceReturnValue')) {\n return this._onceReturnValue;\n }\n else {\n return true;\n }\n };\n\n /**\n * Fetches the events object and creates one if required.\n *\n * @return {Object} The events storage object.\n * @api private\n */\n proto._getEvents = function _getEvents() {\n return this._events || (this._events = {});\n };\n\n /**\n * Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.\n *\n * @return {Function} Non conflicting EventEmitter class.\n */\n EventEmitter.noConflict = function noConflict() {\n exports.EventEmitter = originalGlobalValue;\n return EventEmitter;\n };\n\n // Expose the class either via AMD, CommonJS or the global object\n if (typeof define === 'function' && define.amd) {\n define(function () {\n return EventEmitter;\n });\n }\n else if (typeof module === 'object' && module.exports){\n module.exports = EventEmitter;\n }\n else {\n exports.EventEmitter = EventEmitter;\n }\n}(this || {}));\n\n},{}]},{},[1]);\n })();"]}
assets/js/forms-admin.js CHANGED
@@ -1,218 +1,156 @@
1
  (function () { var require = undefined; var define = undefined; (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
  'use strict';
3
 
4
- var rows = function(m, i18n) {
5
 
6
  var r = {};
7
 
8
- r.showType = function(config) {
9
  // ucfirst
10
  var fieldType = config.type();
11
  fieldType = fieldType.charAt(0).toUpperCase() + fieldType.slice(1);
12
 
13
- return m('div', [
14
- m("label", i18n.fieldType),
15
- m('span', fieldType ),
16
- ]);
17
  };
18
 
19
  r.label = function (config) {
20
  // label row
21
- return m("div", [
22
- m("label", i18n.fieldLabel),
23
- m("input.widefat", {
24
- type : "text",
25
- value : config.label(),
26
- onchange : m.withAttr('value', config.label),
27
- placeholder: config.title()
28
- })
29
- ]);
30
  };
31
 
32
  r.value = function (config) {
33
  var isHidden = config.type() === 'hidden';
34
- return m("div", [
35
- m("label", [
36
- isHidden ? i18n.value : i18n.initialValue,
37
- " ",
38
- isHidden ? '' : m('small', { "style": "float: right; font-weight: normal;" }, i18n.optional )
39
- ]),
40
- m("input.widefat", {
41
- type : "text",
42
- value : config.value(),
43
- onchange: m.withAttr('value', config.value)
44
- }),
45
- isHidden ? '' : m('p.help', i18n.valueHelp)
46
- ]);
47
  };
48
 
49
  r.numberMinMax = function (config) {
50
- return m('div', [
51
- m('div.row', [
52
- m('div.col.col-3', [
53
- m('label', i18n.min),
54
- m('input', {type: 'number', onchange: m.withAttr('value', config.min)})
55
- ]),
56
- m('div.col.col-3', [
57
- m('label', i18n.max),
58
- m('input', {type: 'number', onchange: m.withAttr('value', config.max)})
59
- ])
60
- ])
61
- ])
62
  };
63
 
64
-
65
  r.isRequired = function (config) {
66
  var inputAtts = {
67
- type : 'checkbox',
68
- checked : config.required(),
69
  onchange: m.withAttr('checked', config.required)
70
  };
71
- var desc;
72
 
73
- if( config.forceRequired() ) {
74
  inputAtts.required = true;
75
  inputAtts.disabled = true;
76
- desc = m('p.help', i18n.forceRequired );
77
  }
78
 
79
- return m('div', [
80
- m('label.cb-wrap', [
81
- m('input', inputAtts),
82
- i18n.isFieldRequired
83
- ]),
84
- desc
85
- ]);
86
  };
87
 
88
  r.placeholder = function (config) {
89
 
90
- return m("div", [
91
- m("label", [
92
- i18n.placeholder,
93
- " ",
94
- m('small', { "style": "float: right; font-weight: normal;" }, i18n.optional )
95
- ]),
96
- m("input.widefat", {
97
- type : "text",
98
- value : config.placeholder(),
99
- onchange: m.withAttr('value', config.placeholder),
100
- placeholder: ""
101
- }),
102
- m("p.help", i18n.placeholderHelp)
103
- ]);
104
  };
105
 
106
  r.useParagraphs = function (config) {
107
- return m('div', [
108
- m('label.cb-wrap', [
109
- m('input', {
110
- type : 'checkbox',
111
- checked : config.wrap(),
112
- onchange: m.withAttr('checked', config.wrap)
113
- }),
114
- i18n.wrapInParagraphTags
115
- ])
116
- ]);
117
  };
118
 
119
  r.choiceType = function (config) {
120
-
121
-
122
- var options = [
123
- m('option', {
124
- value : 'select',
125
- selected: config.type() === 'select' ? 'selected' : false
126
- }, i18n.dropdown ),
127
- m('option', {
128
- value : 'radio',
129
- selected: config.type() === 'radio' ? 'selected' : false
130
- }, i18n.radioButtons )
131
- ];
132
 
133
  // only add checkbox choice if field accepts multiple values
134
- if( config.acceptsMultipleValues ) {
135
- options.push(
136
- m('option', {
137
- value : 'checkbox',
138
- selected: config.type() === 'checkbox' ? 'selected' : false
139
- }, i18n.checkboxes )
140
- );
141
  }
142
 
143
- return m('div', [
144
- m('label', i18n.choiceType ),
145
- m('select', {
146
- value : config.type(),
147
- onchange: m.withAttr('value', config.type)
148
- }, options)
149
- ]);
150
  };
151
 
152
  r.choices = function (config) {
153
 
154
  var html = [];
155
- html.push(m('div', [
156
- m('label', i18n.choices),
157
- m('div.limit-height', [
158
- m("table", [
159
-
160
- // table body
161
- config.choices().map(function (choice, index) {
162
- return m('tr', {
163
- 'data-id': index
164
- }, [
165
- m('td.cb', m('input', {
166
- name: 'selected',
167
- type: (config.type() === 'checkbox' ) ? 'checkbox' : 'radio',
168
- onchange: m.withAttr('value', config.selectChoice.bind(config)),
169
- checked: choice.selected(),
170
- value: choice.value(),
171
- title: i18n.preselect
172
- })
173
- ),
174
- m('td.stretch', m('input.widefat', {
175
- type: 'text',
176
- value: choice.label(),
177
- placeholder: choice.title(),
178
- onchange: m.withAttr('value', choice.label)
179
- })),
180
- m('td', m('span', {
181
- "title": i18n.remove,
182
- "class": 'dashicons dashicons-no-alt hover-activated',
183
- "onclick": function (key) {
184
- this.choices().splice(key, 1);
185
- }.bind(config, index)
186
- }, ''))
187
- ])
188
- })
189
- ]) // end of table
190
- ]) // end of limit-height div
191
  ]));
192
-
193
- return html;
194
 
 
195
  };
196
 
197
  return r;
198
  };
199
 
200
  module.exports = rows;
 
201
  },{}],2:[function(require,module,exports){
202
- var forms = function(m, i18n) {
 
 
203
  var forms = {};
204
  var rows = require('./field-forms-rows.js')(m, i18n);
205
 
206
  // route to one of the other form configs, default to "text"
207
- forms.render = function(config) {
208
 
209
  var type = config.type();
210
 
211
- if( typeof( forms[type] ) === "function" ) {
212
- return forms[ type ](config);
213
  }
214
 
215
- switch( type ) {
216
  case 'select':
217
  case 'radio':
218
  case 'checkbox':
@@ -224,85 +162,77 @@ var forms = function(m, i18n) {
224
  return forms.text(config);
225
  };
226
 
227
-
228
- forms.text = function(config) {
229
- return [
230
- rows.label(config),
231
- rows.placeholder(config),
232
- rows.value(config),
233
- rows.isRequired(config),
234
- rows.useParagraphs(config)
235
- ]
236
  };
237
 
238
- forms.choice = function(config) {
239
- var visibleRows = [
240
- rows.label(config),
241
- rows.choiceType(config),
242
- rows.choices(config),
243
- ];
244
 
245
- if( config.type() === 'select' ) {
246
  visibleRows.push(rows.placeholder(config));
247
  }
248
 
249
  visibleRows.push(rows.useParagraphs(config));
250
 
251
- if( config.type() === 'select' || config.type() === 'radio' ) {
252
  visibleRows.push(rows.isRequired(config));
253
  }
254
 
255
  return visibleRows;
256
  };
257
 
258
- forms.hidden = function( config ) {
259
  config.placeholder('');
260
  config.label('');
261
  config.wrap(false);
262
 
263
- return [
264
- rows.showType(config),
265
- rows.value(config)
266
- ]
267
  };
268
 
269
- forms.submit = function(config) {
270
  config.label('');
271
  config.placeholder('');
272
 
273
- return [
274
- rows.value(config),
275
- rows.useParagraphs(config)
276
- ]
277
  };
278
 
279
- forms.number = function(config) {
280
- return [
281
- forms.text(config),
282
- rows.numberMinMax(config)
283
- ];
284
  };
285
 
286
  return forms;
287
  };
288
 
289
-
290
-
291
  module.exports = forms;
 
292
  },{"./field-forms-rows.js":1}],3:[function(require,module,exports){
293
  'use strict';
294
 
295
- var render = require('../third-party/render.js');
296
- var html_beautify = require('../third-party/beautify-html.js');
 
 
 
 
 
 
 
 
 
 
 
 
 
297
 
298
- var g = function(m) {
299
  var generators = {};
300
 
301
  /**
302
- * Generates a <select> field
303
- * @param config
304
- * @returns {*}
305
- */
306
  generators.select = function (config) {
307
  var attributes = {
308
  name: config.name(),
@@ -312,73 +242,67 @@ var g = function(m) {
312
 
313
  var options = config.choices().map(function (choice) {
314
 
315
- if( choice.selected() ) {
316
  hasSelection = true;
317
  }
318
 
319
  return m('option', {
320
- value : ( choice.value() !== choice.label() ) ? choice.value() : undefined,
321
- "selected": choice.selected()
322
- }, choice.label())
 
323
  });
324
 
325
  var placeholder = config.placeholder();
326
- if(placeholder.length > 0 ) {
327
- options.unshift(
328
- m('option', {
329
- 'disabled': true,
330
- 'value': '',
331
- 'selected': ! hasSelection
332
- }, placeholder)
333
- );
334
  }
335
 
336
- return m('select', attributes, options );
337
  };
338
 
339
  /**
340
- * Generates a checkbox or radio type input field.
341
- *
342
- * @param config
343
- * @returns {*}
344
- */
345
  generators.checkbox = function (config) {
346
- var field = config.choices().map(function (choice) {
347
- var name = config.name() + ( config.type() === 'checkbox' ? '[]' : '' );
348
  var required = config.required() && config.type() === 'radio';
349
 
350
- return m('label', [
351
- m('input', {
352
- name : name,
353
- type : config.type(),
354
- value : choice.value(),
355
- checked : choice.selected(),
356
- required: required
357
- }),
358
- ' ',
359
- m('span', choice.label())
360
- ]
361
- )
362
  });
363
-
364
- return field;
365
  };
366
  generators.radio = generators.checkbox;
367
 
368
  /**
369
- * Generates a default field
370
- *
371
- * - text, url, number, email, date
372
- *
373
- * @param config
374
- * @returns {*}
375
- */
376
  generators['default'] = function (config) {
377
-
378
  var attributes = {
379
  type: config.type()
380
  };
381
- var field;
382
 
383
  if (config.name()) {
384
  attributes.name = config.name();
@@ -396,35 +320,38 @@ var g = function(m) {
396
  attributes.value = config.value();
397
  }
398
 
399
- if( config.placeholder().length > 0 ) {
400
  attributes.placeholder = config.placeholder();
401
  }
402
 
403
  attributes.required = config.required();
 
404
 
405
- field = m('input', attributes);
406
- return field;
407
  };
408
 
409
  /**
410
- * Generates an HTML string based on a field (config) object
411
- *
412
- * @param config
413
- * @returns {*}
414
- */
415
  function generate(config) {
416
- var label, field, htmlTemplate, html;
417
-
418
- label = config.label().length ? m("label", config.label()) : '';
419
- field = typeof(generators[config.type()]) === "function" ? generators[config.type()](config) : generators['default'](config);
420
-
 
 
 
421
  htmlTemplate = config.wrap() ? m('p', [label, field]) : [label, field];
422
 
423
- // render HTML on memory node
424
- html = render(htmlTemplate);
425
 
426
  // prettify html
427
- html = html_beautify(html);
428
 
429
  return html + "\n";
430
  }
@@ -433,30 +360,33 @@ var g = function(m) {
433
  };
434
 
435
  module.exports = g;
436
- },{"../third-party/beautify-html.js":12,"../third-party/render.js":13}],4:[function(require,module,exports){
437
- var FieldHelper = function(m, tabs, editor, fields, events, i18n) {
 
 
 
438
  'use strict';
439
 
440
  var generate = require('./field-generator.js')(m);
441
- var overlay = require('./overlay.js')(m,i18n);
442
  var forms = require('./field-forms.js')(m, i18n);
443
  var fieldConfig;
444
 
445
  editor.on('blur', m.redraw);
446
 
447
  /**
448
- * Choose a field to open the helper form for
449
- *
450
- * @param index
451
- * @returns {*}
452
- */
453
  function setActiveField(index) {
454
 
455
  fieldConfig = fields.get(index);
456
 
457
  // if this hidden field has choices (hidden groups), glue them together by their label.
458
- if( fieldConfig && fieldConfig.choices().length > 0 ) {
459
- fieldConfig.value( fieldConfig.choices().map(function(c) {
460
  return c.label();
461
  }).join('|'));
462
  }
@@ -464,24 +394,21 @@ var FieldHelper = function(m, tabs, editor, fields, events, i18n) {
464
  m.redraw();
465
  }
466
 
467
-
468
  /**
469
- * Controller
470
- */
471
- function controller() {
472
-
473
- }
474
 
475
  /**
476
- * Create HTML based on current config object
477
- */
478
  function createFieldHTMLAndAddToForm() {
479
 
480
  // generate html
481
  var html = generate(fieldConfig);
482
 
483
  // add to editor
484
- editor.insert( html );
485
 
486
  // reset field form
487
  setActiveField('');
@@ -491,106 +418,93 @@ var FieldHelper = function(m, tabs, editor, fields, events, i18n) {
491
  }
492
 
493
  /**
494
- * View
495
- * @returns {*}
496
- */
497
  function view() {
498
 
499
  // build DOM for fields choice
500
  var fieldCategories = fields.getCategories();
501
  var availableFields = fields.getAll();
502
 
503
- var fieldsChoice = m( "div.available-fields.small-margin", [
504
- m("h4", i18n.chooseField),
 
 
505
 
506
- fieldCategories.map(function(category) {
507
- var categoryFields = availableFields.filter(function(f) {
508
- return f.category === category;
509
- });
 
 
 
 
 
 
 
 
510
 
511
- if( ! categoryFields.length ) {
512
- return;
 
513
  }
514
 
515
- return m("div.tiny-margin",[
516
- m("strong", category),
517
-
518
- // render fields
519
- categoryFields.map(function(field) {
520
- var className = "button";
521
- if( field.forceRequired() ) {
522
- className += " is-required";
523
- }
524
-
525
- var inForm = field.inFormContent();
526
- if( inForm !== null ) {
527
- className += " " + ( inForm ? 'in-form' : 'not-in-form' );
528
- }
529
-
530
- return m("button", {
531
- className: className,
532
- type : 'button',
533
- onclick: m.withAttr("value", setActiveField),
534
- value : field.index
535
- }, field.title() );
536
- })
537
- ]);
538
- })
539
- ]);
540
 
541
  // build DOM for overlay
542
  var form = null;
543
- if( fieldConfig ) {
544
  form = overlay(
545
- // field wizard
546
- m("div.field-wizard", [
547
-
548
- //heading
549
- m("h3", [
550
- fieldConfig.title(),
551
- fieldConfig.forceRequired() ? m('span.red', '*' ) : '',
552
- fieldConfig.name().length ? m("code", fieldConfig.name()) : ''
553
- ]),
554
-
555
- // help text
556
- ( fieldConfig.help().length ) ? m('p', m.trust( fieldConfig.help() ) ) : '',
557
-
558
- // actual form
559
- forms.render(fieldConfig),
560
-
561
- // add to form button
562
- m("p", [
563
- m("button", {
564
- "class": "button-primary",
565
- type: "button",
566
- onkeydown: function(e) {
567
- e = e || window.event;
568
- if(e.keyCode == 13) {
569
- createFieldHTMLAndAddToForm();
570
- }
571
- },
572
- onclick: createFieldHTMLAndAddToForm
573
- }, i18n.addToForm )
574
- ])
575
- ]), setActiveField);
576
  }
577
 
578
- return [
579
- fieldsChoice,
580
- form
581
- ];
582
  }
583
 
584
  // expose some variables
585
  return {
586
  view: view,
587
  controller: controller
588
- }
589
  };
590
 
591
  module.exports = FieldHelper;
 
592
  },{"./field-forms.js":2,"./field-generator.js":3,"./overlay.js":10}],5:[function(require,module,exports){
593
- var FieldFactory = function(fields, i18n) {
 
 
594
  'use strict';
595
 
596
  /**
@@ -598,6 +512,7 @@ var FieldFactory = function(fields, i18n) {
598
  *
599
  * @type {Array}
600
  */
 
601
  var registeredFields = [];
602
 
603
  /**
@@ -617,7 +532,7 @@ var FieldFactory = function(fields, i18n) {
617
  function register(category, data, sticky) {
618
  var field = fields.register(category, data);
619
 
620
- if( ! sticky ) {
621
  registeredFields.push(field);
622
  }
623
  }
@@ -631,13 +546,13 @@ var FieldFactory = function(fields, i18n) {
631
  function getFieldType(type) {
632
 
633
  var map = {
634
- 'phone' : 'tel',
635
  'dropdown': 'select',
636
  'checkboxes': 'checkbox',
637
  'birthday': 'text'
638
  };
639
 
640
- return typeof map[ type ] !== "undefined" ? map[type] : type;
641
  }
642
 
643
  /**
@@ -662,12 +577,12 @@ var FieldFactory = function(fields, i18n) {
662
  acceptsMultipleValues: false // merge fields never accept multiple values.
663
  };
664
 
665
- if( data.type !== 'address' ) {
666
  register(category, data, false);
667
  } else {
668
  register(category, { name: data.name + '[addr1]', type: 'text', mailchimpType: 'address', title: i18n.streetAddress });
669
  register(category, { name: data.name + '[city]', type: 'text', mailchimpType: 'address', title: i18n.city });
670
- register(category, { name: data.name + '[state]', type: 'text', mailchimpType: 'address', title: i18n.state });
671
  register(category, { name: data.name + '[zip]', type: 'text', mailchimpType: 'address', title: i18n.zip });
672
  register(category, { name: data.name + '[country]', type: 'select', mailchimpType: 'address', title: i18n.country, choices: mc4wp_vars.countries });
673
  }
@@ -680,7 +595,7 @@ var FieldFactory = function(fields, i18n) {
680
  *
681
  * @param interestCategory
682
  */
683
- function registerInterestCategory(interestCategory){
684
  var category = i18n.interestCategories;
685
  var fieldType = getFieldType(interestCategory.field_type);
686
 
@@ -702,12 +617,12 @@ var FieldFactory = function(fields, i18n) {
702
  function registerListFields(list) {
703
 
704
  // make sure EMAIL && public fields come first
705
- list.merge_fields = list.merge_fields.sort(function(a, b) {
706
- if( a.tag === 'EMAIL' || ( a.public && ! b.public ) ) {
707
  return -1;
708
  }
709
 
710
- if( ! a.public && b.public ) {
711
  return 1;
712
  }
713
 
@@ -746,7 +661,7 @@ var FieldFactory = function(fields, i18n) {
746
 
747
  // register lists choice field
748
  choices = {};
749
- for(var key in lists) {
750
  choices[lists[key].id] = lists[key].name;
751
  }
752
 
@@ -780,20 +695,21 @@ var FieldFactory = function(fields, i18n) {
780
  'registerCustomFields': registerCustomFields,
781
  'registerListFields': registerListFields,
782
  'registerListsFields': registerListsFields
783
- }
784
-
785
  };
786
 
787
  module.exports = FieldFactory;
 
788
  },{}],6:[function(require,module,exports){
789
  'use strict';
790
 
791
- module.exports = function(m, events) {
 
 
792
  var timeout;
793
  var fields = [];
794
  var categories = [];
795
 
796
-
797
  /**
798
  * @internal
799
  *
@@ -801,40 +717,39 @@ module.exports = function(m, events) {
801
  * @param data
802
  * @constructor
803
  */
804
- var Field = function (data) {
805
- this.name = m.prop(data.name);
806
- this.title = m.prop(data.title || data.name);
807
- this.type = m.prop(data.type);
808
- this.mailchimpType = m.prop(data.mailchimpType || '');
809
- this.label = m.prop(data.title || '');
810
- this.value = m.prop(data.value || '');
811
- this.placeholder = m.prop(data.placeholder || '');
812
- this.required = m.prop(data.required || false);
813
- this.forceRequired = m.prop( data.forceRequired || false );
814
- this.wrap = m.prop(data.wrap || true);
815
- this.min = m.prop(data.min || null);
816
- this.max = m.prop(data.max || null);
817
- this.help = m.prop(data.help || '');
818
- this.choices = m.prop(data.choices || []);
819
- this.inFormContent = m.prop(null);
820
  this.acceptsMultipleValues = data.acceptsMultipleValues;
821
 
822
- this.selectChoice = function(value) {
823
  var field = this;
824
 
825
- this.choices(this.choices().map(function(choice) {
826
 
827
- if( choice.value() === value ) {
828
  choice.selected(true);
829
  } else {
830
  // only checkboxes allow for multiple selections
831
- if( field.type() !== 'checkbox' ) {
832
  choice.selected(false);
833
  }
834
  }
835
 
836
  return choice;
837
-
838
  }));
839
  };
840
  };
@@ -845,11 +760,11 @@ module.exports = function(m, events) {
845
  * @param data
846
  * @constructor
847
  */
848
- var FieldChoice = function (data) {
849
- this.label = m.prop(data.label);
850
- this.title = m.prop(data.title || data.label);
851
- this.selected = m.prop(data.selected || false);
852
- this.value = m.prop(data.value || data.label);
853
  };
854
 
855
  /**
@@ -860,14 +775,14 @@ module.exports = function(m, events) {
860
  */
861
  function createChoices(data) {
862
  var choices = [];
863
- if (typeof( data.map ) === "function") {
864
  choices = data.map(function (choiceLabel) {
865
- return new FieldChoice({label: choiceLabel});
866
  });
867
  } else {
868
  choices = Object.keys(data).map(function (key) {
869
  var choiceLabel = data[key];
870
- return new FieldChoice({label: choiceLabel, value: key});
871
  });
872
  }
873
 
@@ -888,10 +803,10 @@ module.exports = function(m, events) {
888
  var existingField = getAllWhere('name', data.name).shift();
889
 
890
  // a field with the same "name" already exists
891
- if(existingField) {
892
 
893
  // update "required" status
894
- if( ! existingField.forceRequired() && data.forceRequired ) {
895
  existingField.forceRequired(true);
896
  }
897
 
@@ -903,9 +818,9 @@ module.exports = function(m, events) {
903
  if (data.choices) {
904
  data.choices = createChoices(data.choices);
905
 
906
- if( data.value) {
907
- data.choices = data.choices.map(function(choice) {
908
- if(choice.value() === data.value) {
909
  choice.selected(true);
910
  }
911
  return choice;
@@ -914,7 +829,7 @@ module.exports = function(m, events) {
914
  }
915
 
916
  // register category
917
- if( categories.indexOf(category) < 0 ) {
918
  categories.push(category);
919
  }
920
 
@@ -965,7 +880,7 @@ module.exports = function(m, events) {
965
  */
966
  function getAll() {
967
  // rebuild index property on all fields
968
- fields = fields.map(function(f, i) {
969
  f.index = i;
970
  return f;
971
  });
@@ -990,23 +905,24 @@ module.exports = function(m, events) {
990
  });
991
  }
992
 
993
-
994
  /**
995
  * Exposed methods
996
  */
997
  return {
998
- 'get' : get,
999
- 'getAll' : getAll,
1000
  'getCategories': getCategories,
1001
- 'deregister' : deregister,
1002
- 'register' : register,
1003
  'getAllWhere': getAllWhere
1004
  };
1005
  };
1006
- },{}],7:[function(require,module,exports){
 
1007
  'use strict';
1008
 
1009
  // load CodeMirror & plugins
 
1010
  var CodeMirror = require('codemirror');
1011
  require('codemirror/mode/xml/xml');
1012
  require('codemirror/mode/javascript/javascript');
@@ -1016,7 +932,7 @@ require('codemirror/addon/fold/xml-fold');
1016
  require('codemirror/addon/edit/matchtags');
1017
  require('codemirror/addon/edit/closetag.js');
1018
 
1019
- var FormEditor = function(element) {
1020
 
1021
  // create dom representation of form
1022
  var _dom = document.createElement('form'),
@@ -1026,7 +942,7 @@ var FormEditor = function(element) {
1026
 
1027
  _dom.innerHTML = element.value.toLowerCase();
1028
 
1029
- if( CodeMirror ) {
1030
  editor = CodeMirror.fromTextArea(element, {
1031
  selectionPointer: true,
1032
  matchTags: { bothTags: true },
@@ -1037,8 +953,8 @@ var FormEditor = function(element) {
1037
  });
1038
 
1039
  // dispatch regular "change" on element event every time editor changes (IE9+ only)
1040
- window.dispatchEvent && editor.on('change',function() {
1041
- if(typeof(Event) === "function") {
1042
  // Create a new 'change' event
1043
  var event = new Event('change', { bubbles: true });
1044
  element.dispatchEvent(event);
@@ -1046,17 +962,17 @@ var FormEditor = function(element) {
1046
  });
1047
  }
1048
 
1049
- window.addEventListener('load', function() {
1050
  CodeMirror.signal(editor, "change");
1051
  });
1052
 
1053
  // set domDirty to true everytime the "change" event fires (a lot..)
1054
- element.addEventListener('change',function() {
1055
  domDirty = true;
1056
  });
1057
 
1058
  function dom() {
1059
- if( domDirty ) {
1060
  _dom.innerHTML = r.getValue().toLowerCase();
1061
  domDirty = false;
1062
  }
@@ -1064,38 +980,38 @@ var FormEditor = function(element) {
1064
  return _dom;
1065
  }
1066
 
1067
- r.getValue = function() {
1068
  return editor ? editor.getValue() : element.value;
1069
  };
1070
 
1071
- r.query = function(query) {
1072
  return dom().querySelectorAll(query.toLowerCase());
1073
  };
1074
 
1075
- r.containsField = function(fieldName){
1076
  return dom().elements.namedItem(fieldName.toLowerCase()) !== null;
1077
  };
1078
 
1079
- r.insert = function( html ) {
1080
- if( editor ) {
1081
- editor.replaceSelection( html );
1082
  editor.focus();
1083
  } else {
1084
  element.value += html;
1085
  }
1086
  };
1087
 
1088
- r.on = function(event,callback) {
1089
- if( editor ) {
1090
  // translate "input" event for CodeMirror
1091
- event = ( event === 'input' ) ? 'changes' : event;
1092
- return editor.on(event,callback);
1093
  }
1094
 
1095
- return element.addEventListener(event,callback);
1096
  };
1097
 
1098
- r.refresh = function() {
1099
  editor && editor.refresh();
1100
  };
1101
 
@@ -1103,33 +1019,36 @@ var FormEditor = function(element) {
1103
  };
1104
 
1105
  module.exports = FormEditor;
1106
- },{"codemirror":17,"codemirror/addon/edit/closetag.js":14,"codemirror/addon/edit/matchtags":15,"codemirror/addon/fold/xml-fold":16,"codemirror/mode/css/css":18,"codemirror/mode/htmlmixed/htmlmixed":19,"codemirror/mode/javascript/javascript":20,"codemirror/mode/xml/xml":21}],8:[function(require,module,exports){
1107
- var FormWatcher = function(m, editor, settings, fields, events, helpers) {
 
 
 
1108
  'use strict';
1109
 
1110
  var requiredFieldsInput = document.getElementById('required-fields');
1111
 
1112
  function updateFields() {
1113
- fields.getAll().forEach(function(field) {
1114
  // don't run for empty field names
1115
- if(field.name().length <= 0) return;
1116
 
1117
  var fieldName = field.name();
1118
- if( field.type() === 'checkbox' ) {
1119
  fieldName += '[]';
1120
  }
1121
 
1122
- var inForm = editor.containsField( fieldName );
1123
- field.inFormContent( inForm );
1124
 
1125
  // if form contains 1 address field of group, mark all fields in this group as "required"
1126
- if( field.mailchimpType() === 'address' ) {
1127
  field.originalRequiredValue = field.originalRequiredValue === undefined ? field.forceRequired() : field.originalRequiredValue;
1128
 
1129
  // query other fields for this address group
1130
- var nameGroup = field.name().replace(/\[(\w+)\]/g, '' );
1131
- if( editor.query('[name^="' + nameGroup + '"]').length > 0 ) {
1132
- if( field.originalRequiredValue === undefined ) {
1133
  field.originalRequiredValue = field.forceRequired();
1134
  }
1135
  field.forceRequired(true);
@@ -1137,7 +1056,6 @@ var FormWatcher = function(m, editor, settings, fields, events, helpers) {
1137
  field.forceRequired(field.originalRequiredValue);
1138
  }
1139
  }
1140
-
1141
  });
1142
 
1143
  findRequiredFields();
@@ -1147,23 +1065,25 @@ var FormWatcher = function(m, editor, settings, fields, events, helpers) {
1147
  function findRequiredFields() {
1148
 
1149
  // query fields required by MailChimp
1150
- var requiredFields = fields.getAllWhere('forceRequired', true).map(function(f) { return f.name().toUpperCase().replace(/\[(\w+)\]/g, '.$1' ); });
 
 
1151
 
1152
  // query fields in form with [required] attribute
1153
  var requiredFieldElements = editor.query('[required]');
1154
- Array.prototype.forEach.call(requiredFieldElements, function(el) {
1155
  var name = el.name.toUpperCase();
1156
 
1157
  // bail if name attr starts with underscore
1158
- if( name[0] === '_' ) {
1159
  return;
1160
  }
1161
 
1162
  // replace array brackets with dot style notation
1163
- name = name.replace(/\[(\w+)\]/g, '.$1' );
1164
 
1165
  // only add field if it's not already in it
1166
- if( requiredFields.indexOf(name) === -1 ) {
1167
  requiredFields.push(name);
1168
  }
1169
  });
@@ -1175,10 +1095,10 @@ var FormWatcher = function(m, editor, settings, fields, events, helpers) {
1175
  // events
1176
  editor.on('change', helpers.debounce(updateFields, 500));
1177
  events.on('fields.change', helpers.debounce(updateFields, 500));
1178
-
1179
  };
1180
 
1181
  module.exports = FormWatcher;
 
1182
  },{}],9:[function(require,module,exports){
1183
  'use strict';
1184
 
@@ -1196,39 +1116,41 @@ function hide(id) {
1196
 
1197
  function render() {
1198
  var html = '';
1199
- for(var key in notices) {
1200
  html += '<div class="notice notice-warning inline"><p>' + notices[key] + '</p></div>';
1201
  }
1202
 
1203
  var container = document.querySelector('.mc4wp-notices');
1204
- if( ! container ) {
1205
  container = document.createElement('div');
1206
  container.className = 'mc4wp-notices';
1207
  var heading = document.querySelector('h1, h2');
1208
  heading.parentNode.insertBefore(container, heading.nextSibling);
1209
  }
1210
-
1211
  container.innerHTML = html;
1212
  }
1213
 
1214
- function init( editor, fields ) {
1215
 
1216
- var groupingsNotice = function() {
1217
  var text = "Your form contains old style <code>GROUPINGS</code> fields. <br /><br />Please remove these fields from your form and then re-add them through the available field buttons to make sure your data is getting through to MailChimp correctly.";
1218
  var formCode = editor.getValue().toLowerCase();
1219
- ( formCode.indexOf('name="groupings') > -1 ) ? show('deprecated_groupings', text) : hide('deprecated_groupings');
1220
  };
1221
 
1222
- var requiredFieldsNotice = function() {
1223
  var requiredFields = fields.getAllWhere('forceRequired', true);
1224
- var missingFields = requiredFields.filter(function(f) {
1225
- return ! editor.containsField(f.name().toUpperCase());
1226
  });
1227
 
1228
  var text = '<strong>Heads up!</strong> Your form is missing list fields that are required in MailChimp. Either add these fields to your form or mark them as optional in MailChimp.';
1229
- text += "<br /><ul class=\"ul-square\" style=\"margin-bottom: 0;\"><li>" + missingFields.map(function(f) { return f.title(); }).join('</li><li>') + '</li></ul>';
 
 
1230
 
1231
- ( missingFields.length > 0 ) ? show('required_fields_missing', text) : hide('required_fields_missing');
1232
  };
1233
 
1234
  // old groupings
@@ -1242,17 +1164,18 @@ function init( editor, fields ) {
1242
  editor.on('focus', requiredFieldsNotice);
1243
  }
1244
 
1245
-
1246
-
1247
  module.exports = {
1248
  "init": init
1249
  };
 
1250
  },{}],10:[function(require,module,exports){
1251
- var overlay = function(m, i18n) {
 
 
1252
  'use strict';
1253
 
1254
- var _element,
1255
- _onCloseCallback;
1256
 
1257
  function close() {
1258
  document.removeEventListener('keydown', onKeyDown);
@@ -1264,28 +1187,33 @@ var overlay = function(m, i18n) {
1264
  e = e || window.event;
1265
 
1266
  // close overlay when pressing ESC
1267
- if(e.keyCode == 27) {
1268
  close();
1269
  }
1270
 
1271
  // prevent ENTER
1272
- if(e.keyCode == 13 ) {
1273
  e.preventDefault();
1274
  }
1275
  }
1276
 
1277
  function position() {
1278
- if( ! _element ) return;
1279
 
1280
  // fix for window width in IE8
1281
  var windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
1282
  var windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
1283
 
1284
- var marginLeft = ( windowWidth - _element.clientWidth - 40 ) / 2;
1285
- var marginTop = ( windowHeight - _element.clientHeight - 40 ) / 2;
 
 
 
 
1286
 
1287
- _element.style.left = ( marginLeft > 0 ? marginLeft : 0 ) + "px";
1288
- _element.style.top = ( marginTop > 0 ? marginTop : 0 ) + "px";
 
1289
  }
1290
 
1291
  return function (content, onCloseCallback) {
@@ -1294,39 +1222,26 @@ var overlay = function(m, i18n) {
1294
  document.addEventListener('keydown', onKeyDown);
1295
  window.addEventListener('resize', position);
1296
 
1297
- return [
1298
- m('div.overlay-wrap',
1299
- m("div.overlay", {
1300
- config: function (el) {
1301
- _element = el;
1302
- position();
1303
- }
1304
- },[
1305
-
1306
- // close icon
1307
- m('span', {
1308
- "class": 'close dashicons dashicons-no',
1309
- title : i18n.close,
1310
- onclick: close
1311
- }),
1312
-
1313
- content
1314
- ])
1315
- )
1316
- ,
1317
- m('div.overlay-background', {
1318
- title: i18n.close,
1319
- onclick: close
1320
- })
1321
- ];
1322
  };
1323
  };
1324
 
1325
  module.exports = overlay;
 
1326
  },{}],11:[function(require,module,exports){
1327
  'use strict';
1328
 
1329
  // deps
 
1330
  var i18n = window.mc4wp_forms_i18n;
1331
  var m = window.mc4wp.deps.mithril;
1332
  var events = mc4wp.events;
@@ -1342,13 +1257,13 @@ var fields = require('./admin/fields.js')(m, events);
1342
 
1343
  // vars
1344
  var textareaElement = document.getElementById('mc4wp-form-content');
1345
- var editor = window.formEditor = new FormEditor( textareaElement );
1346
- var watcher = new FormWatcher( m, formEditor, settings, fields, events, helpers );
1347
- var fieldHelper = new FieldHelper( m, tabs, formEditor, fields, events, i18n );
1348
  var notices = require('./admin/notices');
1349
 
1350
  // mount field helper on element
1351
- m.mount( document.getElementById( 'mc4wp-field-wizard'), fieldHelper );
1352
 
1353
  // register fields and redraw screen in 2 seconds (fixes IE8 bug)
1354
  var fieldsFactory = new FieldsFactory(fields, i18n);
@@ -1356,7 +1271,9 @@ events.on('selectedLists.change', fieldsFactory.registerListsFields);
1356
  fieldsFactory.registerListsFields(settings.getSelectedLists());
1357
  fieldsFactory.registerCustomFields(mc4wp_vars.mailchimp.lists);
1358
 
1359
- window.setTimeout( function() { m.redraw();}, 2000 );
 
 
1360
 
1361
  // init notices
1362
  notices.init(editor, fields);
@@ -1367,940 +1284,7 @@ window.mc4wp.forms = window.mc4wp.forms || {};
1367
  window.mc4wp.forms.editor = editor;
1368
  window.mc4wp.forms.fields = fields;
1369
 
1370
- },{"./admin/field-helper.js":4,"./admin/fields-factory.js":5,"./admin/fields.js":6,"./admin/form-editor.js":7,"./admin/form-watcher.js":8,"./admin/notices":9}],12:[function(require,module,exports){
1371
- /*jshint curly:true, eqeqeq:true, laxbreak:true, noempty:false */
1372
- /*
1373
-
1374
- The MIT License (MIT)
1375
-
1376
- Copyright (c) 2007-2013 Einar Lielmanis and contributors.
1377
-
1378
- Permission is hereby granted, free of charge, to any person
1379
- obtaining a copy of this software and associated documentation files
1380
- (the "Software"), to deal in the Software without restriction,
1381
- including without limitation the rights to use, copy, modify, merge,
1382
- publish, distribute, sublicense, and/or sell copies of the Software,
1383
- and to permit persons to whom the Software is furnished to do so,
1384
- subject to the following conditions:
1385
-
1386
- The above copyright notice and this permission notice shall be
1387
- included in all copies or substantial portions of the Software.
1388
-
1389
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1390
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1391
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1392
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
1393
- BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
1394
- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1395
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1396
- SOFTWARE.
1397
-
1398
-
1399
- Style HTML
1400
- ---------------
1401
-
1402
- Written by Nochum Sossonko, (nsossonko@hotmail.com)
1403
-
1404
- Based on code initially developed by: Einar Lielmanis, <elfz@laacz.lv>
1405
- http://jsbeautifier.org/
1406
-
1407
- Usage:
1408
- style_html(html_source);
1409
-
1410
- style_html(html_source, options);
1411
-
1412
- The options are:
1413
- indent_inner_html (default false) — indent <head> and <body> sections,
1414
- indent_size (default 4) — indentation size,
1415
- indent_char (default space) — character to indent with,
1416
- wrap_line_length (default 250) - maximum amount of characters per line (0 = disable)
1417
- brace_style (default "collapse") - "collapse" | "expand" | "end-expand"
1418
- put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or just put end braces on own line.
1419
- unformatted (defaults to inline tags) - list of tags, that shouldn't be reformatted
1420
- indent_scripts (default normal) - "keep"|"separate"|"normal"
1421
- preserve_newlines (default true) - whether existing line breaks before elements should be preserved
1422
- Only works before elements, not inside tags or for text.
1423
- max_preserve_newlines (default unlimited) - maximum number of line breaks to be preserved in one chunk
1424
- indent_handlebars (default false) - format and indent {{#foo}} and {{/foo}}
1425
-
1426
- e.g.
1427
-
1428
- style_html(html_source, {
1429
- 'indent_inner_html': false,
1430
- 'indent_size': 2,
1431
- 'indent_char': ' ',
1432
- 'wrap_line_length': 78,
1433
- 'brace_style': 'expand',
1434
- 'unformatted': ['a', 'sub', 'sup', 'b', 'i', 'u'],
1435
- 'preserve_newlines': true,
1436
- 'max_preserve_newlines': 5,
1437
- 'indent_handlebars': false
1438
- });
1439
- */
1440
-
1441
- (function() {
1442
-
1443
- function trim(s) {
1444
- return s.replace(/^\s+|\s+$/g, '');
1445
- }
1446
-
1447
- function ltrim(s) {
1448
- return s.replace(/^\s+/g, '');
1449
- }
1450
-
1451
- function style_html(html_source, options, js_beautify, css_beautify) {
1452
- //Wrapper function to invoke all the necessary constructors and deal with the output.
1453
-
1454
- var multi_parser,
1455
- indent_inner_html,
1456
- indent_size,
1457
- indent_character,
1458
- wrap_line_length,
1459
- brace_style,
1460
- unformatted,
1461
- preserve_newlines,
1462
- max_preserve_newlines;
1463
-
1464
- options = options || {};
1465
-
1466
- // backwards compatibility to 1.3.4
1467
- if ((options.wrap_line_length === undefined || parseInt(options.wrap_line_length, 10) === 0) &&
1468
- (options.max_char === undefined || parseInt(options.max_char, 10) === 0)) {
1469
- options.wrap_line_length = options.max_char;
1470
- }
1471
-
1472
- indent_inner_html = options.indent_inner_html || false;
1473
- indent_size = parseInt(options.indent_size || 4, 10);
1474
- indent_character = options.indent_char || ' ';
1475
- brace_style = options.brace_style || 'collapse';
1476
- wrap_line_length = parseInt(options.wrap_line_length, 10) === 0 ? 32786 : parseInt(options.wrap_line_length || 250, 10);
1477
- unformatted = options.unformatted || ['a', 'span', 'bdo', 'em', 'strong', 'dfn', 'code', 'samp', 'kbd', 'var', 'cite', 'abbr', 'acronym', 'q', 'sub', 'sup', 'tt', 'i', 'b', 'big', 'small', 'u', 's', 'strike', 'font', 'ins', 'del', 'pre', 'address', 'dt', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
1478
- preserve_newlines = options.preserve_newlines || true;
1479
- max_preserve_newlines = preserve_newlines ? parseInt(options.max_preserve_newlines || 32786, 10) : 0;
1480
- indent_handlebars = options.indent_handlebars || false;
1481
-
1482
- function Parser() {
1483
-
1484
- this.pos = 0; //Parser position
1485
- this.token = '';
1486
- this.current_mode = 'CONTENT'; //reflects the current Parser mode: TAG/CONTENT
1487
- this.tags = { //An object to hold tags, their position, and their parent-tags, initiated with default values
1488
- parent: 'parent1',
1489
- parentcount: 1,
1490
- parent1: ''
1491
- };
1492
- this.tag_type = '';
1493
- this.token_text = this.last_token = this.last_text = this.token_type = '';
1494
- this.newlines = 0;
1495
- this.indent_content = indent_inner_html;
1496
-
1497
- this.Utils = { //Uilities made available to the various functions
1498
- whitespace: "\n\r\t ".split(''),
1499
- single_token: 'br,input,link,meta,!doctype,basefont,base,area,hr,wbr,param,img,isindex,?xml,embed,?php,?,?='.split(','), //all the single tags for HTML
1500
- extra_liners: 'head,body,/html'.split(','), //for tags that need a line of whitespace before them
1501
- in_array: function(what, arr) {
1502
- for (var i = 0; i < arr.length; i++) {
1503
- if (what === arr[i]) {
1504
- return true;
1505
- }
1506
- }
1507
- return false;
1508
- }
1509
- };
1510
-
1511
- this.traverse_whitespace = function() {
1512
- var input_char = '';
1513
-
1514
- input_char = this.input.charAt(this.pos);
1515
- if (this.Utils.in_array(input_char, this.Utils.whitespace)) {
1516
- this.newlines = 0;
1517
- while (this.Utils.in_array(input_char, this.Utils.whitespace)) {
1518
- if (preserve_newlines && input_char === '\n' && this.newlines <= max_preserve_newlines) {
1519
- this.newlines += 1;
1520
- }
1521
-
1522
- this.pos++;
1523
- input_char = this.input.charAt(this.pos);
1524
- }
1525
- return true;
1526
- }
1527
- return false;
1528
- };
1529
-
1530
- this.get_content = function() { //function to capture regular content between tags
1531
-
1532
- var input_char = '',
1533
- content = [],
1534
- space = false; //if a space is needed
1535
-
1536
- while (this.input.charAt(this.pos) !== '<') {
1537
- if (this.pos >= this.input.length) {
1538
- return content.length ? content.join('') : ['', 'TK_EOF'];
1539
- }
1540
-
1541
- if (this.traverse_whitespace()) {
1542
- if (content.length) {
1543
- space = true;
1544
- }
1545
- continue; //don't want to insert unnecessary space
1546
- }
1547
-
1548
- if (indent_handlebars) {
1549
- // Handlebars parsing is complicated.
1550
- // {{#foo}} and {{/foo}} are formatted tags.
1551
- // {{something}} should get treated as content, except:
1552
- // {{else}} specifically behaves like {{#if}} and {{/if}}
1553
- var peek3 = this.input.substr(this.pos, 3);
1554
- if (peek3 === '{{#' || peek3 === '{{/') {
1555
- // These are tags and not content.
1556
- break;
1557
- } else if (this.input.substr(this.pos, 2) === '{{') {
1558
- if (this.get_tag(true) === '{{else}}') {
1559
- break;
1560
- }
1561
- }
1562
- }
1563
-
1564
- input_char = this.input.charAt(this.pos);
1565
- this.pos++;
1566
-
1567
- if (space) {
1568
- if (this.line_char_count >= this.wrap_line_length) { //insert a line when the wrap_line_length is reached
1569
- this.print_newline(false, content);
1570
- this.print_indentation(content);
1571
- } else {
1572
- this.line_char_count++;
1573
- content.push(' ');
1574
- }
1575
- space = false;
1576
- }
1577
- this.line_char_count++;
1578
- content.push(input_char); //letter at-a-time (or string) inserted to an array
1579
- }
1580
- return content.length ? content.join('') : '';
1581
- };
1582
-
1583
- this.get_contents_to = function(name) { //get the full content of a script or style to pass to js_beautify
1584
- if (this.pos === this.input.length) {
1585
- return ['', 'TK_EOF'];
1586
- }
1587
- var input_char = '';
1588
- var content = '';
1589
- var reg_match = new RegExp('</' + name + '\\s*>', 'igm');
1590
- reg_match.lastIndex = this.pos;
1591
- var reg_array = reg_match.exec(this.input);
1592
- var end_script = reg_array ? reg_array.index : this.input.length; //absolute end of script
1593
- if (this.pos < end_script) { //get everything in between the script tags
1594
- content = this.input.substring(this.pos, end_script);
1595
- this.pos = end_script;
1596
- }
1597
- return content;
1598
- };
1599
-
1600
- this.record_tag = function(tag) { //function to record a tag and its parent in this.tags Object
1601
- if (this.tags[tag + 'count']) { //check for the existence of this tag type
1602
- this.tags[tag + 'count']++;
1603
- this.tags[tag + this.tags[tag + 'count']] = this.indent_level; //and record the present indent level
1604
- } else { //otherwise initialize this tag type
1605
- this.tags[tag + 'count'] = 1;
1606
- this.tags[tag + this.tags[tag + 'count']] = this.indent_level; //and record the present indent level
1607
- }
1608
- this.tags[tag + this.tags[tag + 'count'] + 'parent'] = this.tags.parent; //set the parent (i.e. in the case of a div this.tags.div1parent)
1609
- this.tags.parent = tag + this.tags[tag + 'count']; //and make this the current parent (i.e. in the case of a div 'div1')
1610
- };
1611
-
1612
- this.retrieve_tag = function(tag) { //function to retrieve the opening tag to the corresponding closer
1613
- if (this.tags[tag + 'count']) { //if the openener is not in the Object we ignore it
1614
- var temp_parent = this.tags.parent; //check to see if it's a closable tag.
1615
- while (temp_parent) { //till we reach '' (the initial value);
1616
- if (tag + this.tags[tag + 'count'] === temp_parent) { //if this is it use it
1617
- break;
1618
- }
1619
- temp_parent = this.tags[temp_parent + 'parent']; //otherwise keep on climbing up the DOM Tree
1620
- }
1621
- if (temp_parent) { //if we caught something
1622
- this.indent_level = this.tags[tag + this.tags[tag + 'count']]; //set the indent_level accordingly
1623
- this.tags.parent = this.tags[temp_parent + 'parent']; //and set the current parent
1624
- }
1625
- delete this.tags[tag + this.tags[tag + 'count'] + 'parent']; //delete the closed tags parent reference...
1626
- delete this.tags[tag + this.tags[tag + 'count']]; //...and the tag itself
1627
- if (this.tags[tag + 'count'] === 1) {
1628
- delete this.tags[tag + 'count'];
1629
- } else {
1630
- this.tags[tag + 'count']--;
1631
- }
1632
- }
1633
- };
1634
-
1635
- this.indent_to_tag = function(tag) {
1636
- // Match the indentation level to the last use of this tag, but don't remove it.
1637
- if (!this.tags[tag + 'count']) {
1638
- return;
1639
- }
1640
- var temp_parent = this.tags.parent;
1641
- while (temp_parent) {
1642
- if (tag + this.tags[tag + 'count'] === temp_parent) {
1643
- break;
1644
- }
1645
- temp_parent = this.tags[temp_parent + 'parent'];
1646
- }
1647
- if (temp_parent) {
1648
- this.indent_level = this.tags[tag + this.tags[tag + 'count']];
1649
- }
1650
- };
1651
-
1652
- this.get_tag = function(peek) { //function to get a full tag and parse its type
1653
- var input_char = '',
1654
- content = [],
1655
- comment = '',
1656
- space = false,
1657
- tag_start, tag_end,
1658
- tag_start_char,
1659
- orig_pos = this.pos,
1660
- orig_line_char_count = this.line_char_count;
1661
-
1662
- peek = peek !== undefined ? peek : false;
1663
-
1664
- do {
1665
- if (this.pos >= this.input.length) {
1666
- if (peek) {
1667
- this.pos = orig_pos;
1668
- this.line_char_count = orig_line_char_count;
1669
- }
1670
- return content.length ? content.join('') : ['', 'TK_EOF'];
1671
- }
1672
-
1673
- input_char = this.input.charAt(this.pos);
1674
- this.pos++;
1675
-
1676
- if (this.Utils.in_array(input_char, this.Utils.whitespace)) { //don't want to insert unnecessary space
1677
- space = true;
1678
- continue;
1679
- }
1680
-
1681
- if (input_char === "'" || input_char === '"') {
1682
- input_char += this.get_unformatted(input_char);
1683
- space = true;
1684
-
1685
- }
1686
-
1687
- if (input_char === '=') { //no space before =
1688
- space = false;
1689
- }
1690
-
1691
- if (content.length && content[content.length - 1] !== '=' && input_char !== '>' && space) {
1692
- //no space after = or before >
1693
- if (this.line_char_count >= this.wrap_line_length) {
1694
- this.print_newline(false, content);
1695
- this.print_indentation(content);
1696
- } else {
1697
- content.push(' ');
1698
- this.line_char_count++;
1699
- }
1700
- space = false;
1701
- }
1702
-
1703
- if (indent_handlebars && tag_start_char === '<') {
1704
- // When inside an angle-bracket tag, put spaces around
1705
- // handlebars not inside of strings.
1706
- if ((input_char + this.input.charAt(this.pos)) === '{{') {
1707
- input_char += this.get_unformatted('}}');
1708
- if (content.length && content[content.length - 1] !== ' ' && content[content.length - 1] !== '<') {
1709
- input_char = ' ' + input_char;
1710
- }
1711
- space = true;
1712
- }
1713
- }
1714
-
1715
- if (input_char === '<' && !tag_start_char) {
1716
- tag_start = this.pos - 1;
1717
- tag_start_char = '<';
1718
- }
1719
-
1720
- if (indent_handlebars && !tag_start_char) {
1721
- if (content.length >= 2 && content[content.length - 1] === '{' && content[content.length - 2] == '{') {
1722
- if (input_char === '#' || input_char === '/') {
1723
- tag_start = this.pos - 3;
1724
- } else {
1725
- tag_start = this.pos - 2;
1726
- }
1727
- tag_start_char = '{';
1728
- }
1729
- }
1730
-
1731
- this.line_char_count++;
1732
- content.push(input_char); //inserts character at-a-time (or string)
1733
-
1734
- if (content[1] && content[1] === '!') { //if we're in a comment, do something special
1735
- // We treat all comments as literals, even more than preformatted tags
1736
- // we just look for the appropriate close tag
1737
- content = [this.get_comment(tag_start)];
1738
- break;
1739
- }
1740
-
1741
- if (indent_handlebars && tag_start_char === '{' && content.length > 2 && content[content.length - 2] === '}' && content[content.length - 1] === '}') {
1742
- break;
1743
- }
1744
- } while (input_char !== '>');
1745
-
1746
- var tag_complete = content.join('');
1747
- var tag_index;
1748
- var tag_offset;
1749
-
1750
- if (tag_complete.indexOf(' ') !== -1) { //if there's whitespace, thats where the tag name ends
1751
- tag_index = tag_complete.indexOf(' ');
1752
- } else if (tag_complete[0] === '{') {
1753
- tag_index = tag_complete.indexOf('}');
1754
- } else { //otherwise go with the tag ending
1755
- tag_index = tag_complete.indexOf('>');
1756
- }
1757
- if (tag_complete[0] === '<' || !indent_handlebars) {
1758
- tag_offset = 1;
1759
- } else {
1760
- tag_offset = tag_complete[2] === '#' ? 3 : 2;
1761
- }
1762
- var tag_check = tag_complete.substring(tag_offset, tag_index).toLowerCase();
1763
- if (tag_complete.charAt(tag_complete.length - 2) === '/' ||
1764
- this.Utils.in_array(tag_check, this.Utils.single_token)) { //if this tag name is a single tag type (either in the list or has a closing /)
1765
- if (!peek) {
1766
- this.tag_type = 'SINGLE';
1767
- }
1768
- } else if (indent_handlebars && tag_complete[0] === '{' && tag_check === 'else') {
1769
- if (!peek) {
1770
- this.indent_to_tag('if');
1771
- this.tag_type = 'HANDLEBARS_ELSE';
1772
- this.indent_content = true;
1773
- this.traverse_whitespace();
1774
- }
1775
- } else if (tag_check === 'script') { //for later script handling
1776
- if (!peek) {
1777
- this.record_tag(tag_check);
1778
- this.tag_type = 'SCRIPT';
1779
- }
1780
- } else if (tag_check === 'style') { //for future style handling (for now it justs uses get_content)
1781
- if (!peek) {
1782
- this.record_tag(tag_check);
1783
- this.tag_type = 'STYLE';
1784
- }
1785
- } else if (this.is_unformatted(tag_check, unformatted)) { // do not reformat the "unformatted" tags
1786
- comment = this.get_unformatted('</' + tag_check + '>', tag_complete); //...delegate to get_unformatted function
1787
- content.push(comment);
1788
- // Preserve collapsed whitespace either before or after this tag.
1789
- if (tag_start > 0 && this.Utils.in_array(this.input.charAt(tag_start - 1), this.Utils.whitespace)) {
1790
- content.splice(0, 0, this.input.charAt(tag_start - 1));
1791
- }
1792
- tag_end = this.pos - 1;
1793
- if (this.Utils.in_array(this.input.charAt(tag_end + 1), this.Utils.whitespace)) {
1794
- content.push(this.input.charAt(tag_end + 1));
1795
- }
1796
- this.tag_type = 'SINGLE';
1797
- } else if (tag_check.charAt(0) === '!') { //peek for <! comment
1798
- // for comments content is already correct.
1799
- if (!peek) {
1800
- this.tag_type = 'SINGLE';
1801
- this.traverse_whitespace();
1802
- }
1803
- } else if (!peek) {
1804
- if (tag_check.charAt(0) === '/') { //this tag is a double tag so check for tag-ending
1805
- this.retrieve_tag(tag_check.substring(1)); //remove it and all ancestors
1806
- this.tag_type = 'END';
1807
- this.traverse_whitespace();
1808
- } else { //otherwise it's a start-tag
1809
- this.record_tag(tag_check); //push it on the tag stack
1810
- if (tag_check.toLowerCase() !== 'html') {
1811
- this.indent_content = true;
1812
- }
1813
- this.tag_type = 'START';
1814
-
1815
- // Allow preserving of newlines after a start tag
1816
- this.traverse_whitespace();
1817
- }
1818
- if (this.Utils.in_array(tag_check, this.Utils.extra_liners)) { //check if this double needs an extra line
1819
- this.print_newline(false, this.output);
1820
- if (this.output.length && this.output[this.output.length - 2] !== '\n') {
1821
- this.print_newline(true, this.output);
1822
- }
1823
- }
1824
- }
1825
-
1826
- if (peek) {
1827
- this.pos = orig_pos;
1828
- this.line_char_count = orig_line_char_count;
1829
- }
1830
-
1831
- return content.join(''); //returns fully formatted tag
1832
- };
1833
-
1834
- this.get_comment = function(start_pos) { //function to return comment content in its entirety
1835
- // this is will have very poor perf, but will work for now.
1836
- var comment = '',
1837
- delimiter = '>',
1838
- matched = false;
1839
-
1840
- this.pos = start_pos;
1841
- input_char = this.input.charAt(this.pos);
1842
- this.pos++;
1843
-
1844
- while (this.pos <= this.input.length) {
1845
- comment += input_char;
1846
-
1847
- // only need to check for the delimiter if the last chars match
1848
- if (comment[comment.length - 1] === delimiter[delimiter.length - 1] &&
1849
- comment.indexOf(delimiter) !== -1) {
1850
- break;
1851
- }
1852
-
1853
- // only need to search for custom delimiter for the first few characters
1854
- if (!matched && comment.length < 10) {
1855
- if (comment.indexOf('<![if') === 0) { //peek for <![if conditional comment
1856
- delimiter = '<![endif]>';
1857
- matched = true;
1858
- } else if (comment.indexOf('<![cdata[') === 0) { //if it's a <[cdata[ comment...
1859
- delimiter = ']]>';
1860
- matched = true;
1861
- } else if (comment.indexOf('<![') === 0) { // some other ![ comment? ...
1862
- delimiter = ']>';
1863
- matched = true;
1864
- } else if (comment.indexOf('<!--') === 0) { // <!-- comment ...
1865
- delimiter = '-->';
1866
- matched = true;
1867
- }
1868
- }
1869
-
1870
- input_char = this.input.charAt(this.pos);
1871
- this.pos++;
1872
- }
1873
-
1874
- return comment;
1875
- };
1876
-
1877
- this.get_unformatted = function(delimiter, orig_tag) { //function to return unformatted content in its entirety
1878
-
1879
- if (orig_tag && orig_tag.toLowerCase().indexOf(delimiter) !== -1) {
1880
- return '';
1881
- }
1882
- var input_char = '';
1883
- var content = '';
1884
- var min_index = 0;
1885
- var space = true;
1886
- do {
1887
-
1888
- if (this.pos >= this.input.length) {
1889
- return content;
1890
- }
1891
-
1892
- input_char = this.input.charAt(this.pos);
1893
- this.pos++;
1894
-
1895
- if (this.Utils.in_array(input_char, this.Utils.whitespace)) {
1896
- if (!space) {
1897
- this.line_char_count--;
1898
- continue;
1899
- }
1900
- if (input_char === '\n' || input_char === '\r') {
1901
- content += '\n';
1902
- /* Don't change tab indention for unformatted blocks. If using code for html editing, this will greatly affect <pre> tags if they are specified in the 'unformatted array'
1903
- for (var i=0; i<this.indent_level; i++) {
1904
- content += this.indent_string;
1905
- }
1906
- space = false; //...and make sure other indentation is erased
1907
- */
1908
- this.line_char_count = 0;
1909
- continue;
1910
- }
1911
- }
1912
- content += input_char;
1913
- this.line_char_count++;
1914
- space = true;
1915
-
1916
- if (indent_handlebars && input_char === '{' && content.length && content[content.length - 2] === '{') {
1917
- // Handlebars expressions in strings should also be unformatted.
1918
- content += this.get_unformatted('}}');
1919
- // These expressions are opaque. Ignore delimiters found in them.
1920
- min_index = content.length;
1921
- }
1922
- } while (content.toLowerCase().indexOf(delimiter, min_index) === -1);
1923
- return content;
1924
- };
1925
-
1926
- this.get_token = function() { //initial handler for token-retrieval
1927
- var token;
1928
-
1929
- if (this.last_token === 'TK_TAG_SCRIPT' || this.last_token === 'TK_TAG_STYLE') { //check if we need to format javascript
1930
- var type = this.last_token.substr(7);
1931
- token = this.get_contents_to(type);
1932
- if (typeof token !== 'string') {
1933
- return token;
1934
- }
1935
- return [token, 'TK_' + type];
1936
- }
1937
- if (this.current_mode === 'CONTENT') {
1938
- token = this.get_content();
1939
- if (typeof token !== 'string') {
1940
- return token;
1941
- } else {
1942
- return [token, 'TK_CONTENT'];
1943
- }
1944
- }
1945
-
1946
- if (this.current_mode === 'TAG') {
1947
- token = this.get_tag();
1948
- if (typeof token !== 'string') {
1949
- return token;
1950
- } else {
1951
- var tag_name_type = 'TK_TAG_' + this.tag_type;
1952
- return [token, tag_name_type];
1953
- }
1954
- }
1955
- };
1956
-
1957
- this.get_full_indent = function(level) {
1958
- level = this.indent_level + level || 0;
1959
- if (level < 1) {
1960
- return '';
1961
- }
1962
-
1963
- return Array(level + 1).join(this.indent_string);
1964
- };
1965
-
1966
- this.is_unformatted = function(tag_check, unformatted) {
1967
- //is this an HTML5 block-level link?
1968
- if (!this.Utils.in_array(tag_check, unformatted)) {
1969
- return false;
1970
- }
1971
-
1972
- if (tag_check.toLowerCase() !== 'a' || !this.Utils.in_array('a', unformatted)) {
1973
- return true;
1974
- }
1975
-
1976
- //at this point we have an tag; is its first child something we want to remain
1977
- //unformatted?
1978
- var next_tag = this.get_tag(true /* peek. */ );
1979
-
1980
- // test next_tag to see if it is just html tag (no external content)
1981
- var tag = (next_tag || "").match(/^\s*<\s*\/?([a-z]*)\s*[^>]*>\s*$/);
1982
-
1983
- // if next_tag comes back but is not an isolated tag, then
1984
- // let's treat the 'a' tag as having content
1985
- // and respect the unformatted option
1986
- if (!tag || this.Utils.in_array(tag, unformatted)) {
1987
- return true;
1988
- } else {
1989
- return false;
1990
- }
1991
- };
1992
-
1993
- this.printer = function(js_source, indent_character, indent_size, wrap_line_length, brace_style) { //handles input/output and some other printing functions
1994
-
1995
- this.input = js_source || ''; //gets the input for the Parser
1996
- this.output = [];
1997
- this.indent_character = indent_character;
1998
- this.indent_string = '';
1999
- this.indent_size = indent_size;
2000
- this.brace_style = brace_style;
2001
- this.indent_level = 0;
2002
- this.wrap_line_length = wrap_line_length;
2003
- this.line_char_count = 0; //count to see if wrap_line_length was exceeded
2004
-
2005
- for (var i = 0; i < this.indent_size; i++) {
2006
- this.indent_string += this.indent_character;
2007
- }
2008
-
2009
- this.print_newline = function(force, arr) {
2010
- this.line_char_count = 0;
2011
- if (!arr || !arr.length) {
2012
- return;
2013
- }
2014
- if (force || (arr[arr.length - 1] !== '\n')) { //we might want the extra line
2015
- arr.push('\n');
2016
- }
2017
- };
2018
-
2019
- this.print_indentation = function(arr) {
2020
- for (var i = 0; i < this.indent_level; i++) {
2021
- arr.push(this.indent_string);
2022
- this.line_char_count += this.indent_string.length;
2023
- }
2024
- };
2025
-
2026
- this.print_token = function(text) {
2027
- if (text || text !== '') {
2028
- if (this.output.length && this.output[this.output.length - 1] === '\n') {
2029
- this.print_indentation(this.output);
2030
- text = ltrim(text);
2031
- }
2032
- }
2033
- this.print_token_raw(text);
2034
- };
2035
-
2036
- this.print_token_raw = function(text) {
2037
- if (text && text !== '') {
2038
- if (text.length > 1 && text[text.length - 1] === '\n') {
2039
- // unformatted tags can grab newlines as their last character
2040
- this.output.push(text.slice(0, -1));
2041
- this.print_newline(false, this.output);
2042
- } else {
2043
- this.output.push(text);
2044
- }
2045
- }
2046
-
2047
- for (var n = 0; n < this.newlines; n++) {
2048
- this.print_newline(n > 0, this.output);
2049
- }
2050
- this.newlines = 0;
2051
- };
2052
-
2053
- this.indent = function() {
2054
- this.indent_level++;
2055
- };
2056
-
2057
- this.unindent = function() {
2058
- if (this.indent_level > 0) {
2059
- this.indent_level--;
2060
- }
2061
- };
2062
- };
2063
- return this;
2064
- }
2065
-
2066
- /*_____________________--------------------_____________________*/
2067
-
2068
- multi_parser = new Parser(); //wrapping functions Parser
2069
- multi_parser.printer(html_source, indent_character, indent_size, wrap_line_length, brace_style); //initialize starting values
2070
-
2071
- while (true) {
2072
- var t = multi_parser.get_token();
2073
- multi_parser.token_text = t[0];
2074
- multi_parser.token_type = t[1];
2075
-
2076
- if (multi_parser.token_type === 'TK_EOF') {
2077
- break;
2078
- }
2079
-
2080
- switch (multi_parser.token_type) {
2081
- case 'TK_TAG_START':
2082
- multi_parser.print_newline(false, multi_parser.output);
2083
- multi_parser.print_token(multi_parser.token_text);
2084
- if (multi_parser.indent_content) {
2085
- multi_parser.indent();
2086
- multi_parser.indent_content = false;
2087
- }
2088
- multi_parser.current_mode = 'CONTENT';
2089
- break;
2090
- case 'TK_TAG_STYLE':
2091
- case 'TK_TAG_SCRIPT':
2092
- multi_parser.print_newline(false, multi_parser.output);
2093
- multi_parser.print_token(multi_parser.token_text);
2094
- multi_parser.current_mode = 'CONTENT';
2095
- break;
2096
- case 'TK_TAG_END':
2097
- //Print new line only if the tag has no content and has child
2098
- if (multi_parser.last_token === 'TK_CONTENT' && multi_parser.last_text === '') {
2099
- var tag_name = multi_parser.token_text.match(/\w+/)[0];
2100
- var tag_extracted_from_last_output = null;
2101
- if (multi_parser.output.length) {
2102
- tag_extracted_from_last_output = multi_parser.output[multi_parser.output.length - 1].match(/(?:<|{{#)\s*(\w+)/);
2103
- }
2104
- if (tag_extracted_from_last_output === null ||
2105
- tag_extracted_from_last_output[1] !== tag_name) {
2106
- multi_parser.print_newline(false, multi_parser.output);
2107
- }
2108
- }
2109
- multi_parser.print_token(multi_parser.token_text);
2110
- multi_parser.current_mode = 'CONTENT';
2111
- break;
2112
- case 'TK_TAG_SINGLE':
2113
- // Don't add a newline before elements that should remain unformatted.
2114
- var tag_check = multi_parser.token_text.match(/^\s*<([a-z]+)/i);
2115
- if (!tag_check || !multi_parser.Utils.in_array(tag_check[1], unformatted)) {
2116
- multi_parser.print_newline(false, multi_parser.output);
2117
- }
2118
- multi_parser.print_token(multi_parser.token_text);
2119
- multi_parser.current_mode = 'CONTENT';
2120
- break;
2121
- case 'TK_TAG_HANDLEBARS_ELSE':
2122
- multi_parser.print_token(multi_parser.token_text);
2123
- if (multi_parser.indent_content) {
2124
- multi_parser.indent();
2125
- multi_parser.indent_content = false;
2126
- }
2127
- multi_parser.current_mode = 'CONTENT';
2128
- break;
2129
- case 'TK_CONTENT':
2130
- multi_parser.print_token(multi_parser.token_text);
2131
- multi_parser.current_mode = 'TAG';
2132
- break;
2133
- case 'TK_STYLE':
2134
- case 'TK_SCRIPT':
2135
- if (multi_parser.token_text !== '') {
2136
- multi_parser.print_newline(false, multi_parser.output);
2137
- var text = multi_parser.token_text,
2138
- _beautifier,
2139
- script_indent_level = 1;
2140
- if (multi_parser.token_type === 'TK_SCRIPT') {
2141
- _beautifier = typeof js_beautify === 'function' && js_beautify;
2142
- } else if (multi_parser.token_type === 'TK_STYLE') {
2143
- _beautifier = typeof css_beautify === 'function' && css_beautify;
2144
- }
2145
-
2146
- if (options.indent_scripts === "keep") {
2147
- script_indent_level = 0;
2148
- } else if (options.indent_scripts === "separate") {
2149
- script_indent_level = -multi_parser.indent_level;
2150
- }
2151
-
2152
- var indentation = multi_parser.get_full_indent(script_indent_level);
2153
- if (_beautifier) {
2154
- // call the Beautifier if avaliable
2155
- text = _beautifier(text.replace(/^\s*/, indentation), options);
2156
- } else {
2157
- // simply indent the string otherwise
2158
- var white = text.match(/^\s*/)[0];
2159
- var _level = white.match(/[^\n\r]*$/)[0].split(multi_parser.indent_string).length - 1;
2160
- var reindent = multi_parser.get_full_indent(script_indent_level - _level);
2161
- text = text.replace(/^\s*/, indentation)
2162
- .replace(/\r\n|\r|\n/g, '\n' + reindent)
2163
- .replace(/\s+$/, '');
2164
- }
2165
- if (text) {
2166
- multi_parser.print_token_raw(indentation + trim(text));
2167
- multi_parser.print_newline(false, multi_parser.output);
2168
- }
2169
- }
2170
- multi_parser.current_mode = 'TAG';
2171
- break;
2172
- }
2173
- multi_parser.last_token = multi_parser.token_type;
2174
- multi_parser.last_text = multi_parser.token_text;
2175
- }
2176
- return multi_parser.output.join('');
2177
- }
2178
-
2179
- if (typeof module !== "undefined" && typeof( module.exports ) !== "undefined" ) {
2180
- module.exports = style_html;
2181
- } else if (typeof window !== "undefined") {
2182
- // If we're running a web page and don't have either of the above, add our one global
2183
- window.html_beautify = style_html;
2184
- }
2185
-
2186
- }());
2187
- },{}],13:[function(require,module,exports){
2188
- 'use strict';
2189
-
2190
- var VOID_TAGS = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr',
2191
- 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track',
2192
- 'wbr', '!doctype'];
2193
-
2194
- function isArray(thing) {
2195
- return Object.prototype.toString.call(thing) === '[object Array]';
2196
- }
2197
-
2198
- function camelToDash(str) {
2199
- return str.replace(/\W+/g, '-')
2200
- .replace(/([a-z\d])([A-Z])/g, '$1-$2');
2201
- }
2202
-
2203
- function removeEmpties(n) {
2204
- return n != '';
2205
- }
2206
-
2207
- // shameless stolen from https://github.com/punkave/sanitize-html
2208
- function escapeHtml(s, replaceDoubleQuote) {
2209
- if (s === 'undefined') {
2210
- s = '';
2211
- }
2212
- if (typeof(s) !== 'string') {
2213
- s = s + '';
2214
- }
2215
- s = s.replace(/\&/g, '&amp;').replace(/</g, '&lt;').replace(/\>/g, '&gt;');
2216
- if (replaceDoubleQuote) {
2217
- return s.replace(/\"/g, '&quot;');
2218
- }
2219
- return s;
2220
- }
2221
-
2222
- function createAttrString(attrs) {
2223
- if (!attrs || !Object.keys(attrs).length) {
2224
- return '';
2225
- }
2226
-
2227
- return Object.keys(attrs).map(function(name) {
2228
- var value = attrs[name];
2229
- if (typeof value === 'undefined' || value === null || typeof value === 'function') {
2230
- return;
2231
- }
2232
- if (typeof value === 'boolean') {
2233
- return value ? ' ' + name : '';
2234
- }
2235
- if (name === 'style') {
2236
- if (!value) {
2237
- return;
2238
- }
2239
- var styles = attrs.style;
2240
- if (typeof styles === 'object') {
2241
- styles = Object.keys(styles).map(function(property) {
2242
- return styles[property] != '' ? [camelToDash(property).toLowerCase(), styles[property]].join(':') : '';
2243
- }).filter(removeEmpties).join(';');
2244
- }
2245
- return styles != '' ? ' style="' + escapeHtml(styles, true) + '"' : '';
2246
- }
2247
- return ' ' + escapeHtml(name === 'className' ? 'class' : name) + '="' + escapeHtml(value, true) + '"';
2248
- }).join('');
2249
- }
2250
-
2251
- function createChildrenContent(view) {
2252
- if(isArray(view.children) && !view.children.length) {
2253
- return '';
2254
- }
2255
-
2256
- return render(view.children);
2257
- }
2258
-
2259
- function render(view) {
2260
- var type = typeof view;
2261
-
2262
- if (type === 'string') {
2263
- return escapeHtml(view);
2264
- }
2265
-
2266
- if(type === 'number' || type === 'boolean') {
2267
- return view;
2268
- }
2269
-
2270
- if (!view) {
2271
- return '';
2272
- }
2273
-
2274
- if (isArray(view)) {
2275
- return view.map(render).join('');
2276
- }
2277
-
2278
- //compontent
2279
- if (view.view) {
2280
- var scope = view.controller ? new view.controller : {};
2281
- var result = render(view.view(scope));
2282
- if (scope.onunload) {
2283
- scope.onunload();
2284
- }
2285
- return result;
2286
- }
2287
-
2288
- if (view.$trusted) {
2289
- return '' + view;
2290
- }
2291
- var children = createChildrenContent(view);
2292
- if (!children && VOID_TAGS.indexOf(view.tag.toLowerCase()) >= 0) {
2293
- return '<' + view.tag + createAttrString(view.attrs) + '>';
2294
- }
2295
- return [
2296
- '<', view.tag, createAttrString(view.attrs), '>',
2297
- children,
2298
- '</', view.tag, '>',
2299
- ].join('');
2300
- }
2301
-
2302
- module.exports = render;
2303
- },{}],14:[function(require,module,exports){
2304
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
2305
  // Distributed under an MIT license: http://codemirror.net/LICENSE
2306
 
@@ -2471,7 +1455,7 @@ module.exports = render;
2471
  }
2472
  });
2473
 
2474
- },{"../../lib/codemirror":17,"../fold/xml-fold":16}],15:[function(require,module,exports){
2475
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
2476
  // Distributed under an MIT license: http://codemirror.net/LICENSE
2477
 
@@ -2539,7 +1523,7 @@ module.exports = render;
2539
  };
2540
  });
2541
 
2542
- },{"../../lib/codemirror":17,"../fold/xml-fold":16}],16:[function(require,module,exports){
2543
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
2544
  // Distributed under an MIT license: http://codemirror.net/LICENSE
2545
 
@@ -2723,7 +1707,7 @@ module.exports = render;
2723
  };
2724
  });
2725
 
2726
- },{"../../lib/codemirror":17}],17:[function(require,module,exports){
2727
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
2728
  // Distributed under an MIT license: http://codemirror.net/LICENSE
2729
 
@@ -2747,17 +1731,18 @@ var platform = navigator.platform
2747
  var gecko = /gecko\/\d/i.test(userAgent)
2748
  var ie_upto10 = /MSIE \d/.test(userAgent)
2749
  var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent)
2750
- var ie = ie_upto10 || ie_11up
2751
- var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : ie_11up[1])
2752
- var webkit = /WebKit\//.test(userAgent)
 
2753
  var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent)
2754
- var chrome = /Chrome\//.test(userAgent)
2755
  var presto = /Opera\//.test(userAgent)
2756
  var safari = /Apple Computer/.test(navigator.vendor)
2757
  var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent)
2758
  var phantom = /PhantomJS/.test(userAgent)
2759
 
2760
- var ios = /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent)
2761
  // This is woefully incomplete. Suggestions for alternative methods welcome.
2762
  var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent)
2763
  var mac = ios || /Mac/.test(platform)
@@ -2829,18 +1814,20 @@ function contains(parent, child) {
2829
  } while (child = child.parentNode)
2830
  }
2831
 
2832
- var activeElt = function() {
2833
- var activeElement = document.activeElement
 
 
 
 
 
 
 
 
2834
  while (activeElement && activeElement.root && activeElement.root.activeElement)
2835
  { activeElement = activeElement.root.activeElement }
2836
  return activeElement
2837
  }
2838
- // Older versions of IE throws unspecified error when touching
2839
- // document.activeElement in some cases (during loading, in iframe)
2840
- if (ie && ie_version < 11) { activeElt = function() {
2841
- try { return document.activeElement }
2842
- catch(e) { return document.body }
2843
- } }
2844
 
2845
  function addClass(node, cls) {
2846
  var current = node.className
@@ -2889,11 +1876,11 @@ function countColumn(string, end, tabSize, startIndex, startValue) {
2889
  }
2890
  }
2891
 
2892
- function Delayed() {this.id = null}
2893
- Delayed.prototype.set = function(ms, f) {
2894
  clearTimeout(this.id)
2895
  this.id = setTimeout(f, ms)
2896
- }
2897
 
2898
  function indexOf(array, elt) {
2899
  for (var i = 0; i < array.length; ++i)
@@ -2987,6 +1974,23 @@ function isEmpty(obj) {
2987
  var extendingChars = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/
2988
  function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch) }
2989
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2990
  // The display handles the DOM integration, both for input reading
2991
  // and content drawing. It holds references to DOM nodes and
2992
  // display-related state.
@@ -3174,15 +2178,21 @@ function lineNumberFor(options, i) {
3174
  }
3175
 
3176
  // A Pos instance represents a position within the text.
3177
- function Pos (line, ch) {
3178
- if (!(this instanceof Pos)) { return new Pos(line, ch) }
3179
- this.line = line; this.ch = ch
 
 
 
 
3180
  }
3181
 
3182
  // Compare two positions, return 0 if they are the same, a negative
3183
  // number when a is less, and a positive number otherwise.
3184
  function cmp(a, b) { return a.line - b.line || a.ch - b.ch }
3185
 
 
 
3186
  function copyPos(x) {return Pos(x.line, x.ch)}
3187
  function maxPos(a, b) { return cmp(a, b) < 0 ? b : a }
3188
  function minPos(a, b) { return cmp(a, b) < 0 ? a : b }
@@ -3378,7 +2388,7 @@ function removeReadOnlyRanges(doc, from, to) {
3378
  if (dto > 0 || !mk.inclusiveRight && !dto)
3379
  { newParts.push({from: m.to, to: p.to}) }
3380
  parts.splice.apply(parts, newParts)
3381
- j += newParts.length - 1
3382
  }
3383
  }
3384
  return parts
@@ -3422,7 +2432,7 @@ function compareCollapsedMarkers(a, b) {
3422
  // so, return the marker for that span.
3423
  function collapsedSpanAtSide(line, start) {
3424
  var sps = sawCollapsedSpans && line.markedSpans, found
3425
- if (sps) { for (var sp = void 0, i = 0; i < sps.length; ++i) {
3426
  sp = sps[i]
3427
  if (sp.marker.collapsed && (start ? sp.from : sp.to) == null &&
3428
  (!found || compareCollapsedMarkers(found, sp.marker) < 0))
@@ -3463,6 +2473,13 @@ function visualLine(line) {
3463
  return line
3464
  }
3465
 
 
 
 
 
 
 
 
3466
  // Returns an array of logical lines that continue the visual line
3467
  // started by the argument, or undefined if there are no such lines.
3468
  function visualLineContinued(line) {
@@ -3498,7 +2515,7 @@ function visualLineEndNo(doc, lineN) {
3498
  // they are entirely covered by collapsed, non-widget span.
3499
  function lineIsHidden(doc, line) {
3500
  var sps = sawCollapsedSpans && line.markedSpans
3501
- if (sps) { for (var sp = void 0, i = 0; i < sps.length; ++i) {
3502
  sp = sps[i]
3503
  if (!sp.marker.collapsed) { continue }
3504
  if (sp.from == null) { return true }
@@ -3514,7 +2531,7 @@ function lineIsHiddenInner(doc, line, span) {
3514
  }
3515
  if (span.marker.inclusiveRight && span.to == line.text.length)
3516
  { return true }
3517
- for (var sp = void 0, i = 0; i < line.markedSpans.length; ++i) {
3518
  sp = line.markedSpans[i]
3519
  if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to &&
3520
  (sp.to == null || sp.to != span.from) &&
@@ -3594,84 +2611,23 @@ function iterateBidiSections(order, from, to, f) {
3594
  if (!found) { f(from, to, "ltr") }
3595
  }
3596
 
3597
- function bidiLeft(part) { return part.level % 2 ? part.to : part.from }
3598
- function bidiRight(part) { return part.level % 2 ? part.from : part.to }
3599
-
3600
- function lineLeft(line) { var order = getOrder(line); return order ? bidiLeft(order[0]) : 0 }
3601
- function lineRight(line) {
3602
- var order = getOrder(line)
3603
- if (!order) { return line.text.length }
3604
- return bidiRight(lst(order))
3605
- }
3606
-
3607
- function compareBidiLevel(order, a, b) {
3608
- var linedir = order[0].level
3609
- if (a == linedir) { return true }
3610
- if (b == linedir) { return false }
3611
- return a < b
3612
- }
3613
-
3614
  var bidiOther = null
3615
- function getBidiPartAt(order, pos) {
3616
  var found
3617
  bidiOther = null
3618
  for (var i = 0; i < order.length; ++i) {
3619
  var cur = order[i]
3620
- if (cur.from < pos && cur.to > pos) { return i }
3621
- if ((cur.from == pos || cur.to == pos)) {
3622
- if (found == null) {
3623
- found = i
3624
- } else if (compareBidiLevel(order, cur.level, order[found].level)) {
3625
- if (cur.from != cur.to) { bidiOther = found }
3626
- return i
3627
- } else {
3628
- if (cur.from != cur.to) { bidiOther = i }
3629
- return found
3630
- }
3631
  }
3632
- }
3633
- return found
3634
- }
3635
-
3636
- function moveInLine(line, pos, dir, byUnit) {
3637
- if (!byUnit) { return pos + dir }
3638
- do { pos += dir }
3639
- while (pos > 0 && isExtendingChar(line.text.charAt(pos)))
3640
- return pos
3641
- }
3642
-
3643
- // This is needed in order to move 'visually' through bi-directional
3644
- // text -- i.e., pressing left should make the cursor go left, even
3645
- // when in RTL text. The tricky part is the 'jumps', where RTL and
3646
- // LTR text touch each other. This often requires the cursor offset
3647
- // to move more than one unit, in order to visually move one unit.
3648
- function moveVisually(line, start, dir, byUnit) {
3649
- var bidi = getOrder(line)
3650
- if (!bidi) { return moveLogically(line, start, dir, byUnit) }
3651
- var pos = getBidiPartAt(bidi, start), part = bidi[pos]
3652
- var target = moveInLine(line, start, part.level % 2 ? -dir : dir, byUnit)
3653
-
3654
- for (;;) {
3655
- if (target > part.from && target < part.to) { return target }
3656
- if (target == part.from || target == part.to) {
3657
- if (getBidiPartAt(bidi, target) == pos) { return target }
3658
- part = bidi[pos += dir]
3659
- return (dir > 0) == part.level % 2 ? part.to : part.from
3660
- } else {
3661
- part = bidi[pos += dir]
3662
- if (!part) { return null }
3663
- if ((dir > 0) == part.level % 2)
3664
- { target = moveInLine(line, part.to, -1, byUnit) }
3665
- else
3666
- { target = moveInLine(line, part.from, 1, byUnit) }
3667
  }
3668
  }
3669
- }
3670
-
3671
- function moveLogically(line, start, dir, byUnit) {
3672
- var target = start + dir
3673
- if (byUnit) { while (target > 0 && isExtendingChar(line.text.charAt(target))) { target += dir } }
3674
- return target < 0 || target > line.text.length ? null : target
3675
  }
3676
 
3677
  // Bidirectional ordering algorithm
@@ -3700,12 +2656,12 @@ function moveLogically(line, start, dir, byUnit) {
3700
  var bidiOrdering = (function() {
3701
  // Character types for codepoints 0 to 0xff
3702
  var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN"
3703
- // Character types for codepoints 0x600 to 0x6ff
3704
- var arabicTypes = "rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm"
3705
  function charType(code) {
3706
  if (code <= 0xf7) { return lowTypes.charAt(code) }
3707
  else if (0x590 <= code && code <= 0x5f4) { return "R" }
3708
- else if (0x600 <= code && code <= 0x6ed) { return arabicTypes.charAt(code - 0x600) }
3709
  else if (0x6ee <= code && code <= 0x8ac) { return "r" }
3710
  else if (0x2000 <= code && code <= 0x200b) { return "w" }
3711
  else if (code == 0x200c) { return "b" }
@@ -3768,7 +2724,7 @@ var bidiOrdering = (function() {
3768
  var type$3 = types[i$4]
3769
  if (type$3 == ",") { types[i$4] = "N" }
3770
  else if (type$3 == "%") {
3771
- var end = void 0
3772
  for (end = i$4 + 1; end < len && types[end] == "%"; ++end) {}
3773
  var replace = (i$4 && types[i$4-1] == "!") || (end < len && types[end] == "1") ? "1" : "N"
3774
  for (var j = i$4; j < end; ++j) { types[j] = replace }
@@ -3793,7 +2749,7 @@ var bidiOrdering = (function() {
3793
  // N2. Any remaining neutrals take the embedding direction.
3794
  for (var i$6 = 0; i$6 < len; ++i$6) {
3795
  if (isNeutral.test(types[i$6])) {
3796
- var end$1 = void 0
3797
  for (end$1 = i$6 + 1; end$1 < len && isNeutral.test(types[end$1]); ++end$1) {}
3798
  var before = (i$6 ? types[i$6-1] : outerType) == "L"
3799
  var after = (end$1 < len ? types[end$1] : outerType) == "L"
@@ -3837,10 +2793,6 @@ var bidiOrdering = (function() {
3837
  lst(order).to -= m[0].length
3838
  order.push(new BidiSpan(0, len - m[0].length, len))
3839
  }
3840
- if (order[0].level == 2)
3841
- { order.unshift(new BidiSpan(1, order[0].to, order[0].to)) }
3842
- if (order[0].level != lst(order).level)
3843
- { order.push(new BidiSpan(order[0].level, len, len)) }
3844
 
3845
  return order
3846
  }
@@ -3855,44 +2807,150 @@ function getOrder(line) {
3855
  return order
3856
  }
3857
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3858
  // EVENT HANDLING
3859
 
3860
  // Lightweight event framework. on/off also work on DOM nodes,
3861
  // registering native DOM handlers.
3862
 
 
 
3863
  var on = function(emitter, type, f) {
3864
- if (emitter.addEventListener)
3865
- { emitter.addEventListener(type, f, false) }
3866
- else if (emitter.attachEvent)
3867
- { emitter.attachEvent("on" + type, f) }
3868
- else {
3869
  var map = emitter._handlers || (emitter._handlers = {})
3870
- var arr = map[type] || (map[type] = [])
3871
- arr.push(f)
3872
  }
3873
  }
3874
 
3875
- var noHandlers = []
3876
- function getHandlers(emitter, type, copy) {
3877
- var arr = emitter._handlers && emitter._handlers[type]
3878
- if (copy) { return arr && arr.length > 0 ? arr.slice() : noHandlers }
3879
- else { return arr || noHandlers }
3880
  }
3881
 
3882
  function off(emitter, type, f) {
3883
- if (emitter.removeEventListener)
3884
- { emitter.removeEventListener(type, f, false) }
3885
- else if (emitter.detachEvent)
3886
- { emitter.detachEvent("on" + type, f) }
3887
- else {
3888
- var handlers = getHandlers(emitter, type, false)
3889
- for (var i = 0; i < handlers.length; ++i)
3890
- { if (handlers[i] == f) { handlers.splice(i, 1); break } }
 
 
 
3891
  }
3892
  }
3893
 
3894
  function signal(emitter, type /*, values...*/) {
3895
- var handlers = getHandlers(emitter, type, true)
3896
  if (!handlers.length) { return }
3897
  var args = Array.prototype.slice.call(arguments, 2)
3898
  for (var i = 0; i < handlers.length; ++i) { handlers[i].apply(null, args) }
@@ -4142,74 +3200,72 @@ var StringStream = function(string, tabSize) {
4142
  this.tabSize = tabSize || 8
4143
  this.lastColumnPos = this.lastColumnValue = 0
4144
  this.lineStart = 0
4145
- }
4146
 
4147
- StringStream.prototype = {
4148
- eol: function() {return this.pos >= this.string.length},
4149
- sol: function() {return this.pos == this.lineStart},
4150
- peek: function() {return this.string.charAt(this.pos) || undefined},
4151
- next: function() {
4152
- if (this.pos < this.string.length)
4153
- { return this.string.charAt(this.pos++) }
4154
- },
4155
- eat: function(match) {
4156
- var ch = this.string.charAt(this.pos)
4157
- var ok
4158
- if (typeof match == "string") { ok = ch == match }
4159
- else { ok = ch && (match.test ? match.test(ch) : match(ch)) }
4160
- if (ok) {++this.pos; return ch}
4161
- },
4162
- eatWhile: function(match) {
4163
- var start = this.pos
4164
- while (this.eat(match)){}
4165
- return this.pos > start
4166
- },
4167
- eatSpace: function() {
4168
  var this$1 = this;
4169
 
4170
- var start = this.pos
4171
- while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) { ++this$1.pos }
4172
- return this.pos > start
4173
- },
4174
- skipToEnd: function() {this.pos = this.string.length},
4175
- skipTo: function(ch) {
4176
- var found = this.string.indexOf(ch, this.pos)
4177
- if (found > -1) {this.pos = found; return true}
4178
- },
4179
- backUp: function(n) {this.pos -= n},
4180
- column: function() {
4181
- if (this.lastColumnPos < this.start) {
4182
- this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue)
4183
- this.lastColumnPos = this.start
4184
- }
4185
- return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0)
4186
- },
4187
- indentation: function() {
4188
- return countColumn(this.string, null, this.tabSize) -
4189
- (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0)
4190
- },
4191
- match: function(pattern, consume, caseInsensitive) {
4192
- if (typeof pattern == "string") {
4193
- var cased = function (str) { return caseInsensitive ? str.toLowerCase() : str; }
4194
- var substr = this.string.substr(this.pos, pattern.length)
4195
- if (cased(substr) == cased(pattern)) {
4196
- if (consume !== false) { this.pos += pattern.length }
4197
- return true
4198
- }
4199
- } else {
4200
- var match = this.string.slice(this.pos).match(pattern)
4201
- if (match && match.index > 0) { return null }
4202
- if (match && consume !== false) { this.pos += match[0].length }
4203
- return match
4204
  }
4205
- },
4206
- current: function(){return this.string.slice(this.start, this.pos)},
4207
- hideFirstChars: function(n, inner) {
4208
- this.lineStart += n
4209
- try { return inner() }
4210
- finally { this.lineStart -= n }
4211
  }
4212
- }
 
 
 
 
 
 
4213
 
4214
  // Compute a style array (an array starting with a mode generation
4215
  // -- for invalidation -- followed by pairs of end positions and
@@ -4414,13 +3470,14 @@ function findStartLine(cm, n, precise) {
4414
 
4415
  // Line objects. These hold state related to a line, including
4416
  // highlighting info (the styles array).
4417
- function Line(text, markedSpans, estimateHeight) {
4418
  this.text = text
4419
  attachMarkedSpans(this, markedSpans)
4420
  this.height = estimateHeight ? estimateHeight(this) : 1
4421
- }
 
 
4422
  eventMixin(Line)
4423
- Line.prototype.lineNo = function() { return lineNo(this) }
4424
 
4425
  // Change the content (text, markers) of a line. Automatically
4426
  // invalidates cached information and tries to re-estimate the
@@ -4468,11 +3525,14 @@ function buildLineContent(cm, lineView) {
4468
  col: 0, pos: 0, cm: cm,
4469
  trailingSpace: false,
4470
  splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")}
 
 
 
4471
  lineView.measure = {}
4472
 
4473
  // Iterate over the logical lines that make up this visual line.
4474
  for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) {
4475
- var line = i ? lineView.rest[i - 1] : lineView.line, order = void 0
4476
  builder.pos = 0
4477
  builder.addToken = buildToken
4478
  // Optionally wire in some hacks into the token-rendering
@@ -4554,7 +3614,7 @@ function buildToken(builder, text, style, startStyle, endStyle, title, css) {
4554
  }
4555
  if (!m) { break }
4556
  pos += skipped + 1
4557
- var txt$1 = void 0
4558
  if (m[0] == "\t") {
4559
  var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize
4560
  txt$1 = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"))
@@ -4609,7 +3669,7 @@ function buildTokenBadBidi(inner, order) {
4609
  var start = builder.pos, end = start + text.length
4610
  for (;;) {
4611
  // Find the part that overlaps with the start of this text
4612
- var part = void 0
4613
  for (var i = 0; i < order.length; i++) {
4614
  part = order[i]
4615
  if (part.to > start && part.from <= start) { break }
@@ -4655,7 +3715,7 @@ function insertLineContent(line, builder, styles) {
4655
  if (nextChange == pos) { // Update current marker set
4656
  spanStyle = spanEndStyle = spanStartStyle = title = css = ""
4657
  collapsed = null; nextChange = Infinity
4658
- var foundBookmarks = [], endStyles = void 0
4659
  for (var j = 0; j < spans.length; ++j) {
4660
  var sp = spans[j], m = sp.marker
4661
  if (m.type == "bookmark" && sp.from == pos && m.widgetNode) {
@@ -4785,7 +3845,7 @@ var orphanDelayedCallbacks = null
4785
  // them to be executed when the last operation ends, or, if no
4786
  // operation is active, when a timeout fires.
4787
  function signalLater(emitter, type /*, values...*/) {
4788
- var arr = getHandlers(emitter, type, false)
4789
  if (!arr.length) { return }
4790
  var args = Array.prototype.slice.call(arguments, 2), list
4791
  if (operationGroup) {
@@ -4928,7 +3988,7 @@ function updateLineGutter(cm, lineView, lineN, dims) {
4928
 
4929
  function updateLineWidgets(cm, lineView, dims) {
4930
  if (lineView.alignable) { lineView.alignable = null }
4931
- for (var node = lineView.node.firstChild, next = void 0; node; node = next) {
4932
  next = node.nextSibling
4933
  if (node.className == "CodeMirror-linewidget")
4934
  { lineView.node.removeChild(node) }
@@ -5290,8 +4350,8 @@ function pageScrollY() { return window.pageYOffset || (document.documentElement
5290
  // coordinates into another coordinate system. Context may be one of
5291
  // "line", "div" (display.lineDiv), "local"./null (editor), "window",
5292
  // or "page".
5293
- function intoCoordSystem(cm, lineObj, rect, context) {
5294
- if (lineObj.widgets) { for (var i = 0; i < lineObj.widgets.length; ++i) { if (lineObj.widgets[i].above) {
5295
  var size = widgetHeight(lineObj.widgets[i])
5296
  rect.top += size; rect.bottom += size
5297
  } } }
@@ -5337,6 +4397,19 @@ function charCoords(cm, pos, context, lineObj, bias) {
5337
  // Returns a box for a given cursor position, which may have an
5338
  // 'other' property containing the position of the secondary cursor
5339
  // on a bidi boundary.
 
 
 
 
 
 
 
 
 
 
 
 
 
5340
  function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {
5341
  lineObj = lineObj || getLine(cm.doc, pos.line)
5342
  if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj) }
@@ -5345,25 +4418,24 @@ function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {
5345
  if (right) { m.left = m.right; } else { m.right = m.left }
5346
  return intoCoordSystem(cm, lineObj, m, context)
5347
  }
5348
- function getBidi(ch, partPos) {
5349
- var part = order[partPos], right = part.level % 2
5350
- if (ch == bidiLeft(part) && partPos && part.level < order[partPos - 1].level) {
5351
- part = order[--partPos]
5352
- ch = bidiRight(part) - (part.level % 2 ? 0 : 1)
5353
- right = true
5354
- } else if (ch == bidiRight(part) && partPos < order.length - 1 && part.level < order[partPos + 1].level) {
5355
- part = order[++partPos]
5356
- ch = bidiLeft(part) - part.level % 2
5357
- right = false
5358
- }
5359
- if (right && ch == part.to && ch > part.from) { return get(ch - 1) }
5360
- return get(ch, right)
5361
- }
5362
- var order = getOrder(lineObj), ch = pos.ch
5363
- if (!order) { return get(ch) }
5364
- var partPos = getBidiPartAt(order, ch)
5365
- var val = getBidi(ch, partPos)
5366
- if (bidiOther != null) { val.other = getBidi(ch, bidiOther) }
5367
  return val
5368
  }
5369
 
@@ -5384,8 +4456,8 @@ function estimateCoords(cm, pos) {
5384
  // the right of the character position, for example). When outside
5385
  // is true, that means the coordinates lie outside the line's
5386
  // vertical range.
5387
- function PosWithInfo(line, ch, outside, xRel) {
5388
- var pos = Pos(line, ch)
5389
  pos.xRel = xRel
5390
  if (outside) { pos.outside = true }
5391
  return pos
@@ -5396,10 +4468,10 @@ function PosWithInfo(line, ch, outside, xRel) {
5396
  function coordsChar(cm, x, y) {
5397
  var doc = cm.doc
5398
  y += cm.display.viewOffset
5399
- if (y < 0) { return PosWithInfo(doc.first, 0, true, -1) }
5400
  var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1
5401
  if (lineN > last)
5402
- { return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, true, 1) }
5403
  if (x < 0) { x = 0 }
5404
 
5405
  var lineObj = getLine(doc, lineN)
@@ -5414,57 +4486,68 @@ function coordsChar(cm, x, y) {
5414
  }
5415
  }
5416
 
5417
- function coordsCharInner(cm, lineObj, lineNo, x, y) {
5418
- var innerOff = y - heightAtLine(lineObj)
5419
- var wrongLine = false, adjust = 2 * cm.display.wrapper.clientWidth
5420
- var preparedMeasure = prepareMeasureForLine(cm, lineObj)
5421
-
5422
- function getX(ch) {
5423
- var sp = cursorCoords(cm, Pos(lineNo, ch), "line", lineObj, preparedMeasure)
5424
- wrongLine = true
5425
- if (innerOff > sp.bottom) { return sp.left - adjust }
5426
- else if (innerOff < sp.top) { return sp.left + adjust }
5427
- else { wrongLine = false }
5428
- return sp.left
5429
- }
5430
 
5431
- var bidi = getOrder(lineObj), dist = lineObj.text.length
5432
- var from = lineLeft(lineObj), to = lineRight(lineObj)
5433
- var fromX = getX(from), fromOutside = wrongLine, toX = getX(to), toOutside = wrongLine
 
5434
 
5435
- if (x > toX) { return PosWithInfo(lineNo, to, toOutside, 1) }
5436
- // Do a binary search between these bounds.
5437
- for (;;) {
5438
- if (bidi ? to == from || to == moveVisually(lineObj, from, 1) : to - from <= 1) {
5439
- var ch = x < fromX || x - fromX <= toX - x ? from : to
5440
- var outside = ch == from ? fromOutside : toOutside
5441
- var xDiff = x - (ch == from ? fromX : toX)
5442
- // This is a kludge to handle the case where the coordinates
5443
- // are after a line-wrapped line. We should replace it with a
5444
- // more general handling of cursor positions around line
5445
- // breaks. (Issue #4078)
5446
- if (toOutside && !bidi && !/\s/.test(lineObj.text.charAt(ch)) && xDiff > 0 &&
5447
- ch < lineObj.text.length && preparedMeasure.view.measure.heights.length > 1) {
5448
- var charSize = measureCharPrepared(cm, preparedMeasure, ch, "right")
5449
- if (innerOff <= charSize.bottom && innerOff >= charSize.top && Math.abs(x - charSize.right) < xDiff) {
5450
- outside = false
5451
- ch++
5452
- xDiff = x - charSize.right
5453
- }
 
 
 
5454
  }
5455
- while (isExtendingChar(lineObj.text.charAt(ch))) { ++ch }
5456
- var pos = PosWithInfo(lineNo, ch, outside, xDiff < -1 ? -1 : xDiff > 1 ? 1 : 0)
5457
- return pos
5458
- }
5459
- var step = Math.ceil(dist / 2), middle = from + step
5460
- if (bidi) {
5461
- middle = from
5462
- for (var i = 0; i < step; ++i) { middle = moveVisually(lineObj, middle, 1) }
5463
  }
5464
- var middleX = getX(middle)
5465
- if (middleX > x) {to = middle; toX = middleX; if (toOutside = wrongLine) { toX += 1000; } dist = step}
5466
- else {from = middle; fromX = middleX; fromOutside = wrongLine; dist -= step}
5467
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5468
  }
5469
 
5470
  var measureText
@@ -5805,7 +4888,7 @@ function updateHeightsInViewport(cm) {
5805
  var display = cm.display
5806
  var prevBottom = display.lineDiv.offsetTop
5807
  for (var i = 0; i < display.view.length; i++) {
5808
- var cur = display.view[i], height = void 0
5809
  if (cur.hidden) { continue }
5810
  if (ie && ie_version < 8) {
5811
  var bot = cur.node.offsetTop + cur.node.offsetHeight
@@ -6010,7 +5093,7 @@ function measureForScrollbars(cm) {
6010
  }
6011
  }
6012
 
6013
- function NativeScrollbars(place, scroll, cm) {
6014
  this.cm = cm
6015
  var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar")
6016
  var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar")
@@ -6026,91 +5109,92 @@ function NativeScrollbars(place, scroll, cm) {
6026
  this.checkedZeroWidth = false
6027
  // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
6028
  if (ie && ie_version < 8) { this.horiz.style.minHeight = this.vert.style.minWidth = "18px" }
6029
- }
6030
 
6031
- NativeScrollbars.prototype = copyObj({
6032
- update: function(measure) {
6033
- var needsH = measure.scrollWidth > measure.clientWidth + 1
6034
- var needsV = measure.scrollHeight > measure.clientHeight + 1
6035
- var sWidth = measure.nativeBarWidth
 
 
 
 
 
 
 
 
 
 
 
6036
 
6037
- if (needsV) {
6038
- this.vert.style.display = "block"
6039
- this.vert.style.bottom = needsH ? sWidth + "px" : "0"
6040
- var totalHeight = measure.viewHeight - (needsH ? sWidth : 0)
6041
- // A bug in IE8 can cause this value to be negative, so guard it.
6042
- this.vert.firstChild.style.height =
6043
- Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px"
6044
- } else {
6045
- this.vert.style.display = ""
6046
- this.vert.firstChild.style.height = "0"
6047
- }
6048
 
6049
- if (needsH) {
6050
- this.horiz.style.display = "block"
6051
- this.horiz.style.right = needsV ? sWidth + "px" : "0"
6052
- this.horiz.style.left = measure.barLeft + "px"
6053
- var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0)
6054
- this.horiz.firstChild.style.width =
6055
- (measure.scrollWidth - measure.clientWidth + totalWidth) + "px"
6056
- } else {
6057
- this.horiz.style.display = ""
6058
- this.horiz.firstChild.style.width = "0"
6059
- }
6060
 
6061
- if (!this.checkedZeroWidth && measure.clientHeight > 0) {
6062
- if (sWidth == 0) { this.zeroWidthHack() }
6063
- this.checkedZeroWidth = true
6064
- }
6065
 
6066
- return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0}
6067
- },
6068
- setScrollLeft: function(pos) {
6069
- if (this.horiz.scrollLeft != pos) { this.horiz.scrollLeft = pos }
6070
- if (this.disableHoriz) { this.enableZeroWidthBar(this.horiz, this.disableHoriz) }
6071
- },
6072
- setScrollTop: function(pos) {
6073
- if (this.vert.scrollTop != pos) { this.vert.scrollTop = pos }
6074
- if (this.disableVert) { this.enableZeroWidthBar(this.vert, this.disableVert) }
6075
- },
6076
- zeroWidthHack: function() {
6077
- var w = mac && !mac_geMountainLion ? "12px" : "18px"
6078
- this.horiz.style.height = this.vert.style.width = w
6079
- this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none"
6080
- this.disableHoriz = new Delayed
6081
- this.disableVert = new Delayed
6082
- },
6083
- enableZeroWidthBar: function(bar, delay) {
6084
- bar.style.pointerEvents = "auto"
6085
- function maybeDisable() {
6086
- // To find out whether the scrollbar is still visible, we
6087
- // check whether the element under the pixel in the bottom
6088
- // left corner of the scrollbar box is the scrollbar box
6089
- // itself (when the bar is still visible) or its filler child
6090
- // (when the bar is hidden). If it is still visible, we keep
6091
- // it enabled, if it's hidden, we disable pointer events.
6092
- var box = bar.getBoundingClientRect()
6093
- var elt = document.elementFromPoint(box.left + 1, box.bottom - 1)
6094
- if (elt != bar) { bar.style.pointerEvents = "none" }
6095
- else { delay.set(1000, maybeDisable) }
6096
- }
6097
- delay.set(1000, maybeDisable)
6098
- },
6099
- clear: function() {
6100
- var parent = this.horiz.parentNode
6101
- parent.removeChild(this.horiz)
6102
- parent.removeChild(this.vert)
6103
- }
6104
- }, NativeScrollbars.prototype)
 
6105
 
6106
- function NullScrollbars() {}
6107
 
6108
- NullScrollbars.prototype = copyObj({
6109
- update: function() { return {bottom: 0, right: 0} },
6110
- setScrollLeft: function() {},
6111
- setScrollTop: function() {},
6112
- clear: function() {}
6113
- }, NullScrollbars.prototype)
6114
 
6115
  function updateScrollbars(cm, measure) {
6116
  if (!measure) { measure = measureForScrollbars(cm) }
@@ -6689,7 +5773,7 @@ function highlightWorker(cm) {
6689
 
6690
  // DISPLAY DRAWING
6691
 
6692
- function DisplayUpdate(cm, viewport, force) {
6693
  var display = cm.display
6694
 
6695
  this.viewport = viewport
@@ -6702,18 +5786,18 @@ function DisplayUpdate(cm, viewport, force) {
6702
  this.force = force
6703
  this.dims = getDimensions(cm)
6704
  this.events = []
6705
- }
6706
 
6707
- DisplayUpdate.prototype.signal = function(emitter, type) {
6708
  if (hasHandler(emitter, type))
6709
  { this.events.push(arguments) }
6710
- }
6711
- DisplayUpdate.prototype.finish = function() {
6712
- var this$1 = this;
6713
 
6714
  for (var i = 0; i < this.events.length; i++)
6715
  { signal.apply(null, this$1.events[i]) }
6716
- }
6717
 
6718
  function maybeClipScrollbars(cm) {
6719
  var display = cm.display
@@ -6935,63 +6019,61 @@ function setGuttersForLineNumbers(options) {
6935
  // (and non-touching) ranges, sorted, and an integer that indicates
6936
  // which one is the primary selection (the one that's scrolled into
6937
  // view, that getCursor returns, etc).
6938
- function Selection(ranges, primIndex) {
6939
  this.ranges = ranges
6940
  this.primIndex = primIndex
6941
- }
 
 
6942
 
6943
- Selection.prototype = {
6944
- primary: function() { return this.ranges[this.primIndex] },
6945
- equals: function(other) {
6946
  var this$1 = this;
6947
 
6948
- if (other == this) { return true }
6949
- if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) { return false }
6950
- for (var i = 0; i < this.ranges.length; i++) {
6951
- var here = this$1.ranges[i], there = other.ranges[i]
6952
- if (cmp(here.anchor, there.anchor) != 0 || cmp(here.head, there.head) != 0) { return false }
6953
- }
6954
- return true
6955
- },
6956
- deepCopy: function() {
 
6957
  var this$1 = this;
6958
 
6959
- var out = []
6960
- for (var i = 0; i < this.ranges.length; i++)
6961
- { out[i] = new Range(copyPos(this$1.ranges[i].anchor), copyPos(this$1.ranges[i].head)) }
6962
- return new Selection(out, this.primIndex)
6963
- },
6964
- somethingSelected: function() {
 
6965
  var this$1 = this;
6966
 
6967
- for (var i = 0; i < this.ranges.length; i++)
6968
- { if (!this$1.ranges[i].empty()) { return true } }
6969
- return false
6970
- },
6971
- contains: function(pos, end) {
 
6972
  var this$1 = this;
6973
 
6974
- if (!end) { end = pos }
6975
- for (var i = 0; i < this.ranges.length; i++) {
6976
- var range = this$1.ranges[i]
6977
- if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0)
6978
- { return i }
6979
- }
6980
- return -1
6981
  }
6982
- }
 
6983
 
6984
- function Range(anchor, head) {
6985
  this.anchor = anchor; this.head = head
6986
- }
6987
 
6988
- Range.prototype = {
6989
- from: function() { return minPos(this.anchor, this.head) },
6990
- to: function() { return maxPos(this.anchor, this.head) },
6991
- empty: function() {
6992
- return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch
6993
- }
6994
- }
6995
 
6996
  // Take an unsorted, potentially overlapping set of ranges, and
6997
  // build a selection out of it. 'Consumes' ranges array (modifying
@@ -7386,7 +6468,7 @@ function copyHistoryArray(events, newGroup, instantiateSel) {
7386
  var changes = event.changes, newChanges = []
7387
  copy.push({changes: newChanges})
7388
  for (var j = 0; j < changes.length; ++j) {
7389
- var change = changes[j], m = void 0
7390
  newChanges.push({from: change.from, to: change.to, text: change.text})
7391
  if (newGroup) { for (var prop in change) { if (m = prop.match(/^spans_(\d+)$/)) {
7392
  if (indexOf(newGroup, Number(m[1])) > -1) {
@@ -7552,7 +6634,7 @@ function skipAtomicInner(doc, pos, oldPos, dir, mayClear) {
7552
  if (!m.atomic) { continue }
7553
 
7554
  if (oldPos) {
7555
- var near = m.find(dir < 0 ? 1 : -1), diff = void 0
7556
  if (dir < 0 ? m.inclusiveRight : m.inclusiveLeft)
7557
  { near = movePos(doc, near, -dir, near && near.line == pos.line ? line : null) }
7558
  if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0))
@@ -7930,7 +7012,7 @@ function changeLine(doc, handle, changeType, op) {
7930
  //
7931
  // See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html
7932
 
7933
- function LeafChunk(lines) {
7934
  var this$1 = this;
7935
 
7936
  this.lines = lines
@@ -7941,45 +7023,47 @@ function LeafChunk(lines) {
7941
  height += lines[i].height
7942
  }
7943
  this.height = height
7944
- }
 
 
7945
 
7946
- LeafChunk.prototype = {
7947
- chunkSize: function() { return this.lines.length },
7948
- // Remove the n lines at offset 'at'.
7949
- removeInner: function(at, n) {
7950
  var this$1 = this;
7951
 
7952
- for (var i = at, e = at + n; i < e; ++i) {
7953
- var line = this$1.lines[i]
7954
- this$1.height -= line.height
7955
- cleanUpLine(line)
7956
- signalLater(line, "delete")
7957
- }
7958
- this.lines.splice(at, n)
7959
- },
7960
- // Helper used to collapse a small branch into a single leaf.
7961
- collapse: function(lines) {
7962
- lines.push.apply(lines, this.lines)
7963
- },
7964
- // Insert the given array of lines at offset 'at', count them as
7965
- // having the given height.
7966
- insertInner: function(at, lines, height) {
 
 
7967
  var this$1 = this;
7968
 
7969
- this.height += height
7970
- this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at))
7971
- for (var i = 0; i < lines.length; ++i) { lines[i].parent = this$1 }
7972
- },
7973
- // Used to iterate over a part of the tree.
7974
- iterN: function(at, n, op) {
 
7975
  var this$1 = this;
7976
 
7977
- for (var e = at + n; at < e; ++at)
7978
- { if (op(this$1.lines[at])) { return true } }
7979
- }
7980
- }
7981
 
7982
- function BranchChunk(children) {
7983
  var this$1 = this;
7984
 
7985
  this.children = children
@@ -7992,123 +7076,120 @@ function BranchChunk(children) {
7992
  this.size = size
7993
  this.height = height
7994
  this.parent = null
7995
- }
 
 
7996
 
7997
- BranchChunk.prototype = {
7998
- chunkSize: function() { return this.size },
7999
- removeInner: function(at, n) {
8000
  var this$1 = this;
8001
 
8002
- this.size -= n
8003
- for (var i = 0; i < this.children.length; ++i) {
8004
- var child = this$1.children[i], sz = child.chunkSize()
8005
- if (at < sz) {
8006
- var rm = Math.min(n, sz - at), oldHeight = child.height
8007
- child.removeInner(at, rm)
8008
- this$1.height -= oldHeight - child.height
8009
- if (sz == rm) { this$1.children.splice(i--, 1); child.parent = null }
8010
- if ((n -= rm) == 0) { break }
8011
- at = 0
8012
- } else { at -= sz }
8013
- }
8014
- // If the result is smaller than 25 lines, ensure that it is a
8015
- // single leaf node.
8016
- if (this.size - n < 25 &&
8017
- (this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) {
8018
- var lines = []
8019
- this.collapse(lines)
8020
- this.children = [new LeafChunk(lines)]
8021
- this.children[0].parent = this
8022
- }
8023
- },
8024
- collapse: function(lines) {
 
8025
  var this$1 = this;
8026
 
8027
- for (var i = 0; i < this.children.length; ++i) { this$1.children[i].collapse(lines) }
8028
- },
8029
- insertInner: function(at, lines, height) {
 
8030
  var this$1 = this;
8031
 
8032
- this.size += lines.length
8033
- this.height += height
8034
- for (var i = 0; i < this.children.length; ++i) {
8035
- var child = this$1.children[i], sz = child.chunkSize()
8036
- if (at <= sz) {
8037
- child.insertInner(at, lines, height)
8038
- if (child.lines && child.lines.length > 50) {
8039
- // To avoid memory thrashing when child.lines is huge (e.g. first view of a large file), it's never spliced.
8040
- // Instead, small slices are taken. They're taken in order because sequential memory accesses are fastest.
8041
- var remaining = child.lines.length % 25 + 25
8042
- for (var pos = remaining; pos < child.lines.length;) {
8043
- var leaf = new LeafChunk(child.lines.slice(pos, pos += 25))
8044
- child.height -= leaf.height
8045
- this$1.children.splice(++i, 0, leaf)
8046
- leaf.parent = this$1
8047
- }
8048
- child.lines = child.lines.slice(0, remaining)
8049
- this$1.maybeSpill()
8050
  }
8051
- break
 
8052
  }
8053
- at -= sz
8054
  }
8055
- },
8056
- // When a node has grown, check whether it should be split.
8057
- maybeSpill: function() {
8058
- if (this.children.length <= 10) { return }
8059
- var me = this
8060
- do {
8061
- var spilled = me.children.splice(me.children.length - 5, 5)
8062
- var sibling = new BranchChunk(spilled)
8063
- if (!me.parent) { // Become the parent node
8064
- var copy = new BranchChunk(me.children)
8065
- copy.parent = me
8066
- me.children = [copy, sibling]
8067
- me = copy
8068
- } else {
8069
- me.size -= sibling.size
8070
- me.height -= sibling.height
8071
- var myIndex = indexOf(me.parent.children, me)
8072
- me.parent.children.splice(myIndex + 1, 0, sibling)
8073
- }
8074
- sibling.parent = me.parent
8075
- } while (me.children.length > 10)
8076
- me.parent.maybeSpill()
8077
- },
8078
- iterN: function(at, n, op) {
 
 
 
 
8079
  var this$1 = this;
8080
 
8081
- for (var i = 0; i < this.children.length; ++i) {
8082
- var child = this$1.children[i], sz = child.chunkSize()
8083
- if (at < sz) {
8084
- var used = Math.min(n, sz - at)
8085
- if (child.iterN(at, used, op)) { return true }
8086
- if ((n -= used) == 0) { break }
8087
- at = 0
8088
- } else { at -= sz }
8089
- }
8090
  }
8091
- }
8092
 
8093
  // Line widgets are block elements displayed above or below a line.
8094
 
8095
- function LineWidget(doc, node, options) {
8096
  var this$1 = this;
8097
 
8098
  if (options) { for (var opt in options) { if (options.hasOwnProperty(opt))
8099
  { this$1[opt] = options[opt] } } }
8100
  this.doc = doc
8101
  this.node = node
8102
- }
8103
- eventMixin(LineWidget)
8104
-
8105
- function adjustScrollWhenAboveVisible(cm, line, diff) {
8106
- if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop))
8107
- { addToScrollPos(cm, null, diff) }
8108
- }
8109
 
8110
- LineWidget.prototype.clear = function() {
8111
- var this$1 = this;
8112
 
8113
  var cm = this.doc.cm, ws = this.line.widgets, line = this.line, no = lineNo(line)
8114
  if (no == null || !ws) { return }
@@ -8116,21 +7197,36 @@ LineWidget.prototype.clear = function() {
8116
  if (!ws.length) { line.widgets = null }
8117
  var height = widgetHeight(this)
8118
  updateLineHeight(line, Math.max(0, line.height - height))
8119
- if (cm) { runInOp(cm, function () {
8120
- adjustScrollWhenAboveVisible(cm, line, -height)
8121
- regLineChange(cm, no, "widget")
8122
- }) }
8123
- }
8124
- LineWidget.prototype.changed = function() {
 
 
 
 
 
 
8125
  var oldH = this.height, cm = this.doc.cm, line = this.line
8126
  this.height = null
8127
  var diff = widgetHeight(this) - oldH
8128
  if (!diff) { return }
8129
  updateLineHeight(line, line.height + diff)
8130
- if (cm) { runInOp(cm, function () {
8131
- cm.curOp.forceUpdate = true
8132
- adjustScrollWhenAboveVisible(cm, line, diff)
8133
- }) }
 
 
 
 
 
 
 
 
 
8134
  }
8135
 
8136
  function addLineWidget(doc, handle, node, options) {
@@ -8150,6 +7246,7 @@ function addLineWidget(doc, handle, node, options) {
8150
  }
8151
  return true
8152
  })
 
8153
  return widget
8154
  }
8155
 
@@ -8170,17 +7267,16 @@ function addLineWidget(doc, handle, node, options) {
8170
  // when they overlap (they may nest, but not partially overlap).
8171
  var nextMarkerId = 0
8172
 
8173
- function TextMarker(doc, type) {
8174
  this.lines = []
8175
  this.type = type
8176
  this.doc = doc
8177
  this.id = ++nextMarkerId
8178
- }
8179
- eventMixin(TextMarker)
8180
 
8181
  // Clear the marker.
8182
- TextMarker.prototype.clear = function() {
8183
- var this$1 = this;
8184
 
8185
  if (this.explicitlyCleared) { return }
8186
  var cm = this.doc.cm, withOp = cm && !cm.curOp
@@ -8218,18 +7314,18 @@ TextMarker.prototype.clear = function() {
8218
  this.doc.cantEdit = false
8219
  if (cm) { reCheckSelection(cm.doc) }
8220
  }
8221
- if (cm) { signalLater(cm, "markerCleared", cm, this) }
8222
  if (withOp) { endOperation(cm) }
8223
  if (this.parent) { this.parent.clear() }
8224
- }
8225
 
8226
  // Find the position of the marker in the document. Returns a {from,
8227
  // to} object by default. Side can be passed to get a specific side
8228
  // -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the
8229
  // Pos objects returned contain a line object, rather than a line
8230
  // number (used to prevent looking up the same line twice).
8231
- TextMarker.prototype.find = function(side, lineObj) {
8232
- var this$1 = this;
8233
 
8234
  if (side == null && this.type == "bookmark") { side = 1 }
8235
  var from, to
@@ -8246,11 +7342,13 @@ TextMarker.prototype.find = function(side, lineObj) {
8246
  }
8247
  }
8248
  return from && {from: from, to: to}
8249
- }
8250
 
8251
  // Signals that the marker's widget changed, and surrounding layout
8252
  // should be recomputed.
8253
- TextMarker.prototype.changed = function() {
 
 
8254
  var pos = this.find(-1, true), widget = this, cm = this.doc.cm
8255
  if (!pos || !cm) { return }
8256
  runInOp(cm, function () {
@@ -8268,24 +7366,27 @@ TextMarker.prototype.changed = function() {
8268
  if (dHeight)
8269
  { updateLineHeight(line, line.height + dHeight) }
8270
  }
 
8271
  })
8272
- }
8273
 
8274
- TextMarker.prototype.attachLine = function(line) {
8275
  if (!this.lines.length && this.doc.cm) {
8276
  var op = this.doc.cm.curOp
8277
  if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1)
8278
  { (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this) }
8279
  }
8280
  this.lines.push(line)
8281
- }
8282
- TextMarker.prototype.detachLine = function(line) {
 
8283
  this.lines.splice(indexOf(this.lines, line), 1)
8284
  if (!this.lines.length && this.doc.cm) {
8285
  var op = this.doc.cm.curOp
8286
  ;(op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this)
8287
  }
8288
- }
 
8289
 
8290
  // Create a marker, wire it up to the right lines, and
8291
  function markText(doc, from, to, options, type) {
@@ -8305,6 +7406,7 @@ function markText(doc, from, to, options, type) {
8305
  // Showing up as a widget implies collapsed (widget replaces text)
8306
  marker.collapsed = true
8307
  marker.widgetNode = elt("span", [marker.replacedWith], "CodeMirror-widget")
 
8308
  if (!options.handleMouseEvents) { marker.widgetNode.setAttribute("cm-ignore-events", "true") }
8309
  if (options.insertLeft) { marker.widgetNode.insertLeft = true }
8310
  }
@@ -8362,28 +7464,29 @@ function markText(doc, from, to, options, type) {
8362
  // A shared marker spans multiple linked documents. It is
8363
  // implemented as a meta-marker-object controlling multiple normal
8364
  // markers.
8365
- function SharedTextMarker(markers, primary) {
8366
  var this$1 = this;
8367
 
8368
  this.markers = markers
8369
  this.primary = primary
8370
  for (var i = 0; i < markers.length; ++i)
8371
  { markers[i].parent = this$1 }
8372
- }
8373
- eventMixin(SharedTextMarker)
8374
 
8375
- SharedTextMarker.prototype.clear = function() {
8376
- var this$1 = this;
8377
 
8378
  if (this.explicitlyCleared) { return }
8379
  this.explicitlyCleared = true
8380
  for (var i = 0; i < this.markers.length; ++i)
8381
  { this$1.markers[i].clear() }
8382
  signalLater(this, "clear")
8383
- }
8384
- SharedTextMarker.prototype.find = function(side, lineObj) {
 
8385
  return this.primary.find(side, lineObj)
8386
- }
 
8387
 
8388
  function markTextShared(doc, from, to, options, type) {
8389
  options = copyObj(options)
@@ -8640,6 +7743,45 @@ Doc.prototype = createObj(BranchChunk.prototype, {
8640
  hist.undone = copyHistoryArray(histData.undone.slice(0), null, true)
8641
  },
8642
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8643
  addLineClass: docMethodOp(function(handle, where, cls) {
8644
  return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function (line) {
8645
  var prop = where == "text" ? "textClass"
@@ -9049,7 +8191,7 @@ function normalizeKeyMap(keymap) {
9049
 
9050
  var keys = map(keyname.split(" "), normalizeKeyName)
9051
  for (var i = 0; i < keys.length; i++) {
9052
- var val = void 0, name = void 0
9053
  if (i == keys.length - 1) {
9054
  name = keys.join(" ")
9055
  val = value
@@ -9279,19 +8421,13 @@ function lineStart(cm, lineN) {
9279
  var line = getLine(cm.doc, lineN)
9280
  var visual = visualLine(line)
9281
  if (visual != line) { lineN = lineNo(visual) }
9282
- var order = getOrder(visual)
9283
- var ch = !order ? 0 : order[0].level % 2 ? lineRight(visual) : lineLeft(visual)
9284
- return Pos(lineN, ch)
9285
  }
9286
  function lineEnd(cm, lineN) {
9287
- var merged, line = getLine(cm.doc, lineN)
9288
- while (merged = collapsedSpanAtEnd(line)) {
9289
- line = merged.find(1, true).line
9290
- lineN = null
9291
- }
9292
- var order = getOrder(line)
9293
- var ch = !order ? line.text.length : order[0].level % 2 ? lineLeft(line) : lineRight(line)
9294
- return Pos(lineN == null ? lineNo(line) : lineN, ch)
9295
  }
9296
  function lineStartSmart(cm, pos) {
9297
  var start = lineStart(cm, pos.line)
@@ -9300,7 +8436,7 @@ function lineStartSmart(cm, pos) {
9300
  if (!order || order[0].level == 0) {
9301
  var firstNonWS = Math.max(0, line.text.search(/\S/))
9302
  var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch
9303
- return Pos(start.line, inWS ? 0 : firstNonWS)
9304
  }
9305
  return start
9306
  }
@@ -9454,6 +8590,7 @@ function onKeyPress(e) {
9454
  function onMouseDown(e) {
9455
  var cm = this, display = cm.display
9456
  if (signalDOMEvent(cm, e) || display.activeTouch && display.input.supportsTouch()) { return }
 
9457
  display.shift = e.shiftKey
9458
 
9459
  if (eventInWidget(display, e)) {
@@ -9799,7 +8936,7 @@ function defineOptions(CodeMirror) {
9799
  for (var i = newBreaks.length - 1; i >= 0; i--)
9800
  { replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)) }
9801
  })
9802
- option("specialChars", /[\u0000-\u001f\u007f\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g, function (cm, val, old) {
9803
  cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g")
9804
  if (old != Init) { cm.refresh() }
9805
  })
@@ -9889,7 +9026,7 @@ function defineOptions(CodeMirror) {
9889
  function guttersChanged(cm) {
9890
  updateGutters(cm)
9891
  regChange(cm)
9892
- setTimeout(function () { return alignHorizontally(cm); }, 20)
9893
  }
9894
 
9895
  function dragDropChanged(cm, value, old) {
@@ -9944,7 +9081,6 @@ function CodeMirror(place, options) {
9944
  themeChanged(this)
9945
  if (options.lineWrapping)
9946
  { this.display.wrapper.className += " CodeMirror-wrap" }
9947
- if (options.autofocus && !mobile) { display.input.focus() }
9948
  initScrollbars(this)
9949
 
9950
  this.state = {
@@ -9963,6 +9099,8 @@ function CodeMirror(place, options) {
9963
  specialChars: null
9964
  }
9965
 
 
 
9966
  // Override magic textarea content restore that IE sometimes does
9967
  // on our hidden textarea on reload
9968
  if (ie && ie_version < 11) { setTimeout(function () { return this$1.display.input.reset(true); }, 20) }
@@ -10039,6 +9177,7 @@ function registerEventHandlers(cm) {
10039
  }
10040
  on(d.scroller, "touchstart", function (e) {
10041
  if (!signalDOMEvent(cm, e) && !isMouseLikeTouchEvent(e)) {
 
10042
  clearTimeout(touchFinished)
10043
  var now = +new Date
10044
  d.activeTouch = {start: now, moved: false,
@@ -10317,6 +9456,7 @@ function addEditorMethods(CodeMirror) {
10317
  options[option] = value
10318
  if (optionHandlers.hasOwnProperty(option))
10319
  { operation(this, optionHandlers[option])(this, value, old) }
 
10320
  },
10321
 
10322
  getOption: function(option) {return this.options[option]},
@@ -10478,7 +9618,7 @@ function addEditorMethods(CodeMirror) {
10478
  height = fromCoordSystem(this, {top: height, left: 0}, mode || "page").top
10479
  return lineAtHeight(this.doc, height + this.display.viewOffset)
10480
  },
10481
- heightAtLine: function(line, mode) {
10482
  var end = false, lineObj
10483
  if (typeof line == "number") {
10484
  var last = this.doc.first + this.doc.size - 1
@@ -10488,52 +9628,13 @@ function addEditorMethods(CodeMirror) {
10488
  } else {
10489
  lineObj = line
10490
  }
10491
- return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page").top +
10492
  (end ? this.doc.height - heightAtLine(lineObj) : 0)
10493
  },
10494
 
10495
  defaultTextHeight: function() { return textHeight(this.display) },
10496
  defaultCharWidth: function() { return charWidth(this.display) },
10497
 
10498
- setGutterMarker: methodOp(function(line, gutterID, value) {
10499
- return changeLine(this.doc, line, "gutter", function (line) {
10500
- var markers = line.gutterMarkers || (line.gutterMarkers = {})
10501
- markers[gutterID] = value
10502
- if (!value && isEmpty(markers)) { line.gutterMarkers = null }
10503
- return true
10504
- })
10505
- }),
10506
-
10507
- clearGutter: methodOp(function(gutterID) {
10508
- var this$1 = this;
10509
-
10510
- var doc = this.doc, i = doc.first
10511
- doc.iter(function (line) {
10512
- if (line.gutterMarkers && line.gutterMarkers[gutterID]) {
10513
- line.gutterMarkers[gutterID] = null
10514
- regLineChange(this$1, i, "gutter")
10515
- if (isEmpty(line.gutterMarkers)) { line.gutterMarkers = null }
10516
- }
10517
- ++i
10518
- })
10519
- }),
10520
-
10521
- lineInfo: function(line) {
10522
- var n
10523
- if (typeof line == "number") {
10524
- if (!isLine(this.doc, line)) { return null }
10525
- n = line
10526
- line = getLine(this.doc, line)
10527
- if (!line) { return null }
10528
- } else {
10529
- n = lineNo(line)
10530
- if (n == null) { return null }
10531
- }
10532
- return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers,
10533
- textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass,
10534
- widgets: line.widgets}
10535
- },
10536
-
10537
  getViewport: function() { return {from: this.display.viewFrom, to: this.display.viewTo}},
10538
 
10539
  addWidget: function(pos, node, scroll, vert, horiz) {
@@ -10659,7 +9760,7 @@ function addEditorMethods(CodeMirror) {
10659
  var start = pos.ch, end = pos.ch
10660
  if (line) {
10661
  var helper = this.getHelper(pos, "wordChars")
10662
- if ((pos.xRel < 0 || end == line.length) && start) { --start; } else { ++end }
10663
  var startChar = line.charAt(start)
10664
  var check = isWordChar(startChar, helper)
10665
  ? function (ch) { return isWordChar(ch, helper); }
@@ -10790,22 +9891,30 @@ function addEditorMethods(CodeMirror) {
10790
  // position. The resulting position will have a hitSide=true
10791
  // property if it reached the end of the document.
10792
  function findPosH(doc, pos, dir, unit, visually) {
10793
- var line = pos.line, ch = pos.ch, origDir = dir
10794
- var lineObj = getLine(doc, line)
 
10795
  function findNextLine() {
10796
- var l = line + dir
10797
  if (l < doc.first || l >= doc.first + doc.size) { return false }
10798
- line = l
10799
  return lineObj = getLine(doc, l)
10800
  }
10801
  function moveOnce(boundToLine) {
10802
- var next = (visually ? moveVisually : moveLogically)(lineObj, ch, dir, true)
 
 
 
 
 
10803
  if (next == null) {
10804
- if (!boundToLine && findNextLine()) {
10805
- if (visually) { ch = (dir < 0 ? lineRight : lineLeft)(lineObj) }
10806
- else { ch = dir < 0 ? lineObj.text.length : 0 }
10807
- } else { return false }
10808
- } else { ch = next }
 
 
10809
  return true
10810
  }
10811
 
@@ -10818,14 +9927,14 @@ function findPosH(doc, pos, dir, unit, visually) {
10818
  var helper = doc.cm && doc.cm.getHelper(pos, "wordChars")
10819
  for (var first = true;; first = false) {
10820
  if (dir < 0 && !moveOnce(!first)) { break }
10821
- var cur = lineObj.text.charAt(ch) || "\n"
10822
  var type = isWordChar(cur, helper) ? "w"
10823
  : group && cur == "\n" ? "n"
10824
  : !group || /\s/.test(cur) ? null
10825
  : "p"
10826
  if (group && !first && !type) { type = "s" }
10827
  if (sawType && sawType != type) {
10828
- if (dir < 0) {dir = 1; moveOnce()}
10829
  break
10830
  }
10831
 
@@ -10833,8 +9942,8 @@ function findPosH(doc, pos, dir, unit, visually) {
10833
  if (dir > 0 && !moveOnce(!first)) { break }
10834
  }
10835
  }
10836
- var result = skipAtomic(doc, Pos(line, ch), pos, origDir, true)
10837
- if (!cmp(pos, result)) { result.hitSide = true }
10838
  return result
10839
  }
10840
 
@@ -10863,325 +9972,334 @@ function findPosV(cm, pos, dir, unit) {
10863
 
10864
  // CONTENTEDITABLE INPUT STYLE
10865
 
10866
- function ContentEditableInput(cm) {
10867
  this.cm = cm
10868
  this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null
10869
  this.polling = new Delayed()
 
10870
  this.gracePeriod = false
10871
- }
 
10872
 
10873
- ContentEditableInput.prototype = copyObj({
10874
- init: function(display) {
10875
- var input = this, cm = input.cm
10876
- var div = input.div = display.lineDiv
10877
- disableBrowserMagic(div, cm.options.spellcheck)
10878
 
10879
- on(div, "paste", function (e) {
10880
- if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }
10881
- // IE doesn't fire input events, so we schedule a read for the pasted content in this way
10882
- if (ie_version <= 11) { setTimeout(operation(cm, function () {
10883
- if (!input.pollContent()) { regChange(cm) }
10884
- }), 20) }
10885
- })
10886
 
10887
- on(div, "compositionstart", function (e) {
10888
- var data = e.data
10889
- input.composing = {sel: cm.doc.sel, data: data, startData: data}
10890
- if (!data) { return }
10891
- var prim = cm.doc.sel.primary()
10892
- var line = cm.getLine(prim.head.line)
10893
- var found = line.indexOf(data, Math.max(0, prim.head.ch - data.length))
10894
- if (found > -1 && found <= prim.head.ch)
10895
- { input.composing.sel = simpleSelection(Pos(prim.head.line, found),
10896
- Pos(prim.head.line, found + data.length)) }
10897
- })
10898
- on(div, "compositionupdate", function (e) { return input.composing.data = e.data; })
10899
- on(div, "compositionend", function (e) {
10900
- var ours = input.composing
10901
- if (!ours) { return }
10902
- if (e.data != ours.startData && !/\u200b/.test(e.data))
10903
- { ours.data = e.data }
10904
- // Need a small delay to prevent other code (input event,
10905
- // selection polling) from doing damage when fired right after
10906
- // compositionend.
10907
- setTimeout(function () {
10908
- if (!ours.handled)
10909
- { input.applyComposition(ours) }
10910
- if (input.composing == ours)
10911
- { input.composing = null }
10912
- }, 50)
10913
- })
10914
 
10915
- on(div, "touchstart", function () { return input.forceCompositionEnd(); })
 
 
 
 
 
 
 
 
 
 
 
10916
 
10917
- on(div, "input", function () {
10918
- if (input.composing) { return }
10919
- if (cm.isReadOnly() || !input.pollContent())
10920
- { runInOp(input.cm, function () { return regChange(cm); }) }
10921
- })
10922
 
10923
- function onCopyCut(e) {
10924
- if (signalDOMEvent(cm, e)) { return }
10925
- if (cm.somethingSelected()) {
10926
- setLastCopied({lineWise: false, text: cm.getSelections()})
10927
- if (e.type == "cut") { cm.replaceSelection("", null, "cut") }
10928
- } else if (!cm.options.lineWiseCopyCut) {
10929
- return
10930
- } else {
10931
- var ranges = copyableRanges(cm)
10932
- setLastCopied({lineWise: true, text: ranges.text})
10933
- if (e.type == "cut") {
10934
- cm.operation(function () {
10935
- cm.setSelections(ranges.ranges, 0, sel_dontScroll)
10936
- cm.replaceSelection("", null, "cut")
10937
- })
10938
- }
 
 
 
10939
  }
10940
- if (e.clipboardData) {
10941
- e.clipboardData.clearData()
10942
- var content = lastCopied.text.join("\n")
10943
- // iOS exposes the clipboard API, but seems to discard content inserted into it
10944
- e.clipboardData.setData("Text", content)
10945
- if (e.clipboardData.getData("Text") == content) {
10946
- e.preventDefault()
10947
- return
10948
- }
10949
  }
10950
- // Old-fashioned briefly-focus-a-textarea hack
10951
- var kludge = hiddenTextarea(), te = kludge.firstChild
10952
- cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild)
10953
- te.value = lastCopied.text.join("\n")
10954
- var hadFocus = document.activeElement
10955
- selectInput(te)
10956
- setTimeout(function () {
10957
- cm.display.lineSpace.removeChild(kludge)
10958
- hadFocus.focus()
10959
- if (hadFocus == div) { input.showPrimarySelection() }
10960
- }, 50)
10961
  }
10962
- on(div, "copy", onCopyCut)
10963
- on(div, "cut", onCopyCut)
10964
- },
 
 
 
 
 
 
 
 
 
 
 
 
10965
 
10966
- prepareSelection: function() {
10967
- var result = prepareSelection(this.cm, false)
10968
- result.focus = this.cm.state.focused
10969
- return result
10970
- },
10971
 
10972
- showSelection: function(info, takeFocus) {
10973
- if (!info || !this.cm.display.view.length) { return }
10974
- if (info.focus || takeFocus) { this.showPrimarySelection() }
10975
- this.showMultipleSelections(info)
10976
- },
10977
 
10978
- showPrimarySelection: function() {
10979
- var sel = window.getSelection(), prim = this.cm.doc.sel.primary()
10980
- var curAnchor = domToPos(this.cm, sel.anchorNode, sel.anchorOffset)
10981
- var curFocus = domToPos(this.cm, sel.focusNode, sel.focusOffset)
10982
- if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad &&
10983
- cmp(minPos(curAnchor, curFocus), prim.from()) == 0 &&
10984
- cmp(maxPos(curAnchor, curFocus), prim.to()) == 0)
10985
- { return }
10986
-
10987
- var start = posToDOM(this.cm, prim.from())
10988
- var end = posToDOM(this.cm, prim.to())
10989
- if (!start && !end) { return }
10990
-
10991
- var view = this.cm.display.view
10992
- var old = sel.rangeCount && sel.getRangeAt(0)
10993
- if (!start) {
10994
- start = {node: view[0].measure.map[2], offset: 0}
10995
- } else if (!end) { // FIXME dangerously hacky
10996
- var measure = view[view.length - 1].measure
10997
- var map = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map
10998
- end = {node: map[map.length - 1], offset: map[map.length - 2] - map[map.length - 3]}
10999
- }
11000
-
11001
- var rng
11002
- try { rng = range(start.node, start.offset, end.offset, end.node) }
11003
- catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible
11004
- if (rng) {
11005
- if (!gecko && this.cm.state.focused) {
11006
- sel.collapse(start.node, start.offset)
11007
- if (!rng.collapsed) {
11008
- sel.removeAllRanges()
11009
- sel.addRange(rng)
11010
- }
11011
- } else {
11012
  sel.removeAllRanges()
11013
  sel.addRange(rng)
11014
  }
11015
- if (old && sel.anchorNode == null) { sel.addRange(old) }
11016
- else if (gecko) { this.startGracePeriod() }
 
11017
  }
11018
- this.rememberSelection()
11019
- },
 
 
 
11020
 
11021
- startGracePeriod: function() {
11022
  var this$1 = this;
11023
 
11024
- clearTimeout(this.gracePeriod)
11025
- this.gracePeriod = setTimeout(function () {
11026
- this$1.gracePeriod = false
11027
- if (this$1.selectionChanged())
11028
- { this$1.cm.operation(function () { return this$1.cm.curOp.selectionChanged = true; }) }
11029
- }, 20)
11030
- },
11031
 
11032
- showMultipleSelections: function(info) {
11033
- removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors)
11034
- removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection)
11035
- },
11036
 
11037
- rememberSelection: function() {
11038
- var sel = window.getSelection()
11039
- this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset
11040
- this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset
11041
- },
11042
 
11043
- selectionInEditor: function() {
11044
- var sel = window.getSelection()
11045
- if (!sel.rangeCount) { return false }
11046
- var node = sel.getRangeAt(0).commonAncestorContainer
11047
- return contains(this.div, node)
11048
- },
11049
 
11050
- focus: function() {
11051
- if (this.cm.options.readOnly != "nocursor") { this.div.focus() }
11052
- },
11053
- blur: function() { this.div.blur() },
11054
- getField: function() { return this.div },
 
 
 
 
11055
 
11056
- supportsTouch: function() { return true },
11057
 
11058
- receivedFocus: function() {
11059
- var input = this
11060
- if (this.selectionInEditor())
11061
- { this.pollSelection() }
11062
- else
11063
- { runInOp(this.cm, function () { return input.cm.curOp.selectionChanged = true; }) }
11064
 
11065
- function poll() {
11066
- if (input.cm.state.focused) {
11067
- input.pollSelection()
11068
- input.polling.set(input.cm.options.pollInterval, poll)
11069
- }
11070
  }
11071
- this.polling.set(this.cm.options.pollInterval, poll)
11072
- },
 
11073
 
11074
- selectionChanged: function() {
11075
- var sel = window.getSelection()
11076
- return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset ||
11077
- sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset
11078
- },
11079
 
11080
- pollSelection: function() {
11081
- if (!this.composing && !this.gracePeriod && this.selectionChanged()) {
11082
- var sel = window.getSelection(), cm = this.cm
11083
- this.rememberSelection()
11084
- var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset)
11085
- var head = domToPos(cm, sel.focusNode, sel.focusOffset)
11086
- if (anchor && head) { runInOp(cm, function () {
11087
- setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll)
11088
- if (anchor.bad || head.bad) { cm.curOp.selectionChanged = true }
11089
- }) }
11090
- }
11091
- },
11092
 
11093
- pollContent: function() {
11094
- var cm = this.cm, display = cm.display, sel = cm.doc.sel.primary()
11095
- var from = sel.from(), to = sel.to()
11096
- if (from.line < display.viewFrom || to.line > display.viewTo - 1) { return false }
 
11097
 
11098
- var fromIndex, fromLine, fromNode
11099
- if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) {
11100
- fromLine = lineNo(display.view[0].line)
11101
- fromNode = display.view[0].node
11102
- } else {
11103
- fromLine = lineNo(display.view[fromIndex].line)
11104
- fromNode = display.view[fromIndex - 1].node.nextSibling
11105
- }
11106
- var toIndex = findViewIndex(cm, to.line)
11107
- var toLine, toNode
11108
- if (toIndex == display.view.length - 1) {
11109
- toLine = display.viewTo - 1
11110
- toNode = display.lineDiv.lastChild
11111
- } else {
11112
- toLine = lineNo(display.view[toIndex + 1].line) - 1
11113
- toNode = display.view[toIndex + 1].node.previousSibling
11114
- }
11115
-
11116
- var newText = cm.doc.splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine))
11117
- var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length))
11118
- while (newText.length > 1 && oldText.length > 1) {
11119
- if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine-- }
11120
- else if (newText[0] == oldText[0]) { newText.shift(); oldText.shift(); fromLine++ }
11121
- else { break }
11122
- }
11123
-
11124
- var cutFront = 0, cutEnd = 0
11125
- var newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length)
11126
- while (cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront))
11127
- { ++cutFront }
11128
- var newBot = lst(newText), oldBot = lst(oldText)
11129
- var maxCutEnd = Math.min(newBot.length - (newText.length == 1 ? cutFront : 0),
11130
- oldBot.length - (oldText.length == 1 ? cutFront : 0))
11131
- while (cutEnd < maxCutEnd &&
11132
- newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1))
11133
- { ++cutEnd }
11134
-
11135
- newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd)
11136
- newText[0] = newText[0].slice(cutFront)
11137
-
11138
- var chFrom = Pos(fromLine, cutFront)
11139
- var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0)
11140
- if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) {
11141
- replaceRange(cm.doc, newText, chFrom, chTo, "+input")
11142
- return true
11143
- }
11144
- },
11145
 
11146
- ensurePolled: function() {
11147
- this.forceCompositionEnd()
11148
- },
11149
- reset: function() {
11150
- this.forceCompositionEnd()
11151
- },
11152
- forceCompositionEnd: function() {
11153
- if (!this.composing || this.composing.handled) { return }
11154
- this.applyComposition(this.composing)
11155
- this.composing.handled = true
11156
- this.div.blur()
11157
- this.div.focus()
11158
- },
11159
- applyComposition: function(composing) {
11160
- if (this.cm.isReadOnly())
11161
- { operation(this.cm, regChange)(this.cm) }
11162
- else if (composing.data && composing.data != composing.startData)
11163
- { operation(this.cm, applyTextInput)(this.cm, composing.data, 0, composing.sel) }
11164
- },
11165
 
11166
- setUneditable: function(node) {
11167
- node.contentEditable = "false"
11168
- },
 
 
 
 
 
11169
 
11170
- onKeyPress: function(e) {
11171
- e.preventDefault()
11172
- if (!this.cm.isReadOnly())
11173
- { operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0) }
11174
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11175
 
11176
- readOnlyChanged: function(val) {
11177
- this.div.contentEditable = String(val != "nocursor")
11178
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11179
 
11180
- onContextMenu: nothing,
11181
- resetPosition: nothing,
11182
 
11183
- needsContentAttribute: true
11184
- }, ContentEditableInput.prototype)
11185
 
11186
  function posToDOM(cm, pos) {
11187
  var view = findViewForLine(cm, pos.line)
@@ -11208,8 +10326,8 @@ function domTextBetween(cm, from, to, fromLine, toLine) {
11208
  if (node.nodeType == 1) {
11209
  var cmText = node.getAttribute("cm-text")
11210
  if (cmText != null) {
11211
- if (cmText == "") { cmText = node.textContent.replace(/\u200b/g, "") }
11212
- text += cmText
11213
  return
11214
  }
11215
  var markerID = node.getAttribute("cm-marker"), range
@@ -11318,7 +10436,7 @@ function locateNodeInLineView(lineView, node, offset) {
11318
 
11319
  // TEXTAREA INPUT STYLE
11320
 
11321
- function TextareaInput(cm) {
11322
  this.cm = cm
11323
  // See input.poll and input.reset
11324
  this.prevInput = ""
@@ -11335,335 +10453,337 @@ function TextareaInput(cm) {
11335
  // Used to work around IE issue with selection being forgotten when focus moves away from textarea
11336
  this.hasSelection = false
11337
  this.composing = null
11338
- }
11339
 
11340
- TextareaInput.prototype = copyObj({
11341
- init: function(display) {
11342
  var this$1 = this;
11343
 
11344
- var input = this, cm = this.cm
11345
 
11346
- // Wraps and hides input textarea
11347
- var div = this.wrapper = hiddenTextarea()
11348
- // The semihidden textarea that is focused when the editor is
11349
- // focused, and receives input.
11350
- var te = this.textarea = div.firstChild
11351
- display.wrapper.insertBefore(div, display.wrapper.firstChild)
11352
 
11353
- // Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore)
11354
- if (ios) { te.style.width = "0px" }
11355
 
11356
- on(te, "input", function () {
11357
- if (ie && ie_version >= 9 && this$1.hasSelection) { this$1.hasSelection = null }
11358
- input.poll()
11359
- })
11360
 
11361
- on(te, "paste", function (e) {
11362
- if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }
11363
 
11364
- cm.state.pasteIncoming = true
11365
- input.fastPoll()
11366
- })
11367
 
11368
- function prepareCopyCut(e) {
11369
- if (signalDOMEvent(cm, e)) { return }
11370
- if (cm.somethingSelected()) {
11371
- setLastCopied({lineWise: false, text: cm.getSelections()})
11372
- if (input.inaccurateSelection) {
11373
- input.prevInput = ""
11374
- input.inaccurateSelection = false
11375
- te.value = lastCopied.text.join("\n")
11376
- selectInput(te)
11377
- }
11378
- } else if (!cm.options.lineWiseCopyCut) {
11379
- return
 
 
 
 
 
11380
  } else {
11381
- var ranges = copyableRanges(cm)
11382
- setLastCopied({lineWise: true, text: ranges.text})
11383
- if (e.type == "cut") {
11384
- cm.setSelections(ranges.ranges, null, sel_dontScroll)
11385
- } else {
11386
- input.prevInput = ""
11387
- te.value = ranges.text.join("\n")
11388
- selectInput(te)
11389
- }
11390
  }
11391
- if (e.type == "cut") { cm.state.cutIncoming = true }
11392
  }
11393
- on(te, "cut", prepareCopyCut)
11394
- on(te, "copy", prepareCopyCut)
 
 
11395
 
11396
- on(display.scroller, "paste", function (e) {
11397
- if (eventInWidget(display, e) || signalDOMEvent(cm, e)) { return }
11398
- cm.state.pasteIncoming = true
11399
- input.focus()
11400
- })
11401
 
11402
- // Prevent normal selection in the editor (we handle our own)
11403
- on(display.lineSpace, "selectstart", function (e) {
11404
- if (!eventInWidget(display, e)) { e_preventDefault(e) }
11405
- })
11406
 
11407
- on(te, "compositionstart", function () {
11408
- var start = cm.getCursor("from")
11409
- if (input.composing) { input.composing.range.clear() }
11410
- input.composing = {
11411
- start: start,
11412
- range: cm.markText(start, cm.getCursor("to"), {className: "CodeMirror-composing"})
11413
- }
11414
- })
11415
- on(te, "compositionend", function () {
11416
- if (input.composing) {
11417
- input.poll()
11418
- input.composing.range.clear()
11419
- input.composing = null
11420
- }
11421
- })
11422
- },
11423
 
11424
- prepareSelection: function() {
11425
- // Redraw the selection and/or cursor
11426
- var cm = this.cm, display = cm.display, doc = cm.doc
11427
- var result = prepareSelection(cm)
11428
 
11429
- // Move the hidden textarea near the cursor to prevent scrolling artifacts
11430
- if (cm.options.moveInputWithCursor) {
11431
- var headPos = cursorCoords(cm, doc.sel.primary().head, "div")
11432
- var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect()
11433
- result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10,
11434
- headPos.top + lineOff.top - wrapOff.top))
11435
- result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10,
11436
- headPos.left + lineOff.left - wrapOff.left))
11437
- }
11438
 
11439
- return result
11440
- },
11441
 
11442
- showSelection: function(drawn) {
11443
- var cm = this.cm, display = cm.display
11444
- removeChildrenAndAdd(display.cursorDiv, drawn.cursors)
11445
- removeChildrenAndAdd(display.selectionDiv, drawn.selection)
11446
- if (drawn.teTop != null) {
11447
- this.wrapper.style.top = drawn.teTop + "px"
11448
- this.wrapper.style.left = drawn.teLeft + "px"
11449
- }
11450
- },
11451
 
11452
- // Reset the input to correspond to the selection (or to be empty,
11453
- // when not typing and nothing is selected)
11454
- reset: function(typing) {
11455
- if (this.contextMenuPending) { return }
11456
- var minimal, selected, cm = this.cm, doc = cm.doc
11457
- if (cm.somethingSelected()) {
11458
- this.prevInput = ""
11459
- var range = doc.sel.primary()
11460
- minimal = hasCopyEvent &&
11461
- (range.to().line - range.from().line > 100 || (selected = cm.getSelection()).length > 1000)
11462
- var content = minimal ? "-" : selected || cm.getSelection()
11463
- this.textarea.value = content
11464
- if (cm.state.focused) { selectInput(this.textarea) }
11465
- if (ie && ie_version >= 9) { this.hasSelection = content }
11466
- } else if (!typing) {
11467
- this.prevInput = this.textarea.value = ""
11468
- if (ie && ie_version >= 9) { this.hasSelection = null }
11469
- }
11470
- this.inaccurateSelection = minimal
11471
- },
11472
 
11473
- getField: function() { return this.textarea },
11474
 
11475
- supportsTouch: function() { return false },
11476
 
11477
- focus: function() {
11478
- if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) {
11479
- try { this.textarea.focus() }
11480
- catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
11481
- }
11482
- },
11483
 
11484
- blur: function() { this.textarea.blur() },
11485
 
11486
- resetPosition: function() {
11487
- this.wrapper.style.top = this.wrapper.style.left = 0
11488
- },
11489
 
11490
- receivedFocus: function() { this.slowPoll() },
11491
 
11492
- // Poll for input changes, using the normal rate of polling. This
11493
- // runs as long as the editor is focused.
11494
- slowPoll: function() {
11495
  var this$1 = this;
11496
 
11497
- if (this.pollingFast) { return }
11498
- this.polling.set(this.cm.options.pollInterval, function () {
11499
- this$1.poll()
11500
- if (this$1.cm.state.focused) { this$1.slowPoll() }
11501
- })
11502
- },
11503
 
11504
- // When an event has just come in that is likely to add or change
11505
- // something in the input textarea, we poll faster, to ensure that
11506
- // the change appears on the screen quickly.
11507
- fastPoll: function() {
11508
- var missed = false, input = this
11509
- input.pollingFast = true
11510
- function p() {
11511
- var changed = input.poll()
11512
- if (!changed && !missed) {missed = true; input.polling.set(60, p)}
11513
- else {input.pollingFast = false; input.slowPoll()}
11514
- }
11515
- input.polling.set(20, p)
11516
- },
11517
 
11518
- // Read input from the textarea, and update the document to match.
11519
- // When something is selected, it is present in the textarea, and
11520
- // selected (unless it is huge, in which case a placeholder is
11521
- // used). When nothing is selected, the cursor sits after previously
11522
- // seen text (can be empty), which is stored in prevInput (we must
11523
- // not reset the textarea when typing, because that breaks IME).
11524
- poll: function() {
11525
  var this$1 = this;
11526
 
11527
- var cm = this.cm, input = this.textarea, prevInput = this.prevInput
11528
- // Since this is called a *lot*, try to bail out as cheaply as
11529
- // possible when it is clear that nothing happened. hasSelection
11530
- // will be the case when there is a lot of text in the textarea,
11531
- // in which case reading its value would be expensive.
11532
- if (this.contextMenuPending || !cm.state.focused ||
11533
- (hasSelection(input) && !prevInput && !this.composing) ||
11534
- cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq)
11535
- { return false }
11536
-
11537
- var text = input.value
11538
- // If nothing changed, bail.
11539
- if (text == prevInput && !cm.somethingSelected()) { return false }
11540
- // Work around nonsensical selection resetting in IE9/10, and
11541
- // inexplicable appearance of private area unicode characters on
11542
- // some key combos in Mac (#2689).
11543
- if (ie && ie_version >= 9 && this.hasSelection === text ||
11544
- mac && /[\uf700-\uf7ff]/.test(text)) {
11545
- cm.display.input.reset()
11546
- return false
11547
- }
11548
 
11549
- if (cm.doc.sel == cm.display.selForContextMenu) {
11550
- var first = text.charCodeAt(0)
11551
- if (first == 0x200b && !prevInput) { prevInput = "\u200b" }
11552
- if (first == 0x21da) { this.reset(); return this.cm.execCommand("undo") }
11553
- }
11554
- // Find the part of the input that is actually new
11555
- var same = 0, l = Math.min(prevInput.length, text.length)
11556
- while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) { ++same }
 
 
 
11557
 
11558
- runInOp(cm, function () {
11559
- applyTextInput(cm, text.slice(same), prevInput.length - same,
11560
- null, this$1.composing ? "*compose" : null)
 
 
 
 
 
11561
 
11562
- // Don't leave long text in the textarea, since it makes further polling slow
11563
- if (text.length > 1000 || text.indexOf("\n") > -1) { input.value = this$1.prevInput = "" }
11564
- else { this$1.prevInput = text }
11565
 
11566
- if (this$1.composing) {
11567
- this$1.composing.range.clear()
11568
- this$1.composing.range = cm.markText(this$1.composing.start, cm.getCursor("to"),
11569
- {className: "CodeMirror-composing"})
11570
- }
11571
- })
11572
- return true
11573
- },
11574
 
11575
- ensurePolled: function() {
11576
- if (this.pollingFast && this.poll()) { this.pollingFast = false }
11577
- },
 
 
 
 
 
11578
 
11579
- onKeyPress: function() {
11580
- if (ie && ie_version >= 9) { this.hasSelection = null }
11581
- this.fastPoll()
11582
- },
11583
 
11584
- onContextMenu: function(e) {
11585
- var input = this, cm = input.cm, display = cm.display, te = input.textarea
11586
- var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop
11587
- if (!pos || presto) { return } // Opera is difficult.
11588
-
11589
- // Reset the current text selection only if the click is done outside of the selection
11590
- // and 'resetSelectionOnContextMenu' option is true.
11591
- var reset = cm.options.resetSelectionOnContextMenu
11592
- if (reset && cm.doc.sel.contains(pos) == -1)
11593
- { operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll) }
11594
-
11595
- var oldCSS = te.style.cssText, oldWrapperCSS = input.wrapper.style.cssText
11596
- input.wrapper.style.cssText = "position: absolute"
11597
- var wrapperBox = input.wrapper.getBoundingClientRect()
11598
- te.style.cssText = "position: absolute; width: 30px; height: 30px;\n top: " + (e.clientY - wrapperBox.top - 5) + "px; left: " + (e.clientX - wrapperBox.left - 5) + "px;\n z-index: 1000; background: " + (ie ? "rgba(255, 255, 255, .05)" : "transparent") + ";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);"
11599
- var oldScrollY
11600
- if (webkit) { oldScrollY = window.scrollY } // Work around Chrome issue (#2712)
11601
- display.input.focus()
11602
- if (webkit) { window.scrollTo(null, oldScrollY) }
11603
- display.input.reset()
11604
- // Adds "Select all" to context menu in FF
11605
- if (!cm.somethingSelected()) { te.value = input.prevInput = " " }
11606
- input.contextMenuPending = true
11607
- display.selForContextMenu = cm.doc.sel
11608
- clearTimeout(display.detectingSelectAll)
11609
-
11610
- // Select-all will be greyed out if there's nothing to select, so
11611
- // this adds a zero-width space so that we can later check whether
11612
- // it got selected.
11613
- function prepareSelectAllHack() {
11614
- if (te.selectionStart != null) {
11615
- var selected = cm.somethingSelected()
11616
- var extval = "\u200b" + (selected ? te.value : "")
11617
- te.value = "\u21da" // Used to catch context-menu undo
11618
- te.value = extval
11619
- input.prevInput = selected ? "" : "\u200b"
11620
- te.selectionStart = 1; te.selectionEnd = extval.length
11621
- // Re-set this, in case some other handler touched the
11622
- // selection in the meantime.
11623
- display.selForContextMenu = cm.doc.sel
11624
- }
11625
- }
11626
- function rehide() {
11627
- input.contextMenuPending = false
11628
- input.wrapper.style.cssText = oldWrapperCSS
11629
- te.style.cssText = oldCSS
11630
- if (ie && ie_version < 9) { display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos) }
11631
-
11632
- // Try to detect the user choosing select-all
11633
- if (te.selectionStart != null) {
11634
- if (!ie || (ie && ie_version < 9)) { prepareSelectAllHack() }
11635
- var i = 0, poll = function () {
11636
- if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 &&
11637
- te.selectionEnd > 0 && input.prevInput == "\u200b")
11638
- { operation(cm, selectAll)(cm) }
11639
- else if (i++ < 10) { display.detectingSelectAll = setTimeout(poll, 500) }
11640
- else { display.input.reset() }
 
 
 
 
 
 
 
 
11641
  }
11642
- display.detectingSelectAll = setTimeout(poll, 200)
11643
  }
 
11644
  }
 
11645
 
11646
- if (ie && ie_version >= 9) { prepareSelectAllHack() }
11647
- if (captureRightClick) {
11648
- e_stop(e)
11649
- var mouseup = function () {
11650
- off(window, "mouseup", mouseup)
11651
- setTimeout(rehide, 20)
11652
- }
11653
- on(window, "mouseup", mouseup)
11654
- } else {
11655
- setTimeout(rehide, 50)
11656
  }
11657
- },
 
 
 
 
11658
 
11659
- readOnlyChanged: function(val) {
11660
- if (!val) { this.reset() }
11661
- },
11662
 
11663
- setUneditable: nothing,
11664
 
11665
- needsContentAttribute: false
11666
- }, TextareaInput.prototype)
11667
 
11668
  function fromTextArea(textarea, options) {
11669
  options = options ? copyObj(options) : {}
@@ -11814,12 +10934,12 @@ CodeMirror.fromTextArea = fromTextArea
11814
 
11815
  addLegacyProps(CodeMirror)
11816
 
11817
- CodeMirror.version = "5.20.2"
11818
 
11819
  return CodeMirror;
11820
 
11821
  })));
11822
- },{}],18:[function(require,module,exports){
11823
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
11824
  // Distributed under an MIT license: http://codemirror.net/LICENSE
11825
 
@@ -11850,6 +10970,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
11850
  colorKeywords = parserConfig.colorKeywords || {},
11851
  valueKeywords = parserConfig.valueKeywords || {},
11852
  allowNested = parserConfig.allowNested,
 
11853
  supportsAtComponent = parserConfig.supportsAtComponent === true;
11854
 
11855
  var type, override;
@@ -12075,6 +11196,8 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
12075
  };
12076
 
12077
  states.pseudo = function(type, stream, state) {
 
 
12078
  if (type == "word") {
12079
  override = "variable-3";
12080
  return state.context.type;
@@ -12229,6 +11352,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
12229
  electricChars: "}",
12230
  blockCommentStart: "/*",
12231
  blockCommentEnd: "*/",
 
12232
  fold: "brace"
12233
  };
12234
  });
@@ -12316,7 +11440,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
12316
  "line-stacking-shift", "line-stacking-strategy", "list-style",
12317
  "list-style-image", "list-style-position", "list-style-type", "margin",
12318
  "margin-bottom", "margin-left", "margin-right", "margin-top",
12319
- "marker-offset", "marks", "marquee-direction", "marquee-loop",
12320
  "marquee-play-count", "marquee-speed", "marquee-style", "max-height",
12321
  "max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index",
12322
  "nav-left", "nav-right", "nav-up", "object-fit", "object-position",
@@ -12344,9 +11468,9 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
12344
  "text-wrap", "top", "transform", "transform-origin", "transform-style",
12345
  "transition", "transition-delay", "transition-duration",
12346
  "transition-property", "transition-timing-function", "unicode-bidi",
12347
- "vertical-align", "visibility", "voice-balance", "voice-duration",
12348
  "voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress",
12349
- "voice-volume", "volume", "white-space", "widows", "width", "word-break",
12350
  "word-spacing", "word-wrap", "z-index",
12351
  // SVG-specific
12352
  "clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color",
@@ -12411,7 +11535,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
12411
  "above", "absolute", "activeborder", "additive", "activecaption", "afar",
12412
  "after-white-space", "ahead", "alias", "all", "all-scroll", "alphabetic", "alternate",
12413
  "always", "amharic", "amharic-abegede", "antialiased", "appworkspace",
12414
- "arabic-indic", "armenian", "asterisks", "attr", "auto", "avoid", "avoid-column", "avoid-page",
12415
  "avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary",
12416
  "bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
12417
  "both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel",
@@ -12420,7 +11544,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
12420
  "cell", "center", "checkbox", "circle", "cjk-decimal", "cjk-earthly-branch",
12421
  "cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
12422
  "col-resize", "collapse", "color", "color-burn", "color-dodge", "column", "column-reverse",
12423
- "compact", "condensed", "contain", "content",
12424
  "content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover", "crop",
12425
  "cross", "crosshair", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal",
12426
  "decimal-leading-zero", "default", "default-button", "dense", "destination-atop",
@@ -12463,7 +11587,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
12463
  "mix", "mongolian", "monospace", "move", "multiple", "multiply", "myanmar", "n-resize",
12464
  "narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop",
12465
  "no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap",
12466
- "ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", "oblique", "octal", "open-quote",
12467
  "optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset",
12468
  "outside", "outside-shape", "overlay", "overline", "padding", "padding-box",
12469
  "painted", "page", "paused", "persian", "perspective", "plus-darker", "plus-lighter",
@@ -12475,7 +11599,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
12475
  "rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY",
12476
  "rotateZ", "round", "row", "row-resize", "row-reverse", "rtl", "run-in", "running",
12477
  "s-resize", "sans-serif", "saturation", "scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen",
12478
- "scroll", "scrollbar", "se-resize", "searchfield",
12479
  "searchfield-cancel-button", "searchfield-decoration",
12480
  "searchfield-results-button", "searchfield-results-decoration",
12481
  "semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama",
@@ -12493,9 +11617,9 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
12493
  "thick", "thin", "threeddarkshadow", "threedface", "threedhighlight",
12494
  "threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er",
12495
  "tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top",
12496
- "trad-chinese-formal", "trad-chinese-informal",
12497
  "translate", "translate3d", "translateX", "translateY", "translateZ",
12498
- "transparent", "ultra-condensed", "ultra-expanded", "underline", "up",
12499
  "upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal",
12500
  "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url",
12501
  "var", "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
@@ -12552,6 +11676,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
12552
  valueKeywords: valueKeywords,
12553
  fontProperties: fontProperties,
12554
  allowNested: true,
 
12555
  tokenHooks: {
12556
  "/": function(stream, state) {
12557
  if (stream.eat("/")) {
@@ -12594,6 +11719,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
12594
  valueKeywords: valueKeywords,
12595
  fontProperties: fontProperties,
12596
  allowNested: true,
 
12597
  tokenHooks: {
12598
  "/": function(stream, state) {
12599
  if (stream.eat("/")) {
@@ -12646,7 +11772,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
12646
 
12647
  });
12648
 
12649
- },{"../../lib/codemirror":17}],19:[function(require,module,exports){
12650
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
12651
  // Distributed under an MIT license: http://codemirror.net/LICENSE
12652
 
@@ -12663,7 +11789,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
12663
  var defaultTags = {
12664
  script: [
12665
  ["lang", /(javascript|babel)/i, "javascript"],
12666
- ["type", /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^$/i, "javascript"],
12667
  ["type", /./, "text/plain"],
12668
  [null, null, "javascript"]
12669
  ],
@@ -12800,7 +11926,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
12800
  CodeMirror.defineMIME("text/html", "htmlmixed");
12801
  });
12802
 
12803
- },{"../../lib/codemirror":17,"../css/css":18,"../javascript/javascript":20,"../xml/xml":21}],20:[function(require,module,exports){
12804
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
12805
  // Distributed under an MIT license: http://codemirror.net/LICENSE
12806
 
@@ -12815,7 +11941,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
12815
  "use strict";
12816
 
12817
  function expressionAllowed(stream, state, backUp) {
12818
- return /^(?:operator|sof|keyword c|case|new|[\[{}\(,;:]|=>)$/.test(state.lastType) ||
12819
  (state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0))))
12820
  }
12821
 
@@ -12949,7 +12075,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
12949
  stream.skipToEnd();
12950
  return ret("error", "error");
12951
  } else if (isOperatorChar.test(ch)) {
12952
- stream.eatWhile(isOperatorChar);
 
12953
  return ret("operator", "operator", stream.current());
12954
  } else if (wordRE.test(ch)) {
12955
  stream.eatWhile(wordRE);
@@ -13307,9 +12434,9 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
13307
  if (type == ":") return cont(expressionNoComma);
13308
  if (type == "(") return pass(functiondef);
13309
  }
13310
- function commasep(what, end) {
13311
  function proceed(type, value) {
13312
- if (type == ",") {
13313
  var lex = cx.state.lexical;
13314
  if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;
13315
  return cont(function(type, value) {
@@ -13342,16 +12469,19 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
13342
  }
13343
  function typeexpr(type) {
13344
  if (type == "variable") {cx.marked = "variable-3"; return cont(afterType);}
13345
- if (type == "{") return cont(commasep(typeprop, "}"))
 
13346
  if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType)
13347
  }
13348
  function maybeReturnType(type) {
13349
  if (type == "=>") return cont(typeexpr)
13350
  }
13351
- function typeprop(type) {
13352
  if (type == "variable" || cx.style == "keyword") {
13353
  cx.marked = "property"
13354
  return cont(typeprop)
 
 
13355
  } else if (type == ":") {
13356
  return cont(typeexpr)
13357
  }
@@ -13361,7 +12491,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
13361
  else if (type == ":") return cont(typeexpr)
13362
  }
13363
  function afterType(type, value) {
13364
- if (value == "<") return cont(commasep(typeexpr, ">"), afterType)
 
13365
  if (type == "[") return cont(expect("]"), afterType)
13366
  }
13367
  function vardef() {
@@ -13432,12 +12563,13 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
13432
  if (type == "variable") {register(value); return cont(classNameAfter);}
13433
  }
13434
  function classNameAfter(type, value) {
13435
- if (value == "extends" || value == "implements") return cont(isTS ? typeexpr : expression, classNameAfter);
 
13436
  if (type == "{") return cont(pushlex("}"), classBody, poplex);
13437
  }
13438
  function classBody(type, value) {
13439
  if (type == "variable" || cx.style == "keyword") {
13440
- if ((value == "static" || value == "get" || value == "set" ||
13441
  (isTS && (value == "public" || value == "private" || value == "protected" || value == "readonly" || value == "abstract"))) &&
13442
  cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false)) {
13443
  cx.marked = "keyword";
@@ -13446,6 +12578,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
13446
  cx.marked = "property";
13447
  return cont(isTS ? classfield : functiondef, classBody);
13448
  }
 
 
13449
  if (value == "*") {
13450
  cx.marked = "keyword";
13451
  return cont(classBody);
@@ -13458,14 +12592,19 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
13458
  if (type == ":") return cont(typeexpr, maybeAssign)
13459
  return pass(functiondef)
13460
  }
13461
- function afterExport(_type, value) {
13462
  if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
13463
  if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); }
 
13464
  return pass(statement);
13465
  }
 
 
 
 
13466
  function afterImport(type) {
13467
  if (type == "string") return cont();
13468
- return pass(importSpec, maybeFrom);
13469
  }
13470
  function importSpec(type, value) {
13471
  if (type == "{") return contCommasep(importSpec, "}");
@@ -13473,6 +12612,9 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
13473
  if (value == "*") cx.marked = "keyword";
13474
  return cont(maybeAs);
13475
  }
 
 
 
13476
  function maybeAs(_type, value) {
13477
  if (value == "as") { cx.marked = "keyword"; return cont(importSpec); }
13478
  }
@@ -13586,7 +12728,7 @@ CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript
13586
 
13587
  });
13588
 
13589
- },{"../../lib/codemirror":17}],21:[function(require,module,exports){
13590
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
13591
  // Distributed under an MIT license: http://codemirror.net/LICENSE
13592
 
@@ -13982,5 +13124,662 @@ if (!CodeMirror.mimeModes.hasOwnProperty("text/html"))
13982
 
13983
  });
13984
 
13985
- },{"../../lib/codemirror":17}]},{},[11]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13986
  })();
1
  (function () { var require = undefined; var define = undefined; (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
  'use strict';
3
 
4
+ var rows = function rows(m, i18n) {
5
 
6
  var r = {};
7
 
8
+ r.showType = function (config) {
9
  // ucfirst
10
  var fieldType = config.type();
11
  fieldType = fieldType.charAt(0).toUpperCase() + fieldType.slice(1);
12
 
13
+ return m('div', [m("label", i18n.fieldType), m('span', fieldType)]);
 
 
 
14
  };
15
 
16
  r.label = function (config) {
17
  // label row
18
+ return m("div", [m("label", i18n.fieldLabel), m("input.widefat", {
19
+ type: "text",
20
+ value: config.label(),
21
+ onchange: m.withAttr('value', config.label),
22
+ placeholder: config.title()
23
+ })]);
 
 
 
24
  };
25
 
26
  r.value = function (config) {
27
  var isHidden = config.type() === 'hidden';
28
+ return m("div", [m("label", [isHidden ? i18n.value : i18n.initialValue, " ", isHidden ? '' : m('small', { "style": "float: right; font-weight: normal;" }, i18n.optional)]), m("input.widefat", {
29
+ type: "text",
30
+ value: config.value(),
31
+ onchange: m.withAttr('value', config.value)
32
+ }), isHidden ? '' : m('p.help', i18n.valueHelp)]);
 
 
 
 
 
 
 
 
33
  };
34
 
35
  r.numberMinMax = function (config) {
36
+ return m('div', [m('div.row', [m('div.col.col-3', [m('label', i18n.min), m('input', { type: 'number', onchange: m.withAttr('value', config.min) })]), m('div.col.col-3', [m('label', i18n.max), m('input', { type: 'number', onchange: m.withAttr('value', config.max) })])])]);
 
 
 
 
 
 
 
 
 
 
 
37
  };
38
 
 
39
  r.isRequired = function (config) {
40
  var inputAtts = {
41
+ type: 'checkbox',
42
+ checked: config.required(),
43
  onchange: m.withAttr('checked', config.required)
44
  };
45
+ var desc = void 0;
46
 
47
+ if (config.forceRequired()) {
48
  inputAtts.required = true;
49
  inputAtts.disabled = true;
50
+ desc = m('p.help', i18n.forceRequired);
51
  }
52
 
53
+ return m('div', [m('label.cb-wrap', [m('input', inputAtts), i18n.isFieldRequired]), desc]);
 
 
 
 
 
 
54
  };
55
 
56
  r.placeholder = function (config) {
57
 
58
+ return m("div", [m("label", [i18n.placeholder, " ", m('small', { "style": "float: right; font-weight: normal;" }, i18n.optional)]), m("input.widefat", {
59
+ type: "text",
60
+ value: config.placeholder(),
61
+ onchange: m.withAttr('value', config.placeholder),
62
+ placeholder: ""
63
+ }), m("p.help", i18n.placeholderHelp)]);
 
 
 
 
 
 
 
 
64
  };
65
 
66
  r.useParagraphs = function (config) {
67
+ return m('div', [m('label.cb-wrap', [m('input', {
68
+ type: 'checkbox',
69
+ checked: config.wrap(),
70
+ onchange: m.withAttr('checked', config.wrap)
71
+ }), i18n.wrapInParagraphTags])]);
 
 
 
 
 
72
  };
73
 
74
  r.choiceType = function (config) {
75
+ var options = [m('option', {
76
+ value: 'select',
77
+ selected: config.type() === 'select' ? 'selected' : false
78
+ }, i18n.dropdown), m('option', {
79
+ value: 'radio',
80
+ selected: config.type() === 'radio' ? 'selected' : false
81
+ }, i18n.radioButtons)];
 
 
 
 
 
82
 
83
  // only add checkbox choice if field accepts multiple values
84
+ if (config.acceptsMultipleValues) {
85
+ options.push(m('option', {
86
+ value: 'checkbox',
87
+ selected: config.type() === 'checkbox' ? 'selected' : false
88
+ }, i18n.checkboxes));
 
 
89
  }
90
 
91
+ return m('div', [m('label', i18n.choiceType), m('select', {
92
+ value: config.type(),
93
+ onchange: m.withAttr('value', config.type)
94
+ }, options)]);
 
 
 
95
  };
96
 
97
  r.choices = function (config) {
98
 
99
  var html = [];
100
+ html.push(m('div', [m('label', i18n.choices), m('div.limit-height', [m("table", [
101
+
102
+ // table body
103
+ config.choices().map(function (choice, index) {
104
+ return m('tr', {
105
+ 'data-id': index
106
+ }, [m('td.cb', m('input', {
107
+ name: 'selected',
108
+ type: config.type() === 'checkbox' ? 'checkbox' : 'radio',
109
+ onchange: m.withAttr('value', config.selectChoice.bind(config)),
110
+ checked: choice.selected(),
111
+ value: choice.value(),
112
+ title: i18n.preselect
113
+ })), m('td.stretch', m('input.widefat', {
114
+ type: 'text',
115
+ value: choice.label(),
116
+ placeholder: choice.title(),
117
+ onchange: m.withAttr('value', choice.label)
118
+ })), m('td', m('span', {
119
+ "title": i18n.remove,
120
+ "class": 'dashicons dashicons-no-alt hover-activated',
121
+ "onclick": function (key) {
122
+ this.choices().splice(key, 1);
123
+ }.bind(config, index)
124
+ }, ''))]);
125
+ })]) // end of table
126
+ ]) // end of limit-height div
 
 
 
 
 
 
 
 
 
127
  ]));
 
 
128
 
129
+ return html;
130
  };
131
 
132
  return r;
133
  };
134
 
135
  module.exports = rows;
136
+
137
  },{}],2:[function(require,module,exports){
138
+ 'use strict';
139
+
140
+ var forms = function forms(m, i18n) {
141
  var forms = {};
142
  var rows = require('./field-forms-rows.js')(m, i18n);
143
 
144
  // route to one of the other form configs, default to "text"
145
+ forms.render = function (config) {
146
 
147
  var type = config.type();
148
 
149
+ if (typeof forms[type] === "function") {
150
+ return forms[type](config);
151
  }
152
 
153
+ switch (type) {
154
  case 'select':
155
  case 'radio':
156
  case 'checkbox':
162
  return forms.text(config);
163
  };
164
 
165
+ forms.text = function (config) {
166
+ return [rows.label(config), rows.placeholder(config), rows.value(config), rows.isRequired(config), rows.useParagraphs(config)];
 
 
 
 
 
 
 
167
  };
168
 
169
+ forms.choice = function (config) {
170
+ var visibleRows = [rows.label(config), rows.choiceType(config), rows.choices(config)];
 
 
 
 
171
 
172
+ if (config.type() === 'select') {
173
  visibleRows.push(rows.placeholder(config));
174
  }
175
 
176
  visibleRows.push(rows.useParagraphs(config));
177
 
178
+ if (config.type() === 'select' || config.type() === 'radio') {
179
  visibleRows.push(rows.isRequired(config));
180
  }
181
 
182
  return visibleRows;
183
  };
184
 
185
+ forms.hidden = function (config) {
186
  config.placeholder('');
187
  config.label('');
188
  config.wrap(false);
189
 
190
+ return [rows.showType(config), rows.value(config)];
 
 
 
191
  };
192
 
193
+ forms.submit = function (config) {
194
  config.label('');
195
  config.placeholder('');
196
 
197
+ return [rows.value(config), rows.useParagraphs(config)];
 
 
 
198
  };
199
 
200
+ forms.number = function (config) {
201
+ return [forms.text(config), rows.numberMinMax(config)];
 
 
 
202
  };
203
 
204
  return forms;
205
  };
206
 
 
 
207
  module.exports = forms;
208
+
209
  },{"./field-forms-rows.js":1}],3:[function(require,module,exports){
210
  'use strict';
211
 
212
+ var htmlutil = require('html');
213
+
214
+ var setAttributes = function setAttributes(vnode) {
215
+ if (vnode.dom.checked) {
216
+ vnode.dom.setAttribute("checked", "true");
217
+ }
218
+
219
+ if (vnode.dom.value) {
220
+ vnode.dom.setAttribute('value', vnode.dom.value);
221
+ }
222
+
223
+ if (vnode.dom.selected) {
224
+ vnode.dom.setAttribute("selected", "true");
225
+ }
226
+ };
227
 
228
+ var g = function g(m) {
229
  var generators = {};
230
 
231
  /**
232
+ * Generates a <select> field
233
+ * @param config
234
+ * @returns {*}
235
+ */
236
  generators.select = function (config) {
237
  var attributes = {
238
  name: config.name(),
242
 
243
  var options = config.choices().map(function (choice) {
244
 
245
+ if (choice.selected()) {
246
  hasSelection = true;
247
  }
248
 
249
  return m('option', {
250
+ value: choice.value() !== choice.label() ? choice.value() : undefined,
251
+ "selected": choice.selected(),
252
+ oncreate: setAttributes
253
+ }, choice.label());
254
  });
255
 
256
  var placeholder = config.placeholder();
257
+ if (placeholder.length > 0) {
258
+ options.unshift(m('option', {
259
+ 'disabled': true,
260
+ 'value': '',
261
+ 'selected': !hasSelection,
262
+ oncreate: setAttributes
263
+ }, placeholder));
 
264
  }
265
 
266
+ return m('select', attributes, options);
267
  };
268
 
269
  /**
270
+ * Generates a checkbox or radio type input field.
271
+ *
272
+ * @param config
273
+ * @returns {*}
274
+ */
275
  generators.checkbox = function (config) {
276
+ var fields = config.choices().map(function (choice) {
277
+ var name = config.name() + (config.type() === 'checkbox' ? '[]' : '');
278
  var required = config.required() && config.type() === 'radio';
279
 
280
+ return m('label', [m('input', {
281
+ name: name,
282
+ type: config.type(),
283
+ value: choice.value(),
284
+ checked: choice.selected(),
285
+ required: required,
286
+ oncreate: setAttributes
287
+ }), ' ', m('span', choice.label())]);
 
 
 
 
288
  });
289
+
290
+ return fields;
291
  };
292
  generators.radio = generators.checkbox;
293
 
294
  /**
295
+ * Generates a default field
296
+ *
297
+ * - text, url, number, email, date
298
+ *
299
+ * @param config
300
+ * @returns {*}
301
+ */
302
  generators['default'] = function (config) {
 
303
  var attributes = {
304
  type: config.type()
305
  };
 
306
 
307
  if (config.name()) {
308
  attributes.name = config.name();
320
  attributes.value = config.value();
321
  }
322
 
323
+ if (config.placeholder().length > 0) {
324
  attributes.placeholder = config.placeholder();
325
  }
326
 
327
  attributes.required = config.required();
328
+ attributes.oncreate = setAttributes;
329
 
330
+ return m('input', attributes);
 
331
  };
332
 
333
  /**
334
+ * Generates an HTML string based on a field (config) object
335
+ *
336
+ * @param config
337
+ * @returns {*}
338
+ */
339
  function generate(config) {
340
+ var label = void 0,
341
+ field = void 0,
342
+ htmlTemplate = void 0,
343
+ html = void 0,
344
+ vdom = document.createElement('div');
345
+
346
+ label = config.label().length > 0 ? m("label", {}, config.label()) : '';
347
+ field = typeof generators[config.type()] === "function" ? generators[config.type()](config) : generators['default'](config);
348
  htmlTemplate = config.wrap() ? m('p', [label, field]) : [label, field];
349
 
350
+ // render in vdom
351
+ m.render(vdom, htmlTemplate);
352
 
353
  // prettify html
354
+ html = htmlutil.prettyPrint(vdom.innerHTML);
355
 
356
  return html + "\n";
357
  }
360
  };
361
 
362
  module.exports = g;
363
+
364
+ },{"html":20}],4:[function(require,module,exports){
365
+ 'use strict';
366
+
367
+ var FieldHelper = function FieldHelper(m, tabs, editor, fields, events, i18n) {
368
  'use strict';
369
 
370
  var generate = require('./field-generator.js')(m);
371
+ var overlay = require('./overlay.js')(m, i18n);
372
  var forms = require('./field-forms.js')(m, i18n);
373
  var fieldConfig;
374
 
375
  editor.on('blur', m.redraw);
376
 
377
  /**
378
+ * Choose a field to open the helper form for
379
+ *
380
+ * @param index
381
+ * @returns {*}
382
+ */
383
  function setActiveField(index) {
384
 
385
  fieldConfig = fields.get(index);
386
 
387
  // if this hidden field has choices (hidden groups), glue them together by their label.
388
+ if (fieldConfig && fieldConfig.choices().length > 0) {
389
+ fieldConfig.value(fieldConfig.choices().map(function (c) {
390
  return c.label();
391
  }).join('|'));
392
  }
394
  m.redraw();
395
  }
396
 
 
397
  /**
398
+ * Controller
399
+ */
400
+ function controller() {}
 
 
401
 
402
  /**
403
+ * Create HTML based on current config object
404
+ */
405
  function createFieldHTMLAndAddToForm() {
406
 
407
  // generate html
408
  var html = generate(fieldConfig);
409
 
410
  // add to editor
411
+ editor.insert(html);
412
 
413
  // reset field form
414
  setActiveField('');
418
  }
419
 
420
  /**
421
+ * View
422
+ * @returns {*}
423
+ */
424
  function view() {
425
 
426
  // build DOM for fields choice
427
  var fieldCategories = fields.getCategories();
428
  var availableFields = fields.getAll();
429
 
430
+ var fieldsChoice = m("div.available-fields.small-margin", [m("h4", i18n.chooseField), fieldCategories.map(function (category) {
431
+ var categoryFields = availableFields.filter(function (f) {
432
+ return f.category === category;
433
+ });
434
 
435
+ if (!categoryFields.length) {
436
+ return;
437
+ }
438
+
439
+ return m("div.tiny-margin", [m("strong", category),
440
+
441
+ // render fields
442
+ categoryFields.map(function (field) {
443
+ var className = "button";
444
+ if (field.forceRequired()) {
445
+ className += " is-required";
446
+ }
447
 
448
+ var inForm = field.inFormContent();
449
+ if (inForm !== null) {
450
+ className += " " + (inForm ? 'in-form' : 'not-in-form');
451
  }
452
 
453
+ return m("button", {
454
+ className: className,
455
+ type: 'button',
456
+ onclick: m.withAttr("value", setActiveField),
457
+ value: field.index
458
+ }, field.title());
459
+ })]);
460
+ })]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
461
 
462
  // build DOM for overlay
463
  var form = null;
464
+ if (fieldConfig) {
465
  form = overlay(
466
+ // field wizard
467
+ m("div.field-wizard", [
468
+
469
+ //heading
470
+ m("h3", [fieldConfig.title(), fieldConfig.forceRequired() ? m('span.red', '*') : '', fieldConfig.name().length ? m("code", fieldConfig.name()) : '']),
471
+
472
+ // help text
473
+ fieldConfig.help().length ? m('p', m.trust(fieldConfig.help())) : '',
474
+
475
+ // actual form
476
+ forms.render(fieldConfig),
477
+
478
+ // add to form button
479
+ m("p", [m("button", {
480
+ "class": "button-primary",
481
+ type: "button",
482
+ onkeydown: function onkeydown(e) {
483
+ e = e || window.event;
484
+ if (e.keyCode == 13) {
485
+ createFieldHTMLAndAddToForm();
486
+ }
487
+ },
488
+ onclick: createFieldHTMLAndAddToForm
489
+ }, i18n.addToForm)])]), setActiveField);
 
 
 
 
 
 
 
490
  }
491
 
492
+ return [fieldsChoice, form];
 
 
 
493
  }
494
 
495
  // expose some variables
496
  return {
497
  view: view,
498
  controller: controller
499
+ };
500
  };
501
 
502
  module.exports = FieldHelper;
503
+
504
  },{"./field-forms.js":2,"./field-generator.js":3,"./overlay.js":10}],5:[function(require,module,exports){
505
+ 'use strict';
506
+
507
+ var FieldFactory = function FieldFactory(fields, i18n) {
508
  'use strict';
509
 
510
  /**
512
  *
513
  * @type {Array}
514
  */
515
+
516
  var registeredFields = [];
517
 
518
  /**
532
  function register(category, data, sticky) {
533
  var field = fields.register(category, data);
534
 
535
+ if (!sticky) {
536
  registeredFields.push(field);
537
  }
538
  }
546
  function getFieldType(type) {
547
 
548
  var map = {
549
+ 'phone': 'tel',
550
  'dropdown': 'select',
551
  'checkboxes': 'checkbox',
552
  'birthday': 'text'
553
  };
554
 
555
+ return typeof map[type] !== "undefined" ? map[type] : type;
556
  }
557
 
558
  /**
577
  acceptsMultipleValues: false // merge fields never accept multiple values.
578
  };
579
 
580
+ if (data.type !== 'address') {
581
  register(category, data, false);
582
  } else {
583
  register(category, { name: data.name + '[addr1]', type: 'text', mailchimpType: 'address', title: i18n.streetAddress });
584
  register(category, { name: data.name + '[city]', type: 'text', mailchimpType: 'address', title: i18n.city });
585
+ register(category, { name: data.name + '[state]', type: 'text', mailchimpType: 'address', title: i18n.state });
586
  register(category, { name: data.name + '[zip]', type: 'text', mailchimpType: 'address', title: i18n.zip });
587
  register(category, { name: data.name + '[country]', type: 'select', mailchimpType: 'address', title: i18n.country, choices: mc4wp_vars.countries });
588
  }
595
  *
596
  * @param interestCategory
597
  */
598
+ function registerInterestCategory(interestCategory) {
599
  var category = i18n.interestCategories;
600
  var fieldType = getFieldType(interestCategory.field_type);
601
 
617
  function registerListFields(list) {
618
 
619
  // make sure EMAIL && public fields come first
620
+ list.merge_fields = list.merge_fields.sort(function (a, b) {
621
+ if (a.tag === 'EMAIL' || a.public && !b.public) {
622
  return -1;
623
  }
624
 
625
+ if (!a.public && b.public) {
626
  return 1;
627
  }
628
 
661
 
662
  // register lists choice field
663
  choices = {};
664
+ for (var key in lists) {
665
  choices[lists[key].id] = lists[key].name;
666
  }
667
 
695
  'registerCustomFields': registerCustomFields,
696
  'registerListFields': registerListFields,
697
  'registerListsFields': registerListsFields
698
+ };
 
699
  };
700
 
701
  module.exports = FieldFactory;
702
+
703
  },{}],6:[function(require,module,exports){
704
  'use strict';
705
 
706
+ var prop = require("mithril/stream");
707
+
708
+ module.exports = function (m, events) {
709
  var timeout;
710
  var fields = [];
711
  var categories = [];
712
 
 
713
  /**
714
  * @internal
715
  *
717
  * @param data
718
  * @constructor
719
  */
720
+ var Field = function Field(data) {
721
+ this.name = prop(data.name);
722
+ this.title = prop(data.title || data.name);
723
+ this.type = prop(data.type);
724
+ this.mailchimpType = prop(data.mailchimpType || '');
725
+ this.label = prop(data.title || '');
726
+ this.value = prop(data.value || '');
727
+ this.placeholder = prop(data.placeholder || '');
728
+ this.required = prop(data.required || false);
729
+ this.forceRequired = prop(data.forceRequired || false);
730
+ this.wrap = prop(data.wrap || true);
731
+ this.min = prop(data.min || null);
732
+ this.max = prop(data.max || null);
733
+ this.help = prop(data.help || '');
734
+ this.choices = prop(data.choices || []);
735
+ this.inFormContent = prop(null);
736
  this.acceptsMultipleValues = data.acceptsMultipleValues;
737
 
738
+ this.selectChoice = function (value) {
739
  var field = this;
740
 
741
+ this.choices(this.choices().map(function (choice) {
742
 
743
+ if (choice.value() === value) {
744
  choice.selected(true);
745
  } else {
746
  // only checkboxes allow for multiple selections
747
+ if (field.type() !== 'checkbox') {
748
  choice.selected(false);
749
  }
750
  }
751
 
752
  return choice;
 
753
  }));
754
  };
755
  };
760
  * @param data
761
  * @constructor
762
  */
763
+ var FieldChoice = function FieldChoice(data) {
764
+ this.label = prop(data.label);
765
+ this.title = prop(data.title || data.label);
766
+ this.selected = prop(data.selected || false);
767
+ this.value = prop(data.value || data.label);
768
  };
769
 
770
  /**
775
  */
776
  function createChoices(data) {
777
  var choices = [];
778
+ if (typeof data.map === "function") {
779
  choices = data.map(function (choiceLabel) {
780
+ return new FieldChoice({ label: choiceLabel });
781
  });
782
  } else {
783
  choices = Object.keys(data).map(function (key) {
784
  var choiceLabel = data[key];
785
+ return new FieldChoice({ label: choiceLabel, value: key });
786
  });
787
  }
788
 
803
  var existingField = getAllWhere('name', data.name).shift();
804
 
805
  // a field with the same "name" already exists
806
+ if (existingField) {
807
 
808
  // update "required" status
809
+ if (!existingField.forceRequired() && data.forceRequired) {
810
  existingField.forceRequired(true);
811
  }
812
 
818
  if (data.choices) {
819
  data.choices = createChoices(data.choices);
820
 
821
+ if (data.value) {
822
+ data.choices = data.choices.map(function (choice) {
823
+ if (choice.value() === data.value) {
824
  choice.selected(true);
825
  }
826
  return choice;
829
  }
830
 
831
  // register category
832
+ if (categories.indexOf(category) < 0) {
833
  categories.push(category);
834
  }
835
 
880
  */
881
  function getAll() {
882
  // rebuild index property on all fields
883
+ fields = fields.map(function (f, i) {
884
  f.index = i;
885
  return f;
886
  });
905
  });
906
  }
907
 
 
908
  /**
909
  * Exposed methods
910
  */
911
  return {
912
+ 'get': get,
913
+ 'getAll': getAll,
914
  'getCategories': getCategories,
915
+ 'deregister': deregister,
916
+ 'register': register,
917
  'getAllWhere': getAllWhere
918
  };
919
  };
920
+
921
+ },{"mithril/stream":21}],7:[function(require,module,exports){
922
  'use strict';
923
 
924
  // load CodeMirror & plugins
925
+
926
  var CodeMirror = require('codemirror');
927
  require('codemirror/mode/xml/xml');
928
  require('codemirror/mode/javascript/javascript');
932
  require('codemirror/addon/edit/matchtags');
933
  require('codemirror/addon/edit/closetag.js');
934
 
935
+ var FormEditor = function FormEditor(element) {
936
 
937
  // create dom representation of form
938
  var _dom = document.createElement('form'),
942
 
943
  _dom.innerHTML = element.value.toLowerCase();
944
 
945
+ if (CodeMirror) {
946
  editor = CodeMirror.fromTextArea(element, {
947
  selectionPointer: true,
948
  matchTags: { bothTags: true },
953
  });
954
 
955
  // dispatch regular "change" on element event every time editor changes (IE9+ only)
956
+ window.dispatchEvent && editor.on('change', function () {
957
+ if (typeof Event === "function") {
958
  // Create a new 'change' event
959
  var event = new Event('change', { bubbles: true });
960
  element.dispatchEvent(event);
962
  });
963
  }
964
 
965
+ window.addEventListener('load', function () {
966
  CodeMirror.signal(editor, "change");
967
  });
968
 
969
  // set domDirty to true everytime the "change" event fires (a lot..)
970
+ element.addEventListener('change', function () {
971
  domDirty = true;
972
  });
973
 
974
  function dom() {
975
+ if (domDirty) {
976
  _dom.innerHTML = r.getValue().toLowerCase();
977
  domDirty = false;
978
  }
980
  return _dom;
981
  }
982
 
983
+ r.getValue = function () {
984
  return editor ? editor.getValue() : element.value;
985
  };
986
 
987
+ r.query = function (query) {
988
  return dom().querySelectorAll(query.toLowerCase());
989
  };
990
 
991
+ r.containsField = function (fieldName) {
992
  return dom().elements.namedItem(fieldName.toLowerCase()) !== null;
993
  };
994
 
995
+ r.insert = function (html) {
996
+ if (editor) {
997
+ editor.replaceSelection(html);
998
  editor.focus();
999
  } else {
1000
  element.value += html;
1001
  }
1002
  };
1003
 
1004
+ r.on = function (event, callback) {
1005
+ if (editor) {
1006
  // translate "input" event for CodeMirror
1007
+ event = event === 'input' ? 'changes' : event;
1008
+ return editor.on(event, callback);
1009
  }
1010
 
1011
+ return element.addEventListener(event, callback);
1012
  };
1013
 
1014
+ r.refresh = function () {
1015
  editor && editor.refresh();
1016
  };
1017
 
1019
  };
1020
 
1021
  module.exports = FormEditor;
1022
+
1023
+ },{"codemirror":15,"codemirror/addon/edit/closetag.js":12,"codemirror/addon/edit/matchtags":13,"codemirror/addon/fold/xml-fold":14,"codemirror/mode/css/css":16,"codemirror/mode/htmlmixed/htmlmixed":17,"codemirror/mode/javascript/javascript":18,"codemirror/mode/xml/xml":19}],8:[function(require,module,exports){
1024
+ 'use strict';
1025
+
1026
+ var FormWatcher = function FormWatcher(m, editor, settings, fields, events, helpers) {
1027
  'use strict';
1028
 
1029
  var requiredFieldsInput = document.getElementById('required-fields');
1030
 
1031
  function updateFields() {
1032
+ fields.getAll().forEach(function (field) {
1033
  // don't run for empty field names
1034
+ if (field.name().length <= 0) return;
1035
 
1036
  var fieldName = field.name();
1037
+ if (field.type() === 'checkbox') {
1038
  fieldName += '[]';
1039
  }
1040
 
1041
+ var inForm = editor.containsField(fieldName);
1042
+ field.inFormContent(inForm);
1043
 
1044
  // if form contains 1 address field of group, mark all fields in this group as "required"
1045
+ if (field.mailchimpType() === 'address') {
1046
  field.originalRequiredValue = field.originalRequiredValue === undefined ? field.forceRequired() : field.originalRequiredValue;
1047
 
1048
  // query other fields for this address group
1049
+ var nameGroup = field.name().replace(/\[(\w+)\]/g, '');
1050
+ if (editor.query('[name^="' + nameGroup + '"]').length > 0) {
1051
+ if (field.originalRequiredValue === undefined) {
1052
  field.originalRequiredValue = field.forceRequired();
1053
  }
1054
  field.forceRequired(true);
1056
  field.forceRequired(field.originalRequiredValue);
1057
  }
1058
  }
 
1059
  });
1060
 
1061
  findRequiredFields();
1065
  function findRequiredFields() {
1066
 
1067
  // query fields required by MailChimp
1068
+ var requiredFields = fields.getAllWhere('forceRequired', true).map(function (f) {
1069
+ return f.name().toUpperCase().replace(/\[(\w+)\]/g, '.$1');
1070
+ });
1071
 
1072
  // query fields in form with [required] attribute
1073
  var requiredFieldElements = editor.query('[required]');
1074
+ Array.prototype.forEach.call(requiredFieldElements, function (el) {
1075
  var name = el.name.toUpperCase();
1076
 
1077
  // bail if name attr starts with underscore
1078
+ if (name[0] === '_') {
1079
  return;
1080
  }
1081
 
1082
  // replace array brackets with dot style notation
1083
+ name = name.replace(/\[(\w+)\]/g, '.$1');
1084
 
1085
  // only add field if it's not already in it
1086
+ if (requiredFields.indexOf(name) === -1) {
1087
  requiredFields.push(name);
1088
  }
1089
  });
1095
  // events
1096
  editor.on('change', helpers.debounce(updateFields, 500));
1097
  events.on('fields.change', helpers.debounce(updateFields, 500));
 
1098
  };
1099
 
1100
  module.exports = FormWatcher;
1101
+
1102
  },{}],9:[function(require,module,exports){
1103
  'use strict';
1104
 
1116
 
1117
  function render() {
1118
  var html = '';
1119
+ for (var key in notices) {
1120
  html += '<div class="notice notice-warning inline"><p>' + notices[key] + '</p></div>';
1121
  }
1122
 
1123
  var container = document.querySelector('.mc4wp-notices');
1124
+ if (!container) {
1125
  container = document.createElement('div');
1126
  container.className = 'mc4wp-notices';
1127
  var heading = document.querySelector('h1, h2');
1128
  heading.parentNode.insertBefore(container, heading.nextSibling);
1129
  }
1130
+
1131
  container.innerHTML = html;
1132
  }
1133
 
1134
+ function init(editor, fields) {
1135
 
1136
+ var groupingsNotice = function groupingsNotice() {
1137
  var text = "Your form contains old style <code>GROUPINGS</code> fields. <br /><br />Please remove these fields from your form and then re-add them through the available field buttons to make sure your data is getting through to MailChimp correctly.";
1138
  var formCode = editor.getValue().toLowerCase();
1139
+ formCode.indexOf('name="groupings') > -1 ? show('deprecated_groupings', text) : hide('deprecated_groupings');
1140
  };
1141
 
1142
+ var requiredFieldsNotice = function requiredFieldsNotice() {
1143
  var requiredFields = fields.getAllWhere('forceRequired', true);
1144
+ var missingFields = requiredFields.filter(function (f) {
1145
+ return !editor.containsField(f.name().toUpperCase());
1146
  });
1147
 
1148
  var text = '<strong>Heads up!</strong> Your form is missing list fields that are required in MailChimp. Either add these fields to your form or mark them as optional in MailChimp.';
1149
+ text += "<br /><ul class=\"ul-square\" style=\"margin-bottom: 0;\"><li>" + missingFields.map(function (f) {
1150
+ return f.title();
1151
+ }).join('</li><li>') + '</li></ul>';
1152
 
1153
+ missingFields.length > 0 ? show('required_fields_missing', text) : hide('required_fields_missing');
1154
  };
1155
 
1156
  // old groupings
1164
  editor.on('focus', requiredFieldsNotice);
1165
  }
1166
 
 
 
1167
  module.exports = {
1168
  "init": init
1169
  };
1170
+
1171
  },{}],10:[function(require,module,exports){
1172
+ 'use strict';
1173
+
1174
+ var overlay = function overlay(m, i18n) {
1175
  'use strict';
1176
 
1177
+ var _element = void 0,
1178
+ _onCloseCallback = void 0;
1179
 
1180
  function close() {
1181
  document.removeEventListener('keydown', onKeyDown);
1187
  e = e || window.event;
1188
 
1189
  // close overlay when pressing ESC
1190
+ if (e.keyCode == 27) {
1191
  close();
1192
  }
1193
 
1194
  // prevent ENTER
1195
+ if (e.keyCode == 13) {
1196
  e.preventDefault();
1197
  }
1198
  }
1199
 
1200
  function position() {
1201
+ if (!_element) return;
1202
 
1203
  // fix for window width in IE8
1204
  var windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
1205
  var windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
1206
 
1207
+ var marginLeft = (windowWidth - _element.clientWidth - 40) / 2;
1208
+ var marginTop = (windowHeight - _element.clientHeight - 40) / 2;
1209
+
1210
+ _element.style.left = (marginLeft > 0 ? marginLeft : 0) + "px";
1211
+ _element.style.top = (marginTop > 0 ? marginTop : 0) + "px";
1212
+ }
1213
 
1214
+ function storeElementReference(vnode) {
1215
+ _element = vnode.dom;
1216
+ position();
1217
  }
1218
 
1219
  return function (content, onCloseCallback) {
1222
  document.addEventListener('keydown', onKeyDown);
1223
  window.addEventListener('resize', position);
1224
 
1225
+ return [m('div.overlay-wrap', m("div.overlay", { oncreate: storeElementReference }, [
1226
+ // close icon
1227
+ m('span', {
1228
+ "class": 'close dashicons dashicons-no',
1229
+ title: i18n.close,
1230
+ onclick: close
1231
+ }), content])), m('div.overlay-background', {
1232
+ title: i18n.close,
1233
+ onclick: close
1234
+ })];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1235
  };
1236
  };
1237
 
1238
  module.exports = overlay;
1239
+
1240
  },{}],11:[function(require,module,exports){
1241
  'use strict';
1242
 
1243
  // deps
1244
+
1245
  var i18n = window.mc4wp_forms_i18n;
1246
  var m = window.mc4wp.deps.mithril;
1247
  var events = mc4wp.events;
1257
 
1258
  // vars
1259
  var textareaElement = document.getElementById('mc4wp-form-content');
1260
+ var editor = window.formEditor = new FormEditor(textareaElement);
1261
+ var watcher = new FormWatcher(m, formEditor, settings, fields, events, helpers);
1262
+ var fieldHelper = new FieldHelper(m, tabs, formEditor, fields, events, i18n);
1263
  var notices = require('./admin/notices');
1264
 
1265
  // mount field helper on element
1266
+ m.mount(document.getElementById('mc4wp-field-wizard'), fieldHelper);
1267
 
1268
  // register fields and redraw screen in 2 seconds (fixes IE8 bug)
1269
  var fieldsFactory = new FieldsFactory(fields, i18n);
1271
  fieldsFactory.registerListsFields(settings.getSelectedLists());
1272
  fieldsFactory.registerCustomFields(mc4wp_vars.mailchimp.lists);
1273
 
1274
+ window.setTimeout(function () {
1275
+ m.redraw();
1276
+ }, 2000);
1277
 
1278
  // init notices
1279
  notices.init(editor, fields);
1284
  window.mc4wp.forms.editor = editor;
1285
  window.mc4wp.forms.fields = fields;
1286
 
1287
+ },{"./admin/field-helper.js":4,"./admin/fields-factory.js":5,"./admin/fields.js":6,"./admin/form-editor.js":7,"./admin/form-watcher.js":8,"./admin/notices":9}],12:[function(require,module,exports){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1288
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
1289
  // Distributed under an MIT license: http://codemirror.net/LICENSE
1290
 
1455
  }
1456
  });
1457
 
1458
+ },{"../../lib/codemirror":15,"../fold/xml-fold":14}],13:[function(require,module,exports){
1459
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
1460
  // Distributed under an MIT license: http://codemirror.net/LICENSE
1461
 
1523
  };
1524
  });
1525
 
1526
+ },{"../../lib/codemirror":15,"../fold/xml-fold":14}],14:[function(require,module,exports){
1527
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
1528
  // Distributed under an MIT license: http://codemirror.net/LICENSE
1529
 
1707
  };
1708
  });
1709
 
1710
+ },{"../../lib/codemirror":15}],15:[function(require,module,exports){
1711
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
1712
  // Distributed under an MIT license: http://codemirror.net/LICENSE
1713
 
1731
  var gecko = /gecko\/\d/i.test(userAgent)
1732
  var ie_upto10 = /MSIE \d/.test(userAgent)
1733
  var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent)
1734
+ var edge = /Edge\/(\d+)/.exec(userAgent)
1735
+ var ie = ie_upto10 || ie_11up || edge
1736
+ var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : +(edge || ie_11up)[1])
1737
+ var webkit = !edge && /WebKit\//.test(userAgent)
1738
  var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent)
1739
+ var chrome = !edge && /Chrome\//.test(userAgent)
1740
  var presto = /Opera\//.test(userAgent)
1741
  var safari = /Apple Computer/.test(navigator.vendor)
1742
  var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent)
1743
  var phantom = /PhantomJS/.test(userAgent)
1744
 
1745
+ var ios = !edge && /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent)
1746
  // This is woefully incomplete. Suggestions for alternative methods welcome.
1747
  var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent)
1748
  var mac = ios || /Mac/.test(platform)
1814
  } while (child = child.parentNode)
1815
  }
1816
 
1817
+ function activeElt() {
1818
+ // IE and Edge may throw an "Unspecified Error" when accessing document.activeElement.
1819
+ // IE < 10 will throw when accessed while the page is loading or in an iframe.
1820
+ // IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable.
1821
+ var activeElement
1822
+ try {
1823
+ activeElement = document.activeElement
1824
+ } catch(e) {
1825
+ activeElement = document.body || null
1826
+ }
1827
  while (activeElement && activeElement.root && activeElement.root.activeElement)
1828
  { activeElement = activeElement.root.activeElement }
1829
  return activeElement
1830
  }
 
 
 
 
 
 
1831
 
1832
  function addClass(node, cls) {
1833
  var current = node.className
1876
  }
1877
  }
1878
 
1879
+ var Delayed = function() {this.id = null};
1880
+ Delayed.prototype.set = function (ms, f) {
1881
  clearTimeout(this.id)
1882
  this.id = setTimeout(f, ms)
1883
+ };
1884
 
1885
  function indexOf(array, elt) {
1886
  for (var i = 0; i < array.length; ++i)
1974
  var extendingChars = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/
1975
  function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch) }
1976
 
1977
+ // Returns a number from the range [`0`; `str.length`] unless `pos` is outside that range.
1978
+ function skipExtendingChars(str, pos, dir) {
1979
+ while ((dir < 0 ? pos > 0 : pos < str.length) && isExtendingChar(str.charAt(pos))) { pos += dir }
1980
+ return pos
1981
+ }
1982
+
1983
+ // Returns the value from the range [`from`; `to`] that satisfies
1984
+ // `pred` and is closest to `from`. Assumes that at least `to` satisfies `pred`.
1985
+ function findFirst(pred, from, to) {
1986
+ for (;;) {
1987
+ if (Math.abs(from - to) <= 1) { return pred(from) ? from : to }
1988
+ var mid = Math.floor((from + to) / 2)
1989
+ if (pred(mid)) { to = mid }
1990
+ else { from = mid }
1991
+ }
1992
+ }
1993
+
1994
  // The display handles the DOM integration, both for input reading
1995
  // and content drawing. It holds references to DOM nodes and
1996
  // display-related state.
2178
  }
2179
 
2180
  // A Pos instance represents a position within the text.
2181
+ function Pos(line, ch, sticky) {
2182
+ if ( sticky === void 0 ) sticky = null;
2183
+
2184
+ if (!(this instanceof Pos)) { return new Pos(line, ch, sticky) }
2185
+ this.line = line
2186
+ this.ch = ch
2187
+ this.sticky = sticky
2188
  }
2189
 
2190
  // Compare two positions, return 0 if they are the same, a negative
2191
  // number when a is less, and a positive number otherwise.
2192
  function cmp(a, b) { return a.line - b.line || a.ch - b.ch }
2193
 
2194
+ function equalCursorPos(a, b) { return a.sticky == b.sticky && cmp(a, b) == 0 }
2195
+
2196
  function copyPos(x) {return Pos(x.line, x.ch)}
2197
  function maxPos(a, b) { return cmp(a, b) < 0 ? b : a }
2198
  function minPos(a, b) { return cmp(a, b) < 0 ? a : b }
2388
  if (dto > 0 || !mk.inclusiveRight && !dto)
2389
  { newParts.push({from: m.to, to: p.to}) }
2390
  parts.splice.apply(parts, newParts)
2391
+ j += newParts.length - 3
2392
  }
2393
  }
2394
  return parts
2432
  // so, return the marker for that span.
2433
  function collapsedSpanAtSide(line, start) {
2434
  var sps = sawCollapsedSpans && line.markedSpans, found
2435
+ if (sps) { for (var sp = (void 0), i = 0; i < sps.length; ++i) {
2436
  sp = sps[i]
2437
  if (sp.marker.collapsed && (start ? sp.from : sp.to) == null &&
2438
  (!found || compareCollapsedMarkers(found, sp.marker) < 0))
2473
  return line
2474
  }
2475
 
2476
+ function visualLineEnd(line) {
2477
+ var merged
2478
+ while (merged = collapsedSpanAtEnd(line))
2479
+ { line = merged.find(1, true).line }
2480
+ return line
2481
+ }
2482
+
2483
  // Returns an array of logical lines that continue the visual line
2484
  // started by the argument, or undefined if there are no such lines.
2485
  function visualLineContinued(line) {
2515
  // they are entirely covered by collapsed, non-widget span.
2516
  function lineIsHidden(doc, line) {
2517
  var sps = sawCollapsedSpans && line.markedSpans
2518
+ if (sps) { for (var sp = (void 0), i = 0; i < sps.length; ++i) {
2519
  sp = sps[i]
2520
  if (!sp.marker.collapsed) { continue }
2521
  if (sp.from == null) { return true }
2531
  }
2532
  if (span.marker.inclusiveRight && span.to == line.text.length)
2533
  { return true }
2534
+ for (var sp = (void 0), i = 0; i < line.markedSpans.length; ++i) {
2535
  sp = line.markedSpans[i]
2536
  if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to &&
2537
  (sp.to == null || sp.to != span.from) &&
2611
  if (!found) { f(from, to, "ltr") }
2612
  }
2613
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2614
  var bidiOther = null
2615
+ function getBidiPartAt(order, ch, sticky) {
2616
  var found
2617
  bidiOther = null
2618
  for (var i = 0; i < order.length; ++i) {
2619
  var cur = order[i]
2620
+ if (cur.from < ch && cur.to > ch) { return i }
2621
+ if (cur.to == ch) {
2622
+ if (cur.from != cur.to && sticky == "before") { found = i }
2623
+ else { bidiOther = i }
 
 
 
 
 
 
 
2624
  }
2625
+ if (cur.from == ch) {
2626
+ if (cur.from != cur.to && sticky != "before") { found = i }
2627
+ else { bidiOther = i }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2628
  }
2629
  }
2630
+ return found != null ? found : bidiOther
 
 
 
 
 
2631
  }
2632
 
2633
  // Bidirectional ordering algorithm
2656
  var bidiOrdering = (function() {
2657
  // Character types for codepoints 0 to 0xff
2658
  var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN"
2659
+ // Character types for codepoints 0x600 to 0x6f9
2660
+ var arabicTypes = "nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111"
2661
  function charType(code) {
2662
  if (code <= 0xf7) { return lowTypes.charAt(code) }
2663
  else if (0x590 <= code && code <= 0x5f4) { return "R" }
2664
+ else if (0x600 <= code && code <= 0x6f9) { return arabicTypes.charAt(code - 0x600) }
2665
  else if (0x6ee <= code && code <= 0x8ac) { return "r" }
2666
  else if (0x2000 <= code && code <= 0x200b) { return "w" }
2667
  else if (code == 0x200c) { return "b" }
2724
  var type$3 = types[i$4]
2725
  if (type$3 == ",") { types[i$4] = "N" }
2726
  else if (type$3 == "%") {
2727
+ var end = (void 0)
2728
  for (end = i$4 + 1; end < len && types[end] == "%"; ++end) {}
2729
  var replace = (i$4 && types[i$4-1] == "!") || (end < len && types[end] == "1") ? "1" : "N"
2730
  for (var j = i$4; j < end; ++j) { types[j] = replace }
2749
  // N2. Any remaining neutrals take the embedding direction.
2750
  for (var i$6 = 0; i$6 < len; ++i$6) {
2751
  if (isNeutral.test(types[i$6])) {
2752
+ var end$1 = (void 0)
2753
  for (end$1 = i$6 + 1; end$1 < len && isNeutral.test(types[end$1]); ++end$1) {}
2754
  var before = (i$6 ? types[i$6-1] : outerType) == "L"
2755
  var after = (end$1 < len ? types[end$1] : outerType) == "L"
2793
  lst(order).to -= m[0].length
2794
  order.push(new BidiSpan(0, len - m[0].length, len))
2795
  }
 
 
 
 
2796
 
2797
  return order
2798
  }
2807
  return order
2808
  }
2809
 
2810
+ function moveCharLogically(line, ch, dir) {
2811
+ var target = skipExtendingChars(line.text, ch + dir, dir)
2812
+ return target < 0 || target > line.text.length ? null : target
2813
+ }
2814
+
2815
+ function moveLogically(line, start, dir) {
2816
+ var ch = moveCharLogically(line, start.ch, dir)
2817
+ return ch == null ? null : new Pos(start.line, ch, dir < 0 ? "after" : "before")
2818
+ }
2819
+
2820
+ function endOfLine(visually, cm, lineObj, lineNo, dir) {
2821
+ if (visually) {
2822
+ var order = getOrder(lineObj)
2823
+ if (order) {
2824
+ var part = dir < 0 ? lst(order) : order[0]
2825
+ var moveInStorageOrder = (dir < 0) == (part.level == 1)
2826
+ var sticky = moveInStorageOrder ? "after" : "before"
2827
+ var ch
2828
+ // With a wrapped rtl chunk (possibly spanning multiple bidi parts),
2829
+ // it could be that the last bidi part is not on the last visual line,
2830
+ // since visual lines contain content order-consecutive chunks.
2831
+ // Thus, in rtl, we are looking for the first (content-order) character
2832
+ // in the rtl chunk that is on the last line (that is, the same line
2833
+ // as the last (content-order) character).
2834
+ if (part.level > 0) {
2835
+ var prep = prepareMeasureForLine(cm, lineObj)
2836
+ ch = dir < 0 ? lineObj.text.length - 1 : 0
2837
+ var targetTop = measureCharPrepared(cm, prep, ch).top
2838
+ ch = findFirst(function (ch) { return measureCharPrepared(cm, prep, ch).top == targetTop; }, (dir < 0) == (part.level == 1) ? part.from : part.to - 1, ch)
2839
+ if (sticky == "before") { ch = moveCharLogically(lineObj, ch, 1, true) }
2840
+ } else { ch = dir < 0 ? part.to : part.from }
2841
+ return new Pos(lineNo, ch, sticky)
2842
+ }
2843
+ }
2844
+ return new Pos(lineNo, dir < 0 ? lineObj.text.length : 0, dir < 0 ? "before" : "after")
2845
+ }
2846
+
2847
+ function moveVisually(cm, line, start, dir) {
2848
+ var bidi = getOrder(line)
2849
+ if (!bidi) { return moveLogically(line, start, dir) }
2850
+ if (start.ch >= line.text.length) {
2851
+ start.ch = line.text.length
2852
+ start.sticky = "before"
2853
+ } else if (start.ch <= 0) {
2854
+ start.ch = 0
2855
+ start.sticky = "after"
2856
+ }
2857
+ var partPos = getBidiPartAt(bidi, start.ch, start.sticky), part = bidi[partPos]
2858
+ if (part.level % 2 == 0 && (dir > 0 ? part.to > start.ch : part.from < start.ch)) {
2859
+ // Case 1: We move within an ltr part. Even with wrapped lines,
2860
+ // nothing interesting happens.
2861
+ return moveLogically(line, start, dir)
2862
+ }
2863
+
2864
+ var mv = function (pos, dir) { return moveCharLogically(line, pos instanceof Pos ? pos.ch : pos, dir); }
2865
+ var prep
2866
+ var getWrappedLineExtent = function (ch) {
2867
+ if (!cm.options.lineWrapping) { return {begin: 0, end: line.text.length} }
2868
+ prep = prep || prepareMeasureForLine(cm, line)
2869
+ return wrappedLineExtentChar(cm, line, prep, ch)
2870
+ }
2871
+ var wrappedLineExtent = getWrappedLineExtent(start.sticky == "before" ? mv(start, -1) : start.ch)
2872
+
2873
+ if (part.level % 2 == 1) {
2874
+ var ch = mv(start, -dir)
2875
+ if (ch != null && (dir > 0 ? ch >= part.from && ch >= wrappedLineExtent.begin : ch <= part.to && ch <= wrappedLineExtent.end)) {
2876
+ // Case 2: We move within an rtl part on the same visual line
2877
+ var sticky = dir < 0 ? "before" : "after"
2878
+ return new Pos(start.line, ch, sticky)
2879
+ }
2880
+ }
2881
+
2882
+ // Case 3: Could not move within this bidi part in this visual line, so leave
2883
+ // the current bidi part
2884
+
2885
+ var searchInVisualLine = function (partPos, dir, wrappedLineExtent) {
2886
+ var getRes = function (ch, moveInStorageOrder) { return moveInStorageOrder
2887
+ ? new Pos(start.line, mv(ch, 1), "before")
2888
+ : new Pos(start.line, ch, "after"); }
2889
+
2890
+ for (; partPos >= 0 && partPos < bidi.length; partPos += dir) {
2891
+ var part = bidi[partPos]
2892
+ var moveInStorageOrder = (dir > 0) == (part.level != 1)
2893
+ var ch = moveInStorageOrder ? wrappedLineExtent.begin : mv(wrappedLineExtent.end, -1)
2894
+ if (part.from <= ch && ch < part.to) { return getRes(ch, moveInStorageOrder) }
2895
+ ch = moveInStorageOrder ? part.from : mv(part.to, -1)
2896
+ if (wrappedLineExtent.begin <= ch && ch < wrappedLineExtent.end) { return getRes(ch, moveInStorageOrder) }
2897
+ }
2898
+ }
2899
+
2900
+ // Case 3a: Look for other bidi parts on the same visual line
2901
+ var res = searchInVisualLine(partPos + dir, dir, wrappedLineExtent)
2902
+ if (res) { return res }
2903
+
2904
+ // Case 3b: Look for other bidi parts on the next visual line
2905
+ var nextCh = dir > 0 ? wrappedLineExtent.end : mv(wrappedLineExtent.begin, -1)
2906
+ if (nextCh != null && !(dir > 0 && nextCh == line.text.length)) {
2907
+ res = searchInVisualLine(dir > 0 ? 0 : bidi.length - 1, dir, getWrappedLineExtent(nextCh))
2908
+ if (res) { return res }
2909
+ }
2910
+
2911
+ // Case 4: Nowhere to move
2912
+ return null
2913
+ }
2914
+
2915
  // EVENT HANDLING
2916
 
2917
  // Lightweight event framework. on/off also work on DOM nodes,
2918
  // registering native DOM handlers.
2919
 
2920
+ var noHandlers = []
2921
+
2922
  var on = function(emitter, type, f) {
2923
+ if (emitter.addEventListener) {
2924
+ emitter.addEventListener(type, f, false)
2925
+ } else if (emitter.attachEvent) {
2926
+ emitter.attachEvent("on" + type, f)
2927
+ } else {
2928
  var map = emitter._handlers || (emitter._handlers = {})
2929
+ map[type] = (map[type] || noHandlers).concat(f)
 
2930
  }
2931
  }
2932
 
2933
+ function getHandlers(emitter, type) {
2934
+ return emitter._handlers && emitter._handlers[type] || noHandlers
 
 
 
2935
  }
2936
 
2937
  function off(emitter, type, f) {
2938
+ if (emitter.removeEventListener) {
2939
+ emitter.removeEventListener(type, f, false)
2940
+ } else if (emitter.detachEvent) {
2941
+ emitter.detachEvent("on" + type, f)
2942
+ } else {
2943
+ var map = emitter._handlers, arr = map && map[type]
2944
+ if (arr) {
2945
+ var index = indexOf(arr, f)
2946
+ if (index > -1)
2947
+ { map[type] = arr.slice(0, index).concat(arr.slice(index + 1)) }
2948
+ }
2949
  }
2950
  }
2951
 
2952
  function signal(emitter, type /*, values...*/) {
2953
+ var handlers = getHandlers(emitter, type)
2954
  if (!handlers.length) { return }
2955
  var args = Array.prototype.slice.call(arguments, 2)
2956
  for (var i = 0; i < handlers.length; ++i) { handlers[i].apply(null, args) }
3200
  this.tabSize = tabSize || 8
3201
  this.lastColumnPos = this.lastColumnValue = 0
3202
  this.lineStart = 0
3203
+ };
3204
 
3205
+ StringStream.prototype.eol = function () {return this.pos >= this.string.length};
3206
+ StringStream.prototype.sol = function () {return this.pos == this.lineStart};
3207
+ StringStream.prototype.peek = function () {return this.string.charAt(this.pos) || undefined};
3208
+ StringStream.prototype.next = function () {
3209
+ if (this.pos < this.string.length)
3210
+ { return this.string.charAt(this.pos++) }
3211
+ };
3212
+ StringStream.prototype.eat = function (match) {
3213
+ var ch = this.string.charAt(this.pos)
3214
+ var ok
3215
+ if (typeof match == "string") { ok = ch == match }
3216
+ else { ok = ch && (match.test ? match.test(ch) : match(ch)) }
3217
+ if (ok) {++this.pos; return ch}
3218
+ };
3219
+ StringStream.prototype.eatWhile = function (match) {
3220
+ var start = this.pos
3221
+ while (this.eat(match)){}
3222
+ return this.pos > start
3223
+ };
3224
+ StringStream.prototype.eatSpace = function () {
 
3225
  var this$1 = this;
3226
 
3227
+ var start = this.pos
3228
+ while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) { ++this$1.pos }
3229
+ return this.pos > start
3230
+ };
3231
+ StringStream.prototype.skipToEnd = function () {this.pos = this.string.length};
3232
+ StringStream.prototype.skipTo = function (ch) {
3233
+ var found = this.string.indexOf(ch, this.pos)
3234
+ if (found > -1) {this.pos = found; return true}
3235
+ };
3236
+ StringStream.prototype.backUp = function (n) {this.pos -= n};
3237
+ StringStream.prototype.column = function () {
3238
+ if (this.lastColumnPos < this.start) {
3239
+ this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue)
3240
+ this.lastColumnPos = this.start
3241
+ }
3242
+ return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0)
3243
+ };
3244
+ StringStream.prototype.indentation = function () {
3245
+ return countColumn(this.string, null, this.tabSize) -
3246
+ (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0)
3247
+ };
3248
+ StringStream.prototype.match = function (pattern, consume, caseInsensitive) {
3249
+ if (typeof pattern == "string") {
3250
+ var cased = function (str) { return caseInsensitive ? str.toLowerCase() : str; }
3251
+ var substr = this.string.substr(this.pos, pattern.length)
3252
+ if (cased(substr) == cased(pattern)) {
3253
+ if (consume !== false) { this.pos += pattern.length }
3254
+ return true
 
 
 
 
 
 
3255
  }
3256
+ } else {
3257
+ var match = this.string.slice(this.pos).match(pattern)
3258
+ if (match && match.index > 0) { return null }
3259
+ if (match && consume !== false) { this.pos += match[0].length }
3260
+ return match
 
3261
  }
3262
+ };
3263
+ StringStream.prototype.current = function (){return this.string.slice(this.start, this.pos)};
3264
+ StringStream.prototype.hideFirstChars = function (n, inner) {
3265
+ this.lineStart += n
3266
+ try { return inner() }
3267
+ finally { this.lineStart -= n }
3268
+ };
3269
 
3270
  // Compute a style array (an array starting with a mode generation
3271
  // -- for invalidation -- followed by pairs of end positions and
3470
 
3471
  // Line objects. These hold state related to a line, including
3472
  // highlighting info (the styles array).
3473
+ var Line = function(text, markedSpans, estimateHeight) {
3474
  this.text = text
3475
  attachMarkedSpans(this, markedSpans)
3476
  this.height = estimateHeight ? estimateHeight(this) : 1
3477
+ };
3478
+
3479
+ Line.prototype.lineNo = function () { return lineNo(this) };
3480
  eventMixin(Line)
 
3481
 
3482
  // Change the content (text, markers) of a line. Automatically
3483
  // invalidates cached information and tries to re-estimate the
3525
  col: 0, pos: 0, cm: cm,
3526
  trailingSpace: false,
3527
  splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")}
3528
+ // hide from accessibility tree
3529
+ content.setAttribute("role", "presentation")
3530
+ builder.pre.setAttribute("role", "presentation")
3531
  lineView.measure = {}
3532
 
3533
  // Iterate over the logical lines that make up this visual line.
3534
  for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) {
3535
+ var line = i ? lineView.rest[i - 1] : lineView.line, order = (void 0)
3536
  builder.pos = 0
3537
  builder.addToken = buildToken
3538
  // Optionally wire in some hacks into the token-rendering
3614
  }
3615
  if (!m) { break }
3616
  pos += skipped + 1
3617
+ var txt$1 = (void 0)
3618
  if (m[0] == "\t") {
3619
  var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize
3620
  txt$1 = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"))
3669
  var start = builder.pos, end = start + text.length
3670
  for (;;) {
3671
  // Find the part that overlaps with the start of this text
3672
+ var part = (void 0)
3673
  for (var i = 0; i < order.length; i++) {
3674
  part = order[i]
3675
  if (part.to > start && part.from <= start) { break }
3715
  if (nextChange == pos) { // Update current marker set
3716
  spanStyle = spanEndStyle = spanStartStyle = title = css = ""
3717
  collapsed = null; nextChange = Infinity
3718
+ var foundBookmarks = [], endStyles = (void 0)
3719
  for (var j = 0; j < spans.length; ++j) {
3720
  var sp = spans[j], m = sp.marker
3721
  if (m.type == "bookmark" && sp.from == pos && m.widgetNode) {
3845
  // them to be executed when the last operation ends, or, if no
3846
  // operation is active, when a timeout fires.
3847
  function signalLater(emitter, type /*, values...*/) {
3848
+ var arr = getHandlers(emitter, type)
3849
  if (!arr.length) { return }
3850
  var args = Array.prototype.slice.call(arguments, 2), list
3851
  if (operationGroup) {
3988
 
3989
  function updateLineWidgets(cm, lineView, dims) {
3990
  if (lineView.alignable) { lineView.alignable = null }
3991
+ for (var node = lineView.node.firstChild, next = (void 0); node; node = next) {
3992
  next = node.nextSibling
3993
  if (node.className == "CodeMirror-linewidget")
3994
  { lineView.node.removeChild(node) }
4350
  // coordinates into another coordinate system. Context may be one of
4351
  // "line", "div" (display.lineDiv), "local"./null (editor), "window",
4352
  // or "page".
4353
+ function intoCoordSystem(cm, lineObj, rect, context, includeWidgets) {
4354
+ if (!includeWidgets && lineObj.widgets) { for (var i = 0; i < lineObj.widgets.length; ++i) { if (lineObj.widgets[i].above) {
4355
  var size = widgetHeight(lineObj.widgets[i])
4356
  rect.top += size; rect.bottom += size
4357
  } } }
4397
  // Returns a box for a given cursor position, which may have an
4398
  // 'other' property containing the position of the secondary cursor
4399
  // on a bidi boundary.
4400
+ // A cursor Pos(line, char, "before") is on the same visual line as `char - 1`
4401
+ // and after `char - 1` in writing order of `char - 1`
4402
+ // A cursor Pos(line, char, "after") is on the same visual line as `char`
4403
+ // and before `char` in writing order of `char`
4404
+ // Examples (upper-case letters are RTL, lower-case are LTR):
4405
+ // Pos(0, 1, ...)
4406
+ // before after
4407
+ // ab a|b a|b
4408
+ // aB a|B aB|
4409
+ // Ab |Ab A|b
4410
+ // AB B|A B|A
4411
+ // Every position after the last character on a line is considered to stick
4412
+ // to the last character on the line.
4413
  function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {
4414
  lineObj = lineObj || getLine(cm.doc, pos.line)
4415
  if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj) }
4418
  if (right) { m.left = m.right; } else { m.right = m.left }
4419
  return intoCoordSystem(cm, lineObj, m, context)
4420
  }
4421
+ var order = getOrder(lineObj), ch = pos.ch, sticky = pos.sticky
4422
+ if (ch >= lineObj.text.length) {
4423
+ ch = lineObj.text.length
4424
+ sticky = "before"
4425
+ } else if (ch <= 0) {
4426
+ ch = 0
4427
+ sticky = "after"
4428
+ }
4429
+ if (!order) { return get(sticky == "before" ? ch - 1 : ch, sticky == "before") }
4430
+
4431
+ function getBidi(ch, partPos, invert) {
4432
+ var part = order[partPos], right = (part.level % 2) != 0
4433
+ return get(invert ? ch - 1 : ch, right != invert)
4434
+ }
4435
+ var partPos = getBidiPartAt(order, ch, sticky)
4436
+ var other = bidiOther
4437
+ var val = getBidi(ch, partPos, sticky == "before")
4438
+ if (other != null) { val.other = getBidi(ch, other, sticky != "before") }
 
4439
  return val
4440
  }
4441
 
4456
  // the right of the character position, for example). When outside
4457
  // is true, that means the coordinates lie outside the line's
4458
  // vertical range.
4459
+ function PosWithInfo(line, ch, sticky, outside, xRel) {
4460
+ var pos = Pos(line, ch, sticky)
4461
  pos.xRel = xRel
4462
  if (outside) { pos.outside = true }
4463
  return pos
4468
  function coordsChar(cm, x, y) {
4469
  var doc = cm.doc
4470
  y += cm.display.viewOffset
4471
+ if (y < 0) { return PosWithInfo(doc.first, 0, null, true, -1) }
4472
  var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1
4473
  if (lineN > last)
4474
+ { return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, null, true, 1) }
4475
  if (x < 0) { x = 0 }
4476
 
4477
  var lineObj = getLine(doc, lineN)
4486
  }
4487
  }
4488
 
4489
+ function wrappedLineExtent(cm, lineObj, preparedMeasure, y) {
4490
+ var measure = function (ch) { return intoCoordSystem(cm, lineObj, measureCharPrepared(cm, preparedMeasure, ch), "line"); }
4491
+ var end = lineObj.text.length
4492
+ var begin = findFirst(function (ch) { return measure(ch - 1).bottom <= y; }, end, 0)
4493
+ end = findFirst(function (ch) { return measure(ch).top > y; }, begin, end)
4494
+ return {begin: begin, end: end}
4495
+ }
 
 
 
 
 
 
4496
 
4497
+ function wrappedLineExtentChar(cm, lineObj, preparedMeasure, target) {
4498
+ var targetTop = intoCoordSystem(cm, lineObj, measureCharPrepared(cm, preparedMeasure, target), "line").top
4499
+ return wrappedLineExtent(cm, lineObj, preparedMeasure, targetTop)
4500
+ }
4501
 
4502
+ function coordsCharInner(cm, lineObj, lineNo, x, y) {
4503
+ y -= heightAtLine(lineObj)
4504
+ var begin = 0, end = lineObj.text.length
4505
+ var preparedMeasure = prepareMeasureForLine(cm, lineObj)
4506
+ var pos
4507
+ var order = getOrder(lineObj)
4508
+ if (order) {
4509
+ if (cm.options.lineWrapping) {
4510
+ ;var assign;
4511
+ ((assign = wrappedLineExtent(cm, lineObj, preparedMeasure, y), begin = assign.begin, end = assign.end, assign))
4512
+ }
4513
+ pos = new Pos(lineNo, begin)
4514
+ var beginLeft = cursorCoords(cm, pos, "line", lineObj, preparedMeasure).left
4515
+ var dir = beginLeft < x ? 1 : -1
4516
+ var prevDiff, diff = beginLeft - x, prevPos
4517
+ do {
4518
+ prevDiff = diff
4519
+ prevPos = pos
4520
+ pos = moveVisually(cm, lineObj, pos, dir)
4521
+ if (pos == null || pos.ch < begin || end <= (pos.sticky == "before" ? pos.ch - 1 : pos.ch)) {
4522
+ pos = prevPos
4523
+ break
4524
  }
4525
+ diff = cursorCoords(cm, pos, "line", lineObj, preparedMeasure).left - x
4526
+ } while ((dir < 0) != (diff < 0) && (Math.abs(diff) <= Math.abs(prevDiff)))
4527
+ if (Math.abs(diff) > Math.abs(prevDiff)) {
4528
+ if ((diff < 0) == (prevDiff < 0)) { throw new Error("Broke out of infinite loop in coordsCharInner") }
4529
+ pos = prevPos
 
 
 
4530
  }
4531
+ } else {
4532
+ var ch = findFirst(function (ch) {
4533
+ var box = intoCoordSystem(cm, lineObj, measureCharPrepared(cm, preparedMeasure, ch), "line")
4534
+ if (box.top > y) {
4535
+ // For the cursor stickiness
4536
+ end = Math.min(ch, end)
4537
+ return true
4538
+ }
4539
+ else if (box.bottom <= y) { return false }
4540
+ else if (box.left > x) { return true }
4541
+ else if (box.right < x) { return false }
4542
+ else { return (x - box.left < box.right - x) }
4543
+ }, begin, end)
4544
+ ch = skipExtendingChars(lineObj.text, ch, 1)
4545
+ pos = new Pos(lineNo, ch, ch == end ? "before" : "after")
4546
+ }
4547
+ var coords = cursorCoords(cm, pos, "line", lineObj, preparedMeasure)
4548
+ if (y < coords.top || coords.bottom < y) { pos.outside = true }
4549
+ pos.xRel = x < coords.left ? -1 : (x > coords.right ? 1 : 0)
4550
+ return pos
4551
  }
4552
 
4553
  var measureText
4888
  var display = cm.display
4889
  var prevBottom = display.lineDiv.offsetTop
4890
  for (var i = 0; i < display.view.length; i++) {
4891
+ var cur = display.view[i], height = (void 0)
4892
  if (cur.hidden) { continue }
4893
  if (ie && ie_version < 8) {
4894
  var bot = cur.node.offsetTop + cur.node.offsetHeight
5093
  }
5094
  }
5095
 
5096
+ var NativeScrollbars = function(place, scroll, cm) {
5097
  this.cm = cm
5098
  var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar")
5099
  var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar")
5109
  this.checkedZeroWidth = false
5110
  // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
5111
  if (ie && ie_version < 8) { this.horiz.style.minHeight = this.vert.style.minWidth = "18px" }
5112
+ };
5113
 
5114
+ NativeScrollbars.prototype.update = function (measure) {
5115
+ var needsH = measure.scrollWidth > measure.clientWidth + 1
5116
+ var needsV = measure.scrollHeight > measure.clientHeight + 1
5117
+ var sWidth = measure.nativeBarWidth
5118
+
5119
+ if (needsV) {
5120
+ this.vert.style.display = "block"
5121
+ this.vert.style.bottom = needsH ? sWidth + "px" : "0"
5122
+ var totalHeight = measure.viewHeight - (needsH ? sWidth : 0)
5123
+ // A bug in IE8 can cause this value to be negative, so guard it.
5124
+ this.vert.firstChild.style.height =
5125
+ Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px"
5126
+ } else {
5127
+ this.vert.style.display = ""
5128
+ this.vert.firstChild.style.height = "0"
5129
+ }
5130
 
5131
+ if (needsH) {
5132
+ this.horiz.style.display = "block"
5133
+ this.horiz.style.right = needsV ? sWidth + "px" : "0"
5134
+ this.horiz.style.left = measure.barLeft + "px"
5135
+ var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0)
5136
+ this.horiz.firstChild.style.width =
5137
+ Math.max(0, measure.scrollWidth - measure.clientWidth + totalWidth) + "px"
5138
+ } else {
5139
+ this.horiz.style.display = ""
5140
+ this.horiz.firstChild.style.width = "0"
5141
+ }
5142
 
5143
+ if (!this.checkedZeroWidth && measure.clientHeight > 0) {
5144
+ if (sWidth == 0) { this.zeroWidthHack() }
5145
+ this.checkedZeroWidth = true
5146
+ }
 
 
 
 
 
 
 
5147
 
5148
+ return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0}
5149
+ };
 
 
5150
 
5151
+ NativeScrollbars.prototype.setScrollLeft = function (pos) {
5152
+ if (this.horiz.scrollLeft != pos) { this.horiz.scrollLeft = pos }
5153
+ if (this.disableHoriz) { this.enableZeroWidthBar(this.horiz, this.disableHoriz) }
5154
+ };
5155
+
5156
+ NativeScrollbars.prototype.setScrollTop = function (pos) {
5157
+ if (this.vert.scrollTop != pos) { this.vert.scrollTop = pos }
5158
+ if (this.disableVert) { this.enableZeroWidthBar(this.vert, this.disableVert) }
5159
+ };
5160
+
5161
+ NativeScrollbars.prototype.zeroWidthHack = function () {
5162
+ var w = mac && !mac_geMountainLion ? "12px" : "18px"
5163
+ this.horiz.style.height = this.vert.style.width = w
5164
+ this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none"
5165
+ this.disableHoriz = new Delayed
5166
+ this.disableVert = new Delayed
5167
+ };
5168
+
5169
+ NativeScrollbars.prototype.enableZeroWidthBar = function (bar, delay) {
5170
+ bar.style.pointerEvents = "auto"
5171
+ function maybeDisable() {
5172
+ // To find out whether the scrollbar is still visible, we
5173
+ // check whether the element under the pixel in the bottom
5174
+ // left corner of the scrollbar box is the scrollbar box
5175
+ // itself (when the bar is still visible) or its filler child
5176
+ // (when the bar is hidden). If it is still visible, we keep
5177
+ // it enabled, if it's hidden, we disable pointer events.
5178
+ var box = bar.getBoundingClientRect()
5179
+ var elt = document.elementFromPoint(box.left + 1, box.bottom - 1)
5180
+ if (elt != bar) { bar.style.pointerEvents = "none" }
5181
+ else { delay.set(1000, maybeDisable) }
5182
+ }
5183
+ delay.set(1000, maybeDisable)
5184
+ };
5185
+
5186
+ NativeScrollbars.prototype.clear = function () {
5187
+ var parent = this.horiz.parentNode
5188
+ parent.removeChild(this.horiz)
5189
+ parent.removeChild(this.vert)
5190
+ };
5191
 
5192
+ var NullScrollbars = function () {};
5193
 
5194
+ NullScrollbars.prototype.update = function () { return {bottom: 0, right: 0} };
5195
+ NullScrollbars.prototype.setScrollLeft = function () {};
5196
+ NullScrollbars.prototype.setScrollTop = function () {};
5197
+ NullScrollbars.prototype.clear = function () {};
 
 
5198
 
5199
  function updateScrollbars(cm, measure) {
5200
  if (!measure) { measure = measureForScrollbars(cm) }
5773
 
5774
  // DISPLAY DRAWING
5775
 
5776
+ var DisplayUpdate = function(cm, viewport, force) {
5777
  var display = cm.display
5778
 
5779
  this.viewport = viewport
5786
  this.force = force
5787
  this.dims = getDimensions(cm)
5788
  this.events = []
5789
+ };
5790
 
5791
+ DisplayUpdate.prototype.signal = function (emitter, type) {
5792
  if (hasHandler(emitter, type))
5793
  { this.events.push(arguments) }
5794
+ };
5795
+ DisplayUpdate.prototype.finish = function () {
5796
+ var this$1 = this;
5797
 
5798
  for (var i = 0; i < this.events.length; i++)
5799
  { signal.apply(null, this$1.events[i]) }
5800
+ };
5801
 
5802
  function maybeClipScrollbars(cm) {
5803
  var display = cm.display
6019
  // (and non-touching) ranges, sorted, and an integer that indicates
6020
  // which one is the primary selection (the one that's scrolled into
6021
  // view, that getCursor returns, etc).
6022
+ var Selection = function(ranges, primIndex) {
6023
  this.ranges = ranges
6024
  this.primIndex = primIndex
6025
+ };
6026
+
6027
+ Selection.prototype.primary = function () { return this.ranges[this.primIndex] };
6028
 
6029
+ Selection.prototype.equals = function (other) {
 
 
6030
  var this$1 = this;
6031
 
6032
+ if (other == this) { return true }
6033
+ if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) { return false }
6034
+ for (var i = 0; i < this.ranges.length; i++) {
6035
+ var here = this$1.ranges[i], there = other.ranges[i]
6036
+ if (!equalCursorPos(here.anchor, there.anchor) || !equalCursorPos(here.head, there.head)) { return false }
6037
+ }
6038
+ return true
6039
+ };
6040
+
6041
+ Selection.prototype.deepCopy = function () {
6042
  var this$1 = this;
6043
 
6044
+ var out = []
6045
+ for (var i = 0; i < this.ranges.length; i++)
6046
+ { out[i] = new Range(copyPos(this$1.ranges[i].anchor), copyPos(this$1.ranges[i].head)) }
6047
+ return new Selection(out, this.primIndex)
6048
+ };
6049
+
6050
+ Selection.prototype.somethingSelected = function () {
6051
  var this$1 = this;
6052
 
6053
+ for (var i = 0; i < this.ranges.length; i++)
6054
+ { if (!this$1.ranges[i].empty()) { return true } }
6055
+ return false
6056
+ };
6057
+
6058
+ Selection.prototype.contains = function (pos, end) {
6059
  var this$1 = this;
6060
 
6061
+ if (!end) { end = pos }
6062
+ for (var i = 0; i < this.ranges.length; i++) {
6063
+ var range = this$1.ranges[i]
6064
+ if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0)
6065
+ { return i }
 
 
6066
  }
6067
+ return -1
6068
+ };
6069
 
6070
+ var Range = function(anchor, head) {
6071
  this.anchor = anchor; this.head = head
6072
+ };
6073
 
6074
+ Range.prototype.from = function () { return minPos(this.anchor, this.head) };
6075
+ Range.prototype.to = function () { return maxPos(this.anchor, this.head) };
6076
+ Range.prototype.empty = function () { return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch };
 
 
 
 
6077
 
6078
  // Take an unsorted, potentially overlapping set of ranges, and
6079
  // build a selection out of it. 'Consumes' ranges array (modifying
6468
  var changes = event.changes, newChanges = []
6469
  copy.push({changes: newChanges})
6470
  for (var j = 0; j < changes.length; ++j) {
6471
+ var change = changes[j], m = (void 0)
6472
  newChanges.push({from: change.from, to: change.to, text: change.text})
6473
  if (newGroup) { for (var prop in change) { if (m = prop.match(/^spans_(\d+)$/)) {
6474
  if (indexOf(newGroup, Number(m[1])) > -1) {
6634
  if (!m.atomic) { continue }
6635
 
6636
  if (oldPos) {
6637
+ var near = m.find(dir < 0 ? 1 : -1), diff = (void 0)
6638
  if (dir < 0 ? m.inclusiveRight : m.inclusiveLeft)
6639
  { near = movePos(doc, near, -dir, near && near.line == pos.line ? line : null) }
6640
  if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0))
7012
  //
7013
  // See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html
7014
 
7015
+ var LeafChunk = function(lines) {
7016
  var this$1 = this;
7017
 
7018
  this.lines = lines
7023
  height += lines[i].height
7024
  }
7025
  this.height = height
7026
+ };
7027
+
7028
+ LeafChunk.prototype.chunkSize = function () { return this.lines.length };
7029
 
7030
+ // Remove the n lines at offset 'at'.
7031
+ LeafChunk.prototype.removeInner = function (at, n) {
 
 
7032
  var this$1 = this;
7033
 
7034
+ for (var i = at, e = at + n; i < e; ++i) {
7035
+ var line = this$1.lines[i]
7036
+ this$1.height -= line.height
7037
+ cleanUpLine(line)
7038
+ signalLater(line, "delete")
7039
+ }
7040
+ this.lines.splice(at, n)
7041
+ };
7042
+
7043
+ // Helper used to collapse a small branch into a single leaf.
7044
+ LeafChunk.prototype.collapse = function (lines) {
7045
+ lines.push.apply(lines, this.lines)
7046
+ };
7047
+
7048
+ // Insert the given array of lines at offset 'at', count them as
7049
+ // having the given height.
7050
+ LeafChunk.prototype.insertInner = function (at, lines, height) {
7051
  var this$1 = this;
7052
 
7053
+ this.height += height
7054
+ this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at))
7055
+ for (var i = 0; i < lines.length; ++i) { lines[i].parent = this$1 }
7056
+ };
7057
+
7058
+ // Used to iterate over a part of the tree.
7059
+ LeafChunk.prototype.iterN = function (at, n, op) {
7060
  var this$1 = this;
7061
 
7062
+ for (var e = at + n; at < e; ++at)
7063
+ { if (op(this$1.lines[at])) { return true } }
7064
+ };
 
7065
 
7066
+ var BranchChunk = function(children) {
7067
  var this$1 = this;
7068
 
7069
  this.children = children
7076
  this.size = size
7077
  this.height = height
7078
  this.parent = null
7079
+ };
7080
+
7081
+ BranchChunk.prototype.chunkSize = function () { return this.size };
7082
 
7083
+ BranchChunk.prototype.removeInner = function (at, n) {
 
 
7084
  var this$1 = this;
7085
 
7086
+ this.size -= n
7087
+ for (var i = 0; i < this.children.length; ++i) {
7088
+ var child = this$1.children[i], sz = child.chunkSize()
7089
+ if (at < sz) {
7090
+ var rm = Math.min(n, sz - at), oldHeight = child.height
7091
+ child.removeInner(at, rm)
7092
+ this$1.height -= oldHeight - child.height
7093
+ if (sz == rm) { this$1.children.splice(i--, 1); child.parent = null }
7094
+ if ((n -= rm) == 0) { break }
7095
+ at = 0
7096
+ } else { at -= sz }
7097
+ }
7098
+ // If the result is smaller than 25 lines, ensure that it is a
7099
+ // single leaf node.
7100
+ if (this.size - n < 25 &&
7101
+ (this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) {
7102
+ var lines = []
7103
+ this.collapse(lines)
7104
+ this.children = [new LeafChunk(lines)]
7105
+ this.children[0].parent = this
7106
+ }
7107
+ };
7108
+
7109
+ BranchChunk.prototype.collapse = function (lines) {
7110
  var this$1 = this;
7111
 
7112
+ for (var i = 0; i < this.children.length; ++i) { this$1.children[i].collapse(lines) }
7113
+ };
7114
+
7115
+ BranchChunk.prototype.insertInner = function (at, lines, height) {
7116
  var this$1 = this;
7117
 
7118
+ this.size += lines.length
7119
+ this.height += height
7120
+ for (var i = 0; i < this.children.length; ++i) {
7121
+ var child = this$1.children[i], sz = child.chunkSize()
7122
+ if (at <= sz) {
7123
+ child.insertInner(at, lines, height)
7124
+ if (child.lines && child.lines.length > 50) {
7125
+ // To avoid memory thrashing when child.lines is huge (e.g. first view of a large file), it's never spliced.
7126
+ // Instead, small slices are taken. They're taken in order because sequential memory accesses are fastest.
7127
+ var remaining = child.lines.length % 25 + 25
7128
+ for (var pos = remaining; pos < child.lines.length;) {
7129
+ var leaf = new LeafChunk(child.lines.slice(pos, pos += 25))
7130
+ child.height -= leaf.height
7131
+ this$1.children.splice(++i, 0, leaf)
7132
+ leaf.parent = this$1
 
 
 
7133
  }
7134
+ child.lines = child.lines.slice(0, remaining)
7135
+ this$1.maybeSpill()
7136
  }
7137
+ break
7138
  }
7139
+ at -= sz
7140
+ }
7141
+ };
7142
+
7143
+ // When a node has grown, check whether it should be split.
7144
+ BranchChunk.prototype.maybeSpill = function () {
7145
+ if (this.children.length <= 10) { return }
7146
+ var me = this
7147
+ do {
7148
+ var spilled = me.children.splice(me.children.length - 5, 5)
7149
+ var sibling = new BranchChunk(spilled)
7150
+ if (!me.parent) { // Become the parent node
7151
+ var copy = new BranchChunk(me.children)
7152
+ copy.parent = me
7153
+ me.children = [copy, sibling]
7154
+ me = copy
7155
+ } else {
7156
+ me.size -= sibling.size
7157
+ me.height -= sibling.height
7158
+ var myIndex = indexOf(me.parent.children, me)
7159
+ me.parent.children.splice(myIndex + 1, 0, sibling)
7160
+ }
7161
+ sibling.parent = me.parent
7162
+ } while (me.children.length > 10)
7163
+ me.parent.maybeSpill()
7164
+ };
7165
+
7166
+ BranchChunk.prototype.iterN = function (at, n, op) {
7167
  var this$1 = this;
7168
 
7169
+ for (var i = 0; i < this.children.length; ++i) {
7170
+ var child = this$1.children[i], sz = child.chunkSize()
7171
+ if (at < sz) {
7172
+ var used = Math.min(n, sz - at)
7173
+ if (child.iterN(at, used, op)) { return true }
7174
+ if ((n -= used) == 0) { break }
7175
+ at = 0
7176
+ } else { at -= sz }
 
7177
  }
7178
+ };
7179
 
7180
  // Line widgets are block elements displayed above or below a line.
7181
 
7182
+ var LineWidget = function(doc, node, options) {
7183
  var this$1 = this;
7184
 
7185
  if (options) { for (var opt in options) { if (options.hasOwnProperty(opt))
7186
  { this$1[opt] = options[opt] } } }
7187
  this.doc = doc
7188
  this.node = node
7189
+ };
 
 
 
 
 
 
7190
 
7191
+ LineWidget.prototype.clear = function () {
7192
+ var this$1 = this;
7193
 
7194
  var cm = this.doc.cm, ws = this.line.widgets, line = this.line, no = lineNo(line)
7195
  if (no == null || !ws) { return }
7197
  if (!ws.length) { line.widgets = null }
7198
  var height = widgetHeight(this)
7199
  updateLineHeight(line, Math.max(0, line.height - height))
7200
+ if (cm) {
7201
+ runInOp(cm, function () {
7202
+ adjustScrollWhenAboveVisible(cm, line, -height)
7203
+ regLineChange(cm, no, "widget")
7204
+ })
7205
+ signalLater(cm, "lineWidgetCleared", cm, this, no)
7206
+ }
7207
+ };
7208
+
7209
+ LineWidget.prototype.changed = function () {
7210
+ var this$1 = this;
7211
+
7212
  var oldH = this.height, cm = this.doc.cm, line = this.line
7213
  this.height = null
7214
  var diff = widgetHeight(this) - oldH
7215
  if (!diff) { return }
7216
  updateLineHeight(line, line.height + diff)
7217
+ if (cm) {
7218
+ runInOp(cm, function () {
7219
+ cm.curOp.forceUpdate = true
7220
+ adjustScrollWhenAboveVisible(cm, line, diff)
7221
+ signalLater(cm, "lineWidgetChanged", cm, this$1, lineNo(line))
7222
+ })
7223
+ }
7224
+ };
7225
+ eventMixin(LineWidget)
7226
+
7227
+ function adjustScrollWhenAboveVisible(cm, line, diff) {
7228
+ if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop))
7229
+ { addToScrollPos(cm, null, diff) }
7230
  }
7231
 
7232
  function addLineWidget(doc, handle, node, options) {
7246
  }
7247
  return true
7248
  })
7249
+ signalLater(cm, "lineWidgetAdded", cm, widget, typeof handle == "number" ? handle : lineNo(handle))
7250
  return widget
7251
  }
7252
 
7267
  // when they overlap (they may nest, but not partially overlap).
7268
  var nextMarkerId = 0
7269
 
7270
+ var TextMarker = function(doc, type) {
7271
  this.lines = []
7272
  this.type = type
7273
  this.doc = doc
7274
  this.id = ++nextMarkerId
7275
+ };
 
7276
 
7277
  // Clear the marker.
7278
+ TextMarker.prototype.clear = function () {
7279
+ var this$1 = this;
7280
 
7281
  if (this.explicitlyCleared) { return }
7282
  var cm = this.doc.cm, withOp = cm && !cm.curOp
7314
  this.doc.cantEdit = false
7315
  if (cm) { reCheckSelection(cm.doc) }
7316
  }
7317
+ if (cm) { signalLater(cm, "markerCleared", cm, this, min, max) }
7318
  if (withOp) { endOperation(cm) }
7319
  if (this.parent) { this.parent.clear() }
7320
+ };
7321
 
7322
  // Find the position of the marker in the document. Returns a {from,
7323
  // to} object by default. Side can be passed to get a specific side
7324
  // -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the
7325
  // Pos objects returned contain a line object, rather than a line
7326
  // number (used to prevent looking up the same line twice).
7327
+ TextMarker.prototype.find = function (side, lineObj) {
7328
+ var this$1 = this;
7329
 
7330
  if (side == null && this.type == "bookmark") { side = 1 }
7331
  var from, to
7342
  }
7343
  }
7344
  return from && {from: from, to: to}
7345
+ };
7346
 
7347
  // Signals that the marker's widget changed, and surrounding layout
7348
  // should be recomputed.
7349
+ TextMarker.prototype.changed = function () {
7350
+ var this$1 = this;
7351
+
7352
  var pos = this.find(-1, true), widget = this, cm = this.doc.cm
7353
  if (!pos || !cm) { return }
7354
  runInOp(cm, function () {
7366
  if (dHeight)
7367
  { updateLineHeight(line, line.height + dHeight) }
7368
  }
7369
+ signalLater(cm, "markerChanged", cm, this$1)
7370
  })
7371
+ };
7372
 
7373
+ TextMarker.prototype.attachLine = function (line) {
7374
  if (!this.lines.length && this.doc.cm) {
7375
  var op = this.doc.cm.curOp
7376
  if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1)
7377
  { (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this) }
7378
  }
7379
  this.lines.push(line)
7380
+ };
7381
+
7382
+ TextMarker.prototype.detachLine = function (line) {
7383
  this.lines.splice(indexOf(this.lines, line), 1)
7384
  if (!this.lines.length && this.doc.cm) {
7385
  var op = this.doc.cm.curOp
7386
  ;(op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this)
7387
  }
7388
+ };
7389
+ eventMixin(TextMarker)
7390
 
7391
  // Create a marker, wire it up to the right lines, and
7392
  function markText(doc, from, to, options, type) {
7406
  // Showing up as a widget implies collapsed (widget replaces text)
7407
  marker.collapsed = true
7408
  marker.widgetNode = elt("span", [marker.replacedWith], "CodeMirror-widget")
7409
+ marker.widgetNode.setAttribute("role", "presentation") // hide from accessibility tree
7410
  if (!options.handleMouseEvents) { marker.widgetNode.setAttribute("cm-ignore-events", "true") }
7411
  if (options.insertLeft) { marker.widgetNode.insertLeft = true }
7412
  }
7464
  // A shared marker spans multiple linked documents. It is
7465
  // implemented as a meta-marker-object controlling multiple normal
7466
  // markers.
7467
+ var SharedTextMarker = function(markers, primary) {
7468
  var this$1 = this;
7469
 
7470
  this.markers = markers
7471
  this.primary = primary
7472
  for (var i = 0; i < markers.length; ++i)
7473
  { markers[i].parent = this$1 }
7474
+ };
 
7475
 
7476
+ SharedTextMarker.prototype.clear = function () {
7477
+ var this$1 = this;
7478
 
7479
  if (this.explicitlyCleared) { return }
7480
  this.explicitlyCleared = true
7481
  for (var i = 0; i < this.markers.length; ++i)
7482
  { this$1.markers[i].clear() }
7483
  signalLater(this, "clear")
7484
+ };
7485
+
7486
+ SharedTextMarker.prototype.find = function (side, lineObj) {
7487
  return this.primary.find(side, lineObj)
7488
+ };
7489
+ eventMixin(SharedTextMarker)
7490
 
7491
  function markTextShared(doc, from, to, options, type) {
7492
  options = copyObj(options)
7743
  hist.undone = copyHistoryArray(histData.undone.slice(0), null, true)
7744
  },
7745
 
7746
+ setGutterMarker: docMethodOp(function(line, gutterID, value) {
7747
+ return changeLine(this, line, "gutter", function (line) {
7748
+ var markers = line.gutterMarkers || (line.gutterMarkers = {})
7749
+ markers[gutterID] = value
7750
+ if (!value && isEmpty(markers)) { line.gutterMarkers = null }
7751
+ return true
7752
+ })
7753
+ }),
7754
+
7755
+ clearGutter: docMethodOp(function(gutterID) {
7756
+ var this$1 = this;
7757
+
7758
+ this.iter(function (line) {
7759
+ if (line.gutterMarkers && line.gutterMarkers[gutterID]) {
7760
+ changeLine(this$1, line, "gutter", function () {
7761
+ line.gutterMarkers[gutterID] = null
7762
+ if (isEmpty(line.gutterMarkers)) { line.gutterMarkers = null }
7763
+ return true
7764
+ })
7765
+ }
7766
+ })
7767
+ }),
7768
+
7769
+ lineInfo: function(line) {
7770
+ var n
7771
+ if (typeof line == "number") {
7772
+ if (!isLine(this, line)) { return null }
7773
+ n = line
7774
+ line = getLine(this, line)
7775
+ if (!line) { return null }
7776
+ } else {
7777
+ n = lineNo(line)
7778
+ if (n == null) { return null }
7779
+ }
7780
+ return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers,
7781
+ textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass,
7782
+ widgets: line.widgets}
7783
+ },
7784
+
7785
  addLineClass: docMethodOp(function(handle, where, cls) {
7786
  return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function (line) {
7787
  var prop = where == "text" ? "textClass"
8191
 
8192
  var keys = map(keyname.split(" "), normalizeKeyName)
8193
  for (var i = 0; i < keys.length; i++) {
8194
+ var val = (void 0), name = (void 0)
8195
  if (i == keys.length - 1) {
8196
  name = keys.join(" ")
8197
  val = value
8421
  var line = getLine(cm.doc, lineN)
8422
  var visual = visualLine(line)
8423
  if (visual != line) { lineN = lineNo(visual) }
8424
+ return endOfLine(true, cm, visual, lineN, 1)
 
 
8425
  }
8426
  function lineEnd(cm, lineN) {
8427
+ var line = getLine(cm.doc, lineN)
8428
+ var visual = visualLineEnd(line)
8429
+ if (visual != line) { lineN = lineNo(visual) }
8430
+ return endOfLine(true, cm, line, lineN, -1)
 
 
 
 
8431
  }
8432
  function lineStartSmart(cm, pos) {
8433
  var start = lineStart(cm, pos.line)
8436
  if (!order || order[0].level == 0) {
8437
  var firstNonWS = Math.max(0, line.text.search(/\S/))
8438
  var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch
8439
+ return Pos(start.line, inWS ? 0 : firstNonWS, start.sticky)
8440
  }
8441
  return start
8442
  }
8590
  function onMouseDown(e) {
8591
  var cm = this, display = cm.display
8592
  if (signalDOMEvent(cm, e) || display.activeTouch && display.input.supportsTouch()) { return }
8593
+ display.input.ensurePolled()
8594
  display.shift = e.shiftKey
8595
 
8596
  if (eventInWidget(display, e)) {
8936
  for (var i = newBreaks.length - 1; i >= 0; i--)
8937
  { replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)) }
8938
  })
8939
+ option("specialChars", /[\u0000-\u001f\u007f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff]/g, function (cm, val, old) {
8940
  cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g")
8941
  if (old != Init) { cm.refresh() }
8942
  })
9026
  function guttersChanged(cm) {
9027
  updateGutters(cm)
9028
  regChange(cm)
9029
+ alignHorizontally(cm)
9030
  }
9031
 
9032
  function dragDropChanged(cm, value, old) {
9081
  themeChanged(this)
9082
  if (options.lineWrapping)
9083
  { this.display.wrapper.className += " CodeMirror-wrap" }
 
9084
  initScrollbars(this)
9085
 
9086
  this.state = {
9099
  specialChars: null
9100
  }
9101
 
9102
+ if (options.autofocus && !mobile) { display.input.focus() }
9103
+
9104
  // Override magic textarea content restore that IE sometimes does
9105
  // on our hidden textarea on reload
9106
  if (ie && ie_version < 11) { setTimeout(function () { return this$1.display.input.reset(true); }, 20) }
9177
  }
9178
  on(d.scroller, "touchstart", function (e) {
9179
  if (!signalDOMEvent(cm, e) && !isMouseLikeTouchEvent(e)) {
9180
+ d.input.ensurePolled()
9181
  clearTimeout(touchFinished)
9182
  var now = +new Date
9183
  d.activeTouch = {start: now, moved: false,
9456
  options[option] = value
9457
  if (optionHandlers.hasOwnProperty(option))
9458
  { operation(this, optionHandlers[option])(this, value, old) }
9459
+ signal(this, "optionChange", this, option)
9460
  },
9461
 
9462
  getOption: function(option) {return this.options[option]},
9618
  height = fromCoordSystem(this, {top: height, left: 0}, mode || "page").top
9619
  return lineAtHeight(this.doc, height + this.display.viewOffset)
9620
  },
9621
+ heightAtLine: function(line, mode, includeWidgets) {
9622
  var end = false, lineObj
9623
  if (typeof line == "number") {
9624
  var last = this.doc.first + this.doc.size - 1
9628
  } else {
9629
  lineObj = line
9630
  }
9631
+ return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page", includeWidgets || end).top +
9632
  (end ? this.doc.height - heightAtLine(lineObj) : 0)
9633
  },
9634
 
9635
  defaultTextHeight: function() { return textHeight(this.display) },
9636
  defaultCharWidth: function() { return charWidth(this.display) },
9637
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9638
  getViewport: function() { return {from: this.display.viewFrom, to: this.display.viewTo}},
9639
 
9640
  addWidget: function(pos, node, scroll, vert, horiz) {
9760
  var start = pos.ch, end = pos.ch
9761
  if (line) {
9762
  var helper = this.getHelper(pos, "wordChars")
9763
+ if ((pos.sticky == "before" || end == line.length) && start) { --start; } else { ++end }
9764
  var startChar = line.charAt(start)
9765
  var check = isWordChar(startChar, helper)
9766
  ? function (ch) { return isWordChar(ch, helper); }
9891
  // position. The resulting position will have a hitSide=true
9892
  // property if it reached the end of the document.
9893
  function findPosH(doc, pos, dir, unit, visually) {
9894
+ var oldPos = pos
9895
+ var origDir = dir
9896
+ var lineObj = getLine(doc, pos.line)
9897
  function findNextLine() {
9898
+ var l = pos.line + dir
9899
  if (l < doc.first || l >= doc.first + doc.size) { return false }
9900
+ pos = new Pos(l, pos.ch, pos.sticky)
9901
  return lineObj = getLine(doc, l)
9902
  }
9903
  function moveOnce(boundToLine) {
9904
+ var next
9905
+ if (visually) {
9906
+ next = moveVisually(doc.cm, lineObj, pos, dir)
9907
+ } else {
9908
+ next = moveLogically(lineObj, pos, dir)
9909
+ }
9910
  if (next == null) {
9911
+ if (!boundToLine && findNextLine())
9912
+ { pos = endOfLine(visually, doc.cm, lineObj, pos.line, dir) }
9913
+ else
9914
+ { return false }
9915
+ } else {
9916
+ pos = next
9917
+ }
9918
  return true
9919
  }
9920
 
9927
  var helper = doc.cm && doc.cm.getHelper(pos, "wordChars")
9928
  for (var first = true;; first = false) {
9929
  if (dir < 0 && !moveOnce(!first)) { break }
9930
+ var cur = lineObj.text.charAt(pos.ch) || "\n"
9931
  var type = isWordChar(cur, helper) ? "w"
9932
  : group && cur == "\n" ? "n"
9933
  : !group || /\s/.test(cur) ? null
9934
  : "p"
9935
  if (group && !first && !type) { type = "s" }
9936
  if (sawType && sawType != type) {
9937
+ if (dir < 0) {dir = 1; moveOnce(); pos.sticky = "after"}
9938
  break
9939
  }
9940
 
9942
  if (dir > 0 && !moveOnce(!first)) { break }
9943
  }
9944
  }
9945
+ var result = skipAtomic(doc, pos, oldPos, origDir, true)
9946
+ if (equalCursorPos(oldPos, result)) { result.hitSide = true }
9947
  return result
9948
  }
9949
 
9972
 
9973
  // CONTENTEDITABLE INPUT STYLE
9974
 
9975
+ var ContentEditableInput = function(cm) {
9976
  this.cm = cm
9977
  this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null
9978
  this.polling = new Delayed()
9979
+ this.composing = null
9980
  this.gracePeriod = false
9981
+ this.readDOMTimeout = null
9982
+ };
9983
 
9984
+ ContentEditableInput.prototype.init = function (display) {
9985
+ var this$1 = this;
 
 
 
9986
 
9987
+ var input = this, cm = input.cm
9988
+ var div = input.div = display.lineDiv
9989
+ disableBrowserMagic(div, cm.options.spellcheck)
 
 
 
 
9990
 
9991
+ on(div, "paste", function (e) {
9992
+ if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }
9993
+ // IE doesn't fire input events, so we schedule a read for the pasted content in this way
9994
+ if (ie_version <= 11) { setTimeout(operation(cm, function () {
9995
+ if (!input.pollContent()) { regChange(cm) }
9996
+ }), 20) }
9997
+ })
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9998
 
9999
+ on(div, "compositionstart", function (e) {
10000
+ this$1.composing = {data: e.data, done: false}
10001
+ })
10002
+ on(div, "compositionupdate", function (e) {
10003
+ if (!this$1.composing) { this$1.composing = {data: e.data, done: false} }
10004
+ })
10005
+ on(div, "compositionend", function (e) {
10006
+ if (this$1.composing) {
10007
+ if (e.data != this$1.composing.data) { this$1.readFromDOMSoon() }
10008
+ this$1.composing.done = true
10009
+ }
10010
+ })
10011
 
10012
+ on(div, "touchstart", function () { return input.forceCompositionEnd(); })
 
 
 
 
10013
 
10014
+ on(div, "input", function () {
10015
+ if (!this$1.composing) { this$1.readFromDOMSoon() }
10016
+ })
10017
+
10018
+ function onCopyCut(e) {
10019
+ if (signalDOMEvent(cm, e)) { return }
10020
+ if (cm.somethingSelected()) {
10021
+ setLastCopied({lineWise: false, text: cm.getSelections()})
10022
+ if (e.type == "cut") { cm.replaceSelection("", null, "cut") }
10023
+ } else if (!cm.options.lineWiseCopyCut) {
10024
+ return
10025
+ } else {
10026
+ var ranges = copyableRanges(cm)
10027
+ setLastCopied({lineWise: true, text: ranges.text})
10028
+ if (e.type == "cut") {
10029
+ cm.operation(function () {
10030
+ cm.setSelections(ranges.ranges, 0, sel_dontScroll)
10031
+ cm.replaceSelection("", null, "cut")
10032
+ })
10033
  }
10034
+ }
10035
+ if (e.clipboardData) {
10036
+ e.clipboardData.clearData()
10037
+ var content = lastCopied.text.join("\n")
10038
+ // iOS exposes the clipboard API, but seems to discard content inserted into it
10039
+ e.clipboardData.setData("Text", content)
10040
+ if (e.clipboardData.getData("Text") == content) {
10041
+ e.preventDefault()
10042
+ return
10043
  }
 
 
 
 
 
 
 
 
 
 
 
10044
  }
10045
+ // Old-fashioned briefly-focus-a-textarea hack
10046
+ var kludge = hiddenTextarea(), te = kludge.firstChild
10047
+ cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild)
10048
+ te.value = lastCopied.text.join("\n")
10049
+ var hadFocus = document.activeElement
10050
+ selectInput(te)
10051
+ setTimeout(function () {
10052
+ cm.display.lineSpace.removeChild(kludge)
10053
+ hadFocus.focus()
10054
+ if (hadFocus == div) { input.showPrimarySelection() }
10055
+ }, 50)
10056
+ }
10057
+ on(div, "copy", onCopyCut)
10058
+ on(div, "cut", onCopyCut)
10059
+ };
10060
 
10061
+ ContentEditableInput.prototype.prepareSelection = function () {
10062
+ var result = prepareSelection(this.cm, false)
10063
+ result.focus = this.cm.state.focused
10064
+ return result
10065
+ };
10066
 
10067
+ ContentEditableInput.prototype.showSelection = function (info, takeFocus) {
10068
+ if (!info || !this.cm.display.view.length) { return }
10069
+ if (info.focus || takeFocus) { this.showPrimarySelection() }
10070
+ this.showMultipleSelections(info)
10071
+ };
10072
 
10073
+ ContentEditableInput.prototype.showPrimarySelection = function () {
10074
+ var sel = window.getSelection(), prim = this.cm.doc.sel.primary()
10075
+ var curAnchor = domToPos(this.cm, sel.anchorNode, sel.anchorOffset)
10076
+ var curFocus = domToPos(this.cm, sel.focusNode, sel.focusOffset)
10077
+ if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad &&
10078
+ cmp(minPos(curAnchor, curFocus), prim.from()) == 0 &&
10079
+ cmp(maxPos(curAnchor, curFocus), prim.to()) == 0)
10080
+ { return }
10081
+
10082
+ var start = posToDOM(this.cm, prim.from())
10083
+ var end = posToDOM(this.cm, prim.to())
10084
+ if (!start && !end) { return }
10085
+
10086
+ var view = this.cm.display.view
10087
+ var old = sel.rangeCount && sel.getRangeAt(0)
10088
+ if (!start) {
10089
+ start = {node: view[0].measure.map[2], offset: 0}
10090
+ } else if (!end) { // FIXME dangerously hacky
10091
+ var measure = view[view.length - 1].measure
10092
+ var map = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map
10093
+ end = {node: map[map.length - 1], offset: map[map.length - 2] - map[map.length - 3]}
10094
+ }
10095
+
10096
+ var rng
10097
+ try { rng = range(start.node, start.offset, end.offset, end.node) }
10098
+ catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible
10099
+ if (rng) {
10100
+ if (!gecko && this.cm.state.focused) {
10101
+ sel.collapse(start.node, start.offset)
10102
+ if (!rng.collapsed) {
 
 
 
 
10103
  sel.removeAllRanges()
10104
  sel.addRange(rng)
10105
  }
10106
+ } else {
10107
+ sel.removeAllRanges()
10108
+ sel.addRange(rng)
10109
  }
10110
+ if (old && sel.anchorNode == null) { sel.addRange(old) }
10111
+ else if (gecko) { this.startGracePeriod() }
10112
+ }
10113
+ this.rememberSelection()
10114
+ };
10115
 
10116
+ ContentEditableInput.prototype.startGracePeriod = function () {
10117
  var this$1 = this;
10118
 
10119
+ clearTimeout(this.gracePeriod)
10120
+ this.gracePeriod = setTimeout(function () {
10121
+ this$1.gracePeriod = false
10122
+ if (this$1.selectionChanged())
10123
+ { this$1.cm.operation(function () { return this$1.cm.curOp.selectionChanged = true; }) }
10124
+ }, 20)
10125
+ };
10126
 
10127
+ ContentEditableInput.prototype.showMultipleSelections = function (info) {
10128
+ removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors)
10129
+ removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection)
10130
+ };
10131
 
10132
+ ContentEditableInput.prototype.rememberSelection = function () {
10133
+ var sel = window.getSelection()
10134
+ this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset
10135
+ this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset
10136
+ };
10137
 
10138
+ ContentEditableInput.prototype.selectionInEditor = function () {
10139
+ var sel = window.getSelection()
10140
+ if (!sel.rangeCount) { return false }
10141
+ var node = sel.getRangeAt(0).commonAncestorContainer
10142
+ return contains(this.div, node)
10143
+ };
10144
 
10145
+ ContentEditableInput.prototype.focus = function () {
10146
+ if (this.cm.options.readOnly != "nocursor") {
10147
+ if (!this.selectionInEditor())
10148
+ { this.showSelection(this.prepareSelection(), true) }
10149
+ this.div.focus()
10150
+ }
10151
+ };
10152
+ ContentEditableInput.prototype.blur = function () { this.div.blur() };
10153
+ ContentEditableInput.prototype.getField = function () { return this.div };
10154
 
10155
+ ContentEditableInput.prototype.supportsTouch = function () { return true };
10156
 
10157
+ ContentEditableInput.prototype.receivedFocus = function () {
10158
+ var input = this
10159
+ if (this.selectionInEditor())
10160
+ { this.pollSelection() }
10161
+ else
10162
+ { runInOp(this.cm, function () { return input.cm.curOp.selectionChanged = true; }) }
10163
 
10164
+ function poll() {
10165
+ if (input.cm.state.focused) {
10166
+ input.pollSelection()
10167
+ input.polling.set(input.cm.options.pollInterval, poll)
 
10168
  }
10169
+ }
10170
+ this.polling.set(this.cm.options.pollInterval, poll)
10171
+ };
10172
 
10173
+ ContentEditableInput.prototype.selectionChanged = function () {
10174
+ var sel = window.getSelection()
10175
+ return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset ||
10176
+ sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset
10177
+ };
10178
 
10179
+ ContentEditableInput.prototype.pollSelection = function () {
10180
+ if (!this.composing && this.readDOMTimeout == null && !this.gracePeriod && this.selectionChanged()) {
10181
+ var sel = window.getSelection(), cm = this.cm
10182
+ this.rememberSelection()
10183
+ var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset)
10184
+ var head = domToPos(cm, sel.focusNode, sel.focusOffset)
10185
+ if (anchor && head) { runInOp(cm, function () {
10186
+ setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll)
10187
+ if (anchor.bad || head.bad) { cm.curOp.selectionChanged = true }
10188
+ }) }
10189
+ }
10190
+ };
10191
 
10192
+ ContentEditableInput.prototype.pollContent = function () {
10193
+ if (this.readDOMTimeout != null) {
10194
+ clearTimeout(this.readDOMTimeout)
10195
+ this.readDOMTimeout = null
10196
+ }
10197
 
10198
+ var cm = this.cm, display = cm.display, sel = cm.doc.sel.primary()
10199
+ var from = sel.from(), to = sel.to()
10200
+ if (from.ch == 0 && from.line > cm.firstLine())
10201
+ { from = Pos(from.line - 1, getLine(cm.doc, from.line - 1).length) }
10202
+ if (to.ch == getLine(cm.doc, to.line).text.length && to.line < cm.lastLine())
10203
+ { to = Pos(to.line + 1, 0) }
10204
+ if (from.line < display.viewFrom || to.line > display.viewTo - 1) { return false }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10205
 
10206
+ var fromIndex, fromLine, fromNode
10207
+ if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) {
10208
+ fromLine = lineNo(display.view[0].line)
10209
+ fromNode = display.view[0].node
10210
+ } else {
10211
+ fromLine = lineNo(display.view[fromIndex].line)
10212
+ fromNode = display.view[fromIndex - 1].node.nextSibling
10213
+ }
10214
+ var toIndex = findViewIndex(cm, to.line)
10215
+ var toLine, toNode
10216
+ if (toIndex == display.view.length - 1) {
10217
+ toLine = display.viewTo - 1
10218
+ toNode = display.lineDiv.lastChild
10219
+ } else {
10220
+ toLine = lineNo(display.view[toIndex + 1].line) - 1
10221
+ toNode = display.view[toIndex + 1].node.previousSibling
10222
+ }
 
 
10223
 
10224
+ if (!fromNode) { return false }
10225
+ var newText = cm.doc.splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine))
10226
+ var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length))
10227
+ while (newText.length > 1 && oldText.length > 1) {
10228
+ if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine-- }
10229
+ else if (newText[0] == oldText[0]) { newText.shift(); oldText.shift(); fromLine++ }
10230
+ else { break }
10231
+ }
10232
 
10233
+ var cutFront = 0, cutEnd = 0
10234
+ var newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length)
10235
+ while (cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront))
10236
+ { ++cutFront }
10237
+ var newBot = lst(newText), oldBot = lst(oldText)
10238
+ var maxCutEnd = Math.min(newBot.length - (newText.length == 1 ? cutFront : 0),
10239
+ oldBot.length - (oldText.length == 1 ? cutFront : 0))
10240
+ while (cutEnd < maxCutEnd &&
10241
+ newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1))
10242
+ { ++cutEnd }
10243
+
10244
+ newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd).replace(/^\u200b+/, "")
10245
+ newText[0] = newText[0].slice(cutFront).replace(/\u200b+$/, "")
10246
+
10247
+ var chFrom = Pos(fromLine, cutFront)
10248
+ var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0)
10249
+ if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) {
10250
+ replaceRange(cm.doc, newText, chFrom, chTo, "+input")
10251
+ return true
10252
+ }
10253
+ };
10254
 
10255
+ ContentEditableInput.prototype.ensurePolled = function () {
10256
+ this.forceCompositionEnd()
10257
+ };
10258
+ ContentEditableInput.prototype.reset = function () {
10259
+ this.forceCompositionEnd()
10260
+ };
10261
+ ContentEditableInput.prototype.forceCompositionEnd = function () {
10262
+ if (!this.composing) { return }
10263
+ clearTimeout(this.readDOMTimeout)
10264
+ this.composing = null
10265
+ if (!this.pollContent()) { regChange(this.cm) }
10266
+ this.div.blur()
10267
+ this.div.focus()
10268
+ };
10269
+ ContentEditableInput.prototype.readFromDOMSoon = function () {
10270
+ var this$1 = this;
10271
+
10272
+ if (this.readDOMTimeout != null) { return }
10273
+ this.readDOMTimeout = setTimeout(function () {
10274
+ this$1.readDOMTimeout = null
10275
+ if (this$1.composing) {
10276
+ if (this$1.composing.done) { this$1.composing = null }
10277
+ else { return }
10278
+ }
10279
+ if (this$1.cm.isReadOnly() || !this$1.pollContent())
10280
+ { runInOp(this$1.cm, function () { return regChange(this$1.cm); }) }
10281
+ }, 80)
10282
+ };
10283
+
10284
+ ContentEditableInput.prototype.setUneditable = function (node) {
10285
+ node.contentEditable = "false"
10286
+ };
10287
+
10288
+ ContentEditableInput.prototype.onKeyPress = function (e) {
10289
+ if (e.charCode == 0) { return }
10290
+ e.preventDefault()
10291
+ if (!this.cm.isReadOnly())
10292
+ { operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0) }
10293
+ };
10294
+
10295
+ ContentEditableInput.prototype.readOnlyChanged = function (val) {
10296
+ this.div.contentEditable = String(val != "nocursor")
10297
+ };
10298
 
10299
+ ContentEditableInput.prototype.onContextMenu = function () {};
10300
+ ContentEditableInput.prototype.resetPosition = function () {};
10301
 
10302
+ ContentEditableInput.prototype.needsContentAttribute = true
 
10303
 
10304
  function posToDOM(cm, pos) {
10305
  var view = findViewForLine(cm, pos.line)
10326
  if (node.nodeType == 1) {
10327
  var cmText = node.getAttribute("cm-text")
10328
  if (cmText != null) {
10329
+ if (cmText == "") { text += node.textContent.replace(/\u200b/g, "") }
10330
+ else { text += cmText }
10331
  return
10332
  }
10333
  var markerID = node.getAttribute("cm-marker"), range
10436
 
10437
  // TEXTAREA INPUT STYLE
10438
 
10439
+ var TextareaInput = function(cm) {
10440
  this.cm = cm
10441
  // See input.poll and input.reset
10442
  this.prevInput = ""
10453
  // Used to work around IE issue with selection being forgotten when focus moves away from textarea
10454
  this.hasSelection = false
10455
  this.composing = null
10456
+ };
10457
 
10458
+ TextareaInput.prototype.init = function (display) {
 
10459
  var this$1 = this;
10460
 
10461
+ var input = this, cm = this.cm
10462
 
10463
+ // Wraps and hides input textarea
10464
+ var div = this.wrapper = hiddenTextarea()
10465
+ // The semihidden textarea that is focused when the editor is
10466
+ // focused, and receives input.
10467
+ var te = this.textarea = div.firstChild
10468
+ display.wrapper.insertBefore(div, display.wrapper.firstChild)
10469
 
10470
+ // Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore)
10471
+ if (ios) { te.style.width = "0px" }
10472
 
10473
+ on(te, "input", function () {
10474
+ if (ie && ie_version >= 9 && this$1.hasSelection) { this$1.hasSelection = null }
10475
+ input.poll()
10476
+ })
10477
 
10478
+ on(te, "paste", function (e) {
10479
+ if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }
10480
 
10481
+ cm.state.pasteIncoming = true
10482
+ input.fastPoll()
10483
+ })
10484
 
10485
+ function prepareCopyCut(e) {
10486
+ if (signalDOMEvent(cm, e)) { return }
10487
+ if (cm.somethingSelected()) {
10488
+ setLastCopied({lineWise: false, text: cm.getSelections()})
10489
+ if (input.inaccurateSelection) {
10490
+ input.prevInput = ""
10491
+ input.inaccurateSelection = false
10492
+ te.value = lastCopied.text.join("\n")
10493
+ selectInput(te)
10494
+ }
10495
+ } else if (!cm.options.lineWiseCopyCut) {
10496
+ return
10497
+ } else {
10498
+ var ranges = copyableRanges(cm)
10499
+ setLastCopied({lineWise: true, text: ranges.text})
10500
+ if (e.type == "cut") {
10501
+ cm.setSelections(ranges.ranges, null, sel_dontScroll)
10502
  } else {
10503
+ input.prevInput = ""
10504
+ te.value = ranges.text.join("\n")
10505
+ selectInput(te)
 
 
 
 
 
 
10506
  }
 
10507
  }
10508
+ if (e.type == "cut") { cm.state.cutIncoming = true }
10509
+ }
10510
+ on(te, "cut", prepareCopyCut)
10511
+ on(te, "copy", prepareCopyCut)
10512
 
10513
+ on(display.scroller, "paste", function (e) {
10514
+ if (eventInWidget(display, e) || signalDOMEvent(cm, e)) { return }
10515
+ cm.state.pasteIncoming = true
10516
+ input.focus()
10517
+ })
10518
 
10519
+ // Prevent normal selection in the editor (we handle our own)
10520
+ on(display.lineSpace, "selectstart", function (e) {
10521
+ if (!eventInWidget(display, e)) { e_preventDefault(e) }
10522
+ })
10523
 
10524
+ on(te, "compositionstart", function () {
10525
+ var start = cm.getCursor("from")
10526
+ if (input.composing) { input.composing.range.clear() }
10527
+ input.composing = {
10528
+ start: start,
10529
+ range: cm.markText(start, cm.getCursor("to"), {className: "CodeMirror-composing"})
10530
+ }
10531
+ })
10532
+ on(te, "compositionend", function () {
10533
+ if (input.composing) {
10534
+ input.poll()
10535
+ input.composing.range.clear()
10536
+ input.composing = null
10537
+ }
10538
+ })
10539
+ };
10540
 
10541
+ TextareaInput.prototype.prepareSelection = function () {
10542
+ // Redraw the selection and/or cursor
10543
+ var cm = this.cm, display = cm.display, doc = cm.doc
10544
+ var result = prepareSelection(cm)
10545
 
10546
+ // Move the hidden textarea near the cursor to prevent scrolling artifacts
10547
+ if (cm.options.moveInputWithCursor) {
10548
+ var headPos = cursorCoords(cm, doc.sel.primary().head, "div")
10549
+ var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect()
10550
+ result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10,
10551
+ headPos.top + lineOff.top - wrapOff.top))
10552
+ result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10,
10553
+ headPos.left + lineOff.left - wrapOff.left))
10554
+ }
10555
 
10556
+ return result
10557
+ };
10558
 
10559
+ TextareaInput.prototype.showSelection = function (drawn) {
10560
+ var cm = this.cm, display = cm.display
10561
+ removeChildrenAndAdd(display.cursorDiv, drawn.cursors)
10562
+ removeChildrenAndAdd(display.selectionDiv, drawn.selection)
10563
+ if (drawn.teTop != null) {
10564
+ this.wrapper.style.top = drawn.teTop + "px"
10565
+ this.wrapper.style.left = drawn.teLeft + "px"
10566
+ }
10567
+ };
10568
 
10569
+ // Reset the input to correspond to the selection (or to be empty,
10570
+ // when not typing and nothing is selected)
10571
+ TextareaInput.prototype.reset = function (typing) {
10572
+ if (this.contextMenuPending) { return }
10573
+ var minimal, selected, cm = this.cm, doc = cm.doc
10574
+ if (cm.somethingSelected()) {
10575
+ this.prevInput = ""
10576
+ var range = doc.sel.primary()
10577
+ minimal = hasCopyEvent &&
10578
+ (range.to().line - range.from().line > 100 || (selected = cm.getSelection()).length > 1000)
10579
+ var content = minimal ? "-" : selected || cm.getSelection()
10580
+ this.textarea.value = content
10581
+ if (cm.state.focused) { selectInput(this.textarea) }
10582
+ if (ie && ie_version >= 9) { this.hasSelection = content }
10583
+ } else if (!typing) {
10584
+ this.prevInput = this.textarea.value = ""
10585
+ if (ie && ie_version >= 9) { this.hasSelection = null }
10586
+ }
10587
+ this.inaccurateSelection = minimal
10588
+ };
10589
 
10590
+ TextareaInput.prototype.getField = function () { return this.textarea };
10591
 
10592
+ TextareaInput.prototype.supportsTouch = function () { return false };
10593
 
10594
+ TextareaInput.prototype.focus = function () {
10595
+ if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) {
10596
+ try { this.textarea.focus() }
10597
+ catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
10598
+ }
10599
+ };
10600
 
10601
+ TextareaInput.prototype.blur = function () { this.textarea.blur() };
10602
 
10603
+ TextareaInput.prototype.resetPosition = function () {
10604
+ this.wrapper.style.top = this.wrapper.style.left = 0
10605
+ };
10606
 
10607
+ TextareaInput.prototype.receivedFocus = function () { this.slowPoll() };
10608
 
10609
+ // Poll for input changes, using the normal rate of polling. This
10610
+ // runs as long as the editor is focused.
10611
+ TextareaInput.prototype.slowPoll = function () {
10612
  var this$1 = this;
10613
 
10614
+ if (this.pollingFast) { return }
10615
+ this.polling.set(this.cm.options.pollInterval, function () {
10616
+ this$1.poll()
10617
+ if (this$1.cm.state.focused) { this$1.slowPoll() }
10618
+ })
10619
+ };
10620
 
10621
+ // When an event has just come in that is likely to add or change
10622
+ // something in the input textarea, we poll faster, to ensure that
10623
+ // the change appears on the screen quickly.
10624
+ TextareaInput.prototype.fastPoll = function () {
10625
+ var missed = false, input = this
10626
+ input.pollingFast = true
10627
+ function p() {
10628
+ var changed = input.poll()
10629
+ if (!changed && !missed) {missed = true; input.polling.set(60, p)}
10630
+ else {input.pollingFast = false; input.slowPoll()}
10631
+ }
10632
+ input.polling.set(20, p)
10633
+ };
10634
 
10635
+ // Read input from the textarea, and update the document to match.
10636
+ // When something is selected, it is present in the textarea, and
10637
+ // selected (unless it is huge, in which case a placeholder is
10638
+ // used). When nothing is selected, the cursor sits after previously
10639
+ // seen text (can be empty), which is stored in prevInput (we must
10640
+ // not reset the textarea when typing, because that breaks IME).
10641
+ TextareaInput.prototype.poll = function () {
10642
  var this$1 = this;
10643
 
10644
+ var cm = this.cm, input = this.textarea, prevInput = this.prevInput
10645
+ // Since this is called a *lot*, try to bail out as cheaply as
10646
+ // possible when it is clear that nothing happened. hasSelection
10647
+ // will be the case when there is a lot of text in the textarea,
10648
+ // in which case reading its value would be expensive.
10649
+ if (this.contextMenuPending || !cm.state.focused ||
10650
+ (hasSelection(input) && !prevInput && !this.composing) ||
10651
+ cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq)
10652
+ { return false }
 
 
 
 
 
 
 
 
 
 
 
 
10653
 
10654
+ var text = input.value
10655
+ // If nothing changed, bail.
10656
+ if (text == prevInput && !cm.somethingSelected()) { return false }
10657
+ // Work around nonsensical selection resetting in IE9/10, and
10658
+ // inexplicable appearance of private area unicode characters on
10659
+ // some key combos in Mac (#2689).
10660
+ if (ie && ie_version >= 9 && this.hasSelection === text ||
10661
+ mac && /[\uf700-\uf7ff]/.test(text)) {
10662
+ cm.display.input.reset()
10663
+ return false
10664
+ }
10665
 
10666
+ if (cm.doc.sel == cm.display.selForContextMenu) {
10667
+ var first = text.charCodeAt(0)
10668
+ if (first == 0x200b && !prevInput) { prevInput = "\u200b" }
10669
+ if (first == 0x21da) { this.reset(); return this.cm.execCommand("undo") }
10670
+ }
10671
+ // Find the part of the input that is actually new
10672
+ var same = 0, l = Math.min(prevInput.length, text.length)
10673
+ while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) { ++same }
10674
 
10675
+ runInOp(cm, function () {
10676
+ applyTextInput(cm, text.slice(same), prevInput.length - same,
10677
+ null, this$1.composing ? "*compose" : null)
10678
 
10679
+ // Don't leave long text in the textarea, since it makes further polling slow
10680
+ if (text.length > 1000 || text.indexOf("\n") > -1) { input.value = this$1.prevInput = "" }
10681
+ else { this$1.prevInput = text }
 
 
 
 
 
10682
 
10683
+ if (this$1.composing) {
10684
+ this$1.composing.range.clear()
10685
+ this$1.composing.range = cm.markText(this$1.composing.start, cm.getCursor("to"),
10686
+ {className: "CodeMirror-composing"})
10687
+ }
10688
+ })
10689
+ return true
10690
+ };
10691
 
10692
+ TextareaInput.prototype.ensurePolled = function () {
10693
+ if (this.pollingFast && this.poll()) { this.pollingFast = false }
10694
+ };
 
10695
 
10696
+ TextareaInput.prototype.onKeyPress = function () {
10697
+ if (ie && ie_version >= 9) { this.hasSelection = null }
10698
+ this.fastPoll()
10699
+ };
10700
+
10701
+ TextareaInput.prototype.onContextMenu = function (e) {
10702
+ var input = this, cm = input.cm, display = cm.display, te = input.textarea
10703
+ var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop
10704
+ if (!pos || presto) { return } // Opera is difficult.
10705
+
10706
+ // Reset the current text selection only if the click is done outside of the selection
10707
+ // and 'resetSelectionOnContextMenu' option is true.
10708
+ var reset = cm.options.resetSelectionOnContextMenu
10709
+ if (reset && cm.doc.sel.contains(pos) == -1)
10710
+ { operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll) }
10711
+
10712
+ var oldCSS = te.style.cssText, oldWrapperCSS = input.wrapper.style.cssText
10713
+ input.wrapper.style.cssText = "position: absolute"
10714
+ var wrapperBox = input.wrapper.getBoundingClientRect()
10715
+ te.style.cssText = "position: absolute; width: 30px; height: 30px;\n top: " + (e.clientY - wrapperBox.top - 5) + "px; left: " + (e.clientX - wrapperBox.left - 5) + "px;\n z-index: 1000; background: " + (ie ? "rgba(255, 255, 255, .05)" : "transparent") + ";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);"
10716
+ var oldScrollY
10717
+ if (webkit) { oldScrollY = window.scrollY } // Work around Chrome issue (#2712)
10718
+ display.input.focus()
10719
+ if (webkit) { window.scrollTo(null, oldScrollY) }
10720
+ display.input.reset()
10721
+ // Adds "Select all" to context menu in FF
10722
+ if (!cm.somethingSelected()) { te.value = input.prevInput = " " }
10723
+ input.contextMenuPending = true
10724
+ display.selForContextMenu = cm.doc.sel
10725
+ clearTimeout(display.detectingSelectAll)
10726
+
10727
+ // Select-all will be greyed out if there's nothing to select, so
10728
+ // this adds a zero-width space so that we can later check whether
10729
+ // it got selected.
10730
+ function prepareSelectAllHack() {
10731
+ if (te.selectionStart != null) {
10732
+ var selected = cm.somethingSelected()
10733
+ var extval = "\u200b" + (selected ? te.value : "")
10734
+ te.value = "\u21da" // Used to catch context-menu undo
10735
+ te.value = extval
10736
+ input.prevInput = selected ? "" : "\u200b"
10737
+ te.selectionStart = 1; te.selectionEnd = extval.length
10738
+ // Re-set this, in case some other handler touched the
10739
+ // selection in the meantime.
10740
+ display.selForContextMenu = cm.doc.sel
10741
+ }
10742
+ }
10743
+ function rehide() {
10744
+ input.contextMenuPending = false
10745
+ input.wrapper.style.cssText = oldWrapperCSS
10746
+ te.style.cssText = oldCSS
10747
+ if (ie && ie_version < 9) { display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos) }
10748
+
10749
+ // Try to detect the user choosing select-all
10750
+ if (te.selectionStart != null) {
10751
+ if (!ie || (ie && ie_version < 9)) { prepareSelectAllHack() }
10752
+ var i = 0, poll = function () {
10753
+ if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 &&
10754
+ te.selectionEnd > 0 && input.prevInput == "\u200b") {
10755
+ operation(cm, selectAll)(cm)
10756
+ } else if (i++ < 10) {
10757
+ display.detectingSelectAll = setTimeout(poll, 500)
10758
+ } else {
10759
+ display.selForContextMenu = null
10760
+ display.input.reset()
10761
  }
 
10762
  }
10763
+ display.detectingSelectAll = setTimeout(poll, 200)
10764
  }
10765
+ }
10766
 
10767
+ if (ie && ie_version >= 9) { prepareSelectAllHack() }
10768
+ if (captureRightClick) {
10769
+ e_stop(e)
10770
+ var mouseup = function () {
10771
+ off(window, "mouseup", mouseup)
10772
+ setTimeout(rehide, 20)
 
 
 
 
10773
  }
10774
+ on(window, "mouseup", mouseup)
10775
+ } else {
10776
+ setTimeout(rehide, 50)
10777
+ }
10778
+ };
10779
 
10780
+ TextareaInput.prototype.readOnlyChanged = function (val) {
10781
+ if (!val) { this.reset() }
10782
+ };
10783
 
10784
+ TextareaInput.prototype.setUneditable = function () {};
10785
 
10786
+ TextareaInput.prototype.needsContentAttribute = false
 
10787
 
10788
  function fromTextArea(textarea, options) {
10789
  options = options ? copyObj(options) : {}
10934
 
10935
  addLegacyProps(CodeMirror)
10936
 
10937
+ CodeMirror.version = "5.24.2"
10938
 
10939
  return CodeMirror;
10940
 
10941
  })));
10942
+ },{}],16:[function(require,module,exports){
10943
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
10944
  // Distributed under an MIT license: http://codemirror.net/LICENSE
10945
 
10970
  colorKeywords = parserConfig.colorKeywords || {},
10971
  valueKeywords = parserConfig.valueKeywords || {},
10972
  allowNested = parserConfig.allowNested,
10973
+ lineComment = parserConfig.lineComment,
10974
  supportsAtComponent = parserConfig.supportsAtComponent === true;
10975
 
10976
  var type, override;
11196
  };
11197
 
11198
  states.pseudo = function(type, stream, state) {
11199
+ if (type == "meta") return "pseudo";
11200
+
11201
  if (type == "word") {
11202
  override = "variable-3";
11203
  return state.context.type;
11352
  electricChars: "}",
11353
  blockCommentStart: "/*",
11354
  blockCommentEnd: "*/",
11355
+ lineComment: lineComment,
11356
  fold: "brace"
11357
  };
11358
  });
11440
  "line-stacking-shift", "line-stacking-strategy", "list-style",
11441
  "list-style-image", "list-style-position", "list-style-type", "margin",
11442
  "margin-bottom", "margin-left", "margin-right", "margin-top",
11443
+ "marks", "marquee-direction", "marquee-loop",
11444
  "marquee-play-count", "marquee-speed", "marquee-style", "max-height",
11445
  "max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index",
11446
  "nav-left", "nav-right", "nav-up", "object-fit", "object-position",
11468
  "text-wrap", "top", "transform", "transform-origin", "transform-style",
11469
  "transition", "transition-delay", "transition-duration",
11470
  "transition-property", "transition-timing-function", "unicode-bidi",
11471
+ "user-select", "vertical-align", "visibility", "voice-balance", "voice-duration",
11472
  "voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress",
11473
+ "voice-volume", "volume", "white-space", "widows", "width", "will-change", "word-break",
11474
  "word-spacing", "word-wrap", "z-index",
11475
  // SVG-specific
11476
  "clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color",
11535
  "above", "absolute", "activeborder", "additive", "activecaption", "afar",
11536
  "after-white-space", "ahead", "alias", "all", "all-scroll", "alphabetic", "alternate",
11537
  "always", "amharic", "amharic-abegede", "antialiased", "appworkspace",
11538
+ "arabic-indic", "armenian", "asterisks", "attr", "auto", "auto-flow", "avoid", "avoid-column", "avoid-page",
11539
  "avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary",
11540
  "bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
11541
  "both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel",
11544
  "cell", "center", "checkbox", "circle", "cjk-decimal", "cjk-earthly-branch",
11545
  "cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
11546
  "col-resize", "collapse", "color", "color-burn", "color-dodge", "column", "column-reverse",
11547
+ "compact", "condensed", "contain", "content", "contents",
11548
  "content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover", "crop",
11549
  "cross", "crosshair", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal",
11550
  "decimal-leading-zero", "default", "default-button", "dense", "destination-atop",
11587
  "mix", "mongolian", "monospace", "move", "multiple", "multiply", "myanmar", "n-resize",
11588
  "narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop",
11589
  "no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap",
11590
+ "ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", "oblique", "octal", "opacity", "open-quote",
11591
  "optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset",
11592
  "outside", "outside-shape", "overlay", "overline", "padding", "padding-box",
11593
  "painted", "page", "paused", "persian", "perspective", "plus-darker", "plus-lighter",
11599
  "rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY",
11600
  "rotateZ", "round", "row", "row-resize", "row-reverse", "rtl", "run-in", "running",
11601
  "s-resize", "sans-serif", "saturation", "scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen",
11602
+ "scroll", "scrollbar", "scroll-position", "se-resize", "searchfield",
11603
  "searchfield-cancel-button", "searchfield-decoration",
11604
  "searchfield-results-button", "searchfield-results-decoration",
11605
  "semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama",
11617
  "thick", "thin", "threeddarkshadow", "threedface", "threedhighlight",
11618
  "threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er",
11619
  "tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top",
11620
+ "trad-chinese-formal", "trad-chinese-informal", "transform",
11621
  "translate", "translate3d", "translateX", "translateY", "translateZ",
11622
+ "transparent", "ultra-condensed", "ultra-expanded", "underline", "unset", "up",
11623
  "upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal",
11624
  "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url",
11625
  "var", "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
11676
  valueKeywords: valueKeywords,
11677
  fontProperties: fontProperties,
11678
  allowNested: true,
11679
+ lineComment: "//",
11680
  tokenHooks: {
11681
  "/": function(stream, state) {
11682
  if (stream.eat("/")) {
11719
  valueKeywords: valueKeywords,
11720
  fontProperties: fontProperties,
11721
  allowNested: true,
11722
+ lineComment: "//",
11723
  tokenHooks: {
11724
  "/": function(stream, state) {
11725
  if (stream.eat("/")) {
11772
 
11773
  });
11774
 
11775
+ },{"../../lib/codemirror":15}],17:[function(require,module,exports){
11776
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
11777
  // Distributed under an MIT license: http://codemirror.net/LICENSE
11778
 
11789
  var defaultTags = {
11790
  script: [
11791
  ["lang", /(javascript|babel)/i, "javascript"],
11792
+ ["type", /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i, "javascript"],
11793
  ["type", /./, "text/plain"],
11794
  [null, null, "javascript"]
11795
  ],
11926
  CodeMirror.defineMIME("text/html", "htmlmixed");
11927
  });
11928
 
11929
+ },{"../../lib/codemirror":15,"../css/css":16,"../javascript/javascript":18,"../xml/xml":19}],18:[function(require,module,exports){
11930
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
11931
  // Distributed under an MIT license: http://codemirror.net/LICENSE
11932
 
11941
  "use strict";
11942
 
11943
  function expressionAllowed(stream, state, backUp) {
11944
+ return /^(?:operator|sof|keyword c|case|new|export|default|[\[{}\(,;:]|=>)$/.test(state.lastType) ||
11945
  (state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0))))
11946
  }
11947
 
12075
  stream.skipToEnd();
12076
  return ret("error", "error");
12077
  } else if (isOperatorChar.test(ch)) {
12078
+ if (ch != ">" || !state.lexical || state.lexical.type != ">")
12079
+ stream.eatWhile(isOperatorChar);
12080
  return ret("operator", "operator", stream.current());
12081
  } else if (wordRE.test(ch)) {
12082
  stream.eatWhile(wordRE);
12434
  if (type == ":") return cont(expressionNoComma);
12435
  if (type == "(") return pass(functiondef);
12436
  }
12437
+ function commasep(what, end, sep) {
12438
  function proceed(type, value) {
12439
+ if (sep ? sep.indexOf(type) > -1 : type == ",") {
12440
  var lex = cx.state.lexical;
12441
  if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;
12442
  return cont(function(type, value) {
12469
  }
12470
  function typeexpr(type) {
12471
  if (type == "variable") {cx.marked = "variable-3"; return cont(afterType);}
12472
+ if (type == "string" || type == "number" || type == "atom") return cont(afterType);
12473
+ if (type == "{") return cont(pushlex("}"), commasep(typeprop, "}", ",;"), poplex)
12474
  if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType)
12475
  }
12476
  function maybeReturnType(type) {
12477
  if (type == "=>") return cont(typeexpr)
12478
  }
12479
+ function typeprop(type, value) {
12480
  if (type == "variable" || cx.style == "keyword") {
12481
  cx.marked = "property"
12482
  return cont(typeprop)
12483
+ } else if (value == "?") {
12484
+ return cont(typeprop)
12485
  } else if (type == ":") {
12486
  return cont(typeexpr)
12487
  }
12491
  else if (type == ":") return cont(typeexpr)
12492
  }
12493
  function afterType(type, value) {
12494
+ if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
12495
+ if (value == "|" || type == ".") return cont(typeexpr)
12496
  if (type == "[") return cont(expect("]"), afterType)
12497
  }
12498
  function vardef() {
12563
  if (type == "variable") {register(value); return cont(classNameAfter);}
12564
  }
12565
  function classNameAfter(type, value) {
12566
+ if (value == "extends" || value == "implements" || (isTS && type == ","))
12567
+ return cont(isTS ? typeexpr : expression, classNameAfter);
12568
  if (type == "{") return cont(pushlex("}"), classBody, poplex);
12569
  }
12570
  function classBody(type, value) {
12571
  if (type == "variable" || cx.style == "keyword") {
12572
+ if ((value == "async" || value == "static" || value == "get" || value == "set" ||
12573
  (isTS && (value == "public" || value == "private" || value == "protected" || value == "readonly" || value == "abstract"))) &&
12574
  cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false)) {
12575
  cx.marked = "keyword";
12578
  cx.marked = "property";
12579
  return cont(isTS ? classfield : functiondef, classBody);
12580
  }
12581
+ if (type == "[")
12582
+ return cont(expression, expect("]"), isTS ? classfield : functiondef, classBody)
12583
  if (value == "*") {
12584
  cx.marked = "keyword";
12585
  return cont(classBody);
12592
  if (type == ":") return cont(typeexpr, maybeAssign)
12593
  return pass(functiondef)
12594
  }
12595
+ function afterExport(type, value) {
12596
  if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
12597
  if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); }
12598
+ if (type == "{") return cont(commasep(exportField, "}"), maybeFrom, expect(";"));
12599
  return pass(statement);
12600
  }
12601
+ function exportField(type, value) {
12602
+ if (value == "as") { cx.marked = "keyword"; return cont(expect("variable")); }
12603
+ if (type == "variable") return pass(expressionNoComma, exportField);
12604
+ }
12605
  function afterImport(type) {
12606
  if (type == "string") return cont();
12607
+ return pass(importSpec, maybeMoreImports, maybeFrom);
12608
  }
12609
  function importSpec(type, value) {
12610
  if (type == "{") return contCommasep(importSpec, "}");
12612
  if (value == "*") cx.marked = "keyword";
12613
  return cont(maybeAs);
12614
  }
12615
+ function maybeMoreImports(type) {
12616
+ if (type == ",") return cont(importSpec, maybeMoreImports)
12617
+ }
12618
  function maybeAs(_type, value) {
12619
  if (value == "as") { cx.marked = "keyword"; return cont(importSpec); }
12620
  }
12728
 
12729
  });
12730
 
12731
+ },{"../../lib/codemirror":15}],19:[function(require,module,exports){
12732
  // CodeMirror, copyright (c) by Marijn Haverbeke and others
12733
  // Distributed under an MIT license: http://codemirror.net/LICENSE
12734
 
13124
 
13125
  });
13126
 
13127
+ },{"../../lib/codemirror":15}],20:[function(require,module,exports){
13128
+ /*
13129
+
13130
+ Style HTML
13131
+ ---------------
13132
+
13133
+ Written by Nochum Sossonko, (nsossonko@hotmail.com)
13134
+
13135
+ Based on code initially developed by: Einar Lielmanis, <elfz@laacz.lv>
13136
+ http://jsbeautifier.org/
13137
+
13138
+
13139
+ You are free to use this in any way you want, in case you find this useful or working for you.
13140
+
13141
+ Usage:
13142
+ style_html(html_source);
13143
+
13144
+ style_html(html_source, options);
13145
+
13146
+ The options are:
13147
+ indent_size (default 4) — indentation size,
13148
+ indent_char (default space) — character to indent with,
13149
+ max_char (default 70) - maximum amount of characters per line,
13150
+ brace_style (default "collapse") - "collapse" | "expand" | "end-expand"
13151
+ put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or just put end braces on own line.
13152
+ unformatted (defaults to inline tags) - list of tags, that shouldn't be reformatted
13153
+ indent_scripts (default normal) - "keep"|"separate"|"normal"
13154
+
13155
+ e.g.
13156
+
13157
+ style_html(html_source, {
13158
+ 'indent_size': 2,
13159
+ 'indent_char': ' ',
13160
+ 'max_char': 78,
13161
+ 'brace_style': 'expand',
13162
+ 'unformatted': ['a', 'sub', 'sup', 'b', 'i', 'u']
13163
+ });
13164
+ */
13165
+
13166
+ function style_html(html_source, options) {
13167
+ //Wrapper function to invoke all the necessary constructors and deal with the output.
13168
+
13169
+ var multi_parser,
13170
+ indent_size,
13171
+ indent_character,
13172
+ max_char,
13173
+ brace_style,
13174
+ unformatted;
13175
+
13176
+ options = options || {};
13177
+ indent_size = options.indent_size || 4;
13178
+ indent_character = options.indent_char || ' ';
13179
+ brace_style = options.brace_style || 'collapse';
13180
+ max_char = options.max_char == 0 ? Infinity : options.max_char || 70;
13181
+ unformatted = options.unformatted || ['a', 'span', 'bdo', 'em', 'strong', 'dfn', 'code', 'samp', 'kbd', 'var', 'cite', 'abbr', 'acronym', 'q', 'sub', 'sup', 'tt', 'i', 'b', 'big', 'small', 'u', 's', 'strike', 'font', 'ins', 'del', 'pre', 'address', 'dt', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
13182
+
13183
+ function Parser() {
13184
+
13185
+ this.pos = 0; //Parser position
13186
+ this.token = '';
13187
+ this.current_mode = 'CONTENT'; //reflects the current Parser mode: TAG/CONTENT
13188
+ this.tags = { //An object to hold tags, their position, and their parent-tags, initiated with default values
13189
+ parent: 'parent1',
13190
+ parentcount: 1,
13191
+ parent1: ''
13192
+ };
13193
+ this.tag_type = '';
13194
+ this.token_text = this.last_token = this.last_text = this.token_type = '';
13195
+
13196
+ this.Utils = { //Uilities made available to the various functions
13197
+ whitespace: "\n\r\t ".split(''),
13198
+ single_token: 'br,input,link,meta,!doctype,basefont,base,area,hr,wbr,param,img,isindex,?xml,embed,?php,?,?='.split(','), //all the single tags for HTML
13199
+ extra_liners: 'head,body,/html'.split(','), //for tags that need a line of whitespace before them
13200
+ in_array: function (what, arr) {
13201
+ for (var i=0; i<arr.length; i++) {
13202
+ if (what === arr[i]) {
13203
+ return true;
13204
+ }
13205
+ }
13206
+ return false;
13207
+ }
13208
+ }
13209
+
13210
+ this.get_content = function () { //function to capture regular content between tags
13211
+
13212
+ var input_char = '',
13213
+ content = [],
13214
+ space = false; //if a space is needed
13215
+
13216
+ while (this.input.charAt(this.pos) !== '<') {
13217
+ if (this.pos >= this.input.length) {
13218
+ return content.length?content.join(''):['', 'TK_EOF'];
13219
+ }
13220
+
13221
+ input_char = this.input.charAt(this.pos);
13222
+ this.pos++;
13223
+ this.line_char_count++;
13224
+
13225
+ if (this.Utils.in_array(input_char, this.Utils.whitespace)) {
13226
+ if (content.length) {
13227
+ space = true;
13228
+ }
13229
+ this.line_char_count--;
13230
+ continue; //don't want to insert unnecessary space
13231
+ }
13232
+ else if (space) {
13233
+ if (this.line_char_count >= this.max_char) { //insert a line when the max_char is reached
13234
+ content.push('\n');
13235
+ for (var i=0; i<this.indent_level; i++) {
13236
+ content.push(this.indent_string);
13237
+ }
13238
+ this.line_char_count = 0;
13239
+ }
13240
+ else{
13241
+ content.push(' ');
13242
+ this.line_char_count++;
13243
+ }
13244
+ space = false;
13245
+ }
13246
+ content.push(input_char); //letter at-a-time (or string) inserted to an array
13247
+ }
13248
+ return content.length?content.join(''):'';
13249
+ }
13250
+
13251
+ this.get_contents_to = function (name) { //get the full content of a script or style to pass to js_beautify
13252
+ if (this.pos == this.input.length) {
13253
+ return ['', 'TK_EOF'];
13254
+ }
13255
+ var input_char = '';
13256
+ var content = '';
13257
+ var reg_match = new RegExp('\<\/' + name + '\\s*\>', 'igm');
13258
+ reg_match.lastIndex = this.pos;
13259
+ var reg_array = reg_match.exec(this.input);
13260
+ var end_script = reg_array?reg_array.index:this.input.length; //absolute end of script
13261
+ if(this.pos < end_script) { //get everything in between the script tags
13262
+ content = this.input.substring(this.pos, end_script);
13263
+ this.pos = end_script;
13264
+ }
13265
+ return content;
13266
+ }
13267
+
13268
+ this.record_tag = function (tag){ //function to record a tag and its parent in this.tags Object
13269
+ if (this.tags[tag + 'count']) { //check for the existence of this tag type
13270
+ this.tags[tag + 'count']++;
13271
+ this.tags[tag + this.tags[tag + 'count']] = this.indent_level; //and record the present indent level
13272
+ }
13273
+ else { //otherwise initialize this tag type
13274
+ this.tags[tag + 'count'] = 1;
13275
+ this.tags[tag + this.tags[tag + 'count']] = this.indent_level; //and record the present indent level
13276
+ }
13277
+ this.tags[tag + this.tags[tag + 'count'] + 'parent'] = this.tags.parent; //set the parent (i.e. in the case of a div this.tags.div1parent)
13278
+ this.tags.parent = tag + this.tags[tag + 'count']; //and make this the current parent (i.e. in the case of a div 'div1')
13279
+ }
13280
+
13281
+ this.retrieve_tag = function (tag) { //function to retrieve the opening tag to the corresponding closer
13282
+ if (this.tags[tag + 'count']) { //if the openener is not in the Object we ignore it
13283
+ var temp_parent = this.tags.parent; //check to see if it's a closable tag.
13284
+ while (temp_parent) { //till we reach '' (the initial value);
13285
+ if (tag + this.tags[tag + 'count'] === temp_parent) { //if this is it use it
13286
+ break;
13287
+ }
13288
+ temp_parent = this.tags[temp_parent + 'parent']; //otherwise keep on climbing up the DOM Tree
13289
+ }
13290
+ if (temp_parent) { //if we caught something
13291
+ this.indent_level = this.tags[tag + this.tags[tag + 'count']]; //set the indent_level accordingly
13292
+ this.tags.parent = this.tags[temp_parent + 'parent']; //and set the current parent
13293
+ }
13294
+ delete this.tags[tag + this.tags[tag + 'count'] + 'parent']; //delete the closed tags parent reference...
13295
+ delete this.tags[tag + this.tags[tag + 'count']]; //...and the tag itself
13296
+ if (this.tags[tag + 'count'] == 1) {
13297
+ delete this.tags[tag + 'count'];
13298
+ }
13299
+ else {
13300
+ this.tags[tag + 'count']--;
13301
+ }
13302
+ }
13303
+ }
13304
+
13305
+ this.get_tag = function () { //function to get a full tag and parse its type
13306
+ var input_char = '',
13307
+ content = [],
13308
+ space = false,
13309
+ tag_start, tag_end;
13310
+
13311
+ do {
13312
+ if (this.pos >= this.input.length) {
13313
+ return content.length?content.join(''):['', 'TK_EOF'];
13314
+ }
13315
+
13316
+ input_char = this.input.charAt(this.pos);
13317
+ this.pos++;
13318
+ this.line_char_count++;
13319
+
13320
+ if (this.Utils.in_array(input_char, this.Utils.whitespace)) { //don't want to insert unnecessary space
13321
+ space = true;
13322
+ this.line_char_count--;
13323
+ continue;
13324
+ }
13325
+
13326
+ if (input_char === "'" || input_char === '"') {
13327
+ if (!content[1] || content[1] !== '!') { //if we're in a comment strings don't get treated specially
13328
+ input_char += this.get_unformatted(input_char);
13329
+ space = true;
13330
+ }
13331
+ }
13332
+
13333
+ if (input_char === '=') { //no space before =
13334
+ space = false;
13335
+ }
13336
+
13337
+ if (content.length && content[content.length-1] !== '=' && input_char !== '>'
13338
+ && space) { //no space after = or before >
13339
+ if (this.line_char_count >= this.max_char) {
13340
+ this.print_newline(false, content);
13341
+ this.line_char_count = 0;
13342
+ }
13343
+ else {
13344
+ content.push(' ');
13345
+ this.line_char_count++;
13346
+ }
13347
+ space = false;
13348
+ }
13349
+ if (input_char === '<') {
13350
+ tag_start = this.pos - 1;
13351
+ }
13352
+ content.push(input_char); //inserts character at-a-time (or string)
13353
+ } while (input_char !== '>');
13354
+
13355
+ var tag_complete = content.join('');
13356
+ var tag_index;
13357
+ if (tag_complete.indexOf(' ') != -1) { //if there's whitespace, thats where the tag name ends
13358
+ tag_index = tag_complete.indexOf(' ');
13359
+ }
13360
+ else { //otherwise go with the tag ending
13361
+ tag_index = tag_complete.indexOf('>');
13362
+ }
13363
+ var tag_check = tag_complete.substring(1, tag_index).toLowerCase();
13364
+ if (tag_complete.charAt(tag_complete.length-2) === '/' ||
13365
+ this.Utils.in_array(tag_check, this.Utils.single_token)) { //if this tag name is a single tag type (either in the list or has a closing /)
13366
+ this.tag_type = 'SINGLE';
13367
+ }
13368
+ else if (tag_check === 'script') { //for later script handling
13369
+ this.record_tag(tag_check);
13370
+ this.tag_type = 'SCRIPT';
13371
+ }
13372
+ else if (tag_check === 'style') { //for future style handling (for now it justs uses get_content)
13373
+ this.record_tag(tag_check);
13374
+ this.tag_type = 'STYLE';
13375
+ }
13376
+ else if (this.Utils.in_array(tag_check, unformatted)) { // do not reformat the "unformatted" tags
13377
+ var comment = this.get_unformatted('</'+tag_check+'>', tag_complete); //...delegate to get_unformatted function
13378
+ content.push(comment);
13379
+ // Preserve collapsed whitespace either before or after this tag.
13380
+ if (tag_start > 0 && this.Utils.in_array(this.input.charAt(tag_start - 1), this.Utils.whitespace)){
13381
+ content.splice(0, 0, this.input.charAt(tag_start - 1));
13382
+ }
13383
+ tag_end = this.pos - 1;
13384
+ if (this.Utils.in_array(this.input.charAt(tag_end + 1), this.Utils.whitespace)){
13385
+ content.push(this.input.charAt(tag_end + 1));
13386
+ }
13387
+ this.tag_type = 'SINGLE';
13388
+ }
13389
+ else if (tag_check.charAt(0) === '!') { //peek for <!-- comment
13390
+ if (tag_check.indexOf('[if') != -1) { //peek for <!--[if conditional comment
13391
+ if (tag_complete.indexOf('!IE') != -1) { //this type needs a closing --> so...
13392
+ var comment = this.get_unformatted('-->', tag_complete); //...delegate to get_unformatted
13393
+ content.push(comment);
13394
+ }
13395
+ this.tag_type = 'START';
13396
+ }
13397
+ else if (tag_check.indexOf('[endif') != -1) {//peek for <!--[endif end conditional comment
13398
+ this.tag_type = 'END';
13399
+ this.unindent();
13400
+ }
13401
+ else if (tag_check.indexOf('[cdata[') != -1) { //if it's a <[cdata[ comment...
13402
+ var comment = this.get_unformatted(']]>', tag_complete); //...delegate to get_unformatted function
13403
+ content.push(comment);
13404
+ this.tag_type = 'SINGLE'; //<![CDATA[ comments are treated like single tags
13405
+ }
13406
+ else {
13407
+ var comment = this.get_unformatted('-->', tag_complete);
13408
+ content.push(comment);
13409
+ this.tag_type = 'SINGLE';
13410
+ }
13411
+ }
13412
+ else {
13413
+ if (tag_check.charAt(0) === '/') { //this tag is a double tag so check for tag-ending
13414
+ this.retrieve_tag(tag_check.substring(1)); //remove it and all ancestors
13415
+ this.tag_type = 'END';
13416
+ }
13417
+ else { //otherwise it's a start-tag
13418
+ this.record_tag(tag_check); //push it on the tag stack
13419
+ this.tag_type = 'START';
13420
+ }
13421
+ if (this.Utils.in_array(tag_check, this.Utils.extra_liners)) { //check if this double needs an extra line
13422
+ this.print_newline(true, this.output);
13423
+ }
13424
+ }
13425
+ return content.join(''); //returns fully formatted tag
13426
+ }
13427
+
13428
+ this.get_unformatted = function (delimiter, orig_tag) { //function to return unformatted content in its entirety
13429
+
13430
+ if (orig_tag && orig_tag.toLowerCase().indexOf(delimiter) != -1) {
13431
+ return '';
13432
+ }
13433
+ var input_char = '';
13434
+ var content = '';
13435
+ var space = true;
13436
+ do {
13437
+
13438
+ if (this.pos >= this.input.length) {
13439
+ return content;
13440
+ }
13441
+
13442
+ input_char = this.input.charAt(this.pos);
13443
+ this.pos++
13444
+
13445
+ if (this.Utils.in_array(input_char, this.Utils.whitespace)) {
13446
+ if (!space) {
13447
+ this.line_char_count--;
13448
+ continue;
13449
+ }
13450
+ if (input_char === '\n' || input_char === '\r') {
13451
+ content += '\n';
13452
+ /* Don't change tab indention for unformatted blocks. If using code for html editing, this will greatly affect <pre> tags if they are specified in the 'unformatted array'
13453
+ for (var i=0; i<this.indent_level; i++) {
13454
+ content += this.indent_string;
13455
+ }
13456
+ space = false; //...and make sure other indentation is erased
13457
+ */
13458
+ this.line_char_count = 0;
13459
+ continue;
13460
+ }
13461
+ }
13462
+ content += input_char;
13463
+ this.line_char_count++;
13464
+ space = true;
13465
+
13466
+
13467
+ } while (content.toLowerCase().indexOf(delimiter) == -1);
13468
+ return content;
13469
+ }
13470
+
13471
+ this.get_token = function () { //initial handler for token-retrieval
13472
+ var token;
13473
+
13474
+ if (this.last_token === 'TK_TAG_SCRIPT' || this.last_token === 'TK_TAG_STYLE') { //check if we need to format javascript
13475
+ var type = this.last_token.substr(7)
13476
+ token = this.get_contents_to(type);
13477
+ if (typeof token !== 'string') {
13478
+ return token;
13479
+ }
13480
+ return [token, 'TK_' + type];
13481
+ }
13482
+ if (this.current_mode === 'CONTENT') {
13483
+ token = this.get_content();
13484
+ if (typeof token !== 'string') {
13485
+ return token;
13486
+ }
13487
+ else {
13488
+ return [token, 'TK_CONTENT'];
13489
+ }
13490
+ }
13491
+
13492
+ if (this.current_mode === 'TAG') {
13493
+ token = this.get_tag();
13494
+ if (typeof token !== 'string') {
13495
+ return token;
13496
+ }
13497
+ else {
13498
+ var tag_name_type = 'TK_TAG_' + this.tag_type;
13499
+ return [token, tag_name_type];
13500
+ }
13501
+ }
13502
+ }
13503
+
13504
+ this.get_full_indent = function (level) {
13505
+ level = this.indent_level + level || 0;
13506
+ if (level < 1)
13507
+ return '';
13508
+
13509
+ return Array(level + 1).join(this.indent_string);
13510
+ }
13511
+
13512
+
13513
+ this.printer = function (js_source, indent_character, indent_size, max_char, brace_style) { //handles input/output and some other printing functions
13514
+
13515
+ this.input = js_source || ''; //gets the input for the Parser
13516
+ this.output = [];
13517
+ this.indent_character = indent_character;
13518
+ this.indent_string = '';
13519
+ this.indent_size = indent_size;
13520
+ this.brace_style = brace_style;
13521
+ this.indent_level = 0;
13522
+ this.max_char = max_char;
13523
+ this.line_char_count = 0; //count to see if max_char was exceeded
13524
+
13525
+ for (var i=0; i<this.indent_size; i++) {
13526
+ this.indent_string += this.indent_character;
13527
+ }
13528
+
13529
+ this.print_newline = function (ignore, arr) {
13530
+ this.line_char_count = 0;
13531
+ if (!arr || !arr.length) {
13532
+ return;
13533
+ }
13534
+ if (!ignore) { //we might want the extra line
13535
+ while (this.Utils.in_array(arr[arr.length-1], this.Utils.whitespace)) {
13536
+ arr.pop();
13537
+ }
13538
+ }
13539
+ arr.push('\n');
13540
+ for (var i=0; i<this.indent_level; i++) {
13541
+ arr.push(this.indent_string);
13542
+ }
13543
+ }
13544
+
13545
+ this.print_token = function (text) {
13546
+ this.output.push(text);
13547
+ }
13548
+
13549
+ this.indent = function () {
13550
+ this.indent_level++;
13551
+ }
13552
+
13553
+ this.unindent = function () {
13554
+ if (this.indent_level > 0) {
13555
+ this.indent_level--;
13556
+ }
13557
+ }
13558
+ }
13559
+ return this;
13560
+ }
13561
+
13562
+ /*_____________________--------------------_____________________*/
13563
+
13564
+ multi_parser = new Parser(); //wrapping functions Parser
13565
+ multi_parser.printer(html_source, indent_character, indent_size, max_char, brace_style); //initialize starting values
13566
+
13567
+ while (true) {
13568
+ var t = multi_parser.get_token();
13569
+ multi_parser.token_text = t[0];
13570
+ multi_parser.token_type = t[1];
13571
+
13572
+ if (multi_parser.token_type === 'TK_EOF') {
13573
+ break;
13574
+ }
13575
+
13576
+ switch (multi_parser.token_type) {
13577
+ case 'TK_TAG_START':
13578
+ multi_parser.print_newline(false, multi_parser.output);
13579
+ multi_parser.print_token(multi_parser.token_text);
13580
+ multi_parser.indent();
13581
+ multi_parser.current_mode = 'CONTENT';
13582
+ break;
13583
+ case 'TK_TAG_STYLE':
13584
+ case 'TK_TAG_SCRIPT':
13585
+ multi_parser.print_newline(false, multi_parser.output);
13586
+ multi_parser.print_token(multi_parser.token_text);
13587
+ multi_parser.current_mode = 'CONTENT';
13588
+ break;
13589
+ case 'TK_TAG_END':
13590
+ //Print new line only if the tag has no content and has child
13591
+ if (multi_parser.last_token === 'TK_CONTENT' && multi_parser.last_text === '') {
13592
+ var tag_name = multi_parser.token_text.match(/\w+/)[0];
13593
+ var tag_extracted_from_last_output = multi_parser.output[multi_parser.output.length -1].match(/<\s*(\w+)/);
13594
+ if (tag_extracted_from_last_output === null || tag_extracted_from_last_output[1] !== tag_name)
13595
+ multi_parser.print_newline(true, multi_parser.output);
13596
+ }
13597
+ multi_parser.print_token(multi_parser.token_text);
13598
+ multi_parser.current_mode = 'CONTENT';
13599
+ break;
13600
+ case 'TK_TAG_SINGLE':
13601
+ // Don't add a newline before elements that should remain unformatted.
13602
+ var tag_check = multi_parser.token_text.match(/^\s*<([a-z]+)/i);
13603
+ if (!tag_check || !multi_parser.Utils.in_array(tag_check[1], unformatted)){
13604
+ multi_parser.print_newline(false, multi_parser.output);
13605
+ }
13606
+ multi_parser.print_token(multi_parser.token_text);
13607
+ multi_parser.current_mode = 'CONTENT';
13608
+ break;
13609
+ case 'TK_CONTENT':
13610
+ if (multi_parser.token_text !== '') {
13611
+ multi_parser.print_token(multi_parser.token_text);
13612
+ }
13613
+ multi_parser.current_mode = 'TAG';
13614
+ break;
13615
+ case 'TK_STYLE':
13616
+ case 'TK_SCRIPT':
13617
+ if (multi_parser.token_text !== '') {
13618
+ multi_parser.output.push('\n');
13619
+ var text = multi_parser.token_text;
13620
+ if (multi_parser.token_type == 'TK_SCRIPT') {
13621
+ var _beautifier = typeof js_beautify == 'function' && js_beautify;
13622
+ } else if (multi_parser.token_type == 'TK_STYLE') {
13623
+ var _beautifier = typeof css_beautify == 'function' && css_beautify;
13624
+ }
13625
+
13626
+ if (options.indent_scripts == "keep") {
13627
+ var script_indent_level = 0;
13628
+ } else if (options.indent_scripts == "separate") {
13629
+ var script_indent_level = -multi_parser.indent_level;
13630
+ } else {
13631
+ var script_indent_level = 1;
13632
+ }
13633
+
13634
+ var indentation = multi_parser.get_full_indent(script_indent_level);
13635
+ if (_beautifier) {
13636
+ // call the Beautifier if avaliable
13637
+ text = _beautifier(text.replace(/^\s*/, indentation), options);
13638
+ } else {
13639
+ // simply indent the string otherwise
13640
+ var white = text.match(/^\s*/)[0];
13641
+ var _level = white.match(/[^\n\r]*$/)[0].split(multi_parser.indent_string).length - 1;
13642
+ var reindent = multi_parser.get_full_indent(script_indent_level -_level);
13643
+ text = text.replace(/^\s*/, indentation)
13644
+ .replace(/\r\n|\r|\n/g, '\n' + reindent)
13645
+ .replace(/\s*$/, '');
13646
+ }
13647
+ if (text) {
13648
+ multi_parser.print_token(text);
13649
+ multi_parser.print_newline(true, multi_parser.output);
13650
+ }
13651
+ }
13652
+ multi_parser.current_mode = 'TAG';
13653
+ break;
13654
+ }
13655
+ multi_parser.last_token = multi_parser.token_type;
13656
+ multi_parser.last_text = multi_parser.token_text;
13657
+ }
13658
+ return multi_parser.output.join('');
13659
+ }
13660
+
13661
+ module.exports = {
13662
+ prettyPrint: style_html
13663
+ };
13664
+ },{}],21:[function(require,module,exports){
13665
+ module.exports = require("./stream/stream")
13666
+ },{"./stream/stream":22}],22:[function(require,module,exports){
13667
+ "use strict"
13668
+
13669
+ var guid = 0, HALT = {}
13670
+ function createStream() {
13671
+ function stream() {
13672
+ if (arguments.length > 0 && arguments[0] !== HALT) updateStream(stream, arguments[0])
13673
+ return stream._state.value
13674
+ }
13675
+ initStream(stream)
13676
+
13677
+ if (arguments.length > 0 && arguments[0] !== HALT) updateStream(stream, arguments[0])
13678
+
13679
+ return stream
13680
+ }
13681
+ function initStream(stream) {
13682
+ stream.constructor = createStream
13683
+ stream._state = {id: guid++, value: undefined, state: 0, derive: undefined, recover: undefined, deps: {}, parents: [], endStream: undefined}
13684
+ stream.map = stream["fantasy-land/map"] = map, stream["fantasy-land/ap"] = ap, stream["fantasy-land/of"] = createStream
13685
+ stream.valueOf = valueOf, stream.toJSON = toJSON, stream.toString = valueOf
13686
+
13687
+ Object.defineProperties(stream, {
13688
+ end: {get: function() {
13689
+ if (!stream._state.endStream) {
13690
+ var endStream = createStream()
13691
+ endStream.map(function(value) {
13692
+ if (value === true) unregisterStream(stream), unregisterStream(endStream)
13693
+ return value
13694
+ })
13695
+ stream._state.endStream = endStream
13696
+ }
13697
+ return stream._state.endStream
13698
+ }}
13699
+ })
13700
+ }
13701
+ function updateStream(stream, value) {
13702
+ updateState(stream, value)
13703
+ for (var id in stream._state.deps) updateDependency(stream._state.deps[id], false)
13704
+ finalize(stream)
13705
+ }
13706
+ function updateState(stream, value) {
13707
+ stream._state.value = value
13708
+ stream._state.changed = true
13709
+ if (stream._state.state !== 2) stream._state.state = 1
13710
+ }
13711
+ function updateDependency(stream, mustSync) {
13712
+ var state = stream._state, parents = state.parents
13713
+ if (parents.length > 0 && parents.every(active) && (mustSync || parents.some(changed))) {
13714
+ var value = stream._state.derive()
13715
+ if (value === HALT) return false
13716
+ updateState(stream, value)
13717
+ }
13718
+ }
13719
+ function finalize(stream) {
13720
+ stream._state.changed = false
13721
+ for (var id in stream._state.deps) stream._state.deps[id]._state.changed = false
13722
+ }
13723
+
13724
+ function combine(fn, streams) {
13725
+ if (!streams.every(valid)) throw new Error("Ensure that each item passed to m.prop.combine/m.prop.merge is a stream")
13726
+ return initDependency(createStream(), streams, function() {
13727
+ return fn.apply(this, streams.concat([streams.filter(changed)]))
13728
+ })
13729
+ }
13730
+
13731
+ function initDependency(dep, streams, derive) {
13732
+ var state = dep._state
13733
+ state.derive = derive
13734
+ state.parents = streams.filter(notEnded)
13735
+
13736
+ registerDependency(dep, state.parents)
13737
+ updateDependency(dep, true)
13738
+
13739
+ return dep
13740
+ }
13741
+ function registerDependency(stream, parents) {
13742
+ for (var i = 0; i < parents.length; i++) {
13743
+ parents[i]._state.deps[stream._state.id] = stream
13744
+ registerDependency(stream, parents[i]._state.parents)
13745
+ }
13746
+ }
13747
+ function unregisterStream(stream) {
13748
+ for (var i = 0; i < stream._state.parents.length; i++) {
13749
+ var parent = stream._state.parents[i]
13750
+ delete parent._state.deps[stream._state.id]
13751
+ }
13752
+ for (var id in stream._state.deps) {
13753
+ var dependent = stream._state.deps[id]
13754
+ var index = dependent._state.parents.indexOf(stream)
13755
+ if (index > -1) dependent._state.parents.splice(index, 1)
13756
+ }
13757
+ stream._state.state = 2 //ended
13758
+ stream._state.deps = {}
13759
+ }
13760
+
13761
+ function map(fn) {return combine(function(stream) {return fn(stream())}, [this])}
13762
+ function ap(stream) {return combine(function(s1, s2) {return s1()(s2())}, [stream, this])}
13763
+ function valueOf() {return this._state.value}
13764
+ function toJSON() {return this._state.value != null && typeof this._state.value.toJSON === "function" ? this._state.value.toJSON() : this._state.value}
13765
+
13766
+ function valid(stream) {return stream._state }
13767
+ function active(stream) {return stream._state.state === 1}
13768
+ function changed(stream) {return stream._state.changed}
13769
+ function notEnded(stream) {return stream._state.state !== 2}
13770
+
13771
+ function merge(streams) {
13772
+ return combine(function() {
13773
+ return streams.map(function(s) {return s()})
13774
+ }, streams)
13775
+ }
13776
+ createStream["fantasy-land/of"] = createStream
13777
+ createStream.merge = merge
13778
+ createStream.combine = combine
13779
+ createStream.HALT = HALT
13780
+
13781
+ if (typeof module !== "undefined") module["exports"] = createStream
13782
+ else window.stream = createStream
13783
+
13784
+ },{}]},{},[11]);
13785
  })();
assets/js/forms-admin.min.js CHANGED
@@ -1,9 +1,9 @@
1
- !function(){var e=void 0,t=void 0;!function r(t,n,i){function o(l,s){if(!n[l]){if(!t[l]){var c="function"==typeof e&&e;if(!s&&c)return c(l,!0);if(a)return a(l,!0);var u=new Error("Cannot find module '"+l+"'");throw u.code="MODULE_NOT_FOUND",u}var d=n[l]={exports:{}};t[l][0].call(d.exports,function(e){var r=t[l][1][e];return o(r?r:e)},d,d.exports,r,t,n,i)}return n[l].exports}for(var a="function"==typeof e&&e,l=0;l<i.length;l++)o(i[l]);return o}({1:[function(e,t,r){"use strict";var n=function(e,t){var r={};return r.showType=function(r){var n=r.type();return n=n.charAt(0).toUpperCase()+n.slice(1),e("div",[e("label",t.fieldType),e("span",n)])},r.label=function(r){return e("div",[e("label",t.fieldLabel),e("input.widefat",{type:"text",value:r.label(),onchange:e.withAttr("value",r.label),placeholder:r.title()})])},r.value=function(r){var n="hidden"===r.type();return e("div",[e("label",[n?t.value:t.initialValue," ",n?"":e("small",{style:"float: right; font-weight: normal;"},t.optional)]),e("input.widefat",{type:"text",value:r.value(),onchange:e.withAttr("value",r.value)}),n?"":e("p.help",t.valueHelp)])},r.numberMinMax=function(r){return e("div",[e("div.row",[e("div.col.col-3",[e("label",t.min),e("input",{type:"number",onchange:e.withAttr("value",r.min)})]),e("div.col.col-3",[e("label",t.max),e("input",{type:"number",onchange:e.withAttr("value",r.max)})])])])},r.isRequired=function(r){var n,i={type:"checkbox",checked:r.required(),onchange:e.withAttr("checked",r.required)};return r.forceRequired()&&(i.required=!0,i.disabled=!0,n=e("p.help",t.forceRequired)),e("div",[e("label.cb-wrap",[e("input",i),t.isFieldRequired]),n])},r.placeholder=function(r){return e("div",[e("label",[t.placeholder," ",e("small",{style:"float: right; font-weight: normal;"},t.optional)]),e("input.widefat",{type:"text",value:r.placeholder(),onchange:e.withAttr("value",r.placeholder),placeholder:""}),e("p.help",t.placeholderHelp)])},r.useParagraphs=function(r){return e("div",[e("label.cb-wrap",[e("input",{type:"checkbox",checked:r.wrap(),onchange:e.withAttr("checked",r.wrap)}),t.wrapInParagraphTags])])},r.choiceType=function(r){var n=[e("option",{value:"select",selected:"select"===r.type()&&"selected"},t.dropdown),e("option",{value:"radio",selected:"radio"===r.type()&&"selected"},t.radioButtons)];return r.acceptsMultipleValues&&n.push(e("option",{value:"checkbox",selected:"checkbox"===r.type()&&"selected"},t.checkboxes)),e("div",[e("label",t.choiceType),e("select",{value:r.type(),onchange:e.withAttr("value",r.type)},n)])},r.choices=function(r){var n=[];return n.push(e("div",[e("label",t.choices),e("div.limit-height",[e("table",[r.choices().map(function(n,i){return e("tr",{"data-id":i},[e("td.cb",e("input",{name:"selected",type:"checkbox"===r.type()?"checkbox":"radio",onchange:e.withAttr("value",r.selectChoice.bind(r)),checked:n.selected(),value:n.value(),title:t.preselect})),e("td.stretch",e("input.widefat",{type:"text",value:n.label(),placeholder:n.title(),onchange:e.withAttr("value",n.label)})),e("td",e("span",{title:t.remove,"class":"dashicons dashicons-no-alt hover-activated",onclick:function(e){this.choices().splice(e,1)}.bind(r,i)},""))])})])])])),n},r};t.exports=n},{}],2:[function(e,t,r){var n=function(t,r){var n={},i=e("./field-forms-rows.js")(t,r);return n.render=function(e){var t=e.type();if("function"==typeof n[t])return n[t](e);switch(t){case"select":case"radio":case"checkbox":return n.choice(e)}return n.text(e)},n.text=function(e){return[i.label(e),i.placeholder(e),i.value(e),i.isRequired(e),i.useParagraphs(e)]},n.choice=function(e){var t=[i.label(e),i.choiceType(e),i.choices(e)];return"select"===e.type()&&t.push(i.placeholder(e)),t.push(i.useParagraphs(e)),"select"!==e.type()&&"radio"!==e.type()||t.push(i.isRequired(e)),t},n.hidden=function(e){return e.placeholder(""),e.label(""),e.wrap(!1),[i.showType(e),i.value(e)]},n.submit=function(e){return e.label(""),e.placeholder(""),[i.value(e),i.useParagraphs(e)]},n.number=function(e){return[n.text(e),i.numberMinMax(e)]},n};t.exports=n},{"./field-forms-rows.js":1}],3:[function(e,t,r){"use strict";var n=e("../third-party/render.js"),i=e("../third-party/beautify-html.js"),o=function(e){function t(t){var o,a,l,s;return o=t.label().length?e("label",t.label()):"",a="function"==typeof r[t.type()]?r[t.type()](t):r["default"](t),l=t.wrap()?e("p",[o,a]):[o,a],s=n(l),s=i(s),s+"\n"}var r={};return r.select=function(t){var r={name:t.name(),required:t.required()},n=!1,i=t.choices().map(function(t){return t.selected()&&(n=!0),e("option",{value:t.value()!==t.label()?t.value():void 0,selected:t.selected()},t.label())}),o=t.placeholder();return o.length>0&&i.unshift(e("option",{disabled:!0,value:"",selected:!n},o)),e("select",r,i)},r.checkbox=function(t){var r=t.choices().map(function(r){var n=t.name()+("checkbox"===t.type()?"[]":""),i=t.required()&&"radio"===t.type();return e("label",[e("input",{name:n,type:t.type(),value:r.value(),checked:r.selected(),required:i})," ",e("span",r.label())])});return r},r.radio=r.checkbox,r["default"]=function(t){var r,n={type:t.type()};return t.name()&&(n.name=t.name()),t.min()&&(n.min=t.min()),t.max()&&(n.max=t.max()),t.value().length>0&&(n.value=t.value()),t.placeholder().length>0&&(n.placeholder=t.placeholder()),n.required=t.required(),r=e("input",n)},t};t.exports=o},{"../third-party/beautify-html.js":12,"../third-party/render.js":13}],4:[function(e,t,r){var n=function(t,r,n,i,o,a){"use strict";function l(e){d=i.get(e),d&&d.choices().length>0&&d.value(d.choices().map(function(e){return e.label()}).join("|")),t.redraw()}function s(){}function c(){var e=f(d);n.insert(e),l(""),t.redraw()}function u(){var e=i.getCategories(),r=i.getAll(),n=t("div.available-fields.small-margin",[t("h4",a.chooseField),e.map(function(e){var n=r.filter(function(t){return t.category===e});if(n.length)return t("div.tiny-margin",[t("strong",e),n.map(function(e){var r="button";e.forceRequired()&&(r+=" is-required");var n=e.inFormContent();return null!==n&&(r+=" "+(n?"in-form":"not-in-form")),t("button",{className:r,type:"button",onclick:t.withAttr("value",l),value:e.index},e.title())})])})]),o=null;return d&&(o=h(t("div.field-wizard",[t("h3",[d.title(),d.forceRequired()?t("span.red","*"):"",d.name().length?t("code",d.name()):""]),d.help().length?t("p",t.trust(d.help())):"",p.render(d),t("p",[t("button",{"class":"button-primary",type:"button",onkeydown:function(e){e=e||window.event,13==e.keyCode&&c()},onclick:c},a.addToForm)])]),l)),[n,o]}var d,f=e("./field-generator.js")(t),h=e("./overlay.js")(t,a),p=e("./field-forms.js")(t,a);return n.on("blur",t.redraw),{view:u,controller:s}};t.exports=n},{"./field-forms.js":2,"./field-generator.js":3,"./overlay.js":10}],5:[function(e,t,r){var n=function(e,t){"use strict";function r(){u.forEach(e.deregister)}function n(t,r,n){var i=e.register(t,r);n||u.push(i)}function i(e){var t={phone:"tel",dropdown:"select",checkboxes:"checkbox",birthday:"text"};return"undefined"!=typeof t[e]?t[e]:e}function o(e){var r=t.listFields,o=i(e.field_type),a={name:e.tag,title:e.name,required:e.required,forceRequired:e.required,type:o,choices:e.choices,acceptsMultipleValues:!1};return"address"!==a.type?n(r,a,!1):(n(r,{name:a.name+"[addr1]",type:"text",mailchimpType:"address",title:t.streetAddress}),n(r,{name:a.name+"[city]",type:"text",mailchimpType:"address",title:t.city}),n(r,{name:a.name+"[state]",type:"text",mailchimpType:"address",title:t.state}),n(r,{name:a.name+"[zip]",type:"text",mailchimpType:"address",title:t.zip}),n(r,{name:a.name+"[country]",type:"select",mailchimpType:"address",title:t.country,choices:mc4wp_vars.countries})),!0}function a(e){var r=t.interestCategories,o=i(e.field_type),a={title:e.name,name:"INTERESTS["+e.id+"]",type:o,choices:e.interests,acceptsMultipleValues:"checkbox"===o};n(r,a,!1)}function l(e){e.merge_fields=e.merge_fields.sort(function(e,t){return"EMAIL"===e.tag||e["public"]&&!t["public"]?-1:!e["public"]&&t["public"]?1:0}),e.merge_fields.forEach(o),e.interest_categories.forEach(a)}function s(e){r(),e.forEach(l)}function c(e){var r,i=t.formFields;n(i,{name:"",value:t.subscribe,type:"submit",title:t.submitButton},!0),r={};for(var o in e)r[e[o].id]=e[o].name;n(i,{name:"_mc4wp_lists",type:"checkbox",title:t.listChoice,choices:r,help:t.listChoiceDescription,acceptsMultipleValues:!0},!0),r={subscribe:"Subscribe",unsubscribe:"Unsubscribe"},n(i,{name:"_mc4wp_action",type:"radio",title:t.formAction,choices:r,value:"subscribe",help:t.formActionDescription},!0)}var u=[];return{registerCustomFields:c,registerListFields:l,registerListsFields:s}};t.exports=n},{}],6:[function(e,t,r){"use strict";t.exports=function(e,t){function r(e){var t=[];return t="function"==typeof e.map?e.map(function(e){return new h({label:e})}):Object.keys(e).map(function(t){var r=e[t];return new h({label:r,value:t})})}function n(n,i){var o,a=s("name",i.name).shift();return a?void(!a.forceRequired()&&i.forceRequired&&a.forceRequired(!0)):(i.choices&&(i.choices=r(i.choices),i.value&&(i.choices=i.choices.map(function(e){return e.value()===i.value&&e.selected(!0),e}))),d.indexOf(n)<0&&d.push(n),o=new f(i),o.category=n,u.push(o),c&&window.clearTimeout(c),c=window.setTimeout(e.redraw,200),t.trigger("fields.change"),o)}function i(t){var r=u.indexOf(t);r>-1&&(delete u[r],e.redraw())}function o(e){return u[e]}function a(){return u=u.map(function(e,t){return e.index=t,e})}function l(){return d}function s(e,t){return u.filter(function(r){return r[e]()===t})}var c,u=[],d=[],f=function(t){this.name=e.prop(t.name),this.title=e.prop(t.title||t.name),this.type=e.prop(t.type),this.mailchimpType=e.prop(t.mailchimpType||""),this.label=e.prop(t.title||""),this.value=e.prop(t.value||""),this.placeholder=e.prop(t.placeholder||""),this.required=e.prop(t.required||!1),this.forceRequired=e.prop(t.forceRequired||!1),this.wrap=e.prop(t.wrap||!0),this.min=e.prop(t.min||null),this.max=e.prop(t.max||null),this.help=e.prop(t.help||""),this.choices=e.prop(t.choices||[]),this.inFormContent=e.prop(null),this.acceptsMultipleValues=t.acceptsMultipleValues,this.selectChoice=function(e){var t=this;this.choices(this.choices().map(function(r){return r.value()===e?r.selected(!0):"checkbox"!==t.type()&&r.selected(!1),r}))}},h=function(t){this.label=e.prop(t.label),this.title=e.prop(t.title||t.label),this.selected=e.prop(t.selected||!1),this.value=e.prop(t.value||t.label)};return{get:o,getAll:a,getCategories:l,deregister:i,register:n,getAllWhere:s}}},{}],7:[function(e,t,r){"use strict";var n=e("codemirror");e("codemirror/mode/xml/xml"),e("codemirror/mode/javascript/javascript"),e("codemirror/mode/css/css"),e("codemirror/mode/htmlmixed/htmlmixed"),e("codemirror/addon/fold/xml-fold"),e("codemirror/addon/edit/matchtags"),e("codemirror/addon/edit/closetag.js");var i=function(e){function t(){return o&&(i.innerHTML=a.getValue().toLowerCase(),o=!1),i}var r,i=document.createElement("form"),o=!1,a={};return i.innerHTML=e.value.toLowerCase(),n&&(r=n.fromTextArea(e,{selectionPointer:!0,matchTags:{bothTags:!0},mode:"htmlmixed",htmlMode:!0,autoCloseTags:!0,autoRefresh:!0}),window.dispatchEvent&&r.on("change",function(){if("function"==typeof Event){var t=new Event("change",{bubbles:!0});e.dispatchEvent(t)}})),window.addEventListener("load",function(){n.signal(r,"change")}),e.addEventListener("change",function(){o=!0}),a.getValue=function(){return r?r.getValue():e.value},a.query=function(e){return t().querySelectorAll(e.toLowerCase())},a.containsField=function(e){return null!==t().elements.namedItem(e.toLowerCase())},a.insert=function(t){r?(r.replaceSelection(t),r.focus()):e.value+=t},a.on=function(t,n){return r?(t="input"===t?"changes":t,r.on(t,n)):e.addEventListener(t,n)},a.refresh=function(){r&&r.refresh()},a};t.exports=i},{codemirror:17,"codemirror/addon/edit/closetag.js":14,"codemirror/addon/edit/matchtags":15,"codemirror/addon/fold/xml-fold":16,"codemirror/mode/css/css":18,"codemirror/mode/htmlmixed/htmlmixed":19,"codemirror/mode/javascript/javascript":20,"codemirror/mode/xml/xml":21}],8:[function(e,t,r){var n=function(e,t,r,n,i,o){"use strict";function a(){n.getAll().forEach(function(e){if(!(e.name().length<=0)){var r=e.name();"checkbox"===e.type()&&(r+="[]");var n=t.containsField(r);if(e.inFormContent(n),"address"===e.mailchimpType()){e.originalRequiredValue=void 0===e.originalRequiredValue?e.forceRequired():e.originalRequiredValue;var i=e.name().replace(/\[(\w+)\]/g,"");t.query('[name^="'+i+'"]').length>0?(void 0===e.originalRequiredValue&&(e.originalRequiredValue=e.forceRequired()),e.forceRequired(!0)):e.forceRequired(e.originalRequiredValue)}}}),l(),e.redraw()}function l(){var e=n.getAllWhere("forceRequired",!0).map(function(e){return e.name().toUpperCase().replace(/\[(\w+)\]/g,".$1")}),r=t.query("[required]");Array.prototype.forEach.call(r,function(t){var r=t.name.toUpperCase();"_"!==r[0]&&(r=r.replace(/\[(\w+)\]/g,".$1"),e.indexOf(r)===-1&&e.push(r))}),s.value=e.join(",")}var s=document.getElementById("required-fields");t.on("change",o.debounce(a,500)),i.on("fields.change",o.debounce(a,500))};t.exports=n},{}],9:[function(e,t,r){"use strict";function n(e,t){l[e]=t,o()}function i(e){delete l[e],o()}function o(){var e="";for(var t in l)e+='<div class="notice notice-warning inline"><p>'+l[t]+"</p></div>";var r=document.querySelector(".mc4wp-notices");if(!r){r=document.createElement("div"),r.className="mc4wp-notices";var n=document.querySelector("h1, h2");n.parentNode.insertBefore(r,n.nextSibling)}r.innerHTML=e}function a(e,t){var r=function(){var t="Your form contains old style <code>GROUPINGS</code> fields. <br /><br />Please remove these fields from your form and then re-add them through the available field buttons to make sure your data is getting through to MailChimp correctly.",r=e.getValue().toLowerCase();r.indexOf('name="groupings')>-1?n("deprecated_groupings",t):i("deprecated_groupings")},o=function(){var r=t.getAllWhere("forceRequired",!0),o=r.filter(function(t){return!e.containsField(t.name().toUpperCase())}),a="<strong>Heads up!</strong> Your form is missing list fields that are required in MailChimp. Either add these fields to your form or mark them as optional in MailChimp.";a+='<br /><ul class="ul-square" style="margin-bottom: 0;"><li>'+o.map(function(e){return e.title()}).join("</li><li>")+"</li></ul>",o.length>0?n("required_fields_missing",a):i("required_fields_missing")};r(),e.on("focus",r),e.on("blur",r),o(),e.on("blur",o),e.on("focus",o)}var l={};t.exports={init:a}},{}],10:[function(e,t,r){var n=function(e,t){"use strict";function r(){document.removeEventListener("keydown",n),window.removeEventListener("resize",i),a()}function n(e){e=e||window.event,27==e.keyCode&&r(),13==e.keyCode&&e.preventDefault()}function i(){if(o){var e=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,t=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,r=(e-o.clientWidth-40)/2,n=(t-o.clientHeight-40)/2;o.style.left=(r>0?r:0)+"px",o.style.top=(n>0?n:0)+"px"}}var o,a;return function(l,s){return a=s,document.addEventListener("keydown",n),window.addEventListener("resize",i),[e("div.overlay-wrap",e("div.overlay",{config:function(e){o=e,i()}},[e("span",{"class":"close dashicons dashicons-no",title:t.close,onclick:r}),l])),e("div.overlay-background",{title:t.close,onclick:r})]}};t.exports=n},{}],11:[function(e,t,r){"use strict";var n=window.mc4wp_forms_i18n,i=window.mc4wp.deps.mithril,o=mc4wp.events,a=mc4wp.settings,l=mc4wp.helpers,s=mc4wp.tabs,c=e("./admin/form-watcher.js"),u=e("./admin/form-editor.js"),d=e("./admin/field-helper.js"),f=e("./admin/fields-factory.js"),h=e("./admin/fields.js")(i,o),p=document.getElementById("mc4wp-form-content"),g=window.formEditor=new u(p),m=(new c(i,formEditor,a,h,o,l),new d(i,s,formEditor,h,o,n)),v=e("./admin/notices");i.mount(document.getElementById("mc4wp-field-wizard"),m);var y=new f(h,n);o.on("selectedLists.change",y.registerListsFields),y.registerListsFields(a.getSelectedLists()),y.registerCustomFields(mc4wp_vars.mailchimp.lists),window.setTimeout(function(){i.redraw()},2e3),v.init(g,h),window.mc4wp=window.mc4wp||{},window.mc4wp.forms=window.mc4wp.forms||{},window.mc4wp.forms.editor=g,window.mc4wp.forms.fields=h},{"./admin/field-helper.js":4,"./admin/fields-factory.js":5,"./admin/fields.js":6,"./admin/form-editor.js":7,"./admin/form-watcher.js":8,"./admin/notices":9}],12:[function(e,t,r){!function(){function e(e){return e.replace(/^\s+|\s+$/g,"")}function r(e){return e.replace(/^\s+/g,"")}function n(t,n,i,o){function a(){return this.pos=0,this.token="",this.current_mode="CONTENT",this.tags={parent:"parent1",parentcount:1,parent1:""},this.tag_type="",this.token_text=this.last_token=this.last_text=this.token_type="",this.newlines=0,this.indent_content=s,this.Utils={whitespace:"\n\r\t ".split(""),single_token:"br,input,link,meta,!doctype,basefont,base,area,hr,wbr,param,img,isindex,?xml,embed,?php,?,?=".split(","),extra_liners:"head,body,/html".split(","),in_array:function(e,t){for(var r=0;r<t.length;r++)if(e===t[r])return!0;return!1}},this.traverse_whitespace=function(){var e="";if(e=this.input.charAt(this.pos),this.Utils.in_array(e,this.Utils.whitespace)){for(this.newlines=0;this.Utils.in_array(e,this.Utils.whitespace);)p&&"\n"===e&&this.newlines<=g&&(this.newlines+=1),this.pos++,e=this.input.charAt(this.pos);return!0}return!1},this.get_content=function(){for(var e="",t=[],r=!1;"<"!==this.input.charAt(this.pos);){if(this.pos>=this.input.length)return t.length?t.join(""):["","TK_EOF"];if(this.traverse_whitespace())t.length&&(r=!0);else{if(indent_handlebars){var n=this.input.substr(this.pos,3);if("{{#"===n||"{{/"===n)break;if("{{"===this.input.substr(this.pos,2)&&"{{else}}"===this.get_tag(!0))break}e=this.input.charAt(this.pos),this.pos++,r&&(this.line_char_count>=this.wrap_line_length?(this.print_newline(!1,t),this.print_indentation(t)):(this.line_char_count++,t.push(" ")),r=!1),this.line_char_count++,t.push(e)}}return t.length?t.join(""):""},this.get_contents_to=function(e){if(this.pos===this.input.length)return["","TK_EOF"];var t="",r=new RegExp("</"+e+"\\s*>","igm");r.lastIndex=this.pos;var n=r.exec(this.input),i=n?n.index:this.input.length;return this.pos<i&&(t=this.input.substring(this.pos,i),this.pos=i),t},this.record_tag=function(e){this.tags[e+"count"]?(this.tags[e+"count"]++,this.tags[e+this.tags[e+"count"]]=this.indent_level):(this.tags[e+"count"]=1,this.tags[e+this.tags[e+"count"]]=this.indent_level),this.tags[e+this.tags[e+"count"]+"parent"]=this.tags.parent,this.tags.parent=e+this.tags[e+"count"]},this.retrieve_tag=function(e){if(this.tags[e+"count"]){for(var t=this.tags.parent;t&&e+this.tags[e+"count"]!==t;)t=this.tags[t+"parent"];t&&(this.indent_level=this.tags[e+this.tags[e+"count"]],this.tags.parent=this.tags[t+"parent"]),delete this.tags[e+this.tags[e+"count"]+"parent"],delete this.tags[e+this.tags[e+"count"]],1===this.tags[e+"count"]?delete this.tags[e+"count"]:this.tags[e+"count"]--}},this.indent_to_tag=function(e){if(this.tags[e+"count"]){for(var t=this.tags.parent;t&&e+this.tags[e+"count"]!==t;)t=this.tags[t+"parent"];t&&(this.indent_level=this.tags[e+this.tags[e+"count"]])}},this.get_tag=function(e){var t,r,n,i="",o=[],a="",l=!1,s=this.pos,c=this.line_char_count;e=void 0!==e&&e;do{if(this.pos>=this.input.length)return e&&(this.pos=s,this.line_char_count=c),o.length?o.join(""):["","TK_EOF"];if(i=this.input.charAt(this.pos),this.pos++,this.Utils.in_array(i,this.Utils.whitespace))l=!0;else{if("'"!==i&&'"'!==i||(i+=this.get_unformatted(i),l=!0),"="===i&&(l=!1),o.length&&"="!==o[o.length-1]&&">"!==i&&l&&(this.line_char_count>=this.wrap_line_length?(this.print_newline(!1,o),this.print_indentation(o)):(o.push(" "),this.line_char_count++),l=!1),indent_handlebars&&"<"===n&&i+this.input.charAt(this.pos)==="{{"&&(i+=this.get_unformatted("}}"),o.length&&" "!==o[o.length-1]&&"<"!==o[o.length-1]&&(i=" "+i),l=!0),"<"!==i||n||(t=this.pos-1,n="<"),indent_handlebars&&!n&&o.length>=2&&"{"===o[o.length-1]&&"{"==o[o.length-2]&&(t="#"===i||"/"===i?this.pos-3:this.pos-2,n="{"),this.line_char_count++,o.push(i),o[1]&&"!"===o[1]){o=[this.get_comment(t)];break}if(indent_handlebars&&"{"===n&&o.length>2&&"}"===o[o.length-2]&&"}"===o[o.length-1])break}}while(">"!==i);var u,d,f=o.join("");u=f.indexOf(" ")!==-1?f.indexOf(" "):"{"===f[0]?f.indexOf("}"):f.indexOf(">"),d="<"!==f[0]&&indent_handlebars?"#"===f[2]?3:2:1;var p=f.substring(d,u).toLowerCase();return"/"===f.charAt(f.length-2)||this.Utils.in_array(p,this.Utils.single_token)?e||(this.tag_type="SINGLE"):indent_handlebars&&"{"===f[0]&&"else"===p?e||(this.indent_to_tag("if"),this.tag_type="HANDLEBARS_ELSE",this.indent_content=!0,this.traverse_whitespace()):"script"===p?e||(this.record_tag(p),this.tag_type="SCRIPT"):"style"===p?e||(this.record_tag(p),this.tag_type="STYLE"):this.is_unformatted(p,h)?(a=this.get_unformatted("</"+p+">",f),o.push(a),t>0&&this.Utils.in_array(this.input.charAt(t-1),this.Utils.whitespace)&&o.splice(0,0,this.input.charAt(t-1)),r=this.pos-1,this.Utils.in_array(this.input.charAt(r+1),this.Utils.whitespace)&&o.push(this.input.charAt(r+1)),this.tag_type="SINGLE"):"!"===p.charAt(0)?e||(this.tag_type="SINGLE",this.traverse_whitespace()):e||("/"===p.charAt(0)?(this.retrieve_tag(p.substring(1)),this.tag_type="END",this.traverse_whitespace()):(this.record_tag(p),"html"!==p.toLowerCase()&&(this.indent_content=!0),this.tag_type="START",this.traverse_whitespace()),this.Utils.in_array(p,this.Utils.extra_liners)&&(this.print_newline(!1,this.output),this.output.length&&"\n"!==this.output[this.output.length-2]&&this.print_newline(!0,this.output))),e&&(this.pos=s,this.line_char_count=c),o.join("")},this.get_comment=function(e){var t="",r=">",n=!1;for(this.pos=e,input_char=this.input.charAt(this.pos),this.pos++;this.pos<=this.input.length&&(t+=input_char,t[t.length-1]!==r[r.length-1]||t.indexOf(r)===-1);)!n&&t.length<10&&(0===t.indexOf("<![if")?(r="<![endif]>",n=!0):0===t.indexOf("<![cdata[")?(r="]]>",n=!0):0===t.indexOf("<![")?(r="]>",n=!0):0===t.indexOf("<!--")&&(r="-->",n=!0)),input_char=this.input.charAt(this.pos),this.pos++;return t},this.get_unformatted=function(e,t){if(t&&t.toLowerCase().indexOf(e)!==-1)return"";var r="",n="",i=0,o=!0;do{if(this.pos>=this.input.length)return n;if(r=this.input.charAt(this.pos),this.pos++,this.Utils.in_array(r,this.Utils.whitespace)){if(!o){this.line_char_count--;continue}if("\n"===r||"\r"===r){n+="\n",this.line_char_count=0;continue}}n+=r,this.line_char_count++,o=!0,indent_handlebars&&"{"===r&&n.length&&"{"===n[n.length-2]&&(n+=this.get_unformatted("}}"),i=n.length)}while(n.toLowerCase().indexOf(e,i)===-1);return n},this.get_token=function(){var e;if("TK_TAG_SCRIPT"===this.last_token||"TK_TAG_STYLE"===this.last_token){var t=this.last_token.substr(7);return e=this.get_contents_to(t),"string"!=typeof e?e:[e,"TK_"+t]}if("CONTENT"===this.current_mode)return e=this.get_content(),"string"!=typeof e?e:[e,"TK_CONTENT"];if("TAG"===this.current_mode){if(e=this.get_tag(),"string"!=typeof e)return e;var r="TK_TAG_"+this.tag_type;return[e,r]}},this.get_full_indent=function(e){return e=this.indent_level+e||0,e<1?"":Array(e+1).join(this.indent_string)},this.is_unformatted=function(e,t){if(!this.Utils.in_array(e,t))return!1;if("a"!==e.toLowerCase()||!this.Utils.in_array("a",t))return!0;var r=this.get_tag(!0),n=(r||"").match(/^\s*<\s*\/?([a-z]*)\s*[^>]*>\s*$/);return!(n&&!this.Utils.in_array(n,t))},this.printer=function(e,t,n,i,o){this.input=e||"",this.output=[],this.indent_character=t,this.indent_string="",this.indent_size=n,this.brace_style=o,this.indent_level=0,this.wrap_line_length=i,this.line_char_count=0;for(var a=0;a<this.indent_size;a++)this.indent_string+=this.indent_character;this.print_newline=function(e,t){this.line_char_count=0,t&&t.length&&(e||"\n"!==t[t.length-1])&&t.push("\n")},this.print_indentation=function(e){for(var t=0;t<this.indent_level;t++)e.push(this.indent_string),this.line_char_count+=this.indent_string.length},this.print_token=function(e){(e||""!==e)&&this.output.length&&"\n"===this.output[this.output.length-1]&&(this.print_indentation(this.output),e=r(e)),this.print_token_raw(e)},this.print_token_raw=function(e){e&&""!==e&&(e.length>1&&"\n"===e[e.length-1]?(this.output.push(e.slice(0,-1)),this.print_newline(!1,this.output)):this.output.push(e));for(var t=0;t<this.newlines;t++)this.print_newline(t>0,this.output);this.newlines=0},this.indent=function(){this.indent_level++},this.unindent=function(){this.indent_level>0&&this.indent_level--}},this}var l,s,c,u,d,f,h,p,g;for(n=n||{},void 0!==n.wrap_line_length&&0!==parseInt(n.wrap_line_length,10)||void 0!==n.max_char&&0!==parseInt(n.max_char,10)||(n.wrap_line_length=n.max_char),s=n.indent_inner_html||!1,c=parseInt(n.indent_size||4,10),u=n.indent_char||" ",f=n.brace_style||"collapse",d=0===parseInt(n.wrap_line_length,10)?32786:parseInt(n.wrap_line_length||250,10),h=n.unformatted||["a","span","bdo","em","strong","dfn","code","samp","kbd","var","cite","abbr","acronym","q","sub","sup","tt","i","b","big","small","u","s","strike","font","ins","del","pre","address","dt","h1","h2","h3","h4","h5","h6"],p=n.preserve_newlines||!0,g=p?parseInt(n.max_preserve_newlines||32786,10):0,indent_handlebars=n.indent_handlebars||!1,l=new a,l.printer(t,u,c,d,f);;){var m=l.get_token();if(l.token_text=m[0],l.token_type=m[1],"TK_EOF"===l.token_type)break;switch(l.token_type){case"TK_TAG_START":l.print_newline(!1,l.output),l.print_token(l.token_text),l.indent_content&&(l.indent(),l.indent_content=!1),l.current_mode="CONTENT";break;case"TK_TAG_STYLE":case"TK_TAG_SCRIPT":l.print_newline(!1,l.output),l.print_token(l.token_text),l.current_mode="CONTENT";break;case"TK_TAG_END":if("TK_CONTENT"===l.last_token&&""===l.last_text){var v=l.token_text.match(/\w+/)[0],y=null;l.output.length&&(y=l.output[l.output.length-1].match(/(?:<|{{#)\s*(\w+)/)),null!==y&&y[1]===v||l.print_newline(!1,l.output)}l.print_token(l.token_text),l.current_mode="CONTENT";break;case"TK_TAG_SINGLE":var b=l.token_text.match(/^\s*<([a-z]+)/i);b&&l.Utils.in_array(b[1],h)||l.print_newline(!1,l.output),l.print_token(l.token_text),l.current_mode="CONTENT";break;case"TK_TAG_HANDLEBARS_ELSE":l.print_token(l.token_text),l.indent_content&&(l.indent(),l.indent_content=!1),l.current_mode="CONTENT";break;case"TK_CONTENT":l.print_token(l.token_text),l.current_mode="TAG";break;case"TK_STYLE":case"TK_SCRIPT":if(""!==l.token_text){l.print_newline(!1,l.output);var w,x=l.token_text,k=1;"TK_SCRIPT"===l.token_type?w="function"==typeof i&&i:"TK_STYLE"===l.token_type&&(w="function"==typeof o&&o),"keep"===n.indent_scripts?k=0:"separate"===n.indent_scripts&&(k=-l.indent_level);var C=l.get_full_indent(k);if(w)x=w(x.replace(/^\s*/,C),n);else{var S=x.match(/^\s*/)[0],T=S.match(/[^\n\r]*$/)[0].split(l.indent_string).length-1,L=l.get_full_indent(k-T);x=x.replace(/^\s*/,C).replace(/\r\n|\r|\n/g,"\n"+L).replace(/\s+$/,"")}x&&(l.print_token_raw(C+e(x)),l.print_newline(!1,l.output))}l.current_mode="TAG"}l.last_token=l.token_type,l.last_text=l.token_text}return l.output.join("")}"undefined"!=typeof t&&"undefined"!=typeof t.exports?t.exports=n:"undefined"!=typeof window&&(window.html_beautify=n)}()},{}],13:[function(e,t,r){"use strict";function n(e){return"[object Array]"===Object.prototype.toString.call(e)}function i(e){return e.replace(/\W+/g,"-").replace(/([a-z\d])([A-Z])/g,"$1-$2")}function o(e){return""!=e}function a(e,t){return"undefined"===e&&(e=""),"string"!=typeof e&&(e+=""),e=e.replace(/\&/g,"&amp;").replace(/</g,"&lt;").replace(/\>/g,"&gt;"),t?e.replace(/\"/g,"&quot;"):e}function l(e){return e&&Object.keys(e).length?Object.keys(e).map(function(t){var r=e[t];if("undefined"!=typeof r&&null!==r&&"function"!=typeof r){if("boolean"==typeof r)return r?" "+t:"";if("style"===t){if(!r)return;var n=e.style;return"object"==typeof n&&(n=Object.keys(n).map(function(e){return""!=n[e]?[i(e).toLowerCase(),n[e]].join(":"):""}).filter(o).join(";")),""!=n?' style="'+a(n,!0)+'"':""}return" "+a("className"===t?"class":t)+'="'+a(r,!0)+'"'}}).join(""):""}function s(e){return n(e.children)&&!e.children.length?"":c(e.children)}function c(e){var t=typeof e;if("string"===t)return a(e);if("number"===t||"boolean"===t)return e;if(!e)return"";if(n(e))return e.map(c).join("");if(e.view){var r=e.controller?new e.controller:{},i=c(e.view(r));return r.onunload&&r.onunload(),i}if(e.$trusted)return""+e;var o=s(e);return!o&&u.indexOf(e.tag.toLowerCase())>=0?"<"+e.tag+l(e.attrs)+">":["<",e.tag,l(e.attrs),">",o,"</",e.tag,">"].join("")}var u=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr","!doctype"];t.exports=c},{}],14:[function(e,r,n){!function(i){"object"==typeof n&&"object"==typeof r?i(e("../../lib/codemirror"),e("../fold/xml-fold")):"function"==typeof t&&t.amd?t(["../../lib/codemirror","../fold/xml-fold"],i):i(CodeMirror)}(function(e){function t(t){if(t.getOption("disableInput"))return e.Pass;for(var r=t.listSelections(),n=[],s=0;s<r.length;s++){if(!r[s].empty())return e.Pass;var c=r[s].head,u=t.getTokenAt(c),d=e.innerMode(t.getMode(),u.state),f=d.state;if("xml"!=d.mode.name||!f.tagName)return e.Pass;var h=t.getOption("autoCloseTags"),p="html"==d.mode.configuration,g="object"==typeof h&&h.dontCloseTags||p&&a,m="object"==typeof h&&h.indentTags||p&&l,v=f.tagName;u.end>c.ch&&(v=v.slice(0,v.length-u.end+c.ch));var y=v.toLowerCase();if(!v||"string"==u.type&&(u.end!=c.ch||!/[\"\']/.test(u.string.charAt(u.string.length-1))||1==u.string.length)||"tag"==u.type&&"closeTag"==f.type||u.string.indexOf("/")==u.string.length-1||g&&i(g,y)>-1||o(t,v,c,f,!0))return e.Pass;var b=m&&i(m,y)>-1;n[s]={indent:b,text:">"+(b?"\n\n":"")+"</"+v+">",newPos:b?e.Pos(c.line+1,0):e.Pos(c.line,c.ch+1)}}for(var s=r.length-1;s>=0;s--){var w=n[s];t.replaceRange(w.text,r[s].head,r[s].anchor,"+insert");var x=t.listSelections().slice(0);x[s]={head:w.newPos,anchor:w.newPos},t.setSelections(x),w.indent&&(t.indentLine(w.newPos.line,null,!0),t.indentLine(w.newPos.line+1,null,!0))}}function r(t,r){for(var n=t.listSelections(),i=[],a=r?"/":"</",l=0;l<n.length;l++){if(!n[l].empty())return e.Pass;var s=n[l].head,c=t.getTokenAt(s),u=e.innerMode(t.getMode(),c.state),d=u.state;if(r&&("string"==c.type||"<"!=c.string.charAt(0)||c.start!=s.ch-1))return e.Pass;var f;if("xml"!=u.mode.name)if("htmlmixed"==t.getMode().name&&"javascript"==u.mode.name)f=a+"script";else{if("htmlmixed"!=t.getMode().name||"css"!=u.mode.name)return e.Pass;f=a+"style"}else{if(!d.context||!d.context.tagName||o(t,d.context.tagName,s,d))return e.Pass;f=a+d.context.tagName}">"!=t.getLine(s.line).charAt(c.end)&&(f+=">"),i[l]=f}t.replaceSelections(i),n=t.listSelections();for(var l=0;l<n.length;l++)(l==n.length-1||n[l].head.line<n[l+1].head.line)&&t.indentLine(n[l].head.line)}function n(t){return t.getOption("disableInput")?e.Pass:r(t,!0)}function i(e,t){if(e.indexOf)return e.indexOf(t);for(var r=0,n=e.length;r<n;++r)if(e[r]==t)return r;return-1}function o(t,r,n,i,o){if(!e.scanForClosingTag)return!1;var a=Math.min(t.lastLine()+1,n.line+500),l=e.scanForClosingTag(t,n,null,a);if(!l||l.tag!=r)return!1;for(var s=i.context,c=o?1:0;s&&s.tagName==r;s=s.prev)++c;n=l.to;for(var u=1;u<c;u++){var d=e.scanForClosingTag(t,n,null,a);if(!d||d.tag!=r)return!1;n=d.to}return!0}e.defineOption("autoCloseTags",!1,function(r,i,o){if(o!=e.Init&&o&&r.removeKeyMap("autoCloseTags"),i){var a={name:"autoCloseTags"};("object"!=typeof i||i.whenClosing)&&(a["'/'"]=function(e){return n(e)}),("object"!=typeof i||i.whenOpening)&&(a["'>'"]=function(e){return t(e)}),r.addKeyMap(a)}});var a=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],l=["applet","blockquote","body","button","div","dl","fieldset","form","frameset","h1","h2","h3","h4","h5","h6","head","html","iframe","layer","legend","object","ol","p","select","table","ul"];e.commands.closeTag=function(e){return r(e)}})},{"../../lib/codemirror":17,"../fold/xml-fold":16}],15:[function(e,r,n){!function(i){"object"==typeof n&&"object"==typeof r?i(e("../../lib/codemirror"),e("../fold/xml-fold")):"function"==typeof t&&t.amd?t(["../../lib/codemirror","../fold/xml-fold"],i):i(CodeMirror);
2
- }(function(e){"use strict";function t(e){e.state.tagHit&&e.state.tagHit.clear(),e.state.tagOther&&e.state.tagOther.clear(),e.state.tagHit=e.state.tagOther=null}function r(r){r.state.failedTagMatch=!1,r.operation(function(){if(t(r),!r.somethingSelected()){var n=r.getCursor(),i=r.getViewport();i.from=Math.min(i.from,n.line),i.to=Math.max(n.line+1,i.to);var o=e.findMatchingTag(r,n,i);if(o){if(r.state.matchBothTags){var a="open"==o.at?o.open:o.close;a&&(r.state.tagHit=r.markText(a.from,a.to,{className:"CodeMirror-matchingtag"}))}var l="close"==o.at?o.open:o.close;l?r.state.tagOther=r.markText(l.from,l.to,{className:"CodeMirror-matchingtag"}):r.state.failedTagMatch=!0}}})}function n(e){e.state.failedTagMatch&&r(e)}e.defineOption("matchTags",!1,function(i,o,a){a&&a!=e.Init&&(i.off("cursorActivity",r),i.off("viewportChange",n),t(i)),o&&(i.state.matchBothTags="object"==typeof o&&o.bothTags,i.on("cursorActivity",r),i.on("viewportChange",n),r(i))}),e.commands.toMatchingTag=function(t){var r=e.findMatchingTag(t,t.getCursor());if(r){var n="close"==r.at?r.open:r.close;n&&t.extendSelection(n.to,n.from)}}})},{"../../lib/codemirror":17,"../fold/xml-fold":16}],16:[function(e,r,n){!function(i){"object"==typeof n&&"object"==typeof r?i(e("../../lib/codemirror")):"function"==typeof t&&t.amd?t(["../../lib/codemirror"],i):i(CodeMirror)}(function(e){"use strict";function t(e,t){return e.line-t.line||e.ch-t.ch}function r(e,t,r,n){this.line=t,this.ch=r,this.cm=e,this.text=e.getLine(t),this.min=n?Math.max(n.from,e.firstLine()):e.firstLine(),this.max=n?Math.min(n.to-1,e.lastLine()):e.lastLine()}function n(e,t){var r=e.cm.getTokenTypeAt(f(e.line,t));return r&&/\btag\b/.test(r)}function i(e){if(!(e.line>=e.max))return e.ch=0,e.text=e.cm.getLine(++e.line),!0}function o(e){if(!(e.line<=e.min))return e.text=e.cm.getLine(--e.line),e.ch=e.text.length,!0}function a(e){for(;;){var t=e.text.indexOf(">",e.ch);if(t==-1){if(i(e))continue;return}{if(n(e,t+1)){var r=e.text.lastIndexOf("/",t),o=r>-1&&!/\S/.test(e.text.slice(r+1,t));return e.ch=t+1,o?"selfClose":"regular"}e.ch=t+1}}}function l(e){for(;;){var t=e.ch?e.text.lastIndexOf("<",e.ch-1):-1;if(t==-1){if(o(e))continue;return}if(n(e,t+1)){g.lastIndex=t,e.ch=t;var r=g.exec(e.text);if(r&&r.index==t)return r}else e.ch=t}}function s(e){for(;;){g.lastIndex=e.ch;var t=g.exec(e.text);if(!t){if(i(e))continue;return}{if(n(e,t.index+1))return e.ch=t.index+t[0].length,t;e.ch=t.index+1}}}function c(e){for(;;){var t=e.ch?e.text.lastIndexOf(">",e.ch-1):-1;if(t==-1){if(o(e))continue;return}{if(n(e,t+1)){var r=e.text.lastIndexOf("/",t),i=r>-1&&!/\S/.test(e.text.slice(r+1,t));return e.ch=t+1,i?"selfClose":"regular"}e.ch=t}}}function u(e,t){for(var r=[];;){var n,i=s(e),o=e.line,l=e.ch-(i?i[0].length:0);if(!i||!(n=a(e)))return;if("selfClose"!=n)if(i[1]){for(var c=r.length-1;c>=0;--c)if(r[c]==i[2]){r.length=c;break}if(c<0&&(!t||t==i[2]))return{tag:i[2],from:f(o,l),to:f(e.line,e.ch)}}else r.push(i[2])}}function d(e,t){for(var r=[];;){var n=c(e);if(!n)return;if("selfClose"!=n){var i=e.line,o=e.ch,a=l(e);if(!a)return;if(a[1])r.push(a[2]);else{for(var s=r.length-1;s>=0;--s)if(r[s]==a[2]){r.length=s;break}if(s<0&&(!t||t==a[2]))return{tag:a[2],from:f(e.line,e.ch),to:f(i,o)}}}else l(e)}}var f=e.Pos,h="A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",p=h+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",g=new RegExp("<(/?)(["+h+"]["+p+"]*)","g");e.registerHelper("fold","xml",function(e,t){for(var n=new r(e,t.line,0);;){var i,o=s(n);if(!o||n.line!=t.line||!(i=a(n)))return;if(!o[1]&&"selfClose"!=i){var l=f(n.line,n.ch),c=u(n,o[2]);return c&&{from:l,to:c.from}}}}),e.findMatchingTag=function(e,n,i){var o=new r(e,n.line,n.ch,i);if(o.text.indexOf(">")!=-1||o.text.indexOf("<")!=-1){var s=a(o),c=s&&f(o.line,o.ch),h=s&&l(o);if(s&&h&&!(t(o,n)>0)){var p={from:f(o.line,o.ch),to:c,tag:h[2]};return"selfClose"==s?{open:p,close:null,at:"open"}:h[1]?{open:d(o,h[2]),close:p,at:"close"}:(o=new r(e,c.line,c.ch,i),{open:p,close:u(o,h[2]),at:"open"})}}},e.findEnclosingTag=function(e,t,n){for(var i=new r(e,t.line,t.ch,n);;){var o=d(i);if(!o)break;var a=new r(e,t.line,t.ch,n),l=u(a,o.tag);if(l)return{open:o,close:l}}},e.scanForClosingTag=function(e,t,n,i){var o=new r(e,t.line,t.ch,i?{from:0,to:i}:null);return u(o,n)}})},{"../../lib/codemirror":17}],17:[function(e,r,n){!function(e,i){"object"==typeof n&&"undefined"!=typeof r?r.exports=i():"function"==typeof t&&t.amd?t(i):e.CodeMirror=i()}(this,function(){"use strict";function e(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function t(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function r(e,r){return t(e).appendChild(r)}function n(e,t,r,n){var i=document.createElement(e);if(r&&(i.className=r),n&&(i.style.cssText=n),"string"==typeof t)i.appendChild(document.createTextNode(t));else if(t)for(var o=0;o<t.length;++o)i.appendChild(t[o]);return i}function i(e,t){if(3==t.nodeType&&(t=t.parentNode),e.contains)return e.contains(t);do if(11==t.nodeType&&(t=t.host),t==e)return!0;while(t=t.parentNode)}function o(t,r){var n=t.className;e(r).test(n)||(t.className+=(n?" ":"")+r)}function a(t,r){for(var n=t.split(" "),i=0;i<n.length;i++)n[i]&&!e(n[i]).test(r)&&(r+=" "+n[i]);return r}function l(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function s(e,t,r){t||(t={});for(var n in e)!e.hasOwnProperty(n)||r===!1&&t.hasOwnProperty(n)||(t[n]=e[n]);return t}function c(e,t,r,n,i){null==t&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));for(var o=n||0,a=i||0;;){var l=e.indexOf("\t",o);if(l<0||l>=t)return a+(t-o);a+=l-o,a+=r-a%r,o=l+1}}function u(){this.id=null}function d(e,t){for(var r=0;r<e.length;++r)if(e[r]==t)return r;return-1}function f(e,t,r){for(var n=0,i=0;;){var o=e.indexOf("\t",n);o==-1&&(o=e.length);var a=o-n;if(o==e.length||i+a>=t)return n+Math.min(a,t-i);if(i+=o-n,i+=r-i%r,n=o+1,i>=t)return n}}function h(e){for(;za.length<=e;)za.push(p(za)+" ");return za[e]}function p(e){return e[e.length-1]}function g(e,t){for(var r=[],n=0;n<e.length;n++)r[n]=t(e[n],n);return r}function m(e,t,r){for(var n=0,i=r(t);n<e.length&&r(e[n])<=i;)n++;e.splice(n,0,t)}function v(){}function y(e,t){var r;return Object.create?r=Object.create(e):(v.prototype=e,r=new v),t&&s(t,r),r}function b(e){return/\w/.test(e)||e>"€"&&(e.toUpperCase()!=e.toLowerCase()||Pa.test(e))}function w(e,t){return t?!!(t.source.indexOf("\\w")>-1&&b(e))||t.test(e):b(e)}function x(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function k(e){return e.charCodeAt(0)>=768&&Da.test(e)}function C(e,t,r){var i=this;this.input=r,i.scrollbarFiller=n("div",null,"CodeMirror-scrollbar-filler"),i.scrollbarFiller.setAttribute("cm-not-content","true"),i.gutterFiller=n("div",null,"CodeMirror-gutter-filler"),i.gutterFiller.setAttribute("cm-not-content","true"),i.lineDiv=n("div",null,"CodeMirror-code"),i.selectionDiv=n("div",null,null,"position: relative; z-index: 1"),i.cursorDiv=n("div",null,"CodeMirror-cursors"),i.measure=n("div",null,"CodeMirror-measure"),i.lineMeasure=n("div",null,"CodeMirror-measure"),i.lineSpace=n("div",[i.measure,i.lineMeasure,i.selectionDiv,i.cursorDiv,i.lineDiv],null,"position: relative; outline: none"),i.mover=n("div",[n("div",[i.lineSpace],"CodeMirror-lines")],null,"position: relative"),i.sizer=n("div",[i.mover],"CodeMirror-sizer"),i.sizerWidth=null,i.heightForcer=n("div",null,null,"position: absolute; height: "+Aa+"px; width: 1px;"),i.gutters=n("div",null,"CodeMirror-gutters"),i.lineGutter=null,i.scroller=n("div",[i.sizer,i.heightForcer,i.gutters],"CodeMirror-scroll"),i.scroller.setAttribute("tabIndex","-1"),i.wrapper=n("div",[i.scrollbarFiller,i.gutterFiller,i.scroller],"CodeMirror"),aa&&la<8&&(i.gutters.style.zIndex=-1,i.scroller.style.paddingRight=0),sa||na&&ma||(i.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(i.wrapper):e(i.wrapper)),i.viewFrom=i.viewTo=t.first,i.reportedViewFrom=i.reportedViewTo=t.first,i.view=[],i.renderedView=null,i.externalMeasured=null,i.viewOffset=0,i.lastWrapHeight=i.lastWrapWidth=0,i.updateLineNumbers=null,i.nativeBarWidth=i.barHeight=i.barWidth=0,i.scrollbarsClipped=!1,i.lineNumWidth=i.lineNumInnerWidth=i.lineNumChars=null,i.alignWidgets=!1,i.cachedCharWidth=i.cachedTextHeight=i.cachedPaddingH=null,i.maxLine=null,i.maxLineLength=0,i.maxLineChanged=!1,i.wheelDX=i.wheelDY=i.wheelStartX=i.wheelStartY=null,i.shift=!1,i.selForContextMenu=null,i.activeTouch=null,r.init(i)}function S(e,t){if(t-=e.first,t<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var r=e;!r.lines;)for(var n=0;;++n){var i=r.children[n],o=i.chunkSize();if(t<o){r=i;break}t-=o}return r.lines[t]}function T(e,t,r){var n=[],i=t.line;return e.iter(t.line,r.line+1,function(e){var o=e.text;i==r.line&&(o=o.slice(0,r.ch)),i==t.line&&(o=o.slice(t.ch)),n.push(o),++i}),n}function L(e,t,r){var n=[];return e.iter(t,r,function(e){n.push(e.text)}),n}function M(e,t){var r=t-e.height;if(r)for(var n=e;n;n=n.parent)n.height+=r}function _(e){if(null==e.parent)return null;for(var t=e.parent,r=d(t.lines,e),n=t.parent;n;t=n,n=n.parent)for(var i=0;n.children[i]!=t;++i)r+=n.children[i].chunkSize();return r+t.first}function A(e,t){var r=e.first;e:do{for(var n=0;n<e.children.length;++n){var i=e.children[n],o=i.height;if(t<o){e=i;continue e}t-=o,r+=i.chunkSize()}return r}while(!e.lines);for(var a=0;a<e.lines.length;++a){var l=e.lines[a],s=l.height;if(t<s)break;t-=s}return r+a}function N(e,t){return t>=e.first&&t<e.first+e.size}function O(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function W(e,t){return this instanceof W?(this.line=e,void(this.ch=t)):new W(e,t)}function E(e,t){return e.line-t.line||e.ch-t.ch}function z(e){return W(e.line,e.ch)}function P(e,t){return E(e,t)<0?t:e}function D(e,t){return E(e,t)<0?e:t}function H(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function I(e,t){if(t.line<e.first)return W(e.first,0);var r=e.first+e.size-1;return t.line>r?W(r,S(e,r).text.length):F(t,S(e,t.line).text.length)}function F(e,t){var r=e.ch;return null==r||r>t?W(e.line,t):r<0?W(e.line,0):e}function j(e,t){for(var r=[],n=0;n<t.length;n++)r[n]=I(e,t[n]);return r}function R(){Ha=!0}function B(){Ia=!0}function q(e,t,r){this.marker=e,this.from=t,this.to=r}function K(e,t){if(e)for(var r=0;r<e.length;++r){var n=e[r];if(n.marker==t)return n}}function U(e,t){for(var r,n=0;n<e.length;++n)e[n]!=t&&(r||(r=[])).push(e[n]);return r}function V(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function G(e,t,r){var n;if(e)for(var i=0;i<e.length;++i){var o=e[i],a=o.marker,l=null==o.from||(a.inclusiveLeft?o.from<=t:o.from<t);if(l||o.from==t&&"bookmark"==a.type&&(!r||!o.marker.insertLeft)){var s=null==o.to||(a.inclusiveRight?o.to>=t:o.to>t);(n||(n=[])).push(new q(a,o.from,s?null:o.to))}}return n}function $(e,t,r){var n;if(e)for(var i=0;i<e.length;++i){var o=e[i],a=o.marker,l=null==o.to||(a.inclusiveRight?o.to>=t:o.to>t);if(l||o.from==t&&"bookmark"==a.type&&(!r||o.marker.insertLeft)){var s=null==o.from||(a.inclusiveLeft?o.from<=t:o.from<t);(n||(n=[])).push(new q(a,s?null:o.from-t,null==o.to?null:o.to-t))}}return n}function Y(e,t){if(t.full)return null;var r=N(e,t.from.line)&&S(e,t.from.line).markedSpans,n=N(e,t.to.line)&&S(e,t.to.line).markedSpans;if(!r&&!n)return null;var i=t.from.ch,o=t.to.ch,a=0==E(t.from,t.to),l=G(r,i,a),s=$(n,o,a),c=1==t.text.length,u=p(t.text).length+(c?i:0);if(l)for(var d=0;d<l.length;++d){var f=l[d];if(null==f.to){var h=K(s,f.marker);h?c&&(f.to=null==h.to?null:h.to+u):f.to=i}}if(s)for(var g=0;g<s.length;++g){var m=s[g];if(null!=m.to&&(m.to+=u),null==m.from){var v=K(l,m.marker);v||(m.from=u,c&&(l||(l=[])).push(m))}else m.from+=u,c&&(l||(l=[])).push(m)}l&&(l=X(l)),s&&s!=l&&(s=X(s));var y=[l];if(!c){var b,w=t.text.length-2;if(w>0&&l)for(var x=0;x<l.length;++x)null==l[x].to&&(b||(b=[])).push(new q(l[x].marker,null,null));for(var k=0;k<w;++k)y.push(b);y.push(s)}return y}function X(e){for(var t=0;t<e.length;++t){var r=e[t];null!=r.from&&r.from==r.to&&r.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function Z(e,t,r){var n=null;if(e.iter(t.line,r.line+1,function(e){if(e.markedSpans)for(var t=0;t<e.markedSpans.length;++t){var r=e.markedSpans[t].marker;!r.readOnly||n&&d(n,r)!=-1||(n||(n=[])).push(r)}}),!n)return null;for(var i=[{from:t,to:r}],o=0;o<n.length;++o)for(var a=n[o],l=a.find(0),s=0;s<i.length;++s){var c=i[s];if(!(E(c.to,l.from)<0||E(c.from,l.to)>0)){var u=[s,1],f=E(c.from,l.from),h=E(c.to,l.to);(f<0||!a.inclusiveLeft&&!f)&&u.push({from:c.from,to:l.from}),(h>0||!a.inclusiveRight&&!h)&&u.push({from:l.to,to:c.to}),i.splice.apply(i,u),s+=u.length-1}}return i}function Q(e){var t=e.markedSpans;if(t){for(var r=0;r<t.length;++r)t[r].marker.detachLine(e);e.markedSpans=null}}function J(e,t){if(t){for(var r=0;r<t.length;++r)t[r].marker.attachLine(e);e.markedSpans=t}}function ee(e){return e.inclusiveLeft?-1:0}function te(e){return e.inclusiveRight?1:0}function re(e,t){var r=e.lines.length-t.lines.length;if(0!=r)return r;var n=e.find(),i=t.find(),o=E(n.from,i.from)||ee(e)-ee(t);if(o)return-o;var a=E(n.to,i.to)||te(e)-te(t);return a?a:t.id-e.id}function ne(e,t){var r,n=Ia&&e.markedSpans;if(n)for(var i=void 0,o=0;o<n.length;++o)i=n[o],i.marker.collapsed&&null==(t?i.from:i.to)&&(!r||re(r,i.marker)<0)&&(r=i.marker);return r}function ie(e){return ne(e,!0)}function oe(e){return ne(e,!1)}function ae(e,t,r,n,i){var o=S(e,t),a=Ia&&o.markedSpans;if(a)for(var l=0;l<a.length;++l){var s=a[l];if(s.marker.collapsed){var c=s.marker.find(0),u=E(c.from,r)||ee(s.marker)-ee(i),d=E(c.to,n)||te(s.marker)-te(i);if(!(u>=0&&d<=0||u<=0&&d>=0)&&(u<=0&&(s.marker.inclusiveRight&&i.inclusiveLeft?E(c.to,r)>=0:E(c.to,r)>0)||u>=0&&(s.marker.inclusiveRight&&i.inclusiveLeft?E(c.from,n)<=0:E(c.from,n)<0)))return!0}}}function le(e){for(var t;t=ie(e);)e=t.find(-1,!0).line;return e}function se(e){for(var t,r;t=oe(e);)e=t.find(1,!0).line,(r||(r=[])).push(e);return r}function ce(e,t){var r=S(e,t),n=le(r);return r==n?t:_(n)}function ue(e,t){if(t>e.lastLine())return t;var r,n=S(e,t);if(!de(e,n))return t;for(;r=oe(n);)n=r.find(1,!0).line;return _(n)+1}function de(e,t){var r=Ia&&t.markedSpans;if(r)for(var n=void 0,i=0;i<r.length;++i)if(n=r[i],n.marker.collapsed){if(null==n.from)return!0;if(!n.marker.widgetNode&&0==n.from&&n.marker.inclusiveLeft&&fe(e,t,n))return!0}}function fe(e,t,r){if(null==r.to){var n=r.marker.find(1,!0);return fe(e,n.line,K(n.line.markedSpans,r.marker))}if(r.marker.inclusiveRight&&r.to==t.text.length)return!0;for(var i=void 0,o=0;o<t.markedSpans.length;++o)if(i=t.markedSpans[o],i.marker.collapsed&&!i.marker.widgetNode&&i.from==r.to&&(null==i.to||i.to!=r.from)&&(i.marker.inclusiveLeft||r.marker.inclusiveRight)&&fe(e,t,i))return!0}function he(e){e=le(e);for(var t=0,r=e.parent,n=0;n<r.lines.length;++n){var i=r.lines[n];if(i==e)break;t+=i.height}for(var o=r.parent;o;r=o,o=r.parent)for(var a=0;a<o.children.length;++a){var l=o.children[a];if(l==r)break;t+=l.height}return t}function pe(e){if(0==e.height)return 0;for(var t,r=e.text.length,n=e;t=ie(n);){var i=t.find(0,!0);n=i.from.line,r+=i.from.ch-i.to.ch}for(n=e;t=oe(n);){var o=t.find(0,!0);r-=n.text.length-o.from.ch,n=o.to.line,r+=n.text.length-o.to.ch}return r}function ge(e){var t=e.display,r=e.doc;t.maxLine=S(r,r.first),t.maxLineLength=pe(t.maxLine),t.maxLineChanged=!0,r.iter(function(e){var r=pe(e);r>t.maxLineLength&&(t.maxLineLength=r,t.maxLine=e)})}function me(e,t,r,n){if(!e)return n(t,r,"ltr");for(var i=!1,o=0;o<e.length;++o){var a=e[o];(a.from<r&&a.to>t||t==r&&a.to==t)&&(n(Math.max(a.from,t),Math.min(a.to,r),1==a.level?"rtl":"ltr"),i=!0)}i||n(t,r,"ltr")}function ve(e){return e.level%2?e.to:e.from}function ye(e){return e.level%2?e.from:e.to}function be(e){var t=Le(e);return t?ve(t[0]):0}function we(e){var t=Le(e);return t?ye(p(t)):e.text.length}function xe(e,t,r){var n=e[0].level;return t==n||r!=n&&t<r}function ke(e,t){var r;Fa=null;for(var n=0;n<e.length;++n){var i=e[n];if(i.from<t&&i.to>t)return n;if(i.from==t||i.to==t){if(null!=r)return xe(e,i.level,e[r].level)?(i.from!=i.to&&(Fa=r),n):(i.from!=i.to&&(Fa=n),r);r=n}}return r}function Ce(e,t,r,n){if(!n)return t+r;do t+=r;while(t>0&&k(e.text.charAt(t)));return t}function Se(e,t,r,n){var i=Le(e);if(!i)return Te(e,t,r,n);for(var o=ke(i,t),a=i[o],l=Ce(e,t,a.level%2?-r:r,n);;){if(l>a.from&&l<a.to)return l;if(l==a.from||l==a.to)return ke(i,l)==o?l:(a=i[o+=r],r>0==a.level%2?a.to:a.from);if(a=i[o+=r],!a)return null;l=r>0==a.level%2?Ce(e,a.to,-1,n):Ce(e,a.from,1,n)}}function Te(e,t,r,n){var i=t+r;if(n)for(;i>0&&k(e.text.charAt(i));)i+=r;return i<0||i>e.text.length?null:i}function Le(e){var t=e.order;return null==t&&(t=e.order=ja(e.text)),t}function Me(e,t,r){var n=e._handlers&&e._handlers[t];return r?n&&n.length>0?n.slice():Ba:n||Ba}function _e(e,t,r){if(e.removeEventListener)e.removeEventListener(t,r,!1);else if(e.detachEvent)e.detachEvent("on"+t,r);else for(var n=Me(e,t,!1),i=0;i<n.length;++i)if(n[i]==r){n.splice(i,1);break}}function Ae(e,t){var r=Me(e,t,!0);if(r.length)for(var n=Array.prototype.slice.call(arguments,2),i=0;i<r.length;++i)r[i].apply(null,n)}function Ne(e,t,r){return"string"==typeof t&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),Ae(e,r||t.type,e,t),De(t)||t.codemirrorIgnore}function Oe(e){var t=e._handlers&&e._handlers.cursorActivity;if(t)for(var r=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),n=0;n<t.length;++n)d(r,t[n])==-1&&r.push(t[n])}function We(e,t){return Me(e,t).length>0}function Ee(e){e.prototype.on=function(e,t){Ra(this,e,t)},e.prototype.off=function(e,t){_e(this,e,t)}}function ze(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function Pe(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function De(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function He(e){ze(e),Pe(e)}function Ie(e){return e.target||e.srcElement}function Fe(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),va&&e.ctrlKey&&1==t&&(t=3),t}function je(e){if(null==Ma){var t=n("span","​");r(e,n("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(Ma=t.offsetWidth<=1&&t.offsetHeight>2&&!(aa&&la<8))}var i=Ma?n("span","​"):n("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}function Re(e){if(null!=_a)return _a;var n=r(e,document.createTextNode("AخA")),i=xa(n,0,1).getBoundingClientRect(),o=xa(n,1,2).getBoundingClientRect();return t(e),!(!i||i.left==i.right)&&(_a=o.right-i.right<3)}function Be(e){if(null!=Ga)return Ga;var t=r(e,n("span","x")),i=t.getBoundingClientRect(),o=xa(t,0,1).getBoundingClientRect();return Ga=Math.abs(i.left-o.left)>1}function qe(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),$a[e]=t}function Ke(e,t){Ya[e]=t}function Ue(e){if("string"==typeof e&&Ya.hasOwnProperty(e))e=Ya[e];else if(e&&"string"==typeof e.name&&Ya.hasOwnProperty(e.name)){var t=Ya[e.name];"string"==typeof t&&(t={name:t}),e=y(t,e),e.name=t.name}else{if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return Ue("application/xml");if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return Ue("application/json")}return"string"==typeof e?{name:e}:e||{name:"null"}}function Ve(e,t){t=Ue(t);var r=$a[t.name];if(!r)return Ve(e,"text/plain");var n=r(e,t);if(Xa.hasOwnProperty(t.name)){var i=Xa[t.name];for(var o in i)i.hasOwnProperty(o)&&(n.hasOwnProperty(o)&&(n["_"+o]=n[o]),n[o]=i[o])}if(n.name=t.name,t.helperType&&(n.helperType=t.helperType),t.modeProps)for(var a in t.modeProps)n[a]=t.modeProps[a];return n}function Ge(e,t){var r=Xa.hasOwnProperty(e)?Xa[e]:Xa[e]={};s(t,r)}function $e(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var r={};for(var n in t){var i=t[n];i instanceof Array&&(i=i.concat([])),r[n]=i}return r}function Ye(e,t){for(var r;e.innerMode&&(r=e.innerMode(t),r&&r.mode!=e);)t=r.state,e=r.mode;return r||{mode:e,state:t}}function Xe(e,t,r){return!e.startState||e.startState(t,r)}function Ze(e,t,r,n){var i=[e.state.modeGen],o={};ot(e,t.text,e.doc.mode,r,function(e,t){return i.push(e,t)},o,n);for(var a=function(r){var n=e.state.overlays[r],a=1,l=0;ot(e,t.text,n.mode,!0,function(e,t){for(var r=a;l<e;){var o=i[a];o>e&&i.splice(a,1,e,i[a+1],o),a+=2,l=Math.min(e,o)}if(t)if(n.opaque)i.splice(r,a-r,e,"overlay "+t),a=r+2;else for(;r<a;r+=2){var s=i[r+1];i[r+1]=(s?s+" ":"")+"overlay "+t}},o)},l=0;l<e.state.overlays.length;++l)a(l);return{styles:i,classes:o.bgClass||o.textClass?o:null}}function Qe(e,t,r){if(!t.styles||t.styles[0]!=e.state.modeGen){var n=Je(e,_(t)),i=Ze(e,t,t.text.length>e.options.maxHighlightLength?$e(e.doc.mode,n):n);t.stateAfter=n,t.styles=i.styles,i.classes?t.styleClasses=i.classes:t.styleClasses&&(t.styleClasses=null),r===e.doc.frontier&&e.doc.frontier++}return t.styles}function Je(e,t,r){var n=e.doc,i=e.display;if(!n.mode.startState)return!0;var o=at(e,t,r),a=o>n.first&&S(n,o-1).stateAfter;return a=a?$e(n.mode,a):Xe(n.mode),n.iter(o,t,function(r){et(e,r.text,a);var l=o==t-1||o%5==0||o>=i.viewFrom&&o<i.viewTo;r.stateAfter=l?$e(n.mode,a):null,++o}),r&&(n.frontier=o),a}function et(e,t,r,n){var i=e.doc.mode,o=new Za(t,e.options.tabSize);for(o.start=o.pos=n||0,""==t&&tt(i,r);!o.eol();)rt(i,o,r),o.start=o.pos}function tt(e,t){if(e.blankLine)return e.blankLine(t);if(e.innerMode){var r=Ye(e,t);return r.mode.blankLine?r.mode.blankLine(r.state):void 0}}function rt(e,t,r,n){for(var i=0;i<10;i++){n&&(n[0]=Ye(e,r).mode);var o=e.token(t,r);if(t.pos>t.start)return o}throw new Error("Mode "+e.name+" failed to advance stream.")}function nt(e,t,r,n){var i,o=function(e){return{start:d.start,end:d.pos,string:d.current(),type:i||null,state:e?$e(a.mode,u):u}},a=e.doc,l=a.mode;t=I(a,t);var s,c=S(a,t.line),u=Je(e,t.line,r),d=new Za(c.text,e.options.tabSize);for(n&&(s=[]);(n||d.pos<t.ch)&&!d.eol();)d.start=d.pos,i=rt(l,d,u),n&&s.push(o(!0));return n?s:o()}function it(e,t){if(e)for(;;){var r=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!r)break;e=e.slice(0,r.index)+e.slice(r.index+r[0].length);var n=r[1]?"bgClass":"textClass";null==t[n]?t[n]=r[2]:new RegExp("(?:^|s)"+r[2]+"(?:$|s)").test(t[n])||(t[n]+=" "+r[2])}return e}function ot(e,t,r,n,i,o,a){var l=r.flattenSpans;null==l&&(l=e.options.flattenSpans);var s,c=0,u=null,d=new Za(t,e.options.tabSize),f=e.options.addModeClass&&[null];for(""==t&&it(tt(r,n),o);!d.eol();){if(d.pos>e.options.maxHighlightLength?(l=!1,a&&et(e,t,n,d.pos),d.pos=t.length,s=null):s=it(rt(r,d,n,f),o),f){var h=f[0].name;h&&(s="m-"+(s?h+" "+s:h))}if(!l||u!=s){for(;c<d.start;)c=Math.min(d.start,c+5e3),i(c,u);u=s}d.start=d.pos}for(;c<d.pos;){var p=Math.min(d.pos,c+5e3);i(p,u),c=p}}function at(e,t,r){for(var n,i,o=e.doc,a=r?-1:t-(e.doc.mode.innerMode?1e3:100),l=t;l>a;--l){if(l<=o.first)return o.first;var s=S(o,l-1);if(s.stateAfter&&(!r||l<=o.frontier))return l;var u=c(s.text,null,e.options.tabSize);(null==i||n>u)&&(i=l-1,n=u)}return i}function lt(e,t,r){this.text=e,J(this,t),this.height=r?r(this):1}function st(e,t,r,n){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),null!=e.order&&(e.order=null),Q(e),J(e,r);var i=n?n(e):1;i!=e.height&&M(e,i)}function ct(e){e.parent=null,Q(e)}function ut(e,t){if(!e||/^\s*$/.test(e))return null;var r=t.addModeClass?el:Ja;return r[e]||(r[e]=e.replace(/\S+/g,"cm-$&"))}function dt(e,t){var r=n("span",null,null,sa?"padding-right: .1px":null),i={pre:n("pre",[r],"CodeMirror-line"),content:r,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:(aa||sa)&&e.getOption("lineWrapping")};t.measure={};for(var o=0;o<=(t.rest?t.rest.length:0);o++){var l=o?t.rest[o-1]:t.line,s=void 0;i.pos=0,i.addToken=ht,Re(e.display.measure)&&(s=Le(l))&&(i.addToken=gt(i.addToken,s)),i.map=[];var c=t!=e.display.externalMeasured&&_(l);vt(l,i,Qe(e,l,c)),l.styleClasses&&(l.styleClasses.bgClass&&(i.bgClass=a(l.styleClasses.bgClass,i.bgClass||"")),l.styleClasses.textClass&&(i.textClass=a(l.styleClasses.textClass,i.textClass||""))),0==i.map.length&&i.map.push(0,0,i.content.appendChild(je(e.display.measure))),0==o?(t.measure.map=i.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(i.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(sa){var u=i.content.lastChild;(/\bcm-tab\b/.test(u.className)||u.querySelector&&u.querySelector(".cm-tab"))&&(i.content.className="cm-tab-wrap-hack")}return Ae(e,"renderLine",e,t.line,i.pre),i.pre.className&&(i.textClass=a(i.pre.className,i.textClass||"")),i}function ft(e){var t=n("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function ht(e,t,r,i,o,a,l){if(t){var s,c=e.splitSpaces?pt(t,e.trailingSpace):t,u=e.cm.state.specialChars,d=!1;if(u.test(t)){s=document.createDocumentFragment();for(var f=0;;){u.lastIndex=f;var p=u.exec(t),g=p?p.index-f:t.length-f;if(g){var m=document.createTextNode(c.slice(f,f+g));aa&&la<9?s.appendChild(n("span",[m])):s.appendChild(m),e.map.push(e.pos,e.pos+g,m),e.col+=g,e.pos+=g}if(!p)break;f+=g+1;var v=void 0;if("\t"==p[0]){var y=e.cm.options.tabSize,b=y-e.col%y;v=s.appendChild(n("span",h(b),"cm-tab")),v.setAttribute("role","presentation"),v.setAttribute("cm-text","\t"),e.col+=b}else"\r"==p[0]||"\n"==p[0]?(v=s.appendChild(n("span","\r"==p[0]?"␍":"␤","cm-invalidchar")),v.setAttribute("cm-text",p[0]),e.col+=1):(v=e.cm.options.specialCharPlaceholder(p[0]),v.setAttribute("cm-text",p[0]),aa&&la<9?s.appendChild(n("span",[v])):s.appendChild(v),e.col+=1);e.map.push(e.pos,e.pos+1,v),e.pos++}}else e.col+=t.length,s=document.createTextNode(c),e.map.push(e.pos,e.pos+t.length,s),aa&&la<9&&(d=!0),e.pos+=t.length;if(e.trailingSpace=32==c.charCodeAt(t.length-1),r||i||o||d||l){var w=r||"";i&&(w+=i),o&&(w+=o);var x=n("span",[s],w,l);return a&&(x.title=a),e.content.appendChild(x)}e.content.appendChild(s)}}function pt(e,t){if(e.length>1&&!/ /.test(e))return e;for(var r=t,n="",i=0;i<e.length;i++){var o=e.charAt(i);" "!=o||!r||i!=e.length-1&&32!=e.charCodeAt(i+1)||(o=" "),n+=o,r=" "==o}return n}function gt(e,t){return function(r,n,i,o,a,l,s){i=i?i+" cm-force-border":"cm-force-border";for(var c=r.pos,u=c+n.length;;){for(var d=void 0,f=0;f<t.length&&(d=t[f],!(d.to>c&&d.from<=c));f++);if(d.to>=u)return e(r,n,i,o,a,l,s);e(r,n.slice(0,d.to-c),i,o,null,l,s),o=null,n=n.slice(d.to-c),c=d.to}}}function mt(e,t,r,n){var i=!n&&r.widgetNode;i&&e.map.push(e.pos,e.pos+t,i),!n&&e.cm.display.input.needsContentAttribute&&(i||(i=e.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",r.id)),i&&(e.cm.display.input.setUneditable(i),e.content.appendChild(i)),e.pos+=t,e.trailingSpace=!1}function vt(e,t,r){var n=e.markedSpans,i=e.text,o=0;if(n)for(var a,l,s,c,u,d,f,h=i.length,p=0,g=1,m="",v=0;;){if(v==p){s=c=u=d=l="",f=null,v=1/0;for(var y=[],b=void 0,w=0;w<n.length;++w){var x=n[w],k=x.marker;"bookmark"==k.type&&x.from==p&&k.widgetNode?y.push(k):x.from<=p&&(null==x.to||x.to>p||k.collapsed&&x.to==p&&x.from==p)?(null!=x.to&&x.to!=p&&v>x.to&&(v=x.to,c=""),k.className&&(s+=" "+k.className),k.css&&(l=(l?l+";":"")+k.css),k.startStyle&&x.from==p&&(u+=" "+k.startStyle),k.endStyle&&x.to==v&&(b||(b=[])).push(k.endStyle,x.to),k.title&&!d&&(d=k.title),k.collapsed&&(!f||re(f.marker,k)<0)&&(f=x)):x.from>p&&v>x.from&&(v=x.from)}if(b)for(var C=0;C<b.length;C+=2)b[C+1]==v&&(c+=" "+b[C]);if(!f||f.from==p)for(var S=0;S<y.length;++S)mt(t,0,y[S]);if(f&&(f.from||0)==p){if(mt(t,(null==f.to?h+1:f.to)-p,f.marker,null==f.from),null==f.to)return;f.to==p&&(f=!1)}}if(p>=h)break;for(var T=Math.min(h,v);;){if(m){var L=p+m.length;if(!f){var M=L>T?m.slice(0,T-p):m;t.addToken(t,M,a?a+s:s,u,p+M.length==v?c:"",d,l)}if(L>=T){m=m.slice(T-p),p=T;break}p=L,u=""}m=i.slice(o,o=r[g++]),a=ut(r[g++],t.cm.options)}}else for(var _=1;_<r.length;_+=2)t.addToken(t,i.slice(o,o=r[_]),ut(r[_+1],t.cm.options))}function yt(e,t,r){this.line=t,this.rest=se(t),this.size=this.rest?_(p(this.rest))-r+1:1,this.node=this.text=null,this.hidden=de(e,t)}function bt(e,t,r){for(var n,i=[],o=t;o<r;o=n){var a=new yt(e.doc,S(e.doc,o),o);n=o+a.size,i.push(a)}return i}function wt(e){tl?tl.ops.push(e):e.ownsGroup=tl={ops:[e],delayedCallbacks:[]}}function xt(e){var t=e.delayedCallbacks,r=0;do{for(;r<t.length;r++)t[r].call(null);for(var n=0;n<e.ops.length;n++){var i=e.ops[n];if(i.cursorActivityHandlers)for(;i.cursorActivityCalled<i.cursorActivityHandlers.length;)i.cursorActivityHandlers[i.cursorActivityCalled++].call(null,i.cm)}}while(r<t.length)}function kt(e,t){var r=e.ownsGroup;if(r)try{xt(r)}finally{tl=null,t(r)}}function Ct(e,t){var r=Me(e,t,!1);if(r.length){var n,i=Array.prototype.slice.call(arguments,2);tl?n=tl.delayedCallbacks:rl?n=rl:(n=rl=[],setTimeout(St,0));for(var o=function(e){n.push(function(){return r[e].apply(null,i)})},a=0;a<r.length;++a)o(a)}}function St(){var e=rl;rl=null;for(var t=0;t<e.length;++t)e[t]()}function Tt(e,t,r,n){for(var i=0;i<t.changes.length;i++){var o=t.changes[i];"text"==o?At(e,t):"gutter"==o?Ot(e,t,r,n):"class"==o?Nt(t):"widget"==o&&Wt(e,t,n)}t.changes=null}function Lt(e){return e.node==e.text&&(e.node=n("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),aa&&la<8&&(e.node.style.zIndex=2)),e.node}function Mt(e){var t=e.bgClass?e.bgClass+" "+(e.line.bgClass||""):e.line.bgClass;if(t&&(t+=" CodeMirror-linebackground"),e.background)t?e.background.className=t:(e.background.parentNode.removeChild(e.background),e.background=null);else if(t){var r=Lt(e);e.background=r.insertBefore(n("div",null,t),r.firstChild)}}function _t(e,t){var r=e.display.externalMeasured;return r&&r.line==t.line?(e.display.externalMeasured=null,t.measure=r.measure,r.built):dt(e,t)}function At(e,t){var r=t.text.className,n=_t(e,t);t.text==t.node&&(t.node=n.pre),t.text.parentNode.replaceChild(n.pre,t.text),t.text=n.pre,n.bgClass!=t.bgClass||n.textClass!=t.textClass?(t.bgClass=n.bgClass,t.textClass=n.textClass,Nt(t)):r&&(t.text.className=r)}function Nt(e){Mt(e),e.line.wrapClass?Lt(e).className=e.line.wrapClass:e.node!=e.text&&(e.node.className="");var t=e.textClass?e.textClass+" "+(e.line.textClass||""):e.line.textClass;e.text.className=t||""}function Ot(e,t,r,i){if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass){var o=Lt(t);t.gutterBackground=n("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?i.fixedPos:-i.gutterTotalWidth)+"px; width: "+i.gutterTotalWidth+"px"),o.insertBefore(t.gutterBackground,t.text)}var a=t.line.gutterMarkers;if(e.options.lineNumbers||a){var l=Lt(t),s=t.gutter=n("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?i.fixedPos:-i.gutterTotalWidth)+"px");if(e.display.input.setUneditable(s),l.insertBefore(s,t.text),t.line.gutterClass&&(s.className+=" "+t.line.gutterClass),!e.options.lineNumbers||a&&a["CodeMirror-linenumbers"]||(t.lineNumber=s.appendChild(n("div",O(e.options,r),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+i.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),a)for(var c=0;c<e.options.gutters.length;++c){var u=e.options.gutters[c],d=a.hasOwnProperty(u)&&a[u];d&&s.appendChild(n("div",[d],"CodeMirror-gutter-elt","left: "+i.gutterLeft[u]+"px; width: "+i.gutterWidth[u]+"px"))}}}function Wt(e,t,r){t.alignable&&(t.alignable=null);for(var n=t.node.firstChild,i=void 0;n;n=i)i=n.nextSibling,"CodeMirror-linewidget"==n.className&&t.node.removeChild(n);zt(e,t,r)}function Et(e,t,r,n){var i=_t(e,t);return t.text=t.node=i.pre,i.bgClass&&(t.bgClass=i.bgClass),i.textClass&&(t.textClass=i.textClass),Nt(t),Ot(e,t,r,n),zt(e,t,n),t.node}function zt(e,t,r){if(Pt(e,t.line,t,r,!0),t.rest)for(var n=0;n<t.rest.length;n++)Pt(e,t.rest[n],t,r,!1)}function Pt(e,t,r,i,o){if(t.widgets)for(var a=Lt(r),l=0,s=t.widgets;l<s.length;++l){var c=s[l],u=n("div",[c.node],"CodeMirror-linewidget");
3
- c.handleMouseEvents||u.setAttribute("cm-ignore-events","true"),Dt(c,u,r,i),e.display.input.setUneditable(u),o&&c.above?a.insertBefore(u,r.gutter||r.text):a.appendChild(u),Ct(c,"redraw")}}function Dt(e,t,r,n){if(e.noHScroll){(r.alignable||(r.alignable=[])).push(t);var i=n.wrapperWidth;t.style.left=n.fixedPos+"px",e.coverGutter||(i-=n.gutterTotalWidth,t.style.paddingLeft=n.gutterTotalWidth+"px"),t.style.width=i+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-n.gutterTotalWidth+"px"))}function Ht(e){if(null!=e.height)return e.height;var t=e.doc.cm;if(!t)return 0;if(!i(document.body,e.node)){var o="position: relative;";e.coverGutter&&(o+="margin-left: -"+t.display.gutters.offsetWidth+"px;"),e.noHScroll&&(o+="width: "+t.display.wrapper.clientWidth+"px;"),r(t.display.measure,n("div",[e.node],null,o))}return e.height=e.node.parentNode.offsetHeight}function It(e,t){for(var r=Ie(t);r!=e.wrapper;r=r.parentNode)if(!r||1==r.nodeType&&"true"==r.getAttribute("cm-ignore-events")||r.parentNode==e.sizer&&r!=e.mover)return!0}function Ft(e){return e.lineSpace.offsetTop}function jt(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function Rt(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=r(e.measure,n("pre","x")),i=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,o={left:parseInt(i.paddingLeft),right:parseInt(i.paddingRight)};return isNaN(o.left)||isNaN(o.right)||(e.cachedPaddingH=o),o}function Bt(e){return Aa-e.display.nativeBarWidth}function qt(e){return e.display.scroller.clientWidth-Bt(e)-e.display.barWidth}function Kt(e){return e.display.scroller.clientHeight-Bt(e)-e.display.barHeight}function Ut(e,t,r){var n=e.options.lineWrapping,i=n&&qt(e);if(!t.measure.heights||n&&t.measure.width!=i){var o=t.measure.heights=[];if(n){t.measure.width=i;for(var a=t.text.firstChild.getClientRects(),l=0;l<a.length-1;l++){var s=a[l],c=a[l+1];Math.abs(s.bottom-c.bottom)>2&&o.push((s.bottom+c.top)/2-r.top)}}o.push(r.bottom-r.top)}}function Vt(e,t,r){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var n=0;n<e.rest.length;n++)if(e.rest[n]==t)return{map:e.measure.maps[n],cache:e.measure.caches[n]};for(var i=0;i<e.rest.length;i++)if(_(e.rest[i])>r)return{map:e.measure.maps[i],cache:e.measure.caches[i],before:!0}}function Gt(e,t){t=le(t);var n=_(t),i=e.display.externalMeasured=new yt(e.doc,t,n);i.lineN=n;var o=i.built=dt(e,i);return i.text=o.pre,r(e.display.lineMeasure,o.pre),i}function $t(e,t,r,n){return Zt(e,Xt(e,t),r,n)}function Yt(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[kr(e,t)];var r=e.display.externalMeasured;return r&&t>=r.lineN&&t<r.lineN+r.size?r:void 0}function Xt(e,t){var r=_(t),n=Yt(e,r);n&&!n.text?n=null:n&&n.changes&&(Tt(e,n,r,vr(e)),e.curOp.forceUpdate=!0),n||(n=Gt(e,t));var i=Vt(n,t,r);return{line:t,view:n,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function Zt(e,t,r,n,i){t.before&&(r=-1);var o,a=r+(n||"");return t.cache.hasOwnProperty(a)?o=t.cache[a]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Ut(e,t.view,t.rect),t.hasHeights=!0),o=er(e,t,r,n),o.bogus||(t.cache[a]=o)),{left:o.left,right:o.right,top:i?o.rtop:o.top,bottom:i?o.rbottom:o.bottom}}function Qt(e,t,r){for(var n,i,o,a,l,s,c=0;c<e.length;c+=3)if(l=e[c],s=e[c+1],t<l?(i=0,o=1,a="left"):t<s?(i=t-l,o=i+1):(c==e.length-3||t==s&&e[c+3]>t)&&(o=s-l,i=o-1,t>=s&&(a="right")),null!=i){if(n=e[c+2],l==s&&r==(n.insertLeft?"left":"right")&&(a=r),"left"==r&&0==i)for(;c&&e[c-2]==e[c-3]&&e[c-1].insertLeft;)n=e[(c-=3)+2],a="left";if("right"==r&&i==s-l)for(;c<e.length-3&&e[c+3]==e[c+4]&&!e[c+5].insertLeft;)n=e[(c+=3)+2],a="right";break}return{node:n,start:i,end:o,collapse:a,coverStart:l,coverEnd:s}}function Jt(e,t){var r=nl;if("left"==t)for(var n=0;n<e.length&&(r=e[n]).left==r.right;n++);else for(var i=e.length-1;i>=0&&(r=e[i]).left==r.right;i--);return r}function er(e,t,r,n){var i,o=Qt(t.map,r,n),a=o.node,l=o.start,s=o.end,c=o.collapse;if(3==a.nodeType){for(var u=0;u<4;u++){for(;l&&k(t.line.text.charAt(o.coverStart+l));)--l;for(;o.coverStart+s<o.coverEnd&&k(t.line.text.charAt(o.coverStart+s));)++s;if(i=aa&&la<9&&0==l&&s==o.coverEnd-o.coverStart?a.parentNode.getBoundingClientRect():Jt(xa(a,l,s).getClientRects(),n),i.left||i.right||0==l)break;s=l,l-=1,c="right"}aa&&la<11&&(i=tr(e.display.measure,i))}else{l>0&&(c=n="right");var d;i=e.options.lineWrapping&&(d=a.getClientRects()).length>1?d["right"==n?d.length-1:0]:a.getBoundingClientRect()}if(aa&&la<9&&!l&&(!i||!i.left&&!i.right)){var f=a.parentNode.getClientRects()[0];i=f?{left:f.left,right:f.left+mr(e.display),top:f.top,bottom:f.bottom}:nl}for(var h=i.top-t.rect.top,p=i.bottom-t.rect.top,g=(h+p)/2,m=t.view.measure.heights,v=0;v<m.length-1&&!(g<m[v]);v++);var y=v?m[v-1]:0,b=m[v],w={left:("right"==c?i.right:i.left)-t.rect.left,right:("left"==c?i.left:i.right)-t.rect.left,top:y,bottom:b};return i.left||i.right||(w.bogus=!0),e.options.singleCursorHeightPerLine||(w.rtop=h,w.rbottom=p),w}function tr(e,t){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!Be(e))return t;var r=screen.logicalXDPI/screen.deviceXDPI,n=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*r,right:t.right*r,top:t.top*n,bottom:t.bottom*n}}function rr(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function nr(e){e.display.externalMeasure=null,t(e.display.lineMeasure);for(var r=0;r<e.display.view.length;r++)rr(e.display.view[r])}function ir(e){nr(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function or(){return window.pageXOffset||(document.documentElement||document.body).scrollLeft}function ar(){return window.pageYOffset||(document.documentElement||document.body).scrollTop}function lr(e,t,r,n){if(t.widgets)for(var i=0;i<t.widgets.length;++i)if(t.widgets[i].above){var o=Ht(t.widgets[i]);r.top+=o,r.bottom+=o}if("line"==n)return r;n||(n="local");var a=he(t);if("local"==n?a+=Ft(e.display):a-=e.display.viewOffset,"page"==n||"window"==n){var l=e.display.lineSpace.getBoundingClientRect();a+=l.top+("window"==n?0:ar());var s=l.left+("window"==n?0:or());r.left+=s,r.right+=s}return r.top+=a,r.bottom+=a,r}function sr(e,t,r){if("div"==r)return t;var n=t.left,i=t.top;if("page"==r)n-=or(),i-=ar();else if("local"==r||!r){var o=e.display.sizer.getBoundingClientRect();n+=o.left,i+=o.top}var a=e.display.lineSpace.getBoundingClientRect();return{left:n-a.left,top:i-a.top}}function cr(e,t,r,n,i){return n||(n=S(e.doc,t.line)),lr(e,n,$t(e,n,t.ch,i),r)}function ur(e,t,r,n,i,o){function a(t,a){var l=Zt(e,i,t,a?"right":"left",o);return a?l.left=l.right:l.right=l.left,lr(e,n,l,r)}function l(e,t){var r=s[t],n=r.level%2;return e==ve(r)&&t&&r.level<s[t-1].level?(r=s[--t],e=ye(r)-(r.level%2?0:1),n=!0):e==ye(r)&&t<s.length-1&&r.level<s[t+1].level&&(r=s[++t],e=ve(r)-r.level%2,n=!1),n&&e==r.to&&e>r.from?a(e-1):a(e,n)}n=n||S(e.doc,t.line),i||(i=Xt(e,n));var s=Le(n),c=t.ch;if(!s)return a(c);var u=ke(s,c),d=l(c,u);return null!=Fa&&(d.other=l(c,Fa)),d}function dr(e,t){var r=0;t=I(e.doc,t),e.options.lineWrapping||(r=mr(e.display)*t.ch);var n=S(e.doc,t.line),i=he(n)+Ft(e.display);return{left:r,right:r,top:i,bottom:i+n.height}}function fr(e,t,r,n){var i=W(e,t);return i.xRel=n,r&&(i.outside=!0),i}function hr(e,t,r){var n=e.doc;if(r+=e.display.viewOffset,r<0)return fr(n.first,0,!0,-1);var i=A(n,r),o=n.first+n.size-1;if(i>o)return fr(n.first+n.size-1,S(n,o).text.length,!0,1);t<0&&(t=0);for(var a=S(n,i);;){var l=pr(e,a,i,t,r),s=oe(a),c=s&&s.find(0,!0);if(!s||!(l.ch>c.from.ch||l.ch==c.from.ch&&l.xRel>0))return l;i=_(a=c.to.line)}}function pr(e,t,r,n,i){function o(n){var i=ur(e,W(r,n),"line",t,c);return l=!0,a>i.bottom?i.left-s:a<i.top?i.left+s:(l=!1,i.left)}var a=i-he(t),l=!1,s=2*e.display.wrapper.clientWidth,c=Xt(e,t),u=Le(t),d=t.text.length,f=be(t),h=we(t),p=o(f),g=l,m=o(h),v=l;if(n>m)return fr(r,h,v,1);for(;;){if(u?h==f||h==Se(t,f,1):h-f<=1){var y=n<p||n-p<=m-n?f:h,b=y==f?g:v,w=n-(y==f?p:m);if(v&&!u&&!/\s/.test(t.text.charAt(y))&&w>0&&y<t.text.length&&c.view.measure.heights.length>1){var x=Zt(e,c,y,"right");a<=x.bottom&&a>=x.top&&Math.abs(n-x.right)<w&&(b=!1,y++,w=n-x.right)}for(;k(t.text.charAt(y));)++y;var C=fr(r,y,b,w<-1?-1:w>1?1:0);return C}var S=Math.ceil(d/2),T=f+S;if(u){T=f;for(var L=0;L<S;++L)T=Se(t,T,1)}var M=o(T);M>n?(h=T,m=M,(v=l)&&(m+=1e3),d=S):(f=T,p=M,g=l,d-=S)}}function gr(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Qa){Qa=n("pre");for(var i=0;i<49;++i)Qa.appendChild(document.createTextNode("x")),Qa.appendChild(n("br"));Qa.appendChild(document.createTextNode("x"))}r(e.measure,Qa);var o=Qa.offsetHeight/50;return o>3&&(e.cachedTextHeight=o),t(e.measure),o||1}function mr(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=n("span","xxxxxxxxxx"),i=n("pre",[t]);r(e.measure,i);var o=t.getBoundingClientRect(),a=(o.right-o.left)/10;return a>2&&(e.cachedCharWidth=a),a||10}function vr(e){for(var t=e.display,r={},n={},i=t.gutters.clientLeft,o=t.gutters.firstChild,a=0;o;o=o.nextSibling,++a)r[e.options.gutters[a]]=o.offsetLeft+o.clientLeft+i,n[e.options.gutters[a]]=o.clientWidth;return{fixedPos:yr(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:r,gutterWidth:n,wrapperWidth:t.wrapper.clientWidth}}function yr(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function br(e){var t=gr(e.display),r=e.options.lineWrapping,n=r&&Math.max(5,e.display.scroller.clientWidth/mr(e.display)-3);return function(i){if(de(e.doc,i))return 0;var o=0;if(i.widgets)for(var a=0;a<i.widgets.length;a++)i.widgets[a].height&&(o+=i.widgets[a].height);return r?o+(Math.ceil(i.text.length/n)||1)*t:o+t}}function wr(e){var t=e.doc,r=br(e);t.iter(function(e){var t=r(e);t!=e.height&&M(e,t)})}function xr(e,t,r,n){var i=e.display;if(!r&&"true"==Ie(t).getAttribute("cm-not-content"))return null;var o,a,l=i.lineSpace.getBoundingClientRect();try{o=t.clientX-l.left,a=t.clientY-l.top}catch(t){return null}var s,u=hr(e,o,a);if(n&&1==u.xRel&&(s=S(e.doc,u.line).text).length==u.ch){var d=c(s,s.length,e.options.tabSize)-s.length;u=W(u.line,Math.max(0,Math.round((o-Rt(e.display).left)/mr(e.display))-d))}return u}function kr(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,t<0)return null;for(var r=e.display.view,n=0;n<r.length;n++)if(t-=r[n].size,t<0)return n}function Cr(e){e.display.input.showSelection(e.display.input.prepareSelection())}function Sr(e,t){for(var r=e.doc,n={},i=n.cursors=document.createDocumentFragment(),o=n.selection=document.createDocumentFragment(),a=0;a<r.sel.ranges.length;a++)if(t!==!1||a!=r.sel.primIndex){var l=r.sel.ranges[a];if(!(l.from().line>=e.display.viewTo||l.to().line<e.display.viewFrom)){var s=l.empty();(s||e.options.showCursorWhenSelecting)&&Tr(e,l.head,i),s||Lr(e,l,o)}}return n}function Tr(e,t,r){var i=ur(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),o=r.appendChild(n("div"," ","CodeMirror-cursor"));if(o.style.left=i.left+"px",o.style.top=i.top+"px",o.style.height=Math.max(0,i.bottom-i.top)*e.options.cursorHeight+"px",i.other){var a=r.appendChild(n("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));a.style.display="",a.style.left=i.other.left+"px",a.style.top=i.other.top+"px",a.style.height=.85*(i.other.bottom-i.other.top)+"px"}}function Lr(e,t,r){function i(e,t,r,i){t<0&&(t=0),t=Math.round(t),i=Math.round(i),s.appendChild(n("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px;\n top: "+t+"px; width: "+(null==r?d-e:r)+"px;\n height: "+(i-t)+"px"))}function o(t,r,n){function o(r,n){return cr(e,W(t,r),"div",c,n)}var a,s,c=S(l,t),f=c.text.length;return me(Le(c),r||0,null==n?f:n,function(e,t,l){var c,h,p,g=o(e,"left");if(e==t)c=g,h=p=g.left;else{if(c=o(t-1,"right"),"rtl"==l){var m=g;g=c,c=m}h=g.left,p=c.right}null==r&&0==e&&(h=u),c.top-g.top>3&&(i(h,g.top,null,g.bottom),h=u,g.bottom<c.top&&i(h,g.bottom,null,c.top)),null==n&&t==f&&(p=d),(!a||g.top<a.top||g.top==a.top&&g.left<a.left)&&(a=g),(!s||c.bottom>s.bottom||c.bottom==s.bottom&&c.right>s.right)&&(s=c),h<u+1&&(h=u),i(h,c.top,p-h,c.bottom)}),{start:a,end:s}}var a=e.display,l=e.doc,s=document.createDocumentFragment(),c=Rt(e.display),u=c.left,d=Math.max(a.sizerWidth,qt(e)-a.sizer.offsetLeft)-c.right,f=t.from(),h=t.to();if(f.line==h.line)o(f.line,f.ch,h.ch);else{var p=S(l,f.line),g=S(l,h.line),m=le(p)==le(g),v=o(f.line,f.ch,m?p.text.length+1:null).end,y=o(h.line,m?0:null,h.ch).start;m&&(v.top<y.top-2?(i(v.right,v.top,null,v.bottom),i(u,y.top,y.left,y.bottom)):i(v.right,v.top,y.left-v.right,v.bottom)),v.bottom<y.top&&i(u,v.bottom,null,y.top)}r.appendChild(s)}function Mr(e){if(e.state.focused){var t=e.display;clearInterval(t.blinker);var r=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){return t.cursorDiv.style.visibility=(r=!r)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function _r(e){e.state.focused||(e.display.input.focus(),Nr(e))}function Ar(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,Or(e))},100)}function Nr(e,t){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(Ae(e,"focus",e,t),e.state.focused=!0,o(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),sa&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Mr(e))}function Or(e,t){e.state.delayingBlurEvent||(e.state.focused&&(Ae(e,"blur",e,t),e.state.focused=!1,Sa(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function Wr(e){var t=e.display,r=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var n=yr(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=n+"px",a=0;a<r.length;a++)if(!r[a].hidden){e.options.fixedGutter&&(r[a].gutter&&(r[a].gutter.style.left=o),r[a].gutterBackground&&(r[a].gutterBackground.style.left=o));var l=r[a].alignable;if(l)for(var s=0;s<l.length;s++)l[s].style.left=o}e.options.fixedGutter&&(t.gutters.style.left=n+i+"px")}}function Er(e){if(!e.options.lineNumbers)return!1;var t=e.doc,r=O(e.options,t.first+t.size-1),i=e.display;if(r.length!=i.lineNumChars){var o=i.measure.appendChild(n("div",[n("div",r)],"CodeMirror-linenumber CodeMirror-gutter-elt")),a=o.firstChild.offsetWidth,l=o.offsetWidth-a;return i.lineGutter.style.width="",i.lineNumInnerWidth=Math.max(a,i.lineGutter.offsetWidth-l)+1,i.lineNumWidth=i.lineNumInnerWidth+l,i.lineNumChars=i.lineNumInnerWidth?r.length:-1,i.lineGutter.style.width=i.lineNumWidth+"px",_n(e),!0}return!1}function zr(e){for(var t=e.display,r=t.lineDiv.offsetTop,n=0;n<t.view.length;n++){var i=t.view[n],o=void 0;if(!i.hidden){if(aa&&la<8){var a=i.node.offsetTop+i.node.offsetHeight;o=a-r,r=a}else{var l=i.node.getBoundingClientRect();o=l.bottom-l.top}var s=i.line.height-o;if(o<2&&(o=gr(t)),(s>.001||s<-.001)&&(M(i.line,o),Pr(i.line),i.rest))for(var c=0;c<i.rest.length;c++)Pr(i.rest[c])}}}function Pr(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t)e.widgets[t].height=e.widgets[t].node.parentNode.offsetHeight}function Dr(e,t,r){var n=r&&null!=r.top?Math.max(0,r.top):e.scroller.scrollTop;n=Math.floor(n-Ft(e));var i=r&&null!=r.bottom?r.bottom:n+e.wrapper.clientHeight,o=A(t,n),a=A(t,i);if(r&&r.ensure){var l=r.ensure.from.line,s=r.ensure.to.line;l<o?(o=l,a=A(t,he(S(t,l))+e.wrapper.clientHeight)):Math.min(s,t.lastLine())>=a&&(o=A(t,he(S(t,s))-e.wrapper.clientHeight),a=s)}return{from:o,to:Math.max(a,o+1)}}function Hr(e,t){Math.abs(e.doc.scrollTop-t)<2||(e.doc.scrollTop=t,na||Ln(e,{top:t}),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t),e.display.scrollbars.setScrollTop(t),na&&Ln(e),wn(e,100))}function Ir(e,t,r){(r?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)||(t=Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth),e.doc.scrollLeft=t,Wr(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function Fr(e){var t=e.wheelDeltaX,r=e.wheelDeltaY;return null==t&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),null==r&&e.detail&&e.axis==e.VERTICAL_AXIS?r=e.detail:null==r&&(r=e.wheelDelta),{x:t,y:r}}function jr(e){var t=Fr(e);return t.x*=ol,t.y*=ol,t}function Rr(e,t){var r=Fr(t),n=r.x,i=r.y,o=e.display,a=o.scroller,l=a.scrollWidth>a.clientWidth,s=a.scrollHeight>a.clientHeight;if(n&&l||i&&s){if(i&&va&&sa)e:for(var c=t.target,u=o.view;c!=a;c=c.parentNode)for(var d=0;d<u.length;d++)if(u[d].node==c){e.display.currentWheelTarget=c;break e}if(n&&!na&&!da&&null!=ol)return i&&s&&Hr(e,Math.max(0,Math.min(a.scrollTop+i*ol,a.scrollHeight-a.clientHeight))),Ir(e,Math.max(0,Math.min(a.scrollLeft+n*ol,a.scrollWidth-a.clientWidth))),(!i||i&&s)&&ze(t),void(o.wheelStartX=null);if(i&&null!=ol){var f=i*ol,h=e.doc.scrollTop,p=h+o.wrapper.clientHeight;f<0?h=Math.max(0,h+f-50):p=Math.min(e.doc.height,p+f+50),Ln(e,{top:h,bottom:p})}il<20&&(null==o.wheelStartX?(o.wheelStartX=a.scrollLeft,o.wheelStartY=a.scrollTop,o.wheelDX=n,o.wheelDY=i,setTimeout(function(){if(null!=o.wheelStartX){var e=a.scrollLeft-o.wheelStartX,t=a.scrollTop-o.wheelStartY,r=t&&o.wheelDY&&t/o.wheelDY||e&&o.wheelDX&&e/o.wheelDX;o.wheelStartX=o.wheelStartY=null,r&&(ol=(ol*il+r)/(il+1),++il)}},200)):(o.wheelDX+=n,o.wheelDY+=i))}}function Br(e){var t=e.display,r=t.gutters.offsetWidth,n=Math.round(e.doc.height+jt(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?r:0,docHeight:n,scrollHeight:n+Bt(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:r}}function qr(e,t,r){this.cm=r;var i=this.vert=n("div",[n("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),o=this.horiz=n("div",[n("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");e(i),e(o),Ra(i,"scroll",function(){i.clientHeight&&t(i.scrollTop,"vertical")}),Ra(o,"scroll",function(){o.clientWidth&&t(o.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,aa&&la<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}function Kr(){}function Ur(e,t){t||(t=Br(e));var r=e.display.barWidth,n=e.display.barHeight;Vr(e,t);for(var i=0;i<4&&r!=e.display.barWidth||n!=e.display.barHeight;i++)r!=e.display.barWidth&&e.options.lineWrapping&&zr(e),Vr(e,Br(e)),r=e.display.barWidth,n=e.display.barHeight}function Vr(e,t){var r=e.display,n=r.scrollbars.update(t);r.sizer.style.paddingRight=(r.barWidth=n.right)+"px",r.sizer.style.paddingBottom=(r.barHeight=n.bottom)+"px",r.heightForcer.style.borderBottom=n.bottom+"px solid transparent",n.right&&n.bottom?(r.scrollbarFiller.style.display="block",r.scrollbarFiller.style.height=n.bottom+"px",r.scrollbarFiller.style.width=n.right+"px"):r.scrollbarFiller.style.display="",n.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(r.gutterFiller.style.display="block",r.gutterFiller.style.height=n.bottom+"px",r.gutterFiller.style.width=t.gutterWidth+"px"):r.gutterFiller.style.display=""}function Gr(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&Sa(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new al[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),Ra(t,"mousedown",function(){e.state.focused&&setTimeout(function(){return e.display.input.focus()},0)}),t.setAttribute("cm-not-content","true")},function(t,r){"horizontal"==r?Ir(e,t):Hr(e,t)},e),e.display.scrollbars.addClass&&o(e.display.wrapper,e.display.scrollbars.addClass)}function $r(e,t){if(!Ne(e,"scrollCursorIntoView")){var r=e.display,i=r.sizer.getBoundingClientRect(),o=null;if(t.top+i.top<0?o=!0:t.bottom+i.top>(window.innerHeight||document.documentElement.clientHeight)&&(o=!1),null!=o&&!pa){var a=n("div","​",null,"position: absolute;\n top: "+(t.top-r.viewOffset-Ft(e.display))+"px;\n height: "+(t.bottom-t.top+Bt(e)+r.barHeight)+"px;\n left: "+t.left+"px; width: 2px;");e.display.lineSpace.appendChild(a),a.scrollIntoView(o),e.display.lineSpace.removeChild(a)}}}function Yr(e,t,r,n){null==n&&(n=0);for(var i,o=0;o<5;o++){var a=!1;i=ur(e,t);var l=r&&r!=t?ur(e,r):i,s=Zr(e,Math.min(i.left,l.left),Math.min(i.top,l.top)-n,Math.max(i.left,l.left),Math.max(i.bottom,l.bottom)+n),c=e.doc.scrollTop,u=e.doc.scrollLeft;if(null!=s.scrollTop&&(Hr(e,s.scrollTop),Math.abs(e.doc.scrollTop-c)>1&&(a=!0)),null!=s.scrollLeft&&(Ir(e,s.scrollLeft),Math.abs(e.doc.scrollLeft-u)>1&&(a=!0)),!a)break}return i}function Xr(e,t,r,n,i){var o=Zr(e,t,r,n,i);null!=o.scrollTop&&Hr(e,o.scrollTop),null!=o.scrollLeft&&Ir(e,o.scrollLeft)}function Zr(e,t,r,n,i){var o=e.display,a=gr(e.display);r<0&&(r=0);var l=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:o.scroller.scrollTop,s=Kt(e),c={};i-r>s&&(i=r+s);var u=e.doc.height+jt(o),d=r<a,f=i>u-a;if(r<l)c.scrollTop=d?0:r;else if(i>l+s){var h=Math.min(r,(f?u:i)-s);h!=l&&(c.scrollTop=h)}var p=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:o.scroller.scrollLeft,g=qt(e)-(e.options.fixedGutter?o.gutters.offsetWidth:0),m=n-t>g;return m&&(n=t+g),t<10?c.scrollLeft=0:t<p?c.scrollLeft=Math.max(0,t-(m?0:10)):n>g+p-3&&(c.scrollLeft=n+(m?0:10)-g),c}function Qr(e,t,r){null==t&&null==r||en(e),null!=t&&(e.curOp.scrollLeft=(null==e.curOp.scrollLeft?e.doc.scrollLeft:e.curOp.scrollLeft)+t),null!=r&&(e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+r)}function Jr(e){en(e);var t=e.getCursor(),r=t,n=t;e.options.lineWrapping||(r=t.ch?W(t.line,t.ch-1):t,n=W(t.line,t.ch+1)),e.curOp.scrollToPos={from:r,to:n,margin:e.options.cursorScrollMargin,isCursor:!0}}function en(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var r=dr(e,t.from),n=dr(e,t.to),i=Zr(e,Math.min(r.left,n.left),Math.min(r.top,n.top)-t.margin,Math.max(r.right,n.right),Math.max(r.bottom,n.bottom)+t.margin);e.scrollTo(i.scrollLeft,i.scrollTop)}}function tn(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++ll},wt(e.curOp)}function rn(e){var t=e.curOp;kt(t,function(e){for(var t=0;t<e.ops.length;t++)e.ops[t].cm.curOp=null;nn(e)})}function nn(e){for(var t=e.ops,r=0;r<t.length;r++)on(t[r]);for(var n=0;n<t.length;n++)an(t[n]);for(var i=0;i<t.length;i++)ln(t[i]);for(var o=0;o<t.length;o++)sn(t[o]);for(var a=0;a<t.length;a++)cn(t[a])}function on(e){var t=e.cm,r=t.display;Cn(t),e.updateMaxLine&&ge(t),e.mustUpdate=e.viewChanged||e.forceUpdate||null!=e.scrollTop||e.scrollToPos&&(e.scrollToPos.from.line<r.viewFrom||e.scrollToPos.to.line>=r.viewTo)||r.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new kn(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function an(e){e.updatedDisplay=e.mustUpdate&&Sn(e.cm,e.update)}function ln(e){var t=e.cm,r=t.display;e.updatedDisplay&&zr(t),e.barMeasure=Br(t),r.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=$t(t,r.maxLine,r.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(r.scroller.clientWidth,r.sizer.offsetLeft+e.adjustWidthTo+Bt(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,r.sizer.offsetLeft+e.adjustWidthTo-qt(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=r.input.prepareSelection(e.focus))}function sn(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&Ir(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1);var r=e.focus&&e.focus==Ta()&&(!document.hasFocus||document.hasFocus());e.preparedSelection&&t.display.input.showSelection(e.preparedSelection,r),(e.updatedDisplay||e.startHeight!=t.doc.height)&&Ur(t,e.barMeasure),e.updatedDisplay&&An(t,e.barMeasure),e.selectionChanged&&Mr(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),r&&_r(e.cm)}function cn(e){var t=e.cm,r=t.display,n=t.doc;if(e.updatedDisplay&&Tn(t,e.update),null==r.wheelStartX||null==e.scrollTop&&null==e.scrollLeft&&!e.scrollToPos||(r.wheelStartX=r.wheelStartY=null),null==e.scrollTop||r.scroller.scrollTop==e.scrollTop&&!e.forceScroll||(n.scrollTop=Math.max(0,Math.min(r.scroller.scrollHeight-r.scroller.clientHeight,e.scrollTop)),r.scrollbars.setScrollTop(n.scrollTop),r.scroller.scrollTop=n.scrollTop),null==e.scrollLeft||r.scroller.scrollLeft==e.scrollLeft&&!e.forceScroll||(n.scrollLeft=Math.max(0,Math.min(r.scroller.scrollWidth-r.scroller.clientWidth,e.scrollLeft)),r.scrollbars.setScrollLeft(n.scrollLeft),r.scroller.scrollLeft=n.scrollLeft,Wr(t)),e.scrollToPos){var i=Yr(t,I(n,e.scrollToPos.from),I(n,e.scrollToPos.to),e.scrollToPos.margin);e.scrollToPos.isCursor&&t.state.focused&&$r(t,i)}var o=e.maybeHiddenMarkers,a=e.maybeUnhiddenMarkers;if(o)for(var l=0;l<o.length;++l)o[l].lines.length||Ae(o[l],"hide");if(a)for(var s=0;s<a.length;++s)a[s].lines.length&&Ae(a[s],"unhide");r.wrapper.offsetHeight&&(n.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&Ae(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function un(e,t){if(e.curOp)return t();tn(e);try{return t()}finally{rn(e)}}function dn(e,t){return function(){if(e.curOp)return t.apply(e,arguments);tn(e);try{return t.apply(e,arguments)}finally{rn(e)}}}function fn(e){return function(){if(this.curOp)return e.apply(this,arguments);tn(this);try{return e.apply(this,arguments)}finally{rn(this)}}}function hn(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);tn(t);try{return e.apply(this,arguments)}finally{rn(t)}}}function pn(e,t,r,n){null==t&&(t=e.doc.first),null==r&&(r=e.doc.first+e.doc.size),n||(n=0);var i=e.display;if(n&&r<i.viewTo&&(null==i.updateLineNumbers||i.updateLineNumbers>t)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)Ia&&ce(e.doc,t)<i.viewTo&&mn(e);else if(r<=i.viewFrom)Ia&&ue(e.doc,r+n)>i.viewFrom?mn(e):(i.viewFrom+=n,i.viewTo+=n);else if(t<=i.viewFrom&&r>=i.viewTo)mn(e);else if(t<=i.viewFrom){var o=vn(e,r,r+n,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=n):mn(e)}else if(r>=i.viewTo){var a=vn(e,t,t,-1);a?(i.view=i.view.slice(0,a.index),i.viewTo=a.lineN):mn(e)}else{var l=vn(e,t,t,-1),s=vn(e,r,r+n,1);l&&s?(i.view=i.view.slice(0,l.index).concat(bt(e,l.lineN,s.lineN)).concat(i.view.slice(s.index)),i.viewTo+=n):mn(e)}var c=i.externalMeasured;c&&(r<c.lineN?c.lineN+=n:t<c.lineN+c.size&&(i.externalMeasured=null))}function gn(e,t,r){e.curOp.viewChanged=!0;var n=e.display,i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size&&(n.externalMeasured=null),!(t<n.viewFrom||t>=n.viewTo)){var o=n.view[kr(e,t)];if(null!=o.node){var a=o.changes||(o.changes=[]);d(a,r)==-1&&a.push(r)}}}function mn(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function vn(e,t,r,n){var i,o=kr(e,t),a=e.display.view;if(!Ia||r==e.doc.first+e.doc.size)return{index:o,lineN:r};for(var l=e.display.viewFrom,s=0;s<o;s++)l+=a[s].size;if(l!=t){if(n>0){if(o==a.length-1)return null;i=l+a[o].size-t,o++}else i=l-t;t+=i,r+=i}for(;ce(e.doc,r)!=r;){if(o==(n<0?0:a.length-1))return null;r+=n*a[o-(n<0?1:0)].size,o+=n}return{index:o,lineN:r}}function yn(e,t,r){var n=e.display,i=n.view;0==i.length||t>=n.viewTo||r<=n.viewFrom?(n.view=bt(e,t,r),n.viewFrom=t):(n.viewFrom>t?n.view=bt(e,t,n.viewFrom).concat(n.view):n.viewFrom<t&&(n.view=n.view.slice(kr(e,t))),n.viewFrom=t,n.viewTo<r?n.view=n.view.concat(bt(e,n.viewTo,r)):n.viewTo>r&&(n.view=n.view.slice(0,kr(e,r)))),n.viewTo=r}function bn(e){for(var t=e.display.view,r=0,n=0;n<t.length;n++){var i=t[n];i.hidden||i.node&&!i.changes||++r}return r}function wn(e,t){e.doc.mode.startState&&e.doc.frontier<e.display.viewTo&&e.state.highlight.set(t,l(xn,e))}function xn(e){var t=e.doc;if(t.frontier<t.first&&(t.frontier=t.first),!(t.frontier>=e.display.viewTo)){var r=+new Date+e.options.workTime,n=$e(t.mode,Je(e,t.frontier)),i=[];t.iter(t.frontier,Math.min(t.first+t.size,e.display.viewTo+500),function(o){if(t.frontier>=e.display.viewFrom){var a=o.styles,l=o.text.length>e.options.maxHighlightLength,s=Ze(e,o,l?$e(t.mode,n):n,!0);o.styles=s.styles;var c=o.styleClasses,u=s.classes;u?o.styleClasses=u:c&&(o.styleClasses=null);for(var d=!a||a.length!=o.styles.length||c!=u&&(!c||!u||c.bgClass!=u.bgClass||c.textClass!=u.textClass),f=0;!d&&f<a.length;++f)d=a[f]!=o.styles[f];d&&i.push(t.frontier),o.stateAfter=l?n:$e(t.mode,n)}else o.text.length<=e.options.maxHighlightLength&&et(e,o.text,n),o.stateAfter=t.frontier%5==0?$e(t.mode,n):null;if(++t.frontier,+new Date>r)return wn(e,e.options.workDelay),!0}),i.length&&un(e,function(){for(var t=0;t<i.length;t++)gn(e,i[t],"text")})}}function kn(e,t,r){var n=e.display;this.viewport=t,this.visible=Dr(n,e.doc,t),this.editorIsHidden=!n.wrapper.offsetWidth,this.wrapperHeight=n.wrapper.clientHeight,this.wrapperWidth=n.wrapper.clientWidth,this.oldDisplayWidth=qt(e),this.force=r,this.dims=vr(e),this.events=[]}function Cn(e){var t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=Bt(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=Bt(e)+"px",t.scrollbarsClipped=!0)}function Sn(e,r){var n=e.display,i=e.doc;if(r.editorIsHidden)return mn(e),!1;if(!r.force&&r.visible.from>=n.viewFrom&&r.visible.to<=n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&0==bn(e))return!1;Er(e)&&(mn(e),r.dims=vr(e));var o=i.first+i.size,a=Math.max(r.visible.from-e.options.viewportMargin,i.first),l=Math.min(o,r.visible.to+e.options.viewportMargin);n.viewFrom<a&&a-n.viewFrom<20&&(a=Math.max(i.first,n.viewFrom)),n.viewTo>l&&n.viewTo-l<20&&(l=Math.min(o,n.viewTo)),Ia&&(a=ce(e.doc,a),l=ue(e.doc,l));var s=a!=n.viewFrom||l!=n.viewTo||n.lastWrapHeight!=r.wrapperHeight||n.lastWrapWidth!=r.wrapperWidth;yn(e,a,l),n.viewOffset=he(S(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var c=bn(e);if(!s&&0==c&&!r.force&&n.renderedView==n.view&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo))return!1;var u=Ta();return c>4&&(n.lineDiv.style.display="none"),Mn(e,n.updateLineNumbers,r.dims),c>4&&(n.lineDiv.style.display=""),n.renderedView=n.view,u&&Ta()!=u&&u.offsetHeight&&u.focus(),t(n.cursorDiv),t(n.selectionDiv),n.gutters.style.height=n.sizer.style.minHeight=0,s&&(n.lastWrapHeight=r.wrapperHeight,n.lastWrapWidth=r.wrapperWidth,wn(e,400)),n.updateLineNumbers=null,!0}function Tn(e,t){for(var r=t.viewport,n=!0;(n&&e.options.lineWrapping&&t.oldDisplayWidth!=qt(e)||(r&&null!=r.top&&(r={top:Math.min(e.doc.height+jt(e.display)-Kt(e),r.top)}),t.visible=Dr(e.display,e.doc,r),!(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)))&&Sn(e,t);n=!1){zr(e);var i=Br(e);Cr(e),Ur(e,i),An(e,i)}t.signal(e,"update",e),e.display.viewFrom==e.display.reportedViewFrom&&e.display.viewTo==e.display.reportedViewTo||(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function Ln(e,t){var r=new kn(e,t);if(Sn(e,r)){zr(e),Tn(e,r);var n=Br(e);Cr(e),Ur(e,n),An(e,n),r.finish()}}function Mn(e,r,n){function i(t){var r=t.nextSibling;return sa&&va&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),r}for(var o=e.display,a=e.options.lineNumbers,l=o.lineDiv,s=l.firstChild,c=o.view,u=o.viewFrom,f=0;f<c.length;f++){
4
- var h=c[f];if(h.hidden);else if(h.node&&h.node.parentNode==l){for(;s!=h.node;)s=i(s);var p=a&&null!=r&&r<=u&&h.lineNumber;h.changes&&(d(h.changes,"gutter")>-1&&(p=!1),Tt(e,h,u,n)),p&&(t(h.lineNumber),h.lineNumber.appendChild(document.createTextNode(O(e.options,u)))),s=h.node.nextSibling}else{var g=Et(e,h,u,n);l.insertBefore(g,s)}u+=h.size}for(;s;)s=i(s)}function _n(e){var t=e.display.gutters.offsetWidth;e.display.sizer.style.marginLeft=t+"px"}function An(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+Bt(e)+"px"}function Nn(e){var r=e.display.gutters,i=e.options.gutters;t(r);for(var o=0;o<i.length;++o){var a=i[o],l=r.appendChild(n("div",null,"CodeMirror-gutter "+a));"CodeMirror-linenumbers"==a&&(e.display.lineGutter=l,l.style.width=(e.display.lineNumWidth||1)+"px")}r.style.display=o?"":"none",_n(e)}function On(e){var t=d(e.gutters,"CodeMirror-linenumbers");t==-1&&e.lineNumbers?e.gutters=e.gutters.concat(["CodeMirror-linenumbers"]):t>-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}function Wn(e,t){this.ranges=e,this.primIndex=t}function En(e,t){this.anchor=e,this.head=t}function zn(e,t){var r=e[t];e.sort(function(e,t){return E(e.from(),t.from())}),t=d(e,r);for(var n=1;n<e.length;n++){var i=e[n],o=e[n-1];if(E(o.to(),i.from())>=0){var a=D(o.from(),i.from()),l=P(o.to(),i.to()),s=o.empty()?i.from()==i.head:o.from()==o.head;n<=t&&--t,e.splice(--n,2,new En(s?l:a,s?a:l))}}return new Wn(e,t)}function Pn(e,t){return new Wn([new En(e,t||e)],0)}function Dn(e){return e.text?W(e.from.line+e.text.length-1,p(e.text).length+(1==e.text.length?e.from.ch:0)):e.to}function Hn(e,t){if(E(e,t.from)<0)return e;if(E(e,t.to)<=0)return Dn(t);var r=e.line+t.text.length-(t.to.line-t.from.line)-1,n=e.ch;return e.line==t.to.line&&(n+=Dn(t).ch-t.to.ch),W(r,n)}function In(e,t){for(var r=[],n=0;n<e.sel.ranges.length;n++){var i=e.sel.ranges[n];r.push(new En(Hn(i.anchor,t),Hn(i.head,t)))}return zn(r,e.sel.primIndex)}function Fn(e,t,r){return e.line==t.line?W(r.line,e.ch-t.ch+r.ch):W(r.line+(e.line-t.line),e.ch)}function jn(e,t,r){for(var n=[],i=W(e.first,0),o=i,a=0;a<t.length;a++){var l=t[a],s=Fn(l.from,i,o),c=Fn(Dn(l),i,o);if(i=l.to,o=c,"around"==r){var u=e.sel.ranges[a],d=E(u.head,u.anchor)<0;n[a]=new En(d?c:s,d?s:c)}else n[a]=new En(s,s)}return new Wn(n,e.sel.primIndex)}function Rn(e){e.doc.mode=Ve(e.options,e.doc.modeOption),Bn(e)}function Bn(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.frontier=e.doc.first,wn(e,100),e.state.modeGen++,e.curOp&&pn(e)}function qn(e,t){return 0==t.from.ch&&0==t.to.ch&&""==p(t.text)&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Kn(e,t,r,n){function i(e){return r?r[e]:null}function o(e,r,i){st(e,r,i,n),Ct(e,"change",e,t)}function a(e,t){for(var r=[],o=e;o<t;++o)r.push(new lt(c[o],i(o),n));return r}var l=t.from,s=t.to,c=t.text,u=S(e,l.line),d=S(e,s.line),f=p(c),h=i(c.length-1),g=s.line-l.line;if(t.full)e.insert(0,a(0,c.length)),e.remove(c.length,e.size-c.length);else if(qn(e,t)){var m=a(0,c.length-1);o(d,d.text,h),g&&e.remove(l.line,g),m.length&&e.insert(l.line,m)}else if(u==d)if(1==c.length)o(u,u.text.slice(0,l.ch)+f+u.text.slice(s.ch),h);else{var v=a(1,c.length-1);v.push(new lt(f+u.text.slice(s.ch),h,n)),o(u,u.text.slice(0,l.ch)+c[0],i(0)),e.insert(l.line+1,v)}else if(1==c.length)o(u,u.text.slice(0,l.ch)+c[0]+d.text.slice(s.ch),i(0)),e.remove(l.line+1,g);else{o(u,u.text.slice(0,l.ch)+c[0],i(0)),o(d,f+d.text.slice(s.ch),h);var y=a(1,c.length-1);g>1&&e.remove(l.line+1,g-1),e.insert(l.line+1,y)}Ct(e,"change",e,t)}function Un(e,t,r){function n(e,i,o){if(e.linked)for(var a=0;a<e.linked.length;++a){var l=e.linked[a];if(l.doc!=i){var s=o&&l.sharedHist;r&&!s||(t(l.doc,s),n(l.doc,e,s))}}}n(e,null,!0)}function Vn(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,wr(e),Rn(e),e.options.lineWrapping||ge(e),e.options.mode=t.modeOption,pn(e)}function Gn(e){this.done=[],this.undone=[],this.undoDepth=1/0,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e||1}function $n(e,t){var r={from:z(t.from),to:Dn(t),text:T(e,t.from,t.to)};return ti(e,r,t.from.line,t.to.line+1),Un(e,function(e){return ti(e,r,t.from.line,t.to.line+1)},!0),r}function Yn(e){for(;e.length;){var t=p(e);if(!t.ranges)break;e.pop()}}function Xn(e,t){return t?(Yn(e.done),p(e.done)):e.done.length&&!p(e.done).ranges?p(e.done):e.done.length>1&&!e.done[e.done.length-2].ranges?(e.done.pop(),p(e.done)):void 0}function Zn(e,t,r,n){var i=e.history;i.undone.length=0;var o,a,l=+new Date;if((i.lastOp==n||i.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&e.cm&&i.lastModTime>l-e.cm.options.historyEventDelay||"*"==t.origin.charAt(0)))&&(o=Xn(i,i.lastOp==n)))a=p(o.changes),0==E(t.from,t.to)&&0==E(t.from,a.to)?a.to=Dn(t):o.changes.push($n(e,t));else{var s=p(i.done);for(s&&s.ranges||ei(e.sel,i.done),o={changes:[$n(e,t)],generation:i.generation},i.done.push(o);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(r),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=l,i.lastOp=i.lastSelOp=n,i.lastOrigin=i.lastSelOrigin=t.origin,a||Ae(e,"historyAdded")}function Qn(e,t,r,n){var i=t.charAt(0);return"*"==i||"+"==i&&r.ranges.length==n.ranges.length&&r.somethingSelected()==n.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function Jn(e,t,r,n){var i=e.history,o=n&&n.origin;r==i.lastSelOp||o&&i.lastSelOrigin==o&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==o||Qn(e,o,p(i.done),t))?i.done[i.done.length-1]=t:ei(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=r,n&&n.clearRedo!==!1&&Yn(i.undone)}function ei(e,t){var r=p(t);r&&r.ranges&&r.equals(e)||t.push(e)}function ti(e,t,r,n){var i=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,r),Math.min(e.first+e.size,n),function(r){r.markedSpans&&((i||(i=t["spans_"+e.id]={}))[o]=r.markedSpans),++o})}function ri(e){if(!e)return null;for(var t,r=0;r<e.length;++r)e[r].marker.explicitlyCleared?t||(t=e.slice(0,r)):t&&t.push(e[r]);return t?t.length?t:null:e}function ni(e,t){var r=t["spans_"+e.id];if(!r)return null;for(var n=[],i=0;i<t.text.length;++i)n.push(ri(r[i]));return n}function ii(e,t){var r=ni(e,t),n=Y(e,t);if(!r)return n;if(!n)return r;for(var i=0;i<r.length;++i){var o=r[i],a=n[i];if(o&&a)e:for(var l=0;l<a.length;++l){for(var s=a[l],c=0;c<o.length;++c)if(o[c].marker==s.marker)continue e;o.push(s)}else a&&(r[i]=a)}return r}function oi(e,t,r){for(var n=[],i=0;i<e.length;++i){var o=e[i];if(o.ranges)n.push(r?Wn.prototype.deepCopy.call(o):o);else{var a=o.changes,l=[];n.push({changes:l});for(var s=0;s<a.length;++s){var c=a[s],u=void 0;if(l.push({from:c.from,to:c.to,text:c.text}),t)for(var f in c)(u=f.match(/^spans_(\d+)$/))&&d(t,Number(u[1]))>-1&&(p(l)[f]=c[f],delete c[f])}}}return n}function ai(e,t,r,n){if(e.cm&&e.cm.display.shift||e.extend){var i=t.anchor;if(n){var o=E(r,i)<0;o!=E(n,i)<0?(i=r,r=n):o!=E(r,n)<0&&(r=n)}return new En(i,r)}return new En(n||r,r)}function li(e,t,r,n){hi(e,new Wn([ai(e,e.sel.primary(),t,r)],0),n)}function si(e,t,r){for(var n=[],i=0;i<e.sel.ranges.length;i++)n[i]=ai(e,e.sel.ranges[i],t[i],null);var o=zn(n,e.sel.primIndex);hi(e,o,r)}function ci(e,t,r,n){var i=e.sel.ranges.slice(0);i[t]=r,hi(e,zn(i,e.sel.primIndex),n)}function ui(e,t,r,n){hi(e,Pn(t,r),n)}function di(e,t,r){var n={ranges:t.ranges,update:function(t){var r=this;this.ranges=[];for(var n=0;n<t.length;n++)r.ranges[n]=new En(I(e,t[n].anchor),I(e,t[n].head))},origin:r&&r.origin};return Ae(e,"beforeSelectionChange",e,n),e.cm&&Ae(e.cm,"beforeSelectionChange",e.cm,n),n.ranges!=t.ranges?zn(n.ranges,n.ranges.length-1):t}function fi(e,t,r){var n=e.history.done,i=p(n);i&&i.ranges?(n[n.length-1]=t,pi(e,t,r)):hi(e,t,r)}function hi(e,t,r){pi(e,t,r),Jn(e,e.sel,e.cm?e.cm.curOp.id:NaN,r)}function pi(e,t,r){(We(e,"beforeSelectionChange")||e.cm&&We(e.cm,"beforeSelectionChange"))&&(t=di(e,t,r));var n=r&&r.bias||(E(t.primary().head,e.sel.primary().head)<0?-1:1);gi(e,vi(e,t,n,!0)),r&&r.scroll===!1||!e.cm||Jr(e.cm)}function gi(e,t){t.equals(e.sel)||(e.sel=t,e.cm&&(e.cm.curOp.updateInput=e.cm.curOp.selectionChanged=!0,Oe(e.cm)),Ct(e,"cursorActivity",e))}function mi(e){gi(e,vi(e,e.sel,null,!1),Oa)}function vi(e,t,r,n){for(var i,o=0;o<t.ranges.length;o++){var a=t.ranges[o],l=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[o],s=bi(e,a.anchor,l&&l.anchor,r,n),c=bi(e,a.head,l&&l.head,r,n);(i||s!=a.anchor||c!=a.head)&&(i||(i=t.ranges.slice(0,o)),i[o]=new En(s,c))}return i?zn(i,t.primIndex):t}function yi(e,t,r,n,i){var o=S(e,t.line);if(o.markedSpans)for(var a=0;a<o.markedSpans.length;++a){var l=o.markedSpans[a],s=l.marker;if((null==l.from||(s.inclusiveLeft?l.from<=t.ch:l.from<t.ch))&&(null==l.to||(s.inclusiveRight?l.to>=t.ch:l.to>t.ch))){if(i&&(Ae(s,"beforeCursorEnter"),s.explicitlyCleared)){if(o.markedSpans){--a;continue}break}if(!s.atomic)continue;if(r){var c=s.find(n<0?1:-1),u=void 0;if((n<0?s.inclusiveRight:s.inclusiveLeft)&&(c=wi(e,c,-n,c&&c.line==t.line?o:null)),c&&c.line==t.line&&(u=E(c,r))&&(n<0?u<0:u>0))return yi(e,c,t,n,i)}var d=s.find(n<0?-1:1);return(n<0?s.inclusiveLeft:s.inclusiveRight)&&(d=wi(e,d,n,d.line==t.line?o:null)),d?yi(e,d,t,n,i):null}}return t}function bi(e,t,r,n,i){var o=n||1,a=yi(e,t,r,o,i)||!i&&yi(e,t,r,o,!0)||yi(e,t,r,-o,i)||!i&&yi(e,t,r,-o,!0);return a?a:(e.cantEdit=!0,W(e.first,0))}function wi(e,t,r,n){return r<0&&0==t.ch?t.line>e.first?I(e,W(t.line-1)):null:r>0&&t.ch==(n||S(e,t.line)).text.length?t.line<e.first+e.size-1?W(t.line+1,0):null:new W(t.line,t.ch+r)}function xi(e){e.setSelection(W(e.firstLine(),0),W(e.lastLine()),Oa)}function ki(e,t,r){var n={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){return n.canceled=!0}};return r&&(n.update=function(t,r,i,o){t&&(n.from=I(e,t)),r&&(n.to=I(e,r)),i&&(n.text=i),void 0!==o&&(n.origin=o)}),Ae(e,"beforeChange",e,n),e.cm&&Ae(e.cm,"beforeChange",e.cm,n),n.canceled?null:{from:n.from,to:n.to,text:n.text,origin:n.origin}}function Ci(e,t,r){if(e.cm){if(!e.cm.curOp)return dn(e.cm,Ci)(e,t,r);if(e.cm.state.suppressEdits)return}if(!(We(e,"beforeChange")||e.cm&&We(e.cm,"beforeChange"))||(t=ki(e,t,!0))){var n=Ha&&!r&&Z(e,t.from,t.to);if(n)for(var i=n.length-1;i>=0;--i)Si(e,{from:n[i].from,to:n[i].to,text:i?[""]:t.text});else Si(e,t)}}function Si(e,t){if(1!=t.text.length||""!=t.text[0]||0!=E(t.from,t.to)){var r=In(e,t);Zn(e,t,r,e.cm?e.cm.curOp.id:NaN),Mi(e,t,r,Y(e,t));var n=[];Un(e,function(e,r){r||d(n,e.history)!=-1||(Wi(e.history,t),n.push(e.history)),Mi(e,t,null,Y(e,t))})}}function Ti(e,t,r){if(!e.cm||!e.cm.state.suppressEdits||r){for(var n,i=e.history,o=e.sel,a="undo"==t?i.done:i.undone,l="undo"==t?i.undone:i.done,s=0;s<a.length&&(n=a[s],r?!n.ranges||n.equals(e.sel):n.ranges);s++);if(s!=a.length){for(i.lastOrigin=i.lastSelOrigin=null;n=a.pop(),n.ranges;){if(ei(n,l),r&&!n.equals(e.sel))return void hi(e,n,{clearRedo:!1});o=n}var c=[];ei(o,l),l.push({changes:c,generation:i.generation}),i.generation=n.generation||++i.maxGeneration;for(var u=We(e,"beforeChange")||e.cm&&We(e.cm,"beforeChange"),f=function(r){var i=n.changes[r];if(i.origin=t,u&&!ki(e,i,!1))return a.length=0,{};c.push($n(e,i));var o=r?In(e,i):p(a);Mi(e,i,o,ii(e,i)),!r&&e.cm&&e.cm.scrollIntoView({from:i.from,to:Dn(i)});var l=[];Un(e,function(e,t){t||d(l,e.history)!=-1||(Wi(e.history,i),l.push(e.history)),Mi(e,i,null,ii(e,i))})},h=n.changes.length-1;h>=0;--h){var g=f(h);if(g)return g.v}}}}function Li(e,t){if(0!=t&&(e.first+=t,e.sel=new Wn(g(e.sel.ranges,function(e){return new En(W(e.anchor.line+t,e.anchor.ch),W(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){pn(e.cm,e.first,e.first-t,t);for(var r=e.cm.display,n=r.viewFrom;n<r.viewTo;n++)gn(e.cm,n,"gutter")}}function Mi(e,t,r,n){if(e.cm&&!e.cm.curOp)return dn(e.cm,Mi)(e,t,r,n);if(t.to.line<e.first)return void Li(e,t.text.length-1-(t.to.line-t.from.line));if(!(t.from.line>e.lastLine())){if(t.from.line<e.first){var i=t.text.length-1-(e.first-t.from.line);Li(e,i),t={from:W(e.first,0),to:W(t.to.line+i,t.to.ch),text:[p(t.text)],origin:t.origin}}var o=e.lastLine();t.to.line>o&&(t={from:t.from,to:W(o,S(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=T(e,t.from,t.to),r||(r=In(e,t)),e.cm?_i(e.cm,t,n):Kn(e,t,n),pi(e,r,Oa)}}function _i(e,t,r){var n=e.doc,i=e.display,o=t.from,a=t.to,l=!1,s=o.line;e.options.lineWrapping||(s=_(le(S(n,o.line))),n.iter(s,a.line+1,function(e){if(e==i.maxLine)return l=!0,!0})),n.sel.contains(t.from,t.to)>-1&&Oe(e),Kn(n,t,r,br(e)),e.options.lineWrapping||(n.iter(s,o.line+t.text.length,function(e){var t=pe(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,l=!1)}),l&&(e.curOp.updateMaxLine=!0)),n.frontier=Math.min(n.frontier,o.line),wn(e,400);var c=t.text.length-(a.line-o.line)-1;t.full?pn(e):o.line!=a.line||1!=t.text.length||qn(e.doc,t)?pn(e,o.line,a.line+1,c):gn(e,o.line,"text");var u=We(e,"changes"),d=We(e,"change");if(d||u){var f={from:o,to:a,text:t.text,removed:t.removed,origin:t.origin};d&&Ct(e,"change",e,f),u&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(f)}e.display.selForContextMenu=null}function Ai(e,t,r,n,i){if(n||(n=r),E(n,r)<0){var o=n;n=r,r=o}"string"==typeof t&&(t=e.splitLines(t)),Ci(e,{from:r,to:n,text:t,origin:i})}function Ni(e,t,r,n){r<e.line?e.line+=n:t<e.line&&(e.line=t,e.ch=0)}function Oi(e,t,r,n){for(var i=0;i<e.length;++i){var o=e[i],a=!0;if(o.ranges){o.copied||(o=e[i]=o.deepCopy(),o.copied=!0);for(var l=0;l<o.ranges.length;l++)Ni(o.ranges[l].anchor,t,r,n),Ni(o.ranges[l].head,t,r,n)}else{for(var s=0;s<o.changes.length;++s){var c=o.changes[s];if(r<c.from.line)c.from=W(c.from.line+n,c.from.ch),c.to=W(c.to.line+n,c.to.ch);else if(t<=c.to.line){a=!1;break}}a||(e.splice(0,i+1),i=0)}}}function Wi(e,t){var r=t.from.line,n=t.to.line,i=t.text.length-(n-r)-1;Oi(e.done,r,n,i),Oi(e.undone,r,n,i)}function Ei(e,t,r,n){var i=t,o=t;return"number"==typeof t?o=S(e,H(e,t)):i=_(t),null==i?null:(n(o,i)&&e.cm&&gn(e.cm,i,r),o)}function zi(e){var t=this;this.lines=e,this.parent=null;for(var r=0,n=0;n<e.length;++n)e[n].parent=t,r+=e[n].height;this.height=r}function Pi(e){var t=this;this.children=e;for(var r=0,n=0,i=0;i<e.length;++i){var o=e[i];r+=o.chunkSize(),n+=o.height,o.parent=t}this.size=r,this.height=n,this.parent=null}function Di(e,t,r){var n=this;if(r)for(var i in r)r.hasOwnProperty(i)&&(n[i]=r[i]);this.doc=e,this.node=t}function Hi(e,t,r){he(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&Qr(e,null,r)}function Ii(e,t,r,n){var i=new Di(e,r,n),o=e.cm;return o&&i.noHScroll&&(o.display.alignWidgets=!0),Ei(e,t,"widget",function(t){var r=t.widgets||(t.widgets=[]);if(null==i.insertAt?r.push(i):r.splice(Math.min(r.length-1,Math.max(0,i.insertAt)),0,i),i.line=t,o&&!de(e,t)){var n=he(t)<e.scrollTop;M(t,t.height+Ht(i)),n&&Qr(o,null,i.height),o.curOp.forceUpdate=!0}return!0}),i}function Fi(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++sl}function ji(e,t,r,i,o){if(i&&i.shared)return Bi(e,t,r,i,o);if(e.cm&&!e.cm.curOp)return dn(e.cm,ji)(e,t,r,i,o);var a=new Fi(e,o),l=E(t,r);if(i&&s(i,a,!1),l>0||0==l&&a.clearWhenEmpty!==!1)return a;if(a.replacedWith&&(a.collapsed=!0,a.widgetNode=n("span",[a.replacedWith],"CodeMirror-widget"),i.handleMouseEvents||a.widgetNode.setAttribute("cm-ignore-events","true"),i.insertLeft&&(a.widgetNode.insertLeft=!0)),a.collapsed){if(ae(e,t.line,t,r,a)||t.line!=r.line&&ae(e,r.line,t,r,a))throw new Error("Inserting collapsed marker partially overlapping an existing one");B()}a.addToHistory&&Zn(e,{from:t,to:r,origin:"markText"},e.sel,NaN);var c,u=t.line,d=e.cm;if(e.iter(u,r.line+1,function(e){d&&a.collapsed&&!d.options.lineWrapping&&le(e)==d.display.maxLine&&(c=!0),a.collapsed&&u!=t.line&&M(e,0),V(e,new q(a,u==t.line?t.ch:null,u==r.line?r.ch:null)),++u}),a.collapsed&&e.iter(t.line,r.line+1,function(t){de(e,t)&&M(t,0)}),a.clearOnEnter&&Ra(a,"beforeCursorEnter",function(){return a.clear()}),a.readOnly&&(R(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),a.collapsed&&(a.id=++sl,a.atomic=!0),d){if(c&&(d.curOp.updateMaxLine=!0),a.collapsed)pn(d,t.line,r.line+1);else if(a.className||a.title||a.startStyle||a.endStyle||a.css)for(var f=t.line;f<=r.line;f++)gn(d,f,"text");a.atomic&&mi(d.doc),Ct(d,"markerAdded",d,a)}return a}function Ri(e,t){var r=this;this.markers=e,this.primary=t;for(var n=0;n<e.length;++n)e[n].parent=r}function Bi(e,t,r,n,i){n=s(n),n.shared=!1;var o=[ji(e,t,r,n,i)],a=o[0],l=n.widgetNode;return Un(e,function(e){l&&(n.widgetNode=l.cloneNode(!0)),o.push(ji(e,I(e,t),I(e,r),n,i));for(var s=0;s<e.linked.length;++s)if(e.linked[s].isParent)return;a=p(o)}),new Ri(o,a)}function qi(e){return e.findMarks(W(e.first,0),e.clipPos(W(e.lastLine())),function(e){return e.parent})}function Ki(e,t){for(var r=0;r<t.length;r++){var n=t[r],i=n.find(),o=e.clipPos(i.from),a=e.clipPos(i.to);if(E(o,a)){var l=ji(e,o,a,n.primary,n.primary.type);n.markers.push(l),l.parent=n}}}function Ui(e){for(var t=function(t){var r=e[t],n=[r.primary.doc];Un(r.primary.doc,function(e){return n.push(e)});for(var i=0;i<r.markers.length;i++){var o=r.markers[i];d(n,o.doc)==-1&&(o.parent=null,r.markers.splice(i--,1))}},r=0;r<e.length;r++)t(r)}function Vi(e){var t=this;if(Yi(t),!Ne(t,e)&&!It(t.display,e)){ze(e),aa&&(dl=+new Date);var r=xr(t,e,!0),n=e.dataTransfer.files;if(r&&!t.isReadOnly())if(n&&n.length&&window.FileReader&&window.File)for(var i=n.length,o=Array(i),a=0,l=function(e,n){if(!t.options.allowDropFileTypes||d(t.options.allowDropFileTypes,e.type)!=-1){var l=new FileReader;l.onload=dn(t,function(){var e=l.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(e)&&(e=""),o[n]=e,++a==i){r=I(t.doc,r);var s={from:r,to:r,text:t.doc.splitLines(o.join(t.doc.lineSeparator())),origin:"paste"};Ci(t.doc,s),fi(t.doc,Pn(r,Dn(s)))}}),l.readAsText(e)}},s=0;s<i;++s)l(n[s],s);else{if(t.state.draggingText&&t.doc.sel.contains(r)>-1)return t.state.draggingText(e),void setTimeout(function(){return t.display.input.focus()},20);try{var c=e.dataTransfer.getData("Text");if(c){var u;if(t.state.draggingText&&!t.state.draggingText.copy&&(u=t.listSelections()),pi(t.doc,Pn(r,r)),u)for(var f=0;f<u.length;++f)Ai(t.doc,"",u[f].anchor,u[f].head,"drag");t.replaceSelection(c,"around","paste"),t.display.input.focus()}}catch(e){}}}}function Gi(e,t){if(aa&&(!e.state.draggingText||+new Date-dl<100))return void He(t);if(!Ne(e,t)&&!It(e.display,t)&&(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!fa)){var r=n("img",null,null,"position: fixed; left: 0; top: 0;");r.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",da&&(r.width=r.height=1,e.display.wrapper.appendChild(r),r._top=r.offsetTop),t.dataTransfer.setDragImage(r,0,0),da&&r.parentNode.removeChild(r)}}function $i(e,t){var i=xr(e,t);if(i){var o=document.createDocumentFragment();Tr(e,i,o),e.display.dragCursor||(e.display.dragCursor=n("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),r(e.display.dragCursor,o)}}function Yi(e){e.display.dragCursor&&(e.display.lineSpace.removeChild(e.display.dragCursor),e.display.dragCursor=null)}function Xi(e){if(document.body.getElementsByClassName)for(var t=document.body.getElementsByClassName("CodeMirror"),r=0;r<t.length;r++){var n=t[r].CodeMirror;n&&e(n)}}function Zi(){fl||(Qi(),fl=!0)}function Qi(){var e;Ra(window,"resize",function(){null==e&&(e=setTimeout(function(){e=null,Xi(Ji)},100))}),Ra(window,"blur",function(){return Xi(Or)})}function Ji(e){var t=e.display;t.lastWrapHeight==t.wrapper.clientHeight&&t.lastWrapWidth==t.wrapper.clientWidth||(t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize())}function eo(e){var t=e.split(/-(?!$)/);e=t[t.length-1];for(var r,n,i,o,a=0;a<t.length-1;a++){var l=t[a];if(/^(cmd|meta|m)$/i.test(l))o=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))n=!0;else{if(!/^s(hift)?$/i.test(l))throw new Error("Unrecognized modifier name: "+l);i=!0}}return r&&(e="Alt-"+e),n&&(e="Ctrl-"+e),o&&(e="Cmd-"+e),i&&(e="Shift-"+e),e}function to(e){var t={};for(var r in e)if(e.hasOwnProperty(r)){var n=e[r];if(/^(name|fallthrough|(de|at)tach)$/.test(r))continue;if("..."==n){delete e[r];continue}for(var i=g(r.split(" "),eo),o=0;o<i.length;o++){var a=void 0,l=void 0;o==i.length-1?(l=i.join(" "),a=n):(l=i.slice(0,o+1).join(" "),a="...");var s=t[l];if(s){if(s!=a)throw new Error("Inconsistent bindings for "+l)}else t[l]=a}delete e[r]}for(var c in t)e[c]=t[c];return e}function ro(e,t,r,n){t=oo(t);var i=t.call?t.call(e,n):t[e];if(i===!1)return"nothing";if("..."===i)return"multi";if(null!=i&&r(i))return"handled";if(t.fallthrough){if("[object Array]"!=Object.prototype.toString.call(t.fallthrough))return ro(e,t.fallthrough,r,n);for(var o=0;o<t.fallthrough.length;o++){var a=ro(e,t.fallthrough[o],r,n);if(a)return a}}}function no(e){var t="string"==typeof e?e:hl[e.keyCode];return"Ctrl"==t||"Alt"==t||"Shift"==t||"Mod"==t}function io(e,t){if(da&&34==e.keyCode&&e["char"])return!1;var r=hl[e.keyCode],n=r;return null!=n&&!e.altGraphKey&&(e.altKey&&"Alt"!=r&&(n="Alt-"+n),(ka?e.metaKey:e.ctrlKey)&&"Ctrl"!=r&&(n="Ctrl-"+n),(ka?e.ctrlKey:e.metaKey)&&"Cmd"!=r&&(n="Cmd-"+n),!t&&e.shiftKey&&"Shift"!=r&&(n="Shift-"+n),n)}function oo(e){return"string"==typeof e?vl[e]:e}function ao(e,t){for(var r=e.doc.sel.ranges,n=[],i=0;i<r.length;i++){for(var o=t(r[i]);n.length&&E(o.from,p(n).to)<=0;){var a=n.pop();if(E(a.from,o.from)<0){o.from=a.from;break}}n.push(o)}un(e,function(){for(var t=n.length-1;t>=0;t--)Ai(e.doc,"",n[t].from,n[t].to,"+delete");Jr(e)})}function lo(e,t){var r=S(e.doc,t),n=le(r);n!=r&&(t=_(n));var i=Le(n),o=i?i[0].level%2?we(n):be(n):0;return W(t,o)}function so(e,t){for(var r,n=S(e.doc,t);r=oe(n);)n=r.find(1,!0).line,t=null;var i=Le(n),o=i?i[0].level%2?be(n):we(n):n.text.length;return W(null==t?_(n):t,o)}function co(e,t){var r=lo(e,t.line),n=S(e.doc,r.line),i=Le(n);if(!i||0==i[0].level){var o=Math.max(0,n.text.search(/\S/)),a=t.line==r.line&&t.ch<=o&&t.ch;return W(r.line,a?0:o)}return r}function uo(e,t,r){if("string"==typeof t&&(t=wl[t],!t))return!1;e.display.input.ensurePolled();var n=e.display.shift,i=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),r&&(e.display.shift=!1),i=t(e)!=Na}finally{e.display.shift=n,e.state.suppressEdits=!1}return i}function fo(e,t,r){for(var n=0;n<e.state.keyMaps.length;n++){var i=ro(t,e.state.keyMaps[n],r,e);if(i)return i}return e.options.extraKeys&&ro(t,e.options.extraKeys,r,e)||ro(t,e.options.keyMap,r,e)}function ho(e,t,r,n){var i=e.state.keySeq;if(i){if(no(t))return"handled";xl.set(50,function(){e.state.keySeq==i&&(e.state.keySeq=null,e.display.input.reset())}),t=i+" "+t}var o=fo(e,t,n);return"multi"==o&&(e.state.keySeq=t),"handled"==o&&Ct(e,"keyHandled",e,t,r),"handled"!=o&&"multi"!=o||(ze(r),Mr(e)),i&&!o&&/\'$/.test(t)?(ze(r),!0):!!o}function po(e,t){var r=io(t,!0);return!!r&&(t.shiftKey&&!e.state.keySeq?ho(e,"Shift-"+r,t,function(t){return uo(e,t,!0)})||ho(e,r,t,function(t){if("string"==typeof t?/^go[A-Z]/.test(t):t.motion)return uo(e,t)}):ho(e,r,t,function(t){return uo(e,t)}))}function go(e,t,r){return ho(e,"'"+r+"'",t,function(t){return uo(e,t,!0)})}function mo(e){var t=this;if(t.curOp.focus=Ta(),!Ne(t,e)){aa&&la<11&&27==e.keyCode&&(e.returnValue=!1);var r=e.keyCode;t.display.shift=16==r||e.shiftKey;var n=po(t,e);da&&(kl=n?r:null,!n&&88==r&&!Va&&(va?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),18!=r||/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)||vo(t)}}function vo(e){function t(e){18!=e.keyCode&&e.altKey||(Sa(r,"CodeMirror-crosshair"),_e(document,"keyup",t),_e(document,"mouseover",t))}var r=e.display.lineDiv;o(r,"CodeMirror-crosshair"),Ra(document,"keyup",t),Ra(document,"mouseover",t)}function yo(e){16==e.keyCode&&(this.doc.sel.shift=!1),Ne(this,e)}function bo(e){var t=this;if(!(It(t.display,e)||Ne(t,e)||e.ctrlKey&&!e.altKey||va&&e.metaKey)){var r=e.keyCode,n=e.charCode;if(da&&r==kl)return kl=null,void ze(e);if(!da||e.which&&!(e.which<10)||!po(t,e)){var i=String.fromCharCode(null==n?r:n);"\b"!=i&&(go(t,e,i)||t.display.input.onKeyPress(e))}}}function wo(e){var t=this,r=t.display;if(!(Ne(t,e)||r.activeTouch&&r.input.supportsTouch())){if(r.shift=e.shiftKey,It(r,e))return void(sa||(r.scroller.draggable=!1,setTimeout(function(){return r.scroller.draggable=!0},100)));if(!To(t,e)){var n=xr(t,e);switch(window.focus(),Fe(e)){case 1:t.state.selectingText?t.state.selectingText(e):n?xo(t,e,n):Ie(e)==r.scroller&&ze(e);break;case 2:sa&&(t.state.lastMiddleDown=+new Date),n&&li(t.doc,n),setTimeout(function(){return r.input.focus()},20),ze(e);break;case 3:Ca?Lo(t,e):Ar(t)}}}}function xo(e,t,r){aa?setTimeout(l(_r,e),0):e.curOp.focus=Ta();var n,i=+new Date;bl&&bl.time>i-400&&0==E(bl.pos,r)?n="triple":yl&&yl.time>i-400&&0==E(yl.pos,r)?(n="double",bl={time:i,pos:r}):(n="single",yl={time:i,pos:r});var o,a=e.doc.sel,s=va?t.metaKey:t.ctrlKey;e.options.dragDrop&&qa&&!e.isReadOnly()&&"single"==n&&(o=a.contains(r))>-1&&(E((o=a.ranges[o]).from(),r)<0||r.xRel>0)&&(E(o.to(),r)>0||r.xRel<0)?ko(e,t,r,s):Co(e,t,r,n,s)}function ko(e,t,r,n){var i=e.display,o=+new Date,a=dn(e,function(l){sa&&(i.scroller.draggable=!1),e.state.draggingText=!1,_e(document,"mouseup",a),_e(i.scroller,"drop",a),Math.abs(t.clientX-l.clientX)+Math.abs(t.clientY-l.clientY)<10&&(ze(l),!n&&+new Date-200<o&&li(e.doc,r),sa||aa&&9==la?setTimeout(function(){document.body.focus(),i.input.focus()},20):i.input.focus())});sa&&(i.scroller.draggable=!0),e.state.draggingText=a,a.copy=va?t.altKey:t.ctrlKey,i.scroller.dragDrop&&i.scroller.dragDrop(),Ra(document,"mouseup",a),Ra(i.scroller,"drop",a)}function Co(e,t,r,n,i){function o(t){if(0!=E(y,t))if(y=t,"rect"==n){for(var i=[],o=e.options.tabSize,a=c(S(u,r.line).text,r.ch,o),l=c(S(u,t.line).text,t.ch,o),s=Math.min(a,l),g=Math.max(a,l),m=Math.min(r.line,t.line),v=Math.min(e.lastLine(),Math.max(r.line,t.line));m<=v;m++){var b=S(u,m).text,w=f(b,s,o);s==g?i.push(new En(W(m,w),W(m,w))):b.length>w&&i.push(new En(W(m,w),W(m,f(b,g,o))))}i.length||i.push(new En(r,r)),hi(u,zn(p.ranges.slice(0,h).concat(i),h),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var x=d,k=x.anchor,C=t;if("single"!=n){var T;T="double"==n?e.findWordAt(t):new En(W(t.line,0),I(u,W(t.line+1,0))),E(T.anchor,k)>0?(C=T.head,k=D(x.from(),T.anchor)):(C=T.anchor,k=P(x.to(),T.head))}var L=p.ranges.slice(0);L[h]=new En(I(u,k),C),hi(u,zn(L,h),Wa)}}function a(t){var r=++w,i=xr(e,t,!0,"rect"==n);if(i)if(0!=E(i,y)){e.curOp.focus=Ta(),o(i);var l=Dr(s,u);(i.line>=l.to||i.line<l.from)&&setTimeout(dn(e,function(){w==r&&a(t)}),150)}else{var c=t.clientY<b.top?-20:t.clientY>b.bottom?20:0;c&&setTimeout(dn(e,function(){w==r&&(s.scroller.scrollTop+=c,a(t))}),50)}}function l(t){e.state.selectingText=!1,w=1/0,ze(t),s.input.focus(),_e(document,"mousemove",x),_e(document,"mouseup",k),u.history.lastSelOrigin=null}var s=e.display,u=e.doc;ze(t);var d,h,p=u.sel,g=p.ranges;if(i&&!t.shiftKey?(h=u.sel.contains(r),d=h>-1?g[h]:new En(r,r)):(d=u.sel.primary(),h=u.sel.primIndex),ya?t.shiftKey&&t.metaKey:t.altKey)n="rect",i||(d=new En(r,r)),r=xr(e,t,!0,!0),h=-1;else if("double"==n){var m=e.findWordAt(r);d=e.display.shift||u.extend?ai(u,d,m.anchor,m.head):m}else if("triple"==n){var v=new En(W(r.line,0),I(u,W(r.line+1,0)));d=e.display.shift||u.extend?ai(u,d,v.anchor,v.head):v}else d=ai(u,d,r);i?h==-1?(h=g.length,hi(u,zn(g.concat([d]),h),{scroll:!1,origin:"*mouse"})):g.length>1&&g[h].empty()&&"single"==n&&!t.shiftKey?(hi(u,zn(g.slice(0,h).concat(g.slice(h+1)),0),{scroll:!1,origin:"*mouse"}),p=u.sel):ci(u,h,d,Wa):(h=0,hi(u,new Wn([d],0),Wa),p=u.sel);var y=r,b=s.wrapper.getBoundingClientRect(),w=0,x=dn(e,function(e){Fe(e)?a(e):l(e)}),k=dn(e,l);e.state.selectingText=k,Ra(document,"mousemove",x),Ra(document,"mouseup",k)}function So(e,t,r,n){var i,o;try{i=t.clientX,o=t.clientY}catch(t){return!1}if(i>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;n&&ze(t);var a=e.display,l=a.lineDiv.getBoundingClientRect();if(o>l.bottom||!We(e,r))return De(t);o-=l.top-a.viewOffset;for(var s=0;s<e.options.gutters.length;++s){var c=a.gutters.childNodes[s];if(c&&c.getBoundingClientRect().right>=i){var u=A(e.doc,o),d=e.options.gutters[s];return Ae(e,r,e,u,d,t),De(t)}}}function To(e,t){return So(e,t,"gutterClick",!0)}function Lo(e,t){It(e.display,t)||Mo(e,t)||Ne(e,t,"contextmenu")||e.display.input.onContextMenu(t)}function Mo(e,t){return!!We(e,"gutterContextMenu")&&So(e,t,"gutterContextMenu",!1)}function _o(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),ir(e)}function Ao(e){function t(t,n,i,o){e.defaults[t]=n,i&&(r[t]=o?function(e,t,r){r!=Cl&&i(e,t,r)}:i)}var r=e.optionHandlers;e.defineOption=t,e.Init=Cl,t("value","",function(e,t){return e.setValue(t)},!0),t("mode",null,function(e,t){e.doc.modeOption=t,Rn(e)},!0),t("indentUnit",2,Rn,!0),t("indentWithTabs",!1),t("smartIndent",!0),t("tabSize",4,function(e){Bn(e),ir(e),pn(e)},!0),t("lineSeparator",null,function(e,t){if(e.doc.lineSep=t,t){var r=[],n=e.doc.first;e.doc.iter(function(e){for(var i=0;;){var o=e.text.indexOf(t,i);if(o==-1)break;i=o+t.length,r.push(W(n,o))}n++});for(var i=r.length-1;i>=0;i--)Ai(e.doc,t,r[i],W(r[i].line,r[i].ch+t.length))}}),t("specialChars",/[\u0000-\u001f\u007f\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(e,t,r){e.state.specialChars=new RegExp(t.source+(t.test("\t")?"":"|\t"),"g"),r!=Cl&&e.refresh()}),t("specialCharPlaceholder",ft,function(e){return e.refresh()},!0),t("electricChars",!0),t("inputStyle",ma?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),t("spellcheck",!1,function(e,t){return e.getInputField().spellcheck=t},!0),t("rtlMoveVisually",!ba),t("wholeLineUpdateBefore",!0),t("theme","default",function(e){_o(e),No(e)},!0),t("keyMap","default",function(e,t,r){var n=oo(t),i=r!=Cl&&oo(r);i&&i.detach&&i.detach(e,n),n.attach&&n.attach(e,i||null)}),t("extraKeys",null),t("lineWrapping",!1,Wo,!0),t("gutters",[],function(e){On(e.options),No(e)},!0),t("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?yr(e.display)+"px":"0",e.refresh()},!0),t("coverGutterNextToScrollbar",!1,function(e){return Ur(e)},!0),t("scrollbarStyle","native",function(e){Gr(e),Ur(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),t("lineNumbers",!1,function(e){On(e.options),No(e)},!0),t("firstLineNumber",1,No,!0),t("lineNumberFormatter",function(e){return e},No,!0),t("showCursorWhenSelecting",!1,Cr,!0),t("resetSelectionOnContextMenu",!0),t("lineWiseCopyCut",!0),t("readOnly",!1,function(e,t){"nocursor"==t?(Or(e),e.display.input.blur(),e.display.disabled=!0):e.display.disabled=!1,e.display.input.readOnlyChanged(t)}),t("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),t("dragDrop",!0,Oo),t("allowDropFileTypes",null),t("cursorBlinkRate",530),t("cursorScrollMargin",0),t("cursorHeight",1,Cr,!0),t("singleCursorHeightPerLine",!0,Cr,!0),t("workTime",100),t("workDelay",100),t("flattenSpans",!0,Bn,!0),t("addModeClass",!1,Bn,!0),t("pollInterval",100),t("undoDepth",200,function(e,t){return e.doc.history.undoDepth=t}),t("historyEventDelay",1250),t("viewportMargin",10,function(e){return e.refresh()},!0),t("maxHighlightLength",1e4,Bn,!0),t("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),t("tabindex",null,function(e,t){return e.display.input.getField().tabIndex=t||""}),t("autofocus",null)}function No(e){Nn(e),pn(e),setTimeout(function(){return Wr(e)},20)}function Oo(e,t,r){var n=r&&r!=Cl;if(!t!=!n){var i=e.display.dragFunctions,o=t?Ra:_e;o(e.display.scroller,"dragstart",i.start),o(e.display.scroller,"dragenter",i.enter),o(e.display.scroller,"dragover",i.over),o(e.display.scroller,"dragleave",i.leave),o(e.display.scroller,"drop",i.drop)}}function Wo(e){
5
- e.options.lineWrapping?(o(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(Sa(e.display.wrapper,"CodeMirror-wrap"),ge(e)),wr(e),pn(e),ir(e),setTimeout(function(){return Ur(e)},100)}function Eo(e,t){var r=this;if(!(this instanceof Eo))return new Eo(e,t);this.options=t=t?s(t):{},s(Sl,t,!1),On(t);var n=t.value;"string"==typeof n&&(n=new ul(n,t.mode,null,t.lineSeparator)),this.doc=n;var i=new Eo.inputStyles[t.inputStyle](this),o=this.display=new C(e,n,i);o.wrapper.CodeMirror=this,Nn(this),_o(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),t.autofocus&&!ma&&o.input.focus(),Gr(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,selectingText:!1,draggingText:!1,highlight:new u,keySeq:null,specialChars:null},aa&&la<11&&setTimeout(function(){return r.display.input.reset(!0)},20),zo(this),Zi(),tn(this),this.curOp.forceUpdate=!0,Vn(this,n),t.autofocus&&!ma||this.hasFocus()?setTimeout(l(Nr,this),20):Or(this);for(var a in Tl)Tl.hasOwnProperty(a)&&Tl[a](r,t[a],Cl);Er(this),t.finishInit&&t.finishInit(this);for(var c=0;c<Ll.length;++c)Ll[c](r);rn(this),sa&&t.lineWrapping&&"optimizelegibility"==getComputedStyle(o.lineDiv).textRendering&&(o.lineDiv.style.textRendering="auto")}function zo(e){function t(){i.activeTouch&&(o=setTimeout(function(){return i.activeTouch=null},1e3),a=i.activeTouch,a.end=+new Date)}function r(e){if(1!=e.touches.length)return!1;var t=e.touches[0];return t.radiusX<=1&&t.radiusY<=1}function n(e,t){if(null==t.left)return!0;var r=t.left-e.left,n=t.top-e.top;return r*r+n*n>400}var i=e.display;Ra(i.scroller,"mousedown",dn(e,wo)),aa&&la<11?Ra(i.scroller,"dblclick",dn(e,function(t){if(!Ne(e,t)){var r=xr(e,t);if(r&&!To(e,t)&&!It(e.display,t)){ze(t);var n=e.findWordAt(r);li(e.doc,n.anchor,n.head)}}})):Ra(i.scroller,"dblclick",function(t){return Ne(e,t)||ze(t)}),Ca||Ra(i.scroller,"contextmenu",function(t){return Lo(e,t)});var o,a={end:0};Ra(i.scroller,"touchstart",function(t){if(!Ne(e,t)&&!r(t)){clearTimeout(o);var n=+new Date;i.activeTouch={start:n,moved:!1,prev:n-a.end<=300?a:null},1==t.touches.length&&(i.activeTouch.left=t.touches[0].pageX,i.activeTouch.top=t.touches[0].pageY)}}),Ra(i.scroller,"touchmove",function(){i.activeTouch&&(i.activeTouch.moved=!0)}),Ra(i.scroller,"touchend",function(r){var o=i.activeTouch;if(o&&!It(i,r)&&null!=o.left&&!o.moved&&new Date-o.start<300){var a,l=e.coordsChar(i.activeTouch,"page");a=!o.prev||n(o,o.prev)?new En(l,l):!o.prev.prev||n(o,o.prev.prev)?e.findWordAt(l):new En(W(l.line,0),I(e.doc,W(l.line+1,0))),e.setSelection(a.anchor,a.head),e.focus(),ze(r)}t()}),Ra(i.scroller,"touchcancel",t),Ra(i.scroller,"scroll",function(){i.scroller.clientHeight&&(Hr(e,i.scroller.scrollTop),Ir(e,i.scroller.scrollLeft,!0),Ae(e,"scroll",e))}),Ra(i.scroller,"mousewheel",function(t){return Rr(e,t)}),Ra(i.scroller,"DOMMouseScroll",function(t){return Rr(e,t)}),Ra(i.wrapper,"scroll",function(){return i.wrapper.scrollTop=i.wrapper.scrollLeft=0}),i.dragFunctions={enter:function(t){Ne(e,t)||He(t)},over:function(t){Ne(e,t)||($i(e,t),He(t))},start:function(t){return Gi(e,t)},drop:dn(e,Vi),leave:function(t){Ne(e,t)||Yi(e)}};var l=i.input.getField();Ra(l,"keyup",function(t){return yo.call(e,t)}),Ra(l,"keydown",dn(e,mo)),Ra(l,"keypress",dn(e,bo)),Ra(l,"focus",function(t){return Nr(e,t)}),Ra(l,"blur",function(t){return Or(e,t)})}function Po(e,t,r,n){var i,o=e.doc;null==r&&(r="add"),"smart"==r&&(o.mode.indent?i=Je(e,t):r="prev");var a=e.options.tabSize,l=S(o,t),s=c(l.text,null,a);l.stateAfter&&(l.stateAfter=null);var u,d=l.text.match(/^\s*/)[0];if(n||/\S/.test(l.text)){if("smart"==r&&(u=o.mode.indent(i,l.text.slice(d.length),l.text),u==Na||u>150)){if(!n)return;r="prev"}}else u=0,r="not";"prev"==r?u=t>o.first?c(S(o,t-1).text,null,a):0:"add"==r?u=s+e.options.indentUnit:"subtract"==r?u=s-e.options.indentUnit:"number"==typeof r&&(u=s+r),u=Math.max(0,u);var f="",p=0;if(e.options.indentWithTabs)for(var g=Math.floor(u/a);g;--g)p+=a,f+="\t";if(p<u&&(f+=h(u-p)),f!=d)return Ai(o,f,W(t,0),W(t,d.length),"+input"),l.stateAfter=null,!0;for(var m=0;m<o.sel.ranges.length;m++){var v=o.sel.ranges[m];if(v.head.line==t&&v.head.ch<d.length){var y=W(t,d.length);ci(o,m,new En(y,y));break}}}function Do(e){Ml=e}function Ho(e,t,r,n,i){var o=e.doc;e.display.shift=!1,n||(n=o.sel);var a=e.state.pasteIncoming||"paste"==i,l=Ka(t),s=null;if(a&&n.ranges.length>1)if(Ml&&Ml.text.join("\n")==t){if(n.ranges.length%Ml.text.length==0){s=[];for(var c=0;c<Ml.text.length;c++)s.push(o.splitLines(Ml.text[c]))}}else l.length==n.ranges.length&&(s=g(l,function(e){return[e]}));for(var u,d=n.ranges.length-1;d>=0;d--){var f=n.ranges[d],h=f.from(),m=f.to();f.empty()&&(r&&r>0?h=W(h.line,h.ch-r):e.state.overwrite&&!a?m=W(m.line,Math.min(S(o,m.line).text.length,m.ch+p(l).length)):Ml&&Ml.lineWise&&Ml.text.join("\n")==t&&(h=m=W(h.line,0))),u=e.curOp.updateInput;var v={from:h,to:m,text:s?s[d%s.length]:l,origin:i||(a?"paste":e.state.cutIncoming?"cut":"+input")};Ci(e.doc,v),Ct(e,"inputRead",e,v)}t&&!a&&Fo(e,t),Jr(e),e.curOp.updateInput=u,e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=!1}function Io(e,t){var r=e.clipboardData&&e.clipboardData.getData("Text");if(r)return e.preventDefault(),t.isReadOnly()||t.options.disableInput||un(t,function(){return Ho(t,r,0,null,"paste")}),!0}function Fo(e,t){if(e.options.electricChars&&e.options.smartIndent)for(var r=e.doc.sel,n=r.ranges.length-1;n>=0;n--){var i=r.ranges[n];if(!(i.head.ch>100||n&&r.ranges[n-1].head.line==i.head.line)){var o=e.getModeAt(i.head),a=!1;if(o.electricChars){for(var l=0;l<o.electricChars.length;l++)if(t.indexOf(o.electricChars.charAt(l))>-1){a=Po(e,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(S(e.doc,i.head.line).text.slice(0,i.head.ch))&&(a=Po(e,i.head.line,"smart"));a&&Ct(e,"electricInput",e,i.head.line)}}}function jo(e){for(var t=[],r=[],n=0;n<e.doc.sel.ranges.length;n++){var i=e.doc.sel.ranges[n].head.line,o={anchor:W(i,0),head:W(i+1,0)};r.push(o),t.push(e.getRange(o.anchor,o.head))}return{text:t,ranges:r}}function Ro(e,t){e.setAttribute("autocorrect","off"),e.setAttribute("autocapitalize","off"),e.setAttribute("spellcheck",!!t)}function Bo(){var e=n("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),t=n("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return sa?e.style.width="1000px":e.setAttribute("wrap","off"),ga&&(e.style.border="1px solid black"),Ro(e),t}function qo(e){var t=e.optionHandlers,r=e.helpers={};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,r){var n=this.options,i=n[e];n[e]==r&&"mode"!=e||(n[e]=r,t.hasOwnProperty(e)&&dn(this,t[e])(this,r,i))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](oo(e))},removeKeyMap:function(e){for(var t=this.state.keyMaps,r=0;r<t.length;++r)if(t[r]==e||t[r].name==e)return t.splice(r,1),!0},addOverlay:fn(function(t,r){var n=t.token?t:e.getMode(this.options,t);if(n.startState)throw new Error("Overlays may not be stateful.");m(this.state.overlays,{mode:n,modeSpec:t,opaque:r&&r.opaque,priority:r&&r.priority||0},function(e){return e.priority}),this.state.modeGen++,pn(this)}),removeOverlay:fn(function(e){for(var t=this,r=this.state.overlays,n=0;n<r.length;++n){var i=r[n].modeSpec;if(i==e||"string"==typeof e&&i.name==e)return r.splice(n,1),t.state.modeGen++,void pn(t)}}),indentLine:fn(function(e,t,r){"string"!=typeof t&&"number"!=typeof t&&(t=null==t?this.options.smartIndent?"smart":"prev":t?"add":"subtract"),N(this.doc,e)&&Po(this,e,t,r)}),indentSelection:fn(function(e){for(var t=this,r=this.doc.sel.ranges,n=-1,i=0;i<r.length;i++){var o=r[i];if(o.empty())o.head.line>n&&(Po(t,o.head.line,e,!0),n=o.head.line,i==t.doc.sel.primIndex&&Jr(t));else{var a=o.from(),l=o.to(),s=Math.max(n,a.line);n=Math.min(t.lastLine(),l.line-(l.ch?0:1))+1;for(var c=s;c<n;++c)Po(t,c,e);var u=t.doc.sel.ranges;0==a.ch&&r.length==u.length&&u[i].from().ch>0&&ci(t.doc,i,new En(a,u[i].to()),Oa)}}}),getTokenAt:function(e,t){return nt(this,e,t)},getLineTokens:function(e,t){return nt(this,W(e),t,!0)},getTokenTypeAt:function(e){e=I(this.doc,e);var t,r=Qe(this,S(this.doc,e.line)),n=0,i=(r.length-1)/2,o=e.ch;if(0==o)t=r[2];else for(;;){var a=n+i>>1;if((a?r[2*a-1]:0)>=o)i=a;else{if(!(r[2*a+1]<o)){t=r[2*a+2];break}n=a+1}}var l=t?t.indexOf("overlay "):-1;return l<0?t:0==l?null:t.slice(0,l-1)},getModeAt:function(t){var r=this.doc.mode;return r.innerMode?e.innerMode(r,this.getTokenAt(t).state).mode:r},getHelper:function(e,t){return this.getHelpers(e,t)[0]},getHelpers:function(e,t){var n=this,i=[];if(!r.hasOwnProperty(t))return i;var o=r[t],a=this.getModeAt(e);if("string"==typeof a[t])o[a[t]]&&i.push(o[a[t]]);else if(a[t])for(var l=0;l<a[t].length;l++){var s=o[a[t][l]];s&&i.push(s)}else a.helperType&&o[a.helperType]?i.push(o[a.helperType]):o[a.name]&&i.push(o[a.name]);for(var c=0;c<o._global.length;c++){var u=o._global[c];u.pred(a,n)&&d(i,u.val)==-1&&i.push(u.val)}return i},getStateAfter:function(e,t){var r=this.doc;return e=H(r,null==e?r.first+r.size-1:e),Je(this,e+1,t)},cursorCoords:function(e,t){var r,n=this.doc.sel.primary();return r=null==e?n.head:"object"==typeof e?I(this.doc,e):e?n.from():n.to(),ur(this,r,t||"page")},charCoords:function(e,t){return cr(this,I(this.doc,e),t||"page")},coordsChar:function(e,t){return e=sr(this,e,t||"page"),hr(this,e.left,e.top)},lineAtHeight:function(e,t){return e=sr(this,{top:e,left:0},t||"page").top,A(this.doc,e+this.display.viewOffset)},heightAtLine:function(e,t){var r,n=!1;if("number"==typeof e){var i=this.doc.first+this.doc.size-1;e<this.doc.first?e=this.doc.first:e>i&&(e=i,n=!0),r=S(this.doc,e)}else r=e;return lr(this,r,{top:0,left:0},t||"page").top+(n?this.doc.height-he(r):0)},defaultTextHeight:function(){return gr(this.display)},defaultCharWidth:function(){return mr(this.display)},setGutterMarker:fn(function(e,t,r){return Ei(this.doc,e,"gutter",function(e){var n=e.gutterMarkers||(e.gutterMarkers={});return n[t]=r,!r&&x(n)&&(e.gutterMarkers=null),!0})}),clearGutter:fn(function(e){var t=this,r=this.doc,n=r.first;r.iter(function(r){r.gutterMarkers&&r.gutterMarkers[e]&&(r.gutterMarkers[e]=null,gn(t,n,"gutter"),x(r.gutterMarkers)&&(r.gutterMarkers=null)),++n})}),lineInfo:function(e){var t;if("number"==typeof e){if(!N(this.doc,e))return null;if(t=e,e=S(this.doc,e),!e)return null}else if(t=_(e),null==t)return null;return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,r,n,i){var o=this.display;e=ur(this,I(this.doc,e));var a=e.bottom,l=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),o.sizer.appendChild(t),"over"==n)a=e.top;else if("above"==n||"near"==n){var s=Math.max(o.wrapper.clientHeight,this.doc.height),c=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==n||e.bottom+t.offsetHeight>s)&&e.top>t.offsetHeight?a=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=s&&(a=e.bottom),l+t.offsetWidth>c&&(l=c-t.offsetWidth)}t.style.top=a+"px",t.style.left=t.style.right="","right"==i?(l=o.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==i?l=0:"middle"==i&&(l=(o.sizer.clientWidth-t.offsetWidth)/2),t.style.left=l+"px"),r&&Xr(this,l,a,l+t.offsetWidth,a+t.offsetHeight)},triggerOnKeyDown:fn(mo),triggerOnKeyPress:fn(bo),triggerOnKeyUp:yo,execCommand:function(e){if(wl.hasOwnProperty(e))return wl[e].call(null,this)},triggerElectric:fn(function(e){Fo(this,e)}),findPosH:function(e,t,r,n){var i=this,o=1;t<0&&(o=-1,t=-t);for(var a=I(this.doc,e),l=0;l<t&&(a=Ko(i.doc,a,o,r,n),!a.hitSide);++l);return a},moveH:fn(function(e,t){var r=this;this.extendSelectionsBy(function(n){return r.display.shift||r.doc.extend||n.empty()?Ko(r.doc,n.head,e,t,r.options.rtlMoveVisually):e<0?n.from():n.to()},Ea)}),deleteH:fn(function(e,t){var r=this.doc.sel,n=this.doc;r.somethingSelected()?n.replaceSelection("",null,"+delete"):ao(this,function(r){var i=Ko(n,r.head,e,t,!1);return e<0?{from:i,to:r.head}:{from:r.head,to:i}})}),findPosV:function(e,t,r,n){var i=this,o=1,a=n;t<0&&(o=-1,t=-t);for(var l=I(this.doc,e),s=0;s<t;++s){var c=ur(i,l,"div");if(null==a?a=c.left:c.left=a,l=Uo(i,c,o,r),l.hitSide)break}return l},moveV:fn(function(e,t){var r=this,n=this.doc,i=[],o=!this.display.shift&&!n.extend&&n.sel.somethingSelected();if(n.extendSelectionsBy(function(a){if(o)return e<0?a.from():a.to();var l=ur(r,a.head,"div");null!=a.goalColumn&&(l.left=a.goalColumn),i.push(l.left);var s=Uo(r,l,e,t);return"page"==t&&a==n.sel.primary()&&Qr(r,null,cr(r,s,"div").top-l.top),s},Ea),i.length)for(var a=0;a<n.sel.ranges.length;a++)n.sel.ranges[a].goalColumn=i[a]}),findWordAt:function(e){var t=this.doc,r=S(t,e.line).text,n=e.ch,i=e.ch;if(r){var o=this.getHelper(e,"wordChars");(e.xRel<0||i==r.length)&&n?--n:++i;for(var a=r.charAt(n),l=w(a,o)?function(e){return w(e,o)}:/\s/.test(a)?function(e){return/\s/.test(e)}:function(e){return!/\s/.test(e)&&!w(e)};n>0&&l(r.charAt(n-1));)--n;for(;i<r.length&&l(r.charAt(i));)++i}return new En(W(e.line,n),W(e.line,i))},toggleOverwrite:function(e){null!=e&&e==this.state.overwrite||((this.state.overwrite=!this.state.overwrite)?o(this.display.cursorDiv,"CodeMirror-overwrite"):Sa(this.display.cursorDiv,"CodeMirror-overwrite"),Ae(this,"overwriteToggle",this,this.state.overwrite))},hasFocus:function(){return this.display.input.getField()==Ta()},isReadOnly:function(){return!(!this.options.readOnly&&!this.doc.cantEdit)},scrollTo:fn(function(e,t){null==e&&null==t||en(this),null!=e&&(this.curOp.scrollLeft=e),null!=t&&(this.curOp.scrollTop=t)}),getScrollInfo:function(){var e=this.display.scroller;return{left:e.scrollLeft,top:e.scrollTop,height:e.scrollHeight-Bt(this)-this.display.barHeight,width:e.scrollWidth-Bt(this)-this.display.barWidth,clientHeight:Kt(this),clientWidth:qt(this)}},scrollIntoView:fn(function(e,t){if(null==e?(e={from:this.doc.sel.primary().head,to:null},null==t&&(t=this.options.cursorScrollMargin)):"number"==typeof e?e={from:W(e,0),to:null}:null==e.from&&(e={from:e,to:null}),e.to||(e.to=e.from),e.margin=t||0,null!=e.from.line)en(this),this.curOp.scrollToPos=e;else{var r=Zr(this,Math.min(e.from.left,e.to.left),Math.min(e.from.top,e.to.top)-e.margin,Math.max(e.from.right,e.to.right),Math.max(e.from.bottom,e.to.bottom)+e.margin);this.scrollTo(r.scrollLeft,r.scrollTop)}}),setSize:fn(function(e,t){var r=this,n=function(e){return"number"==typeof e||/^\d+$/.test(String(e))?e+"px":e};null!=e&&(this.display.wrapper.style.width=n(e)),null!=t&&(this.display.wrapper.style.height=n(t)),this.options.lineWrapping&&nr(this);var i=this.display.viewFrom;this.doc.iter(i,this.display.viewTo,function(e){if(e.widgets)for(var t=0;t<e.widgets.length;t++)if(e.widgets[t].noHScroll){gn(r,i,"widget");break}++i}),this.curOp.forceUpdate=!0,Ae(this,"refresh",this)}),operation:function(e){return un(this,e)},refresh:fn(function(){var e=this.display.cachedTextHeight;pn(this),this.curOp.forceUpdate=!0,ir(this),this.scrollTo(this.doc.scrollLeft,this.doc.scrollTop),_n(this),(null==e||Math.abs(e-gr(this.display))>.5)&&wr(this),Ae(this,"refresh",this)}),swapDoc:fn(function(e){var t=this.doc;return t.cm=null,Vn(this,e),ir(this),this.display.input.reset(),this.scrollTo(e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,Ct(this,"swapDoc",this,t),t}),getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},Ee(e),e.registerHelper=function(t,n,i){r.hasOwnProperty(t)||(r[t]=e[t]={_global:[]}),r[t][n]=i},e.registerGlobalHelper=function(t,n,i,o){e.registerHelper(t,n,o),r[t]._global.push({pred:i,val:o})}}function Ko(e,t,r,n,i){function o(){var t=l+r;return!(t<e.first||t>=e.first+e.size)&&(l=t,u=S(e,t))}function a(e){var t=(i?Se:Te)(u,s,r,!0);if(null==t){if(e||!o())return!1;s=i?(r<0?we:be)(u):r<0?u.text.length:0}else s=t;return!0}var l=t.line,s=t.ch,c=r,u=S(e,l);if("char"==n)a();else if("column"==n)a(!0);else if("word"==n||"group"==n)for(var d=null,f="group"==n,h=e.cm&&e.cm.getHelper(t,"wordChars"),p=!0;!(r<0)||a(!p);p=!1){var g=u.text.charAt(s)||"\n",m=w(g,h)?"w":f&&"\n"==g?"n":!f||/\s/.test(g)?null:"p";if(!f||p||m||(m="s"),d&&d!=m){r<0&&(r=1,a());break}if(m&&(d=m),r>0&&!a(!p))break}var v=bi(e,W(l,s),t,c,!0);return E(t,v)||(v.hitSide=!0),v}function Uo(e,t,r,n){var i,o=e.doc,a=t.left;if("page"==n){var l=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),s=Math.max(l-.5*gr(e.display),3);i=(r>0?t.bottom:t.top)+r*s}else"line"==n&&(i=r>0?t.bottom+3:t.top-3);for(var c;c=hr(e,a,i),c.outside;){if(r<0?i<=0:i>=o.height){c.hitSide=!0;break}i+=5*r}return c}function Vo(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new u,this.gracePeriod=!1}function Go(e,t){var r=Yt(e,t.line);if(!r||r.hidden)return null;var n=S(e.doc,t.line),i=Vt(r,n,t.line),o=Le(n),a="left";if(o){var l=ke(o,t.ch);a=l%2?"right":"left"}var s=Qt(i.map,t.ch,a);return s.offset="right"==s.collapse?s.end:s.start,s}function $o(e,t){return t&&(e.bad=!0),e}function Yo(e,t,r,n,i){function o(e){return function(t){return t.id==e}}function a(t){if(1==t.nodeType){var r=t.getAttribute("cm-text");if(null!=r)return""==r&&(r=t.textContent.replace(/\u200b/g,"")),void(l+=r);var u,d=t.getAttribute("cm-marker");if(d){var f=e.findMarks(W(n,0),W(i+1,0),o(+d));return void(f.length&&(u=f[0].find())&&(l+=T(e.doc,u.from,u.to).join(c)))}if("false"==t.getAttribute("contenteditable"))return;for(var h=0;h<t.childNodes.length;h++)a(t.childNodes[h]);/^(pre|div|p)$/i.test(t.nodeName)&&(s=!0)}else if(3==t.nodeType){var p=t.nodeValue;if(!p)return;s&&(l+=c,s=!1),l+=p}}for(var l="",s=!1,c=e.doc.lineSeparator();a(t),t!=r;)t=t.nextSibling;return l}function Xo(e,t,r){var n;if(t==e.display.lineDiv){if(n=e.display.lineDiv.childNodes[r],!n)return $o(e.clipPos(W(e.display.viewTo-1)),!0);t=null,r=0}else for(n=t;;n=n.parentNode){if(!n||n==e.display.lineDiv)return null;if(n.parentNode&&n.parentNode==e.display.lineDiv)break}for(var i=0;i<e.display.view.length;i++){var o=e.display.view[i];if(o.node==n)return Zo(o,t,r)}}function Zo(e,t,r){function n(t,r,n){for(var i=-1;i<(d?d.length:0);i++)for(var o=i<0?u.map:d[i],a=0;a<o.length;a+=3){var l=o[a+2];if(l==t||l==r){var s=_(i<0?e.line:e.rest[i]),c=o[a]+n;return(n<0||l!=t)&&(c=o[a+(n?1:0)]),W(s,c)}}}var o=e.text.firstChild,a=!1;if(!t||!i(o,t))return $o(W(_(e.line),0),!0);if(t==o&&(a=!0,t=o.childNodes[r],r=0,!t)){var l=e.rest?p(e.rest):e.line;return $o(W(_(l),l.text.length),a)}var s=3==t.nodeType?t:null,c=t;for(s||1!=t.childNodes.length||3!=t.firstChild.nodeType||(s=t.firstChild,r&&(r=s.nodeValue.length));c.parentNode!=o;)c=c.parentNode;var u=e.measure,d=u.maps,f=n(s,c,r);if(f)return $o(f,a);for(var h=c.nextSibling,g=s?s.nodeValue.length-r:0;h;h=h.nextSibling){if(f=n(h,h.firstChild,0))return $o(W(f.line,f.ch-g),a);g+=h.textContent.length}for(var m=c.previousSibling,v=r;m;m=m.previousSibling){if(f=n(m,m.firstChild,-1))return $o(W(f.line,f.ch+v),a);v+=m.textContent.length}}function Qo(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new u,this.inaccurateSelection=!1,this.hasSelection=!1,this.composing=null}function Jo(e,t){function r(){e.value=c.getValue()}if(t=t?s(t):{},t.value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),null==t.autofocus){var n=Ta();t.autofocus=n==e||null!=e.getAttribute("autofocus")&&n==document.body}var i;if(e.form&&(Ra(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var o=e.form;i=o.submit;try{var a=o.submit=function(){r(),o.submit=i,o.submit(),o.submit=a}}catch(l){}}t.finishInit=function(t){t.save=r,t.getTextArea=function(){return e},t.toTextArea=function(){t.toTextArea=isNaN,r(),e.parentNode.removeChild(t.getWrapperElement()),e.style.display="",e.form&&(_e(e.form,"submit",r),"function"==typeof e.form.submit&&(e.form.submit=i))}},e.style.display="none";var c=Eo(function(t){return e.parentNode.insertBefore(t,e.nextSibling)},t);return c}function ea(e){e.off=_e,e.on=Ra,e.wheelEventPixels=jr,e.Doc=ul,e.splitLines=Ka,e.countColumn=c,e.findColumn=f,e.isWordChar=b,e.Pass=Na,e.signal=Ae,e.Line=lt,e.changeEnd=Dn,e.scrollbarModel=al,e.Pos=W,e.cmpPos=E,e.modes=$a,e.mimeModes=Ya,e.resolveMode=Ue,e.getMode=Ve,e.modeExtensions=Xa,e.extendMode=Ge,e.copyState=$e,e.startState=Xe,e.innerMode=Ye,e.commands=wl,e.keyMap=vl,e.keyName=io,e.isModifierKey=no,e.lookupKey=ro,e.normalizeKeyMap=to,e.StringStream=Za,e.SharedTextMarker=Ri,e.TextMarker=Fi,e.LineWidget=Di,e.e_preventDefault=ze,e.e_stopPropagation=Pe,e.e_stop=He,e.addClass=o,e.contains=i,e.rmClass=Sa,e.keyNames=hl}var ta=navigator.userAgent,ra=navigator.platform,na=/gecko\/\d/i.test(ta),ia=/MSIE \d/.test(ta),oa=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ta),aa=ia||oa,la=aa&&(ia?document.documentMode||6:oa[1]),sa=/WebKit\//.test(ta),ca=sa&&/Qt\/\d+\.\d+/.test(ta),ua=/Chrome\//.test(ta),da=/Opera\//.test(ta),fa=/Apple Computer/.test(navigator.vendor),ha=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(ta),pa=/PhantomJS/.test(ta),ga=/AppleWebKit/.test(ta)&&/Mobile\/\w+/.test(ta),ma=ga||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(ta),va=ga||/Mac/.test(ra),ya=/\bCrOS\b/.test(ta),ba=/win/i.test(ra),wa=da&&ta.match(/Version\/(\d*\.\d*)/);wa&&(wa=Number(wa[1])),wa&&wa>=15&&(da=!1,sa=!0);var xa,ka=va&&(ca||da&&(null==wa||wa<12.11)),Ca=na||aa&&la>=9,Sa=function(t,r){var n=t.className,i=e(r).exec(n);if(i){var o=n.slice(i.index+i[0].length);t.className=n.slice(0,i.index)+(o?i[1]+o:"")}};xa=document.createRange?function(e,t,r,n){var i=document.createRange();return i.setEnd(n||e,r),i.setStart(e,t),i}:function(e,t,r){var n=document.body.createTextRange();try{n.moveToElementText(e.parentNode)}catch(i){return n}return n.collapse(!0),n.moveEnd("character",r),n.moveStart("character",t),n};var Ta=function(){for(var e=document.activeElement;e&&e.root&&e.root.activeElement;)e=e.root.activeElement;return e};aa&&la<11&&(Ta=function(){try{return document.activeElement}catch(e){return document.body}});var La=function(e){e.select()};ga?La=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:aa&&(La=function(e){try{e.select()}catch(t){}}),u.prototype.set=function(e,t){clearTimeout(this.id),this.id=setTimeout(t,e)};var Ma,_a,Aa=30,Na={toString:function(){return"CodeMirror.Pass"}},Oa={scroll:!1},Wa={origin:"*mouse"},Ea={origin:"+move"},za=[""],Pa=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Da=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/,Ha=!1,Ia=!1,Fa=null,ja=function(){function e(e){return e<=247?r.charAt(e):1424<=e&&e<=1524?"R":1536<=e&&e<=1773?n.charAt(e-1536):1774<=e&&e<=2220?"r":8192<=e&&e<=8203?"w":8204==e?"b":"L"}function t(e,t,r){this.level=e,this.from=t,this.to=r}var r="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",n="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",i=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,o=/[stwN]/,a=/[LRr]/,l=/[Lb1n]/,s=/[1n]/,c="L";return function(r){if(!i.test(r))return!1;for(var n=r.length,u=[],d=0;d<n;++d)u.push(e(r.charCodeAt(d)));for(var f=0,h=c;f<n;++f){var g=u[f];"m"==g?u[f]=h:h=g}for(var m=0,v=c;m<n;++m){var y=u[m];"1"==y&&"r"==v?u[m]="n":a.test(y)&&(v=y,"r"==y&&(u[m]="R"))}for(var b=1,w=u[0];b<n-1;++b){var x=u[b];"+"==x&&"1"==w&&"1"==u[b+1]?u[b]="1":","!=x||w!=u[b+1]||"1"!=w&&"n"!=w||(u[b]=w),w=x}for(var k=0;k<n;++k){var C=u[k];if(","==C)u[k]="N";else if("%"==C){var S=void 0;for(S=k+1;S<n&&"%"==u[S];++S);for(var T=k&&"!"==u[k-1]||S<n&&"1"==u[S]?"1":"N",L=k;L<S;++L)u[L]=T;k=S-1}}for(var M=0,_=c;M<n;++M){var A=u[M];"L"==_&&"1"==A?u[M]="L":a.test(A)&&(_=A)}for(var N=0;N<n;++N)if(o.test(u[N])){var O=void 0;for(O=N+1;O<n&&o.test(u[O]);++O);for(var W="L"==(N?u[N-1]:c),E="L"==(O<n?u[O]:c),z=W||E?"L":"R",P=N;P<O;++P)u[P]=z;N=O-1}for(var D,H=[],I=0;I<n;)if(l.test(u[I])){var F=I;for(++I;I<n&&l.test(u[I]);++I);H.push(new t(0,F,I))}else{var j=I,R=H.length;for(++I;I<n&&"L"!=u[I];++I);for(var B=j;B<I;)if(s.test(u[B])){j<B&&H.splice(R,0,new t(1,j,B));var q=B;for(++B;B<I&&s.test(u[B]);++B);H.splice(R,0,new t(2,q,B)),j=B}else++B;j<I&&H.splice(R,0,new t(1,j,I))}return 1==H[0].level&&(D=r.match(/^\s+/))&&(H[0].from=D[0].length,H.unshift(new t(0,0,D[0].length))),1==p(H).level&&(D=r.match(/\s+$/))&&(p(H).to-=D[0].length,H.push(new t(0,n-D[0].length,n))),2==H[0].level&&H.unshift(new t(1,H[0].to,H[0].to)),H[0].level!=p(H).level&&H.push(new t(H[0].level,n,n)),H}}(),Ra=function(e,t,r){if(e.addEventListener)e.addEventListener(t,r,!1);else if(e.attachEvent)e.attachEvent("on"+t,r);else{var n=e._handlers||(e._handlers={}),i=n[t]||(n[t]=[]);i.push(r)}},Ba=[],qa=function(){if(aa&&la<9)return!1;var e=n("div");return"draggable"in e||"dragDrop"in e}(),Ka=3!="\n\nb".split(/\n/).length?function(e){for(var t=0,r=[],n=e.length;t<=n;){var i=e.indexOf("\n",t);i==-1&&(i=e.length);var o=e.slice(t,"\r"==e.charAt(i-1)?i-1:i),a=o.indexOf("\r");a!=-1?(r.push(o.slice(0,a)),t+=a+1):(r.push(o),t=i+1)}return r}:function(e){return e.split(/\r\n?|\n/)},Ua=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch(r){}return!(!t||t.parentElement()!=e)&&0!=t.compareEndPoints("StartToEnd",t)},Va=function(){var e=n("div");return"oncopy"in e||(e.setAttribute("oncopy","return;"),"function"==typeof e.oncopy)}(),Ga=null,$a={},Ya={},Xa={},Za=function(e,t){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0};Za.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},eat:function(e){var t,r=this.string.charAt(this.pos);if(t="string"==typeof e?r==e:r&&(e.test?e.test(r):e(r)))return++this.pos,r},eatWhile:function(e){for(var t=this.pos;this.eat(e););return this.pos>t},eatSpace:function(){for(var e=this,t=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++e.pos;return this.pos>t},skipToEnd:function(){this.pos=this.string.length},skipTo:function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},backUp:function(e){this.pos-=e},column:function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=c(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?c(this.string,this.lineStart,this.tabSize):0)},indentation:function(){return c(this.string,null,this.tabSize)-(this.lineStart?c(this.string,this.lineStart,this.tabSize):0)},match:function(e,t,r){if("string"!=typeof e){var n=this.string.slice(this.pos).match(e);return n&&n.index>0?null:(n&&t!==!1&&(this.pos+=n[0].length),n)}var i=function(e){return r?e.toLowerCase():e},o=this.string.substr(this.pos,e.length);if(i(o)==i(e))return t!==!1&&(this.pos+=e.length),!0},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}}},Ee(lt),lt.prototype.lineNo=function(){return _(this)};var Qa,Ja={},el={},tl=null,rl=null,nl={left:0,right:0,top:0,bottom:0},il=0,ol=null;aa?ol=-.53:na?ol=15:ua?ol=-.7:fa&&(ol=-1/3),qr.prototype=s({update:function(e){var t=e.scrollWidth>e.clientWidth+1,r=e.scrollHeight>e.clientHeight+1,n=e.nativeBarWidth;if(r){this.vert.style.display="block",this.vert.style.bottom=t?n+"px":"0";var i=e.viewHeight-(t?n:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+i)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=r?n+"px":"0",this.horiz.style.left=e.barLeft+"px";var o=e.viewWidth-e.barLeft-(r?n:0);this.horiz.firstChild.style.width=e.scrollWidth-e.clientWidth+o+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(0==n&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:r?n:0,bottom:t?n:0}},setScrollLeft:function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz)},setScrollTop:function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert)},zeroWidthHack:function(){var e=va&&!ha?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new u,this.disableVert=new u},enableZeroWidthBar:function(e,t){function r(){var n=e.getBoundingClientRect(),i=document.elementFromPoint(n.left+1,n.bottom-1);i!=e?e.style.pointerEvents="none":t.set(1e3,r)}e.style.pointerEvents="auto",t.set(1e3,r)},clear:function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)}},qr.prototype),Kr.prototype=s({update:function(){return{bottom:0,right:0}},setScrollLeft:function(){},setScrollTop:function(){},clear:function(){}},Kr.prototype);var al={"native":qr,"null":Kr},ll=0;kn.prototype.signal=function(e,t){We(e,t)&&this.events.push(arguments)},kn.prototype.finish=function(){for(var e=this,t=0;t<this.events.length;t++)Ae.apply(null,e.events[t]);
6
- },Wn.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(e){var t=this;if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(var r=0;r<this.ranges.length;r++){var n=t.ranges[r],i=e.ranges[r];if(0!=E(n.anchor,i.anchor)||0!=E(n.head,i.head))return!1}return!0},deepCopy:function(){for(var e=this,t=[],r=0;r<this.ranges.length;r++)t[r]=new En(z(e.ranges[r].anchor),z(e.ranges[r].head));return new Wn(t,this.primIndex)},somethingSelected:function(){for(var e=this,t=0;t<this.ranges.length;t++)if(!e.ranges[t].empty())return!0;return!1},contains:function(e,t){var r=this;t||(t=e);for(var n=0;n<this.ranges.length;n++){var i=r.ranges[n];if(E(t,i.from())>=0&&E(e,i.to())<=0)return n}return-1}},En.prototype={from:function(){return D(this.anchor,this.head)},to:function(){return P(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}},zi.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var r=this,n=e,i=e+t;n<i;++n){var o=r.lines[n];r.height-=o.height,ct(o),Ct(o,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,r){var n=this;this.height+=r,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var i=0;i<t.length;++i)t[i].parent=n},iterN:function(e,t,r){for(var n=this,i=e+t;e<i;++e)if(r(n.lines[e]))return!0}},Pi.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){var r=this;this.size-=t;for(var n=0;n<this.children.length;++n){var i=r.children[n],o=i.chunkSize();if(e<o){var a=Math.min(t,o-e),l=i.height;if(i.removeInner(e,a),r.height-=l-i.height,o==a&&(r.children.splice(n--,1),i.parent=null),0==(t-=a))break;e=0}else e-=o}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof zi))){var s=[];this.collapse(s),this.children=[new zi(s)],this.children[0].parent=this}},collapse:function(e){for(var t=this,r=0;r<this.children.length;++r)t.children[r].collapse(e)},insertInner:function(e,t,r){var n=this;this.size+=t.length,this.height+=r;for(var i=0;i<this.children.length;++i){var o=n.children[i],a=o.chunkSize();if(e<=a){if(o.insertInner(e,t,r),o.lines&&o.lines.length>50){for(var l=o.lines.length%25+25,s=l;s<o.lines.length;){var c=new zi(o.lines.slice(s,s+=25));o.height-=c.height,n.children.splice(++i,0,c),c.parent=n}o.lines=o.lines.slice(0,l),n.maybeSpill()}break}e-=a}},maybeSpill:function(){if(!(this.children.length<=10)){var e=this;do{var t=e.children.splice(e.children.length-5,5),r=new Pi(t);if(e.parent){e.size-=r.size,e.height-=r.height;var n=d(e.parent.children,e);e.parent.children.splice(n+1,0,r)}else{var i=new Pi(e.children);i.parent=e,e.children=[i,r],e=i}r.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()}},iterN:function(e,t,r){for(var n=this,i=0;i<this.children.length;++i){var o=n.children[i],a=o.chunkSize();if(e<a){var l=Math.min(t,a-e);if(o.iterN(e,l,r))return!0;if(0==(t-=l))break;e=0}else e-=a}}},Ee(Di),Di.prototype.clear=function(){var e=this,t=this.doc.cm,r=this.line.widgets,n=this.line,i=_(n);if(null!=i&&r){for(var o=0;o<r.length;++o)r[o]==e&&r.splice(o--,1);r.length||(n.widgets=null);var a=Ht(this);M(n,Math.max(0,n.height-a)),t&&un(t,function(){Hi(t,n,-a),gn(t,i,"widget")})}},Di.prototype.changed=function(){var e=this.height,t=this.doc.cm,r=this.line;this.height=null;var n=Ht(this)-e;n&&(M(r,r.height+n),t&&un(t,function(){t.curOp.forceUpdate=!0,Hi(t,r,n)}))};var sl=0;Ee(Fi),Fi.prototype.clear=function(){var e=this;if(!this.explicitlyCleared){var t=this.doc.cm,r=t&&!t.curOp;if(r&&tn(t),We(this,"clear")){var n=this.find();n&&Ct(this,"clear",n.from,n.to)}for(var i=null,o=null,a=0;a<this.lines.length;++a){var l=e.lines[a],s=K(l.markedSpans,e);t&&!e.collapsed?gn(t,_(l),"text"):t&&(null!=s.to&&(o=_(l)),null!=s.from&&(i=_(l))),l.markedSpans=U(l.markedSpans,s),null==s.from&&e.collapsed&&!de(e.doc,l)&&t&&M(l,gr(t.display))}if(t&&this.collapsed&&!t.options.lineWrapping)for(var c=0;c<this.lines.length;++c){var u=le(e.lines[c]),d=pe(u);d>t.display.maxLineLength&&(t.display.maxLine=u,t.display.maxLineLength=d,t.display.maxLineChanged=!0)}null!=i&&t&&this.collapsed&&pn(t,i,o+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,t&&mi(t.doc)),t&&Ct(t,"markerCleared",t,this),r&&rn(t),this.parent&&this.parent.clear()}},Fi.prototype.find=function(e,t){var r=this;null==e&&"bookmark"==this.type&&(e=1);for(var n,i,o=0;o<this.lines.length;++o){var a=r.lines[o],l=K(a.markedSpans,r);if(null!=l.from&&(n=W(t?a:_(a),l.from),e==-1))return n;if(null!=l.to&&(i=W(t?a:_(a),l.to),1==e))return i}return n&&{from:n,to:i}},Fi.prototype.changed=function(){var e=this.find(-1,!0),t=this,r=this.doc.cm;e&&r&&un(r,function(){var n=e.line,i=_(e.line),o=Yt(r,i);if(o&&(rr(o),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!de(t.doc,n)&&null!=t.height){var a=t.height;t.height=null;var l=Ht(t)-a;l&&M(n,n.height+l)}})},Fi.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;t.maybeHiddenMarkers&&d(t.maybeHiddenMarkers,this)!=-1||(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},Fi.prototype.detachLine=function(e){if(this.lines.splice(d(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}},Ee(Ri),Ri.prototype.clear=function(){var e=this;if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var t=0;t<this.markers.length;++t)e.markers[t].clear();Ct(this,"clear")}},Ri.prototype.find=function(e,t){return this.primary.find(e,t)};var cl=0,ul=function(e,t,r,n){if(!(this instanceof ul))return new ul(e,t,r,n);null==r&&(r=0),Pi.call(this,[new zi([new lt("",null)])]),this.first=r,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=r;var i=W(r,0);this.sel=Pn(i),this.history=new Gn(null),this.id=++cl,this.modeOption=t,this.lineSep=n,this.extend=!1,"string"==typeof e&&(e=this.splitLines(e)),Kn(this,{from:i,to:i,text:e}),hi(this,Pn(i),Oa)};ul.prototype=y(Pi.prototype,{constructor:ul,iter:function(e,t,r){r?this.iterN(e-this.first,t-e,r):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var r=0,n=0;n<t.length;++n)r+=t[n].height;this.insertInner(e-this.first,t,r)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=L(this,this.first,this.first+this.size);return e===!1?t:t.join(e||this.lineSeparator())},setValue:hn(function(e){var t=W(this.first,0),r=this.first+this.size-1;Ci(this,{from:t,to:W(r,S(this,r).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0),hi(this,Pn(t))}),replaceRange:function(e,t,r,n){t=I(this,t),r=r?I(this,r):t,Ai(this,e,t,r,n)},getRange:function(e,t,r){var n=T(this,I(this,e),I(this,t));return r===!1?n:n.join(r||this.lineSeparator())},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){if(N(this,e))return S(this,e)},getLineNumber:function(e){return _(e)},getLineHandleVisualStart:function(e){return"number"==typeof e&&(e=S(this,e)),le(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return I(this,e)},getCursor:function(e){var t,r=this.sel.primary();return t=null==e||"head"==e?r.head:"anchor"==e?r.anchor:"end"==e||"to"==e||e===!1?r.to():r.from()},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:hn(function(e,t,r){ui(this,I(this,"number"==typeof e?W(e,t||0):e),null,r)}),setSelection:hn(function(e,t,r){ui(this,I(this,e),I(this,t||e),r)}),extendSelection:hn(function(e,t,r){li(this,I(this,e),t&&I(this,t),r)}),extendSelections:hn(function(e,t){si(this,j(this,e),t)}),extendSelectionsBy:hn(function(e,t){var r=g(this.sel.ranges,e);si(this,j(this,r),t)}),setSelections:hn(function(e,t,r){var n=this;if(e.length){for(var i=[],o=0;o<e.length;o++)i[o]=new En(I(n,e[o].anchor),I(n,e[o].head));null==t&&(t=Math.min(e.length-1,this.sel.primIndex)),hi(this,zn(i,t),r)}}),addSelection:hn(function(e,t,r){var n=this.sel.ranges.slice(0);n.push(new En(I(this,e),I(this,t||e))),hi(this,zn(n,n.length-1),r)}),getSelection:function(e){for(var t,r=this,n=this.sel.ranges,i=0;i<n.length;i++){var o=T(r,n[i].from(),n[i].to());t=t?t.concat(o):o}return e===!1?t:t.join(e||this.lineSeparator())},getSelections:function(e){for(var t=this,r=[],n=this.sel.ranges,i=0;i<n.length;i++){var o=T(t,n[i].from(),n[i].to());e!==!1&&(o=o.join(e||t.lineSeparator())),r[i]=o}return r},replaceSelection:function(e,t,r){for(var n=[],i=0;i<this.sel.ranges.length;i++)n[i]=e;this.replaceSelections(n,t,r||"+input")},replaceSelections:hn(function(e,t,r){for(var n=this,i=[],o=this.sel,a=0;a<o.ranges.length;a++){var l=o.ranges[a];i[a]={from:l.from(),to:l.to(),text:n.splitLines(e[a]),origin:r}}for(var s=t&&"end"!=t&&jn(this,i,t),c=i.length-1;c>=0;c--)Ci(n,i[c]);s?fi(this,s):this.cm&&Jr(this.cm)}),undo:hn(function(){Ti(this,"undo")}),redo:hn(function(){Ti(this,"redo")}),undoSelection:hn(function(){Ti(this,"undo",!0)}),redoSelection:hn(function(){Ti(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,r=0,n=0;n<e.done.length;n++)e.done[n].ranges||++t;for(var i=0;i<e.undone.length;i++)e.undone[i].ranges||++r;return{undo:t,redo:r}},clearHistory:function(){this.history=new Gn(this.history.maxGeneration)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(e){return e&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function(){return{done:oi(this.history.done),undone:oi(this.history.undone)}},setHistory:function(e){var t=this.history=new Gn(this.history.maxGeneration);t.done=oi(e.done.slice(0),null,!0),t.undone=oi(e.undone.slice(0),null,!0)},addLineClass:hn(function(t,r,n){return Ei(this,t,"gutter"==r?"gutter":"class",function(t){var i="text"==r?"textClass":"background"==r?"bgClass":"gutter"==r?"gutterClass":"wrapClass";if(t[i]){if(e(n).test(t[i]))return!1;t[i]+=" "+n}else t[i]=n;return!0})}),removeLineClass:hn(function(t,r,n){return Ei(this,t,"gutter"==r?"gutter":"class",function(t){var i="text"==r?"textClass":"background"==r?"bgClass":"gutter"==r?"gutterClass":"wrapClass",o=t[i];if(!o)return!1;if(null==n)t[i]=null;else{var a=o.match(e(n));if(!a)return!1;var l=a.index+a[0].length;t[i]=o.slice(0,a.index)+(a.index&&l!=o.length?" ":"")+o.slice(l)||null}return!0})}),addLineWidget:hn(function(e,t,r){return Ii(this,e,t,r)}),removeLineWidget:function(e){e.clear()},markText:function(e,t,r){return ji(this,I(this,e),I(this,t),r,r&&r.type||"range")},setBookmark:function(e,t){var r={replacedWith:t&&(null==t.nodeType?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared,handleMouseEvents:t&&t.handleMouseEvents};return e=I(this,e),ji(this,e,e,r,"bookmark")},findMarksAt:function(e){e=I(this,e);var t=[],r=S(this,e.line).markedSpans;if(r)for(var n=0;n<r.length;++n){var i=r[n];(null==i.from||i.from<=e.ch)&&(null==i.to||i.to>=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,r){e=I(this,e),t=I(this,t);var n=[],i=e.line;return this.iter(e.line,t.line+1,function(o){var a=o.markedSpans;if(a)for(var l=0;l<a.length;l++){var s=a[l];null!=s.to&&i==e.line&&e.ch>=s.to||null==s.from&&i!=e.line||null!=s.from&&i==t.line&&s.from>=t.ch||r&&!r(s.marker)||n.push(s.marker.parent||s.marker)}++i}),n},getAllMarks:function(){var e=[];return this.iter(function(t){var r=t.markedSpans;if(r)for(var n=0;n<r.length;++n)null!=r[n].from&&e.push(r[n].marker)}),e},posFromIndex:function(e){var t,r=this.first,n=this.lineSeparator().length;return this.iter(function(i){var o=i.text.length+n;return o>e?(t=e,!0):(e-=o,void++r)}),I(this,W(r,t))},indexFromPos:function(e){e=I(this,e);var t=e.ch;if(e.line<this.first||e.ch<0)return 0;var r=this.lineSeparator().length;return this.iter(this.first,e.line,function(e){t+=e.text.length+r}),t},copy:function(e){var t=new ul(L(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,e&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(e){e||(e={});var t=this.first,r=this.first+this.size;null!=e.from&&e.from>t&&(t=e.from),null!=e.to&&e.to<r&&(r=e.to);var n=new ul(L(this,t,r),e.mode||this.modeOption,t,this.lineSep);return e.sharedHist&&(n.history=this.history),(this.linked||(this.linked=[])).push({doc:n,sharedHist:e.sharedHist}),n.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],Ki(n,qi(this)),n},unlinkDoc:function(e){var t=this;if(e instanceof Eo&&(e=e.doc),this.linked)for(var r=0;r<this.linked.length;++r){var n=t.linked[r];if(n.doc==e){t.linked.splice(r,1),e.unlinkDoc(t),Ui(qi(t));break}}if(e.history==this.history){var i=[e.id];Un(e,function(e){return i.push(e.id)},!0),e.history=new Gn(null),e.history.done=oi(this.history.done,i),e.history.undone=oi(this.history.undone,i)}},iterLinkedDocs:function(e){Un(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(e){return this.lineSep?e.split(this.lineSep):Ka(e)},lineSeparator:function(){return this.lineSep||"\n"}}),ul.prototype.eachLine=ul.prototype.iter;for(var dl=0,fl=!1,hl={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"},pl=0;pl<10;pl++)hl[pl+48]=hl[pl+96]=String(pl);for(var gl=65;gl<=90;gl++)hl[gl]=String.fromCharCode(gl);for(var ml=1;ml<=12;ml++)hl[ml+111]=hl[ml+63235]="F"+ml;var vl={};vl.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},vl.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},vl.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"},vl.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},vl["default"]=va?vl.macDefault:vl.pcDefault;var yl,bl,wl={selectAll:xi,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Oa)},killLine:function(e){return ao(e,function(t){if(t.empty()){var r=S(e.doc,t.head.line).text.length;return t.head.ch==r&&t.head.line<e.lastLine()?{from:t.head,to:W(t.head.line+1,0)}:{from:t.head,to:W(t.head.line,r)}}return{from:t.from(),to:t.to()}})},deleteLine:function(e){return ao(e,function(t){return{from:W(t.from().line,0),to:I(e.doc,W(t.to().line+1,0))}})},delLineLeft:function(e){return ao(e,function(e){return{from:W(e.from().line,0),to:e.from()}})},delWrappedLineLeft:function(e){return ao(e,function(t){var r=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:0,top:r},"div");return{from:n,to:t.from()}})},delWrappedLineRight:function(e){return ao(e,function(t){var r=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:r},"div");return{from:t.from(),to:n}})},undo:function(e){return e.undo()},redo:function(e){return e.redo()},undoSelection:function(e){return e.undoSelection()},redoSelection:function(e){return e.redoSelection()},goDocStart:function(e){return e.extendSelection(W(e.firstLine(),0))},goDocEnd:function(e){return e.extendSelection(W(e.lastLine()))},goLineStart:function(e){return e.extendSelectionsBy(function(t){return lo(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){return e.extendSelectionsBy(function(t){return co(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function(e){return e.extendSelectionsBy(function(t){return so(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(e){return e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:r},"div")},Ea)},goLineLeft:function(e){return e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:r},"div")},Ea)},goLineLeftSmart:function(e){return e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:0,top:r},"div");return n.ch<e.getLine(n.line).search(/\S/)?co(e,t.head):n},Ea)},goLineUp:function(e){return e.moveV(-1,"line")},goLineDown:function(e){return e.moveV(1,"line")},goPageUp:function(e){return e.moveV(-1,"page")},goPageDown:function(e){return e.moveV(1,"page")},goCharLeft:function(e){return e.moveH(-1,"char")},goCharRight:function(e){return e.moveH(1,"char")},goColumnLeft:function(e){return e.moveH(-1,"column")},goColumnRight:function(e){return e.moveH(1,"column")},goWordLeft:function(e){return e.moveH(-1,"word")},goGroupRight:function(e){return e.moveH(1,"group")},goGroupLeft:function(e){return e.moveH(-1,"group")},goWordRight:function(e){return e.moveH(1,"word")},delCharBefore:function(e){return e.deleteH(-1,"char")},delCharAfter:function(e){return e.deleteH(1,"char")},delWordBefore:function(e){return e.deleteH(-1,"word")},delWordAfter:function(e){return e.deleteH(1,"word")},delGroupBefore:function(e){return e.deleteH(-1,"group")},delGroupAfter:function(e){return e.deleteH(1,"group")},indentAuto:function(e){return e.indentSelection("smart")},indentMore:function(e){return e.indentSelection("add")},indentLess:function(e){return e.indentSelection("subtract")},insertTab:function(e){return e.replaceSelection("\t")},insertSoftTab:function(e){for(var t=[],r=e.listSelections(),n=e.options.tabSize,i=0;i<r.length;i++){var o=r[i].from(),a=c(e.getLine(o.line),o.ch,n);t.push(h(n-a%n))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){return un(e,function(){for(var t=e.listSelections(),r=[],n=0;n<t.length;n++)if(t[n].empty()){var i=t[n].head,o=S(e.doc,i.line).text;if(o)if(i.ch==o.length&&(i=new W(i.line,i.ch-1)),i.ch>0)i=new W(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),W(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var a=S(e.doc,i.line-1).text;a&&(i=new W(i.line,1),e.replaceRange(o.charAt(0)+e.doc.lineSeparator()+a.charAt(a.length-1),W(i.line-1,a.length-1),i,"+transpose"))}r.push(new En(i,i))}e.setSelections(r)})},newlineAndIndent:function(e){return un(e,function(){for(var t=e.listSelections(),r=t.length-1;r>=0;r--)e.replaceRange(e.doc.lineSeparator(),t[r].anchor,t[r].head,"+input");t=e.listSelections();for(var n=0;n<t.length;n++)e.indentLine(t[n].from().line,null,!0);Jr(e)})},openLine:function(e){return e.replaceSelection("\n","start")},toggleOverwrite:function(e){return e.toggleOverwrite()}},xl=new u,kl=null,Cl={toString:function(){return"CodeMirror.Init"}},Sl={},Tl={};Eo.defaults=Sl,Eo.optionHandlers=Tl;var Ll=[];Eo.defineInitHook=function(e){return Ll.push(e)};var Ml=null;Vo.prototype=s({init:function(e){function t(e){if(!Ne(n,e)){if(n.somethingSelected())Do({lineWise:!1,text:n.getSelections()}),"cut"==e.type&&n.replaceSelection("",null,"cut");else{if(!n.options.lineWiseCopyCut)return;var t=jo(n);Do({lineWise:!0,text:t.text}),"cut"==e.type&&n.operation(function(){n.setSelections(t.ranges,0,Oa),n.replaceSelection("",null,"cut")})}if(e.clipboardData){e.clipboardData.clearData();var o=Ml.text.join("\n");if(e.clipboardData.setData("Text",o),e.clipboardData.getData("Text")==o)return void e.preventDefault()}var a=Bo(),l=a.firstChild;n.display.lineSpace.insertBefore(a,n.display.lineSpace.firstChild),l.value=Ml.text.join("\n");var s=document.activeElement;La(l),setTimeout(function(){n.display.lineSpace.removeChild(a),s.focus(),s==i&&r.showPrimarySelection()},50)}}var r=this,n=r.cm,i=r.div=e.lineDiv;Ro(i,n.options.spellcheck),Ra(i,"paste",function(e){Ne(n,e)||Io(e,n)||la<=11&&setTimeout(dn(n,function(){r.pollContent()||pn(n)}),20)}),Ra(i,"compositionstart",function(e){var t=e.data;if(r.composing={sel:n.doc.sel,data:t,startData:t},t){var i=n.doc.sel.primary(),o=n.getLine(i.head.line),a=o.indexOf(t,Math.max(0,i.head.ch-t.length));a>-1&&a<=i.head.ch&&(r.composing.sel=Pn(W(i.head.line,a),W(i.head.line,a+t.length)))}}),Ra(i,"compositionupdate",function(e){return r.composing.data=e.data}),Ra(i,"compositionend",function(e){var t=r.composing;t&&(e.data==t.startData||/\u200b/.test(e.data)||(t.data=e.data),setTimeout(function(){t.handled||r.applyComposition(t),r.composing==t&&(r.composing=null)},50))}),Ra(i,"touchstart",function(){return r.forceCompositionEnd()}),Ra(i,"input",function(){r.composing||!n.isReadOnly()&&r.pollContent()||un(r.cm,function(){return pn(n)})}),Ra(i,"copy",t),Ra(i,"cut",t)},prepareSelection:function(){var e=Sr(this.cm,!1);return e.focus=this.cm.state.focused,e},showSelection:function(e,t){e&&this.cm.display.view.length&&((e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e))},showPrimarySelection:function(){var e=window.getSelection(),t=this.cm.doc.sel.primary(),r=Xo(this.cm,e.anchorNode,e.anchorOffset),n=Xo(this.cm,e.focusNode,e.focusOffset);if(!r||r.bad||!n||n.bad||0!=E(D(r,n),t.from())||0!=E(P(r,n),t.to())){var i=Go(this.cm,t.from()),o=Go(this.cm,t.to());if(i||o){var a=this.cm.display.view,l=e.rangeCount&&e.getRangeAt(0);if(i){if(!o){var s=a[a.length-1].measure,c=s.maps?s.maps[s.maps.length-1]:s.map;o={node:c[c.length-1],offset:c[c.length-2]-c[c.length-3]}}}else i={node:a[0].measure.map[2],offset:0};var u;try{u=xa(i.node,i.offset,o.offset,o.node)}catch(d){}u&&(!na&&this.cm.state.focused?(e.collapse(i.node,i.offset),u.collapsed||(e.removeAllRanges(),e.addRange(u))):(e.removeAllRanges(),e.addRange(u)),l&&null==e.anchorNode?e.addRange(l):na&&this.startGracePeriod()),this.rememberSelection()}}},startGracePeriod:function(){var e=this;clearTimeout(this.gracePeriod),this.gracePeriod=setTimeout(function(){e.gracePeriod=!1,e.selectionChanged()&&e.cm.operation(function(){return e.cm.curOp.selectionChanged=!0})},20)},showMultipleSelections:function(e){r(this.cm.display.cursorDiv,e.cursors),r(this.cm.display.selectionDiv,e.selection)},rememberSelection:function(){var e=window.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},selectionInEditor:function(){var e=window.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return i(this.div,t)},focus:function(){"nocursor"!=this.cm.options.readOnly&&this.div.focus()},blur:function(){this.div.blur()},getField:function(){return this.div},supportsTouch:function(){return!0},receivedFocus:function(){function e(){t.cm.state.focused&&(t.pollSelection(),t.polling.set(t.cm.options.pollInterval,e))}var t=this;this.selectionInEditor()?this.pollSelection():un(this.cm,function(){return t.cm.curOp.selectionChanged=!0}),this.polling.set(this.cm.options.pollInterval,e)},selectionChanged:function(){var e=window.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},pollSelection:function(){if(!this.composing&&!this.gracePeriod&&this.selectionChanged()){var e=window.getSelection(),t=this.cm;this.rememberSelection();var r=Xo(t,e.anchorNode,e.anchorOffset),n=Xo(t,e.focusNode,e.focusOffset);r&&n&&un(t,function(){hi(t.doc,Pn(r,n),Oa),(r.bad||n.bad)&&(t.curOp.selectionChanged=!0)})}},pollContent:function(){var e=this.cm,t=e.display,r=e.doc.sel.primary(),n=r.from(),i=r.to();if(n.line<t.viewFrom||i.line>t.viewTo-1)return!1;var o,a,l;n.line==t.viewFrom||0==(o=kr(e,n.line))?(a=_(t.view[0].line),l=t.view[0].node):(a=_(t.view[o].line),l=t.view[o-1].node.nextSibling);var s,c,u=kr(e,i.line);u==t.view.length-1?(s=t.viewTo-1,c=t.lineDiv.lastChild):(s=_(t.view[u+1].line)-1,c=t.view[u+1].node.previousSibling);for(var d=e.doc.splitLines(Yo(e,l,c,a,s)),f=T(e.doc,W(a,0),W(s,S(e.doc,s).text.length));d.length>1&&f.length>1;)if(p(d)==p(f))d.pop(),f.pop(),s--;else{if(d[0]!=f[0])break;d.shift(),f.shift(),a++}for(var h=0,g=0,m=d[0],v=f[0],y=Math.min(m.length,v.length);h<y&&m.charCodeAt(h)==v.charCodeAt(h);)++h;for(var b=p(d),w=p(f),x=Math.min(b.length-(1==d.length?h:0),w.length-(1==f.length?h:0));g<x&&b.charCodeAt(b.length-g-1)==w.charCodeAt(w.length-g-1);)++g;d[d.length-1]=b.slice(0,b.length-g),d[0]=d[0].slice(h);var k=W(a,h),C=W(s,f.length?p(f).length-g:0);return d.length>1||d[0]||E(k,C)?(Ai(e.doc,d,k,C,"+input"),!0):void 0},ensurePolled:function(){this.forceCompositionEnd()},reset:function(){this.forceCompositionEnd()},forceCompositionEnd:function(){this.composing&&!this.composing.handled&&(this.applyComposition(this.composing),this.composing.handled=!0,this.div.blur(),this.div.focus())},applyComposition:function(e){this.cm.isReadOnly()?dn(this.cm,pn)(this.cm):e.data&&e.data!=e.startData&&dn(this.cm,Ho)(this.cm,e.data,0,e.sel)},setUneditable:function(e){e.contentEditable="false"},onKeyPress:function(e){e.preventDefault(),this.cm.isReadOnly()||dn(this.cm,Ho)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0)},readOnlyChanged:function(e){this.div.contentEditable=String("nocursor"!=e)},onContextMenu:v,resetPosition:v,needsContentAttribute:!0},Vo.prototype),Qo.prototype=s({init:function(e){function t(e){if(!Ne(i,e)){if(i.somethingSelected())Do({lineWise:!1,text:i.getSelections()}),n.inaccurateSelection&&(n.prevInput="",n.inaccurateSelection=!1,a.value=Ml.text.join("\n"),La(a));else{if(!i.options.lineWiseCopyCut)return;var t=jo(i);Do({lineWise:!0,text:t.text}),"cut"==e.type?i.setSelections(t.ranges,null,Oa):(n.prevInput="",a.value=t.text.join("\n"),La(a))}"cut"==e.type&&(i.state.cutIncoming=!0)}}var r=this,n=this,i=this.cm,o=this.wrapper=Bo(),a=this.textarea=o.firstChild;e.wrapper.insertBefore(o,e.wrapper.firstChild),ga&&(a.style.width="0px"),Ra(a,"input",function(){aa&&la>=9&&r.hasSelection&&(r.hasSelection=null),n.poll()}),Ra(a,"paste",function(e){Ne(i,e)||Io(e,i)||(i.state.pasteIncoming=!0,n.fastPoll())}),Ra(a,"cut",t),Ra(a,"copy",t),Ra(e.scroller,"paste",function(t){It(e,t)||Ne(i,t)||(i.state.pasteIncoming=!0,n.focus())}),Ra(e.lineSpace,"selectstart",function(t){It(e,t)||ze(t)}),Ra(a,"compositionstart",function(){var e=i.getCursor("from");n.composing&&n.composing.range.clear(),n.composing={start:e,range:i.markText(e,i.getCursor("to"),{className:"CodeMirror-composing"})}}),Ra(a,"compositionend",function(){n.composing&&(n.poll(),n.composing.range.clear(),n.composing=null)})},prepareSelection:function(){var e=this.cm,t=e.display,r=e.doc,n=Sr(e);if(e.options.moveInputWithCursor){var i=ur(e,r.sel.primary().head,"div"),o=t.wrapper.getBoundingClientRect(),a=t.lineDiv.getBoundingClientRect();n.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,i.top+a.top-o.top)),n.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,i.left+a.left-o.left))}return n},showSelection:function(e){var t=this.cm,n=t.display;r(n.cursorDiv,e.cursors),r(n.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},reset:function(e){if(!this.contextMenuPending){var t,r,n=this.cm,i=n.doc;if(n.somethingSelected()){this.prevInput="";var o=i.sel.primary();t=Va&&(o.to().line-o.from().line>100||(r=n.getSelection()).length>1e3);var a=t?"-":r||n.getSelection();this.textarea.value=a,n.state.focused&&La(this.textarea),aa&&la>=9&&(this.hasSelection=a)}else e||(this.prevInput=this.textarea.value="",aa&&la>=9&&(this.hasSelection=null));this.inaccurateSelection=t}},getField:function(){return this.textarea},supportsTouch:function(){return!1},focus:function(){if("nocursor"!=this.cm.options.readOnly&&(!ma||Ta()!=this.textarea))try{this.textarea.focus()}catch(e){}},blur:function(){this.textarea.blur()},resetPosition:function(){this.wrapper.style.top=this.wrapper.style.left=0},receivedFocus:function(){this.slowPoll()},slowPoll:function(){var e=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},fastPoll:function(){function e(){var n=r.poll();n||t?(r.pollingFast=!1,r.slowPoll()):(t=!0,r.polling.set(60,e))}var t=!1,r=this;r.pollingFast=!0,r.polling.set(20,e)},poll:function(){var e=this,t=this.cm,r=this.textarea,n=this.prevInput;if(this.contextMenuPending||!t.state.focused||Ua(r)&&!n&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;var i=r.value;if(i==n&&!t.somethingSelected())return!1;if(aa&&la>=9&&this.hasSelection===i||va&&/[\uf700-\uf7ff]/.test(i))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var o=i.charCodeAt(0);if(8203!=o||n||(n="​"),8666==o)return this.reset(),this.cm.execCommand("undo")}for(var a=0,l=Math.min(n.length,i.length);a<l&&n.charCodeAt(a)==i.charCodeAt(a);)++a;return un(t,function(){Ho(t,i.slice(a),n.length-a,null,e.composing?"*compose":null),i.length>1e3||i.indexOf("\n")>-1?r.value=e.prevInput="":e.prevInput=i,e.composing&&(e.composing.range.clear(),e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},ensurePolled:function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},onKeyPress:function(){aa&&la>=9&&(this.hasSelection=null),this.fastPoll()},onContextMenu:function(e){function t(){if(null!=a.selectionStart){var e=i.somethingSelected(),t="​"+(e?a.value:"");a.value="⇚",a.value=t,n.prevInput=e?"":"​",a.selectionStart=1,a.selectionEnd=t.length,o.selForContextMenu=i.doc.sel}}function r(){if(n.contextMenuPending=!1,n.wrapper.style.cssText=d,a.style.cssText=u,aa&&la<9&&o.scrollbars.setScrollTop(o.scroller.scrollTop=s),null!=a.selectionStart){(!aa||aa&&la<9)&&t();var e=0,r=function(){o.selForContextMenu==i.doc.sel&&0==a.selectionStart&&a.selectionEnd>0&&"​"==n.prevInput?dn(i,xi)(i):e++<10?o.detectingSelectAll=setTimeout(r,500):o.input.reset();
7
- };o.detectingSelectAll=setTimeout(r,200)}}var n=this,i=n.cm,o=i.display,a=n.textarea,l=xr(i,e),s=o.scroller.scrollTop;if(l&&!da){var c=i.options.resetSelectionOnContextMenu;c&&i.doc.sel.contains(l)==-1&&dn(i,hi)(i.doc,Pn(l),Oa);var u=a.style.cssText,d=n.wrapper.style.cssText;n.wrapper.style.cssText="position: absolute";var f=n.wrapper.getBoundingClientRect();a.style.cssText="position: absolute; width: 30px; height: 30px;\n top: "+(e.clientY-f.top-5)+"px; left: "+(e.clientX-f.left-5)+"px;\n z-index: 1000; background: "+(aa?"rgba(255, 255, 255, .05)":"transparent")+";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";var h;if(sa&&(h=window.scrollY),o.input.focus(),sa&&window.scrollTo(null,h),o.input.reset(),i.somethingSelected()||(a.value=n.prevInput=" "),n.contextMenuPending=!0,o.selForContextMenu=i.doc.sel,clearTimeout(o.detectingSelectAll),aa&&la>=9&&t(),Ca){He(e);var p=function(){_e(window,"mouseup",p),setTimeout(r,20)};Ra(window,"mouseup",p)}else setTimeout(r,50)}},readOnlyChanged:function(e){e||this.reset()},setUneditable:v,needsContentAttribute:!1},Qo.prototype),Ao(Eo),qo(Eo);var _l="iter insert remove copy getEditor constructor".split(" ");for(var Al in ul.prototype)ul.prototype.hasOwnProperty(Al)&&d(_l,Al)<0&&(Eo.prototype[Al]=function(e){return function(){return e.apply(this.doc,arguments)}}(ul.prototype[Al]));return Ee(ul),Eo.inputStyles={textarea:Qo,contenteditable:Vo},Eo.defineMode=function(e){Eo.defaults.mode||"null"==e||(Eo.defaults.mode=e),qe.apply(this,arguments)},Eo.defineMIME=Ke,Eo.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),Eo.defineMIME("text/plain","null"),Eo.defineExtension=function(e,t){Eo.prototype[e]=t},Eo.defineDocExtension=function(e,t){ul.prototype[e]=t},Eo.fromTextArea=Jo,ea(Eo),Eo.version="5.20.2",Eo})},{}],18:[function(e,r,n){!function(i){"object"==typeof n&&"object"==typeof r?i(e("../../lib/codemirror")):"function"==typeof t&&t.amd?t(["../../lib/codemirror"],i):i(CodeMirror)}(function(e){"use strict";function t(e){for(var t={},r=0;r<e.length;++r)t[e[r].toLowerCase()]=!0;return t}function r(e,t){for(var r,n=!1;null!=(r=e.next());){if(n&&"/"==r){t.tokenize=null;break}n="*"==r}return["comment","comment"]}e.defineMode("css",function(t,r){function n(e,t){return p=t,e}function i(e,t){var r=e.next();if(v[r]){var i=v[r](e,t);if(i!==!1)return i}return"@"==r?(e.eatWhile(/[\w\\\-]/),n("def",e.current())):"="==r||("~"==r||"|"==r)&&e.eat("=")?n(null,"compare"):'"'==r||"'"==r?(t.tokenize=o(r),t.tokenize(e,t)):"#"==r?(e.eatWhile(/[\w\\\-]/),n("atom","hash")):"!"==r?(e.match(/^\s*\w*/),n("keyword","important")):/\d/.test(r)||"."==r&&e.eat(/\d/)?(e.eatWhile(/[\w.%]/),n("number","unit")):"-"!==r?/[,+>*\/]/.test(r)?n(null,"select-op"):"."==r&&e.match(/^-?[_a-z][_a-z0-9-]*/i)?n("qualifier","qualifier"):/[:;{}\[\]\(\)]/.test(r)?n(null,r):"u"==r&&e.match(/rl(-prefix)?\(/)||"d"==r&&e.match("omain(")||"r"==r&&e.match("egexp(")?(e.backUp(1),t.tokenize=a,n("property","word")):/[\w\\\-]/.test(r)?(e.eatWhile(/[\w\\\-]/),n("property","word")):n(null,null):/[\d.]/.test(e.peek())?(e.eatWhile(/[\w.%]/),n("number","unit")):e.match(/^-[\w\\\-]+/)?(e.eatWhile(/[\w\\\-]/),e.match(/^\s*:/,!1)?n("variable-2","variable-definition"):n("variable-2","variable")):e.match(/^\w+-/)?n("meta","meta"):void 0}function o(e){return function(t,r){for(var i,o=!1;null!=(i=t.next());){if(i==e&&!o){")"==e&&t.backUp(1);break}o=!o&&"\\"==i}return(i==e||!o&&")"!=e)&&(r.tokenize=null),n("string","string")}}function a(e,t){return e.next(),e.match(/\s*[\"\')]/,!1)?t.tokenize=null:t.tokenize=o(")"),n(null,"(")}function l(e,t,r){this.type=e,this.indent=t,this.prev=r}function s(e,t,r,n){return e.context=new l(r,t.indentation()+(n===!1?0:m),e.context),r}function c(e){return e.context.prev&&(e.context=e.context.prev),e.context.type}function u(e,t,r){return N[r.context.type](e,t,r)}function d(e,t,r,n){for(var i=n||1;i>0;i--)r.context=r.context.prev;return u(e,t,r)}function f(e){var t=e.current().toLowerCase();g=M.hasOwnProperty(t)?"atom":L.hasOwnProperty(t)?"keyword":"variable"}var h=r.inline;r.propertyKeywords||(r=e.resolveMode("text/css"));var p,g,m=t.indentUnit,v=r.tokenHooks,y=r.documentTypes||{},b=r.mediaTypes||{},w=r.mediaFeatures||{},x=r.mediaValueKeywords||{},k=r.propertyKeywords||{},C=r.nonStandardPropertyKeywords||{},S=r.fontProperties||{},T=r.counterDescriptors||{},L=r.colorKeywords||{},M=r.valueKeywords||{},_=r.allowNested,A=r.supportsAtComponent===!0,N={};return N.top=function(e,t,r){if("{"==e)return s(r,t,"block");if("}"==e&&r.context.prev)return c(r);if(A&&/@component/.test(e))return s(r,t,"atComponentBlock");if(/^@(-moz-)?document$/.test(e))return s(r,t,"documentTypes");if(/^@(media|supports|(-moz-)?document|import)$/.test(e))return s(r,t,"atBlock");if(/^@(font-face|counter-style)/.test(e))return r.stateArg=e,"restricted_atBlock_before";if(/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(e))return"keyframes";if(e&&"@"==e.charAt(0))return s(r,t,"at");if("hash"==e)g="builtin";else if("word"==e)g="tag";else{if("variable-definition"==e)return"maybeprop";if("interpolation"==e)return s(r,t,"interpolation");if(":"==e)return"pseudo";if(_&&"("==e)return s(r,t,"parens")}return r.context.type},N.block=function(e,t,r){if("word"==e){var n=t.current().toLowerCase();return k.hasOwnProperty(n)?(g="property","maybeprop"):C.hasOwnProperty(n)?(g="string-2","maybeprop"):_?(g=t.match(/^\s*:(?:\s|$)/,!1)?"property":"tag","block"):(g+=" error","maybeprop")}return"meta"==e?"block":_||"hash"!=e&&"qualifier"!=e?N.top(e,t,r):(g="error","block")},N.maybeprop=function(e,t,r){return":"==e?s(r,t,"prop"):u(e,t,r)},N.prop=function(e,t,r){if(";"==e)return c(r);if("{"==e&&_)return s(r,t,"propBlock");if("}"==e||"{"==e)return d(e,t,r);if("("==e)return s(r,t,"parens");if("hash"!=e||/^#([0-9a-fA-f]{3,4}|[0-9a-fA-f]{6}|[0-9a-fA-f]{8})$/.test(t.current())){if("word"==e)f(t);else if("interpolation"==e)return s(r,t,"interpolation")}else g+=" error";return"prop"},N.propBlock=function(e,t,r){return"}"==e?c(r):"word"==e?(g="property","maybeprop"):r.context.type},N.parens=function(e,t,r){return"{"==e||"}"==e?d(e,t,r):")"==e?c(r):"("==e?s(r,t,"parens"):"interpolation"==e?s(r,t,"interpolation"):("word"==e&&f(t),"parens")},N.pseudo=function(e,t,r){return"word"==e?(g="variable-3",r.context.type):u(e,t,r)},N.documentTypes=function(e,t,r){return"word"==e&&y.hasOwnProperty(t.current())?(g="tag",r.context.type):N.atBlock(e,t,r)},N.atBlock=function(e,t,r){if("("==e)return s(r,t,"atBlock_parens");if("}"==e||";"==e)return d(e,t,r);if("{"==e)return c(r)&&s(r,t,_?"block":"top");if("interpolation"==e)return s(r,t,"interpolation");if("word"==e){var n=t.current().toLowerCase();g="only"==n||"not"==n||"and"==n||"or"==n?"keyword":b.hasOwnProperty(n)?"attribute":w.hasOwnProperty(n)?"property":x.hasOwnProperty(n)?"keyword":k.hasOwnProperty(n)?"property":C.hasOwnProperty(n)?"string-2":M.hasOwnProperty(n)?"atom":L.hasOwnProperty(n)?"keyword":"error"}return r.context.type},N.atComponentBlock=function(e,t,r){return"}"==e?d(e,t,r):"{"==e?c(r)&&s(r,t,_?"block":"top",!1):("word"==e&&(g="error"),r.context.type)},N.atBlock_parens=function(e,t,r){return")"==e?c(r):"{"==e||"}"==e?d(e,t,r,2):N.atBlock(e,t,r)},N.restricted_atBlock_before=function(e,t,r){return"{"==e?s(r,t,"restricted_atBlock"):"word"==e&&"@counter-style"==r.stateArg?(g="variable","restricted_atBlock_before"):u(e,t,r)},N.restricted_atBlock=function(e,t,r){return"}"==e?(r.stateArg=null,c(r)):"word"==e?(g="@font-face"==r.stateArg&&!S.hasOwnProperty(t.current().toLowerCase())||"@counter-style"==r.stateArg&&!T.hasOwnProperty(t.current().toLowerCase())?"error":"property","maybeprop"):"restricted_atBlock"},N.keyframes=function(e,t,r){return"word"==e?(g="variable","keyframes"):"{"==e?s(r,t,"top"):u(e,t,r)},N.at=function(e,t,r){return";"==e?c(r):"{"==e||"}"==e?d(e,t,r):("word"==e?g="tag":"hash"==e&&(g="builtin"),"at")},N.interpolation=function(e,t,r){return"}"==e?c(r):"{"==e||";"==e?d(e,t,r):("word"==e?g="variable":"variable"!=e&&"("!=e&&")"!=e&&(g="error"),"interpolation")},{startState:function(e){return{tokenize:null,state:h?"block":"top",stateArg:null,context:new l(h?"block":"top",e||0,null)}},token:function(e,t){if(!t.tokenize&&e.eatSpace())return null;var r=(t.tokenize||i)(e,t);return r&&"object"==typeof r&&(p=r[1],r=r[0]),g=r,t.state=N[t.state](p,e,t),g},indent:function(e,t){var r=e.context,n=t&&t.charAt(0),i=r.indent;return"prop"!=r.type||"}"!=n&&")"!=n||(r=r.prev),r.prev&&("}"!=n||"block"!=r.type&&"top"!=r.type&&"interpolation"!=r.type&&"restricted_atBlock"!=r.type?(")"!=n||"parens"!=r.type&&"atBlock_parens"!=r.type)&&("{"!=n||"at"!=r.type&&"atBlock"!=r.type)||(i=Math.max(0,r.indent-m),r=r.prev):(r=r.prev,i=r.indent)),i},electricChars:"}",blockCommentStart:"/*",blockCommentEnd:"*/",fold:"brace"}});var n=["domain","regexp","url","url-prefix"],i=t(n),o=["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"],a=t(o),l=["width","min-width","max-width","height","min-height","max-height","device-width","min-device-width","max-device-width","device-height","min-device-height","max-device-height","aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio","color","min-color","max-color","color-index","min-color-index","max-color-index","monochrome","min-monochrome","max-monochrome","resolution","min-resolution","max-resolution","scan","grid","orientation","device-pixel-ratio","min-device-pixel-ratio","max-device-pixel-ratio","pointer","any-pointer","hover","any-hover"],s=t(l),c=["landscape","portrait","none","coarse","fine","on-demand","hover","interlace","progressive"],u=t(c),d=["align-content","align-items","align-self","alignment-adjust","alignment-baseline","anchor-point","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","azimuth","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","baseline-shift","binding","bleed","bookmark-label","bookmark-level","bookmark-state","bookmark-target","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","clear","clip","color","color-profile","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","content","counter-increment","counter-reset","crop","cue","cue-after","cue-before","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit","fit-position","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-offset","flow-from","flow-into","font","font-feature-settings","font-family","font-kerning","font-language-override","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-weight","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-gap","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-gap","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","inline-box-align","justify-content","left","letter-spacing","line-break","line-height","line-stacking","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marker-offset","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","max-height","max-width","min-height","min-width","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","object-fit","object-position","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-style","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","page-policy","pause","pause-after","pause-before","perspective","perspective-origin","pitch","pitch-range","play-during","position","presentation-level","punctuation-trim","quotes","region-break-after","region-break-before","region-break-inside","region-fragment","rendering-intent","resize","rest","rest-after","rest-before","richness","right","rotation","rotation-point","ruby-align","ruby-overhang","ruby-position","ruby-span","shape-image-threshold","shape-inside","shape-margin","shape-outside","size","speak","speak-as","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","string-set","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-height","text-indent","text-justify","text-outline","text-overflow","text-shadow","text-size-adjust","text-space-collapse","text-transform","text-underline-position","text-wrap","top","transform","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","volume","white-space","widows","width","word-break","word-spacing","word-wrap","z-index","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","text-anchor","writing-mode"],f=t(d),h=["scrollbar-arrow-color","scrollbar-base-color","scrollbar-dark-shadow-color","scrollbar-face-color","scrollbar-highlight-color","scrollbar-shadow-color","scrollbar-3d-light-color","scrollbar-track-color","shape-inside","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","zoom"],p=t(h),g=["font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"],m=t(g),v=["additive-symbols","fallback","negative","pad","prefix","range","speak-as","suffix","symbols","system"],y=t(v),b=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"],w=t(b),x=["above","absolute","activeborder","additive","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","attr","auto","avoid","avoid-column","avoid-page","avoid-region","background","backwards","baseline","below","bidi-override","binary","bengali","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","cambodian","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","clear","clip","close-quote","col-resize","collapse","color","color-burn","color-dodge","column","column-reverse","compact","condensed","contain","content","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","darken","dashed","decimal","decimal-leading-zero","default","default-button","dense","destination-atop","destination-in","destination-out","destination-over","devanagari","difference","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic","ethiopic-abegede","ethiopic-abegede-am-et","ethiopic-abegede-gez","ethiopic-abegede-ti-er","ethiopic-abegede-ti-et","ethiopic-halehame-aa-er","ethiopic-halehame-aa-et","ethiopic-halehame-am-et","ethiopic-halehame-gez","ethiopic-halehame-om-et","ethiopic-halehame-sid-et","ethiopic-halehame-so-et","ethiopic-halehame-ti-er","ethiopic-halehame-ti-et","ethiopic-halehame-tig","ethiopic-numeric","ew-resize","exclusion","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","georgian","graytext","grid","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hard-light","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","hue","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-grid","inline-table","inset","inside","intrinsic","invert","italic","japanese-formal","japanese-informal","justify","kannada","katakana","katakana-iroha","keep-all","khmer","korean-hangul-formal","korean-hanja-formal","korean-hanja-informal","landscape","lao","large","larger","left","level","lighter","lighten","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-alpha","lower-armenian","lower-greek","lower-hexadecimal","lower-latin","lower-norwegian","lower-roman","lowercase","ltr","luminosity","malayalam","match","matrix","matrix3d","media-controls-background","media-current-time-display","media-fullscreen-button","media-mute-button","media-play-button","media-return-to-realtime-button","media-rewind-button","media-seek-back-button","media-seek-forward-button","media-slider","media-sliderthumb","media-time-remaining-display","media-volume-slider","media-volume-slider-container","media-volume-sliderthumb","medium","menu","menulist","menulist-button","menulist-text","menulist-textfield","menutext","message-box","middle","min-intrinsic","mix","mongolian","monospace","move","multiple","multiply","myanmar","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","octal","open-quote","optimizeLegibility","optimizeSpeed","oriya","oromo","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","persian","perspective","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row","row-resize","row-reverse","rtl","run-in","running","s-resize","sans-serif","saturation","scale","scale3d","scaleX","scaleY","scaleZ","screen","scroll","scrollbar","se-resize","searchfield","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","semi-condensed","semi-expanded","separate","serif","show","sidama","simp-chinese-formal","simp-chinese-informal","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","soft-light","solid","somali","source-atop","source-in","source-out","source-over","space","space-around","space-between","spell-out","square","square-button","start","static","status-bar","stretch","stroke","sub","subpixel-antialiased","super","sw-resize","symbolic","symbols","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","tamil","telugu","text","text-bottom","text-top","textarea","textfield","thai","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","tibetan","tigre","tigrinya-er","tigrinya-er-abegede","tigrinya-et","tigrinya-et-abegede","to","top","trad-chinese-formal","trad-chinese-informal","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","var","vertical","vertical-text","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","wrap","wrap-reverse","x-large","x-small","xor","xx-large","xx-small"],k=t(x),C=n.concat(o).concat(l).concat(c).concat(d).concat(h).concat(b).concat(x);e.registerHelper("hintWords","css",C),e.defineMIME("text/css",{documentTypes:i,mediaTypes:a,mediaFeatures:s,mediaValueKeywords:u,propertyKeywords:f,nonStandardPropertyKeywords:p,fontProperties:m,counterDescriptors:y,colorKeywords:w,valueKeywords:k,tokenHooks:{"/":function(e,t){return!!e.eat("*")&&(t.tokenize=r,r(e,t))}},name:"css"}),e.defineMIME("text/x-scss",{mediaTypes:a,mediaFeatures:s,mediaValueKeywords:u,propertyKeywords:f,nonStandardPropertyKeywords:p,colorKeywords:w,valueKeywords:k,fontProperties:m,allowNested:!0,tokenHooks:{"/":function(e,t){return e.eat("/")?(e.skipToEnd(),["comment","comment"]):e.eat("*")?(t.tokenize=r,r(e,t)):["operator","operator"]},":":function(e){return!!e.match(/\s*\{/)&&[null,"{"]},$:function(e){return e.match(/^[\w-]+/),e.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"]},"#":function(e){return!!e.eat("{")&&[null,"interpolation"]}},name:"css",helperType:"scss"}),e.defineMIME("text/x-less",{mediaTypes:a,mediaFeatures:s,mediaValueKeywords:u,propertyKeywords:f,nonStandardPropertyKeywords:p,colorKeywords:w,valueKeywords:k,fontProperties:m,allowNested:!0,tokenHooks:{"/":function(e,t){return e.eat("/")?(e.skipToEnd(),["comment","comment"]):e.eat("*")?(t.tokenize=r,r(e,t)):["operator","operator"]},"@":function(e){return e.eat("{")?[null,"interpolation"]:!e.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/,!1)&&(e.eatWhile(/[\w\\\-]/),e.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"])},"&":function(){return["atom","atom"]}},name:"css",helperType:"less"}),e.defineMIME("text/x-gss",{documentTypes:i,mediaTypes:a,mediaFeatures:s,propertyKeywords:f,nonStandardPropertyKeywords:p,fontProperties:m,counterDescriptors:y,colorKeywords:w,valueKeywords:k,supportsAtComponent:!0,tokenHooks:{"/":function(e,t){return!!e.eat("*")&&(t.tokenize=r,r(e,t))}},name:"css",helperType:"gss"})})},{"../../lib/codemirror":17}],19:[function(e,r,n){!function(i){"object"==typeof n&&"object"==typeof r?i(e("../../lib/codemirror"),e("../xml/xml"),e("../javascript/javascript"),e("../css/css")):"function"==typeof t&&t.amd?t(["../../lib/codemirror","../xml/xml","../javascript/javascript","../css/css"],i):i(CodeMirror)}(function(e){"use strict";function t(e,t,r){var n=e.current(),i=n.search(t);return i>-1?e.backUp(n.length-i):n.match(/<\/?$/)&&(e.backUp(n.length),e.match(t,!1)||e.match(n)),r}function r(e){var t=s[e];return t?t:s[e]=new RegExp("\\s+"+e+"\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*")}function n(e,t){var n=e.match(r(t));return n?/^\s*(.*?)\s*$/.exec(n[2])[1]:""}function i(e,t){return new RegExp((t?"^":"")+"</s*"+e+"s*>","i")}function o(e,t){for(var r in e)for(var n=t[r]||(t[r]=[]),i=e[r],o=i.length-1;o>=0;o--)n.unshift(i[o])}function a(e,t){for(var r=0;r<e.length;r++){var i=e[r];if(!i[0]||i[1].test(n(t,i[0])))return i[2]}}var l={script:[["lang",/(javascript|babel)/i,"javascript"],["type",/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^$/i,"javascript"],["type",/./,"text/plain"],[null,null,"javascript"]],style:[["lang",/^css$/i,"css"],["type",/^(text\/)?(x-)?(stylesheet|css)$/i,"css"],["type",/./,"text/plain"],[null,null,"css"]]},s={};e.defineMode("htmlmixed",function(r,n){function s(n,o){var l,d=c.token(n,o.htmlState),f=/\btag\b/.test(d);if(f&&!/[<>\s\/]/.test(n.current())&&(l=o.htmlState.tagName&&o.htmlState.tagName.toLowerCase())&&u.hasOwnProperty(l))o.inTag=l+" ";else if(o.inTag&&f&&/>$/.test(n.current())){var h=/^([\S]+) (.*)/.exec(o.inTag);o.inTag=null;var p=">"==n.current()&&a(u[h[1]],h[2]),g=e.getMode(r,p),m=i(h[1],!0),v=i(h[1],!1);o.token=function(e,r){return e.match(m,!1)?(r.token=s,r.localState=r.localMode=null,null):t(e,v,r.localMode.token(e,r.localState))},o.localMode=g,o.localState=e.startState(g,c.indent(o.htmlState,""))}else o.inTag&&(o.inTag+=n.current(),n.eol()&&(o.inTag+=" "));return d}var c=e.getMode(r,{name:"xml",htmlMode:!0,multilineTagIndentFactor:n.multilineTagIndentFactor,multilineTagIndentPastTag:n.multilineTagIndentPastTag}),u={},d=n&&n.tags,f=n&&n.scriptTypes;if(o(l,u),d&&o(d,u),f)for(var h=f.length-1;h>=0;h--)u.script.unshift(["type",f[h].matches,f[h].mode]);return{startState:function(){var t=e.startState(c);return{token:s,inTag:null,localMode:null,localState:null,htmlState:t}},copyState:function(t){var r;return t.localState&&(r=e.copyState(t.localMode,t.localState)),{token:t.token,inTag:t.inTag,localMode:t.localMode,localState:r,htmlState:e.copyState(c,t.htmlState)}},token:function(e,t){return t.token(e,t)},indent:function(t,r){return!t.localMode||/^\s*<\//.test(r)?c.indent(t.htmlState,r):t.localMode.indent?t.localMode.indent(t.localState,r):e.Pass},innerMode:function(e){return{state:e.localState||e.htmlState,mode:e.localMode||c}}}},"xml","javascript","css"),e.defineMIME("text/html","htmlmixed")})},{"../../lib/codemirror":17,"../css/css":18,"../javascript/javascript":20,"../xml/xml":21}],20:[function(e,r,n){!function(i){"object"==typeof n&&"object"==typeof r?i(e("../../lib/codemirror")):"function"==typeof t&&t.amd?t(["../../lib/codemirror"],i):i(CodeMirror)}(function(e){"use strict";function t(e,t,r){return/^(?:operator|sof|keyword c|case|new|[\[{}\(,;:]|=>)$/.test(t.lastType)||"quasi"==t.lastType&&/\{\s*$/.test(e.string.slice(0,e.pos-(r||0)))}e.defineMode("javascript",function(r,n){function i(e){for(var t,r=!1,n=!1;null!=(t=e.next());){if(!r){if("/"==t&&!n)return;"["==t?n=!0:n&&"]"==t&&(n=!1)}r=!r&&"\\"==t}}function o(e,t,r){return Ce=e,Se=r,t}function a(e,r){var n=e.next();if('"'==n||"'"==n)return r.tokenize=l(n),r.tokenize(e,r);if("."==n&&e.match(/^\d+(?:[eE][+\-]?\d+)?/))return o("number","number");if("."==n&&e.match(".."))return o("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(n))return o(n);if("="==n&&e.eat(">"))return o("=>","operator");if("0"==n&&e.eat(/x/i))return e.eatWhile(/[\da-f]/i),o("number","number");if("0"==n&&e.eat(/o/i))return e.eatWhile(/[0-7]/i),o("number","number");if("0"==n&&e.eat(/b/i))return e.eatWhile(/[01]/i),o("number","number");if(/\d/.test(n))return e.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/),o("number","number");if("/"==n)return e.eat("*")?(r.tokenize=s,s(e,r)):e.eat("/")?(e.skipToEnd(),o("comment","comment")):t(e,r,1)?(i(e),e.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/),o("regexp","string-2")):(e.eatWhile(We),o("operator","operator",e.current()));if("`"==n)return r.tokenize=c,c(e,r);if("#"==n)return e.skipToEnd(),o("error","error");if(We.test(n))return e.eatWhile(We),o("operator","operator",e.current());if(Ne.test(n)){e.eatWhile(Ne);var a=e.current(),u=Oe.propertyIsEnumerable(a)&&Oe[a];return u&&"."!=r.lastType?o(u.type,u.style,a):o("variable","variable",a)}}function l(e){return function(t,r){var n,i=!1;if(Me&&"@"==t.peek()&&t.match(Ee))return r.tokenize=a,o("jsonld-keyword","meta");for(;null!=(n=t.next())&&(n!=e||i);)i=!i&&"\\"==n;return i||(r.tokenize=a),o("string","string")}}function s(e,t){for(var r,n=!1;r=e.next();){if("/"==r&&n){t.tokenize=a;break}n="*"==r}return o("comment","comment")}function c(e,t){for(var r,n=!1;null!=(r=e.next());){if(!n&&("`"==r||"$"==r&&e.eat("{"))){t.tokenize=a;break}n=!n&&"\\"==r}return o("quasi","string-2",e.current())}function u(e,t){t.fatArrowAt&&(t.fatArrowAt=null);var r=e.string.indexOf("=>",e.start);if(!(r<0)){if(Ae){var n=/:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(e.string.slice(e.start,r));n&&(r=n.index)}for(var i=0,o=!1,a=r-1;a>=0;--a){var l=e.string.charAt(a),s=ze.indexOf(l);if(s>=0&&s<3){if(!i){++a;break}if(0==--i){"("==l&&(o=!0);break}}else if(s>=3&&s<6)++i;else if(Ne.test(l))o=!0;else{if(/["'\/]/.test(l))return;if(o&&!i){++a;break}}}o&&!i&&(t.fatArrowAt=a)}}function d(e,t,r,n,i,o){
8
- this.indented=e,this.column=t,this.type=r,this.prev=i,this.info=o,null!=n&&(this.align=n)}function f(e,t){for(var r=e.localVars;r;r=r.next)if(r.name==t)return!0;for(var n=e.context;n;n=n.prev)for(var r=n.vars;r;r=r.next)if(r.name==t)return!0}function h(e,t,r,n,i){var o=e.cc;for(De.state=e,De.stream=i,De.marked=null,De.cc=o,De.style=t,e.lexical.hasOwnProperty("align")||(e.lexical.align=!0);;){var a=o.length?o.pop():_e?C:k;if(a(r,n)){for(;o.length&&o[o.length-1].lex;)o.pop()();return De.marked?De.marked:"variable"==r&&f(e,n)?"variable-2":t}}}function p(){for(var e=arguments.length-1;e>=0;e--)De.cc.push(arguments[e])}function g(){return p.apply(null,arguments),!0}function m(e){function t(t){for(var r=t;r;r=r.next)if(r.name==e)return!0;return!1}var r=De.state;if(De.marked="def",r.context){if(t(r.localVars))return;r.localVars={name:e,next:r.localVars}}else{if(t(r.globalVars))return;n.globalVars&&(r.globalVars={name:e,next:r.globalVars})}}function v(){De.state.context={prev:De.state.context,vars:De.state.localVars},De.state.localVars=He}function y(){De.state.localVars=De.state.context.vars,De.state.context=De.state.context.prev}function b(e,t){var r=function(){var r=De.state,n=r.indented;if("stat"==r.lexical.type)n=r.lexical.indented;else for(var i=r.lexical;i&&")"==i.type&&i.align;i=i.prev)n=i.indented;r.lexical=new d(n,De.stream.column(),e,null,r.lexical,t)};return r.lex=!0,r}function w(){var e=De.state;e.lexical.prev&&(")"==e.lexical.type&&(e.indented=e.lexical.indented),e.lexical=e.lexical.prev)}function x(e){function t(r){return r==e?g():";"==e?p():g(t)}return t}function k(e,t){return"var"==e?g(b("vardef",t.length),Q,x(";"),w):"keyword a"==e?g(b("form"),T,k,w):"keyword b"==e?g(b("form"),k,w):"{"==e?g(b("}"),U,w):";"==e?g():"if"==e?("else"==De.state.lexical.info&&De.state.cc[De.state.cc.length-1]==w&&De.state.cc.pop()(),g(b("form"),T,k,w,ne)):"function"==e?g(ce):"for"==e?g(b("form"),ie,k,w):"variable"==e?g(b("stat"),I):"switch"==e?g(b("form"),T,b("}","switch"),x("{"),U,w,w):"case"==e?g(C,x(":")):"default"==e?g(x(":")):"catch"==e?g(b("form"),v,x("("),ue,x(")"),k,w,y):"class"==e?g(b("form"),fe,w):"export"==e?g(b("stat"),me,w):"import"==e?g(b("stat"),ve,w):"module"==e?g(b("form"),J,b("}"),x("{"),U,w,w):"type"==e?g(G,x("operator"),G,x(";")):"async"==e?g(k):p(b("stat"),C,x(";"),w)}function C(e){return L(e,!1)}function S(e){return L(e,!0)}function T(e){return"("!=e?p():g(b(")"),C,x(")"),w)}function L(e,t){if(De.state.fatArrowAt==De.stream.start){var r=t?z:E;if("("==e)return g(v,b(")"),q(J,")"),w,x("=>"),r,y);if("variable"==e)return p(v,J,x("=>"),r,y)}var n=t?N:A;return Pe.hasOwnProperty(e)?g(n):"function"==e?g(ce,n):"class"==e?g(b("form"),de,w):"keyword c"==e||"async"==e?g(t?_:M):"("==e?g(b(")"),M,x(")"),w,n):"operator"==e||"spread"==e?g(t?S:C):"["==e?g(b("]"),xe,w,n):"{"==e?K(j,"}",null,n):"quasi"==e?p(O,n):"new"==e?g(P(t)):g()}function M(e){return e.match(/[;\}\)\],]/)?p():p(C)}function _(e){return e.match(/[;\}\)\],]/)?p():p(S)}function A(e,t){return","==e?g(C):N(e,t,!1)}function N(e,t,r){var n=0==r?A:N,i=0==r?C:S;return"=>"==e?g(v,r?z:E,y):"operator"==e?/\+\+|--/.test(t)?g(n):"?"==t?g(C,x(":"),i):g(i):"quasi"==e?p(O,n):";"!=e?"("==e?K(S,")","call",n):"."==e?g(F,n):"["==e?g(b("]"),M,x("]"),w,n):void 0:void 0}function O(e,t){return"quasi"!=e?p():"${"!=t.slice(t.length-2)?g(O):g(C,W)}function W(e){if("}"==e)return De.marked="string-2",De.state.tokenize=c,g(O)}function E(e){return u(De.stream,De.state),p("{"==e?k:C)}function z(e){return u(De.stream,De.state),p("{"==e?k:S)}function P(e){return function(t){return"."==t?g(e?H:D):p(e?S:C)}}function D(e,t){if("target"==t)return De.marked="keyword",g(A)}function H(e,t){if("target"==t)return De.marked="keyword",g(N)}function I(e){return":"==e?g(w,k):p(A,x(";"),w)}function F(e){if("variable"==e)return De.marked="property",g()}function j(e,t){return"async"==e?(De.marked="property",g(j)):"variable"==e||"keyword"==De.style?(De.marked="property",g("get"==t||"set"==t?R:B)):"number"==e||"string"==e?(De.marked=Me?"property":De.style+" property",g(B)):"jsonld-keyword"==e?g(B):"modifier"==e?g(j):"["==e?g(C,x("]"),B):"spread"==e?g(C):":"==e?p(B):void 0}function R(e){return"variable"!=e?p(B):(De.marked="property",g(ce))}function B(e){return":"==e?g(S):"("==e?p(ce):void 0}function q(e,t){function r(n,i){if(","==n){var o=De.state.lexical;return"call"==o.info&&(o.pos=(o.pos||0)+1),g(function(r,n){return r==t||n==t?p():p(e)},r)}return n==t||i==t?g():g(x(t))}return function(n,i){return n==t||i==t?g():p(e,r)}}function K(e,t,r){for(var n=3;n<arguments.length;n++)De.cc.push(arguments[n]);return g(b(t,r),q(e,t),w)}function U(e){return"}"==e?g():p(k,U)}function V(e,t){if(Ae){if(":"==e)return g(G);if("?"==t)return g(V)}}function G(e){return"variable"==e?(De.marked="variable-3",g(Z)):"{"==e?g(q(Y,"}")):"("==e?g(q(X,")"),$):void 0}function $(e){if("=>"==e)return g(G)}function Y(e){return"variable"==e||"keyword"==De.style?(De.marked="property",g(Y)):":"==e?g(G):void 0}function X(e){return"variable"==e?g(X):":"==e?g(G):void 0}function Z(e,t){return"<"==t?g(q(G,">"),Z):"["==e?g(x("]"),Z):void 0}function Q(){return p(J,V,te,re)}function J(e,t){return"modifier"==e?g(J):"variable"==e?(m(t),g()):"spread"==e?g(J):"["==e?K(J,"]"):"{"==e?K(ee,"}"):void 0}function ee(e,t){return"variable"!=e||De.stream.match(/^\s*:/,!1)?("variable"==e&&(De.marked="property"),"spread"==e?g(J):"}"==e?p():g(x(":"),J,te)):(m(t),g(te))}function te(e,t){if("="==t)return g(S)}function re(e){if(","==e)return g(Q)}function ne(e,t){if("keyword b"==e&&"else"==t)return g(b("form","else"),k,w)}function ie(e){if("("==e)return g(b(")"),oe,x(")"),w)}function oe(e){return"var"==e?g(Q,x(";"),le):";"==e?g(le):"variable"==e?g(ae):p(C,x(";"),le)}function ae(e,t){return"in"==t||"of"==t?(De.marked="keyword",g(C)):g(A,le)}function le(e,t){return";"==e?g(se):"in"==t||"of"==t?(De.marked="keyword",g(C)):p(C,x(";"),se)}function se(e){")"!=e&&g(C)}function ce(e,t){return"*"==t?(De.marked="keyword",g(ce)):"variable"==e?(m(t),g(ce)):"("==e?g(v,b(")"),q(ue,")"),w,V,k,y):void 0}function ue(e){return"spread"==e?g(ue):p(J,V,te)}function de(e,t){return"variable"==e?fe(e,t):he(e,t)}function fe(e,t){if("variable"==e)return m(t),g(he)}function he(e,t){return"extends"==t||"implements"==t?g(Ae?G:C,he):"{"==e?g(b("}"),pe,w):void 0}function pe(e,t){return"variable"==e||"keyword"==De.style?("static"==t||"get"==t||"set"==t||Ae&&("public"==t||"private"==t||"protected"==t||"readonly"==t||"abstract"==t))&&De.stream.match(/^\s+[\w$\xa1-\uffff]/,!1)?(De.marked="keyword",g(pe)):(De.marked="property",g(Ae?ge:ce,pe)):"*"==t?(De.marked="keyword",g(pe)):";"==e?g(pe):"}"==e?g():void 0}function ge(e,t){return"?"==t?g(ge):":"==e?g(G,te):p(ce)}function me(e,t){return"*"==t?(De.marked="keyword",g(we,x(";"))):"default"==t?(De.marked="keyword",g(C,x(";"))):p(k)}function ve(e){return"string"==e?g():p(ye,we)}function ye(e,t){return"{"==e?K(ye,"}"):("variable"==e&&m(t),"*"==t&&(De.marked="keyword"),g(be))}function be(e,t){if("as"==t)return De.marked="keyword",g(ye)}function we(e,t){if("from"==t)return De.marked="keyword",g(C)}function xe(e){return"]"==e?g():p(q(S,"]"))}function ke(e,t){return"operator"==e.lastType||","==e.lastType||We.test(t.charAt(0))||/[,.]/.test(t.charAt(0))}var Ce,Se,Te=r.indentUnit,Le=n.statementIndent,Me=n.jsonld,_e=n.json||Me,Ae=n.typescript,Ne=n.wordCharacters||/[\w$\xa1-\uffff]/,Oe=function(){function e(e){return{type:e,style:"keyword"}}var t=e("keyword a"),r=e("keyword b"),n=e("keyword c"),i=e("operator"),o={type:"atom",style:"atom"},a={"if":e("if"),"while":t,"with":t,"else":r,"do":r,"try":r,"finally":r,"return":n,"break":n,"continue":n,"new":e("new"),"delete":n,"throw":n,"debugger":n,"var":e("var"),"const":e("var"),"let":e("var"),"function":e("function"),"catch":e("catch"),"for":e("for"),"switch":e("switch"),"case":e("case"),"default":e("default"),"in":i,"typeof":i,"instanceof":i,"true":o,"false":o,"null":o,undefined:o,NaN:o,Infinity:o,"this":e("this"),"class":e("class"),"super":e("atom"),"yield":n,"export":e("export"),"import":e("import"),"extends":n,await:n,async:e("async")};if(Ae){var l={type:"variable",style:"variable-3"},s={"interface":e("class"),"implements":n,namespace:n,module:e("module"),"enum":e("module"),type:e("type"),"public":e("modifier"),"private":e("modifier"),"protected":e("modifier"),"abstract":e("modifier"),as:i,string:l,number:l,"boolean":l,any:l};for(var c in s)a[c]=s[c]}return a}(),We=/[+\-*&%=<>!?|~^]/,Ee=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/,ze="([{}])",Pe={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,"this":!0,"jsonld-keyword":!0},De={state:null,column:null,marked:null,cc:null},He={name:"this",next:{name:"arguments"}};return w.lex=!0,{startState:function(e){var t={tokenize:a,lastType:"sof",cc:[],lexical:new d((e||0)-Te,0,"block",(!1)),localVars:n.localVars,context:n.localVars&&{vars:n.localVars},indented:e||0};return n.globalVars&&"object"==typeof n.globalVars&&(t.globalVars=n.globalVars),t},token:function(e,t){if(e.sol()&&(t.lexical.hasOwnProperty("align")||(t.lexical.align=!1),t.indented=e.indentation(),u(e,t)),t.tokenize!=s&&e.eatSpace())return null;var r=t.tokenize(e,t);return"comment"==Ce?r:(t.lastType="operator"!=Ce||"++"!=Se&&"--"!=Se?Ce:"incdec",h(t,r,Ce,Se,e))},indent:function(t,r){if(t.tokenize==s)return e.Pass;if(t.tokenize!=a)return 0;var i,o=r&&r.charAt(0),l=t.lexical;if(!/^\s*else\b/.test(r))for(var c=t.cc.length-1;c>=0;--c){var u=t.cc[c];if(u==w)l=l.prev;else if(u!=ne)break}for(;("stat"==l.type||"form"==l.type)&&("}"==o||(i=t.cc[t.cc.length-1])&&(i==A||i==N)&&!/^[,\.=+\-*:?[\(]/.test(r));)l=l.prev;Le&&")"==l.type&&"stat"==l.prev.type&&(l=l.prev);var d=l.type,f=o==d;return"vardef"==d?l.indented+("operator"==t.lastType||","==t.lastType?l.info+1:0):"form"==d&&"{"==o?l.indented:"form"==d?l.indented+Te:"stat"==d?l.indented+(ke(t,r)?Le||Te:0):"switch"!=l.info||f||0==n.doubleIndentSwitch?l.align?l.column+(f?0:1):l.indented+(f?0:Te):l.indented+(/^(?:case|default)\b/.test(r)?Te:2*Te)},electricInput:/^\s*(?:case .*?:|default:|\{|\})$/,blockCommentStart:_e?null:"/*",blockCommentEnd:_e?null:"*/",lineComment:_e?null:"//",fold:"brace",closeBrackets:"()[]{}''\"\"``",helperType:_e?"json":"javascript",jsonldMode:Me,jsonMode:_e,expressionAllowed:t,skipExpression:function(e){var t=e.cc[e.cc.length-1];t!=C&&t!=S||e.cc.pop()}}}),e.registerHelper("wordChars","javascript",/[\w$]/),e.defineMIME("text/javascript","javascript"),e.defineMIME("text/ecmascript","javascript"),e.defineMIME("application/javascript","javascript"),e.defineMIME("application/x-javascript","javascript"),e.defineMIME("application/ecmascript","javascript"),e.defineMIME("application/json",{name:"javascript",json:!0}),e.defineMIME("application/x-json",{name:"javascript",json:!0}),e.defineMIME("application/ld+json",{name:"javascript",jsonld:!0}),e.defineMIME("text/typescript",{name:"javascript",typescript:!0}),e.defineMIME("application/typescript",{name:"javascript",typescript:!0})})},{"../../lib/codemirror":17}],21:[function(e,r,n){!function(i){"object"==typeof n&&"object"==typeof r?i(e("../../lib/codemirror")):"function"==typeof t&&t.amd?t(["../../lib/codemirror"],i):i(CodeMirror)}(function(e){"use strict";var t={autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!0,caseFold:!0},r={autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,caseFold:!1};e.defineMode("xml",function(n,i){function o(e,t){function r(r){return t.tokenize=r,r(e,t)}var n=e.next();if("<"==n)return e.eat("!")?e.eat("[")?e.match("CDATA[")?r(s("atom","]]>")):null:e.match("--")?r(s("comment","-->")):e.match("DOCTYPE",!0,!0)?(e.eatWhile(/[\w\._\-]/),r(c(1))):null:e.eat("?")?(e.eatWhile(/[\w\._\-]/),t.tokenize=s("meta","?>"),"meta"):(L=e.eat("/")?"closeTag":"openTag",t.tokenize=a,"tag bracket");if("&"==n){var i;return i=e.eat("#")?e.eat("x")?e.eatWhile(/[a-fA-F\d]/)&&e.eat(";"):e.eatWhile(/[\d]/)&&e.eat(";"):e.eatWhile(/[\w\.\-:]/)&&e.eat(";"),i?"atom":"error"}return e.eatWhile(/[^&<]/),null}function a(e,t){var r=e.next();if(">"==r||"/"==r&&e.eat(">"))return t.tokenize=o,L=">"==r?"endTag":"selfcloseTag","tag bracket";if("="==r)return L="equals",null;if("<"==r){t.tokenize=o,t.state=h,t.tagName=t.tagStart=null;var n=t.tokenize(e,t);return n?n+" tag error":"tag error"}return/[\'\"]/.test(r)?(t.tokenize=l(r),t.stringStartCol=e.column(),t.tokenize(e,t)):(e.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function l(e){var t=function(t,r){for(;!t.eol();)if(t.next()==e){r.tokenize=a;break}return"string"};return t.isInAttribute=!0,t}function s(e,t){return function(r,n){for(;!r.eol();){if(r.match(t)){n.tokenize=o;break}r.next()}return e}}function c(e){return function(t,r){for(var n;null!=(n=t.next());){if("<"==n)return r.tokenize=c(e+1),r.tokenize(t,r);if(">"==n){if(1==e){r.tokenize=o;break}return r.tokenize=c(e-1),r.tokenize(t,r)}}return"meta"}}function u(e,t,r){this.prev=e.context,this.tagName=t,this.indent=e.indented,this.startOfLine=r,(C.doNotIndent.hasOwnProperty(t)||e.context&&e.context.noIndent)&&(this.noIndent=!0)}function d(e){e.context&&(e.context=e.context.prev)}function f(e,t){for(var r;;){if(!e.context)return;if(r=e.context.tagName,!C.contextGrabbers.hasOwnProperty(r)||!C.contextGrabbers[r].hasOwnProperty(t))return;d(e)}}function h(e,t,r){return"openTag"==e?(r.tagStart=t.column(),p):"closeTag"==e?g:h}function p(e,t,r){return"word"==e?(r.tagName=t.current(),M="tag",y):(M="error",p)}function g(e,t,r){if("word"==e){var n=t.current();return r.context&&r.context.tagName!=n&&C.implicitlyClosed.hasOwnProperty(r.context.tagName)&&d(r),r.context&&r.context.tagName==n||C.matchClosing===!1?(M="tag",m):(M="tag error",v)}return M="error",v}function m(e,t,r){return"endTag"!=e?(M="error",m):(d(r),h)}function v(e,t,r){return M="error",m(e,t,r)}function y(e,t,r){if("word"==e)return M="attribute",b;if("endTag"==e||"selfcloseTag"==e){var n=r.tagName,i=r.tagStart;return r.tagName=r.tagStart=null,"selfcloseTag"==e||C.autoSelfClosers.hasOwnProperty(n)?f(r,n):(f(r,n),r.context=new u(r,n,i==r.indented)),h}return M="error",y}function b(e,t,r){return"equals"==e?w:(C.allowMissing||(M="error"),y(e,t,r))}function w(e,t,r){return"string"==e?x:"word"==e&&C.allowUnquoted?(M="string",y):(M="error",y(e,t,r))}function x(e,t,r){return"string"==e?x:y(e,t,r)}var k=n.indentUnit,C={},S=i.htmlMode?t:r;for(var T in S)C[T]=S[T];for(var T in i)C[T]=i[T];var L,M;return o.isInText=!0,{startState:function(e){var t={tokenize:o,state:h,indented:e||0,tagName:null,tagStart:null,context:null};return null!=e&&(t.baseIndent=e),t},token:function(e,t){if(!t.tagName&&e.sol()&&(t.indented=e.indentation()),e.eatSpace())return null;L=null;var r=t.tokenize(e,t);return(r||L)&&"comment"!=r&&(M=null,t.state=t.state(L||r,e,t),M&&(r="error"==M?r+" error":M)),r},indent:function(t,r,n){var i=t.context;if(t.tokenize.isInAttribute)return t.tagStart==t.indented?t.stringStartCol+1:t.indented+k;if(i&&i.noIndent)return e.Pass;if(t.tokenize!=a&&t.tokenize!=o)return n?n.match(/^(\s*)/)[0].length:0;if(t.tagName)return C.multilineTagIndentPastTag!==!1?t.tagStart+t.tagName.length+2:t.tagStart+k*(C.multilineTagIndentFactor||1);if(C.alignCDATA&&/<!\[CDATA\[/.test(r))return 0;var l=r&&/^<(\/)?([\w_:\.-]*)/.exec(r);if(l&&l[1])for(;i;){if(i.tagName==l[2]){i=i.prev;break}if(!C.implicitlyClosed.hasOwnProperty(i.tagName))break;i=i.prev}else if(l)for(;i;){var s=C.contextGrabbers[i.tagName];if(!s||!s.hasOwnProperty(l[2]))break;i=i.prev}for(;i&&i.prev&&!i.startOfLine;)i=i.prev;return i?i.indent+k:t.baseIndent||0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"<!--",blockCommentEnd:"-->",configuration:C.htmlMode?"html":"xml",helperType:C.htmlMode?"html":"xml",skipAttribute:function(e){e.state==w&&(e.state=y)}}}),e.defineMIME("text/xml","xml"),e.defineMIME("application/xml","xml"),e.mimeModes.hasOwnProperty("text/html")||e.defineMIME("text/html",{name:"xml",htmlMode:!0})})},{"../../lib/codemirror":17}]},{},[11])}();
1
+ !function(){var e=void 0,t=void 0;!function t(r,n,i){function o(l,s){if(!n[l]){if(!r[l]){var c="function"==typeof e&&e;if(!s&&c)return c(l,!0);if(a)return a(l,!0);var u=new Error("Cannot find module '"+l+"'");throw u.code="MODULE_NOT_FOUND",u}var d=n[l]={exports:{}};r[l][0].call(d.exports,function(e){var t=r[l][1][e];return o(t?t:e)},d,d.exports,t,r,n,i)}return n[l].exports}for(var a="function"==typeof e&&e,l=0;l<i.length;l++)o(i[l]);return o}({1:[function(e,t,r){"use strict";var n=function(e,t){var r={};return r.showType=function(r){var n=r.type();return n=n.charAt(0).toUpperCase()+n.slice(1),e("div",[e("label",t.fieldType),e("span",n)])},r.label=function(r){return e("div",[e("label",t.fieldLabel),e("input.widefat",{type:"text",value:r.label(),onchange:e.withAttr("value",r.label),placeholder:r.title()})])},r.value=function(r){var n="hidden"===r.type();return e("div",[e("label",[n?t.value:t.initialValue," ",n?"":e("small",{style:"float: right; font-weight: normal;"},t.optional)]),e("input.widefat",{type:"text",value:r.value(),onchange:e.withAttr("value",r.value)}),n?"":e("p.help",t.valueHelp)])},r.numberMinMax=function(r){return e("div",[e("div.row",[e("div.col.col-3",[e("label",t.min),e("input",{type:"number",onchange:e.withAttr("value",r.min)})]),e("div.col.col-3",[e("label",t.max),e("input",{type:"number",onchange:e.withAttr("value",r.max)})])])])},r.isRequired=function(r){var n={type:"checkbox",checked:r.required(),onchange:e.withAttr("checked",r.required)},i=void 0;return r.forceRequired()&&(n.required=!0,n.disabled=!0,i=e("p.help",t.forceRequired)),e("div",[e("label.cb-wrap",[e("input",n),t.isFieldRequired]),i])},r.placeholder=function(r){return e("div",[e("label",[t.placeholder," ",e("small",{style:"float: right; font-weight: normal;"},t.optional)]),e("input.widefat",{type:"text",value:r.placeholder(),onchange:e.withAttr("value",r.placeholder),placeholder:""}),e("p.help",t.placeholderHelp)])},r.useParagraphs=function(r){return e("div",[e("label.cb-wrap",[e("input",{type:"checkbox",checked:r.wrap(),onchange:e.withAttr("checked",r.wrap)}),t.wrapInParagraphTags])])},r.choiceType=function(r){var n=[e("option",{value:"select",selected:"select"===r.type()&&"selected"},t.dropdown),e("option",{value:"radio",selected:"radio"===r.type()&&"selected"},t.radioButtons)];return r.acceptsMultipleValues&&n.push(e("option",{value:"checkbox",selected:"checkbox"===r.type()&&"selected"},t.checkboxes)),e("div",[e("label",t.choiceType),e("select",{value:r.type(),onchange:e.withAttr("value",r.type)},n)])},r.choices=function(r){var n=[];return n.push(e("div",[e("label",t.choices),e("div.limit-height",[e("table",[r.choices().map(function(n,i){return e("tr",{"data-id":i},[e("td.cb",e("input",{name:"selected",type:"checkbox"===r.type()?"checkbox":"radio",onchange:e.withAttr("value",r.selectChoice.bind(r)),checked:n.selected(),value:n.value(),title:t.preselect})),e("td.stretch",e("input.widefat",{type:"text",value:n.label(),placeholder:n.title(),onchange:e.withAttr("value",n.label)})),e("td",e("span",{title:t.remove,class:"dashicons dashicons-no-alt hover-activated",onclick:function(e){this.choices().splice(e,1)}.bind(r,i)},""))])})])])])),n},r};t.exports=n},{}],2:[function(e,t,r){"use strict";var n=function t(r,n){var t={},i=e("./field-forms-rows.js")(r,n);return t.render=function(e){var r=e.type();if("function"==typeof t[r])return t[r](e);switch(r){case"select":case"radio":case"checkbox":return t.choice(e)}return t.text(e)},t.text=function(e){return[i.label(e),i.placeholder(e),i.value(e),i.isRequired(e),i.useParagraphs(e)]},t.choice=function(e){var t=[i.label(e),i.choiceType(e),i.choices(e)];return"select"===e.type()&&t.push(i.placeholder(e)),t.push(i.useParagraphs(e)),"select"!==e.type()&&"radio"!==e.type()||t.push(i.isRequired(e)),t},t.hidden=function(e){return e.placeholder(""),e.label(""),e.wrap(!1),[i.showType(e),i.value(e)]},t.submit=function(e){return e.label(""),e.placeholder(""),[i.value(e),i.useParagraphs(e)]},t.number=function(e){return[t.text(e),i.numberMinMax(e)]},t};t.exports=n},{"./field-forms-rows.js":1}],3:[function(e,t,r){"use strict";var n=e("html"),i=function(e){e.dom.checked&&e.dom.setAttribute("checked","true"),e.dom.value&&e.dom.setAttribute("value",e.dom.value),e.dom.selected&&e.dom.setAttribute("selected","true")},o=function(e){function t(t){var i=void 0,o=void 0,a=void 0,l=document.createElement("div");return i=t.label().length>0?e("label",{},t.label()):"",o="function"==typeof r[t.type()]?r[t.type()](t):r.default(t),a=t.wrap()?e("p",[i,o]):[i,o],e.render(l,a),n.prettyPrint(l.innerHTML)+"\n"}var r={};return r.select=function(t){var r={name:t.name(),required:t.required()},n=!1,o=t.choices().map(function(t){return t.selected()&&(n=!0),e("option",{value:t.value()!==t.label()?t.value():void 0,selected:t.selected(),oncreate:i},t.label())}),a=t.placeholder();return a.length>0&&o.unshift(e("option",{disabled:!0,value:"",selected:!n,oncreate:i},a)),e("select",r,o)},r.checkbox=function(t){return t.choices().map(function(r){var n=t.name()+("checkbox"===t.type()?"[]":""),o=t.required()&&"radio"===t.type();return e("label",[e("input",{name:n,type:t.type(),value:r.value(),checked:r.selected(),required:o,oncreate:i})," ",e("span",r.label())])})},r.radio=r.checkbox,r.default=function(t){var r={type:t.type()};return t.name()&&(r.name=t.name()),t.min()&&(r.min=t.min()),t.max()&&(r.max=t.max()),t.value().length>0&&(r.value=t.value()),t.placeholder().length>0&&(r.placeholder=t.placeholder()),r.required=t.required(),r.oncreate=i,e("input",r)},t};t.exports=o},{html:20}],4:[function(e,t,r){"use strict";var n=function(t,r,n,i,o,a){function l(e){d=i.get(e),d&&d.choices().length>0&&d.value(d.choices().map(function(e){return e.label()}).join("|")),t.redraw()}function s(){}function c(){var e=f(d);n.insert(e),l(""),t.redraw()}function u(){var e=i.getCategories(),r=i.getAll(),n=t("div.available-fields.small-margin",[t("h4",a.chooseField),e.map(function(e){var n=r.filter(function(t){return t.category===e});if(n.length)return t("div.tiny-margin",[t("strong",e),n.map(function(e){var r="button";e.forceRequired()&&(r+=" is-required");var n=e.inFormContent();return null!==n&&(r+=" "+(n?"in-form":"not-in-form")),t("button",{className:r,type:"button",onclick:t.withAttr("value",l),value:e.index},e.title())})])})]),o=null;return d&&(o=h(t("div.field-wizard",[t("h3",[d.title(),d.forceRequired()?t("span.red","*"):"",d.name().length?t("code",d.name()):""]),d.help().length?t("p",t.trust(d.help())):"",p.render(d),t("p",[t("button",{class:"button-primary",type:"button",onkeydown:function(e){e=e||window.event,13==e.keyCode&&c()},onclick:c},a.addToForm)])]),l)),[n,o]}var d,f=e("./field-generator.js")(t),h=e("./overlay.js")(t,a),p=e("./field-forms.js")(t,a);return n.on("blur",t.redraw),{view:u,controller:s}};t.exports=n},{"./field-forms.js":2,"./field-generator.js":3,"./overlay.js":10}],5:[function(e,t,r){"use strict";var n=function(e,t){function r(){u.forEach(e.deregister)}function n(t,r,n){var i=e.register(t,r);n||u.push(i)}function i(e){var t={phone:"tel",dropdown:"select",checkboxes:"checkbox",birthday:"text"};return void 0!==t[e]?t[e]:e}function o(e){var r=t.listFields,o=i(e.field_type),a={name:e.tag,title:e.name,required:e.required,forceRequired:e.required,type:o,choices:e.choices,acceptsMultipleValues:!1};return"address"!==a.type?n(r,a,!1):(n(r,{name:a.name+"[addr1]",type:"text",mailchimpType:"address",title:t.streetAddress}),n(r,{name:a.name+"[city]",type:"text",mailchimpType:"address",title:t.city}),n(r,{name:a.name+"[state]",type:"text",mailchimpType:"address",title:t.state}),n(r,{name:a.name+"[zip]",type:"text",mailchimpType:"address",title:t.zip}),n(r,{name:a.name+"[country]",type:"select",mailchimpType:"address",title:t.country,choices:mc4wp_vars.countries})),!0}function a(e){var r=t.interestCategories,o=i(e.field_type);n(r,{title:e.name,name:"INTERESTS["+e.id+"]",type:o,choices:e.interests,acceptsMultipleValues:"checkbox"===o},!1)}function l(e){e.merge_fields=e.merge_fields.sort(function(e,t){return"EMAIL"===e.tag||e.public&&!t.public?-1:!e.public&&t.public?1:0}),e.merge_fields.forEach(o),e.interest_categories.forEach(a)}function s(e){r(),e.forEach(l)}function c(e){var r,i=t.formFields;n(i,{name:"",value:t.subscribe,type:"submit",title:t.submitButton},!0),r={};for(var o in e)r[e[o].id]=e[o].name;n(i,{name:"_mc4wp_lists",type:"checkbox",title:t.listChoice,choices:r,help:t.listChoiceDescription,acceptsMultipleValues:!0},!0),r={subscribe:"Subscribe",unsubscribe:"Unsubscribe"},n(i,{name:"_mc4wp_action",type:"radio",title:t.formAction,choices:r,value:"subscribe",help:t.formActionDescription},!0)}var u=[];return{registerCustomFields:c,registerListFields:l,registerListsFields:s}};t.exports=n},{}],6:[function(e,t,r){"use strict";var n=e("mithril/stream");t.exports=function(e,t){function r(e){return"function"==typeof e.map?e.map(function(e){return new p({label:e})}):Object.keys(e).map(function(t){return new p({label:e[t],value:t})})}function i(n,i){var o,a=c("name",i.name).shift();return a?void(!a.forceRequired()&&i.forceRequired&&a.forceRequired(!0)):(i.choices&&(i.choices=r(i.choices),i.value&&(i.choices=i.choices.map(function(e){return e.value()===i.value&&e.selected(!0),e}))),f.indexOf(n)<0&&f.push(n),o=new h(i),o.category=n,d.push(o),u&&window.clearTimeout(u),u=window.setTimeout(e.redraw,200),t.trigger("fields.change"),o)}function o(t){var r=d.indexOf(t);r>-1&&(delete d[r],e.redraw())}function a(e){return d[e]}function l(){return d=d.map(function(e,t){return e.index=t,e})}function s(){return f}function c(e,t){return d.filter(function(r){return r[e]()===t})}var u,d=[],f=[],h=function(e){this.name=n(e.name),this.title=n(e.title||e.name),this.type=n(e.type),this.mailchimpType=n(e.mailchimpType||""),this.label=n(e.title||""),this.value=n(e.value||""),this.placeholder=n(e.placeholder||""),this.required=n(e.required||!1),this.forceRequired=n(e.forceRequired||!1),this.wrap=n(e.wrap||!0),this.min=n(e.min||null),this.max=n(e.max||null),this.help=n(e.help||""),this.choices=n(e.choices||[]),this.inFormContent=n(null),this.acceptsMultipleValues=e.acceptsMultipleValues,this.selectChoice=function(e){var t=this;this.choices(this.choices().map(function(r){return r.value()===e?r.selected(!0):"checkbox"!==t.type()&&r.selected(!1),r}))}},p=function(e){this.label=n(e.label),this.title=n(e.title||e.label),this.selected=n(e.selected||!1),this.value=n(e.value||e.label)};return{get:a,getAll:l,getCategories:s,deregister:o,register:i,getAllWhere:c}}},{"mithril/stream":21}],7:[function(e,t,r){"use strict";var n=e("codemirror");e("codemirror/mode/xml/xml"),e("codemirror/mode/javascript/javascript"),e("codemirror/mode/css/css"),e("codemirror/mode/htmlmixed/htmlmixed"),e("codemirror/addon/fold/xml-fold"),e("codemirror/addon/edit/matchtags"),e("codemirror/addon/edit/closetag.js");var i=function(e){function t(){return o&&(i.innerHTML=a.getValue().toLowerCase(),o=!1),i}var r,i=document.createElement("form"),o=!1,a={};return i.innerHTML=e.value.toLowerCase(),n&&(r=n.fromTextArea(e,{selectionPointer:!0,matchTags:{bothTags:!0},mode:"htmlmixed",htmlMode:!0,autoCloseTags:!0,autoRefresh:!0}),window.dispatchEvent&&r.on("change",function(){if("function"==typeof Event){var t=new Event("change",{bubbles:!0});e.dispatchEvent(t)}})),window.addEventListener("load",function(){n.signal(r,"change")}),e.addEventListener("change",function(){o=!0}),a.getValue=function(){return r?r.getValue():e.value},a.query=function(e){return t().querySelectorAll(e.toLowerCase())},a.containsField=function(e){return null!==t().elements.namedItem(e.toLowerCase())},a.insert=function(t){r?(r.replaceSelection(t),r.focus()):e.value+=t},a.on=function(t,n){return r?(t="input"===t?"changes":t,r.on(t,n)):e.addEventListener(t,n)},a.refresh=function(){r&&r.refresh()},a};t.exports=i},{codemirror:15,"codemirror/addon/edit/closetag.js":12,"codemirror/addon/edit/matchtags":13,"codemirror/addon/fold/xml-fold":14,"codemirror/mode/css/css":16,"codemirror/mode/htmlmixed/htmlmixed":17,"codemirror/mode/javascript/javascript":18,"codemirror/mode/xml/xml":19}],8:[function(e,t,r){"use strict";var n=function(e,t,r,n,i,o){function a(){n.getAll().forEach(function(e){if(!(e.name().length<=0)){var r=e.name();"checkbox"===e.type()&&(r+="[]");var n=t.containsField(r);if(e.inFormContent(n),"address"===e.mailchimpType()){e.originalRequiredValue=void 0===e.originalRequiredValue?e.forceRequired():e.originalRequiredValue;var i=e.name().replace(/\[(\w+)\]/g,"");t.query('[name^="'+i+'"]').length>0?(void 0===e.originalRequiredValue&&(e.originalRequiredValue=e.forceRequired()),e.forceRequired(!0)):e.forceRequired(e.originalRequiredValue)}}}),l(),e.redraw()}function l(){var e=n.getAllWhere("forceRequired",!0).map(function(e){return e.name().toUpperCase().replace(/\[(\w+)\]/g,".$1")}),r=t.query("[required]");Array.prototype.forEach.call(r,function(t){var r=t.name.toUpperCase();"_"!==r[0]&&(r=r.replace(/\[(\w+)\]/g,".$1"),e.indexOf(r)===-1&&e.push(r))}),s.value=e.join(",")}var s=document.getElementById("required-fields");t.on("change",o.debounce(a,500)),i.on("fields.change",o.debounce(a,500))};t.exports=n},{}],9:[function(e,t,r){"use strict";function n(e,t){l[e]=t,o()}function i(e){delete l[e],o()}function o(){var e="";for(var t in l)e+='<div class="notice notice-warning inline"><p>'+l[t]+"</p></div>";var r=document.querySelector(".mc4wp-notices");if(!r){r=document.createElement("div"),r.className="mc4wp-notices";var n=document.querySelector("h1, h2");n.parentNode.insertBefore(r,n.nextSibling)}r.innerHTML=e}function a(e,t){var r=function(){e.getValue().toLowerCase().indexOf('name="groupings')>-1?n("deprecated_groupings","Your form contains old style <code>GROUPINGS</code> fields. <br /><br />Please remove these fields from your form and then re-add them through the available field buttons to make sure your data is getting through to MailChimp correctly."):i("deprecated_groupings")},o=function(){var r=t.getAllWhere("forceRequired",!0),o=r.filter(function(t){return!e.containsField(t.name().toUpperCase())}),a="<strong>Heads up!</strong> Your form is missing list fields that are required in MailChimp. Either add these fields to your form or mark them as optional in MailChimp.";a+='<br /><ul class="ul-square" style="margin-bottom: 0;"><li>'+o.map(function(e){return e.title()}).join("</li><li>")+"</li></ul>",o.length>0?n("required_fields_missing",a):i("required_fields_missing")};r(),e.on("focus",r),e.on("blur",r),o(),e.on("blur",o),e.on("focus",o)}var l={};t.exports={init:a}},{}],10:[function(e,t,r){"use strict";var n=function(e,t){function r(){document.removeEventListener("keydown",n),window.removeEventListener("resize",i),l()}function n(e){e=e||window.event,27==e.keyCode&&r(),13==e.keyCode&&e.preventDefault()}function i(){if(a){var e=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,t=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,r=(e-a.clientWidth-40)/2,n=(t-a.clientHeight-40)/2;a.style.left=(r>0?r:0)+"px",a.style.top=(n>0?n:0)+"px"}}function o(e){a=e.dom,i()}var a=void 0,l=void 0;return function(a,s){return l=s,document.addEventListener("keydown",n),window.addEventListener("resize",i),[e("div.overlay-wrap",e("div.overlay",{oncreate:o},[e("span",{class:"close dashicons dashicons-no",title:t.close,onclick:r}),a])),e("div.overlay-background",{title:t.close,onclick:r})]}};t.exports=n},{}],11:[function(e,t,r){"use strict";var n=window.mc4wp_forms_i18n,i=window.mc4wp.deps.mithril,o=mc4wp.events,a=mc4wp.settings,l=mc4wp.helpers,s=mc4wp.tabs,c=e("./admin/form-watcher.js"),u=e("./admin/form-editor.js"),d=e("./admin/field-helper.js"),f=e("./admin/fields-factory.js"),h=e("./admin/fields.js")(i,o),p=document.getElementById("mc4wp-form-content"),m=window.formEditor=new u(p),g=(new c(i,formEditor,a,h,o,l),new d(i,s,formEditor,h,o,n)),v=e("./admin/notices");i.mount(document.getElementById("mc4wp-field-wizard"),g);var y=new f(h,n);o.on("selectedLists.change",y.registerListsFields),y.registerListsFields(a.getSelectedLists()),y.registerCustomFields(mc4wp_vars.mailchimp.lists),window.setTimeout(function(){i.redraw()},2e3),v.init(m,h),window.mc4wp=window.mc4wp||{},window.mc4wp.forms=window.mc4wp.forms||{},window.mc4wp.forms.editor=m,window.mc4wp.forms.fields=h},{"./admin/field-helper.js":4,"./admin/fields-factory.js":5,"./admin/fields.js":6,"./admin/form-editor.js":7,"./admin/form-watcher.js":8,"./admin/notices":9}],12:[function(e,r,n){!function(i){"object"==typeof n&&"object"==typeof r?i(e("../../lib/codemirror"),e("../fold/xml-fold")):"function"==typeof t&&t.amd?t(["../../lib/codemirror","../fold/xml-fold"],i):i(CodeMirror)}(function(e){function t(t){if(t.getOption("disableInput"))return e.Pass;for(var r=t.listSelections(),n=[],s=0;s<r.length;s++){if(!r[s].empty())return e.Pass;var c=r[s].head,u=t.getTokenAt(c),d=e.innerMode(t.getMode(),u.state),f=d.state;if("xml"!=d.mode.name||!f.tagName)return e.Pass;var h=t.getOption("autoCloseTags"),p="html"==d.mode.configuration,m="object"==typeof h&&h.dontCloseTags||p&&a,g="object"==typeof h&&h.indentTags||p&&l,v=f.tagName;u.end>c.ch&&(v=v.slice(0,v.length-u.end+c.ch));var y=v.toLowerCase();if(!v||"string"==u.type&&(u.end!=c.ch||!/[\"\']/.test(u.string.charAt(u.string.length-1))||1==u.string.length)||"tag"==u.type&&"closeTag"==f.type||u.string.indexOf("/")==u.string.length-1||m&&i(m,y)>-1||o(t,v,c,f,!0))return e.Pass;var b=g&&i(g,y)>-1;n[s]={indent:b,text:">"+(b?"\n\n":"")+"</"+v+">",newPos:b?e.Pos(c.line+1,0):e.Pos(c.line,c.ch+1)}}for(var s=r.length-1;s>=0;s--){var w=n[s];t.replaceRange(w.text,r[s].head,r[s].anchor,"+insert");var x=t.listSelections().slice(0);x[s]={head:w.newPos,anchor:w.newPos},t.setSelections(x),w.indent&&(t.indentLine(w.newPos.line,null,!0),t.indentLine(w.newPos.line+1,null,!0))}}function r(t,r){for(var n=t.listSelections(),i=[],a=r?"/":"</",l=0;l<n.length;l++){if(!n[l].empty())return e.Pass;var s=n[l].head,c=t.getTokenAt(s),u=e.innerMode(t.getMode(),c.state),d=u.state;if(r&&("string"==c.type||"<"!=c.string.charAt(0)||c.start!=s.ch-1))return e.Pass;var f;if("xml"!=u.mode.name)if("htmlmixed"==t.getMode().name&&"javascript"==u.mode.name)f=a+"script";else{if("htmlmixed"!=t.getMode().name||"css"!=u.mode.name)return e.Pass;f=a+"style"}else{if(!d.context||!d.context.tagName||o(t,d.context.tagName,s,d))return e.Pass;f=a+d.context.tagName}">"!=t.getLine(s.line).charAt(c.end)&&(f+=">"),i[l]=f}t.replaceSelections(i),n=t.listSelections();for(var l=0;l<n.length;l++)(l==n.length-1||n[l].head.line<n[l+1].head.line)&&t.indentLine(n[l].head.line)}function n(t){return t.getOption("disableInput")?e.Pass:r(t,!0)}function i(e,t){if(e.indexOf)return e.indexOf(t);for(var r=0,n=e.length;r<n;++r)if(e[r]==t)return r;return-1}function o(t,r,n,i,o){if(!e.scanForClosingTag)return!1;var a=Math.min(t.lastLine()+1,n.line+500),l=e.scanForClosingTag(t,n,null,a);if(!l||l.tag!=r)return!1;for(var s=i.context,c=o?1:0;s&&s.tagName==r;s=s.prev)++c;n=l.to;for(var u=1;u<c;u++){var d=e.scanForClosingTag(t,n,null,a);if(!d||d.tag!=r)return!1;n=d.to}return!0}e.defineOption("autoCloseTags",!1,function(r,i,o){if(o!=e.Init&&o&&r.removeKeyMap("autoCloseTags"),i){var a={name:"autoCloseTags"};("object"!=typeof i||i.whenClosing)&&(a["'/'"]=function(e){return n(e)}),("object"!=typeof i||i.whenOpening)&&(a["'>'"]=function(e){return t(e)}),r.addKeyMap(a)}});var a=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],l=["applet","blockquote","body","button","div","dl","fieldset","form","frameset","h1","h2","h3","h4","h5","h6","head","html","iframe","layer","legend","object","ol","p","select","table","ul"];e.commands.closeTag=function(e){return r(e)}})},{"../../lib/codemirror":15,"../fold/xml-fold":14}],13:[function(e,r,n){!function(i){"object"==typeof n&&"object"==typeof r?i(e("../../lib/codemirror"),e("../fold/xml-fold")):"function"==typeof t&&t.amd?t(["../../lib/codemirror","../fold/xml-fold"],i):i(CodeMirror)}(function(e){"use strict";function t(e){e.state.tagHit&&e.state.tagHit.clear(),e.state.tagOther&&e.state.tagOther.clear(),e.state.tagHit=e.state.tagOther=null}function r(r){r.state.failedTagMatch=!1,r.operation(function(){if(t(r),!r.somethingSelected()){var n=r.getCursor(),i=r.getViewport();i.from=Math.min(i.from,n.line),i.to=Math.max(n.line+1,i.to);var o=e.findMatchingTag(r,n,i);if(o){if(r.state.matchBothTags){var a="open"==o.at?o.open:o.close;a&&(r.state.tagHit=r.markText(a.from,a.to,{className:"CodeMirror-matchingtag"}))}var l="close"==o.at?o.open:o.close;l?r.state.tagOther=r.markText(l.from,l.to,{className:"CodeMirror-matchingtag"}):r.state.failedTagMatch=!0}}})}function n(e){e.state.failedTagMatch&&r(e)}e.defineOption("matchTags",!1,function(i,o,a){a&&a!=e.Init&&(i.off("cursorActivity",r),i.off("viewportChange",n),t(i)),o&&(i.state.matchBothTags="object"==typeof o&&o.bothTags,i.on("cursorActivity",r),i.on("viewportChange",n),r(i))}),e.commands.toMatchingTag=function(t){var r=e.findMatchingTag(t,t.getCursor());if(r){var n="close"==r.at?r.open:r.close;n&&t.extendSelection(n.to,n.from)}}})},{"../../lib/codemirror":15,"../fold/xml-fold":14}],14:[function(e,r,n){!function(i){"object"==typeof n&&"object"==typeof r?i(e("../../lib/codemirror")):"function"==typeof t&&t.amd?t(["../../lib/codemirror"],i):i(CodeMirror)}(function(e){"use strict";function t(e,t){return e.line-t.line||e.ch-t.ch}function r(e,t,r,n){this.line=t,this.ch=r,this.cm=e,this.text=e.getLine(t),this.min=n?Math.max(n.from,e.firstLine()):e.firstLine(),this.max=n?Math.min(n.to-1,e.lastLine()):e.lastLine()}function n(e,t){var r=e.cm.getTokenTypeAt(f(e.line,t));return r&&/\btag\b/.test(r)}function i(e){if(!(e.line>=e.max))return e.ch=0,e.text=e.cm.getLine(++e.line),!0}function o(e){if(!(e.line<=e.min))return e.text=e.cm.getLine(--e.line),e.ch=e.text.length,!0}function a(e){for(;;){var t=e.text.indexOf(">",e.ch);if(t==-1){if(i(e))continue;return}{if(n(e,t+1)){var r=e.text.lastIndexOf("/",t),o=r>-1&&!/\S/.test(e.text.slice(r+1,t));return e.ch=t+1,o?"selfClose":"regular"}e.ch=t+1}}}function l(e){for(;;){var t=e.ch?e.text.lastIndexOf("<",e.ch-1):-1;if(t==-1){if(o(e))continue;return}if(n(e,t+1)){p.lastIndex=t,e.ch=t;var r=p.exec(e.text);if(r&&r.index==t)return r}else e.ch=t}}function s(e){for(;;){p.lastIndex=e.ch;var t=p.exec(e.text);if(!t){if(i(e))continue;return}{if(n(e,t.index+1))return e.ch=t.index+t[0].length,t;e.ch=t.index+1}}}function c(e){for(;;){var t=e.ch?e.text.lastIndexOf(">",e.ch-1):-1;if(t==-1){if(o(e))continue;return}{if(n(e,t+1)){var r=e.text.lastIndexOf("/",t),i=r>-1&&!/\S/.test(e.text.slice(r+1,t));return e.ch=t+1,i?"selfClose":"regular"}e.ch=t}}}function u(e,t){for(var r=[];;){var n,i=s(e),o=e.line,l=e.ch-(i?i[0].length:0);if(!i||!(n=a(e)))return;if("selfClose"!=n)if(i[1]){for(var c=r.length-1;c>=0;--c)if(r[c]==i[2]){r.length=c;break}if(c<0&&(!t||t==i[2]))return{tag:i[2],from:f(o,l),to:f(e.line,e.ch)}}else r.push(i[2])}}function d(e,t){for(var r=[];;){var n=c(e);if(!n)return;if("selfClose"!=n){var i=e.line,o=e.ch,a=l(e);if(!a)return;if(a[1])r.push(a[2]);else{for(var s=r.length-1;s>=0;--s)if(r[s]==a[2]){r.length=s;break}if(s<0&&(!t||t==a[2]))return{tag:a[2],from:f(e.line,e.ch),to:f(i,o)}}}else l(e)}}var f=e.Pos,h="A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",p=new RegExp("<(/?)(["+h+"]["+h+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*)","g");e.registerHelper("fold","xml",function(e,t){for(var n=new r(e,t.line,0);;){var i,o=s(n);if(!o||n.line!=t.line||!(i=a(n)))return;if(!o[1]&&"selfClose"!=i){var l=f(n.line,n.ch),c=u(n,o[2]);return c&&{from:l,to:c.from}}}}),e.findMatchingTag=function(e,n,i){var o=new r(e,n.line,n.ch,i);if(o.text.indexOf(">")!=-1||o.text.indexOf("<")!=-1){var s=a(o),c=s&&f(o.line,o.ch),h=s&&l(o);if(s&&h&&!(t(o,n)>0)){var p={from:f(o.line,o.ch),to:c,tag:h[2]};return"selfClose"==s?{open:p,close:null,at:"open"}:h[1]?{open:d(o,h[2]),close:p,at:"close"}:(o=new r(e,c.line,c.ch,i),{open:p,close:u(o,h[2]),at:"open"})}}},e.findEnclosingTag=function(e,t,n){for(var i=new r(e,t.line,t.ch,n);;){var o=d(i);if(!o)break;var a=new r(e,t.line,t.ch,n),l=u(a,o.tag);if(l)return{open:o,close:l}}},e.scanForClosingTag=function(e,t,n,i){return u(new r(e,t.line,t.ch,i?{from:0,to:i}:null),n)}})},{"../../lib/codemirror":15}],15:[function(e,r,n){!function(e,i){"object"==typeof n&&void 0!==r?r.exports=i():"function"==typeof t&&t.amd?t(i):e.CodeMirror=i()}(this,function(){"use strict";function e(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function t(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function r(e,r){return t(e).appendChild(r)}function n(e,t,r,n){var i=document.createElement(e);if(r&&(i.className=r),n&&(i.style.cssText=n),"string"==typeof t)i.appendChild(document.createTextNode(t));else if(t)for(var o=0;o<t.length;++o)i.appendChild(t[o]);return i}function i(e,t){if(3==t.nodeType&&(t=t.parentNode),e.contains)return e.contains(t);do{if(11==t.nodeType&&(t=t.host),t==e)return!0}while(t=t.parentNode)}function o(){var e;try{e=document.activeElement}catch(t){e=document.body||null}for(;e&&e.root&&e.root.activeElement;)e=e.root.activeElement;return e}function a(t,r){var n=t.className;e(r).test(n)||(t.className+=(n?" ":"")+r)}function l(t,r){for(var n=t.split(" "),i=0;i<n.length;i++)n[i]&&!e(n[i]).test(r)&&(r+=" "+n[i]);return r}function s(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function c(e,t,r){t||(t={});for(var n in e)!e.hasOwnProperty(n)||r===!1&&t.hasOwnProperty(n)||(t[n]=e[n]);return t}function u(e,t,r,n,i){null==t&&(t=e.search(/[^\s\u00a0]/))==-1&&(t=e.length);for(var o=n||0,a=i||0;;){var l=e.indexOf("\t",o);if(l<0||l>=t)return a+(t-o);a+=l-o,a+=r-a%r,o=l+1}}function d(e,t){for(var r=0;r<e.length;++r)if(e[r]==t)return r;return-1}function f(e,t,r){for(var n=0,i=0;;){var o=e.indexOf("\t",n);o==-1&&(o=e.length);var a=o-n;if(o==e.length||i+a>=t)return n+Math.min(a,t-i);if(i+=o-n,i+=r-i%r,n=o+1,i>=t)return n}}function h(e){for(;xa.length<=e;)xa.push(p(xa)+" ");return xa[e]}function p(e){return e[e.length-1]}function m(e,t){for(var r=[],n=0;n<e.length;n++)r[n]=t(e[n],n);return r}function g(e,t,r){for(var n=0,i=r(t);n<e.length&&r(e[n])<=i;)n++;e.splice(n,0,t)}function v(){}function y(e,t){var r;return Object.create?r=Object.create(e):(v.prototype=e,r=new v),t&&c(t,r),r}function b(e){return/\w/.test(e)||e>"€"&&(e.toUpperCase()!=e.toLowerCase()||ka.test(e))}function w(e,t){return t?!!(t.source.indexOf("\\w")>-1&&b(e))||t.test(e):b(e)}function x(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function k(e){return e.charCodeAt(0)>=768&&Ca.test(e)}function C(e,t,r){for(;(r<0?t>0:t<e.length)&&k(e.charAt(t));)t+=r;return t}function S(e,t,r){for(;;){if(Math.abs(t-r)<=1)return e(t)?t:r;var n=Math.floor((t+r)/2);e(n)?r=n:t=n}}function T(e,t,r){var i=this;this.input=r,i.scrollbarFiller=n("div",null,"CodeMirror-scrollbar-filler"),i.scrollbarFiller.setAttribute("cm-not-content","true"),i.gutterFiller=n("div",null,"CodeMirror-gutter-filler"),i.gutterFiller.setAttribute("cm-not-content","true"),i.lineDiv=n("div",null,"CodeMirror-code"),i.selectionDiv=n("div",null,null,"position: relative; z-index: 1"),i.cursorDiv=n("div",null,"CodeMirror-cursors"),i.measure=n("div",null,"CodeMirror-measure"),i.lineMeasure=n("div",null,"CodeMirror-measure"),i.lineSpace=n("div",[i.measure,i.lineMeasure,i.selectionDiv,i.cursorDiv,i.lineDiv],null,"position: relative; outline: none"),i.mover=n("div",[n("div",[i.lineSpace],"CodeMirror-lines")],null,"position: relative"),i.sizer=n("div",[i.mover],"CodeMirror-sizer"),i.sizerWidth=null,i.heightForcer=n("div",null,null,"position: absolute; height: "+ga+"px; width: 1px;"),i.gutters=n("div",null,"CodeMirror-gutters"),i.lineGutter=null,i.scroller=n("div",[i.sizer,i.heightForcer,i.gutters],"CodeMirror-scroll"),i.scroller.setAttribute("tabIndex","-1"),i.wrapper=n("div",[i.scrollbarFiller,i.gutterFiller,i.scroller],"CodeMirror"),Go&&$o<8&&(i.gutters.style.zIndex=-1,i.scroller.style.paddingRight=0),Yo||qo&&na||(i.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(i.wrapper):e(i.wrapper)),i.viewFrom=i.viewTo=t.first,i.reportedViewFrom=i.reportedViewTo=t.first,i.view=[],i.renderedView=null,i.externalMeasured=null,i.viewOffset=0,i.lastWrapHeight=i.lastWrapWidth=0,i.updateLineNumbers=null,i.nativeBarWidth=i.barHeight=i.barWidth=0,i.scrollbarsClipped=!1,i.lineNumWidth=i.lineNumInnerWidth=i.lineNumChars=null,i.alignWidgets=!1,i.cachedCharWidth=i.cachedTextHeight=i.cachedPaddingH=null,i.maxLine=null,i.maxLineLength=0,i.maxLineChanged=!1,i.wheelDX=i.wheelDY=i.wheelStartX=i.wheelStartY=null,i.shift=!1,i.selForContextMenu=null,i.activeTouch=null,r.init(i)}function L(e,t){if((t-=e.first)<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var r=e;!r.lines;)for(var n=0;;++n){var i=r.children[n],o=i.chunkSize();if(t<o){r=i;break}t-=o}return r.lines[t]}function M(e,t,r){var n=[],i=t.line;return e.iter(t.line,r.line+1,function(e){var o=e.text;i==r.line&&(o=o.slice(0,r.ch)),i==t.line&&(o=o.slice(t.ch)),n.push(o),++i}),n}function A(e,t,r){var n=[];return e.iter(t,r,function(e){n.push(e.text)}),n}function _(e,t){var r=t-e.height;if(r)for(var n=e;n;n=n.parent)n.height+=r}function O(e){if(null==e.parent)return null;for(var t=e.parent,r=d(t.lines,e),n=t.parent;n;t=n,n=n.parent)for(var i=0;n.children[i]!=t;++i)r+=n.children[i].chunkSize();return r+t.first}function N(e,t){var r=e.first;e:do{for(var n=0;n<e.children.length;++n){var i=e.children[n],o=i.height;if(t<o){e=i;continue e}t-=o,r+=i.chunkSize()}return r}while(!e.lines);for(var a=0;a<e.lines.length;++a){var l=e.lines[a],s=l.height;if(t<s)break;t-=s}return r+a}function W(e,t){return t>=e.first&&t<e.first+e.size}function E(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function z(e,t,r){if(void 0===r&&(r=null),!(this instanceof z))return new z(e,t,r);this.line=e,this.ch=t,this.sticky=r}function D(e,t){return e.line-t.line||e.ch-t.ch}function P(e,t){return e.sticky==t.sticky&&0==D(e,t)}function H(e){return z(e.line,e.ch)}function I(e,t){return D(e,t)<0?t:e}function F(e,t){return D(e,t)<0?e:t}function j(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function R(e,t){if(t.line<e.first)return z(e.first,0);var r=e.first+e.size-1;return t.line>r?z(r,L(e,r).text.length):B(t,L(e,t.line).text.length)}function B(e,t){var r=e.ch;return null==r||r>t?z(e.line,t):r<0?z(e.line,0):e}function q(e,t){for(var r=[],n=0;n<t.length;n++)r[n]=R(e,t[n]);return r}function K(){Sa=!0}function U(){Ta=!0}function V(e,t,r){this.marker=e,this.from=t,this.to=r}function G(e,t){if(e)for(var r=0;r<e.length;++r){var n=e[r];if(n.marker==t)return n}}function $(e,t){for(var r,n=0;n<e.length;++n)e[n]!=t&&(r||(r=[])).push(e[n]);return r}function Y(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function X(e,t,r){var n;if(e)for(var i=0;i<e.length;++i){var o=e[i],a=o.marker,l=null==o.from||(a.inclusiveLeft?o.from<=t:o.from<t);if(l||o.from==t&&"bookmark"==a.type&&(!r||!o.marker.insertLeft)){var s=null==o.to||(a.inclusiveRight?o.to>=t:o.to>t);(n||(n=[])).push(new V(a,o.from,s?null:o.to))}}return n}function Z(e,t,r){var n;if(e)for(var i=0;i<e.length;++i){var o=e[i],a=o.marker,l=null==o.to||(a.inclusiveRight?o.to>=t:o.to>t);if(l||o.from==t&&"bookmark"==a.type&&(!r||o.marker.insertLeft)){var s=null==o.from||(a.inclusiveLeft?o.from<=t:o.from<t);(n||(n=[])).push(new V(a,s?null:o.from-t,null==o.to?null:o.to-t))}}return n}function J(e,t){if(t.full)return null;var r=W(e,t.from.line)&&L(e,t.from.line).markedSpans,n=W(e,t.to.line)&&L(e,t.to.line).markedSpans;if(!r&&!n)return null;var i=t.from.ch,o=t.to.ch,a=0==D(t.from,t.to),l=X(r,i,a),s=Z(n,o,a),c=1==t.text.length,u=p(t.text).length+(c?i:0);if(l)for(var d=0;d<l.length;++d){var f=l[d];if(null==f.to){var h=G(s,f.marker);h?c&&(f.to=null==h.to?null:h.to+u):f.to=i}}
2
+ if(s)for(var m=0;m<s.length;++m){var g=s[m];if(null!=g.to&&(g.to+=u),null==g.from){var v=G(l,g.marker);v||(g.from=u,c&&(l||(l=[])).push(g))}else g.from+=u,c&&(l||(l=[])).push(g)}l&&(l=Q(l)),s&&s!=l&&(s=Q(s));var y=[l];if(!c){var b,w=t.text.length-2;if(w>0&&l)for(var x=0;x<l.length;++x)null==l[x].to&&(b||(b=[])).push(new V(l[x].marker,null,null));for(var k=0;k<w;++k)y.push(b);y.push(s)}return y}function Q(e){for(var t=0;t<e.length;++t){var r=e[t];null!=r.from&&r.from==r.to&&r.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function ee(e,t,r){var n=null;if(e.iter(t.line,r.line+1,function(e){if(e.markedSpans)for(var t=0;t<e.markedSpans.length;++t){var r=e.markedSpans[t].marker;!r.readOnly||n&&d(n,r)!=-1||(n||(n=[])).push(r)}}),!n)return null;for(var i=[{from:t,to:r}],o=0;o<n.length;++o)for(var a=n[o],l=a.find(0),s=0;s<i.length;++s){var c=i[s];if(!(D(c.to,l.from)<0||D(c.from,l.to)>0)){var u=[s,1],f=D(c.from,l.from),h=D(c.to,l.to);(f<0||!a.inclusiveLeft&&!f)&&u.push({from:c.from,to:l.from}),(h>0||!a.inclusiveRight&&!h)&&u.push({from:l.to,to:c.to}),i.splice.apply(i,u),s+=u.length-3}}return i}function te(e){var t=e.markedSpans;if(t){for(var r=0;r<t.length;++r)t[r].marker.detachLine(e);e.markedSpans=null}}function re(e,t){if(t){for(var r=0;r<t.length;++r)t[r].marker.attachLine(e);e.markedSpans=t}}function ne(e){return e.inclusiveLeft?-1:0}function ie(e){return e.inclusiveRight?1:0}function oe(e,t){var r=e.lines.length-t.lines.length;if(0!=r)return r;var n=e.find(),i=t.find(),o=D(n.from,i.from)||ne(e)-ne(t);if(o)return-o;var a=D(n.to,i.to)||ie(e)-ie(t);return a?a:t.id-e.id}function ae(e,t){var r,n=Ta&&e.markedSpans;if(n)for(var i=void 0,o=0;o<n.length;++o)i=n[o],i.marker.collapsed&&null==(t?i.from:i.to)&&(!r||oe(r,i.marker)<0)&&(r=i.marker);return r}function le(e){return ae(e,!0)}function se(e){return ae(e,!1)}function ce(e,t,r,n,i){var o=L(e,t),a=Ta&&o.markedSpans;if(a)for(var l=0;l<a.length;++l){var s=a[l];if(s.marker.collapsed){var c=s.marker.find(0),u=D(c.from,r)||ne(s.marker)-ne(i),d=D(c.to,n)||ie(s.marker)-ie(i);if(!(u>=0&&d<=0||u<=0&&d>=0)&&(u<=0&&(s.marker.inclusiveRight&&i.inclusiveLeft?D(c.to,r)>=0:D(c.to,r)>0)||u>=0&&(s.marker.inclusiveRight&&i.inclusiveLeft?D(c.from,n)<=0:D(c.from,n)<0)))return!0}}}function ue(e){for(var t;t=le(e);)e=t.find(-1,!0).line;return e}function de(e){for(var t;t=se(e);)e=t.find(1,!0).line;return e}function fe(e){for(var t,r;t=se(e);)e=t.find(1,!0).line,(r||(r=[])).push(e);return r}function he(e,t){var r=L(e,t),n=ue(r);return r==n?t:O(n)}function pe(e,t){if(t>e.lastLine())return t;var r,n=L(e,t);if(!me(e,n))return t;for(;r=se(n);)n=r.find(1,!0).line;return O(n)+1}function me(e,t){var r=Ta&&t.markedSpans;if(r)for(var n=void 0,i=0;i<r.length;++i)if(n=r[i],n.marker.collapsed){if(null==n.from)return!0;if(!n.marker.widgetNode&&0==n.from&&n.marker.inclusiveLeft&&ge(e,t,n))return!0}}function ge(e,t,r){if(null==r.to){var n=r.marker.find(1,!0);return ge(e,n.line,G(n.line.markedSpans,r.marker))}if(r.marker.inclusiveRight&&r.to==t.text.length)return!0;for(var i=void 0,o=0;o<t.markedSpans.length;++o)if(i=t.markedSpans[o],i.marker.collapsed&&!i.marker.widgetNode&&i.from==r.to&&(null==i.to||i.to!=r.from)&&(i.marker.inclusiveLeft||r.marker.inclusiveRight)&&ge(e,t,i))return!0}function ve(e){e=ue(e);for(var t=0,r=e.parent,n=0;n<r.lines.length;++n){var i=r.lines[n];if(i==e)break;t+=i.height}for(var o=r.parent;o;r=o,o=r.parent)for(var a=0;a<o.children.length;++a){var l=o.children[a];if(l==r)break;t+=l.height}return t}function ye(e){if(0==e.height)return 0;for(var t,r=e.text.length,n=e;t=le(n);){var i=t.find(0,!0);n=i.from.line,r+=i.from.ch-i.to.ch}for(n=e;t=se(n);){var o=t.find(0,!0);r-=n.text.length-o.from.ch,n=o.to.line,r+=n.text.length-o.to.ch}return r}function be(e){var t=e.display,r=e.doc;t.maxLine=L(r,r.first),t.maxLineLength=ye(t.maxLine),t.maxLineChanged=!0,r.iter(function(e){var r=ye(e);r>t.maxLineLength&&(t.maxLineLength=r,t.maxLine=e)})}function we(e,t,r,n){if(!e)return n(t,r,"ltr");for(var i=!1,o=0;o<e.length;++o){var a=e[o];(a.from<r&&a.to>t||t==r&&a.to==t)&&(n(Math.max(a.from,t),Math.min(a.to,r),1==a.level?"rtl":"ltr"),i=!0)}i||n(t,r,"ltr")}function xe(e,t,r){var n;La=null;for(var i=0;i<e.length;++i){var o=e[i];if(o.from<t&&o.to>t)return i;o.to==t&&(o.from!=o.to&&"before"==r?n=i:La=i),o.from==t&&(o.from!=o.to&&"before"!=r?n=i:La=i)}return null!=n?n:La}function ke(e){var t=e.order;return null==t&&(t=e.order=Ma(e.text)),t}function Ce(e,t,r){var n=C(e.text,t+r,r);return n<0||n>e.text.length?null:n}function Se(e,t,r){var n=Ce(e,t.ch,r);return null==n?null:new z(t.line,n,r<0?"after":"before")}function Te(e,t,r,n,i){if(e){var o=ke(r);if(o){var a,l=i<0?p(o):o[0],s=i<0==(1==l.level),c=s?"after":"before";if(l.level>0){var u=Yt(t,r);a=i<0?r.text.length-1:0;var d=Xt(t,u,a).top;a=S(function(e){return Xt(t,u,e).top==d},i<0==(1==l.level)?l.from:l.to-1,a),"before"==c&&(a=Ce(r,a,1,!0))}else a=i<0?l.to:l.from;return new z(n,a,c)}}return new z(n,i<0?r.text.length:0,i<0?"before":"after")}function Le(e,t,r,n){var i=ke(t);if(!i)return Se(t,r,n);r.ch>=t.text.length?(r.ch=t.text.length,r.sticky="before"):r.ch<=0&&(r.ch=0,r.sticky="after");var o=xe(i,r.ch,r.sticky),a=i[o];if(a.level%2==0&&(n>0?a.to>r.ch:a.from<r.ch))return Se(t,r,n);var l,s=function(e,r){return Ce(t,e instanceof z?e.ch:e,r)},c=function(r){return e.options.lineWrapping?(l=l||Yt(e,t),pr(e,t,l,r)):{begin:0,end:t.text.length}},u=c("before"==r.sticky?s(r,-1):r.ch);if(a.level%2==1){var d=s(r,-n);if(null!=d&&(n>0?d>=a.from&&d>=u.begin:d<=a.to&&d<=u.end)){var f=n<0?"before":"after";return new z(r.line,d,f)}}var h=function(e,t,n){for(var o=function(e,t){return t?new z(r.line,s(e,1),"before"):new z(r.line,e,"after")};e>=0&&e<i.length;e+=t){var a=i[e],l=t>0==(1!=a.level),c=l?n.begin:s(n.end,-1);if(a.from<=c&&c<a.to)return o(c,l);if(c=l?a.from:s(a.to,-1),n.begin<=c&&c<n.end)return o(c,l)}},p=h(o+n,n,u);if(p)return p;var m=n>0?u.end:s(u.begin,-1);return null==m||n>0&&m==t.text.length||!(p=h(n>0?0:i.length-1,n,c(m)))?null:p}function Me(e,t){return e._handlers&&e._handlers[t]||Aa}function Ae(e,t,r){if(e.removeEventListener)e.removeEventListener(t,r,!1);else if(e.detachEvent)e.detachEvent("on"+t,r);else{var n=e._handlers,i=n&&n[t];if(i){var o=d(i,r);o>-1&&(n[t]=i.slice(0,o).concat(i.slice(o+1)))}}}function _e(e,t){var r=Me(e,t);if(r.length)for(var n=Array.prototype.slice.call(arguments,2),i=0;i<r.length;++i)r[i].apply(null,n)}function Oe(e,t,r){return"string"==typeof t&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),_e(e,r||t.type,e,t),Pe(t)||t.codemirrorIgnore}function Ne(e){var t=e._handlers&&e._handlers.cursorActivity;if(t)for(var r=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),n=0;n<t.length;++n)d(r,t[n])==-1&&r.push(t[n])}function We(e,t){return Me(e,t).length>0}function Ee(e){e.prototype.on=function(e,t){_a(this,e,t)},e.prototype.off=function(e,t){Ae(this,e,t)}}function ze(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function De(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function Pe(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function He(e){ze(e),De(e)}function Ie(e){return e.target||e.srcElement}function Fe(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),ia&&e.ctrlKey&&1==t&&(t=3),t}function je(e){if(null==pa){var t=n("span","​");r(e,n("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(pa=t.offsetWidth<=1&&t.offsetHeight>2&&!(Go&&$o<8))}var i=pa?n("span","​"):n("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}function Re(e){if(null!=ma)return ma;var n=r(e,document.createTextNode("AخA")),i=sa(n,0,1).getBoundingClientRect(),o=sa(n,1,2).getBoundingClientRect();return t(e),!(!i||i.left==i.right)&&(ma=o.right-i.right<3)}function Be(e){if(null!=za)return za;var t=r(e,n("span","x")),i=t.getBoundingClientRect(),o=sa(t,0,1).getBoundingClientRect();return za=Math.abs(i.left-o.left)>1}function qe(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Da[e]=t}function Ke(e,t){Pa[e]=t}function Ue(e){if("string"==typeof e&&Pa.hasOwnProperty(e))e=Pa[e];else if(e&&"string"==typeof e.name&&Pa.hasOwnProperty(e.name)){var t=Pa[e.name];"string"==typeof t&&(t={name:t}),e=y(t,e),e.name=t.name}else{if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return Ue("application/xml");if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return Ue("application/json")}return"string"==typeof e?{name:e}:e||{name:"null"}}function Ve(e,t){t=Ue(t);var r=Da[t.name];if(!r)return Ve(e,"text/plain");var n=r(e,t);if(Ha.hasOwnProperty(t.name)){var i=Ha[t.name];for(var o in i)i.hasOwnProperty(o)&&(n.hasOwnProperty(o)&&(n["_"+o]=n[o]),n[o]=i[o])}if(n.name=t.name,t.helperType&&(n.helperType=t.helperType),t.modeProps)for(var a in t.modeProps)n[a]=t.modeProps[a];return n}function Ge(e,t){c(t,Ha.hasOwnProperty(e)?Ha[e]:Ha[e]={})}function $e(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var r={};for(var n in t){var i=t[n];i instanceof Array&&(i=i.concat([])),r[n]=i}return r}function Ye(e,t){for(var r;e.innerMode&&((r=e.innerMode(t))&&r.mode!=e);)t=r.state,e=r.mode;return r||{mode:e,state:t}}function Xe(e,t,r){return!e.startState||e.startState(t,r)}function Ze(e,t,r,n){var i=[e.state.modeGen],o={};ot(e,t.text,e.doc.mode,r,function(e,t){return i.push(e,t)},o,n);for(var a=0;a<e.state.overlays.length;++a)!function(r){var n=e.state.overlays[r],a=1,l=0;ot(e,t.text,n.mode,!0,function(e,t){for(var r=a;l<e;){var o=i[a];o>e&&i.splice(a,1,e,i[a+1],o),a+=2,l=Math.min(e,o)}if(t)if(n.opaque)i.splice(r,a-r,e,"overlay "+t),a=r+2;else for(;r<a;r+=2){var s=i[r+1];i[r+1]=(s?s+" ":"")+"overlay "+t}},o)}(a);return{styles:i,classes:o.bgClass||o.textClass?o:null}}function Je(e,t,r){if(!t.styles||t.styles[0]!=e.state.modeGen){var n=Qe(e,O(t)),i=Ze(e,t,t.text.length>e.options.maxHighlightLength?$e(e.doc.mode,n):n);t.stateAfter=n,t.styles=i.styles,i.classes?t.styleClasses=i.classes:t.styleClasses&&(t.styleClasses=null),r===e.doc.frontier&&e.doc.frontier++}return t.styles}function Qe(e,t,r){var n=e.doc,i=e.display;if(!n.mode.startState)return!0;var o=at(e,t,r),a=o>n.first&&L(n,o-1).stateAfter;return a=a?$e(n.mode,a):Xe(n.mode),n.iter(o,t,function(r){et(e,r.text,a);var l=o==t-1||o%5==0||o>=i.viewFrom&&o<i.viewTo;r.stateAfter=l?$e(n.mode,a):null,++o}),r&&(n.frontier=o),a}function et(e,t,r,n){var i=e.doc.mode,o=new Ia(t,e.options.tabSize);for(o.start=o.pos=n||0,""==t&&tt(i,r);!o.eol();)rt(i,o,r),o.start=o.pos}function tt(e,t){if(e.blankLine)return e.blankLine(t);if(e.innerMode){var r=Ye(e,t);return r.mode.blankLine?r.mode.blankLine(r.state):void 0}}function rt(e,t,r,n){for(var i=0;i<10;i++){n&&(n[0]=Ye(e,r).mode);var o=e.token(t,r);if(t.pos>t.start)return o}throw new Error("Mode "+e.name+" failed to advance stream.")}function nt(e,t,r,n){var i,o=function(e){return{start:d.start,end:d.pos,string:d.current(),type:i||null,state:e?$e(a.mode,u):u}},a=e.doc,l=a.mode;t=R(a,t);var s,c=L(a,t.line),u=Qe(e,t.line,r),d=new Ia(c.text,e.options.tabSize);for(n&&(s=[]);(n||d.pos<t.ch)&&!d.eol();)d.start=d.pos,i=rt(l,d,u),n&&s.push(o(!0));return n?s:o()}function it(e,t){if(e)for(;;){var r=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!r)break;e=e.slice(0,r.index)+e.slice(r.index+r[0].length);var n=r[1]?"bgClass":"textClass";null==t[n]?t[n]=r[2]:new RegExp("(?:^|s)"+r[2]+"(?:$|s)").test(t[n])||(t[n]+=" "+r[2])}return e}function ot(e,t,r,n,i,o,a){var l=r.flattenSpans;null==l&&(l=e.options.flattenSpans);var s,c=0,u=null,d=new Ia(t,e.options.tabSize),f=e.options.addModeClass&&[null];for(""==t&&it(tt(r,n),o);!d.eol();){if(d.pos>e.options.maxHighlightLength?(l=!1,a&&et(e,t,n,d.pos),d.pos=t.length,s=null):s=it(rt(r,d,n,f),o),f){var h=f[0].name;h&&(s="m-"+(s?h+" "+s:h))}if(!l||u!=s){for(;c<d.start;)c=Math.min(d.start,c+5e3),i(c,u);u=s}d.start=d.pos}for(;c<d.pos;){var p=Math.min(d.pos,c+5e3);i(p,u),c=p}}function at(e,t,r){for(var n,i,o=e.doc,a=r?-1:t-(e.doc.mode.innerMode?1e3:100),l=t;l>a;--l){if(l<=o.first)return o.first;var s=L(o,l-1);if(s.stateAfter&&(!r||l<=o.frontier))return l;var c=u(s.text,null,e.options.tabSize);(null==i||n>c)&&(i=l-1,n=c)}return i}function lt(e,t,r,n){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),null!=e.order&&(e.order=null),te(e),re(e,r);var i=n?n(e):1;i!=e.height&&_(e,i)}function st(e){e.parent=null,te(e)}function ct(e,t){if(!e||/^\s*$/.test(e))return null;var r=t.addModeClass?Ba:Ra;return r[e]||(r[e]=e.replace(/\S+/g,"cm-$&"))}function ut(e,t){var r=n("span",null,null,Yo?"padding-right: .1px":null),i={pre:n("pre",[r],"CodeMirror-line"),content:r,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:(Go||Yo)&&e.getOption("lineWrapping")};r.setAttribute("role","presentation"),i.pre.setAttribute("role","presentation"),t.measure={};for(var o=0;o<=(t.rest?t.rest.length:0);o++){var a=o?t.rest[o-1]:t.line,s=void 0;i.pos=0,i.addToken=ft,Re(e.display.measure)&&(s=ke(a))&&(i.addToken=pt(i.addToken,s)),i.map=[];gt(a,i,Je(e,a,t!=e.display.externalMeasured&&O(a))),a.styleClasses&&(a.styleClasses.bgClass&&(i.bgClass=l(a.styleClasses.bgClass,i.bgClass||"")),a.styleClasses.textClass&&(i.textClass=l(a.styleClasses.textClass,i.textClass||""))),0==i.map.length&&i.map.push(0,0,i.content.appendChild(je(e.display.measure))),0==o?(t.measure.map=i.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(i.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(Yo){var c=i.content.lastChild;(/\bcm-tab\b/.test(c.className)||c.querySelector&&c.querySelector(".cm-tab"))&&(i.content.className="cm-tab-wrap-hack")}return _e(e,"renderLine",e,t.line,i.pre),i.pre.className&&(i.textClass=l(i.pre.className,i.textClass||"")),i}function dt(e){var t=n("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function ft(e,t,r,i,o,a,l){if(t){var s,c=e.splitSpaces?ht(t,e.trailingSpace):t,u=e.cm.state.specialChars,d=!1;if(u.test(t)){s=document.createDocumentFragment();for(var f=0;;){u.lastIndex=f;var p=u.exec(t),m=p?p.index-f:t.length-f;if(m){var g=document.createTextNode(c.slice(f,f+m));Go&&$o<9?s.appendChild(n("span",[g])):s.appendChild(g),e.map.push(e.pos,e.pos+m,g),e.col+=m,e.pos+=m}if(!p)break;f+=m+1;var v=void 0;if("\t"==p[0]){var y=e.cm.options.tabSize,b=y-e.col%y;v=s.appendChild(n("span",h(b),"cm-tab")),v.setAttribute("role","presentation"),v.setAttribute("cm-text","\t"),e.col+=b}else"\r"==p[0]||"\n"==p[0]?(v=s.appendChild(n("span","\r"==p[0]?"␍":"␤","cm-invalidchar")),v.setAttribute("cm-text",p[0]),e.col+=1):(v=e.cm.options.specialCharPlaceholder(p[0]),v.setAttribute("cm-text",p[0]),Go&&$o<9?s.appendChild(n("span",[v])):s.appendChild(v),e.col+=1);e.map.push(e.pos,e.pos+1,v),e.pos++}}else e.col+=t.length,s=document.createTextNode(c),e.map.push(e.pos,e.pos+t.length,s),Go&&$o<9&&(d=!0),e.pos+=t.length;if(e.trailingSpace=32==c.charCodeAt(t.length-1),r||i||o||d||l){var w=r||"";i&&(w+=i),o&&(w+=o);var x=n("span",[s],w,l);return a&&(x.title=a),e.content.appendChild(x)}e.content.appendChild(s)}}function ht(e,t){if(e.length>1&&!/ /.test(e))return e;for(var r=t,n="",i=0;i<e.length;i++){var o=e.charAt(i);" "!=o||!r||i!=e.length-1&&32!=e.charCodeAt(i+1)||(o=" "),n+=o,r=" "==o}return n}function pt(e,t){return function(r,n,i,o,a,l,s){i=i?i+" cm-force-border":"cm-force-border";for(var c=r.pos,u=c+n.length;;){for(var d=void 0,f=0;f<t.length&&(d=t[f],!(d.to>c&&d.from<=c));f++);if(d.to>=u)return e(r,n,i,o,a,l,s);e(r,n.slice(0,d.to-c),i,o,null,l,s),o=null,n=n.slice(d.to-c),c=d.to}}}function mt(e,t,r,n){var i=!n&&r.widgetNode;i&&e.map.push(e.pos,e.pos+t,i),!n&&e.cm.display.input.needsContentAttribute&&(i||(i=e.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",r.id)),i&&(e.cm.display.input.setUneditable(i),e.content.appendChild(i)),e.pos+=t,e.trailingSpace=!1}function gt(e,t,r){var n=e.markedSpans,i=e.text,o=0;if(n)for(var a,l,s,c,u,d,f,h=i.length,p=0,m=1,g="",v=0;;){if(v==p){s=c=u=d=l="",f=null,v=1/0;for(var y=[],b=void 0,w=0;w<n.length;++w){var x=n[w],k=x.marker;"bookmark"==k.type&&x.from==p&&k.widgetNode?y.push(k):x.from<=p&&(null==x.to||x.to>p||k.collapsed&&x.to==p&&x.from==p)?(null!=x.to&&x.to!=p&&v>x.to&&(v=x.to,c=""),k.className&&(s+=" "+k.className),k.css&&(l=(l?l+";":"")+k.css),k.startStyle&&x.from==p&&(u+=" "+k.startStyle),k.endStyle&&x.to==v&&(b||(b=[])).push(k.endStyle,x.to),k.title&&!d&&(d=k.title),k.collapsed&&(!f||oe(f.marker,k)<0)&&(f=x)):x.from>p&&v>x.from&&(v=x.from)}if(b)for(var C=0;C<b.length;C+=2)b[C+1]==v&&(c+=" "+b[C]);if(!f||f.from==p)for(var S=0;S<y.length;++S)mt(t,0,y[S]);if(f&&(f.from||0)==p){if(mt(t,(null==f.to?h+1:f.to)-p,f.marker,null==f.from),null==f.to)return;f.to==p&&(f=!1)}}if(p>=h)break;for(var T=Math.min(h,v);;){if(g){var L=p+g.length;if(!f){var M=L>T?g.slice(0,T-p):g;t.addToken(t,M,a?a+s:s,u,p+M.length==v?c:"",d,l)}if(L>=T){g=g.slice(T-p),p=T;break}p=L,u=""}g=i.slice(o,o=r[m++]),a=ct(r[m++],t.cm.options)}}else for(var A=1;A<r.length;A+=2)t.addToken(t,i.slice(o,o=r[A]),ct(r[A+1],t.cm.options))}function vt(e,t,r){this.line=t,this.rest=fe(t),this.size=this.rest?O(p(this.rest))-r+1:1,this.node=this.text=null,this.hidden=me(e,t)}function yt(e,t,r){for(var n,i=[],o=t;o<r;o=n){var a=new vt(e.doc,L(e.doc,o),o);n=o+a.size,i.push(a)}return i}function bt(e){qa?qa.ops.push(e):e.ownsGroup=qa={ops:[e],delayedCallbacks:[]}}function wt(e){var t=e.delayedCallbacks,r=0;do{for(;r<t.length;r++)t[r].call(null);for(var n=0;n<e.ops.length;n++){var i=e.ops[n];if(i.cursorActivityHandlers)for(;i.cursorActivityCalled<i.cursorActivityHandlers.length;)i.cursorActivityHandlers[i.cursorActivityCalled++].call(null,i.cm)}}while(r<t.length)}function xt(e,t){var r=e.ownsGroup;if(r)try{wt(r)}finally{qa=null,t(r)}}function kt(e,t){var r=Me(e,t);if(r.length){var n,i=Array.prototype.slice.call(arguments,2);qa?n=qa.delayedCallbacks:Ka?n=Ka:(n=Ka=[],setTimeout(Ct,0));for(var o=0;o<r.length;++o)!function(e){n.push(function(){return r[e].apply(null,i)})}(o)}}function Ct(){var e=Ka;Ka=null;for(var t=0;t<e.length;++t)e[t]()}function St(e,t,r,n){for(var i=0;i<t.changes.length;i++){var o=t.changes[i];"text"==o?At(e,t):"gutter"==o?Ot(e,t,r,n):"class"==o?_t(t):"widget"==o&&Nt(e,t,n)}t.changes=null}function Tt(e){return e.node==e.text&&(e.node=n("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),Go&&$o<8&&(e.node.style.zIndex=2)),e.node}function Lt(e){var t=e.bgClass?e.bgClass+" "+(e.line.bgClass||""):e.line.bgClass;if(t&&(t+=" CodeMirror-linebackground"),e.background)t?e.background.className=t:(e.background.parentNode.removeChild(e.background),e.background=null);else if(t){var r=Tt(e);e.background=r.insertBefore(n("div",null,t),r.firstChild)}}function Mt(e,t){var r=e.display.externalMeasured;return r&&r.line==t.line?(e.display.externalMeasured=null,t.measure=r.measure,r.built):ut(e,t)}function At(e,t){var r=t.text.className,n=Mt(e,t);t.text==t.node&&(t.node=n.pre),t.text.parentNode.replaceChild(n.pre,t.text),t.text=n.pre,n.bgClass!=t.bgClass||n.textClass!=t.textClass?(t.bgClass=n.bgClass,t.textClass=n.textClass,_t(t)):r&&(t.text.className=r)}function _t(e){Lt(e),e.line.wrapClass?Tt(e).className=e.line.wrapClass:e.node!=e.text&&(e.node.className="");var t=e.textClass?e.textClass+" "+(e.line.textClass||""):e.line.textClass;e.text.className=t||""}function Ot(e,t,r,i){if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass){var o=Tt(t);t.gutterBackground=n("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?i.fixedPos:-i.gutterTotalWidth)+"px; width: "+i.gutterTotalWidth+"px"),o.insertBefore(t.gutterBackground,t.text)}var a=t.line.gutterMarkers;if(e.options.lineNumbers||a){var l=Tt(t),s=t.gutter=n("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?i.fixedPos:-i.gutterTotalWidth)+"px");if(e.display.input.setUneditable(s),l.insertBefore(s,t.text),t.line.gutterClass&&(s.className+=" "+t.line.gutterClass),!e.options.lineNumbers||a&&a["CodeMirror-linenumbers"]||(t.lineNumber=s.appendChild(n("div",E(e.options,r),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+i.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),a)for(var c=0;c<e.options.gutters.length;++c){var u=e.options.gutters[c],d=a.hasOwnProperty(u)&&a[u];d&&s.appendChild(n("div",[d],"CodeMirror-gutter-elt","left: "+i.gutterLeft[u]+"px; width: "+i.gutterWidth[u]+"px"))}}}function Nt(e,t,r){t.alignable&&(t.alignable=null);for(var n=t.node.firstChild,i=void 0;n;n=i)i=n.nextSibling,"CodeMirror-linewidget"==n.className&&t.node.removeChild(n);Et(e,t,r)}function Wt(e,t,r,n){var i=Mt(e,t);return t.text=t.node=i.pre,i.bgClass&&(t.bgClass=i.bgClass),i.textClass&&(t.textClass=i.textClass),_t(t),Ot(e,t,r,n),Et(e,t,n),t.node}function Et(e,t,r){if(zt(e,t.line,t,r,!0),t.rest)for(var n=0;n<t.rest.length;n++)zt(e,t.rest[n],t,r,!1)}function zt(e,t,r,i,o){if(t.widgets)for(var a=Tt(r),l=0,s=t.widgets;l<s.length;++l){var c=s[l],u=n("div",[c.node],"CodeMirror-linewidget");c.handleMouseEvents||u.setAttribute("cm-ignore-events","true"),Dt(c,u,r,i),e.display.input.setUneditable(u),o&&c.above?a.insertBefore(u,r.gutter||r.text):a.appendChild(u),kt(c,"redraw")}}function Dt(e,t,r,n){if(e.noHScroll){(r.alignable||(r.alignable=[])).push(t);var i=n.wrapperWidth;t.style.left=n.fixedPos+"px",e.coverGutter||(i-=n.gutterTotalWidth,t.style.paddingLeft=n.gutterTotalWidth+"px"),t.style.width=i+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-n.gutterTotalWidth+"px"))}function Pt(e){if(null!=e.height)return e.height;var t=e.doc.cm;if(!t)return 0;if(!i(document.body,e.node)){var o="position: relative;";e.coverGutter&&(o+="margin-left: -"+t.display.gutters.offsetWidth+"px;"),e.noHScroll&&(o+="width: "+t.display.wrapper.clientWidth+"px;"),r(t.display.measure,n("div",[e.node],null,o))}return e.height=e.node.parentNode.offsetHeight}function Ht(e,t){for(var r=Ie(t);r!=e.wrapper;r=r.parentNode)if(!r||1==r.nodeType&&"true"==r.getAttribute("cm-ignore-events")||r.parentNode==e.sizer&&r!=e.mover)return!0}function It(e){return e.lineSpace.offsetTop}function Ft(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function jt(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=r(e.measure,n("pre","x")),i=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,o={left:parseInt(i.paddingLeft),right:parseInt(i.paddingRight)};return isNaN(o.left)||isNaN(o.right)||(e.cachedPaddingH=o),o}function Rt(e){return ga-e.display.nativeBarWidth}function Bt(e){return e.display.scroller.clientWidth-Rt(e)-e.display.barWidth}function qt(e){return e.display.scroller.clientHeight-Rt(e)-e.display.barHeight}function Kt(e,t,r){var n=e.options.lineWrapping,i=n&&Bt(e);if(!t.measure.heights||n&&t.measure.width!=i){var o=t.measure.heights=[];if(n){t.measure.width=i;for(var a=t.text.firstChild.getClientRects(),l=0;l<a.length-1;l++){var s=a[l],c=a[l+1];Math.abs(s.bottom-c.bottom)>2&&o.push((s.bottom+c.top)/2-r.top)}}o.push(r.bottom-r.top)}}function Ut(e,t,r){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var n=0;n<e.rest.length;n++)if(e.rest[n]==t)return{map:e.measure.maps[n],cache:e.measure.caches[n]};for(var i=0;i<e.rest.length;i++)if(O(e.rest[i])>r)return{map:e.measure.maps[i],cache:e.measure.caches[i],before:!0}}function Vt(e,t){t=ue(t);var n=O(t),i=e.display.externalMeasured=new vt(e.doc,t,n);i.lineN=n;var o=i.built=ut(e,i);return i.text=o.pre,r(e.display.lineMeasure,o.pre),i}function Gt(e,t,r,n){return Xt(e,Yt(e,t),r,n)}function $t(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Cr(e,t)];var r=e.display.externalMeasured;return r&&t>=r.lineN&&t<r.lineN+r.size?r:void 0}function Yt(e,t){var r=O(t),n=$t(e,r);n&&!n.text?n=null:n&&n.changes&&(St(e,n,r,yr(e)),e.curOp.forceUpdate=!0),n||(n=Vt(e,t));var i=Ut(n,t,r);return{line:t,view:n,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function Xt(e,t,r,n,i){t.before&&(r=-1);var o,a=r+(n||"");return t.cache.hasOwnProperty(a)?o=t.cache[a]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Kt(e,t.view,t.rect),t.hasHeights=!0),o=Qt(e,t,r,n),o.bogus||(t.cache[a]=o)),{left:o.left,right:o.right,top:i?o.rtop:o.top,bottom:i?o.rbottom:o.bottom}}function Zt(e,t,r){for(var n,i,o,a,l,s,c=0;c<e.length;c+=3)if(l=e[c],s=e[c+1],t<l?(i=0,o=1,a="left"):t<s?(i=t-l,o=i+1):(c==e.length-3||t==s&&e[c+3]>t)&&(o=s-l,i=o-1,t>=s&&(a="right")),null!=i){if(n=e[c+2],l==s&&r==(n.insertLeft?"left":"right")&&(a=r),"left"==r&&0==i)for(;c&&e[c-2]==e[c-3]&&e[c-1].insertLeft;)n=e[2+(c-=3)],a="left";if("right"==r&&i==s-l)for(;c<e.length-3&&e[c+3]==e[c+4]&&!e[c+5].insertLeft;)n=e[2+(c+=3)],a="right";break}return{node:n,start:i,end:o,collapse:a,coverStart:l,coverEnd:s}}function Jt(e,t){var r=Ua;if("left"==t)for(var n=0;n<e.length&&(r=e[n]).left==r.right;n++);else for(var i=e.length-1;i>=0&&(r=e[i]).left==r.right;i--);return r}function Qt(e,t,r,n){var i,o=Zt(t.map,r,n),a=o.node,l=o.start,s=o.end,c=o.collapse;if(3==a.nodeType){for(var u=0;u<4;u++){for(;l&&k(t.line.text.charAt(o.coverStart+l));)--l;for(;o.coverStart+s<o.coverEnd&&k(t.line.text.charAt(o.coverStart+s));)++s;if(i=Go&&$o<9&&0==l&&s==o.coverEnd-o.coverStart?a.parentNode.getBoundingClientRect():Jt(sa(a,l,s).getClientRects(),n),i.left||i.right||0==l)break;s=l,l-=1,c="right"}Go&&$o<11&&(i=er(e.display.measure,i))}else{l>0&&(c=n="right");var d;i=e.options.lineWrapping&&(d=a.getClientRects()).length>1?d["right"==n?d.length-1:0]:a.getBoundingClientRect()}if(Go&&$o<9&&!l&&(!i||!i.left&&!i.right)){var f=a.parentNode.getClientRects()[0];i=f?{left:f.left,right:f.left+vr(e.display),top:f.top,bottom:f.bottom}:Ua}for(var h=i.top-t.rect.top,p=i.bottom-t.rect.top,m=(h+p)/2,g=t.view.measure.heights,v=0;v<g.length-1&&!(m<g[v]);v++);var y=v?g[v-1]:0,b=g[v],w={left:("right"==c?i.right:i.left)-t.rect.left,right:("left"==c?i.left:i.right)-t.rect.left,top:y,bottom:b};return i.left||i.right||(w.bogus=!0),e.options.singleCursorHeightPerLine||(w.rtop=h,w.rbottom=p),w}function er(e,t){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!Be(e))return t;var r=screen.logicalXDPI/screen.deviceXDPI,n=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*r,right:t.right*r,top:t.top*n,bottom:t.bottom*n}}function tr(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function rr(e){e.display.externalMeasure=null,t(e.display.lineMeasure);for(var r=0;r<e.display.view.length;r++)tr(e.display.view[r])}function nr(e){rr(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function ir(){return window.pageXOffset||(document.documentElement||document.body).scrollLeft}function or(){return window.pageYOffset||(document.documentElement||document.body).scrollTop}function ar(e,t,r,n,i){if(!i&&t.widgets)for(var o=0;o<t.widgets.length;++o)if(t.widgets[o].above){var a=Pt(t.widgets[o]);r.top+=a,r.bottom+=a}if("line"==n)return r;n||(n="local");var l=ve(t);if("local"==n?l+=It(e.display):l-=e.display.viewOffset,"page"==n||"window"==n){var s=e.display.lineSpace.getBoundingClientRect();l+=s.top+("window"==n?0:or());var c=s.left+("window"==n?0:ir());r.left+=c,r.right+=c}return r.top+=l,r.bottom+=l,r}function lr(e,t,r){if("div"==r)return t;var n=t.left,i=t.top;if("page"==r)n-=ir(),i-=or();else if("local"==r||!r){var o=e.display.sizer.getBoundingClientRect();n+=o.left,i+=o.top}var a=e.display.lineSpace.getBoundingClientRect();return{left:n-a.left,top:i-a.top}}function sr(e,t,r,n,i){return n||(n=L(e.doc,t.line)),ar(e,n,Gt(e,n,t.ch,i),r)}function cr(e,t,r,n,i,o){function a(t,a){var l=Xt(e,i,t,a?"right":"left",o);return a?l.left=l.right:l.right=l.left,ar(e,n,l,r)}function l(e,t,r){var n=s[t],i=n.level%2!=0;return a(r?e-1:e,i!=r)}n=n||L(e.doc,t.line),i||(i=Yt(e,n));var s=ke(n),c=t.ch,u=t.sticky;if(c>=n.text.length?(c=n.text.length,u="before"):c<=0&&(c=0,u="after"),!s)return a("before"==u?c-1:c,"before"==u);var d=xe(s,c,u),f=La,h=l(c,d,"before"==u);return null!=f&&(h.other=l(c,f,"before"!=u)),h}function ur(e,t){var r=0;t=R(e.doc,t),e.options.lineWrapping||(r=vr(e.display)*t.ch);var n=L(e.doc,t.line),i=ve(n)+It(e.display);return{left:r,right:r,top:i,bottom:i+n.height}}function dr(e,t,r,n,i){var o=z(e,t,r);return o.xRel=i,n&&(o.outside=!0),o}function fr(e,t,r){var n=e.doc;if((r+=e.display.viewOffset)<0)return dr(n.first,0,null,!0,-1);var i=N(n,r),o=n.first+n.size-1;if(i>o)return dr(n.first+n.size-1,L(n,o).text.length,null,!0,1);t<0&&(t=0);for(var a=L(n,i);;){var l=mr(e,a,i,t,r),s=se(a),c=s&&s.find(0,!0);if(!s||!(l.ch>c.from.ch||l.ch==c.from.ch&&l.xRel>0))return l;i=O(a=c.to.line)}}function hr(e,t,r,n){var i=function(n){return ar(e,t,Xt(e,r,n),"line")},o=t.text.length,a=S(function(e){return i(e-1).bottom<=n},o,0);return o=S(function(e){return i(e).top>n},a,o),{begin:a,end:o}}function pr(e,t,r,n){return hr(e,t,r,ar(e,t,Xt(e,r,n),"line").top)}function mr(e,t,r,n,i){i-=ve(t);var o,a=0,l=t.text.length,s=Yt(e,t);if(ke(t)){if(e.options.lineWrapping){var c;c=hr(e,t,s,i),a=c.begin,l=c.end}o=new z(r,a);var u,d,f=cr(e,o,"line",t,s).left,h=f<n?1:-1,p=f-n;do{if(u=p,d=o,null==(o=Le(e,t,o,h))||o.ch<a||l<=("before"==o.sticky?o.ch-1:o.ch)){o=d;break}p=cr(e,o,"line",t,s).left-n}while(h<0!=p<0&&Math.abs(p)<=Math.abs(u));if(Math.abs(p)>Math.abs(u)){if(p<0==u<0)throw new Error("Broke out of infinite loop in coordsCharInner");o=d}}else{var m=S(function(r){var o=ar(e,t,Xt(e,s,r),"line");return o.top>i?(l=Math.min(r,l),!0):!(o.bottom<=i)&&(o.left>n||!(o.right<n)&&n-o.left<o.right-n)},a,l);m=C(t.text,m,1),o=new z(r,m,m==l?"before":"after")}var g=cr(e,o,"line",t,s);return(i<g.top||g.bottom<i)&&(o.outside=!0),o.xRel=n<g.left?-1:n>g.right?1:0,o}function gr(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==ja){ja=n("pre");for(var i=0;i<49;++i)ja.appendChild(document.createTextNode("x")),ja.appendChild(n("br"));ja.appendChild(document.createTextNode("x"))}r(e.measure,ja);var o=ja.offsetHeight/50;return o>3&&(e.cachedTextHeight=o),t(e.measure),o||1}function vr(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=n("span","xxxxxxxxxx"),i=n("pre",[t]);r(e.measure,i);var o=t.getBoundingClientRect(),a=(o.right-o.left)/10;return a>2&&(e.cachedCharWidth=a),a||10}function yr(e){for(var t=e.display,r={},n={},i=t.gutters.clientLeft,o=t.gutters.firstChild,a=0;o;o=o.nextSibling,++a)r[e.options.gutters[a]]=o.offsetLeft+o.clientLeft+i,n[e.options.gutters[a]]=o.clientWidth;return{fixedPos:br(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:r,gutterWidth:n,wrapperWidth:t.wrapper.clientWidth}}function br(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function wr(e){var t=gr(e.display),r=e.options.lineWrapping,n=r&&Math.max(5,e.display.scroller.clientWidth/vr(e.display)-3);return function(i){if(me(e.doc,i))return 0;var o=0;if(i.widgets)for(var a=0;a<i.widgets.length;a++)i.widgets[a].height&&(o+=i.widgets[a].height);return r?o+(Math.ceil(i.text.length/n)||1)*t:o+t}}function xr(e){var t=e.doc,r=wr(e);t.iter(function(e){var t=r(e);t!=e.height&&_(e,t)})}function kr(e,t,r,n){var i=e.display;if(!r&&"true"==Ie(t).getAttribute("cm-not-content"))return null;var o,a,l=i.lineSpace.getBoundingClientRect();try{o=t.clientX-l.left,a=t.clientY-l.top}catch(e){return null}var s,c=fr(e,o,a);if(n&&1==c.xRel&&(s=L(e.doc,c.line).text).length==c.ch){var d=u(s,s.length,e.options.tabSize)-s.length;c=z(c.line,Math.max(0,Math.round((o-jt(e.display).left)/vr(e.display))-d))}return c}function Cr(e,t){if(t>=e.display.viewTo)return null;if((t-=e.display.viewFrom)<0)return null;for(var r=e.display.view,n=0;n<r.length;n++)if((t-=r[n].size)<0)return n}function Sr(e){
3
+ e.display.input.showSelection(e.display.input.prepareSelection())}function Tr(e,t){for(var r=e.doc,n={},i=n.cursors=document.createDocumentFragment(),o=n.selection=document.createDocumentFragment(),a=0;a<r.sel.ranges.length;a++)if(t!==!1||a!=r.sel.primIndex){var l=r.sel.ranges[a];if(!(l.from().line>=e.display.viewTo||l.to().line<e.display.viewFrom)){var s=l.empty();(s||e.options.showCursorWhenSelecting)&&Lr(e,l.head,i),s||Mr(e,l,o)}}return n}function Lr(e,t,r){var i=cr(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),o=r.appendChild(n("div"," ","CodeMirror-cursor"));if(o.style.left=i.left+"px",o.style.top=i.top+"px",o.style.height=Math.max(0,i.bottom-i.top)*e.options.cursorHeight+"px",i.other){var a=r.appendChild(n("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));a.style.display="",a.style.left=i.other.left+"px",a.style.top=i.other.top+"px",a.style.height=.85*(i.other.bottom-i.other.top)+"px"}}function Mr(e,t,r){function i(e,t,r,i){t<0&&(t=0),t=Math.round(t),i=Math.round(i),s.appendChild(n("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px;\n top: "+t+"px; width: "+(null==r?d-e:r)+"px;\n height: "+(i-t)+"px"))}function o(t,r,n){function o(r,n){return sr(e,z(t,r),"div",c,n)}var a,s,c=L(l,t),f=c.text.length;return we(ke(c),r||0,null==n?f:n,function(e,t,l){var c,h,p,m=o(e,"left");if(e==t)c=m,h=p=m.left;else{if(c=o(t-1,"right"),"rtl"==l){var g=m;m=c,c=g}h=m.left,p=c.right}null==r&&0==e&&(h=u),c.top-m.top>3&&(i(h,m.top,null,m.bottom),h=u,m.bottom<c.top&&i(h,m.bottom,null,c.top)),null==n&&t==f&&(p=d),(!a||m.top<a.top||m.top==a.top&&m.left<a.left)&&(a=m),(!s||c.bottom>s.bottom||c.bottom==s.bottom&&c.right>s.right)&&(s=c),h<u+1&&(h=u),i(h,c.top,p-h,c.bottom)}),{start:a,end:s}}var a=e.display,l=e.doc,s=document.createDocumentFragment(),c=jt(e.display),u=c.left,d=Math.max(a.sizerWidth,Bt(e)-a.sizer.offsetLeft)-c.right,f=t.from(),h=t.to();if(f.line==h.line)o(f.line,f.ch,h.ch);else{var p=L(l,f.line),m=L(l,h.line),g=ue(p)==ue(m),v=o(f.line,f.ch,g?p.text.length+1:null).end,y=o(h.line,g?0:null,h.ch).start;g&&(v.top<y.top-2?(i(v.right,v.top,null,v.bottom),i(u,y.top,y.left,y.bottom)):i(v.right,v.top,y.left-v.right,v.bottom)),v.bottom<y.top&&i(u,v.bottom,null,y.top)}r.appendChild(s)}function Ar(e){if(e.state.focused){var t=e.display;clearInterval(t.blinker);var r=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){return t.cursorDiv.style.visibility=(r=!r)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function _r(e){e.state.focused||(e.display.input.focus(),Nr(e))}function Or(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,Wr(e))},100)}function Nr(e,t){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(_e(e,"focus",e,t),e.state.focused=!0,a(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),Yo&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Ar(e))}function Wr(e,t){e.state.delayingBlurEvent||(e.state.focused&&(_e(e,"blur",e,t),e.state.focused=!1,da(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function Er(e){var t=e.display,r=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var n=br(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=n+"px",a=0;a<r.length;a++)if(!r[a].hidden){e.options.fixedGutter&&(r[a].gutter&&(r[a].gutter.style.left=o),r[a].gutterBackground&&(r[a].gutterBackground.style.left=o));var l=r[a].alignable;if(l)for(var s=0;s<l.length;s++)l[s].style.left=o}e.options.fixedGutter&&(t.gutters.style.left=n+i+"px")}}function zr(e){if(!e.options.lineNumbers)return!1;var t=e.doc,r=E(e.options,t.first+t.size-1),i=e.display;if(r.length!=i.lineNumChars){var o=i.measure.appendChild(n("div",[n("div",r)],"CodeMirror-linenumber CodeMirror-gutter-elt")),a=o.firstChild.offsetWidth,l=o.offsetWidth-a;return i.lineGutter.style.width="",i.lineNumInnerWidth=Math.max(a,i.lineGutter.offsetWidth-l)+1,i.lineNumWidth=i.lineNumInnerWidth+l,i.lineNumChars=i.lineNumInnerWidth?r.length:-1,i.lineGutter.style.width=i.lineNumWidth+"px",Ln(e),!0}return!1}function Dr(e){for(var t=e.display,r=t.lineDiv.offsetTop,n=0;n<t.view.length;n++){var i=t.view[n],o=void 0;if(!i.hidden){if(Go&&$o<8){var a=i.node.offsetTop+i.node.offsetHeight;o=a-r,r=a}else{var l=i.node.getBoundingClientRect();o=l.bottom-l.top}var s=i.line.height-o;if(o<2&&(o=gr(t)),(s>.001||s<-.001)&&(_(i.line,o),Pr(i.line),i.rest))for(var c=0;c<i.rest.length;c++)Pr(i.rest[c])}}}function Pr(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t)e.widgets[t].height=e.widgets[t].node.parentNode.offsetHeight}function Hr(e,t,r){var n=r&&null!=r.top?Math.max(0,r.top):e.scroller.scrollTop;n=Math.floor(n-It(e));var i=r&&null!=r.bottom?r.bottom:n+e.wrapper.clientHeight,o=N(t,n),a=N(t,i);if(r&&r.ensure){var l=r.ensure.from.line,s=r.ensure.to.line;l<o?(o=l,a=N(t,ve(L(t,l))+e.wrapper.clientHeight)):Math.min(s,t.lastLine())>=a&&(o=N(t,ve(L(t,s))-e.wrapper.clientHeight),a=s)}return{from:o,to:Math.max(a,o+1)}}function Ir(e,t){Math.abs(e.doc.scrollTop-t)<2||(e.doc.scrollTop=t,qo||Sn(e,{top:t}),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t),e.display.scrollbars.setScrollTop(t),qo&&Sn(e),bn(e,100))}function Fr(e,t,r){(r?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)||(t=Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth),e.doc.scrollLeft=t,Er(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function jr(e){var t=e.wheelDeltaX,r=e.wheelDeltaY;return null==t&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),null==r&&e.detail&&e.axis==e.VERTICAL_AXIS?r=e.detail:null==r&&(r=e.wheelDelta),{x:t,y:r}}function Rr(e){var t=jr(e);return t.x*=Ga,t.y*=Ga,t}function Br(e,t){var r=jr(t),n=r.x,i=r.y,o=e.display,a=o.scroller,l=a.scrollWidth>a.clientWidth,s=a.scrollHeight>a.clientHeight;if(n&&l||i&&s){if(i&&ia&&Yo)e:for(var c=t.target,u=o.view;c!=a;c=c.parentNode)for(var d=0;d<u.length;d++)if(u[d].node==c){e.display.currentWheelTarget=c;break e}if(n&&!qo&&!Jo&&null!=Ga)return i&&s&&Ir(e,Math.max(0,Math.min(a.scrollTop+i*Ga,a.scrollHeight-a.clientHeight))),Fr(e,Math.max(0,Math.min(a.scrollLeft+n*Ga,a.scrollWidth-a.clientWidth))),(!i||i&&s)&&ze(t),void(o.wheelStartX=null);if(i&&null!=Ga){var f=i*Ga,h=e.doc.scrollTop,p=h+o.wrapper.clientHeight;f<0?h=Math.max(0,h+f-50):p=Math.min(e.doc.height,p+f+50),Sn(e,{top:h,bottom:p})}Va<20&&(null==o.wheelStartX?(o.wheelStartX=a.scrollLeft,o.wheelStartY=a.scrollTop,o.wheelDX=n,o.wheelDY=i,setTimeout(function(){if(null!=o.wheelStartX){var e=a.scrollLeft-o.wheelStartX,t=a.scrollTop-o.wheelStartY,r=t&&o.wheelDY&&t/o.wheelDY||e&&o.wheelDX&&e/o.wheelDX;o.wheelStartX=o.wheelStartY=null,r&&(Ga=(Ga*Va+r)/(Va+1),++Va)}},200)):(o.wheelDX+=n,o.wheelDY+=i))}}function qr(e){var t=e.display,r=t.gutters.offsetWidth,n=Math.round(e.doc.height+Ft(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?r:0,docHeight:n,scrollHeight:n+Rt(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:r}}function Kr(e,t){t||(t=qr(e));var r=e.display.barWidth,n=e.display.barHeight;Ur(e,t);for(var i=0;i<4&&r!=e.display.barWidth||n!=e.display.barHeight;i++)r!=e.display.barWidth&&e.options.lineWrapping&&Dr(e),Ur(e,qr(e)),r=e.display.barWidth,n=e.display.barHeight}function Ur(e,t){var r=e.display,n=r.scrollbars.update(t);r.sizer.style.paddingRight=(r.barWidth=n.right)+"px",r.sizer.style.paddingBottom=(r.barHeight=n.bottom)+"px",r.heightForcer.style.borderBottom=n.bottom+"px solid transparent",n.right&&n.bottom?(r.scrollbarFiller.style.display="block",r.scrollbarFiller.style.height=n.bottom+"px",r.scrollbarFiller.style.width=n.right+"px"):r.scrollbarFiller.style.display="",n.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(r.gutterFiller.style.display="block",r.gutterFiller.style.height=n.bottom+"px",r.gutterFiller.style.width=t.gutterWidth+"px"):r.gutterFiller.style.display=""}function Vr(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&da(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new Xa[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),_a(t,"mousedown",function(){e.state.focused&&setTimeout(function(){return e.display.input.focus()},0)}),t.setAttribute("cm-not-content","true")},function(t,r){"horizontal"==r?Fr(e,t):Ir(e,t)},e),e.display.scrollbars.addClass&&a(e.display.wrapper,e.display.scrollbars.addClass)}function Gr(e,t){if(!Oe(e,"scrollCursorIntoView")){var r=e.display,i=r.sizer.getBoundingClientRect(),o=null;if(t.top+i.top<0?o=!0:t.bottom+i.top>(window.innerHeight||document.documentElement.clientHeight)&&(o=!1),null!=o&&!ta){var a=n("div","​",null,"position: absolute;\n top: "+(t.top-r.viewOffset-It(e.display))+"px;\n height: "+(t.bottom-t.top+Rt(e)+r.barHeight)+"px;\n left: "+t.left+"px; width: 2px;");e.display.lineSpace.appendChild(a),a.scrollIntoView(o),e.display.lineSpace.removeChild(a)}}}function $r(e,t,r,n){null==n&&(n=0);for(var i,o=0;o<5;o++){var a=!1;i=cr(e,t);var l=r&&r!=t?cr(e,r):i,s=Xr(e,Math.min(i.left,l.left),Math.min(i.top,l.top)-n,Math.max(i.left,l.left),Math.max(i.bottom,l.bottom)+n),c=e.doc.scrollTop,u=e.doc.scrollLeft;if(null!=s.scrollTop&&(Ir(e,s.scrollTop),Math.abs(e.doc.scrollTop-c)>1&&(a=!0)),null!=s.scrollLeft&&(Fr(e,s.scrollLeft),Math.abs(e.doc.scrollLeft-u)>1&&(a=!0)),!a)break}return i}function Yr(e,t,r,n,i){var o=Xr(e,t,r,n,i);null!=o.scrollTop&&Ir(e,o.scrollTop),null!=o.scrollLeft&&Fr(e,o.scrollLeft)}function Xr(e,t,r,n,i){var o=e.display,a=gr(e.display);r<0&&(r=0);var l=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:o.scroller.scrollTop,s=qt(e),c={};i-r>s&&(i=r+s);var u=e.doc.height+Ft(o),d=r<a,f=i>u-a;if(r<l)c.scrollTop=d?0:r;else if(i>l+s){var h=Math.min(r,(f?u:i)-s);h!=l&&(c.scrollTop=h)}var p=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:o.scroller.scrollLeft,m=Bt(e)-(e.options.fixedGutter?o.gutters.offsetWidth:0),g=n-t>m;return g&&(n=t+m),t<10?c.scrollLeft=0:t<p?c.scrollLeft=Math.max(0,t-(g?0:10)):n>m+p-3&&(c.scrollLeft=n+(g?0:10)-m),c}function Zr(e,t,r){null==t&&null==r||Qr(e),null!=t&&(e.curOp.scrollLeft=(null==e.curOp.scrollLeft?e.doc.scrollLeft:e.curOp.scrollLeft)+t),null!=r&&(e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+r)}function Jr(e){Qr(e);var t=e.getCursor(),r=t,n=t;e.options.lineWrapping||(r=t.ch?z(t.line,t.ch-1):t,n=z(t.line,t.ch+1)),e.curOp.scrollToPos={from:r,to:n,margin:e.options.cursorScrollMargin,isCursor:!0}}function Qr(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var r=ur(e,t.from),n=ur(e,t.to),i=Xr(e,Math.min(r.left,n.left),Math.min(r.top,n.top)-t.margin,Math.max(r.right,n.right),Math.max(r.bottom,n.bottom)+t.margin);e.scrollTo(i.scrollLeft,i.scrollTop)}}function en(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Za},bt(e.curOp)}function tn(e){xt(e.curOp,function(e){for(var t=0;t<e.ops.length;t++)e.ops[t].cm.curOp=null;rn(e)})}function rn(e){for(var t=e.ops,r=0;r<t.length;r++)nn(t[r]);for(var n=0;n<t.length;n++)on(t[n]);for(var i=0;i<t.length;i++)an(t[i]);for(var o=0;o<t.length;o++)ln(t[o]);for(var a=0;a<t.length;a++)sn(t[a])}function nn(e){var t=e.cm,r=t.display;xn(t),e.updateMaxLine&&be(t),e.mustUpdate=e.viewChanged||e.forceUpdate||null!=e.scrollTop||e.scrollToPos&&(e.scrollToPos.from.line<r.viewFrom||e.scrollToPos.to.line>=r.viewTo)||r.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new Ja(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function on(e){e.updatedDisplay=e.mustUpdate&&kn(e.cm,e.update)}function an(e){var t=e.cm,r=t.display;e.updatedDisplay&&Dr(t),e.barMeasure=qr(t),r.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=Gt(t,r.maxLine,r.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(r.scroller.clientWidth,r.sizer.offsetLeft+e.adjustWidthTo+Rt(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,r.sizer.offsetLeft+e.adjustWidthTo-Bt(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=r.input.prepareSelection(e.focus))}function ln(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&Fr(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1);var r=e.focus&&e.focus==o()&&(!document.hasFocus||document.hasFocus());e.preparedSelection&&t.display.input.showSelection(e.preparedSelection,r),(e.updatedDisplay||e.startHeight!=t.doc.height)&&Kr(t,e.barMeasure),e.updatedDisplay&&Mn(t,e.barMeasure),e.selectionChanged&&Ar(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),r&&_r(e.cm)}function sn(e){var t=e.cm,r=t.display,n=t.doc;if(e.updatedDisplay&&Cn(t,e.update),null==r.wheelStartX||null==e.scrollTop&&null==e.scrollLeft&&!e.scrollToPos||(r.wheelStartX=r.wheelStartY=null),null==e.scrollTop||r.scroller.scrollTop==e.scrollTop&&!e.forceScroll||(n.scrollTop=Math.max(0,Math.min(r.scroller.scrollHeight-r.scroller.clientHeight,e.scrollTop)),r.scrollbars.setScrollTop(n.scrollTop),r.scroller.scrollTop=n.scrollTop),null==e.scrollLeft||r.scroller.scrollLeft==e.scrollLeft&&!e.forceScroll||(n.scrollLeft=Math.max(0,Math.min(r.scroller.scrollWidth-r.scroller.clientWidth,e.scrollLeft)),r.scrollbars.setScrollLeft(n.scrollLeft),r.scroller.scrollLeft=n.scrollLeft,Er(t)),e.scrollToPos){var i=$r(t,R(n,e.scrollToPos.from),R(n,e.scrollToPos.to),e.scrollToPos.margin);e.scrollToPos.isCursor&&t.state.focused&&Gr(t,i)}var o=e.maybeHiddenMarkers,a=e.maybeUnhiddenMarkers;if(o)for(var l=0;l<o.length;++l)o[l].lines.length||_e(o[l],"hide");if(a)for(var s=0;s<a.length;++s)a[s].lines.length&&_e(a[s],"unhide");r.wrapper.offsetHeight&&(n.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&_e(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function cn(e,t){if(e.curOp)return t();en(e);try{return t()}finally{tn(e)}}function un(e,t){return function(){if(e.curOp)return t.apply(e,arguments);en(e);try{return t.apply(e,arguments)}finally{tn(e)}}}function dn(e){return function(){if(this.curOp)return e.apply(this,arguments);en(this);try{return e.apply(this,arguments)}finally{tn(this)}}}function fn(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);en(t);try{return e.apply(this,arguments)}finally{tn(t)}}}function hn(e,t,r,n){null==t&&(t=e.doc.first),null==r&&(r=e.doc.first+e.doc.size),n||(n=0);var i=e.display;if(n&&r<i.viewTo&&(null==i.updateLineNumbers||i.updateLineNumbers>t)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)Ta&&he(e.doc,t)<i.viewTo&&mn(e);else if(r<=i.viewFrom)Ta&&pe(e.doc,r+n)>i.viewFrom?mn(e):(i.viewFrom+=n,i.viewTo+=n);else if(t<=i.viewFrom&&r>=i.viewTo)mn(e);else if(t<=i.viewFrom){var o=gn(e,r,r+n,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=n):mn(e)}else if(r>=i.viewTo){var a=gn(e,t,t,-1);a?(i.view=i.view.slice(0,a.index),i.viewTo=a.lineN):mn(e)}else{var l=gn(e,t,t,-1),s=gn(e,r,r+n,1);l&&s?(i.view=i.view.slice(0,l.index).concat(yt(e,l.lineN,s.lineN)).concat(i.view.slice(s.index)),i.viewTo+=n):mn(e)}var c=i.externalMeasured;c&&(r<c.lineN?c.lineN+=n:t<c.lineN+c.size&&(i.externalMeasured=null))}function pn(e,t,r){e.curOp.viewChanged=!0;var n=e.display,i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size&&(n.externalMeasured=null),!(t<n.viewFrom||t>=n.viewTo)){var o=n.view[Cr(e,t)];if(null!=o.node){var a=o.changes||(o.changes=[]);d(a,r)==-1&&a.push(r)}}}function mn(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function gn(e,t,r,n){var i,o=Cr(e,t),a=e.display.view;if(!Ta||r==e.doc.first+e.doc.size)return{index:o,lineN:r};for(var l=e.display.viewFrom,s=0;s<o;s++)l+=a[s].size;if(l!=t){if(n>0){if(o==a.length-1)return null;i=l+a[o].size-t,o++}else i=l-t;t+=i,r+=i}for(;he(e.doc,r)!=r;){if(o==(n<0?0:a.length-1))return null;r+=n*a[o-(n<0?1:0)].size,o+=n}return{index:o,lineN:r}}function vn(e,t,r){var n=e.display;0==n.view.length||t>=n.viewTo||r<=n.viewFrom?(n.view=yt(e,t,r),n.viewFrom=t):(n.viewFrom>t?n.view=yt(e,t,n.viewFrom).concat(n.view):n.viewFrom<t&&(n.view=n.view.slice(Cr(e,t))),n.viewFrom=t,n.viewTo<r?n.view=n.view.concat(yt(e,n.viewTo,r)):n.viewTo>r&&(n.view=n.view.slice(0,Cr(e,r)))),n.viewTo=r}function yn(e){for(var t=e.display.view,r=0,n=0;n<t.length;n++){var i=t[n];i.hidden||i.node&&!i.changes||++r}return r}function bn(e,t){e.doc.mode.startState&&e.doc.frontier<e.display.viewTo&&e.state.highlight.set(t,s(wn,e))}function wn(e){var t=e.doc;if(t.frontier<t.first&&(t.frontier=t.first),!(t.frontier>=e.display.viewTo)){var r=+new Date+e.options.workTime,n=$e(t.mode,Qe(e,t.frontier)),i=[];t.iter(t.frontier,Math.min(t.first+t.size,e.display.viewTo+500),function(o){if(t.frontier>=e.display.viewFrom){var a=o.styles,l=o.text.length>e.options.maxHighlightLength,s=Ze(e,o,l?$e(t.mode,n):n,!0);o.styles=s.styles;var c=o.styleClasses,u=s.classes;u?o.styleClasses=u:c&&(o.styleClasses=null);for(var d=!a||a.length!=o.styles.length||c!=u&&(!c||!u||c.bgClass!=u.bgClass||c.textClass!=u.textClass),f=0;!d&&f<a.length;++f)d=a[f]!=o.styles[f];d&&i.push(t.frontier),o.stateAfter=l?n:$e(t.mode,n)}else o.text.length<=e.options.maxHighlightLength&&et(e,o.text,n),o.stateAfter=t.frontier%5==0?$e(t.mode,n):null;if(++t.frontier,+new Date>r)return bn(e,e.options.workDelay),!0}),i.length&&cn(e,function(){for(var t=0;t<i.length;t++)pn(e,i[t],"text")})}}function xn(e){var t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=Rt(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=Rt(e)+"px",t.scrollbarsClipped=!0)}function kn(e,r){var n=e.display,i=e.doc;if(r.editorIsHidden)return mn(e),!1;if(!r.force&&r.visible.from>=n.viewFrom&&r.visible.to<=n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&0==yn(e))return!1;zr(e)&&(mn(e),r.dims=yr(e));var a=i.first+i.size,l=Math.max(r.visible.from-e.options.viewportMargin,i.first),s=Math.min(a,r.visible.to+e.options.viewportMargin);n.viewFrom<l&&l-n.viewFrom<20&&(l=Math.max(i.first,n.viewFrom)),n.viewTo>s&&n.viewTo-s<20&&(s=Math.min(a,n.viewTo)),Ta&&(l=he(e.doc,l),s=pe(e.doc,s));var c=l!=n.viewFrom||s!=n.viewTo||n.lastWrapHeight!=r.wrapperHeight||n.lastWrapWidth!=r.wrapperWidth;vn(e,l,s),n.viewOffset=ve(L(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var u=yn(e);if(!c&&0==u&&!r.force&&n.renderedView==n.view&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo))return!1;var d=o();return u>4&&(n.lineDiv.style.display="none"),Tn(e,n.updateLineNumbers,r.dims),u>4&&(n.lineDiv.style.display=""),n.renderedView=n.view,d&&o()!=d&&d.offsetHeight&&d.focus(),t(n.cursorDiv),t(n.selectionDiv),n.gutters.style.height=n.sizer.style.minHeight=0,c&&(n.lastWrapHeight=r.wrapperHeight,n.lastWrapWidth=r.wrapperWidth,bn(e,400)),n.updateLineNumbers=null,!0}function Cn(e,t){for(var r=t.viewport,n=!0;(n&&e.options.lineWrapping&&t.oldDisplayWidth!=Bt(e)||(r&&null!=r.top&&(r={top:Math.min(e.doc.height+Ft(e.display)-qt(e),r.top)}),t.visible=Hr(e.display,e.doc,r),!(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)))&&kn(e,t);n=!1){Dr(e);var i=qr(e);Sr(e),Kr(e,i),Mn(e,i)}t.signal(e,"update",e),e.display.viewFrom==e.display.reportedViewFrom&&e.display.viewTo==e.display.reportedViewTo||(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function Sn(e,t){var r=new Ja(e,t);if(kn(e,r)){Dr(e),Cn(e,r);var n=qr(e);Sr(e),Kr(e,n),Mn(e,n),r.finish()}}function Tn(e,r,n){function i(t){var r=t.nextSibling;return Yo&&ia&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),r}for(var o=e.display,a=e.options.lineNumbers,l=o.lineDiv,s=l.firstChild,c=o.view,u=o.viewFrom,f=0;f<c.length;f++){var h=c[f];if(h.hidden);else if(h.node&&h.node.parentNode==l){for(;s!=h.node;)s=i(s);var p=a&&null!=r&&r<=u&&h.lineNumber;h.changes&&(d(h.changes,"gutter")>-1&&(p=!1),St(e,h,u,n)),p&&(t(h.lineNumber),h.lineNumber.appendChild(document.createTextNode(E(e.options,u)))),s=h.node.nextSibling}else{var m=Wt(e,h,u,n);l.insertBefore(m,s)}u+=h.size}for(;s;)s=i(s)}function Ln(e){var t=e.display.gutters.offsetWidth;e.display.sizer.style.marginLeft=t+"px"}function Mn(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+Rt(e)+"px"}function An(e){var r=e.display.gutters,i=e.options.gutters;t(r);for(var o=0;o<i.length;++o){var a=i[o],l=r.appendChild(n("div",null,"CodeMirror-gutter "+a));"CodeMirror-linenumbers"==a&&(e.display.lineGutter=l,l.style.width=(e.display.lineNumWidth||1)+"px")}r.style.display=o?"":"none",Ln(e)}function _n(e){var t=d(e.gutters,"CodeMirror-linenumbers");t==-1&&e.lineNumbers?e.gutters=e.gutters.concat(["CodeMirror-linenumbers"]):t>-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}function On(e,t){var r=e[t];e.sort(function(e,t){return D(e.from(),t.from())}),t=d(e,r);for(var n=1;n<e.length;n++){var i=e[n],o=e[n-1];if(D(o.to(),i.from())>=0){var a=F(o.from(),i.from()),l=I(o.to(),i.to()),s=o.empty()?i.from()==i.head:o.from()==o.head;n<=t&&--t,e.splice(--n,2,new el(s?l:a,s?a:l))}}return new Qa(e,t)}function Nn(e,t){return new Qa([new el(e,t||e)],0)}function Wn(e){return e.text?z(e.from.line+e.text.length-1,p(e.text).length+(1==e.text.length?e.from.ch:0)):e.to}function En(e,t){if(D(e,t.from)<0)return e;if(D(e,t.to)<=0)return Wn(t);var r=e.line+t.text.length-(t.to.line-t.from.line)-1,n=e.ch;return e.line==t.to.line&&(n+=Wn(t).ch-t.to.ch),z(r,n)}function zn(e,t){for(var r=[],n=0;n<e.sel.ranges.length;n++){var i=e.sel.ranges[n];r.push(new el(En(i.anchor,t),En(i.head,t)))}return On(r,e.sel.primIndex)}function Dn(e,t,r){return e.line==t.line?z(r.line,e.ch-t.ch+r.ch):z(r.line+(e.line-t.line),e.ch)}function Pn(e,t,r){for(var n=[],i=z(e.first,0),o=i,a=0;a<t.length;a++){var l=t[a],s=Dn(l.from,i,o),c=Dn(Wn(l),i,o);if(i=l.to,o=c,"around"==r){var u=e.sel.ranges[a],d=D(u.head,u.anchor)<0;n[a]=new el(d?c:s,d?s:c)}else n[a]=new el(s,s)}return new Qa(n,e.sel.primIndex)}function Hn(e){e.doc.mode=Ve(e.options,e.doc.modeOption),In(e)}function In(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.frontier=e.doc.first,bn(e,100),e.state.modeGen++,e.curOp&&hn(e)}function Fn(e,t){return 0==t.from.ch&&0==t.to.ch&&""==p(t.text)&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function jn(e,t,r,n){function i(e){return r?r[e]:null}function o(e,r,i){lt(e,r,i,n),kt(e,"change",e,t)}function a(e,t){for(var r=[],o=e;o<t;++o)r.push(new Fa(c[o],i(o),n));return r}var l=t.from,s=t.to,c=t.text,u=L(e,l.line),d=L(e,s.line),f=p(c),h=i(c.length-1),m=s.line-l.line;if(t.full)e.insert(0,a(0,c.length)),e.remove(c.length,e.size-c.length);else if(Fn(e,t)){var g=a(0,c.length-1);o(d,d.text,h),m&&e.remove(l.line,m),g.length&&e.insert(l.line,g)}else if(u==d)if(1==c.length)o(u,u.text.slice(0,l.ch)+f+u.text.slice(s.ch),h);else{var v=a(1,c.length-1);v.push(new Fa(f+u.text.slice(s.ch),h,n)),o(u,u.text.slice(0,l.ch)+c[0],i(0)),e.insert(l.line+1,v)}else if(1==c.length)o(u,u.text.slice(0,l.ch)+c[0]+d.text.slice(s.ch),i(0)),e.remove(l.line+1,m);else{o(u,u.text.slice(0,l.ch)+c[0],i(0)),o(d,f+d.text.slice(s.ch),h);var y=a(1,c.length-1);m>1&&e.remove(l.line+1,m-1),e.insert(l.line+1,y)}kt(e,"change",e,t)}function Rn(e,t,r){function n(e,i,o){if(e.linked)for(var a=0;a<e.linked.length;++a){var l=e.linked[a];if(l.doc!=i){var s=o&&l.sharedHist;r&&!s||(t(l.doc,s),n(l.doc,e,s))}}}n(e,null,!0)}function Bn(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,xr(e),Hn(e),e.options.lineWrapping||be(e),e.options.mode=t.modeOption,hn(e)}function qn(e){this.done=[],this.undone=[],this.undoDepth=1/0,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e||1}function Kn(e,t){var r={from:H(t.from),to:Wn(t),text:M(e,t.from,t.to)};return Zn(e,r,t.from.line,t.to.line+1),Rn(e,function(e){return Zn(e,r,t.from.line,t.to.line+1)},!0),r}function Un(e){for(;e.length;){if(!p(e).ranges)break;e.pop()}}function Vn(e,t){return t?(Un(e.done),p(e.done)):e.done.length&&!p(e.done).ranges?p(e.done):e.done.length>1&&!e.done[e.done.length-2].ranges?(e.done.pop(),p(e.done)):void 0}function Gn(e,t,r,n){var i=e.history;i.undone.length=0;var o,a,l=+new Date;if((i.lastOp==n||i.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&e.cm&&i.lastModTime>l-e.cm.options.historyEventDelay||"*"==t.origin.charAt(0)))&&(o=Vn(i,i.lastOp==n)))a=p(o.changes),0==D(t.from,t.to)&&0==D(t.from,a.to)?a.to=Wn(t):o.changes.push(Kn(e,t));else{var s=p(i.done);for(s&&s.ranges||Xn(e.sel,i.done),o={changes:[Kn(e,t)],generation:i.generation},i.done.push(o);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(r),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=l,i.lastOp=i.lastSelOp=n,i.lastOrigin=i.lastSelOrigin=t.origin,a||_e(e,"historyAdded")}function $n(e,t,r,n){var i=t.charAt(0);return"*"==i||"+"==i&&r.ranges.length==n.ranges.length&&r.somethingSelected()==n.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function Yn(e,t,r,n){var i=e.history,o=n&&n.origin;r==i.lastSelOp||o&&i.lastSelOrigin==o&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==o||$n(e,o,p(i.done),t))?i.done[i.done.length-1]=t:Xn(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=r,n&&n.clearRedo!==!1&&Un(i.undone)}function Xn(e,t){var r=p(t);r&&r.ranges&&r.equals(e)||t.push(e)}function Zn(e,t,r,n){var i=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,r),Math.min(e.first+e.size,n),function(r){r.markedSpans&&((i||(i=t["spans_"+e.id]={}))[o]=r.markedSpans),++o})}function Jn(e){if(!e)return null;for(var t,r=0;r<e.length;++r)e[r].marker.explicitlyCleared?t||(t=e.slice(0,r)):t&&t.push(e[r]);return t?t.length?t:null:e}function Qn(e,t){var r=t["spans_"+e.id];if(!r)return null;for(var n=[],i=0;i<t.text.length;++i)n.push(Jn(r[i]));return n}function ei(e,t){var r=Qn(e,t),n=J(e,t);if(!r)return n;if(!n)return r;for(var i=0;i<r.length;++i){var o=r[i],a=n[i];if(o&&a)e:for(var l=0;l<a.length;++l){for(var s=a[l],c=0;c<o.length;++c)if(o[c].marker==s.marker)continue e;o.push(s)}else a&&(r[i]=a)}return r}function ti(e,t,r){for(var n=[],i=0;i<e.length;++i){var o=e[i];if(o.ranges)n.push(r?Qa.prototype.deepCopy.call(o):o);else{var a=o.changes,l=[];n.push({changes:l});for(var s=0;s<a.length;++s){var c=a[s],u=void 0;if(l.push({from:c.from,to:c.to,text:c.text}),t)for(var f in c)(u=f.match(/^spans_(\d+)$/))&&d(t,Number(u[1]))>-1&&(p(l)[f]=c[f],delete c[f])}}}return n}function ri(e,t,r,n){if(e.cm&&e.cm.display.shift||e.extend){var i=t.anchor;if(n){var o=D(r,i)<0;o!=D(n,i)<0?(i=r,r=n):o!=D(r,n)<0&&(r=n)}return new el(i,r)}return new el(n||r,r)}function ni(e,t,r,n){ci(e,new Qa([ri(e,e.sel.primary(),t,r)],0),n)}function ii(e,t,r){for(var n=[],i=0;i<e.sel.ranges.length;i++)n[i]=ri(e,e.sel.ranges[i],t[i],null);ci(e,On(n,e.sel.primIndex),r)}function oi(e,t,r,n){var i=e.sel.ranges.slice(0);i[t]=r,ci(e,On(i,e.sel.primIndex),n)}function ai(e,t,r,n){ci(e,Nn(t,r),n)}function li(e,t,r){var n={ranges:t.ranges,update:function(t){var r=this;this.ranges=[];for(var n=0;n<t.length;n++)r.ranges[n]=new el(R(e,t[n].anchor),R(e,t[n].head))},origin:r&&r.origin};return _e(e,"beforeSelectionChange",e,n),e.cm&&_e(e.cm,"beforeSelectionChange",e.cm,n),n.ranges!=t.ranges?On(n.ranges,n.ranges.length-1):t}function si(e,t,r){var n=e.history.done,i=p(n);i&&i.ranges?(n[n.length-1]=t,ui(e,t,r)):ci(e,t,r)}function ci(e,t,r){ui(e,t,r),Yn(e,e.sel,e.cm?e.cm.curOp.id:NaN,r)}function ui(e,t,r){(We(e,"beforeSelectionChange")||e.cm&&We(e.cm,"beforeSelectionChange"))&&(t=li(e,t,r)),di(e,hi(e,t,r&&r.bias||(D(t.primary().head,e.sel.primary().head)<0?-1:1),!0)),r&&r.scroll===!1||!e.cm||Jr(e.cm)}function di(e,t){t.equals(e.sel)||(e.sel=t,e.cm&&(e.cm.curOp.updateInput=e.cm.curOp.selectionChanged=!0,Ne(e.cm)),kt(e,"cursorActivity",e))}function fi(e){di(e,hi(e,e.sel,null,!1),ya)}function hi(e,t,r,n){for(var i,o=0;o<t.ranges.length;o++){var a=t.ranges[o],l=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[o],s=mi(e,a.anchor,l&&l.anchor,r,n),c=mi(e,a.head,l&&l.head,r,n);(i||s!=a.anchor||c!=a.head)&&(i||(i=t.ranges.slice(0,o)),i[o]=new el(s,c))}return i?On(i,t.primIndex):t}function pi(e,t,r,n,i){var o=L(e,t.line);if(o.markedSpans)for(var a=0;a<o.markedSpans.length;++a){var l=o.markedSpans[a],s=l.marker;if((null==l.from||(s.inclusiveLeft?l.from<=t.ch:l.from<t.ch))&&(null==l.to||(s.inclusiveRight?l.to>=t.ch:l.to>t.ch))){if(i&&(_e(s,"beforeCursorEnter"),s.explicitlyCleared)){if(o.markedSpans){--a;continue}break}if(!s.atomic)continue;if(r){var c=s.find(n<0?1:-1),u=void 0;if((n<0?s.inclusiveRight:s.inclusiveLeft)&&(c=gi(e,c,-n,c&&c.line==t.line?o:null)),c&&c.line==t.line&&(u=D(c,r))&&(n<0?u<0:u>0))return pi(e,c,t,n,i)}var d=s.find(n<0?-1:1);return(n<0?s.inclusiveLeft:s.inclusiveRight)&&(d=gi(e,d,n,d.line==t.line?o:null)),d?pi(e,d,t,n,i):null}}return t}function mi(e,t,r,n,i){var o=n||1,a=pi(e,t,r,o,i)||!i&&pi(e,t,r,o,!0)||pi(e,t,r,-o,i)||!i&&pi(e,t,r,-o,!0);return a?a:(e.cantEdit=!0,z(e.first,0))}function gi(e,t,r,n){return r<0&&0==t.ch?t.line>e.first?R(e,z(t.line-1)):null:r>0&&t.ch==(n||L(e,t.line)).text.length?t.line<e.first+e.size-1?z(t.line+1,0):null:new z(t.line,t.ch+r)}function vi(e){e.setSelection(z(e.firstLine(),0),z(e.lastLine()),ya)}function yi(e,t,r){var n={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){return n.canceled=!0}};return r&&(n.update=function(t,r,i,o){t&&(n.from=R(e,t)),r&&(n.to=R(e,r)),i&&(n.text=i),void 0!==o&&(n.origin=o)}),_e(e,"beforeChange",e,n),e.cm&&_e(e.cm,"beforeChange",e.cm,n),n.canceled?null:{from:n.from,to:n.to,text:n.text,origin:n.origin}}function bi(e,t,r){if(e.cm){if(!e.cm.curOp)return un(e.cm,bi)(e,t,r);if(e.cm.state.suppressEdits)return}if(!(We(e,"beforeChange")||e.cm&&We(e.cm,"beforeChange"))||(t=yi(e,t,!0))){var n=Sa&&!r&&ee(e,t.from,t.to);if(n)for(var i=n.length-1;i>=0;--i)wi(e,{from:n[i].from,to:n[i].to,text:i?[""]:t.text});else wi(e,t)}}function wi(e,t){if(1!=t.text.length||""!=t.text[0]||0!=D(t.from,t.to)){var r=zn(e,t);Gn(e,t,r,e.cm?e.cm.curOp.id:NaN),Ci(e,t,r,J(e,t));var n=[];Rn(e,function(e,r){r||d(n,e.history)!=-1||(Ai(e.history,t),n.push(e.history)),Ci(e,t,null,J(e,t))})}}function xi(e,t,r){if(!e.cm||!e.cm.state.suppressEdits||r){for(var n,i=e.history,o=e.sel,a="undo"==t?i.done:i.undone,l="undo"==